aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/hw')
-rw-r--r--xorg-server/hw/dmx/Makefile.am178
-rw-r--r--xorg-server/hw/dmx/dmxcb.c446
-rw-r--r--xorg-server/hw/dmx/dmxextension.c3240
-rw-r--r--xorg-server/hw/dmx/dmxgcops.c1210
-rw-r--r--xorg-server/hw/dmx/dmxwindow.c2034
-rw-r--r--xorg-server/hw/dmx/doc/Makefile.am68
-rw-r--r--xorg-server/hw/dmx/glxProxy/glxcmds.c7290
-rw-r--r--xorg-server/hw/dmx/glxProxy/glxsingle.c2032
-rw-r--r--xorg-server/hw/dmx/glxProxy/glxvendor.c1170
-rw-r--r--xorg-server/hw/dmx/glxProxy/render2swap.c572
-rw-r--r--xorg-server/hw/dmx/input/dmxevents.c1532
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyr.c2376
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyr.h414
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyrinit.c866
-rw-r--r--xorg-server/hw/kdrive/src/kdrive.c2386
-rw-r--r--xorg-server/hw/kdrive/src/kdrive.h1254
-rw-r--r--xorg-server/hw/kdrive/src/kinput.c4690
-rw-r--r--xorg-server/hw/xfree86/Makefile.am234
-rw-r--r--xorg-server/hw/xfree86/common/xf86Config.c5068
-rw-r--r--xorg-server/hw/xfree86/common/xf86Configure.c1510
-rw-r--r--xorg-server/hw/xfree86/common/xf86Events.c1502
-rw-r--r--xorg-server/hw/xfree86/common/xf86Helper.c3898
-rw-r--r--xorg-server/hw/xfree86/common/xf86Init.c3040
-rw-r--r--xorg-server/hw/xfree86/common/xf86Module.h424
-rw-r--r--xorg-server/hw/xfree86/common/xf86Option.c1832
-rw-r--r--xorg-server/hw/xfree86/common/xf86Priv.h308
-rw-r--r--xorg-server/hw/xfree86/common/xf86RandR.c970
-rw-r--r--xorg-server/hw/xfree86/common/xf86Xinput.c2802
-rw-r--r--xorg-server/hw/xfree86/common/xf86sbusBus.c1428
-rw-r--r--xorg-server/hw/xfree86/common/xf86xv.c4380
-rw-r--r--xorg-server/hw/xfree86/ddc/ddcProperty.c248
-rw-r--r--xorg-server/hw/xfree86/doc/Makefile.am36
-rw-r--r--xorg-server/hw/xfree86/dri/dri.c4992
-rw-r--r--xorg-server/hw/xfree86/dri/xf86dri.c1324
-rw-r--r--xorg-server/hw/xfree86/dri2/dri2.c2484
-rw-r--r--xorg-server/hw/xfree86/fbdevhw/fbdevhw.c1810
-rw-r--r--xorg-server/hw/xfree86/loader/Makefile.am42
-rw-r--r--xorg-server/hw/xfree86/loader/loadmod.c2506
-rw-r--r--xorg-server/hw/xfree86/man/xorg.conf.man4990
-rw-r--r--xorg-server/hw/xfree86/modes/xf86Crtc.h1944
-rw-r--r--xorg-server/hw/xfree86/modes/xf86Cursors.c1376
-rw-r--r--xorg-server/hw/xfree86/modes/xf86RandR12.c3646
-rw-r--r--xorg-server/hw/xfree86/modes/xf86Rotate.c1050
-rw-r--r--xorg-server/hw/xfree86/os-support/bsd/bsd_init.c1512
-rw-r--r--xorg-server/hw/xfree86/os-support/linux/lnx_init.c690
-rw-r--r--xorg-server/hw/xfree86/ramdac/xf86Cursor.c950
-rw-r--r--xorg-server/hw/xfree86/sdksyms.sh850
-rw-r--r--xorg-server/hw/xfree86/vbe/vbe.c2178
-rw-r--r--xorg-server/hw/xnest/Events.c434
-rw-r--r--xorg-server/hw/xnest/Init.c302
-rw-r--r--xorg-server/hw/xnest/Pixmap.c272
-rw-r--r--xorg-server/hw/xquartz/GL/capabilities.c1086
-rw-r--r--xorg-server/hw/xquartz/GL/indirect.c1230
-rw-r--r--xorg-server/hw/xquartz/GL/visualConfigs.c568
-rw-r--r--xorg-server/hw/xquartz/Makefile.am108
-rw-r--r--xorg-server/hw/xquartz/X11Application.h232
-rw-r--r--xorg-server/hw/xquartz/X11Application.m2842
-rw-r--r--xorg-server/hw/xquartz/applewm.c1472
-rw-r--r--xorg-server/hw/xquartz/applewmExt.h190
-rw-r--r--xorg-server/hw/xquartz/bundle/Info.plist.cpp98
-rw-r--r--xorg-server/hw/xquartz/bundle/Makefile.am202
-rw-r--r--xorg-server/hw/xquartz/bundle/Resources/French.lproj/locversion.plist28
-rw-r--r--xorg-server/hw/xquartz/bundle/Resources/French.lproj/main.nib/designable.nib7344
-rw-r--r--xorg-server/hw/xquartz/bundle/Resources/German.lproj/locversion.plist28
-rw-r--r--xorg-server/hw/xquartz/bundle/Resources/German.lproj/main.nib/designable.nib7230
-rw-r--r--xorg-server/hw/xquartz/bundle/Resources/Japanese.lproj/locversion.plist28
-rw-r--r--xorg-server/hw/xquartz/bundle/Resources/Japanese.lproj/main.nib/designable.nib7240
-rw-r--r--xorg-server/hw/xquartz/console_redirect.c836
-rw-r--r--xorg-server/hw/xquartz/darwin.c1572
-rw-r--r--xorg-server/hw/xquartz/darwin.h172
-rw-r--r--xorg-server/hw/xquartz/darwinEvents.c1204
-rw-r--r--xorg-server/hw/xquartz/darwinEvents.h182
-rw-r--r--xorg-server/hw/xquartz/darwinXinput.c302
-rw-r--r--xorg-server/hw/xquartz/mach-startup/Makefile.am168
-rw-r--r--xorg-server/hw/xquartz/mach-startup/bundle-main.c1508
-rw-r--r--xorg-server/hw/xquartz/mach-startup/launchd_fd.c182
-rw-r--r--xorg-server/hw/xquartz/mach-startup/stub.c636
-rw-r--r--xorg-server/hw/xquartz/man/Xquartz.man384
-rw-r--r--xorg-server/hw/xquartz/pbproxy/Makefile.am56
-rw-r--r--xorg-server/hw/xquartz/pbproxy/app-main.m228
-rw-r--r--xorg-server/hw/xquartz/pbproxy/main.m298
-rw-r--r--xorg-server/hw/xquartz/pbproxy/pbproxy.h186
-rw-r--r--xorg-server/hw/xquartz/pbproxy/x-input.m346
-rw-r--r--xorg-server/hw/xquartz/pbproxy/x-selection.h220
-rw-r--r--xorg-server/hw/xquartz/pbproxy/x-selection.m3174
-rw-r--r--xorg-server/hw/xquartz/quartz.c976
-rw-r--r--xorg-server/hw/xquartz/quartz.h294
-rw-r--r--xorg-server/hw/xquartz/quartzKeyboard.c1736
-rw-r--r--xorg-server/hw/xquartz/quartzKeyboard.h112
-rw-r--r--xorg-server/hw/xquartz/quartzRandR.c1170
-rw-r--r--xorg-server/hw/xquartz/quartzStartup.c238
-rw-r--r--xorg-server/hw/xquartz/sanitizedCocoa.h128
-rw-r--r--xorg-server/hw/xquartz/xpr/dri.c1768
-rw-r--r--xorg-server/hw/xquartz/xpr/xpr.h138
-rw-r--r--xorg-server/hw/xquartz/xpr/xprAppleWM.c324
-rw-r--r--xorg-server/hw/xquartz/xpr/xprEvent.c156
-rw-r--r--xorg-server/hw/xquartz/xpr/xprFrame.c1216
-rw-r--r--xorg-server/hw/xquartz/xpr/xprScreen.c970
-rw-r--r--xorg-server/hw/xwin/InitOutput.c2240
-rw-r--r--xorg-server/hw/xwin/XWin.rc232
-rw-r--r--xorg-server/hw/xwin/man/XWin.man806
-rw-r--r--xorg-server/hw/xwin/win.h2928
-rw-r--r--xorg-server/hw/xwin/winclipboardtextconv.c310
-rw-r--r--xorg-server/hw/xwin/winclipboardwndproc.c1132
-rw-r--r--xorg-server/hw/xwin/winclipboardxevents.c1686
-rw-r--r--xorg-server/hw/xwin/winkeybd.c1078
-rw-r--r--xorg-server/hw/xwin/winmonitors.c146
-rw-r--r--xorg-server/hw/xwin/winmouse.c760
-rw-r--r--xorg-server/hw/xwin/winmultiwindowicons.c1298
-rw-r--r--xorg-server/hw/xwin/winmultiwindowwindow.c2042
-rw-r--r--xorg-server/hw/xwin/winmultiwindowwm.c3510
-rw-r--r--xorg-server/hw/xwin/winpfbdd.c1350
-rw-r--r--xorg-server/hw/xwin/winprefs.c1680
-rw-r--r--xorg-server/hw/xwin/winprefs.h380
-rw-r--r--xorg-server/hw/xwin/winprefsyacc.y920
-rw-r--r--xorg-server/hw/xwin/winrandr.c442
-rw-r--r--xorg-server/hw/xwin/winscrinit.c1520
-rw-r--r--xorg-server/hw/xwin/winshaddd.c2652
-rw-r--r--xorg-server/hw/xwin/winshadddnl.c2720
-rw-r--r--xorg-server/hw/xwin/winshadgdi.c2476
-rw-r--r--xorg-server/hw/xwin/winvideo.c416
-rw-r--r--xorg-server/hw/xwin/winwin32rootless.c1766
122 files changed, 89043 insertions, 89043 deletions
diff --git a/xorg-server/hw/dmx/Makefile.am b/xorg-server/hw/dmx/Makefile.am
index 369edf802..fb727e656 100644
--- a/xorg-server/hw/dmx/Makefile.am
+++ b/xorg-server/hw/dmx/Makefile.am
@@ -1,89 +1,89 @@
-
-SUBDIRS = input config examples doc doxygen man
-bin_PROGRAMS = Xdmx
-
-if XINERAMA
-PANORAMIX_SRCS = $(top_srcdir)/Xext/panoramiX.c
-endif
-
-if GLX
-SUBDIRS += glxProxy
-GLX_LIBS = glxProxy/libglxproxy.a
-GLX_SRCS = $(PANORAMIX_SRCS) dmx_glxvisuals.c dmx_glxvisuals.h
-GLX_INCS = -I$(top_srcdir)/hw/xfree86/dixmods/extmod
-GLX_DEFS = @GL_CFLAGS@
-endif
-
-AM_CFLAGS = \
- -DHAVE_DMX_CONFIG_H \
- $(DIX_CFLAGS) \
- $(GLX_INCS) \
- $(GLX_DEFS) \
- $(DMX_CFLAGS) \
- @DMXMODULES_CFLAGS@
-
-Xdmx_SOURCES = dmx.c \
- dmxcb.c \
- dmxcb.h \
- dmxclient.h \
- dmxcmap.c \
- dmxcmap.h \
- dmx-config.h \
- dmxcursor.c \
- dmxcursor.h \
- dmxdpms.c \
- dmxdpms.h \
- dmxextension.c \
- dmxextension.h \
- dmxfont.c \
- dmxfont.h \
- dmxgc.c \
- dmxgc.h \
- dmxgcops.c \
- dmxgcops.h \
- dmx.h \
- dmxinit.c \
- dmxinit.h \
- dmxinput.c \
- dmxinput.h \
- dmxlog.c \
- dmxlog.h \
- dmxpict.c \
- dmxpict.h \
- dmxpixmap.c \
- dmxpixmap.h \
- dmxprop.c \
- dmxprop.h \
- dmxscrinit.c \
- dmxscrinit.h \
- dmxshadow.c \
- dmxshadow.h \
- dmxstat.c \
- dmxstat.h \
- dmxsync.c \
- dmxsync.h \
- dmxvisual.c \
- dmxvisual.h \
- dmxwindow.c \
- dmxwindow.h \
- $(top_srcdir)/mi/miinitext.c \
- $(top_srcdir)/fb/fbcmap_mi.c \
- $(GLX_SRCS)
-
-
-#if COMPOSITE
-#Xdmx_SOURCES += fakecw.c
-#endif
-
-XDMX_LIBS = \
- $(GLX_LIBS) \
- @XDMX_LIBS@ \
- input/libdmxinput.a \
- config/libdmxconfig.a
-
-Xdmx_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
-Xdmx_DEPENDENCIES= $(XDMX_LIBS)
-Xdmx_LDADD = $(XDMX_LIBS) $(XDMX_SYS_LIBS) $(XSERVER_SYS_LIBS)
-
-relink:
- $(AM_V_at)rm -f Xdmx$(EXEEXT) && $(MAKE) Xdmx$(EXEEXT)
+
+SUBDIRS = input config examples doc doxygen man
+bin_PROGRAMS = Xdmx
+
+if XINERAMA
+PANORAMIX_SRCS = $(top_srcdir)/Xext/panoramiX.c
+endif
+
+if GLX
+SUBDIRS += glxProxy
+GLX_LIBS = glxProxy/libglxproxy.a
+GLX_SRCS = $(PANORAMIX_SRCS) dmx_glxvisuals.c dmx_glxvisuals.h
+GLX_INCS = -I$(top_srcdir)/hw/xfree86/dixmods/extmod
+GLX_DEFS = @GL_CFLAGS@
+endif
+
+AM_CFLAGS = \
+ -DHAVE_DMX_CONFIG_H \
+ $(DIX_CFLAGS) \
+ $(GLX_INCS) \
+ $(GLX_DEFS) \
+ $(DMX_CFLAGS) \
+ @DMXMODULES_CFLAGS@
+
+Xdmx_SOURCES = dmx.c \
+ dmxcb.c \
+ dmxcb.h \
+ dmxclient.h \
+ dmxcmap.c \
+ dmxcmap.h \
+ dmx-config.h \
+ dmxcursor.c \
+ dmxcursor.h \
+ dmxdpms.c \
+ dmxdpms.h \
+ dmxextension.c \
+ dmxextension.h \
+ dmxfont.c \
+ dmxfont.h \
+ dmxgc.c \
+ dmxgc.h \
+ dmxgcops.c \
+ dmxgcops.h \
+ dmx.h \
+ dmxinit.c \
+ dmxinit.h \
+ dmxinput.c \
+ dmxinput.h \
+ dmxlog.c \
+ dmxlog.h \
+ dmxpict.c \
+ dmxpict.h \
+ dmxpixmap.c \
+ dmxpixmap.h \
+ dmxprop.c \
+ dmxprop.h \
+ dmxscrinit.c \
+ dmxscrinit.h \
+ dmxshadow.c \
+ dmxshadow.h \
+ dmxstat.c \
+ dmxstat.h \
+ dmxsync.c \
+ dmxsync.h \
+ dmxvisual.c \
+ dmxvisual.h \
+ dmxwindow.c \
+ dmxwindow.h \
+ $(top_srcdir)/mi/miinitext.c \
+ $(top_srcdir)/fb/fbcmap_mi.c \
+ $(GLX_SRCS)
+
+
+#if COMPOSITE
+#Xdmx_SOURCES += fakecw.c
+#endif
+
+XDMX_LIBS = \
+ $(GLX_LIBS) \
+ @XDMX_LIBS@ \
+ input/libdmxinput.a \
+ config/libdmxconfig.a
+
+Xdmx_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+Xdmx_DEPENDENCIES= $(XDMX_LIBS)
+Xdmx_LDADD = $(XDMX_LIBS) $(XDMX_SYS_LIBS) $(XSERVER_SYS_LIBS)
+
+relink:
+ $(AM_V_at)rm -f Xdmx$(EXEEXT) && $(MAKE) Xdmx$(EXEEXT)
diff --git a/xorg-server/hw/dmx/dmxcb.c b/xorg-server/hw/dmx/dmxcb.c
index bc3281f56..d0eb35117 100644
--- a/xorg-server/hw/dmx/dmxcb.c
+++ b/xorg-server/hw/dmx/dmxcb.c
@@ -1,223 +1,223 @@
-/*
- * 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:
- * Rickard E. (Rik) Faith <faith@redhat.com>
- *
- */
-
-/** \file
- * This code queries and modifies the connection block. */
-
-#ifdef HAVE_DMX_CONFIG_H
-#include <dmx-config.h>
-#endif
-
-#include "dmx.h"
-#include "dmxcb.h"
-#include "dmxinput.h"
-#include "dmxlog.h"
-
-extern int connBlockScreenStart;
-
-#ifdef PANORAMIX
-#include "panoramiXsrv.h"
-extern int PanoramiXPixWidth;
-extern int PanoramiXPixHeight;
-extern int PanoramiXNumScreens;
-#endif
-
- int dmxGlobalWidth, dmxGlobalHeight;
-
-/** We may want the wall dimensions to be different from the bounding
- * box dimensions that Xinerama computes, so save those and update them
- * here.
- */
-void dmxSetWidthHeight(int width, int height)
-{
- dmxGlobalWidth = width;
- dmxGlobalHeight = height;
-}
-
-/** Computes the global bounding box for DMX. This may be larger than
- * the one computed by Xinerama because of the DMX configuration
- * file. */
-void dmxComputeWidthHeight(DMXRecomputeFlag flag)
-{
- int i;
- DMXScreenInfo *dmxScreen;
- int w = 0;
- int h = 0;
-
- for (i = 0; i < dmxNumScreens; i++) {
- /* Don't use root* here because this is
- * the global bounding box. */
- dmxScreen = &dmxScreens[i];
- if (w < dmxScreen->scrnWidth + dmxScreen->rootXOrigin)
- w = dmxScreen->scrnWidth + dmxScreen->rootXOrigin;
- if (h < dmxScreen->scrnHeight + dmxScreen->rootYOrigin)
- h = dmxScreen->scrnHeight + dmxScreen->rootYOrigin;
- }
- if (!dmxGlobalWidth && !dmxGlobalHeight) {
- dmxLog(dmxInfo, "Using %dx%d as global bounding box\n", w, h);
- } else {
- switch (flag) {
- case DMX_NO_RECOMPUTE_BOUNDING_BOX:
- dmxLog(dmxInfo,
- "Using old bounding box (%dx%d) instead of new (%dx%d)\n",
- dmxGlobalWidth, dmxGlobalHeight, w, h);
- w = dmxGlobalWidth;
- h = dmxGlobalHeight;
- break;
- case DMX_RECOMPUTE_BOUNDING_BOX:
- dmxLog(dmxInfo,
- "Using %dx%d as global bounding box, instead of %dx%d\n",
- w, h, dmxGlobalWidth, dmxGlobalHeight);
- break;
- }
- }
-
- dmxGlobalWidth = w;
- dmxGlobalHeight = h;
-}
-
-/** A callback routine that hooks into Xinerama and provides a
- * convenient place to print summary log information during server
- * startup. This routine does not modify any values. */
-void dmxConnectionBlockCallback(void)
-{
- xWindowRoot *root = (xWindowRoot *)(ConnectionInfo+connBlockScreenStart);
- int offset = connBlockScreenStart + sizeof(xWindowRoot);
- int i;
- Bool *found = NULL;
-
- MAXSCREENSALLOC(found);
- if (!found)
- dmxLog(dmxFatal, "dmxConnectionBlockCallback: out of memory\n");
-
- dmxLog(dmxInfo, "===== Start of Summary =====\n");
-#ifdef PANORAMIX
- if (!noPanoramiXExtension) {
- if (dmxGlobalWidth && dmxGlobalHeight
- && (dmxGlobalWidth != PanoramiXPixWidth
- || dmxGlobalHeight != PanoramiXPixHeight)) {
- dmxLog(dmxInfo,
- "Changing Xinerama dimensions from %d %d to %d %d\n",
- PanoramiXPixWidth, PanoramiXPixHeight,
- dmxGlobalWidth, dmxGlobalHeight);
- PanoramiXPixWidth = root->pixWidth = dmxGlobalWidth;
- PanoramiXPixHeight = root->pixHeight = dmxGlobalHeight;
- } else {
- dmxGlobalWidth = PanoramiXPixWidth;
- dmxGlobalHeight = PanoramiXPixHeight;
- }
- dmxLog(dmxInfo, "%d screens configured with Xinerama (%d %d)\n",
- PanoramiXNumScreens, PanoramiXPixWidth, PanoramiXPixHeight);
- FOR_NSCREENS(i) found[i] = FALSE;
- } else {
-#endif
- /* This never happens because we're
- * either called from a Xinerama
- * callback or during reconfiguration
- * (which only works with Xinerama on).
- * In any case, be reasonable. */
- dmxLog(dmxInfo, "%d screens configured (%d %d)\n",
- screenInfo.numScreens, root->pixWidth, root->pixHeight);
-#ifdef PANORAMIX
- }
-#endif
-
- for (i = 0; i < root->nDepths; i++) {
- xDepth *depth = (xDepth *)(ConnectionInfo + offset);
- int voffset = offset + sizeof(xDepth);
- xVisualType *visual = (xVisualType *)(ConnectionInfo + voffset);
- int j;
-
- dmxLog(dmxInfo, "%d visuals at depth %d:\n",
- depth->nVisuals, depth->depth);
- for (j = 0; j < depth->nVisuals; j++, visual++) {
- XVisualInfo vi;
-
- vi.visual = NULL;
- vi.visualid = visual->visualID;
- vi.screen = 0;
- vi.depth = depth->depth;
- vi.class = visual->class;
- vi.red_mask = visual->redMask;
- vi.green_mask = visual->greenMask;
- vi.blue_mask = visual->blueMask;
- vi.colormap_size = visual->colormapEntries;
- vi.bits_per_rgb = visual->bitsPerRGB;
- dmxLogVisual(NULL, &vi, 0);
-
-#ifdef PANORAMIX
- if (!noPanoramiXExtension) {
- int k;
- FOR_NSCREENS(k) {
- DMXScreenInfo *dmxScreen = &dmxScreens[k];
-
- if (dmxScreen->beDisplay) {
- XVisualInfo *pvi =
- &dmxScreen->beVisuals[dmxScreen->beDefVisualIndex];
- if (pvi->depth == depth->depth &&
- pvi->class == visual->class)
- found[k] = TRUE;
- } else {
- /* Screen #k is detatched, so it always succeeds */
- found[k] = TRUE;
- }
- }
- }
-#endif
- }
- offset = voffset + depth->nVisuals * sizeof(xVisualType);
- }
-
- dmxInputLogDevices();
- dmxLog(dmxInfo, "===== End of Summary =====\n");
-
-#ifdef PANORAMIX
- if (!noPanoramiXExtension) {
- Bool fatal = FALSE;
- FOR_NSCREENS(i) {
- fatal |= !found[i];
- if (!found[i]) {
- dmxLog(dmxError,
- "The default visual for screen #%d does not match "
- "any of the\n", i);
- dmxLog(dmxError,
- "consolidated visuals from Xinerama (listed above)\n");
- }
- }
- if (fatal)
- dmxLog(dmxFatal,
- "dmxConnectionBlockCallback: invalid screen(s) found");
- }
-#endif
- MAXSCREENSFREE(found);
-}
+/*
+ * 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:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * This code queries and modifies the connection block. */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmx.h"
+#include "dmxcb.h"
+#include "dmxinput.h"
+#include "dmxlog.h"
+
+extern int connBlockScreenStart;
+
+#ifdef PANORAMIX
+#include "panoramiXsrv.h"
+extern int PanoramiXPixWidth;
+extern int PanoramiXPixHeight;
+extern int PanoramiXNumScreens;
+#endif
+
+ int dmxGlobalWidth, dmxGlobalHeight;
+
+/** We may want the wall dimensions to be different from the bounding
+ * box dimensions that Xinerama computes, so save those and update them
+ * here.
+ */
+void dmxSetWidthHeight(int width, int height)
+{
+ dmxGlobalWidth = width;
+ dmxGlobalHeight = height;
+}
+
+/** Computes the global bounding box for DMX. This may be larger than
+ * the one computed by Xinerama because of the DMX configuration
+ * file. */
+void dmxComputeWidthHeight(DMXRecomputeFlag flag)
+{
+ int i;
+ DMXScreenInfo *dmxScreen;
+ int w = 0;
+ int h = 0;
+
+ for (i = 0; i < dmxNumScreens; i++) {
+ /* Don't use root* here because this is
+ * the global bounding box. */
+ dmxScreen = &dmxScreens[i];
+ if (w < dmxScreen->scrnWidth + dmxScreen->rootXOrigin)
+ w = dmxScreen->scrnWidth + dmxScreen->rootXOrigin;
+ if (h < dmxScreen->scrnHeight + dmxScreen->rootYOrigin)
+ h = dmxScreen->scrnHeight + dmxScreen->rootYOrigin;
+ }
+ if (!dmxGlobalWidth && !dmxGlobalHeight) {
+ dmxLog(dmxInfo, "Using %dx%d as global bounding box\n", w, h);
+ } else {
+ switch (flag) {
+ case DMX_NO_RECOMPUTE_BOUNDING_BOX:
+ dmxLog(dmxInfo,
+ "Using old bounding box (%dx%d) instead of new (%dx%d)\n",
+ dmxGlobalWidth, dmxGlobalHeight, w, h);
+ w = dmxGlobalWidth;
+ h = dmxGlobalHeight;
+ break;
+ case DMX_RECOMPUTE_BOUNDING_BOX:
+ dmxLog(dmxInfo,
+ "Using %dx%d as global bounding box, instead of %dx%d\n",
+ w, h, dmxGlobalWidth, dmxGlobalHeight);
+ break;
+ }
+ }
+
+ dmxGlobalWidth = w;
+ dmxGlobalHeight = h;
+}
+
+/** A callback routine that hooks into Xinerama and provides a
+ * convenient place to print summary log information during server
+ * startup. This routine does not modify any values. */
+void dmxConnectionBlockCallback(void)
+{
+ xWindowRoot *root = (xWindowRoot *)(ConnectionInfo+connBlockScreenStart);
+ int offset = connBlockScreenStart + sizeof(xWindowRoot);
+ int i;
+ Bool *found = NULL;
+
+ MAXSCREENSALLOC(found);
+ if (!found)
+ dmxLog(dmxFatal, "dmxConnectionBlockCallback: out of memory\n");
+
+ dmxLog(dmxInfo, "===== Start of Summary =====\n");
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ if (dmxGlobalWidth && dmxGlobalHeight
+ && (dmxGlobalWidth != PanoramiXPixWidth
+ || dmxGlobalHeight != PanoramiXPixHeight)) {
+ dmxLog(dmxInfo,
+ "Changing Xinerama dimensions from %d %d to %d %d\n",
+ PanoramiXPixWidth, PanoramiXPixHeight,
+ dmxGlobalWidth, dmxGlobalHeight);
+ PanoramiXPixWidth = root->pixWidth = dmxGlobalWidth;
+ PanoramiXPixHeight = root->pixHeight = dmxGlobalHeight;
+ } else {
+ dmxGlobalWidth = PanoramiXPixWidth;
+ dmxGlobalHeight = PanoramiXPixHeight;
+ }
+ dmxLog(dmxInfo, "%d screens configured with Xinerama (%d %d)\n",
+ PanoramiXNumScreens, PanoramiXPixWidth, PanoramiXPixHeight);
+ FOR_NSCREENS(i) found[i] = FALSE;
+ } else {
+#endif
+ /* This never happens because we're
+ * either called from a Xinerama
+ * callback or during reconfiguration
+ * (which only works with Xinerama on).
+ * In any case, be reasonable. */
+ dmxLog(dmxInfo, "%d screens configured (%d %d)\n",
+ screenInfo.numScreens, root->pixWidth, root->pixHeight);
+#ifdef PANORAMIX
+ }
+#endif
+
+ for (i = 0; i < root->nDepths; i++) {
+ xDepth *depth = (xDepth *)(ConnectionInfo + offset);
+ int voffset = offset + sizeof(xDepth);
+ xVisualType *visual = (xVisualType *)(ConnectionInfo + voffset);
+ int j;
+
+ dmxLog(dmxInfo, "%d visuals at depth %d:\n",
+ depth->nVisuals, depth->depth);
+ for (j = 0; j < depth->nVisuals; j++, visual++) {
+ XVisualInfo vi;
+
+ vi.visual = NULL;
+ vi.visualid = visual->visualID;
+ vi.screen = 0;
+ vi.depth = depth->depth;
+ vi.class = visual->class;
+ vi.red_mask = visual->redMask;
+ vi.green_mask = visual->greenMask;
+ vi.blue_mask = visual->blueMask;
+ vi.colormap_size = visual->colormapEntries;
+ vi.bits_per_rgb = visual->bitsPerRGB;
+ dmxLogVisual(NULL, &vi, 0);
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ int k;
+ FOR_NSCREENS(k) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[k];
+
+ if (dmxScreen->beDisplay) {
+ XVisualInfo *pvi =
+ &dmxScreen->beVisuals[dmxScreen->beDefVisualIndex];
+ if (pvi->depth == depth->depth &&
+ pvi->class == visual->class)
+ found[k] = TRUE;
+ } else {
+ /* Screen #k is detatched, so it always succeeds */
+ found[k] = TRUE;
+ }
+ }
+ }
+#endif
+ }
+ offset = voffset + depth->nVisuals * sizeof(xVisualType);
+ }
+
+ dmxInputLogDevices();
+ dmxLog(dmxInfo, "===== End of Summary =====\n");
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ Bool fatal = FALSE;
+ FOR_NSCREENS(i) {
+ fatal |= !found[i];
+ if (!found[i]) {
+ dmxLog(dmxError,
+ "The default visual for screen #%d does not match "
+ "any of the\n", i);
+ dmxLog(dmxError,
+ "consolidated visuals from Xinerama (listed above)\n");
+ }
+ }
+ if (fatal)
+ dmxLog(dmxFatal,
+ "dmxConnectionBlockCallback: invalid screen(s) found");
+ }
+#endif
+ MAXSCREENSFREE(found);
+}
diff --git a/xorg-server/hw/dmx/dmxextension.c b/xorg-server/hw/dmx/dmxextension.c
index 00b95a96d..db5709ee6 100644
--- a/xorg-server/hw/dmx/dmxextension.c
+++ b/xorg-server/hw/dmx/dmxextension.c
@@ -1,1620 +1,1620 @@
-/*
- * Copyright 2003-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.
- */
-
-/*
- * Author:
- * Rickard E. (Rik) Faith <faith@redhat.com>
- * Kevin E. Martin <kem@redhat.com>
- *
- */
-
-/** \file
- * This file provides the only interface to the X server extension support
- * in programs/Xserver/Xext. Those programs should only include dmxext.h
- */
-
-#ifdef HAVE_DMX_CONFIG_H
-#include <dmx-config.h>
-#endif
-
-#include <stdlib.h>
-
-#include "dmx.h"
-#include "dmxinit.h"
-#include "dmxextension.h"
-#include "dmxwindow.h"
-#include "dmxcb.h"
-#include "dmxcursor.h"
-#include "dmxpixmap.h"
-#include "dmxgc.h"
-#include "dmxfont.h"
-#include "dmxcmap.h"
-#include "dmxpict.h"
-#include "dmxinput.h"
-#include "dmxsync.h"
-#include "dmxscrinit.h"
-#include "input/dmxinputinit.h"
-
-#include "windowstr.h"
-#include "inputstr.h" /* For DeviceIntRec */
-#include <X11/extensions/dmxproto.h> /* For DMX_BAD_* */
-#include "cursorstr.h"
-
-/* The default font is declared in dix/globals.c, but is not included in
- * _any_ header files. */
-extern FontPtr defaultFont;
-
-/** This routine provides information to the DMX protocol extension
- * about a particular screen. */
-Bool dmxGetScreenAttributes(int physical, DMXScreenAttributesPtr attr)
-{
- DMXScreenInfo *dmxScreen;
-
- if (physical < 0 || physical >= dmxNumScreens) return FALSE;
-
- dmxScreen = &dmxScreens[physical];
- attr->displayName = dmxScreen->name;
-#ifdef PANORAMIX
- attr->logicalScreen = noPanoramiXExtension ? dmxScreen->index : 0;
-#else
- attr->logicalScreen = dmxScreen->index;
-#endif
-
- attr->screenWindowWidth = dmxScreen->scrnWidth;
- attr->screenWindowHeight = dmxScreen->scrnHeight;
- attr->screenWindowXoffset = dmxScreen->scrnX;
- attr->screenWindowYoffset = dmxScreen->scrnY;
-
- attr->rootWindowWidth = dmxScreen->rootWidth;
- attr->rootWindowHeight = dmxScreen->rootHeight;
- attr->rootWindowXoffset = dmxScreen->rootX;
- attr->rootWindowYoffset = dmxScreen->rootY;
-
- attr->rootWindowXorigin = dmxScreen->rootXOrigin;
- attr->rootWindowYorigin = dmxScreen->rootYOrigin;
-
- return TRUE;
-}
-
-/** This routine provides information to the DMX protocol extension
- * about a particular window. */
-Bool dmxGetWindowAttributes(WindowPtr pWindow, DMXWindowAttributesPtr attr)
-{
- dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
-
- attr->screen = pWindow->drawable.pScreen->myNum;
- attr->window = pWinPriv->window;
-
- attr->pos.x = pWindow->drawable.x;
- attr->pos.y = pWindow->drawable.y;
- attr->pos.width = pWindow->drawable.width;
- attr->pos.height = pWindow->drawable.height;
-
- if (!pWinPriv->window || pWinPriv->offscreen) {
- attr->vis.x = 0;
- attr->vis.y = 0;
- attr->vis.height = 0;
- attr->vis.width = 0;
- return pWinPriv->window ? TRUE : FALSE;
- }
-
- /* Compute display-relative coordinates */
- attr->vis.x = pWindow->drawable.x;
- attr->vis.y = pWindow->drawable.y;
- attr->vis.width = pWindow->drawable.width;
- attr->vis.height = pWindow->drawable.height;
-
- if (attr->pos.x < 0) {
- attr->vis.x -= attr->pos.x;
- attr->vis.width = attr->pos.x + attr->pos.width - attr->vis.x;
- }
- if (attr->pos.x + attr->pos.width > pWindow->drawable.pScreen->width) {
- if (attr->pos.x < 0)
- attr->vis.width = pWindow->drawable.pScreen->width;
- else
- attr->vis.width = pWindow->drawable.pScreen->width - attr->pos.x;
- }
- if (attr->pos.y < 0) {
- attr->vis.y -= attr->pos.y;
- attr->vis.height = attr->pos.y + attr->pos.height - attr->vis.y;
- }
- if (attr->pos.y + attr->pos.height > pWindow->drawable.pScreen->height) {
- if (attr->pos.y < 0)
- attr->vis.height = pWindow->drawable.pScreen->height;
- else
- attr->vis.height = pWindow->drawable.pScreen->height - attr->pos.y;
- }
-
- /* Convert to window-relative coordinates */
- attr->vis.x -= attr->pos.x;
- attr->vis.y -= attr->pos.y;
-
- return TRUE;
-}
-
-void dmxGetDesktopAttributes(DMXDesktopAttributesPtr attr)
-{
- attr->width = dmxGlobalWidth;
- attr->height = dmxGlobalHeight;
- attr->shiftX = 0; /* NOTE: The upper left hand corner of */
- attr->shiftY = 0; /* the desktop is always <0,0>. */
-}
-
-/** Return the total number of devices, not just #dmxNumInputs. The
- * number returned should be the same as that returned by
- * XListInputDevices. */
-int dmxGetInputCount(void)
-{
- int i, total;
-
- for (total = i = 0; i < dmxNumInputs; i++) total += dmxInputs[i].numDevs;
- return total;
-}
-
-/** Return information about the device with id = \a deviceId. This
- * information is primarily for the #ProcDMXGetInputAttributes()
- * function, which does not have access to the appropriate data
- * structure. */
-int dmxGetInputAttributes(int deviceId, DMXInputAttributesPtr attr)
-{
- int i, j;
- DMXInputInfo *dmxInput;
-
- if (deviceId < 0) return -1;
- for (i = 0; i < dmxNumInputs; i++) {
- dmxInput = &dmxInputs[i];
- for (j = 0; j < dmxInput->numDevs; j++) {
- DMXLocalInputInfoPtr dmxLocal = dmxInput->devs[j];
- if (deviceId != dmxLocal->pDevice->id) continue;
- attr->isCore = !!dmxLocal->isCore;
- attr->sendsCore = !!dmxLocal->sendsCore;
- attr->detached = !!dmxInput->detached;
- attr->physicalScreen = -1;
- attr->physicalId = -1;
- attr->name = NULL;
- switch (dmxLocal->extType) {
- case DMX_LOCAL_TYPE_LOCAL:
- attr->inputType = 0;
- break;
- case DMX_LOCAL_TYPE_CONSOLE:
- attr->inputType = 1;
- attr->name = dmxInput->name;
- attr->physicalId = dmxLocal->deviceId;
- break;
- case DMX_LOCAL_TYPE_BACKEND:
- case DMX_LOCAL_TYPE_COMMON:
- attr->inputType = 2;
- attr->physicalScreen = dmxInput->scrnIdx;
- attr->name = dmxInput->name;
- attr->physicalId = dmxLocal->deviceId;
- break;
- }
- return 0; /* Success */
- }
- }
- return -1; /* Failure */
-}
-
-/** Reinitialized the cursor boundaries. */
-static void dmxAdjustCursorBoundaries(void)
-{
- int i;
-
- dmxReInitOrigins();
- dmxInitOverlap();
- dmxComputeWidthHeight(DMX_NO_RECOMPUTE_BOUNDING_BOX);
- dmxConnectionBlockCallback();
- for (i = 0; i < dmxNumInputs; i++) {
- DMXInputInfo *dmxInput = &dmxInputs[i];
- if (!dmxInput->detached) dmxInputReInit(dmxInput);
- }
-
- dmxCheckCursor();
-
- for (i = 0; i < dmxNumInputs; i++) {
- DMXInputInfo *dmxInput = &dmxInputs[i];
- if (!dmxInput->detached) dmxInputLateReInit(dmxInput);
- }
-}
-
-/** Add an input with the specified attributes. If the input is added,
- * the physical id is returned in \a deviceId. */
-int dmxAddInput(DMXInputAttributesPtr attr, int *id)
-{
- int retcode = BadValue;
-
- if (attr->inputType == 1) /* console */
- retcode = dmxInputAttachConsole(attr->name, attr->sendsCore, id);
- else if (attr->inputType == 2) /* backend */
- retcode = dmxInputAttachBackend(attr->physicalScreen,
- attr->sendsCore,id);
-
- if (retcode == Success) {
- /* Adjust the cursor boundaries */
- dmxAdjustCursorBoundaries();
-
- /* Force completion of the changes */
- dmxSync(NULL, TRUE);
- }
-
- return retcode;
-}
-
-/** Remove the input with physical id \a id. */
-int dmxRemoveInput(int id)
-{
- return dmxInputDetachId(id);
-}
-
-/** Return the value of #dmxNumScreens -- the total number of backend
- * screens in use (these are logical screens and may be larger than the
- * number of backend displays). */
-unsigned long dmxGetNumScreens(void)
-{
- return dmxNumScreens;
-}
-
-/** Make sure that #dmxCreateAndRealizeWindow has been called for \a
- * pWindow. */
-void dmxForceWindowCreation(WindowPtr pWindow)
-{
- dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
- if (!pWinPriv->window) dmxCreateAndRealizeWindow(pWindow, TRUE);
-}
-
-/** Flush pending syncs for all screens. */
-void dmxFlushPendingSyncs(void)
-{
- dmxSync(NULL, TRUE);
-}
-
-/** Update DMX's screen resources to match those of the newly moved
- * and/or resized "root" window. */
-void dmxUpdateScreenResources(ScreenPtr pScreen, int x, int y, int w, int h)
-{
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
- WindowPtr pRoot = pScreen->root;
- WindowPtr pChild;
- Bool anyMarked = FALSE;
-
- /* Handle special case where width and/or height are zero */
- if (w == 0 || h == 0) {
- w = 1;
- h = 1;
- }
-
- /* Change screen size */
- pScreen->width = w;
- pScreen->height = h;
-
- /* Reset the root window's drawable's size */
- pRoot->drawable.width = w;
- pRoot->drawable.height = h;
-
- /* Set the root window's new winSize and borderSize */
- pRoot->winSize.extents.x1 = 0;
- pRoot->winSize.extents.y1 = 0;
- pRoot->winSize.extents.x2 = w;
- pRoot->winSize.extents.y2 = h;
-
- pRoot->borderSize.extents.x1 = 0;
- pRoot->borderSize.extents.y1 = 0;
- pRoot->borderSize.extents.x2 = w;
- pRoot->borderSize.extents.y2 = h;
-
- /* Recompute this screen's mmWidth & mmHeight */
- pScreen->mmWidth =
- (w * 254 + dmxScreen->beXDPI * 5) / (dmxScreen->beXDPI * 10);
- pScreen->mmHeight =
- (h * 254 + dmxScreen->beYDPI * 5) / (dmxScreen->beYDPI * 10);
-
- /* Recompute this screen's window's clip rects as follows: */
- /* 1. Mark all of root's children's windows */
- for (pChild = pRoot->firstChild; pChild; pChild = pChild->nextSib)
- anyMarked |= pScreen->MarkOverlappedWindows(pChild, pChild,
- (WindowPtr *)NULL);
-
- /* 2. Set the root window's borderClip */
- pRoot->borderClip.extents.x1 = 0;
- pRoot->borderClip.extents.y1 = 0;
- pRoot->borderClip.extents.x2 = w;
- pRoot->borderClip.extents.y2 = h;
-
- /* 3. Set the root window's clipList */
- if (anyMarked) {
- /* If any windows have been marked, set the root window's
- * clipList to be broken since it will be recalculated in
- * ValidateTree()
- */
- RegionBreak(&pRoot->clipList);
- } else {
- /* Otherwise, we just set it directly since there are no
- * windows visible on this screen
- */
- pRoot->clipList.extents.x1 = 0;
- pRoot->clipList.extents.y1 = 0;
- pRoot->clipList.extents.x2 = w;
- pRoot->clipList.extents.y2 = h;
- }
-
- /* 4. Revalidate all clip rects and generate expose events */
- if (anyMarked) {
- pScreen->ValidateTree(pRoot, NULL, VTBroken);
- pScreen->HandleExposures(pRoot);
- if (pScreen->PostValidateTree)
- pScreen->PostValidateTree(pRoot, NULL, VTBroken);
- }
-}
-
-#ifdef PANORAMIX
-#include "panoramiXsrv.h"
-
-/** Change the "screen" window attributes by resizing the actual window
- * on the back-end display (if necessary). */
-static void dmxConfigureScreenWindow(int idx,
- int x, int y, int w, int h)
-{
- DMXScreenInfo *dmxScreen = &dmxScreens[idx];
- ScreenPtr pScreen = screenInfo.screens[idx];
-
- /* Resize "screen" window */
- if (dmxScreen->scrnX != x ||
- dmxScreen->scrnY != y ||
- dmxScreen->scrnWidth != w ||
- dmxScreen->scrnHeight != h) {
- dmxResizeScreenWindow(pScreen, x, y, w, h);
- }
-
- /* Change "screen" window values */
- dmxScreen->scrnX = x;
- dmxScreen->scrnY = y;
- dmxScreen->scrnWidth = w;
- dmxScreen->scrnHeight = h;
-}
-
-/** Change the "root" window position and size by resizing the actual
- * window on the back-end display (if necessary) and updating all of
- * DMX's resources by calling #dmxUpdateScreenResources. */
-static void dmxConfigureRootWindow(int idx, int x, int y, int w, int h)
-{
- DMXScreenInfo *dmxScreen = &dmxScreens[idx];
- WindowPtr pRoot = screenInfo.screens[idx]->root;
-
- /* NOTE: Either this function or the ones that it calls must handle
- * the case where w == 0 || h == 0. Currently, the functions that
- * this one calls handle that case. */
-
- /* 1. Resize "root" window */
- if (dmxScreen->rootX != x ||
- dmxScreen->rootY != y ||
- dmxScreen->rootWidth != w ||
- dmxScreen->rootHeight != h) {
- dmxResizeRootWindow(pRoot, x, y, w, h);
- }
-
- /* 2. Update all of the screen's resources associated with this root
- * window */
- if (dmxScreen->rootWidth != w ||
- dmxScreen->rootHeight != h) {
- dmxUpdateScreenResources(screenInfo.screens[idx], x, y, w, h);
- }
-
- /* Change "root" window values */
- dmxScreen->rootX = x;
- dmxScreen->rootY = y;
- dmxScreen->rootWidth = w;
- dmxScreen->rootHeight = h;
-}
-
-/** Change the "root" window's origin by updating DMX's internal data
- * structures (dix and Xinerama) to use the new origin and adjust the
- * positions of windows that overlap this "root" window. */
-static void dmxSetRootWindowOrigin(int idx, int x, int y)
-{
- DMXScreenInfo *dmxScreen = &dmxScreens[idx];
- ScreenPtr pScreen = screenInfo.screens[idx];
- WindowPtr pRoot = pScreen->root;
- WindowPtr pChild;
- int xoff;
- int yoff;
-
- /* Change "root" window's origin */
- dmxScreen->rootXOrigin = x;
- dmxScreen->rootYOrigin = y;
-
- /* Compute offsets here in case <x,y> has been changed above */
- xoff = x - pScreen->x;
- yoff = y - pScreen->y;
-
- /* Adjust the root window's position */
- pScreen->x = dmxScreen->rootXOrigin;
- pScreen->y = dmxScreen->rootYOrigin;
-
- /* Recalculate the Xinerama regions and data structs */
- XineramaReinitData(pScreen);
-
- /* Adjust each of the root window's children */
- if (!idx) ReinitializeRootWindow(screenInfo.screens[0]->root, xoff, yoff);
- pChild = pRoot->firstChild;
- while (pChild) {
- /* Adjust child window's position */
- pScreen->MoveWindow(pChild,
- pChild->origin.x - wBorderWidth(pChild) - xoff,
- pChild->origin.y - wBorderWidth(pChild) - yoff,
- pChild->nextSib,
- VTMove);
-
- /* Note that the call to MoveWindow will eventually call
- * dmxPositionWindow which will automatically create a
- * window if it is now exposed on screen (for lazy window
- * creation optimization) and it will properly set the
- * offscreen flag.
- */
-
- pChild = pChild->nextSib;
- }
-}
-
-/** Configure the attributes of each "screen" and "root" window. */
-int dmxConfigureScreenWindows(int nscreens,
- CARD32 *screens,
- DMXScreenAttributesPtr attribs,
- int *errorScreen)
-{
- int i;
-
- for (i = 0; i < nscreens; i++) {
- DMXScreenAttributesPtr attr = &attribs[i];
- int idx = screens[i];
- DMXScreenInfo *dmxScreen = &dmxScreens[idx];
-
- if (errorScreen) *errorScreen = i;
-
- if (!dmxScreen->beDisplay) return DMX_BAD_VALUE;
-
- /* Check for illegal values */
- if (idx < 0 || idx >= dmxNumScreens) return BadValue;
-
- /* The "screen" and "root" windows must have valid sizes */
- if (attr->screenWindowWidth <= 0 || attr->screenWindowHeight <= 0 ||
- attr->rootWindowWidth < 0 || attr->rootWindowHeight < 0)
- return DMX_BAD_VALUE;
-
- /* The "screen" window must fit entirely within the BE display */
- if (attr->screenWindowXoffset < 0 ||
- attr->screenWindowYoffset < 0 ||
- attr->screenWindowXoffset
- + attr->screenWindowWidth > (unsigned)dmxScreen->beWidth ||
- attr->screenWindowYoffset
- + attr->screenWindowHeight > (unsigned)dmxScreen->beHeight)
- return DMX_BAD_VALUE;
-
- /* The "root" window must fit entirely within the "screen" window */
- if (attr->rootWindowXoffset < 0 ||
- attr->rootWindowYoffset < 0 ||
- attr->rootWindowXoffset
- + attr->rootWindowWidth > attr->screenWindowWidth ||
- attr->rootWindowYoffset
- + attr->rootWindowHeight > attr->screenWindowHeight)
- return DMX_BAD_VALUE;
-
- /* The "root" window must not expose unaddressable coordinates */
- if (attr->rootWindowXorigin < 0 ||
- attr->rootWindowYorigin < 0 ||
- attr->rootWindowXorigin + attr->rootWindowWidth > 32767 ||
- attr->rootWindowYorigin + attr->rootWindowHeight > 32767)
- return DMX_BAD_VALUE;
-
- /* The "root" window must fit within the global bounding box */
- if (attr->rootWindowXorigin
- + attr->rootWindowWidth > (unsigned)dmxGlobalWidth ||
- attr->rootWindowYorigin
- + attr->rootWindowHeight > (unsigned)dmxGlobalHeight)
- return DMX_BAD_VALUE;
-
- /* FIXME: Handle the rest of the illegal value checking */
- }
-
- /* No illegal values found */
- if (errorScreen) *errorScreen = 0;
-
- for (i = 0; i < nscreens; i++) {
- DMXScreenAttributesPtr attr = &attribs[i];
- int idx = screens[i];
- DMXScreenInfo *dmxScreen = &dmxScreens[idx];
-
- dmxLog(dmxInfo, "Changing screen #%d attributes "
- "from %dx%d+%d+%d %dx%d+%d+%d +%d+%d "
- "to %dx%d+%d+%d %dx%d+%d+%d +%d+%d\n",
- idx,
- dmxScreen->scrnWidth, dmxScreen->scrnHeight,
- dmxScreen->scrnX, dmxScreen->scrnY,
- dmxScreen->rootWidth, dmxScreen->rootHeight,
- dmxScreen->rootX, dmxScreen->rootY,
- dmxScreen->rootXOrigin, dmxScreen->rootYOrigin,
- attr->screenWindowWidth, attr->screenWindowHeight,
- attr->screenWindowXoffset, attr->screenWindowYoffset,
- attr->rootWindowWidth, attr->rootWindowHeight,
- attr->rootWindowXoffset, attr->rootWindowYoffset,
- attr->rootWindowXorigin, attr->rootWindowYorigin);
-
- /* Configure "screen" window */
- dmxConfigureScreenWindow(idx,
- attr->screenWindowXoffset,
- attr->screenWindowYoffset,
- attr->screenWindowWidth,
- attr->screenWindowHeight);
-
- /* Configure "root" window */
- dmxConfigureRootWindow(idx,
- attr->rootWindowXoffset,
- attr->rootWindowYoffset,
- attr->rootWindowWidth,
- attr->rootWindowHeight);
-
-
- /* Set "root" window's origin */
- dmxSetRootWindowOrigin(idx,
- attr->rootWindowXorigin,
- attr->rootWindowYorigin);
- }
-
- /* Adjust the cursor boundaries */
- dmxAdjustCursorBoundaries();
-
- /* Force completion of the changes */
- dmxSync(NULL, TRUE);
-
- return Success;
-}
-
-/** Configure the attributes of the global desktop. */
-int dmxConfigureDesktop(DMXDesktopAttributesPtr attribs)
-{
- if (attribs->width <= 0 || attribs->width >= 32767 ||
- attribs->height <= 0 || attribs->height >= 32767)
- return DMX_BAD_VALUE;
-
- /* If the desktop is shrinking, adjust the "root" windows on each
- * "screen" window to only show the visible desktop. Also, handle
- * the special case where the desktop shrinks such that the it no
- * longer overlaps an portion of a "screen" window. */
- if (attribs->width < dmxGlobalWidth || attribs->height < dmxGlobalHeight) {
- int i;
- for (i = 0; i < dmxNumScreens; i++) {
- DMXScreenInfo *dmxScreen = &dmxScreens[i];
- if (dmxScreen->rootXOrigin
- + dmxScreen->rootWidth > attribs->width ||
- dmxScreen->rootYOrigin
- + dmxScreen->rootHeight > attribs->height) {
- int w, h;
- if ((w = attribs->width - dmxScreen->rootXOrigin) < 0) w = 0;
- if ((h = attribs->height - dmxScreen->rootYOrigin) < 0) h = 0;
- if (w > dmxScreen->scrnWidth) w = dmxScreen->scrnWidth;
- if (h > dmxScreen->scrnHeight) h = dmxScreen->scrnHeight;
- if (w > dmxScreen->rootWidth) w = dmxScreen->rootWidth;
- if (h > dmxScreen->rootHeight) h = dmxScreen->rootHeight;
- dmxConfigureRootWindow(i,
- dmxScreen->rootX,
- dmxScreen->rootY,
- w, h);
- }
- }
- }
-
- /* Set the global width/height */
- dmxSetWidthHeight(attribs->width, attribs->height);
-
- /* Handle shift[XY] changes */
- if (attribs->shiftX || attribs->shiftY) {
- int i;
- for (i = 0; i < dmxNumScreens; i++) {
- ScreenPtr pScreen = screenInfo.screens[i];
- WindowPtr pChild = pScreen->root->firstChild;
- while (pChild) {
- /* Adjust child window's position */
- pScreen->MoveWindow(pChild,
- pChild->origin.x - wBorderWidth(pChild)
- - attribs->shiftX,
- pChild->origin.y - wBorderWidth(pChild)
- - attribs->shiftY,
- pChild->nextSib,
- VTMove);
-
- /* Note that the call to MoveWindow will eventually call
- * dmxPositionWindow which will automatically create a
- * window if it is now exposed on screen (for lazy
- * window creation optimization) and it will properly
- * set the offscreen flag.
- */
-
- pChild = pChild->nextSib;
- }
- }
- }
-
- /* Update connection block, Xinerama, etc. -- these appears to
- * already be handled in dmxConnectionBlockCallback(), which is
- * called from dmxAdjustCursorBoundaries() [below]. */
-
- /* Adjust the cursor boundaries */
- dmxAdjustCursorBoundaries();
-
- /* Force completion of the changes */
- dmxSync(NULL, TRUE);
-
- return Success;
-}
-#endif
-
-/** Create the scratch GCs per depth. */
-static void dmxBECreateScratchGCs(int scrnNum)
-{
- ScreenPtr pScreen = screenInfo.screens[scrnNum];
- GCPtr *ppGC = pScreen->GCperDepth;
- int i;
-
- for (i = 0; i <= pScreen->numDepths; i++)
- dmxBECreateGC(pScreen, ppGC[i]);
-}
-
-#ifdef PANORAMIX
-static Bool FoundPixImage;
-
-/** Search the Xinerama XRT_PIXMAP resources for the pixmap that needs
- * to have its image restored. When it is found, see if there is
- * another screen with the same image. If so, copy the pixmap image
- * from the existing screen to the newly created pixmap. */
-static void dmxBERestorePixmapImage(pointer value, XID id, RESTYPE type,
- pointer p)
-{
- if ((type & TypeMask) == (XRT_PIXMAP & TypeMask)) {
- PixmapPtr pDst = (PixmapPtr)p;
- int idx = pDst->drawable.pScreen->myNum;
- PanoramiXRes *pXinPix = (PanoramiXRes *)value;
- PixmapPtr pPix;
- int i;
-
- dixLookupResourceByType((pointer*) &pPix, pXinPix->info[idx].id,
- RT_PIXMAP, NullClient, DixUnknownAccess);
- if (pPix != pDst) return; /* Not a match.... Next! */
-
- FOR_NSCREENS(i) {
- PixmapPtr pSrc;
- dmxPixPrivPtr pSrcPriv = NULL;
-
- if (i == idx) continue; /* Self replication is bad */
-
- dixLookupResourceByType((pointer*) &pSrc, pXinPix->info[i].id,
- RT_PIXMAP, NullClient, DixUnknownAccess);
- pSrcPriv = DMX_GET_PIXMAP_PRIV(pSrc);
- if (pSrcPriv->pixmap) {
- DMXScreenInfo *dmxSrcScreen = &dmxScreens[i];
- DMXScreenInfo *dmxDstScreen = &dmxScreens[idx];
- dmxPixPrivPtr pDstPriv = DMX_GET_PIXMAP_PRIV(pDst);
- XImage *img;
- int j;
- XlibGC gc = NULL;
-
- /* This should never happen, but just in case.... */
- if (pSrc->drawable.width != pDst->drawable.width ||
- pSrc->drawable.height != pDst->drawable.height)
- return;
-
- /* Copy from src pixmap to dst pixmap */
- img = XGetImage(dmxSrcScreen->beDisplay,
- pSrcPriv->pixmap,
- 0, 0,
- pSrc->drawable.width, pSrc->drawable.height,
- -1,
- ZPixmap);
-
- for (j = 0; j < dmxDstScreen->beNumPixmapFormats; j++) {
- if (dmxDstScreen->bePixmapFormats[j].depth == img->depth) {
- unsigned long m;
- XGCValues v;
-
- m = GCFunction | GCPlaneMask | GCClipMask;
- v.function = GXcopy;
- v.plane_mask = AllPlanes;
- v.clip_mask = None;
-
- gc = XCreateGC(dmxDstScreen->beDisplay,
- dmxDstScreen->scrnDefDrawables[j],
- m, &v);
- break;
- }
- }
-
- if (gc) {
- XPutImage(dmxDstScreen->beDisplay,
- pDstPriv->pixmap,
- gc, img, 0, 0, 0, 0,
- pDst->drawable.width, pDst->drawable.height);
- XFreeGC(dmxDstScreen->beDisplay, gc);
- FoundPixImage = True;
- } else {
- dmxLog(dmxWarning, "Could not create GC\n");
- }
-
- XDestroyImage(img);
- return;
- }
- }
- }
-}
-#endif
-
-/** Restore the pixmap image either from another screen or from an image
- * that was saved when the screen was previously detached. */
-static void dmxBERestorePixmap(PixmapPtr pPixmap)
-{
-#ifdef PANORAMIX
- int i;
-
- /* If Xinerama is not active, there's nothing we can do (see comment
- * in #else below for more info). */
- if (noPanoramiXExtension) {
- dmxLog(dmxWarning, "Cannot restore pixmap image\n");
- return;
- }
-
- FoundPixImage = False;
- for (i = currentMaxClients; --i >= 0; )
- if (clients[i])
- FindAllClientResources(clients[i], dmxBERestorePixmapImage,
- (pointer)pPixmap);
-
- /* No corresponding pixmap image was found on other screens, so we
- * need to copy it from the saved image when the screen was detached
- * (if available). */
- if (!FoundPixImage) {
- dmxPixPrivPtr pPixPriv = DMX_GET_PIXMAP_PRIV(pPixmap);
-
- if (pPixPriv->detachedImage) {
- ScreenPtr pScreen = pPixmap->drawable.pScreen;
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
- XlibGC gc = NULL;
-
- for (i = 0; i < dmxScreen->beNumPixmapFormats; i++) {
- if (dmxScreen->bePixmapFormats[i].depth ==
- pPixPriv->detachedImage->depth) {
- unsigned long m;
- XGCValues v;
-
- m = GCFunction | GCPlaneMask | GCClipMask;
- v.function = GXcopy;
- v.plane_mask = AllPlanes;
- v.clip_mask = None;
-
- gc = XCreateGC(dmxScreen->beDisplay,
- dmxScreen->scrnDefDrawables[i],
- m, &v);
- break;
- }
- }
-
- if (gc) {
- XPutImage(dmxScreen->beDisplay,
- pPixPriv->pixmap,
- gc,
- pPixPriv->detachedImage,
- 0, 0, 0, 0,
- pPixmap->drawable.width, pPixmap->drawable.height);
- XFreeGC(dmxScreen->beDisplay, gc);
- } else {
- dmxLog(dmxWarning, "Cannot restore pixmap image\n");
- }
-
- XDestroyImage(pPixPriv->detachedImage);
- pPixPriv->detachedImage = NULL;
- } else {
- dmxLog(dmxWarning, "Cannot restore pixmap image\n");
- }
- }
-#else
- /* If Xinerama is not enabled, then there is no other copy of the
- * pixmap image that we can restore. Saving all pixmap data is not
- * a feasible option since there is no mechanism for updating pixmap
- * data when a screen is detached, which means that the data that
- * was previously saved would most likely be out of date. */
- dmxLog(dmxWarning, "Cannot restore pixmap image\n");
- return;
-#endif
-}
-
-/** Create resources on the back-end server. This function is called
- * from #dmxAttachScreen() via the dix layer's FindAllResources
- * function. It walks all resources, compares them to the screen
- * number passed in as \a n and calls the appropriate DMX function to
- * create the associated resource on the back-end server. */
-static void dmxBECreateResources(pointer value, XID id, RESTYPE type,
- pointer n)
-{
- int scrnNum = (uintptr_t)n;
- ScreenPtr pScreen = screenInfo.screens[scrnNum];
-
- if ((type & TypeMask) == (RT_WINDOW & TypeMask)) {
- /* Window resources are created below in dmxBECreateWindowTree */
- } else if ((type & TypeMask) == (RT_PIXMAP & TypeMask)) {
- PixmapPtr pPix = value;
- if (pPix->drawable.pScreen->myNum == scrnNum) {
- dmxBECreatePixmap(pPix);
- dmxBERestorePixmap(pPix);
- }
- } else if ((type & TypeMask) == (RT_GC & TypeMask)) {
- GCPtr pGC = value;
- if (pGC->pScreen->myNum == scrnNum) {
- /* Create the GC on the back-end server */
- dmxBECreateGC(pScreen, pGC);
- /* Create any pixmaps associated with this GC */
- if (!pGC->tileIsPixel) {
- dmxBECreatePixmap(pGC->tile.pixmap);
- dmxBERestorePixmap(pGC->tile.pixmap);
- }
- if (pGC->stipple != pScreen->PixmapPerDepth[0]) {
- dmxBECreatePixmap(pGC->stipple);
- dmxBERestorePixmap(pGC->stipple);
- }
- if (pGC->font != defaultFont) {
- (void)dmxBELoadFont(pScreen, pGC->font);
- }
- /* Update the GC on the back-end server */
- dmxChangeGC(pGC, -1L);
- }
- } else if ((type & TypeMask) == (RT_FONT & TypeMask)) {
- (void)dmxBELoadFont(pScreen, (FontPtr)value);
- } else if ((type & TypeMask) == (RT_CURSOR & TypeMask)) {
- dmxBECreateCursor(pScreen, (CursorPtr)value);
- } else if ((type & TypeMask) == (RT_COLORMAP & TypeMask)) {
- ColormapPtr pCmap = value;
- if (pCmap->pScreen->myNum == scrnNum)
- (void)dmxBECreateColormap((ColormapPtr)value);
-#if 0
- /* TODO: Recreate Picture and GlyphSet resources */
- } else if ((type & TypeMask) == (PictureType & TypeMask)) {
- /* Picture resources are created when windows are created */
- } else if ((type & TypeMask) == (GlyphSetType & TypeMask)) {
- dmxBEFreeGlyphSet(pScreen, (GlyphSetPtr)value);
-#endif
- } else {
- /* Other resource types??? */
- }
-}
-
-/** Create window hierachy on back-end server. The window tree is
- * created in a special order (bottom most subwindow first) so that the
- * #dmxCreateNonRootWindow() function does not need to recursively call
- * itself to create each window's parents. This is required so that we
- * have the opportunity to create each window's border and background
- * pixmaps (where appropriate) before the window is created. */
-static void dmxBECreateWindowTree(int idx)
-{
- DMXScreenInfo *dmxScreen = &dmxScreens[idx];
- WindowPtr pRoot = screenInfo.screens[idx]->root;
- dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pRoot);
- WindowPtr pWin;
-
- /* Create the pixmaps associated with the root window */
- if (!pRoot->borderIsPixel) {
- dmxBECreatePixmap(pRoot->border.pixmap);
- dmxBERestorePixmap(pRoot->border.pixmap);
- }
- if (pRoot->backgroundState == BackgroundPixmap) {
- dmxBECreatePixmap(pRoot->background.pixmap);
- dmxBERestorePixmap(pRoot->background.pixmap);
- }
-
- /* Create root window first */
- dmxScreen->rootWin = pWinPriv->window = dmxCreateRootWindow(pRoot);
- XMapWindow(dmxScreen->beDisplay, dmxScreen->rootWin);
-
- pWin = pRoot->lastChild;
- while (pWin) {
- pWinPriv = DMX_GET_WINDOW_PRIV(pWin);
-
- /* Create the pixmaps regardless of whether or not the
- * window is created or not due to lazy window creation.
- */
- if (!pWin->borderIsPixel) {
- dmxBECreatePixmap(pWin->border.pixmap);
- dmxBERestorePixmap(pWin->border.pixmap);
- }
- if (pWin->backgroundState == BackgroundPixmap) {
- dmxBECreatePixmap(pWin->background.pixmap);
- dmxBERestorePixmap(pWin->background.pixmap);
- }
-
- /* Reset the window attributes */
- dmxGetDefaultWindowAttributes(pWin,
- &pWinPriv->cmap,
- &pWinPriv->visual);
-
- /* Create the window */
- if (pWinPriv->mapped && !pWinPriv->offscreen)
- dmxCreateAndRealizeWindow(pWin, TRUE);
-
- /* Next, create the bottom-most child */
- if (pWin->lastChild) {
- pWin = pWin->lastChild;
- continue;
- }
-
- /* If the window has no children, move on to the next higher window */
- while (!pWin->prevSib && (pWin != pRoot))
- pWin = pWin->parent;
-
- if (pWin->prevSib) {
- pWin = pWin->prevSib;
- continue;
- }
-
- /* When we reach the root window, we are finished */
- if (pWin == pRoot)
- break;
- }
-}
-
-/* Refresh screen by generating exposure events for all windows */
-static void dmxForceExposures(int idx)
-{
- ScreenPtr pScreen = screenInfo.screens[idx];
- WindowPtr pRoot = pScreen->root;
- Bool anyMarked = FALSE;
- WindowPtr pChild;
-
- for (pChild = pRoot->firstChild; pChild; pChild = pChild->nextSib)
- anyMarked |= pScreen->MarkOverlappedWindows(pChild, pChild,
- (WindowPtr *)NULL);
- if (anyMarked) {
- /* If any windows have been marked, set the root window's
- * clipList to be broken since it will be recalculated in
- * ValidateTree()
- */
- RegionBreak(&pRoot->clipList);
- pScreen->ValidateTree(pRoot, NULL, VTBroken);
- pScreen->HandleExposures(pRoot);
- if (pScreen->PostValidateTree)
- pScreen->PostValidateTree(pRoot, NULL, VTBroken);
- }
-}
-
-/** Compare the new and old screens to see if they are compatible. */
-static Bool dmxCompareScreens(DMXScreenInfo *new, DMXScreenInfo *old)
-{
- int i;
-
- if (new->beWidth != old->beWidth) return FALSE;
- if (new->beHeight != old->beHeight) return FALSE;
- if (new->beDepth != old->beDepth) return FALSE;
- if (new->beBPP != old->beBPP) return FALSE;
-
- if (new->beNumDepths != old->beNumDepths) return FALSE;
- for (i = 0; i < old->beNumDepths; i++)
- if (new->beDepths[i] != old->beDepths[i]) return FALSE;
-
- if (new->beNumPixmapFormats != old->beNumPixmapFormats) return FALSE;
- for (i = 0; i < old->beNumPixmapFormats; i++) {
- if (new->bePixmapFormats[i].depth !=
- old->bePixmapFormats[i].depth) return FALSE;
- if (new->bePixmapFormats[i].bits_per_pixel !=
- old->bePixmapFormats[i].bits_per_pixel) return FALSE;
- if (new->bePixmapFormats[i].scanline_pad !=
- old->bePixmapFormats[i].scanline_pad) return FALSE;
- }
-
- if (new->beNumVisuals != old->beNumVisuals) return FALSE;
- for (i = 0; i < old->beNumVisuals; i++) {
- if (new->beVisuals[i].visualid !=
- old->beVisuals[i].visualid) return FALSE;
- if (new->beVisuals[i].screen !=
- old->beVisuals[i].screen) return FALSE;
- if (new->beVisuals[i].depth !=
- old->beVisuals[i].depth) return FALSE;
- if (new->beVisuals[i].class !=
- old->beVisuals[i].class) return FALSE;
- if (new->beVisuals[i].red_mask !=
- old->beVisuals[i].red_mask) return FALSE;
- if (new->beVisuals[i].green_mask !=
- old->beVisuals[i].green_mask) return FALSE;
- if (new->beVisuals[i].blue_mask !=
- old->beVisuals[i].blue_mask) return FALSE;
- if (new->beVisuals[i].colormap_size !=
- old->beVisuals[i].colormap_size) return FALSE;
- if (new->beVisuals[i].bits_per_rgb !=
- old->beVisuals[i].bits_per_rgb) return FALSE;
- }
-
- if (new->beDefVisualIndex != old->beDefVisualIndex) return FALSE;
-
- return TRUE;
-}
-
-/** Restore Render's picture */
-static void dmxBERestoreRenderPict(pointer value, XID id, pointer n)
-{
- PicturePtr pPicture = value; /* The picture */
- DrawablePtr pDraw = pPicture->pDrawable; /* The picture's drawable */
- int scrnNum = (uintptr_t)n;
-
- if (pDraw->pScreen->myNum != scrnNum) {
- /* Picture not on the screen we are restoring*/
- return;
- }
-
- if (pDraw->type == DRAWABLE_PIXMAP) {
- PixmapPtr pPixmap = (PixmapPtr)pDraw;
-
- /* Create and restore the pixmap drawable */
- dmxBECreatePixmap(pPixmap);
- dmxBERestorePixmap(pPixmap);
- }
-
- dmxBECreatePicture(pPicture);
-}
-
-/** Restore Render's glyphs */
-static void dmxBERestoreRenderGlyph(pointer value, XID id, pointer n)
-{
- GlyphSetPtr glyphSet = value;
- int scrnNum = (uintptr_t)n;
- dmxGlyphPrivPtr glyphPriv = DMX_GET_GLYPH_PRIV(glyphSet);
- DMXScreenInfo *dmxScreen = &dmxScreens[scrnNum];
- GlyphRefPtr table;
- char *images;
- Glyph *gids;
- XGlyphInfo *glyphs;
- char *pos;
- int beret;
- int len_images = 0;
- int i;
- int ctr;
-
- if (glyphPriv->glyphSets[scrnNum]) {
- /* Only restore glyphs on the screen we are attaching */
- return;
- }
-
- /* First we must create the glyph set on the backend. */
- if ((beret = dmxBECreateGlyphSet(scrnNum, glyphSet)) != Success) {
- dmxLog(dmxWarning,
- "\tdmxBERestoreRenderGlyph failed to create glyphset!\n");
- return;
- }
-
- /* Now for the complex part, restore the glyph data */
- table = glyphSet->hash.table;
-
- /* We need to know how much memory to allocate for this part */
- for (i = 0; i < glyphSet->hash.hashSet->size; i++) {
- GlyphRefPtr gr = &table[i];
- GlyphPtr gl = gr->glyph;
-
- if (!gl || gl == DeletedGlyph) continue;
- len_images += gl->size - sizeof(gl->info);
- }
-
- /* Now allocate the memory we need */
- images = calloc(len_images, sizeof(char));
- gids = malloc(glyphSet->hash.tableEntries*sizeof(Glyph));
- glyphs = malloc(glyphSet->hash.tableEntries*sizeof(XGlyphInfo));
-
- pos = images;
- ctr = 0;
-
- /* Fill the allocated memory with the proper data */
- for (i = 0; i < glyphSet->hash.hashSet->size; i++) {
- GlyphRefPtr gr = &table[i];
- GlyphPtr gl = gr->glyph;
-
- if (!gl || gl == DeletedGlyph) continue;
-
- /* First lets put the data into gids */
- gids[ctr] = gr->signature;
-
- /* Next do the glyphs data structures */
- glyphs[ctr].width = gl->info.width;
- glyphs[ctr].height = gl->info.height;
- glyphs[ctr].x = gl->info.x;
- glyphs[ctr].y = gl->info.y;
- glyphs[ctr].xOff = gl->info.xOff;
- glyphs[ctr].yOff = gl->info.yOff;
-
- /* Copy the images from the DIX's data into the buffer */
- memcpy(pos, gl+1, gl->size - sizeof(gl->info));
- pos += gl->size - sizeof(gl->info);
- ctr++;
- }
-
- /* Now restore the glyph data */
- XRenderAddGlyphs(dmxScreen->beDisplay, glyphPriv->glyphSets[scrnNum],
- gids,glyphs, glyphSet->hash.tableEntries, images,
- len_images);
-
- /* Clean up */
- free(images);
- free(gids);
- free(glyphs);
-}
-
-/** Reattach previously detached back-end screen. */
-int dmxAttachScreen(int idx, DMXScreenAttributesPtr attr)
-{
- ScreenPtr pScreen;
- DMXScreenInfo *dmxScreen;
- CARD32 scrnNum = idx;
- DMXScreenInfo oldDMXScreen;
- int i;
-
- /* Return failure if dynamic addition/removal of screens is disabled */
- if (!dmxAddRemoveScreens) {
- dmxLog(dmxWarning,
- "Attempting to add a screen, but the AddRemoveScreen\n");
- dmxLog(dmxWarning,
- "extension has not been enabled. To enable this extension\n");
- dmxLog(dmxWarning,
- "add the \"-addremovescreens\" option either to the command\n");
- dmxLog(dmxWarning,
- "line or in the configuration file.\n");
- return 1;
- }
-
- /* Cannot add a screen that does not exist */
- if (idx < 0 || idx >= dmxNumScreens) return 1;
- pScreen = screenInfo.screens[idx];
- dmxScreen = &dmxScreens[idx];
-
- /* Cannot attach to a screen that is already opened */
- if (dmxScreen->beDisplay) {
- dmxLog(dmxWarning,
- "Attempting to add screen #%d but a screen already exists\n",
- idx);
- return 1;
- }
-
- dmxLogOutput(dmxScreen, "Attaching screen #%d\n", idx);
-
- /* Save old info */
- oldDMXScreen = *dmxScreen;
-
- /* Copy the name to the new screen */
- dmxScreen->name = strdup(attr->displayName);
-
- /* Open display and get all of the screen info */
- if (!dmxOpenDisplay(dmxScreen)) {
- dmxLog(dmxWarning,
- "dmxOpenDisplay: Unable to open display %s\n",
- dmxScreen->name);
-
- /* Restore the old screen */
- *dmxScreen = oldDMXScreen;
- return 1;
- }
-
- dmxSetErrorHandler(dmxScreen);
- dmxCheckForWM(dmxScreen);
- dmxGetScreenAttribs(dmxScreen);
-
- if (!dmxGetVisualInfo(dmxScreen)) {
- dmxLog(dmxWarning, "dmxGetVisualInfo: No matching visuals found\n");
- XFree(dmxScreen->beVisuals);
- XCloseDisplay(dmxScreen->beDisplay);
-
- /* Restore the old screen */
- *dmxScreen = oldDMXScreen;
- return 1;
- }
-
- dmxGetColormaps(dmxScreen);
- dmxGetPixmapFormats(dmxScreen);
-
- /* Verify that the screen to be added has the same info as the
- * previously added screen. */
- if (!dmxCompareScreens(dmxScreen, &oldDMXScreen)) {
- dmxLog(dmxWarning,
- "New screen data (%s) does not match previously\n",
- dmxScreen->name);
- dmxLog(dmxWarning,
- "attached screen data (%s)\n",
- oldDMXScreen.name);
- dmxLog(dmxWarning,
- "All data must match in order to attach to screen #%d\n",
- idx);
- XFree(dmxScreen->beVisuals);
- XFree(dmxScreen->beDepths);
- XFree(dmxScreen->bePixmapFormats);
- XCloseDisplay(dmxScreen->beDisplay);
-
- /* Restore the old screen */
- *dmxScreen = oldDMXScreen;
- return 1;
- }
-
- /* Initialize the BE screen resources */
- dmxBEScreenInit(idx, screenInfo.screens[idx]);
-
- /* TODO: Handle GLX visual initialization. GLXProxy needs to be
- * updated to handle dynamic addition/removal of screens. */
-
- /* Create default stipple */
- dmxBECreatePixmap(pScreen->PixmapPerDepth[0]);
- dmxBERestorePixmap(pScreen->PixmapPerDepth[0]);
-
- /* Create the scratch GCs */
- dmxBECreateScratchGCs(idx);
-
- /* Create the default font */
- (void)dmxBELoadFont(pScreen, defaultFont);
-
- /* Create all resources that don't depend on windows */
- for (i = currentMaxClients; --i >= 0; )
- if (clients[i])
- FindAllClientResources(clients[i], dmxBECreateResources,
- (pointer)(uintptr_t)idx);
-
- /* Create window hierarchy (top down) */
- dmxBECreateWindowTree(idx);
-
- /* Restore the picture state for RENDER */
- for (i = currentMaxClients; --i >= 0; )
- if (clients[i])
- FindClientResourcesByType(clients[i],PictureType,
- dmxBERestoreRenderPict,
- (pointer)(uintptr_t)idx);
-
- /* Restore the glyph state for RENDER */
- for (i = currentMaxClients; --i >= 0; )
- if (clients[i])
- FindClientResourcesByType(clients[i],GlyphSetType,
- dmxBERestoreRenderGlyph,
- (pointer)(uintptr_t)idx);
-
- /* Refresh screen by generating exposure events for all windows */
- dmxForceExposures(idx);
-
- dmxSync(&dmxScreens[idx], TRUE);
-
- /* We used these to compare the old and new screens. They are no
- * longer needed since we have a newly attached screen, so we can
- * now free the old screen's resources. */
- XFree(oldDMXScreen.beVisuals);
- XFree(oldDMXScreen.beDepths);
- XFree(oldDMXScreen.bePixmapFormats);
- /* TODO: should oldDMXScreen.name be freed?? */
-
-#ifdef PANORAMIX
- if (!noPanoramiXExtension)
- return dmxConfigureScreenWindows(1, &scrnNum, attr, NULL);
- else
-#endif
- return 0; /* Success */
-}
-
-/*
- * Resources that may have state on the BE server and need to be freed:
- *
- * RT_NONE
- * RT_WINDOW
- * RT_PIXMAP
- * RT_GC
- * RT_FONT
- * RT_CURSOR
- * RT_COLORMAP
- * RT_CMAPENTRY
- * RT_OTHERCLIENT
- * RT_PASSIVEGRAB
- * XRT_WINDOW
- * XRT_PIXMAP
- * XRT_GC
- * XRT_COLORMAP
- * XRT_PICTURE
- * PictureType
- * PictFormatType
- * GlyphSetType
- * ClientType
- * EventType
- * RT_INPUTCLIENT
- * XETrapType
- * RTCounter
- * RTAwait
- * RTAlarmClient
- * RT_XKBCLIENT
- * RTContext
- * TagResType
- * StalledResType
- * SecurityAuthorizationResType
- * RTEventClient
- * __glXContextRes
- * __glXClientRes
- * __glXPixmapRes
- * __glXWindowRes
- * __glXPbufferRes
- */
-
-#ifdef PANORAMIX
-/** Search the Xinerama XRT_PIXMAP resources for the pixmap that needs
- * to have its image saved. */
-static void dmxBEFindPixmapImage(pointer value, XID id, RESTYPE type,
- pointer p)
-{
- if ((type & TypeMask) == (XRT_PIXMAP & TypeMask)) {
- PixmapPtr pDst = (PixmapPtr)p;
- int idx = pDst->drawable.pScreen->myNum;
- PanoramiXRes *pXinPix = (PanoramiXRes *)value;
- PixmapPtr pPix;
- int i;
-
- dixLookupResourceByType((pointer*) &pPix, pXinPix->info[idx].id,
- RT_PIXMAP, NullClient, DixUnknownAccess);
- if (pPix != pDst) return; /* Not a match.... Next! */
-
- FOR_NSCREENS(i) {
- PixmapPtr pSrc;
- dmxPixPrivPtr pSrcPriv = NULL;
-
- if (i == idx) continue; /* Self replication is bad */
-
- dixLookupResourceByType((pointer*) &pSrc, pXinPix->info[i].id,
- RT_PIXMAP, NullClient, DixUnknownAccess);
- pSrcPriv = DMX_GET_PIXMAP_PRIV(pSrc);
- if (pSrcPriv->pixmap) {
- FoundPixImage = True;
- return;
- }
- }
- }
-}
-#endif
-
-/** Save the pixmap image only when there is not another screen with
- * that pixmap from which the image can be read when the screen is
- * reattached. To do this, we first try to find a pixmap on another
- * screen corresponding to the one we are trying to save. If we find
- * one, then we do not need to save the image data since during
- * reattachment, the image data can be read from that other pixmap.
- * However, if we do not find one, then we need to save the image data.
- * The common case for these are for the default stipple and root
- * tile. */
-static void dmxBESavePixmap(PixmapPtr pPixmap)
-{
-#ifdef PANORAMIX
- int i;
-
- /* If Xinerama is not active, there's nothing we can do (see comment
- * in #else below for more info). */
- if (noPanoramiXExtension) return;
-
- FoundPixImage = False;
- for (i = currentMaxClients; --i >= 0; )
- if (clients[i])
- FindAllClientResources(clients[i], dmxBEFindPixmapImage,
- (pointer)pPixmap);
-
- /* Save the image only if there is no other screens that have a
- * pixmap that corresponds to the one we are trying to save. */
- if (!FoundPixImage) {
- dmxPixPrivPtr pPixPriv = DMX_GET_PIXMAP_PRIV(pPixmap);
-
- if (!pPixPriv->detachedImage) {
- ScreenPtr pScreen = pPixmap->drawable.pScreen;
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
-
- pPixPriv->detachedImage = XGetImage(dmxScreen->beDisplay,
- pPixPriv->pixmap,
- 0, 0,
- pPixmap->drawable.width,
- pPixmap->drawable.height,
- -1,
- ZPixmap);
- if (!pPixPriv->detachedImage)
- dmxLog(dmxWarning, "Cannot save pixmap image\n");
- }
- }
-#else
- /* NOTE: The only time there is a pixmap on another screen that
- * corresponds to the one we are trying to save is when Xinerama is
- * active. Otherwise, the pixmap image data is only stored on a
- * single screen, which means that once it is detached, that data is
- * lost. We could save the data here, but then that would require
- * us to implement the ability for Xdmx to keep the pixmap up to
- * date while the screen is detached, which is beyond the scope of
- * the current project. */
- return;
-#endif
-}
-
-/** Destroy resources on the back-end server. This function is called
- * from #dmxDetachScreen() via the dix layer's FindAllResources
- * function. It walks all resources, compares them to the screen
- * number passed in as \a n and calls the appropriate DMX function to
- * free the associated resource on the back-end server. */
-static void dmxBEDestroyResources(pointer value, XID id, RESTYPE type,
- pointer n)
-{
- int scrnNum = (uintptr_t)n;
- ScreenPtr pScreen = screenInfo.screens[scrnNum];
-
- if ((type & TypeMask) == (RT_WINDOW & TypeMask)) {
- /* Window resources are destroyed below in dmxBEDestroyWindowTree */
- } else if ((type & TypeMask) == (RT_PIXMAP & TypeMask)) {
- PixmapPtr pPix = value;
- if (pPix->drawable.pScreen->myNum == scrnNum) {
- dmxBESavePixmap(pPix);
- dmxBEFreePixmap(pPix);
- }
- } else if ((type & TypeMask) == (RT_GC & TypeMask)) {
- GCPtr pGC = value;
- if (pGC->pScreen->myNum == scrnNum)
- dmxBEFreeGC(pGC);
- } else if ((type & TypeMask) == (RT_FONT & TypeMask)) {
- dmxBEFreeFont(pScreen, (FontPtr)value);
- } else if ((type & TypeMask) == (RT_CURSOR & TypeMask)) {
- dmxBEFreeCursor(pScreen, (CursorPtr)value);
- } else if ((type & TypeMask) == (RT_COLORMAP & TypeMask)) {
- ColormapPtr pCmap = value;
- if (pCmap->pScreen->myNum == scrnNum)
- dmxBEFreeColormap((ColormapPtr)value);
- } else if ((type & TypeMask) == (PictureType & TypeMask)) {
- PicturePtr pPict = value;
- if (pPict->pDrawable->pScreen->myNum == scrnNum) {
- /* Free the pixmaps on the backend if needed */
- if (pPict->pDrawable->type == DRAWABLE_PIXMAP) {
- PixmapPtr pPixmap = (PixmapPtr)(pPict->pDrawable);
- dmxBESavePixmap(pPixmap);
- dmxBEFreePixmap(pPixmap);
- }
- dmxBEFreePicture((PicturePtr)value);
- }
- } else if ((type & TypeMask) == (GlyphSetType & TypeMask)) {
- dmxBEFreeGlyphSet(pScreen, (GlyphSetPtr)value);
- } else {
- /* Other resource types??? */
- }
-}
-
-/** Destroy the scratch GCs that are created per depth. */
-static void dmxBEDestroyScratchGCs(int scrnNum)
-{
- ScreenPtr pScreen = screenInfo.screens[scrnNum];
- GCPtr *ppGC = pScreen->GCperDepth;
- int i;
-
- for (i = 0; i <= pScreen->numDepths; i++)
- dmxBEFreeGC(ppGC[i]);
-}
-
-/** Destroy window hierachy on back-end server. To ensure that all
- * XDestroyWindow() calls succeed, they must be performed in a bottom
- * up order so that windows are not destroyed before their children.
- * XDestroyWindow(), which is called from #dmxBEDestroyWindow(), will
- * destroy a window as well as all of it's children. */
-static void dmxBEDestroyWindowTree(int idx)
-{
- WindowPtr pWin = screenInfo.screens[idx]->root;
- WindowPtr pChild = pWin;
-
- while (1) {
- if (pChild->firstChild) {
- pChild = pChild->firstChild;
- continue;
- }
-
- /* Destroy the window */
- dmxBEDestroyWindow(pChild);
-
- /* Make sure we destroy the window's border and background
- * pixmaps if they exist */
- if (!pChild->borderIsPixel) {
- dmxBESavePixmap(pChild->border.pixmap);
- dmxBEFreePixmap(pChild->border.pixmap);
- }
- if (pChild->backgroundState == BackgroundPixmap) {
- dmxBESavePixmap(pChild->background.pixmap);
- dmxBEFreePixmap(pChild->background.pixmap);
- }
-
- while (!pChild->nextSib && (pChild != pWin)) {
- pChild = pChild->parent;
- dmxBEDestroyWindow(pChild);
- if (!pChild->borderIsPixel) {
- dmxBESavePixmap(pChild->border.pixmap);
- dmxBEFreePixmap(pChild->border.pixmap);
- }
- if (pChild->backgroundState == BackgroundPixmap) {
- dmxBESavePixmap(pChild->background.pixmap);
- dmxBEFreePixmap(pChild->background.pixmap);
- }
- }
-
- if (pChild == pWin)
- break;
-
- pChild = pChild->nextSib;
- }
-}
-
-/** Detach back-end screen. */
-int dmxDetachScreen(int idx)
-{
- DMXScreenInfo *dmxScreen = &dmxScreens[idx];
- int i;
-
- /* Return failure if dynamic addition/removal of screens is disabled */
- if (!dmxAddRemoveScreens) {
- dmxLog(dmxWarning,
- "Attempting to remove a screen, but the AddRemoveScreen\n");
- dmxLog(dmxWarning,
- "extension has not been enabled. To enable this extension\n");
- dmxLog(dmxWarning,
- "add the \"-addremovescreens\" option either to the command\n");
- dmxLog(dmxWarning,
- "line or in the configuration file.\n");
- return 1;
- }
-
- /* Cannot remove a screen that does not exist */
- if (idx < 0 || idx >= dmxNumScreens) return 1;
-
- /* Cannot detach from a screen that is not opened */
- if (!dmxScreen->beDisplay) {
- dmxLog(dmxWarning,
- "Attempting to remove screen #%d but it has not been opened\n",
- idx);
- return 1;
- }
-
- dmxLogOutput(dmxScreen, "Detaching screen #%d\n", idx);
-
- /* Detach input */
- dmxInputDetachAll(dmxScreen);
-
- /* Save all relevant state (TODO) */
-
- /* Free all non-window resources related to this screen */
- for (i = currentMaxClients; --i >= 0; )
- if (clients[i])
- FindAllClientResources(clients[i], dmxBEDestroyResources,
- (pointer)(uintptr_t)idx);
-
- /* Free scratch GCs */
- dmxBEDestroyScratchGCs(idx);
-
- /* Free window resources related to this screen */
- dmxBEDestroyWindowTree(idx);
-
- /* Free default stipple */
- dmxBESavePixmap(screenInfo.screens[idx]->PixmapPerDepth[0]);
- dmxBEFreePixmap(screenInfo.screens[idx]->PixmapPerDepth[0]);
-
- /* Free the remaining screen resources and close the screen */
- dmxBECloseScreen(screenInfo.screens[idx]);
-
- /* Adjust the cursor boundaries (paints detached console window) */
- dmxAdjustCursorBoundaries();
-
- return 0; /* Success */
-}
+/*
+ * Copyright 2003-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.
+ */
+
+/*
+ * Author:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ * Kevin E. Martin <kem@redhat.com>
+ *
+ */
+
+/** \file
+ * This file provides the only interface to the X server extension support
+ * in programs/Xserver/Xext. Those programs should only include dmxext.h
+ */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include <stdlib.h>
+
+#include "dmx.h"
+#include "dmxinit.h"
+#include "dmxextension.h"
+#include "dmxwindow.h"
+#include "dmxcb.h"
+#include "dmxcursor.h"
+#include "dmxpixmap.h"
+#include "dmxgc.h"
+#include "dmxfont.h"
+#include "dmxcmap.h"
+#include "dmxpict.h"
+#include "dmxinput.h"
+#include "dmxsync.h"
+#include "dmxscrinit.h"
+#include "input/dmxinputinit.h"
+
+#include "windowstr.h"
+#include "inputstr.h" /* For DeviceIntRec */
+#include <X11/extensions/dmxproto.h> /* For DMX_BAD_* */
+#include "cursorstr.h"
+
+/* The default font is declared in dix/globals.c, but is not included in
+ * _any_ header files. */
+extern FontPtr defaultFont;
+
+/** This routine provides information to the DMX protocol extension
+ * about a particular screen. */
+Bool dmxGetScreenAttributes(int physical, DMXScreenAttributesPtr attr)
+{
+ DMXScreenInfo *dmxScreen;
+
+ if (physical < 0 || physical >= dmxNumScreens) return FALSE;
+
+ dmxScreen = &dmxScreens[physical];
+ attr->displayName = dmxScreen->name;
+#ifdef PANORAMIX
+ attr->logicalScreen = noPanoramiXExtension ? dmxScreen->index : 0;
+#else
+ attr->logicalScreen = dmxScreen->index;
+#endif
+
+ attr->screenWindowWidth = dmxScreen->scrnWidth;
+ attr->screenWindowHeight = dmxScreen->scrnHeight;
+ attr->screenWindowXoffset = dmxScreen->scrnX;
+ attr->screenWindowYoffset = dmxScreen->scrnY;
+
+ attr->rootWindowWidth = dmxScreen->rootWidth;
+ attr->rootWindowHeight = dmxScreen->rootHeight;
+ attr->rootWindowXoffset = dmxScreen->rootX;
+ attr->rootWindowYoffset = dmxScreen->rootY;
+
+ attr->rootWindowXorigin = dmxScreen->rootXOrigin;
+ attr->rootWindowYorigin = dmxScreen->rootYOrigin;
+
+ return TRUE;
+}
+
+/** This routine provides information to the DMX protocol extension
+ * about a particular window. */
+Bool dmxGetWindowAttributes(WindowPtr pWindow, DMXWindowAttributesPtr attr)
+{
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+
+ attr->screen = pWindow->drawable.pScreen->myNum;
+ attr->window = pWinPriv->window;
+
+ attr->pos.x = pWindow->drawable.x;
+ attr->pos.y = pWindow->drawable.y;
+ attr->pos.width = pWindow->drawable.width;
+ attr->pos.height = pWindow->drawable.height;
+
+ if (!pWinPriv->window || pWinPriv->offscreen) {
+ attr->vis.x = 0;
+ attr->vis.y = 0;
+ attr->vis.height = 0;
+ attr->vis.width = 0;
+ return pWinPriv->window ? TRUE : FALSE;
+ }
+
+ /* Compute display-relative coordinates */
+ attr->vis.x = pWindow->drawable.x;
+ attr->vis.y = pWindow->drawable.y;
+ attr->vis.width = pWindow->drawable.width;
+ attr->vis.height = pWindow->drawable.height;
+
+ if (attr->pos.x < 0) {
+ attr->vis.x -= attr->pos.x;
+ attr->vis.width = attr->pos.x + attr->pos.width - attr->vis.x;
+ }
+ if (attr->pos.x + attr->pos.width > pWindow->drawable.pScreen->width) {
+ if (attr->pos.x < 0)
+ attr->vis.width = pWindow->drawable.pScreen->width;
+ else
+ attr->vis.width = pWindow->drawable.pScreen->width - attr->pos.x;
+ }
+ if (attr->pos.y < 0) {
+ attr->vis.y -= attr->pos.y;
+ attr->vis.height = attr->pos.y + attr->pos.height - attr->vis.y;
+ }
+ if (attr->pos.y + attr->pos.height > pWindow->drawable.pScreen->height) {
+ if (attr->pos.y < 0)
+ attr->vis.height = pWindow->drawable.pScreen->height;
+ else
+ attr->vis.height = pWindow->drawable.pScreen->height - attr->pos.y;
+ }
+
+ /* Convert to window-relative coordinates */
+ attr->vis.x -= attr->pos.x;
+ attr->vis.y -= attr->pos.y;
+
+ return TRUE;
+}
+
+void dmxGetDesktopAttributes(DMXDesktopAttributesPtr attr)
+{
+ attr->width = dmxGlobalWidth;
+ attr->height = dmxGlobalHeight;
+ attr->shiftX = 0; /* NOTE: The upper left hand corner of */
+ attr->shiftY = 0; /* the desktop is always <0,0>. */
+}
+
+/** Return the total number of devices, not just #dmxNumInputs. The
+ * number returned should be the same as that returned by
+ * XListInputDevices. */
+int dmxGetInputCount(void)
+{
+ int i, total;
+
+ for (total = i = 0; i < dmxNumInputs; i++) total += dmxInputs[i].numDevs;
+ return total;
+}
+
+/** Return information about the device with id = \a deviceId. This
+ * information is primarily for the #ProcDMXGetInputAttributes()
+ * function, which does not have access to the appropriate data
+ * structure. */
+int dmxGetInputAttributes(int deviceId, DMXInputAttributesPtr attr)
+{
+ int i, j;
+ DMXInputInfo *dmxInput;
+
+ if (deviceId < 0) return -1;
+ for (i = 0; i < dmxNumInputs; i++) {
+ dmxInput = &dmxInputs[i];
+ for (j = 0; j < dmxInput->numDevs; j++) {
+ DMXLocalInputInfoPtr dmxLocal = dmxInput->devs[j];
+ if (deviceId != dmxLocal->pDevice->id) continue;
+ attr->isCore = !!dmxLocal->isCore;
+ attr->sendsCore = !!dmxLocal->sendsCore;
+ attr->detached = !!dmxInput->detached;
+ attr->physicalScreen = -1;
+ attr->physicalId = -1;
+ attr->name = NULL;
+ switch (dmxLocal->extType) {
+ case DMX_LOCAL_TYPE_LOCAL:
+ attr->inputType = 0;
+ break;
+ case DMX_LOCAL_TYPE_CONSOLE:
+ attr->inputType = 1;
+ attr->name = dmxInput->name;
+ attr->physicalId = dmxLocal->deviceId;
+ break;
+ case DMX_LOCAL_TYPE_BACKEND:
+ case DMX_LOCAL_TYPE_COMMON:
+ attr->inputType = 2;
+ attr->physicalScreen = dmxInput->scrnIdx;
+ attr->name = dmxInput->name;
+ attr->physicalId = dmxLocal->deviceId;
+ break;
+ }
+ return 0; /* Success */
+ }
+ }
+ return -1; /* Failure */
+}
+
+/** Reinitialized the cursor boundaries. */
+static void dmxAdjustCursorBoundaries(void)
+{
+ int i;
+
+ dmxReInitOrigins();
+ dmxInitOverlap();
+ dmxComputeWidthHeight(DMX_NO_RECOMPUTE_BOUNDING_BOX);
+ dmxConnectionBlockCallback();
+ for (i = 0; i < dmxNumInputs; i++) {
+ DMXInputInfo *dmxInput = &dmxInputs[i];
+ if (!dmxInput->detached) dmxInputReInit(dmxInput);
+ }
+
+ dmxCheckCursor();
+
+ for (i = 0; i < dmxNumInputs; i++) {
+ DMXInputInfo *dmxInput = &dmxInputs[i];
+ if (!dmxInput->detached) dmxInputLateReInit(dmxInput);
+ }
+}
+
+/** Add an input with the specified attributes. If the input is added,
+ * the physical id is returned in \a deviceId. */
+int dmxAddInput(DMXInputAttributesPtr attr, int *id)
+{
+ int retcode = BadValue;
+
+ if (attr->inputType == 1) /* console */
+ retcode = dmxInputAttachConsole(attr->name, attr->sendsCore, id);
+ else if (attr->inputType == 2) /* backend */
+ retcode = dmxInputAttachBackend(attr->physicalScreen,
+ attr->sendsCore,id);
+
+ if (retcode == Success) {
+ /* Adjust the cursor boundaries */
+ dmxAdjustCursorBoundaries();
+
+ /* Force completion of the changes */
+ dmxSync(NULL, TRUE);
+ }
+
+ return retcode;
+}
+
+/** Remove the input with physical id \a id. */
+int dmxRemoveInput(int id)
+{
+ return dmxInputDetachId(id);
+}
+
+/** Return the value of #dmxNumScreens -- the total number of backend
+ * screens in use (these are logical screens and may be larger than the
+ * number of backend displays). */
+unsigned long dmxGetNumScreens(void)
+{
+ return dmxNumScreens;
+}
+
+/** Make sure that #dmxCreateAndRealizeWindow has been called for \a
+ * pWindow. */
+void dmxForceWindowCreation(WindowPtr pWindow)
+{
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+ if (!pWinPriv->window) dmxCreateAndRealizeWindow(pWindow, TRUE);
+}
+
+/** Flush pending syncs for all screens. */
+void dmxFlushPendingSyncs(void)
+{
+ dmxSync(NULL, TRUE);
+}
+
+/** Update DMX's screen resources to match those of the newly moved
+ * and/or resized "root" window. */
+void dmxUpdateScreenResources(ScreenPtr pScreen, int x, int y, int w, int h)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ WindowPtr pRoot = pScreen->root;
+ WindowPtr pChild;
+ Bool anyMarked = FALSE;
+
+ /* Handle special case where width and/or height are zero */
+ if (w == 0 || h == 0) {
+ w = 1;
+ h = 1;
+ }
+
+ /* Change screen size */
+ pScreen->width = w;
+ pScreen->height = h;
+
+ /* Reset the root window's drawable's size */
+ pRoot->drawable.width = w;
+ pRoot->drawable.height = h;
+
+ /* Set the root window's new winSize and borderSize */
+ pRoot->winSize.extents.x1 = 0;
+ pRoot->winSize.extents.y1 = 0;
+ pRoot->winSize.extents.x2 = w;
+ pRoot->winSize.extents.y2 = h;
+
+ pRoot->borderSize.extents.x1 = 0;
+ pRoot->borderSize.extents.y1 = 0;
+ pRoot->borderSize.extents.x2 = w;
+ pRoot->borderSize.extents.y2 = h;
+
+ /* Recompute this screen's mmWidth & mmHeight */
+ pScreen->mmWidth =
+ (w * 254 + dmxScreen->beXDPI * 5) / (dmxScreen->beXDPI * 10);
+ pScreen->mmHeight =
+ (h * 254 + dmxScreen->beYDPI * 5) / (dmxScreen->beYDPI * 10);
+
+ /* Recompute this screen's window's clip rects as follows: */
+ /* 1. Mark all of root's children's windows */
+ for (pChild = pRoot->firstChild; pChild; pChild = pChild->nextSib)
+ anyMarked |= pScreen->MarkOverlappedWindows(pChild, pChild,
+ (WindowPtr *)NULL);
+
+ /* 2. Set the root window's borderClip */
+ pRoot->borderClip.extents.x1 = 0;
+ pRoot->borderClip.extents.y1 = 0;
+ pRoot->borderClip.extents.x2 = w;
+ pRoot->borderClip.extents.y2 = h;
+
+ /* 3. Set the root window's clipList */
+ if (anyMarked) {
+ /* If any windows have been marked, set the root window's
+ * clipList to be broken since it will be recalculated in
+ * ValidateTree()
+ */
+ RegionBreak(&pRoot->clipList);
+ } else {
+ /* Otherwise, we just set it directly since there are no
+ * windows visible on this screen
+ */
+ pRoot->clipList.extents.x1 = 0;
+ pRoot->clipList.extents.y1 = 0;
+ pRoot->clipList.extents.x2 = w;
+ pRoot->clipList.extents.y2 = h;
+ }
+
+ /* 4. Revalidate all clip rects and generate expose events */
+ if (anyMarked) {
+ pScreen->ValidateTree(pRoot, NULL, VTBroken);
+ pScreen->HandleExposures(pRoot);
+ if (pScreen->PostValidateTree)
+ pScreen->PostValidateTree(pRoot, NULL, VTBroken);
+ }
+}
+
+#ifdef PANORAMIX
+#include "panoramiXsrv.h"
+
+/** Change the "screen" window attributes by resizing the actual window
+ * on the back-end display (if necessary). */
+static void dmxConfigureScreenWindow(int idx,
+ int x, int y, int w, int h)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[idx];
+ ScreenPtr pScreen = screenInfo.screens[idx];
+
+ /* Resize "screen" window */
+ if (dmxScreen->scrnX != x ||
+ dmxScreen->scrnY != y ||
+ dmxScreen->scrnWidth != w ||
+ dmxScreen->scrnHeight != h) {
+ dmxResizeScreenWindow(pScreen, x, y, w, h);
+ }
+
+ /* Change "screen" window values */
+ dmxScreen->scrnX = x;
+ dmxScreen->scrnY = y;
+ dmxScreen->scrnWidth = w;
+ dmxScreen->scrnHeight = h;
+}
+
+/** Change the "root" window position and size by resizing the actual
+ * window on the back-end display (if necessary) and updating all of
+ * DMX's resources by calling #dmxUpdateScreenResources. */
+static void dmxConfigureRootWindow(int idx, int x, int y, int w, int h)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[idx];
+ WindowPtr pRoot = screenInfo.screens[idx]->root;
+
+ /* NOTE: Either this function or the ones that it calls must handle
+ * the case where w == 0 || h == 0. Currently, the functions that
+ * this one calls handle that case. */
+
+ /* 1. Resize "root" window */
+ if (dmxScreen->rootX != x ||
+ dmxScreen->rootY != y ||
+ dmxScreen->rootWidth != w ||
+ dmxScreen->rootHeight != h) {
+ dmxResizeRootWindow(pRoot, x, y, w, h);
+ }
+
+ /* 2. Update all of the screen's resources associated with this root
+ * window */
+ if (dmxScreen->rootWidth != w ||
+ dmxScreen->rootHeight != h) {
+ dmxUpdateScreenResources(screenInfo.screens[idx], x, y, w, h);
+ }
+
+ /* Change "root" window values */
+ dmxScreen->rootX = x;
+ dmxScreen->rootY = y;
+ dmxScreen->rootWidth = w;
+ dmxScreen->rootHeight = h;
+}
+
+/** Change the "root" window's origin by updating DMX's internal data
+ * structures (dix and Xinerama) to use the new origin and adjust the
+ * positions of windows that overlap this "root" window. */
+static void dmxSetRootWindowOrigin(int idx, int x, int y)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[idx];
+ ScreenPtr pScreen = screenInfo.screens[idx];
+ WindowPtr pRoot = pScreen->root;
+ WindowPtr pChild;
+ int xoff;
+ int yoff;
+
+ /* Change "root" window's origin */
+ dmxScreen->rootXOrigin = x;
+ dmxScreen->rootYOrigin = y;
+
+ /* Compute offsets here in case <x,y> has been changed above */
+ xoff = x - pScreen->x;
+ yoff = y - pScreen->y;
+
+ /* Adjust the root window's position */
+ pScreen->x = dmxScreen->rootXOrigin;
+ pScreen->y = dmxScreen->rootYOrigin;
+
+ /* Recalculate the Xinerama regions and data structs */
+ XineramaReinitData(pScreen);
+
+ /* Adjust each of the root window's children */
+ if (!idx) ReinitializeRootWindow(screenInfo.screens[0]->root, xoff, yoff);
+ pChild = pRoot->firstChild;
+ while (pChild) {
+ /* Adjust child window's position */
+ pScreen->MoveWindow(pChild,
+ pChild->origin.x - wBorderWidth(pChild) - xoff,
+ pChild->origin.y - wBorderWidth(pChild) - yoff,
+ pChild->nextSib,
+ VTMove);
+
+ /* Note that the call to MoveWindow will eventually call
+ * dmxPositionWindow which will automatically create a
+ * window if it is now exposed on screen (for lazy window
+ * creation optimization) and it will properly set the
+ * offscreen flag.
+ */
+
+ pChild = pChild->nextSib;
+ }
+}
+
+/** Configure the attributes of each "screen" and "root" window. */
+int dmxConfigureScreenWindows(int nscreens,
+ CARD32 *screens,
+ DMXScreenAttributesPtr attribs,
+ int *errorScreen)
+{
+ int i;
+
+ for (i = 0; i < nscreens; i++) {
+ DMXScreenAttributesPtr attr = &attribs[i];
+ int idx = screens[i];
+ DMXScreenInfo *dmxScreen = &dmxScreens[idx];
+
+ if (errorScreen) *errorScreen = i;
+
+ if (!dmxScreen->beDisplay) return DMX_BAD_VALUE;
+
+ /* Check for illegal values */
+ if (idx < 0 || idx >= dmxNumScreens) return BadValue;
+
+ /* The "screen" and "root" windows must have valid sizes */
+ if (attr->screenWindowWidth <= 0 || attr->screenWindowHeight <= 0 ||
+ attr->rootWindowWidth < 0 || attr->rootWindowHeight < 0)
+ return DMX_BAD_VALUE;
+
+ /* The "screen" window must fit entirely within the BE display */
+ if (attr->screenWindowXoffset < 0 ||
+ attr->screenWindowYoffset < 0 ||
+ attr->screenWindowXoffset
+ + attr->screenWindowWidth > (unsigned)dmxScreen->beWidth ||
+ attr->screenWindowYoffset
+ + attr->screenWindowHeight > (unsigned)dmxScreen->beHeight)
+ return DMX_BAD_VALUE;
+
+ /* The "root" window must fit entirely within the "screen" window */
+ if (attr->rootWindowXoffset < 0 ||
+ attr->rootWindowYoffset < 0 ||
+ attr->rootWindowXoffset
+ + attr->rootWindowWidth > attr->screenWindowWidth ||
+ attr->rootWindowYoffset
+ + attr->rootWindowHeight > attr->screenWindowHeight)
+ return DMX_BAD_VALUE;
+
+ /* The "root" window must not expose unaddressable coordinates */
+ if (attr->rootWindowXorigin < 0 ||
+ attr->rootWindowYorigin < 0 ||
+ attr->rootWindowXorigin + attr->rootWindowWidth > 32767 ||
+ attr->rootWindowYorigin + attr->rootWindowHeight > 32767)
+ return DMX_BAD_VALUE;
+
+ /* The "root" window must fit within the global bounding box */
+ if (attr->rootWindowXorigin
+ + attr->rootWindowWidth > (unsigned)dmxGlobalWidth ||
+ attr->rootWindowYorigin
+ + attr->rootWindowHeight > (unsigned)dmxGlobalHeight)
+ return DMX_BAD_VALUE;
+
+ /* FIXME: Handle the rest of the illegal value checking */
+ }
+
+ /* No illegal values found */
+ if (errorScreen) *errorScreen = 0;
+
+ for (i = 0; i < nscreens; i++) {
+ DMXScreenAttributesPtr attr = &attribs[i];
+ int idx = screens[i];
+ DMXScreenInfo *dmxScreen = &dmxScreens[idx];
+
+ dmxLog(dmxInfo, "Changing screen #%d attributes "
+ "from %dx%d+%d+%d %dx%d+%d+%d +%d+%d "
+ "to %dx%d+%d+%d %dx%d+%d+%d +%d+%d\n",
+ idx,
+ dmxScreen->scrnWidth, dmxScreen->scrnHeight,
+ dmxScreen->scrnX, dmxScreen->scrnY,
+ dmxScreen->rootWidth, dmxScreen->rootHeight,
+ dmxScreen->rootX, dmxScreen->rootY,
+ dmxScreen->rootXOrigin, dmxScreen->rootYOrigin,
+ attr->screenWindowWidth, attr->screenWindowHeight,
+ attr->screenWindowXoffset, attr->screenWindowYoffset,
+ attr->rootWindowWidth, attr->rootWindowHeight,
+ attr->rootWindowXoffset, attr->rootWindowYoffset,
+ attr->rootWindowXorigin, attr->rootWindowYorigin);
+
+ /* Configure "screen" window */
+ dmxConfigureScreenWindow(idx,
+ attr->screenWindowXoffset,
+ attr->screenWindowYoffset,
+ attr->screenWindowWidth,
+ attr->screenWindowHeight);
+
+ /* Configure "root" window */
+ dmxConfigureRootWindow(idx,
+ attr->rootWindowXoffset,
+ attr->rootWindowYoffset,
+ attr->rootWindowWidth,
+ attr->rootWindowHeight);
+
+
+ /* Set "root" window's origin */
+ dmxSetRootWindowOrigin(idx,
+ attr->rootWindowXorigin,
+ attr->rootWindowYorigin);
+ }
+
+ /* Adjust the cursor boundaries */
+ dmxAdjustCursorBoundaries();
+
+ /* Force completion of the changes */
+ dmxSync(NULL, TRUE);
+
+ return Success;
+}
+
+/** Configure the attributes of the global desktop. */
+int dmxConfigureDesktop(DMXDesktopAttributesPtr attribs)
+{
+ if (attribs->width <= 0 || attribs->width >= 32767 ||
+ attribs->height <= 0 || attribs->height >= 32767)
+ return DMX_BAD_VALUE;
+
+ /* If the desktop is shrinking, adjust the "root" windows on each
+ * "screen" window to only show the visible desktop. Also, handle
+ * the special case where the desktop shrinks such that the it no
+ * longer overlaps an portion of a "screen" window. */
+ if (attribs->width < dmxGlobalWidth || attribs->height < dmxGlobalHeight) {
+ int i;
+ for (i = 0; i < dmxNumScreens; i++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[i];
+ if (dmxScreen->rootXOrigin
+ + dmxScreen->rootWidth > attribs->width ||
+ dmxScreen->rootYOrigin
+ + dmxScreen->rootHeight > attribs->height) {
+ int w, h;
+ if ((w = attribs->width - dmxScreen->rootXOrigin) < 0) w = 0;
+ if ((h = attribs->height - dmxScreen->rootYOrigin) < 0) h = 0;
+ if (w > dmxScreen->scrnWidth) w = dmxScreen->scrnWidth;
+ if (h > dmxScreen->scrnHeight) h = dmxScreen->scrnHeight;
+ if (w > dmxScreen->rootWidth) w = dmxScreen->rootWidth;
+ if (h > dmxScreen->rootHeight) h = dmxScreen->rootHeight;
+ dmxConfigureRootWindow(i,
+ dmxScreen->rootX,
+ dmxScreen->rootY,
+ w, h);
+ }
+ }
+ }
+
+ /* Set the global width/height */
+ dmxSetWidthHeight(attribs->width, attribs->height);
+
+ /* Handle shift[XY] changes */
+ if (attribs->shiftX || attribs->shiftY) {
+ int i;
+ for (i = 0; i < dmxNumScreens; i++) {
+ ScreenPtr pScreen = screenInfo.screens[i];
+ WindowPtr pChild = pScreen->root->firstChild;
+ while (pChild) {
+ /* Adjust child window's position */
+ pScreen->MoveWindow(pChild,
+ pChild->origin.x - wBorderWidth(pChild)
+ - attribs->shiftX,
+ pChild->origin.y - wBorderWidth(pChild)
+ - attribs->shiftY,
+ pChild->nextSib,
+ VTMove);
+
+ /* Note that the call to MoveWindow will eventually call
+ * dmxPositionWindow which will automatically create a
+ * window if it is now exposed on screen (for lazy
+ * window creation optimization) and it will properly
+ * set the offscreen flag.
+ */
+
+ pChild = pChild->nextSib;
+ }
+ }
+ }
+
+ /* Update connection block, Xinerama, etc. -- these appears to
+ * already be handled in dmxConnectionBlockCallback(), which is
+ * called from dmxAdjustCursorBoundaries() [below]. */
+
+ /* Adjust the cursor boundaries */
+ dmxAdjustCursorBoundaries();
+
+ /* Force completion of the changes */
+ dmxSync(NULL, TRUE);
+
+ return Success;
+}
+#endif
+
+/** Create the scratch GCs per depth. */
+static void dmxBECreateScratchGCs(int scrnNum)
+{
+ ScreenPtr pScreen = screenInfo.screens[scrnNum];
+ GCPtr *ppGC = pScreen->GCperDepth;
+ int i;
+
+ for (i = 0; i <= pScreen->numDepths; i++)
+ dmxBECreateGC(pScreen, ppGC[i]);
+}
+
+#ifdef PANORAMIX
+static Bool FoundPixImage;
+
+/** Search the Xinerama XRT_PIXMAP resources for the pixmap that needs
+ * to have its image restored. When it is found, see if there is
+ * another screen with the same image. If so, copy the pixmap image
+ * from the existing screen to the newly created pixmap. */
+static void dmxBERestorePixmapImage(pointer value, XID id, RESTYPE type,
+ pointer p)
+{
+ if ((type & TypeMask) == (XRT_PIXMAP & TypeMask)) {
+ PixmapPtr pDst = (PixmapPtr)p;
+ int idx = pDst->drawable.pScreen->myNum;
+ PanoramiXRes *pXinPix = (PanoramiXRes *)value;
+ PixmapPtr pPix;
+ int i;
+
+ dixLookupResourceByType((pointer*) &pPix, pXinPix->info[idx].id,
+ RT_PIXMAP, NullClient, DixUnknownAccess);
+ if (pPix != pDst) return; /* Not a match.... Next! */
+
+ FOR_NSCREENS(i) {
+ PixmapPtr pSrc;
+ dmxPixPrivPtr pSrcPriv = NULL;
+
+ if (i == idx) continue; /* Self replication is bad */
+
+ dixLookupResourceByType((pointer*) &pSrc, pXinPix->info[i].id,
+ RT_PIXMAP, NullClient, DixUnknownAccess);
+ pSrcPriv = DMX_GET_PIXMAP_PRIV(pSrc);
+ if (pSrcPriv->pixmap) {
+ DMXScreenInfo *dmxSrcScreen = &dmxScreens[i];
+ DMXScreenInfo *dmxDstScreen = &dmxScreens[idx];
+ dmxPixPrivPtr pDstPriv = DMX_GET_PIXMAP_PRIV(pDst);
+ XImage *img;
+ int j;
+ XlibGC gc = NULL;
+
+ /* This should never happen, but just in case.... */
+ if (pSrc->drawable.width != pDst->drawable.width ||
+ pSrc->drawable.height != pDst->drawable.height)
+ return;
+
+ /* Copy from src pixmap to dst pixmap */
+ img = XGetImage(dmxSrcScreen->beDisplay,
+ pSrcPriv->pixmap,
+ 0, 0,
+ pSrc->drawable.width, pSrc->drawable.height,
+ -1,
+ ZPixmap);
+
+ for (j = 0; j < dmxDstScreen->beNumPixmapFormats; j++) {
+ if (dmxDstScreen->bePixmapFormats[j].depth == img->depth) {
+ unsigned long m;
+ XGCValues v;
+
+ m = GCFunction | GCPlaneMask | GCClipMask;
+ v.function = GXcopy;
+ v.plane_mask = AllPlanes;
+ v.clip_mask = None;
+
+ gc = XCreateGC(dmxDstScreen->beDisplay,
+ dmxDstScreen->scrnDefDrawables[j],
+ m, &v);
+ break;
+ }
+ }
+
+ if (gc) {
+ XPutImage(dmxDstScreen->beDisplay,
+ pDstPriv->pixmap,
+ gc, img, 0, 0, 0, 0,
+ pDst->drawable.width, pDst->drawable.height);
+ XFreeGC(dmxDstScreen->beDisplay, gc);
+ FoundPixImage = True;
+ } else {
+ dmxLog(dmxWarning, "Could not create GC\n");
+ }
+
+ XDestroyImage(img);
+ return;
+ }
+ }
+ }
+}
+#endif
+
+/** Restore the pixmap image either from another screen or from an image
+ * that was saved when the screen was previously detached. */
+static void dmxBERestorePixmap(PixmapPtr pPixmap)
+{
+#ifdef PANORAMIX
+ int i;
+
+ /* If Xinerama is not active, there's nothing we can do (see comment
+ * in #else below for more info). */
+ if (noPanoramiXExtension) {
+ dmxLog(dmxWarning, "Cannot restore pixmap image\n");
+ return;
+ }
+
+ FoundPixImage = False;
+ for (i = currentMaxClients; --i >= 0; )
+ if (clients[i])
+ FindAllClientResources(clients[i], dmxBERestorePixmapImage,
+ (pointer)pPixmap);
+
+ /* No corresponding pixmap image was found on other screens, so we
+ * need to copy it from the saved image when the screen was detached
+ * (if available). */
+ if (!FoundPixImage) {
+ dmxPixPrivPtr pPixPriv = DMX_GET_PIXMAP_PRIV(pPixmap);
+
+ if (pPixPriv->detachedImage) {
+ ScreenPtr pScreen = pPixmap->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ XlibGC gc = NULL;
+
+ for (i = 0; i < dmxScreen->beNumPixmapFormats; i++) {
+ if (dmxScreen->bePixmapFormats[i].depth ==
+ pPixPriv->detachedImage->depth) {
+ unsigned long m;
+ XGCValues v;
+
+ m = GCFunction | GCPlaneMask | GCClipMask;
+ v.function = GXcopy;
+ v.plane_mask = AllPlanes;
+ v.clip_mask = None;
+
+ gc = XCreateGC(dmxScreen->beDisplay,
+ dmxScreen->scrnDefDrawables[i],
+ m, &v);
+ break;
+ }
+ }
+
+ if (gc) {
+ XPutImage(dmxScreen->beDisplay,
+ pPixPriv->pixmap,
+ gc,
+ pPixPriv->detachedImage,
+ 0, 0, 0, 0,
+ pPixmap->drawable.width, pPixmap->drawable.height);
+ XFreeGC(dmxScreen->beDisplay, gc);
+ } else {
+ dmxLog(dmxWarning, "Cannot restore pixmap image\n");
+ }
+
+ XDestroyImage(pPixPriv->detachedImage);
+ pPixPriv->detachedImage = NULL;
+ } else {
+ dmxLog(dmxWarning, "Cannot restore pixmap image\n");
+ }
+ }
+#else
+ /* If Xinerama is not enabled, then there is no other copy of the
+ * pixmap image that we can restore. Saving all pixmap data is not
+ * a feasible option since there is no mechanism for updating pixmap
+ * data when a screen is detached, which means that the data that
+ * was previously saved would most likely be out of date. */
+ dmxLog(dmxWarning, "Cannot restore pixmap image\n");
+ return;
+#endif
+}
+
+/** Create resources on the back-end server. This function is called
+ * from #dmxAttachScreen() via the dix layer's FindAllResources
+ * function. It walks all resources, compares them to the screen
+ * number passed in as \a n and calls the appropriate DMX function to
+ * create the associated resource on the back-end server. */
+static void dmxBECreateResources(pointer value, XID id, RESTYPE type,
+ pointer n)
+{
+ int scrnNum = (uintptr_t)n;
+ ScreenPtr pScreen = screenInfo.screens[scrnNum];
+
+ if ((type & TypeMask) == (RT_WINDOW & TypeMask)) {
+ /* Window resources are created below in dmxBECreateWindowTree */
+ } else if ((type & TypeMask) == (RT_PIXMAP & TypeMask)) {
+ PixmapPtr pPix = value;
+ if (pPix->drawable.pScreen->myNum == scrnNum) {
+ dmxBECreatePixmap(pPix);
+ dmxBERestorePixmap(pPix);
+ }
+ } else if ((type & TypeMask) == (RT_GC & TypeMask)) {
+ GCPtr pGC = value;
+ if (pGC->pScreen->myNum == scrnNum) {
+ /* Create the GC on the back-end server */
+ dmxBECreateGC(pScreen, pGC);
+ /* Create any pixmaps associated with this GC */
+ if (!pGC->tileIsPixel) {
+ dmxBECreatePixmap(pGC->tile.pixmap);
+ dmxBERestorePixmap(pGC->tile.pixmap);
+ }
+ if (pGC->stipple != pScreen->PixmapPerDepth[0]) {
+ dmxBECreatePixmap(pGC->stipple);
+ dmxBERestorePixmap(pGC->stipple);
+ }
+ if (pGC->font != defaultFont) {
+ (void)dmxBELoadFont(pScreen, pGC->font);
+ }
+ /* Update the GC on the back-end server */
+ dmxChangeGC(pGC, -1L);
+ }
+ } else if ((type & TypeMask) == (RT_FONT & TypeMask)) {
+ (void)dmxBELoadFont(pScreen, (FontPtr)value);
+ } else if ((type & TypeMask) == (RT_CURSOR & TypeMask)) {
+ dmxBECreateCursor(pScreen, (CursorPtr)value);
+ } else if ((type & TypeMask) == (RT_COLORMAP & TypeMask)) {
+ ColormapPtr pCmap = value;
+ if (pCmap->pScreen->myNum == scrnNum)
+ (void)dmxBECreateColormap((ColormapPtr)value);
+#if 0
+ /* TODO: Recreate Picture and GlyphSet resources */
+ } else if ((type & TypeMask) == (PictureType & TypeMask)) {
+ /* Picture resources are created when windows are created */
+ } else if ((type & TypeMask) == (GlyphSetType & TypeMask)) {
+ dmxBEFreeGlyphSet(pScreen, (GlyphSetPtr)value);
+#endif
+ } else {
+ /* Other resource types??? */
+ }
+}
+
+/** Create window hierachy on back-end server. The window tree is
+ * created in a special order (bottom most subwindow first) so that the
+ * #dmxCreateNonRootWindow() function does not need to recursively call
+ * itself to create each window's parents. This is required so that we
+ * have the opportunity to create each window's border and background
+ * pixmaps (where appropriate) before the window is created. */
+static void dmxBECreateWindowTree(int idx)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[idx];
+ WindowPtr pRoot = screenInfo.screens[idx]->root;
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pRoot);
+ WindowPtr pWin;
+
+ /* Create the pixmaps associated with the root window */
+ if (!pRoot->borderIsPixel) {
+ dmxBECreatePixmap(pRoot->border.pixmap);
+ dmxBERestorePixmap(pRoot->border.pixmap);
+ }
+ if (pRoot->backgroundState == BackgroundPixmap) {
+ dmxBECreatePixmap(pRoot->background.pixmap);
+ dmxBERestorePixmap(pRoot->background.pixmap);
+ }
+
+ /* Create root window first */
+ dmxScreen->rootWin = pWinPriv->window = dmxCreateRootWindow(pRoot);
+ XMapWindow(dmxScreen->beDisplay, dmxScreen->rootWin);
+
+ pWin = pRoot->lastChild;
+ while (pWin) {
+ pWinPriv = DMX_GET_WINDOW_PRIV(pWin);
+
+ /* Create the pixmaps regardless of whether or not the
+ * window is created or not due to lazy window creation.
+ */
+ if (!pWin->borderIsPixel) {
+ dmxBECreatePixmap(pWin->border.pixmap);
+ dmxBERestorePixmap(pWin->border.pixmap);
+ }
+ if (pWin->backgroundState == BackgroundPixmap) {
+ dmxBECreatePixmap(pWin->background.pixmap);
+ dmxBERestorePixmap(pWin->background.pixmap);
+ }
+
+ /* Reset the window attributes */
+ dmxGetDefaultWindowAttributes(pWin,
+ &pWinPriv->cmap,
+ &pWinPriv->visual);
+
+ /* Create the window */
+ if (pWinPriv->mapped && !pWinPriv->offscreen)
+ dmxCreateAndRealizeWindow(pWin, TRUE);
+
+ /* Next, create the bottom-most child */
+ if (pWin->lastChild) {
+ pWin = pWin->lastChild;
+ continue;
+ }
+
+ /* If the window has no children, move on to the next higher window */
+ while (!pWin->prevSib && (pWin != pRoot))
+ pWin = pWin->parent;
+
+ if (pWin->prevSib) {
+ pWin = pWin->prevSib;
+ continue;
+ }
+
+ /* When we reach the root window, we are finished */
+ if (pWin == pRoot)
+ break;
+ }
+}
+
+/* Refresh screen by generating exposure events for all windows */
+static void dmxForceExposures(int idx)
+{
+ ScreenPtr pScreen = screenInfo.screens[idx];
+ WindowPtr pRoot = pScreen->root;
+ Bool anyMarked = FALSE;
+ WindowPtr pChild;
+
+ for (pChild = pRoot->firstChild; pChild; pChild = pChild->nextSib)
+ anyMarked |= pScreen->MarkOverlappedWindows(pChild, pChild,
+ (WindowPtr *)NULL);
+ if (anyMarked) {
+ /* If any windows have been marked, set the root window's
+ * clipList to be broken since it will be recalculated in
+ * ValidateTree()
+ */
+ RegionBreak(&pRoot->clipList);
+ pScreen->ValidateTree(pRoot, NULL, VTBroken);
+ pScreen->HandleExposures(pRoot);
+ if (pScreen->PostValidateTree)
+ pScreen->PostValidateTree(pRoot, NULL, VTBroken);
+ }
+}
+
+/** Compare the new and old screens to see if they are compatible. */
+static Bool dmxCompareScreens(DMXScreenInfo *new, DMXScreenInfo *old)
+{
+ int i;
+
+ if (new->beWidth != old->beWidth) return FALSE;
+ if (new->beHeight != old->beHeight) return FALSE;
+ if (new->beDepth != old->beDepth) return FALSE;
+ if (new->beBPP != old->beBPP) return FALSE;
+
+ if (new->beNumDepths != old->beNumDepths) return FALSE;
+ for (i = 0; i < old->beNumDepths; i++)
+ if (new->beDepths[i] != old->beDepths[i]) return FALSE;
+
+ if (new->beNumPixmapFormats != old->beNumPixmapFormats) return FALSE;
+ for (i = 0; i < old->beNumPixmapFormats; i++) {
+ if (new->bePixmapFormats[i].depth !=
+ old->bePixmapFormats[i].depth) return FALSE;
+ if (new->bePixmapFormats[i].bits_per_pixel !=
+ old->bePixmapFormats[i].bits_per_pixel) return FALSE;
+ if (new->bePixmapFormats[i].scanline_pad !=
+ old->bePixmapFormats[i].scanline_pad) return FALSE;
+ }
+
+ if (new->beNumVisuals != old->beNumVisuals) return FALSE;
+ for (i = 0; i < old->beNumVisuals; i++) {
+ if (new->beVisuals[i].visualid !=
+ old->beVisuals[i].visualid) return FALSE;
+ if (new->beVisuals[i].screen !=
+ old->beVisuals[i].screen) return FALSE;
+ if (new->beVisuals[i].depth !=
+ old->beVisuals[i].depth) return FALSE;
+ if (new->beVisuals[i].class !=
+ old->beVisuals[i].class) return FALSE;
+ if (new->beVisuals[i].red_mask !=
+ old->beVisuals[i].red_mask) return FALSE;
+ if (new->beVisuals[i].green_mask !=
+ old->beVisuals[i].green_mask) return FALSE;
+ if (new->beVisuals[i].blue_mask !=
+ old->beVisuals[i].blue_mask) return FALSE;
+ if (new->beVisuals[i].colormap_size !=
+ old->beVisuals[i].colormap_size) return FALSE;
+ if (new->beVisuals[i].bits_per_rgb !=
+ old->beVisuals[i].bits_per_rgb) return FALSE;
+ }
+
+ if (new->beDefVisualIndex != old->beDefVisualIndex) return FALSE;
+
+ return TRUE;
+}
+
+/** Restore Render's picture */
+static void dmxBERestoreRenderPict(pointer value, XID id, pointer n)
+{
+ PicturePtr pPicture = value; /* The picture */
+ DrawablePtr pDraw = pPicture->pDrawable; /* The picture's drawable */
+ int scrnNum = (uintptr_t)n;
+
+ if (pDraw->pScreen->myNum != scrnNum) {
+ /* Picture not on the screen we are restoring*/
+ return;
+ }
+
+ if (pDraw->type == DRAWABLE_PIXMAP) {
+ PixmapPtr pPixmap = (PixmapPtr)pDraw;
+
+ /* Create and restore the pixmap drawable */
+ dmxBECreatePixmap(pPixmap);
+ dmxBERestorePixmap(pPixmap);
+ }
+
+ dmxBECreatePicture(pPicture);
+}
+
+/** Restore Render's glyphs */
+static void dmxBERestoreRenderGlyph(pointer value, XID id, pointer n)
+{
+ GlyphSetPtr glyphSet = value;
+ int scrnNum = (uintptr_t)n;
+ dmxGlyphPrivPtr glyphPriv = DMX_GET_GLYPH_PRIV(glyphSet);
+ DMXScreenInfo *dmxScreen = &dmxScreens[scrnNum];
+ GlyphRefPtr table;
+ char *images;
+ Glyph *gids;
+ XGlyphInfo *glyphs;
+ char *pos;
+ int beret;
+ int len_images = 0;
+ int i;
+ int ctr;
+
+ if (glyphPriv->glyphSets[scrnNum]) {
+ /* Only restore glyphs on the screen we are attaching */
+ return;
+ }
+
+ /* First we must create the glyph set on the backend. */
+ if ((beret = dmxBECreateGlyphSet(scrnNum, glyphSet)) != Success) {
+ dmxLog(dmxWarning,
+ "\tdmxBERestoreRenderGlyph failed to create glyphset!\n");
+ return;
+ }
+
+ /* Now for the complex part, restore the glyph data */
+ table = glyphSet->hash.table;
+
+ /* We need to know how much memory to allocate for this part */
+ for (i = 0; i < glyphSet->hash.hashSet->size; i++) {
+ GlyphRefPtr gr = &table[i];
+ GlyphPtr gl = gr->glyph;
+
+ if (!gl || gl == DeletedGlyph) continue;
+ len_images += gl->size - sizeof(gl->info);
+ }
+
+ /* Now allocate the memory we need */
+ images = calloc(len_images, sizeof(char));
+ gids = malloc(glyphSet->hash.tableEntries*sizeof(Glyph));
+ glyphs = malloc(glyphSet->hash.tableEntries*sizeof(XGlyphInfo));
+
+ pos = images;
+ ctr = 0;
+
+ /* Fill the allocated memory with the proper data */
+ for (i = 0; i < glyphSet->hash.hashSet->size; i++) {
+ GlyphRefPtr gr = &table[i];
+ GlyphPtr gl = gr->glyph;
+
+ if (!gl || gl == DeletedGlyph) continue;
+
+ /* First lets put the data into gids */
+ gids[ctr] = gr->signature;
+
+ /* Next do the glyphs data structures */
+ glyphs[ctr].width = gl->info.width;
+ glyphs[ctr].height = gl->info.height;
+ glyphs[ctr].x = gl->info.x;
+ glyphs[ctr].y = gl->info.y;
+ glyphs[ctr].xOff = gl->info.xOff;
+ glyphs[ctr].yOff = gl->info.yOff;
+
+ /* Copy the images from the DIX's data into the buffer */
+ memcpy(pos, gl+1, gl->size - sizeof(gl->info));
+ pos += gl->size - sizeof(gl->info);
+ ctr++;
+ }
+
+ /* Now restore the glyph data */
+ XRenderAddGlyphs(dmxScreen->beDisplay, glyphPriv->glyphSets[scrnNum],
+ gids,glyphs, glyphSet->hash.tableEntries, images,
+ len_images);
+
+ /* Clean up */
+ free(images);
+ free(gids);
+ free(glyphs);
+}
+
+/** Reattach previously detached back-end screen. */
+int dmxAttachScreen(int idx, DMXScreenAttributesPtr attr)
+{
+ ScreenPtr pScreen;
+ DMXScreenInfo *dmxScreen;
+ CARD32 scrnNum = idx;
+ DMXScreenInfo oldDMXScreen;
+ int i;
+
+ /* Return failure if dynamic addition/removal of screens is disabled */
+ if (!dmxAddRemoveScreens) {
+ dmxLog(dmxWarning,
+ "Attempting to add a screen, but the AddRemoveScreen\n");
+ dmxLog(dmxWarning,
+ "extension has not been enabled. To enable this extension\n");
+ dmxLog(dmxWarning,
+ "add the \"-addremovescreens\" option either to the command\n");
+ dmxLog(dmxWarning,
+ "line or in the configuration file.\n");
+ return 1;
+ }
+
+ /* Cannot add a screen that does not exist */
+ if (idx < 0 || idx >= dmxNumScreens) return 1;
+ pScreen = screenInfo.screens[idx];
+ dmxScreen = &dmxScreens[idx];
+
+ /* Cannot attach to a screen that is already opened */
+ if (dmxScreen->beDisplay) {
+ dmxLog(dmxWarning,
+ "Attempting to add screen #%d but a screen already exists\n",
+ idx);
+ return 1;
+ }
+
+ dmxLogOutput(dmxScreen, "Attaching screen #%d\n", idx);
+
+ /* Save old info */
+ oldDMXScreen = *dmxScreen;
+
+ /* Copy the name to the new screen */
+ dmxScreen->name = strdup(attr->displayName);
+
+ /* Open display and get all of the screen info */
+ if (!dmxOpenDisplay(dmxScreen)) {
+ dmxLog(dmxWarning,
+ "dmxOpenDisplay: Unable to open display %s\n",
+ dmxScreen->name);
+
+ /* Restore the old screen */
+ *dmxScreen = oldDMXScreen;
+ return 1;
+ }
+
+ dmxSetErrorHandler(dmxScreen);
+ dmxCheckForWM(dmxScreen);
+ dmxGetScreenAttribs(dmxScreen);
+
+ if (!dmxGetVisualInfo(dmxScreen)) {
+ dmxLog(dmxWarning, "dmxGetVisualInfo: No matching visuals found\n");
+ XFree(dmxScreen->beVisuals);
+ XCloseDisplay(dmxScreen->beDisplay);
+
+ /* Restore the old screen */
+ *dmxScreen = oldDMXScreen;
+ return 1;
+ }
+
+ dmxGetColormaps(dmxScreen);
+ dmxGetPixmapFormats(dmxScreen);
+
+ /* Verify that the screen to be added has the same info as the
+ * previously added screen. */
+ if (!dmxCompareScreens(dmxScreen, &oldDMXScreen)) {
+ dmxLog(dmxWarning,
+ "New screen data (%s) does not match previously\n",
+ dmxScreen->name);
+ dmxLog(dmxWarning,
+ "attached screen data (%s)\n",
+ oldDMXScreen.name);
+ dmxLog(dmxWarning,
+ "All data must match in order to attach to screen #%d\n",
+ idx);
+ XFree(dmxScreen->beVisuals);
+ XFree(dmxScreen->beDepths);
+ XFree(dmxScreen->bePixmapFormats);
+ XCloseDisplay(dmxScreen->beDisplay);
+
+ /* Restore the old screen */
+ *dmxScreen = oldDMXScreen;
+ return 1;
+ }
+
+ /* Initialize the BE screen resources */
+ dmxBEScreenInit(idx, screenInfo.screens[idx]);
+
+ /* TODO: Handle GLX visual initialization. GLXProxy needs to be
+ * updated to handle dynamic addition/removal of screens. */
+
+ /* Create default stipple */
+ dmxBECreatePixmap(pScreen->PixmapPerDepth[0]);
+ dmxBERestorePixmap(pScreen->PixmapPerDepth[0]);
+
+ /* Create the scratch GCs */
+ dmxBECreateScratchGCs(idx);
+
+ /* Create the default font */
+ (void)dmxBELoadFont(pScreen, defaultFont);
+
+ /* Create all resources that don't depend on windows */
+ for (i = currentMaxClients; --i >= 0; )
+ if (clients[i])
+ FindAllClientResources(clients[i], dmxBECreateResources,
+ (pointer)(uintptr_t)idx);
+
+ /* Create window hierarchy (top down) */
+ dmxBECreateWindowTree(idx);
+
+ /* Restore the picture state for RENDER */
+ for (i = currentMaxClients; --i >= 0; )
+ if (clients[i])
+ FindClientResourcesByType(clients[i],PictureType,
+ dmxBERestoreRenderPict,
+ (pointer)(uintptr_t)idx);
+
+ /* Restore the glyph state for RENDER */
+ for (i = currentMaxClients; --i >= 0; )
+ if (clients[i])
+ FindClientResourcesByType(clients[i],GlyphSetType,
+ dmxBERestoreRenderGlyph,
+ (pointer)(uintptr_t)idx);
+
+ /* Refresh screen by generating exposure events for all windows */
+ dmxForceExposures(idx);
+
+ dmxSync(&dmxScreens[idx], TRUE);
+
+ /* We used these to compare the old and new screens. They are no
+ * longer needed since we have a newly attached screen, so we can
+ * now free the old screen's resources. */
+ XFree(oldDMXScreen.beVisuals);
+ XFree(oldDMXScreen.beDepths);
+ XFree(oldDMXScreen.bePixmapFormats);
+ /* TODO: should oldDMXScreen.name be freed?? */
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension)
+ return dmxConfigureScreenWindows(1, &scrnNum, attr, NULL);
+ else
+#endif
+ return 0; /* Success */
+}
+
+/*
+ * Resources that may have state on the BE server and need to be freed:
+ *
+ * RT_NONE
+ * RT_WINDOW
+ * RT_PIXMAP
+ * RT_GC
+ * RT_FONT
+ * RT_CURSOR
+ * RT_COLORMAP
+ * RT_CMAPENTRY
+ * RT_OTHERCLIENT
+ * RT_PASSIVEGRAB
+ * XRT_WINDOW
+ * XRT_PIXMAP
+ * XRT_GC
+ * XRT_COLORMAP
+ * XRT_PICTURE
+ * PictureType
+ * PictFormatType
+ * GlyphSetType
+ * ClientType
+ * EventType
+ * RT_INPUTCLIENT
+ * XETrapType
+ * RTCounter
+ * RTAwait
+ * RTAlarmClient
+ * RT_XKBCLIENT
+ * RTContext
+ * TagResType
+ * StalledResType
+ * SecurityAuthorizationResType
+ * RTEventClient
+ * __glXContextRes
+ * __glXClientRes
+ * __glXPixmapRes
+ * __glXWindowRes
+ * __glXPbufferRes
+ */
+
+#ifdef PANORAMIX
+/** Search the Xinerama XRT_PIXMAP resources for the pixmap that needs
+ * to have its image saved. */
+static void dmxBEFindPixmapImage(pointer value, XID id, RESTYPE type,
+ pointer p)
+{
+ if ((type & TypeMask) == (XRT_PIXMAP & TypeMask)) {
+ PixmapPtr pDst = (PixmapPtr)p;
+ int idx = pDst->drawable.pScreen->myNum;
+ PanoramiXRes *pXinPix = (PanoramiXRes *)value;
+ PixmapPtr pPix;
+ int i;
+
+ dixLookupResourceByType((pointer*) &pPix, pXinPix->info[idx].id,
+ RT_PIXMAP, NullClient, DixUnknownAccess);
+ if (pPix != pDst) return; /* Not a match.... Next! */
+
+ FOR_NSCREENS(i) {
+ PixmapPtr pSrc;
+ dmxPixPrivPtr pSrcPriv = NULL;
+
+ if (i == idx) continue; /* Self replication is bad */
+
+ dixLookupResourceByType((pointer*) &pSrc, pXinPix->info[i].id,
+ RT_PIXMAP, NullClient, DixUnknownAccess);
+ pSrcPriv = DMX_GET_PIXMAP_PRIV(pSrc);
+ if (pSrcPriv->pixmap) {
+ FoundPixImage = True;
+ return;
+ }
+ }
+ }
+}
+#endif
+
+/** Save the pixmap image only when there is not another screen with
+ * that pixmap from which the image can be read when the screen is
+ * reattached. To do this, we first try to find a pixmap on another
+ * screen corresponding to the one we are trying to save. If we find
+ * one, then we do not need to save the image data since during
+ * reattachment, the image data can be read from that other pixmap.
+ * However, if we do not find one, then we need to save the image data.
+ * The common case for these are for the default stipple and root
+ * tile. */
+static void dmxBESavePixmap(PixmapPtr pPixmap)
+{
+#ifdef PANORAMIX
+ int i;
+
+ /* If Xinerama is not active, there's nothing we can do (see comment
+ * in #else below for more info). */
+ if (noPanoramiXExtension) return;
+
+ FoundPixImage = False;
+ for (i = currentMaxClients; --i >= 0; )
+ if (clients[i])
+ FindAllClientResources(clients[i], dmxBEFindPixmapImage,
+ (pointer)pPixmap);
+
+ /* Save the image only if there is no other screens that have a
+ * pixmap that corresponds to the one we are trying to save. */
+ if (!FoundPixImage) {
+ dmxPixPrivPtr pPixPriv = DMX_GET_PIXMAP_PRIV(pPixmap);
+
+ if (!pPixPriv->detachedImage) {
+ ScreenPtr pScreen = pPixmap->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+
+ pPixPriv->detachedImage = XGetImage(dmxScreen->beDisplay,
+ pPixPriv->pixmap,
+ 0, 0,
+ pPixmap->drawable.width,
+ pPixmap->drawable.height,
+ -1,
+ ZPixmap);
+ if (!pPixPriv->detachedImage)
+ dmxLog(dmxWarning, "Cannot save pixmap image\n");
+ }
+ }
+#else
+ /* NOTE: The only time there is a pixmap on another screen that
+ * corresponds to the one we are trying to save is when Xinerama is
+ * active. Otherwise, the pixmap image data is only stored on a
+ * single screen, which means that once it is detached, that data is
+ * lost. We could save the data here, but then that would require
+ * us to implement the ability for Xdmx to keep the pixmap up to
+ * date while the screen is detached, which is beyond the scope of
+ * the current project. */
+ return;
+#endif
+}
+
+/** Destroy resources on the back-end server. This function is called
+ * from #dmxDetachScreen() via the dix layer's FindAllResources
+ * function. It walks all resources, compares them to the screen
+ * number passed in as \a n and calls the appropriate DMX function to
+ * free the associated resource on the back-end server. */
+static void dmxBEDestroyResources(pointer value, XID id, RESTYPE type,
+ pointer n)
+{
+ int scrnNum = (uintptr_t)n;
+ ScreenPtr pScreen = screenInfo.screens[scrnNum];
+
+ if ((type & TypeMask) == (RT_WINDOW & TypeMask)) {
+ /* Window resources are destroyed below in dmxBEDestroyWindowTree */
+ } else if ((type & TypeMask) == (RT_PIXMAP & TypeMask)) {
+ PixmapPtr pPix = value;
+ if (pPix->drawable.pScreen->myNum == scrnNum) {
+ dmxBESavePixmap(pPix);
+ dmxBEFreePixmap(pPix);
+ }
+ } else if ((type & TypeMask) == (RT_GC & TypeMask)) {
+ GCPtr pGC = value;
+ if (pGC->pScreen->myNum == scrnNum)
+ dmxBEFreeGC(pGC);
+ } else if ((type & TypeMask) == (RT_FONT & TypeMask)) {
+ dmxBEFreeFont(pScreen, (FontPtr)value);
+ } else if ((type & TypeMask) == (RT_CURSOR & TypeMask)) {
+ dmxBEFreeCursor(pScreen, (CursorPtr)value);
+ } else if ((type & TypeMask) == (RT_COLORMAP & TypeMask)) {
+ ColormapPtr pCmap = value;
+ if (pCmap->pScreen->myNum == scrnNum)
+ dmxBEFreeColormap((ColormapPtr)value);
+ } else if ((type & TypeMask) == (PictureType & TypeMask)) {
+ PicturePtr pPict = value;
+ if (pPict->pDrawable->pScreen->myNum == scrnNum) {
+ /* Free the pixmaps on the backend if needed */
+ if (pPict->pDrawable->type == DRAWABLE_PIXMAP) {
+ PixmapPtr pPixmap = (PixmapPtr)(pPict->pDrawable);
+ dmxBESavePixmap(pPixmap);
+ dmxBEFreePixmap(pPixmap);
+ }
+ dmxBEFreePicture((PicturePtr)value);
+ }
+ } else if ((type & TypeMask) == (GlyphSetType & TypeMask)) {
+ dmxBEFreeGlyphSet(pScreen, (GlyphSetPtr)value);
+ } else {
+ /* Other resource types??? */
+ }
+}
+
+/** Destroy the scratch GCs that are created per depth. */
+static void dmxBEDestroyScratchGCs(int scrnNum)
+{
+ ScreenPtr pScreen = screenInfo.screens[scrnNum];
+ GCPtr *ppGC = pScreen->GCperDepth;
+ int i;
+
+ for (i = 0; i <= pScreen->numDepths; i++)
+ dmxBEFreeGC(ppGC[i]);
+}
+
+/** Destroy window hierachy on back-end server. To ensure that all
+ * XDestroyWindow() calls succeed, they must be performed in a bottom
+ * up order so that windows are not destroyed before their children.
+ * XDestroyWindow(), which is called from #dmxBEDestroyWindow(), will
+ * destroy a window as well as all of it's children. */
+static void dmxBEDestroyWindowTree(int idx)
+{
+ WindowPtr pWin = screenInfo.screens[idx]->root;
+ WindowPtr pChild = pWin;
+
+ while (1) {
+ if (pChild->firstChild) {
+ pChild = pChild->firstChild;
+ continue;
+ }
+
+ /* Destroy the window */
+ dmxBEDestroyWindow(pChild);
+
+ /* Make sure we destroy the window's border and background
+ * pixmaps if they exist */
+ if (!pChild->borderIsPixel) {
+ dmxBESavePixmap(pChild->border.pixmap);
+ dmxBEFreePixmap(pChild->border.pixmap);
+ }
+ if (pChild->backgroundState == BackgroundPixmap) {
+ dmxBESavePixmap(pChild->background.pixmap);
+ dmxBEFreePixmap(pChild->background.pixmap);
+ }
+
+ while (!pChild->nextSib && (pChild != pWin)) {
+ pChild = pChild->parent;
+ dmxBEDestroyWindow(pChild);
+ if (!pChild->borderIsPixel) {
+ dmxBESavePixmap(pChild->border.pixmap);
+ dmxBEFreePixmap(pChild->border.pixmap);
+ }
+ if (pChild->backgroundState == BackgroundPixmap) {
+ dmxBESavePixmap(pChild->background.pixmap);
+ dmxBEFreePixmap(pChild->background.pixmap);
+ }
+ }
+
+ if (pChild == pWin)
+ break;
+
+ pChild = pChild->nextSib;
+ }
+}
+
+/** Detach back-end screen. */
+int dmxDetachScreen(int idx)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[idx];
+ int i;
+
+ /* Return failure if dynamic addition/removal of screens is disabled */
+ if (!dmxAddRemoveScreens) {
+ dmxLog(dmxWarning,
+ "Attempting to remove a screen, but the AddRemoveScreen\n");
+ dmxLog(dmxWarning,
+ "extension has not been enabled. To enable this extension\n");
+ dmxLog(dmxWarning,
+ "add the \"-addremovescreens\" option either to the command\n");
+ dmxLog(dmxWarning,
+ "line or in the configuration file.\n");
+ return 1;
+ }
+
+ /* Cannot remove a screen that does not exist */
+ if (idx < 0 || idx >= dmxNumScreens) return 1;
+
+ /* Cannot detach from a screen that is not opened */
+ if (!dmxScreen->beDisplay) {
+ dmxLog(dmxWarning,
+ "Attempting to remove screen #%d but it has not been opened\n",
+ idx);
+ return 1;
+ }
+
+ dmxLogOutput(dmxScreen, "Detaching screen #%d\n", idx);
+
+ /* Detach input */
+ dmxInputDetachAll(dmxScreen);
+
+ /* Save all relevant state (TODO) */
+
+ /* Free all non-window resources related to this screen */
+ for (i = currentMaxClients; --i >= 0; )
+ if (clients[i])
+ FindAllClientResources(clients[i], dmxBEDestroyResources,
+ (pointer)(uintptr_t)idx);
+
+ /* Free scratch GCs */
+ dmxBEDestroyScratchGCs(idx);
+
+ /* Free window resources related to this screen */
+ dmxBEDestroyWindowTree(idx);
+
+ /* Free default stipple */
+ dmxBESavePixmap(screenInfo.screens[idx]->PixmapPerDepth[0]);
+ dmxBEFreePixmap(screenInfo.screens[idx]->PixmapPerDepth[0]);
+
+ /* Free the remaining screen resources and close the screen */
+ dmxBECloseScreen(screenInfo.screens[idx]);
+
+ /* Adjust the cursor boundaries (paints detached console window) */
+ dmxAdjustCursorBoundaries();
+
+ return 0; /* Success */
+}
diff --git a/xorg-server/hw/dmx/dmxgcops.c b/xorg-server/hw/dmx/dmxgcops.c
index 07165f731..500e2cdf1 100644
--- a/xorg-server/hw/dmx/dmxgcops.c
+++ b/xorg-server/hw/dmx/dmxgcops.c
@@ -1,605 +1,605 @@
-/*
- * 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>
- *
- */
-
-/** \file
- * This file provides support for GC operations. */
-
-#ifdef HAVE_DMX_CONFIG_H
-#include <dmx-config.h>
-#endif
-
-#include "dmx.h"
-#include "dmxsync.h"
-#include "dmxgc.h"
-#include "dmxgcops.h"
-#include "dmxwindow.h"
-#include "dmxpixmap.h"
-
-#include "mi.h"
-#include "gcstruct.h"
-#include "pixmapstr.h"
-#include "dixfontstr.h"
-
-#ifdef PANORAMIX
-#include "panoramiXsrv.h"
-#endif
-
-#define DMX_GCOPS_SET_DRAWABLE(_pDraw, _draw) \
-do { \
- if ((_pDraw)->type == DRAWABLE_WINDOW) { \
- dmxWinPrivPtr pWinPriv = \
- DMX_GET_WINDOW_PRIV((WindowPtr)(_pDraw)); \
- (_draw) = (Drawable)pWinPriv->window; \
- } else { \
- dmxPixPrivPtr pPixPriv = \
- DMX_GET_PIXMAP_PRIV((PixmapPtr)(_pDraw)); \
- (_draw) = (Drawable)pPixPriv->pixmap; \
- } \
-} while (0)
-
-#define DMX_GCOPS_OFFSCREEN(_pDraw) \
- (!dmxScreens[(_pDraw)->pScreen->myNum].beDisplay || \
- (dmxOffScreenOpt && \
- (_pDraw)->type == DRAWABLE_WINDOW && \
- (DMX_GET_WINDOW_PRIV((WindowPtr)(_pDraw))->offscreen || \
- !DMX_GET_WINDOW_PRIV((WindowPtr)(_pDraw))->window)))
-
-/** Fill spans -- this function should never be called. */
-void dmxFillSpans(DrawablePtr pDrawable, GCPtr pGC,
- int nInit, DDXPointPtr pptInit, int *pwidthInit,
- int fSorted)
-{
- /* Error -- this should never happen! */
-}
-
-/** Set spans -- this function should never be called. */
-void dmxSetSpans(DrawablePtr pDrawable, GCPtr pGC,
- char *psrc, DDXPointPtr ppt, int *pwidth, int nspans,
- int fSorted)
-{
- /* Error -- this should never happen! */
-}
-
-/** Transfer \a pBits image to back-end server associated with \a
- * pDrawable's screen. If primitive subdivision optimization is
- * enabled, then only transfer the sections of \a pBits that are
- * visible (i.e., not-clipped) to the back-end server. */
-void dmxPutImage(DrawablePtr pDrawable, GCPtr pGC,
- int depth, int x, int y, int w, int h,
- int leftPad, int format, char *pBits)
-{
- DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
- dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
- XImage *img;
-
- if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;
-
- img = XCreateImage(dmxScreen->beDisplay,
- dmxScreen->beVisuals[dmxScreen->beDefVisualIndex].visual,
- depth, format, leftPad, pBits, w, h,
- BitmapPad(dmxScreen->beDisplay),
- (format == ZPixmap) ?
- PixmapBytePad(w, depth) : BitmapBytePad(w+leftPad));
-
- if (img) {
- Drawable draw;
-
- DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
-
- if (dmxSubdividePrimitives && pGC->pCompositeClip) {
- RegionPtr pSubImages;
- RegionPtr pClip;
- BoxRec box;
- BoxPtr pBox;
- int nBox;
-
- box.x1 = x;
- box.y1 = y;
- box.x2 = x + w;
- box.y2 = y + h;
- pSubImages = RegionCreate(&box, 1);
-
- pClip = RegionCreate(NullBox, 1);
- RegionCopy(pClip, pGC->pCompositeClip);
- RegionTranslate(pClip,
- -pDrawable->x, -pDrawable->y);
- RegionIntersect(pSubImages, pSubImages, pClip);
-
- nBox = RegionNumRects(pSubImages);
- pBox = RegionRects(pSubImages);
-
- while (nBox--) {
- XPutImage(dmxScreen->beDisplay, draw, pGCPriv->gc, img,
- pBox->x1 - box.x1,
- pBox->y1 - box.y1,
- pBox->x1,
- pBox->y1,
- pBox->x2 - pBox->x1,
- pBox->y2 - pBox->y1);
- pBox++;
- }
- RegionDestroy(pClip);
- RegionDestroy(pSubImages);
- } else {
- XPutImage(dmxScreen->beDisplay, draw, pGCPriv->gc,
- img, 0, 0, x, y, w, h);
- }
- XFree(img); /* Use XFree instead of XDestroyImage
- * because pBits is passed in from the
- * caller. */
-
- dmxSync(dmxScreen, FALSE);
- } else {
- /* Error -- this should not happen! */
- }
-}
-
-/** Copy area from \a pSrc drawable to \a pDst drawable on the back-end
- * server associated with \a pSrc drawable's screen. If the offscreen
- * optimization is enabled, only copy when both \a pSrc and \a pDst are
- * at least partially visible. */
-RegionPtr dmxCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
- int srcx, int srcy, int w, int h, int dstx, int dsty)
-{
- DMXScreenInfo *dmxScreen = &dmxScreens[pSrc->pScreen->myNum];
- dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
- Drawable srcDraw, dstDraw;
-
- if (DMX_GCOPS_OFFSCREEN(pSrc) || DMX_GCOPS_OFFSCREEN(pDst))
- return miHandleExposures(pSrc, pDst, pGC, srcx, srcy, w, h,
- dstx, dsty, 0L);
-
- DMX_GCOPS_SET_DRAWABLE(pSrc, srcDraw);
- DMX_GCOPS_SET_DRAWABLE(pDst, dstDraw);
-
- XCopyArea(dmxScreen->beDisplay, srcDraw, dstDraw, pGCPriv->gc,
- srcx, srcy, w, h, dstx, dsty);
- dmxSync(dmxScreen, FALSE);
-
- return miHandleExposures(pSrc, pDst, pGC, srcx, srcy, w, h,
- dstx, dsty, 0L);
-}
-
-/** Copy plane number \a bitPlane from \a pSrc drawable to \a pDst
- * drawable on the back-end server associated with \a pSrc drawable's
- * screen. If the offscreen optimization is enabled, only copy when
- * both \a pSrc and \a pDst are at least partially visible. */
-RegionPtr dmxCopyPlane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
- int srcx, int srcy, int width, int height,
- int dstx, int dsty, unsigned long bitPlane)
-{
- DMXScreenInfo *dmxScreen = &dmxScreens[pSrc->pScreen->myNum];
- dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
- Drawable srcDraw, dstDraw;
-
- if (DMX_GCOPS_OFFSCREEN(pSrc) || DMX_GCOPS_OFFSCREEN(pDst))
- return miHandleExposures(pSrc, pDst, pGC, srcx, srcy, width, height,
- dstx, dsty, bitPlane);
-
- DMX_GCOPS_SET_DRAWABLE(pSrc, srcDraw);
- DMX_GCOPS_SET_DRAWABLE(pDst, dstDraw);
-
- XCopyPlane(dmxScreen->beDisplay, srcDraw, dstDraw, pGCPriv->gc,
- srcx, srcy, width, height, dstx, dsty, bitPlane);
- dmxSync(dmxScreen, FALSE);
-
- return miHandleExposures(pSrc, pDst, pGC, srcx, srcy, width, height,
- dstx, dsty, bitPlane);
-}
-
-/** Render list of points, \a pptInit in \a pDrawable on the back-end
- * server associated with \a pDrawable's screen. If the offscreen
- * optimization is enabled, only draw when \a pDrawable is at least
- * partially visible. */
-void dmxPolyPoint(DrawablePtr pDrawable, GCPtr pGC,
- int mode, int npt, DDXPointPtr pptInit)
-{
- DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
- dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
- Drawable draw;
-
- if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;
-
- DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
-
- XDrawPoints(dmxScreen->beDisplay, draw, pGCPriv->gc,
- (XPoint *)pptInit, npt, mode);
- dmxSync(dmxScreen, FALSE);
-}
-
-/** Render list of connected lines, \a pptInit in \a pDrawable on the
- * back-end server associated with \a pDrawable's screen. If the
- * offscreen optimization is enabled, only draw when \a pDrawable is at
- * least partially visible. */
-void dmxPolylines(DrawablePtr pDrawable, GCPtr pGC,
- int mode, int npt, DDXPointPtr pptInit)
-{
- DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
- dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
- Drawable draw;
-
- if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;
-
- DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
-
- XDrawLines(dmxScreen->beDisplay, draw, pGCPriv->gc,
- (XPoint *)pptInit, npt, mode);
- dmxSync(dmxScreen, FALSE);
-}
-
-/** Render list of disjoint segments, \a pSegs in \a pDrawable on the
- * back-end server associated with \a pDrawable's screen. If the
- * offscreen optimization is enabled, only draw when \a pDrawable is at
- * least partially visible. */
-void dmxPolySegment(DrawablePtr pDrawable, GCPtr pGC,
- int nseg, xSegment *pSegs)
-{
- DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
- dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
- Drawable draw;
-
- if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;
-
- DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
-
- XDrawSegments(dmxScreen->beDisplay, draw, pGCPriv->gc,
- (XSegment *)pSegs, nseg);
- dmxSync(dmxScreen, FALSE);
-}
-
-/** Render list of rectangle outlines, \a pRects in \a pDrawable on the
- * back-end server associated with \a pDrawable's screen. If the
- * offscreen optimization is enabled, only draw when \a pDrawable is at
- * least partially visible. */
-void dmxPolyRectangle(DrawablePtr pDrawable, GCPtr pGC,
- int nrects, xRectangle *pRects)
-{
- DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
- dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
- Drawable draw;
-
- if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;
-
- DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
-
- XDrawRectangles(dmxScreen->beDisplay, draw, pGCPriv->gc,
- (XRectangle *)pRects, nrects);
-
- dmxSync(dmxScreen, FALSE);
-}
-
-/** Render list of arc outlines, \a parcs in \a pDrawable on the
- * back-end server associated with \a pDrawable's screen. If the
- * offscreen optimization is enabled, only draw when \a pDrawable is at
- * least partially visible. */
-void dmxPolyArc(DrawablePtr pDrawable, GCPtr pGC,
- int narcs, xArc *parcs)
-{
- DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
- dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
- Drawable draw;
-
- if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;
-
- DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
-
- XDrawArcs(dmxScreen->beDisplay, draw, pGCPriv->gc,
- (XArc *)parcs, narcs);
- dmxSync(dmxScreen, FALSE);
-}
-
-/** Render a filled polygons in \a pDrawable on the back-end server
- * associated with \a pDrawable's screen. If the offscreen
- * optimization is enabled, only draw when \a pDrawable is at least
- * partially visible. */
-void dmxFillPolygon(DrawablePtr pDrawable, GCPtr pGC,
- int shape, int mode, int count, DDXPointPtr pPts)
-{
- DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
- dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
- Drawable draw;
-
- if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;
-
- DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
-
- XFillPolygon(dmxScreen->beDisplay, draw, pGCPriv->gc,
- (XPoint *)pPts, count, shape, mode);
- dmxSync(dmxScreen, FALSE);
-}
-
-/** Render list of filled rectangles, \a prectInit in \a pDrawable on
- * the back-end server associated with \a pDrawable's screen. If the
- * offscreen optimization is enabled, only draw when \a pDrawable is at
- * least partially visible. */
-void dmxPolyFillRect(DrawablePtr pDrawable, GCPtr pGC,
- int nrectFill, xRectangle *prectInit)
-{
- DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
- dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
- Drawable draw;
-
- if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;
-
- DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
-
- XFillRectangles(dmxScreen->beDisplay, draw, pGCPriv->gc,
- (XRectangle *)prectInit, nrectFill);
- dmxSync(dmxScreen, FALSE);
-}
-
-/** Render list of filled arcs, \a parcs in \a pDrawable on the back-end
- * server associated with \a pDrawable's screen. If the offscreen
- * optimization is enabled, only draw when \a pDrawable is at least
- * partially visible. */
-void dmxPolyFillArc(DrawablePtr pDrawable, GCPtr pGC,
- int narcs, xArc *parcs)
-{
- DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
- dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
- Drawable draw;
-
- if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;
-
- DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
-
- XFillArcs(dmxScreen->beDisplay, draw, pGCPriv->gc,
- (XArc *)parcs, narcs);
- dmxSync(dmxScreen, FALSE);
-}
-
-/** Render string of 8-bit \a chars (foreground only) in \a pDrawable on
- * the back-end server associated with \a pDrawable's screen. If the
- * offscreen optimization is enabled, only draw when \a pDrawable is at
- * least partially visible. */
-int dmxPolyText8(DrawablePtr pDrawable, GCPtr pGC,
- int x, int y, int count, char *chars)
-{
- DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
- dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
- unsigned long n, i;
- int w;
- CharInfoPtr charinfo[255];
- Drawable draw;
-
- GetGlyphs(pGC->font, (unsigned long)count, (unsigned char *)chars,
- Linear8Bit, &n, charinfo);
-
- /* Calculate text width */
- w = 0;
- for (i = 0; i < n; i++) w += charinfo[i]->metrics.characterWidth;
-
- if (n != 0 && !DMX_GCOPS_OFFSCREEN(pDrawable)) {
- DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
-
- XDrawString(dmxScreen->beDisplay, draw, pGCPriv->gc,
- x, y, chars, count);
- dmxSync(dmxScreen, FALSE);
- }
-
- return x+w;
-}
-
-/** Render string of 16-bit \a chars (foreground only) in \a pDrawable
- * on the back-end server associated with \a pDrawable's screen. If
- * the offscreen optimization is enabled, only draw when \a pDrawable
- * is at least partially visible. */
-int dmxPolyText16(DrawablePtr pDrawable, GCPtr pGC,
- int x, int y, int count, unsigned short *chars)
-{
- DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
- dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
- unsigned long n, i;
- int w;
- CharInfoPtr charinfo[255];
- Drawable draw;
-
- GetGlyphs(pGC->font, (unsigned long)count, (unsigned char *)chars,
- (FONTLASTROW(pGC->font) == 0) ? Linear16Bit : TwoD16Bit,
- &n, charinfo);
-
- /* Calculate text width */
- w = 0;
- for (i = 0; i < n; i++) w += charinfo[i]->metrics.characterWidth;
-
- if (n != 0 && !DMX_GCOPS_OFFSCREEN(pDrawable)) {
- DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
-
- XDrawString16(dmxScreen->beDisplay, draw, pGCPriv->gc,
- x, y, (XChar2b *)chars, count);
- dmxSync(dmxScreen, FALSE);
- }
-
- return x+w;
-}
-
-/** Render string of 8-bit \a chars (both foreground and background) in
- * \a pDrawable on the back-end server associated with \a pDrawable's
- * screen. If the offscreen optimization is enabled, only draw when \a
- * pDrawable is at least partially visible. */
-void dmxImageText8(DrawablePtr pDrawable, GCPtr pGC,
- int x, int y, int count, char *chars)
-{
- DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
- dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
- Drawable draw;
-
- if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;
-
- DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
-
- XDrawImageString(dmxScreen->beDisplay, draw, pGCPriv->gc,
- x, y, chars, count);
- dmxSync(dmxScreen, FALSE);
-}
-
-/** Render string of 16-bit \a chars (both foreground and background) in
- * \a pDrawable on the back-end server associated with \a pDrawable's
- * screen. If the offscreen optimization is enabled, only draw when \a
- * pDrawable is at least partially visible. */
-void dmxImageText16(DrawablePtr pDrawable, GCPtr pGC,
- int x, int y, int count, unsigned short *chars)
-{
- DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
- dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
- Drawable draw;
-
- if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;
-
- DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
-
- XDrawImageString16(dmxScreen->beDisplay, draw, pGCPriv->gc,
- x, y, (XChar2b *)chars, count);
- dmxSync(dmxScreen, FALSE);
-}
-
-/** Image Glyph Blt -- this function should never be called. */
-void dmxImageGlyphBlt(DrawablePtr pDrawable, GCPtr pGC,
- int x, int y, unsigned int nglyph,
- CharInfoPtr *ppci, pointer pglyphBase)
-{
- /* Error -- this should never happen! */
-}
-
-/** Poly Glyph Blt -- this function should never be called. */
-void dmxPolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC,
- int x, int y, unsigned int nglyph,
- CharInfoPtr *ppci, pointer pglyphBase)
-{
- /* Error -- this should never happen! */
-}
-
-/** Push Pixels -- this function should never be called. */
-void dmxPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDst,
- int w, int h, int x, int y)
-{
- /* Error -- this should never happen! */
-}
-
-/**********************************************************************
- * Miscellaneous drawing commands
- */
-
-/** When Xinerama is active, the client pixmaps are always obtained from
- * screen 0. When screen 0 is detached, the pixmaps must be obtained
- * from any other screen that is not detached. Usually, this is screen
- * 1. */
-static DMXScreenInfo *dmxFindAlternatePixmap(DrawablePtr pDrawable, XID *draw)
-{
-#ifdef PANORAMIX
- PanoramiXRes *pXinPix;
- int i;
- DMXScreenInfo *dmxScreen;
-
- if (noPanoramiXExtension) return NULL;
- if (pDrawable->type != DRAWABLE_PIXMAP) return NULL;
-
- if (Success != dixLookupResourceByType((pointer*) &pXinPix,
- pDrawable->id, XRT_PIXMAP,
- NullClient, DixUnknownAccess))
- return NULL;
-
- FOR_NSCREENS_FORWARD_SKIP(i) {
- dmxScreen = &dmxScreens[i];
- if (dmxScreen->beDisplay) {
- PixmapPtr pSrc;
- dmxPixPrivPtr pSrcPriv;
-
- dixLookupResourceByType((pointer*) &pSrc, pXinPix->info[i].id,
- RT_PIXMAP, NullClient, DixUnknownAccess);
- pSrcPriv = DMX_GET_PIXMAP_PRIV(pSrc);
- if (pSrcPriv->pixmap) {
- *draw = pSrcPriv->pixmap;
- return dmxScreen;
- }
- }
- }
-#endif
- return NULL;
-}
-
-/** Get an image from the back-end server associated with \a pDrawable's
- * screen. If \a pDrawable is a window, it must be viewable to get an
- * image from it. If it is not viewable, then get the image from the
- * first ancestor of \a pDrawable that is viewable. If no viewable
- * ancestor is found, then simply return without getting an image. */
-void dmxGetImage(DrawablePtr pDrawable, int sx, int sy, int w, int h,
- unsigned int format, unsigned long planeMask, char *pdstLine)
-{
- DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
- XImage *img;
- Drawable draw;
-
- /* Cannot get image from unviewable window */
- if (pDrawable->type == DRAWABLE_WINDOW) {
- WindowPtr pWindow = (WindowPtr)pDrawable;
- if (!pWindow->viewable) {
- while (!pWindow->viewable && pWindow->parent) {
- sx += pWindow->origin.x - wBorderWidth(pWindow);
- sx += pWindow->origin.y - wBorderWidth(pWindow);
- pWindow = pWindow->parent;
- }
- if (!pWindow->viewable) {
- return;
- }
- }
- DMX_GCOPS_SET_DRAWABLE(&pWindow->drawable, draw);
- if (DMX_GCOPS_OFFSCREEN(&pWindow->drawable))
- return;
- } else {
- DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
- if (DMX_GCOPS_OFFSCREEN(pDrawable)) {
- /* Try to find the pixmap on a non-detached Xinerama screen */
- dmxScreen = dmxFindAlternatePixmap(pDrawable, &draw);
- if (!dmxScreen) return;
- }
- }
-
- img = XGetImage(dmxScreen->beDisplay, draw,
- sx, sy, w, h, planeMask, format);
- if (img) {
- int len = img->bytes_per_line * img->height;
- memmove(pdstLine, img->data, len);
- XDestroyImage(img);
- }
-
- dmxSync(dmxScreen, FALSE);
-}
-
-/** Get Spans -- this function should never be called. */
-void dmxGetSpans(DrawablePtr pDrawable, int wMax,
- DDXPointPtr ppt, int *pwidth, int nspans,
- char *pdstStart)
-{
- /* Error -- this should never happen! */
-}
+/*
+ * 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>
+ *
+ */
+
+/** \file
+ * This file provides support for GC operations. */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmx.h"
+#include "dmxsync.h"
+#include "dmxgc.h"
+#include "dmxgcops.h"
+#include "dmxwindow.h"
+#include "dmxpixmap.h"
+
+#include "mi.h"
+#include "gcstruct.h"
+#include "pixmapstr.h"
+#include "dixfontstr.h"
+
+#ifdef PANORAMIX
+#include "panoramiXsrv.h"
+#endif
+
+#define DMX_GCOPS_SET_DRAWABLE(_pDraw, _draw) \
+do { \
+ if ((_pDraw)->type == DRAWABLE_WINDOW) { \
+ dmxWinPrivPtr pWinPriv = \
+ DMX_GET_WINDOW_PRIV((WindowPtr)(_pDraw)); \
+ (_draw) = (Drawable)pWinPriv->window; \
+ } else { \
+ dmxPixPrivPtr pPixPriv = \
+ DMX_GET_PIXMAP_PRIV((PixmapPtr)(_pDraw)); \
+ (_draw) = (Drawable)pPixPriv->pixmap; \
+ } \
+} while (0)
+
+#define DMX_GCOPS_OFFSCREEN(_pDraw) \
+ (!dmxScreens[(_pDraw)->pScreen->myNum].beDisplay || \
+ (dmxOffScreenOpt && \
+ (_pDraw)->type == DRAWABLE_WINDOW && \
+ (DMX_GET_WINDOW_PRIV((WindowPtr)(_pDraw))->offscreen || \
+ !DMX_GET_WINDOW_PRIV((WindowPtr)(_pDraw))->window)))
+
+/** Fill spans -- this function should never be called. */
+void dmxFillSpans(DrawablePtr pDrawable, GCPtr pGC,
+ int nInit, DDXPointPtr pptInit, int *pwidthInit,
+ int fSorted)
+{
+ /* Error -- this should never happen! */
+}
+
+/** Set spans -- this function should never be called. */
+void dmxSetSpans(DrawablePtr pDrawable, GCPtr pGC,
+ char *psrc, DDXPointPtr ppt, int *pwidth, int nspans,
+ int fSorted)
+{
+ /* Error -- this should never happen! */
+}
+
+/** Transfer \a pBits image to back-end server associated with \a
+ * pDrawable's screen. If primitive subdivision optimization is
+ * enabled, then only transfer the sections of \a pBits that are
+ * visible (i.e., not-clipped) to the back-end server. */
+void dmxPutImage(DrawablePtr pDrawable, GCPtr pGC,
+ int depth, int x, int y, int w, int h,
+ int leftPad, int format, char *pBits)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ XImage *img;
+
+ if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;
+
+ img = XCreateImage(dmxScreen->beDisplay,
+ dmxScreen->beVisuals[dmxScreen->beDefVisualIndex].visual,
+ depth, format, leftPad, pBits, w, h,
+ BitmapPad(dmxScreen->beDisplay),
+ (format == ZPixmap) ?
+ PixmapBytePad(w, depth) : BitmapBytePad(w+leftPad));
+
+ if (img) {
+ Drawable draw;
+
+ DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
+
+ if (dmxSubdividePrimitives && pGC->pCompositeClip) {
+ RegionPtr pSubImages;
+ RegionPtr pClip;
+ BoxRec box;
+ BoxPtr pBox;
+ int nBox;
+
+ box.x1 = x;
+ box.y1 = y;
+ box.x2 = x + w;
+ box.y2 = y + h;
+ pSubImages = RegionCreate(&box, 1);
+
+ pClip = RegionCreate(NullBox, 1);
+ RegionCopy(pClip, pGC->pCompositeClip);
+ RegionTranslate(pClip,
+ -pDrawable->x, -pDrawable->y);
+ RegionIntersect(pSubImages, pSubImages, pClip);
+
+ nBox = RegionNumRects(pSubImages);
+ pBox = RegionRects(pSubImages);
+
+ while (nBox--) {
+ XPutImage(dmxScreen->beDisplay, draw, pGCPriv->gc, img,
+ pBox->x1 - box.x1,
+ pBox->y1 - box.y1,
+ pBox->x1,
+ pBox->y1,
+ pBox->x2 - pBox->x1,
+ pBox->y2 - pBox->y1);
+ pBox++;
+ }
+ RegionDestroy(pClip);
+ RegionDestroy(pSubImages);
+ } else {
+ XPutImage(dmxScreen->beDisplay, draw, pGCPriv->gc,
+ img, 0, 0, x, y, w, h);
+ }
+ XFree(img); /* Use XFree instead of XDestroyImage
+ * because pBits is passed in from the
+ * caller. */
+
+ dmxSync(dmxScreen, FALSE);
+ } else {
+ /* Error -- this should not happen! */
+ }
+}
+
+/** Copy area from \a pSrc drawable to \a pDst drawable on the back-end
+ * server associated with \a pSrc drawable's screen. If the offscreen
+ * optimization is enabled, only copy when both \a pSrc and \a pDst are
+ * at least partially visible. */
+RegionPtr dmxCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
+ int srcx, int srcy, int w, int h, int dstx, int dsty)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pSrc->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ Drawable srcDraw, dstDraw;
+
+ if (DMX_GCOPS_OFFSCREEN(pSrc) || DMX_GCOPS_OFFSCREEN(pDst))
+ return miHandleExposures(pSrc, pDst, pGC, srcx, srcy, w, h,
+ dstx, dsty, 0L);
+
+ DMX_GCOPS_SET_DRAWABLE(pSrc, srcDraw);
+ DMX_GCOPS_SET_DRAWABLE(pDst, dstDraw);
+
+ XCopyArea(dmxScreen->beDisplay, srcDraw, dstDraw, pGCPriv->gc,
+ srcx, srcy, w, h, dstx, dsty);
+ dmxSync(dmxScreen, FALSE);
+
+ return miHandleExposures(pSrc, pDst, pGC, srcx, srcy, w, h,
+ dstx, dsty, 0L);
+}
+
+/** Copy plane number \a bitPlane from \a pSrc drawable to \a pDst
+ * drawable on the back-end server associated with \a pSrc drawable's
+ * screen. If the offscreen optimization is enabled, only copy when
+ * both \a pSrc and \a pDst are at least partially visible. */
+RegionPtr dmxCopyPlane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
+ int srcx, int srcy, int width, int height,
+ int dstx, int dsty, unsigned long bitPlane)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pSrc->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ Drawable srcDraw, dstDraw;
+
+ if (DMX_GCOPS_OFFSCREEN(pSrc) || DMX_GCOPS_OFFSCREEN(pDst))
+ return miHandleExposures(pSrc, pDst, pGC, srcx, srcy, width, height,
+ dstx, dsty, bitPlane);
+
+ DMX_GCOPS_SET_DRAWABLE(pSrc, srcDraw);
+ DMX_GCOPS_SET_DRAWABLE(pDst, dstDraw);
+
+ XCopyPlane(dmxScreen->beDisplay, srcDraw, dstDraw, pGCPriv->gc,
+ srcx, srcy, width, height, dstx, dsty, bitPlane);
+ dmxSync(dmxScreen, FALSE);
+
+ return miHandleExposures(pSrc, pDst, pGC, srcx, srcy, width, height,
+ dstx, dsty, bitPlane);
+}
+
+/** Render list of points, \a pptInit in \a pDrawable on the back-end
+ * server associated with \a pDrawable's screen. If the offscreen
+ * optimization is enabled, only draw when \a pDrawable is at least
+ * partially visible. */
+void dmxPolyPoint(DrawablePtr pDrawable, GCPtr pGC,
+ int mode, int npt, DDXPointPtr pptInit)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ Drawable draw;
+
+ if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;
+
+ DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
+
+ XDrawPoints(dmxScreen->beDisplay, draw, pGCPriv->gc,
+ (XPoint *)pptInit, npt, mode);
+ dmxSync(dmxScreen, FALSE);
+}
+
+/** Render list of connected lines, \a pptInit in \a pDrawable on the
+ * back-end server associated with \a pDrawable's screen. If the
+ * offscreen optimization is enabled, only draw when \a pDrawable is at
+ * least partially visible. */
+void dmxPolylines(DrawablePtr pDrawable, GCPtr pGC,
+ int mode, int npt, DDXPointPtr pptInit)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ Drawable draw;
+
+ if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;
+
+ DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
+
+ XDrawLines(dmxScreen->beDisplay, draw, pGCPriv->gc,
+ (XPoint *)pptInit, npt, mode);
+ dmxSync(dmxScreen, FALSE);
+}
+
+/** Render list of disjoint segments, \a pSegs in \a pDrawable on the
+ * back-end server associated with \a pDrawable's screen. If the
+ * offscreen optimization is enabled, only draw when \a pDrawable is at
+ * least partially visible. */
+void dmxPolySegment(DrawablePtr pDrawable, GCPtr pGC,
+ int nseg, xSegment *pSegs)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ Drawable draw;
+
+ if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;
+
+ DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
+
+ XDrawSegments(dmxScreen->beDisplay, draw, pGCPriv->gc,
+ (XSegment *)pSegs, nseg);
+ dmxSync(dmxScreen, FALSE);
+}
+
+/** Render list of rectangle outlines, \a pRects in \a pDrawable on the
+ * back-end server associated with \a pDrawable's screen. If the
+ * offscreen optimization is enabled, only draw when \a pDrawable is at
+ * least partially visible. */
+void dmxPolyRectangle(DrawablePtr pDrawable, GCPtr pGC,
+ int nrects, xRectangle *pRects)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ Drawable draw;
+
+ if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;
+
+ DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
+
+ XDrawRectangles(dmxScreen->beDisplay, draw, pGCPriv->gc,
+ (XRectangle *)pRects, nrects);
+
+ dmxSync(dmxScreen, FALSE);
+}
+
+/** Render list of arc outlines, \a parcs in \a pDrawable on the
+ * back-end server associated with \a pDrawable's screen. If the
+ * offscreen optimization is enabled, only draw when \a pDrawable is at
+ * least partially visible. */
+void dmxPolyArc(DrawablePtr pDrawable, GCPtr pGC,
+ int narcs, xArc *parcs)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ Drawable draw;
+
+ if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;
+
+ DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
+
+ XDrawArcs(dmxScreen->beDisplay, draw, pGCPriv->gc,
+ (XArc *)parcs, narcs);
+ dmxSync(dmxScreen, FALSE);
+}
+
+/** Render a filled polygons in \a pDrawable on the back-end server
+ * associated with \a pDrawable's screen. If the offscreen
+ * optimization is enabled, only draw when \a pDrawable is at least
+ * partially visible. */
+void dmxFillPolygon(DrawablePtr pDrawable, GCPtr pGC,
+ int shape, int mode, int count, DDXPointPtr pPts)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ Drawable draw;
+
+ if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;
+
+ DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
+
+ XFillPolygon(dmxScreen->beDisplay, draw, pGCPriv->gc,
+ (XPoint *)pPts, count, shape, mode);
+ dmxSync(dmxScreen, FALSE);
+}
+
+/** Render list of filled rectangles, \a prectInit in \a pDrawable on
+ * the back-end server associated with \a pDrawable's screen. If the
+ * offscreen optimization is enabled, only draw when \a pDrawable is at
+ * least partially visible. */
+void dmxPolyFillRect(DrawablePtr pDrawable, GCPtr pGC,
+ int nrectFill, xRectangle *prectInit)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ Drawable draw;
+
+ if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;
+
+ DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
+
+ XFillRectangles(dmxScreen->beDisplay, draw, pGCPriv->gc,
+ (XRectangle *)prectInit, nrectFill);
+ dmxSync(dmxScreen, FALSE);
+}
+
+/** Render list of filled arcs, \a parcs in \a pDrawable on the back-end
+ * server associated with \a pDrawable's screen. If the offscreen
+ * optimization is enabled, only draw when \a pDrawable is at least
+ * partially visible. */
+void dmxPolyFillArc(DrawablePtr pDrawable, GCPtr pGC,
+ int narcs, xArc *parcs)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ Drawable draw;
+
+ if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;
+
+ DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
+
+ XFillArcs(dmxScreen->beDisplay, draw, pGCPriv->gc,
+ (XArc *)parcs, narcs);
+ dmxSync(dmxScreen, FALSE);
+}
+
+/** Render string of 8-bit \a chars (foreground only) in \a pDrawable on
+ * the back-end server associated with \a pDrawable's screen. If the
+ * offscreen optimization is enabled, only draw when \a pDrawable is at
+ * least partially visible. */
+int dmxPolyText8(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, int count, char *chars)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ unsigned long n, i;
+ int w;
+ CharInfoPtr charinfo[255];
+ Drawable draw;
+
+ GetGlyphs(pGC->font, (unsigned long)count, (unsigned char *)chars,
+ Linear8Bit, &n, charinfo);
+
+ /* Calculate text width */
+ w = 0;
+ for (i = 0; i < n; i++) w += charinfo[i]->metrics.characterWidth;
+
+ if (n != 0 && !DMX_GCOPS_OFFSCREEN(pDrawable)) {
+ DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
+
+ XDrawString(dmxScreen->beDisplay, draw, pGCPriv->gc,
+ x, y, chars, count);
+ dmxSync(dmxScreen, FALSE);
+ }
+
+ return x+w;
+}
+
+/** Render string of 16-bit \a chars (foreground only) in \a pDrawable
+ * on the back-end server associated with \a pDrawable's screen. If
+ * the offscreen optimization is enabled, only draw when \a pDrawable
+ * is at least partially visible. */
+int dmxPolyText16(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, int count, unsigned short *chars)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ unsigned long n, i;
+ int w;
+ CharInfoPtr charinfo[255];
+ Drawable draw;
+
+ GetGlyphs(pGC->font, (unsigned long)count, (unsigned char *)chars,
+ (FONTLASTROW(pGC->font) == 0) ? Linear16Bit : TwoD16Bit,
+ &n, charinfo);
+
+ /* Calculate text width */
+ w = 0;
+ for (i = 0; i < n; i++) w += charinfo[i]->metrics.characterWidth;
+
+ if (n != 0 && !DMX_GCOPS_OFFSCREEN(pDrawable)) {
+ DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
+
+ XDrawString16(dmxScreen->beDisplay, draw, pGCPriv->gc,
+ x, y, (XChar2b *)chars, count);
+ dmxSync(dmxScreen, FALSE);
+ }
+
+ return x+w;
+}
+
+/** Render string of 8-bit \a chars (both foreground and background) in
+ * \a pDrawable on the back-end server associated with \a pDrawable's
+ * screen. If the offscreen optimization is enabled, only draw when \a
+ * pDrawable is at least partially visible. */
+void dmxImageText8(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, int count, char *chars)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ Drawable draw;
+
+ if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;
+
+ DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
+
+ XDrawImageString(dmxScreen->beDisplay, draw, pGCPriv->gc,
+ x, y, chars, count);
+ dmxSync(dmxScreen, FALSE);
+}
+
+/** Render string of 16-bit \a chars (both foreground and background) in
+ * \a pDrawable on the back-end server associated with \a pDrawable's
+ * screen. If the offscreen optimization is enabled, only draw when \a
+ * pDrawable is at least partially visible. */
+void dmxImageText16(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, int count, unsigned short *chars)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
+ dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC);
+ Drawable draw;
+
+ if (DMX_GCOPS_OFFSCREEN(pDrawable)) return;
+
+ DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
+
+ XDrawImageString16(dmxScreen->beDisplay, draw, pGCPriv->gc,
+ x, y, (XChar2b *)chars, count);
+ dmxSync(dmxScreen, FALSE);
+}
+
+/** Image Glyph Blt -- this function should never be called. */
+void dmxImageGlyphBlt(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, unsigned int nglyph,
+ CharInfoPtr *ppci, pointer pglyphBase)
+{
+ /* Error -- this should never happen! */
+}
+
+/** Poly Glyph Blt -- this function should never be called. */
+void dmxPolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, unsigned int nglyph,
+ CharInfoPtr *ppci, pointer pglyphBase)
+{
+ /* Error -- this should never happen! */
+}
+
+/** Push Pixels -- this function should never be called. */
+void dmxPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDst,
+ int w, int h, int x, int y)
+{
+ /* Error -- this should never happen! */
+}
+
+/**********************************************************************
+ * Miscellaneous drawing commands
+ */
+
+/** When Xinerama is active, the client pixmaps are always obtained from
+ * screen 0. When screen 0 is detached, the pixmaps must be obtained
+ * from any other screen that is not detached. Usually, this is screen
+ * 1. */
+static DMXScreenInfo *dmxFindAlternatePixmap(DrawablePtr pDrawable, XID *draw)
+{
+#ifdef PANORAMIX
+ PanoramiXRes *pXinPix;
+ int i;
+ DMXScreenInfo *dmxScreen;
+
+ if (noPanoramiXExtension) return NULL;
+ if (pDrawable->type != DRAWABLE_PIXMAP) return NULL;
+
+ if (Success != dixLookupResourceByType((pointer*) &pXinPix,
+ pDrawable->id, XRT_PIXMAP,
+ NullClient, DixUnknownAccess))
+ return NULL;
+
+ FOR_NSCREENS_FORWARD_SKIP(i) {
+ dmxScreen = &dmxScreens[i];
+ if (dmxScreen->beDisplay) {
+ PixmapPtr pSrc;
+ dmxPixPrivPtr pSrcPriv;
+
+ dixLookupResourceByType((pointer*) &pSrc, pXinPix->info[i].id,
+ RT_PIXMAP, NullClient, DixUnknownAccess);
+ pSrcPriv = DMX_GET_PIXMAP_PRIV(pSrc);
+ if (pSrcPriv->pixmap) {
+ *draw = pSrcPriv->pixmap;
+ return dmxScreen;
+ }
+ }
+ }
+#endif
+ return NULL;
+}
+
+/** Get an image from the back-end server associated with \a pDrawable's
+ * screen. If \a pDrawable is a window, it must be viewable to get an
+ * image from it. If it is not viewable, then get the image from the
+ * first ancestor of \a pDrawable that is viewable. If no viewable
+ * ancestor is found, then simply return without getting an image. */
+void dmxGetImage(DrawablePtr pDrawable, int sx, int sy, int w, int h,
+ unsigned int format, unsigned long planeMask, char *pdstLine)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pDrawable->pScreen->myNum];
+ XImage *img;
+ Drawable draw;
+
+ /* Cannot get image from unviewable window */
+ if (pDrawable->type == DRAWABLE_WINDOW) {
+ WindowPtr pWindow = (WindowPtr)pDrawable;
+ if (!pWindow->viewable) {
+ while (!pWindow->viewable && pWindow->parent) {
+ sx += pWindow->origin.x - wBorderWidth(pWindow);
+ sx += pWindow->origin.y - wBorderWidth(pWindow);
+ pWindow = pWindow->parent;
+ }
+ if (!pWindow->viewable) {
+ return;
+ }
+ }
+ DMX_GCOPS_SET_DRAWABLE(&pWindow->drawable, draw);
+ if (DMX_GCOPS_OFFSCREEN(&pWindow->drawable))
+ return;
+ } else {
+ DMX_GCOPS_SET_DRAWABLE(pDrawable, draw);
+ if (DMX_GCOPS_OFFSCREEN(pDrawable)) {
+ /* Try to find the pixmap on a non-detached Xinerama screen */
+ dmxScreen = dmxFindAlternatePixmap(pDrawable, &draw);
+ if (!dmxScreen) return;
+ }
+ }
+
+ img = XGetImage(dmxScreen->beDisplay, draw,
+ sx, sy, w, h, planeMask, format);
+ if (img) {
+ int len = img->bytes_per_line * img->height;
+ memmove(pdstLine, img->data, len);
+ XDestroyImage(img);
+ }
+
+ dmxSync(dmxScreen, FALSE);
+}
+
+/** Get Spans -- this function should never be called. */
+void dmxGetSpans(DrawablePtr pDrawable, int wMax,
+ DDXPointPtr ppt, int *pwidth, int nspans,
+ char *pdstStart)
+{
+ /* Error -- this should never happen! */
+}
diff --git a/xorg-server/hw/dmx/dmxwindow.c b/xorg-server/hw/dmx/dmxwindow.c
index 16b79b830..704fcff54 100644
--- a/xorg-server/hw/dmx/dmxwindow.c
+++ b/xorg-server/hw/dmx/dmxwindow.c
@@ -1,1017 +1,1017 @@
-/*
- * 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>
- *
- */
-
-/** \file
- * This file provides support for window-related functions. */
-
-#ifdef HAVE_DMX_CONFIG_H
-#include <dmx-config.h>
-#endif
-
-#include "dmx.h"
-#include "dmxsync.h"
-#include "dmxwindow.h"
-#include "dmxpixmap.h"
-#include "dmxcmap.h"
-#include "dmxvisual.h"
-#include "dmxinput.h"
-#include "dmxextension.h"
-#include "dmxpict.h"
-
-#include "windowstr.h"
-
-static void dmxDoRestackWindow(WindowPtr pWindow);
-static void dmxDoChangeWindowAttributes(WindowPtr pWindow,
- unsigned long *mask,
- XSetWindowAttributes *attribs);
-
-static void dmxDoSetShape(WindowPtr pWindow);
-
-/** Initialize the private area for the window functions. */
-Bool dmxInitWindow(ScreenPtr pScreen)
-{
- if (!dixRegisterPrivateKey(&dmxWinPrivateKeyRec, PRIVATE_WINDOW, sizeof(dmxWinPrivRec)))
- return FALSE;
-
- return TRUE;
-}
-
-
-Window dmxCreateRootWindow(WindowPtr pWindow)
-{
- ScreenPtr pScreen = pWindow->drawable.pScreen;
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
- dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
- Window parent;
- Visual *visual;
- unsigned long mask;
- XSetWindowAttributes attribs;
- ColormapPtr pCmap;
- dmxColormapPrivPtr pCmapPriv;
-
- /* Create root window */
-
- parent = dmxScreen->scrnWin; /* This is our "Screen" window */
- visual = dmxScreen->beVisuals[dmxScreen->beDefVisualIndex].visual;
-
- dixLookupResourceByType((pointer*) &pCmap, wColormap(pWindow),
- RT_COLORMAP, NullClient, DixUnknownAccess);
- pCmapPriv = DMX_GET_COLORMAP_PRIV(pCmap);
-
- mask = CWEventMask | CWBackingStore | CWColormap | CWBorderPixel;
- attribs.event_mask = ExposureMask;
- attribs.backing_store = NotUseful;
- attribs.colormap = pCmapPriv->cmap;
- attribs.border_pixel = 0;
-
- /* Incorporate new attributes, if needed */
- if (pWinPriv->attribMask) {
- dmxDoChangeWindowAttributes(pWindow, &pWinPriv->attribMask, &attribs);
- mask |= pWinPriv->attribMask;
- }
-
- return XCreateWindow(dmxScreen->beDisplay,
- parent,
- pWindow->origin.x - wBorderWidth(pWindow),
- pWindow->origin.y - wBorderWidth(pWindow),
- pWindow->drawable.width,
- pWindow->drawable.height,
- pWindow->borderWidth,
- pWindow->drawable.depth,
- pWindow->drawable.class,
- visual,
- mask,
- &attribs);
-}
-
-/** Change the location and size of the "screen" window. Called from
- * dmxextension.c dmxConfigureScreenWindow(). */
-void dmxResizeScreenWindow(ScreenPtr pScreen,
- int x, int y, int w, int h)
-{
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
- unsigned int m;
- XWindowChanges c;
-
- if (!dmxScreen->beDisplay)
- return;
-
- /* Handle resizing on back-end server */
- m = CWX | CWY | CWWidth | CWHeight;
- c.x = x;
- c.y = y;
- c.width = w;
- c.height = h;
-
- XConfigureWindow(dmxScreen->beDisplay, dmxScreen->scrnWin, m, &c);
- dmxSync(dmxScreen, False);
-}
-
-/** Change the location and size of the "root" window. Called from
- * #dmxCreateWindow. */
-void dmxResizeRootWindow(WindowPtr pRoot,
- int x, int y, int w, int h)
-{
- DMXScreenInfo *dmxScreen = &dmxScreens[pRoot->drawable.pScreen->myNum];
- dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pRoot);
- unsigned int m;
- XWindowChanges c;
-
- /* Handle resizing on back-end server */
- if (dmxScreen->beDisplay) {
- m = CWX | CWY | CWWidth | CWHeight;
- c.x = x;
- c.y = y;
- c.width = (w > 0) ? w : 1;
- c.height = (h > 0) ? h : 1;
-
- XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
- }
-
- if (w == 0 || h == 0) {
- if (pWinPriv->mapped) {
- if (dmxScreen->beDisplay)
- XUnmapWindow(dmxScreen->beDisplay, pWinPriv->window);
- pWinPriv->mapped = FALSE;
- }
- } else if (!pWinPriv->mapped) {
- if (dmxScreen->beDisplay)
- XMapWindow(dmxScreen->beDisplay, pWinPriv->window);
- pWinPriv->mapped = TRUE;
- }
-
- if (dmxScreen->beDisplay)
- dmxSync(dmxScreen, False);
-}
-
-void dmxGetDefaultWindowAttributes(WindowPtr pWindow,
- Colormap *cmap,
- Visual **visual)
-{
- ScreenPtr pScreen = pWindow->drawable.pScreen;
-
- if (pWindow->drawable.class != InputOnly &&
- pWindow->optional &&
- pWindow->optional->visual != wVisual(pWindow->parent)) {
-
- /* Find the matching visual */
- *visual = dmxLookupVisualFromID(pScreen, wVisual(pWindow));
-
- /* Handle optional colormaps */
- if (pWindow->optional->colormap) {
- ColormapPtr pCmap;
- dmxColormapPrivPtr pCmapPriv;
-
- dixLookupResourceByType((pointer*) &pCmap, wColormap(pWindow),
- RT_COLORMAP, NullClient, DixUnknownAccess);
- pCmapPriv = DMX_GET_COLORMAP_PRIV(pCmap);
- *cmap = pCmapPriv->cmap;
- } else {
- *cmap = dmxColormapFromDefaultVisual(pScreen, *visual);
- }
- } else {
- *visual = CopyFromParent;
- *cmap = (Colormap)0;
- }
-}
-
-static Window dmxCreateNonRootWindow(WindowPtr pWindow)
-{
- ScreenPtr pScreen = pWindow->drawable.pScreen;
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
- dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
- Window parent;
- unsigned long mask = 0L;
- XSetWindowAttributes attribs;
- dmxWinPrivPtr pParentPriv = DMX_GET_WINDOW_PRIV(pWindow->parent);
-
- /* Create window on back-end server */
-
- parent = pParentPriv->window;
-
- /* The parent won't exist if this call to CreateNonRootWindow came
- from ReparentWindow and the grandparent window has not yet been
- created */
- if (!parent) {
- dmxCreateAndRealizeWindow(pWindow->parent, FALSE);
- parent = pParentPriv->window;
- }
-
- /* Incorporate new attributes, if needed */
- if (pWinPriv->attribMask) {
- dmxDoChangeWindowAttributes(pWindow, &pWinPriv->attribMask, &attribs);
- mask |= pWinPriv->attribMask;
- }
-
- /* Add in default attributes */
- if (pWindow->drawable.class != InputOnly) {
- mask |= CWBackingStore;
- attribs.backing_store = NotUseful;
-
- if (!(mask & CWColormap) && pWinPriv->cmap) {
- mask |= CWColormap;
- attribs.colormap = pWinPriv->cmap;
- if (!(mask & CWBorderPixel)) {
- mask |= CWBorderPixel;
- attribs.border_pixel = 0;
- }
- }
- }
-
- /* Handle case where subwindows are being mapped, but created out of
- order -- if current window has a previous sibling, then it cannot
- be created on top of the stack, so we must restack the windows */
- pWinPriv->restacked = (pWindow->prevSib != NullWindow);
-
- return XCreateWindow(dmxScreen->beDisplay,
- parent,
- pWindow->origin.x - wBorderWidth(pWindow),
- pWindow->origin.y - wBorderWidth(pWindow),
- pWindow->drawable.width,
- pWindow->drawable.height,
- pWindow->borderWidth,
- pWindow->drawable.depth,
- pWindow->drawable.class,
- pWinPriv->visual,
- mask,
- &attribs);
-}
-
-/** This function handles lazy window creation and realization. Window
- * creation is handled by #dmxCreateNonRootWindow(). It also handles
- * any stacking changes that have occured since the window was
- * originally created by calling #dmxDoRestackWindow(). If the window
- * is shaped, the shape is set on the back-end server by calling
- * #dmxDoSetShape(), and if the window has pictures (from RENDER)
- * associated with it, those pictures are created on the back-end
- * server by calling #dmxCreatePictureList(). If \a doSync is TRUE,
- * then #dmxSync() is called. */
-void dmxCreateAndRealizeWindow(WindowPtr pWindow, Bool doSync)
-{
- ScreenPtr pScreen = pWindow->drawable.pScreen;
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
- dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
-
- if (!dmxScreen->beDisplay) return;
-
- pWinPriv->window = dmxCreateNonRootWindow(pWindow);
- if (pWinPriv->restacked) dmxDoRestackWindow(pWindow);
- if (pWinPriv->isShaped) dmxDoSetShape(pWindow);
- if (pWinPriv->hasPict) dmxCreatePictureList(pWindow);
- if (pWinPriv->mapped) XMapWindow(dmxScreen->beDisplay,
- pWinPriv->window);
- if (doSync) dmxSync(dmxScreen, False);
-}
-
-/** Create \a pWindow on the back-end server. If the lazy window
- * creation optimization is enabled, then the actual creation and
- * realization of the window is handled by
- * #dmxCreateAndRealizeWindow(). */
-Bool dmxCreateWindow(WindowPtr pWindow)
-{
- ScreenPtr pScreen = pWindow->drawable.pScreen;
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
- dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
- Bool ret = TRUE;
-
- DMX_UNWRAP(CreateWindow, dmxScreen, pScreen);
-#if 0
- if (pScreen->CreateWindow)
- ret = pScreen->CreateWindow(pWindow);
-#endif
-
- /* Set up the defaults */
- pWinPriv->window = (Window)0;
- pWinPriv->offscreen = TRUE;
- pWinPriv->mapped = FALSE;
- pWinPriv->restacked = FALSE;
- pWinPriv->attribMask = 0;
- pWinPriv->isShaped = FALSE;
- pWinPriv->hasPict = FALSE;
-#ifdef GLXEXT
- pWinPriv->swapGroup = NULL;
- pWinPriv->barrier = 0;
-#endif
-
- if (dmxScreen->beDisplay) {
- /* Only create the root window at this stage -- non-root windows are
- created when they are mapped and are on-screen */
- if (!pWindow->parent) {
- dmxScreen->rootWin = pWinPriv->window
- = dmxCreateRootWindow(pWindow);
- if (dmxScreen->scrnX != dmxScreen->rootX
- || dmxScreen->scrnY != dmxScreen->rootY
- || dmxScreen->scrnWidth != dmxScreen->rootWidth
- || dmxScreen->scrnHeight != dmxScreen->rootHeight) {
- dmxResizeRootWindow(pWindow,
- dmxScreen->rootX,
- dmxScreen->rootY,
- dmxScreen->rootWidth,
- dmxScreen->rootHeight);
- dmxUpdateScreenResources(screenInfo.screens[dmxScreen->index],
- dmxScreen->rootX,
- dmxScreen->rootY,
- dmxScreen->rootWidth,
- dmxScreen->rootHeight);
- pWindow->origin.x = dmxScreen->rootX;
- pWindow->origin.y = dmxScreen->rootY;
- }
- } else {
- dmxGetDefaultWindowAttributes(pWindow,
- &pWinPriv->cmap,
- &pWinPriv->visual);
-
- if (dmxLazyWindowCreation) {
- /* Save parent's visual for use later */
- if (pWinPriv->visual == CopyFromParent)
- pWinPriv->visual =
- dmxLookupVisualFromID(pScreen,
- wVisual(pWindow->parent));
- } else {
- pWinPriv->window = dmxCreateNonRootWindow(pWindow);
- }
- }
-
- dmxSync(dmxScreen, False);
- }
-
- DMX_WRAP(CreateWindow, dmxCreateWindow, dmxScreen, pScreen);
-
- return ret;
-}
-
-/** Destroy \a pWindow on the back-end server. */
-Bool dmxBEDestroyWindow(WindowPtr pWindow)
-{
- ScreenPtr pScreen = pWindow->drawable.pScreen;
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
- dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
-
- if (pWinPriv->window) {
- XDestroyWindow(dmxScreen->beDisplay, pWinPriv->window);
- pWinPriv->window = (Window)0;
- return TRUE;
- }
-
- return FALSE;
-}
-
-/** Destroy \a pWindow on the back-end server. If any RENDER pictures
- were created, destroy them as well. */
-Bool dmxDestroyWindow(WindowPtr pWindow)
-{
- ScreenPtr pScreen = pWindow->drawable.pScreen;
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
- Bool ret = TRUE;
- Bool needSync = FALSE;
-#ifdef GLXEXT
- dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
-#endif
-
- DMX_UNWRAP(DestroyWindow, dmxScreen, pScreen);
-
- /* Destroy any picture list associated with this window */
- needSync |= dmxDestroyPictureList(pWindow);
-
- /* Destroy window on back-end server */
- needSync |= dmxBEDestroyWindow(pWindow);
- if (needSync) dmxSync(dmxScreen, FALSE);
-
-#ifdef GLXEXT
- if (pWinPriv->swapGroup && pWinPriv->windowDestroyed)
- pWinPriv->windowDestroyed(pWindow);
-#endif
-
- if (pScreen->DestroyWindow)
- ret = pScreen->DestroyWindow(pWindow);
-
- DMX_WRAP(DestroyWindow, dmxDestroyWindow, dmxScreen, pScreen);
-
- return ret;
-}
-
-/** Change the position of \a pWindow to be \a x, \a y. */
-Bool dmxPositionWindow(WindowPtr pWindow, int x, int y)
-{
- ScreenPtr pScreen = pWindow->drawable.pScreen;
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
- Bool ret = TRUE;
- dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
- unsigned int m;
- XWindowChanges c;
-
- DMX_UNWRAP(PositionWindow, dmxScreen, pScreen);
-#if 0
- if (pScreen->PositionWindow)
- ret = pScreen->PositionWindow(pWindow, x, y);
-#endif
-
- /* Determine if the window is completely off the visible portion of
- the screen */
- pWinPriv->offscreen = DMX_WINDOW_OFFSCREEN(pWindow);
-
- /* If the window is now on-screen and it is mapped and it has not
- been created yet, create it and map it */
- if (!pWinPriv->window && pWinPriv->mapped && !pWinPriv->offscreen) {
- dmxCreateAndRealizeWindow(pWindow, TRUE);
- } else if (pWinPriv->window) {
- /* Position window on back-end server */
- m = CWX | CWY | CWWidth | CWHeight;
- c.x = pWindow->origin.x - wBorderWidth(pWindow);
- c.y = pWindow->origin.y - wBorderWidth(pWindow);
- c.width = pWindow->drawable.width;
- c.height = pWindow->drawable.height;
- if (pWindow->drawable.class != InputOnly) {
- m |= CWBorderWidth;
- c.border_width = pWindow->borderWidth;
- }
-
- XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
- dmxSync(dmxScreen, False);
- }
-
- DMX_WRAP(PositionWindow, dmxPositionWindow, dmxScreen, pScreen);
-
- return ret;
-}
-
-static void dmxDoChangeWindowAttributes(WindowPtr pWindow,
- unsigned long *mask,
- XSetWindowAttributes *attribs)
-{
- dmxPixPrivPtr pPixPriv;
-
- if (*mask & CWBackPixmap) {
- switch (pWindow->backgroundState) {
- case None:
- attribs->background_pixmap = None;
- break;
-
- case ParentRelative:
- attribs->background_pixmap = ParentRelative;
- break;
-
- case BackgroundPixmap:
- pPixPriv = DMX_GET_PIXMAP_PRIV(pWindow->background.pixmap);
- attribs->background_pixmap = pPixPriv->pixmap;
- break;
-
- case BackgroundPixel:
- *mask &= ~CWBackPixmap;
- break;
- }
- }
-
- if (*mask & CWBackPixel) {
- if (pWindow->backgroundState == BackgroundPixel)
- attribs->background_pixel = pWindow->background.pixel;
- else
- *mask &= ~CWBackPixel;
- }
-
- if (*mask & CWBorderPixmap) {
- if (pWindow->borderIsPixel)
- *mask &= ~CWBorderPixmap;
- else {
- pPixPriv = DMX_GET_PIXMAP_PRIV(pWindow->border.pixmap);
- attribs->border_pixmap = pPixPriv->pixmap;
- }
- }
-
- if (*mask & CWBorderPixel) {
- if (pWindow->borderIsPixel)
- attribs->border_pixel = pWindow->border.pixel;
- else
- *mask &= ~CWBorderPixel;
- }
-
- if (*mask & CWBitGravity)
- attribs->bit_gravity = pWindow->bitGravity;
-
- if (*mask & CWWinGravity)
- *mask &= ~CWWinGravity; /* Handled by dix */
-
- if (*mask & CWBackingStore)
- *mask &= ~CWBackingStore; /* Backing store not supported */
-
- if (*mask & CWBackingPlanes)
- *mask &= ~CWBackingPlanes; /* Backing store not supported */
-
- if (*mask & CWBackingPixel)
- *mask &= ~CWBackingPixel; /* Backing store not supported */
-
- if (*mask & CWOverrideRedirect)
- attribs->override_redirect = pWindow->overrideRedirect;
-
- if (*mask & CWSaveUnder)
- *mask &= ~CWSaveUnder; /* Save unders not supported */
-
- if (*mask & CWEventMask)
- *mask &= ~CWEventMask; /* Events are handled by dix */
-
- if (*mask & CWDontPropagate)
- *mask &= ~CWDontPropagate; /* Events are handled by dix */
-
- if (*mask & CWColormap) {
- ColormapPtr pCmap;
- dmxColormapPrivPtr pCmapPriv;
-
- dixLookupResourceByType((pointer*) &pCmap, wColormap(pWindow),
- RT_COLORMAP, NullClient, DixUnknownAccess);
- pCmapPriv = DMX_GET_COLORMAP_PRIV(pCmap);
- attribs->colormap = pCmapPriv->cmap;
- }
-
- if (*mask & CWCursor)
- *mask &= ~CWCursor; /* Handled by the cursor code */
-}
-
-/** Change the window attributes of \a pWindow. */
-Bool dmxChangeWindowAttributes(WindowPtr pWindow, unsigned long mask)
-{
- ScreenPtr pScreen = pWindow->drawable.pScreen;
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
- Bool ret = TRUE;
- dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
- XSetWindowAttributes attribs;
-
- DMX_UNWRAP(ChangeWindowAttributes, dmxScreen, pScreen);
-#if 0
- if (pScreen->ChangeWindowAttributes)
- ret = pScreen->ChangeWindowAttributes(pWindow, mask);
-#endif
-
- /* Change window attribs on back-end server */
- dmxDoChangeWindowAttributes(pWindow, &mask, &attribs);
-
- /* Save mask for lazy window creation optimization */
- pWinPriv->attribMask |= mask;
-
- if (mask && pWinPriv->window) {
- XChangeWindowAttributes(dmxScreen->beDisplay, pWinPriv->window,
- mask, &attribs);
- dmxSync(dmxScreen, False);
- }
-
- DMX_WRAP(ChangeWindowAttributes, dmxChangeWindowAttributes, dmxScreen,
- pScreen);
-
- return ret;
-}
-
-/** Realize \a pWindow on the back-end server. If the lazy window
- * creation optimization is enabled, the window is only realized when
- * it at least partially overlaps the screen. */
-Bool dmxRealizeWindow(WindowPtr pWindow)
-{
- ScreenPtr pScreen = pWindow->drawable.pScreen;
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
- Bool ret = TRUE;
- dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
-
- DMX_UNWRAP(RealizeWindow, dmxScreen, pScreen);
-#if 0
- if (pScreen->RealizeWindow)
- ret = pScreen->RealizeWindow(pWindow);
-#endif
-
- /* Determine if the window is completely off the visible portion of
- the screen */
- pWinPriv->offscreen = DMX_WINDOW_OFFSCREEN(pWindow);
-
- /* If the window hasn't been created and it's not offscreen, then
- create it */
- if (!pWinPriv->window && !pWinPriv->offscreen) {
- dmxCreateAndRealizeWindow(pWindow, FALSE);
- }
-
- if (pWinPriv->window) {
- /* Realize window on back-end server */
- XMapWindow(dmxScreen->beDisplay, pWinPriv->window);
- dmxSync(dmxScreen, False);
- }
-
- /* Let the other functions know that the window is now mapped */
- pWinPriv->mapped = TRUE;
-
- DMX_WRAP(RealizeWindow, dmxRealizeWindow, dmxScreen, pScreen);
-
- dmxUpdateWindowInfo(DMX_UPDATE_REALIZE, pWindow);
- return ret;
-}
-
-/** Unrealize \a pWindow on the back-end server. */
-Bool dmxUnrealizeWindow(WindowPtr pWindow)
-{
- ScreenPtr pScreen = pWindow->drawable.pScreen;
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
- Bool ret = TRUE;
- dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
-
- DMX_UNWRAP(UnrealizeWindow, dmxScreen, pScreen);
-#if 0
- if (pScreen->UnrealizeWindow)
- ret = pScreen->UnrealizeWindow(pWindow);
-#endif
-
- if (pWinPriv->window) {
- /* Unrealize window on back-end server */
- XUnmapWindow(dmxScreen->beDisplay, pWinPriv->window);
- dmxSync(dmxScreen, False);
- }
-
- /* When unrealized (i.e., unmapped), the window is always considered
- off of the visible portion of the screen */
- pWinPriv->offscreen = TRUE;
- pWinPriv->mapped = FALSE;
-
-#ifdef GLXEXT
- if (pWinPriv->swapGroup && pWinPriv->windowUnmapped)
- pWinPriv->windowUnmapped(pWindow);
-#endif
-
- DMX_WRAP(UnrealizeWindow, dmxUnrealizeWindow, dmxScreen, pScreen);
-
- dmxUpdateWindowInfo(DMX_UPDATE_UNREALIZE, pWindow);
- return ret;
-}
-
-static void dmxDoRestackWindow(WindowPtr pWindow)
-{
- ScreenPtr pScreen = pWindow->drawable.pScreen;
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
- dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
- WindowPtr pNextSib = pWindow->nextSib;
- unsigned int m;
- XWindowChanges c;
-
- if (pNextSib == NullWindow) {
- /* Window is at the bottom of the stack */
- m = CWStackMode;
- c.sibling = (Window)0;
- c.stack_mode = Below;
- XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
- } else {
- /* Window is not at the bottom of the stack */
- dmxWinPrivPtr pNextSibPriv = DMX_GET_WINDOW_PRIV(pNextSib);
-
- /* Handle case where siblings have not yet been created due to
- lazy window creation optimization by first finding the next
- sibling in the sibling list that has been created (if any)
- and then putting the current window just above that sibling,
- and if no next siblings have been created yet, then put it at
- the bottom of the stack (since it might have a previous
- sibling that should be above it). */
- while (!pNextSibPriv->window) {
- pNextSib = pNextSib->nextSib;
- if (pNextSib == NullWindow) {
- /* Window is at the bottom of the stack */
- m = CWStackMode;
- c.sibling = (Window)0;
- c.stack_mode = Below;
- XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
- return;
- }
- pNextSibPriv = DMX_GET_WINDOW_PRIV(pNextSib);
- }
-
- m = CWStackMode | CWSibling;
- c.sibling = pNextSibPriv->window;
- c.stack_mode = Above;
- XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
- }
-}
-
-/** Handle window restacking. The actual restacking occurs in
- * #dmxDoRestackWindow(). */
-void dmxRestackWindow(WindowPtr pWindow, WindowPtr pOldNextSib)
-{
- ScreenPtr pScreen = pWindow->drawable.pScreen;
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
- dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
-
- DMX_UNWRAP(RestackWindow, dmxScreen, pScreen);
-#if 0
- if (pScreen->RestackWindow)
- pScreen->RestackWindow(pWindow, pOldNextSib);
-#endif
-
- if (pOldNextSib != pWindow->nextSib) {
- /* Track restacking for lazy window creation optimization */
- pWinPriv->restacked = TRUE;
-
- /* Restack window on back-end server */
- if (pWinPriv->window) {
- dmxDoRestackWindow(pWindow);
- dmxSync(dmxScreen, False);
- }
- }
-
- DMX_WRAP(RestackWindow, dmxRestackWindow, dmxScreen, pScreen);
- dmxUpdateWindowInfo(DMX_UPDATE_RESTACK, pWindow);
-}
-
-static Bool dmxWindowExposurePredicate(Display *dpy, XEvent *ev, XPointer ptr)
-{
- return (ev->type == Expose && ev->xexpose.window == *(Window *)ptr);
-}
-
-/** Handle exposures on \a pWindow. Since window exposures are handled
- * in DMX, the events that are generated by the back-end server are
- * redundant, so we eat them here. */
-void dmxWindowExposures(WindowPtr pWindow, RegionPtr prgn,
- RegionPtr other_exposed)
-{
- ScreenPtr pScreen = pWindow->drawable.pScreen;
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
- dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
- XEvent ev;
-
- DMX_UNWRAP(WindowExposures, dmxScreen, pScreen);
-
- dmxSync(dmxScreen, False);
-
- if (pWinPriv->window) {
- while (XCheckIfEvent(dmxScreen->beDisplay, &ev,
- dmxWindowExposurePredicate,
- (XPointer)&pWinPriv->window)) {
- /* Handle expose events -- this should not be necessary
- since the base window in which the root window was
- created is guaranteed to be on top (override_redirect),
- so we should just swallow these events. If for some
- reason the window is not on top, then we'd need to
- collect these events and send them to the client later
- (e.g., during the block handler as Xnest does). */
- }
- }
-
-#if 1
- if (pScreen->WindowExposures)
- pScreen->WindowExposures(pWindow, prgn, other_exposed);
-#endif
- DMX_WRAP(WindowExposures, dmxWindowExposures, dmxScreen, pScreen);
-}
-
-/** Move \a pWindow on the back-end server. Determine whether or not it
- * is on or offscreen, and realize it if it is newly on screen and the
- * lazy window creation optimization is enabled. */
-void dmxCopyWindow(WindowPtr pWindow, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
-{
- ScreenPtr pScreen = pWindow->drawable.pScreen;
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
- dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
- unsigned int m;
- XWindowChanges c;
-
- DMX_UNWRAP(CopyWindow, dmxScreen, pScreen);
-#if 0
- if (pScreen->CopyWindow)
- pScreen->CopyWindow(pWindow, ptOldOrg, prgnSrc);
-#endif
-
- /* Determine if the window is completely off the visible portion of
- the screen */
- pWinPriv->offscreen = DMX_WINDOW_OFFSCREEN(pWindow);
-
- /* If the window is now on-screen and it is mapped and it has not
- been created yet, create it and map it */
- if (!pWinPriv->window && pWinPriv->mapped && !pWinPriv->offscreen) {
- dmxCreateAndRealizeWindow(pWindow, TRUE);
- } else if (pWinPriv->window) {
- /* Move window on back-end server */
- m = CWX | CWY | CWWidth | CWHeight;
- c.x = pWindow->origin.x - wBorderWidth(pWindow);
- c.y = pWindow->origin.y - wBorderWidth(pWindow);
- c.width = pWindow->drawable.width;
- c.height = pWindow->drawable.height;
-
- XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
- dmxSync(dmxScreen, False);
- }
-
- DMX_WRAP(CopyWindow, dmxCopyWindow, dmxScreen, pScreen);
- dmxUpdateWindowInfo(DMX_UPDATE_COPY, pWindow);
-}
-
-/** Resize \a pWindow on the back-end server. Determine whether or not
- * it is on or offscreen, and realize it if it is newly on screen and
- * the lazy window creation optimization is enabled. */
-void dmxResizeWindow(WindowPtr pWindow, int x, int y,
- unsigned int w, unsigned int h, WindowPtr pSib)
-{
- ScreenPtr pScreen = pWindow->drawable.pScreen;
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
- dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
- dmxWinPrivPtr pSibPriv;
- unsigned int m;
- XWindowChanges c;
-
- if (pSib)
- pSibPriv = DMX_GET_WINDOW_PRIV(pSib);
-
- DMX_UNWRAP(ResizeWindow, dmxScreen, pScreen);
-#if 1
- if (pScreen->ResizeWindow)
- pScreen->ResizeWindow(pWindow, x, y, w, h, pSib);
-#endif
-
- /* Determine if the window is completely off the visible portion of
- the screen */
- pWinPriv->offscreen = DMX_WINDOW_OFFSCREEN(pWindow);
-
- /* If the window is now on-screen and it is mapped and it has not
- been created yet, create it and map it */
- if (!pWinPriv->window && pWinPriv->mapped && !pWinPriv->offscreen) {
- dmxCreateAndRealizeWindow(pWindow, TRUE);
- } else if (pWinPriv->window) {
- /* Handle resizing on back-end server */
- m = CWX | CWY | CWWidth | CWHeight;
- c.x = pWindow->origin.x - wBorderWidth(pWindow);
- c.y = pWindow->origin.y - wBorderWidth(pWindow);
- c.width = pWindow->drawable.width;
- c.height = pWindow->drawable.height;
-
- XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
- dmxSync(dmxScreen, False);
- }
-
- DMX_WRAP(ResizeWindow, dmxResizeWindow, dmxScreen, pScreen);
- dmxUpdateWindowInfo(DMX_UPDATE_RESIZE, pWindow);
-}
-
-/** Reparent \a pWindow on the back-end server. */
-void dmxReparentWindow(WindowPtr pWindow, WindowPtr pPriorParent)
-{
- ScreenPtr pScreen = pWindow->drawable.pScreen;
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
- dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
- dmxWinPrivPtr pParentPriv = DMX_GET_WINDOW_PRIV(pWindow->parent);
-
- DMX_UNWRAP(ReparentWindow, dmxScreen, pScreen);
-#if 0
- if (pScreen->ReparentWindow)
- pScreen->ReparentWindow(pWindow, pPriorParent);
-#endif
-
- if (pWinPriv->window) {
- if (!pParentPriv->window) {
- dmxCreateAndRealizeWindow(pWindow->parent, FALSE);
- }
-
- /* Handle reparenting on back-end server */
- XReparentWindow(dmxScreen->beDisplay, pWinPriv->window,
- pParentPriv->window,
- pWindow->origin.x - wBorderWidth(pWindow),
- pWindow->origin.x - wBorderWidth(pWindow));
- dmxSync(dmxScreen, False);
- }
-
- DMX_WRAP(ReparentWindow, dmxReparentWindow, dmxScreen, pScreen);
- dmxUpdateWindowInfo(DMX_UPDATE_REPARENT, pWindow);
-}
-
-/** Change border width for \a pWindow to \a width pixels. */
-void dmxChangeBorderWidth(WindowPtr pWindow, unsigned int width)
-{
- ScreenPtr pScreen = pWindow->drawable.pScreen;
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
- dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
- unsigned int m;
- XWindowChanges c;
-
- DMX_UNWRAP(ChangeBorderWidth, dmxScreen, pScreen);
-#if 1
- if (pScreen->ChangeBorderWidth)
- pScreen->ChangeBorderWidth(pWindow, width);
-#endif
-
- /* NOTE: Do we need to check for on/off screen here? */
-
- if (pWinPriv->window) {
- /* Handle border width change on back-end server */
- m = CWBorderWidth;
- c.border_width = width;
-
- XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
- dmxSync(dmxScreen, False);
- }
-
- DMX_WRAP(ChangeBorderWidth, dmxChangeBorderWidth, dmxScreen, pScreen);
-}
-
-static void dmxDoSetShape(WindowPtr pWindow)
-{
- ScreenPtr pScreen = pWindow->drawable.pScreen;
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
- dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
- int nBox;
- BoxPtr pBox;
- int nRect;
- XRectangle *pRect;
- XRectangle *pRectFirst;
-
- /* First, set the bounding shape */
- if (wBoundingShape(pWindow)) {
- pBox = RegionRects(wBoundingShape(pWindow));
- nRect = nBox = RegionNumRects(wBoundingShape(pWindow));
- pRectFirst = pRect = malloc(nRect * sizeof(*pRect));
- while (nBox--) {
- pRect->x = pBox->x1;
- pRect->y = pBox->y1;
- pRect->width = pBox->x2 - pBox->x1;
- pRect->height = pBox->y2 - pBox->y1;
- pBox++;
- pRect++;
- }
- XShapeCombineRectangles(dmxScreen->beDisplay, pWinPriv->window,
- ShapeBounding, 0, 0,
- pRectFirst, nRect,
- ShapeSet, YXBanded);
- free(pRectFirst);
- } else {
- XShapeCombineMask(dmxScreen->beDisplay, pWinPriv->window,
- ShapeBounding, 0, 0, None, ShapeSet);
- }
-
- /* Next, set the clip shape */
- if (wClipShape(pWindow)) {
- pBox = RegionRects(wClipShape(pWindow));
- nRect = nBox = RegionNumRects(wClipShape(pWindow));
- pRectFirst = pRect = malloc(nRect * sizeof(*pRect));
- while (nBox--) {
- pRect->x = pBox->x1;
- pRect->y = pBox->y1;
- pRect->width = pBox->x2 - pBox->x1;
- pRect->height = pBox->y2 - pBox->y1;
- pBox++;
- pRect++;
- }
- XShapeCombineRectangles(dmxScreen->beDisplay, pWinPriv->window,
- ShapeClip, 0, 0,
- pRectFirst, nRect,
- ShapeSet, YXBanded);
- free(pRectFirst);
- } else {
- XShapeCombineMask(dmxScreen->beDisplay, pWinPriv->window,
- ShapeClip, 0, 0, None, ShapeSet);
- }
-
- if (XShapeInputSelected(dmxScreen->beDisplay, pWinPriv->window)) {
- ErrorF("Input selected for window %x on Screen %d\n",
- (unsigned int)pWinPriv->window, pScreen->myNum);
- }
-}
-
-/** Set shape of \a pWindow on the back-end server. */
-void dmxSetShape(WindowPtr pWindow, int kind)
-{
- ScreenPtr pScreen = pWindow->drawable.pScreen;
- DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
- dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
-
- DMX_UNWRAP(SetShape, dmxScreen, pScreen);
-#if 1
- if (pScreen->SetShape)
- pScreen->SetShape(pWindow, kind);
-#endif
-
- if (pWinPriv->window) {
- /* Handle setting the current shape on the back-end server */
- dmxDoSetShape(pWindow);
- dmxSync(dmxScreen, False);
- } else {
- pWinPriv->isShaped = TRUE;
- }
-
- DMX_WRAP(SetShape, dmxSetShape, dmxScreen, pScreen);
-}
+/*
+ * 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>
+ *
+ */
+
+/** \file
+ * This file provides support for window-related functions. */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmx.h"
+#include "dmxsync.h"
+#include "dmxwindow.h"
+#include "dmxpixmap.h"
+#include "dmxcmap.h"
+#include "dmxvisual.h"
+#include "dmxinput.h"
+#include "dmxextension.h"
+#include "dmxpict.h"
+
+#include "windowstr.h"
+
+static void dmxDoRestackWindow(WindowPtr pWindow);
+static void dmxDoChangeWindowAttributes(WindowPtr pWindow,
+ unsigned long *mask,
+ XSetWindowAttributes *attribs);
+
+static void dmxDoSetShape(WindowPtr pWindow);
+
+/** Initialize the private area for the window functions. */
+Bool dmxInitWindow(ScreenPtr pScreen)
+{
+ if (!dixRegisterPrivateKey(&dmxWinPrivateKeyRec, PRIVATE_WINDOW, sizeof(dmxWinPrivRec)))
+ return FALSE;
+
+ return TRUE;
+}
+
+
+Window dmxCreateRootWindow(WindowPtr pWindow)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+ Window parent;
+ Visual *visual;
+ unsigned long mask;
+ XSetWindowAttributes attribs;
+ ColormapPtr pCmap;
+ dmxColormapPrivPtr pCmapPriv;
+
+ /* Create root window */
+
+ parent = dmxScreen->scrnWin; /* This is our "Screen" window */
+ visual = dmxScreen->beVisuals[dmxScreen->beDefVisualIndex].visual;
+
+ dixLookupResourceByType((pointer*) &pCmap, wColormap(pWindow),
+ RT_COLORMAP, NullClient, DixUnknownAccess);
+ pCmapPriv = DMX_GET_COLORMAP_PRIV(pCmap);
+
+ mask = CWEventMask | CWBackingStore | CWColormap | CWBorderPixel;
+ attribs.event_mask = ExposureMask;
+ attribs.backing_store = NotUseful;
+ attribs.colormap = pCmapPriv->cmap;
+ attribs.border_pixel = 0;
+
+ /* Incorporate new attributes, if needed */
+ if (pWinPriv->attribMask) {
+ dmxDoChangeWindowAttributes(pWindow, &pWinPriv->attribMask, &attribs);
+ mask |= pWinPriv->attribMask;
+ }
+
+ return XCreateWindow(dmxScreen->beDisplay,
+ parent,
+ pWindow->origin.x - wBorderWidth(pWindow),
+ pWindow->origin.y - wBorderWidth(pWindow),
+ pWindow->drawable.width,
+ pWindow->drawable.height,
+ pWindow->borderWidth,
+ pWindow->drawable.depth,
+ pWindow->drawable.class,
+ visual,
+ mask,
+ &attribs);
+}
+
+/** Change the location and size of the "screen" window. Called from
+ * dmxextension.c dmxConfigureScreenWindow(). */
+void dmxResizeScreenWindow(ScreenPtr pScreen,
+ int x, int y, int w, int h)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ unsigned int m;
+ XWindowChanges c;
+
+ if (!dmxScreen->beDisplay)
+ return;
+
+ /* Handle resizing on back-end server */
+ m = CWX | CWY | CWWidth | CWHeight;
+ c.x = x;
+ c.y = y;
+ c.width = w;
+ c.height = h;
+
+ XConfigureWindow(dmxScreen->beDisplay, dmxScreen->scrnWin, m, &c);
+ dmxSync(dmxScreen, False);
+}
+
+/** Change the location and size of the "root" window. Called from
+ * #dmxCreateWindow. */
+void dmxResizeRootWindow(WindowPtr pRoot,
+ int x, int y, int w, int h)
+{
+ DMXScreenInfo *dmxScreen = &dmxScreens[pRoot->drawable.pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pRoot);
+ unsigned int m;
+ XWindowChanges c;
+
+ /* Handle resizing on back-end server */
+ if (dmxScreen->beDisplay) {
+ m = CWX | CWY | CWWidth | CWHeight;
+ c.x = x;
+ c.y = y;
+ c.width = (w > 0) ? w : 1;
+ c.height = (h > 0) ? h : 1;
+
+ XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
+ }
+
+ if (w == 0 || h == 0) {
+ if (pWinPriv->mapped) {
+ if (dmxScreen->beDisplay)
+ XUnmapWindow(dmxScreen->beDisplay, pWinPriv->window);
+ pWinPriv->mapped = FALSE;
+ }
+ } else if (!pWinPriv->mapped) {
+ if (dmxScreen->beDisplay)
+ XMapWindow(dmxScreen->beDisplay, pWinPriv->window);
+ pWinPriv->mapped = TRUE;
+ }
+
+ if (dmxScreen->beDisplay)
+ dmxSync(dmxScreen, False);
+}
+
+void dmxGetDefaultWindowAttributes(WindowPtr pWindow,
+ Colormap *cmap,
+ Visual **visual)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+
+ if (pWindow->drawable.class != InputOnly &&
+ pWindow->optional &&
+ pWindow->optional->visual != wVisual(pWindow->parent)) {
+
+ /* Find the matching visual */
+ *visual = dmxLookupVisualFromID(pScreen, wVisual(pWindow));
+
+ /* Handle optional colormaps */
+ if (pWindow->optional->colormap) {
+ ColormapPtr pCmap;
+ dmxColormapPrivPtr pCmapPriv;
+
+ dixLookupResourceByType((pointer*) &pCmap, wColormap(pWindow),
+ RT_COLORMAP, NullClient, DixUnknownAccess);
+ pCmapPriv = DMX_GET_COLORMAP_PRIV(pCmap);
+ *cmap = pCmapPriv->cmap;
+ } else {
+ *cmap = dmxColormapFromDefaultVisual(pScreen, *visual);
+ }
+ } else {
+ *visual = CopyFromParent;
+ *cmap = (Colormap)0;
+ }
+}
+
+static Window dmxCreateNonRootWindow(WindowPtr pWindow)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+ Window parent;
+ unsigned long mask = 0L;
+ XSetWindowAttributes attribs;
+ dmxWinPrivPtr pParentPriv = DMX_GET_WINDOW_PRIV(pWindow->parent);
+
+ /* Create window on back-end server */
+
+ parent = pParentPriv->window;
+
+ /* The parent won't exist if this call to CreateNonRootWindow came
+ from ReparentWindow and the grandparent window has not yet been
+ created */
+ if (!parent) {
+ dmxCreateAndRealizeWindow(pWindow->parent, FALSE);
+ parent = pParentPriv->window;
+ }
+
+ /* Incorporate new attributes, if needed */
+ if (pWinPriv->attribMask) {
+ dmxDoChangeWindowAttributes(pWindow, &pWinPriv->attribMask, &attribs);
+ mask |= pWinPriv->attribMask;
+ }
+
+ /* Add in default attributes */
+ if (pWindow->drawable.class != InputOnly) {
+ mask |= CWBackingStore;
+ attribs.backing_store = NotUseful;
+
+ if (!(mask & CWColormap) && pWinPriv->cmap) {
+ mask |= CWColormap;
+ attribs.colormap = pWinPriv->cmap;
+ if (!(mask & CWBorderPixel)) {
+ mask |= CWBorderPixel;
+ attribs.border_pixel = 0;
+ }
+ }
+ }
+
+ /* Handle case where subwindows are being mapped, but created out of
+ order -- if current window has a previous sibling, then it cannot
+ be created on top of the stack, so we must restack the windows */
+ pWinPriv->restacked = (pWindow->prevSib != NullWindow);
+
+ return XCreateWindow(dmxScreen->beDisplay,
+ parent,
+ pWindow->origin.x - wBorderWidth(pWindow),
+ pWindow->origin.y - wBorderWidth(pWindow),
+ pWindow->drawable.width,
+ pWindow->drawable.height,
+ pWindow->borderWidth,
+ pWindow->drawable.depth,
+ pWindow->drawable.class,
+ pWinPriv->visual,
+ mask,
+ &attribs);
+}
+
+/** This function handles lazy window creation and realization. Window
+ * creation is handled by #dmxCreateNonRootWindow(). It also handles
+ * any stacking changes that have occured since the window was
+ * originally created by calling #dmxDoRestackWindow(). If the window
+ * is shaped, the shape is set on the back-end server by calling
+ * #dmxDoSetShape(), and if the window has pictures (from RENDER)
+ * associated with it, those pictures are created on the back-end
+ * server by calling #dmxCreatePictureList(). If \a doSync is TRUE,
+ * then #dmxSync() is called. */
+void dmxCreateAndRealizeWindow(WindowPtr pWindow, Bool doSync)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+
+ if (!dmxScreen->beDisplay) return;
+
+ pWinPriv->window = dmxCreateNonRootWindow(pWindow);
+ if (pWinPriv->restacked) dmxDoRestackWindow(pWindow);
+ if (pWinPriv->isShaped) dmxDoSetShape(pWindow);
+ if (pWinPriv->hasPict) dmxCreatePictureList(pWindow);
+ if (pWinPriv->mapped) XMapWindow(dmxScreen->beDisplay,
+ pWinPriv->window);
+ if (doSync) dmxSync(dmxScreen, False);
+}
+
+/** Create \a pWindow on the back-end server. If the lazy window
+ * creation optimization is enabled, then the actual creation and
+ * realization of the window is handled by
+ * #dmxCreateAndRealizeWindow(). */
+Bool dmxCreateWindow(WindowPtr pWindow)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+ Bool ret = TRUE;
+
+ DMX_UNWRAP(CreateWindow, dmxScreen, pScreen);
+#if 0
+ if (pScreen->CreateWindow)
+ ret = pScreen->CreateWindow(pWindow);
+#endif
+
+ /* Set up the defaults */
+ pWinPriv->window = (Window)0;
+ pWinPriv->offscreen = TRUE;
+ pWinPriv->mapped = FALSE;
+ pWinPriv->restacked = FALSE;
+ pWinPriv->attribMask = 0;
+ pWinPriv->isShaped = FALSE;
+ pWinPriv->hasPict = FALSE;
+#ifdef GLXEXT
+ pWinPriv->swapGroup = NULL;
+ pWinPriv->barrier = 0;
+#endif
+
+ if (dmxScreen->beDisplay) {
+ /* Only create the root window at this stage -- non-root windows are
+ created when they are mapped and are on-screen */
+ if (!pWindow->parent) {
+ dmxScreen->rootWin = pWinPriv->window
+ = dmxCreateRootWindow(pWindow);
+ if (dmxScreen->scrnX != dmxScreen->rootX
+ || dmxScreen->scrnY != dmxScreen->rootY
+ || dmxScreen->scrnWidth != dmxScreen->rootWidth
+ || dmxScreen->scrnHeight != dmxScreen->rootHeight) {
+ dmxResizeRootWindow(pWindow,
+ dmxScreen->rootX,
+ dmxScreen->rootY,
+ dmxScreen->rootWidth,
+ dmxScreen->rootHeight);
+ dmxUpdateScreenResources(screenInfo.screens[dmxScreen->index],
+ dmxScreen->rootX,
+ dmxScreen->rootY,
+ dmxScreen->rootWidth,
+ dmxScreen->rootHeight);
+ pWindow->origin.x = dmxScreen->rootX;
+ pWindow->origin.y = dmxScreen->rootY;
+ }
+ } else {
+ dmxGetDefaultWindowAttributes(pWindow,
+ &pWinPriv->cmap,
+ &pWinPriv->visual);
+
+ if (dmxLazyWindowCreation) {
+ /* Save parent's visual for use later */
+ if (pWinPriv->visual == CopyFromParent)
+ pWinPriv->visual =
+ dmxLookupVisualFromID(pScreen,
+ wVisual(pWindow->parent));
+ } else {
+ pWinPriv->window = dmxCreateNonRootWindow(pWindow);
+ }
+ }
+
+ dmxSync(dmxScreen, False);
+ }
+
+ DMX_WRAP(CreateWindow, dmxCreateWindow, dmxScreen, pScreen);
+
+ return ret;
+}
+
+/** Destroy \a pWindow on the back-end server. */
+Bool dmxBEDestroyWindow(WindowPtr pWindow)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+
+ if (pWinPriv->window) {
+ XDestroyWindow(dmxScreen->beDisplay, pWinPriv->window);
+ pWinPriv->window = (Window)0;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/** Destroy \a pWindow on the back-end server. If any RENDER pictures
+ were created, destroy them as well. */
+Bool dmxDestroyWindow(WindowPtr pWindow)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ Bool ret = TRUE;
+ Bool needSync = FALSE;
+#ifdef GLXEXT
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+#endif
+
+ DMX_UNWRAP(DestroyWindow, dmxScreen, pScreen);
+
+ /* Destroy any picture list associated with this window */
+ needSync |= dmxDestroyPictureList(pWindow);
+
+ /* Destroy window on back-end server */
+ needSync |= dmxBEDestroyWindow(pWindow);
+ if (needSync) dmxSync(dmxScreen, FALSE);
+
+#ifdef GLXEXT
+ if (pWinPriv->swapGroup && pWinPriv->windowDestroyed)
+ pWinPriv->windowDestroyed(pWindow);
+#endif
+
+ if (pScreen->DestroyWindow)
+ ret = pScreen->DestroyWindow(pWindow);
+
+ DMX_WRAP(DestroyWindow, dmxDestroyWindow, dmxScreen, pScreen);
+
+ return ret;
+}
+
+/** Change the position of \a pWindow to be \a x, \a y. */
+Bool dmxPositionWindow(WindowPtr pWindow, int x, int y)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ Bool ret = TRUE;
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+ unsigned int m;
+ XWindowChanges c;
+
+ DMX_UNWRAP(PositionWindow, dmxScreen, pScreen);
+#if 0
+ if (pScreen->PositionWindow)
+ ret = pScreen->PositionWindow(pWindow, x, y);
+#endif
+
+ /* Determine if the window is completely off the visible portion of
+ the screen */
+ pWinPriv->offscreen = DMX_WINDOW_OFFSCREEN(pWindow);
+
+ /* If the window is now on-screen and it is mapped and it has not
+ been created yet, create it and map it */
+ if (!pWinPriv->window && pWinPriv->mapped && !pWinPriv->offscreen) {
+ dmxCreateAndRealizeWindow(pWindow, TRUE);
+ } else if (pWinPriv->window) {
+ /* Position window on back-end server */
+ m = CWX | CWY | CWWidth | CWHeight;
+ c.x = pWindow->origin.x - wBorderWidth(pWindow);
+ c.y = pWindow->origin.y - wBorderWidth(pWindow);
+ c.width = pWindow->drawable.width;
+ c.height = pWindow->drawable.height;
+ if (pWindow->drawable.class != InputOnly) {
+ m |= CWBorderWidth;
+ c.border_width = pWindow->borderWidth;
+ }
+
+ XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
+ dmxSync(dmxScreen, False);
+ }
+
+ DMX_WRAP(PositionWindow, dmxPositionWindow, dmxScreen, pScreen);
+
+ return ret;
+}
+
+static void dmxDoChangeWindowAttributes(WindowPtr pWindow,
+ unsigned long *mask,
+ XSetWindowAttributes *attribs)
+{
+ dmxPixPrivPtr pPixPriv;
+
+ if (*mask & CWBackPixmap) {
+ switch (pWindow->backgroundState) {
+ case None:
+ attribs->background_pixmap = None;
+ break;
+
+ case ParentRelative:
+ attribs->background_pixmap = ParentRelative;
+ break;
+
+ case BackgroundPixmap:
+ pPixPriv = DMX_GET_PIXMAP_PRIV(pWindow->background.pixmap);
+ attribs->background_pixmap = pPixPriv->pixmap;
+ break;
+
+ case BackgroundPixel:
+ *mask &= ~CWBackPixmap;
+ break;
+ }
+ }
+
+ if (*mask & CWBackPixel) {
+ if (pWindow->backgroundState == BackgroundPixel)
+ attribs->background_pixel = pWindow->background.pixel;
+ else
+ *mask &= ~CWBackPixel;
+ }
+
+ if (*mask & CWBorderPixmap) {
+ if (pWindow->borderIsPixel)
+ *mask &= ~CWBorderPixmap;
+ else {
+ pPixPriv = DMX_GET_PIXMAP_PRIV(pWindow->border.pixmap);
+ attribs->border_pixmap = pPixPriv->pixmap;
+ }
+ }
+
+ if (*mask & CWBorderPixel) {
+ if (pWindow->borderIsPixel)
+ attribs->border_pixel = pWindow->border.pixel;
+ else
+ *mask &= ~CWBorderPixel;
+ }
+
+ if (*mask & CWBitGravity)
+ attribs->bit_gravity = pWindow->bitGravity;
+
+ if (*mask & CWWinGravity)
+ *mask &= ~CWWinGravity; /* Handled by dix */
+
+ if (*mask & CWBackingStore)
+ *mask &= ~CWBackingStore; /* Backing store not supported */
+
+ if (*mask & CWBackingPlanes)
+ *mask &= ~CWBackingPlanes; /* Backing store not supported */
+
+ if (*mask & CWBackingPixel)
+ *mask &= ~CWBackingPixel; /* Backing store not supported */
+
+ if (*mask & CWOverrideRedirect)
+ attribs->override_redirect = pWindow->overrideRedirect;
+
+ if (*mask & CWSaveUnder)
+ *mask &= ~CWSaveUnder; /* Save unders not supported */
+
+ if (*mask & CWEventMask)
+ *mask &= ~CWEventMask; /* Events are handled by dix */
+
+ if (*mask & CWDontPropagate)
+ *mask &= ~CWDontPropagate; /* Events are handled by dix */
+
+ if (*mask & CWColormap) {
+ ColormapPtr pCmap;
+ dmxColormapPrivPtr pCmapPriv;
+
+ dixLookupResourceByType((pointer*) &pCmap, wColormap(pWindow),
+ RT_COLORMAP, NullClient, DixUnknownAccess);
+ pCmapPriv = DMX_GET_COLORMAP_PRIV(pCmap);
+ attribs->colormap = pCmapPriv->cmap;
+ }
+
+ if (*mask & CWCursor)
+ *mask &= ~CWCursor; /* Handled by the cursor code */
+}
+
+/** Change the window attributes of \a pWindow. */
+Bool dmxChangeWindowAttributes(WindowPtr pWindow, unsigned long mask)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ Bool ret = TRUE;
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+ XSetWindowAttributes attribs;
+
+ DMX_UNWRAP(ChangeWindowAttributes, dmxScreen, pScreen);
+#if 0
+ if (pScreen->ChangeWindowAttributes)
+ ret = pScreen->ChangeWindowAttributes(pWindow, mask);
+#endif
+
+ /* Change window attribs on back-end server */
+ dmxDoChangeWindowAttributes(pWindow, &mask, &attribs);
+
+ /* Save mask for lazy window creation optimization */
+ pWinPriv->attribMask |= mask;
+
+ if (mask && pWinPriv->window) {
+ XChangeWindowAttributes(dmxScreen->beDisplay, pWinPriv->window,
+ mask, &attribs);
+ dmxSync(dmxScreen, False);
+ }
+
+ DMX_WRAP(ChangeWindowAttributes, dmxChangeWindowAttributes, dmxScreen,
+ pScreen);
+
+ return ret;
+}
+
+/** Realize \a pWindow on the back-end server. If the lazy window
+ * creation optimization is enabled, the window is only realized when
+ * it at least partially overlaps the screen. */
+Bool dmxRealizeWindow(WindowPtr pWindow)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ Bool ret = TRUE;
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+
+ DMX_UNWRAP(RealizeWindow, dmxScreen, pScreen);
+#if 0
+ if (pScreen->RealizeWindow)
+ ret = pScreen->RealizeWindow(pWindow);
+#endif
+
+ /* Determine if the window is completely off the visible portion of
+ the screen */
+ pWinPriv->offscreen = DMX_WINDOW_OFFSCREEN(pWindow);
+
+ /* If the window hasn't been created and it's not offscreen, then
+ create it */
+ if (!pWinPriv->window && !pWinPriv->offscreen) {
+ dmxCreateAndRealizeWindow(pWindow, FALSE);
+ }
+
+ if (pWinPriv->window) {
+ /* Realize window on back-end server */
+ XMapWindow(dmxScreen->beDisplay, pWinPriv->window);
+ dmxSync(dmxScreen, False);
+ }
+
+ /* Let the other functions know that the window is now mapped */
+ pWinPriv->mapped = TRUE;
+
+ DMX_WRAP(RealizeWindow, dmxRealizeWindow, dmxScreen, pScreen);
+
+ dmxUpdateWindowInfo(DMX_UPDATE_REALIZE, pWindow);
+ return ret;
+}
+
+/** Unrealize \a pWindow on the back-end server. */
+Bool dmxUnrealizeWindow(WindowPtr pWindow)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ Bool ret = TRUE;
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+
+ DMX_UNWRAP(UnrealizeWindow, dmxScreen, pScreen);
+#if 0
+ if (pScreen->UnrealizeWindow)
+ ret = pScreen->UnrealizeWindow(pWindow);
+#endif
+
+ if (pWinPriv->window) {
+ /* Unrealize window on back-end server */
+ XUnmapWindow(dmxScreen->beDisplay, pWinPriv->window);
+ dmxSync(dmxScreen, False);
+ }
+
+ /* When unrealized (i.e., unmapped), the window is always considered
+ off of the visible portion of the screen */
+ pWinPriv->offscreen = TRUE;
+ pWinPriv->mapped = FALSE;
+
+#ifdef GLXEXT
+ if (pWinPriv->swapGroup && pWinPriv->windowUnmapped)
+ pWinPriv->windowUnmapped(pWindow);
+#endif
+
+ DMX_WRAP(UnrealizeWindow, dmxUnrealizeWindow, dmxScreen, pScreen);
+
+ dmxUpdateWindowInfo(DMX_UPDATE_UNREALIZE, pWindow);
+ return ret;
+}
+
+static void dmxDoRestackWindow(WindowPtr pWindow)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+ WindowPtr pNextSib = pWindow->nextSib;
+ unsigned int m;
+ XWindowChanges c;
+
+ if (pNextSib == NullWindow) {
+ /* Window is at the bottom of the stack */
+ m = CWStackMode;
+ c.sibling = (Window)0;
+ c.stack_mode = Below;
+ XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
+ } else {
+ /* Window is not at the bottom of the stack */
+ dmxWinPrivPtr pNextSibPriv = DMX_GET_WINDOW_PRIV(pNextSib);
+
+ /* Handle case where siblings have not yet been created due to
+ lazy window creation optimization by first finding the next
+ sibling in the sibling list that has been created (if any)
+ and then putting the current window just above that sibling,
+ and if no next siblings have been created yet, then put it at
+ the bottom of the stack (since it might have a previous
+ sibling that should be above it). */
+ while (!pNextSibPriv->window) {
+ pNextSib = pNextSib->nextSib;
+ if (pNextSib == NullWindow) {
+ /* Window is at the bottom of the stack */
+ m = CWStackMode;
+ c.sibling = (Window)0;
+ c.stack_mode = Below;
+ XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
+ return;
+ }
+ pNextSibPriv = DMX_GET_WINDOW_PRIV(pNextSib);
+ }
+
+ m = CWStackMode | CWSibling;
+ c.sibling = pNextSibPriv->window;
+ c.stack_mode = Above;
+ XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
+ }
+}
+
+/** Handle window restacking. The actual restacking occurs in
+ * #dmxDoRestackWindow(). */
+void dmxRestackWindow(WindowPtr pWindow, WindowPtr pOldNextSib)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+
+ DMX_UNWRAP(RestackWindow, dmxScreen, pScreen);
+#if 0
+ if (pScreen->RestackWindow)
+ pScreen->RestackWindow(pWindow, pOldNextSib);
+#endif
+
+ if (pOldNextSib != pWindow->nextSib) {
+ /* Track restacking for lazy window creation optimization */
+ pWinPriv->restacked = TRUE;
+
+ /* Restack window on back-end server */
+ if (pWinPriv->window) {
+ dmxDoRestackWindow(pWindow);
+ dmxSync(dmxScreen, False);
+ }
+ }
+
+ DMX_WRAP(RestackWindow, dmxRestackWindow, dmxScreen, pScreen);
+ dmxUpdateWindowInfo(DMX_UPDATE_RESTACK, pWindow);
+}
+
+static Bool dmxWindowExposurePredicate(Display *dpy, XEvent *ev, XPointer ptr)
+{
+ return (ev->type == Expose && ev->xexpose.window == *(Window *)ptr);
+}
+
+/** Handle exposures on \a pWindow. Since window exposures are handled
+ * in DMX, the events that are generated by the back-end server are
+ * redundant, so we eat them here. */
+void dmxWindowExposures(WindowPtr pWindow, RegionPtr prgn,
+ RegionPtr other_exposed)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+ XEvent ev;
+
+ DMX_UNWRAP(WindowExposures, dmxScreen, pScreen);
+
+ dmxSync(dmxScreen, False);
+
+ if (pWinPriv->window) {
+ while (XCheckIfEvent(dmxScreen->beDisplay, &ev,
+ dmxWindowExposurePredicate,
+ (XPointer)&pWinPriv->window)) {
+ /* Handle expose events -- this should not be necessary
+ since the base window in which the root window was
+ created is guaranteed to be on top (override_redirect),
+ so we should just swallow these events. If for some
+ reason the window is not on top, then we'd need to
+ collect these events and send them to the client later
+ (e.g., during the block handler as Xnest does). */
+ }
+ }
+
+#if 1
+ if (pScreen->WindowExposures)
+ pScreen->WindowExposures(pWindow, prgn, other_exposed);
+#endif
+ DMX_WRAP(WindowExposures, dmxWindowExposures, dmxScreen, pScreen);
+}
+
+/** Move \a pWindow on the back-end server. Determine whether or not it
+ * is on or offscreen, and realize it if it is newly on screen and the
+ * lazy window creation optimization is enabled. */
+void dmxCopyWindow(WindowPtr pWindow, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+ unsigned int m;
+ XWindowChanges c;
+
+ DMX_UNWRAP(CopyWindow, dmxScreen, pScreen);
+#if 0
+ if (pScreen->CopyWindow)
+ pScreen->CopyWindow(pWindow, ptOldOrg, prgnSrc);
+#endif
+
+ /* Determine if the window is completely off the visible portion of
+ the screen */
+ pWinPriv->offscreen = DMX_WINDOW_OFFSCREEN(pWindow);
+
+ /* If the window is now on-screen and it is mapped and it has not
+ been created yet, create it and map it */
+ if (!pWinPriv->window && pWinPriv->mapped && !pWinPriv->offscreen) {
+ dmxCreateAndRealizeWindow(pWindow, TRUE);
+ } else if (pWinPriv->window) {
+ /* Move window on back-end server */
+ m = CWX | CWY | CWWidth | CWHeight;
+ c.x = pWindow->origin.x - wBorderWidth(pWindow);
+ c.y = pWindow->origin.y - wBorderWidth(pWindow);
+ c.width = pWindow->drawable.width;
+ c.height = pWindow->drawable.height;
+
+ XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
+ dmxSync(dmxScreen, False);
+ }
+
+ DMX_WRAP(CopyWindow, dmxCopyWindow, dmxScreen, pScreen);
+ dmxUpdateWindowInfo(DMX_UPDATE_COPY, pWindow);
+}
+
+/** Resize \a pWindow on the back-end server. Determine whether or not
+ * it is on or offscreen, and realize it if it is newly on screen and
+ * the lazy window creation optimization is enabled. */
+void dmxResizeWindow(WindowPtr pWindow, int x, int y,
+ unsigned int w, unsigned int h, WindowPtr pSib)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+ dmxWinPrivPtr pSibPriv;
+ unsigned int m;
+ XWindowChanges c;
+
+ if (pSib)
+ pSibPriv = DMX_GET_WINDOW_PRIV(pSib);
+
+ DMX_UNWRAP(ResizeWindow, dmxScreen, pScreen);
+#if 1
+ if (pScreen->ResizeWindow)
+ pScreen->ResizeWindow(pWindow, x, y, w, h, pSib);
+#endif
+
+ /* Determine if the window is completely off the visible portion of
+ the screen */
+ pWinPriv->offscreen = DMX_WINDOW_OFFSCREEN(pWindow);
+
+ /* If the window is now on-screen and it is mapped and it has not
+ been created yet, create it and map it */
+ if (!pWinPriv->window && pWinPriv->mapped && !pWinPriv->offscreen) {
+ dmxCreateAndRealizeWindow(pWindow, TRUE);
+ } else if (pWinPriv->window) {
+ /* Handle resizing on back-end server */
+ m = CWX | CWY | CWWidth | CWHeight;
+ c.x = pWindow->origin.x - wBorderWidth(pWindow);
+ c.y = pWindow->origin.y - wBorderWidth(pWindow);
+ c.width = pWindow->drawable.width;
+ c.height = pWindow->drawable.height;
+
+ XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
+ dmxSync(dmxScreen, False);
+ }
+
+ DMX_WRAP(ResizeWindow, dmxResizeWindow, dmxScreen, pScreen);
+ dmxUpdateWindowInfo(DMX_UPDATE_RESIZE, pWindow);
+}
+
+/** Reparent \a pWindow on the back-end server. */
+void dmxReparentWindow(WindowPtr pWindow, WindowPtr pPriorParent)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+ dmxWinPrivPtr pParentPriv = DMX_GET_WINDOW_PRIV(pWindow->parent);
+
+ DMX_UNWRAP(ReparentWindow, dmxScreen, pScreen);
+#if 0
+ if (pScreen->ReparentWindow)
+ pScreen->ReparentWindow(pWindow, pPriorParent);
+#endif
+
+ if (pWinPriv->window) {
+ if (!pParentPriv->window) {
+ dmxCreateAndRealizeWindow(pWindow->parent, FALSE);
+ }
+
+ /* Handle reparenting on back-end server */
+ XReparentWindow(dmxScreen->beDisplay, pWinPriv->window,
+ pParentPriv->window,
+ pWindow->origin.x - wBorderWidth(pWindow),
+ pWindow->origin.x - wBorderWidth(pWindow));
+ dmxSync(dmxScreen, False);
+ }
+
+ DMX_WRAP(ReparentWindow, dmxReparentWindow, dmxScreen, pScreen);
+ dmxUpdateWindowInfo(DMX_UPDATE_REPARENT, pWindow);
+}
+
+/** Change border width for \a pWindow to \a width pixels. */
+void dmxChangeBorderWidth(WindowPtr pWindow, unsigned int width)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+ unsigned int m;
+ XWindowChanges c;
+
+ DMX_UNWRAP(ChangeBorderWidth, dmxScreen, pScreen);
+#if 1
+ if (pScreen->ChangeBorderWidth)
+ pScreen->ChangeBorderWidth(pWindow, width);
+#endif
+
+ /* NOTE: Do we need to check for on/off screen here? */
+
+ if (pWinPriv->window) {
+ /* Handle border width change on back-end server */
+ m = CWBorderWidth;
+ c.border_width = width;
+
+ XConfigureWindow(dmxScreen->beDisplay, pWinPriv->window, m, &c);
+ dmxSync(dmxScreen, False);
+ }
+
+ DMX_WRAP(ChangeBorderWidth, dmxChangeBorderWidth, dmxScreen, pScreen);
+}
+
+static void dmxDoSetShape(WindowPtr pWindow)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+ int nBox;
+ BoxPtr pBox;
+ int nRect;
+ XRectangle *pRect;
+ XRectangle *pRectFirst;
+
+ /* First, set the bounding shape */
+ if (wBoundingShape(pWindow)) {
+ pBox = RegionRects(wBoundingShape(pWindow));
+ nRect = nBox = RegionNumRects(wBoundingShape(pWindow));
+ pRectFirst = pRect = malloc(nRect * sizeof(*pRect));
+ while (nBox--) {
+ pRect->x = pBox->x1;
+ pRect->y = pBox->y1;
+ pRect->width = pBox->x2 - pBox->x1;
+ pRect->height = pBox->y2 - pBox->y1;
+ pBox++;
+ pRect++;
+ }
+ XShapeCombineRectangles(dmxScreen->beDisplay, pWinPriv->window,
+ ShapeBounding, 0, 0,
+ pRectFirst, nRect,
+ ShapeSet, YXBanded);
+ free(pRectFirst);
+ } else {
+ XShapeCombineMask(dmxScreen->beDisplay, pWinPriv->window,
+ ShapeBounding, 0, 0, None, ShapeSet);
+ }
+
+ /* Next, set the clip shape */
+ if (wClipShape(pWindow)) {
+ pBox = RegionRects(wClipShape(pWindow));
+ nRect = nBox = RegionNumRects(wClipShape(pWindow));
+ pRectFirst = pRect = malloc(nRect * sizeof(*pRect));
+ while (nBox--) {
+ pRect->x = pBox->x1;
+ pRect->y = pBox->y1;
+ pRect->width = pBox->x2 - pBox->x1;
+ pRect->height = pBox->y2 - pBox->y1;
+ pBox++;
+ pRect++;
+ }
+ XShapeCombineRectangles(dmxScreen->beDisplay, pWinPriv->window,
+ ShapeClip, 0, 0,
+ pRectFirst, nRect,
+ ShapeSet, YXBanded);
+ free(pRectFirst);
+ } else {
+ XShapeCombineMask(dmxScreen->beDisplay, pWinPriv->window,
+ ShapeClip, 0, 0, None, ShapeSet);
+ }
+
+ if (XShapeInputSelected(dmxScreen->beDisplay, pWinPriv->window)) {
+ ErrorF("Input selected for window %x on Screen %d\n",
+ (unsigned int)pWinPriv->window, pScreen->myNum);
+ }
+}
+
+/** Set shape of \a pWindow on the back-end server. */
+void dmxSetShape(WindowPtr pWindow, int kind)
+{
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
+ dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
+
+ DMX_UNWRAP(SetShape, dmxScreen, pScreen);
+#if 1
+ if (pScreen->SetShape)
+ pScreen->SetShape(pWindow, kind);
+#endif
+
+ if (pWinPriv->window) {
+ /* Handle setting the current shape on the back-end server */
+ dmxDoSetShape(pWindow);
+ dmxSync(dmxScreen, False);
+ } else {
+ pWinPriv->isShaped = TRUE;
+ }
+
+ DMX_WRAP(SetShape, dmxSetShape, dmxScreen, pScreen);
+}
diff --git a/xorg-server/hw/dmx/doc/Makefile.am b/xorg-server/hw/dmx/doc/Makefile.am
index 9a20f9487..0713884cd 100644
--- a/xorg-server/hw/dmx/doc/Makefile.am
+++ b/xorg-server/hw/dmx/doc/Makefile.am
@@ -1,34 +1,34 @@
-# Copyright 2005 Red Hat, Inc.
-#
-# 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 Red Hat
-# not be used in advertising or publicity pertaining to distribution
-# of the software without specific, written prior permission. Red
-# Hat makes no representations about the suitability of this software
-# for any purpose. It is provided "as is" without express or implied
-# warranty.
-#
-# RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
-# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
-# NO EVENT SHALL RED HAT 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.
-
-if ENABLE_DEVEL_DOCS
-if HAVE_XMLTO
-
-# Main DocBook/XML files (DOCTYPE book)
-docbook = dmx.xml scaled.xml
-
-# Generate DocBook/XML output formats with or without stylesheets
-include $(top_srcdir)/devbook.am
-
-endif HAVE_XMLTO
-endif ENABLE_DEVEL_DOCS
-
-EXTRA_DIST = DMXSpec.txt DMXSpec-v1.txt
+# Copyright 2005 Red Hat, Inc.
+#
+# 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 Red Hat
+# not be used in advertising or publicity pertaining to distribution
+# of the software without specific, written prior permission. Red
+# Hat makes no representations about the suitability of this software
+# for any purpose. It is provided "as is" without express or implied
+# warranty.
+#
+# RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+# NO EVENT SHALL RED HAT 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.
+
+if ENABLE_DEVEL_DOCS
+if HAVE_XMLTO
+
+# Main DocBook/XML files (DOCTYPE book)
+docbook = dmx.xml scaled.xml
+
+# Generate DocBook/XML output formats with or without stylesheets
+include $(top_srcdir)/devbook.am
+
+endif HAVE_XMLTO
+endif ENABLE_DEVEL_DOCS
+
+EXTRA_DIST = DMXSpec.txt DMXSpec-v1.txt
diff --git a/xorg-server/hw/dmx/glxProxy/glxcmds.c b/xorg-server/hw/dmx/glxProxy/glxcmds.c
index eb589f428..f79264ea9 100644
--- a/xorg-server/hw/dmx/glxProxy/glxcmds.c
+++ b/xorg-server/hw/dmx/glxProxy/glxcmds.c
@@ -1,3645 +1,3645 @@
-/*
- * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
- * Copyright (C) 1991-2000 Silicon Graphics, 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 including the dates of first publication and
- * either this permission notice or a reference to
- * http://oss.sgi.com/projects/FreeB/
- * 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
- * SILICON GRAPHICS, INC. 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 Silicon Graphics, Inc.
- * shall not be used in advertising or otherwise to promote the sale, use or
- * other dealings in this Software without prior written authorization from
- * Silicon Graphics, Inc.
- */
-
-#ifdef HAVE_DMX_CONFIG_H
-#include <dmx-config.h>
-#endif
-
-#include "dmx.h"
-#include "dmxwindow.h"
-#include "dmxpixmap.h"
-#include "dmxfont.h"
-#include "dmxsync.h"
-
-#include "glxserver.h"
-#include <GL/glxtokens.h>
-#include "g_disptab.h"
-#include <pixmapstr.h>
-#include <windowstr.h>
-#include "glxutil.h"
-#include "glxext.h"
-#include "unpack.h"
-
-#include "GL/glxproto.h"
-#include "glxvendor.h"
-#include "glxvisuals.h"
-#include "glxswap.h"
-
-#ifdef PANORAMIX
-#include "panoramiXsrv.h"
-#endif
-
-extern __GLXFBConfig **__glXFBConfigs;
-extern int __glXNumFBConfigs;
-
-extern __GLXFBConfig *glxLookupFBConfig( GLXFBConfigID id );
-extern __GLXFBConfig *glxLookupFBConfigByVID( VisualID vid );
-extern __GLXFBConfig *glxLookupBackEndFBConfig( GLXFBConfigID id, int screen );
-extern int glxIsExtensionSupported( char *ext );
-extern int __glXGetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc);
-
-#define BE_TO_CLIENT_ERROR(x) \
- ( (x) >= __glXerrorBase ? \
- (x) - dmxScreen->glxErrorBase + __glXerrorBase \
- : (x) )
-
-Display *GetBackEndDisplay( __GLXclientState *cl, int s )
-{
- if (! cl->be_displays[s] ) {
- cl->be_displays[s] = XOpenDisplay( DisplayString(dmxScreens[s].beDisplay) );
- }
- return cl->be_displays[s];
-}
-
-/*
-** Create a GL context with the given properties.
-*/
-static int CreateContext(__GLXclientState *cl,
- GLXContextID gcId,
- VisualID vid, GLXFBConfigID fbconfigId,
- int screen,
- GLXContextID shareList,
- int isDirect )
-{
- ClientPtr client = cl->client;
- xGLXCreateContextReq *be_req;
- xGLXCreateNewContextReq *be_new_req;
- VisualPtr pVisual;
- ScreenPtr pScreen;
- __GLXcontext *glxc, *shareglxc;
- __GLXvisualConfig *pGlxVisual;
- __GLXscreenInfo *pGlxScreen;
- VisualID visual = vid;
- GLint i;
- int from_screen = screen;
- int to_screen = screen;
- DMXScreenInfo *dmxScreen;
- VisualID be_vid = 0;
- GLXFBConfigID be_fbconfigId = 0;
- int num_be_screens;
- Display *dpy;
-
- /*
- ** Check if screen exists.
- */
- if (screen >= screenInfo.numScreens) {
- client->errorValue = screen;
- return BadValue;
- }
-
-
-#ifdef PANORAMIX
- if (!noPanoramiXExtension) {
- from_screen = 0;
- to_screen = screenInfo.numScreens - 1;
- }
-#endif
-
- /*
- ** Find the display list space that we want to share.
- **
- */
- if (shareList == None) {
- shareglxc = NULL;
- } else {
- dixLookupResourceByType((pointer*) &shareglxc, shareList,
- __glXContextRes, NullClient, DixUnknownAccess);
- if (!shareglxc) {
- client->errorValue = shareList;
- return __glXBadContext;
- }
- }
-
- /*
- ** Allocate memory for the new context
- */
- glxc = calloc(1, sizeof(__GLXcontext));
- if (!glxc) {
- return BadAlloc;
- }
-
- pScreen = screenInfo.screens[screen];
- pGlxScreen = &__glXActiveScreens[screen];
-
- if (fbconfigId != None) {
- glxc->pFBConfig = glxLookupFBConfig( fbconfigId );
- if (!glxc->pFBConfig) {
- client->errorValue = fbconfigId;
- free( glxc );
- return BadValue;
- }
- visual = glxc->pFBConfig->associatedVisualId;
- }
- else {
- glxc->pFBConfig = NULL;
- }
-
- if (visual != None) {
- /*
- ** Check if the visual ID is valid for this screen.
- */
- pVisual = pScreen->visuals;
- for (i = 0; i < pScreen->numVisuals; i++, pVisual++) {
- if (pVisual->vid == visual) {
- break;
- }
- }
- if (i == pScreen->numVisuals) {
- client->errorValue = visual;
- free( glxc );
- return BadValue;
- }
-
- pGlxVisual = pGlxScreen->pGlxVisual;
- for (i = 0; i < pGlxScreen->numVisuals; i++, pGlxVisual++) {
- if (pGlxVisual->vid == visual) {
- break;
- }
- }
- if (i == pGlxScreen->numVisuals) {
- /*
- ** Visual not support on this screen by this OpenGL implementation.
- */
- client->errorValue = visual;
- free( glxc );
- return BadValue;
- }
-
- if ( glxc->pFBConfig == NULL ) {
- glxc->pFBConfig = glxLookupFBConfigByVID( visual );
-
- if ( glxc->pFBConfig == NULL ) {
- /*
- * visual does not have an FBConfig ???
- client->errorValue = visual;
- free( glxc );
- return BadValue;
- */
- }
- }
- }
- else {
- pVisual = NULL;
- pGlxVisual = NULL;
- }
-
- glxc->pScreen = pScreen;
- glxc->pGlxScreen = pGlxScreen;
- glxc->pVisual = pVisual;
- glxc->pGlxVisual = pGlxVisual;
-
- /*
- * allocate memory for back-end servers info
- */
- num_be_screens = to_screen - from_screen + 1;
- glxc->real_ids = (XID *)malloc(sizeof(XID) * num_be_screens);
- if (!glxc->real_ids) {
- return BadAlloc;
- }
- glxc->real_vids = (XID *)malloc(sizeof(XID) * num_be_screens);
- if (!glxc->real_vids) {
- return BadAlloc;
- }
-
- for (screen = from_screen; screen <= to_screen; screen++) {
- int sent = 0;
- pScreen = screenInfo.screens[screen];
- pGlxScreen = &__glXActiveScreens[screen];
- dmxScreen = &dmxScreens[screen];
-
- if (glxc->pFBConfig) {
- __GLXFBConfig *beFBConfig = glxLookupBackEndFBConfig( glxc->pFBConfig->id,
- screen );
- be_fbconfigId = beFBConfig->id;
- }
-
- if (pGlxVisual) {
-
- be_vid = glxMatchGLXVisualInConfigList( pGlxVisual,
- dmxScreen->glxVisuals,
- dmxScreen->numGlxVisuals );
-
- if (!be_vid) {
- /* visual is not supported on the back-end server */
- free( glxc->real_ids );
- free( glxc->real_vids );
- free( glxc );
- return BadValue;
- }
- }
-
- glxc->real_ids[screen-from_screen] = XAllocID(GetBackEndDisplay(cl,screen));
-
- /* send the create context request to the back-end server */
- dpy = GetBackEndDisplay(cl,screen);
- if (glxc->pFBConfig) {
- /*Since for a certain visual both RGB and COLOR INDEX
- *can be on then the only parmeter to choose the renderType
- * should be the class of the colormap since all 4 first
- * classes does not support RGB mode only COLOR INDEX ,
- * and so TrueColor and DirectColor does not support COLOR INDEX*/
- int renderType = glxc->pFBConfig->renderType;
- if ( pVisual ) {
- switch ( pVisual->class ){
- case PseudoColor:
- case StaticColor:
- case GrayScale:
- case StaticGray:
- renderType = GLX_COLOR_INDEX_TYPE;
- break;
- case TrueColor:
- case DirectColor:
- default:
- renderType = GLX_RGBA_TYPE;
- break;
- }
- }
- if ( __GLX_IS_VERSION_SUPPORTED(1,3) ) {
- LockDisplay(dpy);
- GetReq(GLXCreateNewContext,be_new_req);
- be_new_req->reqType = dmxScreen->glxMajorOpcode;
- be_new_req->glxCode = X_GLXCreateNewContext;
- be_new_req->context = (unsigned int)glxc->real_ids[screen-from_screen];
- be_new_req->fbconfig = (unsigned int)be_fbconfigId;
- be_new_req->screen = DefaultScreen(dpy);
- be_new_req->renderType = renderType;
-
- be_new_req->shareList = (shareglxc ? shareglxc->real_ids[screen-from_screen] : 0);
- be_new_req->isDirect = 0;
- UnlockDisplay(dpy);
- glxc->real_vids[screen-from_screen] = be_fbconfigId;
- sent = 1;
- }
- else if (glxIsExtensionSupported("GLX_SGIX_fbconfig")) {
-
- xGLXCreateContextWithConfigSGIXReq *ext_req;
- xGLXVendorPrivateReq *vpreq;
- LockDisplay(dpy);
- GetReqExtra(GLXVendorPrivate,
- sz_xGLXCreateContextWithConfigSGIXReq - sz_xGLXVendorPrivateReq,
- vpreq);
- ext_req = (xGLXCreateContextWithConfigSGIXReq *)vpreq;
- ext_req->reqType = dmxScreen->glxMajorOpcode;
- ext_req->glxCode = X_GLXVendorPrivate;
- ext_req->vendorCode = X_GLXvop_CreateContextWithConfigSGIX;
- ext_req->context = (unsigned int)glxc->real_ids[screen-from_screen];
- ext_req->fbconfig = (unsigned int)be_fbconfigId;
- ext_req->screen = DefaultScreen(dpy);
- ext_req->renderType = renderType;
- ext_req->shareList = (shareglxc ? shareglxc->real_ids[screen-from_screen] : 0);
- ext_req->isDirect = 0;
- UnlockDisplay(dpy);
- glxc->real_vids[screen-from_screen] = be_fbconfigId;
- sent = 1;
- }
- }
-
- if (!sent) {
- LockDisplay(dpy);
- GetReq(GLXCreateContext,be_req);
- be_req->reqType = dmxScreen->glxMajorOpcode;
- be_req->glxCode = X_GLXCreateContext;
- be_req->context = (unsigned int)glxc->real_ids[screen-from_screen];
- be_req->visual = (unsigned int)be_vid;
- be_req->screen = DefaultScreen(dpy);
- be_req->shareList = (shareglxc ? shareglxc->real_ids[screen-from_screen] : 0);
- be_req->isDirect = 0;
- UnlockDisplay(dpy);
- glxc->real_vids[screen-from_screen] = be_vid;
- }
- SyncHandle();
-
- }
-
- /*
- ** Register this context as a resource.
- */
- if (!AddResource(gcId, __glXContextRes, (pointer)glxc)) {
- free( glxc->real_ids );
- free( glxc->real_vids );
- free( glxc );
- client->errorValue = gcId;
- return BadAlloc;
- }
-
- /*
- ** Finally, now that everything is working, setup the rest of the
- ** context.
- */
- glxc->id = gcId;
- glxc->share_id = shareList;
- glxc->idExists = GL_TRUE;
- glxc->isCurrent = GL_FALSE;
-
- return Success;
-}
-
-int __glXCreateContext(__GLXclientState *cl, GLbyte *pc)
-{
- xGLXCreateContextReq *req = (xGLXCreateContextReq *) pc;
-
- return( CreateContext(cl, req->context,req->visual, None,
- req->screen, req->shareList, req->isDirect) );
-
-}
-
-int __glXCreateNewContext(__GLXclientState *cl, GLbyte *pc)
-{
- xGLXCreateNewContextReq *req = (xGLXCreateNewContextReq *) pc;
-
- return( CreateContext(cl, req->context,None, req->fbconfig,
- req->screen, req->shareList, req->isDirect) );
-
-}
-
-int __glXCreateContextWithConfigSGIX(__GLXclientState *cl, GLbyte *pc)
-{
- xGLXCreateContextWithConfigSGIXReq *req = (xGLXCreateContextWithConfigSGIXReq *) pc;
-
- return( CreateContext(cl, req->context, None, req->fbconfig,
- req->screen, req->shareList, req->isDirect) );
-
-}
-
-int __glXQueryMaxSwapBarriersSGIX(__GLXclientState *cl, GLbyte *pc)
-{
- ClientPtr client = cl->client;
- xGLXQueryMaxSwapBarriersSGIXReq *req =
- (xGLXQueryMaxSwapBarriersSGIXReq *)pc;
- xGLXQueryMaxSwapBarriersSGIXReply reply;
-
- reply.type = X_Reply;
- reply.sequenceNumber = client->sequence;
- reply.length = 0;
- reply.max = QueryMaxSwapBarriersSGIX(req->screen);
-
- if (client->swapped) {
- __glXSwapQueryMaxSwapBarriersSGIXReply(client, &reply);
- } else {
- WriteToClient(client, sz_xGLXQueryMaxSwapBarriersSGIXReply,
- (char *)&reply);
- }
-
- return Success;
-}
-
-int __glXBindSwapBarrierSGIX(__GLXclientState *cl, GLbyte *pc)
-{
- ClientPtr client = cl->client;
- xGLXBindSwapBarrierSGIXReq *req = (xGLXBindSwapBarrierSGIXReq *)pc;
- DrawablePtr pDraw;
- __GLXpixmap *pGlxPixmap = NULL;
- __glXWindow *pGlxWindow = NULL;
- int rc;
-
- rc = dixLookupDrawable(&pDraw, req->drawable, client, 0, DixGetAttrAccess);
- if (rc != Success) {
- dixLookupResourceByType((pointer*) &pGlxPixmap, req->drawable,
- __glXPixmapRes, NullClient, DixUnknownAccess);
- if (pGlxPixmap) pDraw = pGlxPixmap->pDraw;
- }
-
- if (!pDraw && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
- dixLookupResourceByType((pointer*) &pGlxWindow, req->drawable,
- __glXWindowRes, NullClient, DixUnknownAccess);
- if (pGlxWindow) pDraw = pGlxWindow->pDraw;
- }
-
- if (!pDraw) {
- client->errorValue = req->drawable;
- return __glXBadDrawable;
- }
-
- return BindSwapBarrierSGIX(pDraw, req->barrier);
-}
-
-int __glXJoinSwapGroupSGIX(__GLXclientState *cl, GLbyte *pc)
-{
- ClientPtr client = cl->client;
- xGLXJoinSwapGroupSGIXReq *req = (xGLXJoinSwapGroupSGIXReq *)pc;
- DrawablePtr pDraw, pMember = NULL;
- __GLXpixmap *pGlxPixmap = NULL;
- __glXWindow *pGlxWindow = NULL;
- int rc;
-
- rc = dixLookupDrawable(&pDraw, req->drawable, client, 0, DixManageAccess);
- if (rc != Success) {
- dixLookupResourceByType((pointer*) &pGlxPixmap, req->drawable,
- __glXPixmapRes, NullClient, DixUnknownAccess);
- if (pGlxPixmap) pDraw = pGlxPixmap->pDraw;
- }
-
- if (!pDraw && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
- dixLookupResourceByType((pointer*) &pGlxWindow, req->drawable,
- __glXWindowRes, NullClient, DixUnknownAccess);
- if (pGlxWindow) pDraw = pGlxWindow->pDraw;
- }
-
- if (!pDraw) {
- client->errorValue = req->drawable;
- return __glXBadDrawable;
- }
-
- if (req->member != None) {
- rc = dixLookupDrawable(&pMember, req->member, client, 0,
- DixGetAttrAccess);
- if (rc != Success) {
- dixLookupResourceByType((pointer*) &pGlxPixmap, req->member,
- __glXPixmapRes, NullClient,
- DixUnknownAccess);
- if (pGlxPixmap) pMember = pGlxPixmap->pDraw;
- }
-
- if (!pMember && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
- dixLookupResourceByType((pointer*) &pGlxWindow, req->member,
- __glXWindowRes, NullClient,
- DixUnknownAccess);
- if (pGlxWindow) pMember = pGlxWindow->pDraw;
- }
-
- if (!pMember) {
- client->errorValue = req->member;
- return __glXBadDrawable;
- }
- }
-
- return JoinSwapGroupSGIX(pDraw, pMember);
-}
-
-
-/*
-** Destroy a GL context as an X resource.
-*/
-int __glXDestroyContext(__GLXclientState *cl, GLbyte *pc)
-{
- ClientPtr client = cl->client;
- xGLXDestroyContextReq *req = (xGLXDestroyContextReq *) pc;
- xGLXDestroyContextReq *be_req;
- GLXContextID gcId = req->context;
- __GLXcontext *glxc;
- int from_screen = 0;
- int to_screen = 0;
- int s;
-
- dixLookupResourceByType((pointer*) &glxc, gcId, __glXContextRes,
- NullClient, DixUnknownAccess);
- if (glxc) {
- /*
- ** Just free the resource; don't actually destroy the context,
- ** because it might be in use. The
- ** destroy method will be called by the resource destruction routine
- ** if necessary.
- */
- FreeResourceByType(gcId, __glXContextRes, FALSE);
-
- from_screen = to_screen = glxc->pScreen->myNum;
-
- } else {
- client->errorValue = gcId;
- return __glXBadContext;
- }
-
-#ifdef PANORAMIX
- if (!noPanoramiXExtension) {
- from_screen = 0;
- to_screen = screenInfo.numScreens - 1;
- }
-#endif
-
- /*
- * send DestroyContext request to all back-end servers
- */
- for (s=from_screen; s<=to_screen; s++) {
- DMXScreenInfo *dmxScreen = &dmxScreens[s];
- Display *dpy = GetBackEndDisplay(cl,s);
-
- LockDisplay(dpy);
- GetReq(GLXDestroyContext,be_req);
- be_req->reqType = dmxScreen->glxMajorOpcode;
- be_req->glxCode = X_GLXDestroyContext;
- be_req->context = glxc->real_ids[s-from_screen];
- UnlockDisplay(dpy);
- SyncHandle();
- }
-
- return Success;
-}
-
-/*****************************************************************************/
-
-/*
-** For each client, the server keeps a table of all the contexts that are
-** current for that client (each thread of a client may have its own current
-** context). These routines add, change, and lookup contexts in the table.
-*/
-
-/*
-** Add a current context, and return the tag that will be used to refer to it.
-*/
-static int AddCurrentContext(__GLXclientState *cl, __GLXcontext *glxc, DrawablePtr pDraw)
-{
- int i;
- int num = cl->numCurrentContexts;
- __GLXcontext **table = cl->currentContexts;
-
- if (!glxc) return -1;
-
- /*
- ** Try to find an empty slot and use it.
- */
- for (i=0; i < num; i++) {
- if (!table[i]) {
- table[i] = glxc;
- return i+1;
- }
- }
- /*
- ** Didn't find a free slot, so we'll have to grow the table.
- */
- if (!num) {
- table = (__GLXcontext **) malloc(sizeof(__GLXcontext *));
- cl->currentDrawables = (DrawablePtr *) malloc(sizeof(DrawablePtr));
- cl->be_currentCTag = (GLXContextTag *) malloc(screenInfo.numScreens *sizeof(GLXContextTag));
- } else {
- table = (__GLXcontext **) realloc(table,
- (num+1)*sizeof(__GLXcontext *));
- cl->currentDrawables = (DrawablePtr *) realloc(
- cl->currentDrawables ,
- (num+1)*sizeof(DrawablePtr));
- cl->be_currentCTag = (GLXContextTag *) realloc(cl->be_currentCTag,
- (num+1)*screenInfo.numScreens*sizeof(GLXContextTag));
- }
- table[num] = glxc;
- cl->currentDrawables[num] = pDraw;
- cl->currentContexts = table;
- cl->numCurrentContexts++;
-
- memset(cl->be_currentCTag + num*screenInfo.numScreens, 0,
- screenInfo.numScreens * sizeof(GLXContextTag));
-
- return num+1;
-}
-
-/*
-** Given a tag, change the current context for the corresponding entry.
-*/
-static void ChangeCurrentContext(__GLXclientState *cl, __GLXcontext *glxc,
- GLXContextTag tag)
-{
- __GLXcontext **table = cl->currentContexts;
- table[tag-1] = glxc;
-}
-
-/*
-** Given a tag, and back-end screen number, retrives the current back-end
-** tag.
-*/
-int GetCurrentBackEndTag(__GLXclientState *cl, GLXContextTag tag, int s)
-{
- if (tag >0) {
- return( cl->be_currentCTag[ (tag-1)*screenInfo.numScreens + s ] );
- }
- else {
- return 0;
- }
-}
-
-/*
-** Given a tag, and back-end screen number, sets the current back-end
-** tag.
-*/
-static void SetCurrentBackEndTag(__GLXclientState *cl, GLXContextTag tag, int s, GLXContextTag be_tag)
-{
- if (tag >0) {
- cl->be_currentCTag[ (tag-1)*screenInfo.numScreens + s ] = be_tag;
- }
-}
-
-/*
-** For this implementation we have chosen to simply use the index of the
-** context's entry in the table as the context tag. A tag must be greater
-** than 0.
-*/
-__GLXcontext *__glXLookupContextByTag(__GLXclientState *cl, GLXContextTag tag)
-{
- int num = cl->numCurrentContexts;
-
- if (tag < 1 || tag > num) {
- return 0;
- } else {
- return cl->currentContexts[tag-1];
- }
-}
-
-DrawablePtr __glXLookupDrawableByTag(__GLXclientState *cl, GLXContextTag tag)
-{
- int num = cl->numCurrentContexts;
-
- if (tag < 1 || tag > num) {
- return 0;
- } else {
- return cl->currentDrawables[tag-1];
- }
-}
-
-/*****************************************************************************/
-
-static void StopUsingContext(__GLXcontext *glxc)
-{
- if (glxc) {
- if (glxc == __glXLastContext) {
- /* Tell server GL library */
- __glXLastContext = 0;
- }
- glxc->isCurrent = GL_FALSE;
- if (!glxc->idExists) {
- __glXFreeContext(glxc);
- }
- }
-}
-
-static void StartUsingContext(__GLXclientState *cl, __GLXcontext *glxc)
-{
- glxc->isCurrent = GL_TRUE;
-}
-
-/*****************************************************************************/
-/*
-** Make an OpenGL context and drawable current.
-*/
-static int MakeCurrent(__GLXclientState *cl,
- GLXDrawable drawable,
- GLXDrawable readdrawable,
- GLXContextID context,
- GLXContextTag oldContextTag)
-{
- ClientPtr client = cl->client;
- DrawablePtr pDraw = NULL;
- DrawablePtr pReadDraw = NULL;
- xGLXMakeCurrentReadSGIReply new_reply;
- xGLXMakeCurrentReq *be_req;
- xGLXMakeCurrentReply be_reply;
- xGLXMakeContextCurrentReq *be_new_req;
- xGLXMakeContextCurrentReply be_new_reply;
- GLXDrawable drawId = drawable;
- GLXDrawable readId = readdrawable;
- GLXContextID contextId = context;
- __GLXpixmap *pGlxPixmap = 0;
- __GLXpixmap *pReadGlxPixmap = 0;
- __GLXcontext *glxc, *prevglxc;
- GLXContextTag tag = oldContextTag;
- WindowPtr pWin = NULL;
- WindowPtr pReadWin = NULL;
- __glXWindow *pGlxWindow = NULL;
- __glXWindow *pGlxReadWindow = NULL;
- __glXPbuffer *pGlxPbuffer = NULL;
- __glXPbuffer *pGlxReadPbuffer = NULL;
-#ifdef PANORAMIX
- PanoramiXRes *pXinDraw = NULL;
- PanoramiXRes *pXinReadDraw = NULL;
-#endif
- int from_screen = 0;
- int to_screen = 0;
- int s, rc;
-
- /*
- ** If one is None and the other isn't, it's a bad match.
- */
- if ((drawId == None && contextId != None) ||
- (drawId != None && contextId == None)) {
- return BadMatch;
- }
-
- /*
- ** Lookup old context. If we have one, it must be in a usable state.
- */
- if (tag != 0) {
- prevglxc = __glXLookupContextByTag(cl, tag);
- if (!prevglxc) {
- /*
- ** Tag for previous context is invalid.
- */
- return __glXBadContextTag;
- }
- } else {
- prevglxc = 0;
- }
-
- /*
- ** Lookup new context. It must not be current for someone else.
- */
- if (contextId != None) {
- dixLookupResourceByType((pointer*) &glxc, contextId, __glXContextRes,
- NullClient, DixUnknownAccess);
- if (!glxc) {
- client->errorValue = contextId;
- return __glXBadContext;
- }
- if ((glxc != prevglxc) && glxc->isCurrent) {
- /* Context is current to somebody else */
- return BadAccess;
- }
- } else {
- /* Switching to no context. Ignore new drawable. */
- glxc = 0;
- }
-
- if (drawId != None) {
- rc = dixLookupDrawable(&pDraw, drawId, client, 0, DixWriteAccess);
- if (rc == Success) {
- if (pDraw->type == DRAWABLE_WINDOW) {
- /*
- ** Drawable is an X Window.
- */
- VisualID vid;
- pWin = (WindowPtr)pDraw;
- vid = wVisual(pWin);
-
- new_reply.writeVid = (glxc->pFBConfig ? glxc->pFBConfig->id : vid);
- new_reply.writeType = GLX_WINDOW_TYPE;
-
- /*
- ** Check if window and context are similar.
- */
- if ((vid != glxc->pVisual->vid) ||
- (pWin->drawable.pScreen != glxc->pScreen)) {
- client->errorValue = drawId;
- return BadMatch;
- }
-
- from_screen = to_screen = pWin->drawable.pScreen->myNum;
-
- } else {
- /*
- ** An X Pixmap is not allowed as a parameter (a GLX Pixmap
- ** is, but it must first be created with glxCreateGLXPixmap).
- */
- client->errorValue = drawId;
- return __glXBadDrawable;
- }
- }
-
- if (!pDraw) {
- dixLookupResourceByType((pointer*) &pGlxPixmap, drawId,
- __glXPixmapRes, NullClient,
- DixUnknownAccess);
- if (pGlxPixmap) {
- /*
- ** Check if pixmap and context are similar.
- */
- if (pGlxPixmap->pScreen != glxc->pScreen ||
- pGlxPixmap->pGlxVisual != glxc->pGlxVisual) {
- client->errorValue = drawId;
- return BadMatch;
- }
- pDraw = pGlxPixmap->pDraw;
-
- new_reply.writeVid = (glxc->pFBConfig ? glxc->pFBConfig->id :
- pGlxPixmap->pGlxVisual->vid);
-
- new_reply.writeType = GLX_PIXMAP_TYPE;
-
- from_screen = to_screen = pGlxPixmap->pScreen->myNum;
-
- }
- }
-
- if (!pDraw && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
- dixLookupResourceByType((pointer*) &pGlxWindow, drawId,
- __glXWindowRes, NullClient,
- DixUnknownAccess);
- if (pGlxWindow) {
- /*
- ** Drawable is a GLXWindow.
- **
- ** Check if GLX window and context are similar.
- */
- if (pGlxWindow->pScreen != glxc->pScreen ||
- pGlxWindow->pGlxFBConfig != glxc->pFBConfig) {
- client->errorValue = drawId;
- return BadMatch;
- }
-
- pDraw = pGlxWindow->pDraw;
- new_reply.writeVid = pGlxWindow->pGlxFBConfig->id;
- new_reply.writeType = GLX_GLXWINDOW_TYPE;
- }
-
- }
-
- if (!pDraw && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
- dixLookupResourceByType((pointer*) &pGlxPbuffer, drawId,
- __glXPbufferRes, NullClient,
- DixUnknownAccess);
- if (pGlxPbuffer) {
- if (pGlxPbuffer->pScreen != glxc->pScreen ||
- pGlxPbuffer->pFBConfig != glxc->pFBConfig) {
- client->errorValue = drawId;
- return BadMatch;
- }
-
- pDraw = (DrawablePtr)pGlxPbuffer;
- new_reply.writeVid = pGlxPbuffer->pFBConfig->id;
- new_reply.writeType = GLX_PBUFFER_TYPE;
- }
- }
-
- if (!pDraw) {
- /*
- ** Drawable is not a Window , GLXWindow or a GLXPixmap.
- */
- client->errorValue = drawId;
- return __glXBadDrawable;
- }
-
- } else {
- pDraw = 0;
- }
-
- if (readId != None && readId != drawId ) {
- rc = dixLookupDrawable(&pReadDraw, readId, client, 0, DixReadAccess);
- if (rc == Success) {
- if (pReadDraw->type == DRAWABLE_WINDOW) {
- /*
- ** Drawable is an X Window.
- */
- VisualID vid;
- pReadWin = (WindowPtr)pDraw;
- vid = wVisual(pReadWin);
-
- new_reply.readVid = (glxc->pFBConfig ? glxc->pFBConfig->id : vid);
- new_reply.readType = GLX_WINDOW_TYPE;
-
- /*
- ** Check if window and context are similar.
- */
- if ((vid != glxc->pVisual->vid) ||
- (pReadWin->drawable.pScreen != glxc->pScreen)) {
- client->errorValue = readId;
- return BadMatch;
- }
-
- } else {
-
- /*
- ** An X Pixmap is not allowed as a parameter (a GLX Pixmap
- ** is, but it must first be created with glxCreateGLXPixmap).
- */
- client->errorValue = readId;
- return __glXBadDrawable;
- }
- }
-
- if (!pReadDraw) {
- dixLookupResourceByType((pointer*) &pReadGlxPixmap, readId,
- __glXPixmapRes, NullClient,
- DixUnknownAccess);
- if (pReadGlxPixmap) {
- /*
- ** Check if pixmap and context are similar.
- */
- if (pReadGlxPixmap->pScreen != glxc->pScreen ||
- pReadGlxPixmap->pGlxVisual != glxc->pGlxVisual) {
- client->errorValue = readId;
- return BadMatch;
- }
- pReadDraw = pReadGlxPixmap->pDraw;
-
- new_reply.readVid = (glxc->pFBConfig ? glxc->pFBConfig->id :
- pReadGlxPixmap->pGlxVisual->vid );
- new_reply.readType = GLX_PIXMAP_TYPE;
-
- }
- }
-
- if (!pReadDraw && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
- dixLookupResourceByType((pointer*) &pGlxReadWindow, readId,
- __glXWindowRes, NullClient,
- DixUnknownAccess);
- if (pGlxReadWindow) {
- /*
- ** Drawable is a GLXWindow.
- **
- ** Check if GLX window and context are similar.
- */
- if (pGlxReadWindow->pScreen != glxc->pScreen ||
- pGlxReadWindow->pGlxFBConfig != glxc->pFBConfig) {
- client->errorValue = readId;
- return BadMatch;
- }
-
- pReadDraw = pGlxReadWindow->pDraw;
- new_reply.readVid = pGlxReadWindow->pGlxFBConfig->id;
- new_reply.readType = GLX_GLXWINDOW_TYPE;
- }
- }
-
- if (!pReadDraw && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
- dixLookupResourceByType((pointer*) &pGlxReadPbuffer, readId,
- __glXPbufferRes, NullClient,
- DixUnknownAccess);
- if (pGlxReadPbuffer) {
- if (pGlxReadPbuffer->pScreen != glxc->pScreen ||
- pGlxReadPbuffer->pFBConfig != glxc->pFBConfig) {
- client->errorValue = drawId;
- return BadMatch;
- }
-
- pReadDraw = (DrawablePtr)pGlxReadPbuffer;
- new_reply.readVid = pGlxReadPbuffer->pFBConfig->id;
- new_reply.readType = GLX_PBUFFER_TYPE;
- }
- }
-
- if (!pReadDraw) {
- /*
- ** Drawable is neither a Window nor a GLXPixmap.
- */
- client->errorValue = readId;
- return __glXBadDrawable;
- }
-
- } else {
- pReadDraw = pDraw;
- pReadGlxPixmap = pGlxPixmap;
- pReadWin = pWin;
- new_reply.readVid = new_reply.writeVid;
- new_reply.readType = new_reply.writeType;
- }
-
- if (prevglxc) {
-
- if (prevglxc->pGlxPixmap) {
- /*
- ** The previous drawable was a glx pixmap, release it.
- */
- prevglxc->pGlxPixmap->refcnt--;
- __glXFreeGLXPixmap( prevglxc->pGlxPixmap );
- prevglxc->pGlxPixmap = 0;
- }
-
- if (prevglxc->pGlxReadPixmap) {
- /*
- ** The previous drawable was a glx pixmap, release it.
- */
- prevglxc->pGlxReadPixmap->refcnt--;
- __glXFreeGLXPixmap( prevglxc->pGlxReadPixmap );
- prevglxc->pGlxReadPixmap = 0;
- }
-
- if (prevglxc->pGlxWindow) {
- /*
- ** The previous drawable was a glx window, release it.
- */
- prevglxc->pGlxWindow->refcnt--;
- __glXFreeGLXWindow( prevglxc->pGlxWindow );
- prevglxc->pGlxWindow = 0;
- }
-
- if (prevglxc->pGlxReadWindow) {
- /*
- ** The previous drawable was a glx window, release it.
- */
- prevglxc->pGlxReadWindow->refcnt--;
- __glXFreeGLXWindow( prevglxc->pGlxReadWindow );
- prevglxc->pGlxReadWindow = 0;
- }
-
- if (prevglxc->pGlxPbuffer) {
- /*
- ** The previous drawable was a glx Pbuffer, release it.
- */
- prevglxc->pGlxPbuffer->refcnt--;
- __glXFreeGLXPbuffer( prevglxc->pGlxPbuffer );
- prevglxc->pGlxPbuffer = 0;
- }
-
- if (prevglxc->pGlxReadPbuffer) {
- /*
- ** The previous drawable was a glx Pbuffer, release it.
- */
- prevglxc->pGlxReadPbuffer->refcnt--;
- __glXFreeGLXPbuffer( prevglxc->pGlxReadPbuffer );
- prevglxc->pGlxReadPbuffer = 0;
- }
-
- ChangeCurrentContext(cl, glxc, tag);
- ChangeCurrentContext(cl, glxc, tag);
- StopUsingContext(prevglxc);
- } else {
- tag = AddCurrentContext(cl, glxc, pDraw);
- }
- if (glxc) {
-
- glxc->pGlxPixmap = pGlxPixmap;
- glxc->pGlxReadPixmap = pReadGlxPixmap;
- glxc->pGlxWindow = pGlxWindow;
- glxc->pGlxReadWindow = pGlxReadWindow;
- glxc->pGlxPbuffer = pGlxPbuffer;
- glxc->pGlxReadPbuffer = pGlxReadPbuffer;
-
- if (pGlxPixmap) {
- pGlxPixmap->refcnt++;
- }
-
- if (pReadGlxPixmap) {
- pReadGlxPixmap->refcnt++;
- }
-
- if (pGlxWindow) {
- pGlxWindow->refcnt++;
- }
-
- if (pGlxReadWindow) {
- pGlxReadWindow->refcnt++;
- }
-
- if (pGlxPbuffer) {
- pGlxPbuffer->refcnt++;
- }
-
- if (pGlxReadPbuffer) {
- pGlxReadPbuffer->refcnt++;
- }
-
- StartUsingContext(cl, glxc);
- new_reply.contextTag = tag;
- } else {
- new_reply.contextTag = 0;
- }
- new_reply.length = 0;
- new_reply.type = X_Reply;
- new_reply.sequenceNumber = client->sequence;
-
-#ifdef PANORAMIX
- if (!noPanoramiXExtension) {
- from_screen = 0;
- to_screen = screenInfo.numScreens - 1;
-
- if (pDraw && new_reply.writeType != GLX_PBUFFER_TYPE) {
- dixLookupResourceByClass((pointer*) &pXinDraw,
- pDraw->id, XRC_DRAWABLE,
- client, DixReadAccess);
- }
-
- if (pReadDraw && pReadDraw != pDraw &&
- new_reply.readType != GLX_PBUFFER_TYPE) {
- dixLookupResourceByClass((pointer*) &pXinReadDraw,
- pReadDraw->id, XRC_DRAWABLE,
- client, DixReadAccess);
- }
- else {
- pXinReadDraw = pXinDraw;
- }
- }
-#endif
-
-
- /* send the MakeCurrent request to all required
- * back-end servers.
- */
- for (s = from_screen; s<=to_screen; s++) {
- DMXScreenInfo *dmxScreen = &dmxScreens[s];
- Display *dpy = GetBackEndDisplay(cl,s);
- unsigned int be_draw = None;
- unsigned int be_read_draw = None;
-
- if (pGlxPixmap) {
- be_draw = pGlxPixmap->be_xids[s];
- }
- else if (pGlxPbuffer) {
- be_draw = pGlxPbuffer->be_xids[s];
- }
-#ifdef PANORAMIX
- else if (pXinDraw) {
- dixLookupWindow(&pWin, pXinDraw->info[s].id, client, DixReadAccess);
- }
-#endif
- else if (pGlxWindow) {
- pWin = (WindowPtr)pGlxWindow->pDraw;
- }
-
- if (pWin && be_draw == None) {
- be_draw = (unsigned int)(DMX_GET_WINDOW_PRIV(pWin))->window;
- if (!be_draw) {
- /* it might be that the window did not created yet on the */
- /* back-end server (lazy window creation option), force */
- /* creation of the window */
- dmxCreateAndRealizeWindow( pWin, TRUE );
- be_draw = (unsigned int)(DMX_GET_WINDOW_PRIV(pWin))->window;
- }
- }
-
- /*
- * Before sending the MakeCurrent request - sync the
- * X11 connection to the back-end servers to make sure
- * that drawable is already created
- */
- dmxSync( dmxScreen, 1 );
-
- if (drawId == readId) {
- LockDisplay(dpy);
- GetReq(GLXMakeCurrent, be_req);
- be_req->reqType = dmxScreen->glxMajorOpcode;
- be_req->glxCode = X_GLXMakeCurrent;
- be_req->drawable = be_draw;
- be_req->context = (unsigned int)(glxc ? glxc->real_ids[s-from_screen] : 0);
- be_req->oldContextTag = GetCurrentBackEndTag(cl, tag, s);
- if (!_XReply(dpy, (xReply *) &be_reply, 0, False)) {
-
- /* The make current failed */
- UnlockDisplay(dpy);
- SyncHandle();
- return( BE_TO_CLIENT_ERROR(dmxLastErrorEvent.error_code) );
- }
-
- UnlockDisplay(dpy);
- SyncHandle();
-
- SetCurrentBackEndTag( cl, tag, s, be_reply.contextTag );
- }
- else {
-
- if (pReadGlxPixmap) {
- be_read_draw = pReadGlxPixmap->be_xids[s];
- }
- else if (pGlxReadPbuffer) {
- be_read_draw = pGlxReadPbuffer->be_xids[s];
- }
-#ifdef PANORAMIX
- else if (pXinReadDraw) {
- dixLookupWindow(&pReadWin, pXinReadDraw->info[s].id, client,
- DixReadAccess);
- }
-#endif
- else if (pGlxReadWindow) {
- pReadWin = (WindowPtr)pGlxReadWindow->pDraw;
- }
-
- if (pReadWin && be_read_draw == None) {
- be_read_draw = (unsigned int)(DMX_GET_WINDOW_PRIV(pReadWin))->window;
- if (!be_read_draw) {
- /* it might be that the window did not created yet on the */
- /* back-end server (lazy window creation option), force */
- /* creation of the window */
- dmxCreateAndRealizeWindow( pReadWin, TRUE );
- be_read_draw = (unsigned int)(DMX_GET_WINDOW_PRIV(pReadWin))->window;
- dmxSync( dmxScreen, 1 );
- }
- }
-
- if ( __GLX_IS_VERSION_SUPPORTED(1,3) ) {
- LockDisplay(dpy);
- GetReq(GLXMakeContextCurrent, be_new_req);
- be_new_req->reqType = dmxScreen->glxMajorOpcode;
- be_new_req->glxCode = X_GLXMakeContextCurrent;
- be_new_req->drawable = be_draw;
- be_new_req->readdrawable = be_read_draw;
- be_new_req->context = (unsigned int)(glxc ? glxc->real_ids[s-from_screen] : 0);
- be_new_req->oldContextTag = GetCurrentBackEndTag(cl, tag, s);
- if (!_XReply(dpy, (xReply *) &be_new_reply, 0, False)) {
-
- /* The make current failed */
- UnlockDisplay(dpy);
- SyncHandle();
- return( BE_TO_CLIENT_ERROR(dmxLastErrorEvent.error_code) );
- }
-
- UnlockDisplay(dpy);
- SyncHandle();
-
- SetCurrentBackEndTag( cl, tag, s, be_new_reply.contextTag );
- }
- else if (glxIsExtensionSupported("GLX_SGI_make_current_read")) {
- xGLXMakeCurrentReadSGIReq *ext_req;
- xGLXVendorPrivateWithReplyReq *vpreq;
- xGLXMakeCurrentReadSGIReply ext_reply;
-
- LockDisplay(dpy);
- GetReqExtra(GLXVendorPrivateWithReply,
- sz_xGLXMakeCurrentReadSGIReq - sz_xGLXVendorPrivateWithReplyReq,
- vpreq);
- ext_req = (xGLXMakeCurrentReadSGIReq *)vpreq;
- ext_req->reqType = dmxScreen->glxMajorOpcode;
- ext_req->glxCode = X_GLXVendorPrivateWithReply;
- ext_req->vendorCode = X_GLXvop_MakeCurrentReadSGI;
- ext_req->drawable = be_draw;
- ext_req->readable = be_read_draw;
- ext_req->context = (unsigned int)(glxc ? glxc->real_ids[s-from_screen] : 0);
- ext_req->oldContextTag = GetCurrentBackEndTag(cl, tag, s);
- if (!_XReply(dpy, (xReply *) &ext_reply, 0, False)) {
-
- /* The make current failed */
- UnlockDisplay(dpy);
- SyncHandle();
- return( BE_TO_CLIENT_ERROR(dmxLastErrorEvent.error_code) );
- }
-
- UnlockDisplay(dpy);
- SyncHandle();
-
- SetCurrentBackEndTag( cl, tag, s, ext_reply.contextTag );
-
- }
- else {
- return BadMatch;
- }
- }
-
- XFlush( dpy );
- }
-
- if (client->swapped) {
- __glXSwapMakeCurrentReply(client, &new_reply);
- } else {
- WriteToClient(client, sz_xGLXMakeContextCurrentReply, (char *)&new_reply);
- }
-
- return Success;
-}
-
-int __glXMakeCurrent(__GLXclientState *cl, GLbyte *pc)
-{
- xGLXMakeCurrentReq *req = (xGLXMakeCurrentReq *) pc;
-
- return( MakeCurrent(cl, req->drawable, req->drawable,
- req->context, req->oldContextTag ) );
-}
-
-int __glXMakeContextCurrent(__GLXclientState *cl, GLbyte *pc)
-{
- xGLXMakeContextCurrentReq *req = (xGLXMakeContextCurrentReq *) pc;
-
- return( MakeCurrent(cl, req->drawable, req->readdrawable,
- req->context, req->oldContextTag ) );
-}
-
-int __glXMakeCurrentReadSGI(__GLXclientState *cl, GLbyte *pc)
-{
- xGLXMakeCurrentReadSGIReq *req = (xGLXMakeCurrentReadSGIReq *) pc;
-
- return( MakeCurrent(cl, req->drawable, req->readable,
- req->context, req->oldContextTag ) );
-}
-
-int __glXIsDirect(__GLXclientState *cl, GLbyte *pc)
-{
- ClientPtr client = cl->client;
- xGLXIsDirectReq *req = (xGLXIsDirectReq *) pc;
- xGLXIsDirectReply reply;
- __GLXcontext *glxc;
-
- /*
- ** Find the GL context.
- */
- dixLookupResourceByType((pointer*) &glxc, req->context, __glXContextRes,
- NullClient, DixUnknownAccess);
- if (!glxc) {
- client->errorValue = req->context;
- return __glXBadContext;
- }
-
- reply.isDirect = 0;
- reply.length = 0;
- reply.type = X_Reply;
- reply.sequenceNumber = client->sequence;
-
- if (client->swapped) {
- __glXSwapIsDirectReply(client, &reply);
- } else {
- WriteToClient(client, sz_xGLXIsDirectReply, (char *)&reply);
- }
-
- return Success;
-}
-
-int __glXQueryVersion(__GLXclientState *cl, GLbyte *pc)
-{
- ClientPtr client = cl->client;
-/* xGLXQueryVersionReq *req = (xGLXQueryVersionReq *) pc; */
- xGLXQueryVersionReply reply;
-
- /*
- ** Server should take into consideration the version numbers sent by the
- ** client if it wants to work with older clients; however, in this
- ** implementation the server just returns its version number.
- */
- reply.majorVersion = __glXVersionMajor;
- reply.minorVersion = __glXVersionMinor;
- reply.length = 0;
- reply.type = X_Reply;
- reply.sequenceNumber = client->sequence;
-
- if (client->swapped) {
- __glXSwapQueryVersionReply(client, &reply);
- } else {
- WriteToClient(client, sz_xGLXQueryVersionReply, (char *)&reply);
- }
- return Success;
-}
-
-int __glXWaitGL(__GLXclientState *cl, GLbyte *pc)
-{
- xGLXWaitGLReq *req = (xGLXWaitGLReq *)pc;
- xGLXWaitGLReq *be_req = (xGLXWaitGLReq *)pc;
- int from_screen = 0;
- int to_screen = 0;
- int s;
- __GLXcontext *glxc = NULL;
-
- if (req->contextTag != 0) {
- glxc = __glXLookupContextByTag(cl, req->contextTag);
- if (glxc) {
- from_screen = to_screen = glxc->pScreen->myNum;
- }
- }
-
-#ifdef PANORAMIX
- if (!noPanoramiXExtension) {
- from_screen = 0;
- to_screen = screenInfo.numScreens - 1;
- }
-#endif
-
- for (s=from_screen; s<=to_screen; s++) {
- DMXScreenInfo *dmxScreen = &dmxScreens[s];
- Display *dpy = GetBackEndDisplay(cl,s);
-
- LockDisplay(dpy);
- GetReq(GLXWaitGL,be_req);
- be_req->reqType = dmxScreen->glxMajorOpcode;
- be_req->glxCode = X_GLXWaitGL;
- be_req->contextTag = (glxc ? GetCurrentBackEndTag(cl,req->contextTag,s) : 0);
- UnlockDisplay(dpy);
- SyncHandle();
-
- XSync(dpy, False);
- }
-
- return Success;
-}
-
-int __glXWaitX(__GLXclientState *cl, GLbyte *pc)
-{
- xGLXWaitXReq *req = (xGLXWaitXReq *)pc;
- xGLXWaitXReq *be_req;
- int from_screen = 0;
- int to_screen = 0;
- int s;
- __GLXcontext *glxc = NULL;
-
- if (req->contextTag != 0) {
- glxc = __glXLookupContextByTag(cl, req->contextTag);
- if (glxc) {
- from_screen = to_screen = glxc->pScreen->myNum;
- }
- }
-
-#ifdef PANORAMIX
- if (!noPanoramiXExtension) {
- from_screen = 0;
- to_screen = screenInfo.numScreens - 1;
- }
-#endif
-
- for (s=from_screen; s<=to_screen; s++) {
- DMXScreenInfo *dmxScreen = &dmxScreens[s];
- Display *dpy = GetBackEndDisplay(cl,s);
-
- dmxSync( dmxScreen, 1 );
-
- LockDisplay(dpy);
- GetReq(GLXWaitX,be_req);
- be_req->reqType = dmxScreen->glxMajorOpcode;
- be_req->glxCode = X_GLXWaitX;
- be_req->contextTag = (glxc ? GetCurrentBackEndTag(cl,req->contextTag,s) : 0);
- UnlockDisplay(dpy);
- SyncHandle();
-
- XFlush( dpy );
- }
-
- return Success;
-}
-
-int __glXCopyContext(__GLXclientState *cl, GLbyte *pc)
-{
- ClientPtr client = cl->client;
- xGLXCopyContextReq *be_req;
- xGLXCopyContextReq *req = (xGLXCopyContextReq *) pc;
- GLXContextID source = req->source;
- GLXContextID dest = req->dest;
- GLXContextTag tag = req->contextTag;
- unsigned long mask = req->mask;
- __GLXcontext *src, *dst;
- int s;
- int from_screen = 0;
- int to_screen = 0;
-
- /*
- ** Check that each context exists.
- */
- dixLookupResourceByType((pointer*) &src, source, __glXContextRes,
- NullClient, DixUnknownAccess);
- if (!src) {
- client->errorValue = source;
- return __glXBadContext;
- }
- dixLookupResourceByType((pointer*) &dst, dest, __glXContextRes,
- NullClient, DixUnknownAccess);
- if (!dst) {
- client->errorValue = dest;
- return __glXBadContext;
- }
-
- /*
- ** They must be in the same address space, and same screen.
- */
- if (src->pGlxScreen != dst->pGlxScreen) {
- client->errorValue = source;
- return BadMatch;
- }
-
- /*
- ** The destination context must not be current for any client.
- */
- if (dst->isCurrent) {
- client->errorValue = dest;
- return BadAccess;
- }
-
- if (tag) {
- __GLXcontext *tagcx = __glXLookupContextByTag(cl, tag);
-
- if (!tagcx) {
- return __glXBadContextTag;
- }
- if (tagcx != src) {
- /*
- ** This would be caused by a faulty implementation of the client
- ** library.
- */
- return BadMatch;
- }
- }
-
- from_screen = to_screen = src->pScreen->myNum;
-
-#ifdef PANORAMIX
- if (!noPanoramiXExtension) {
- from_screen = 0;
- to_screen = screenInfo.numScreens - 1;
- }
-#endif
-
- for (s=from_screen; s<=to_screen; s++) {
- DMXScreenInfo *dmxScreen = &dmxScreens[s];
- Display *dpy = GetBackEndDisplay(cl,s);
-
- LockDisplay(dpy);
- GetReq(GLXCopyContext,be_req);
- be_req->reqType = dmxScreen->glxMajorOpcode;
- be_req->glxCode = X_GLXCopyContext;
- be_req->source = (unsigned int)src->real_ids[s-from_screen];
- be_req->dest = (unsigned int)dst->real_ids[s-from_screen];
- be_req->mask = mask;
- be_req->contextTag = (tag ? GetCurrentBackEndTag(cl,req->contextTag,s) : 0);
- UnlockDisplay(dpy);
- SyncHandle();
- }
-
- return Success;
-}
-
-int __glXGetVisualConfigs(__GLXclientState *cl, GLbyte *pc)
-{
- ClientPtr client = cl->client;
- xGLXGetVisualConfigsReq *req = (xGLXGetVisualConfigsReq *) pc;
- xGLXGetVisualConfigsReply reply;
- __GLXscreenInfo *pGlxScreen;
- __GLXvisualConfig *pGlxVisual;
- CARD32 buf[__GLX_TOTAL_CONFIG];
- unsigned int screen;
- int i, p;
-
- screen = req->screen;
- if (screen >= screenInfo.numScreens) {
- /* The client library must send a valid screen number. */
- client->errorValue = screen;
- return BadValue;
- }
- pGlxScreen = &__glXActiveScreens[screen];
-
- reply.numVisuals = pGlxScreen->numGLXVisuals;
- reply.numProps = __GLX_TOTAL_CONFIG;
- reply.length = (pGlxScreen->numGLXVisuals * __GLX_SIZE_CARD32 *
- __GLX_TOTAL_CONFIG) >> 2;
- reply.type = X_Reply;
- reply.sequenceNumber = client->sequence;
-
- WriteToClient(client, sz_xGLXGetVisualConfigsReply, (char *)&reply);
-
- for (i=0; i < pGlxScreen->numVisuals; i++) {
- pGlxVisual = &pGlxScreen->pGlxVisual[i];
- if (!pGlxScreen->isGLXvis[i] || pGlxVisual->vid == 0) {
- /* not a usable visual */
- continue;
- }
- p = 0;
- buf[p++] = pGlxVisual->vid;
- buf[p++] = pGlxVisual->class;
- buf[p++] = pGlxVisual->rgba;
-
- buf[p++] = pGlxVisual->redSize;
- buf[p++] = pGlxVisual->greenSize;
- buf[p++] = pGlxVisual->blueSize;
- buf[p++] = pGlxVisual->alphaSize;
- buf[p++] = pGlxVisual->accumRedSize;
- buf[p++] = pGlxVisual->accumGreenSize;
- buf[p++] = pGlxVisual->accumBlueSize;
- buf[p++] = pGlxVisual->accumAlphaSize;
-
- buf[p++] = pGlxVisual->doubleBuffer;
- buf[p++] = pGlxVisual->stereo;
-
- buf[p++] = pGlxVisual->bufferSize;
- buf[p++] = pGlxVisual->depthSize;
- buf[p++] = pGlxVisual->stencilSize;
- buf[p++] = pGlxVisual->auxBuffers;
- buf[p++] = pGlxVisual->level;
- /*
- ** Add token/value pairs for extensions.
- */
- buf[p++] = GLX_VISUAL_CAVEAT_EXT;
- buf[p++] = pGlxVisual->visualRating;
- buf[p++] = GLX_TRANSPARENT_TYPE_EXT;
- buf[p++] = pGlxVisual->transparentPixel;
- buf[p++] = GLX_TRANSPARENT_RED_VALUE_EXT;
- buf[p++] = pGlxVisual->transparentRed;
- buf[p++] = GLX_TRANSPARENT_GREEN_VALUE_EXT;
- buf[p++] = pGlxVisual->transparentGreen;
- buf[p++] = GLX_TRANSPARENT_BLUE_VALUE_EXT;
- buf[p++] = pGlxVisual->transparentBlue;
- buf[p++] = GLX_TRANSPARENT_ALPHA_VALUE_EXT;
- buf[p++] = pGlxVisual->transparentAlpha;
- buf[p++] = GLX_TRANSPARENT_INDEX_VALUE_EXT;
- buf[p++] = pGlxVisual->transparentIndex;
- buf[p++] = GLX_SAMPLES_SGIS;
- buf[p++] = pGlxVisual->multiSampleSize;
- buf[p++] = GLX_SAMPLE_BUFFERS_SGIS;
- buf[p++] = pGlxVisual->nMultiSampleBuffers;
- buf[p++] = GLX_VISUAL_SELECT_GROUP_SGIX;
- buf[p++] = pGlxVisual->visualSelectGroup;
-
- WriteToClient(client, __GLX_SIZE_CARD32 * __GLX_TOTAL_CONFIG,
- (char *)buf);
- }
- return Success;
-}
-
-/*
-** Create a GLX Pixmap from an X Pixmap.
-*/
-static int CreateGLXPixmap(__GLXclientState *cl,
- VisualID visual, GLXFBConfigID fbconfigId,
- int screenNum, XID pixmapId, XID glxpixmapId )
-{
- ClientPtr client = cl->client;
- xGLXCreateGLXPixmapReq *be_req;
- xGLXCreatePixmapReq *be_new_req;
- DrawablePtr pDraw;
- ScreenPtr pScreen;
- VisualPtr pVisual;
- __GLXpixmap *pGlxPixmap;
- __GLXscreenInfo *pGlxScreen;
- __GLXvisualConfig *pGlxVisual;
- __GLXFBConfig *pFBConfig;
- int i, s, rc;
- int from_screen, to_screen;
-#ifdef PANORAMIX
- PanoramiXRes *pXinDraw = NULL;
-#endif
-
- rc = dixLookupDrawable(&pDraw, pixmapId, client, M_DRAWABLE_PIXMAP,
- DixAddAccess);
- if (rc != Success)
- return rc;
-
- /*
- ** Check if screen of visual matches screen of pixmap.
- */
- pScreen = pDraw->pScreen;
- if (screenNum != pScreen->myNum) {
- return BadMatch;
- }
-
- if (fbconfigId == 0 && visual == 0) {
- return BadValue;
- }
-
- if (fbconfigId != None) {
- pFBConfig = glxLookupFBConfig( fbconfigId );
- if (!pFBConfig) {
- client->errorValue = fbconfigId;
- return BadValue;
- }
- visual = pFBConfig->associatedVisualId;
- }
- else {
- pFBConfig = NULL;
- }
-
- if (visual != None) {
- /*
- ** Find the VisualRec for this visual.
- */
- pVisual = pScreen->visuals;
- for (i=0; i < pScreen->numVisuals; i++, pVisual++) {
- if (pVisual->vid == visual) {
- break;
- }
- }
- if (i == pScreen->numVisuals) {
- client->errorValue = visual;
- return BadValue;
- }
- /*
- ** Check if depth of visual matches depth of pixmap.
- */
- if (pVisual->nplanes != pDraw->depth) {
- client->errorValue = visual;
- return BadMatch;
- }
-
- /*
- ** Get configuration of the visual.
- */
- pGlxScreen = &__glXActiveScreens[screenNum];
- pGlxVisual = pGlxScreen->pGlxVisual;
- for (i = 0; i < pGlxScreen->numVisuals; i++, pGlxVisual++) {
- if (pGlxVisual->vid == visual) {
- break;
- }
- }
- if (i == pGlxScreen->numVisuals) {
- /*
- ** Visual not support on this screen by this OpenGL implementation.
- */
- client->errorValue = visual;
- return BadValue;
- }
-
-
- /* find the FBConfig for that visual (if any) */
- if ( pFBConfig == NULL ) {
- pFBConfig = glxLookupFBConfigByVID( visual );
-
- if ( pFBConfig == NULL ) {
- /*
- * visual does not have an FBConfig ???
- client->errorValue = visual;
- return BadValue;
- */
- }
- }
- }
- else {
- pVisual = NULL;
- pGlxVisual = NULL;
- pGlxScreen = &__glXActiveScreens[pDraw->pScreen->myNum];
- }
-
- pGlxPixmap = (__GLXpixmap *) malloc(sizeof(__GLXpixmap));
- if (!pGlxPixmap) {
- return BadAlloc;
- }
- pGlxPixmap->be_xids = (XID *) malloc(sizeof(XID) * screenInfo.numScreens);
- if (!pGlxPixmap->be_xids) {
- free( pGlxPixmap );
- return BadAlloc;
- }
-
- pGlxPixmap->pDraw = pDraw;
- pGlxPixmap->pGlxScreen = pGlxScreen;
- pGlxPixmap->pGlxVisual = pGlxVisual;
- pGlxPixmap->pFBConfig = pFBConfig;
- pGlxPixmap->pScreen = pScreen;
- pGlxPixmap->idExists = True;
- pGlxPixmap->refcnt = 0;
-
- /*
- ** Bump the ref count on the X pixmap so it won't disappear.
- */
- ((PixmapPtr) pDraw)->refcnt++;
-
- /*
- * send the request to the back-end server(s)
- */
- from_screen = to_screen = screenNum;
-#ifdef PANORAMIX
- if (!noPanoramiXExtension) {
- from_screen = 0;
- to_screen = screenInfo.numScreens - 1;
-
- dixLookupResourceByClass((pointer*) &pXinDraw,
- pDraw->id, XRC_DRAWABLE,
- client, DixReadAccess);
- }
-#endif
-
- for (s=from_screen; s<=to_screen; s++) {
-
- DMXScreenInfo *dmxScreen = &dmxScreens[s];
- Display *dpy = GetBackEndDisplay(cl,s);
- Pixmap be_pixmap;
- DrawablePtr pRealDraw = pDraw;
-
-#ifdef PANORAMIX
- if (pXinDraw) {
- dixLookupDrawable(&pRealDraw, pXinDraw->info[s].id, client, 0,
- DixAddAccess);
- }
-#endif
-
- be_pixmap = (DMX_GET_PIXMAP_PRIV((PixmapPtr)pRealDraw))->pixmap;
-
- /* make sure pixmap already created on back-end */
- dmxSync( dmxScreen, 1 );
-
- if ( pFBConfig && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
- __GLXFBConfig *be_FBConfig = glxLookupBackEndFBConfig( pFBConfig->id, s );
-
- LockDisplay(dpy);
- pGlxPixmap->be_xids[s] = XAllocID(dpy);
- GetReq(GLXCreatePixmap,be_new_req);
- be_new_req->reqType = dmxScreen->glxMajorOpcode;
- be_new_req->glxCode = X_GLXCreatePixmap;
- be_new_req->screen = DefaultScreen(dpy);
- be_new_req->fbconfig = be_FBConfig->id;
- be_new_req->pixmap = (unsigned int)be_pixmap;
- be_new_req->glxpixmap = (unsigned int)pGlxPixmap->be_xids[s];
- be_new_req->numAttribs = 0;
- UnlockDisplay(dpy);
- SyncHandle();
- }
- else if (pFBConfig && glxIsExtensionSupported("GLX_SGIX_fbconfig")) {
- __GLXFBConfig *be_FBConfig = glxLookupBackEndFBConfig( pFBConfig->id, s );
- xGLXCreateGLXPixmapWithConfigSGIXReq *ext_req;
- xGLXVendorPrivateReq *vpreq;
-
- LockDisplay(dpy);
- pGlxPixmap->be_xids[s] = XAllocID(dpy);
- GetReqExtra(GLXVendorPrivate,
- sz_xGLXCreateGLXPixmapWithConfigSGIXReq-sz_xGLXVendorPrivateReq,
- vpreq);
- ext_req = (xGLXCreateGLXPixmapWithConfigSGIXReq *)vpreq;
- ext_req->reqType = dmxScreen->glxMajorOpcode;
- ext_req->glxCode = X_GLXVendorPrivate;
- ext_req->vendorCode = X_GLXvop_CreateGLXPixmapWithConfigSGIX;
- ext_req->screen = DefaultScreen(dpy);
- ext_req->fbconfig = be_FBConfig->id;
- ext_req->pixmap = (unsigned int)be_pixmap;
- ext_req->glxpixmap = (unsigned int)pGlxPixmap->be_xids[s];
- UnlockDisplay(dpy);
- SyncHandle();
- }
- else if (pGlxVisual) {
- LockDisplay(dpy);
- pGlxPixmap->be_xids[s] = XAllocID(dpy);
- GetReq(GLXCreateGLXPixmap,be_req);
- be_req->reqType = dmxScreen->glxMajorOpcode;
- be_req->glxCode = X_GLXCreateGLXPixmap;
- be_req->screen = DefaultScreen(dpy);
- be_req->visual = (unsigned int)glxMatchGLXVisualInConfigList(
- pGlxVisual,
- dmxScreen->glxVisuals,
- dmxScreen->numGlxVisuals );
- be_req->pixmap = (unsigned int)be_pixmap;
- be_req->glxpixmap = (unsigned int)pGlxPixmap->be_xids[s];
- UnlockDisplay(dpy);
- SyncHandle();
- }
- else {
- client->errorValue = ( visual ? visual : fbconfigId );
- free( pGlxPixmap );
- return BadValue;
- }
-
- XFlush( dpy );
- }
-
- if (!(AddResource(glxpixmapId, __glXPixmapRes, pGlxPixmap))) {
- free( pGlxPixmap );
- return BadAlloc;
- }
-
- return Success;
-}
-
-int __glXCreateGLXPixmap(__GLXclientState *cl, GLbyte *pc)
-{
- xGLXCreateGLXPixmapReq *req = (xGLXCreateGLXPixmapReq *) pc;
-
- return( CreateGLXPixmap(cl, req->visual, None,
- req->screen, req->pixmap, req->glxpixmap) );
-}
-
-int __glXCreatePixmap(__GLXclientState *cl, GLbyte *pc)
-{
- xGLXCreatePixmapReq *req = (xGLXCreatePixmapReq *) pc;
-
- return( CreateGLXPixmap(cl, None, req->fbconfig,
- req->screen, req->pixmap, req->glxpixmap) );
-}
-
-int __glXDestroyGLXPixmap(__GLXclientState *cl, GLbyte *pc)
-{
- ClientPtr client = cl->client;
- xGLXDestroyGLXPixmapReq *req = (xGLXDestroyGLXPixmapReq *) pc;
- XID glxpixmap = req->glxpixmap;
- __GLXpixmap *pGlxPixmap;
- int s;
- int from_screen, to_screen;
-
- /*
- ** Check if it's a valid GLX pixmap.
- */
- dixLookupResourceByType((pointer*) &pGlxPixmap, glxpixmap,
- __glXPixmapRes, NullClient, DixUnknownAccess);
- if (!pGlxPixmap) {
- client->errorValue = glxpixmap;
- return __glXBadPixmap;
- }
- FreeResource(glxpixmap, FALSE);
-
- /*
- * destroy the pixmap on the back-end server(s).
- */
- from_screen = to_screen = pGlxPixmap->pDraw->pScreen->myNum;
-#ifdef PANORAMIX
- if (!noPanoramiXExtension) {
- from_screen = 0;
- to_screen = screenInfo.numScreens - 1;
- }
-#endif
-
- for (s=from_screen; s<=to_screen; s++) {
- DMXScreenInfo *dmxScreen = &dmxScreens[s];
- Display *dpy = GetBackEndDisplay(cl,s);
-
- /* make sure pixmap exist in back-end */
- dmxSync( dmxScreen, 1 );
-
- LockDisplay(dpy);
- GetReq(GLXDestroyGLXPixmap,req);
- req->reqType = dmxScreen->glxMajorOpcode;
- req->glxCode = X_GLXDestroyGLXPixmap;
- req->glxpixmap = (unsigned int)pGlxPixmap->be_xids[s];
- UnlockDisplay(dpy);
- SyncHandle();
- }
-
-
- return Success;
-}
-
-/*****************************************************************************/
-
-/*
-** NOTE: There is no portable implementation for swap buffers as of
-** this time that is of value. Consequently, this code must be
-** implemented by somebody other than SGI.
-*/
-int __glXDoSwapBuffers(__GLXclientState *cl, XID drawId, GLXContextTag tag)
-{
- ClientPtr client = cl->client;
- DrawablePtr pDraw;
- xGLXSwapBuffersReq *be_req;
- WindowPtr pWin = NULL;
- __GLXpixmap *pGlxPixmap = NULL;
- __GLXcontext *glxc = NULL;
-#ifdef PANORAMIX
- PanoramiXRes *pXinDraw = NULL;
-#endif
- __glXWindow *pGlxWindow = NULL;
- int from_screen = 0;
- int to_screen = 0;
- int s, rc;
-
- /*
- ** Check that the GLX drawable is valid.
- */
- rc = dixLookupDrawable(&pDraw, drawId, client, 0, DixWriteAccess);
- if (rc == Success) {
- from_screen = to_screen = pDraw->pScreen->myNum;
-
- if (pDraw->type == DRAWABLE_WINDOW) {
- /*
- ** Drawable is an X window.
- */
- pWin = (WindowPtr)pDraw;
- } else {
- /*
- ** Drawable is an X pixmap, which is not allowed.
- */
- client->errorValue = drawId;
- return __glXBadDrawable;
- }
- }
-
- if (!pDraw) {
- dixLookupResourceByType((pointer*) &pGlxPixmap, drawId,
- __glXPixmapRes, NullClient, DixUnknownAccess);
- if (pGlxPixmap) {
- /*
- ** Drawable is a GLX pixmap.
- */
- pDraw = pGlxPixmap->pDraw;
- from_screen = to_screen = pGlxPixmap->pScreen->myNum;
- }
- }
-
- if (!pDraw && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
- dixLookupResourceByType((pointer*) &pGlxWindow, drawId,
- __glXWindowRes, NullClient, DixUnknownAccess);
- if (pGlxWindow) {
- /*
- ** Drawable is a GLXWindow.
- */
- pDraw = pGlxWindow->pDraw;
- from_screen = to_screen = pGlxWindow->pScreen->myNum;
- }
- }
-
- if (!pDraw) {
- /*
- ** Drawable is neither a X window nor a GLX pixmap.
- */
- client->errorValue = drawId;
- return __glXBadDrawable;
- }
-
- if (tag) {
- glxc = __glXLookupContextByTag(cl, tag);
- if (!glxc) {
- return __glXBadContextTag;
- }
- }
-
-#ifdef PANORAMIX
- if (!noPanoramiXExtension) {
- from_screen = 0;
- to_screen = screenInfo.numScreens - 1;
- dixLookupResourceByClass((pointer*) &pXinDraw,
- pDraw->id, XRC_DRAWABLE,
- client, DixReadAccess);
- }
-#endif
-
- /* If requested, send a glFinish to all back-end servers before swapping. */
- if (dmxGLXFinishSwap) {
- for (s=from_screen; s<=to_screen; s++) {
- Display *dpy = GetBackEndDisplay(cl,s);
- DMXScreenInfo *dmxScreen = &dmxScreens[s];
- xGLXSingleReq *finishReq;
- xGLXSingleReply reply;
-
-#define X_GLXSingle 0 /* needed by GetReq below */
-
- LockDisplay(dpy);
- GetReq(GLXSingle,finishReq);
- finishReq->reqType = dmxScreen->glxMajorOpcode;
- finishReq->glxCode = X_GLsop_Finish;
- finishReq->contextTag = (tag ? GetCurrentBackEndTag(cl,tag,s) : 0);
- (void) _XReply(dpy, (xReply*) &reply, 0, False);
- UnlockDisplay(dpy);
- SyncHandle();
- }
- }
-
- /* If requested, send an XSync to all back-end servers before swapping. */
- if (dmxGLXSyncSwap) {
- for (s=from_screen; s<=to_screen; s++)
- XSync(GetBackEndDisplay(cl,s), False);
- }
-
-
- /* send the SwapBuffers request to all back-end servers */
-
- for (s=from_screen; s<=to_screen; s++) {
- DMXScreenInfo *dmxScreen = &dmxScreens[s];
- Display *dpy = GetBackEndDisplay(cl,s);
- unsigned int be_draw = 0;
-
- if (pGlxPixmap) {
- be_draw = (unsigned int)pGlxPixmap->be_xids[s];
- }
-#ifdef PANORAMIX
- else if (pXinDraw) {
- dixLookupWindow(&pWin, pXinDraw->info[s].id, client, DixReadAccess);
- }
-#endif
- else if (pGlxWindow) {
- pWin = (WindowPtr)pGlxWindow->pDraw;
- }
-
- if (pWin && !be_draw) {
- be_draw = (unsigned int)(DMX_GET_WINDOW_PRIV(pWin))->window;
- if (!be_draw) {
- /* it might be that the window did not created yet on the */
- /* back-end server (lazy window creation option), force */
- /* creation of the window */
- dmxCreateAndRealizeWindow( pWin, TRUE );
- be_draw = (unsigned int)(DMX_GET_WINDOW_PRIV(pWin))->window;
- }
- }
-
- dmxSync( dmxScreen, 1 );
-
- LockDisplay(dpy);
- GetReq(GLXSwapBuffers,be_req);
- be_req->reqType = dmxScreen->glxMajorOpcode;
- be_req->glxCode = X_GLXSwapBuffers;
- be_req->drawable = be_draw;
- be_req->contextTag = ( tag ? GetCurrentBackEndTag(cl,tag,s) : 0 );
- UnlockDisplay(dpy);
- SyncHandle();
- XFlush(dpy);
- }
-
- return Success;
-}
-
-int __glXSwapBuffers(__GLXclientState *cl, GLbyte *pc)
-{
- ClientPtr client = cl->client;
- DrawablePtr pDraw;
- xGLXSwapBuffersReq *req = (xGLXSwapBuffersReq *) pc;
- GLXContextTag tag = req->contextTag;
- XID drawId = req->drawable;
- __GLXpixmap *pGlxPixmap = NULL;
- __GLXcontext *glxc = NULL;
- __glXWindow *pGlxWindow = NULL;
- int rc;
-
- /*
- ** Check that the GLX drawable is valid.
- */
- rc = dixLookupDrawable(&pDraw, drawId, client, 0, DixWriteAccess);
- if (rc == Success) {
- if (pDraw->type != DRAWABLE_WINDOW) {
- /*
- ** Drawable is an X pixmap, which is not allowed.
- */
- client->errorValue = drawId;
- return __glXBadDrawable;
- }
- }
-
- if (!pDraw) {
- dixLookupResourceByType((pointer*) &pGlxPixmap, drawId,
- __glXPixmapRes, NullClient, DixUnknownAccess);
- if (pGlxPixmap) {
- /*
- ** Drawable is a GLX pixmap.
- */
- pDraw = pGlxPixmap->pDraw;
- }
- }
-
- if (!pDraw && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
- dixLookupResourceByType((pointer*) &pGlxWindow, drawId,
- __glXWindowRes, NullClient, DixUnknownAccess);
- if (pGlxWindow) {
- /*
- ** Drawable is a GLXWindow.
- */
- pDraw = pGlxWindow->pDraw;
- }
- }
-
- if (!pDraw) {
- /*
- ** Drawable is neither a X window nor a GLX pixmap.
- */
- client->errorValue = drawId;
- return __glXBadDrawable;
- }
-
- if (tag) {
- glxc = __glXLookupContextByTag(cl, tag);
- if (!glxc) {
- return __glXBadContextTag;
- }
- }
-
- if (pDraw &&
- pDraw->type == DRAWABLE_WINDOW &&
- DMX_GET_WINDOW_PRIV((WindowPtr)pDraw)->swapGroup) {
- return SGSwapBuffers(cl, drawId, tag, pDraw);
- }
-
- return __glXDoSwapBuffers(cl, drawId, tag);
-}
-
-
-/************************************************************************/
-
-/*
-** Render and Renderlarge are not in the GLX API. They are used by the GLX
-** client library to send batches of GL rendering commands.
-*/
-
-/*
-** Execute all the drawing commands in a request.
-*/
-int __glXRender(__GLXclientState *cl, GLbyte *pc)
-{
- xGLXRenderReq *req;
- xGLXRenderReq *be_req;
- int size;
- __GLXcontext *glxc;
- int from_screen = 0;
- int to_screen = 0;
- int s;
-
- /*
- ** NOTE: much of this code also appears in the byteswapping version of this
- ** routine, __glXSwapRender(). Any changes made here should also be
- ** duplicated there.
- */
-
- req = (xGLXRenderReq *) pc;
-
- glxc = __glXLookupContextByTag(cl, req->contextTag);
- if (!glxc) {
- return 0;
- }
- from_screen = to_screen = glxc->pScreen->myNum;
-
-#ifdef PANORAMIX
- if (!noPanoramiXExtension) {
- from_screen = 0;
- to_screen = screenInfo.numScreens - 1;
- }
-#endif
-
- pc += sz_xGLXRenderReq;
- size = (req->length << 2) - sz_xGLXRenderReq;
-
- /*
- * just forward the request to back-end server(s)
- */
- for (s=from_screen; s<=to_screen; s++) {
- DMXScreenInfo *dmxScreen = &dmxScreens[s];
- Display *dpy = GetBackEndDisplay(cl,s);
-
- LockDisplay(dpy);
- GetReq(GLXRender,be_req);
- be_req->reqType = dmxScreen->glxMajorOpcode;
- be_req->glxCode = X_GLXRender;
- be_req->length = req->length;
- be_req->contextTag = GetCurrentBackEndTag(cl,req->contextTag,s);
- _XSend(dpy, (const char *)pc, size);
- UnlockDisplay(dpy);
- SyncHandle();
- }
-
- return Success;
-}
-
-/*
-** Execute a large rendering request (one that spans multiple X requests).
-*/
-int __glXRenderLarge(__GLXclientState *cl, GLbyte *pc)
-{
- xGLXRenderLargeReq *req;
- xGLXRenderLargeReq *be_req;
- __GLXcontext *glxc;
- int from_screen = 0;
- int to_screen = 0;
- int s;
-
- /*
- ** NOTE: much of this code also appears in the byteswapping version of this
- ** routine, __glXSwapRenderLarge(). Any changes made here should also be
- ** duplicated there.
- */
-
- req = (xGLXRenderLargeReq *) pc;
- glxc = __glXLookupContextByTag(cl, req->contextTag);
- if (!glxc) {
- return 0;
- }
- from_screen = to_screen = glxc->pScreen->myNum;
-
-#ifdef PANORAMIX
- if (!noPanoramiXExtension) {
- from_screen = 0;
- to_screen = screenInfo.numScreens - 1;
- }
-#endif
-
- pc += sz_xGLXRenderLargeReq;
-
- /*
- * just forward the request to back-end server(s)
- */
- for (s=from_screen; s<=to_screen; s++) {
- DMXScreenInfo *dmxScreen = &dmxScreens[s];
- Display *dpy = GetBackEndDisplay(cl,s);
-
- GetReq(GLXRenderLarge,be_req);
- be_req->reqType = dmxScreen->glxMajorOpcode;
- be_req->glxCode = X_GLXRenderLarge;
- be_req->contextTag = GetCurrentBackEndTag(cl,req->contextTag,s);
- be_req->length = req->length;
- be_req->requestNumber = req->requestNumber;
- be_req->requestTotal = req->requestTotal;
- be_req->dataBytes = req->dataBytes;
- Data(dpy, (const char *)pc, req->dataBytes);
- UnlockDisplay(dpy);
- SyncHandle();
-
- }
-
- return Success;
-}
-
-
-/************************************************************************/
-
-int __glXVendorPrivate(__GLXclientState *cl, GLbyte *pc)
-{
- xGLXVendorPrivateReq *req;
-
- req = (xGLXVendorPrivateReq *) pc;
-
- switch( req->vendorCode ) {
-
- case X_GLvop_DeleteTexturesEXT:
- return __glXVForwardSingleReq( cl, pc );
- break;
-
- case X_GLXvop_SwapIntervalSGI:
- if (glxIsExtensionSupported("SGI_swap_control")) {
- return __glXVForwardSingleReq( cl, pc );
- }
- else {
- return Success;
- }
- break;
-
-#if 0 /* glx 1.3 */
- case X_GLXvop_CreateGLXVideoSourceSGIX:
- break;
- case X_GLXvop_DestroyGLXVideoSourceSGIX:
- break;
- case X_GLXvop_CreateGLXPixmapWithConfigSGIX:
- break;
- case X_GLXvop_DestroyGLXPbufferSGIX:
- break;
- case X_GLXvop_ChangeDrawableAttributesSGIX:
- break;
-#endif
-
- case X_GLXvop_BindSwapBarrierSGIX:
- return __glXBindSwapBarrierSGIX( cl, pc );
- break;
-
- case X_GLXvop_JoinSwapGroupSGIX:
- return __glXJoinSwapGroupSGIX( cl, pc );
- break;
-
- case X_GLXvop_CreateContextWithConfigSGIX:
- return __glXCreateContextWithConfigSGIX( cl, pc );
- break;
-
- default:
- /*
- ** unsupported private request
- */
- cl->client->errorValue = req->vendorCode;
- return __glXUnsupportedPrivateRequest;
- }
-
- cl->client->errorValue = req->vendorCode;
- return __glXUnsupportedPrivateRequest;
-
-}
-
-int __glXVendorPrivateWithReply(__GLXclientState *cl, GLbyte *pc)
-{
- xGLXVendorPrivateWithReplyReq *req;
-
- req = (xGLXVendorPrivateWithReplyReq *) pc;
-
- switch( req->vendorCode ) {
-
- case X_GLvop_GetConvolutionFilterEXT:
- case X_GLvop_GetConvolutionParameterfvEXT:
- case X_GLvop_GetConvolutionParameterivEXT:
- case X_GLvop_GetSeparableFilterEXT:
- case X_GLvop_GetHistogramEXT:
- case X_GLvop_GetHistogramParameterivEXT:
- case X_GLvop_GetMinmaxEXT:
- case X_GLvop_GetMinmaxParameterfvEXT:
- case X_GLvop_GetMinmaxParameterivEXT:
- case X_GLvop_AreTexturesResidentEXT:
- case X_GLvop_IsTextureEXT:
- return( __glXVForwardPipe0WithReply(cl, pc) );
- break;
-
- case X_GLvop_GenTexturesEXT:
- return( __glXVForwardAllWithReply(cl, pc) );
- break;
-
-
-#if 0 /* glx1.3 */
- case X_GLvop_GetDetailTexFuncSGIS:
- case X_GLvop_GetSharpenTexFuncSGIS:
- case X_GLvop_GetColorTableSGI:
- case X_GLvop_GetColorTableParameterfvSGI:
- case X_GLvop_GetColorTableParameterivSGI:
- case X_GLvop_GetTexFilterFuncSGIS:
- case X_GLvop_GetInstrumentsSGIX:
- case X_GLvop_InstrumentsBufferSGIX:
- case X_GLvop_PollInstrumentsSGIX:
- case X_GLvop_FlushRasterSGIX:
- case X_GLXvop_CreateGLXPbufferSGIX:
- case X_GLXvop_GetDrawableAttributesSGIX:
- case X_GLXvop_QueryHyperpipeNetworkSGIX:
- case X_GLXvop_QueryHyperpipeConfigSGIX:
- case X_GLXvop_HyperpipeConfigSGIX:
- case X_GLXvop_DestroyHyperpipeConfigSGIX:
-#endif
- case X_GLXvop_QueryMaxSwapBarriersSGIX:
- return( __glXQueryMaxSwapBarriersSGIX(cl, pc) );
- break;
-
- case X_GLXvop_GetFBConfigsSGIX:
- return( __glXGetFBConfigsSGIX(cl, pc) );
- break;
-
- case X_GLXvop_MakeCurrentReadSGI:
- return( __glXMakeCurrentReadSGI(cl, pc) );
- break;
-
- case X_GLXvop_QueryContextInfoEXT:
- return( __glXQueryContextInfoEXT(cl,pc) );
- break;
-
- default:
- /*
- ** unsupported private request
- */
- cl->client->errorValue = req->vendorCode;
- return __glXUnsupportedPrivateRequest;
- }
-
-}
-
-int __glXQueryExtensionsString(__GLXclientState *cl, GLbyte *pc)
-{
- ClientPtr client = cl->client;
- xGLXQueryExtensionsStringReq *req = (xGLXQueryExtensionsStringReq *) pc;
- xGLXQueryExtensionsStringReply reply;
- GLint screen;
- size_t length;
- int len, numbytes;
- char *be_buf;
-
-#ifdef FWD_QUERY_REQ
- xGLXQueryExtensionsStringReq *be_req;
- xGLXQueryExtensionsStringReply be_reply;
- DMXScreenInfo *dmxScreen;
- Display *dpy;
- int slop;
-#endif
-
- screen = req->screen;
-
- /*
- ** Check if screen exists.
- */
- if ((screen < 0) || (screen >= screenInfo.numScreens)) {
- client->errorValue = screen;
- return BadValue;
- }
-
-#ifdef FWD_QUERY_REQ
- dmxScreen = &dmxScreens[screen];
-
- /* Send the glXQueryServerString request */
- dpy = GetBackEndDisplay(cl,screen);
- LockDisplay(dpy);
- GetReq(GLXQueryExtensionsString,be_req);
- be_req->reqType = dmxScreen->glxMajorOpcode;
- be_req->glxCode = X_GLXQueryServerString;
- be_req->screen = DefaultScreen(dpy);
- _XReply(dpy, (xReply*) &be_reply, 0, False);
- len = (int)be_reply.length;
- numbytes = (int)be_reply.n;
- slop = numbytes * __GLX_SIZE_INT8 & 3;
- be_buf = (char *)malloc(numbytes);
- if (!be_buf) {
- /* Throw data on the floor */
- _XEatData(dpy, len);
- } else {
- _XRead(dpy, (char *)be_buf, numbytes);
- if (slop) _XEatData(dpy,4-slop);
- }
- UnlockDisplay(dpy);
- SyncHandle();
-
-#else
-
- be_buf = __glXGetServerString(GLX_EXTENSIONS);
- numbytes = strlen(be_buf) + 1;
- len = __GLX_PAD(numbytes) >> 2;
-
-#endif
-
- length = len;
- reply.type = X_Reply;
- reply.sequenceNumber = client->sequence;
- reply.length = len;
- reply.n = numbytes;
-
- if (client->swapped) {
- glxSwapQueryExtensionsStringReply(client, &reply, be_buf);
- } else {
- WriteToClient(client, sz_xGLXQueryExtensionsStringReply,(char *)&reply);
- WriteToClient(client, (int)(length << 2), (char *)be_buf);
- }
-
- return Success;
-}
-
-int __glXQueryServerString(__GLXclientState *cl, GLbyte *pc)
-{
- ClientPtr client = cl->client;
- xGLXQueryServerStringReq *req = (xGLXQueryServerStringReq *) pc;
- xGLXQueryServerStringReply reply;
- int name;
- GLint screen;
- size_t length;
- int len, numbytes;
- char *be_buf;
-#ifdef FWD_QUERY_REQ
- xGLXQueryServerStringReq *be_req;
- xGLXQueryServerStringReply be_reply;
- DMXScreenInfo *dmxScreen;
- Display *dpy;
- int slop;
-#endif
-
- name = req->name;
- screen = req->screen;
- /*
- ** Check if screen exists.
- */
- if ((screen < 0) || (screen >= screenInfo.numScreens)) {
- client->errorValue = screen;
- return BadValue;
- }
-
-#ifdef FWD_QUERY_REQ
- dmxScreen = &dmxScreens[screen];
-
- /* Send the glXQueryServerString request */
- dpy = GetBackEndDisplay(cl,screen);
- LockDisplay(dpy);
- GetReq(GLXQueryServerString,be_req);
- be_req->reqType = dmxScreen->glxMajorOpcode;
- be_req->glxCode = X_GLXQueryServerString;
- be_req->screen = DefaultScreen(dpy);
- be_req->name = name;
- _XReply(dpy, (xReply*) &be_reply, 0, False);
- len = (int)be_reply.length;
- numbytes = (int)be_reply.n;
- slop = numbytes * __GLX_SIZE_INT8 & 3;
- be_buf = (char *)malloc(numbytes);
- if (!be_buf) {
- /* Throw data on the floor */
- _XEatData(dpy, len);
- } else {
- _XRead(dpy, (char *)be_buf, numbytes);
- if (slop) _XEatData(dpy,4-slop);
- }
- UnlockDisplay(dpy);
- SyncHandle();
-
-#else
- be_buf = __glXGetServerString(name);
- numbytes = strlen(be_buf) + 1;
- len = __GLX_PAD(numbytes) >> 2;
-#endif
-
- length = len;
- reply.type = X_Reply;
- reply.sequenceNumber = client->sequence;
- reply.length = length;
- reply.n = numbytes;
-
- if (client->swapped) {
- glxSwapQueryServerStringReply(client, &reply, be_buf);
- } else {
- WriteToClient(client, sz_xGLXQueryServerStringReply, (char *)&reply);
- WriteToClient(client, (int)(length << 2), be_buf);
- }
-
- return Success;
-}
-
-int __glXClientInfo(__GLXclientState *cl, GLbyte *pc)
-{
- xGLXClientInfoReq *req = (xGLXClientInfoReq *) pc;
- xGLXClientInfoReq *be_req;
- const char *buf;
- int from_screen = 0;
- int to_screen = 0;
- int s;
-
- cl->GLClientmajorVersion = req->major;
- cl->GLClientminorVersion = req->minor;
- free(cl->GLClientextensions);
- buf = (const char *)(req+1);
- cl->GLClientextensions = strdup(buf);
-
- to_screen = screenInfo.numScreens - 1;
-
- for (s=from_screen; s<=to_screen; s++)
- {
- DMXScreenInfo *dmxScreen = &dmxScreens[s];
- Display *dpy = GetBackEndDisplay(cl,s);
-
- LockDisplay(dpy);
- GetReq(GLXClientInfo,be_req);
- be_req->reqType = dmxScreen->glxMajorOpcode;
- be_req->glxCode = X_GLXClientInfo;
- be_req->major = req->major;
- be_req->minor = req->minor;
- be_req->length = req->length;
- be_req->numbytes = req->numbytes;
- Data(dpy, buf, req->numbytes);
-
- UnlockDisplay(dpy);
- SyncHandle();
- }
-
- return Success;
-}
-
-int __glXUseXFont(__GLXclientState *cl, GLbyte *pc)
-{
- ClientPtr client = cl->client;
- xGLXUseXFontReq *req;
- xGLXUseXFontReq *be_req;
- FontPtr pFont;
- __GLXcontext *glxc = NULL;
- int from_screen = 0;
- int to_screen = 0;
- int s;
- dmxFontPrivPtr pFontPriv;
- DMXScreenInfo *dmxScreen;
- Display *dpy;
-
- req = (xGLXUseXFontReq *) pc;
-
- if (req->contextTag != 0) {
- glxc = __glXLookupContextByTag(cl, req->contextTag);
- if (glxc) {
- from_screen = to_screen = glxc->pScreen->myNum;
- }
- }
-
- /*
- ** Font can actually be either the ID of a font or the ID of a GC
- ** containing a font.
- */
- dixLookupResourceByType((pointer*) &pFont, req->font, RT_FONT,
- NullClient, DixUnknownAccess);
- if (!pFont) {
- GC *pGC;
- dixLookupResourceByType((pointer*) &pGC, req->font,
- RT_GC, NullClient,
- DixUnknownAccess);
- if (!pGC) {
- client->errorValue = req->font;
- return BadFont;
- }
- pFont = pGC->font;
- }
-
- pFontPriv = FontGetPrivate(pFont, dmxFontPrivateIndex);
-
-#ifdef PANORAMIX
- if (!noPanoramiXExtension) {
- from_screen = 0;
- to_screen = screenInfo.numScreens - 1;
- }
-#endif
-
-
- for (s=from_screen; s<=to_screen; s++) {
- dmxScreen = &dmxScreens[s];
- dpy = GetBackEndDisplay(cl,s);
-
- dmxSync( dmxScreen, 1 );
-
- LockDisplay(dpy);
- GetReq(GLXUseXFont,be_req);
- be_req->reqType = dmxScreen->glxMajorOpcode;
- be_req->glxCode = X_GLXUseXFont;
- be_req->contextTag = (glxc ? GetCurrentBackEndTag(cl,req->contextTag,s) : 0);
- be_req->font = pFontPriv->font[s]->fid;
- be_req->first = req->first;
- be_req->count = req->count;
- be_req->listBase = req->listBase;
- UnlockDisplay(dpy);
- SyncHandle();
-
- XSync( dpy, False );
- }
-
- return Success;
-}
-
-/*
- * start GLX 1.3 here
- */
-
-int __glXGetFBConfigs(__GLXclientState *cl, GLbyte *pc)
-{
- ClientPtr client = cl->client;
- xGLXGetFBConfigsReq *req = (xGLXGetFBConfigsReq *) pc;
- xGLXGetFBConfigsReply reply;
- __GLXFBConfig *pFBConfig;
- CARD32 buf[2 * __GLX_TOTAL_FBCONFIG_PROPS];
- int numAttribs = __GLX_TOTAL_FBCONFIG_PROPS;
- unsigned int screen = req->screen;
- int numFBConfigs, i, p;
- __GLXscreenInfo *pGlxScreen;
-
- if (screen >= screenInfo.numScreens) {
- /* The client library must send a valid screen number. */
- client->errorValue = screen;
- return BadValue;
- }
-
- pGlxScreen = &__glXActiveScreens[screen];
- numFBConfigs = __glXNumFBConfigs;
-
- reply.numFBConfigs = numFBConfigs;
- reply.numAttribs = numAttribs;
- reply.length = (numFBConfigs * 2 * numAttribs * __GLX_SIZE_CARD32) >> 2;
- reply.type = X_Reply;
- reply.sequenceNumber = client->sequence;
-
- if (client->swapped) {
- __GLX_DECLARE_SWAP_VARIABLES;
- __GLX_SWAP_SHORT(&reply.sequenceNumber);
- __GLX_SWAP_INT(&reply.length);
- __GLX_SWAP_INT(&reply.numFBConfigs);
- __GLX_SWAP_INT(&reply.numAttribs);
- }
- WriteToClient(client, sz_xGLXGetFBConfigsReply, (char *)&reply);
-
- for (i=0; i < numFBConfigs; i++) {
- int associatedVisualId = 0;
- int drawableTypeIndex;
- pFBConfig = __glXFBConfigs[ i * (screenInfo.numScreens+1) ];
-
- p = 0;
- /* core attributes */
- buf[p++] = GLX_FBCONFIG_ID;
- buf[p++] = pFBConfig->id;
- buf[p++] = GLX_BUFFER_SIZE;
- buf[p++] = pFBConfig->indexBits;
- buf[p++] = GLX_LEVEL;
- buf[p++] = pFBConfig->level;
- buf[p++] = GLX_DOUBLEBUFFER;
- buf[p++] = pFBConfig->doubleBufferMode;
- buf[p++] = GLX_STEREO;
- buf[p++] = pFBConfig->stereoMode;
- buf[p++] = GLX_AUX_BUFFERS;
- buf[p++] = pFBConfig->maxAuxBuffers;
- buf[p++] = GLX_RED_SIZE;
- buf[p++] = pFBConfig->redBits;
- buf[p++] = GLX_GREEN_SIZE;
- buf[p++] = pFBConfig->greenBits;
- buf[p++] = GLX_BLUE_SIZE;
- buf[p++] = pFBConfig->blueBits;
- buf[p++] = GLX_ALPHA_SIZE;
- buf[p++] = pFBConfig->alphaBits;
- buf[p++] = GLX_DEPTH_SIZE;
- buf[p++] = pFBConfig->depthBits;
- buf[p++] = GLX_STENCIL_SIZE;
- buf[p++] = pFBConfig->stencilBits;
- buf[p++] = GLX_ACCUM_RED_SIZE;
- buf[p++] = pFBConfig->accumRedBits;
- buf[p++] = GLX_ACCUM_GREEN_SIZE;
- buf[p++] = pFBConfig->accumGreenBits;
- buf[p++] = GLX_ACCUM_BLUE_SIZE;
- buf[p++] = pFBConfig->accumBlueBits;
- buf[p++] = GLX_ACCUM_ALPHA_SIZE;
- buf[p++] = pFBConfig->accumAlphaBits;
- buf[p++] = GLX_RENDER_TYPE;
- buf[p++] = pFBConfig->renderType;
- buf[p++] = GLX_DRAWABLE_TYPE;
- drawableTypeIndex = p;
- buf[p++] = pFBConfig->drawableType;
- buf[p++] = GLX_X_VISUAL_TYPE;
- buf[p++] = pFBConfig->visualType;
- buf[p++] = GLX_CONFIG_CAVEAT;
- buf[p++] = pFBConfig->visualCaveat;
- buf[p++] = GLX_TRANSPARENT_TYPE;
- buf[p++] = pFBConfig->transparentType;
- buf[p++] = GLX_TRANSPARENT_RED_VALUE;
- buf[p++] = pFBConfig->transparentRed;
- buf[p++] = GLX_TRANSPARENT_GREEN_VALUE;
- buf[p++] = pFBConfig->transparentGreen;
- buf[p++] = GLX_TRANSPARENT_BLUE_VALUE;
- buf[p++] = pFBConfig->transparentBlue;
- buf[p++] = GLX_TRANSPARENT_ALPHA_VALUE;
- buf[p++] = pFBConfig->transparentAlpha;
- buf[p++] = GLX_TRANSPARENT_INDEX_VALUE;
- buf[p++] = pFBConfig->transparentIndex;
- buf[p++] = GLX_MAX_PBUFFER_WIDTH;
- buf[p++] = pFBConfig->maxPbufferWidth;
- buf[p++] = GLX_MAX_PBUFFER_HEIGHT;
- buf[p++] = pFBConfig->maxPbufferHeight;
- buf[p++] = GLX_MAX_PBUFFER_PIXELS;
- buf[p++] = pFBConfig->maxPbufferPixels;
-
- /*
- * find the visual of the back-end server and match a visual
- * on the proxy.
- * do only once - if a visual is not yet associated.
- */
- if (pFBConfig->associatedVisualId == (unsigned int)-1) {
- DMXScreenInfo *dmxScreen = &dmxScreens[screen];
- __GLXFBConfig *be_pFBConfig = __glXFBConfigs[ i * (screenInfo.numScreens+1)+screen+1 ];
- __GLXvisualConfig *pGlxVisual = NULL;
- int v;
- int found = 0;
- for (v=0; v<dmxScreen->numGlxVisuals; v++) {
- if (dmxScreen->glxVisuals[v].vid == be_pFBConfig->associatedVisualId) {
- pGlxVisual = &dmxScreen->glxVisuals[v];
- break;
- }
- }
-
- if (pGlxVisual) {
- for (v=0; v<pGlxScreen->numVisuals; v++) {
- if (glxVisualsMatch(&pGlxScreen->pGlxVisual[v], pGlxVisual)) {
- associatedVisualId = pGlxScreen->pGlxVisual[v].vid;
- found = 1;
- break;
- }
- }
- }
-
- if (!found) {
- associatedVisualId = 0;
- pFBConfig->drawableType &= ~(GLX_WINDOW_BIT);
- buf[drawableTypeIndex] = pFBConfig->drawableType;
- }
-#ifdef PANORAMIX
- else if (!noPanoramiXExtension) {
- /* convert the associated visualId to the panoramix one */
- pFBConfig->associatedVisualId =
- PanoramiXTranslateVisualID(screen, v);
- }
-#endif
- }
- else {
- associatedVisualId = pFBConfig->associatedVisualId;
- }
-
- buf[p++] = GLX_VISUAL_ID;
- buf[p++] = associatedVisualId;
-
- /* SGIS_multisample attributes */
- buf[p++] = GLX_SAMPLES_SGIS;
- buf[p++] = pFBConfig->multiSampleSize;
- buf[p++] = GLX_SAMPLE_BUFFERS_SGIS;
- buf[p++] = pFBConfig->nMultiSampleBuffers;
-
- /* SGIX_pbuffer specific attributes */
- buf[p++] = GLX_OPTIMAL_PBUFFER_WIDTH_SGIX;
- buf[p++] = pFBConfig->optimalPbufferWidth;
- buf[p++] = GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX;
- buf[p++] = pFBConfig->optimalPbufferHeight;
-
- buf[p++] = GLX_VISUAL_SELECT_GROUP_SGIX;
- buf[p++] = pFBConfig->visualSelectGroup;
-
- if (client->swapped) {
- __GLX_DECLARE_SWAP_VARIABLES;
- __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
- __GLX_SWAP_INT_ARRAY((int *)buf, 2*numAttribs);
- }
- WriteToClient(client, 2*numAttribs * __GLX_SIZE_CARD32, (char *)buf);
- }
- return Success;
-}
-
-int __glXGetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc)
-{
- xGLXGetFBConfigsSGIXReq *req = (xGLXGetFBConfigsSGIXReq *)pc;
- xGLXGetFBConfigsReq new_req;
-
- new_req.reqType = req->reqType;
- new_req.glxCode = req->glxCode;
- new_req.length = req->length;
- new_req.screen = req->screen;
-
- return( __glXGetFBConfigs( cl, (GLbyte *)&new_req ) );
-}
-
-
-int __glXCreateWindow(__GLXclientState *cl, GLbyte *pc)
-{
- ClientPtr client = cl->client;
- xGLXCreateWindowReq *req = (xGLXCreateWindowReq *) pc;
- int screen = req->screen;
- GLXFBConfigID fbconfigId = req->fbconfig;
- XID windowId = req->window;
- XID glxwindowId = req->glxwindow;
- DrawablePtr pDraw;
- ScreenPtr pScreen;
- __glXWindow *pGlxWindow;
- __GLXFBConfig *pGlxFBConfig = NULL;
- VisualPtr pVisual;
- VisualID visId;
- int i, rc;
- pointer val;
-
- /*
- ** Check if windowId is valid
- */
- rc = dixLookupDrawable(&pDraw, windowId, client, M_DRAWABLE_WINDOW,
- DixAddAccess);
- if (rc != Success)
- return rc;
-
- /*
- ** Check if screen of window matches screen of fbconfig.
- */
- pScreen = pDraw->pScreen;
- if (screen != pScreen->myNum) {
- return BadMatch;
- }
-
- /*
- ** Find the FBConfigRec for this fbconfigid.
- */
- if (!(pGlxFBConfig = glxLookupFBConfig(fbconfigId))) {
- client->errorValue = fbconfigId;
- return __glXBadFBConfig;
- }
- visId = pGlxFBConfig->associatedVisualId;
-
- /*
- ** Check if the fbconfig supports rendering to windows
- */
- if( !(pGlxFBConfig->drawableType & GLX_WINDOW_BIT) ) {
- return BadMatch;
- }
-
- if (visId != None) {
- /*
- ** Check if the visual ID is valid for this screen.
- */
- pVisual = pScreen->visuals;
- for (i = 0; i < pScreen->numVisuals; i++, pVisual++) {
- if (pVisual->vid == visId) {
- break;
- }
- }
- if (i == pScreen->numVisuals) {
- client->errorValue = visId;
- return BadValue;
- }
-
- /*
- ** Check if color buffer depth of fbconfig matches depth
- ** of window.
- */
- if (pVisual->nplanes != pDraw->depth) {
- return BadMatch;
- }
- } else
- /*
- ** The window was created with no visual that corresponds
- ** to fbconfig
- */
- return BadMatch;
-
- /*
- ** Check if there is already a fbconfig associated with this window
- */
- if (Success == dixLookupResourceByType(&val,
- glxwindowId, __glXWindowRes,
- NullClient, DixUnknownAccess)) {
- client->errorValue = glxwindowId;
- return BadAlloc;
- }
-
- pGlxWindow = (__glXWindow *) malloc(sizeof(__glXWindow));
- if (!pGlxWindow) {
- return BadAlloc;
- }
-
- /*
- ** Register this GLX window as a resource
- */
- if (!(AddResource(glxwindowId, __glXWindowRes, pGlxWindow))) {
- return BadAlloc;
- }
-
- pGlxWindow->pDraw = pDraw;
- pGlxWindow->type = GLX_GLXWINDOW_TYPE;
- pGlxWindow->idExists = True;
- pGlxWindow->refcnt = 0;
- pGlxWindow->pGlxFBConfig = pGlxFBConfig;
- pGlxWindow->pScreen = pScreen;
-
- return Success;
-}
-
-int __glXDestroyWindow(__GLXclientState *cl, GLbyte *pc)
-{
- ClientPtr client = cl->client;
- xGLXDestroyWindowReq *req = (xGLXDestroyWindowReq *) pc;
- XID glxwindow = req->glxwindow;
- pointer val;
-
- /*
- ** Check if it's a valid GLX window.
- */
- if (Success != dixLookupResourceByType(&val,
- glxwindow, __glXWindowRes,
- NullClient, DixUnknownAccess)) {
- client->errorValue = glxwindow;
- return __glXBadDrawable;
- }
- /*
- ** The glx window destructor will check whether it's current before
- ** freeing anything.
- */
- FreeResource(glxwindow, RT_NONE);
-
- return Success;
-}
-
-int __glXQueryContext(__GLXclientState *cl, GLbyte *pc)
-{
- ClientPtr client = cl->client;
- __GLXcontext *ctx;
- xGLXQueryContextReq *req;
- xGLXQueryContextReply reply;
- int nProps;
- int *sendBuf, *pSendBuf;
- int nReplyBytes;
-
- req = (xGLXQueryContextReq *)pc;
- dixLookupResourceByType((pointer*) &ctx, req->context, __glXContextRes,
- NullClient, DixUnknownAccess);
- if (!ctx) {
- client->errorValue = req->context;
- return __glXBadContext;
- }
-
- nProps = 3;
-
- reply.length = nProps << 1;
- reply.type = X_Reply;
- reply.sequenceNumber = client->sequence;
- reply.n = nProps;
-
- nReplyBytes = reply.length << 2;
- sendBuf = (int *)malloc(nReplyBytes);
- pSendBuf = sendBuf;
- *pSendBuf++ = GLX_FBCONFIG_ID;
- *pSendBuf++ = (int)(ctx->pFBConfig->id);
- *pSendBuf++ = GLX_RENDER_TYPE;
- *pSendBuf++ = (int)(ctx->pFBConfig->renderType);
- *pSendBuf++ = GLX_SCREEN;
- *pSendBuf++ = (int)(ctx->pScreen->myNum);
-
- if (client->swapped) {
- __glXSwapQueryContextReply(client, &reply, sendBuf);
- } else {
- WriteToClient(client, sz_xGLXQueryContextReply, (char *)&reply);
- WriteToClient(client, nReplyBytes, (char *)sendBuf);
- }
- free((char *)sendBuf);
-
- return Success;
-}
-
-int __glXQueryContextInfoEXT(__GLXclientState *cl, GLbyte *pc)
-{
- ClientPtr client = cl->client;
- __GLXcontext *ctx;
- xGLXQueryContextInfoEXTReq *req;
- xGLXQueryContextInfoEXTReply reply;
- int nProps;
- int *sendBuf, *pSendBuf;
- int nReplyBytes;
-
- req = (xGLXQueryContextInfoEXTReq *)pc;
- dixLookupResourceByType((pointer*) &ctx,
- req->context, __glXContextRes,
- client, DixReadAccess);
-
- if (!ctx) {
- client->errorValue = req->context;
- return __glXBadContext;
- }
-
- nProps = 4;
-
- reply.length = nProps << 1;
- reply.type = X_Reply;
- reply.sequenceNumber = client->sequence;
- reply.n = nProps;
-
- nReplyBytes = reply.length << 2;
- sendBuf = (int *)malloc(nReplyBytes);
- pSendBuf = sendBuf;
- *pSendBuf++ = GLX_SHARE_CONTEXT_EXT;
- *pSendBuf++ = (int)(ctx->share_id);
- *pSendBuf++ = GLX_VISUAL_ID_EXT;
- *pSendBuf++ = (int)(ctx->pVisual ? ctx->pVisual->vid : 0);
- *pSendBuf++ = GLX_SCREEN_EXT;
- *pSendBuf++ = (int)(ctx->pScreen->myNum);
- *pSendBuf++ = GLX_FBCONFIG_ID;
- *pSendBuf++ = (int)(ctx->pFBConfig ? ctx->pFBConfig->id : 0);
-
- if (client->swapped) {
- __glXSwapQueryContextInfoEXTReply(client, &reply, sendBuf);
- } else {
- WriteToClient(client, sz_xGLXQueryContextInfoEXTReply, (char *)&reply);
- WriteToClient(client, nReplyBytes, (char *)sendBuf);
- }
- free((char *)sendBuf);
-
- return Success;
-}
-
-int __glXCreatePbuffer(__GLXclientState *cl, GLbyte *pc)
-{
- ClientPtr client = cl->client;
- xGLXCreatePbufferReq *req = (xGLXCreatePbufferReq *)pc;
- xGLXCreatePbufferReq *be_req;
- int screen = req->screen;
- GLXFBConfigID fbconfigId = req->fbconfig;
- GLXPbuffer pbuffer = req->pbuffer;
- __glXPbuffer *pGlxPbuffer;
- int numAttribs = req->numAttribs;
- int *attr;
- ScreenPtr pScreen;
- __GLXFBConfig *pGlxFBConfig;
- __GLXFBConfig *be_pGlxFBConfig;
- XID be_xid;
- Display *dpy;
- DMXScreenInfo *dmxScreen;
- int s;
- int from_screen, to_screen;
-
- /*
- ** Look up screen and FBConfig.
- */
- if (screen >= screenInfo.numScreens) {
- /* The client library must send a valid screen number. */
- client->errorValue = screen;
- return BadValue;
- }
- pScreen = screenInfo.screens[screen];
-
- /*
- ** Find the FBConfigRec for this fbconfigid.
- */
- if (!(pGlxFBConfig = glxLookupFBConfig(fbconfigId))) {
- client->errorValue = fbconfigId;
- return __glXBadFBConfig;
- }
-
- /*
- ** Create the GLX part of the Pbuffer.
- */
- pGlxPbuffer = (__glXPbuffer *) malloc(sizeof(__glXPbuffer));
- if (!pGlxPbuffer) {
- return BadAlloc;
- }
-
- pGlxPbuffer->be_xids = (XID *) malloc( sizeof(XID) * screenInfo.numScreens );
- if (!pGlxPbuffer->be_xids) {
- free(pGlxPbuffer);
- return BadAlloc;
- }
-
- /*
- * Allocate an XID on the back-end server(s) and send him the request
- */
- from_screen = to_screen = screen;
-#ifdef PANORAMIX
- if (!noPanoramiXExtension) {
- from_screen = 0;
- to_screen = screenInfo.numScreens - 1;
- }
-#endif
-
- for (s=from_screen; s<=to_screen; s++) {
- dpy = GetBackEndDisplay(cl,s);
- be_xid = XAllocID(dpy);
- dmxScreen = &dmxScreens[s];
- be_pGlxFBConfig = glxLookupBackEndFBConfig( pGlxFBConfig->id, s );
-
- attr = (int *)( req+1 );
-
- LockDisplay(dpy);
- GetReqExtra(GLXCreatePbuffer, 2 * numAttribs * __GLX_SIZE_CARD32, be_req);
- be_req->reqType = dmxScreen->glxMajorOpcode;
- be_req->glxCode = X_GLXCreatePbuffer;
- be_req->screen = be_pGlxFBConfig->screen;
- be_req->fbconfig = be_pGlxFBConfig->id;
- be_req->pbuffer = be_xid;
- be_req->numAttribs = numAttribs;
-
- /* Send attributes */
- if ( attr != NULL ) {
- CARD32 *pc = (CARD32 *)(be_req + 1);
-
- while (numAttribs-- > 0) {
- *pc++ = *attr++; /* token */
- *pc++ = *attr++; /* value */
- }
- }
-
- UnlockDisplay(dpy);
- SyncHandle();
-
- pGlxPbuffer->be_xids[s] = be_xid;
- }
-
-
- pGlxPbuffer->idExists = True;
- pGlxPbuffer->refcnt = 0;
- pGlxPbuffer->pFBConfig = pGlxFBConfig;
- pGlxPbuffer->pScreen = pScreen;
-
- /*
- ** Register the resource.
- */
- if (!(AddResource(pbuffer, __glXPbufferRes, pGlxPbuffer))) {
- return BadAlloc;
- }
-
- return Success;
-
-}
-
-int __glXDestroyPbuffer(__GLXclientState *cl, GLbyte *pc)
-{
- ClientPtr client = cl->client;
- xGLXDestroyPbufferReq *req = (xGLXDestroyPbufferReq *) pc;
- xGLXDestroyPbufferReq *be_req;
- GLXPbuffer pbuffer = req->pbuffer;
- Display *dpy;
- int screen;
- DMXScreenInfo *dmxScreen;
- __glXPbuffer *pGlxPbuffer;
- int s;
- int from_screen, to_screen;
-
- /*
- ** Check if it's a valid Pbuffer
- */
- dixLookupResourceByType((pointer*) &pGlxPbuffer, pbuffer,
- __glXPbufferRes, NullClient, DixUnknownAccess);
- if (!pGlxPbuffer) {
- client->errorValue = pbuffer;
- return __glXBadPbuffer;
- }
-
- screen = pGlxPbuffer->pScreen->myNum;
-
- from_screen = to_screen = screen;
-#ifdef PANORAMIX
- if (!noPanoramiXExtension) {
- from_screen = 0;
- to_screen = screenInfo.numScreens - 1;
- }
-#endif
-
- for (s=from_screen; s<=to_screen; s++) {
- dpy = GetBackEndDisplay(cl,s);
- dmxScreen = &dmxScreens[s];
-
- /* send the destroy request to the back-end server */
- LockDisplay(dpy);
- GetReq(GLXDestroyPbuffer, be_req);
- be_req->reqType = dmxScreen->glxMajorOpcode;
- be_req->glxCode = X_GLXDestroyPbuffer;
- be_req->pbuffer = pGlxPbuffer->be_xids[s];
- UnlockDisplay(dpy);
- SyncHandle();
- }
-
- FreeResource(pbuffer, RT_NONE);
-
- return Success;
-}
-
-int __glXGetDrawableAttributes(__GLXclientState *cl, GLbyte *pc)
-{
- xGLXGetDrawableAttributesReq *req = (xGLXGetDrawableAttributesReq *)pc;
- xGLXGetDrawableAttributesReq *be_req;
- xGLXGetDrawableAttributesReply reply;
- ClientPtr client = cl->client;
- GLXDrawable drawId = req->drawable;
- GLXDrawable be_drawable = 0;
- DrawablePtr pDraw = NULL;
- Display *dpy;
- int screen, rc;
- DMXScreenInfo *dmxScreen;
- CARD32 *attribs = NULL;
- int attribs_size = 0;
-#ifdef PANORAMIX
- PanoramiXRes *pXinDraw = NULL;
-#endif
-
- if (drawId != None) {
- rc = dixLookupDrawable(&pDraw, drawId, client, 0, DixGetAttrAccess);
- if (rc == Success && pDraw->type == DRAWABLE_WINDOW) {
- WindowPtr pWin = (WindowPtr)pDraw;
- be_drawable = 0;
- screen = pWin->drawable.pScreen->myNum;
- } else {
- /*
- ** Drawable is not a Window , GLXWindow or a GLXPixmap.
- */
- client->errorValue = drawId;
- return __glXBadDrawable;
- }
-
- if (!pDraw) {
- __GLXpixmap *pGlxPixmap;
- dixLookupResourceByType((pointer*) &pGlxPixmap,
- drawId, __glXPixmapRes,
- NullClient, DixUnknownAccess);
- if (pGlxPixmap) {
- pDraw = pGlxPixmap->pDraw;
- screen = pGlxPixmap->pScreen->myNum;
- be_drawable = pGlxPixmap->be_xids[screen];
- }
- }
-
- if (!pDraw) {
- __glXWindow *pGlxWindow;
- dixLookupResourceByType((pointer*) &pGlxWindow,
- drawId, __glXWindowRes,
- NullClient, DixUnknownAccess);
- if (pGlxWindow) {
- pDraw = pGlxWindow->pDraw;
- screen = pGlxWindow->pScreen->myNum;
- be_drawable = 0;
- }
- }
-
- if (!pDraw) {
- __glXPbuffer *pGlxPbuffer;
- dixLookupResourceByType((pointer*) &pGlxPbuffer,
- drawId, __glXPbufferRes,
- NullClient, DixUnknownAccess);
- if (pGlxPbuffer) {
- pDraw = (DrawablePtr)pGlxPbuffer;
- screen = pGlxPbuffer->pScreen->myNum;
- be_drawable = pGlxPbuffer->be_xids[screen];
- }
- }
- }
-
- if (!pDraw) {
- /*
- ** Drawable is not a Window , GLXWindow or a GLXPixmap.
- */
- client->errorValue = drawId;
- return __glXBadDrawable;
- }
-
- /* if the drawable is a window or GLXWindow -
- * we need to find the base id on the back-end server
- */
- if (!be_drawable) {
- WindowPtr pWin = (WindowPtr)pDraw;
-
-#ifdef PANORAMIX
- if (!noPanoramiXExtension) {
- if (Success != dixLookupResourceByClass((pointer*) &pXinDraw,
- pDraw->id, XRC_DRAWABLE,
- client, DixReadAccess)) {
- client->errorValue = drawId;
- return __glXBadDrawable;
- }
-
- dixLookupWindow(&pWin, pXinDraw->info[screen].id, client,
- DixReadAccess);
- }
-#endif
-
- if (pWin) {
- be_drawable = (unsigned int)(DMX_GET_WINDOW_PRIV(pWin))->window;
- if (!be_drawable) {
- /* it might be that the window did not created yet on the */
- /* back-end server (lazy window creation option), force */
- /* creation of the window */
- dmxCreateAndRealizeWindow( pWin, TRUE );
- be_drawable = (unsigned int)(DMX_GET_WINDOW_PRIV(pWin))->window;
- }
- }
- else {
- client->errorValue = drawId;
- return __glXBadDrawable;
- }
- }
-
-
- /* send the request to the back-end server */
- dpy = GetBackEndDisplay(cl,screen);
- dmxScreen = &dmxScreens[screen];
-
- /* make sure drawable exists on back-end */
- dmxSync( dmxScreen, 1 );
-
- LockDisplay(dpy);
- GetReq(GLXGetDrawableAttributes, be_req);
- be_req->reqType = dmxScreen->glxMajorOpcode;
- be_req->glxCode = X_GLXGetDrawableAttributes;
- be_req->drawable = be_drawable;
- be_req->length = req->length;
- if (!_XReply(dpy, (xReply *) &reply, 0, False)) {
- UnlockDisplay(dpy);
- SyncHandle();
- return( BE_TO_CLIENT_ERROR(dmxLastErrorEvent.error_code) );
- }
-
- if (reply.numAttribs) {
- attribs_size = 2 * reply.numAttribs * __GLX_SIZE_CARD32;
- attribs = (CARD32 *) malloc(attribs_size);
- if (attribs == NULL) {
- UnlockDisplay(dpy);
- SyncHandle();
- return BadAlloc;
- }
-
- _XRead(dpy, (char *) attribs, attribs_size);
- }
-
- UnlockDisplay(dpy);
- SyncHandle();
-
-
- /* send the reply back to the client */
- reply.sequenceNumber = client->sequence;
- if (client->swapped) {
- __glXSwapGetDrawableAttributesReply(client, &reply, (int *)attribs);
- }
- else {
- WriteToClient(client, sz_xGLXGetDrawableAttributesReply, (char *)&reply);
- WriteToClient(client, attribs_size, (char *)attribs);
- }
-
- free(attribs);
-
- return Success;
-}
-
-int __glXChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc)
-{
- xGLXChangeDrawableAttributesReq *req = (xGLXChangeDrawableAttributesReq *)pc;
- xGLXChangeDrawableAttributesReq *be_req;
- ClientPtr client = cl->client;
- GLXDrawable drawId = req->drawable;
- GLXDrawable be_drawable = 0;
- DrawablePtr pDraw = NULL;
- Display *dpy;
- int screen, rc;
- DMXScreenInfo *dmxScreen;
-
- if (drawId != None) {
- rc = dixLookupDrawable(&pDraw, drawId, client, 0, DixSetAttrAccess);
- if (rc == Success && pDraw->type == DRAWABLE_WINDOW) {
- be_drawable = 0;
- screen = pDraw->pScreen->myNum;
- } else {
- /*
- ** Drawable is not a Window , GLXWindow or a GLXPixmap.
- */
- client->errorValue = drawId;
- return __glXBadDrawable;
- }
-
- if (!pDraw) {
- __GLXpixmap *pGlxPixmap;
- dixLookupResourceByType((pointer*) &pGlxPixmap,
- drawId, __glXPixmapRes,
- NullClient, DixUnknownAccess);
- if (pGlxPixmap) {
- pDraw = pGlxPixmap->pDraw;
- screen = pGlxPixmap->pScreen->myNum;
- be_drawable = pGlxPixmap->be_xids[screen];
- }
- }
-
- if (!pDraw) {
- __glXWindow *pGlxWindow;
- dixLookupResourceByType((pointer*) &pGlxWindow,
- drawId, __glXWindowRes,
- NullClient, DixUnknownAccess);
- if (pGlxWindow) {
- pDraw = pGlxWindow->pDraw;
- screen = pGlxWindow->pScreen->myNum;
- be_drawable = 0;
- }
- }
-
- if (!pDraw) {
- __glXPbuffer *pGlxPbuffer;
- dixLookupResourceByType((pointer*) &pGlxPbuffer,
- drawId, __glXPbufferRes,
- NullClient, DixUnknownAccess);
- if (pGlxPbuffer) {
- pDraw = (DrawablePtr)pGlxPbuffer;
- screen = pGlxPbuffer->pScreen->myNum;
- be_drawable = pGlxPbuffer->be_xids[screen];
- }
- }
- }
-
- if (!pDraw) {
- /*
- ** Drawable is not a Window , GLXWindow or a GLXPixmap.
- */
- client->errorValue = drawId;
- return __glXBadDrawable;
- }
-
- /* if the drawable is a window or GLXWindow -
- * we need to find the base id on the back-end server
- */
- if (!be_drawable) {
- WindowPtr pWin = (WindowPtr)pDraw;
-
-#ifdef PANORAMIX
- if (!noPanoramiXExtension) {
- PanoramiXRes *pXinDraw;
- if (Success != dixLookupResourceByClass((pointer*) &pXinDraw,
- pDraw->id, XRC_DRAWABLE,
- client, DixReadAccess)) {
- client->errorValue = drawId;
- return __glXBadDrawable;
- }
-
- dixLookupWindow(&pWin, pXinDraw->info[screen].id, client,
- DixReadAccess);
- }
-#endif
-
- if (pWin) {
- be_drawable = (unsigned int)(DMX_GET_WINDOW_PRIV(pWin))->window;
- if (!be_drawable) {
- /* it might be that the window did not created yet on the */
- /* back-end server (lazy window creation option), force */
- /* creation of the window */
- dmxCreateAndRealizeWindow( pWin, TRUE );
- be_drawable = (unsigned int)(DMX_GET_WINDOW_PRIV(pWin))->window;
- }
- }
- else {
- client->errorValue = drawId;
- return __glXBadDrawable;
- }
- }
-
-
- /* send the request to the back-end server */
- dpy = GetBackEndDisplay(cl,screen);
- dmxScreen = &dmxScreens[screen];
-
- /* make sure drawable exists on back-end */
- dmxSync( dmxScreen, 1 );
-
- LockDisplay(dpy);
- GetReqExtra(GLXChangeDrawableAttributes,
- 2 * req->numAttribs * __GLX_SIZE_CARD32, be_req);
- be_req->reqType = dmxScreen->glxMajorOpcode;
- be_req->glxCode = X_GLXChangeDrawableAttributes;
- be_req->drawable = be_drawable;
- be_req->numAttribs = req->numAttribs;
- be_req->length = req->length;
-
- UnlockDisplay(dpy);
- SyncHandle();
-
- return Success;
-}
-
-int __glXSendLargeCommand(__GLXclientState *cl, GLXContextTag contextTag)
-{
- ClientPtr client = cl->client;
- xGLXRenderLargeReq *req;
- GLint maxSize, amount;
- GLint totalRequests, requestNumber;
- GLint dataLen;
- GLbyte *data;
- __GLXcontext *glxc;
- int s;
- int from_screen, to_screen;
-
- maxSize = cl->largeCmdMaxReqDataSize - (GLint)sizeof(xGLXRenderLargeReq);
- dataLen = cl->largeCmdBytesTotal;
- totalRequests = (dataLen / maxSize);
- if (dataLen % maxSize) totalRequests++;
-
- glxc = __glXLookupContextByTag(cl, contextTag);
- if (!glxc) {
- client->errorValue = contextTag;
- return __glXBadContext;
- }
- from_screen = to_screen = glxc->pScreen->myNum;
-
-#ifdef PANORAMIX
- if (!noPanoramiXExtension) {
- from_screen = 0;
- to_screen = screenInfo.numScreens - 1;
- }
-#endif
-
- /*
- ** Send enough requests until the whole array is sent.
- */
- requestNumber = 1;
- data = cl->largeCmdBuf;
- while (dataLen > 0) {
- amount = dataLen;
- if (amount > maxSize) {
- amount = maxSize;
- }
-
- for (s=from_screen; s<=to_screen; s++) {
-
- Display *dpy = GetBackEndDisplay(cl,s);
- DMXScreenInfo *dmxScreen = &dmxScreens[s];
-
- LockDisplay(dpy);
- GetReq(GLXRenderLarge,req);
- req->reqType = dmxScreen->glxMajorOpcode;
- req->glxCode = X_GLXRenderLarge;
- req->contextTag = GetCurrentBackEndTag(cl,contextTag,s);
- req->length += (amount + 3) >> 2;
- req->requestNumber = requestNumber++;
- req->requestTotal = totalRequests;
- req->dataBytes = amount;
- Data(dpy, ((const char*)data), amount);
- dataLen -= amount;
- data = ((GLbyte *) data) + amount;
- UnlockDisplay(dpy);
- SyncHandle();
- }
- }
-
- return Success;
-}
+/*
+ * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
+ * Copyright (C) 1991-2000 Silicon Graphics, 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 including the dates of first publication and
+ * either this permission notice or a reference to
+ * http://oss.sgi.com/projects/FreeB/
+ * 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
+ * SILICON GRAPHICS, INC. 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 Silicon Graphics, Inc.
+ * shall not be used in advertising or otherwise to promote the sale, use or
+ * other dealings in this Software without prior written authorization from
+ * Silicon Graphics, Inc.
+ */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmx.h"
+#include "dmxwindow.h"
+#include "dmxpixmap.h"
+#include "dmxfont.h"
+#include "dmxsync.h"
+
+#include "glxserver.h"
+#include <GL/glxtokens.h>
+#include "g_disptab.h"
+#include <pixmapstr.h>
+#include <windowstr.h>
+#include "glxutil.h"
+#include "glxext.h"
+#include "unpack.h"
+
+#include "GL/glxproto.h"
+#include "glxvendor.h"
+#include "glxvisuals.h"
+#include "glxswap.h"
+
+#ifdef PANORAMIX
+#include "panoramiXsrv.h"
+#endif
+
+extern __GLXFBConfig **__glXFBConfigs;
+extern int __glXNumFBConfigs;
+
+extern __GLXFBConfig *glxLookupFBConfig( GLXFBConfigID id );
+extern __GLXFBConfig *glxLookupFBConfigByVID( VisualID vid );
+extern __GLXFBConfig *glxLookupBackEndFBConfig( GLXFBConfigID id, int screen );
+extern int glxIsExtensionSupported( char *ext );
+extern int __glXGetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc);
+
+#define BE_TO_CLIENT_ERROR(x) \
+ ( (x) >= __glXerrorBase ? \
+ (x) - dmxScreen->glxErrorBase + __glXerrorBase \
+ : (x) )
+
+Display *GetBackEndDisplay( __GLXclientState *cl, int s )
+{
+ if (! cl->be_displays[s] ) {
+ cl->be_displays[s] = XOpenDisplay( DisplayString(dmxScreens[s].beDisplay) );
+ }
+ return cl->be_displays[s];
+}
+
+/*
+** Create a GL context with the given properties.
+*/
+static int CreateContext(__GLXclientState *cl,
+ GLXContextID gcId,
+ VisualID vid, GLXFBConfigID fbconfigId,
+ int screen,
+ GLXContextID shareList,
+ int isDirect )
+{
+ ClientPtr client = cl->client;
+ xGLXCreateContextReq *be_req;
+ xGLXCreateNewContextReq *be_new_req;
+ VisualPtr pVisual;
+ ScreenPtr pScreen;
+ __GLXcontext *glxc, *shareglxc;
+ __GLXvisualConfig *pGlxVisual;
+ __GLXscreenInfo *pGlxScreen;
+ VisualID visual = vid;
+ GLint i;
+ int from_screen = screen;
+ int to_screen = screen;
+ DMXScreenInfo *dmxScreen;
+ VisualID be_vid = 0;
+ GLXFBConfigID be_fbconfigId = 0;
+ int num_be_screens;
+ Display *dpy;
+
+ /*
+ ** Check if screen exists.
+ */
+ if (screen >= screenInfo.numScreens) {
+ client->errorValue = screen;
+ return BadValue;
+ }
+
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ from_screen = 0;
+ to_screen = screenInfo.numScreens - 1;
+ }
+#endif
+
+ /*
+ ** Find the display list space that we want to share.
+ **
+ */
+ if (shareList == None) {
+ shareglxc = NULL;
+ } else {
+ dixLookupResourceByType((pointer*) &shareglxc, shareList,
+ __glXContextRes, NullClient, DixUnknownAccess);
+ if (!shareglxc) {
+ client->errorValue = shareList;
+ return __glXBadContext;
+ }
+ }
+
+ /*
+ ** Allocate memory for the new context
+ */
+ glxc = calloc(1, sizeof(__GLXcontext));
+ if (!glxc) {
+ return BadAlloc;
+ }
+
+ pScreen = screenInfo.screens[screen];
+ pGlxScreen = &__glXActiveScreens[screen];
+
+ if (fbconfigId != None) {
+ glxc->pFBConfig = glxLookupFBConfig( fbconfigId );
+ if (!glxc->pFBConfig) {
+ client->errorValue = fbconfigId;
+ free( glxc );
+ return BadValue;
+ }
+ visual = glxc->pFBConfig->associatedVisualId;
+ }
+ else {
+ glxc->pFBConfig = NULL;
+ }
+
+ if (visual != None) {
+ /*
+ ** Check if the visual ID is valid for this screen.
+ */
+ pVisual = pScreen->visuals;
+ for (i = 0; i < pScreen->numVisuals; i++, pVisual++) {
+ if (pVisual->vid == visual) {
+ break;
+ }
+ }
+ if (i == pScreen->numVisuals) {
+ client->errorValue = visual;
+ free( glxc );
+ return BadValue;
+ }
+
+ pGlxVisual = pGlxScreen->pGlxVisual;
+ for (i = 0; i < pGlxScreen->numVisuals; i++, pGlxVisual++) {
+ if (pGlxVisual->vid == visual) {
+ break;
+ }
+ }
+ if (i == pGlxScreen->numVisuals) {
+ /*
+ ** Visual not support on this screen by this OpenGL implementation.
+ */
+ client->errorValue = visual;
+ free( glxc );
+ return BadValue;
+ }
+
+ if ( glxc->pFBConfig == NULL ) {
+ glxc->pFBConfig = glxLookupFBConfigByVID( visual );
+
+ if ( glxc->pFBConfig == NULL ) {
+ /*
+ * visual does not have an FBConfig ???
+ client->errorValue = visual;
+ free( glxc );
+ return BadValue;
+ */
+ }
+ }
+ }
+ else {
+ pVisual = NULL;
+ pGlxVisual = NULL;
+ }
+
+ glxc->pScreen = pScreen;
+ glxc->pGlxScreen = pGlxScreen;
+ glxc->pVisual = pVisual;
+ glxc->pGlxVisual = pGlxVisual;
+
+ /*
+ * allocate memory for back-end servers info
+ */
+ num_be_screens = to_screen - from_screen + 1;
+ glxc->real_ids = (XID *)malloc(sizeof(XID) * num_be_screens);
+ if (!glxc->real_ids) {
+ return BadAlloc;
+ }
+ glxc->real_vids = (XID *)malloc(sizeof(XID) * num_be_screens);
+ if (!glxc->real_vids) {
+ return BadAlloc;
+ }
+
+ for (screen = from_screen; screen <= to_screen; screen++) {
+ int sent = 0;
+ pScreen = screenInfo.screens[screen];
+ pGlxScreen = &__glXActiveScreens[screen];
+ dmxScreen = &dmxScreens[screen];
+
+ if (glxc->pFBConfig) {
+ __GLXFBConfig *beFBConfig = glxLookupBackEndFBConfig( glxc->pFBConfig->id,
+ screen );
+ be_fbconfigId = beFBConfig->id;
+ }
+
+ if (pGlxVisual) {
+
+ be_vid = glxMatchGLXVisualInConfigList( pGlxVisual,
+ dmxScreen->glxVisuals,
+ dmxScreen->numGlxVisuals );
+
+ if (!be_vid) {
+ /* visual is not supported on the back-end server */
+ free( glxc->real_ids );
+ free( glxc->real_vids );
+ free( glxc );
+ return BadValue;
+ }
+ }
+
+ glxc->real_ids[screen-from_screen] = XAllocID(GetBackEndDisplay(cl,screen));
+
+ /* send the create context request to the back-end server */
+ dpy = GetBackEndDisplay(cl,screen);
+ if (glxc->pFBConfig) {
+ /*Since for a certain visual both RGB and COLOR INDEX
+ *can be on then the only parmeter to choose the renderType
+ * should be the class of the colormap since all 4 first
+ * classes does not support RGB mode only COLOR INDEX ,
+ * and so TrueColor and DirectColor does not support COLOR INDEX*/
+ int renderType = glxc->pFBConfig->renderType;
+ if ( pVisual ) {
+ switch ( pVisual->class ){
+ case PseudoColor:
+ case StaticColor:
+ case GrayScale:
+ case StaticGray:
+ renderType = GLX_COLOR_INDEX_TYPE;
+ break;
+ case TrueColor:
+ case DirectColor:
+ default:
+ renderType = GLX_RGBA_TYPE;
+ break;
+ }
+ }
+ if ( __GLX_IS_VERSION_SUPPORTED(1,3) ) {
+ LockDisplay(dpy);
+ GetReq(GLXCreateNewContext,be_new_req);
+ be_new_req->reqType = dmxScreen->glxMajorOpcode;
+ be_new_req->glxCode = X_GLXCreateNewContext;
+ be_new_req->context = (unsigned int)glxc->real_ids[screen-from_screen];
+ be_new_req->fbconfig = (unsigned int)be_fbconfigId;
+ be_new_req->screen = DefaultScreen(dpy);
+ be_new_req->renderType = renderType;
+
+ be_new_req->shareList = (shareglxc ? shareglxc->real_ids[screen-from_screen] : 0);
+ be_new_req->isDirect = 0;
+ UnlockDisplay(dpy);
+ glxc->real_vids[screen-from_screen] = be_fbconfigId;
+ sent = 1;
+ }
+ else if (glxIsExtensionSupported("GLX_SGIX_fbconfig")) {
+
+ xGLXCreateContextWithConfigSGIXReq *ext_req;
+ xGLXVendorPrivateReq *vpreq;
+ LockDisplay(dpy);
+ GetReqExtra(GLXVendorPrivate,
+ sz_xGLXCreateContextWithConfigSGIXReq - sz_xGLXVendorPrivateReq,
+ vpreq);
+ ext_req = (xGLXCreateContextWithConfigSGIXReq *)vpreq;
+ ext_req->reqType = dmxScreen->glxMajorOpcode;
+ ext_req->glxCode = X_GLXVendorPrivate;
+ ext_req->vendorCode = X_GLXvop_CreateContextWithConfigSGIX;
+ ext_req->context = (unsigned int)glxc->real_ids[screen-from_screen];
+ ext_req->fbconfig = (unsigned int)be_fbconfigId;
+ ext_req->screen = DefaultScreen(dpy);
+ ext_req->renderType = renderType;
+ ext_req->shareList = (shareglxc ? shareglxc->real_ids[screen-from_screen] : 0);
+ ext_req->isDirect = 0;
+ UnlockDisplay(dpy);
+ glxc->real_vids[screen-from_screen] = be_fbconfigId;
+ sent = 1;
+ }
+ }
+
+ if (!sent) {
+ LockDisplay(dpy);
+ GetReq(GLXCreateContext,be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = X_GLXCreateContext;
+ be_req->context = (unsigned int)glxc->real_ids[screen-from_screen];
+ be_req->visual = (unsigned int)be_vid;
+ be_req->screen = DefaultScreen(dpy);
+ be_req->shareList = (shareglxc ? shareglxc->real_ids[screen-from_screen] : 0);
+ be_req->isDirect = 0;
+ UnlockDisplay(dpy);
+ glxc->real_vids[screen-from_screen] = be_vid;
+ }
+ SyncHandle();
+
+ }
+
+ /*
+ ** Register this context as a resource.
+ */
+ if (!AddResource(gcId, __glXContextRes, (pointer)glxc)) {
+ free( glxc->real_ids );
+ free( glxc->real_vids );
+ free( glxc );
+ client->errorValue = gcId;
+ return BadAlloc;
+ }
+
+ /*
+ ** Finally, now that everything is working, setup the rest of the
+ ** context.
+ */
+ glxc->id = gcId;
+ glxc->share_id = shareList;
+ glxc->idExists = GL_TRUE;
+ glxc->isCurrent = GL_FALSE;
+
+ return Success;
+}
+
+int __glXCreateContext(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreateContextReq *req = (xGLXCreateContextReq *) pc;
+
+ return( CreateContext(cl, req->context,req->visual, None,
+ req->screen, req->shareList, req->isDirect) );
+
+}
+
+int __glXCreateNewContext(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreateNewContextReq *req = (xGLXCreateNewContextReq *) pc;
+
+ return( CreateContext(cl, req->context,None, req->fbconfig,
+ req->screen, req->shareList, req->isDirect) );
+
+}
+
+int __glXCreateContextWithConfigSGIX(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreateContextWithConfigSGIXReq *req = (xGLXCreateContextWithConfigSGIXReq *) pc;
+
+ return( CreateContext(cl, req->context, None, req->fbconfig,
+ req->screen, req->shareList, req->isDirect) );
+
+}
+
+int __glXQueryMaxSwapBarriersSGIX(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXQueryMaxSwapBarriersSGIXReq *req =
+ (xGLXQueryMaxSwapBarriersSGIXReq *)pc;
+ xGLXQueryMaxSwapBarriersSGIXReply reply;
+
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+ reply.length = 0;
+ reply.max = QueryMaxSwapBarriersSGIX(req->screen);
+
+ if (client->swapped) {
+ __glXSwapQueryMaxSwapBarriersSGIXReply(client, &reply);
+ } else {
+ WriteToClient(client, sz_xGLXQueryMaxSwapBarriersSGIXReply,
+ (char *)&reply);
+ }
+
+ return Success;
+}
+
+int __glXBindSwapBarrierSGIX(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXBindSwapBarrierSGIXReq *req = (xGLXBindSwapBarrierSGIXReq *)pc;
+ DrawablePtr pDraw;
+ __GLXpixmap *pGlxPixmap = NULL;
+ __glXWindow *pGlxWindow = NULL;
+ int rc;
+
+ rc = dixLookupDrawable(&pDraw, req->drawable, client, 0, DixGetAttrAccess);
+ if (rc != Success) {
+ dixLookupResourceByType((pointer*) &pGlxPixmap, req->drawable,
+ __glXPixmapRes, NullClient, DixUnknownAccess);
+ if (pGlxPixmap) pDraw = pGlxPixmap->pDraw;
+ }
+
+ if (!pDraw && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
+ dixLookupResourceByType((pointer*) &pGlxWindow, req->drawable,
+ __glXWindowRes, NullClient, DixUnknownAccess);
+ if (pGlxWindow) pDraw = pGlxWindow->pDraw;
+ }
+
+ if (!pDraw) {
+ client->errorValue = req->drawable;
+ return __glXBadDrawable;
+ }
+
+ return BindSwapBarrierSGIX(pDraw, req->barrier);
+}
+
+int __glXJoinSwapGroupSGIX(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXJoinSwapGroupSGIXReq *req = (xGLXJoinSwapGroupSGIXReq *)pc;
+ DrawablePtr pDraw, pMember = NULL;
+ __GLXpixmap *pGlxPixmap = NULL;
+ __glXWindow *pGlxWindow = NULL;
+ int rc;
+
+ rc = dixLookupDrawable(&pDraw, req->drawable, client, 0, DixManageAccess);
+ if (rc != Success) {
+ dixLookupResourceByType((pointer*) &pGlxPixmap, req->drawable,
+ __glXPixmapRes, NullClient, DixUnknownAccess);
+ if (pGlxPixmap) pDraw = pGlxPixmap->pDraw;
+ }
+
+ if (!pDraw && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
+ dixLookupResourceByType((pointer*) &pGlxWindow, req->drawable,
+ __glXWindowRes, NullClient, DixUnknownAccess);
+ if (pGlxWindow) pDraw = pGlxWindow->pDraw;
+ }
+
+ if (!pDraw) {
+ client->errorValue = req->drawable;
+ return __glXBadDrawable;
+ }
+
+ if (req->member != None) {
+ rc = dixLookupDrawable(&pMember, req->member, client, 0,
+ DixGetAttrAccess);
+ if (rc != Success) {
+ dixLookupResourceByType((pointer*) &pGlxPixmap, req->member,
+ __glXPixmapRes, NullClient,
+ DixUnknownAccess);
+ if (pGlxPixmap) pMember = pGlxPixmap->pDraw;
+ }
+
+ if (!pMember && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
+ dixLookupResourceByType((pointer*) &pGlxWindow, req->member,
+ __glXWindowRes, NullClient,
+ DixUnknownAccess);
+ if (pGlxWindow) pMember = pGlxWindow->pDraw;
+ }
+
+ if (!pMember) {
+ client->errorValue = req->member;
+ return __glXBadDrawable;
+ }
+ }
+
+ return JoinSwapGroupSGIX(pDraw, pMember);
+}
+
+
+/*
+** Destroy a GL context as an X resource.
+*/
+int __glXDestroyContext(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXDestroyContextReq *req = (xGLXDestroyContextReq *) pc;
+ xGLXDestroyContextReq *be_req;
+ GLXContextID gcId = req->context;
+ __GLXcontext *glxc;
+ int from_screen = 0;
+ int to_screen = 0;
+ int s;
+
+ dixLookupResourceByType((pointer*) &glxc, gcId, __glXContextRes,
+ NullClient, DixUnknownAccess);
+ if (glxc) {
+ /*
+ ** Just free the resource; don't actually destroy the context,
+ ** because it might be in use. The
+ ** destroy method will be called by the resource destruction routine
+ ** if necessary.
+ */
+ FreeResourceByType(gcId, __glXContextRes, FALSE);
+
+ from_screen = to_screen = glxc->pScreen->myNum;
+
+ } else {
+ client->errorValue = gcId;
+ return __glXBadContext;
+ }
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ from_screen = 0;
+ to_screen = screenInfo.numScreens - 1;
+ }
+#endif
+
+ /*
+ * send DestroyContext request to all back-end servers
+ */
+ for (s=from_screen; s<=to_screen; s++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[s];
+ Display *dpy = GetBackEndDisplay(cl,s);
+
+ LockDisplay(dpy);
+ GetReq(GLXDestroyContext,be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = X_GLXDestroyContext;
+ be_req->context = glxc->real_ids[s-from_screen];
+ UnlockDisplay(dpy);
+ SyncHandle();
+ }
+
+ return Success;
+}
+
+/*****************************************************************************/
+
+/*
+** For each client, the server keeps a table of all the contexts that are
+** current for that client (each thread of a client may have its own current
+** context). These routines add, change, and lookup contexts in the table.
+*/
+
+/*
+** Add a current context, and return the tag that will be used to refer to it.
+*/
+static int AddCurrentContext(__GLXclientState *cl, __GLXcontext *glxc, DrawablePtr pDraw)
+{
+ int i;
+ int num = cl->numCurrentContexts;
+ __GLXcontext **table = cl->currentContexts;
+
+ if (!glxc) return -1;
+
+ /*
+ ** Try to find an empty slot and use it.
+ */
+ for (i=0; i < num; i++) {
+ if (!table[i]) {
+ table[i] = glxc;
+ return i+1;
+ }
+ }
+ /*
+ ** Didn't find a free slot, so we'll have to grow the table.
+ */
+ if (!num) {
+ table = (__GLXcontext **) malloc(sizeof(__GLXcontext *));
+ cl->currentDrawables = (DrawablePtr *) malloc(sizeof(DrawablePtr));
+ cl->be_currentCTag = (GLXContextTag *) malloc(screenInfo.numScreens *sizeof(GLXContextTag));
+ } else {
+ table = (__GLXcontext **) realloc(table,
+ (num+1)*sizeof(__GLXcontext *));
+ cl->currentDrawables = (DrawablePtr *) realloc(
+ cl->currentDrawables ,
+ (num+1)*sizeof(DrawablePtr));
+ cl->be_currentCTag = (GLXContextTag *) realloc(cl->be_currentCTag,
+ (num+1)*screenInfo.numScreens*sizeof(GLXContextTag));
+ }
+ table[num] = glxc;
+ cl->currentDrawables[num] = pDraw;
+ cl->currentContexts = table;
+ cl->numCurrentContexts++;
+
+ memset(cl->be_currentCTag + num*screenInfo.numScreens, 0,
+ screenInfo.numScreens * sizeof(GLXContextTag));
+
+ return num+1;
+}
+
+/*
+** Given a tag, change the current context for the corresponding entry.
+*/
+static void ChangeCurrentContext(__GLXclientState *cl, __GLXcontext *glxc,
+ GLXContextTag tag)
+{
+ __GLXcontext **table = cl->currentContexts;
+ table[tag-1] = glxc;
+}
+
+/*
+** Given a tag, and back-end screen number, retrives the current back-end
+** tag.
+*/
+int GetCurrentBackEndTag(__GLXclientState *cl, GLXContextTag tag, int s)
+{
+ if (tag >0) {
+ return( cl->be_currentCTag[ (tag-1)*screenInfo.numScreens + s ] );
+ }
+ else {
+ return 0;
+ }
+}
+
+/*
+** Given a tag, and back-end screen number, sets the current back-end
+** tag.
+*/
+static void SetCurrentBackEndTag(__GLXclientState *cl, GLXContextTag tag, int s, GLXContextTag be_tag)
+{
+ if (tag >0) {
+ cl->be_currentCTag[ (tag-1)*screenInfo.numScreens + s ] = be_tag;
+ }
+}
+
+/*
+** For this implementation we have chosen to simply use the index of the
+** context's entry in the table as the context tag. A tag must be greater
+** than 0.
+*/
+__GLXcontext *__glXLookupContextByTag(__GLXclientState *cl, GLXContextTag tag)
+{
+ int num = cl->numCurrentContexts;
+
+ if (tag < 1 || tag > num) {
+ return 0;
+ } else {
+ return cl->currentContexts[tag-1];
+ }
+}
+
+DrawablePtr __glXLookupDrawableByTag(__GLXclientState *cl, GLXContextTag tag)
+{
+ int num = cl->numCurrentContexts;
+
+ if (tag < 1 || tag > num) {
+ return 0;
+ } else {
+ return cl->currentDrawables[tag-1];
+ }
+}
+
+/*****************************************************************************/
+
+static void StopUsingContext(__GLXcontext *glxc)
+{
+ if (glxc) {
+ if (glxc == __glXLastContext) {
+ /* Tell server GL library */
+ __glXLastContext = 0;
+ }
+ glxc->isCurrent = GL_FALSE;
+ if (!glxc->idExists) {
+ __glXFreeContext(glxc);
+ }
+ }
+}
+
+static void StartUsingContext(__GLXclientState *cl, __GLXcontext *glxc)
+{
+ glxc->isCurrent = GL_TRUE;
+}
+
+/*****************************************************************************/
+/*
+** Make an OpenGL context and drawable current.
+*/
+static int MakeCurrent(__GLXclientState *cl,
+ GLXDrawable drawable,
+ GLXDrawable readdrawable,
+ GLXContextID context,
+ GLXContextTag oldContextTag)
+{
+ ClientPtr client = cl->client;
+ DrawablePtr pDraw = NULL;
+ DrawablePtr pReadDraw = NULL;
+ xGLXMakeCurrentReadSGIReply new_reply;
+ xGLXMakeCurrentReq *be_req;
+ xGLXMakeCurrentReply be_reply;
+ xGLXMakeContextCurrentReq *be_new_req;
+ xGLXMakeContextCurrentReply be_new_reply;
+ GLXDrawable drawId = drawable;
+ GLXDrawable readId = readdrawable;
+ GLXContextID contextId = context;
+ __GLXpixmap *pGlxPixmap = 0;
+ __GLXpixmap *pReadGlxPixmap = 0;
+ __GLXcontext *glxc, *prevglxc;
+ GLXContextTag tag = oldContextTag;
+ WindowPtr pWin = NULL;
+ WindowPtr pReadWin = NULL;
+ __glXWindow *pGlxWindow = NULL;
+ __glXWindow *pGlxReadWindow = NULL;
+ __glXPbuffer *pGlxPbuffer = NULL;
+ __glXPbuffer *pGlxReadPbuffer = NULL;
+#ifdef PANORAMIX
+ PanoramiXRes *pXinDraw = NULL;
+ PanoramiXRes *pXinReadDraw = NULL;
+#endif
+ int from_screen = 0;
+ int to_screen = 0;
+ int s, rc;
+
+ /*
+ ** If one is None and the other isn't, it's a bad match.
+ */
+ if ((drawId == None && contextId != None) ||
+ (drawId != None && contextId == None)) {
+ return BadMatch;
+ }
+
+ /*
+ ** Lookup old context. If we have one, it must be in a usable state.
+ */
+ if (tag != 0) {
+ prevglxc = __glXLookupContextByTag(cl, tag);
+ if (!prevglxc) {
+ /*
+ ** Tag for previous context is invalid.
+ */
+ return __glXBadContextTag;
+ }
+ } else {
+ prevglxc = 0;
+ }
+
+ /*
+ ** Lookup new context. It must not be current for someone else.
+ */
+ if (contextId != None) {
+ dixLookupResourceByType((pointer*) &glxc, contextId, __glXContextRes,
+ NullClient, DixUnknownAccess);
+ if (!glxc) {
+ client->errorValue = contextId;
+ return __glXBadContext;
+ }
+ if ((glxc != prevglxc) && glxc->isCurrent) {
+ /* Context is current to somebody else */
+ return BadAccess;
+ }
+ } else {
+ /* Switching to no context. Ignore new drawable. */
+ glxc = 0;
+ }
+
+ if (drawId != None) {
+ rc = dixLookupDrawable(&pDraw, drawId, client, 0, DixWriteAccess);
+ if (rc == Success) {
+ if (pDraw->type == DRAWABLE_WINDOW) {
+ /*
+ ** Drawable is an X Window.
+ */
+ VisualID vid;
+ pWin = (WindowPtr)pDraw;
+ vid = wVisual(pWin);
+
+ new_reply.writeVid = (glxc->pFBConfig ? glxc->pFBConfig->id : vid);
+ new_reply.writeType = GLX_WINDOW_TYPE;
+
+ /*
+ ** Check if window and context are similar.
+ */
+ if ((vid != glxc->pVisual->vid) ||
+ (pWin->drawable.pScreen != glxc->pScreen)) {
+ client->errorValue = drawId;
+ return BadMatch;
+ }
+
+ from_screen = to_screen = pWin->drawable.pScreen->myNum;
+
+ } else {
+ /*
+ ** An X Pixmap is not allowed as a parameter (a GLX Pixmap
+ ** is, but it must first be created with glxCreateGLXPixmap).
+ */
+ client->errorValue = drawId;
+ return __glXBadDrawable;
+ }
+ }
+
+ if (!pDraw) {
+ dixLookupResourceByType((pointer*) &pGlxPixmap, drawId,
+ __glXPixmapRes, NullClient,
+ DixUnknownAccess);
+ if (pGlxPixmap) {
+ /*
+ ** Check if pixmap and context are similar.
+ */
+ if (pGlxPixmap->pScreen != glxc->pScreen ||
+ pGlxPixmap->pGlxVisual != glxc->pGlxVisual) {
+ client->errorValue = drawId;
+ return BadMatch;
+ }
+ pDraw = pGlxPixmap->pDraw;
+
+ new_reply.writeVid = (glxc->pFBConfig ? glxc->pFBConfig->id :
+ pGlxPixmap->pGlxVisual->vid);
+
+ new_reply.writeType = GLX_PIXMAP_TYPE;
+
+ from_screen = to_screen = pGlxPixmap->pScreen->myNum;
+
+ }
+ }
+
+ if (!pDraw && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
+ dixLookupResourceByType((pointer*) &pGlxWindow, drawId,
+ __glXWindowRes, NullClient,
+ DixUnknownAccess);
+ if (pGlxWindow) {
+ /*
+ ** Drawable is a GLXWindow.
+ **
+ ** Check if GLX window and context are similar.
+ */
+ if (pGlxWindow->pScreen != glxc->pScreen ||
+ pGlxWindow->pGlxFBConfig != glxc->pFBConfig) {
+ client->errorValue = drawId;
+ return BadMatch;
+ }
+
+ pDraw = pGlxWindow->pDraw;
+ new_reply.writeVid = pGlxWindow->pGlxFBConfig->id;
+ new_reply.writeType = GLX_GLXWINDOW_TYPE;
+ }
+
+ }
+
+ if (!pDraw && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
+ dixLookupResourceByType((pointer*) &pGlxPbuffer, drawId,
+ __glXPbufferRes, NullClient,
+ DixUnknownAccess);
+ if (pGlxPbuffer) {
+ if (pGlxPbuffer->pScreen != glxc->pScreen ||
+ pGlxPbuffer->pFBConfig != glxc->pFBConfig) {
+ client->errorValue = drawId;
+ return BadMatch;
+ }
+
+ pDraw = (DrawablePtr)pGlxPbuffer;
+ new_reply.writeVid = pGlxPbuffer->pFBConfig->id;
+ new_reply.writeType = GLX_PBUFFER_TYPE;
+ }
+ }
+
+ if (!pDraw) {
+ /*
+ ** Drawable is not a Window , GLXWindow or a GLXPixmap.
+ */
+ client->errorValue = drawId;
+ return __glXBadDrawable;
+ }
+
+ } else {
+ pDraw = 0;
+ }
+
+ if (readId != None && readId != drawId ) {
+ rc = dixLookupDrawable(&pReadDraw, readId, client, 0, DixReadAccess);
+ if (rc == Success) {
+ if (pReadDraw->type == DRAWABLE_WINDOW) {
+ /*
+ ** Drawable is an X Window.
+ */
+ VisualID vid;
+ pReadWin = (WindowPtr)pDraw;
+ vid = wVisual(pReadWin);
+
+ new_reply.readVid = (glxc->pFBConfig ? glxc->pFBConfig->id : vid);
+ new_reply.readType = GLX_WINDOW_TYPE;
+
+ /*
+ ** Check if window and context are similar.
+ */
+ if ((vid != glxc->pVisual->vid) ||
+ (pReadWin->drawable.pScreen != glxc->pScreen)) {
+ client->errorValue = readId;
+ return BadMatch;
+ }
+
+ } else {
+
+ /*
+ ** An X Pixmap is not allowed as a parameter (a GLX Pixmap
+ ** is, but it must first be created with glxCreateGLXPixmap).
+ */
+ client->errorValue = readId;
+ return __glXBadDrawable;
+ }
+ }
+
+ if (!pReadDraw) {
+ dixLookupResourceByType((pointer*) &pReadGlxPixmap, readId,
+ __glXPixmapRes, NullClient,
+ DixUnknownAccess);
+ if (pReadGlxPixmap) {
+ /*
+ ** Check if pixmap and context are similar.
+ */
+ if (pReadGlxPixmap->pScreen != glxc->pScreen ||
+ pReadGlxPixmap->pGlxVisual != glxc->pGlxVisual) {
+ client->errorValue = readId;
+ return BadMatch;
+ }
+ pReadDraw = pReadGlxPixmap->pDraw;
+
+ new_reply.readVid = (glxc->pFBConfig ? glxc->pFBConfig->id :
+ pReadGlxPixmap->pGlxVisual->vid );
+ new_reply.readType = GLX_PIXMAP_TYPE;
+
+ }
+ }
+
+ if (!pReadDraw && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
+ dixLookupResourceByType((pointer*) &pGlxReadWindow, readId,
+ __glXWindowRes, NullClient,
+ DixUnknownAccess);
+ if (pGlxReadWindow) {
+ /*
+ ** Drawable is a GLXWindow.
+ **
+ ** Check if GLX window and context are similar.
+ */
+ if (pGlxReadWindow->pScreen != glxc->pScreen ||
+ pGlxReadWindow->pGlxFBConfig != glxc->pFBConfig) {
+ client->errorValue = readId;
+ return BadMatch;
+ }
+
+ pReadDraw = pGlxReadWindow->pDraw;
+ new_reply.readVid = pGlxReadWindow->pGlxFBConfig->id;
+ new_reply.readType = GLX_GLXWINDOW_TYPE;
+ }
+ }
+
+ if (!pReadDraw && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
+ dixLookupResourceByType((pointer*) &pGlxReadPbuffer, readId,
+ __glXPbufferRes, NullClient,
+ DixUnknownAccess);
+ if (pGlxReadPbuffer) {
+ if (pGlxReadPbuffer->pScreen != glxc->pScreen ||
+ pGlxReadPbuffer->pFBConfig != glxc->pFBConfig) {
+ client->errorValue = drawId;
+ return BadMatch;
+ }
+
+ pReadDraw = (DrawablePtr)pGlxReadPbuffer;
+ new_reply.readVid = pGlxReadPbuffer->pFBConfig->id;
+ new_reply.readType = GLX_PBUFFER_TYPE;
+ }
+ }
+
+ if (!pReadDraw) {
+ /*
+ ** Drawable is neither a Window nor a GLXPixmap.
+ */
+ client->errorValue = readId;
+ return __glXBadDrawable;
+ }
+
+ } else {
+ pReadDraw = pDraw;
+ pReadGlxPixmap = pGlxPixmap;
+ pReadWin = pWin;
+ new_reply.readVid = new_reply.writeVid;
+ new_reply.readType = new_reply.writeType;
+ }
+
+ if (prevglxc) {
+
+ if (prevglxc->pGlxPixmap) {
+ /*
+ ** The previous drawable was a glx pixmap, release it.
+ */
+ prevglxc->pGlxPixmap->refcnt--;
+ __glXFreeGLXPixmap( prevglxc->pGlxPixmap );
+ prevglxc->pGlxPixmap = 0;
+ }
+
+ if (prevglxc->pGlxReadPixmap) {
+ /*
+ ** The previous drawable was a glx pixmap, release it.
+ */
+ prevglxc->pGlxReadPixmap->refcnt--;
+ __glXFreeGLXPixmap( prevglxc->pGlxReadPixmap );
+ prevglxc->pGlxReadPixmap = 0;
+ }
+
+ if (prevglxc->pGlxWindow) {
+ /*
+ ** The previous drawable was a glx window, release it.
+ */
+ prevglxc->pGlxWindow->refcnt--;
+ __glXFreeGLXWindow( prevglxc->pGlxWindow );
+ prevglxc->pGlxWindow = 0;
+ }
+
+ if (prevglxc->pGlxReadWindow) {
+ /*
+ ** The previous drawable was a glx window, release it.
+ */
+ prevglxc->pGlxReadWindow->refcnt--;
+ __glXFreeGLXWindow( prevglxc->pGlxReadWindow );
+ prevglxc->pGlxReadWindow = 0;
+ }
+
+ if (prevglxc->pGlxPbuffer) {
+ /*
+ ** The previous drawable was a glx Pbuffer, release it.
+ */
+ prevglxc->pGlxPbuffer->refcnt--;
+ __glXFreeGLXPbuffer( prevglxc->pGlxPbuffer );
+ prevglxc->pGlxPbuffer = 0;
+ }
+
+ if (prevglxc->pGlxReadPbuffer) {
+ /*
+ ** The previous drawable was a glx Pbuffer, release it.
+ */
+ prevglxc->pGlxReadPbuffer->refcnt--;
+ __glXFreeGLXPbuffer( prevglxc->pGlxReadPbuffer );
+ prevglxc->pGlxReadPbuffer = 0;
+ }
+
+ ChangeCurrentContext(cl, glxc, tag);
+ ChangeCurrentContext(cl, glxc, tag);
+ StopUsingContext(prevglxc);
+ } else {
+ tag = AddCurrentContext(cl, glxc, pDraw);
+ }
+ if (glxc) {
+
+ glxc->pGlxPixmap = pGlxPixmap;
+ glxc->pGlxReadPixmap = pReadGlxPixmap;
+ glxc->pGlxWindow = pGlxWindow;
+ glxc->pGlxReadWindow = pGlxReadWindow;
+ glxc->pGlxPbuffer = pGlxPbuffer;
+ glxc->pGlxReadPbuffer = pGlxReadPbuffer;
+
+ if (pGlxPixmap) {
+ pGlxPixmap->refcnt++;
+ }
+
+ if (pReadGlxPixmap) {
+ pReadGlxPixmap->refcnt++;
+ }
+
+ if (pGlxWindow) {
+ pGlxWindow->refcnt++;
+ }
+
+ if (pGlxReadWindow) {
+ pGlxReadWindow->refcnt++;
+ }
+
+ if (pGlxPbuffer) {
+ pGlxPbuffer->refcnt++;
+ }
+
+ if (pGlxReadPbuffer) {
+ pGlxReadPbuffer->refcnt++;
+ }
+
+ StartUsingContext(cl, glxc);
+ new_reply.contextTag = tag;
+ } else {
+ new_reply.contextTag = 0;
+ }
+ new_reply.length = 0;
+ new_reply.type = X_Reply;
+ new_reply.sequenceNumber = client->sequence;
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ from_screen = 0;
+ to_screen = screenInfo.numScreens - 1;
+
+ if (pDraw && new_reply.writeType != GLX_PBUFFER_TYPE) {
+ dixLookupResourceByClass((pointer*) &pXinDraw,
+ pDraw->id, XRC_DRAWABLE,
+ client, DixReadAccess);
+ }
+
+ if (pReadDraw && pReadDraw != pDraw &&
+ new_reply.readType != GLX_PBUFFER_TYPE) {
+ dixLookupResourceByClass((pointer*) &pXinReadDraw,
+ pReadDraw->id, XRC_DRAWABLE,
+ client, DixReadAccess);
+ }
+ else {
+ pXinReadDraw = pXinDraw;
+ }
+ }
+#endif
+
+
+ /* send the MakeCurrent request to all required
+ * back-end servers.
+ */
+ for (s = from_screen; s<=to_screen; s++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[s];
+ Display *dpy = GetBackEndDisplay(cl,s);
+ unsigned int be_draw = None;
+ unsigned int be_read_draw = None;
+
+ if (pGlxPixmap) {
+ be_draw = pGlxPixmap->be_xids[s];
+ }
+ else if (pGlxPbuffer) {
+ be_draw = pGlxPbuffer->be_xids[s];
+ }
+#ifdef PANORAMIX
+ else if (pXinDraw) {
+ dixLookupWindow(&pWin, pXinDraw->info[s].id, client, DixReadAccess);
+ }
+#endif
+ else if (pGlxWindow) {
+ pWin = (WindowPtr)pGlxWindow->pDraw;
+ }
+
+ if (pWin && be_draw == None) {
+ be_draw = (unsigned int)(DMX_GET_WINDOW_PRIV(pWin))->window;
+ if (!be_draw) {
+ /* it might be that the window did not created yet on the */
+ /* back-end server (lazy window creation option), force */
+ /* creation of the window */
+ dmxCreateAndRealizeWindow( pWin, TRUE );
+ be_draw = (unsigned int)(DMX_GET_WINDOW_PRIV(pWin))->window;
+ }
+ }
+
+ /*
+ * Before sending the MakeCurrent request - sync the
+ * X11 connection to the back-end servers to make sure
+ * that drawable is already created
+ */
+ dmxSync( dmxScreen, 1 );
+
+ if (drawId == readId) {
+ LockDisplay(dpy);
+ GetReq(GLXMakeCurrent, be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = X_GLXMakeCurrent;
+ be_req->drawable = be_draw;
+ be_req->context = (unsigned int)(glxc ? glxc->real_ids[s-from_screen] : 0);
+ be_req->oldContextTag = GetCurrentBackEndTag(cl, tag, s);
+ if (!_XReply(dpy, (xReply *) &be_reply, 0, False)) {
+
+ /* The make current failed */
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return( BE_TO_CLIENT_ERROR(dmxLastErrorEvent.error_code) );
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ SetCurrentBackEndTag( cl, tag, s, be_reply.contextTag );
+ }
+ else {
+
+ if (pReadGlxPixmap) {
+ be_read_draw = pReadGlxPixmap->be_xids[s];
+ }
+ else if (pGlxReadPbuffer) {
+ be_read_draw = pGlxReadPbuffer->be_xids[s];
+ }
+#ifdef PANORAMIX
+ else if (pXinReadDraw) {
+ dixLookupWindow(&pReadWin, pXinReadDraw->info[s].id, client,
+ DixReadAccess);
+ }
+#endif
+ else if (pGlxReadWindow) {
+ pReadWin = (WindowPtr)pGlxReadWindow->pDraw;
+ }
+
+ if (pReadWin && be_read_draw == None) {
+ be_read_draw = (unsigned int)(DMX_GET_WINDOW_PRIV(pReadWin))->window;
+ if (!be_read_draw) {
+ /* it might be that the window did not created yet on the */
+ /* back-end server (lazy window creation option), force */
+ /* creation of the window */
+ dmxCreateAndRealizeWindow( pReadWin, TRUE );
+ be_read_draw = (unsigned int)(DMX_GET_WINDOW_PRIV(pReadWin))->window;
+ dmxSync( dmxScreen, 1 );
+ }
+ }
+
+ if ( __GLX_IS_VERSION_SUPPORTED(1,3) ) {
+ LockDisplay(dpy);
+ GetReq(GLXMakeContextCurrent, be_new_req);
+ be_new_req->reqType = dmxScreen->glxMajorOpcode;
+ be_new_req->glxCode = X_GLXMakeContextCurrent;
+ be_new_req->drawable = be_draw;
+ be_new_req->readdrawable = be_read_draw;
+ be_new_req->context = (unsigned int)(glxc ? glxc->real_ids[s-from_screen] : 0);
+ be_new_req->oldContextTag = GetCurrentBackEndTag(cl, tag, s);
+ if (!_XReply(dpy, (xReply *) &be_new_reply, 0, False)) {
+
+ /* The make current failed */
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return( BE_TO_CLIENT_ERROR(dmxLastErrorEvent.error_code) );
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ SetCurrentBackEndTag( cl, tag, s, be_new_reply.contextTag );
+ }
+ else if (glxIsExtensionSupported("GLX_SGI_make_current_read")) {
+ xGLXMakeCurrentReadSGIReq *ext_req;
+ xGLXVendorPrivateWithReplyReq *vpreq;
+ xGLXMakeCurrentReadSGIReply ext_reply;
+
+ LockDisplay(dpy);
+ GetReqExtra(GLXVendorPrivateWithReply,
+ sz_xGLXMakeCurrentReadSGIReq - sz_xGLXVendorPrivateWithReplyReq,
+ vpreq);
+ ext_req = (xGLXMakeCurrentReadSGIReq *)vpreq;
+ ext_req->reqType = dmxScreen->glxMajorOpcode;
+ ext_req->glxCode = X_GLXVendorPrivateWithReply;
+ ext_req->vendorCode = X_GLXvop_MakeCurrentReadSGI;
+ ext_req->drawable = be_draw;
+ ext_req->readable = be_read_draw;
+ ext_req->context = (unsigned int)(glxc ? glxc->real_ids[s-from_screen] : 0);
+ ext_req->oldContextTag = GetCurrentBackEndTag(cl, tag, s);
+ if (!_XReply(dpy, (xReply *) &ext_reply, 0, False)) {
+
+ /* The make current failed */
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return( BE_TO_CLIENT_ERROR(dmxLastErrorEvent.error_code) );
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ SetCurrentBackEndTag( cl, tag, s, ext_reply.contextTag );
+
+ }
+ else {
+ return BadMatch;
+ }
+ }
+
+ XFlush( dpy );
+ }
+
+ if (client->swapped) {
+ __glXSwapMakeCurrentReply(client, &new_reply);
+ } else {
+ WriteToClient(client, sz_xGLXMakeContextCurrentReply, (char *)&new_reply);
+ }
+
+ return Success;
+}
+
+int __glXMakeCurrent(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXMakeCurrentReq *req = (xGLXMakeCurrentReq *) pc;
+
+ return( MakeCurrent(cl, req->drawable, req->drawable,
+ req->context, req->oldContextTag ) );
+}
+
+int __glXMakeContextCurrent(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXMakeContextCurrentReq *req = (xGLXMakeContextCurrentReq *) pc;
+
+ return( MakeCurrent(cl, req->drawable, req->readdrawable,
+ req->context, req->oldContextTag ) );
+}
+
+int __glXMakeCurrentReadSGI(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXMakeCurrentReadSGIReq *req = (xGLXMakeCurrentReadSGIReq *) pc;
+
+ return( MakeCurrent(cl, req->drawable, req->readable,
+ req->context, req->oldContextTag ) );
+}
+
+int __glXIsDirect(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXIsDirectReq *req = (xGLXIsDirectReq *) pc;
+ xGLXIsDirectReply reply;
+ __GLXcontext *glxc;
+
+ /*
+ ** Find the GL context.
+ */
+ dixLookupResourceByType((pointer*) &glxc, req->context, __glXContextRes,
+ NullClient, DixUnknownAccess);
+ if (!glxc) {
+ client->errorValue = req->context;
+ return __glXBadContext;
+ }
+
+ reply.isDirect = 0;
+ reply.length = 0;
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+
+ if (client->swapped) {
+ __glXSwapIsDirectReply(client, &reply);
+ } else {
+ WriteToClient(client, sz_xGLXIsDirectReply, (char *)&reply);
+ }
+
+ return Success;
+}
+
+int __glXQueryVersion(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+/* xGLXQueryVersionReq *req = (xGLXQueryVersionReq *) pc; */
+ xGLXQueryVersionReply reply;
+
+ /*
+ ** Server should take into consideration the version numbers sent by the
+ ** client if it wants to work with older clients; however, in this
+ ** implementation the server just returns its version number.
+ */
+ reply.majorVersion = __glXVersionMajor;
+ reply.minorVersion = __glXVersionMinor;
+ reply.length = 0;
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+
+ if (client->swapped) {
+ __glXSwapQueryVersionReply(client, &reply);
+ } else {
+ WriteToClient(client, sz_xGLXQueryVersionReply, (char *)&reply);
+ }
+ return Success;
+}
+
+int __glXWaitGL(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXWaitGLReq *req = (xGLXWaitGLReq *)pc;
+ xGLXWaitGLReq *be_req = (xGLXWaitGLReq *)pc;
+ int from_screen = 0;
+ int to_screen = 0;
+ int s;
+ __GLXcontext *glxc = NULL;
+
+ if (req->contextTag != 0) {
+ glxc = __glXLookupContextByTag(cl, req->contextTag);
+ if (glxc) {
+ from_screen = to_screen = glxc->pScreen->myNum;
+ }
+ }
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ from_screen = 0;
+ to_screen = screenInfo.numScreens - 1;
+ }
+#endif
+
+ for (s=from_screen; s<=to_screen; s++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[s];
+ Display *dpy = GetBackEndDisplay(cl,s);
+
+ LockDisplay(dpy);
+ GetReq(GLXWaitGL,be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = X_GLXWaitGL;
+ be_req->contextTag = (glxc ? GetCurrentBackEndTag(cl,req->contextTag,s) : 0);
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ XSync(dpy, False);
+ }
+
+ return Success;
+}
+
+int __glXWaitX(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXWaitXReq *req = (xGLXWaitXReq *)pc;
+ xGLXWaitXReq *be_req;
+ int from_screen = 0;
+ int to_screen = 0;
+ int s;
+ __GLXcontext *glxc = NULL;
+
+ if (req->contextTag != 0) {
+ glxc = __glXLookupContextByTag(cl, req->contextTag);
+ if (glxc) {
+ from_screen = to_screen = glxc->pScreen->myNum;
+ }
+ }
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ from_screen = 0;
+ to_screen = screenInfo.numScreens - 1;
+ }
+#endif
+
+ for (s=from_screen; s<=to_screen; s++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[s];
+ Display *dpy = GetBackEndDisplay(cl,s);
+
+ dmxSync( dmxScreen, 1 );
+
+ LockDisplay(dpy);
+ GetReq(GLXWaitX,be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = X_GLXWaitX;
+ be_req->contextTag = (glxc ? GetCurrentBackEndTag(cl,req->contextTag,s) : 0);
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ XFlush( dpy );
+ }
+
+ return Success;
+}
+
+int __glXCopyContext(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXCopyContextReq *be_req;
+ xGLXCopyContextReq *req = (xGLXCopyContextReq *) pc;
+ GLXContextID source = req->source;
+ GLXContextID dest = req->dest;
+ GLXContextTag tag = req->contextTag;
+ unsigned long mask = req->mask;
+ __GLXcontext *src, *dst;
+ int s;
+ int from_screen = 0;
+ int to_screen = 0;
+
+ /*
+ ** Check that each context exists.
+ */
+ dixLookupResourceByType((pointer*) &src, source, __glXContextRes,
+ NullClient, DixUnknownAccess);
+ if (!src) {
+ client->errorValue = source;
+ return __glXBadContext;
+ }
+ dixLookupResourceByType((pointer*) &dst, dest, __glXContextRes,
+ NullClient, DixUnknownAccess);
+ if (!dst) {
+ client->errorValue = dest;
+ return __glXBadContext;
+ }
+
+ /*
+ ** They must be in the same address space, and same screen.
+ */
+ if (src->pGlxScreen != dst->pGlxScreen) {
+ client->errorValue = source;
+ return BadMatch;
+ }
+
+ /*
+ ** The destination context must not be current for any client.
+ */
+ if (dst->isCurrent) {
+ client->errorValue = dest;
+ return BadAccess;
+ }
+
+ if (tag) {
+ __GLXcontext *tagcx = __glXLookupContextByTag(cl, tag);
+
+ if (!tagcx) {
+ return __glXBadContextTag;
+ }
+ if (tagcx != src) {
+ /*
+ ** This would be caused by a faulty implementation of the client
+ ** library.
+ */
+ return BadMatch;
+ }
+ }
+
+ from_screen = to_screen = src->pScreen->myNum;
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ from_screen = 0;
+ to_screen = screenInfo.numScreens - 1;
+ }
+#endif
+
+ for (s=from_screen; s<=to_screen; s++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[s];
+ Display *dpy = GetBackEndDisplay(cl,s);
+
+ LockDisplay(dpy);
+ GetReq(GLXCopyContext,be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = X_GLXCopyContext;
+ be_req->source = (unsigned int)src->real_ids[s-from_screen];
+ be_req->dest = (unsigned int)dst->real_ids[s-from_screen];
+ be_req->mask = mask;
+ be_req->contextTag = (tag ? GetCurrentBackEndTag(cl,req->contextTag,s) : 0);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ }
+
+ return Success;
+}
+
+int __glXGetVisualConfigs(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXGetVisualConfigsReq *req = (xGLXGetVisualConfigsReq *) pc;
+ xGLXGetVisualConfigsReply reply;
+ __GLXscreenInfo *pGlxScreen;
+ __GLXvisualConfig *pGlxVisual;
+ CARD32 buf[__GLX_TOTAL_CONFIG];
+ unsigned int screen;
+ int i, p;
+
+ screen = req->screen;
+ if (screen >= screenInfo.numScreens) {
+ /* The client library must send a valid screen number. */
+ client->errorValue = screen;
+ return BadValue;
+ }
+ pGlxScreen = &__glXActiveScreens[screen];
+
+ reply.numVisuals = pGlxScreen->numGLXVisuals;
+ reply.numProps = __GLX_TOTAL_CONFIG;
+ reply.length = (pGlxScreen->numGLXVisuals * __GLX_SIZE_CARD32 *
+ __GLX_TOTAL_CONFIG) >> 2;
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+
+ WriteToClient(client, sz_xGLXGetVisualConfigsReply, (char *)&reply);
+
+ for (i=0; i < pGlxScreen->numVisuals; i++) {
+ pGlxVisual = &pGlxScreen->pGlxVisual[i];
+ if (!pGlxScreen->isGLXvis[i] || pGlxVisual->vid == 0) {
+ /* not a usable visual */
+ continue;
+ }
+ p = 0;
+ buf[p++] = pGlxVisual->vid;
+ buf[p++] = pGlxVisual->class;
+ buf[p++] = pGlxVisual->rgba;
+
+ buf[p++] = pGlxVisual->redSize;
+ buf[p++] = pGlxVisual->greenSize;
+ buf[p++] = pGlxVisual->blueSize;
+ buf[p++] = pGlxVisual->alphaSize;
+ buf[p++] = pGlxVisual->accumRedSize;
+ buf[p++] = pGlxVisual->accumGreenSize;
+ buf[p++] = pGlxVisual->accumBlueSize;
+ buf[p++] = pGlxVisual->accumAlphaSize;
+
+ buf[p++] = pGlxVisual->doubleBuffer;
+ buf[p++] = pGlxVisual->stereo;
+
+ buf[p++] = pGlxVisual->bufferSize;
+ buf[p++] = pGlxVisual->depthSize;
+ buf[p++] = pGlxVisual->stencilSize;
+ buf[p++] = pGlxVisual->auxBuffers;
+ buf[p++] = pGlxVisual->level;
+ /*
+ ** Add token/value pairs for extensions.
+ */
+ buf[p++] = GLX_VISUAL_CAVEAT_EXT;
+ buf[p++] = pGlxVisual->visualRating;
+ buf[p++] = GLX_TRANSPARENT_TYPE_EXT;
+ buf[p++] = pGlxVisual->transparentPixel;
+ buf[p++] = GLX_TRANSPARENT_RED_VALUE_EXT;
+ buf[p++] = pGlxVisual->transparentRed;
+ buf[p++] = GLX_TRANSPARENT_GREEN_VALUE_EXT;
+ buf[p++] = pGlxVisual->transparentGreen;
+ buf[p++] = GLX_TRANSPARENT_BLUE_VALUE_EXT;
+ buf[p++] = pGlxVisual->transparentBlue;
+ buf[p++] = GLX_TRANSPARENT_ALPHA_VALUE_EXT;
+ buf[p++] = pGlxVisual->transparentAlpha;
+ buf[p++] = GLX_TRANSPARENT_INDEX_VALUE_EXT;
+ buf[p++] = pGlxVisual->transparentIndex;
+ buf[p++] = GLX_SAMPLES_SGIS;
+ buf[p++] = pGlxVisual->multiSampleSize;
+ buf[p++] = GLX_SAMPLE_BUFFERS_SGIS;
+ buf[p++] = pGlxVisual->nMultiSampleBuffers;
+ buf[p++] = GLX_VISUAL_SELECT_GROUP_SGIX;
+ buf[p++] = pGlxVisual->visualSelectGroup;
+
+ WriteToClient(client, __GLX_SIZE_CARD32 * __GLX_TOTAL_CONFIG,
+ (char *)buf);
+ }
+ return Success;
+}
+
+/*
+** Create a GLX Pixmap from an X Pixmap.
+*/
+static int CreateGLXPixmap(__GLXclientState *cl,
+ VisualID visual, GLXFBConfigID fbconfigId,
+ int screenNum, XID pixmapId, XID glxpixmapId )
+{
+ ClientPtr client = cl->client;
+ xGLXCreateGLXPixmapReq *be_req;
+ xGLXCreatePixmapReq *be_new_req;
+ DrawablePtr pDraw;
+ ScreenPtr pScreen;
+ VisualPtr pVisual;
+ __GLXpixmap *pGlxPixmap;
+ __GLXscreenInfo *pGlxScreen;
+ __GLXvisualConfig *pGlxVisual;
+ __GLXFBConfig *pFBConfig;
+ int i, s, rc;
+ int from_screen, to_screen;
+#ifdef PANORAMIX
+ PanoramiXRes *pXinDraw = NULL;
+#endif
+
+ rc = dixLookupDrawable(&pDraw, pixmapId, client, M_DRAWABLE_PIXMAP,
+ DixAddAccess);
+ if (rc != Success)
+ return rc;
+
+ /*
+ ** Check if screen of visual matches screen of pixmap.
+ */
+ pScreen = pDraw->pScreen;
+ if (screenNum != pScreen->myNum) {
+ return BadMatch;
+ }
+
+ if (fbconfigId == 0 && visual == 0) {
+ return BadValue;
+ }
+
+ if (fbconfigId != None) {
+ pFBConfig = glxLookupFBConfig( fbconfigId );
+ if (!pFBConfig) {
+ client->errorValue = fbconfigId;
+ return BadValue;
+ }
+ visual = pFBConfig->associatedVisualId;
+ }
+ else {
+ pFBConfig = NULL;
+ }
+
+ if (visual != None) {
+ /*
+ ** Find the VisualRec for this visual.
+ */
+ pVisual = pScreen->visuals;
+ for (i=0; i < pScreen->numVisuals; i++, pVisual++) {
+ if (pVisual->vid == visual) {
+ break;
+ }
+ }
+ if (i == pScreen->numVisuals) {
+ client->errorValue = visual;
+ return BadValue;
+ }
+ /*
+ ** Check if depth of visual matches depth of pixmap.
+ */
+ if (pVisual->nplanes != pDraw->depth) {
+ client->errorValue = visual;
+ return BadMatch;
+ }
+
+ /*
+ ** Get configuration of the visual.
+ */
+ pGlxScreen = &__glXActiveScreens[screenNum];
+ pGlxVisual = pGlxScreen->pGlxVisual;
+ for (i = 0; i < pGlxScreen->numVisuals; i++, pGlxVisual++) {
+ if (pGlxVisual->vid == visual) {
+ break;
+ }
+ }
+ if (i == pGlxScreen->numVisuals) {
+ /*
+ ** Visual not support on this screen by this OpenGL implementation.
+ */
+ client->errorValue = visual;
+ return BadValue;
+ }
+
+
+ /* find the FBConfig for that visual (if any) */
+ if ( pFBConfig == NULL ) {
+ pFBConfig = glxLookupFBConfigByVID( visual );
+
+ if ( pFBConfig == NULL ) {
+ /*
+ * visual does not have an FBConfig ???
+ client->errorValue = visual;
+ return BadValue;
+ */
+ }
+ }
+ }
+ else {
+ pVisual = NULL;
+ pGlxVisual = NULL;
+ pGlxScreen = &__glXActiveScreens[pDraw->pScreen->myNum];
+ }
+
+ pGlxPixmap = (__GLXpixmap *) malloc(sizeof(__GLXpixmap));
+ if (!pGlxPixmap) {
+ return BadAlloc;
+ }
+ pGlxPixmap->be_xids = (XID *) malloc(sizeof(XID) * screenInfo.numScreens);
+ if (!pGlxPixmap->be_xids) {
+ free( pGlxPixmap );
+ return BadAlloc;
+ }
+
+ pGlxPixmap->pDraw = pDraw;
+ pGlxPixmap->pGlxScreen = pGlxScreen;
+ pGlxPixmap->pGlxVisual = pGlxVisual;
+ pGlxPixmap->pFBConfig = pFBConfig;
+ pGlxPixmap->pScreen = pScreen;
+ pGlxPixmap->idExists = True;
+ pGlxPixmap->refcnt = 0;
+
+ /*
+ ** Bump the ref count on the X pixmap so it won't disappear.
+ */
+ ((PixmapPtr) pDraw)->refcnt++;
+
+ /*
+ * send the request to the back-end server(s)
+ */
+ from_screen = to_screen = screenNum;
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ from_screen = 0;
+ to_screen = screenInfo.numScreens - 1;
+
+ dixLookupResourceByClass((pointer*) &pXinDraw,
+ pDraw->id, XRC_DRAWABLE,
+ client, DixReadAccess);
+ }
+#endif
+
+ for (s=from_screen; s<=to_screen; s++) {
+
+ DMXScreenInfo *dmxScreen = &dmxScreens[s];
+ Display *dpy = GetBackEndDisplay(cl,s);
+ Pixmap be_pixmap;
+ DrawablePtr pRealDraw = pDraw;
+
+#ifdef PANORAMIX
+ if (pXinDraw) {
+ dixLookupDrawable(&pRealDraw, pXinDraw->info[s].id, client, 0,
+ DixAddAccess);
+ }
+#endif
+
+ be_pixmap = (DMX_GET_PIXMAP_PRIV((PixmapPtr)pRealDraw))->pixmap;
+
+ /* make sure pixmap already created on back-end */
+ dmxSync( dmxScreen, 1 );
+
+ if ( pFBConfig && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
+ __GLXFBConfig *be_FBConfig = glxLookupBackEndFBConfig( pFBConfig->id, s );
+
+ LockDisplay(dpy);
+ pGlxPixmap->be_xids[s] = XAllocID(dpy);
+ GetReq(GLXCreatePixmap,be_new_req);
+ be_new_req->reqType = dmxScreen->glxMajorOpcode;
+ be_new_req->glxCode = X_GLXCreatePixmap;
+ be_new_req->screen = DefaultScreen(dpy);
+ be_new_req->fbconfig = be_FBConfig->id;
+ be_new_req->pixmap = (unsigned int)be_pixmap;
+ be_new_req->glxpixmap = (unsigned int)pGlxPixmap->be_xids[s];
+ be_new_req->numAttribs = 0;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ }
+ else if (pFBConfig && glxIsExtensionSupported("GLX_SGIX_fbconfig")) {
+ __GLXFBConfig *be_FBConfig = glxLookupBackEndFBConfig( pFBConfig->id, s );
+ xGLXCreateGLXPixmapWithConfigSGIXReq *ext_req;
+ xGLXVendorPrivateReq *vpreq;
+
+ LockDisplay(dpy);
+ pGlxPixmap->be_xids[s] = XAllocID(dpy);
+ GetReqExtra(GLXVendorPrivate,
+ sz_xGLXCreateGLXPixmapWithConfigSGIXReq-sz_xGLXVendorPrivateReq,
+ vpreq);
+ ext_req = (xGLXCreateGLXPixmapWithConfigSGIXReq *)vpreq;
+ ext_req->reqType = dmxScreen->glxMajorOpcode;
+ ext_req->glxCode = X_GLXVendorPrivate;
+ ext_req->vendorCode = X_GLXvop_CreateGLXPixmapWithConfigSGIX;
+ ext_req->screen = DefaultScreen(dpy);
+ ext_req->fbconfig = be_FBConfig->id;
+ ext_req->pixmap = (unsigned int)be_pixmap;
+ ext_req->glxpixmap = (unsigned int)pGlxPixmap->be_xids[s];
+ UnlockDisplay(dpy);
+ SyncHandle();
+ }
+ else if (pGlxVisual) {
+ LockDisplay(dpy);
+ pGlxPixmap->be_xids[s] = XAllocID(dpy);
+ GetReq(GLXCreateGLXPixmap,be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = X_GLXCreateGLXPixmap;
+ be_req->screen = DefaultScreen(dpy);
+ be_req->visual = (unsigned int)glxMatchGLXVisualInConfigList(
+ pGlxVisual,
+ dmxScreen->glxVisuals,
+ dmxScreen->numGlxVisuals );
+ be_req->pixmap = (unsigned int)be_pixmap;
+ be_req->glxpixmap = (unsigned int)pGlxPixmap->be_xids[s];
+ UnlockDisplay(dpy);
+ SyncHandle();
+ }
+ else {
+ client->errorValue = ( visual ? visual : fbconfigId );
+ free( pGlxPixmap );
+ return BadValue;
+ }
+
+ XFlush( dpy );
+ }
+
+ if (!(AddResource(glxpixmapId, __glXPixmapRes, pGlxPixmap))) {
+ free( pGlxPixmap );
+ return BadAlloc;
+ }
+
+ return Success;
+}
+
+int __glXCreateGLXPixmap(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreateGLXPixmapReq *req = (xGLXCreateGLXPixmapReq *) pc;
+
+ return( CreateGLXPixmap(cl, req->visual, None,
+ req->screen, req->pixmap, req->glxpixmap) );
+}
+
+int __glXCreatePixmap(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreatePixmapReq *req = (xGLXCreatePixmapReq *) pc;
+
+ return( CreateGLXPixmap(cl, None, req->fbconfig,
+ req->screen, req->pixmap, req->glxpixmap) );
+}
+
+int __glXDestroyGLXPixmap(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXDestroyGLXPixmapReq *req = (xGLXDestroyGLXPixmapReq *) pc;
+ XID glxpixmap = req->glxpixmap;
+ __GLXpixmap *pGlxPixmap;
+ int s;
+ int from_screen, to_screen;
+
+ /*
+ ** Check if it's a valid GLX pixmap.
+ */
+ dixLookupResourceByType((pointer*) &pGlxPixmap, glxpixmap,
+ __glXPixmapRes, NullClient, DixUnknownAccess);
+ if (!pGlxPixmap) {
+ client->errorValue = glxpixmap;
+ return __glXBadPixmap;
+ }
+ FreeResource(glxpixmap, FALSE);
+
+ /*
+ * destroy the pixmap on the back-end server(s).
+ */
+ from_screen = to_screen = pGlxPixmap->pDraw->pScreen->myNum;
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ from_screen = 0;
+ to_screen = screenInfo.numScreens - 1;
+ }
+#endif
+
+ for (s=from_screen; s<=to_screen; s++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[s];
+ Display *dpy = GetBackEndDisplay(cl,s);
+
+ /* make sure pixmap exist in back-end */
+ dmxSync( dmxScreen, 1 );
+
+ LockDisplay(dpy);
+ GetReq(GLXDestroyGLXPixmap,req);
+ req->reqType = dmxScreen->glxMajorOpcode;
+ req->glxCode = X_GLXDestroyGLXPixmap;
+ req->glxpixmap = (unsigned int)pGlxPixmap->be_xids[s];
+ UnlockDisplay(dpy);
+ SyncHandle();
+ }
+
+
+ return Success;
+}
+
+/*****************************************************************************/
+
+/*
+** NOTE: There is no portable implementation for swap buffers as of
+** this time that is of value. Consequently, this code must be
+** implemented by somebody other than SGI.
+*/
+int __glXDoSwapBuffers(__GLXclientState *cl, XID drawId, GLXContextTag tag)
+{
+ ClientPtr client = cl->client;
+ DrawablePtr pDraw;
+ xGLXSwapBuffersReq *be_req;
+ WindowPtr pWin = NULL;
+ __GLXpixmap *pGlxPixmap = NULL;
+ __GLXcontext *glxc = NULL;
+#ifdef PANORAMIX
+ PanoramiXRes *pXinDraw = NULL;
+#endif
+ __glXWindow *pGlxWindow = NULL;
+ int from_screen = 0;
+ int to_screen = 0;
+ int s, rc;
+
+ /*
+ ** Check that the GLX drawable is valid.
+ */
+ rc = dixLookupDrawable(&pDraw, drawId, client, 0, DixWriteAccess);
+ if (rc == Success) {
+ from_screen = to_screen = pDraw->pScreen->myNum;
+
+ if (pDraw->type == DRAWABLE_WINDOW) {
+ /*
+ ** Drawable is an X window.
+ */
+ pWin = (WindowPtr)pDraw;
+ } else {
+ /*
+ ** Drawable is an X pixmap, which is not allowed.
+ */
+ client->errorValue = drawId;
+ return __glXBadDrawable;
+ }
+ }
+
+ if (!pDraw) {
+ dixLookupResourceByType((pointer*) &pGlxPixmap, drawId,
+ __glXPixmapRes, NullClient, DixUnknownAccess);
+ if (pGlxPixmap) {
+ /*
+ ** Drawable is a GLX pixmap.
+ */
+ pDraw = pGlxPixmap->pDraw;
+ from_screen = to_screen = pGlxPixmap->pScreen->myNum;
+ }
+ }
+
+ if (!pDraw && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
+ dixLookupResourceByType((pointer*) &pGlxWindow, drawId,
+ __glXWindowRes, NullClient, DixUnknownAccess);
+ if (pGlxWindow) {
+ /*
+ ** Drawable is a GLXWindow.
+ */
+ pDraw = pGlxWindow->pDraw;
+ from_screen = to_screen = pGlxWindow->pScreen->myNum;
+ }
+ }
+
+ if (!pDraw) {
+ /*
+ ** Drawable is neither a X window nor a GLX pixmap.
+ */
+ client->errorValue = drawId;
+ return __glXBadDrawable;
+ }
+
+ if (tag) {
+ glxc = __glXLookupContextByTag(cl, tag);
+ if (!glxc) {
+ return __glXBadContextTag;
+ }
+ }
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ from_screen = 0;
+ to_screen = screenInfo.numScreens - 1;
+ dixLookupResourceByClass((pointer*) &pXinDraw,
+ pDraw->id, XRC_DRAWABLE,
+ client, DixReadAccess);
+ }
+#endif
+
+ /* If requested, send a glFinish to all back-end servers before swapping. */
+ if (dmxGLXFinishSwap) {
+ for (s=from_screen; s<=to_screen; s++) {
+ Display *dpy = GetBackEndDisplay(cl,s);
+ DMXScreenInfo *dmxScreen = &dmxScreens[s];
+ xGLXSingleReq *finishReq;
+ xGLXSingleReply reply;
+
+#define X_GLXSingle 0 /* needed by GetReq below */
+
+ LockDisplay(dpy);
+ GetReq(GLXSingle,finishReq);
+ finishReq->reqType = dmxScreen->glxMajorOpcode;
+ finishReq->glxCode = X_GLsop_Finish;
+ finishReq->contextTag = (tag ? GetCurrentBackEndTag(cl,tag,s) : 0);
+ (void) _XReply(dpy, (xReply*) &reply, 0, False);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ }
+ }
+
+ /* If requested, send an XSync to all back-end servers before swapping. */
+ if (dmxGLXSyncSwap) {
+ for (s=from_screen; s<=to_screen; s++)
+ XSync(GetBackEndDisplay(cl,s), False);
+ }
+
+
+ /* send the SwapBuffers request to all back-end servers */
+
+ for (s=from_screen; s<=to_screen; s++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[s];
+ Display *dpy = GetBackEndDisplay(cl,s);
+ unsigned int be_draw = 0;
+
+ if (pGlxPixmap) {
+ be_draw = (unsigned int)pGlxPixmap->be_xids[s];
+ }
+#ifdef PANORAMIX
+ else if (pXinDraw) {
+ dixLookupWindow(&pWin, pXinDraw->info[s].id, client, DixReadAccess);
+ }
+#endif
+ else if (pGlxWindow) {
+ pWin = (WindowPtr)pGlxWindow->pDraw;
+ }
+
+ if (pWin && !be_draw) {
+ be_draw = (unsigned int)(DMX_GET_WINDOW_PRIV(pWin))->window;
+ if (!be_draw) {
+ /* it might be that the window did not created yet on the */
+ /* back-end server (lazy window creation option), force */
+ /* creation of the window */
+ dmxCreateAndRealizeWindow( pWin, TRUE );
+ be_draw = (unsigned int)(DMX_GET_WINDOW_PRIV(pWin))->window;
+ }
+ }
+
+ dmxSync( dmxScreen, 1 );
+
+ LockDisplay(dpy);
+ GetReq(GLXSwapBuffers,be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = X_GLXSwapBuffers;
+ be_req->drawable = be_draw;
+ be_req->contextTag = ( tag ? GetCurrentBackEndTag(cl,tag,s) : 0 );
+ UnlockDisplay(dpy);
+ SyncHandle();
+ XFlush(dpy);
+ }
+
+ return Success;
+}
+
+int __glXSwapBuffers(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ DrawablePtr pDraw;
+ xGLXSwapBuffersReq *req = (xGLXSwapBuffersReq *) pc;
+ GLXContextTag tag = req->contextTag;
+ XID drawId = req->drawable;
+ __GLXpixmap *pGlxPixmap = NULL;
+ __GLXcontext *glxc = NULL;
+ __glXWindow *pGlxWindow = NULL;
+ int rc;
+
+ /*
+ ** Check that the GLX drawable is valid.
+ */
+ rc = dixLookupDrawable(&pDraw, drawId, client, 0, DixWriteAccess);
+ if (rc == Success) {
+ if (pDraw->type != DRAWABLE_WINDOW) {
+ /*
+ ** Drawable is an X pixmap, which is not allowed.
+ */
+ client->errorValue = drawId;
+ return __glXBadDrawable;
+ }
+ }
+
+ if (!pDraw) {
+ dixLookupResourceByType((pointer*) &pGlxPixmap, drawId,
+ __glXPixmapRes, NullClient, DixUnknownAccess);
+ if (pGlxPixmap) {
+ /*
+ ** Drawable is a GLX pixmap.
+ */
+ pDraw = pGlxPixmap->pDraw;
+ }
+ }
+
+ if (!pDraw && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
+ dixLookupResourceByType((pointer*) &pGlxWindow, drawId,
+ __glXWindowRes, NullClient, DixUnknownAccess);
+ if (pGlxWindow) {
+ /*
+ ** Drawable is a GLXWindow.
+ */
+ pDraw = pGlxWindow->pDraw;
+ }
+ }
+
+ if (!pDraw) {
+ /*
+ ** Drawable is neither a X window nor a GLX pixmap.
+ */
+ client->errorValue = drawId;
+ return __glXBadDrawable;
+ }
+
+ if (tag) {
+ glxc = __glXLookupContextByTag(cl, tag);
+ if (!glxc) {
+ return __glXBadContextTag;
+ }
+ }
+
+ if (pDraw &&
+ pDraw->type == DRAWABLE_WINDOW &&
+ DMX_GET_WINDOW_PRIV((WindowPtr)pDraw)->swapGroup) {
+ return SGSwapBuffers(cl, drawId, tag, pDraw);
+ }
+
+ return __glXDoSwapBuffers(cl, drawId, tag);
+}
+
+
+/************************************************************************/
+
+/*
+** Render and Renderlarge are not in the GLX API. They are used by the GLX
+** client library to send batches of GL rendering commands.
+*/
+
+/*
+** Execute all the drawing commands in a request.
+*/
+int __glXRender(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXRenderReq *req;
+ xGLXRenderReq *be_req;
+ int size;
+ __GLXcontext *glxc;
+ int from_screen = 0;
+ int to_screen = 0;
+ int s;
+
+ /*
+ ** NOTE: much of this code also appears in the byteswapping version of this
+ ** routine, __glXSwapRender(). Any changes made here should also be
+ ** duplicated there.
+ */
+
+ req = (xGLXRenderReq *) pc;
+
+ glxc = __glXLookupContextByTag(cl, req->contextTag);
+ if (!glxc) {
+ return 0;
+ }
+ from_screen = to_screen = glxc->pScreen->myNum;
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ from_screen = 0;
+ to_screen = screenInfo.numScreens - 1;
+ }
+#endif
+
+ pc += sz_xGLXRenderReq;
+ size = (req->length << 2) - sz_xGLXRenderReq;
+
+ /*
+ * just forward the request to back-end server(s)
+ */
+ for (s=from_screen; s<=to_screen; s++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[s];
+ Display *dpy = GetBackEndDisplay(cl,s);
+
+ LockDisplay(dpy);
+ GetReq(GLXRender,be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = X_GLXRender;
+ be_req->length = req->length;
+ be_req->contextTag = GetCurrentBackEndTag(cl,req->contextTag,s);
+ _XSend(dpy, (const char *)pc, size);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ }
+
+ return Success;
+}
+
+/*
+** Execute a large rendering request (one that spans multiple X requests).
+*/
+int __glXRenderLarge(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXRenderLargeReq *req;
+ xGLXRenderLargeReq *be_req;
+ __GLXcontext *glxc;
+ int from_screen = 0;
+ int to_screen = 0;
+ int s;
+
+ /*
+ ** NOTE: much of this code also appears in the byteswapping version of this
+ ** routine, __glXSwapRenderLarge(). Any changes made here should also be
+ ** duplicated there.
+ */
+
+ req = (xGLXRenderLargeReq *) pc;
+ glxc = __glXLookupContextByTag(cl, req->contextTag);
+ if (!glxc) {
+ return 0;
+ }
+ from_screen = to_screen = glxc->pScreen->myNum;
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ from_screen = 0;
+ to_screen = screenInfo.numScreens - 1;
+ }
+#endif
+
+ pc += sz_xGLXRenderLargeReq;
+
+ /*
+ * just forward the request to back-end server(s)
+ */
+ for (s=from_screen; s<=to_screen; s++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[s];
+ Display *dpy = GetBackEndDisplay(cl,s);
+
+ GetReq(GLXRenderLarge,be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = X_GLXRenderLarge;
+ be_req->contextTag = GetCurrentBackEndTag(cl,req->contextTag,s);
+ be_req->length = req->length;
+ be_req->requestNumber = req->requestNumber;
+ be_req->requestTotal = req->requestTotal;
+ be_req->dataBytes = req->dataBytes;
+ Data(dpy, (const char *)pc, req->dataBytes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ }
+
+ return Success;
+}
+
+
+/************************************************************************/
+
+int __glXVendorPrivate(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXVendorPrivateReq *req;
+
+ req = (xGLXVendorPrivateReq *) pc;
+
+ switch( req->vendorCode ) {
+
+ case X_GLvop_DeleteTexturesEXT:
+ return __glXVForwardSingleReq( cl, pc );
+ break;
+
+ case X_GLXvop_SwapIntervalSGI:
+ if (glxIsExtensionSupported("SGI_swap_control")) {
+ return __glXVForwardSingleReq( cl, pc );
+ }
+ else {
+ return Success;
+ }
+ break;
+
+#if 0 /* glx 1.3 */
+ case X_GLXvop_CreateGLXVideoSourceSGIX:
+ break;
+ case X_GLXvop_DestroyGLXVideoSourceSGIX:
+ break;
+ case X_GLXvop_CreateGLXPixmapWithConfigSGIX:
+ break;
+ case X_GLXvop_DestroyGLXPbufferSGIX:
+ break;
+ case X_GLXvop_ChangeDrawableAttributesSGIX:
+ break;
+#endif
+
+ case X_GLXvop_BindSwapBarrierSGIX:
+ return __glXBindSwapBarrierSGIX( cl, pc );
+ break;
+
+ case X_GLXvop_JoinSwapGroupSGIX:
+ return __glXJoinSwapGroupSGIX( cl, pc );
+ break;
+
+ case X_GLXvop_CreateContextWithConfigSGIX:
+ return __glXCreateContextWithConfigSGIX( cl, pc );
+ break;
+
+ default:
+ /*
+ ** unsupported private request
+ */
+ cl->client->errorValue = req->vendorCode;
+ return __glXUnsupportedPrivateRequest;
+ }
+
+ cl->client->errorValue = req->vendorCode;
+ return __glXUnsupportedPrivateRequest;
+
+}
+
+int __glXVendorPrivateWithReply(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXVendorPrivateWithReplyReq *req;
+
+ req = (xGLXVendorPrivateWithReplyReq *) pc;
+
+ switch( req->vendorCode ) {
+
+ case X_GLvop_GetConvolutionFilterEXT:
+ case X_GLvop_GetConvolutionParameterfvEXT:
+ case X_GLvop_GetConvolutionParameterivEXT:
+ case X_GLvop_GetSeparableFilterEXT:
+ case X_GLvop_GetHistogramEXT:
+ case X_GLvop_GetHistogramParameterivEXT:
+ case X_GLvop_GetMinmaxEXT:
+ case X_GLvop_GetMinmaxParameterfvEXT:
+ case X_GLvop_GetMinmaxParameterivEXT:
+ case X_GLvop_AreTexturesResidentEXT:
+ case X_GLvop_IsTextureEXT:
+ return( __glXVForwardPipe0WithReply(cl, pc) );
+ break;
+
+ case X_GLvop_GenTexturesEXT:
+ return( __glXVForwardAllWithReply(cl, pc) );
+ break;
+
+
+#if 0 /* glx1.3 */
+ case X_GLvop_GetDetailTexFuncSGIS:
+ case X_GLvop_GetSharpenTexFuncSGIS:
+ case X_GLvop_GetColorTableSGI:
+ case X_GLvop_GetColorTableParameterfvSGI:
+ case X_GLvop_GetColorTableParameterivSGI:
+ case X_GLvop_GetTexFilterFuncSGIS:
+ case X_GLvop_GetInstrumentsSGIX:
+ case X_GLvop_InstrumentsBufferSGIX:
+ case X_GLvop_PollInstrumentsSGIX:
+ case X_GLvop_FlushRasterSGIX:
+ case X_GLXvop_CreateGLXPbufferSGIX:
+ case X_GLXvop_GetDrawableAttributesSGIX:
+ case X_GLXvop_QueryHyperpipeNetworkSGIX:
+ case X_GLXvop_QueryHyperpipeConfigSGIX:
+ case X_GLXvop_HyperpipeConfigSGIX:
+ case X_GLXvop_DestroyHyperpipeConfigSGIX:
+#endif
+ case X_GLXvop_QueryMaxSwapBarriersSGIX:
+ return( __glXQueryMaxSwapBarriersSGIX(cl, pc) );
+ break;
+
+ case X_GLXvop_GetFBConfigsSGIX:
+ return( __glXGetFBConfigsSGIX(cl, pc) );
+ break;
+
+ case X_GLXvop_MakeCurrentReadSGI:
+ return( __glXMakeCurrentReadSGI(cl, pc) );
+ break;
+
+ case X_GLXvop_QueryContextInfoEXT:
+ return( __glXQueryContextInfoEXT(cl,pc) );
+ break;
+
+ default:
+ /*
+ ** unsupported private request
+ */
+ cl->client->errorValue = req->vendorCode;
+ return __glXUnsupportedPrivateRequest;
+ }
+
+}
+
+int __glXQueryExtensionsString(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXQueryExtensionsStringReq *req = (xGLXQueryExtensionsStringReq *) pc;
+ xGLXQueryExtensionsStringReply reply;
+ GLint screen;
+ size_t length;
+ int len, numbytes;
+ char *be_buf;
+
+#ifdef FWD_QUERY_REQ
+ xGLXQueryExtensionsStringReq *be_req;
+ xGLXQueryExtensionsStringReply be_reply;
+ DMXScreenInfo *dmxScreen;
+ Display *dpy;
+ int slop;
+#endif
+
+ screen = req->screen;
+
+ /*
+ ** Check if screen exists.
+ */
+ if ((screen < 0) || (screen >= screenInfo.numScreens)) {
+ client->errorValue = screen;
+ return BadValue;
+ }
+
+#ifdef FWD_QUERY_REQ
+ dmxScreen = &dmxScreens[screen];
+
+ /* Send the glXQueryServerString request */
+ dpy = GetBackEndDisplay(cl,screen);
+ LockDisplay(dpy);
+ GetReq(GLXQueryExtensionsString,be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = X_GLXQueryServerString;
+ be_req->screen = DefaultScreen(dpy);
+ _XReply(dpy, (xReply*) &be_reply, 0, False);
+ len = (int)be_reply.length;
+ numbytes = (int)be_reply.n;
+ slop = numbytes * __GLX_SIZE_INT8 & 3;
+ be_buf = (char *)malloc(numbytes);
+ if (!be_buf) {
+ /* Throw data on the floor */
+ _XEatData(dpy, len);
+ } else {
+ _XRead(dpy, (char *)be_buf, numbytes);
+ if (slop) _XEatData(dpy,4-slop);
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+#else
+
+ be_buf = __glXGetServerString(GLX_EXTENSIONS);
+ numbytes = strlen(be_buf) + 1;
+ len = __GLX_PAD(numbytes) >> 2;
+
+#endif
+
+ length = len;
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+ reply.length = len;
+ reply.n = numbytes;
+
+ if (client->swapped) {
+ glxSwapQueryExtensionsStringReply(client, &reply, be_buf);
+ } else {
+ WriteToClient(client, sz_xGLXQueryExtensionsStringReply,(char *)&reply);
+ WriteToClient(client, (int)(length << 2), (char *)be_buf);
+ }
+
+ return Success;
+}
+
+int __glXQueryServerString(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXQueryServerStringReq *req = (xGLXQueryServerStringReq *) pc;
+ xGLXQueryServerStringReply reply;
+ int name;
+ GLint screen;
+ size_t length;
+ int len, numbytes;
+ char *be_buf;
+#ifdef FWD_QUERY_REQ
+ xGLXQueryServerStringReq *be_req;
+ xGLXQueryServerStringReply be_reply;
+ DMXScreenInfo *dmxScreen;
+ Display *dpy;
+ int slop;
+#endif
+
+ name = req->name;
+ screen = req->screen;
+ /*
+ ** Check if screen exists.
+ */
+ if ((screen < 0) || (screen >= screenInfo.numScreens)) {
+ client->errorValue = screen;
+ return BadValue;
+ }
+
+#ifdef FWD_QUERY_REQ
+ dmxScreen = &dmxScreens[screen];
+
+ /* Send the glXQueryServerString request */
+ dpy = GetBackEndDisplay(cl,screen);
+ LockDisplay(dpy);
+ GetReq(GLXQueryServerString,be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = X_GLXQueryServerString;
+ be_req->screen = DefaultScreen(dpy);
+ be_req->name = name;
+ _XReply(dpy, (xReply*) &be_reply, 0, False);
+ len = (int)be_reply.length;
+ numbytes = (int)be_reply.n;
+ slop = numbytes * __GLX_SIZE_INT8 & 3;
+ be_buf = (char *)malloc(numbytes);
+ if (!be_buf) {
+ /* Throw data on the floor */
+ _XEatData(dpy, len);
+ } else {
+ _XRead(dpy, (char *)be_buf, numbytes);
+ if (slop) _XEatData(dpy,4-slop);
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+#else
+ be_buf = __glXGetServerString(name);
+ numbytes = strlen(be_buf) + 1;
+ len = __GLX_PAD(numbytes) >> 2;
+#endif
+
+ length = len;
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+ reply.length = length;
+ reply.n = numbytes;
+
+ if (client->swapped) {
+ glxSwapQueryServerStringReply(client, &reply, be_buf);
+ } else {
+ WriteToClient(client, sz_xGLXQueryServerStringReply, (char *)&reply);
+ WriteToClient(client, (int)(length << 2), be_buf);
+ }
+
+ return Success;
+}
+
+int __glXClientInfo(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXClientInfoReq *req = (xGLXClientInfoReq *) pc;
+ xGLXClientInfoReq *be_req;
+ const char *buf;
+ int from_screen = 0;
+ int to_screen = 0;
+ int s;
+
+ cl->GLClientmajorVersion = req->major;
+ cl->GLClientminorVersion = req->minor;
+ free(cl->GLClientextensions);
+ buf = (const char *)(req+1);
+ cl->GLClientextensions = strdup(buf);
+
+ to_screen = screenInfo.numScreens - 1;
+
+ for (s=from_screen; s<=to_screen; s++)
+ {
+ DMXScreenInfo *dmxScreen = &dmxScreens[s];
+ Display *dpy = GetBackEndDisplay(cl,s);
+
+ LockDisplay(dpy);
+ GetReq(GLXClientInfo,be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = X_GLXClientInfo;
+ be_req->major = req->major;
+ be_req->minor = req->minor;
+ be_req->length = req->length;
+ be_req->numbytes = req->numbytes;
+ Data(dpy, buf, req->numbytes);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ }
+
+ return Success;
+}
+
+int __glXUseXFont(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXUseXFontReq *req;
+ xGLXUseXFontReq *be_req;
+ FontPtr pFont;
+ __GLXcontext *glxc = NULL;
+ int from_screen = 0;
+ int to_screen = 0;
+ int s;
+ dmxFontPrivPtr pFontPriv;
+ DMXScreenInfo *dmxScreen;
+ Display *dpy;
+
+ req = (xGLXUseXFontReq *) pc;
+
+ if (req->contextTag != 0) {
+ glxc = __glXLookupContextByTag(cl, req->contextTag);
+ if (glxc) {
+ from_screen = to_screen = glxc->pScreen->myNum;
+ }
+ }
+
+ /*
+ ** Font can actually be either the ID of a font or the ID of a GC
+ ** containing a font.
+ */
+ dixLookupResourceByType((pointer*) &pFont, req->font, RT_FONT,
+ NullClient, DixUnknownAccess);
+ if (!pFont) {
+ GC *pGC;
+ dixLookupResourceByType((pointer*) &pGC, req->font,
+ RT_GC, NullClient,
+ DixUnknownAccess);
+ if (!pGC) {
+ client->errorValue = req->font;
+ return BadFont;
+ }
+ pFont = pGC->font;
+ }
+
+ pFontPriv = FontGetPrivate(pFont, dmxFontPrivateIndex);
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ from_screen = 0;
+ to_screen = screenInfo.numScreens - 1;
+ }
+#endif
+
+
+ for (s=from_screen; s<=to_screen; s++) {
+ dmxScreen = &dmxScreens[s];
+ dpy = GetBackEndDisplay(cl,s);
+
+ dmxSync( dmxScreen, 1 );
+
+ LockDisplay(dpy);
+ GetReq(GLXUseXFont,be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = X_GLXUseXFont;
+ be_req->contextTag = (glxc ? GetCurrentBackEndTag(cl,req->contextTag,s) : 0);
+ be_req->font = pFontPriv->font[s]->fid;
+ be_req->first = req->first;
+ be_req->count = req->count;
+ be_req->listBase = req->listBase;
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ XSync( dpy, False );
+ }
+
+ return Success;
+}
+
+/*
+ * start GLX 1.3 here
+ */
+
+int __glXGetFBConfigs(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXGetFBConfigsReq *req = (xGLXGetFBConfigsReq *) pc;
+ xGLXGetFBConfigsReply reply;
+ __GLXFBConfig *pFBConfig;
+ CARD32 buf[2 * __GLX_TOTAL_FBCONFIG_PROPS];
+ int numAttribs = __GLX_TOTAL_FBCONFIG_PROPS;
+ unsigned int screen = req->screen;
+ int numFBConfigs, i, p;
+ __GLXscreenInfo *pGlxScreen;
+
+ if (screen >= screenInfo.numScreens) {
+ /* The client library must send a valid screen number. */
+ client->errorValue = screen;
+ return BadValue;
+ }
+
+ pGlxScreen = &__glXActiveScreens[screen];
+ numFBConfigs = __glXNumFBConfigs;
+
+ reply.numFBConfigs = numFBConfigs;
+ reply.numAttribs = numAttribs;
+ reply.length = (numFBConfigs * 2 * numAttribs * __GLX_SIZE_CARD32) >> 2;
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+
+ if (client->swapped) {
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_SWAP_SHORT(&reply.sequenceNumber);
+ __GLX_SWAP_INT(&reply.length);
+ __GLX_SWAP_INT(&reply.numFBConfigs);
+ __GLX_SWAP_INT(&reply.numAttribs);
+ }
+ WriteToClient(client, sz_xGLXGetFBConfigsReply, (char *)&reply);
+
+ for (i=0; i < numFBConfigs; i++) {
+ int associatedVisualId = 0;
+ int drawableTypeIndex;
+ pFBConfig = __glXFBConfigs[ i * (screenInfo.numScreens+1) ];
+
+ p = 0;
+ /* core attributes */
+ buf[p++] = GLX_FBCONFIG_ID;
+ buf[p++] = pFBConfig->id;
+ buf[p++] = GLX_BUFFER_SIZE;
+ buf[p++] = pFBConfig->indexBits;
+ buf[p++] = GLX_LEVEL;
+ buf[p++] = pFBConfig->level;
+ buf[p++] = GLX_DOUBLEBUFFER;
+ buf[p++] = pFBConfig->doubleBufferMode;
+ buf[p++] = GLX_STEREO;
+ buf[p++] = pFBConfig->stereoMode;
+ buf[p++] = GLX_AUX_BUFFERS;
+ buf[p++] = pFBConfig->maxAuxBuffers;
+ buf[p++] = GLX_RED_SIZE;
+ buf[p++] = pFBConfig->redBits;
+ buf[p++] = GLX_GREEN_SIZE;
+ buf[p++] = pFBConfig->greenBits;
+ buf[p++] = GLX_BLUE_SIZE;
+ buf[p++] = pFBConfig->blueBits;
+ buf[p++] = GLX_ALPHA_SIZE;
+ buf[p++] = pFBConfig->alphaBits;
+ buf[p++] = GLX_DEPTH_SIZE;
+ buf[p++] = pFBConfig->depthBits;
+ buf[p++] = GLX_STENCIL_SIZE;
+ buf[p++] = pFBConfig->stencilBits;
+ buf[p++] = GLX_ACCUM_RED_SIZE;
+ buf[p++] = pFBConfig->accumRedBits;
+ buf[p++] = GLX_ACCUM_GREEN_SIZE;
+ buf[p++] = pFBConfig->accumGreenBits;
+ buf[p++] = GLX_ACCUM_BLUE_SIZE;
+ buf[p++] = pFBConfig->accumBlueBits;
+ buf[p++] = GLX_ACCUM_ALPHA_SIZE;
+ buf[p++] = pFBConfig->accumAlphaBits;
+ buf[p++] = GLX_RENDER_TYPE;
+ buf[p++] = pFBConfig->renderType;
+ buf[p++] = GLX_DRAWABLE_TYPE;
+ drawableTypeIndex = p;
+ buf[p++] = pFBConfig->drawableType;
+ buf[p++] = GLX_X_VISUAL_TYPE;
+ buf[p++] = pFBConfig->visualType;
+ buf[p++] = GLX_CONFIG_CAVEAT;
+ buf[p++] = pFBConfig->visualCaveat;
+ buf[p++] = GLX_TRANSPARENT_TYPE;
+ buf[p++] = pFBConfig->transparentType;
+ buf[p++] = GLX_TRANSPARENT_RED_VALUE;
+ buf[p++] = pFBConfig->transparentRed;
+ buf[p++] = GLX_TRANSPARENT_GREEN_VALUE;
+ buf[p++] = pFBConfig->transparentGreen;
+ buf[p++] = GLX_TRANSPARENT_BLUE_VALUE;
+ buf[p++] = pFBConfig->transparentBlue;
+ buf[p++] = GLX_TRANSPARENT_ALPHA_VALUE;
+ buf[p++] = pFBConfig->transparentAlpha;
+ buf[p++] = GLX_TRANSPARENT_INDEX_VALUE;
+ buf[p++] = pFBConfig->transparentIndex;
+ buf[p++] = GLX_MAX_PBUFFER_WIDTH;
+ buf[p++] = pFBConfig->maxPbufferWidth;
+ buf[p++] = GLX_MAX_PBUFFER_HEIGHT;
+ buf[p++] = pFBConfig->maxPbufferHeight;
+ buf[p++] = GLX_MAX_PBUFFER_PIXELS;
+ buf[p++] = pFBConfig->maxPbufferPixels;
+
+ /*
+ * find the visual of the back-end server and match a visual
+ * on the proxy.
+ * do only once - if a visual is not yet associated.
+ */
+ if (pFBConfig->associatedVisualId == (unsigned int)-1) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[screen];
+ __GLXFBConfig *be_pFBConfig = __glXFBConfigs[ i * (screenInfo.numScreens+1)+screen+1 ];
+ __GLXvisualConfig *pGlxVisual = NULL;
+ int v;
+ int found = 0;
+ for (v=0; v<dmxScreen->numGlxVisuals; v++) {
+ if (dmxScreen->glxVisuals[v].vid == be_pFBConfig->associatedVisualId) {
+ pGlxVisual = &dmxScreen->glxVisuals[v];
+ break;
+ }
+ }
+
+ if (pGlxVisual) {
+ for (v=0; v<pGlxScreen->numVisuals; v++) {
+ if (glxVisualsMatch(&pGlxScreen->pGlxVisual[v], pGlxVisual)) {
+ associatedVisualId = pGlxScreen->pGlxVisual[v].vid;
+ found = 1;
+ break;
+ }
+ }
+ }
+
+ if (!found) {
+ associatedVisualId = 0;
+ pFBConfig->drawableType &= ~(GLX_WINDOW_BIT);
+ buf[drawableTypeIndex] = pFBConfig->drawableType;
+ }
+#ifdef PANORAMIX
+ else if (!noPanoramiXExtension) {
+ /* convert the associated visualId to the panoramix one */
+ pFBConfig->associatedVisualId =
+ PanoramiXTranslateVisualID(screen, v);
+ }
+#endif
+ }
+ else {
+ associatedVisualId = pFBConfig->associatedVisualId;
+ }
+
+ buf[p++] = GLX_VISUAL_ID;
+ buf[p++] = associatedVisualId;
+
+ /* SGIS_multisample attributes */
+ buf[p++] = GLX_SAMPLES_SGIS;
+ buf[p++] = pFBConfig->multiSampleSize;
+ buf[p++] = GLX_SAMPLE_BUFFERS_SGIS;
+ buf[p++] = pFBConfig->nMultiSampleBuffers;
+
+ /* SGIX_pbuffer specific attributes */
+ buf[p++] = GLX_OPTIMAL_PBUFFER_WIDTH_SGIX;
+ buf[p++] = pFBConfig->optimalPbufferWidth;
+ buf[p++] = GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX;
+ buf[p++] = pFBConfig->optimalPbufferHeight;
+
+ buf[p++] = GLX_VISUAL_SELECT_GROUP_SGIX;
+ buf[p++] = pFBConfig->visualSelectGroup;
+
+ if (client->swapped) {
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+ __GLX_SWAP_INT_ARRAY((int *)buf, 2*numAttribs);
+ }
+ WriteToClient(client, 2*numAttribs * __GLX_SIZE_CARD32, (char *)buf);
+ }
+ return Success;
+}
+
+int __glXGetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXGetFBConfigsSGIXReq *req = (xGLXGetFBConfigsSGIXReq *)pc;
+ xGLXGetFBConfigsReq new_req;
+
+ new_req.reqType = req->reqType;
+ new_req.glxCode = req->glxCode;
+ new_req.length = req->length;
+ new_req.screen = req->screen;
+
+ return( __glXGetFBConfigs( cl, (GLbyte *)&new_req ) );
+}
+
+
+int __glXCreateWindow(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXCreateWindowReq *req = (xGLXCreateWindowReq *) pc;
+ int screen = req->screen;
+ GLXFBConfigID fbconfigId = req->fbconfig;
+ XID windowId = req->window;
+ XID glxwindowId = req->glxwindow;
+ DrawablePtr pDraw;
+ ScreenPtr pScreen;
+ __glXWindow *pGlxWindow;
+ __GLXFBConfig *pGlxFBConfig = NULL;
+ VisualPtr pVisual;
+ VisualID visId;
+ int i, rc;
+ pointer val;
+
+ /*
+ ** Check if windowId is valid
+ */
+ rc = dixLookupDrawable(&pDraw, windowId, client, M_DRAWABLE_WINDOW,
+ DixAddAccess);
+ if (rc != Success)
+ return rc;
+
+ /*
+ ** Check if screen of window matches screen of fbconfig.
+ */
+ pScreen = pDraw->pScreen;
+ if (screen != pScreen->myNum) {
+ return BadMatch;
+ }
+
+ /*
+ ** Find the FBConfigRec for this fbconfigid.
+ */
+ if (!(pGlxFBConfig = glxLookupFBConfig(fbconfigId))) {
+ client->errorValue = fbconfigId;
+ return __glXBadFBConfig;
+ }
+ visId = pGlxFBConfig->associatedVisualId;
+
+ /*
+ ** Check if the fbconfig supports rendering to windows
+ */
+ if( !(pGlxFBConfig->drawableType & GLX_WINDOW_BIT) ) {
+ return BadMatch;
+ }
+
+ if (visId != None) {
+ /*
+ ** Check if the visual ID is valid for this screen.
+ */
+ pVisual = pScreen->visuals;
+ for (i = 0; i < pScreen->numVisuals; i++, pVisual++) {
+ if (pVisual->vid == visId) {
+ break;
+ }
+ }
+ if (i == pScreen->numVisuals) {
+ client->errorValue = visId;
+ return BadValue;
+ }
+
+ /*
+ ** Check if color buffer depth of fbconfig matches depth
+ ** of window.
+ */
+ if (pVisual->nplanes != pDraw->depth) {
+ return BadMatch;
+ }
+ } else
+ /*
+ ** The window was created with no visual that corresponds
+ ** to fbconfig
+ */
+ return BadMatch;
+
+ /*
+ ** Check if there is already a fbconfig associated with this window
+ */
+ if (Success == dixLookupResourceByType(&val,
+ glxwindowId, __glXWindowRes,
+ NullClient, DixUnknownAccess)) {
+ client->errorValue = glxwindowId;
+ return BadAlloc;
+ }
+
+ pGlxWindow = (__glXWindow *) malloc(sizeof(__glXWindow));
+ if (!pGlxWindow) {
+ return BadAlloc;
+ }
+
+ /*
+ ** Register this GLX window as a resource
+ */
+ if (!(AddResource(glxwindowId, __glXWindowRes, pGlxWindow))) {
+ return BadAlloc;
+ }
+
+ pGlxWindow->pDraw = pDraw;
+ pGlxWindow->type = GLX_GLXWINDOW_TYPE;
+ pGlxWindow->idExists = True;
+ pGlxWindow->refcnt = 0;
+ pGlxWindow->pGlxFBConfig = pGlxFBConfig;
+ pGlxWindow->pScreen = pScreen;
+
+ return Success;
+}
+
+int __glXDestroyWindow(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXDestroyWindowReq *req = (xGLXDestroyWindowReq *) pc;
+ XID glxwindow = req->glxwindow;
+ pointer val;
+
+ /*
+ ** Check if it's a valid GLX window.
+ */
+ if (Success != dixLookupResourceByType(&val,
+ glxwindow, __glXWindowRes,
+ NullClient, DixUnknownAccess)) {
+ client->errorValue = glxwindow;
+ return __glXBadDrawable;
+ }
+ /*
+ ** The glx window destructor will check whether it's current before
+ ** freeing anything.
+ */
+ FreeResource(glxwindow, RT_NONE);
+
+ return Success;
+}
+
+int __glXQueryContext(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ __GLXcontext *ctx;
+ xGLXQueryContextReq *req;
+ xGLXQueryContextReply reply;
+ int nProps;
+ int *sendBuf, *pSendBuf;
+ int nReplyBytes;
+
+ req = (xGLXQueryContextReq *)pc;
+ dixLookupResourceByType((pointer*) &ctx, req->context, __glXContextRes,
+ NullClient, DixUnknownAccess);
+ if (!ctx) {
+ client->errorValue = req->context;
+ return __glXBadContext;
+ }
+
+ nProps = 3;
+
+ reply.length = nProps << 1;
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+ reply.n = nProps;
+
+ nReplyBytes = reply.length << 2;
+ sendBuf = (int *)malloc(nReplyBytes);
+ pSendBuf = sendBuf;
+ *pSendBuf++ = GLX_FBCONFIG_ID;
+ *pSendBuf++ = (int)(ctx->pFBConfig->id);
+ *pSendBuf++ = GLX_RENDER_TYPE;
+ *pSendBuf++ = (int)(ctx->pFBConfig->renderType);
+ *pSendBuf++ = GLX_SCREEN;
+ *pSendBuf++ = (int)(ctx->pScreen->myNum);
+
+ if (client->swapped) {
+ __glXSwapQueryContextReply(client, &reply, sendBuf);
+ } else {
+ WriteToClient(client, sz_xGLXQueryContextReply, (char *)&reply);
+ WriteToClient(client, nReplyBytes, (char *)sendBuf);
+ }
+ free((char *)sendBuf);
+
+ return Success;
+}
+
+int __glXQueryContextInfoEXT(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ __GLXcontext *ctx;
+ xGLXQueryContextInfoEXTReq *req;
+ xGLXQueryContextInfoEXTReply reply;
+ int nProps;
+ int *sendBuf, *pSendBuf;
+ int nReplyBytes;
+
+ req = (xGLXQueryContextInfoEXTReq *)pc;
+ dixLookupResourceByType((pointer*) &ctx,
+ req->context, __glXContextRes,
+ client, DixReadAccess);
+
+ if (!ctx) {
+ client->errorValue = req->context;
+ return __glXBadContext;
+ }
+
+ nProps = 4;
+
+ reply.length = nProps << 1;
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+ reply.n = nProps;
+
+ nReplyBytes = reply.length << 2;
+ sendBuf = (int *)malloc(nReplyBytes);
+ pSendBuf = sendBuf;
+ *pSendBuf++ = GLX_SHARE_CONTEXT_EXT;
+ *pSendBuf++ = (int)(ctx->share_id);
+ *pSendBuf++ = GLX_VISUAL_ID_EXT;
+ *pSendBuf++ = (int)(ctx->pVisual ? ctx->pVisual->vid : 0);
+ *pSendBuf++ = GLX_SCREEN_EXT;
+ *pSendBuf++ = (int)(ctx->pScreen->myNum);
+ *pSendBuf++ = GLX_FBCONFIG_ID;
+ *pSendBuf++ = (int)(ctx->pFBConfig ? ctx->pFBConfig->id : 0);
+
+ if (client->swapped) {
+ __glXSwapQueryContextInfoEXTReply(client, &reply, sendBuf);
+ } else {
+ WriteToClient(client, sz_xGLXQueryContextInfoEXTReply, (char *)&reply);
+ WriteToClient(client, nReplyBytes, (char *)sendBuf);
+ }
+ free((char *)sendBuf);
+
+ return Success;
+}
+
+int __glXCreatePbuffer(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXCreatePbufferReq *req = (xGLXCreatePbufferReq *)pc;
+ xGLXCreatePbufferReq *be_req;
+ int screen = req->screen;
+ GLXFBConfigID fbconfigId = req->fbconfig;
+ GLXPbuffer pbuffer = req->pbuffer;
+ __glXPbuffer *pGlxPbuffer;
+ int numAttribs = req->numAttribs;
+ int *attr;
+ ScreenPtr pScreen;
+ __GLXFBConfig *pGlxFBConfig;
+ __GLXFBConfig *be_pGlxFBConfig;
+ XID be_xid;
+ Display *dpy;
+ DMXScreenInfo *dmxScreen;
+ int s;
+ int from_screen, to_screen;
+
+ /*
+ ** Look up screen and FBConfig.
+ */
+ if (screen >= screenInfo.numScreens) {
+ /* The client library must send a valid screen number. */
+ client->errorValue = screen;
+ return BadValue;
+ }
+ pScreen = screenInfo.screens[screen];
+
+ /*
+ ** Find the FBConfigRec for this fbconfigid.
+ */
+ if (!(pGlxFBConfig = glxLookupFBConfig(fbconfigId))) {
+ client->errorValue = fbconfigId;
+ return __glXBadFBConfig;
+ }
+
+ /*
+ ** Create the GLX part of the Pbuffer.
+ */
+ pGlxPbuffer = (__glXPbuffer *) malloc(sizeof(__glXPbuffer));
+ if (!pGlxPbuffer) {
+ return BadAlloc;
+ }
+
+ pGlxPbuffer->be_xids = (XID *) malloc( sizeof(XID) * screenInfo.numScreens );
+ if (!pGlxPbuffer->be_xids) {
+ free(pGlxPbuffer);
+ return BadAlloc;
+ }
+
+ /*
+ * Allocate an XID on the back-end server(s) and send him the request
+ */
+ from_screen = to_screen = screen;
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ from_screen = 0;
+ to_screen = screenInfo.numScreens - 1;
+ }
+#endif
+
+ for (s=from_screen; s<=to_screen; s++) {
+ dpy = GetBackEndDisplay(cl,s);
+ be_xid = XAllocID(dpy);
+ dmxScreen = &dmxScreens[s];
+ be_pGlxFBConfig = glxLookupBackEndFBConfig( pGlxFBConfig->id, s );
+
+ attr = (int *)( req+1 );
+
+ LockDisplay(dpy);
+ GetReqExtra(GLXCreatePbuffer, 2 * numAttribs * __GLX_SIZE_CARD32, be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = X_GLXCreatePbuffer;
+ be_req->screen = be_pGlxFBConfig->screen;
+ be_req->fbconfig = be_pGlxFBConfig->id;
+ be_req->pbuffer = be_xid;
+ be_req->numAttribs = numAttribs;
+
+ /* Send attributes */
+ if ( attr != NULL ) {
+ CARD32 *pc = (CARD32 *)(be_req + 1);
+
+ while (numAttribs-- > 0) {
+ *pc++ = *attr++; /* token */
+ *pc++ = *attr++; /* value */
+ }
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ pGlxPbuffer->be_xids[s] = be_xid;
+ }
+
+
+ pGlxPbuffer->idExists = True;
+ pGlxPbuffer->refcnt = 0;
+ pGlxPbuffer->pFBConfig = pGlxFBConfig;
+ pGlxPbuffer->pScreen = pScreen;
+
+ /*
+ ** Register the resource.
+ */
+ if (!(AddResource(pbuffer, __glXPbufferRes, pGlxPbuffer))) {
+ return BadAlloc;
+ }
+
+ return Success;
+
+}
+
+int __glXDestroyPbuffer(__GLXclientState *cl, GLbyte *pc)
+{
+ ClientPtr client = cl->client;
+ xGLXDestroyPbufferReq *req = (xGLXDestroyPbufferReq *) pc;
+ xGLXDestroyPbufferReq *be_req;
+ GLXPbuffer pbuffer = req->pbuffer;
+ Display *dpy;
+ int screen;
+ DMXScreenInfo *dmxScreen;
+ __glXPbuffer *pGlxPbuffer;
+ int s;
+ int from_screen, to_screen;
+
+ /*
+ ** Check if it's a valid Pbuffer
+ */
+ dixLookupResourceByType((pointer*) &pGlxPbuffer, pbuffer,
+ __glXPbufferRes, NullClient, DixUnknownAccess);
+ if (!pGlxPbuffer) {
+ client->errorValue = pbuffer;
+ return __glXBadPbuffer;
+ }
+
+ screen = pGlxPbuffer->pScreen->myNum;
+
+ from_screen = to_screen = screen;
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ from_screen = 0;
+ to_screen = screenInfo.numScreens - 1;
+ }
+#endif
+
+ for (s=from_screen; s<=to_screen; s++) {
+ dpy = GetBackEndDisplay(cl,s);
+ dmxScreen = &dmxScreens[s];
+
+ /* send the destroy request to the back-end server */
+ LockDisplay(dpy);
+ GetReq(GLXDestroyPbuffer, be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = X_GLXDestroyPbuffer;
+ be_req->pbuffer = pGlxPbuffer->be_xids[s];
+ UnlockDisplay(dpy);
+ SyncHandle();
+ }
+
+ FreeResource(pbuffer, RT_NONE);
+
+ return Success;
+}
+
+int __glXGetDrawableAttributes(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXGetDrawableAttributesReq *req = (xGLXGetDrawableAttributesReq *)pc;
+ xGLXGetDrawableAttributesReq *be_req;
+ xGLXGetDrawableAttributesReply reply;
+ ClientPtr client = cl->client;
+ GLXDrawable drawId = req->drawable;
+ GLXDrawable be_drawable = 0;
+ DrawablePtr pDraw = NULL;
+ Display *dpy;
+ int screen, rc;
+ DMXScreenInfo *dmxScreen;
+ CARD32 *attribs = NULL;
+ int attribs_size = 0;
+#ifdef PANORAMIX
+ PanoramiXRes *pXinDraw = NULL;
+#endif
+
+ if (drawId != None) {
+ rc = dixLookupDrawable(&pDraw, drawId, client, 0, DixGetAttrAccess);
+ if (rc == Success && pDraw->type == DRAWABLE_WINDOW) {
+ WindowPtr pWin = (WindowPtr)pDraw;
+ be_drawable = 0;
+ screen = pWin->drawable.pScreen->myNum;
+ } else {
+ /*
+ ** Drawable is not a Window , GLXWindow or a GLXPixmap.
+ */
+ client->errorValue = drawId;
+ return __glXBadDrawable;
+ }
+
+ if (!pDraw) {
+ __GLXpixmap *pGlxPixmap;
+ dixLookupResourceByType((pointer*) &pGlxPixmap,
+ drawId, __glXPixmapRes,
+ NullClient, DixUnknownAccess);
+ if (pGlxPixmap) {
+ pDraw = pGlxPixmap->pDraw;
+ screen = pGlxPixmap->pScreen->myNum;
+ be_drawable = pGlxPixmap->be_xids[screen];
+ }
+ }
+
+ if (!pDraw) {
+ __glXWindow *pGlxWindow;
+ dixLookupResourceByType((pointer*) &pGlxWindow,
+ drawId, __glXWindowRes,
+ NullClient, DixUnknownAccess);
+ if (pGlxWindow) {
+ pDraw = pGlxWindow->pDraw;
+ screen = pGlxWindow->pScreen->myNum;
+ be_drawable = 0;
+ }
+ }
+
+ if (!pDraw) {
+ __glXPbuffer *pGlxPbuffer;
+ dixLookupResourceByType((pointer*) &pGlxPbuffer,
+ drawId, __glXPbufferRes,
+ NullClient, DixUnknownAccess);
+ if (pGlxPbuffer) {
+ pDraw = (DrawablePtr)pGlxPbuffer;
+ screen = pGlxPbuffer->pScreen->myNum;
+ be_drawable = pGlxPbuffer->be_xids[screen];
+ }
+ }
+ }
+
+ if (!pDraw) {
+ /*
+ ** Drawable is not a Window , GLXWindow or a GLXPixmap.
+ */
+ client->errorValue = drawId;
+ return __glXBadDrawable;
+ }
+
+ /* if the drawable is a window or GLXWindow -
+ * we need to find the base id on the back-end server
+ */
+ if (!be_drawable) {
+ WindowPtr pWin = (WindowPtr)pDraw;
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ if (Success != dixLookupResourceByClass((pointer*) &pXinDraw,
+ pDraw->id, XRC_DRAWABLE,
+ client, DixReadAccess)) {
+ client->errorValue = drawId;
+ return __glXBadDrawable;
+ }
+
+ dixLookupWindow(&pWin, pXinDraw->info[screen].id, client,
+ DixReadAccess);
+ }
+#endif
+
+ if (pWin) {
+ be_drawable = (unsigned int)(DMX_GET_WINDOW_PRIV(pWin))->window;
+ if (!be_drawable) {
+ /* it might be that the window did not created yet on the */
+ /* back-end server (lazy window creation option), force */
+ /* creation of the window */
+ dmxCreateAndRealizeWindow( pWin, TRUE );
+ be_drawable = (unsigned int)(DMX_GET_WINDOW_PRIV(pWin))->window;
+ }
+ }
+ else {
+ client->errorValue = drawId;
+ return __glXBadDrawable;
+ }
+ }
+
+
+ /* send the request to the back-end server */
+ dpy = GetBackEndDisplay(cl,screen);
+ dmxScreen = &dmxScreens[screen];
+
+ /* make sure drawable exists on back-end */
+ dmxSync( dmxScreen, 1 );
+
+ LockDisplay(dpy);
+ GetReq(GLXGetDrawableAttributes, be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = X_GLXGetDrawableAttributes;
+ be_req->drawable = be_drawable;
+ be_req->length = req->length;
+ if (!_XReply(dpy, (xReply *) &reply, 0, False)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return( BE_TO_CLIENT_ERROR(dmxLastErrorEvent.error_code) );
+ }
+
+ if (reply.numAttribs) {
+ attribs_size = 2 * reply.numAttribs * __GLX_SIZE_CARD32;
+ attribs = (CARD32 *) malloc(attribs_size);
+ if (attribs == NULL) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return BadAlloc;
+ }
+
+ _XRead(dpy, (char *) attribs, attribs_size);
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+
+ /* send the reply back to the client */
+ reply.sequenceNumber = client->sequence;
+ if (client->swapped) {
+ __glXSwapGetDrawableAttributesReply(client, &reply, (int *)attribs);
+ }
+ else {
+ WriteToClient(client, sz_xGLXGetDrawableAttributesReply, (char *)&reply);
+ WriteToClient(client, attribs_size, (char *)attribs);
+ }
+
+ free(attribs);
+
+ return Success;
+}
+
+int __glXChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXChangeDrawableAttributesReq *req = (xGLXChangeDrawableAttributesReq *)pc;
+ xGLXChangeDrawableAttributesReq *be_req;
+ ClientPtr client = cl->client;
+ GLXDrawable drawId = req->drawable;
+ GLXDrawable be_drawable = 0;
+ DrawablePtr pDraw = NULL;
+ Display *dpy;
+ int screen, rc;
+ DMXScreenInfo *dmxScreen;
+
+ if (drawId != None) {
+ rc = dixLookupDrawable(&pDraw, drawId, client, 0, DixSetAttrAccess);
+ if (rc == Success && pDraw->type == DRAWABLE_WINDOW) {
+ be_drawable = 0;
+ screen = pDraw->pScreen->myNum;
+ } else {
+ /*
+ ** Drawable is not a Window , GLXWindow or a GLXPixmap.
+ */
+ client->errorValue = drawId;
+ return __glXBadDrawable;
+ }
+
+ if (!pDraw) {
+ __GLXpixmap *pGlxPixmap;
+ dixLookupResourceByType((pointer*) &pGlxPixmap,
+ drawId, __glXPixmapRes,
+ NullClient, DixUnknownAccess);
+ if (pGlxPixmap) {
+ pDraw = pGlxPixmap->pDraw;
+ screen = pGlxPixmap->pScreen->myNum;
+ be_drawable = pGlxPixmap->be_xids[screen];
+ }
+ }
+
+ if (!pDraw) {
+ __glXWindow *pGlxWindow;
+ dixLookupResourceByType((pointer*) &pGlxWindow,
+ drawId, __glXWindowRes,
+ NullClient, DixUnknownAccess);
+ if (pGlxWindow) {
+ pDraw = pGlxWindow->pDraw;
+ screen = pGlxWindow->pScreen->myNum;
+ be_drawable = 0;
+ }
+ }
+
+ if (!pDraw) {
+ __glXPbuffer *pGlxPbuffer;
+ dixLookupResourceByType((pointer*) &pGlxPbuffer,
+ drawId, __glXPbufferRes,
+ NullClient, DixUnknownAccess);
+ if (pGlxPbuffer) {
+ pDraw = (DrawablePtr)pGlxPbuffer;
+ screen = pGlxPbuffer->pScreen->myNum;
+ be_drawable = pGlxPbuffer->be_xids[screen];
+ }
+ }
+ }
+
+ if (!pDraw) {
+ /*
+ ** Drawable is not a Window , GLXWindow or a GLXPixmap.
+ */
+ client->errorValue = drawId;
+ return __glXBadDrawable;
+ }
+
+ /* if the drawable is a window or GLXWindow -
+ * we need to find the base id on the back-end server
+ */
+ if (!be_drawable) {
+ WindowPtr pWin = (WindowPtr)pDraw;
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ PanoramiXRes *pXinDraw;
+ if (Success != dixLookupResourceByClass((pointer*) &pXinDraw,
+ pDraw->id, XRC_DRAWABLE,
+ client, DixReadAccess)) {
+ client->errorValue = drawId;
+ return __glXBadDrawable;
+ }
+
+ dixLookupWindow(&pWin, pXinDraw->info[screen].id, client,
+ DixReadAccess);
+ }
+#endif
+
+ if (pWin) {
+ be_drawable = (unsigned int)(DMX_GET_WINDOW_PRIV(pWin))->window;
+ if (!be_drawable) {
+ /* it might be that the window did not created yet on the */
+ /* back-end server (lazy window creation option), force */
+ /* creation of the window */
+ dmxCreateAndRealizeWindow( pWin, TRUE );
+ be_drawable = (unsigned int)(DMX_GET_WINDOW_PRIV(pWin))->window;
+ }
+ }
+ else {
+ client->errorValue = drawId;
+ return __glXBadDrawable;
+ }
+ }
+
+
+ /* send the request to the back-end server */
+ dpy = GetBackEndDisplay(cl,screen);
+ dmxScreen = &dmxScreens[screen];
+
+ /* make sure drawable exists on back-end */
+ dmxSync( dmxScreen, 1 );
+
+ LockDisplay(dpy);
+ GetReqExtra(GLXChangeDrawableAttributes,
+ 2 * req->numAttribs * __GLX_SIZE_CARD32, be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = X_GLXChangeDrawableAttributes;
+ be_req->drawable = be_drawable;
+ be_req->numAttribs = req->numAttribs;
+ be_req->length = req->length;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return Success;
+}
+
+int __glXSendLargeCommand(__GLXclientState *cl, GLXContextTag contextTag)
+{
+ ClientPtr client = cl->client;
+ xGLXRenderLargeReq *req;
+ GLint maxSize, amount;
+ GLint totalRequests, requestNumber;
+ GLint dataLen;
+ GLbyte *data;
+ __GLXcontext *glxc;
+ int s;
+ int from_screen, to_screen;
+
+ maxSize = cl->largeCmdMaxReqDataSize - (GLint)sizeof(xGLXRenderLargeReq);
+ dataLen = cl->largeCmdBytesTotal;
+ totalRequests = (dataLen / maxSize);
+ if (dataLen % maxSize) totalRequests++;
+
+ glxc = __glXLookupContextByTag(cl, contextTag);
+ if (!glxc) {
+ client->errorValue = contextTag;
+ return __glXBadContext;
+ }
+ from_screen = to_screen = glxc->pScreen->myNum;
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ from_screen = 0;
+ to_screen = screenInfo.numScreens - 1;
+ }
+#endif
+
+ /*
+ ** Send enough requests until the whole array is sent.
+ */
+ requestNumber = 1;
+ data = cl->largeCmdBuf;
+ while (dataLen > 0) {
+ amount = dataLen;
+ if (amount > maxSize) {
+ amount = maxSize;
+ }
+
+ for (s=from_screen; s<=to_screen; s++) {
+
+ Display *dpy = GetBackEndDisplay(cl,s);
+ DMXScreenInfo *dmxScreen = &dmxScreens[s];
+
+ LockDisplay(dpy);
+ GetReq(GLXRenderLarge,req);
+ req->reqType = dmxScreen->glxMajorOpcode;
+ req->glxCode = X_GLXRenderLarge;
+ req->contextTag = GetCurrentBackEndTag(cl,contextTag,s);
+ req->length += (amount + 3) >> 2;
+ req->requestNumber = requestNumber++;
+ req->requestTotal = totalRequests;
+ req->dataBytes = amount;
+ Data(dpy, ((const char*)data), amount);
+ dataLen -= amount;
+ data = ((GLbyte *) data) + amount;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ }
+ }
+
+ return Success;
+}
diff --git a/xorg-server/hw/dmx/glxProxy/glxsingle.c b/xorg-server/hw/dmx/glxProxy/glxsingle.c
index 834c7b8d9..33cc612a7 100644
--- a/xorg-server/hw/dmx/glxProxy/glxsingle.c
+++ b/xorg-server/hw/dmx/glxProxy/glxsingle.c
@@ -1,1016 +1,1016 @@
-/* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED */
-/*
- * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
- * Copyright (C) 1991-2000 Silicon Graphics, 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 including the dates of first publication and
- * either this permission notice or a reference to
- * http://oss.sgi.com/projects/FreeB/
- * 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
- * SILICON GRAPHICS, INC. 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 Silicon Graphics, Inc.
- * shall not be used in advertising or otherwise to promote the sale, use or
- * other dealings in this Software without prior written authorization from
- * Silicon Graphics, Inc.
- */
-
-#ifdef HAVE_DMX_CONFIG_H
-#include <dmx-config.h>
-#endif
-
-#include "dmx.h"
-#include "dmxwindow.h"
-#include "dmxpixmap.h"
-#include "dmxfont.h"
-#include "dmxcb.h"
-
-#include "glxserver.h"
-#include "glxext.h"
-#include "g_disptab.h"
-/* #include "g_disptab_EXT.h" */
-#include "unpack.h"
-#include "glxutil.h"
-
-#include "GL/glxproto.h"
-
-#ifdef PANORAMIX
-#include "panoramiXsrv.h"
-#endif
-
-/*
- * GetReqSingle - this is the equivalent of GetReq macro
- * from Xlibint.h but it does not set the reqType field (the opcode).
- * this is because the GL single opcodes has different naming convension
- * the other X opcodes (ie. X_GLsop_GetFloatv).
- */
-#if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
-#define GetReqSingle(name, req) \
- WORD64ALIGN\
- if ((dpy->bufptr + SIZEOF(x##name##Req)) > dpy->bufmax)\
- _XFlush(dpy);\
- req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\
- req->length = (SIZEOF(x##name##Req))>>2;\
- dpy->bufptr += SIZEOF(x##name##Req);\
- dpy->request++
-
-#else /* non-ANSI C uses empty comment instead of "##" for token concatenation */
-#define GetReqSingle(name, req) \
- WORD64ALIGN\
- if ((dpy->bufptr + SIZEOF(x/**/name/**/Req)) > dpy->bufmax)\
- _XFlush(dpy);\
- req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
- req->length = (SIZEOF(x/**/name/**/Req))>>2;\
- dpy->bufptr += SIZEOF(x/**/name/**/Req);\
- dpy->request++
-#endif
-
-#define X_GLXSingle 0 /* needed by GetReqExtra */
-
-extern Display *GetBackEndDisplay( __GLXclientState *cl, int s );
-extern int GetCurrentBackEndTag(__GLXclientState *cl, GLXContextTag tag, int s);
-
-static int swap_vec_element_size = 0;
-
-static void SendSwappedReply( ClientPtr client,
- xGLXSingleReply *reply,
- char *buf,
- int buf_size )
-{
- __GLX_DECLARE_SWAP_VARIABLES;
- __GLX_SWAP_SHORT(&reply->sequenceNumber);
- __GLX_SWAP_INT(&reply->length);
- __GLX_SWAP_INT(&reply->retval);
- __GLX_SWAP_INT(&reply->size);
-
- if ( (buf_size == 0) && (swap_vec_element_size > 0) ) {
- /*
- * the reply has single component - need to swap pad3
- */
- if (swap_vec_element_size == 2) {
- __GLX_SWAP_SHORT(&reply->pad3);
- }
- else if (swap_vec_element_size == 4) {
- __GLX_SWAP_INT(&reply->pad3);
- __GLX_SWAP_INT(&reply->pad4); /* some requests use also pad4
- * i.e GetConvolutionFilter
- */
- }
- else if (swap_vec_element_size == 8) {
- __GLX_SWAP_DOUBLE(&reply->pad3);
- }
- }
- else if ( (buf_size > 0) && (swap_vec_element_size > 0) ) {
- /*
- * the reply has vector of elements which needs to be swapped
- */
- int vsize = buf_size / swap_vec_element_size;
- char *p = buf;
- int i;
-
- for (i=0; i<vsize; i++) {
- if (swap_vec_element_size == 2) {
- __GLX_SWAP_SHORT(p);
- }
- else if (swap_vec_element_size == 4) {
- __GLX_SWAP_INT(p);
- }
- else if (swap_vec_element_size == 8) {
- __GLX_SWAP_DOUBLE(p);
- }
-
- p += swap_vec_element_size;
- }
-
- /*
- * swap pad words as well - for case that some single reply uses
- * them as well
- */
- __GLX_SWAP_INT(&reply->pad3);
- __GLX_SWAP_INT(&reply->pad4);
- __GLX_SWAP_INT(&reply->pad5);
- __GLX_SWAP_INT(&reply->pad6);
-
- }
-
- WriteToClient(client, sizeof(xGLXSingleReply),(char *)reply);
- if (buf_size > 0)
- WriteToClient(client, buf_size, (char *)buf);
-
-}
-
-int __glXForwardSingleReq( __GLXclientState *cl, GLbyte *pc )
-{
- xGLXSingleReq *req = (xGLXSingleReq *)pc;
- xGLXSingleReq *be_req;
- __GLXcontext *glxc;
- int from_screen = 0;
- int to_screen = 0;
- int buf_size;
- int s;
-
- glxc = __glXLookupContextByTag(cl, req->contextTag);
- if (!glxc) {
- return 0;
- }
- from_screen = to_screen = glxc->pScreen->myNum;
-
-#ifdef PANORAMIX
- if (!noPanoramiXExtension) {
- from_screen = 0;
- to_screen = screenInfo.numScreens - 1;
- }
-#endif
-
- pc += sz_xGLXSingleReq;
- buf_size = (req->length << 2) - sz_xGLXSingleReq;
-
- /*
- * just forward the request to back-end server(s)
- */
- for (s=from_screen; s<=to_screen; s++) {
- DMXScreenInfo *dmxScreen = &dmxScreens[s];
- Display *dpy = GetBackEndDisplay(cl,s);
-
- LockDisplay(dpy);
- GetReqSingle(GLXSingle,be_req);
- be_req->reqType = dmxScreen->glxMajorOpcode;
- be_req->glxCode = req->glxCode;
- be_req->length = req->length;
- be_req->contextTag = GetCurrentBackEndTag(cl,req->contextTag,s);
- if (buf_size > 0)
- _XSend(dpy, (const char *)pc, buf_size);
- UnlockDisplay(dpy);
- SyncHandle();
-
- if (req->glxCode == X_GLsop_Flush) {
- XFlush(dpy);
- }
-
- }
-
- return Success;
-}
-
-int __glXForwardPipe0WithReply( __GLXclientState *cl, GLbyte *pc )
-{
- ClientPtr client = cl->client;
- xGLXSingleReq *req = (xGLXSingleReq *)pc;
- xGLXSingleReq *be_req;
- xGLXSingleReply reply;
- xGLXSingleReply be_reply;
- __GLXcontext *glxc;
- int buf_size;
- char *be_buf = NULL;
- int be_buf_size;
- DMXScreenInfo *dmxScreen;
- Display *dpy;
-
- glxc = __glXLookupContextByTag(cl, req->contextTag);
- if (!glxc) {
- return __glXBadContext;
- }
-
- pc += sz_xGLXSingleReq;
- buf_size = (req->length << 2) - sz_xGLXSingleReq;
-
- dmxScreen = &dmxScreens[glxc->pScreen->myNum];
- dpy = GetBackEndDisplay(cl, glxc->pScreen->myNum);
-
- /*
- * send the request to the first back-end server
- */
- LockDisplay(dpy);
- GetReqSingle(GLXSingle,be_req);
- be_req->reqType = dmxScreen->glxMajorOpcode;
- be_req->glxCode = req->glxCode;
- be_req->length = req->length;
- be_req->contextTag = GetCurrentBackEndTag(cl,req->contextTag,glxc->pScreen->myNum);
- if (buf_size > 0)
- _XSend(dpy, (const char *)pc, buf_size);
-
- /*
- * get the reply from the back-end server
- */
- _XReply(dpy, (xReply*) &be_reply, 0, False);
- be_buf_size = be_reply.length << 2;
- if (be_buf_size > 0) {
- be_buf = (char *)malloc( be_buf_size );
- if (be_buf) {
- _XRead(dpy, be_buf, be_buf_size);
- }
- else {
- /* Throw data on the floor */
- _XEatData(dpy, be_buf_size);
- return BadAlloc;
- }
- }
-
- UnlockDisplay(dpy);
- SyncHandle();
-
- /*
- * send the reply to the client
- */
- reply.type = X_Reply;
- reply.sequenceNumber = client->sequence;
- reply.length = be_reply.length;
- reply.retval = be_reply.retval;
- reply.size = be_reply.size;
- reply.pad3 = be_reply.pad3;
- reply.pad4 = be_reply.pad4;
-
- if (client->swapped) {
- SendSwappedReply( client, &reply, be_buf, be_buf_size );
- }
- else {
- WriteToClient(client, sizeof(xGLXSingleReply),(char *)&reply);
- if (be_buf_size > 0)
- WriteToClient(client, be_buf_size, (char *)be_buf);
- }
-
- if (be_buf_size > 0) free(be_buf);
-
- return Success;
-}
-
-int __glXForwardAllWithReply( __GLXclientState *cl, GLbyte *pc )
-{
- ClientPtr client = cl->client;
- xGLXSingleReq *req = (xGLXSingleReq *)pc;
- xGLXSingleReq *be_req;
- xGLXSingleReply reply;
- xGLXSingleReply be_reply;
- __GLXcontext *glxc;
- int buf_size;
- char *be_buf = NULL;
- int be_buf_size = 0;
- int from_screen = 0;
- int to_screen = 0;
- int s;
-
- DMXScreenInfo *dmxScreen;
- Display *dpy;
-
- glxc = __glXLookupContextByTag(cl, req->contextTag);
- if (!glxc) {
- return 0;
- }
- from_screen = to_screen = glxc->pScreen->myNum;
-
-#ifdef PANORAMIX
- if (!noPanoramiXExtension) {
- from_screen = 0;
- to_screen = screenInfo.numScreens - 1;
- }
-#endif
-
- pc += sz_xGLXSingleReq;
- buf_size = (req->length << 2) - sz_xGLXSingleReq;
-
- /*
- * send the request to the first back-end server(s)
- */
- for (s=to_screen; s>=from_screen; s--) {
- dmxScreen = &dmxScreens[s];
- dpy = GetBackEndDisplay(cl,s);
-
- LockDisplay(dpy);
- GetReqSingle(GLXSingle,be_req);
- be_req->reqType = dmxScreen->glxMajorOpcode;
- be_req->glxCode = req->glxCode;
- be_req->length = req->length;
- be_req->contextTag = GetCurrentBackEndTag(cl,req->contextTag,s);
- if (buf_size > 0)
- _XSend(dpy, (const char *)pc, buf_size);
-
- /*
- * get the reply from the back-end server
- */
- _XReply(dpy, (xReply*) &be_reply, 0, False);
- be_buf_size = be_reply.length << 2;
- if (be_buf_size > 0) {
- be_buf = (char *)malloc( be_buf_size );
- if (be_buf) {
- _XRead(dpy, be_buf, be_buf_size);
- }
- else {
- /* Throw data on the floor */
- _XEatData(dpy, be_buf_size);
- return BadAlloc;
- }
- }
-
- UnlockDisplay(dpy);
- SyncHandle();
-
- if (s > from_screen && be_buf_size > 0) {
- free(be_buf);
- }
- }
-
- /*
- * send the reply to the client
- */
- reply.type = X_Reply;
- reply.sequenceNumber = client->sequence;
- reply.length = be_reply.length;
- reply.retval = be_reply.retval;
- reply.size = be_reply.size;
- reply.pad3 = be_reply.pad3;
- reply.pad4 = be_reply.pad4;
-
- if (client->swapped) {
- SendSwappedReply( client, &reply, be_buf, be_buf_size );
- }
- else {
- WriteToClient(client, sizeof(xGLXSingleReply),(char *)&reply);
- if (be_buf_size > 0)
- WriteToClient(client, be_buf_size, (char *)be_buf);
- }
-
- if (be_buf_size > 0) free(be_buf);
-
- return Success;
-}
-
-int __glXForwardSingleReqSwap( __GLXclientState *cl, GLbyte *pc )
-{
- xGLXSingleReq *req = (xGLXSingleReq *)pc;
- __GLX_DECLARE_SWAP_VARIABLES;
- __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
-
- __GLX_SWAP_SHORT(&req->length);
- __GLX_SWAP_INT(&req->contextTag);
-
- swap_vec_element_size = 0;
-
- /*
- * swap extra data in request - assuming all data
- * (if available) are arrays of 4 bytes components !
- */
- if (req->length > sz_xGLXSingleReq/4) {
- int *data = (int *)(req+1);
- int count = req->length - sz_xGLXSingleReq/4;
- __GLX_SWAP_INT_ARRAY(data, count );
- }
-
- return( __glXForwardSingleReq( cl, pc ) );
-}
-
-int __glXForwardPipe0WithReplySwap( __GLXclientState *cl, GLbyte *pc )
-{
- xGLXSingleReq *req = (xGLXSingleReq *)pc;
- __GLX_DECLARE_SWAP_VARIABLES;
- __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
-
- __GLX_SWAP_SHORT(&req->length);
- __GLX_SWAP_INT(&req->contextTag);
-
- swap_vec_element_size = 0;
-
- /*
- * swap extra data in request - assuming all data
- * (if available) are arrays of 4 bytes components !
- */
- if (req->length > sz_xGLXSingleReq/4) {
- int *data = (int *)(req+1);
- int count = req->length - sz_xGLXSingleReq/4;
- __GLX_SWAP_INT_ARRAY(data, count );
- }
-
- return( __glXForwardPipe0WithReply( cl, pc ) );
-}
-
-int __glXForwardPipe0WithReplySwapsv( __GLXclientState *cl, GLbyte *pc )
-{
- xGLXSingleReq *req = (xGLXSingleReq *)pc;
- __GLX_DECLARE_SWAP_VARIABLES;
- __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
-
- __GLX_SWAP_SHORT(&req->length);
- __GLX_SWAP_INT(&req->contextTag);
-
- swap_vec_element_size = 2;
-
- /*
- * swap extra data in request - assuming all data
- * (if available) are arrays of 4 bytes components !
- */
- if (req->length > sz_xGLXSingleReq/4) {
- int *data = (int *)(req+1);
- int count = req->length - sz_xGLXSingleReq/4;
- __GLX_SWAP_INT_ARRAY(data, count );
- }
-
-
- return( __glXForwardPipe0WithReply( cl, pc ) );
-}
-
-int __glXForwardPipe0WithReplySwapiv( __GLXclientState *cl, GLbyte *pc )
-{
- xGLXSingleReq *req = (xGLXSingleReq *)pc;
- __GLX_DECLARE_SWAP_VARIABLES;
- __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
-
- __GLX_SWAP_SHORT(&req->length);
- __GLX_SWAP_INT(&req->contextTag);
-
- swap_vec_element_size = 4;
-
- /*
- * swap extra data in request - assuming all data
- * (if available) are arrays of 4 bytes components !
- */
- if (req->length > sz_xGLXSingleReq/4) {
- int *data = (int *)(req+1);
- int count = req->length - sz_xGLXSingleReq/4;
- __GLX_SWAP_INT_ARRAY(data, count );
- }
-
-
- return( __glXForwardPipe0WithReply( cl, pc ) );
-}
-
-int __glXForwardPipe0WithReplySwapdv( __GLXclientState *cl, GLbyte *pc )
-{
- xGLXSingleReq *req = (xGLXSingleReq *)pc;
- __GLX_DECLARE_SWAP_VARIABLES;
- __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
-
- __GLX_SWAP_SHORT(&req->length);
- __GLX_SWAP_INT(&req->contextTag);
-
- swap_vec_element_size = 8;
-
- /*
- * swap extra data in request - assuming all data
- * (if available) are arrays of 4 bytes components !
- */
- if (req->length > sz_xGLXSingleReq/4) {
- int *data = (int *)(req+1);
- int count = req->length - sz_xGLXSingleReq/4;
- __GLX_SWAP_INT_ARRAY(data, count );
- }
-
-
- return( __glXForwardPipe0WithReply( cl, pc ) );
-}
-
-int __glXForwardAllWithReplySwap( __GLXclientState *cl, GLbyte *pc )
-{
- xGLXSingleReq *req = (xGLXSingleReq *)pc;
- __GLX_DECLARE_SWAP_VARIABLES;
- __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
-
- __GLX_SWAP_SHORT(&req->length);
- __GLX_SWAP_INT(&req->contextTag);
-
- swap_vec_element_size = 0;
-
- /*
- * swap extra data in request - assuming all data
- * (if available) are arrays of 4 bytes components !
- */
- if (req->length > sz_xGLXSingleReq/4) {
- int *data = (int *)(req+1);
- int count = req->length - sz_xGLXSingleReq/4;
- __GLX_SWAP_INT_ARRAY(data, count );
- }
-
-
- return( __glXForwardAllWithReply( cl, pc ) );
-}
-
-int __glXForwardAllWithReplySwapsv( __GLXclientState *cl, GLbyte *pc )
-{
- xGLXSingleReq *req = (xGLXSingleReq *)pc;
- __GLX_DECLARE_SWAP_VARIABLES;
- __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
-
- __GLX_SWAP_SHORT(&req->length);
- __GLX_SWAP_INT(&req->contextTag);
-
- swap_vec_element_size = 2;
-
- /*
- * swap extra data in request - assuming all data
- * (if available) are arrays of 4 bytes components !
- */
- if (req->length > sz_xGLXSingleReq/4) {
- int *data = (int *)(req+1);
- int count = req->length - sz_xGLXSingleReq/4;
- __GLX_SWAP_INT_ARRAY(data, count );
- }
-
-
- return( __glXForwardAllWithReply( cl, pc ) );
-}
-
-int __glXForwardAllWithReplySwapiv( __GLXclientState *cl, GLbyte *pc )
-{
- xGLXSingleReq *req = (xGLXSingleReq *)pc;
- __GLX_DECLARE_SWAP_VARIABLES;
- __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
-
- __GLX_SWAP_SHORT(&req->length);
- __GLX_SWAP_INT(&req->contextTag);
-
- swap_vec_element_size = 4;
-
- /*
- * swap extra data in request - assuming all data
- * (if available) are arrays of 4 bytes components !
- */
- if (req->length > sz_xGLXSingleReq/4) {
- int *data = (int *)(req+1);
- int count = req->length - sz_xGLXSingleReq/4;
- __GLX_SWAP_INT_ARRAY(data, count );
- }
-
-
- return( __glXForwardAllWithReply( cl, pc ) );
-}
-
-int __glXForwardAllWithReplySwapdv( __GLXclientState *cl, GLbyte *pc )
-{
- xGLXSingleReq *req = (xGLXSingleReq *)pc;
- __GLX_DECLARE_SWAP_VARIABLES;
- __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
-
- __GLX_SWAP_SHORT(&req->length);
- __GLX_SWAP_INT(&req->contextTag);
-
- swap_vec_element_size = 8;
-
- /*
- * swap extra data in request - assuming all data
- * (if available) are arrays of 4 bytes components !
- */
- if (req->length > sz_xGLXSingleReq/4) {
- int *data = (int *)(req+1);
- int count = req->length - sz_xGLXSingleReq/4;
- __GLX_SWAP_INT_ARRAY(data, count );
- }
-
-
- return( __glXForwardAllWithReply( cl, pc ) );
-}
-
-static GLint __glReadPixels_size(GLenum format, GLenum type, GLint w, GLint h,
- int *elementbits_return, int *rowbytes_return )
-{
- GLint elements, esize;
- GLint rowsize, padding;
-
- if (w < 0 || h < 0) {
- return -1;
- }
- switch (format) {
- case GL_COLOR_INDEX:
- case GL_STENCIL_INDEX:
- case GL_DEPTH_COMPONENT:
- elements = 1;
- break;
- case GL_RED:
- case GL_GREEN:
- case GL_BLUE:
- case GL_ALPHA:
- case GL_LUMINANCE:
- elements = 1;
- break;
- case GL_LUMINANCE_ALPHA:
- elements = 2;
- break;
- case GL_RGB:
- case GL_BGR:
- elements = 3;
- break;
- case GL_RGBA:
- case GL_BGRA:
- case GL_ABGR_EXT:
- elements = 4;
- break;
- default:
- return -1;
- }
- /*
- ** According to the GLX protocol, each row must be padded to a multiple of
- ** 4 bytes. 4 bytes also happens to be the default alignment in the pixel
- ** store modes of the GL.
- */
- switch (type) {
- case GL_BITMAP:
- if (format == GL_COLOR_INDEX || format == GL_STENCIL_INDEX) {
- rowsize = ((w * elements)+7)/8;
- padding = rowsize % 4;
- if (padding) {
- rowsize += 4 - padding;
- }
- if (elementbits_return) *elementbits_return = elements;
- if (rowbytes_return) *rowbytes_return = rowsize;
- return rowsize * h;
- } else {
- return -1;
- }
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- esize = 1;
- break;
- case GL_UNSIGNED_BYTE_3_3_2:
- case GL_UNSIGNED_BYTE_2_3_3_REV:
- esize = 1;
- elements = 1;
- break;
- case GL_SHORT:
- case GL_UNSIGNED_SHORT:
- esize = 2;
- break;
- case GL_UNSIGNED_SHORT_5_6_5:
- case GL_UNSIGNED_SHORT_5_6_5_REV:
- case GL_UNSIGNED_SHORT_4_4_4_4:
- case GL_UNSIGNED_SHORT_4_4_4_4_REV:
- case GL_UNSIGNED_SHORT_5_5_5_1:
- case GL_UNSIGNED_SHORT_1_5_5_5_REV:
- esize = 2;
- elements = 1;
- break;
- case GL_INT:
- case GL_UNSIGNED_INT:
- case GL_FLOAT:
- esize = 4;
- break;
- case GL_UNSIGNED_INT_8_8_8_8:
- case GL_UNSIGNED_INT_8_8_8_8_REV:
- case GL_UNSIGNED_INT_10_10_10_2:
- case GL_UNSIGNED_INT_2_10_10_10_REV:
- esize = 4;
- elements = 1;
- break;
- default:
- return -1;
- }
- rowsize = w * elements * esize;
- padding = rowsize % 4;
- if (padding) {
- rowsize += 4 - padding;
- }
-
- if (elementbits_return) *elementbits_return = esize*elements*8;
- if (rowbytes_return) *rowbytes_return = rowsize;
-
- return rowsize * h;
-}
-
-static int intersectRect( int x1, int x2, int y1, int y2,
- int X1, int X2, int Y1, int Y2,
- int *ix1, int *ix2, int *iy1, int *iy2 )
-{
- int right = (x2 < X2 ? x2 : X2);
- int bottom = (y2 < Y2 ? y2 : Y2);
- int left = (x1 > X1 ? x1 : X1);
- int top = (y1 > Y1 ? y1 : Y1);
- int width = right - left + 1;
- int height = bottom - top + 1;
-
- if ( (width <= 0) || (height <= 0) ) {
- *ix1 = *ix2 = *iy1 = *iy2 = 0;
- return 0;
- }
- else {
- *ix1 = left;
- *ix2 = right;
- *iy1 = top;
- *iy2 = bottom;
- return width * height;
- }
-
-}
-
-int __glXDisp_ReadPixels(__GLXclientState *cl, GLbyte *pc)
-{
- xGLXSingleReq *req = (xGLXSingleReq *)pc;
- xGLXSingleReq *be_req;
- xGLXReadPixelsReply reply;
- xGLXReadPixelsReply be_reply;
- GLbyte *be_pc;
- GLint x,y;
- GLsizei width, height;
- GLenum format, type;
- GLboolean swapBytes, lsbFirst;
- ClientPtr client = cl->client;
- DrawablePtr pDraw;
- __GLXcontext *glxc;
- int from_screen = 0;
- int to_screen = 0;
- char *buf;
- int buf_size;
- int s;
- int win_x1, win_x2;
- int win_y1, win_y2;
- int ebits, rowsize;
- __GLX_DECLARE_SWAP_VARIABLES;
-
- if (client->swapped) {
- __GLX_SWAP_INT(&req->contextTag);
- }
-
- glxc = __glXLookupContextByTag(cl, req->contextTag);
- if (!glxc) {
- return 0;
- }
- from_screen = to_screen = glxc->pScreen->myNum;
-
-#ifdef PANORAMIX
- if (!noPanoramiXExtension) {
- from_screen = 0;
- to_screen = screenInfo.numScreens - 1;
- }
-#endif
-
- pc += sz_xGLXSingleReq;
- x = *(GLint *)(pc + 0);
- y = *(GLint *)(pc + 4);
- width = *(GLsizei *)(pc + 8);
- height = *(GLsizei *)(pc + 12);
- format = *(GLenum *)(pc + 16);
- type = *(GLenum *)(pc + 20);
- swapBytes = *(GLboolean *)(pc + 24);
- lsbFirst = *(GLboolean *)(pc + 25);
-
- if (client->swapped) {
- __GLX_SWAP_INT(&x);
- __GLX_SWAP_INT(&y);
- __GLX_SWAP_INT(&width);
- __GLX_SWAP_INT(&height);
- __GLX_SWAP_INT(&format);
- __GLX_SWAP_INT(&type);
- swapBytes = !swapBytes;
- }
-
- buf_size = __glReadPixels_size(format,type,width,height, &ebits, &rowsize);
- if (buf_size > 0) {
- buf = (char *) malloc( buf_size );
- if ( !buf ) {
- return BadAlloc;
- }
- }
- else {
- buf_size = 0;
- buf = NULL;
- }
-
- if (buf_size > 0) {
- /*
- * Get the current drawable this context is bound to
- */
- pDraw = __glXLookupDrawableByTag( cl, req->contextTag );
- win_x1 = pDraw->x + x;
- win_x2 = win_x1 + width - 1;
- win_y1 = (dmxGlobalHeight - pDraw->y - pDraw->height) + y;
- win_y2 = win_y1 + height - 1;
- if (pDraw->type != DRAWABLE_WINDOW) {
- from_screen = to_screen = 0;
- }
-
- for (s=from_screen; s<=to_screen; s++) {
- DMXScreenInfo *dmxScreen = &dmxScreens[s];
- Display *dpy = GetBackEndDisplay(cl,s);
- int scr_x1 = dmxScreen->rootXOrigin;
- int scr_x2 = dmxScreen->rootXOrigin + dmxScreen->scrnWidth - 1;
- int scr_y1 = dmxScreen->rootYOrigin;
- int scr_y2 = dmxScreen->rootYOrigin + dmxScreen->scrnHeight - 1;
- int wx1, wx2, wy1, wy2;
- int sx, sy, sw, sh;
- int npixels;
-
- /*
- * find the window portion that is on the current screen
- */
- if (pDraw->type == DRAWABLE_WINDOW) {
- npixels = intersectRect( scr_x1, scr_x2, scr_y1, scr_y2,
- win_x1, win_x2, win_y1, win_y2,
- &wx1, &wx2, &wy1, &wy2 );
- }
- else {
- wx1 = win_x1;
- wx2 = win_x2;
- wy1 = win_y1;
- wy2 = win_y2;
- npixels = (wx2-wx1+1) * (wy2-wy1+1);
- }
-
- if (npixels > 0) {
-
- /* send the request to the back-end server */
- LockDisplay(dpy);
- GetReqExtra(GLXSingle,__GLX_PAD(26),be_req);
- be_req->reqType = dmxScreen->glxMajorOpcode;
- be_req->glxCode = X_GLsop_ReadPixels;
- be_req->contextTag = GetCurrentBackEndTag(cl,req->contextTag,s);
- be_pc = ((GLbyte *)(be_req) + sz_xGLXSingleReq);
-
- sx = wx1 - pDraw->x;
- sy = wy1 - (dmxGlobalHeight - pDraw->y - pDraw->height);
- sw = (wx2-wx1+1);
- sh = (wy2-wy1+1);
-
- *(GLint *)(be_pc + 0) = sx; /* x */
- *(GLint *)(be_pc + 4) = sy; /* y */
- *(GLsizei *)(be_pc + 8) = sw; /* width */
- *(GLsizei *)(be_pc + 12) = sh; /* height */
- *(GLenum *)(be_pc + 16) = format;
- *(GLenum *)(be_pc + 20) = type;
- *(GLboolean *)(be_pc + 24) = swapBytes;
- *(GLboolean *)(be_pc + 25) = lsbFirst;
-
- _XReply(dpy, (xReply*) &be_reply, 0, False);
-
- if (be_reply.length > 0) {
- char *be_buf;
- int be_buf_size = be_reply.length << 2;
-
- be_buf = (char *) malloc( be_buf_size );
- if (be_buf) {
- _XRead(dpy, be_buf, be_buf_size);
-
- /* copy pixels data to the right location of the */
- /* reply buffer */
- if ( type != GL_BITMAP ) {
- int pbytes = ebits / 8;
- char *dst = buf + (sy-y)*rowsize + (sx-x)*pbytes;
- char *src = be_buf;
- int pad = (pbytes * sw) % 4;
- int r;
-
- for (r=0; r<sh; r++) {
- memcpy( dst, src, pbytes*sw );
- dst += rowsize;
- src += (pbytes*sw + (pad ? 4-pad : 0) );
- }
- }
- else {
- /* this is a GL_BITMAP pixel type, should copy bits */
- int r;
- int src_rowsize = bits_to_bytes(sw * ebits);
- int src_pad = src_rowsize % 4;
- if ( src_pad ) {
- src_rowsize += (4 - src_pad);
- }
-
- for (r=0; r<sh; r++) {
- unsigned char dst_mask = 0x80 >> (sx % 8);
- unsigned char src_mask = 0x80;
- char *dst = buf + (sy-y+r)*rowsize + (sx-x)/8;
- char *src = be_buf + r*src_rowsize;
- int b;
-
- for (b=0; b<sw*ebits; b++) {
- if ( *src & src_mask ) {
- *dst |= dst_mask;
- }
- else {
- *dst &= ~dst_mask;
- }
-
- if (dst_mask > 1) dst_mask >>= 1;
- else {
- dst_mask = 0x80;
- dst++;
- }
-
- if (src_mask > 1) src_mask >>= 1;
- else {
- src_mask = 0x80;
- src++;
- }
- }
- }
-
- }
-
- free( be_buf );
- }
- else {
- /* Throw data on the floor */
- _XEatData(dpy, be_buf_size);
- free( buf );
- return BadAlloc;
- }
- }
-
- UnlockDisplay(dpy);
- SyncHandle();
-
- } /* of npixels > 0 */
-
- } /* of for loop */
-
- } /* of if buf_size > 0 */
-
- reply.type = X_Reply;
- reply.sequenceNumber = client->sequence;
- reply.length = buf_size >> 2;
-
- if (client->swapped) {
- __GLX_SWAP_SHORT(&reply.sequenceNumber);
- __GLX_SWAP_INT(&reply.length);
- }
-
- WriteToClient(client, sizeof(xGLXReadPixelsReply),(char *)&reply);
- if (buf_size > 0) {
- WriteToClient(client, buf_size, (char *)buf);
- free( buf );
- }
-
- return Success;
-}
-
-int __glXDispSwap_GetTexImage(__GLXclientState *cl, GLbyte *pc)
-{
- __GLX_DECLARE_SWAP_VARIABLES;
- GLbyte *lpc = pc;
-
- lpc += sz_xGLXSingleReq;
- __GLX_SWAP_INT(lpc+0);
- __GLX_SWAP_INT(lpc+4);
- __GLX_SWAP_INT(lpc+8);
- __GLX_SWAP_INT(lpc+12);
-
- /* reverse swapBytes */
- *(GLboolean *)(lpc + 16) = ! *(GLboolean *)(lpc + 16);
-
- return( __glXForwardPipe0WithReplySwap( cl, pc ) );
-}
-
-int __glXDispSwap_GetColorTable(__GLXclientState *cl, GLbyte *pc)
-{
- __GLX_DECLARE_SWAP_VARIABLES;
- GLbyte *lpc = pc;
-
- lpc += sz_xGLXSingleReq;
- __GLX_SWAP_INT(lpc+0);
- __GLX_SWAP_INT(lpc+4);
- __GLX_SWAP_INT(lpc+8);
-
- /* reverse swapBytes */
- *(GLboolean *)(lpc + 12) = ! *(GLboolean *)(lpc + 12);
-
- return( __glXForwardPipe0WithReplySwap( cl, pc ) );
-}
-
-
+/* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED */
+/*
+ * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
+ * Copyright (C) 1991-2000 Silicon Graphics, 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 including the dates of first publication and
+ * either this permission notice or a reference to
+ * http://oss.sgi.com/projects/FreeB/
+ * 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
+ * SILICON GRAPHICS, INC. 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 Silicon Graphics, Inc.
+ * shall not be used in advertising or otherwise to promote the sale, use or
+ * other dealings in this Software without prior written authorization from
+ * Silicon Graphics, Inc.
+ */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmx.h"
+#include "dmxwindow.h"
+#include "dmxpixmap.h"
+#include "dmxfont.h"
+#include "dmxcb.h"
+
+#include "glxserver.h"
+#include "glxext.h"
+#include "g_disptab.h"
+/* #include "g_disptab_EXT.h" */
+#include "unpack.h"
+#include "glxutil.h"
+
+#include "GL/glxproto.h"
+
+#ifdef PANORAMIX
+#include "panoramiXsrv.h"
+#endif
+
+/*
+ * GetReqSingle - this is the equivalent of GetReq macro
+ * from Xlibint.h but it does not set the reqType field (the opcode).
+ * this is because the GL single opcodes has different naming convension
+ * the other X opcodes (ie. X_GLsop_GetFloatv).
+ */
+#if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
+#define GetReqSingle(name, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(x##name##Req)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\
+ req->length = (SIZEOF(x##name##Req))>>2;\
+ dpy->bufptr += SIZEOF(x##name##Req);\
+ dpy->request++
+
+#else /* non-ANSI C uses empty comment instead of "##" for token concatenation */
+#define GetReqSingle(name, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(x/**/name/**/Req)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
+ req->length = (SIZEOF(x/**/name/**/Req))>>2;\
+ dpy->bufptr += SIZEOF(x/**/name/**/Req);\
+ dpy->request++
+#endif
+
+#define X_GLXSingle 0 /* needed by GetReqExtra */
+
+extern Display *GetBackEndDisplay( __GLXclientState *cl, int s );
+extern int GetCurrentBackEndTag(__GLXclientState *cl, GLXContextTag tag, int s);
+
+static int swap_vec_element_size = 0;
+
+static void SendSwappedReply( ClientPtr client,
+ xGLXSingleReply *reply,
+ char *buf,
+ int buf_size )
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_SWAP_SHORT(&reply->sequenceNumber);
+ __GLX_SWAP_INT(&reply->length);
+ __GLX_SWAP_INT(&reply->retval);
+ __GLX_SWAP_INT(&reply->size);
+
+ if ( (buf_size == 0) && (swap_vec_element_size > 0) ) {
+ /*
+ * the reply has single component - need to swap pad3
+ */
+ if (swap_vec_element_size == 2) {
+ __GLX_SWAP_SHORT(&reply->pad3);
+ }
+ else if (swap_vec_element_size == 4) {
+ __GLX_SWAP_INT(&reply->pad3);
+ __GLX_SWAP_INT(&reply->pad4); /* some requests use also pad4
+ * i.e GetConvolutionFilter
+ */
+ }
+ else if (swap_vec_element_size == 8) {
+ __GLX_SWAP_DOUBLE(&reply->pad3);
+ }
+ }
+ else if ( (buf_size > 0) && (swap_vec_element_size > 0) ) {
+ /*
+ * the reply has vector of elements which needs to be swapped
+ */
+ int vsize = buf_size / swap_vec_element_size;
+ char *p = buf;
+ int i;
+
+ for (i=0; i<vsize; i++) {
+ if (swap_vec_element_size == 2) {
+ __GLX_SWAP_SHORT(p);
+ }
+ else if (swap_vec_element_size == 4) {
+ __GLX_SWAP_INT(p);
+ }
+ else if (swap_vec_element_size == 8) {
+ __GLX_SWAP_DOUBLE(p);
+ }
+
+ p += swap_vec_element_size;
+ }
+
+ /*
+ * swap pad words as well - for case that some single reply uses
+ * them as well
+ */
+ __GLX_SWAP_INT(&reply->pad3);
+ __GLX_SWAP_INT(&reply->pad4);
+ __GLX_SWAP_INT(&reply->pad5);
+ __GLX_SWAP_INT(&reply->pad6);
+
+ }
+
+ WriteToClient(client, sizeof(xGLXSingleReply),(char *)reply);
+ if (buf_size > 0)
+ WriteToClient(client, buf_size, (char *)buf);
+
+}
+
+int __glXForwardSingleReq( __GLXclientState *cl, GLbyte *pc )
+{
+ xGLXSingleReq *req = (xGLXSingleReq *)pc;
+ xGLXSingleReq *be_req;
+ __GLXcontext *glxc;
+ int from_screen = 0;
+ int to_screen = 0;
+ int buf_size;
+ int s;
+
+ glxc = __glXLookupContextByTag(cl, req->contextTag);
+ if (!glxc) {
+ return 0;
+ }
+ from_screen = to_screen = glxc->pScreen->myNum;
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ from_screen = 0;
+ to_screen = screenInfo.numScreens - 1;
+ }
+#endif
+
+ pc += sz_xGLXSingleReq;
+ buf_size = (req->length << 2) - sz_xGLXSingleReq;
+
+ /*
+ * just forward the request to back-end server(s)
+ */
+ for (s=from_screen; s<=to_screen; s++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[s];
+ Display *dpy = GetBackEndDisplay(cl,s);
+
+ LockDisplay(dpy);
+ GetReqSingle(GLXSingle,be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = req->glxCode;
+ be_req->length = req->length;
+ be_req->contextTag = GetCurrentBackEndTag(cl,req->contextTag,s);
+ if (buf_size > 0)
+ _XSend(dpy, (const char *)pc, buf_size);
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ if (req->glxCode == X_GLsop_Flush) {
+ XFlush(dpy);
+ }
+
+ }
+
+ return Success;
+}
+
+int __glXForwardPipe0WithReply( __GLXclientState *cl, GLbyte *pc )
+{
+ ClientPtr client = cl->client;
+ xGLXSingleReq *req = (xGLXSingleReq *)pc;
+ xGLXSingleReq *be_req;
+ xGLXSingleReply reply;
+ xGLXSingleReply be_reply;
+ __GLXcontext *glxc;
+ int buf_size;
+ char *be_buf = NULL;
+ int be_buf_size;
+ DMXScreenInfo *dmxScreen;
+ Display *dpy;
+
+ glxc = __glXLookupContextByTag(cl, req->contextTag);
+ if (!glxc) {
+ return __glXBadContext;
+ }
+
+ pc += sz_xGLXSingleReq;
+ buf_size = (req->length << 2) - sz_xGLXSingleReq;
+
+ dmxScreen = &dmxScreens[glxc->pScreen->myNum];
+ dpy = GetBackEndDisplay(cl, glxc->pScreen->myNum);
+
+ /*
+ * send the request to the first back-end server
+ */
+ LockDisplay(dpy);
+ GetReqSingle(GLXSingle,be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = req->glxCode;
+ be_req->length = req->length;
+ be_req->contextTag = GetCurrentBackEndTag(cl,req->contextTag,glxc->pScreen->myNum);
+ if (buf_size > 0)
+ _XSend(dpy, (const char *)pc, buf_size);
+
+ /*
+ * get the reply from the back-end server
+ */
+ _XReply(dpy, (xReply*) &be_reply, 0, False);
+ be_buf_size = be_reply.length << 2;
+ if (be_buf_size > 0) {
+ be_buf = (char *)malloc( be_buf_size );
+ if (be_buf) {
+ _XRead(dpy, be_buf, be_buf_size);
+ }
+ else {
+ /* Throw data on the floor */
+ _XEatData(dpy, be_buf_size);
+ return BadAlloc;
+ }
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ /*
+ * send the reply to the client
+ */
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+ reply.length = be_reply.length;
+ reply.retval = be_reply.retval;
+ reply.size = be_reply.size;
+ reply.pad3 = be_reply.pad3;
+ reply.pad4 = be_reply.pad4;
+
+ if (client->swapped) {
+ SendSwappedReply( client, &reply, be_buf, be_buf_size );
+ }
+ else {
+ WriteToClient(client, sizeof(xGLXSingleReply),(char *)&reply);
+ if (be_buf_size > 0)
+ WriteToClient(client, be_buf_size, (char *)be_buf);
+ }
+
+ if (be_buf_size > 0) free(be_buf);
+
+ return Success;
+}
+
+int __glXForwardAllWithReply( __GLXclientState *cl, GLbyte *pc )
+{
+ ClientPtr client = cl->client;
+ xGLXSingleReq *req = (xGLXSingleReq *)pc;
+ xGLXSingleReq *be_req;
+ xGLXSingleReply reply;
+ xGLXSingleReply be_reply;
+ __GLXcontext *glxc;
+ int buf_size;
+ char *be_buf = NULL;
+ int be_buf_size = 0;
+ int from_screen = 0;
+ int to_screen = 0;
+ int s;
+
+ DMXScreenInfo *dmxScreen;
+ Display *dpy;
+
+ glxc = __glXLookupContextByTag(cl, req->contextTag);
+ if (!glxc) {
+ return 0;
+ }
+ from_screen = to_screen = glxc->pScreen->myNum;
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ from_screen = 0;
+ to_screen = screenInfo.numScreens - 1;
+ }
+#endif
+
+ pc += sz_xGLXSingleReq;
+ buf_size = (req->length << 2) - sz_xGLXSingleReq;
+
+ /*
+ * send the request to the first back-end server(s)
+ */
+ for (s=to_screen; s>=from_screen; s--) {
+ dmxScreen = &dmxScreens[s];
+ dpy = GetBackEndDisplay(cl,s);
+
+ LockDisplay(dpy);
+ GetReqSingle(GLXSingle,be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = req->glxCode;
+ be_req->length = req->length;
+ be_req->contextTag = GetCurrentBackEndTag(cl,req->contextTag,s);
+ if (buf_size > 0)
+ _XSend(dpy, (const char *)pc, buf_size);
+
+ /*
+ * get the reply from the back-end server
+ */
+ _XReply(dpy, (xReply*) &be_reply, 0, False);
+ be_buf_size = be_reply.length << 2;
+ if (be_buf_size > 0) {
+ be_buf = (char *)malloc( be_buf_size );
+ if (be_buf) {
+ _XRead(dpy, be_buf, be_buf_size);
+ }
+ else {
+ /* Throw data on the floor */
+ _XEatData(dpy, be_buf_size);
+ return BadAlloc;
+ }
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ if (s > from_screen && be_buf_size > 0) {
+ free(be_buf);
+ }
+ }
+
+ /*
+ * send the reply to the client
+ */
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+ reply.length = be_reply.length;
+ reply.retval = be_reply.retval;
+ reply.size = be_reply.size;
+ reply.pad3 = be_reply.pad3;
+ reply.pad4 = be_reply.pad4;
+
+ if (client->swapped) {
+ SendSwappedReply( client, &reply, be_buf, be_buf_size );
+ }
+ else {
+ WriteToClient(client, sizeof(xGLXSingleReply),(char *)&reply);
+ if (be_buf_size > 0)
+ WriteToClient(client, be_buf_size, (char *)be_buf);
+ }
+
+ if (be_buf_size > 0) free(be_buf);
+
+ return Success;
+}
+
+int __glXForwardSingleReqSwap( __GLXclientState *cl, GLbyte *pc )
+{
+ xGLXSingleReq *req = (xGLXSingleReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ swap_vec_element_size = 0;
+
+ /*
+ * swap extra data in request - assuming all data
+ * (if available) are arrays of 4 bytes components !
+ */
+ if (req->length > sz_xGLXSingleReq/4) {
+ int *data = (int *)(req+1);
+ int count = req->length - sz_xGLXSingleReq/4;
+ __GLX_SWAP_INT_ARRAY(data, count );
+ }
+
+ return( __glXForwardSingleReq( cl, pc ) );
+}
+
+int __glXForwardPipe0WithReplySwap( __GLXclientState *cl, GLbyte *pc )
+{
+ xGLXSingleReq *req = (xGLXSingleReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ swap_vec_element_size = 0;
+
+ /*
+ * swap extra data in request - assuming all data
+ * (if available) are arrays of 4 bytes components !
+ */
+ if (req->length > sz_xGLXSingleReq/4) {
+ int *data = (int *)(req+1);
+ int count = req->length - sz_xGLXSingleReq/4;
+ __GLX_SWAP_INT_ARRAY(data, count );
+ }
+
+ return( __glXForwardPipe0WithReply( cl, pc ) );
+}
+
+int __glXForwardPipe0WithReplySwapsv( __GLXclientState *cl, GLbyte *pc )
+{
+ xGLXSingleReq *req = (xGLXSingleReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ swap_vec_element_size = 2;
+
+ /*
+ * swap extra data in request - assuming all data
+ * (if available) are arrays of 4 bytes components !
+ */
+ if (req->length > sz_xGLXSingleReq/4) {
+ int *data = (int *)(req+1);
+ int count = req->length - sz_xGLXSingleReq/4;
+ __GLX_SWAP_INT_ARRAY(data, count );
+ }
+
+
+ return( __glXForwardPipe0WithReply( cl, pc ) );
+}
+
+int __glXForwardPipe0WithReplySwapiv( __GLXclientState *cl, GLbyte *pc )
+{
+ xGLXSingleReq *req = (xGLXSingleReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ swap_vec_element_size = 4;
+
+ /*
+ * swap extra data in request - assuming all data
+ * (if available) are arrays of 4 bytes components !
+ */
+ if (req->length > sz_xGLXSingleReq/4) {
+ int *data = (int *)(req+1);
+ int count = req->length - sz_xGLXSingleReq/4;
+ __GLX_SWAP_INT_ARRAY(data, count );
+ }
+
+
+ return( __glXForwardPipe0WithReply( cl, pc ) );
+}
+
+int __glXForwardPipe0WithReplySwapdv( __GLXclientState *cl, GLbyte *pc )
+{
+ xGLXSingleReq *req = (xGLXSingleReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ swap_vec_element_size = 8;
+
+ /*
+ * swap extra data in request - assuming all data
+ * (if available) are arrays of 4 bytes components !
+ */
+ if (req->length > sz_xGLXSingleReq/4) {
+ int *data = (int *)(req+1);
+ int count = req->length - sz_xGLXSingleReq/4;
+ __GLX_SWAP_INT_ARRAY(data, count );
+ }
+
+
+ return( __glXForwardPipe0WithReply( cl, pc ) );
+}
+
+int __glXForwardAllWithReplySwap( __GLXclientState *cl, GLbyte *pc )
+{
+ xGLXSingleReq *req = (xGLXSingleReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ swap_vec_element_size = 0;
+
+ /*
+ * swap extra data in request - assuming all data
+ * (if available) are arrays of 4 bytes components !
+ */
+ if (req->length > sz_xGLXSingleReq/4) {
+ int *data = (int *)(req+1);
+ int count = req->length - sz_xGLXSingleReq/4;
+ __GLX_SWAP_INT_ARRAY(data, count );
+ }
+
+
+ return( __glXForwardAllWithReply( cl, pc ) );
+}
+
+int __glXForwardAllWithReplySwapsv( __GLXclientState *cl, GLbyte *pc )
+{
+ xGLXSingleReq *req = (xGLXSingleReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ swap_vec_element_size = 2;
+
+ /*
+ * swap extra data in request - assuming all data
+ * (if available) are arrays of 4 bytes components !
+ */
+ if (req->length > sz_xGLXSingleReq/4) {
+ int *data = (int *)(req+1);
+ int count = req->length - sz_xGLXSingleReq/4;
+ __GLX_SWAP_INT_ARRAY(data, count );
+ }
+
+
+ return( __glXForwardAllWithReply( cl, pc ) );
+}
+
+int __glXForwardAllWithReplySwapiv( __GLXclientState *cl, GLbyte *pc )
+{
+ xGLXSingleReq *req = (xGLXSingleReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ swap_vec_element_size = 4;
+
+ /*
+ * swap extra data in request - assuming all data
+ * (if available) are arrays of 4 bytes components !
+ */
+ if (req->length > sz_xGLXSingleReq/4) {
+ int *data = (int *)(req+1);
+ int count = req->length - sz_xGLXSingleReq/4;
+ __GLX_SWAP_INT_ARRAY(data, count );
+ }
+
+
+ return( __glXForwardAllWithReply( cl, pc ) );
+}
+
+int __glXForwardAllWithReplySwapdv( __GLXclientState *cl, GLbyte *pc )
+{
+ xGLXSingleReq *req = (xGLXSingleReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ swap_vec_element_size = 8;
+
+ /*
+ * swap extra data in request - assuming all data
+ * (if available) are arrays of 4 bytes components !
+ */
+ if (req->length > sz_xGLXSingleReq/4) {
+ int *data = (int *)(req+1);
+ int count = req->length - sz_xGLXSingleReq/4;
+ __GLX_SWAP_INT_ARRAY(data, count );
+ }
+
+
+ return( __glXForwardAllWithReply( cl, pc ) );
+}
+
+static GLint __glReadPixels_size(GLenum format, GLenum type, GLint w, GLint h,
+ int *elementbits_return, int *rowbytes_return )
+{
+ GLint elements, esize;
+ GLint rowsize, padding;
+
+ if (w < 0 || h < 0) {
+ return -1;
+ }
+ switch (format) {
+ case GL_COLOR_INDEX:
+ case GL_STENCIL_INDEX:
+ case GL_DEPTH_COMPONENT:
+ elements = 1;
+ break;
+ case GL_RED:
+ case GL_GREEN:
+ case GL_BLUE:
+ case GL_ALPHA:
+ case GL_LUMINANCE:
+ elements = 1;
+ break;
+ case GL_LUMINANCE_ALPHA:
+ elements = 2;
+ break;
+ case GL_RGB:
+ case GL_BGR:
+ elements = 3;
+ break;
+ case GL_RGBA:
+ case GL_BGRA:
+ case GL_ABGR_EXT:
+ elements = 4;
+ break;
+ default:
+ return -1;
+ }
+ /*
+ ** According to the GLX protocol, each row must be padded to a multiple of
+ ** 4 bytes. 4 bytes also happens to be the default alignment in the pixel
+ ** store modes of the GL.
+ */
+ switch (type) {
+ case GL_BITMAP:
+ if (format == GL_COLOR_INDEX || format == GL_STENCIL_INDEX) {
+ rowsize = ((w * elements)+7)/8;
+ padding = rowsize % 4;
+ if (padding) {
+ rowsize += 4 - padding;
+ }
+ if (elementbits_return) *elementbits_return = elements;
+ if (rowbytes_return) *rowbytes_return = rowsize;
+ return rowsize * h;
+ } else {
+ return -1;
+ }
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ esize = 1;
+ break;
+ case GL_UNSIGNED_BYTE_3_3_2:
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ esize = 1;
+ elements = 1;
+ break;
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ esize = 2;
+ break;
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ esize = 2;
+ elements = 1;
+ break;
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_FLOAT:
+ esize = 4;
+ break;
+ case GL_UNSIGNED_INT_8_8_8_8:
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ esize = 4;
+ elements = 1;
+ break;
+ default:
+ return -1;
+ }
+ rowsize = w * elements * esize;
+ padding = rowsize % 4;
+ if (padding) {
+ rowsize += 4 - padding;
+ }
+
+ if (elementbits_return) *elementbits_return = esize*elements*8;
+ if (rowbytes_return) *rowbytes_return = rowsize;
+
+ return rowsize * h;
+}
+
+static int intersectRect( int x1, int x2, int y1, int y2,
+ int X1, int X2, int Y1, int Y2,
+ int *ix1, int *ix2, int *iy1, int *iy2 )
+{
+ int right = (x2 < X2 ? x2 : X2);
+ int bottom = (y2 < Y2 ? y2 : Y2);
+ int left = (x1 > X1 ? x1 : X1);
+ int top = (y1 > Y1 ? y1 : Y1);
+ int width = right - left + 1;
+ int height = bottom - top + 1;
+
+ if ( (width <= 0) || (height <= 0) ) {
+ *ix1 = *ix2 = *iy1 = *iy2 = 0;
+ return 0;
+ }
+ else {
+ *ix1 = left;
+ *ix2 = right;
+ *iy1 = top;
+ *iy2 = bottom;
+ return width * height;
+ }
+
+}
+
+int __glXDisp_ReadPixels(__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXSingleReq *req = (xGLXSingleReq *)pc;
+ xGLXSingleReq *be_req;
+ xGLXReadPixelsReply reply;
+ xGLXReadPixelsReply be_reply;
+ GLbyte *be_pc;
+ GLint x,y;
+ GLsizei width, height;
+ GLenum format, type;
+ GLboolean swapBytes, lsbFirst;
+ ClientPtr client = cl->client;
+ DrawablePtr pDraw;
+ __GLXcontext *glxc;
+ int from_screen = 0;
+ int to_screen = 0;
+ char *buf;
+ int buf_size;
+ int s;
+ int win_x1, win_x2;
+ int win_y1, win_y2;
+ int ebits, rowsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ if (client->swapped) {
+ __GLX_SWAP_INT(&req->contextTag);
+ }
+
+ glxc = __glXLookupContextByTag(cl, req->contextTag);
+ if (!glxc) {
+ return 0;
+ }
+ from_screen = to_screen = glxc->pScreen->myNum;
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ from_screen = 0;
+ to_screen = screenInfo.numScreens - 1;
+ }
+#endif
+
+ pc += sz_xGLXSingleReq;
+ x = *(GLint *)(pc + 0);
+ y = *(GLint *)(pc + 4);
+ width = *(GLsizei *)(pc + 8);
+ height = *(GLsizei *)(pc + 12);
+ format = *(GLenum *)(pc + 16);
+ type = *(GLenum *)(pc + 20);
+ swapBytes = *(GLboolean *)(pc + 24);
+ lsbFirst = *(GLboolean *)(pc + 25);
+
+ if (client->swapped) {
+ __GLX_SWAP_INT(&x);
+ __GLX_SWAP_INT(&y);
+ __GLX_SWAP_INT(&width);
+ __GLX_SWAP_INT(&height);
+ __GLX_SWAP_INT(&format);
+ __GLX_SWAP_INT(&type);
+ swapBytes = !swapBytes;
+ }
+
+ buf_size = __glReadPixels_size(format,type,width,height, &ebits, &rowsize);
+ if (buf_size > 0) {
+ buf = (char *) malloc( buf_size );
+ if ( !buf ) {
+ return BadAlloc;
+ }
+ }
+ else {
+ buf_size = 0;
+ buf = NULL;
+ }
+
+ if (buf_size > 0) {
+ /*
+ * Get the current drawable this context is bound to
+ */
+ pDraw = __glXLookupDrawableByTag( cl, req->contextTag );
+ win_x1 = pDraw->x + x;
+ win_x2 = win_x1 + width - 1;
+ win_y1 = (dmxGlobalHeight - pDraw->y - pDraw->height) + y;
+ win_y2 = win_y1 + height - 1;
+ if (pDraw->type != DRAWABLE_WINDOW) {
+ from_screen = to_screen = 0;
+ }
+
+ for (s=from_screen; s<=to_screen; s++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[s];
+ Display *dpy = GetBackEndDisplay(cl,s);
+ int scr_x1 = dmxScreen->rootXOrigin;
+ int scr_x2 = dmxScreen->rootXOrigin + dmxScreen->scrnWidth - 1;
+ int scr_y1 = dmxScreen->rootYOrigin;
+ int scr_y2 = dmxScreen->rootYOrigin + dmxScreen->scrnHeight - 1;
+ int wx1, wx2, wy1, wy2;
+ int sx, sy, sw, sh;
+ int npixels;
+
+ /*
+ * find the window portion that is on the current screen
+ */
+ if (pDraw->type == DRAWABLE_WINDOW) {
+ npixels = intersectRect( scr_x1, scr_x2, scr_y1, scr_y2,
+ win_x1, win_x2, win_y1, win_y2,
+ &wx1, &wx2, &wy1, &wy2 );
+ }
+ else {
+ wx1 = win_x1;
+ wx2 = win_x2;
+ wy1 = win_y1;
+ wy2 = win_y2;
+ npixels = (wx2-wx1+1) * (wy2-wy1+1);
+ }
+
+ if (npixels > 0) {
+
+ /* send the request to the back-end server */
+ LockDisplay(dpy);
+ GetReqExtra(GLXSingle,__GLX_PAD(26),be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = X_GLsop_ReadPixels;
+ be_req->contextTag = GetCurrentBackEndTag(cl,req->contextTag,s);
+ be_pc = ((GLbyte *)(be_req) + sz_xGLXSingleReq);
+
+ sx = wx1 - pDraw->x;
+ sy = wy1 - (dmxGlobalHeight - pDraw->y - pDraw->height);
+ sw = (wx2-wx1+1);
+ sh = (wy2-wy1+1);
+
+ *(GLint *)(be_pc + 0) = sx; /* x */
+ *(GLint *)(be_pc + 4) = sy; /* y */
+ *(GLsizei *)(be_pc + 8) = sw; /* width */
+ *(GLsizei *)(be_pc + 12) = sh; /* height */
+ *(GLenum *)(be_pc + 16) = format;
+ *(GLenum *)(be_pc + 20) = type;
+ *(GLboolean *)(be_pc + 24) = swapBytes;
+ *(GLboolean *)(be_pc + 25) = lsbFirst;
+
+ _XReply(dpy, (xReply*) &be_reply, 0, False);
+
+ if (be_reply.length > 0) {
+ char *be_buf;
+ int be_buf_size = be_reply.length << 2;
+
+ be_buf = (char *) malloc( be_buf_size );
+ if (be_buf) {
+ _XRead(dpy, be_buf, be_buf_size);
+
+ /* copy pixels data to the right location of the */
+ /* reply buffer */
+ if ( type != GL_BITMAP ) {
+ int pbytes = ebits / 8;
+ char *dst = buf + (sy-y)*rowsize + (sx-x)*pbytes;
+ char *src = be_buf;
+ int pad = (pbytes * sw) % 4;
+ int r;
+
+ for (r=0; r<sh; r++) {
+ memcpy( dst, src, pbytes*sw );
+ dst += rowsize;
+ src += (pbytes*sw + (pad ? 4-pad : 0) );
+ }
+ }
+ else {
+ /* this is a GL_BITMAP pixel type, should copy bits */
+ int r;
+ int src_rowsize = bits_to_bytes(sw * ebits);
+ int src_pad = src_rowsize % 4;
+ if ( src_pad ) {
+ src_rowsize += (4 - src_pad);
+ }
+
+ for (r=0; r<sh; r++) {
+ unsigned char dst_mask = 0x80 >> (sx % 8);
+ unsigned char src_mask = 0x80;
+ char *dst = buf + (sy-y+r)*rowsize + (sx-x)/8;
+ char *src = be_buf + r*src_rowsize;
+ int b;
+
+ for (b=0; b<sw*ebits; b++) {
+ if ( *src & src_mask ) {
+ *dst |= dst_mask;
+ }
+ else {
+ *dst &= ~dst_mask;
+ }
+
+ if (dst_mask > 1) dst_mask >>= 1;
+ else {
+ dst_mask = 0x80;
+ dst++;
+ }
+
+ if (src_mask > 1) src_mask >>= 1;
+ else {
+ src_mask = 0x80;
+ src++;
+ }
+ }
+ }
+
+ }
+
+ free( be_buf );
+ }
+ else {
+ /* Throw data on the floor */
+ _XEatData(dpy, be_buf_size);
+ free( buf );
+ return BadAlloc;
+ }
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ } /* of npixels > 0 */
+
+ } /* of for loop */
+
+ } /* of if buf_size > 0 */
+
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+ reply.length = buf_size >> 2;
+
+ if (client->swapped) {
+ __GLX_SWAP_SHORT(&reply.sequenceNumber);
+ __GLX_SWAP_INT(&reply.length);
+ }
+
+ WriteToClient(client, sizeof(xGLXReadPixelsReply),(char *)&reply);
+ if (buf_size > 0) {
+ WriteToClient(client, buf_size, (char *)buf);
+ free( buf );
+ }
+
+ return Success;
+}
+
+int __glXDispSwap_GetTexImage(__GLXclientState *cl, GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ GLbyte *lpc = pc;
+
+ lpc += sz_xGLXSingleReq;
+ __GLX_SWAP_INT(lpc+0);
+ __GLX_SWAP_INT(lpc+4);
+ __GLX_SWAP_INT(lpc+8);
+ __GLX_SWAP_INT(lpc+12);
+
+ /* reverse swapBytes */
+ *(GLboolean *)(lpc + 16) = ! *(GLboolean *)(lpc + 16);
+
+ return( __glXForwardPipe0WithReplySwap( cl, pc ) );
+}
+
+int __glXDispSwap_GetColorTable(__GLXclientState *cl, GLbyte *pc)
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ GLbyte *lpc = pc;
+
+ lpc += sz_xGLXSingleReq;
+ __GLX_SWAP_INT(lpc+0);
+ __GLX_SWAP_INT(lpc+4);
+ __GLX_SWAP_INT(lpc+8);
+
+ /* reverse swapBytes */
+ *(GLboolean *)(lpc + 12) = ! *(GLboolean *)(lpc + 12);
+
+ return( __glXForwardPipe0WithReplySwap( cl, pc ) );
+}
+
+
diff --git a/xorg-server/hw/dmx/glxProxy/glxvendor.c b/xorg-server/hw/dmx/glxProxy/glxvendor.c
index 9dbc46daa..0b6ba4134 100644
--- a/xorg-server/hw/dmx/glxProxy/glxvendor.c
+++ b/xorg-server/hw/dmx/glxProxy/glxvendor.c
@@ -1,585 +1,585 @@
-/* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED */
-/*
- * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
- * Copyright (C) 1991-2000 Silicon Graphics, 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 including the dates of first publication and
- * either this permission notice or a reference to
- * http://oss.sgi.com/projects/FreeB/
- * 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
- * SILICON GRAPHICS, INC. 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 Silicon Graphics, Inc.
- * shall not be used in advertising or otherwise to promote the sale, use or
- * other dealings in this Software without prior written authorization from
- * Silicon Graphics, Inc.
- */
-
-#ifdef HAVE_DMX_CONFIG_H
-#include <dmx-config.h>
-#endif
-
-#include "dmx.h"
-#include "dmxwindow.h"
-#include "dmxpixmap.h"
-#include "dmxfont.h"
-
-#include "glxserver.h"
-#include "glxext.h"
-#include "g_disptab.h"
-/* #include "g_disptab_EXT.h" */
-#include "unpack.h"
-#include "glxutil.h"
-
-#include "GL/glxproto.h"
-
-#ifdef PANORAMIX
-#include "panoramiXsrv.h"
-#endif
-
-/*
- * GetReqVendorPrivate - this is the equivalent of GetReq macro
- * from Xlibint.h but it does not set the reqType field (the opcode).
- * this is because the GL single opcodes has different naming convension
- * the other X opcodes (ie. X_GLsop_GetFloatv).
- */
-#if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
-#define GetReqVendorPrivate(name, req) \
- WORD64ALIGN\
- if ((dpy->bufptr + SIZEOF(x##name##Req)) > dpy->bufmax)\
- _XFlush(dpy);\
- req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\
- req->length = (SIZEOF(x##name##Req))>>2;\
- dpy->bufptr += SIZEOF(x##name##Req);\
- dpy->request++
-
-#else /* non-ANSI C uses empty comment instead of "##" for token concatenation */
-#define GetReqVendorPrivate(name, req) \
- WORD64ALIGN\
- if ((dpy->bufptr + SIZEOF(x/**/name/**/Req)) > dpy->bufmax)\
- _XFlush(dpy);\
- req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
- req->length = (SIZEOF(x/**/name/**/Req))>>2;\
- dpy->bufptr += SIZEOF(x/**/name/**/Req);\
- dpy->request++
-#endif
-
-extern Display *GetBackEndDisplay( __GLXclientState *cl, int s );
-extern int GetCurrentBackEndTag(__GLXclientState *cl, GLXContextTag tag, int s);
-
-static int swap_vec_element_size = 0;
-
-static void SendSwappedReply( ClientPtr client,
- xGLXVendorPrivReply *reply,
- char *buf,
- int buf_size )
-{
- __GLX_DECLARE_SWAP_VARIABLES;
- __GLX_SWAP_SHORT(&reply->sequenceNumber);
- __GLX_SWAP_INT(&reply->length);
- __GLX_SWAP_INT(&reply->retval);
- __GLX_SWAP_INT(&reply->size);
-
- if ( (buf_size == 0) && (swap_vec_element_size > 0) ) {
- /*
- * the reply has single component - need to swap pad3
- */
- if (swap_vec_element_size == 2) {
- __GLX_SWAP_SHORT(&reply->pad3);
- }
- else if (swap_vec_element_size == 4) {
- __GLX_SWAP_INT(&reply->pad3);
- __GLX_SWAP_INT(&reply->pad4);
- }
- else if (swap_vec_element_size == 8) {
- __GLX_SWAP_DOUBLE(&reply->pad3);
- }
- }
- else if ( (buf_size > 0) && (swap_vec_element_size > 0) ) {
- /*
- * the reply has vector of elements which needs to be swapped
- */
- int vsize = buf_size / swap_vec_element_size;
- char *p = buf;
- int i;
-
- for (i=0; i<vsize; i++) {
- if (swap_vec_element_size == 2) {
- __GLX_SWAP_SHORT(p);
- }
- else if (swap_vec_element_size == 4) {
- __GLX_SWAP_INT(p);
- }
- else if (swap_vec_element_size == 8) {
- __GLX_SWAP_DOUBLE(p);
- }
-
- p += swap_vec_element_size;
- }
-
- __GLX_SWAP_INT(&reply->pad3);
- __GLX_SWAP_INT(&reply->pad4);
- __GLX_SWAP_INT(&reply->pad5);
- __GLX_SWAP_INT(&reply->pad6);
-
- }
-
- WriteToClient(client, sizeof(xGLXVendorPrivReply),(char *)reply);
- if (buf_size > 0)
- WriteToClient(client, buf_size, (char *)buf);
-
-}
-
-int __glXVForwardSingleReq( __GLXclientState *cl, GLbyte *pc )
-{
- xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
- xGLXVendorPrivateReq *be_req;
- __GLXcontext *glxc;
- int from_screen = 0;
- int to_screen = 0;
- int buf_size;
- int s;
-
- glxc = __glXLookupContextByTag(cl, req->contextTag);
- if (!glxc) {
- return 0;
- }
- from_screen = to_screen = glxc->pScreen->myNum;
-
-#ifdef PANORAMIX
- if (!noPanoramiXExtension) {
- from_screen = 0;
- to_screen = screenInfo.numScreens - 1;
- }
-#endif
-
- pc += sz_xGLXVendorPrivateReq;
- buf_size = (req->length << 2) - sz_xGLXVendorPrivateReq;
-
- /*
- * just forward the request to back-end server(s)
- */
- for (s=from_screen; s<=to_screen; s++) {
- DMXScreenInfo *dmxScreen = &dmxScreens[s];
- Display *dpy = GetBackEndDisplay(cl,s);
-
- LockDisplay(dpy);
- GetReqVendorPrivate(GLXVendorPrivate,be_req);
- be_req->reqType = dmxScreen->glxMajorOpcode;
- be_req->glxCode = req->glxCode;
- be_req->length = req->length;
- be_req->vendorCode = req->vendorCode;
- be_req->contextTag = GetCurrentBackEndTag(cl,req->contextTag,s);
- if (buf_size > 0)
- _XSend(dpy, (const char *)pc, buf_size);
- UnlockDisplay(dpy);
- SyncHandle();
- }
-
- return Success;
-}
-
-int __glXVForwardPipe0WithReply( __GLXclientState *cl, GLbyte *pc )
-{
- ClientPtr client = cl->client;
- xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
- xGLXVendorPrivateReq *be_req;
- xGLXVendorPrivReply reply;
- xGLXVendorPrivReply be_reply;
- __GLXcontext *glxc;
- int buf_size;
- char *be_buf = NULL;
- int be_buf_size;
- DMXScreenInfo *dmxScreen;
- Display *dpy;
-
- glxc = __glXLookupContextByTag(cl, req->contextTag);
- if (!glxc) {
- return __glXBadContext;
- }
-
- pc += sz_xGLXVendorPrivateReq;
- buf_size = (req->length << 2) - sz_xGLXVendorPrivateReq;
-
- dmxScreen = &dmxScreens[glxc->pScreen->myNum];
- dpy = GetBackEndDisplay(cl, glxc->pScreen->myNum);
-
- /*
- * send the request to the first back-end server
- */
- LockDisplay(dpy);
- GetReqVendorPrivate(GLXVendorPrivate,be_req);
- be_req->reqType = dmxScreen->glxMajorOpcode;
- be_req->glxCode = req->glxCode;
- be_req->length = req->length;
- be_req->vendorCode = req->vendorCode;
- be_req->contextTag = GetCurrentBackEndTag(cl,req->contextTag, glxc->pScreen->myNum);
- if (buf_size > 0)
- _XSend(dpy, (const char *)pc, buf_size);
-
- /*
- * get the reply from the back-end server
- */
- _XReply(dpy, (xReply*) &be_reply, 0, False);
- be_buf_size = be_reply.length << 2;
- if (be_buf_size > 0) {
- be_buf = (char *)malloc( be_buf_size );
- if (be_buf) {
- _XRead(dpy, be_buf, be_buf_size);
- }
- else {
- /* Throw data on the floor */
- _XEatData(dpy, be_buf_size);
- return BadAlloc;
- }
- }
-
- UnlockDisplay(dpy);
- SyncHandle();
-
- /*
- * send the reply to the client
- */
- memcpy( &reply, &be_reply, sz_xGLXVendorPrivReply );
- reply.type = X_Reply;
- reply.sequenceNumber = client->sequence;
-
- if (client->swapped) {
- SendSwappedReply( client, &reply, be_buf, be_buf_size );
- }
- else {
- WriteToClient(client, sizeof(xGLXVendorPrivReply),(char *)&reply);
- if (be_buf_size > 0)
- WriteToClient(client, be_buf_size, (char *)be_buf);
- }
-
- if (be_buf_size > 0) free(be_buf);
-
- return Success;
-}
-
-int __glXVForwardAllWithReply( __GLXclientState *cl, GLbyte *pc )
-{
- ClientPtr client = cl->client;
- xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
- xGLXVendorPrivateReq *be_req;
- xGLXVendorPrivReply reply;
- xGLXVendorPrivReply be_reply;
- __GLXcontext *glxc;
- int buf_size;
- char *be_buf = NULL;
- int be_buf_size = 0;
- int from_screen = 0;
- int to_screen = 0;
- int s;
-
- DMXScreenInfo *dmxScreen;
- Display *dpy;
-
- glxc = __glXLookupContextByTag(cl, req->contextTag);
- if (!glxc) {
- return 0;
- }
- from_screen = to_screen = glxc->pScreen->myNum;
-
-#ifdef PANORAMIX
- if (!noPanoramiXExtension) {
- from_screen = 0;
- to_screen = screenInfo.numScreens - 1;
- }
-#endif
-
- pc += sz_xGLXVendorPrivateReq;
- buf_size = (req->length << 2) - sz_xGLXVendorPrivateReq;
-
- /*
- * send the request to the first back-end server(s)
- */
- for (s=to_screen; s>=from_screen; s--) {
- dmxScreen = &dmxScreens[s];
- dpy = GetBackEndDisplay(cl,s);
-
- LockDisplay(dpy);
- GetReqVendorPrivate(GLXVendorPrivate,be_req);
- be_req->reqType = dmxScreen->glxMajorOpcode;
- be_req->glxCode = req->glxCode;
- be_req->length = req->length;
- be_req->vendorCode = req->vendorCode;
- be_req->contextTag = GetCurrentBackEndTag(cl,req->contextTag,s);
- if (buf_size > 0)
- _XSend(dpy, (const char *)pc, buf_size);
-
- /*
- * get the reply from the back-end server
- */
- _XReply(dpy, (xReply*) &be_reply, 0, False);
- be_buf_size = be_reply.length << 2;
- if (be_buf_size > 0) {
- be_buf = (char *)malloc( be_buf_size );
- if (be_buf) {
- _XRead(dpy, be_buf, be_buf_size);
- }
- else {
- /* Throw data on the floor */
- _XEatData(dpy, be_buf_size);
- return BadAlloc;
- }
- }
-
- UnlockDisplay(dpy);
- SyncHandle();
-
- if (s > from_screen && be_buf_size > 0) {
- free(be_buf);
- }
- }
-
- /*
- * send the reply to the client
- */
- memcpy( &reply, &be_reply, sz_xGLXVendorPrivReply );
- reply.type = X_Reply;
- reply.sequenceNumber = client->sequence;
-
- if (client->swapped) {
- SendSwappedReply( client, &reply, be_buf, be_buf_size );
- }
- else {
- WriteToClient(client, sizeof(xGLXVendorPrivReply),(char *)&reply);
- if (be_buf_size > 0)
- WriteToClient(client, be_buf_size, (char *)be_buf);
- }
-
- if (be_buf_size > 0) free(be_buf);
-
- return Success;
-}
-
-int __glXVForwardSingleReqSwap( __GLXclientState *cl, GLbyte *pc )
-{
- xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
- __GLX_DECLARE_SWAP_VARIABLES;
-
- __GLX_SWAP_SHORT(&req->length);
- __GLX_SWAP_INT(&req->vendorCode);
- __GLX_SWAP_INT(&req->contextTag);
-
- swap_vec_element_size = 0;
-
- return( __glXVForwardSingleReq( cl, pc ) );
-}
-
-int __glXVForwardPipe0WithReplySwap( __GLXclientState *cl, GLbyte *pc )
-{
- xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
- __GLX_DECLARE_SWAP_VARIABLES;
- __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
-
- __GLX_SWAP_SHORT(&req->length);
- __GLX_SWAP_INT(&req->vendorCode);
- __GLX_SWAP_INT(&req->contextTag);
-
- swap_vec_element_size = 0;
-
- /*
- * swap extra data in request - assuming all data
- * (if available) are arrays of 4 bytes components !
- */
- if (req->length > sz_xGLXVendorPrivateReq/4) {
- int *data = (int *)(req+1);
- int count = req->length - sz_xGLXVendorPrivateReq/4;
- __GLX_SWAP_INT_ARRAY(data, count );
- }
-
- return( __glXVForwardPipe0WithReply( cl, pc ) );
-}
-
-int __glXVForwardPipe0WithReplySwapsv( __GLXclientState *cl, GLbyte *pc )
-{
- xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
- __GLX_DECLARE_SWAP_VARIABLES;
- __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
-
- __GLX_SWAP_SHORT(&req->length);
- __GLX_SWAP_INT(&req->vendorCode);
- __GLX_SWAP_INT(&req->contextTag);
-
- swap_vec_element_size = 2;
-
- /*
- * swap extra data in request - assuming all data
- * (if available) are arrays of 4 bytes components !
- */
- if (req->length > sz_xGLXVendorPrivateReq/4) {
- int *data = (int *)(req+1);
- int count = req->length - sz_xGLXVendorPrivateReq/4;
- __GLX_SWAP_INT_ARRAY(data, count );
- }
-
- return( __glXVForwardPipe0WithReply( cl, pc ) );
-}
-
-int __glXVForwardPipe0WithReplySwapiv( __GLXclientState *cl, GLbyte *pc )
-{
- xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
- __GLX_DECLARE_SWAP_VARIABLES;
- __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
-
- __GLX_SWAP_SHORT(&req->length);
- __GLX_SWAP_INT(&req->vendorCode);
- __GLX_SWAP_INT(&req->contextTag);
-
- swap_vec_element_size = 4;
-
- /*
- * swap extra data in request - assuming all data
- * (if available) are arrays of 4 bytes components !
- */
- if (req->length > sz_xGLXVendorPrivateReq/4) {
- int *data = (int *)(req+1);
- int count = req->length - sz_xGLXVendorPrivateReq/4;
- __GLX_SWAP_INT_ARRAY(data, count );
- }
-
- return( __glXVForwardPipe0WithReply( cl, pc ) );
-}
-
-int __glXVForwardPipe0WithReplySwapdv( __GLXclientState *cl, GLbyte *pc )
-{
- xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
- __GLX_DECLARE_SWAP_VARIABLES;
- __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
-
- __GLX_SWAP_SHORT(&req->length);
- __GLX_SWAP_INT(&req->vendorCode);
- __GLX_SWAP_INT(&req->contextTag);
-
- swap_vec_element_size = 8;
-
- /*
- * swap extra data in request - assuming all data
- * (if available) are arrays of 4 bytes components !
- */
- if (req->length > sz_xGLXVendorPrivateReq/4) {
- int *data = (int *)(req+1);
- int count = req->length - sz_xGLXVendorPrivateReq/4;
- __GLX_SWAP_INT_ARRAY(data, count );
- }
-
- return( __glXVForwardPipe0WithReply( cl, pc ) );
-}
-
-int __glXVForwardAllWithReplySwap( __GLXclientState *cl, GLbyte *pc )
-{
- xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
- __GLX_DECLARE_SWAP_VARIABLES;
- __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
-
- __GLX_SWAP_SHORT(&req->length);
- __GLX_SWAP_INT(&req->vendorCode);
- __GLX_SWAP_INT(&req->contextTag);
-
- swap_vec_element_size = 0;
-
- /*
- * swap extra data in request - assuming all data
- * (if available) are arrays of 4 bytes components !
- */
- if (req->length > sz_xGLXVendorPrivateReq/4) {
- int *data = (int *)(req+1);
- int count = req->length - sz_xGLXVendorPrivateReq/4;
- __GLX_SWAP_INT_ARRAY(data, count );
- }
-
- return( __glXVForwardAllWithReply( cl, pc ) );
-}
-
-int __glXVForwardAllWithReplySwapsv( __GLXclientState *cl, GLbyte *pc )
-{
- xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
- __GLX_DECLARE_SWAP_VARIABLES;
- __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
-
- __GLX_SWAP_SHORT(&req->length);
- __GLX_SWAP_INT(&req->vendorCode);
- __GLX_SWAP_INT(&req->contextTag);
-
- swap_vec_element_size = 2;
-
- /*
- * swap extra data in request - assuming all data
- * (if available) are arrays of 4 bytes components !
- */
- if (req->length > sz_xGLXVendorPrivateReq/4) {
- int *data = (int *)(req+1);
- int count = req->length - sz_xGLXVendorPrivateReq/4;
- __GLX_SWAP_INT_ARRAY(data, count );
- }
-
- return( __glXVForwardAllWithReply( cl, pc ) );
-}
-
-int __glXVForwardAllWithReplySwapiv( __GLXclientState *cl, GLbyte *pc )
-{
- xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
- __GLX_DECLARE_SWAP_VARIABLES;
- __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
-
- __GLX_SWAP_SHORT(&req->length);
- __GLX_SWAP_INT(&req->vendorCode);
- __GLX_SWAP_INT(&req->contextTag);
-
- swap_vec_element_size = 4;
-
- /*
- * swap extra data in request - assuming all data
- * (if available) are arrays of 4 bytes components !
- */
- if (req->length > sz_xGLXVendorPrivateReq/4) {
- int *data = (int *)(req+1);
- int count = req->length - sz_xGLXVendorPrivateReq/4;
- __GLX_SWAP_INT_ARRAY(data, count );
- }
-
- return( __glXVForwardAllWithReply( cl, pc ) );
-}
-
-int __glXVForwardAllWithReplySwapdv( __GLXclientState *cl, GLbyte *pc )
-{
- xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
- __GLX_DECLARE_SWAP_VARIABLES;
- __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
-
- __GLX_SWAP_SHORT(&req->length);
- __GLX_SWAP_INT(&req->vendorCode);
- __GLX_SWAP_INT(&req->contextTag);
-
- swap_vec_element_size = 8;
-
- /*
- * swap extra data in request - assuming all data
- * (if available) are arrays of 4 bytes components !
- */
- if (req->length > sz_xGLXVendorPrivateReq/4) {
- int *data = (int *)(req+1);
- int count = req->length - sz_xGLXVendorPrivateReq/4;
- __GLX_SWAP_INT_ARRAY(data, count );
- }
-
- return( __glXVForwardAllWithReply( cl, pc ) );
-}
-
+/* DO NOT EDIT - THIS FILE IS AUTOMATICALLY GENERATED */
+/*
+ * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
+ * Copyright (C) 1991-2000 Silicon Graphics, 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 including the dates of first publication and
+ * either this permission notice or a reference to
+ * http://oss.sgi.com/projects/FreeB/
+ * 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
+ * SILICON GRAPHICS, INC. 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 Silicon Graphics, Inc.
+ * shall not be used in advertising or otherwise to promote the sale, use or
+ * other dealings in this Software without prior written authorization from
+ * Silicon Graphics, Inc.
+ */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#include "dmx.h"
+#include "dmxwindow.h"
+#include "dmxpixmap.h"
+#include "dmxfont.h"
+
+#include "glxserver.h"
+#include "glxext.h"
+#include "g_disptab.h"
+/* #include "g_disptab_EXT.h" */
+#include "unpack.h"
+#include "glxutil.h"
+
+#include "GL/glxproto.h"
+
+#ifdef PANORAMIX
+#include "panoramiXsrv.h"
+#endif
+
+/*
+ * GetReqVendorPrivate - this is the equivalent of GetReq macro
+ * from Xlibint.h but it does not set the reqType field (the opcode).
+ * this is because the GL single opcodes has different naming convension
+ * the other X opcodes (ie. X_GLsop_GetFloatv).
+ */
+#if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
+#define GetReqVendorPrivate(name, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(x##name##Req)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\
+ req->length = (SIZEOF(x##name##Req))>>2;\
+ dpy->bufptr += SIZEOF(x##name##Req);\
+ dpy->request++
+
+#else /* non-ANSI C uses empty comment instead of "##" for token concatenation */
+#define GetReqVendorPrivate(name, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(x/**/name/**/Req)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
+ req->length = (SIZEOF(x/**/name/**/Req))>>2;\
+ dpy->bufptr += SIZEOF(x/**/name/**/Req);\
+ dpy->request++
+#endif
+
+extern Display *GetBackEndDisplay( __GLXclientState *cl, int s );
+extern int GetCurrentBackEndTag(__GLXclientState *cl, GLXContextTag tag, int s);
+
+static int swap_vec_element_size = 0;
+
+static void SendSwappedReply( ClientPtr client,
+ xGLXVendorPrivReply *reply,
+ char *buf,
+ int buf_size )
+{
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_SWAP_SHORT(&reply->sequenceNumber);
+ __GLX_SWAP_INT(&reply->length);
+ __GLX_SWAP_INT(&reply->retval);
+ __GLX_SWAP_INT(&reply->size);
+
+ if ( (buf_size == 0) && (swap_vec_element_size > 0) ) {
+ /*
+ * the reply has single component - need to swap pad3
+ */
+ if (swap_vec_element_size == 2) {
+ __GLX_SWAP_SHORT(&reply->pad3);
+ }
+ else if (swap_vec_element_size == 4) {
+ __GLX_SWAP_INT(&reply->pad3);
+ __GLX_SWAP_INT(&reply->pad4);
+ }
+ else if (swap_vec_element_size == 8) {
+ __GLX_SWAP_DOUBLE(&reply->pad3);
+ }
+ }
+ else if ( (buf_size > 0) && (swap_vec_element_size > 0) ) {
+ /*
+ * the reply has vector of elements which needs to be swapped
+ */
+ int vsize = buf_size / swap_vec_element_size;
+ char *p = buf;
+ int i;
+
+ for (i=0; i<vsize; i++) {
+ if (swap_vec_element_size == 2) {
+ __GLX_SWAP_SHORT(p);
+ }
+ else if (swap_vec_element_size == 4) {
+ __GLX_SWAP_INT(p);
+ }
+ else if (swap_vec_element_size == 8) {
+ __GLX_SWAP_DOUBLE(p);
+ }
+
+ p += swap_vec_element_size;
+ }
+
+ __GLX_SWAP_INT(&reply->pad3);
+ __GLX_SWAP_INT(&reply->pad4);
+ __GLX_SWAP_INT(&reply->pad5);
+ __GLX_SWAP_INT(&reply->pad6);
+
+ }
+
+ WriteToClient(client, sizeof(xGLXVendorPrivReply),(char *)reply);
+ if (buf_size > 0)
+ WriteToClient(client, buf_size, (char *)buf);
+
+}
+
+int __glXVForwardSingleReq( __GLXclientState *cl, GLbyte *pc )
+{
+ xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
+ xGLXVendorPrivateReq *be_req;
+ __GLXcontext *glxc;
+ int from_screen = 0;
+ int to_screen = 0;
+ int buf_size;
+ int s;
+
+ glxc = __glXLookupContextByTag(cl, req->contextTag);
+ if (!glxc) {
+ return 0;
+ }
+ from_screen = to_screen = glxc->pScreen->myNum;
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ from_screen = 0;
+ to_screen = screenInfo.numScreens - 1;
+ }
+#endif
+
+ pc += sz_xGLXVendorPrivateReq;
+ buf_size = (req->length << 2) - sz_xGLXVendorPrivateReq;
+
+ /*
+ * just forward the request to back-end server(s)
+ */
+ for (s=from_screen; s<=to_screen; s++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[s];
+ Display *dpy = GetBackEndDisplay(cl,s);
+
+ LockDisplay(dpy);
+ GetReqVendorPrivate(GLXVendorPrivate,be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = req->glxCode;
+ be_req->length = req->length;
+ be_req->vendorCode = req->vendorCode;
+ be_req->contextTag = GetCurrentBackEndTag(cl,req->contextTag,s);
+ if (buf_size > 0)
+ _XSend(dpy, (const char *)pc, buf_size);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ }
+
+ return Success;
+}
+
+int __glXVForwardPipe0WithReply( __GLXclientState *cl, GLbyte *pc )
+{
+ ClientPtr client = cl->client;
+ xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
+ xGLXVendorPrivateReq *be_req;
+ xGLXVendorPrivReply reply;
+ xGLXVendorPrivReply be_reply;
+ __GLXcontext *glxc;
+ int buf_size;
+ char *be_buf = NULL;
+ int be_buf_size;
+ DMXScreenInfo *dmxScreen;
+ Display *dpy;
+
+ glxc = __glXLookupContextByTag(cl, req->contextTag);
+ if (!glxc) {
+ return __glXBadContext;
+ }
+
+ pc += sz_xGLXVendorPrivateReq;
+ buf_size = (req->length << 2) - sz_xGLXVendorPrivateReq;
+
+ dmxScreen = &dmxScreens[glxc->pScreen->myNum];
+ dpy = GetBackEndDisplay(cl, glxc->pScreen->myNum);
+
+ /*
+ * send the request to the first back-end server
+ */
+ LockDisplay(dpy);
+ GetReqVendorPrivate(GLXVendorPrivate,be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = req->glxCode;
+ be_req->length = req->length;
+ be_req->vendorCode = req->vendorCode;
+ be_req->contextTag = GetCurrentBackEndTag(cl,req->contextTag, glxc->pScreen->myNum);
+ if (buf_size > 0)
+ _XSend(dpy, (const char *)pc, buf_size);
+
+ /*
+ * get the reply from the back-end server
+ */
+ _XReply(dpy, (xReply*) &be_reply, 0, False);
+ be_buf_size = be_reply.length << 2;
+ if (be_buf_size > 0) {
+ be_buf = (char *)malloc( be_buf_size );
+ if (be_buf) {
+ _XRead(dpy, be_buf, be_buf_size);
+ }
+ else {
+ /* Throw data on the floor */
+ _XEatData(dpy, be_buf_size);
+ return BadAlloc;
+ }
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ /*
+ * send the reply to the client
+ */
+ memcpy( &reply, &be_reply, sz_xGLXVendorPrivReply );
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+
+ if (client->swapped) {
+ SendSwappedReply( client, &reply, be_buf, be_buf_size );
+ }
+ else {
+ WriteToClient(client, sizeof(xGLXVendorPrivReply),(char *)&reply);
+ if (be_buf_size > 0)
+ WriteToClient(client, be_buf_size, (char *)be_buf);
+ }
+
+ if (be_buf_size > 0) free(be_buf);
+
+ return Success;
+}
+
+int __glXVForwardAllWithReply( __GLXclientState *cl, GLbyte *pc )
+{
+ ClientPtr client = cl->client;
+ xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
+ xGLXVendorPrivateReq *be_req;
+ xGLXVendorPrivReply reply;
+ xGLXVendorPrivReply be_reply;
+ __GLXcontext *glxc;
+ int buf_size;
+ char *be_buf = NULL;
+ int be_buf_size = 0;
+ int from_screen = 0;
+ int to_screen = 0;
+ int s;
+
+ DMXScreenInfo *dmxScreen;
+ Display *dpy;
+
+ glxc = __glXLookupContextByTag(cl, req->contextTag);
+ if (!glxc) {
+ return 0;
+ }
+ from_screen = to_screen = glxc->pScreen->myNum;
+
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ from_screen = 0;
+ to_screen = screenInfo.numScreens - 1;
+ }
+#endif
+
+ pc += sz_xGLXVendorPrivateReq;
+ buf_size = (req->length << 2) - sz_xGLXVendorPrivateReq;
+
+ /*
+ * send the request to the first back-end server(s)
+ */
+ for (s=to_screen; s>=from_screen; s--) {
+ dmxScreen = &dmxScreens[s];
+ dpy = GetBackEndDisplay(cl,s);
+
+ LockDisplay(dpy);
+ GetReqVendorPrivate(GLXVendorPrivate,be_req);
+ be_req->reqType = dmxScreen->glxMajorOpcode;
+ be_req->glxCode = req->glxCode;
+ be_req->length = req->length;
+ be_req->vendorCode = req->vendorCode;
+ be_req->contextTag = GetCurrentBackEndTag(cl,req->contextTag,s);
+ if (buf_size > 0)
+ _XSend(dpy, (const char *)pc, buf_size);
+
+ /*
+ * get the reply from the back-end server
+ */
+ _XReply(dpy, (xReply*) &be_reply, 0, False);
+ be_buf_size = be_reply.length << 2;
+ if (be_buf_size > 0) {
+ be_buf = (char *)malloc( be_buf_size );
+ if (be_buf) {
+ _XRead(dpy, be_buf, be_buf_size);
+ }
+ else {
+ /* Throw data on the floor */
+ _XEatData(dpy, be_buf_size);
+ return BadAlloc;
+ }
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ if (s > from_screen && be_buf_size > 0) {
+ free(be_buf);
+ }
+ }
+
+ /*
+ * send the reply to the client
+ */
+ memcpy( &reply, &be_reply, sz_xGLXVendorPrivReply );
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+
+ if (client->swapped) {
+ SendSwappedReply( client, &reply, be_buf, be_buf_size );
+ }
+ else {
+ WriteToClient(client, sizeof(xGLXVendorPrivReply),(char *)&reply);
+ if (be_buf_size > 0)
+ WriteToClient(client, be_buf_size, (char *)be_buf);
+ }
+
+ if (be_buf_size > 0) free(be_buf);
+
+ return Success;
+}
+
+int __glXVForwardSingleReqSwap( __GLXclientState *cl, GLbyte *pc )
+{
+ xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->vendorCode);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ swap_vec_element_size = 0;
+
+ return( __glXVForwardSingleReq( cl, pc ) );
+}
+
+int __glXVForwardPipe0WithReplySwap( __GLXclientState *cl, GLbyte *pc )
+{
+ xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->vendorCode);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ swap_vec_element_size = 0;
+
+ /*
+ * swap extra data in request - assuming all data
+ * (if available) are arrays of 4 bytes components !
+ */
+ if (req->length > sz_xGLXVendorPrivateReq/4) {
+ int *data = (int *)(req+1);
+ int count = req->length - sz_xGLXVendorPrivateReq/4;
+ __GLX_SWAP_INT_ARRAY(data, count );
+ }
+
+ return( __glXVForwardPipe0WithReply( cl, pc ) );
+}
+
+int __glXVForwardPipe0WithReplySwapsv( __GLXclientState *cl, GLbyte *pc )
+{
+ xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->vendorCode);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ swap_vec_element_size = 2;
+
+ /*
+ * swap extra data in request - assuming all data
+ * (if available) are arrays of 4 bytes components !
+ */
+ if (req->length > sz_xGLXVendorPrivateReq/4) {
+ int *data = (int *)(req+1);
+ int count = req->length - sz_xGLXVendorPrivateReq/4;
+ __GLX_SWAP_INT_ARRAY(data, count );
+ }
+
+ return( __glXVForwardPipe0WithReply( cl, pc ) );
+}
+
+int __glXVForwardPipe0WithReplySwapiv( __GLXclientState *cl, GLbyte *pc )
+{
+ xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->vendorCode);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ swap_vec_element_size = 4;
+
+ /*
+ * swap extra data in request - assuming all data
+ * (if available) are arrays of 4 bytes components !
+ */
+ if (req->length > sz_xGLXVendorPrivateReq/4) {
+ int *data = (int *)(req+1);
+ int count = req->length - sz_xGLXVendorPrivateReq/4;
+ __GLX_SWAP_INT_ARRAY(data, count );
+ }
+
+ return( __glXVForwardPipe0WithReply( cl, pc ) );
+}
+
+int __glXVForwardPipe0WithReplySwapdv( __GLXclientState *cl, GLbyte *pc )
+{
+ xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->vendorCode);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ swap_vec_element_size = 8;
+
+ /*
+ * swap extra data in request - assuming all data
+ * (if available) are arrays of 4 bytes components !
+ */
+ if (req->length > sz_xGLXVendorPrivateReq/4) {
+ int *data = (int *)(req+1);
+ int count = req->length - sz_xGLXVendorPrivateReq/4;
+ __GLX_SWAP_INT_ARRAY(data, count );
+ }
+
+ return( __glXVForwardPipe0WithReply( cl, pc ) );
+}
+
+int __glXVForwardAllWithReplySwap( __GLXclientState *cl, GLbyte *pc )
+{
+ xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->vendorCode);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ swap_vec_element_size = 0;
+
+ /*
+ * swap extra data in request - assuming all data
+ * (if available) are arrays of 4 bytes components !
+ */
+ if (req->length > sz_xGLXVendorPrivateReq/4) {
+ int *data = (int *)(req+1);
+ int count = req->length - sz_xGLXVendorPrivateReq/4;
+ __GLX_SWAP_INT_ARRAY(data, count );
+ }
+
+ return( __glXVForwardAllWithReply( cl, pc ) );
+}
+
+int __glXVForwardAllWithReplySwapsv( __GLXclientState *cl, GLbyte *pc )
+{
+ xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->vendorCode);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ swap_vec_element_size = 2;
+
+ /*
+ * swap extra data in request - assuming all data
+ * (if available) are arrays of 4 bytes components !
+ */
+ if (req->length > sz_xGLXVendorPrivateReq/4) {
+ int *data = (int *)(req+1);
+ int count = req->length - sz_xGLXVendorPrivateReq/4;
+ __GLX_SWAP_INT_ARRAY(data, count );
+ }
+
+ return( __glXVForwardAllWithReply( cl, pc ) );
+}
+
+int __glXVForwardAllWithReplySwapiv( __GLXclientState *cl, GLbyte *pc )
+{
+ xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->vendorCode);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ swap_vec_element_size = 4;
+
+ /*
+ * swap extra data in request - assuming all data
+ * (if available) are arrays of 4 bytes components !
+ */
+ if (req->length > sz_xGLXVendorPrivateReq/4) {
+ int *data = (int *)(req+1);
+ int count = req->length - sz_xGLXVendorPrivateReq/4;
+ __GLX_SWAP_INT_ARRAY(data, count );
+ }
+
+ return( __glXVForwardAllWithReply( cl, pc ) );
+}
+
+int __glXVForwardAllWithReplySwapdv( __GLXclientState *cl, GLbyte *pc )
+{
+ xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *)pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_SHORT(&req->length);
+ __GLX_SWAP_INT(&req->vendorCode);
+ __GLX_SWAP_INT(&req->contextTag);
+
+ swap_vec_element_size = 8;
+
+ /*
+ * swap extra data in request - assuming all data
+ * (if available) are arrays of 4 bytes components !
+ */
+ if (req->length > sz_xGLXVendorPrivateReq/4) {
+ int *data = (int *)(req+1);
+ int count = req->length - sz_xGLXVendorPrivateReq/4;
+ __GLX_SWAP_INT_ARRAY(data, count );
+ }
+
+ return( __glXVForwardAllWithReply( cl, pc ) );
+}
+
diff --git a/xorg-server/hw/dmx/glxProxy/render2swap.c b/xorg-server/hw/dmx/glxProxy/render2swap.c
index 70ed5e802..81bb501ea 100644
--- a/xorg-server/hw/dmx/glxProxy/render2swap.c
+++ b/xorg-server/hw/dmx/glxProxy/render2swap.c
@@ -1,286 +1,286 @@
-/*
- * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
- * Copyright (C) 1991-2000 Silicon Graphics, 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 including the dates of first publication and
- * either this permission notice or a reference to
- * http://oss.sgi.com/projects/FreeB/
- * 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
- * SILICON GRAPHICS, INC. 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 Silicon Graphics, Inc.
- * shall not be used in advertising or otherwise to promote the sale, use or
- * other dealings in this Software without prior written authorization from
- * Silicon Graphics, Inc.
- */
-
-#include "glxserver.h"
-#include "unpack.h"
-#include "g_disptab.h"
-
-GLint __glEvalComputeK(GLenum target)
-{
- switch (target) {
- case GL_MAP1_VERTEX_4:
- case GL_MAP1_COLOR_4:
- case GL_MAP1_TEXTURE_COORD_4:
- case GL_MAP2_VERTEX_4:
- case GL_MAP2_COLOR_4:
- case GL_MAP2_TEXTURE_COORD_4:
- return 4;
- case GL_MAP1_VERTEX_3:
- case GL_MAP1_TEXTURE_COORD_3:
- case GL_MAP1_NORMAL:
- case GL_MAP2_VERTEX_3:
- case GL_MAP2_TEXTURE_COORD_3:
- case GL_MAP2_NORMAL:
- return 3;
- case GL_MAP1_TEXTURE_COORD_2:
- case GL_MAP2_TEXTURE_COORD_2:
- return 2;
- case GL_MAP1_TEXTURE_COORD_1:
- case GL_MAP2_TEXTURE_COORD_1:
- case GL_MAP1_INDEX:
- case GL_MAP2_INDEX:
- return 1;
- default:
- return 0;
- }
-}
-
-void __glXDispSwap_Map1f(GLbyte *pc)
-{
- GLint order, k;
- GLfloat u1, u2, *points;
- GLenum target;
- GLint compsize;
- __GLX_DECLARE_SWAP_VARIABLES;
- __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
-
- __GLX_SWAP_INT(pc + 0);
- __GLX_SWAP_INT(pc + 12);
- __GLX_SWAP_FLOAT(pc + 4);
- __GLX_SWAP_FLOAT(pc + 8);
-
- target = *(GLenum *)(pc + 0);
- order = *(GLint *)(pc + 12);
- u1 = *(GLfloat *)(pc + 4);
- u2 = *(GLfloat *)(pc + 8);
- points = (GLfloat *)(pc + 16);
- k = __glEvalComputeK(target);
-
- if (order <= 0 || k < 0) {
- /* Erroneous command. */
- compsize = 0;
- } else {
- compsize = order * k;
- }
- __GLX_SWAP_FLOAT_ARRAY(points, compsize);
-
-}
-
-void __glXDispSwap_Map2f(GLbyte *pc)
-{
- GLint uorder, vorder, ustride, vstride, k;
- GLfloat u1, u2, v1, v2, *points;
- GLenum target;
- GLint compsize;
- __GLX_DECLARE_SWAP_VARIABLES;
- __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
-
- __GLX_SWAP_INT(pc + 0);
- __GLX_SWAP_INT(pc + 12);
- __GLX_SWAP_INT(pc + 24);
- __GLX_SWAP_FLOAT(pc + 4);
- __GLX_SWAP_FLOAT(pc + 8);
- __GLX_SWAP_FLOAT(pc + 16);
- __GLX_SWAP_FLOAT(pc + 20);
-
- target = *(GLenum *)(pc + 0);
- uorder = *(GLint *)(pc + 12);
- vorder = *(GLint *)(pc + 24);
- u1 = *(GLfloat *)(pc + 4);
- u2 = *(GLfloat *)(pc + 8);
- v1 = *(GLfloat *)(pc + 16);
- v2 = *(GLfloat *)(pc + 20);
- points = (GLfloat *)(pc + 28);
-
- k = __glEvalComputeK(target);
- ustride = vorder * k;
- vstride = k;
-
- if (vorder <= 0 || uorder <= 0 || k < 0) {
- /* Erroneous command. */
- compsize = 0;
- } else {
- compsize = uorder * vorder * k;
- }
- __GLX_SWAP_FLOAT_ARRAY(points, compsize);
-
-}
-
-void __glXDispSwap_Map1d(GLbyte *pc)
-{
- GLint order, k, compsize;
- GLenum target;
- GLdouble u1, u2, *points;
- __GLX_DECLARE_SWAP_VARIABLES;
- __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
-
- __GLX_SWAP_DOUBLE(pc + 0);
- __GLX_SWAP_DOUBLE(pc + 8);
- __GLX_SWAP_INT(pc + 16);
- __GLX_SWAP_INT(pc + 20);
-
- target = *(GLenum*) (pc + 16);
- order = *(GLint*) (pc + 20);
- k = __glEvalComputeK(target);
- if (order <= 0 || k < 0) {
- /* Erroneous command. */
- compsize = 0;
- } else {
- compsize = order * k;
- }
- __GLX_GET_DOUBLE(u1,pc);
- __GLX_GET_DOUBLE(u2,pc+8);
- __GLX_SWAP_DOUBLE_ARRAY(pc+24, compsize);
- pc += 24;
-
-#ifdef __GLX_ALIGN64
- if (((unsigned long)pc) & 7) {
- /*
- ** Copy the doubles up 4 bytes, trashing the command but aligning
- ** the data in the process
- */
- __GLX_MEM_COPY(pc-4, pc, compsize*8);
- points = (GLdouble*) (pc - 4);
- } else {
- points = (GLdouble*) pc;
- }
-#else
- points = (GLdouble*) pc;
-#endif
-}
-
-void __glXDispSwap_Map2d(GLbyte *pc)
-{
- GLdouble u1, u2, v1, v2, *points;
- GLint uorder, vorder, ustride, vstride, k, compsize;
- GLenum target;
- __GLX_DECLARE_SWAP_VARIABLES;
- __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
-
- __GLX_SWAP_DOUBLE(pc + 0);
- __GLX_SWAP_DOUBLE(pc + 8);
- __GLX_SWAP_DOUBLE(pc + 16);
- __GLX_SWAP_DOUBLE(pc + 24);
- __GLX_SWAP_INT(pc + 32);
- __GLX_SWAP_INT(pc + 36);
- __GLX_SWAP_INT(pc + 40);
-
- target = *(GLenum *)(pc + 32);
- uorder = *(GLint *)(pc + 36);
- vorder = *(GLint *)(pc + 40);
- k = __glEvalComputeK(target);
- if (vorder <= 0 || uorder <= 0 || k < 0) {
- /* Erroneous command. */
- compsize = 0;
- } else {
- compsize = uorder * vorder * k;
- }
- __GLX_GET_DOUBLE(u1,pc);
- __GLX_GET_DOUBLE(u2,pc+8);
- __GLX_GET_DOUBLE(v1,pc+16);
- __GLX_GET_DOUBLE(v2,pc+24);
- __GLX_SWAP_DOUBLE_ARRAY(pc+44, compsize);
- pc += 44;
- ustride = vorder * k;
- vstride = k;
-
-#ifdef __GLX_ALIGN64
- if (((unsigned long)pc) & 7) {
- /*
- ** Copy the doubles up 4 bytes, trashing the command but aligning
- ** the data in the process
- */
- __GLX_MEM_COPY(pc-4, pc, compsize*8);
- points = (GLdouble*) (pc - 4);
- } else {
- points = (GLdouble*) pc;
- }
-#else
- points = (GLdouble*) pc;
-#endif
-}
-
-void __glXDispSwap_CallLists(GLbyte *pc)
-{
- GLenum type;
- GLsizei n;
- __GLX_DECLARE_SWAP_VARIABLES;
- __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
-
- __GLX_SWAP_INT(pc + 4);
- __GLX_SWAP_INT(pc + 0);
- type = *(GLenum *)(pc + 4);
- n = *(GLsizei *)(pc + 0);
-
- switch (type) {
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- case GL_2_BYTES:
- case GL_3_BYTES:
- case GL_4_BYTES:
- break;
- case GL_SHORT:
- case GL_UNSIGNED_SHORT:
- __GLX_SWAP_SHORT_ARRAY(pc+8, n);
- break;
- case GL_INT:
- case GL_UNSIGNED_INT:
- __GLX_SWAP_INT_ARRAY(pc+8, n);
- break;
- case GL_FLOAT:
- __GLX_SWAP_FLOAT_ARRAY(pc+8, n);
- break;
- }
-
-}
-
-void __glXDispSwap_DrawArrays(GLbyte *pc)
-{
- __GLXdispatchDrawArraysHeader *hdr = (__GLXdispatchDrawArraysHeader *)pc;
- __GLXdispatchDrawArraysComponentHeader *compHeader;
- int i;
- __GLX_DECLARE_SWAP_VARIABLES;
-
- __GLX_SWAP_INT(&hdr->numVertexes);
- __GLX_SWAP_INT(&hdr->numComponents);
- __GLX_SWAP_INT(&hdr->primType);
-
- pc += sizeof(__GLXdispatchDrawArraysHeader);
- compHeader = (__GLXdispatchDrawArraysComponentHeader *) pc;
-
- /* compute stride (same for all component arrays) */
- for (i=0; i<hdr->numComponents; i++) {
- __GLX_SWAP_INT(&compHeader[i].datatype);
- __GLX_SWAP_INT(&compHeader[i].numVals);
- __GLX_SWAP_INT(&compHeader[i].component);
-
- }
-
-}
+/*
+ * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
+ * Copyright (C) 1991-2000 Silicon Graphics, 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 including the dates of first publication and
+ * either this permission notice or a reference to
+ * http://oss.sgi.com/projects/FreeB/
+ * 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
+ * SILICON GRAPHICS, INC. 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 Silicon Graphics, Inc.
+ * shall not be used in advertising or otherwise to promote the sale, use or
+ * other dealings in this Software without prior written authorization from
+ * Silicon Graphics, Inc.
+ */
+
+#include "glxserver.h"
+#include "unpack.h"
+#include "g_disptab.h"
+
+GLint __glEvalComputeK(GLenum target)
+{
+ switch (target) {
+ case GL_MAP1_VERTEX_4:
+ case GL_MAP1_COLOR_4:
+ case GL_MAP1_TEXTURE_COORD_4:
+ case GL_MAP2_VERTEX_4:
+ case GL_MAP2_COLOR_4:
+ case GL_MAP2_TEXTURE_COORD_4:
+ return 4;
+ case GL_MAP1_VERTEX_3:
+ case GL_MAP1_TEXTURE_COORD_3:
+ case GL_MAP1_NORMAL:
+ case GL_MAP2_VERTEX_3:
+ case GL_MAP2_TEXTURE_COORD_3:
+ case GL_MAP2_NORMAL:
+ return 3;
+ case GL_MAP1_TEXTURE_COORD_2:
+ case GL_MAP2_TEXTURE_COORD_2:
+ return 2;
+ case GL_MAP1_TEXTURE_COORD_1:
+ case GL_MAP2_TEXTURE_COORD_1:
+ case GL_MAP1_INDEX:
+ case GL_MAP2_INDEX:
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+void __glXDispSwap_Map1f(GLbyte *pc)
+{
+ GLint order, k;
+ GLfloat u1, u2, *points;
+ GLenum target;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 12);
+ __GLX_SWAP_FLOAT(pc + 4);
+ __GLX_SWAP_FLOAT(pc + 8);
+
+ target = *(GLenum *)(pc + 0);
+ order = *(GLint *)(pc + 12);
+ u1 = *(GLfloat *)(pc + 4);
+ u2 = *(GLfloat *)(pc + 8);
+ points = (GLfloat *)(pc + 16);
+ k = __glEvalComputeK(target);
+
+ if (order <= 0 || k < 0) {
+ /* Erroneous command. */
+ compsize = 0;
+ } else {
+ compsize = order * k;
+ }
+ __GLX_SWAP_FLOAT_ARRAY(points, compsize);
+
+}
+
+void __glXDispSwap_Map2f(GLbyte *pc)
+{
+ GLint uorder, vorder, ustride, vstride, k;
+ GLfloat u1, u2, v1, v2, *points;
+ GLenum target;
+ GLint compsize;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 0);
+ __GLX_SWAP_INT(pc + 12);
+ __GLX_SWAP_INT(pc + 24);
+ __GLX_SWAP_FLOAT(pc + 4);
+ __GLX_SWAP_FLOAT(pc + 8);
+ __GLX_SWAP_FLOAT(pc + 16);
+ __GLX_SWAP_FLOAT(pc + 20);
+
+ target = *(GLenum *)(pc + 0);
+ uorder = *(GLint *)(pc + 12);
+ vorder = *(GLint *)(pc + 24);
+ u1 = *(GLfloat *)(pc + 4);
+ u2 = *(GLfloat *)(pc + 8);
+ v1 = *(GLfloat *)(pc + 16);
+ v2 = *(GLfloat *)(pc + 20);
+ points = (GLfloat *)(pc + 28);
+
+ k = __glEvalComputeK(target);
+ ustride = vorder * k;
+ vstride = k;
+
+ if (vorder <= 0 || uorder <= 0 || k < 0) {
+ /* Erroneous command. */
+ compsize = 0;
+ } else {
+ compsize = uorder * vorder * k;
+ }
+ __GLX_SWAP_FLOAT_ARRAY(points, compsize);
+
+}
+
+void __glXDispSwap_Map1d(GLbyte *pc)
+{
+ GLint order, k, compsize;
+ GLenum target;
+ GLdouble u1, u2, *points;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_DOUBLE(pc + 0);
+ __GLX_SWAP_DOUBLE(pc + 8);
+ __GLX_SWAP_INT(pc + 16);
+ __GLX_SWAP_INT(pc + 20);
+
+ target = *(GLenum*) (pc + 16);
+ order = *(GLint*) (pc + 20);
+ k = __glEvalComputeK(target);
+ if (order <= 0 || k < 0) {
+ /* Erroneous command. */
+ compsize = 0;
+ } else {
+ compsize = order * k;
+ }
+ __GLX_GET_DOUBLE(u1,pc);
+ __GLX_GET_DOUBLE(u2,pc+8);
+ __GLX_SWAP_DOUBLE_ARRAY(pc+24, compsize);
+ pc += 24;
+
+#ifdef __GLX_ALIGN64
+ if (((unsigned long)pc) & 7) {
+ /*
+ ** Copy the doubles up 4 bytes, trashing the command but aligning
+ ** the data in the process
+ */
+ __GLX_MEM_COPY(pc-4, pc, compsize*8);
+ points = (GLdouble*) (pc - 4);
+ } else {
+ points = (GLdouble*) pc;
+ }
+#else
+ points = (GLdouble*) pc;
+#endif
+}
+
+void __glXDispSwap_Map2d(GLbyte *pc)
+{
+ GLdouble u1, u2, v1, v2, *points;
+ GLint uorder, vorder, ustride, vstride, k, compsize;
+ GLenum target;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_DOUBLE(pc + 0);
+ __GLX_SWAP_DOUBLE(pc + 8);
+ __GLX_SWAP_DOUBLE(pc + 16);
+ __GLX_SWAP_DOUBLE(pc + 24);
+ __GLX_SWAP_INT(pc + 32);
+ __GLX_SWAP_INT(pc + 36);
+ __GLX_SWAP_INT(pc + 40);
+
+ target = *(GLenum *)(pc + 32);
+ uorder = *(GLint *)(pc + 36);
+ vorder = *(GLint *)(pc + 40);
+ k = __glEvalComputeK(target);
+ if (vorder <= 0 || uorder <= 0 || k < 0) {
+ /* Erroneous command. */
+ compsize = 0;
+ } else {
+ compsize = uorder * vorder * k;
+ }
+ __GLX_GET_DOUBLE(u1,pc);
+ __GLX_GET_DOUBLE(u2,pc+8);
+ __GLX_GET_DOUBLE(v1,pc+16);
+ __GLX_GET_DOUBLE(v2,pc+24);
+ __GLX_SWAP_DOUBLE_ARRAY(pc+44, compsize);
+ pc += 44;
+ ustride = vorder * k;
+ vstride = k;
+
+#ifdef __GLX_ALIGN64
+ if (((unsigned long)pc) & 7) {
+ /*
+ ** Copy the doubles up 4 bytes, trashing the command but aligning
+ ** the data in the process
+ */
+ __GLX_MEM_COPY(pc-4, pc, compsize*8);
+ points = (GLdouble*) (pc - 4);
+ } else {
+ points = (GLdouble*) pc;
+ }
+#else
+ points = (GLdouble*) pc;
+#endif
+}
+
+void __glXDispSwap_CallLists(GLbyte *pc)
+{
+ GLenum type;
+ GLsizei n;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ __GLX_SWAP_INT(pc + 4);
+ __GLX_SWAP_INT(pc + 0);
+ type = *(GLenum *)(pc + 4);
+ n = *(GLsizei *)(pc + 0);
+
+ switch (type) {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ case GL_2_BYTES:
+ case GL_3_BYTES:
+ case GL_4_BYTES:
+ break;
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ __GLX_SWAP_SHORT_ARRAY(pc+8, n);
+ break;
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ __GLX_SWAP_INT_ARRAY(pc+8, n);
+ break;
+ case GL_FLOAT:
+ __GLX_SWAP_FLOAT_ARRAY(pc+8, n);
+ break;
+ }
+
+}
+
+void __glXDispSwap_DrawArrays(GLbyte *pc)
+{
+ __GLXdispatchDrawArraysHeader *hdr = (__GLXdispatchDrawArraysHeader *)pc;
+ __GLXdispatchDrawArraysComponentHeader *compHeader;
+ int i;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_INT(&hdr->numVertexes);
+ __GLX_SWAP_INT(&hdr->numComponents);
+ __GLX_SWAP_INT(&hdr->primType);
+
+ pc += sizeof(__GLXdispatchDrawArraysHeader);
+ compHeader = (__GLXdispatchDrawArraysComponentHeader *) pc;
+
+ /* compute stride (same for all component arrays) */
+ for (i=0; i<hdr->numComponents; i++) {
+ __GLX_SWAP_INT(&compHeader[i].datatype);
+ __GLX_SWAP_INT(&compHeader[i].numVals);
+ __GLX_SWAP_INT(&compHeader[i].component);
+
+ }
+
+}
diff --git a/xorg-server/hw/dmx/input/dmxevents.c b/xorg-server/hw/dmx/input/dmxevents.c
index 4e1238c9f..41bc4bf2d 100644
--- a/xorg-server/hw/dmx/input/dmxevents.c
+++ b/xorg-server/hw/dmx/input/dmxevents.c
@@ -1,766 +1,766 @@
-/*
- * Copyright 2002-2003 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:
- * Rickard E. (Rik) Faith <faith@redhat.com>
- *
- */
-
-/** \file
- * Provide support and helper functions for enqueing events received by
- * the low-level input drivers. */
-
-#ifdef HAVE_DMX_CONFIG_H
-#include <dmx-config.h>
-#endif
-
-#define DMX_EVENTS_DEBUG 0
-
-#include "dmxinputinit.h"
-#include "dmxevents.h"
-#include "dmxcb.h"
-#include "dmxcommon.h"
-#include "dmxcursor.h"
-#include "dmxmotion.h"
-#include "dmxsigio.h"
-#include "dmxmap.h"
-
-#include <X11/keysym.h>
-#include "opaque.h"
-#include "inputstr.h"
-#include "inpututils.h"
-#include "mipointer.h"
-#include "mi.h"
-#include "exglobals.h"
-
-#include "xkbsrv.h"
-#include "XIstubs.h"
-
-static int dmxGlobalX, dmxGlobalY; /* Global cursor position */
-static int dmxGlobalInvalid; /* Flag indicating dmxCoreMotion
- * should move the mouse anyway. */
-
-#if DMX_EVENTS_DEBUG
-#define DMXDBG0(f) dmxLog(dmxDebug,f)
-#define DMXDBG1(f,a) dmxLog(dmxDebug,f,a)
-#define DMXDBG2(f,a,b) dmxLog(dmxDebug,f,a,b)
-#define DMXDBG3(f,a,b,c) dmxLog(dmxDebug,f,a,b,c)
-#define DMXDBG4(f,a,b,c,d) dmxLog(dmxDebug,f,a,b,c,d)
-#define DMXDBG5(f,a,b,c,d,e) dmxLog(dmxDebug,f,a,b,c,d,e)
-#define DMXDBG6(f,a,b,c,d,e,g) dmxLog(dmxDebug,f,a,b,c,d,e,g)
-#define DMXDBG7(f,a,b,c,d,e,g,h) dmxLog(dmxDebug,f,a,b,c,d,e,g,h)
-#else
-#define DMXDBG0(f)
-#define DMXDBG1(f,a)
-#define DMXDBG2(f,a,b)
-#define DMXDBG3(f,a,b,c)
-#define DMXDBG4(f,a,b,c,d)
-#define DMXDBG5(f,a,b,c,d,e)
-#define DMXDBG6(f,a,b,c,d,e,g)
-#define DMXDBG7(f,a,b,c,d,e,g,h)
-#endif
-
-static int dmxApplyFunctions(DMXInputInfo *dmxInput, DMXFunctionType f)
-{
- int i;
- int rc = 0;
-
- for (i = 0; i < dmxInput->numDevs; i+= dmxInput->devs[i]->binding)
- if (dmxInput->devs[i]->functions)
- rc += dmxInput->devs[i]->functions(dmxInput->devs[i]->private, f);
- return rc;
-}
-
-static int dmxCheckFunctionKeys(DMXLocalInputInfoPtr dmxLocal,
- int type,
- KeySym keySym)
-{
- DMXInputInfo *dmxInput = &dmxInputs[dmxLocal->inputIdx];
-
-#if 1 /* hack to detect ctrl-alt-q, etc */
- static int ctrl = 0, alt = 0;
- /* keep track of ctrl/alt key status */
- if (type == KeyPress && keySym == 0xffe3) {
- ctrl = 1;
- }
- else if (type == KeyRelease && keySym == 0xffe3) {
- ctrl = 0;
- }
- else if (type == KeyPress && keySym == 0xffe9) {
- alt = 1;
- }
- else if (type == KeyRelease && keySym == 0xffe9) {
- alt = 0;
- }
- if (!ctrl || !alt)
- return 0;
-#else
- unsigned short state = 0;
-
- if (dmxLocal->sendsCore)
- state = dmxLocalCoreKeyboard->pDevice->key->state;
- else if (dmxLocal->pDevice->key)
- state = dmxLocal->pDevice->key->state;
-
- DMXDBG3("dmxCheckFunctionKeys: keySym=0x%04x %s state=0x%04x\n",
- keySym, type == KeyPress ? "press" : "release", state);
-
- if ((state & (ControlMask|Mod1Mask)) != (ControlMask|Mod1Mask))
- return 0;
-#endif
-
- switch (keySym) {
- case XK_g:
- if (type == KeyPress)
- dmxApplyFunctions(dmxInput, DMX_FUNCTION_GRAB);
- return 1;
- case XK_f:
- if (type == KeyPress)
- dmxApplyFunctions(dmxInput, DMX_FUNCTION_FINE);
- return 1;
- case XK_q:
- if (type == KeyPress && dmxLocal->sendsCore)
- if (dmxApplyFunctions(dmxInput, DMX_FUNCTION_TERMINATE)) {
- dmxLog(dmxInfo, "User request for termination\n");
- dispatchException |= DE_TERMINATE;
- }
- return 1;
- }
-
- return 0;
-}
-
-
-DMXScreenInfo *dmxFindFirstScreen(int x, int y)
-{
- int i;
-
- for (i = 0; i < dmxNumScreens; i++) {
- DMXScreenInfo *dmxScreen = &dmxScreens[i];
- if (dmxOnScreen(x, y, dmxScreen))
- return dmxScreen;
- }
- return NULL;
-}
-
-
-/**
- * Enqueue a motion event.
- */
-static void enqueueMotion(DevicePtr pDev, int x, int y)
-{
- GETDMXLOCALFROMPDEV;
- DeviceIntPtr p = dmxLocal->pDevice;
- int valuators[3];
- int detail = 0; /* XXX should this be mask of pressed buttons? */
- ValuatorMask mask;
- valuators[0] = x;
- valuators[1] = y;
-
- valuator_mask_set_range(&mask, 0, 2, valuators);
- QueuePointerEvents(p, MotionNotify, detail,
- POINTER_ABSOLUTE | POINTER_SCREEN, &mask);
- return;
-}
-
-
-void
-dmxCoreMotion(DevicePtr pDev, int x, int y, int delta, DMXBlockType block)
-{
- DMXScreenInfo *dmxScreen;
- DMXInputInfo *dmxInput;
- ScreenPtr pScreen;
- int localX;
- int localY;
- int i;
-
- if (!dmxGlobalInvalid && dmxGlobalX == x && dmxGlobalY == y)
- return;
-
- DMXDBG5("dmxCoreMotion(%d,%d,%d) dmxGlobalX=%d dmxGlobalY=%d\n",
- x, y, delta, dmxGlobalX, dmxGlobalY);
-
- dmxGlobalInvalid = 0;
- dmxGlobalX = x;
- dmxGlobalY = y;
-
- if (dmxGlobalX < 0)
- dmxGlobalX = 0;
- if (dmxGlobalY < 0)
- dmxGlobalY = 0;
- if (dmxGlobalX >= dmxGlobalWidth)
- dmxGlobalX = dmxGlobalWidth + delta -1;
- if (dmxGlobalY >= dmxGlobalHeight)
- dmxGlobalY = dmxGlobalHeight + delta -1;
-
- if ((dmxScreen = dmxFindFirstScreen(dmxGlobalX, dmxGlobalY))) {
- localX = dmxGlobalX - dmxScreen->rootXOrigin;
- localY = dmxGlobalY - dmxScreen->rootYOrigin;
- if ((pScreen = miPointerGetScreen(inputInfo.pointer))
- && pScreen->myNum == dmxScreen->index) {
- /* Screen is old screen */
- if (block)
- dmxSigioBlock();
- if (pDev)
- enqueueMotion(pDev, localX, localY);
- if (block)
- dmxSigioUnblock();
- } else {
- /* Screen is new */
- DMXDBG4(" New screen: old=%d new=%d localX=%d localY=%d\n",
- pScreen->myNum, dmxScreen->index, localX, localY);
- if (block)
- dmxSigioBlock();
- mieqProcessInputEvents();
- miPointerSetScreen(inputInfo.pointer, dmxScreen->index,
- localX, localY);
- if (pDev)
- enqueueMotion(pDev, localX, localY);
- if (block)
- dmxSigioUnblock();
- }
-#if 00
- miPointerGetPosition(inputInfo.pointer, &localX, &localY);
-
- if ((pScreen = miPointerGetScreen(inputInfo.pointer))) {
- dmxGlobalX = localX + dmxScreens[pScreen->myNum].rootXOrigin;
- dmxGlobalY = localY + dmxScreens[pScreen->myNum].rootYOrigin;
- ErrorF("Global is now %d, %d %d, %d\n", dmxGlobalX, dmxGlobalY,
- localX, localY);
- DMXDBG6(" Moved to dmxGlobalX=%d dmxGlobalY=%d"
- " on screen index=%d/%d localX=%d localY=%d\n",
- dmxGlobalX, dmxGlobalY,
- dmxScreen ? dmxScreen->index : -1, pScreen->myNum,
- localX, localY);
- }
-#endif
- }
- /* Send updates down to all core input
- * drivers */
- for (i = 0, dmxInput = &dmxInputs[0]; i < dmxNumInputs; i++, dmxInput++) {
- int j;
- for (j = 0; j < dmxInput->numDevs; j += dmxInput->devs[j]->binding)
- if (!dmxInput->detached
- && dmxInput->devs[j]->sendsCore
- && dmxInput->devs[j]->update_position)
- dmxInput->devs[j]->update_position(dmxInput->devs[j]->private,
- dmxGlobalX, dmxGlobalY);
- }
- if (!dmxScreen) ProcessInputEvents();
-}
-
-
-
-#define DMX_MAX_AXES 32 /* Max axes reported by this routine */
-static void dmxExtMotion(DMXLocalInputInfoPtr dmxLocal,
- int *v, int firstAxis, int axesCount,
- DMXMotionType type, DMXBlockType block)
-{
- DeviceIntPtr pDevice = dmxLocal->pDevice;
- xEvent xE[2 * DMX_MAX_AXES/6];
- deviceKeyButtonPointer *xev = (deviceKeyButtonPointer *)xE;
- deviceValuator *xv = (deviceValuator *)xev+1;
- int thisX = 0;
- int thisY = 0;
- int count;
- ValuatorMask mask;
-
- memset(xE, 0, sizeof(xE));
-
- if (axesCount > DMX_MAX_AXES) axesCount = DMX_MAX_AXES;
-
- if ((valuator_get_mode(pDevice,0) == Relative) && axesCount == 2) {
- /* The dmx console is a relative mode
- * device that sometimes reports
- * absolute motion. It only has two
- * axes. */
- if (type == DMX_RELATIVE) {
- thisX = -v[0];
- thisY = -v[1];
- dmxLocal->lastX += thisX;
- dmxLocal->lastY += thisY;
- if (dmxLocal->update_position)
- dmxLocal->update_position(dmxLocal->private,
- dmxLocal->lastX, dmxLocal->lastY);
- } else { /* Convert to relative */
- if (dmxLocal->lastX || dmxLocal->lastY) {
- thisX = v[0] - dmxLocal->lastX;
- thisY = v[1] - dmxLocal->lastY;
- }
- dmxLocal->lastX = v[0];
- dmxLocal->lastY = v[1];
- }
- v[0] = thisX;
- v[1] = thisY;
- }
-
- if (axesCount <= 6) {
- /* Optimize for the common case when
- * only 1 or 2 axes change. */
- xev->time = GetTimeInMillis();
- xev->type = DeviceMotionNotify;
- xev->detail = 0;
- xev->deviceid = pDevice->id | MORE_EVENTS;
-
- xv->type = DeviceValuator;
- xv->deviceid = pDevice->id;
- xv->num_valuators = axesCount;
- xv->first_valuator = firstAxis;
- switch (xv->num_valuators) {
- case 6: xv->valuator5 = v[5];
- case 5: xv->valuator4 = v[4];
- case 4: xv->valuator3 = v[3];
- case 3: xv->valuator2 = v[2];
- case 2: xv->valuator1 = v[1];
- case 1: xv->valuator0 = v[0];
- }
- count = 2;
- } else {
- int i;
- for (i = 0, count = 0; i < axesCount; i += 6) {
- xev->time = GetTimeInMillis();
- xev->type = DeviceMotionNotify;
- xev->detail = 0;
- xev->deviceid = pDevice->id | MORE_EVENTS;
- xev += 2;
-
- xv->type = DeviceValuator;
- xv->deviceid = pDevice->id;
- xv->num_valuators = (i+6 >= axesCount ? axesCount - i : 6);
- xv->first_valuator = firstAxis + i;
- switch (xv->num_valuators) {
- case 6: xv->valuator5 = v[i+5];
- case 5: xv->valuator4 = v[i+4];
- case 4: xv->valuator3 = v[i+3];
- case 3: xv->valuator2 = v[i+2];
- case 2: xv->valuator1 = v[i+1];
- case 1: xv->valuator0 = v[i+0];
- }
- xv += 2;
- count += 2;
- }
- }
-
- if (block)
- dmxSigioBlock();
- valuator_mask_set_range(&mask, firstAxis, axesCount, v);
- QueuePointerEvents(pDevice, MotionNotify, 0,
- POINTER_ABSOLUTE, &mask);
-
- if (block)
- dmxSigioUnblock();
-}
-
-static int dmxTranslateAndEnqueueExtEvent(DMXLocalInputInfoPtr dmxLocal,
- XEvent *e, DMXBlockType block)
-{
- int type;
- int event = -1;
- XDeviceKeyEvent *ke = (XDeviceKeyEvent *)e;
- XDeviceMotionEvent *me = (XDeviceMotionEvent *)e;
- DeviceIntPtr pDevice = dmxLocal->pDevice;
- int valuators[MAX_VALUATORS];
- ValuatorMask mask;
-
- if (!e)
- return -1; /* No extended event passed, cannot handle */
-
- if ((XID)dmxLocal->deviceId != ke->deviceid) {
- /* Search for the correct dmxLocal,
- * since backend and console events are
- * picked up for the first device on
- * that X server. */
- int i;
- DMXInputInfo *dmxInput = &dmxInputs[dmxLocal->inputIdx];
- for (i = 0; i < dmxInput->numDevs; i++) {
- dmxLocal = dmxInput->devs[i];
- if ((XID)dmxLocal->deviceId == ke->deviceid)
- break;
- }
- }
-
- if ((XID)dmxLocal->deviceId != ke->deviceid
- || (type = dmxMapLookup(dmxLocal, e->type)) < 0)
- return -1; /* No mapping, so this event is unhandled */
-
- switch (type) {
- case XI_DeviceValuator: event = DeviceValuator; break;
- case XI_DeviceKeyPress: event = KeyPress; break;
- case XI_DeviceKeyRelease: event = KeyRelease; break;
- case XI_DeviceButtonPress: event = ButtonPress; break;
- case XI_DeviceButtonRelease: event = ButtonRelease; break;
- case XI_DeviceMotionNotify: event = MotionNotify; break;
- case XI_DeviceFocusIn: event = DeviceFocusIn; break;
- case XI_DeviceFocusOut: event = DeviceFocusOut; break;
- case XI_ProximityIn: event = ProximityIn; break;
- case XI_ProximityOut: event = ProximityOut; break;
- case XI_DeviceStateNotify: event = DeviceStateNotify; break;
- case XI_DeviceMappingNotify: event = DeviceMappingNotify; break;
- case XI_ChangeDeviceNotify: event = ChangeDeviceNotify; break;
- case XI_DeviceKeystateNotify: event = DeviceStateNotify; break;
- case XI_DeviceButtonstateNotify: event = DeviceStateNotify; break;
- }
-
-#define EXTRACT_VALUATORS(ke, valuators) \
- valuators[0] = ke->axis_data[0]; \
- valuators[1] = ke->axis_data[1]; \
- valuators[2] = ke->axis_data[2]; \
- valuators[3] = ke->axis_data[3]; \
- valuators[4] = ke->axis_data[4]; \
- valuators[5] = ke->axis_data[5]; \
-
- switch (type) {
- case XI_DeviceKeyPress:
- case XI_DeviceKeyRelease:
- EXTRACT_VALUATORS(ke, valuators);
- valuator_mask_set_range(&mask, ke->first_axis, ke->axes_count, valuators);
- if (block)
- dmxSigioBlock();
- QueueKeyboardEvents(pDevice, event, ke->keycode, &mask);
- if (block)
- dmxSigioUnblock();
- break;
- case XI_DeviceButtonPress:
- case XI_DeviceButtonRelease:
- EXTRACT_VALUATORS(ke, valuators);
- valuator_mask_set_range(&mask, ke->first_axis, ke->axes_count, valuators);
- if (block)
- dmxSigioBlock();
- QueuePointerEvents(pDevice, event, ke->keycode,
- POINTER_ABSOLUTE, &mask);
- if (block)
- dmxSigioUnblock();
- break;
- case XI_ProximityIn:
- case XI_ProximityOut:
- EXTRACT_VALUATORS(ke, valuators);
- valuator_mask_set_range(&mask, ke->first_axis, ke->axes_count, valuators);
- if (block)
- dmxSigioBlock();
- QueueProximityEvents(pDevice, event, &mask);
- if (block)
- dmxSigioUnblock();
- break;
-
- break;
-
- case XI_DeviceMotionNotify:
- dmxExtMotion(dmxLocal, me->axis_data, me->first_axis, me->axes_count,
- DMX_ABSOLUTE, block);
- break;
- case XI_DeviceFocusIn:
- case XI_DeviceFocusOut:
- case XI_DeviceStateNotify:
- case XI_DeviceMappingNotify:
- case XI_ChangeDeviceNotify:
- case XI_DeviceKeystateNotify:
- case XI_DeviceButtonstateNotify:
- /* These are ignored, since DMX will
- * generate its own events of these
- * types, as necessary.
-
- * Perhaps ChangeDeviceNotify should
- * generate an error, because it is
- * unexpected? */
- break;
- case XI_DeviceValuator:
- default:
- dmxLog(dmxWarning,
- "XInput extension event (remote=%d -> zero-based=%d)"
- " not supported yet\n", e->type, type);
- return -1;
- }
- return 0;
-}
-
-static int dmxGetButtonMapping(DMXLocalInputInfoPtr dmxLocal, int button)
-{
- ButtonClassPtr b = dmxLocal->pDevice->button;
-
- if (button > b->numButtons) { /* This shouldn't happen. */
- dmxLog(dmxWarning, "Button %d pressed, but only %d buttons?!?\n",
- button, b->numButtons);
- return button;
- }
- return b->map[button];
-}
-
-/** Return DMX's notion of the pointer position in the global coordinate
- * space. */
-void dmxGetGlobalPosition(int *x, int *y)
-{
- *x = dmxGlobalX;
- *y = dmxGlobalY;
-}
-
-/** Invalidate the global position for #dmxCoreMotion. */
-void dmxInvalidateGlobalPosition(void)
-{
- dmxGlobalInvalid = 1;
-}
-
-/** Enqueue a motion event for \a pDev. The \a v vector has length \a
- * axesCount, and contains values for each of the axes, starting at \a
- * firstAxes.
- *
- * The \a type of the motion may be \a DMX_RELATIVE, \a DMX_ABSOLUTE, or
- * \a DMX_ABSOLUTE_CONFINED (in the latter case, the pointer will not be
- * allowed to move outside the global boundaires).
- *
- * If \a block is set to \a DMX_BLOCK, then the SIGIO handler will be
- * blocked around calls to \a enqueueMotion(). */
-void dmxMotion(DevicePtr pDev, int *v, int firstAxes, int axesCount,
- DMXMotionType type, DMXBlockType block)
-{
- GETDMXLOCALFROMPDEV;
-
- if (!dmxLocal->sendsCore) {
- dmxExtMotion(dmxLocal, v, firstAxes, axesCount, type, block);
- return;
- }
- if (axesCount == 2) {
- switch (type) {
- case DMX_RELATIVE:
- dmxCoreMotion(pDev, dmxGlobalX - v[0], dmxGlobalY - v[1], 0, block);
- break;
- case DMX_ABSOLUTE:
- dmxCoreMotion(pDev, v[0], v[1], 0, block);
- break;
- case DMX_ABSOLUTE_CONFINED:
- dmxCoreMotion(pDev, v[0], v[1], -1, block);
- break;
- }
- }
-}
-
-static KeySym dmxKeyCodeToKeySym(DMXLocalInputInfoPtr dmxLocal,
- KeyCode keyCode)
-{
- KeySym keysym = NoSymbol;
- int effectiveGroup;
- XkbSrvInfoPtr xkbi;
-
- if (!dmxLocal || !dmxLocal->pDevice || !dmxLocal->pDevice->key)
- goto out;
-
- xkbi = dmxLocal->pDevice->key->xkbInfo;
- effectiveGroup = XkbGetEffectiveGroup(xkbi, &xkbi->state, keyCode);
-
- if (effectiveGroup == -1)
- goto out;
-
- keysym = XkbKeySym(xkbi->desc, keyCode, effectiveGroup);
- DMXDBG2("dmxKeyCodeToKeySym: Translated keyCode=%d to keySym=0x%04x\n",
- keyCode, keysym);
-
-out:
- return keysym;
-}
-
-static KeyCode dmxKeySymToKeyCode(DMXLocalInputInfoPtr dmxLocal, KeySym keySym,
- int tryFirst)
-{
- /* FIXME: this is quite ineffective, converting to a core map first and
- * then extracting the info from there. It'd be better to run the actual
- * xkb map */
- XkbSrvInfoPtr xkbi = dmxLocal->pDevice->key->xkbInfo;
- KeySymsPtr pKeySyms = XkbGetCoreMap(dmxLocal->pDevice);
- int i;
-
- /* Optimize for similar maps */
- if (XkbKeycodeInRange(xkbi->desc, tryFirst)
- && pKeySyms->map[(tryFirst - xkbi->desc->min_key_code)
- * pKeySyms->mapWidth] == keySym)
- return tryFirst;
-
- for (i = pKeySyms->minKeyCode; i <= pKeySyms->maxKeyCode; i++) {
- if (pKeySyms->map[(i - pKeySyms->minKeyCode)
- * pKeySyms->mapWidth] == keySym) {
- DMXDBG3("dmxKeySymToKeyCode: Translated keySym=0x%04x to"
- " keyCode=%d (reverses to core keySym=0x%04x)\n",
- keySym, i, dmxKeyCodeToKeySym(dmxLocalCoreKeyboard,i));
- return i;
- }
- }
- return 0;
-}
-
-static int dmxFixup(DevicePtr pDev, int detail, KeySym keySym)
-{
- GETDMXLOCALFROMPDEV;
- int keyCode;
-
- if (!dmxLocal->pDevice->key) {
- dmxLog(dmxWarning, "dmxFixup: not a keyboard device (%s)\n",
- dmxLocal->pDevice->name);
- return NoSymbol;
- }
- if (!keySym)
- keySym = dmxKeyCodeToKeySym(dmxLocal, detail);
- if (keySym == NoSymbol)
- return detail;
- keyCode = dmxKeySymToKeyCode(dmxLocalCoreKeyboard, keySym, detail);
-
- return keyCode ? keyCode : detail;
-}
-
-/** Enqueue an event from the \a pDev device with the
- * specified \a type and \a detail. If the event is a KeyPress or
- * KeyRelease event, then the \a keySym is also specified.
- *
- * FIXME: make the code do what the comment says, or remove this comment.
- * If \a block is set to \a DMX_BLOCK, then the SIGIO handler will be
- * blocked around calls to dmxeqEnqueue(). */
-
-void dmxEnqueue(DevicePtr pDev, int type, int detail, KeySym keySym,
- XEvent *e, DMXBlockType block)
-{
- GETDMXINPUTFROMPDEV;
- xEvent xE;
- DeviceIntPtr p = dmxLocal->pDevice;
- int valuators[3];
- ValuatorMask mask;
-
- DMXDBG2("dmxEnqueue: Enqueuing type=%d detail=0x%0x\n", type, detail);
-
- switch (type) {
- case KeyPress:
- case KeyRelease:
- if (!keySym)
- keySym = dmxKeyCodeToKeySym(dmxLocal, detail);
- if (dmxCheckFunctionKeys(dmxLocal, type, keySym))
- return;
- if (dmxLocal->sendsCore && dmxLocal != dmxLocalCoreKeyboard)
- xE.u.u.detail = dmxFixup(pDev, detail, keySym);
-
- /*ErrorF("KEY %d sym %d\n", detail, (int) keySym);*/
- QueueKeyboardEvents(p, type, detail, NULL);
- return;
-
- case ButtonPress:
- case ButtonRelease:
- detail = dmxGetButtonMapping(dmxLocal, detail);
- valuator_mask_zero(&mask);
- QueuePointerEvents(p, type, detail,
- POINTER_ABSOLUTE | POINTER_SCREEN, &mask);
- return;
-
- case MotionNotify:
- valuators[0] = e->xmotion.x;
- valuators[1] = e->xmotion.y;
- valuators[2] = e->xmotion.state; /* FIXME: WTF?? */
- valuator_mask_set_range(&mask, 0, 3, valuators);
- QueuePointerEvents(p, type, detail,
- POINTER_ABSOLUTE | POINTER_SCREEN, &mask);
- return;
-
- case EnterNotify:
- case LeaveNotify:
- case KeymapNotify:
- case MappingNotify: /* This is sent because we change the
- * modifier map on the backend/console
- * input device so that we have complete
- * control of the input device LEDs. */
- return;
- default:
- if (type == ProximityIn || type == ProximityOut) {
- if (dmxLocal->sendsCore)
- return; /* Not a core event */
- break;
- }
- if (type >= LASTEvent) {
- if (dmxTranslateAndEnqueueExtEvent(dmxLocal, e, block))
- dmxLogInput(dmxInput, "Unhandled extension event: %d\n", type);
- } else {
- dmxLogInput(dmxInput, "Unhandled event: %d (%s)\n",
- type, dmxEventName(type));
- }
- return;
- }
-
-}
-
-/** A pointer to this routine is passed to low-level input drivers so
- * that all special keychecking is unified to this file. This function
- * returns 0 if no special keys have been pressed. If the user has
- * requested termination of the DMX server, -1 is returned. If the user
- * has requested a switch to a VT, then the (1-based) number of that VT
- * is returned. */
-int dmxCheckSpecialKeys(DevicePtr pDev, KeySym keySym)
-{
- GETDMXINPUTFROMPDEV;
- int vt = 0;
- unsigned short state = 0;
-
- if (dmxLocal->sendsCore)
- state = XkbStateFieldFromRec(&dmxLocalCoreKeyboard->pDevice->key->xkbInfo->state);
- else if (dmxLocal->pDevice->key)
- state = XkbStateFieldFromRec(&dmxLocal->pDevice->key->xkbInfo->state);
-
- if (!dmxLocal->sendsCore) return 0; /* Only for core devices */
-
- DMXDBG2("dmxCheckSpecialKeys: keySym=0x%04x state=0x%04x\n", keySym,state);
-
- if ((state & (ControlMask|Mod1Mask)) != (ControlMask|Mod1Mask)) return 0;
-
- switch (keySym) {
- case XK_F1:
- case XK_F2:
- case XK_F3:
- case XK_F4:
- case XK_F5:
- case XK_F6:
- case XK_F7:
- case XK_F8:
- case XK_F9:
- case XK_F10:
- vt = keySym - XK_F1 + 1;
- break;
-
- case XK_F11:
- case XK_F12:
- vt = keySym - XK_F11 + 11;
- break;
-
- case XK_q: /* To avoid confusion */
- case XK_BackSpace:
- case XK_Delete:
- case XK_KP_Delete:
- dmxLog(dmxInfo, "User request for termination\n");
- dispatchException |= DE_TERMINATE;
- return -1; /* Terminate */
- }
-
- if (vt) {
- dmxLog(dmxInfo, "Request to switch to VT %d\n", vt);
- dmxInput->vt_switch_pending = vt;
- return vt;
- }
-
- return 0; /* Do nothing */
-}
+/*
+ * Copyright 2002-2003 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:
+ * Rickard E. (Rik) Faith <faith@redhat.com>
+ *
+ */
+
+/** \file
+ * Provide support and helper functions for enqueing events received by
+ * the low-level input drivers. */
+
+#ifdef HAVE_DMX_CONFIG_H
+#include <dmx-config.h>
+#endif
+
+#define DMX_EVENTS_DEBUG 0
+
+#include "dmxinputinit.h"
+#include "dmxevents.h"
+#include "dmxcb.h"
+#include "dmxcommon.h"
+#include "dmxcursor.h"
+#include "dmxmotion.h"
+#include "dmxsigio.h"
+#include "dmxmap.h"
+
+#include <X11/keysym.h>
+#include "opaque.h"
+#include "inputstr.h"
+#include "inpututils.h"
+#include "mipointer.h"
+#include "mi.h"
+#include "exglobals.h"
+
+#include "xkbsrv.h"
+#include "XIstubs.h"
+
+static int dmxGlobalX, dmxGlobalY; /* Global cursor position */
+static int dmxGlobalInvalid; /* Flag indicating dmxCoreMotion
+ * should move the mouse anyway. */
+
+#if DMX_EVENTS_DEBUG
+#define DMXDBG0(f) dmxLog(dmxDebug,f)
+#define DMXDBG1(f,a) dmxLog(dmxDebug,f,a)
+#define DMXDBG2(f,a,b) dmxLog(dmxDebug,f,a,b)
+#define DMXDBG3(f,a,b,c) dmxLog(dmxDebug,f,a,b,c)
+#define DMXDBG4(f,a,b,c,d) dmxLog(dmxDebug,f,a,b,c,d)
+#define DMXDBG5(f,a,b,c,d,e) dmxLog(dmxDebug,f,a,b,c,d,e)
+#define DMXDBG6(f,a,b,c,d,e,g) dmxLog(dmxDebug,f,a,b,c,d,e,g)
+#define DMXDBG7(f,a,b,c,d,e,g,h) dmxLog(dmxDebug,f,a,b,c,d,e,g,h)
+#else
+#define DMXDBG0(f)
+#define DMXDBG1(f,a)
+#define DMXDBG2(f,a,b)
+#define DMXDBG3(f,a,b,c)
+#define DMXDBG4(f,a,b,c,d)
+#define DMXDBG5(f,a,b,c,d,e)
+#define DMXDBG6(f,a,b,c,d,e,g)
+#define DMXDBG7(f,a,b,c,d,e,g,h)
+#endif
+
+static int dmxApplyFunctions(DMXInputInfo *dmxInput, DMXFunctionType f)
+{
+ int i;
+ int rc = 0;
+
+ for (i = 0; i < dmxInput->numDevs; i+= dmxInput->devs[i]->binding)
+ if (dmxInput->devs[i]->functions)
+ rc += dmxInput->devs[i]->functions(dmxInput->devs[i]->private, f);
+ return rc;
+}
+
+static int dmxCheckFunctionKeys(DMXLocalInputInfoPtr dmxLocal,
+ int type,
+ KeySym keySym)
+{
+ DMXInputInfo *dmxInput = &dmxInputs[dmxLocal->inputIdx];
+
+#if 1 /* hack to detect ctrl-alt-q, etc */
+ static int ctrl = 0, alt = 0;
+ /* keep track of ctrl/alt key status */
+ if (type == KeyPress && keySym == 0xffe3) {
+ ctrl = 1;
+ }
+ else if (type == KeyRelease && keySym == 0xffe3) {
+ ctrl = 0;
+ }
+ else if (type == KeyPress && keySym == 0xffe9) {
+ alt = 1;
+ }
+ else if (type == KeyRelease && keySym == 0xffe9) {
+ alt = 0;
+ }
+ if (!ctrl || !alt)
+ return 0;
+#else
+ unsigned short state = 0;
+
+ if (dmxLocal->sendsCore)
+ state = dmxLocalCoreKeyboard->pDevice->key->state;
+ else if (dmxLocal->pDevice->key)
+ state = dmxLocal->pDevice->key->state;
+
+ DMXDBG3("dmxCheckFunctionKeys: keySym=0x%04x %s state=0x%04x\n",
+ keySym, type == KeyPress ? "press" : "release", state);
+
+ if ((state & (ControlMask|Mod1Mask)) != (ControlMask|Mod1Mask))
+ return 0;
+#endif
+
+ switch (keySym) {
+ case XK_g:
+ if (type == KeyPress)
+ dmxApplyFunctions(dmxInput, DMX_FUNCTION_GRAB);
+ return 1;
+ case XK_f:
+ if (type == KeyPress)
+ dmxApplyFunctions(dmxInput, DMX_FUNCTION_FINE);
+ return 1;
+ case XK_q:
+ if (type == KeyPress && dmxLocal->sendsCore)
+ if (dmxApplyFunctions(dmxInput, DMX_FUNCTION_TERMINATE)) {
+ dmxLog(dmxInfo, "User request for termination\n");
+ dispatchException |= DE_TERMINATE;
+ }
+ return 1;
+ }
+
+ return 0;
+}
+
+
+DMXScreenInfo *dmxFindFirstScreen(int x, int y)
+{
+ int i;
+
+ for (i = 0; i < dmxNumScreens; i++) {
+ DMXScreenInfo *dmxScreen = &dmxScreens[i];
+ if (dmxOnScreen(x, y, dmxScreen))
+ return dmxScreen;
+ }
+ return NULL;
+}
+
+
+/**
+ * Enqueue a motion event.
+ */
+static void enqueueMotion(DevicePtr pDev, int x, int y)
+{
+ GETDMXLOCALFROMPDEV;
+ DeviceIntPtr p = dmxLocal->pDevice;
+ int valuators[3];
+ int detail = 0; /* XXX should this be mask of pressed buttons? */
+ ValuatorMask mask;
+ valuators[0] = x;
+ valuators[1] = y;
+
+ valuator_mask_set_range(&mask, 0, 2, valuators);
+ QueuePointerEvents(p, MotionNotify, detail,
+ POINTER_ABSOLUTE | POINTER_SCREEN, &mask);
+ return;
+}
+
+
+void
+dmxCoreMotion(DevicePtr pDev, int x, int y, int delta, DMXBlockType block)
+{
+ DMXScreenInfo *dmxScreen;
+ DMXInputInfo *dmxInput;
+ ScreenPtr pScreen;
+ int localX;
+ int localY;
+ int i;
+
+ if (!dmxGlobalInvalid && dmxGlobalX == x && dmxGlobalY == y)
+ return;
+
+ DMXDBG5("dmxCoreMotion(%d,%d,%d) dmxGlobalX=%d dmxGlobalY=%d\n",
+ x, y, delta, dmxGlobalX, dmxGlobalY);
+
+ dmxGlobalInvalid = 0;
+ dmxGlobalX = x;
+ dmxGlobalY = y;
+
+ if (dmxGlobalX < 0)
+ dmxGlobalX = 0;
+ if (dmxGlobalY < 0)
+ dmxGlobalY = 0;
+ if (dmxGlobalX >= dmxGlobalWidth)
+ dmxGlobalX = dmxGlobalWidth + delta -1;
+ if (dmxGlobalY >= dmxGlobalHeight)
+ dmxGlobalY = dmxGlobalHeight + delta -1;
+
+ if ((dmxScreen = dmxFindFirstScreen(dmxGlobalX, dmxGlobalY))) {
+ localX = dmxGlobalX - dmxScreen->rootXOrigin;
+ localY = dmxGlobalY - dmxScreen->rootYOrigin;
+ if ((pScreen = miPointerGetScreen(inputInfo.pointer))
+ && pScreen->myNum == dmxScreen->index) {
+ /* Screen is old screen */
+ if (block)
+ dmxSigioBlock();
+ if (pDev)
+ enqueueMotion(pDev, localX, localY);
+ if (block)
+ dmxSigioUnblock();
+ } else {
+ /* Screen is new */
+ DMXDBG4(" New screen: old=%d new=%d localX=%d localY=%d\n",
+ pScreen->myNum, dmxScreen->index, localX, localY);
+ if (block)
+ dmxSigioBlock();
+ mieqProcessInputEvents();
+ miPointerSetScreen(inputInfo.pointer, dmxScreen->index,
+ localX, localY);
+ if (pDev)
+ enqueueMotion(pDev, localX, localY);
+ if (block)
+ dmxSigioUnblock();
+ }
+#if 00
+ miPointerGetPosition(inputInfo.pointer, &localX, &localY);
+
+ if ((pScreen = miPointerGetScreen(inputInfo.pointer))) {
+ dmxGlobalX = localX + dmxScreens[pScreen->myNum].rootXOrigin;
+ dmxGlobalY = localY + dmxScreens[pScreen->myNum].rootYOrigin;
+ ErrorF("Global is now %d, %d %d, %d\n", dmxGlobalX, dmxGlobalY,
+ localX, localY);
+ DMXDBG6(" Moved to dmxGlobalX=%d dmxGlobalY=%d"
+ " on screen index=%d/%d localX=%d localY=%d\n",
+ dmxGlobalX, dmxGlobalY,
+ dmxScreen ? dmxScreen->index : -1, pScreen->myNum,
+ localX, localY);
+ }
+#endif
+ }
+ /* Send updates down to all core input
+ * drivers */
+ for (i = 0, dmxInput = &dmxInputs[0]; i < dmxNumInputs; i++, dmxInput++) {
+ int j;
+ for (j = 0; j < dmxInput->numDevs; j += dmxInput->devs[j]->binding)
+ if (!dmxInput->detached
+ && dmxInput->devs[j]->sendsCore
+ && dmxInput->devs[j]->update_position)
+ dmxInput->devs[j]->update_position(dmxInput->devs[j]->private,
+ dmxGlobalX, dmxGlobalY);
+ }
+ if (!dmxScreen) ProcessInputEvents();
+}
+
+
+
+#define DMX_MAX_AXES 32 /* Max axes reported by this routine */
+static void dmxExtMotion(DMXLocalInputInfoPtr dmxLocal,
+ int *v, int firstAxis, int axesCount,
+ DMXMotionType type, DMXBlockType block)
+{
+ DeviceIntPtr pDevice = dmxLocal->pDevice;
+ xEvent xE[2 * DMX_MAX_AXES/6];
+ deviceKeyButtonPointer *xev = (deviceKeyButtonPointer *)xE;
+ deviceValuator *xv = (deviceValuator *)xev+1;
+ int thisX = 0;
+ int thisY = 0;
+ int count;
+ ValuatorMask mask;
+
+ memset(xE, 0, sizeof(xE));
+
+ if (axesCount > DMX_MAX_AXES) axesCount = DMX_MAX_AXES;
+
+ if ((valuator_get_mode(pDevice,0) == Relative) && axesCount == 2) {
+ /* The dmx console is a relative mode
+ * device that sometimes reports
+ * absolute motion. It only has two
+ * axes. */
+ if (type == DMX_RELATIVE) {
+ thisX = -v[0];
+ thisY = -v[1];
+ dmxLocal->lastX += thisX;
+ dmxLocal->lastY += thisY;
+ if (dmxLocal->update_position)
+ dmxLocal->update_position(dmxLocal->private,
+ dmxLocal->lastX, dmxLocal->lastY);
+ } else { /* Convert to relative */
+ if (dmxLocal->lastX || dmxLocal->lastY) {
+ thisX = v[0] - dmxLocal->lastX;
+ thisY = v[1] - dmxLocal->lastY;
+ }
+ dmxLocal->lastX = v[0];
+ dmxLocal->lastY = v[1];
+ }
+ v[0] = thisX;
+ v[1] = thisY;
+ }
+
+ if (axesCount <= 6) {
+ /* Optimize for the common case when
+ * only 1 or 2 axes change. */
+ xev->time = GetTimeInMillis();
+ xev->type = DeviceMotionNotify;
+ xev->detail = 0;
+ xev->deviceid = pDevice->id | MORE_EVENTS;
+
+ xv->type = DeviceValuator;
+ xv->deviceid = pDevice->id;
+ xv->num_valuators = axesCount;
+ xv->first_valuator = firstAxis;
+ switch (xv->num_valuators) {
+ case 6: xv->valuator5 = v[5];
+ case 5: xv->valuator4 = v[4];
+ case 4: xv->valuator3 = v[3];
+ case 3: xv->valuator2 = v[2];
+ case 2: xv->valuator1 = v[1];
+ case 1: xv->valuator0 = v[0];
+ }
+ count = 2;
+ } else {
+ int i;
+ for (i = 0, count = 0; i < axesCount; i += 6) {
+ xev->time = GetTimeInMillis();
+ xev->type = DeviceMotionNotify;
+ xev->detail = 0;
+ xev->deviceid = pDevice->id | MORE_EVENTS;
+ xev += 2;
+
+ xv->type = DeviceValuator;
+ xv->deviceid = pDevice->id;
+ xv->num_valuators = (i+6 >= axesCount ? axesCount - i : 6);
+ xv->first_valuator = firstAxis + i;
+ switch (xv->num_valuators) {
+ case 6: xv->valuator5 = v[i+5];
+ case 5: xv->valuator4 = v[i+4];
+ case 4: xv->valuator3 = v[i+3];
+ case 3: xv->valuator2 = v[i+2];
+ case 2: xv->valuator1 = v[i+1];
+ case 1: xv->valuator0 = v[i+0];
+ }
+ xv += 2;
+ count += 2;
+ }
+ }
+
+ if (block)
+ dmxSigioBlock();
+ valuator_mask_set_range(&mask, firstAxis, axesCount, v);
+ QueuePointerEvents(pDevice, MotionNotify, 0,
+ POINTER_ABSOLUTE, &mask);
+
+ if (block)
+ dmxSigioUnblock();
+}
+
+static int dmxTranslateAndEnqueueExtEvent(DMXLocalInputInfoPtr dmxLocal,
+ XEvent *e, DMXBlockType block)
+{
+ int type;
+ int event = -1;
+ XDeviceKeyEvent *ke = (XDeviceKeyEvent *)e;
+ XDeviceMotionEvent *me = (XDeviceMotionEvent *)e;
+ DeviceIntPtr pDevice = dmxLocal->pDevice;
+ int valuators[MAX_VALUATORS];
+ ValuatorMask mask;
+
+ if (!e)
+ return -1; /* No extended event passed, cannot handle */
+
+ if ((XID)dmxLocal->deviceId != ke->deviceid) {
+ /* Search for the correct dmxLocal,
+ * since backend and console events are
+ * picked up for the first device on
+ * that X server. */
+ int i;
+ DMXInputInfo *dmxInput = &dmxInputs[dmxLocal->inputIdx];
+ for (i = 0; i < dmxInput->numDevs; i++) {
+ dmxLocal = dmxInput->devs[i];
+ if ((XID)dmxLocal->deviceId == ke->deviceid)
+ break;
+ }
+ }
+
+ if ((XID)dmxLocal->deviceId != ke->deviceid
+ || (type = dmxMapLookup(dmxLocal, e->type)) < 0)
+ return -1; /* No mapping, so this event is unhandled */
+
+ switch (type) {
+ case XI_DeviceValuator: event = DeviceValuator; break;
+ case XI_DeviceKeyPress: event = KeyPress; break;
+ case XI_DeviceKeyRelease: event = KeyRelease; break;
+ case XI_DeviceButtonPress: event = ButtonPress; break;
+ case XI_DeviceButtonRelease: event = ButtonRelease; break;
+ case XI_DeviceMotionNotify: event = MotionNotify; break;
+ case XI_DeviceFocusIn: event = DeviceFocusIn; break;
+ case XI_DeviceFocusOut: event = DeviceFocusOut; break;
+ case XI_ProximityIn: event = ProximityIn; break;
+ case XI_ProximityOut: event = ProximityOut; break;
+ case XI_DeviceStateNotify: event = DeviceStateNotify; break;
+ case XI_DeviceMappingNotify: event = DeviceMappingNotify; break;
+ case XI_ChangeDeviceNotify: event = ChangeDeviceNotify; break;
+ case XI_DeviceKeystateNotify: event = DeviceStateNotify; break;
+ case XI_DeviceButtonstateNotify: event = DeviceStateNotify; break;
+ }
+
+#define EXTRACT_VALUATORS(ke, valuators) \
+ valuators[0] = ke->axis_data[0]; \
+ valuators[1] = ke->axis_data[1]; \
+ valuators[2] = ke->axis_data[2]; \
+ valuators[3] = ke->axis_data[3]; \
+ valuators[4] = ke->axis_data[4]; \
+ valuators[5] = ke->axis_data[5]; \
+
+ switch (type) {
+ case XI_DeviceKeyPress:
+ case XI_DeviceKeyRelease:
+ EXTRACT_VALUATORS(ke, valuators);
+ valuator_mask_set_range(&mask, ke->first_axis, ke->axes_count, valuators);
+ if (block)
+ dmxSigioBlock();
+ QueueKeyboardEvents(pDevice, event, ke->keycode, &mask);
+ if (block)
+ dmxSigioUnblock();
+ break;
+ case XI_DeviceButtonPress:
+ case XI_DeviceButtonRelease:
+ EXTRACT_VALUATORS(ke, valuators);
+ valuator_mask_set_range(&mask, ke->first_axis, ke->axes_count, valuators);
+ if (block)
+ dmxSigioBlock();
+ QueuePointerEvents(pDevice, event, ke->keycode,
+ POINTER_ABSOLUTE, &mask);
+ if (block)
+ dmxSigioUnblock();
+ break;
+ case XI_ProximityIn:
+ case XI_ProximityOut:
+ EXTRACT_VALUATORS(ke, valuators);
+ valuator_mask_set_range(&mask, ke->first_axis, ke->axes_count, valuators);
+ if (block)
+ dmxSigioBlock();
+ QueueProximityEvents(pDevice, event, &mask);
+ if (block)
+ dmxSigioUnblock();
+ break;
+
+ break;
+
+ case XI_DeviceMotionNotify:
+ dmxExtMotion(dmxLocal, me->axis_data, me->first_axis, me->axes_count,
+ DMX_ABSOLUTE, block);
+ break;
+ case XI_DeviceFocusIn:
+ case XI_DeviceFocusOut:
+ case XI_DeviceStateNotify:
+ case XI_DeviceMappingNotify:
+ case XI_ChangeDeviceNotify:
+ case XI_DeviceKeystateNotify:
+ case XI_DeviceButtonstateNotify:
+ /* These are ignored, since DMX will
+ * generate its own events of these
+ * types, as necessary.
+
+ * Perhaps ChangeDeviceNotify should
+ * generate an error, because it is
+ * unexpected? */
+ break;
+ case XI_DeviceValuator:
+ default:
+ dmxLog(dmxWarning,
+ "XInput extension event (remote=%d -> zero-based=%d)"
+ " not supported yet\n", e->type, type);
+ return -1;
+ }
+ return 0;
+}
+
+static int dmxGetButtonMapping(DMXLocalInputInfoPtr dmxLocal, int button)
+{
+ ButtonClassPtr b = dmxLocal->pDevice->button;
+
+ if (button > b->numButtons) { /* This shouldn't happen. */
+ dmxLog(dmxWarning, "Button %d pressed, but only %d buttons?!?\n",
+ button, b->numButtons);
+ return button;
+ }
+ return b->map[button];
+}
+
+/** Return DMX's notion of the pointer position in the global coordinate
+ * space. */
+void dmxGetGlobalPosition(int *x, int *y)
+{
+ *x = dmxGlobalX;
+ *y = dmxGlobalY;
+}
+
+/** Invalidate the global position for #dmxCoreMotion. */
+void dmxInvalidateGlobalPosition(void)
+{
+ dmxGlobalInvalid = 1;
+}
+
+/** Enqueue a motion event for \a pDev. The \a v vector has length \a
+ * axesCount, and contains values for each of the axes, starting at \a
+ * firstAxes.
+ *
+ * The \a type of the motion may be \a DMX_RELATIVE, \a DMX_ABSOLUTE, or
+ * \a DMX_ABSOLUTE_CONFINED (in the latter case, the pointer will not be
+ * allowed to move outside the global boundaires).
+ *
+ * If \a block is set to \a DMX_BLOCK, then the SIGIO handler will be
+ * blocked around calls to \a enqueueMotion(). */
+void dmxMotion(DevicePtr pDev, int *v, int firstAxes, int axesCount,
+ DMXMotionType type, DMXBlockType block)
+{
+ GETDMXLOCALFROMPDEV;
+
+ if (!dmxLocal->sendsCore) {
+ dmxExtMotion(dmxLocal, v, firstAxes, axesCount, type, block);
+ return;
+ }
+ if (axesCount == 2) {
+ switch (type) {
+ case DMX_RELATIVE:
+ dmxCoreMotion(pDev, dmxGlobalX - v[0], dmxGlobalY - v[1], 0, block);
+ break;
+ case DMX_ABSOLUTE:
+ dmxCoreMotion(pDev, v[0], v[1], 0, block);
+ break;
+ case DMX_ABSOLUTE_CONFINED:
+ dmxCoreMotion(pDev, v[0], v[1], -1, block);
+ break;
+ }
+ }
+}
+
+static KeySym dmxKeyCodeToKeySym(DMXLocalInputInfoPtr dmxLocal,
+ KeyCode keyCode)
+{
+ KeySym keysym = NoSymbol;
+ int effectiveGroup;
+ XkbSrvInfoPtr xkbi;
+
+ if (!dmxLocal || !dmxLocal->pDevice || !dmxLocal->pDevice->key)
+ goto out;
+
+ xkbi = dmxLocal->pDevice->key->xkbInfo;
+ effectiveGroup = XkbGetEffectiveGroup(xkbi, &xkbi->state, keyCode);
+
+ if (effectiveGroup == -1)
+ goto out;
+
+ keysym = XkbKeySym(xkbi->desc, keyCode, effectiveGroup);
+ DMXDBG2("dmxKeyCodeToKeySym: Translated keyCode=%d to keySym=0x%04x\n",
+ keyCode, keysym);
+
+out:
+ return keysym;
+}
+
+static KeyCode dmxKeySymToKeyCode(DMXLocalInputInfoPtr dmxLocal, KeySym keySym,
+ int tryFirst)
+{
+ /* FIXME: this is quite ineffective, converting to a core map first and
+ * then extracting the info from there. It'd be better to run the actual
+ * xkb map */
+ XkbSrvInfoPtr xkbi = dmxLocal->pDevice->key->xkbInfo;
+ KeySymsPtr pKeySyms = XkbGetCoreMap(dmxLocal->pDevice);
+ int i;
+
+ /* Optimize for similar maps */
+ if (XkbKeycodeInRange(xkbi->desc, tryFirst)
+ && pKeySyms->map[(tryFirst - xkbi->desc->min_key_code)
+ * pKeySyms->mapWidth] == keySym)
+ return tryFirst;
+
+ for (i = pKeySyms->minKeyCode; i <= pKeySyms->maxKeyCode; i++) {
+ if (pKeySyms->map[(i - pKeySyms->minKeyCode)
+ * pKeySyms->mapWidth] == keySym) {
+ DMXDBG3("dmxKeySymToKeyCode: Translated keySym=0x%04x to"
+ " keyCode=%d (reverses to core keySym=0x%04x)\n",
+ keySym, i, dmxKeyCodeToKeySym(dmxLocalCoreKeyboard,i));
+ return i;
+ }
+ }
+ return 0;
+}
+
+static int dmxFixup(DevicePtr pDev, int detail, KeySym keySym)
+{
+ GETDMXLOCALFROMPDEV;
+ int keyCode;
+
+ if (!dmxLocal->pDevice->key) {
+ dmxLog(dmxWarning, "dmxFixup: not a keyboard device (%s)\n",
+ dmxLocal->pDevice->name);
+ return NoSymbol;
+ }
+ if (!keySym)
+ keySym = dmxKeyCodeToKeySym(dmxLocal, detail);
+ if (keySym == NoSymbol)
+ return detail;
+ keyCode = dmxKeySymToKeyCode(dmxLocalCoreKeyboard, keySym, detail);
+
+ return keyCode ? keyCode : detail;
+}
+
+/** Enqueue an event from the \a pDev device with the
+ * specified \a type and \a detail. If the event is a KeyPress or
+ * KeyRelease event, then the \a keySym is also specified.
+ *
+ * FIXME: make the code do what the comment says, or remove this comment.
+ * If \a block is set to \a DMX_BLOCK, then the SIGIO handler will be
+ * blocked around calls to dmxeqEnqueue(). */
+
+void dmxEnqueue(DevicePtr pDev, int type, int detail, KeySym keySym,
+ XEvent *e, DMXBlockType block)
+{
+ GETDMXINPUTFROMPDEV;
+ xEvent xE;
+ DeviceIntPtr p = dmxLocal->pDevice;
+ int valuators[3];
+ ValuatorMask mask;
+
+ DMXDBG2("dmxEnqueue: Enqueuing type=%d detail=0x%0x\n", type, detail);
+
+ switch (type) {
+ case KeyPress:
+ case KeyRelease:
+ if (!keySym)
+ keySym = dmxKeyCodeToKeySym(dmxLocal, detail);
+ if (dmxCheckFunctionKeys(dmxLocal, type, keySym))
+ return;
+ if (dmxLocal->sendsCore && dmxLocal != dmxLocalCoreKeyboard)
+ xE.u.u.detail = dmxFixup(pDev, detail, keySym);
+
+ /*ErrorF("KEY %d sym %d\n", detail, (int) keySym);*/
+ QueueKeyboardEvents(p, type, detail, NULL);
+ return;
+
+ case ButtonPress:
+ case ButtonRelease:
+ detail = dmxGetButtonMapping(dmxLocal, detail);
+ valuator_mask_zero(&mask);
+ QueuePointerEvents(p, type, detail,
+ POINTER_ABSOLUTE | POINTER_SCREEN, &mask);
+ return;
+
+ case MotionNotify:
+ valuators[0] = e->xmotion.x;
+ valuators[1] = e->xmotion.y;
+ valuators[2] = e->xmotion.state; /* FIXME: WTF?? */
+ valuator_mask_set_range(&mask, 0, 3, valuators);
+ QueuePointerEvents(p, type, detail,
+ POINTER_ABSOLUTE | POINTER_SCREEN, &mask);
+ return;
+
+ case EnterNotify:
+ case LeaveNotify:
+ case KeymapNotify:
+ case MappingNotify: /* This is sent because we change the
+ * modifier map on the backend/console
+ * input device so that we have complete
+ * control of the input device LEDs. */
+ return;
+ default:
+ if (type == ProximityIn || type == ProximityOut) {
+ if (dmxLocal->sendsCore)
+ return; /* Not a core event */
+ break;
+ }
+ if (type >= LASTEvent) {
+ if (dmxTranslateAndEnqueueExtEvent(dmxLocal, e, block))
+ dmxLogInput(dmxInput, "Unhandled extension event: %d\n", type);
+ } else {
+ dmxLogInput(dmxInput, "Unhandled event: %d (%s)\n",
+ type, dmxEventName(type));
+ }
+ return;
+ }
+
+}
+
+/** A pointer to this routine is passed to low-level input drivers so
+ * that all special keychecking is unified to this file. This function
+ * returns 0 if no special keys have been pressed. If the user has
+ * requested termination of the DMX server, -1 is returned. If the user
+ * has requested a switch to a VT, then the (1-based) number of that VT
+ * is returned. */
+int dmxCheckSpecialKeys(DevicePtr pDev, KeySym keySym)
+{
+ GETDMXINPUTFROMPDEV;
+ int vt = 0;
+ unsigned short state = 0;
+
+ if (dmxLocal->sendsCore)
+ state = XkbStateFieldFromRec(&dmxLocalCoreKeyboard->pDevice->key->xkbInfo->state);
+ else if (dmxLocal->pDevice->key)
+ state = XkbStateFieldFromRec(&dmxLocal->pDevice->key->xkbInfo->state);
+
+ if (!dmxLocal->sendsCore) return 0; /* Only for core devices */
+
+ DMXDBG2("dmxCheckSpecialKeys: keySym=0x%04x state=0x%04x\n", keySym,state);
+
+ if ((state & (ControlMask|Mod1Mask)) != (ControlMask|Mod1Mask)) return 0;
+
+ switch (keySym) {
+ case XK_F1:
+ case XK_F2:
+ case XK_F3:
+ case XK_F4:
+ case XK_F5:
+ case XK_F6:
+ case XK_F7:
+ case XK_F8:
+ case XK_F9:
+ case XK_F10:
+ vt = keySym - XK_F1 + 1;
+ break;
+
+ case XK_F11:
+ case XK_F12:
+ vt = keySym - XK_F11 + 11;
+ break;
+
+ case XK_q: /* To avoid confusion */
+ case XK_BackSpace:
+ case XK_Delete:
+ case XK_KP_Delete:
+ dmxLog(dmxInfo, "User request for termination\n");
+ dispatchException |= DE_TERMINATE;
+ return -1; /* Terminate */
+ }
+
+ if (vt) {
+ dmxLog(dmxInfo, "Request to switch to VT %d\n", vt);
+ dmxInput->vt_switch_pending = vt;
+ return vt;
+ }
+
+ return 0; /* Do nothing */
+}
diff --git a/xorg-server/hw/kdrive/ephyr/ephyr.c b/xorg-server/hw/kdrive/ephyr/ephyr.c
index 07c7643df..9cbb4b0ef 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyr.c
+++ b/xorg-server/hw/kdrive/ephyr/ephyr.c
@@ -1,1188 +1,1188 @@
-/*
- * 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 */
-
-#include "xkbsrv.h"
-
-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;
-static Rotation ephyrRandr = RR_Rotate_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 *) malloc(sizeof (EphyrPriv));
- if (!priv)
- return FALSE;
-
- if (!ephyrInitialize (card, priv))
- {
- free(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.depth = 8;
-
- if (screen->fb.depth && screen->fb.depth != hostx_get_depth())
- {
- if (screen->fb.depth < hostx_get_depth()
- && (screen->fb.depth == 24 || screen->fb.depth == 16
- || screen->fb.depth == 8))
- {
- hostx_set_server_depth(screen, screen->fb.depth);
- }
- else
- ErrorF("\nXephyr: requested screen depth not supported, setting to match hosts.\n");
- }
-
- screen->fb.depth = hostx_get_server_depth(screen);
- screen->rate = 72;
-
- if (screen->fb.depth <= 8)
- {
- if (EphyrWantGrayScale)
- screen->fb.visuals = ((1 << StaticGray) | (1 << GrayScale));
- else
- screen->fb.visuals = ((1 << StaticGray) |
- (1 << GrayScale) |
- (1 << StaticColor) |
- (1 << PseudoColor) |
- (1 << TrueColor) |
- (1 << DirectColor));
-
- screen->fb.redMask = 0x00;
- screen->fb.greenMask = 0x00;
- screen->fb.blueMask = 0x00;
- screen->fb.depth = 8;
- screen->fb.bitsPerPixel = 8;
- }
- else
- {
- screen->fb.visuals = (1 << TrueColor);
-
- if (screen->fb.depth <= 15)
- {
- screen->fb.depth = 15;
- screen->fb.bitsPerPixel = 16;
- }
- else if (screen->fb.depth <= 16)
- {
- screen->fb.depth = 16;
- screen->fb.bitsPerPixel = 16;
- }
- else if (screen->fb.depth <= 24)
- {
- screen->fb.depth = 24;
- screen->fb.bitsPerPixel = 32;
- }
- else if (screen->fb.depth <= 30)
- {
- screen->fb.depth = 30;
- screen->fb.bitsPerPixel = 32;
- }
- else
- {
- ErrorF("\nXephyr: Unsupported screen depth %d\n",
- screen->fb.depth);
- return FALSE;
- }
-
- hostx_get_visual_masks (screen, &redMask, &greenMask, &blueMask);
-
- screen->fb.redMask = (Pixel) redMask;
- screen->fb.greenMask = (Pixel) greenMask;
- screen->fb.blueMask = (Pixel) blueMask;
-
- }
-
- scrpriv->randr = screen->randr;
-
- return ephyrMapFramebuffer (screen);
-}
-
-Bool
-ephyrScreenInit (KdScreenInfo *screen)
-{
- EphyrScrPriv *scrpriv;
-
- scrpriv = calloc(1, sizeof (EphyrScrPriv));
-
- if (!scrpriv)
- return FALSE;
-
- screen->driver = scrpriv;
-
- if (!ephyrScreenInitialize (screen, scrpriv))
- {
- screen->driver = 0;
- free(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;
-}
-
-/**
- * Figure out display buffer size. If fakexa is enabled, allocate a larger
- * buffer so that fakexa has space to put offscreen pixmaps.
- */
-int
-ephyrBufferHeight(KdScreenInfo *screen)
-{
- int buffer_height;
- if (ephyrFuncs.initAccel == NULL)
- buffer_height = screen->height;
- else
- buffer_height = 3 * screen->height;
- return buffer_height;
-}
-
-
-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);
-
- /*
- * Use the rotation last applied to ourselves (in the Xephyr case the fb
- * coordinate system moves independently of the pointer coordiante system).
- */
- KdComputePointerMatrix (&m, ephyrRandr, screen->width, screen->height);
- KdSetPointerMatrix (&m);
-
- priv->bytes_per_line = ((screen->width * screen->fb.bitsPerPixel + 31) >> 5) << 2;
-
- buffer_height = ephyrBufferHeight(screen);
-
- priv->base = hostx_screen_init (screen, screen->width, screen->height, buffer_height);
-
- if ((scrpriv->randr & RR_Rotate_0) && !(scrpriv->randr & RR_Reflect_All))
- {
- scrpriv->shadow = FALSE;
-
- screen->fb.byteStride = priv->bytes_per_line;
- screen->fb.pixelStride = screen->width;
- screen->fb.frameBuffer = (CARD8 *) (priv->base);
- }
- else
- {
- /* Rotated/Reflected so we need to use shadow fb */
- scrpriv->shadow = TRUE;
-
- EPHYR_LOG("allocing shadow");
-
- KdShadowFbAlloc (screen,
- 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);
-
- /* 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 (RegionNotEmpty(pRegion))
- {
- int nbox;
- BoxPtr pbox;
-
- nbox = RegionNumRects (pRegion);
- pbox = RegionRects (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
- */
-
- /*
- * We need to store the rotation value for pointer coords transformation;
- * though initially the pointer and fb rotation are identical, when we map
- * the fb, the screen will be reinitialized and return into an unrotated
- * state (presumably the HW is taking care of the rotation of the fb), but the
- * pointer still needs to be transformed.
- */
- ephyrRandr = KdAddRotation (screen->randr, randr);
- scrpriv->randr = ephyrRandr;
-
- 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.depth,
- screen->fb.bitsPerPixel,
- screen->fb.byteStride,
- screen->fb.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);
- }
- free(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)
-{
-
- DeviceIntPtr pDev = inputInfo.keyboard;
- KeyClassPtr keyc = pDev->key;
- int i;
- CARD8 mask;
- int xkb_state;
-
- if (!pDev)
- return;
-
- xkb_state = XkbStateFieldFromRec(&pDev->key->xkbInfo->state);
- state = state & 0xff;
-
- if (xkb_state == state)
- return;
-
- for (i = 0, mask = 1; i < 8; i++, mask <<= 1) {
- int key;
-
- /* Modifier is down, but shouldn't be
- */
- if ((xkb_state & mask) && !(state & mask)) {
- int count = keyc->modifierKeyCount[i];
-
- for (key = 0; key < MAP_LENGTH; key++)
- if (keyc->xkbInfo->desc->map->modmap[key] & mask) {
- if (key_is_down(pDev, key, KEY_PROCESSED))
- KdEnqueueKeyboardEvent (ephyrKbd, key, TRUE);
-
- if (--count == 0)
- break;
- }
- }
-
- /* Modifier shoud be down, but isn't
- */
- if (!(xkb_state & mask) && (state & mask))
- for (key = 0; key < MAP_LENGTH; key++)
- if (keyc->xkbInfo->desc->map->modmap[key] & mask) {
- KdEnqueueKeyboardEvent (ephyrKbd, key, FALSE);
- break;
- }
- }
-}
-
-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;
- RegionNull(&reg);
- RegionCopy(&reg, &pair->local->clipList);
- screen->WindowExposures (pair->local, &reg, NullRegion);
- RegionUninit(&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;
- ephyrUpdateModifierState(ev.key_state);
- 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;
- free(priv);
-}
-
-void
-ephyrGetColors (ScreenPtr pScreen, 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 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 *)
- calloc(sizeof(EphyrPointerPrivate), 1);
- ((EphyrPointerPrivate *)pi->driverPrivate)->enabled = FALSE;
- pi->nAxes = 3;
- pi->nButtons = 32;
- free(pi->name);
- pi->name = strdup("Xephyr virtual mouse");
-
- /*
- * Must transform pointer coords since the pointer position
- * relative to the Xephyr window is controlled by the host server and
- * remains constant regardless of any rotation applied to the Xephyr screen.
- */
- pi->transformCoordinates = TRUE;
-
- 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 *)
- calloc(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;
- free(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 */
+
+#include "xkbsrv.h"
+
+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;
+static Rotation ephyrRandr = RR_Rotate_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 *) malloc(sizeof (EphyrPriv));
+ if (!priv)
+ return FALSE;
+
+ if (!ephyrInitialize (card, priv))
+ {
+ free(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.depth = 8;
+
+ if (screen->fb.depth && screen->fb.depth != hostx_get_depth())
+ {
+ if (screen->fb.depth < hostx_get_depth()
+ && (screen->fb.depth == 24 || screen->fb.depth == 16
+ || screen->fb.depth == 8))
+ {
+ hostx_set_server_depth(screen, screen->fb.depth);
+ }
+ else
+ ErrorF("\nXephyr: requested screen depth not supported, setting to match hosts.\n");
+ }
+
+ screen->fb.depth = hostx_get_server_depth(screen);
+ screen->rate = 72;
+
+ if (screen->fb.depth <= 8)
+ {
+ if (EphyrWantGrayScale)
+ screen->fb.visuals = ((1 << StaticGray) | (1 << GrayScale));
+ else
+ screen->fb.visuals = ((1 << StaticGray) |
+ (1 << GrayScale) |
+ (1 << StaticColor) |
+ (1 << PseudoColor) |
+ (1 << TrueColor) |
+ (1 << DirectColor));
+
+ screen->fb.redMask = 0x00;
+ screen->fb.greenMask = 0x00;
+ screen->fb.blueMask = 0x00;
+ screen->fb.depth = 8;
+ screen->fb.bitsPerPixel = 8;
+ }
+ else
+ {
+ screen->fb.visuals = (1 << TrueColor);
+
+ if (screen->fb.depth <= 15)
+ {
+ screen->fb.depth = 15;
+ screen->fb.bitsPerPixel = 16;
+ }
+ else if (screen->fb.depth <= 16)
+ {
+ screen->fb.depth = 16;
+ screen->fb.bitsPerPixel = 16;
+ }
+ else if (screen->fb.depth <= 24)
+ {
+ screen->fb.depth = 24;
+ screen->fb.bitsPerPixel = 32;
+ }
+ else if (screen->fb.depth <= 30)
+ {
+ screen->fb.depth = 30;
+ screen->fb.bitsPerPixel = 32;
+ }
+ else
+ {
+ ErrorF("\nXephyr: Unsupported screen depth %d\n",
+ screen->fb.depth);
+ return FALSE;
+ }
+
+ hostx_get_visual_masks (screen, &redMask, &greenMask, &blueMask);
+
+ screen->fb.redMask = (Pixel) redMask;
+ screen->fb.greenMask = (Pixel) greenMask;
+ screen->fb.blueMask = (Pixel) blueMask;
+
+ }
+
+ scrpriv->randr = screen->randr;
+
+ return ephyrMapFramebuffer (screen);
+}
+
+Bool
+ephyrScreenInit (KdScreenInfo *screen)
+{
+ EphyrScrPriv *scrpriv;
+
+ scrpriv = calloc(1, sizeof (EphyrScrPriv));
+
+ if (!scrpriv)
+ return FALSE;
+
+ screen->driver = scrpriv;
+
+ if (!ephyrScreenInitialize (screen, scrpriv))
+ {
+ screen->driver = 0;
+ free(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;
+}
+
+/**
+ * Figure out display buffer size. If fakexa is enabled, allocate a larger
+ * buffer so that fakexa has space to put offscreen pixmaps.
+ */
+int
+ephyrBufferHeight(KdScreenInfo *screen)
+{
+ int buffer_height;
+ if (ephyrFuncs.initAccel == NULL)
+ buffer_height = screen->height;
+ else
+ buffer_height = 3 * screen->height;
+ return buffer_height;
+}
+
+
+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);
+
+ /*
+ * Use the rotation last applied to ourselves (in the Xephyr case the fb
+ * coordinate system moves independently of the pointer coordiante system).
+ */
+ KdComputePointerMatrix (&m, ephyrRandr, screen->width, screen->height);
+ KdSetPointerMatrix (&m);
+
+ priv->bytes_per_line = ((screen->width * screen->fb.bitsPerPixel + 31) >> 5) << 2;
+
+ buffer_height = ephyrBufferHeight(screen);
+
+ priv->base = hostx_screen_init (screen, screen->width, screen->height, buffer_height);
+
+ if ((scrpriv->randr & RR_Rotate_0) && !(scrpriv->randr & RR_Reflect_All))
+ {
+ scrpriv->shadow = FALSE;
+
+ screen->fb.byteStride = priv->bytes_per_line;
+ screen->fb.pixelStride = screen->width;
+ screen->fb.frameBuffer = (CARD8 *) (priv->base);
+ }
+ else
+ {
+ /* Rotated/Reflected so we need to use shadow fb */
+ scrpriv->shadow = TRUE;
+
+ EPHYR_LOG("allocing shadow");
+
+ KdShadowFbAlloc (screen,
+ 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);
+
+ /* 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 (RegionNotEmpty(pRegion))
+ {
+ int nbox;
+ BoxPtr pbox;
+
+ nbox = RegionNumRects (pRegion);
+ pbox = RegionRects (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
+ */
+
+ /*
+ * We need to store the rotation value for pointer coords transformation;
+ * though initially the pointer and fb rotation are identical, when we map
+ * the fb, the screen will be reinitialized and return into an unrotated
+ * state (presumably the HW is taking care of the rotation of the fb), but the
+ * pointer still needs to be transformed.
+ */
+ ephyrRandr = KdAddRotation (screen->randr, randr);
+ scrpriv->randr = ephyrRandr;
+
+ 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.depth,
+ screen->fb.bitsPerPixel,
+ screen->fb.byteStride,
+ screen->fb.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);
+ }
+ free(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)
+{
+
+ DeviceIntPtr pDev = inputInfo.keyboard;
+ KeyClassPtr keyc = pDev->key;
+ int i;
+ CARD8 mask;
+ int xkb_state;
+
+ if (!pDev)
+ return;
+
+ xkb_state = XkbStateFieldFromRec(&pDev->key->xkbInfo->state);
+ state = state & 0xff;
+
+ if (xkb_state == state)
+ return;
+
+ for (i = 0, mask = 1; i < 8; i++, mask <<= 1) {
+ int key;
+
+ /* Modifier is down, but shouldn't be
+ */
+ if ((xkb_state & mask) && !(state & mask)) {
+ int count = keyc->modifierKeyCount[i];
+
+ for (key = 0; key < MAP_LENGTH; key++)
+ if (keyc->xkbInfo->desc->map->modmap[key] & mask) {
+ if (key_is_down(pDev, key, KEY_PROCESSED))
+ KdEnqueueKeyboardEvent (ephyrKbd, key, TRUE);
+
+ if (--count == 0)
+ break;
+ }
+ }
+
+ /* Modifier shoud be down, but isn't
+ */
+ if (!(xkb_state & mask) && (state & mask))
+ for (key = 0; key < MAP_LENGTH; key++)
+ if (keyc->xkbInfo->desc->map->modmap[key] & mask) {
+ KdEnqueueKeyboardEvent (ephyrKbd, key, FALSE);
+ break;
+ }
+ }
+}
+
+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;
+ RegionNull(&reg);
+ RegionCopy(&reg, &pair->local->clipList);
+ screen->WindowExposures (pair->local, &reg, NullRegion);
+ RegionUninit(&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;
+ ephyrUpdateModifierState(ev.key_state);
+ 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;
+ free(priv);
+}
+
+void
+ephyrGetColors (ScreenPtr pScreen, 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 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 *)
+ calloc(sizeof(EphyrPointerPrivate), 1);
+ ((EphyrPointerPrivate *)pi->driverPrivate)->enabled = FALSE;
+ pi->nAxes = 3;
+ pi->nButtons = 32;
+ free(pi->name);
+ pi->name = strdup("Xephyr virtual mouse");
+
+ /*
+ * Must transform pointer coords since the pointer position
+ * relative to the Xephyr window is controlled by the host server and
+ * remains constant regardless of any rotation applied to the Xephyr screen.
+ */
+ pi->transformCoordinates = TRUE;
+
+ 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 *)
+ calloc(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;
+ free(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 6ec8eb609..73ebcfa5b 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyr.h
+++ b/xorg-server/hw/kdrive/ephyr/ephyr.h
@@ -1,207 +1,207 @@
-/*
- * 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.
- */
-
-#ifndef _EPHYR_H_
-#define _EPHYR_H_
-#include <stdio.h>
-#ifndef _MSC_VER
-#include <unistd.h>
-#include <libgen.h>
-#endif
-#include <signal.h>
-
-#include "os.h" /* for OsSignal() */
-#include "kdrive.h"
-#include "hostx.h"
-#include "exa.h"
-
-#ifdef RANDR
-#include "randrstr.h"
-#endif
-
-#include "damage.h"
-
-typedef struct _ephyrPriv {
- CARD8 *base;
- int bytes_per_line;
-} EphyrPriv;
-
-typedef struct _ephyrFakexaPriv {
- ExaDriverPtr exa;
- Bool is_synced;
-
- /* The following are arguments and other information from Prepare* calls
- * which are stored for use in the inner calls.
- */
- int op;
- PicturePtr pSrcPicture, pMaskPicture, pDstPicture;
- void *saved_ptrs[3];
- PixmapPtr pDst, pSrc, pMask;
- GCPtr pGC;
-} EphyrFakexaPriv;
-
-typedef struct _ephyrScrPriv {
- Rotation randr;
- Bool shadow;
- DamagePtr pDamage;
- EphyrFakexaPriv *fakexa;
-} EphyrScrPriv;
-
-extern KdCardFuncs ephyrFuncs;
-extern KdKeyboardInfo *ephyrKbd;
-extern KdPointerInfo *ephyrMouse;
-
-extern miPointerScreenFuncRec ephyrPointerScreenFuncs;
-
-Bool
-ephyrInitialize (KdCardInfo *card, EphyrPriv *priv);
-
-Bool
-ephyrCardInit (KdCardInfo *card);
-
-Bool
-ephyrScreenInit (KdScreenInfo *screen);
-
-Bool
-ephyrScreenInitialize (KdScreenInfo *screen, EphyrScrPriv *scrpriv);
-
-Bool
-ephyrInitScreen (ScreenPtr pScreen);
-
-Bool
-ephyrFinishInitScreen (ScreenPtr pScreen);
-
-Bool
-ephyrCreateResources (ScreenPtr pScreen);
-
-void
-ephyrPreserve (KdCardInfo *card);
-
-Bool
-ephyrEnable (ScreenPtr pScreen);
-
-Bool
-ephyrDPMS (ScreenPtr pScreen, int mode);
-
-void
-ephyrDisable (ScreenPtr pScreen);
-
-void
-ephyrRestore (KdCardInfo *card);
-
-void
-ephyrScreenFini (KdScreenInfo *screen);
-
-void
-ephyrCardFini (KdCardInfo *card);
-
-void
-ephyrGetColors (ScreenPtr pScreen, int n, xColorItem *pdefs);
-
-void
-ephyrPutColors (ScreenPtr pScreen, int n, xColorItem *pdefs);
-
-Bool
-ephyrMapFramebuffer (KdScreenInfo *screen);
-
-void *
-ephyrWindowLinear (ScreenPtr pScreen,
- CARD32 row,
- CARD32 offset,
- int mode,
- CARD32 *size,
- void *closure);
-
-void
-ephyrSetScreenSizes (ScreenPtr pScreen);
-
-Bool
-ephyrUnmapFramebuffer (KdScreenInfo *screen);
-
-void
-ephyrUnsetInternalDamage (ScreenPtr pScreen);
-
-Bool
-ephyrSetInternalDamage (ScreenPtr pScreen);
-
-Bool
-ephyrCreateColormap (ColormapPtr pmap);
-
-void
-ephyrPoll(void);
-
-#ifdef RANDR
-Bool
-ephyrRandRGetInfo (ScreenPtr pScreen, Rotation *rotations);
-
-Bool
-ephyrRandRSetConfig (ScreenPtr pScreen,
- Rotation randr,
- int rate,
- RRScreenSizePtr pSize);
-Bool
-ephyrRandRInit (ScreenPtr pScreen);
-
-void
-ephyrShadowUpdate (ScreenPtr pScreen, shadowBufPtr pBuf);
-
-#endif
-
-void
-ephyrUpdateModifierState(unsigned int state);
-
-extern KdPointerDriver EphyrMouseDriver;
-
-extern KdKeyboardDriver EphyrKeyboardDriver;
-
-extern KdOsFuncs EphyrOsFuncs;
-
-extern Bool ephyrCursorInit(ScreenPtr pScreen);
-
-extern void ephyrCursorEnable(ScreenPtr pScreen);
-
-extern int ephyrBufferHeight(KdScreenInfo *screen);
-
-extern int ephyrBufferHeight(KdScreenInfo *screen);
-
-/* ephyr_draw.c */
-
-Bool
-ephyrDrawInit(ScreenPtr pScreen);
-
-void
-ephyrDrawEnable(ScreenPtr pScreen);
-
-void
-ephyrDrawDisable(ScreenPtr pScreen);
-
-void
-ephyrDrawFini(ScreenPtr pScreen);
-
-/*ephyvideo.c*/
-
-Bool ephyrInitVideo(ScreenPtr pScreen) ;
-
-#endif
+/*
+ * 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.
+ */
+
+#ifndef _EPHYR_H_
+#define _EPHYR_H_
+#include <stdio.h>
+#ifndef _MSC_VER
+#include <unistd.h>
+#include <libgen.h>
+#endif
+#include <signal.h>
+
+#include "os.h" /* for OsSignal() */
+#include "kdrive.h"
+#include "hostx.h"
+#include "exa.h"
+
+#ifdef RANDR
+#include "randrstr.h"
+#endif
+
+#include "damage.h"
+
+typedef struct _ephyrPriv {
+ CARD8 *base;
+ int bytes_per_line;
+} EphyrPriv;
+
+typedef struct _ephyrFakexaPriv {
+ ExaDriverPtr exa;
+ Bool is_synced;
+
+ /* The following are arguments and other information from Prepare* calls
+ * which are stored for use in the inner calls.
+ */
+ int op;
+ PicturePtr pSrcPicture, pMaskPicture, pDstPicture;
+ void *saved_ptrs[3];
+ PixmapPtr pDst, pSrc, pMask;
+ GCPtr pGC;
+} EphyrFakexaPriv;
+
+typedef struct _ephyrScrPriv {
+ Rotation randr;
+ Bool shadow;
+ DamagePtr pDamage;
+ EphyrFakexaPriv *fakexa;
+} EphyrScrPriv;
+
+extern KdCardFuncs ephyrFuncs;
+extern KdKeyboardInfo *ephyrKbd;
+extern KdPointerInfo *ephyrMouse;
+
+extern miPointerScreenFuncRec ephyrPointerScreenFuncs;
+
+Bool
+ephyrInitialize (KdCardInfo *card, EphyrPriv *priv);
+
+Bool
+ephyrCardInit (KdCardInfo *card);
+
+Bool
+ephyrScreenInit (KdScreenInfo *screen);
+
+Bool
+ephyrScreenInitialize (KdScreenInfo *screen, EphyrScrPriv *scrpriv);
+
+Bool
+ephyrInitScreen (ScreenPtr pScreen);
+
+Bool
+ephyrFinishInitScreen (ScreenPtr pScreen);
+
+Bool
+ephyrCreateResources (ScreenPtr pScreen);
+
+void
+ephyrPreserve (KdCardInfo *card);
+
+Bool
+ephyrEnable (ScreenPtr pScreen);
+
+Bool
+ephyrDPMS (ScreenPtr pScreen, int mode);
+
+void
+ephyrDisable (ScreenPtr pScreen);
+
+void
+ephyrRestore (KdCardInfo *card);
+
+void
+ephyrScreenFini (KdScreenInfo *screen);
+
+void
+ephyrCardFini (KdCardInfo *card);
+
+void
+ephyrGetColors (ScreenPtr pScreen, int n, xColorItem *pdefs);
+
+void
+ephyrPutColors (ScreenPtr pScreen, int n, xColorItem *pdefs);
+
+Bool
+ephyrMapFramebuffer (KdScreenInfo *screen);
+
+void *
+ephyrWindowLinear (ScreenPtr pScreen,
+ CARD32 row,
+ CARD32 offset,
+ int mode,
+ CARD32 *size,
+ void *closure);
+
+void
+ephyrSetScreenSizes (ScreenPtr pScreen);
+
+Bool
+ephyrUnmapFramebuffer (KdScreenInfo *screen);
+
+void
+ephyrUnsetInternalDamage (ScreenPtr pScreen);
+
+Bool
+ephyrSetInternalDamage (ScreenPtr pScreen);
+
+Bool
+ephyrCreateColormap (ColormapPtr pmap);
+
+void
+ephyrPoll(void);
+
+#ifdef RANDR
+Bool
+ephyrRandRGetInfo (ScreenPtr pScreen, Rotation *rotations);
+
+Bool
+ephyrRandRSetConfig (ScreenPtr pScreen,
+ Rotation randr,
+ int rate,
+ RRScreenSizePtr pSize);
+Bool
+ephyrRandRInit (ScreenPtr pScreen);
+
+void
+ephyrShadowUpdate (ScreenPtr pScreen, shadowBufPtr pBuf);
+
+#endif
+
+void
+ephyrUpdateModifierState(unsigned int state);
+
+extern KdPointerDriver EphyrMouseDriver;
+
+extern KdKeyboardDriver EphyrKeyboardDriver;
+
+extern KdOsFuncs EphyrOsFuncs;
+
+extern Bool ephyrCursorInit(ScreenPtr pScreen);
+
+extern void ephyrCursorEnable(ScreenPtr pScreen);
+
+extern int ephyrBufferHeight(KdScreenInfo *screen);
+
+extern int ephyrBufferHeight(KdScreenInfo *screen);
+
+/* ephyr_draw.c */
+
+Bool
+ephyrDrawInit(ScreenPtr pScreen);
+
+void
+ephyrDrawEnable(ScreenPtr pScreen);
+
+void
+ephyrDrawDisable(ScreenPtr pScreen);
+
+void
+ephyrDrawFini(ScreenPtr pScreen);
+
+/*ephyvideo.c*/
+
+Bool ephyrInitVideo(ScreenPtr pScreen) ;
+
+#endif
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrinit.c b/xorg-server/hw/kdrive/ephyr/ephyrinit.c
index 1056172ae..8160d8414 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyrinit.c
+++ b/xorg-server/hw/kdrive/ephyr/ephyrinit.c
@@ -1,433 +1,433 @@
-/*
- * 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;
-
-#ifdef KDRIVE_EVDEV
-extern KdPointerDriver LinuxEvdevMouseDriver;
-extern KdKeyboardDriver LinuxEvdevKeyboardDriver;
-#endif
-
-void processScreenArg (char *screen_size, char *parent_id) ;
-
-void
-InitCard (char *name)
-{
- EPHYR_DBG("mark");
- KdCardInfoAdd (&ephyrFuncs, 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 KDRIVE_EVDEV
- KdAddKeyboardDriver(&LinuxEvdevKeyboardDriver);
-#endif
- KdAddPointerDriver(&EphyrMouseDriver);
-#ifdef KDRIVE_EVDEV
- 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();
-}
-
-void
-CloseInput (void)
-{
- KdCloseInput();
-}
-
-#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;
-}
-
-static void
-ephyrDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScreen)
-{
-}
-
-miPointerSpriteFuncRec EphyrPointerSpriteFuncs = {
- ephyrRealizeCursor,
- ephyrUnrealizeCursor,
- ephyrSetCursor,
- ephyrMoveCursor,
- ephyrDeviceCursorInitialize,
- ephyrDeviceCursorCleanup
-};
-
-
-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;
+
+#ifdef KDRIVE_EVDEV
+extern KdPointerDriver LinuxEvdevMouseDriver;
+extern KdKeyboardDriver LinuxEvdevKeyboardDriver;
+#endif
+
+void processScreenArg (char *screen_size, char *parent_id) ;
+
+void
+InitCard (char *name)
+{
+ EPHYR_DBG("mark");
+ KdCardInfoAdd (&ephyrFuncs, 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 KDRIVE_EVDEV
+ KdAddKeyboardDriver(&LinuxEvdevKeyboardDriver);
+#endif
+ KdAddPointerDriver(&EphyrMouseDriver);
+#ifdef KDRIVE_EVDEV
+ 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();
+}
+
+void
+CloseInput (void)
+{
+ KdCloseInput();
+}
+
+#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;
+}
+
+static void
+ephyrDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScreen)
+{
+}
+
+miPointerSpriteFuncRec EphyrPointerSpriteFuncs = {
+ ephyrRealizeCursor,
+ ephyrUnrealizeCursor,
+ ephyrSetCursor,
+ ephyrMoveCursor,
+ ephyrDeviceCursorInitialize,
+ ephyrDeviceCursorCleanup
+};
+
+
+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/src/kdrive.c b/xorg-server/hw/kdrive/src/kdrive.c
index 85fe190fc..f5af57e82 100644
--- a/xorg-server/hw/kdrive/src/kdrive.c
+++ b/xorg-server/hw/kdrive/src/kdrive.c
@@ -1,1193 +1,1193 @@
-/*
- * Copyright © 1999 Keith Packard
- *
- * 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 Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Keith Packard makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD 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 <mivalidate.h>
-#include <dixstruct.h>
-#include "privates.h"
-#ifdef RANDR
-#include <randrstr.h>
-#endif
-
-#ifdef XV
-#include "kxv.h"
-#endif
-
-#ifdef DPMSExtension
-#include "dpmsproc.h"
-#endif
-
-#ifdef HAVE_EXECINFO_H
-#include <execinfo.h>
-#endif
-
-#include <signal.h>
-
-typedef struct _kdDepths {
- CARD8 depth;
- CARD8 bpp;
-} KdDepths;
-
-KdDepths kdDepths[] = {
- { 1, 1 },
- { 4, 4 },
- { 8, 8 },
- { 15, 16 },
- { 16, 16 },
- { 24, 32 },
- { 32, 32 }
-};
-
-#define NUM_KD_DEPTHS (sizeof (kdDepths) / sizeof (kdDepths[0]))
-
-#define KD_DEFAULT_BUTTONS 5
-
-DevPrivateKeyRec kdScreenPrivateKeyRec;
-unsigned long kdGeneration;
-
-Bool kdVideoTest;
-unsigned long kdVideoTestTime;
-Bool kdEmulateMiddleButton;
-Bool kdRawPointerCoordinates;
-Bool kdDisableZaphod;
-Bool kdAllowZap;
-Bool kdEnabled;
-int kdSubpixelOrder;
-int kdVirtualTerminal = -1;
-Bool kdSwitchPending;
-char *kdSwitchCmd;
-DDXPointRec kdOrigin;
-Bool kdHasPointer = FALSE;
-Bool kdHasKbd = FALSE;
-
-static Bool kdCaughtSignal = FALSE;
-
-/*
- * Carry arguments from InitOutput through driver initialization
- * to KdScreenInit
- */
-
-KdOsFuncs *kdOsFuncs;
-
-void
-KdDisableScreen (ScreenPtr pScreen)
-{
- KdScreenPriv(pScreen);
-
- if (!pScreenPriv->enabled)
- return;
- if (!pScreenPriv->closed)
- SetRootClip (pScreen, FALSE);
- KdDisableColormap (pScreen);
- if (!pScreenPriv->screen->dumb && pScreenPriv->card->cfuncs->disableAccel)
- (*pScreenPriv->card->cfuncs->disableAccel) (pScreen);
- if (!pScreenPriv->screen->softCursor && pScreenPriv->card->cfuncs->disableCursor)
- (*pScreenPriv->card->cfuncs->disableCursor) (pScreen);
- if (pScreenPriv->card->cfuncs->dpms)
- (*pScreenPriv->card->cfuncs->dpms) (pScreen, KD_DPMS_NORMAL);
- pScreenPriv->enabled = FALSE;
- if(pScreenPriv->card->cfuncs->disable)
- (*pScreenPriv->card->cfuncs->disable) (pScreen);
-}
-
-static void
-KdDoSwitchCmd (char *reason)
-{
- if (kdSwitchCmd)
- {
- char *command = malloc(strlen (kdSwitchCmd) +
- 1 +
- strlen (reason) +
- 1);
- if (!command)
- return;
- strcpy (command, kdSwitchCmd);
- strcat (command, " ");
- strcat (command, reason);
- system (command);
- free(command);
- }
-}
-
-void
-KdSuspend (void)
-{
- KdCardInfo *card;
- KdScreenInfo *screen;
-
- if (kdEnabled)
- {
- for (card = kdCardInfo; card; card = card->next)
- {
- for (screen = card->screenList; screen; screen = screen->next)
- if (screen->mynum == card->selected && screen->pScreen)
- KdDisableScreen (screen->pScreen);
- if (card->driver && card->cfuncs->restore)
- (*card->cfuncs->restore) (card);
- }
- KdDisableInput ();
- KdDoSwitchCmd ("suspend");
- }
-}
-
-void
-KdDisableScreens (void)
-{
- KdSuspend ();
- if (kdEnabled)
- {
- if (kdOsFuncs->Disable)
- (*kdOsFuncs->Disable) ();
- kdEnabled = FALSE;
- }
-}
-
-Bool
-KdEnableScreen (ScreenPtr pScreen)
-{
- KdScreenPriv (pScreen);
-
- if (pScreenPriv->enabled)
- return TRUE;
- if(pScreenPriv->card->cfuncs->enable)
- if (!(*pScreenPriv->card->cfuncs->enable) (pScreen))
- return FALSE;
- pScreenPriv->enabled = TRUE;
- pScreenPriv->dpmsState = KD_DPMS_NORMAL;
- pScreenPriv->card->selected = pScreenPriv->screen->mynum;
- if (!pScreenPriv->screen->softCursor && pScreenPriv->card->cfuncs->enableCursor)
- (*pScreenPriv->card->cfuncs->enableCursor) (pScreen);
- if (!pScreenPriv->screen->dumb && pScreenPriv->card->cfuncs->enableAccel)
- (*pScreenPriv->card->cfuncs->enableAccel) (pScreen);
- KdEnableColormap (pScreen);
- SetRootClip (pScreen, TRUE);
- if (pScreenPriv->card->cfuncs->dpms)
- (*pScreenPriv->card->cfuncs->dpms) (pScreen, pScreenPriv->dpmsState);
- return TRUE;
-}
-
-void
-KdResume (void)
-{
- KdCardInfo *card;
- KdScreenInfo *screen;
-
- if (kdEnabled)
- {
- KdDoSwitchCmd ("resume");
- for (card = kdCardInfo; card; card = card->next)
- {
- if(card->cfuncs->preserve)
- (*card->cfuncs->preserve) (card);
- for (screen = card->screenList; screen; screen = screen->next)
- if (screen->mynum == card->selected && screen->pScreen)
- KdEnableScreen (screen->pScreen);
- }
- KdEnableInput ();
- KdReleaseAllKeys ();
- }
-}
-
-void
-KdEnableScreens (void)
-{
- if (!kdEnabled)
- {
- kdEnabled = TRUE;
- if (kdOsFuncs->Enable)
- (*kdOsFuncs->Enable) ();
- }
- KdResume ();
-}
-
-void
-KdProcessSwitch (void)
-{
- if (kdEnabled)
- KdDisableScreens ();
- else
- KdEnableScreens ();
-}
-
-#ifndef _MSC_VER
-void
-AbortDDX(enum ExitCode error)
-{
- KdDisableScreens ();
- if (kdOsFuncs)
- {
- if (kdEnabled && kdOsFuncs->Disable)
- (*kdOsFuncs->Disable) ();
- if (kdOsFuncs->Fini)
- (*kdOsFuncs->Fini) ();
- KdDoSwitchCmd ("stop");
- }
-
- if (kdCaughtSignal)
- OsAbort();
-}
-
-void
-ddxGiveUp (enum ExitCode error)
-{
- AbortDDX (error);
-}
-#endif
-
-Bool kdDumbDriver;
-Bool kdSoftCursor;
-
-char *
-KdParseFindNext (char *cur, char *delim, char *save, char *last)
-{
- while (*cur && !strchr (delim, *cur))
- {
- *save++ = *cur++;
- }
- *save = 0;
- *last = *cur;
- if (*cur)
- cur++;
- return cur;
-}
-
-Rotation
-KdAddRotation (Rotation a, Rotation b)
-{
- Rotation rotate = (a & RR_Rotate_All) * (b & RR_Rotate_All);
- Rotation reflect = (a & RR_Reflect_All) ^ (b & RR_Reflect_All);
-
- if (rotate > RR_Rotate_270)
- rotate /= (RR_Rotate_270 * RR_Rotate_90);
- return reflect | rotate;
-}
-
-Rotation
-KdSubRotation (Rotation a, Rotation b)
-{
- Rotation rotate = (a & RR_Rotate_All) * 16 / (b & RR_Rotate_All);
- Rotation reflect = (a & RR_Reflect_All) ^ (b & RR_Reflect_All);
-
- if (rotate > RR_Rotate_270)
- rotate /= (RR_Rotate_270 * RR_Rotate_90);
- return reflect | rotate;
-}
-
-void
-KdParseScreen (KdScreenInfo *screen,
- char *arg)
-{
- char delim;
- char save[1024];
- int i;
- int pixels, mm;
-
- screen->dumb = kdDumbDriver;
- screen->softCursor = kdSoftCursor;
- screen->origin = kdOrigin;
- screen->randr = RR_Rotate_0;
- screen->width = 0;
- screen->height = 0;
- screen->width_mm = 0;
- screen->height_mm = 0;
- screen->subpixel_order = kdSubpixelOrder;
- screen->rate = 0;
- screen->fb.depth = 0;
- if (!arg)
- return;
- if (strlen (arg) >= sizeof (save))
- return;
-
- for (i = 0; i < 2; i++)
- {
- arg = KdParseFindNext (arg, "x/@XY", save, &delim);
- if (!save[0])
- return;
-
- pixels = atoi(save);
- mm = 0;
-
- if (delim == '/')
- {
- arg = KdParseFindNext (arg, "x@XY", save, &delim);
- if (!save[0])
- return;
- mm = atoi(save);
- }
-
- if (i == 0)
- {
- screen->width = pixels;
- screen->width_mm = mm;
- }
- else
- {
- screen->height = pixels;
- screen->height_mm = mm;
- }
- if (delim != 'x' && delim != '@' && delim != 'X' && delim != 'Y')
- return;
- }
-
- kdOrigin.x += screen->width;
- kdOrigin.y = 0;
- kdDumbDriver = FALSE;
- kdSoftCursor = FALSE;
- kdSubpixelOrder = SubPixelUnknown;
-
- if (delim == '@')
- {
- arg = KdParseFindNext (arg, "xXY", save, &delim);
- if (save[0])
- {
- int rotate = atoi (save);
- if (rotate < 45)
- screen->randr = RR_Rotate_0;
- else if (rotate < 135)
- screen->randr = RR_Rotate_90;
- else if (rotate < 225)
- screen->randr = RR_Rotate_180;
- else if (rotate < 315)
- screen->randr = RR_Rotate_270;
- else
- screen->randr = RR_Rotate_0;
- }
- }
- if (delim == 'X')
- {
- arg = KdParseFindNext (arg, "xY", save, &delim);
- screen->randr |= RR_Reflect_X;
- }
-
- if (delim == 'Y')
- {
- arg = KdParseFindNext (arg, "xY", save, &delim);
- screen->randr |= RR_Reflect_Y;
- }
-
- arg = KdParseFindNext (arg, "x/,", save, &delim);
- if (save[0])
- {
- screen->fb.depth = atoi(save);
- if (delim == '/')
- {
- arg = KdParseFindNext (arg, "x,", save, &delim);
- if (save[0])
- screen->fb.bitsPerPixel = atoi (save);
- }
- else
- screen->fb.bitsPerPixel = 0;
- }
-
- if (delim == 'x')
- {
- arg = KdParseFindNext (arg, "x", save, &delim);
- if (save[0])
- screen->rate = atoi(save);
- }
-}
-
-/*
- * Mouse argument syntax:
- *
- * device,protocol,options...
- *
- * Options are any of:
- * 1-5 n button mouse
- * 2button emulate middle button
- * {NMO} Reorder buttons
- */
-
-void
-KdParseRgba (char *rgba)
-{
- if (!strcmp (rgba, "rgb"))
- kdSubpixelOrder = SubPixelHorizontalRGB;
- else if (!strcmp (rgba, "bgr"))
- kdSubpixelOrder = SubPixelHorizontalBGR;
- else if (!strcmp (rgba, "vrgb"))
- kdSubpixelOrder = SubPixelVerticalRGB;
- else if (!strcmp (rgba, "vbgr"))
- kdSubpixelOrder = SubPixelVerticalBGR;
- else if (!strcmp (rgba, "none"))
- kdSubpixelOrder = SubPixelNone;
- else
- kdSubpixelOrder = SubPixelUnknown;
-}
-
-void
-KdUseMsg (void)
-{
- ErrorF("\nTinyX Device Dependent Usage:\n");
- ErrorF("-screen WIDTH[/WIDTHMM]xHEIGHT[/HEIGHTMM][@ROTATION][X][Y][xDEPTH/BPP[xFREQ]] Specify screen characteristics\n");
- ErrorF("-rgba rgb/bgr/vrgb/vbgr/none Specify subpixel ordering for LCD panels\n");
- ErrorF("-mouse driver [,n,,options] Specify the pointer driver and its options (n is the number of buttons)\n");
- ErrorF("-keybd driver [,,options] Specify the keyboard driver and its options\n");
- ErrorF("-zaphod Disable cursor screen switching\n");
- ErrorF("-2button Emulate 3 button mouse\n");
- ErrorF("-3button Disable 3 button mouse emulation\n");
- ErrorF("-rawcoord Don't transform pointer coordinates on rotation\n");
- ErrorF("-dumb Disable hardware acceleration\n");
- ErrorF("-softCursor Force software cursor\n");
- ErrorF("-videoTest Start the server, pause momentarily and exit\n");
- ErrorF("-origin X,Y Locates the next screen in the the virtual screen (Xinerama)\n");
- ErrorF("-switchCmd Command to execute on vt switch\n");
- ErrorF("-zap Terminate server on Ctrl+Alt+Backspace\n");
- ErrorF("vtxx Use virtual terminal xx instead of the next available\n");
-}
-
-int
-KdProcessArgument (int argc, char **argv, int i)
-{
- KdCardInfo *card;
- KdScreenInfo *screen;
-
- if (!strcmp (argv[i], "-screen"))
- {
- if ((i+1) < argc)
- {
- card = KdCardInfoLast ();
- if (!card)
- {
- InitCard (0);
- card = KdCardInfoLast ();
- }
- if (card) {
- screen = KdScreenInfoAdd (card);
- KdParseScreen (screen, argv[i+1]);
- } else
- ErrorF("No matching card found!\n");
- }
- else
- UseMsg ();
- return 2;
- }
- if (!strcmp (argv[i], "-zaphod"))
- {
- kdDisableZaphod = TRUE;
- return 1;
- }
- if (!strcmp (argv[i], "-zap"))
- {
- kdAllowZap = TRUE;
- return 1;
- }
- if (!strcmp (argv[i], "-3button"))
- {
- kdEmulateMiddleButton = FALSE;
- return 1;
- }
- if (!strcmp (argv[i], "-2button"))
- {
- kdEmulateMiddleButton = TRUE;
- return 1;
- }
- if (!strcmp (argv[i], "-rawcoord"))
- {
- kdRawPointerCoordinates = 1;
- return 1;
- }
- if (!strcmp (argv[i], "-dumb"))
- {
- kdDumbDriver = TRUE;
- return 1;
- }
- if (!strcmp (argv[i], "-softCursor"))
- {
- kdSoftCursor = TRUE;
- return 1;
- }
- if (!strcmp (argv[i], "-videoTest"))
- {
- kdVideoTest = TRUE;
- return 1;
- }
- if (!strcmp (argv[i], "-origin"))
- {
- if ((i+1) < argc)
- {
- char *x = argv[i+1];
- char *y = strchr (x, ',');
- if (x)
- kdOrigin.x = atoi (x);
- else
- kdOrigin.x = 0;
- if (y)
- kdOrigin.y = atoi(y+1);
- else
- kdOrigin.y = 0;
- }
- else
- UseMsg ();
- return 2;
- }
- if (!strcmp (argv[i], "-rgba"))
- {
- if ((i+1) < argc)
- KdParseRgba (argv[i+1]);
- else
- UseMsg ();
- return 2;
- }
- if (!strcmp (argv[i], "-switchCmd"))
- {
- if ((i+1) < argc)
- kdSwitchCmd = argv[i+1];
- else
- UseMsg ();
- return 2;
- }
- if (!strncmp (argv[i], "vt", 2) &&
- sscanf (argv[i], "vt%2d", &kdVirtualTerminal) == 1)
- {
- return 1;
- }
- if (!strcmp (argv[i], "-mouse") ||
- !strcmp (argv[i], "-pointer")) {
- if (i + 1 >= argc)
- UseMsg();
- KdAddConfigPointer(argv[i + 1]);
- kdHasPointer = TRUE;
- return 2;
- }
- if (!strcmp (argv[i], "-keybd")) {
- if (i + 1 >= argc)
- UseMsg();
- KdAddConfigKeyboard(argv[i + 1]);
- kdHasKbd = TRUE;
- return 2;
- }
-
- return 0;
-}
-
-/*
- * These are getting tossed in here until I can think of where
- * they really belong
- */
-
-void
-KdOsInit (KdOsFuncs *pOsFuncs)
-{
- kdOsFuncs = pOsFuncs;
- if (pOsFuncs)
- {
- if (serverGeneration == 1)
- {
- KdDoSwitchCmd ("start");
- if (pOsFuncs->Init)
- (*pOsFuncs->Init) ();
- }
- }
-}
-
-Bool
-KdAllocatePrivates (ScreenPtr pScreen)
-{
- KdPrivScreenPtr pScreenPriv;
-
- if (kdGeneration != serverGeneration)
- kdGeneration = serverGeneration;
-
- if (!dixRegisterPrivateKey(&kdScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
- return FALSE;
-
- pScreenPriv = calloc(1, sizeof (*pScreenPriv));
- if (!pScreenPriv)
- return FALSE;
- KdSetScreenPriv (pScreen, pScreenPriv);
- return TRUE;
-}
-
-Bool
-KdCreateScreenResources (ScreenPtr pScreen)
-{
- KdScreenPriv(pScreen);
- KdCardInfo *card = pScreenPriv->card;
- Bool ret;
-
- pScreen->CreateScreenResources = pScreenPriv->CreateScreenResources;
- if(pScreen->CreateScreenResources)
- ret = (*pScreen->CreateScreenResources) (pScreen);
- else
- ret= -1;
- pScreenPriv->CreateScreenResources = pScreen->CreateScreenResources;
- pScreen->CreateScreenResources = KdCreateScreenResources;
- if (ret && card->cfuncs->createRes)
- ret = (*card->cfuncs->createRes) (pScreen);
- return ret;
-}
-
-Bool
-KdCloseScreen (int index, ScreenPtr pScreen)
-{
- KdScreenPriv(pScreen);
- KdScreenInfo *screen = pScreenPriv->screen;
- KdCardInfo *card = pScreenPriv->card;
- Bool ret;
-
- pScreenPriv->closed = TRUE;
- pScreen->CloseScreen = pScreenPriv->CloseScreen;
- if(pScreen->CloseScreen)
- ret = (*pScreen->CloseScreen) (index, pScreen);
- else
- ret = TRUE;
-
- if (pScreenPriv->dpmsState != KD_DPMS_NORMAL)
- (*card->cfuncs->dpms) (pScreen, KD_DPMS_NORMAL);
-
- if (screen->mynum == card->selected)
- KdDisableScreen (pScreen);
-
- /*
- * Restore video hardware when last screen is closed
- */
- if (screen == card->screenList)
- {
- if (kdEnabled && card->cfuncs->restore)
- (*card->cfuncs->restore) (card);
- }
-
- if (!pScreenPriv->screen->dumb && card->cfuncs->finiAccel)
- (*card->cfuncs->finiAccel) (pScreen);
-
- if (!pScreenPriv->screen->softCursor && card->cfuncs->finiCursor)
- (*card->cfuncs->finiCursor) (pScreen);
-
- if(card->cfuncs->scrfini)
- (*card->cfuncs->scrfini) (screen);
-
- /*
- * Clean up card when last screen is closed, DIX closes them in
- * reverse order, thus we check for when the first in the list is closed
- */
- if (screen == card->screenList)
- {
- if(card->cfuncs->cardfini)
- (*card->cfuncs->cardfini) (card);
- /*
- * Clean up OS when last card is closed
- */
- if (card == kdCardInfo)
- {
- if (kdEnabled)
- {
- kdEnabled = FALSE;
- if(kdOsFuncs->Disable)
- (*kdOsFuncs->Disable) ();
- }
- }
- }
-
- pScreenPriv->screen->pScreen = 0;
-
- free((pointer) pScreenPriv);
- return ret;
-}
-
-Bool
-KdSaveScreen (ScreenPtr pScreen, int on)
-{
- KdScreenPriv(pScreen);
- int dpmsState;
-
- if (!pScreenPriv->card->cfuncs->dpms)
- return FALSE;
-
- dpmsState = pScreenPriv->dpmsState;
- switch (on) {
- case SCREEN_SAVER_OFF:
- dpmsState = KD_DPMS_NORMAL;
- break;
- case SCREEN_SAVER_ON:
- if (dpmsState == KD_DPMS_NORMAL)
- dpmsState = KD_DPMS_NORMAL+1;
- break;
- case SCREEN_SAVER_CYCLE:
- if (dpmsState < KD_DPMS_MAX)
- dpmsState++;
- break;
- case SCREEN_SAVER_FORCER:
- break;
- }
- if (dpmsState != pScreenPriv->dpmsState)
- {
- if (pScreenPriv->enabled)
- (*pScreenPriv->card->cfuncs->dpms) (pScreen, dpmsState);
- pScreenPriv->dpmsState = dpmsState;
- }
- return TRUE;
-}
-
-static Bool
-KdCreateWindow (WindowPtr pWin)
-{
-#ifndef PHOENIX
- if (!pWin->parent)
- {
- KdScreenPriv(pWin->drawable.pScreen);
-
- if (!pScreenPriv->enabled)
- {
- RegionEmpty(&pWin->borderClip);
- RegionBreak(&pWin->clipList);
- }
- }
-#endif
- return fbCreateWindow (pWin);
-}
-
-void
-KdSetSubpixelOrder (ScreenPtr pScreen, Rotation randr)
-{
- KdScreenPriv(pScreen);
- KdScreenInfo *screen = pScreenPriv->screen;
- int subpixel_order = screen->subpixel_order;
- Rotation subpixel_dir;
- int i;
-
- static struct {
- int subpixel_order;
- Rotation direction;
- } orders[] = {
- { SubPixelHorizontalRGB, RR_Rotate_0 },
- { SubPixelHorizontalBGR, RR_Rotate_180 },
- { SubPixelVerticalRGB, RR_Rotate_270 },
- { SubPixelVerticalBGR, RR_Rotate_90 },
- };
-
- static struct {
- int bit;
- int normal;
- int reflect;
- } reflects[] = {
- { RR_Reflect_X, SubPixelHorizontalRGB, SubPixelHorizontalBGR },
- { RR_Reflect_X, SubPixelHorizontalBGR, SubPixelHorizontalRGB },
- { RR_Reflect_Y, SubPixelVerticalRGB, SubPixelVerticalBGR },
- { RR_Reflect_Y, SubPixelVerticalRGB, SubPixelVerticalRGB },
- };
-
- /* map subpixel to direction */
- for (i = 0; i < 4; i++)
- if (orders[i].subpixel_order == subpixel_order)
- break;
- if (i < 4)
- {
- subpixel_dir = KdAddRotation (randr & RR_Rotate_All, orders[i].direction);
-
- /* map back to subpixel order */
- for (i = 0; i < 4; i++)
- if (orders[i].direction & subpixel_dir)
- {
- subpixel_order = orders[i].subpixel_order;
- break;
- }
- /* reflect */
- for (i = 0; i < 4; i++)
- if ((randr & reflects[i].bit) &&
- reflects[i].normal == subpixel_order)
- {
- subpixel_order = reflects[i].reflect;
- break;
- }
- }
- PictureSetSubpixelOrder (pScreen, subpixel_order);
-}
-
-/* Pass through AddScreen, which doesn't take any closure */
-static KdScreenInfo *kdCurrentScreen;
-
-Bool
-KdScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
-{
- KdScreenInfo *screen = kdCurrentScreen;
- KdCardInfo *card = screen->card;
- KdPrivScreenPtr pScreenPriv;
- /*
- * note that screen->fb is set up for the nominal orientation
- * of the screen; that means if randr is rotated, the values
- * there should reflect a rotated frame buffer (or shadow).
- */
- Bool rotated = (screen->randr & (RR_Rotate_90|RR_Rotate_270)) != 0;
- int width, height, *width_mmp, *height_mmp;
-
- KdAllocatePrivates (pScreen);
-
- pScreenPriv = KdGetScreenPriv(pScreen);
-
- if (!rotated)
- {
- width = screen->width;
- height = screen->height;
- width_mmp = &screen->width_mm;
- height_mmp = &screen->height_mm;
- }
- else
- {
- width = screen->height;
- height = screen->width;
- width_mmp = &screen->height_mm;
- height_mmp = &screen->width_mm;
- }
- screen->pScreen = pScreen;
- pScreenPriv->screen = screen;
- pScreenPriv->card = card;
- pScreenPriv->bytesPerPixel = screen->fb.bitsPerPixel >> 3;
- pScreenPriv->dpmsState = KD_DPMS_NORMAL;
- pScreen->x = screen->origin.x;
- pScreen->y = screen->origin.y;
-
- if (!monitorResolution)
- monitorResolution = 75;
- /*
- * This is done in this order so that backing store wraps
- * our GC functions; fbFinishScreenInit initializes MI
- * backing store
- */
- if (!fbSetupScreen (pScreen,
- screen->fb.frameBuffer,
- width, height,
- monitorResolution, monitorResolution,
- screen->fb.pixelStride,
- screen->fb.bitsPerPixel))
- {
- return FALSE;
- }
-
- /*
- * Set colormap functions
- */
- pScreen->InstallColormap = KdInstallColormap;
- pScreen->UninstallColormap = KdUninstallColormap;
- pScreen->ListInstalledColormaps = KdListInstalledColormaps;
- pScreen->StoreColors = KdStoreColors;
-
- pScreen->SaveScreen = KdSaveScreen;
- pScreen->CreateWindow = KdCreateWindow;
-
- if (!fbFinishScreenInit (pScreen,
- screen->fb.frameBuffer,
- width, height,
- monitorResolution, monitorResolution,
- screen->fb.pixelStride,
- screen->fb.bitsPerPixel))
- {
- return FALSE;
- }
-
- /*
- * Fix screen sizes; for some reason mi takes dpi instead of mm.
- * Rounding errors are annoying
- */
- if (*width_mmp)
- pScreen->mmWidth = *width_mmp;
- else
- *width_mmp = pScreen->mmWidth;
- if (*height_mmp)
- pScreen->mmHeight = *height_mmp;
- else
- *height_mmp = pScreen->mmHeight;
-
- /*
- * Plug in our own block/wakeup handlers.
- * miScreenInit installs NoopDDA in both places
- */
- pScreen->BlockHandler = KdBlockHandler;
- pScreen->WakeupHandler = KdWakeupHandler;
-
- if (!fbPictureInit (pScreen, 0, 0))
- return FALSE;
- if (card->cfuncs->initScreen)
- if (!(*card->cfuncs->initScreen) (pScreen))
- return FALSE;
-
- if (!screen->dumb && card->cfuncs->initAccel)
- if (!(*card->cfuncs->initAccel) (pScreen))
- screen->dumb = TRUE;
-
- if (card->cfuncs->finishInitScreen)
- if (!(*card->cfuncs->finishInitScreen) (pScreen))
- return FALSE;
-
-#if 0
- fbInitValidateTree (pScreen);
-#endif
-
- /*
- * Wrap CloseScreen, the order now is:
- * KdCloseScreen
- * miBSCloseScreen
- * fbCloseScreen
- */
- pScreenPriv->CloseScreen = pScreen->CloseScreen;
- pScreen->CloseScreen = KdCloseScreen;
-
- pScreenPriv->CreateScreenResources = pScreen->CreateScreenResources;
- pScreen->CreateScreenResources = KdCreateScreenResources;
-
- if (screen->softCursor ||
- !card->cfuncs->initCursor ||
- !(*card->cfuncs->initCursor) (pScreen))
- {
- /* Use MI for cursor display and event queueing. */
- screen->softCursor = TRUE;
- miDCInitialize(pScreen, &kdPointerScreenFuncs);
- }
-
-
- if (!fbCreateDefColormap (pScreen))
- {
- return FALSE;
- }
-
- KdSetSubpixelOrder (pScreen, screen->randr);
-
- /*
- * Enable the hardware
- */
- if (!kdEnabled)
- {
- kdEnabled = TRUE;
- if(kdOsFuncs->Enable)
- (*kdOsFuncs->Enable) ();
- }
-
- if (screen->mynum == card->selected)
- {
- if(card->cfuncs->preserve)
- (*card->cfuncs->preserve) (card);
- if(card->cfuncs->enable)
- if (!(*card->cfuncs->enable) (pScreen))
- return FALSE;
- pScreenPriv->enabled = TRUE;
- if (!screen->softCursor && card->cfuncs->enableCursor)
- (*card->cfuncs->enableCursor) (pScreen);
- KdEnableColormap (pScreen);
- if (!screen->dumb && card->cfuncs->enableAccel)
- (*card->cfuncs->enableAccel) (pScreen);
- }
-
- return TRUE;
-}
-
-void
-KdInitScreen (ScreenInfo *pScreenInfo,
- KdScreenInfo *screen,
- int argc,
- char **argv)
-{
- KdCardInfo *card = screen->card;
-
- (*card->cfuncs->scrinit) (screen);
-
- if (!card->cfuncs->initAccel)
- screen->dumb = TRUE;
- if (!card->cfuncs->initCursor)
- screen->softCursor = TRUE;
-}
-
-static Bool
-KdSetPixmapFormats (ScreenInfo *pScreenInfo)
-{
- CARD8 depthToBpp[33]; /* depth -> bpp map */
- KdCardInfo *card;
- KdScreenInfo *screen;
- int i;
- int bpp;
- PixmapFormatRec *format;
-
- for (i = 1; i <= 32; i++)
- depthToBpp[i] = 0;
-
- /*
- * Generate mappings between bitsPerPixel and depth,
- * also ensure that all screens comply with protocol
- * restrictions on equivalent formats for the same
- * depth on different screens
- */
- for (card = kdCardInfo; card; card = card->next)
- {
- for (screen = card->screenList; screen; screen = screen->next)
- {
- bpp = screen->fb.bitsPerPixel;
- if (bpp == 24)
- bpp = 32;
- if (!depthToBpp[screen->fb.depth])
- depthToBpp[screen->fb.depth] = bpp;
- else if (depthToBpp[screen->fb.depth] != bpp)
- return FALSE;
- }
- }
-
- /*
- * Fill in additional formats
- */
- for (i = 0; i < NUM_KD_DEPTHS; i++)
- if (!depthToBpp[kdDepths[i].depth])
- depthToBpp[kdDepths[i].depth] = kdDepths[i].bpp;
-
- pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
- pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
- pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
- pScreenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
-
- pScreenInfo->numPixmapFormats = 0;
-
- for (i = 1; i <= 32; i++)
- {
- if (depthToBpp[i])
- {
- format = &pScreenInfo->formats[pScreenInfo->numPixmapFormats++];
- format->depth = i;
- format->bitsPerPixel = depthToBpp[i];
- format->scanlinePad = BITMAP_SCANLINE_PAD;
- }
- }
-
- return TRUE;
-}
-
-static void
-KdAddScreen (ScreenInfo *pScreenInfo,
- KdScreenInfo *screen,
- int argc,
- char **argv)
-{
- int i;
- /*
- * Fill in fb visual type masks for this screen
- */
- for (i = 0; i < pScreenInfo->numPixmapFormats; i++)
- {
- unsigned long visuals;
- Pixel rm, gm, bm;
-
- visuals = 0;
- rm = gm = bm = 0;
- if (pScreenInfo->formats[i].depth == screen->fb.depth)
- {
- visuals = screen->fb.visuals;
- rm = screen->fb.redMask;
- gm = screen->fb.greenMask;
- bm = screen->fb.blueMask;
- }
- fbSetVisualTypesAndMasks (pScreenInfo->formats[i].depth,
- visuals,
- 8,
- rm, gm, bm);
- }
-
- kdCurrentScreen = screen;
-
- AddScreen (KdScreenInit, argc, argv);
-}
-
-#if 0 /* This function is not used currently */
-
-int
-KdDepthToFb (ScreenPtr pScreen, int depth)
-{
- KdScreenPriv(pScreen);
-
- for (fb = 0; fb <= KD_MAX_FB && pScreenPriv->screen->fb.frameBuffer; fb++)
- if (pScreenPriv->screen->fb.depth == depth)
- return fb;
-}
-
-#endif
-
-static int
-KdSignalWrapper (int signum)
-{
- kdCaughtSignal = TRUE;
- return 1; /* use generic OS layer cleanup & abort */
-}
-
-void
-KdInitOutput (ScreenInfo *pScreenInfo,
- int argc,
- char **argv)
-{
- KdCardInfo *card;
- KdScreenInfo *screen;
-
- if (!kdCardInfo)
- {
- InitCard (0);
- if (!(card = KdCardInfoLast ()))
- FatalError("No matching cards found!\n");
- screen = KdScreenInfoAdd (card);
- KdParseScreen (screen, 0);
- }
- /*
- * Initialize all of the screens for all of the cards
- */
- for (card = kdCardInfo; card; card = card->next)
- {
- int ret=1;
- if(card->cfuncs->cardinit)
- ret=(*card->cfuncs->cardinit) (card);
- if (ret)
- {
- for (screen = card->screenList; screen; screen = screen->next)
- KdInitScreen (pScreenInfo, screen, argc, argv);
- }
- }
-
- /*
- * Merge the various pixmap formats together, this can fail
- * when two screens share depth but not bitsPerPixel
- */
- if (!KdSetPixmapFormats (pScreenInfo))
- return;
-
- /*
- * Add all of the screens
- */
- for (card = kdCardInfo; card; card = card->next)
- for (screen = card->screenList; screen; screen = screen->next)
- KdAddScreen (pScreenInfo, screen, argc, argv);
-
- OsRegisterSigWrapper(KdSignalWrapper);
-}
-
-#ifndef _MSC_VER
-void
-OsVendorFatalError(void)
-{
-}
-
-int
-DPMSSet(ClientPtr client, int level)
-{
- return Success;
-}
-
-Bool
-DPMSSupported (void)
-{
- return FALSE;
-}
-#endif
+/*
+ * Copyright © 1999 Keith Packard
+ *
+ * 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 Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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 <mivalidate.h>
+#include <dixstruct.h>
+#include "privates.h"
+#ifdef RANDR
+#include <randrstr.h>
+#endif
+
+#ifdef XV
+#include "kxv.h"
+#endif
+
+#ifdef DPMSExtension
+#include "dpmsproc.h"
+#endif
+
+#ifdef HAVE_EXECINFO_H
+#include <execinfo.h>
+#endif
+
+#include <signal.h>
+
+typedef struct _kdDepths {
+ CARD8 depth;
+ CARD8 bpp;
+} KdDepths;
+
+KdDepths kdDepths[] = {
+ { 1, 1 },
+ { 4, 4 },
+ { 8, 8 },
+ { 15, 16 },
+ { 16, 16 },
+ { 24, 32 },
+ { 32, 32 }
+};
+
+#define NUM_KD_DEPTHS (sizeof (kdDepths) / sizeof (kdDepths[0]))
+
+#define KD_DEFAULT_BUTTONS 5
+
+DevPrivateKeyRec kdScreenPrivateKeyRec;
+unsigned long kdGeneration;
+
+Bool kdVideoTest;
+unsigned long kdVideoTestTime;
+Bool kdEmulateMiddleButton;
+Bool kdRawPointerCoordinates;
+Bool kdDisableZaphod;
+Bool kdAllowZap;
+Bool kdEnabled;
+int kdSubpixelOrder;
+int kdVirtualTerminal = -1;
+Bool kdSwitchPending;
+char *kdSwitchCmd;
+DDXPointRec kdOrigin;
+Bool kdHasPointer = FALSE;
+Bool kdHasKbd = FALSE;
+
+static Bool kdCaughtSignal = FALSE;
+
+/*
+ * Carry arguments from InitOutput through driver initialization
+ * to KdScreenInit
+ */
+
+KdOsFuncs *kdOsFuncs;
+
+void
+KdDisableScreen (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+
+ if (!pScreenPriv->enabled)
+ return;
+ if (!pScreenPriv->closed)
+ SetRootClip (pScreen, FALSE);
+ KdDisableColormap (pScreen);
+ if (!pScreenPriv->screen->dumb && pScreenPriv->card->cfuncs->disableAccel)
+ (*pScreenPriv->card->cfuncs->disableAccel) (pScreen);
+ if (!pScreenPriv->screen->softCursor && pScreenPriv->card->cfuncs->disableCursor)
+ (*pScreenPriv->card->cfuncs->disableCursor) (pScreen);
+ if (pScreenPriv->card->cfuncs->dpms)
+ (*pScreenPriv->card->cfuncs->dpms) (pScreen, KD_DPMS_NORMAL);
+ pScreenPriv->enabled = FALSE;
+ if(pScreenPriv->card->cfuncs->disable)
+ (*pScreenPriv->card->cfuncs->disable) (pScreen);
+}
+
+static void
+KdDoSwitchCmd (char *reason)
+{
+ if (kdSwitchCmd)
+ {
+ char *command = malloc(strlen (kdSwitchCmd) +
+ 1 +
+ strlen (reason) +
+ 1);
+ if (!command)
+ return;
+ strcpy (command, kdSwitchCmd);
+ strcat (command, " ");
+ strcat (command, reason);
+ system (command);
+ free(command);
+ }
+}
+
+void
+KdSuspend (void)
+{
+ KdCardInfo *card;
+ KdScreenInfo *screen;
+
+ if (kdEnabled)
+ {
+ for (card = kdCardInfo; card; card = card->next)
+ {
+ for (screen = card->screenList; screen; screen = screen->next)
+ if (screen->mynum == card->selected && screen->pScreen)
+ KdDisableScreen (screen->pScreen);
+ if (card->driver && card->cfuncs->restore)
+ (*card->cfuncs->restore) (card);
+ }
+ KdDisableInput ();
+ KdDoSwitchCmd ("suspend");
+ }
+}
+
+void
+KdDisableScreens (void)
+{
+ KdSuspend ();
+ if (kdEnabled)
+ {
+ if (kdOsFuncs->Disable)
+ (*kdOsFuncs->Disable) ();
+ kdEnabled = FALSE;
+ }
+}
+
+Bool
+KdEnableScreen (ScreenPtr pScreen)
+{
+ KdScreenPriv (pScreen);
+
+ if (pScreenPriv->enabled)
+ return TRUE;
+ if(pScreenPriv->card->cfuncs->enable)
+ if (!(*pScreenPriv->card->cfuncs->enable) (pScreen))
+ return FALSE;
+ pScreenPriv->enabled = TRUE;
+ pScreenPriv->dpmsState = KD_DPMS_NORMAL;
+ pScreenPriv->card->selected = pScreenPriv->screen->mynum;
+ if (!pScreenPriv->screen->softCursor && pScreenPriv->card->cfuncs->enableCursor)
+ (*pScreenPriv->card->cfuncs->enableCursor) (pScreen);
+ if (!pScreenPriv->screen->dumb && pScreenPriv->card->cfuncs->enableAccel)
+ (*pScreenPriv->card->cfuncs->enableAccel) (pScreen);
+ KdEnableColormap (pScreen);
+ SetRootClip (pScreen, TRUE);
+ if (pScreenPriv->card->cfuncs->dpms)
+ (*pScreenPriv->card->cfuncs->dpms) (pScreen, pScreenPriv->dpmsState);
+ return TRUE;
+}
+
+void
+KdResume (void)
+{
+ KdCardInfo *card;
+ KdScreenInfo *screen;
+
+ if (kdEnabled)
+ {
+ KdDoSwitchCmd ("resume");
+ for (card = kdCardInfo; card; card = card->next)
+ {
+ if(card->cfuncs->preserve)
+ (*card->cfuncs->preserve) (card);
+ for (screen = card->screenList; screen; screen = screen->next)
+ if (screen->mynum == card->selected && screen->pScreen)
+ KdEnableScreen (screen->pScreen);
+ }
+ KdEnableInput ();
+ KdReleaseAllKeys ();
+ }
+}
+
+void
+KdEnableScreens (void)
+{
+ if (!kdEnabled)
+ {
+ kdEnabled = TRUE;
+ if (kdOsFuncs->Enable)
+ (*kdOsFuncs->Enable) ();
+ }
+ KdResume ();
+}
+
+void
+KdProcessSwitch (void)
+{
+ if (kdEnabled)
+ KdDisableScreens ();
+ else
+ KdEnableScreens ();
+}
+
+#ifndef _MSC_VER
+void
+AbortDDX(enum ExitCode error)
+{
+ KdDisableScreens ();
+ if (kdOsFuncs)
+ {
+ if (kdEnabled && kdOsFuncs->Disable)
+ (*kdOsFuncs->Disable) ();
+ if (kdOsFuncs->Fini)
+ (*kdOsFuncs->Fini) ();
+ KdDoSwitchCmd ("stop");
+ }
+
+ if (kdCaughtSignal)
+ OsAbort();
+}
+
+void
+ddxGiveUp (enum ExitCode error)
+{
+ AbortDDX (error);
+}
+#endif
+
+Bool kdDumbDriver;
+Bool kdSoftCursor;
+
+char *
+KdParseFindNext (char *cur, char *delim, char *save, char *last)
+{
+ while (*cur && !strchr (delim, *cur))
+ {
+ *save++ = *cur++;
+ }
+ *save = 0;
+ *last = *cur;
+ if (*cur)
+ cur++;
+ return cur;
+}
+
+Rotation
+KdAddRotation (Rotation a, Rotation b)
+{
+ Rotation rotate = (a & RR_Rotate_All) * (b & RR_Rotate_All);
+ Rotation reflect = (a & RR_Reflect_All) ^ (b & RR_Reflect_All);
+
+ if (rotate > RR_Rotate_270)
+ rotate /= (RR_Rotate_270 * RR_Rotate_90);
+ return reflect | rotate;
+}
+
+Rotation
+KdSubRotation (Rotation a, Rotation b)
+{
+ Rotation rotate = (a & RR_Rotate_All) * 16 / (b & RR_Rotate_All);
+ Rotation reflect = (a & RR_Reflect_All) ^ (b & RR_Reflect_All);
+
+ if (rotate > RR_Rotate_270)
+ rotate /= (RR_Rotate_270 * RR_Rotate_90);
+ return reflect | rotate;
+}
+
+void
+KdParseScreen (KdScreenInfo *screen,
+ char *arg)
+{
+ char delim;
+ char save[1024];
+ int i;
+ int pixels, mm;
+
+ screen->dumb = kdDumbDriver;
+ screen->softCursor = kdSoftCursor;
+ screen->origin = kdOrigin;
+ screen->randr = RR_Rotate_0;
+ screen->width = 0;
+ screen->height = 0;
+ screen->width_mm = 0;
+ screen->height_mm = 0;
+ screen->subpixel_order = kdSubpixelOrder;
+ screen->rate = 0;
+ screen->fb.depth = 0;
+ if (!arg)
+ return;
+ if (strlen (arg) >= sizeof (save))
+ return;
+
+ for (i = 0; i < 2; i++)
+ {
+ arg = KdParseFindNext (arg, "x/@XY", save, &delim);
+ if (!save[0])
+ return;
+
+ pixels = atoi(save);
+ mm = 0;
+
+ if (delim == '/')
+ {
+ arg = KdParseFindNext (arg, "x@XY", save, &delim);
+ if (!save[0])
+ return;
+ mm = atoi(save);
+ }
+
+ if (i == 0)
+ {
+ screen->width = pixels;
+ screen->width_mm = mm;
+ }
+ else
+ {
+ screen->height = pixels;
+ screen->height_mm = mm;
+ }
+ if (delim != 'x' && delim != '@' && delim != 'X' && delim != 'Y')
+ return;
+ }
+
+ kdOrigin.x += screen->width;
+ kdOrigin.y = 0;
+ kdDumbDriver = FALSE;
+ kdSoftCursor = FALSE;
+ kdSubpixelOrder = SubPixelUnknown;
+
+ if (delim == '@')
+ {
+ arg = KdParseFindNext (arg, "xXY", save, &delim);
+ if (save[0])
+ {
+ int rotate = atoi (save);
+ if (rotate < 45)
+ screen->randr = RR_Rotate_0;
+ else if (rotate < 135)
+ screen->randr = RR_Rotate_90;
+ else if (rotate < 225)
+ screen->randr = RR_Rotate_180;
+ else if (rotate < 315)
+ screen->randr = RR_Rotate_270;
+ else
+ screen->randr = RR_Rotate_0;
+ }
+ }
+ if (delim == 'X')
+ {
+ arg = KdParseFindNext (arg, "xY", save, &delim);
+ screen->randr |= RR_Reflect_X;
+ }
+
+ if (delim == 'Y')
+ {
+ arg = KdParseFindNext (arg, "xY", save, &delim);
+ screen->randr |= RR_Reflect_Y;
+ }
+
+ arg = KdParseFindNext (arg, "x/,", save, &delim);
+ if (save[0])
+ {
+ screen->fb.depth = atoi(save);
+ if (delim == '/')
+ {
+ arg = KdParseFindNext (arg, "x,", save, &delim);
+ if (save[0])
+ screen->fb.bitsPerPixel = atoi (save);
+ }
+ else
+ screen->fb.bitsPerPixel = 0;
+ }
+
+ if (delim == 'x')
+ {
+ arg = KdParseFindNext (arg, "x", save, &delim);
+ if (save[0])
+ screen->rate = atoi(save);
+ }
+}
+
+/*
+ * Mouse argument syntax:
+ *
+ * device,protocol,options...
+ *
+ * Options are any of:
+ * 1-5 n button mouse
+ * 2button emulate middle button
+ * {NMO} Reorder buttons
+ */
+
+void
+KdParseRgba (char *rgba)
+{
+ if (!strcmp (rgba, "rgb"))
+ kdSubpixelOrder = SubPixelHorizontalRGB;
+ else if (!strcmp (rgba, "bgr"))
+ kdSubpixelOrder = SubPixelHorizontalBGR;
+ else if (!strcmp (rgba, "vrgb"))
+ kdSubpixelOrder = SubPixelVerticalRGB;
+ else if (!strcmp (rgba, "vbgr"))
+ kdSubpixelOrder = SubPixelVerticalBGR;
+ else if (!strcmp (rgba, "none"))
+ kdSubpixelOrder = SubPixelNone;
+ else
+ kdSubpixelOrder = SubPixelUnknown;
+}
+
+void
+KdUseMsg (void)
+{
+ ErrorF("\nTinyX Device Dependent Usage:\n");
+ ErrorF("-screen WIDTH[/WIDTHMM]xHEIGHT[/HEIGHTMM][@ROTATION][X][Y][xDEPTH/BPP[xFREQ]] Specify screen characteristics\n");
+ ErrorF("-rgba rgb/bgr/vrgb/vbgr/none Specify subpixel ordering for LCD panels\n");
+ ErrorF("-mouse driver [,n,,options] Specify the pointer driver and its options (n is the number of buttons)\n");
+ ErrorF("-keybd driver [,,options] Specify the keyboard driver and its options\n");
+ ErrorF("-zaphod Disable cursor screen switching\n");
+ ErrorF("-2button Emulate 3 button mouse\n");
+ ErrorF("-3button Disable 3 button mouse emulation\n");
+ ErrorF("-rawcoord Don't transform pointer coordinates on rotation\n");
+ ErrorF("-dumb Disable hardware acceleration\n");
+ ErrorF("-softCursor Force software cursor\n");
+ ErrorF("-videoTest Start the server, pause momentarily and exit\n");
+ ErrorF("-origin X,Y Locates the next screen in the the virtual screen (Xinerama)\n");
+ ErrorF("-switchCmd Command to execute on vt switch\n");
+ ErrorF("-zap Terminate server on Ctrl+Alt+Backspace\n");
+ ErrorF("vtxx Use virtual terminal xx instead of the next available\n");
+}
+
+int
+KdProcessArgument (int argc, char **argv, int i)
+{
+ KdCardInfo *card;
+ KdScreenInfo *screen;
+
+ if (!strcmp (argv[i], "-screen"))
+ {
+ if ((i+1) < argc)
+ {
+ card = KdCardInfoLast ();
+ if (!card)
+ {
+ InitCard (0);
+ card = KdCardInfoLast ();
+ }
+ if (card) {
+ screen = KdScreenInfoAdd (card);
+ KdParseScreen (screen, argv[i+1]);
+ } else
+ ErrorF("No matching card found!\n");
+ }
+ else
+ UseMsg ();
+ return 2;
+ }
+ if (!strcmp (argv[i], "-zaphod"))
+ {
+ kdDisableZaphod = TRUE;
+ return 1;
+ }
+ if (!strcmp (argv[i], "-zap"))
+ {
+ kdAllowZap = TRUE;
+ return 1;
+ }
+ if (!strcmp (argv[i], "-3button"))
+ {
+ kdEmulateMiddleButton = FALSE;
+ return 1;
+ }
+ if (!strcmp (argv[i], "-2button"))
+ {
+ kdEmulateMiddleButton = TRUE;
+ return 1;
+ }
+ if (!strcmp (argv[i], "-rawcoord"))
+ {
+ kdRawPointerCoordinates = 1;
+ return 1;
+ }
+ if (!strcmp (argv[i], "-dumb"))
+ {
+ kdDumbDriver = TRUE;
+ return 1;
+ }
+ if (!strcmp (argv[i], "-softCursor"))
+ {
+ kdSoftCursor = TRUE;
+ return 1;
+ }
+ if (!strcmp (argv[i], "-videoTest"))
+ {
+ kdVideoTest = TRUE;
+ return 1;
+ }
+ if (!strcmp (argv[i], "-origin"))
+ {
+ if ((i+1) < argc)
+ {
+ char *x = argv[i+1];
+ char *y = strchr (x, ',');
+ if (x)
+ kdOrigin.x = atoi (x);
+ else
+ kdOrigin.x = 0;
+ if (y)
+ kdOrigin.y = atoi(y+1);
+ else
+ kdOrigin.y = 0;
+ }
+ else
+ UseMsg ();
+ return 2;
+ }
+ if (!strcmp (argv[i], "-rgba"))
+ {
+ if ((i+1) < argc)
+ KdParseRgba (argv[i+1]);
+ else
+ UseMsg ();
+ return 2;
+ }
+ if (!strcmp (argv[i], "-switchCmd"))
+ {
+ if ((i+1) < argc)
+ kdSwitchCmd = argv[i+1];
+ else
+ UseMsg ();
+ return 2;
+ }
+ if (!strncmp (argv[i], "vt", 2) &&
+ sscanf (argv[i], "vt%2d", &kdVirtualTerminal) == 1)
+ {
+ return 1;
+ }
+ if (!strcmp (argv[i], "-mouse") ||
+ !strcmp (argv[i], "-pointer")) {
+ if (i + 1 >= argc)
+ UseMsg();
+ KdAddConfigPointer(argv[i + 1]);
+ kdHasPointer = TRUE;
+ return 2;
+ }
+ if (!strcmp (argv[i], "-keybd")) {
+ if (i + 1 >= argc)
+ UseMsg();
+ KdAddConfigKeyboard(argv[i + 1]);
+ kdHasKbd = TRUE;
+ return 2;
+ }
+
+ return 0;
+}
+
+/*
+ * These are getting tossed in here until I can think of where
+ * they really belong
+ */
+
+void
+KdOsInit (KdOsFuncs *pOsFuncs)
+{
+ kdOsFuncs = pOsFuncs;
+ if (pOsFuncs)
+ {
+ if (serverGeneration == 1)
+ {
+ KdDoSwitchCmd ("start");
+ if (pOsFuncs->Init)
+ (*pOsFuncs->Init) ();
+ }
+ }
+}
+
+Bool
+KdAllocatePrivates (ScreenPtr pScreen)
+{
+ KdPrivScreenPtr pScreenPriv;
+
+ if (kdGeneration != serverGeneration)
+ kdGeneration = serverGeneration;
+
+ if (!dixRegisterPrivateKey(&kdScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
+ pScreenPriv = calloc(1, sizeof (*pScreenPriv));
+ if (!pScreenPriv)
+ return FALSE;
+ KdSetScreenPriv (pScreen, pScreenPriv);
+ return TRUE;
+}
+
+Bool
+KdCreateScreenResources (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ KdCardInfo *card = pScreenPriv->card;
+ Bool ret;
+
+ pScreen->CreateScreenResources = pScreenPriv->CreateScreenResources;
+ if(pScreen->CreateScreenResources)
+ ret = (*pScreen->CreateScreenResources) (pScreen);
+ else
+ ret= -1;
+ pScreenPriv->CreateScreenResources = pScreen->CreateScreenResources;
+ pScreen->CreateScreenResources = KdCreateScreenResources;
+ if (ret && card->cfuncs->createRes)
+ ret = (*card->cfuncs->createRes) (pScreen);
+ return ret;
+}
+
+Bool
+KdCloseScreen (int index, ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ KdCardInfo *card = pScreenPriv->card;
+ Bool ret;
+
+ pScreenPriv->closed = TRUE;
+ pScreen->CloseScreen = pScreenPriv->CloseScreen;
+ if(pScreen->CloseScreen)
+ ret = (*pScreen->CloseScreen) (index, pScreen);
+ else
+ ret = TRUE;
+
+ if (pScreenPriv->dpmsState != KD_DPMS_NORMAL)
+ (*card->cfuncs->dpms) (pScreen, KD_DPMS_NORMAL);
+
+ if (screen->mynum == card->selected)
+ KdDisableScreen (pScreen);
+
+ /*
+ * Restore video hardware when last screen is closed
+ */
+ if (screen == card->screenList)
+ {
+ if (kdEnabled && card->cfuncs->restore)
+ (*card->cfuncs->restore) (card);
+ }
+
+ if (!pScreenPriv->screen->dumb && card->cfuncs->finiAccel)
+ (*card->cfuncs->finiAccel) (pScreen);
+
+ if (!pScreenPriv->screen->softCursor && card->cfuncs->finiCursor)
+ (*card->cfuncs->finiCursor) (pScreen);
+
+ if(card->cfuncs->scrfini)
+ (*card->cfuncs->scrfini) (screen);
+
+ /*
+ * Clean up card when last screen is closed, DIX closes them in
+ * reverse order, thus we check for when the first in the list is closed
+ */
+ if (screen == card->screenList)
+ {
+ if(card->cfuncs->cardfini)
+ (*card->cfuncs->cardfini) (card);
+ /*
+ * Clean up OS when last card is closed
+ */
+ if (card == kdCardInfo)
+ {
+ if (kdEnabled)
+ {
+ kdEnabled = FALSE;
+ if(kdOsFuncs->Disable)
+ (*kdOsFuncs->Disable) ();
+ }
+ }
+ }
+
+ pScreenPriv->screen->pScreen = 0;
+
+ free((pointer) pScreenPriv);
+ return ret;
+}
+
+Bool
+KdSaveScreen (ScreenPtr pScreen, int on)
+{
+ KdScreenPriv(pScreen);
+ int dpmsState;
+
+ if (!pScreenPriv->card->cfuncs->dpms)
+ return FALSE;
+
+ dpmsState = pScreenPriv->dpmsState;
+ switch (on) {
+ case SCREEN_SAVER_OFF:
+ dpmsState = KD_DPMS_NORMAL;
+ break;
+ case SCREEN_SAVER_ON:
+ if (dpmsState == KD_DPMS_NORMAL)
+ dpmsState = KD_DPMS_NORMAL+1;
+ break;
+ case SCREEN_SAVER_CYCLE:
+ if (dpmsState < KD_DPMS_MAX)
+ dpmsState++;
+ break;
+ case SCREEN_SAVER_FORCER:
+ break;
+ }
+ if (dpmsState != pScreenPriv->dpmsState)
+ {
+ if (pScreenPriv->enabled)
+ (*pScreenPriv->card->cfuncs->dpms) (pScreen, dpmsState);
+ pScreenPriv->dpmsState = dpmsState;
+ }
+ return TRUE;
+}
+
+static Bool
+KdCreateWindow (WindowPtr pWin)
+{
+#ifndef PHOENIX
+ if (!pWin->parent)
+ {
+ KdScreenPriv(pWin->drawable.pScreen);
+
+ if (!pScreenPriv->enabled)
+ {
+ RegionEmpty(&pWin->borderClip);
+ RegionBreak(&pWin->clipList);
+ }
+ }
+#endif
+ return fbCreateWindow (pWin);
+}
+
+void
+KdSetSubpixelOrder (ScreenPtr pScreen, Rotation randr)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ int subpixel_order = screen->subpixel_order;
+ Rotation subpixel_dir;
+ int i;
+
+ static struct {
+ int subpixel_order;
+ Rotation direction;
+ } orders[] = {
+ { SubPixelHorizontalRGB, RR_Rotate_0 },
+ { SubPixelHorizontalBGR, RR_Rotate_180 },
+ { SubPixelVerticalRGB, RR_Rotate_270 },
+ { SubPixelVerticalBGR, RR_Rotate_90 },
+ };
+
+ static struct {
+ int bit;
+ int normal;
+ int reflect;
+ } reflects[] = {
+ { RR_Reflect_X, SubPixelHorizontalRGB, SubPixelHorizontalBGR },
+ { RR_Reflect_X, SubPixelHorizontalBGR, SubPixelHorizontalRGB },
+ { RR_Reflect_Y, SubPixelVerticalRGB, SubPixelVerticalBGR },
+ { RR_Reflect_Y, SubPixelVerticalRGB, SubPixelVerticalRGB },
+ };
+
+ /* map subpixel to direction */
+ for (i = 0; i < 4; i++)
+ if (orders[i].subpixel_order == subpixel_order)
+ break;
+ if (i < 4)
+ {
+ subpixel_dir = KdAddRotation (randr & RR_Rotate_All, orders[i].direction);
+
+ /* map back to subpixel order */
+ for (i = 0; i < 4; i++)
+ if (orders[i].direction & subpixel_dir)
+ {
+ subpixel_order = orders[i].subpixel_order;
+ break;
+ }
+ /* reflect */
+ for (i = 0; i < 4; i++)
+ if ((randr & reflects[i].bit) &&
+ reflects[i].normal == subpixel_order)
+ {
+ subpixel_order = reflects[i].reflect;
+ break;
+ }
+ }
+ PictureSetSubpixelOrder (pScreen, subpixel_order);
+}
+
+/* Pass through AddScreen, which doesn't take any closure */
+static KdScreenInfo *kdCurrentScreen;
+
+Bool
+KdScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
+{
+ KdScreenInfo *screen = kdCurrentScreen;
+ KdCardInfo *card = screen->card;
+ KdPrivScreenPtr pScreenPriv;
+ /*
+ * note that screen->fb is set up for the nominal orientation
+ * of the screen; that means if randr is rotated, the values
+ * there should reflect a rotated frame buffer (or shadow).
+ */
+ Bool rotated = (screen->randr & (RR_Rotate_90|RR_Rotate_270)) != 0;
+ int width, height, *width_mmp, *height_mmp;
+
+ KdAllocatePrivates (pScreen);
+
+ pScreenPriv = KdGetScreenPriv(pScreen);
+
+ if (!rotated)
+ {
+ width = screen->width;
+ height = screen->height;
+ width_mmp = &screen->width_mm;
+ height_mmp = &screen->height_mm;
+ }
+ else
+ {
+ width = screen->height;
+ height = screen->width;
+ width_mmp = &screen->height_mm;
+ height_mmp = &screen->width_mm;
+ }
+ screen->pScreen = pScreen;
+ pScreenPriv->screen = screen;
+ pScreenPriv->card = card;
+ pScreenPriv->bytesPerPixel = screen->fb.bitsPerPixel >> 3;
+ pScreenPriv->dpmsState = KD_DPMS_NORMAL;
+ pScreen->x = screen->origin.x;
+ pScreen->y = screen->origin.y;
+
+ if (!monitorResolution)
+ monitorResolution = 75;
+ /*
+ * This is done in this order so that backing store wraps
+ * our GC functions; fbFinishScreenInit initializes MI
+ * backing store
+ */
+ if (!fbSetupScreen (pScreen,
+ screen->fb.frameBuffer,
+ width, height,
+ monitorResolution, monitorResolution,
+ screen->fb.pixelStride,
+ screen->fb.bitsPerPixel))
+ {
+ return FALSE;
+ }
+
+ /*
+ * Set colormap functions
+ */
+ pScreen->InstallColormap = KdInstallColormap;
+ pScreen->UninstallColormap = KdUninstallColormap;
+ pScreen->ListInstalledColormaps = KdListInstalledColormaps;
+ pScreen->StoreColors = KdStoreColors;
+
+ pScreen->SaveScreen = KdSaveScreen;
+ pScreen->CreateWindow = KdCreateWindow;
+
+ if (!fbFinishScreenInit (pScreen,
+ screen->fb.frameBuffer,
+ width, height,
+ monitorResolution, monitorResolution,
+ screen->fb.pixelStride,
+ screen->fb.bitsPerPixel))
+ {
+ return FALSE;
+ }
+
+ /*
+ * Fix screen sizes; for some reason mi takes dpi instead of mm.
+ * Rounding errors are annoying
+ */
+ if (*width_mmp)
+ pScreen->mmWidth = *width_mmp;
+ else
+ *width_mmp = pScreen->mmWidth;
+ if (*height_mmp)
+ pScreen->mmHeight = *height_mmp;
+ else
+ *height_mmp = pScreen->mmHeight;
+
+ /*
+ * Plug in our own block/wakeup handlers.
+ * miScreenInit installs NoopDDA in both places
+ */
+ pScreen->BlockHandler = KdBlockHandler;
+ pScreen->WakeupHandler = KdWakeupHandler;
+
+ if (!fbPictureInit (pScreen, 0, 0))
+ return FALSE;
+ if (card->cfuncs->initScreen)
+ if (!(*card->cfuncs->initScreen) (pScreen))
+ return FALSE;
+
+ if (!screen->dumb && card->cfuncs->initAccel)
+ if (!(*card->cfuncs->initAccel) (pScreen))
+ screen->dumb = TRUE;
+
+ if (card->cfuncs->finishInitScreen)
+ if (!(*card->cfuncs->finishInitScreen) (pScreen))
+ return FALSE;
+
+#if 0
+ fbInitValidateTree (pScreen);
+#endif
+
+ /*
+ * Wrap CloseScreen, the order now is:
+ * KdCloseScreen
+ * miBSCloseScreen
+ * fbCloseScreen
+ */
+ pScreenPriv->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = KdCloseScreen;
+
+ pScreenPriv->CreateScreenResources = pScreen->CreateScreenResources;
+ pScreen->CreateScreenResources = KdCreateScreenResources;
+
+ if (screen->softCursor ||
+ !card->cfuncs->initCursor ||
+ !(*card->cfuncs->initCursor) (pScreen))
+ {
+ /* Use MI for cursor display and event queueing. */
+ screen->softCursor = TRUE;
+ miDCInitialize(pScreen, &kdPointerScreenFuncs);
+ }
+
+
+ if (!fbCreateDefColormap (pScreen))
+ {
+ return FALSE;
+ }
+
+ KdSetSubpixelOrder (pScreen, screen->randr);
+
+ /*
+ * Enable the hardware
+ */
+ if (!kdEnabled)
+ {
+ kdEnabled = TRUE;
+ if(kdOsFuncs->Enable)
+ (*kdOsFuncs->Enable) ();
+ }
+
+ if (screen->mynum == card->selected)
+ {
+ if(card->cfuncs->preserve)
+ (*card->cfuncs->preserve) (card);
+ if(card->cfuncs->enable)
+ if (!(*card->cfuncs->enable) (pScreen))
+ return FALSE;
+ pScreenPriv->enabled = TRUE;
+ if (!screen->softCursor && card->cfuncs->enableCursor)
+ (*card->cfuncs->enableCursor) (pScreen);
+ KdEnableColormap (pScreen);
+ if (!screen->dumb && card->cfuncs->enableAccel)
+ (*card->cfuncs->enableAccel) (pScreen);
+ }
+
+ return TRUE;
+}
+
+void
+KdInitScreen (ScreenInfo *pScreenInfo,
+ KdScreenInfo *screen,
+ int argc,
+ char **argv)
+{
+ KdCardInfo *card = screen->card;
+
+ (*card->cfuncs->scrinit) (screen);
+
+ if (!card->cfuncs->initAccel)
+ screen->dumb = TRUE;
+ if (!card->cfuncs->initCursor)
+ screen->softCursor = TRUE;
+}
+
+static Bool
+KdSetPixmapFormats (ScreenInfo *pScreenInfo)
+{
+ CARD8 depthToBpp[33]; /* depth -> bpp map */
+ KdCardInfo *card;
+ KdScreenInfo *screen;
+ int i;
+ int bpp;
+ PixmapFormatRec *format;
+
+ for (i = 1; i <= 32; i++)
+ depthToBpp[i] = 0;
+
+ /*
+ * Generate mappings between bitsPerPixel and depth,
+ * also ensure that all screens comply with protocol
+ * restrictions on equivalent formats for the same
+ * depth on different screens
+ */
+ for (card = kdCardInfo; card; card = card->next)
+ {
+ for (screen = card->screenList; screen; screen = screen->next)
+ {
+ bpp = screen->fb.bitsPerPixel;
+ if (bpp == 24)
+ bpp = 32;
+ if (!depthToBpp[screen->fb.depth])
+ depthToBpp[screen->fb.depth] = bpp;
+ else if (depthToBpp[screen->fb.depth] != bpp)
+ return FALSE;
+ }
+ }
+
+ /*
+ * Fill in additional formats
+ */
+ for (i = 0; i < NUM_KD_DEPTHS; i++)
+ if (!depthToBpp[kdDepths[i].depth])
+ depthToBpp[kdDepths[i].depth] = kdDepths[i].bpp;
+
+ pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
+ pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
+ pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
+ pScreenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
+
+ pScreenInfo->numPixmapFormats = 0;
+
+ for (i = 1; i <= 32; i++)
+ {
+ if (depthToBpp[i])
+ {
+ format = &pScreenInfo->formats[pScreenInfo->numPixmapFormats++];
+ format->depth = i;
+ format->bitsPerPixel = depthToBpp[i];
+ format->scanlinePad = BITMAP_SCANLINE_PAD;
+ }
+ }
+
+ return TRUE;
+}
+
+static void
+KdAddScreen (ScreenInfo *pScreenInfo,
+ KdScreenInfo *screen,
+ int argc,
+ char **argv)
+{
+ int i;
+ /*
+ * Fill in fb visual type masks for this screen
+ */
+ for (i = 0; i < pScreenInfo->numPixmapFormats; i++)
+ {
+ unsigned long visuals;
+ Pixel rm, gm, bm;
+
+ visuals = 0;
+ rm = gm = bm = 0;
+ if (pScreenInfo->formats[i].depth == screen->fb.depth)
+ {
+ visuals = screen->fb.visuals;
+ rm = screen->fb.redMask;
+ gm = screen->fb.greenMask;
+ bm = screen->fb.blueMask;
+ }
+ fbSetVisualTypesAndMasks (pScreenInfo->formats[i].depth,
+ visuals,
+ 8,
+ rm, gm, bm);
+ }
+
+ kdCurrentScreen = screen;
+
+ AddScreen (KdScreenInit, argc, argv);
+}
+
+#if 0 /* This function is not used currently */
+
+int
+KdDepthToFb (ScreenPtr pScreen, int depth)
+{
+ KdScreenPriv(pScreen);
+
+ for (fb = 0; fb <= KD_MAX_FB && pScreenPriv->screen->fb.frameBuffer; fb++)
+ if (pScreenPriv->screen->fb.depth == depth)
+ return fb;
+}
+
+#endif
+
+static int
+KdSignalWrapper (int signum)
+{
+ kdCaughtSignal = TRUE;
+ return 1; /* use generic OS layer cleanup & abort */
+}
+
+void
+KdInitOutput (ScreenInfo *pScreenInfo,
+ int argc,
+ char **argv)
+{
+ KdCardInfo *card;
+ KdScreenInfo *screen;
+
+ if (!kdCardInfo)
+ {
+ InitCard (0);
+ if (!(card = KdCardInfoLast ()))
+ FatalError("No matching cards found!\n");
+ screen = KdScreenInfoAdd (card);
+ KdParseScreen (screen, 0);
+ }
+ /*
+ * Initialize all of the screens for all of the cards
+ */
+ for (card = kdCardInfo; card; card = card->next)
+ {
+ int ret=1;
+ if(card->cfuncs->cardinit)
+ ret=(*card->cfuncs->cardinit) (card);
+ if (ret)
+ {
+ for (screen = card->screenList; screen; screen = screen->next)
+ KdInitScreen (pScreenInfo, screen, argc, argv);
+ }
+ }
+
+ /*
+ * Merge the various pixmap formats together, this can fail
+ * when two screens share depth but not bitsPerPixel
+ */
+ if (!KdSetPixmapFormats (pScreenInfo))
+ return;
+
+ /*
+ * Add all of the screens
+ */
+ for (card = kdCardInfo; card; card = card->next)
+ for (screen = card->screenList; screen; screen = screen->next)
+ KdAddScreen (pScreenInfo, screen, argc, argv);
+
+ OsRegisterSigWrapper(KdSignalWrapper);
+}
+
+#ifndef _MSC_VER
+void
+OsVendorFatalError(void)
+{
+}
+
+int
+DPMSSet(ClientPtr client, int level)
+{
+ return Success;
+}
+
+Bool
+DPMSSupported (void)
+{
+ return FALSE;
+}
+#endif
diff --git a/xorg-server/hw/kdrive/src/kdrive.h b/xorg-server/hw/kdrive/src/kdrive.h
index 4d0201fa1..00f07df41 100644
--- a/xorg-server/hw/kdrive/src/kdrive.h
+++ b/xorg-server/hw/kdrive/src/kdrive.h
@@ -1,627 +1,627 @@
-/*
- * Copyright © 1999 Keith Packard
- *
- * 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 Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Keith Packard makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD 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.
- */
-
-#ifndef _KDRIVE_H_
-#define _KDRIVE_H_
-
-#include <stdio.h>
-#include <string.h>
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include <X11/Xos.h>
-#include "scrnintstr.h"
-#include "pixmapstr.h"
-#include "windowstr.h"
-#include "servermd.h"
-#include "mibstore.h"
-#include "colormapst.h"
-#include "gcstruct.h"
-#include "input.h"
-#include "mipointer.h"
-#include "mi.h"
-#include "dix.h"
-#include "fb.h"
-#include "fboverlay.h"
-#include "shadow.h"
-#include "randrstr.h"
-#include "globals.h"
-
-#include "xkbstr.h"
-
-#define KD_DPMS_NORMAL 0
-#define KD_DPMS_STANDBY 1
-#define KD_DPMS_SUSPEND 2
-#define KD_DPMS_POWERDOWN 3
-#define KD_DPMS_MAX KD_DPMS_POWERDOWN
-
-typedef int Status;
-
-typedef struct _KdCardInfo {
- struct _KdCardFuncs *cfuncs;
- void *closure;
- void *driver;
- struct _KdScreenInfo *screenList;
- int selected;
- struct _KdCardInfo *next;
-} KdCardInfo;
-
-extern KdCardInfo *kdCardInfo;
-
-/*
- * Configuration information per X screen
- */
-typedef struct _KdFrameBuffer {
- CARD8 *frameBuffer;
- int depth;
- int bitsPerPixel;
- int pixelStride;
- int byteStride;
- Bool shadow;
- unsigned long visuals;
- Pixel redMask, greenMask, blueMask;
- void *closure;
-} KdFrameBuffer;
-
-#define RR_Rotate_All (RR_Rotate_0|RR_Rotate_90|RR_Rotate_180|RR_Rotate_270)
-#define RR_Reflect_All (RR_Reflect_X|RR_Reflect_Y)
-
-typedef struct _KdScreenInfo {
- struct _KdScreenInfo *next;
- KdCardInfo *card;
- ScreenPtr pScreen;
- void *driver;
- Rotation randr; /* rotation and reflection */
- int width;
- int height;
- int rate;
- int width_mm;
- int height_mm;
- int subpixel_order;
- Bool dumb;
- Bool softCursor;
- int mynum;
- DDXPointRec origin;
- KdFrameBuffer fb;
-} KdScreenInfo;
-
-typedef struct _KdCardFuncs {
- Bool (*cardinit) (KdCardInfo *); /* detect and map device */
- Bool (*scrinit) (KdScreenInfo *);/* initialize screen information */
- Bool (*initScreen) (ScreenPtr); /* initialize ScreenRec */
- Bool (*finishInitScreen) (ScreenPtr pScreen);
- Bool (*createRes) (ScreenPtr); /* create screen resources */
- void (*preserve) (KdCardInfo *); /* save graphics card state */
- Bool (*enable) (ScreenPtr); /* set up for rendering */
- Bool (*dpms) (ScreenPtr, int); /* set DPMS screen saver */
- void (*disable) (ScreenPtr); /* turn off rendering */
- void (*restore) (KdCardInfo *); /* restore graphics card state */
- void (*scrfini) (KdScreenInfo *);/* close down screen */
- void (*cardfini) (KdCardInfo *); /* close down */
-
- Bool (*initCursor) (ScreenPtr); /* detect and map cursor */
- void (*enableCursor) (ScreenPtr); /* enable cursor */
- void (*disableCursor) (ScreenPtr); /* disable cursor */
- void (*finiCursor) (ScreenPtr); /* close down */
- void (*recolorCursor) (ScreenPtr, int, xColorItem *);
-
- Bool (*initAccel) (ScreenPtr);
- void (*enableAccel) (ScreenPtr);
- void (*disableAccel) (ScreenPtr);
- void (*finiAccel) (ScreenPtr);
-
- void (*getColors) (ScreenPtr, int, xColorItem *);
- void (*putColors) (ScreenPtr, int, xColorItem *);
-
-} KdCardFuncs;
-
-#define KD_MAX_PSEUDO_DEPTH 8
-#define KD_MAX_PSEUDO_SIZE (1 << KD_MAX_PSEUDO_DEPTH)
-
-typedef struct {
- KdScreenInfo *screen;
- KdCardInfo *card;
-
- Bool enabled;
- Bool closed;
- int bytesPerPixel;
-
- int dpmsState;
-
- ColormapPtr pInstalledmap; /* current colormap */
- xColorItem systemPalette[KD_MAX_PSEUDO_SIZE];/* saved windows colors */
-
- CreateScreenResourcesProcPtr CreateScreenResources;
- CloseScreenProcPtr CloseScreen;
-} KdPrivScreenRec, *KdPrivScreenPtr;
-
-typedef enum _kdPointerState {
- start,
- button_1_pend,
- button_1_down,
- button_2_down,
- button_3_pend,
- button_3_down,
- synth_2_down_13,
- synth_2_down_3,
- synth_2_down_1,
- num_input_states
-} KdPointerState;
-
-#define KD_MAX_BUTTON 32
-
-#define KD_KEYBOARD 1
-#define KD_MOUSE 2
-#define KD_TOUCHSCREEN 3
-
-typedef struct _KdPointerInfo KdPointerInfo;
-
-typedef struct _KdPointerDriver {
- char *name;
- Status (*Init) (KdPointerInfo *);
- Status (*Enable) (KdPointerInfo *);
- void (*Disable) (KdPointerInfo *);
- void (*Fini) (KdPointerInfo *);
- struct _KdPointerDriver *next;
-} KdPointerDriver;
-
-struct _KdPointerInfo {
- DeviceIntPtr dixdev;
- char *name;
- char *path;
- char *protocol;
- InputOption *options;
- int inputClass;
-
- CARD8 map[KD_MAX_BUTTON + 1];
- int nButtons;
- int nAxes;
-
- Bool emulateMiddleButton;
- unsigned long emulationTimeout;
- int emulationDx, emulationDy;
-
- Bool timeoutPending;
- KdPointerState mouseState;
- Bool eventHeld;
- struct {
- int type;
- int x;
- int y;
- int z;
- int flags;
- int absrel;
- } heldEvent;
- unsigned char buttonState;
- Bool transformCoordinates;
- int pressureThreshold;
-
- KdPointerDriver *driver;
- void *driverPrivate;
-
- struct _KdPointerInfo *next;
-};
-
-extern int KdCurScreen;
-
-void KdAddPointerDriver (KdPointerDriver *driver);
-void KdRemovePointerDriver (KdPointerDriver *driver);
-KdPointerInfo *KdNewPointer (void);
-void KdFreePointer (KdPointerInfo *);
-int KdAddPointer (KdPointerInfo *ki);
-int KdAddConfigPointer (char *pointer);
-void KdRemovePointer (KdPointerInfo *ki);
-
-
-#define KD_KEY_COUNT 248
-#define KD_MIN_KEYCODE 8
-#define KD_MAX_KEYCODE 255
-#define KD_MAX_WIDTH 4
-#define KD_MAX_LENGTH (KD_MAX_KEYCODE - KD_MIN_KEYCODE + 1)
-
-typedef struct {
- KeySym modsym;
- int modbit;
-} KdKeySymModsRec;
-
-typedef struct _KdKeyboardInfo KdKeyboardInfo;
-
-typedef struct _KdKeyboardDriver {
- char *name;
- Bool (*Init) (KdKeyboardInfo *);
- Bool (*Enable) (KdKeyboardInfo *);
- void (*Leds) (KdKeyboardInfo *, int);
- void (*Bell) (KdKeyboardInfo *, int, int, int);
- void (*Disable) (KdKeyboardInfo *);
- void (*Fini) (KdKeyboardInfo *);
- struct _KdKeyboardDriver *next;
-} KdKeyboardDriver;
-
-struct _KdKeyboardInfo {
- struct _KdKeyboardInfo *next;
- DeviceIntPtr dixdev;
- void *closure;
- char *name;
- char *path;
- int inputClass;
- char *xkbRules;
- char *xkbModel;
- char *xkbLayout;
- char *xkbVariant;
- char *xkbOptions;
- int LockLed;
-
- int minScanCode;
- int maxScanCode;
-
- int leds;
- int bellPitch;
- int bellDuration;
- InputOption *options;
-
- KdKeyboardDriver *driver;
- void *driverPrivate;
-};
-
-void KdAddKeyboardDriver (KdKeyboardDriver *driver);
-void KdRemoveKeyboardDriver (KdKeyboardDriver *driver);
-KdKeyboardInfo *KdNewKeyboard (void);
-void KdFreeKeyboard (KdKeyboardInfo *ki);
-int KdAddConfigKeyboard (char *pointer);
-int KdAddKeyboard (KdKeyboardInfo *ki);
-void KdRemoveKeyboard (KdKeyboardInfo *ki);
-
-typedef struct _KdOsFuncs {
- int (*Init) (void);
- void (*Enable) (void);
- Bool (*SpecialKey) (KeySym);
- void (*Disable) (void);
- void (*Fini) (void);
- void (*pollEvents) (void);
- void (*Bell) (int, int, int);
-} KdOsFuncs;
-
-typedef enum _KdSyncPolarity {
- KdSyncNegative, KdSyncPositive
-} KdSyncPolarity;
-
-typedef struct _KdMonitorTiming {
- /* label */
- int horizontal;
- int vertical;
- int rate;
- /* pixel clock */
- int clock; /* in KHz */
- /* horizontal timing */
- int hfp; /* front porch */
- int hbp; /* back porch */
- int hblank; /* blanking */
- KdSyncPolarity hpol; /* polarity */
- /* vertical timing */
- int vfp; /* front porch */
- int vbp; /* back porch */
- int vblank; /* blanking */
- KdSyncPolarity vpol; /* polarity */
-} KdMonitorTiming;
-
-extern const KdMonitorTiming kdMonitorTimings[];
-extern const int kdNumMonitorTimings;
-
-typedef struct _KdPointerMatrix {
- int matrix[2][3];
-} KdPointerMatrix;
-
-/*
- * This is the only completely portable way to
- * compute this info.
- */
-
-#ifndef BitsPerPixel
-#define BitsPerPixel(d) (\
- PixmapWidthPaddingInfo[d].notPower2 ? \
- (PixmapWidthPaddingInfo[d].bytesPerPixel * 8) : \
- ((1 << PixmapWidthPaddingInfo[d].padBytesLog2) * 8 / \
- (PixmapWidthPaddingInfo[d].padRoundUp+1)))
-#endif
-
-extern DevPrivateKeyRec kdScreenPrivateKeyRec;
-#define kdScreenPrivateKey (&kdScreenPrivateKeyRec)
-
-extern unsigned long kdGeneration;
-extern Bool kdEnabled;
-extern Bool kdSwitchPending;
-extern Bool kdEmulateMiddleButton;
-extern Bool kdDisableZaphod;
-extern Bool kdAllowZap;
-extern int kdVirtualTerminal;
-extern char *kdSwitchCmd;
-extern KdOsFuncs *kdOsFuncs;
-
-#define KdGetScreenPriv(pScreen) ((KdPrivScreenPtr) \
- dixLookupPrivate(&(pScreen)->devPrivates, kdScreenPrivateKey))
-#define KdSetScreenPriv(pScreen,v) \
- dixSetPrivate(&(pScreen)->devPrivates, kdScreenPrivateKey, v)
-#define KdScreenPriv(pScreen) KdPrivScreenPtr pScreenPriv = KdGetScreenPriv(pScreen)
-
-/* kcmap.c */
-void
-KdSetColormap (ScreenPtr pScreen);
-
-void
-KdEnableColormap (ScreenPtr pScreen);
-
-void
-KdDisableColormap (ScreenPtr pScreen);
-
-void
-KdInstallColormap (ColormapPtr pCmap);
-
-void
-KdUninstallColormap (ColormapPtr pCmap);
-
-int
-KdListInstalledColormaps (ScreenPtr pScreen, Colormap *pCmaps);
-
-void
-KdStoreColors (ColormapPtr pCmap, int ndef, xColorItem *pdefs);
-
-/* kdrive.c */
-extern miPointerScreenFuncRec kdPointerScreenFuncs;
-
-void
-KdDisableScreen (ScreenPtr pScreen);
-
-void
-KdDisableScreens (void);
-
-Bool
-KdEnableScreen (ScreenPtr pScreen);
-
-void
-KdEnableScreens (void);
-
-void
-KdSuspend (void);
-
-void
-KdResume (void);
-
-void
-KdProcessSwitch (void);
-
-Rotation
-KdAddRotation (Rotation a, Rotation b);
-
-Rotation
-KdSubRotation (Rotation a, Rotation b);
-
-void
-KdParseScreen (KdScreenInfo *screen,
- char *arg);
-
-KdPointerInfo *
-KdParsePointer (char *arg);
-
-KdKeyboardInfo *
-KdParseKeyboard (char *arg);
-
-char *
-KdParseFindNext (char *cur, char *delim, char *save, char *last);
-
-void
-KdParseRgba (char *rgba);
-
-void
-KdUseMsg (void);
-
-int
-KdProcessArgument (int argc, char **argv, int i);
-
-void
-KdOsInit (KdOsFuncs *pOsFuncs);
-
-void
-KdOsAddInputDrivers (void);
-
-Bool
-KdAllocatePrivates (ScreenPtr pScreen);
-
-Bool
-KdCreateScreenResources (ScreenPtr pScreen);
-
-Bool
-KdCloseScreen (int index, ScreenPtr pScreen);
-
-Bool
-KdSaveScreen (ScreenPtr pScreen, int on);
-
-Bool
-KdScreenInit(int index, ScreenPtr pScreen, int argc, char **argv);
-
-void
-KdInitScreen (ScreenInfo *pScreenInfo,
- KdScreenInfo *screen,
- int argc,
- char **argv);
-
-void
-KdInitCard (ScreenInfo *pScreenInfo,
- KdCardInfo *card,
- int argc,
- char **argv);
-
-void
-KdInitOutput (ScreenInfo *pScreenInfo,
- int argc,
- char **argv);
-
-void
-KdSetSubpixelOrder (ScreenPtr pScreen, Rotation randr);
-
-void
-KdBacktrace (int signum);
-
-/* kinfo.c */
-KdCardInfo *
-KdCardInfoAdd (KdCardFuncs *funcs,
- void *closure);
-
-KdCardInfo *
-KdCardInfoLast (void);
-
-void
-KdCardInfoDispose (KdCardInfo *ci);
-
-KdScreenInfo *
-KdScreenInfoAdd (KdCardInfo *ci);
-
-void
-KdScreenInfoDispose (KdScreenInfo *si);
-
-
-/* kinput.c */
-void
-KdInitInput(void);
-void
-KdCloseInput(void);
-
-void
-KdAddPointerDriver(KdPointerDriver *);
-
-void
-KdAddKeyboardDriver(KdKeyboardDriver *);
-
-Bool
-KdRegisterFd (int fd, void (*read) (int fd, void *closure), void *closure);
-
-void
-KdUnregisterFds (void *closure, Bool do_close);
-
-void
-KdUnregisterFd (void *closure, int fd, Bool do_close);
-
-void
-KdEnqueueKeyboardEvent(KdKeyboardInfo *ki, unsigned char scan_code,
- unsigned char is_up);
-
-#define KD_BUTTON_1 0x01
-#define KD_BUTTON_2 0x02
-#define KD_BUTTON_3 0x04
-#define KD_BUTTON_4 0x08
-#define KD_BUTTON_5 0x10
-#define KD_BUTTON_8 0x80
-#define KD_MOUSE_DELTA 0x80000000
-
-void
-KdEnqueuePointerEvent(KdPointerInfo *pi, unsigned long flags, int rx, int ry,
- int rz);
-
-void
-_KdEnqueuePointerEvent(KdPointerInfo *pi, int type, int x, int y, int z,
- int b, int absrel, Bool force);
-
-void
-KdReleaseAllKeys (void);
-
-void
-KdSetLed (KdKeyboardInfo *ki, int led, Bool on);
-
-void
-KdSetPointerMatrix (KdPointerMatrix *pointer);
-
-void
-KdComputePointerMatrix (KdPointerMatrix *pointer, Rotation randr, int width, int height);
-
-void
-KdScreenToPointerCoords (int *x, int *y);
-
-void
-KdBlockHandler (int screen,
- pointer blockData,
- pointer timeout,
- pointer readmask);
-
-void
-KdWakeupHandler (int screen,
- pointer data,
- unsigned long result,
- pointer readmask);
-
-void
-KdDisableInput (void);
-
-void
-KdEnableInput (void);
-
-void
-ProcessInputEvents (void);
-
-void
-KdRingBell (KdKeyboardInfo *ki,
- int volume,
- int pitch,
- int duration);
-
-/* kmode.c */
-const KdMonitorTiming *
-KdFindMode (KdScreenInfo *screen,
- Bool (*supported) (KdScreenInfo *,
- const KdMonitorTiming *));
-
-Bool
-KdTuneMode (KdScreenInfo *screen,
- Bool (*usable) (KdScreenInfo *),
- Bool (*supported) (KdScreenInfo *,
- const KdMonitorTiming *));
-
-#ifdef RANDR
-Bool
-KdRandRGetInfo (ScreenPtr pScreen,
- int randr,
- Bool (*supported) (ScreenPtr pScreen,
- const KdMonitorTiming *));
-
-const KdMonitorTiming *
-KdRandRGetTiming (ScreenPtr pScreen,
- Bool (*supported) (ScreenPtr pScreen,
- const KdMonitorTiming *),
- int rate,
- RRScreenSizePtr pSize);
-#endif
-
-/* kshadow.c */
-Bool
-KdShadowFbAlloc (KdScreenInfo *screen, Bool rotate);
-
-void
-KdShadowFbFree (KdScreenInfo *screen);
-
-Bool
-KdShadowSet (ScreenPtr pScreen, int randr, ShadowUpdateProc update, ShadowWindowProc window);
-
-void
-KdShadowUnset (ScreenPtr pScreen);
-
-/* function prototypes to be implemented by the drivers */
-void
-InitCard (char *name);
-
-#endif /* _KDRIVE_H_ */
+/*
+ * Copyright © 1999 Keith Packard
+ *
+ * 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 Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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.
+ */
+
+#ifndef _KDRIVE_H_
+#define _KDRIVE_H_
+
+#include <stdio.h>
+#include <string.h>
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/Xos.h>
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "windowstr.h"
+#include "servermd.h"
+#include "mibstore.h"
+#include "colormapst.h"
+#include "gcstruct.h"
+#include "input.h"
+#include "mipointer.h"
+#include "mi.h"
+#include "dix.h"
+#include "fb.h"
+#include "fboverlay.h"
+#include "shadow.h"
+#include "randrstr.h"
+#include "globals.h"
+
+#include "xkbstr.h"
+
+#define KD_DPMS_NORMAL 0
+#define KD_DPMS_STANDBY 1
+#define KD_DPMS_SUSPEND 2
+#define KD_DPMS_POWERDOWN 3
+#define KD_DPMS_MAX KD_DPMS_POWERDOWN
+
+typedef int Status;
+
+typedef struct _KdCardInfo {
+ struct _KdCardFuncs *cfuncs;
+ void *closure;
+ void *driver;
+ struct _KdScreenInfo *screenList;
+ int selected;
+ struct _KdCardInfo *next;
+} KdCardInfo;
+
+extern KdCardInfo *kdCardInfo;
+
+/*
+ * Configuration information per X screen
+ */
+typedef struct _KdFrameBuffer {
+ CARD8 *frameBuffer;
+ int depth;
+ int bitsPerPixel;
+ int pixelStride;
+ int byteStride;
+ Bool shadow;
+ unsigned long visuals;
+ Pixel redMask, greenMask, blueMask;
+ void *closure;
+} KdFrameBuffer;
+
+#define RR_Rotate_All (RR_Rotate_0|RR_Rotate_90|RR_Rotate_180|RR_Rotate_270)
+#define RR_Reflect_All (RR_Reflect_X|RR_Reflect_Y)
+
+typedef struct _KdScreenInfo {
+ struct _KdScreenInfo *next;
+ KdCardInfo *card;
+ ScreenPtr pScreen;
+ void *driver;
+ Rotation randr; /* rotation and reflection */
+ int width;
+ int height;
+ int rate;
+ int width_mm;
+ int height_mm;
+ int subpixel_order;
+ Bool dumb;
+ Bool softCursor;
+ int mynum;
+ DDXPointRec origin;
+ KdFrameBuffer fb;
+} KdScreenInfo;
+
+typedef struct _KdCardFuncs {
+ Bool (*cardinit) (KdCardInfo *); /* detect and map device */
+ Bool (*scrinit) (KdScreenInfo *);/* initialize screen information */
+ Bool (*initScreen) (ScreenPtr); /* initialize ScreenRec */
+ Bool (*finishInitScreen) (ScreenPtr pScreen);
+ Bool (*createRes) (ScreenPtr); /* create screen resources */
+ void (*preserve) (KdCardInfo *); /* save graphics card state */
+ Bool (*enable) (ScreenPtr); /* set up for rendering */
+ Bool (*dpms) (ScreenPtr, int); /* set DPMS screen saver */
+ void (*disable) (ScreenPtr); /* turn off rendering */
+ void (*restore) (KdCardInfo *); /* restore graphics card state */
+ void (*scrfini) (KdScreenInfo *);/* close down screen */
+ void (*cardfini) (KdCardInfo *); /* close down */
+
+ Bool (*initCursor) (ScreenPtr); /* detect and map cursor */
+ void (*enableCursor) (ScreenPtr); /* enable cursor */
+ void (*disableCursor) (ScreenPtr); /* disable cursor */
+ void (*finiCursor) (ScreenPtr); /* close down */
+ void (*recolorCursor) (ScreenPtr, int, xColorItem *);
+
+ Bool (*initAccel) (ScreenPtr);
+ void (*enableAccel) (ScreenPtr);
+ void (*disableAccel) (ScreenPtr);
+ void (*finiAccel) (ScreenPtr);
+
+ void (*getColors) (ScreenPtr, int, xColorItem *);
+ void (*putColors) (ScreenPtr, int, xColorItem *);
+
+} KdCardFuncs;
+
+#define KD_MAX_PSEUDO_DEPTH 8
+#define KD_MAX_PSEUDO_SIZE (1 << KD_MAX_PSEUDO_DEPTH)
+
+typedef struct {
+ KdScreenInfo *screen;
+ KdCardInfo *card;
+
+ Bool enabled;
+ Bool closed;
+ int bytesPerPixel;
+
+ int dpmsState;
+
+ ColormapPtr pInstalledmap; /* current colormap */
+ xColorItem systemPalette[KD_MAX_PSEUDO_SIZE];/* saved windows colors */
+
+ CreateScreenResourcesProcPtr CreateScreenResources;
+ CloseScreenProcPtr CloseScreen;
+} KdPrivScreenRec, *KdPrivScreenPtr;
+
+typedef enum _kdPointerState {
+ start,
+ button_1_pend,
+ button_1_down,
+ button_2_down,
+ button_3_pend,
+ button_3_down,
+ synth_2_down_13,
+ synth_2_down_3,
+ synth_2_down_1,
+ num_input_states
+} KdPointerState;
+
+#define KD_MAX_BUTTON 32
+
+#define KD_KEYBOARD 1
+#define KD_MOUSE 2
+#define KD_TOUCHSCREEN 3
+
+typedef struct _KdPointerInfo KdPointerInfo;
+
+typedef struct _KdPointerDriver {
+ char *name;
+ Status (*Init) (KdPointerInfo *);
+ Status (*Enable) (KdPointerInfo *);
+ void (*Disable) (KdPointerInfo *);
+ void (*Fini) (KdPointerInfo *);
+ struct _KdPointerDriver *next;
+} KdPointerDriver;
+
+struct _KdPointerInfo {
+ DeviceIntPtr dixdev;
+ char *name;
+ char *path;
+ char *protocol;
+ InputOption *options;
+ int inputClass;
+
+ CARD8 map[KD_MAX_BUTTON + 1];
+ int nButtons;
+ int nAxes;
+
+ Bool emulateMiddleButton;
+ unsigned long emulationTimeout;
+ int emulationDx, emulationDy;
+
+ Bool timeoutPending;
+ KdPointerState mouseState;
+ Bool eventHeld;
+ struct {
+ int type;
+ int x;
+ int y;
+ int z;
+ int flags;
+ int absrel;
+ } heldEvent;
+ unsigned char buttonState;
+ Bool transformCoordinates;
+ int pressureThreshold;
+
+ KdPointerDriver *driver;
+ void *driverPrivate;
+
+ struct _KdPointerInfo *next;
+};
+
+extern int KdCurScreen;
+
+void KdAddPointerDriver (KdPointerDriver *driver);
+void KdRemovePointerDriver (KdPointerDriver *driver);
+KdPointerInfo *KdNewPointer (void);
+void KdFreePointer (KdPointerInfo *);
+int KdAddPointer (KdPointerInfo *ki);
+int KdAddConfigPointer (char *pointer);
+void KdRemovePointer (KdPointerInfo *ki);
+
+
+#define KD_KEY_COUNT 248
+#define KD_MIN_KEYCODE 8
+#define KD_MAX_KEYCODE 255
+#define KD_MAX_WIDTH 4
+#define KD_MAX_LENGTH (KD_MAX_KEYCODE - KD_MIN_KEYCODE + 1)
+
+typedef struct {
+ KeySym modsym;
+ int modbit;
+} KdKeySymModsRec;
+
+typedef struct _KdKeyboardInfo KdKeyboardInfo;
+
+typedef struct _KdKeyboardDriver {
+ char *name;
+ Bool (*Init) (KdKeyboardInfo *);
+ Bool (*Enable) (KdKeyboardInfo *);
+ void (*Leds) (KdKeyboardInfo *, int);
+ void (*Bell) (KdKeyboardInfo *, int, int, int);
+ void (*Disable) (KdKeyboardInfo *);
+ void (*Fini) (KdKeyboardInfo *);
+ struct _KdKeyboardDriver *next;
+} KdKeyboardDriver;
+
+struct _KdKeyboardInfo {
+ struct _KdKeyboardInfo *next;
+ DeviceIntPtr dixdev;
+ void *closure;
+ char *name;
+ char *path;
+ int inputClass;
+ char *xkbRules;
+ char *xkbModel;
+ char *xkbLayout;
+ char *xkbVariant;
+ char *xkbOptions;
+ int LockLed;
+
+ int minScanCode;
+ int maxScanCode;
+
+ int leds;
+ int bellPitch;
+ int bellDuration;
+ InputOption *options;
+
+ KdKeyboardDriver *driver;
+ void *driverPrivate;
+};
+
+void KdAddKeyboardDriver (KdKeyboardDriver *driver);
+void KdRemoveKeyboardDriver (KdKeyboardDriver *driver);
+KdKeyboardInfo *KdNewKeyboard (void);
+void KdFreeKeyboard (KdKeyboardInfo *ki);
+int KdAddConfigKeyboard (char *pointer);
+int KdAddKeyboard (KdKeyboardInfo *ki);
+void KdRemoveKeyboard (KdKeyboardInfo *ki);
+
+typedef struct _KdOsFuncs {
+ int (*Init) (void);
+ void (*Enable) (void);
+ Bool (*SpecialKey) (KeySym);
+ void (*Disable) (void);
+ void (*Fini) (void);
+ void (*pollEvents) (void);
+ void (*Bell) (int, int, int);
+} KdOsFuncs;
+
+typedef enum _KdSyncPolarity {
+ KdSyncNegative, KdSyncPositive
+} KdSyncPolarity;
+
+typedef struct _KdMonitorTiming {
+ /* label */
+ int horizontal;
+ int vertical;
+ int rate;
+ /* pixel clock */
+ int clock; /* in KHz */
+ /* horizontal timing */
+ int hfp; /* front porch */
+ int hbp; /* back porch */
+ int hblank; /* blanking */
+ KdSyncPolarity hpol; /* polarity */
+ /* vertical timing */
+ int vfp; /* front porch */
+ int vbp; /* back porch */
+ int vblank; /* blanking */
+ KdSyncPolarity vpol; /* polarity */
+} KdMonitorTiming;
+
+extern const KdMonitorTiming kdMonitorTimings[];
+extern const int kdNumMonitorTimings;
+
+typedef struct _KdPointerMatrix {
+ int matrix[2][3];
+} KdPointerMatrix;
+
+/*
+ * This is the only completely portable way to
+ * compute this info.
+ */
+
+#ifndef BitsPerPixel
+#define BitsPerPixel(d) (\
+ PixmapWidthPaddingInfo[d].notPower2 ? \
+ (PixmapWidthPaddingInfo[d].bytesPerPixel * 8) : \
+ ((1 << PixmapWidthPaddingInfo[d].padBytesLog2) * 8 / \
+ (PixmapWidthPaddingInfo[d].padRoundUp+1)))
+#endif
+
+extern DevPrivateKeyRec kdScreenPrivateKeyRec;
+#define kdScreenPrivateKey (&kdScreenPrivateKeyRec)
+
+extern unsigned long kdGeneration;
+extern Bool kdEnabled;
+extern Bool kdSwitchPending;
+extern Bool kdEmulateMiddleButton;
+extern Bool kdDisableZaphod;
+extern Bool kdAllowZap;
+extern int kdVirtualTerminal;
+extern char *kdSwitchCmd;
+extern KdOsFuncs *kdOsFuncs;
+
+#define KdGetScreenPriv(pScreen) ((KdPrivScreenPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, kdScreenPrivateKey))
+#define KdSetScreenPriv(pScreen,v) \
+ dixSetPrivate(&(pScreen)->devPrivates, kdScreenPrivateKey, v)
+#define KdScreenPriv(pScreen) KdPrivScreenPtr pScreenPriv = KdGetScreenPriv(pScreen)
+
+/* kcmap.c */
+void
+KdSetColormap (ScreenPtr pScreen);
+
+void
+KdEnableColormap (ScreenPtr pScreen);
+
+void
+KdDisableColormap (ScreenPtr pScreen);
+
+void
+KdInstallColormap (ColormapPtr pCmap);
+
+void
+KdUninstallColormap (ColormapPtr pCmap);
+
+int
+KdListInstalledColormaps (ScreenPtr pScreen, Colormap *pCmaps);
+
+void
+KdStoreColors (ColormapPtr pCmap, int ndef, xColorItem *pdefs);
+
+/* kdrive.c */
+extern miPointerScreenFuncRec kdPointerScreenFuncs;
+
+void
+KdDisableScreen (ScreenPtr pScreen);
+
+void
+KdDisableScreens (void);
+
+Bool
+KdEnableScreen (ScreenPtr pScreen);
+
+void
+KdEnableScreens (void);
+
+void
+KdSuspend (void);
+
+void
+KdResume (void);
+
+void
+KdProcessSwitch (void);
+
+Rotation
+KdAddRotation (Rotation a, Rotation b);
+
+Rotation
+KdSubRotation (Rotation a, Rotation b);
+
+void
+KdParseScreen (KdScreenInfo *screen,
+ char *arg);
+
+KdPointerInfo *
+KdParsePointer (char *arg);
+
+KdKeyboardInfo *
+KdParseKeyboard (char *arg);
+
+char *
+KdParseFindNext (char *cur, char *delim, char *save, char *last);
+
+void
+KdParseRgba (char *rgba);
+
+void
+KdUseMsg (void);
+
+int
+KdProcessArgument (int argc, char **argv, int i);
+
+void
+KdOsInit (KdOsFuncs *pOsFuncs);
+
+void
+KdOsAddInputDrivers (void);
+
+Bool
+KdAllocatePrivates (ScreenPtr pScreen);
+
+Bool
+KdCreateScreenResources (ScreenPtr pScreen);
+
+Bool
+KdCloseScreen (int index, ScreenPtr pScreen);
+
+Bool
+KdSaveScreen (ScreenPtr pScreen, int on);
+
+Bool
+KdScreenInit(int index, ScreenPtr pScreen, int argc, char **argv);
+
+void
+KdInitScreen (ScreenInfo *pScreenInfo,
+ KdScreenInfo *screen,
+ int argc,
+ char **argv);
+
+void
+KdInitCard (ScreenInfo *pScreenInfo,
+ KdCardInfo *card,
+ int argc,
+ char **argv);
+
+void
+KdInitOutput (ScreenInfo *pScreenInfo,
+ int argc,
+ char **argv);
+
+void
+KdSetSubpixelOrder (ScreenPtr pScreen, Rotation randr);
+
+void
+KdBacktrace (int signum);
+
+/* kinfo.c */
+KdCardInfo *
+KdCardInfoAdd (KdCardFuncs *funcs,
+ void *closure);
+
+KdCardInfo *
+KdCardInfoLast (void);
+
+void
+KdCardInfoDispose (KdCardInfo *ci);
+
+KdScreenInfo *
+KdScreenInfoAdd (KdCardInfo *ci);
+
+void
+KdScreenInfoDispose (KdScreenInfo *si);
+
+
+/* kinput.c */
+void
+KdInitInput(void);
+void
+KdCloseInput(void);
+
+void
+KdAddPointerDriver(KdPointerDriver *);
+
+void
+KdAddKeyboardDriver(KdKeyboardDriver *);
+
+Bool
+KdRegisterFd (int fd, void (*read) (int fd, void *closure), void *closure);
+
+void
+KdUnregisterFds (void *closure, Bool do_close);
+
+void
+KdUnregisterFd (void *closure, int fd, Bool do_close);
+
+void
+KdEnqueueKeyboardEvent(KdKeyboardInfo *ki, unsigned char scan_code,
+ unsigned char is_up);
+
+#define KD_BUTTON_1 0x01
+#define KD_BUTTON_2 0x02
+#define KD_BUTTON_3 0x04
+#define KD_BUTTON_4 0x08
+#define KD_BUTTON_5 0x10
+#define KD_BUTTON_8 0x80
+#define KD_MOUSE_DELTA 0x80000000
+
+void
+KdEnqueuePointerEvent(KdPointerInfo *pi, unsigned long flags, int rx, int ry,
+ int rz);
+
+void
+_KdEnqueuePointerEvent(KdPointerInfo *pi, int type, int x, int y, int z,
+ int b, int absrel, Bool force);
+
+void
+KdReleaseAllKeys (void);
+
+void
+KdSetLed (KdKeyboardInfo *ki, int led, Bool on);
+
+void
+KdSetPointerMatrix (KdPointerMatrix *pointer);
+
+void
+KdComputePointerMatrix (KdPointerMatrix *pointer, Rotation randr, int width, int height);
+
+void
+KdScreenToPointerCoords (int *x, int *y);
+
+void
+KdBlockHandler (int screen,
+ pointer blockData,
+ pointer timeout,
+ pointer readmask);
+
+void
+KdWakeupHandler (int screen,
+ pointer data,
+ unsigned long result,
+ pointer readmask);
+
+void
+KdDisableInput (void);
+
+void
+KdEnableInput (void);
+
+void
+ProcessInputEvents (void);
+
+void
+KdRingBell (KdKeyboardInfo *ki,
+ int volume,
+ int pitch,
+ int duration);
+
+/* kmode.c */
+const KdMonitorTiming *
+KdFindMode (KdScreenInfo *screen,
+ Bool (*supported) (KdScreenInfo *,
+ const KdMonitorTiming *));
+
+Bool
+KdTuneMode (KdScreenInfo *screen,
+ Bool (*usable) (KdScreenInfo *),
+ Bool (*supported) (KdScreenInfo *,
+ const KdMonitorTiming *));
+
+#ifdef RANDR
+Bool
+KdRandRGetInfo (ScreenPtr pScreen,
+ int randr,
+ Bool (*supported) (ScreenPtr pScreen,
+ const KdMonitorTiming *));
+
+const KdMonitorTiming *
+KdRandRGetTiming (ScreenPtr pScreen,
+ Bool (*supported) (ScreenPtr pScreen,
+ const KdMonitorTiming *),
+ int rate,
+ RRScreenSizePtr pSize);
+#endif
+
+/* kshadow.c */
+Bool
+KdShadowFbAlloc (KdScreenInfo *screen, Bool rotate);
+
+void
+KdShadowFbFree (KdScreenInfo *screen);
+
+Bool
+KdShadowSet (ScreenPtr pScreen, int randr, ShadowUpdateProc update, ShadowWindowProc window);
+
+void
+KdShadowUnset (ScreenPtr pScreen);
+
+/* function prototypes to be implemented by the drivers */
+void
+InitCard (char *name);
+
+#endif /* _KDRIVE_H_ */
diff --git a/xorg-server/hw/kdrive/src/kinput.c b/xorg-server/hw/kdrive/src/kinput.c
index 3358357f4..3d87996be 100644
--- a/xorg-server/hw/kdrive/src/kinput.c
+++ b/xorg-server/hw/kdrive/src/kinput.c
@@ -1,2345 +1,2345 @@
-/*
- * 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"
-#include "inpututils.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 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;
- }
- free(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 = calloc(pi->nButtons, sizeof(Atom));
- if (!btn_labels)
- return BadAlloc;
- axes_labels = calloc(pi->nAxes, sizeof(Atom));
- if (!axes_labels) {
- free(btn_labels);
- return BadAlloc;
- }
-
- switch(pi->nAxes)
- {
- default:
- case 7:
- btn_labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT);
- case 6:
- btn_labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT);
- case 5:
- btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN);
- case 4:
- btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
- case 3:
- btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
- case 2:
- btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
- case 1:
- btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
- case 0:
- break;
- }
-
- if (pi->nAxes >= 2) {
- axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
- axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
- }
-
- InitPointerDeviceStruct(pDev, pi->map, pi->nButtons, btn_labels,
- (PtrCtrlProcPtr)NoopDDA,
- GetMotionHistorySize(), pi->nAxes, axes_labels);
-
- free(btn_labels);
- free(axes_labels);
-
- if (pi->inputClass == KD_TOUCHSCREEN) {
- 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;
- }
- free(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 = calloc(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 *) calloc(sizeof(struct KdConfigDevice), 1);
- if (!new)
- return BadAlloc;
-
- new->line = strdup(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;
- }
-
-#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 *) calloc(sizeof(struct KdConfigDevice), 1);
- if (!new)
- return BadAlloc;
-
- new->line = strdup(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;
- }
-
- 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 = calloc(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 *)malloc(tam_key);
- strncpy(newopt->key, string, tam_key);
- newopt->key[tam_key] = '\0';
- newopt->value = strdup(strchr(string, '=') + 1);
- }
- else
- {
- newopt->key = strdup(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 = strdup(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 = strdup(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();
-}
-
-void
-KdCloseInput (void)
-{
- mieqFini();
-}
-
-/*
- * 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;
- 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);
- QueueGetKeyboardEvents(ki->dixdev, KeyRelease, key, NULL);
- }
- }
- }
-
- 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;
-
- 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;
-
- QueueKeyboardEvents(ki->dixdev, type, key_code, NULL);
- }
- 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 valuators[3] = { x, y, z };
- ValuatorMask mask;
-
- /* TRUE from KdHandlePointerEvent, means 'we swallowed the event'. */
- if (!force && KdHandlePointerEvent(pi, type, x, y, z, b, absrel))
- return;
-
- valuator_mask_set_range(&mask, 0, 3, valuators);
-
- QueuePointerEvents(pi->dixdev, type, b, absrel, &mask);
-}
-
-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();
- if (kdSwitchPending)
- KdProcessSwitch ();
- KdCheckLock ();
-}
-#endif
-
-/* 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:
- case DEVICE_CORE:
- return BadMatch;
- case DEVICE_ENABLE:
- return Success;
-
- default:
- return BadMatch;
- }
-
- /* NOTREACHED */
- return BadImplementation;
-}
-
-int
-NewInputDeviceRequest(InputOption *options, InputAttributes *attrs,
- 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
-#ifdef CONFIG_UDEV
- else if (strcmp(option->key, "_source") == 0 &&
- strcmp(option->value, "server/udev") == 0)
- {
- ErrorF("Ignoring device from udev.\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"
+#include "inpututils.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 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;
+ }
+ free(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 = calloc(pi->nButtons, sizeof(Atom));
+ if (!btn_labels)
+ return BadAlloc;
+ axes_labels = calloc(pi->nAxes, sizeof(Atom));
+ if (!axes_labels) {
+ free(btn_labels);
+ return BadAlloc;
+ }
+
+ switch(pi->nAxes)
+ {
+ default:
+ case 7:
+ btn_labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT);
+ case 6:
+ btn_labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT);
+ case 5:
+ btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN);
+ case 4:
+ btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
+ case 3:
+ btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
+ case 2:
+ btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
+ case 1:
+ btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
+ case 0:
+ break;
+ }
+
+ if (pi->nAxes >= 2) {
+ axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
+ axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
+ }
+
+ InitPointerDeviceStruct(pDev, pi->map, pi->nButtons, btn_labels,
+ (PtrCtrlProcPtr)NoopDDA,
+ GetMotionHistorySize(), pi->nAxes, axes_labels);
+
+ free(btn_labels);
+ free(axes_labels);
+
+ if (pi->inputClass == KD_TOUCHSCREEN) {
+ 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;
+ }
+ free(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 = calloc(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 *) calloc(sizeof(struct KdConfigDevice), 1);
+ if (!new)
+ return BadAlloc;
+
+ new->line = strdup(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;
+ }
+
+#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 *) calloc(sizeof(struct KdConfigDevice), 1);
+ if (!new)
+ return BadAlloc;
+
+ new->line = strdup(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;
+ }
+
+ 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 = calloc(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 *)malloc(tam_key);
+ strncpy(newopt->key, string, tam_key);
+ newopt->key[tam_key] = '\0';
+ newopt->value = strdup(strchr(string, '=') + 1);
+ }
+ else
+ {
+ newopt->key = strdup(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 = strdup(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 = strdup(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();
+}
+
+void
+KdCloseInput (void)
+{
+ mieqFini();
+}
+
+/*
+ * 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;
+ 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);
+ QueueGetKeyboardEvents(ki->dixdev, KeyRelease, key, NULL);
+ }
+ }
+ }
+
+ 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;
+
+ 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;
+
+ QueueKeyboardEvents(ki->dixdev, type, key_code, NULL);
+ }
+ 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 valuators[3] = { x, y, z };
+ ValuatorMask mask;
+
+ /* TRUE from KdHandlePointerEvent, means 'we swallowed the event'. */
+ if (!force && KdHandlePointerEvent(pi, type, x, y, z, b, absrel))
+ return;
+
+ valuator_mask_set_range(&mask, 0, 3, valuators);
+
+ QueuePointerEvents(pi->dixdev, type, b, absrel, &mask);
+}
+
+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();
+ if (kdSwitchPending)
+ KdProcessSwitch ();
+ KdCheckLock ();
+}
+#endif
+
+/* 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:
+ case DEVICE_CORE:
+ return BadMatch;
+ case DEVICE_ENABLE:
+ return Success;
+
+ default:
+ return BadMatch;
+ }
+
+ /* NOTREACHED */
+ return BadImplementation;
+}
+
+int
+NewInputDeviceRequest(InputOption *options, InputAttributes *attrs,
+ 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
+#ifdef CONFIG_UDEV
+ else if (strcmp(option->key, "_source") == 0 &&
+ strcmp(option->value, "server/udev") == 0)
+ {
+ ErrorF("Ignoring device from udev.\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/xfree86/Makefile.am b/xorg-server/hw/xfree86/Makefile.am
index c3e006c1f..e3ef14fc1 100644
--- a/xorg-server/hw/xfree86/Makefile.am
+++ b/xorg-server/hw/xfree86/Makefile.am
@@ -1,117 +1,117 @@
-
-if DRI
-DRI_SUBDIR = dri
-endif
-
-if DRI2
-DRI2_SUBDIR = dri2
-endif
-
-if XF86UTILS
-XF86UTILS_SUBDIR = utils
-endif
-
-if XAA
-XAA_SUBDIR = xaa
-endif
-
-if VGAHW
-VGAHW_SUBDIR = vgahw
-endif
-
-if VBE
-VBE_SUBDIR = vbe
-endif
-
-if INT10MODULE
-INT10_SUBDIR = int10
-endif
-
-SUBDIRS = common ddc i2c x86emu $(INT10_SUBDIR) fbdevhw os-support parser \
- ramdac shadowfb $(VBE_SUBDIR) $(VGAHW_SUBDIR) $(XAA_SUBDIR) \
- loader dixmods exa modes \
- $(DRI_SUBDIR) $(DRI2_SUBDIR) $(XF86UTILS_SUBDIR) doc man
-
-DIST_SUBDIRS = common ddc i2c x86emu int10 fbdevhw os-support \
- parser ramdac shadowfb vbe vgahw xaa \
- loader dixmods dri dri2 exa modes \
- utils doc man
-
-bin_PROGRAMS = Xorg
-nodist_Xorg_SOURCES = sdksyms.c
-
-AM_CFLAGS = $(DIX_CFLAGS) @XORG_CFLAGS@
-INCLUDES = $(XORG_INCS) -I$(srcdir)/parser -I$(top_srcdir)/miext/cw \
- -I$(srcdir)/ddc -I$(srcdir)/i2c -I$(srcdir)/modes -I$(srcdir)/ramdac
-
-LOCAL_LIBS = \
- $(MAIN_LIB) \
- $(XSERVER_LIBS) \
- loader/libloader.la \
- common/libcommon.la \
- os-support/libxorgos.la \
- parser/libxf86config_internal.la \
- dixmods/libdixmods.la \
- modes/libxf86modes.la \
- ramdac/libramdac.la \
- ddc/libddc.la \
- i2c/libi2c.la \
- dixmods/libxorgxkb.la \
- $(XORG_LIBS) \
- $(top_builddir)/mi/libmi.la \
- $(top_builddir)/os/libos.la
-Xorg_LDADD = \
- $(LOCAL_LIBS) \
- $(XORG_SYS_LIBS) \
- $(XSERVER_SYS_LIBS)
-Xorg_DEPENDENCIES = $(LOCAL_LIBS)
-
-Xorg_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
-
-BUILT_SOURCES = xorg.conf.example
-DISTCLEANFILES = xorg.conf.example
-EXTRA_DIST = xorgconf.cpp
-
-if SOLARIS_ASM_INLINE
-# Needs to be built before any files are compiled when using Sun compilers
-# so in*/out* inline definitions are properly processed.
-
-BUILT_SOURCES += os-support/solaris/solaris-@SOLARIS_INOUT_ARCH@.il
-
-os-support/solaris/solaris-@SOLARIS_INOUT_ARCH@.il:
- cd os-support/solaris ; \
- $(MAKE) $(AM_MAKEFLAGS) solaris-@SOLARIS_INOUT_ARCH@.il
-endif
-
-# do not use $(mkdir_p) if you want automake 1.7 to work
-install-data-local:
- mkdir -p $(DESTDIR)$(logdir)
-
-
-install-exec-local: install-binPROGRAMS
- (cd $(DESTDIR)$(bindir) && rm -f X && ln -s Xorg X)
-if INSTALL_SETUID
- chown root $(DESTDIR)$(bindir)/Xorg
- chmod u+s $(DESTDIR)$(bindir)/Xorg
-endif
-
-# Use variables from XORG_MANPAGE_SECTIONS and X Server configuration
-# Do not include manpages.am as values are not appropriate for rc files
-CONF_SUBSTS = -e 's|__filemansuffix__|$(FILE_MAN_SUFFIX)|g' \
- -e 's|MODULEPATH|$(DEFAULT_MODULE_PATH)|g' \
- -e 's|DEFAULTFONTPATH|$(COMPILEDDEFAULTFONTPATH)|g'
-
-xorg.conf.example: xorgconf.cpp
- $(AM_V_GEN)$(SED) $(CONF_SUBSTS) < $(srcdir)/xorgconf.cpp > $@
-
-relink:
- $(AM_V_at)rm -f Xorg && $(MAKE) Xorg
-
-CLEANFILES = sdksyms.c sdksyms.dep
-EXTRA_DIST += sdksyms.sh
-
-sdksyms.dep sdksyms.c: sdksyms.sh
- CPP='$(CPP)' AWK='$(AWK)' $(srcdir)/sdksyms.sh $(top_srcdir) $(CFLAGS) $(AM_CFLAGS) $(INCLUDES)
-
-SDKSYMS_DEP = sdksyms.dep
-include $(SDKSYMS_DEP)
+
+if DRI
+DRI_SUBDIR = dri
+endif
+
+if DRI2
+DRI2_SUBDIR = dri2
+endif
+
+if XF86UTILS
+XF86UTILS_SUBDIR = utils
+endif
+
+if XAA
+XAA_SUBDIR = xaa
+endif
+
+if VGAHW
+VGAHW_SUBDIR = vgahw
+endif
+
+if VBE
+VBE_SUBDIR = vbe
+endif
+
+if INT10MODULE
+INT10_SUBDIR = int10
+endif
+
+SUBDIRS = common ddc i2c x86emu $(INT10_SUBDIR) fbdevhw os-support parser \
+ ramdac shadowfb $(VBE_SUBDIR) $(VGAHW_SUBDIR) $(XAA_SUBDIR) \
+ loader dixmods exa modes \
+ $(DRI_SUBDIR) $(DRI2_SUBDIR) $(XF86UTILS_SUBDIR) doc man
+
+DIST_SUBDIRS = common ddc i2c x86emu int10 fbdevhw os-support \
+ parser ramdac shadowfb vbe vgahw xaa \
+ loader dixmods dri dri2 exa modes \
+ utils doc man
+
+bin_PROGRAMS = Xorg
+nodist_Xorg_SOURCES = sdksyms.c
+
+AM_CFLAGS = $(DIX_CFLAGS) @XORG_CFLAGS@
+INCLUDES = $(XORG_INCS) -I$(srcdir)/parser -I$(top_srcdir)/miext/cw \
+ -I$(srcdir)/ddc -I$(srcdir)/i2c -I$(srcdir)/modes -I$(srcdir)/ramdac
+
+LOCAL_LIBS = \
+ $(MAIN_LIB) \
+ $(XSERVER_LIBS) \
+ loader/libloader.la \
+ common/libcommon.la \
+ os-support/libxorgos.la \
+ parser/libxf86config_internal.la \
+ dixmods/libdixmods.la \
+ modes/libxf86modes.la \
+ ramdac/libramdac.la \
+ ddc/libddc.la \
+ i2c/libi2c.la \
+ dixmods/libxorgxkb.la \
+ $(XORG_LIBS) \
+ $(top_builddir)/mi/libmi.la \
+ $(top_builddir)/os/libos.la
+Xorg_LDADD = \
+ $(LOCAL_LIBS) \
+ $(XORG_SYS_LIBS) \
+ $(XSERVER_SYS_LIBS)
+Xorg_DEPENDENCIES = $(LOCAL_LIBS)
+
+Xorg_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+
+BUILT_SOURCES = xorg.conf.example
+DISTCLEANFILES = xorg.conf.example
+EXTRA_DIST = xorgconf.cpp
+
+if SOLARIS_ASM_INLINE
+# Needs to be built before any files are compiled when using Sun compilers
+# so in*/out* inline definitions are properly processed.
+
+BUILT_SOURCES += os-support/solaris/solaris-@SOLARIS_INOUT_ARCH@.il
+
+os-support/solaris/solaris-@SOLARIS_INOUT_ARCH@.il:
+ cd os-support/solaris ; \
+ $(MAKE) $(AM_MAKEFLAGS) solaris-@SOLARIS_INOUT_ARCH@.il
+endif
+
+# do not use $(mkdir_p) if you want automake 1.7 to work
+install-data-local:
+ mkdir -p $(DESTDIR)$(logdir)
+
+
+install-exec-local: install-binPROGRAMS
+ (cd $(DESTDIR)$(bindir) && rm -f X && ln -s Xorg X)
+if INSTALL_SETUID
+ chown root $(DESTDIR)$(bindir)/Xorg
+ chmod u+s $(DESTDIR)$(bindir)/Xorg
+endif
+
+# Use variables from XORG_MANPAGE_SECTIONS and X Server configuration
+# Do not include manpages.am as values are not appropriate for rc files
+CONF_SUBSTS = -e 's|__filemansuffix__|$(FILE_MAN_SUFFIX)|g' \
+ -e 's|MODULEPATH|$(DEFAULT_MODULE_PATH)|g' \
+ -e 's|DEFAULTFONTPATH|$(COMPILEDDEFAULTFONTPATH)|g'
+
+xorg.conf.example: xorgconf.cpp
+ $(AM_V_GEN)$(SED) $(CONF_SUBSTS) < $(srcdir)/xorgconf.cpp > $@
+
+relink:
+ $(AM_V_at)rm -f Xorg && $(MAKE) Xorg
+
+CLEANFILES = sdksyms.c sdksyms.dep
+EXTRA_DIST += sdksyms.sh
+
+sdksyms.dep sdksyms.c: sdksyms.sh
+ CPP='$(CPP)' AWK='$(AWK)' $(srcdir)/sdksyms.sh $(top_srcdir) $(CFLAGS) $(AM_CFLAGS) $(INCLUDES)
+
+SDKSYMS_DEP = sdksyms.dep
+include $(SDKSYMS_DEP)
diff --git a/xorg-server/hw/xfree86/common/xf86Config.c b/xorg-server/hw/xfree86/common/xf86Config.c
index 19af91509..58b30dd68 100644
--- a/xorg-server/hw/xfree86/common/xf86Config.c
+++ b/xorg-server/hw/xfree86/common/xf86Config.c
@@ -1,2534 +1,2534 @@
-/*
- * Loosely based on code bearing the following copyright:
- *
- * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
- */
-
-/*
- * Copyright 1992-2003 by The XFree86 Project, Inc.
- * Copyright 1997 by Metro Link, 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).
- */
-
-/*
- *
- * Authors:
- * Dirk Hohndel <hohndel@XFree86.Org>
- * David Dawes <dawes@XFree86.Org>
- * Marc La France <tsi@XFree86.Org>
- * Egbert Eich <eich@XFree86.Org>
- * ... and others
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#ifdef XF86DRI
-#include <sys/types.h>
-#include <grp.h>
-#endif
-
-#include "xf86.h"
-#include "xf86Parser.h"
-#include "xf86tokens.h"
-#include "xf86Config.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-#include "configProcs.h"
-#include "globals.h"
-#include "extension.h"
-#include "xf86pciBus.h"
-
-#include "xf86Xinput.h"
-
-#include "xkbsrv.h"
-
-#include "picture.h"
-
-/*
- * These paths define the way the config file search is done. The escape
- * sequences are documented in parser/scan.c.
- */
-#ifndef ROOT_CONFIGPATH
-#define ROOT_CONFIGPATH "%A," "%R," \
- "/etc/X11/%R," "%P/etc/X11/%R," \
- "%E," "%F," \
- "/etc/X11/%F," "%P/etc/X11/%F," \
- "/etc/X11/%X," "/etc/%X," \
- "%P/etc/X11/%X.%H," \
- "%P/etc/X11/%X," \
- "%P/lib/X11/%X.%H," \
- "%P/lib/X11/%X"
-#endif
-#ifndef USER_CONFIGPATH
-#define USER_CONFIGPATH "/etc/X11/%S," "%P/etc/X11/%S," \
- "/etc/X11/%G," "%P/etc/X11/%G," \
- "/etc/X11/%X," "/etc/%X," \
- "%P/etc/X11/%X.%H," \
- "%P/etc/X11/%X," \
- "%P/lib/X11/%X.%H," \
- "%P/lib/X11/%X"
-#endif
-#ifndef ROOT_CONFIGDIRPATH
-#define ROOT_CONFIGDIRPATH "%A," "%R," \
- "/etc/X11/%R," "%C/X11/%R," \
- "/etc/X11/%X," "%C/X11/%X"
-#endif
-#ifndef USER_CONFIGDIRPATH
-#define USER_CONFIGDIRPATH "/etc/X11/%R," "%C/X11/%R," \
- "/etc/X11/%X," "%C/X11/%X"
-#endif
-#ifndef SYS_CONFIGDIRPATH
-#define SYS_CONFIGDIRPATH "/usr/share/X11/%X," "%D/X11/%X"
-#endif
-#ifndef PROJECTROOT
-#define PROJECTROOT "/usr/X11R6"
-#endif
-
-static ModuleDefault ModuleDefaults[] = {
- {.name = "extmod", .toLoad = TRUE, .load_opt=NULL},
-#ifdef DBE
- {.name = "dbe", .toLoad = TRUE, .load_opt=NULL},
-#endif
-#ifdef GLXEXT
- {.name = "glx", .toLoad = TRUE, .load_opt=NULL},
-#endif
-#ifdef XRECORD
- {.name = "record", .toLoad = TRUE, .load_opt=NULL},
-#endif
-#ifdef XF86DRI
- {.name = "dri", .toLoad = TRUE, .load_opt=NULL},
-#endif
-#ifdef DRI2
- {.name = "dri2", .toLoad = TRUE, .load_opt=NULL},
-#endif
- {.name = NULL, .toLoad = FALSE, .load_opt=NULL}
-};
-
-
-/* Forward declarations */
-static Bool configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen,
- int scrnum, MessageType from);
-static Bool configMonitor(MonPtr monitorp, XF86ConfMonitorPtr conf_monitor);
-static Bool configDevice(GDevPtr devicep, XF86ConfDevicePtr conf_device,
- Bool active);
-static Bool configInput(InputInfoPtr pInfo, XF86ConfInputPtr conf_input,
- MessageType from);
-static Bool configDisplay(DispPtr displayp, XF86ConfDisplayPtr conf_display);
-static Bool addDefaultModes(MonPtr monitorp);
-#ifdef XF86DRI
-static void configDRI(XF86ConfDRIPtr drip);
-#endif
-static void configExtensions(XF86ConfExtensionsPtr conf_ext);
-
-/*
- * xf86GetPathElem --
- * Extract a single element from the font path string starting at
- * pnt. The font path element will be returned, and pnt will be
- * updated to point to the start of the next element, or set to
- * NULL if there are no more.
- */
-static char *
-xf86GetPathElem(char **pnt)
-{
- char *p1;
-
- p1 = *pnt;
- *pnt = index(*pnt, ',');
- if (*pnt != NULL) {
- **pnt = '\0';
- *pnt += 1;
- }
- return p1;
-}
-
-/*
- * xf86ValidateFontPath --
- * Validates the user-specified font path. Each element that
- * begins with a '/' is checked to make sure the directory exists.
- * If the directory exists, the existence of a file named 'fonts.dir'
- * is checked. If either check fails, an error is printed and the
- * element is removed from the font path.
- */
-
-#define DIR_FILE "/fonts.dir"
-static char *
-xf86ValidateFontPath(char *path)
-{
- char *tmp_path, *out_pnt, *path_elem, *next, *p1, *dir_elem;
- struct stat stat_buf;
- int flag;
- int dirlen;
-
- tmp_path = calloc(1,strlen(path)+1);
- out_pnt = tmp_path;
- path_elem = NULL;
- next = path;
- while (next != NULL) {
- path_elem = xf86GetPathElem(&next);
- if (*path_elem == '/') {
- dir_elem = xnfcalloc(1, strlen(path_elem) + 1);
- if ((p1 = strchr(path_elem, ':')) != 0)
- dirlen = p1 - path_elem;
- else
- dirlen = strlen(path_elem);
- strncpy(dir_elem, path_elem, dirlen);
- dir_elem[dirlen] = '\0';
- flag = stat(dir_elem, &stat_buf);
- if (flag == 0)
- if (!S_ISDIR(stat_buf.st_mode))
- flag = -1;
- if (flag != 0) {
- xf86Msg(X_WARNING, "The directory \"%s\" does not exist.\n", dir_elem);
- xf86ErrorF("\tEntry deleted from font path.\n");
- free(dir_elem);
- continue;
- }
- else {
- XNFasprintf(&p1, "%s%s", dir_elem, DIR_FILE);
- flag = stat(p1, &stat_buf);
- if (flag == 0)
- if (!S_ISREG(stat_buf.st_mode))
- flag = -1;
- free(p1);
- if (flag != 0) {
- xf86Msg(X_WARNING,
- "`fonts.dir' not found (or not valid) in \"%s\".\n",
- dir_elem);
- xf86ErrorF("\tEntry deleted from font path.\n");
- xf86ErrorF("\t(Run 'mkfontdir' on \"%s\").\n", dir_elem);
- free(dir_elem);
- continue;
- }
- }
- free(dir_elem);
- }
-
- /*
- * Either an OK directory, or a font server name. So add it to
- * the path.
- */
- if (out_pnt != tmp_path)
- *out_pnt++ = ',';
- strcat(out_pnt, path_elem);
- out_pnt += strlen(path_elem);
- }
- return tmp_path;
-}
-
-
-/*
- * use the datastructure that the parser provides and pick out the parts
- * that we need at this point
- */
-char **
-xf86ModulelistFromConfig(pointer **optlist)
-{
- int count = 0, i = 0;
- char **modulearray;
- char *ignore[] = { "GLcore", "speedo", "bitmap", "drm",
- "freetype", "type1",
- NULL };
- pointer *optarray;
- XF86LoadPtr modp;
- Bool found;
-
- /*
- * make sure the config file has been parsed and that we have a
- * ModulePath set; if no ModulePath was given, use the default
- * ModulePath
- */
- if (xf86configptr == NULL) {
- xf86Msg(X_ERROR, "Cannot access global config data structure\n");
- return NULL;
- }
-
- if (xf86configptr->conf_modules) {
- /* Walk the disable list and let people know what we've parsed to
- * not be loaded
- */
- modp = xf86configptr->conf_modules->mod_disable_lst;
- while (modp) {
- xf86Msg(X_WARNING, "\"%s\" will not be loaded unless you've specified it to be loaded elsewhere.\n", modp->load_name);
- modp = (XF86LoadPtr) modp->list.next;
- }
- /*
- * Walk the default settings table. For each module listed to be
- * loaded, make sure it's in the mod_load_lst. If it's not, make
- * sure it's not in the mod_no_load_lst. If it's not disabled,
- * append it to mod_load_lst
- */
- for (i=0 ; ModuleDefaults[i].name != NULL ; i++) {
- if (ModuleDefaults[i].toLoad == FALSE) {
- xf86Msg(X_WARNING, "\"%s\" is not to be loaded by default. Skipping.\n", ModuleDefaults[i].name);
- continue;
- }
- found = FALSE;
- modp = xf86configptr->conf_modules->mod_load_lst;
- while (modp) {
- if (strcmp(modp->load_name, ModuleDefaults[i].name) == 0) {
- xf86Msg(X_INFO, "\"%s\" will be loaded. This was enabled by default and also specified in the config file.\n", ModuleDefaults[i].name);
- found = TRUE;
- break;
- }
- modp = (XF86LoadPtr) modp->list.next;
- }
- if (found == FALSE) {
- modp = xf86configptr->conf_modules->mod_disable_lst;
- while (modp) {
- if (strcmp(modp->load_name, ModuleDefaults[i].name) == 0) {
- xf86Msg(X_INFO, "\"%s\" will be loaded even though the default is to disable it.\n", ModuleDefaults[i].name);
- found = TRUE;
- break;
- }
- modp = (XF86LoadPtr) modp->list.next;
- }
- }
- if (found == FALSE) {
- XF86LoadPtr ptr = (XF86LoadPtr)xf86configptr->conf_modules;
- xf86addNewLoadDirective(ptr, ModuleDefaults[i].name, XF86_LOAD_MODULE, ModuleDefaults[i].load_opt);
- xf86Msg(X_INFO, "\"%s\" will be loaded by default.\n", ModuleDefaults[i].name);
- }
- }
- } else {
- xf86configptr->conf_modules = xnfcalloc(1, sizeof(XF86ConfModuleRec));
- for (i=0 ; ModuleDefaults[i].name != NULL ; i++) {
- if (ModuleDefaults[i].toLoad == TRUE) {
- XF86LoadPtr ptr = (XF86LoadPtr)xf86configptr->conf_modules;
- xf86addNewLoadDirective(ptr, ModuleDefaults[i].name, XF86_LOAD_MODULE, ModuleDefaults[i].load_opt);
- }
- }
- }
-
- /*
- * Walk the list of modules in the "Module" section to determine how
- * many we have.
- */
- modp = xf86configptr->conf_modules->mod_load_lst;
- while (modp) {
- for (i = 0; ignore[i]; i++) {
- if (strcmp(modp->load_name, ignore[i]) == 0)
- modp->ignore = 1;
- }
- if (!modp->ignore)
- count++;
- modp = (XF86LoadPtr) modp->list.next;
- }
-
- /*
- * allocate the memory and walk the list again to fill in the pointers
- */
- modulearray = xnfalloc((count + 1) * sizeof(char*));
- optarray = xnfalloc((count + 1) * sizeof(pointer));
- count = 0;
- if (xf86configptr->conf_modules) {
- modp = xf86configptr->conf_modules->mod_load_lst;
- while (modp) {
- if (!modp->ignore) {
- modulearray[count] = modp->load_name;
- optarray[count] = modp->load_opt;
- count++;
- }
- modp = (XF86LoadPtr) modp->list.next;
- }
- }
- modulearray[count] = NULL;
- optarray[count] = NULL;
- if (optlist)
- *optlist = optarray;
- else
- free(optarray);
- return modulearray;
-}
-
-
-char **
-xf86DriverlistFromConfig(void)
-{
- int count = 0;
- int j;
- char **modulearray;
- screenLayoutPtr slp;
-
- /*
- * make sure the config file has been parsed and that we have a
- * ModulePath set; if no ModulePath was given, use the default
- * ModulePath
- */
- if (xf86configptr == NULL) {
- xf86Msg(X_ERROR, "Cannot access global config data structure\n");
- return NULL;
- }
-
- /*
- * Walk the list of driver lines in active "Device" sections to
- * determine now many implicitly loaded modules there are.
- *
- */
- if (xf86ConfigLayout.screens) {
- slp = xf86ConfigLayout.screens;
- while ((slp++)->screen) {
- count++;
- }
- }
-
- /*
- * Handle the set of inactive "Device" sections.
- */
- j = 0;
- while (xf86ConfigLayout.inactives[j++].identifier)
- count++;
-
- if (count == 0)
- return NULL;
-
- /*
- * allocate the memory and walk the list again to fill in the pointers
- */
- modulearray = xnfalloc((count + 1) * sizeof(char*));
- count = 0;
- slp = xf86ConfigLayout.screens;
- while (slp->screen) {
- modulearray[count] = slp->screen->device->driver;
- count++;
- slp++;
- }
-
- j = 0;
-
- while (xf86ConfigLayout.inactives[j].identifier)
- modulearray[count++] = xf86ConfigLayout.inactives[j++].driver;
-
- modulearray[count] = NULL;
-
- /* Remove duplicates */
- for (count = 0; modulearray[count] != NULL; count++) {
- int i;
-
- for (i = 0; i < count; i++)
- if (xf86NameCmp(modulearray[i], modulearray[count]) == 0) {
- modulearray[count] = "";
- break;
- }
- }
- return modulearray;
-}
-
-char **
-xf86InputDriverlistFromConfig(void)
-{
- int count = 0;
- char **modulearray;
- InputInfoPtr *idp;
-
- /*
- * make sure the config file has been parsed and that we have a
- * ModulePath set; if no ModulePath was given, use the default
- * ModulePath
- */
- if (xf86configptr == NULL) {
- xf86Msg(X_ERROR, "Cannot access global config data structure\n");
- return NULL;
- }
-
- /*
- * Walk the list of driver lines in active "InputDevice" sections to
- * determine now many implicitly loaded modules there are.
- */
- if (xf86ConfigLayout.inputs) {
- idp = xf86ConfigLayout.inputs;
- while (*idp) {
- count++;
- idp++;
- }
- }
-
- if (count == 0)
- return NULL;
-
- /*
- * allocate the memory and walk the list again to fill in the pointers
- */
- modulearray = xnfalloc((count + 1) * sizeof(char*));
- count = 0;
- idp = xf86ConfigLayout.inputs;
- while (idp && *idp) {
- modulearray[count] = (*idp)->driver;
- count++;
- idp++;
- }
- modulearray[count] = NULL;
-
- /* Remove duplicates */
- for (count = 0; modulearray[count] != NULL; count++) {
- int i;
-
- for (i = 0; i < count; i++)
- if (xf86NameCmp(modulearray[i], modulearray[count]) == 0) {
- modulearray[count] = "";
- break;
- }
- }
- return modulearray;
-}
-
-static void
-fixup_video_driver_list(char **drivers)
-{
- static const char *fallback[4] = { "vesa", "fbdev", "wsfb", NULL };
- char **end, **drv;
- char *x;
- int i;
-
- /* walk to the end of the list */
- for (end = drivers; *end && **end; end++) ;
- end--;
-
- /*
- * for each of the fallback drivers, if we find it in the list,
- * swap it with the last available non-fallback driver.
- */
- for (i = 0; fallback[i]; i++) {
- for (drv = drivers; drv != end; drv++) {
- if (strstr(*drv, fallback[i])) {
- x = *drv; *drv = *end; *end = x;
- end--;
- break;
- }
- }
- }
-}
-
-static char **
-GenerateDriverlist(char * dirname)
-{
- char **ret;
- const char *subdirs[] = { dirname, NULL };
- static const char *patlist[] = {"(.*)_drv\\.so", NULL};
- ret = LoaderListDirs(subdirs, patlist);
-
- /* fix up the probe order for video drivers */
- if (strstr(dirname, "drivers") && ret != NULL)
- fixup_video_driver_list(ret);
-
- return ret;
-}
-
-char **
-xf86DriverlistFromCompile(void)
-{
- static char **driverlist = NULL;
-
- if (!driverlist)
- driverlist = GenerateDriverlist("drivers");
-
- return driverlist;
-}
-
-/*
- * xf86ConfigError --
- * Print a READABLE ErrorMessage!!! All information that is
- * available is printed.
- */
-static void
-xf86ConfigError(char *msg, ...)
-{
- va_list ap;
-
- ErrorF("\nConfig Error:\n");
- va_start(ap, msg);
- VErrorF(msg, ap);
- va_end(ap);
- ErrorF("\n");
- return;
-}
-
-static void
-configFiles(XF86ConfFilesPtr fileconf)
-{
- MessageType pathFrom;
- Bool must_copy;
- int size, countDirs;
- char *temp_path, *log_buf, *start, *end;
-
- /* FontPath */
- must_copy = TRUE;
-
- temp_path = defaultFontPath ? defaultFontPath : "";
- if (xf86fpFlag)
- pathFrom = X_CMDLINE;
- else if (fileconf && fileconf->file_fontpath) {
- pathFrom = X_CONFIG;
- if (xf86Info.useDefaultFontPath) {
- if (asprintf(&defaultFontPath, "%s%s%s", fileconf->file_fontpath,
- *temp_path ? "," : "", temp_path) == -1)
- defaultFontPath = NULL;
- else
- must_copy = FALSE;
- }
- else
- defaultFontPath = fileconf->file_fontpath;
- }
- else
- pathFrom = X_DEFAULT;
- temp_path = defaultFontPath ? defaultFontPath : "";
-
- /* xf86ValidateFontPath modifies its argument, but returns a copy of it. */
- temp_path = must_copy ? xnfstrdup(defaultFontPath) : defaultFontPath;
- defaultFontPath = xf86ValidateFontPath(temp_path);
- free(temp_path);
-
- /* make fontpath more readable in the logfiles */
- countDirs = 1;
- temp_path = defaultFontPath;
- while ((temp_path = index(temp_path, ',')) != NULL) {
- countDirs++;
- temp_path++;
- }
-
- log_buf = xnfalloc(strlen(defaultFontPath) + (2 * countDirs) + 1);
- temp_path = log_buf;
- start = defaultFontPath;
- while((end = index(start, ',')) != NULL) {
- size = (end - start) + 1;
- *(temp_path++) = '\t';
- strncpy(temp_path, start, size);
- temp_path += size;
- *(temp_path++) = '\n';
- start += size;
- }
- /* copy last entry */
- *(temp_path++) = '\t';
- strcpy(temp_path, start);
- xf86Msg(pathFrom, "FontPath set to:\n%s\n", log_buf);
- free(log_buf);
-
- /* ModulePath */
-
- if (fileconf) {
- if (xf86ModPathFrom != X_CMDLINE && fileconf->file_modulepath) {
- xf86ModulePath = fileconf->file_modulepath;
- xf86ModPathFrom = X_CONFIG;
- }
- }
-
- xf86Msg(xf86ModPathFrom, "ModulePath set to \"%s\"\n", xf86ModulePath);
-
- if (!xf86xkbdirFlag && fileconf && fileconf->file_xkbdir) {
- XkbBaseDirectory = fileconf->file_xkbdir;
- xf86Msg(X_CONFIG, "XKB base directory set to \"%s\"\n",
- XkbBaseDirectory);
- }
-#if 0
- /* LogFile */
- /*
- * XXX The problem with this is that the log file is already open.
- * One option might be to copy the exiting contents to the new location.
- * and re-open it. The down side is that the default location would
- * already have been overwritten. Another option would be to start with
- * unique temporary location, then copy it once the correct name is known.
- * A problem with this is what happens if the server exits before that
- * happens.
- */
- if (xf86LogFileFrom == X_DEFAULT && fileconf->file_logfile) {
- xf86LogFile = fileconf->file_logfile;
- xf86LogFileFrom = X_CONFIG;
- }
-#endif
-
- return;
-}
-
-typedef enum {
- FLAG_NOTRAPSIGNALS,
- FLAG_DONTVTSWITCH,
- FLAG_DONTZAP,
- FLAG_DONTZOOM,
- FLAG_DISABLEVIDMODE,
- FLAG_ALLOWNONLOCAL,
- FLAG_ALLOWMOUSEOPENFAIL,
- FLAG_VTSYSREQ,
- FLAG_SAVER_BLANKTIME,
- FLAG_DPMS_STANDBYTIME,
- FLAG_DPMS_SUSPENDTIME,
- FLAG_DPMS_OFFTIME,
- FLAG_PIXMAP,
- FLAG_PC98,
- FLAG_NOPM,
- FLAG_XINERAMA,
- FLAG_LOG,
- FLAG_RENDER_COLORMAP_MODE,
- FLAG_RANDR,
- FLAG_AIGLX,
- FLAG_IGNORE_ABI,
- FLAG_ALLOW_EMPTY_INPUT,
- FLAG_USE_DEFAULT_FONT_PATH,
- FLAG_AUTO_ADD_DEVICES,
- FLAG_AUTO_ENABLE_DEVICES,
- FLAG_GLX_VISUALS,
- FLAG_DRI2,
- FLAG_USE_SIGIO
-} FlagValues;
-
-/**
- * NOTE: the last value for each entry is NOT the default. It is set to TRUE
- * if the parser found the option in the config file.
- */
-static OptionInfoRec FlagOptions[] = {
- { FLAG_NOTRAPSIGNALS, "NoTrapSignals", OPTV_BOOLEAN,
- {0}, FALSE },
- { FLAG_DONTVTSWITCH, "DontVTSwitch", OPTV_BOOLEAN,
- {0}, FALSE },
- { FLAG_DONTZAP, "DontZap", OPTV_BOOLEAN,
- {0}, FALSE },
- { FLAG_DONTZOOM, "DontZoom", OPTV_BOOLEAN,
- {0}, FALSE },
- { FLAG_DISABLEVIDMODE, "DisableVidModeExtension", OPTV_BOOLEAN,
- {0}, FALSE },
- { FLAG_ALLOWNONLOCAL, "AllowNonLocalXvidtune", OPTV_BOOLEAN,
- {0}, FALSE },
- { FLAG_ALLOWMOUSEOPENFAIL, "AllowMouseOpenFail", OPTV_BOOLEAN,
- {0}, FALSE },
- { FLAG_VTSYSREQ, "VTSysReq", OPTV_BOOLEAN,
- {0}, FALSE },
- { FLAG_SAVER_BLANKTIME, "BlankTime" , OPTV_INTEGER,
- {0}, FALSE },
- { FLAG_DPMS_STANDBYTIME, "StandbyTime", OPTV_INTEGER,
- {0}, FALSE },
- { FLAG_DPMS_SUSPENDTIME, "SuspendTime", OPTV_INTEGER,
- {0}, FALSE },
- { FLAG_DPMS_OFFTIME, "OffTime", OPTV_INTEGER,
- {0}, FALSE },
- { FLAG_PIXMAP, "Pixmap", OPTV_INTEGER,
- {0}, FALSE },
- { FLAG_PC98, "PC98", OPTV_BOOLEAN,
- {0}, FALSE },
- { FLAG_NOPM, "NoPM", OPTV_BOOLEAN,
- {0}, FALSE },
- { FLAG_XINERAMA, "Xinerama", OPTV_BOOLEAN,
- {0}, FALSE },
- { FLAG_LOG, "Log", OPTV_STRING,
- {0}, FALSE },
- { FLAG_RENDER_COLORMAP_MODE, "RenderColormapMode", OPTV_STRING,
- {0}, FALSE },
- { FLAG_RANDR, "RandR", OPTV_BOOLEAN,
- {0}, FALSE },
- { FLAG_AIGLX, "AIGLX", OPTV_BOOLEAN,
- {0}, FALSE },
- { FLAG_IGNORE_ABI, "IgnoreABI", OPTV_BOOLEAN,
- {0}, FALSE },
- { FLAG_USE_DEFAULT_FONT_PATH, "UseDefaultFontPath", OPTV_BOOLEAN,
- {0}, FALSE },
- { FLAG_AUTO_ADD_DEVICES, "AutoAddDevices", OPTV_BOOLEAN,
- {0}, FALSE },
- { FLAG_AUTO_ENABLE_DEVICES, "AutoEnableDevices", OPTV_BOOLEAN,
- {0}, FALSE },
- { FLAG_GLX_VISUALS, "GlxVisuals", OPTV_STRING,
- {0}, FALSE },
- { FLAG_DRI2, "DRI2", OPTV_BOOLEAN,
- {0}, FALSE },
- { FLAG_USE_SIGIO, "UseSIGIO", OPTV_BOOLEAN,
- {0}, FALSE },
- { -1, NULL, OPTV_NONE,
- {0}, FALSE },
-};
-
-#ifdef SUPPORT_PC98
-static Bool
-detectPC98(void)
-{
- unsigned char buf[2];
-
- if (xf86ReadBIOS(0xf8000, 0xe80, buf, 2) != 2)
- return FALSE;
- if ((buf[0] == 0x98) && (buf[1] == 0x21))
- return TRUE;
- else
- return FALSE;
-}
-#endif
-
-static Bool
-configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
-{
- XF86OptionPtr optp, tmp;
- int i;
- Pix24Flags pix24 = Pix24DontCare;
- Bool value;
- MessageType from;
- const char *s;
- XkbRMLVOSet set;
- /* Default options. */
- set.rules = "base";
- set.model = "pc105";
- set.layout = "us";
- set.variant = NULL;
- set.options = NULL;
-
- /*
- * Merge the ServerLayout and ServerFlags options. The former have
- * precedence over the latter.
- */
- optp = NULL;
- if (flagsconf && flagsconf->flg_option_lst)
- optp = xf86optionListDup(flagsconf->flg_option_lst);
- if (layoutopts) {
- tmp = xf86optionListDup(layoutopts);
- if (optp)
- optp = xf86optionListMerge(optp, tmp);
- else
- optp = tmp;
- }
-
- xf86ProcessOptions(-1, optp, FlagOptions);
-
- xf86GetOptValBool(FlagOptions, FLAG_NOTRAPSIGNALS, &xf86Info.notrapSignals);
- xf86GetOptValBool(FlagOptions, FLAG_DONTVTSWITCH, &xf86Info.dontVTSwitch);
- xf86GetOptValBool(FlagOptions, FLAG_DONTZAP, &xf86Info.dontZap);
- xf86GetOptValBool(FlagOptions, FLAG_DONTZOOM, &xf86Info.dontZoom);
-
- xf86GetOptValBool(FlagOptions, FLAG_IGNORE_ABI, &xf86Info.ignoreABI);
- if (xf86Info.ignoreABI) {
- xf86Msg(X_CONFIG, "Ignoring ABI Version\n");
- }
-
- if (xf86SIGIOSupported()) {
- xf86Info.useSIGIO = xf86ReturnOptValBool(FlagOptions, FLAG_USE_SIGIO, USE_SIGIO_BY_DEFAULT);
- if (xf86IsOptionSet(FlagOptions, FLAG_USE_SIGIO)) {
- from = X_CONFIG;
- } else {
- from = X_DEFAULT;
- }
- if (!xf86Info.useSIGIO) {
- xf86Msg(from, "Disabling SIGIO handlers for input devices\n");
- } else if (from == X_CONFIG) {
- xf86Msg(from, "Enabling SIGIO handlers for input devices\n");
- }
- } else {
- xf86Info.useSIGIO = FALSE;
- }
-
- if (xf86IsOptionSet(FlagOptions, FLAG_AUTO_ADD_DEVICES)) {
- xf86GetOptValBool(FlagOptions, FLAG_AUTO_ADD_DEVICES,
- &xf86Info.autoAddDevices);
- from = X_CONFIG;
- }
- else {
- from = X_DEFAULT;
- }
- xf86Msg(from, "%sutomatically adding devices\n",
- xf86Info.autoAddDevices ? "A" : "Not a");
-
- if (xf86IsOptionSet(FlagOptions, FLAG_AUTO_ENABLE_DEVICES)) {
- xf86GetOptValBool(FlagOptions, FLAG_AUTO_ENABLE_DEVICES,
- &xf86Info.autoEnableDevices);
- from = X_CONFIG;
- }
- else {
- from = X_DEFAULT;
- }
- xf86Msg(from, "%sutomatically enabling devices\n",
- xf86Info.autoEnableDevices ? "A" : "Not a");
-
- /*
- * Set things up based on the config file information. Some of these
- * settings may be overridden later when the command line options are
- * checked.
- */
-#ifdef XF86VIDMODE
- if (xf86GetOptValBool(FlagOptions, FLAG_DISABLEVIDMODE, &value))
- xf86Info.vidModeEnabled = !value;
- if (xf86GetOptValBool(FlagOptions, FLAG_ALLOWNONLOCAL, &value))
- xf86Info.vidModeAllowNonLocal = value;
-#endif
-
- if (xf86GetOptValBool(FlagOptions, FLAG_ALLOWMOUSEOPENFAIL, &value))
- xf86Info.allowMouseOpenFail = value;
-
- if (xf86GetOptValBool(FlagOptions, FLAG_VTSYSREQ, &value)) {
-#ifdef USE_VT_SYSREQ
- xf86Info.vtSysreq = value;
- xf86Msg(X_CONFIG, "VTSysReq %s\n", value ? "enabled" : "disabled");
-#else
- if (value)
- xf86Msg(X_WARNING, "VTSysReq is not supported on this OS\n");
-#endif
- }
-
- xf86Info.pmFlag = TRUE;
- if (xf86GetOptValBool(FlagOptions, FLAG_NOPM, &value))
- xf86Info.pmFlag = !value;
- {
- if ((s = xf86GetOptValString(FlagOptions, FLAG_LOG))) {
- if (!xf86NameCmp(s,"flush")) {
- xf86Msg(X_CONFIG, "Flushing logfile enabled\n");
- xf86Info.log = LogFlush;
- LogSetParameter(XLOG_FLUSH, TRUE);
- } else if (!xf86NameCmp(s,"sync")) {
- xf86Msg(X_CONFIG, "Syncing logfile enabled\n");
- xf86Info.log = LogSync;
- LogSetParameter(XLOG_FLUSH, TRUE);
- LogSetParameter(XLOG_SYNC, TRUE);
- } else {
- xf86Msg(X_WARNING,"Unknown Log option\n");
- }
- }
- }
-
- {
- if ((s = xf86GetOptValString(FlagOptions, FLAG_RENDER_COLORMAP_MODE))){
- int policy = PictureParseCmapPolicy (s);
- if (policy == PictureCmapPolicyInvalid)
- xf86Msg(X_WARNING, "Unknown colormap policy \"%s\"\n", s);
- else
- {
- xf86Msg(X_CONFIG, "Render colormap policy set to %s\n", s);
- PictureCmapPolicy = policy;
- }
- }
- }
-
-#ifdef RANDR
- xf86Info.disableRandR = FALSE;
- xf86Info.randRFrom = X_DEFAULT;
- if (xf86GetOptValBool(FlagOptions, FLAG_RANDR, &value)) {
- xf86Info.disableRandR = !value;
- xf86Info.randRFrom = X_CONFIG;
- }
-#endif
-
- xf86Info.aiglx = TRUE;
- xf86Info.aiglxFrom = X_DEFAULT;
- if (xf86GetOptValBool(FlagOptions, FLAG_AIGLX, &value)) {
- xf86Info.aiglx = value;
- xf86Info.aiglxFrom = X_CONFIG;
- }
-
-#ifdef GLXEXT
- xf86Info.glxVisuals = XF86_GlxVisualsTypical;
- xf86Info.glxVisualsFrom = X_DEFAULT;
- if ((s = xf86GetOptValString(FlagOptions, FLAG_GLX_VISUALS))) {
- if (!xf86NameCmp(s, "minimal")) {
- xf86Info.glxVisuals = XF86_GlxVisualsMinimal;
- } else if (!xf86NameCmp(s, "typical")) {
- xf86Info.glxVisuals = XF86_GlxVisualsTypical;
- } else if (!xf86NameCmp(s, "all")) {
- xf86Info.glxVisuals = XF86_GlxVisualsAll;
- } else {
- xf86Msg(X_WARNING,"Unknown GlxVisuals option\n");
- }
- }
-
- if (xf86GetOptValBool(FlagOptions, FLAG_AIGLX, &value)) {
- xf86Info.aiglx = value;
- xf86Info.aiglxFrom = X_CONFIG;
- }
-#endif
-
- /* if we're not hotplugging, force some input devices to exist */
- xf86Info.forceInputDevices = !(xf86Info.autoAddDevices && xf86Info.autoEnableDevices);
-
- /* when forcing input devices, we use kbd. otherwise evdev, so use the
- * evdev rules set. */
-#if defined(linux)
- if (!xf86Info.forceInputDevices)
- set.rules = "evdev";
-#endif
- XkbSetRulesDflts(&set);
-
- xf86Info.useDefaultFontPath = TRUE;
- xf86Info.useDefaultFontPathFrom = X_DEFAULT;
- if (xf86GetOptValBool(FlagOptions, FLAG_USE_DEFAULT_FONT_PATH, &value)) {
- xf86Info.useDefaultFontPath = value;
- xf86Info.useDefaultFontPathFrom = X_CONFIG;
- }
-
-/* Make sure that timers don't overflow CARD32's after multiplying */
-#define MAX_TIME_IN_MIN (0x7fffffff / MILLI_PER_MIN)
-
- i = -1;
- xf86GetOptValInteger(FlagOptions, FLAG_SAVER_BLANKTIME, &i);
- if ((i >= 0) && (i < MAX_TIME_IN_MIN))
- ScreenSaverTime = defaultScreenSaverTime = i * MILLI_PER_MIN;
- else if (i != -1)
- xf86ConfigError("BlankTime value %d outside legal range of 0 - %d minutes",
- i, MAX_TIME_IN_MIN);
-
-#ifdef DPMSExtension
- i = -1;
- xf86GetOptValInteger(FlagOptions, FLAG_DPMS_STANDBYTIME, &i);
- if ((i >= 0) && (i < MAX_TIME_IN_MIN))
- DPMSStandbyTime = i * MILLI_PER_MIN;
- else if (i != -1)
- xf86ConfigError("StandbyTime value %d outside legal range of 0 - %d minutes",
- i, MAX_TIME_IN_MIN);
- i = -1;
- xf86GetOptValInteger(FlagOptions, FLAG_DPMS_SUSPENDTIME, &i);
- if ((i >= 0) && (i < MAX_TIME_IN_MIN))
- DPMSSuspendTime = i * MILLI_PER_MIN;
- else if (i != -1)
- xf86ConfigError("SuspendTime value %d outside legal range of 0 - %d minutes",
- i, MAX_TIME_IN_MIN);
- i = -1;
- xf86GetOptValInteger(FlagOptions, FLAG_DPMS_OFFTIME, &i);
- if ((i >= 0) && (i < MAX_TIME_IN_MIN))
- DPMSOffTime = i * MILLI_PER_MIN;
- else if (i != -1)
- xf86ConfigError("OffTime value %d outside legal range of 0 - %d minutes",
- i, MAX_TIME_IN_MIN);
-#endif
-
- i = -1;
- xf86GetOptValInteger(FlagOptions, FLAG_PIXMAP, &i);
- switch (i) {
- case 24:
- pix24 = Pix24Use24;
- break;
- case 32:
- pix24 = Pix24Use32;
- break;
- case -1:
- break;
- default:
- xf86ConfigError("Pixmap option's value (%d) must be 24 or 32\n", i);
- return FALSE;
- }
- if (xf86Pix24 != Pix24DontCare) {
- xf86Info.pixmap24 = xf86Pix24;
- xf86Info.pix24From = X_CMDLINE;
- } else if (pix24 != Pix24DontCare) {
- xf86Info.pixmap24 = pix24;
- xf86Info.pix24From = X_CONFIG;
- } else {
- xf86Info.pixmap24 = Pix24DontCare;
- xf86Info.pix24From = X_DEFAULT;
- }
-#ifdef SUPPORT_PC98
- if (xf86GetOptValBool(FlagOptions, FLAG_PC98, &value)) {
- xf86Info.pc98 = value;
- if (value) {
- xf86Msg(X_CONFIG, "Japanese PC98 architecture\n");
- }
- } else
- if (detectPC98()) {
- xf86Info.pc98 = TRUE;
- xf86Msg(X_PROBED, "Japanese PC98 architecture\n");
- }
-#endif
-
-#ifdef PANORAMIX
- from = X_DEFAULT;
- if (!noPanoramiXExtension)
- from = X_CMDLINE;
- else if (xf86GetOptValBool(FlagOptions, FLAG_XINERAMA, &value)) {
- noPanoramiXExtension = !value;
- from = X_CONFIG;
- }
- if (!noPanoramiXExtension)
- xf86Msg(from, "Xinerama: enabled\n");
-#endif
-
-#ifdef DRI2
- xf86Info.dri2 = FALSE;
- xf86Info.dri2From = X_DEFAULT;
- if (xf86GetOptValBool(FlagOptions, FLAG_DRI2, &value)) {
- xf86Info.dri2 = value;
- xf86Info.dri2From = X_CONFIG;
- }
-#endif
-
- return TRUE;
-}
-
-Bool xf86DRI2Enabled(void)
-{
- return xf86Info.dri2;
-}
-
-/*
- * Locate the core input devices. These can be specified/located in
- * the following ways, in order of priority:
- *
- * 1. The InputDevices named by the -pointer and -keyboard command line
- * options.
- * 2. The "CorePointer" and "CoreKeyboard" InputDevices referred to by
- * the active ServerLayout.
- * 3. The first InputDevices marked as "CorePointer" and "CoreKeyboard".
- * 4. The first InputDevices that use 'keyboard' or 'kbd' and a valid mouse
- * driver (mouse, synaptics, evdev, vmmouse, void)
- * 5. Default devices with an empty (default) configuration. These defaults
- * will reference the 'mouse' and 'keyboard' drivers.
- */
-
-static Bool
-checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
-{
- InputInfoPtr corePointer = NULL, coreKeyboard = NULL;
- Bool foundPointer = FALSE, foundKeyboard = FALSE;
- const char *pointerMsg = NULL, *keyboardMsg = NULL;
- InputInfoPtr *devs, /* iterator */
- indp;
- InputInfoRec Pointer = {}, Keyboard = {};
- XF86ConfInputPtr confInput;
- XF86ConfInputRec defPtr, defKbd;
- int count = 0;
- MessageType from = X_DEFAULT;
- int found = 0;
- const char *mousedrivers[] = { "mouse", "synaptics", "evdev", "vmmouse",
- "void", NULL };
-
- /*
- * First check if a core pointer or core keyboard have been specified
- * in the active ServerLayout. If more than one is specified for either,
- * remove the core attribute from the later ones.
- */
- for (devs = servlayoutp->inputs; devs && *devs; devs++) {
- indp = *devs;
- if (indp->options &&
- xf86CheckBoolOption(indp->options, "CorePointer", FALSE)) {
- if (!corePointer) {
- corePointer = indp;
- } else {
- xf86ReplaceBoolOption(indp->options, "CorePointer", FALSE);
- xf86Msg(X_WARNING, "Duplicate core pointer devices. "
- "Removing core pointer attribute from \"%s\"\n",
- indp->name);
- }
- }
- if (indp->options &&
- xf86CheckBoolOption(indp->options, "CoreKeyboard", FALSE)) {
- if (!coreKeyboard) {
- coreKeyboard = indp;
- } else {
- xf86ReplaceBoolOption(indp->options, "CoreKeyboard", FALSE);
- xf86Msg(X_WARNING, "Duplicate core keyboard devices. "
- "Removing core keyboard attribute from \"%s\"\n",
- indp->name);
- }
- }
- count++;
- }
-
- confInput = NULL;
-
- /* 1. Check for the -pointer command line option. */
- if (xf86PointerName) {
- confInput = xf86findInput(xf86PointerName,
- xf86configptr->conf_input_lst);
- if (!confInput) {
- xf86Msg(X_ERROR, "No InputDevice section called \"%s\"\n",
- xf86PointerName);
- return FALSE;
- }
- from = X_CMDLINE;
- /*
- * If one was already specified in the ServerLayout, it needs to be
- * removed.
- */
- if (corePointer) {
- for (devs = servlayoutp->inputs; devs && *devs; devs++)
- if (*devs == corePointer)
- {
- free(*devs);
- *devs = (InputInfoPtr)0x1; /* ensure we dont skip next loop*/
- break;
- }
- for (; devs && *devs; devs++)
- devs[0] = devs[1];
- count--;
- }
- corePointer = NULL;
- foundPointer = TRUE;
- }
-
- /* 2. ServerLayout-specified core pointer. */
- if (corePointer) {
- foundPointer = TRUE;
- from = X_CONFIG;
- }
-
- /* 3. First core pointer device. */
- if (!foundPointer && (xf86Info.forceInputDevices || implicitLayout)) {
- XF86ConfInputPtr p;
-
- for (p = xf86configptr->conf_input_lst; p; p = p->list.next) {
- if (p->inp_option_lst &&
- xf86CheckBoolOption(p->inp_option_lst, "CorePointer", FALSE)) {
- confInput = p;
- foundPointer = TRUE;
- from = X_DEFAULT;
- pointerMsg = "first core pointer device";
- break;
- }
- }
- }
-
- /* 4. First pointer with an allowed mouse driver. */
- if (!foundPointer && xf86Info.forceInputDevices) {
- const char **driver = mousedrivers;
- confInput = xf86findInput(CONF_IMPLICIT_POINTER,
- xf86configptr->conf_input_lst);
- while (*driver && !confInput) {
- confInput = xf86findInputByDriver(*driver,
- xf86configptr->conf_input_lst);
- driver++;
- }
- if (confInput) {
- foundPointer = TRUE;
- from = X_DEFAULT;
- pointerMsg = "first mouse device";
- }
- }
-
- /* 5. Built-in default. */
- if (!foundPointer && xf86Info.forceInputDevices) {
- memset(&defPtr, 0, sizeof(defPtr));
- defPtr.inp_identifier = strdup("<default pointer>");
- defPtr.inp_driver = strdup("mouse");
- confInput = &defPtr;
- foundPointer = TRUE;
- from = X_DEFAULT;
- pointerMsg = "default mouse configuration";
- }
-
- /* Add the core pointer device to the layout, and set it to Core. */
- if (foundPointer && confInput) {
- foundPointer = configInput(&Pointer, confInput, from);
- if (foundPointer) {
- count++;
- devs = xnfrealloc(servlayoutp->inputs,
- (count + 1) * sizeof(InputInfoPtr));
- devs[count - 1] = xnfalloc(sizeof(InputInfoRec));
- Pointer.fd = -1;
- *devs[count - 1] = Pointer;
- devs[count - 1]->options =
- xf86addNewOption(devs[count -1]->options,
- xnfstrdup("CorePointer"), NULL);
- devs[count] = NULL;
- servlayoutp->inputs = devs;
- }
- }
-
- if (!foundPointer && xf86Info.forceInputDevices) {
- /* This shouldn't happen. */
- xf86Msg(X_ERROR, "Cannot locate a core pointer device.\n");
- return FALSE;
- }
-
- /*
- * always synthesize a 'mouse' section configured to send core
- * events, unless a 'void' section is found, in which case the user
- * probably wants to run footless.
- *
- * If you're using an evdev keyboard and expect a default mouse
- * section ... deal.
- */
- for (devs = servlayoutp->inputs; devs && *devs; devs++) {
- const char **driver = mousedrivers;
- while(*driver) {
- if (!strcmp((*devs)->driver, *driver)) {
- found = 1;
- break;
- }
- driver++;
- }
- }
- if (!found && xf86Info.forceInputDevices) {
- xf86Msg(X_INFO, "No default mouse found, adding one\n");
- memset(&defPtr, 0, sizeof(defPtr));
- defPtr.inp_identifier = strdup("<default pointer>");
- defPtr.inp_driver = strdup("mouse");
- confInput = &defPtr;
- foundPointer = configInput(&Pointer, confInput, from);
- if (foundPointer) {
- count++;
- devs = xnfrealloc(servlayoutp->inputs,
- (count + 1) * sizeof(InputInfoPtr));
- devs[count - 1] = xnfalloc(sizeof(InputInfoRec));
- Pointer.fd = -1;
- *devs[count - 1] = Pointer;
- devs[count - 1]->options =
- xf86addNewOption(NULL, xnfstrdup("AlwaysCore"), NULL);
- devs[count] = NULL;
- servlayoutp->inputs = devs;
- }
- }
-
- confInput = NULL;
-
- /* 1. Check for the -keyboard command line option. */
- if (xf86KeyboardName) {
- confInput = xf86findInput(xf86KeyboardName,
- xf86configptr->conf_input_lst);
- if (!confInput) {
- xf86Msg(X_ERROR, "No InputDevice section called \"%s\"\n",
- xf86KeyboardName);
- return FALSE;
- }
- from = X_CMDLINE;
- /*
- * If one was already specified in the ServerLayout, it needs to be
- * removed.
- */
- if (coreKeyboard) {
- for (devs = servlayoutp->inputs; devs && *devs; devs++)
- if (*devs == coreKeyboard)
- {
- free(*devs);
- *devs = (InputInfoPtr)0x1; /* ensure we dont skip next loop */
- break;
- }
- for (; devs && *devs; devs++)
- devs[0] = devs[1];
- count--;
- }
- coreKeyboard = NULL;
- foundKeyboard = TRUE;
- }
-
- /* 2. ServerLayout-specified core keyboard. */
- if (coreKeyboard) {
- foundKeyboard = TRUE;
- from = X_CONFIG;
- }
-
- /* 3. First core keyboard device. */
- if (!foundKeyboard && (xf86Info.forceInputDevices || implicitLayout)) {
- XF86ConfInputPtr p;
-
- for (p = xf86configptr->conf_input_lst; p; p = p->list.next) {
- if (p->inp_option_lst &&
- xf86CheckBoolOption(p->inp_option_lst, "CoreKeyboard", FALSE)) {
- confInput = p;
- foundKeyboard = TRUE;
- from = X_DEFAULT;
- keyboardMsg = "first core keyboard device";
- break;
- }
- }
- }
-
- /* 4. First keyboard with 'keyboard' or 'kbd' as the driver. */
- if (!foundKeyboard && xf86Info.forceInputDevices) {
- confInput = xf86findInput(CONF_IMPLICIT_KEYBOARD,
- xf86configptr->conf_input_lst);
- if (!confInput) {
- confInput = xf86findInputByDriver("kbd",
- xf86configptr->conf_input_lst);
- }
- if (confInput) {
- foundKeyboard = TRUE;
- from = X_DEFAULT;
- keyboardMsg = "first keyboard device";
- }
- }
-
- /* 5. Built-in default. */
- if (!foundKeyboard && xf86Info.forceInputDevices) {
- memset(&defKbd, 0, sizeof(defKbd));
- defKbd.inp_identifier = strdup("<default keyboard>");
- defKbd.inp_driver = strdup("kbd");
- confInput = &defKbd;
- foundKeyboard = TRUE;
- keyboardMsg = "default keyboard configuration";
- from = X_DEFAULT;
- }
-
- /* Add the core keyboard device to the layout, and set it to Core. */
- if (foundKeyboard && confInput) {
- foundKeyboard = configInput(&Keyboard, confInput, from);
- if (foundKeyboard) {
- count++;
- devs = xnfrealloc(servlayoutp->inputs,
- (count + 1) * sizeof(InputInfoPtr));
- devs[count - 1] = xnfalloc(sizeof(InputInfoRec));
- Keyboard.fd = -1;
- *devs[count - 1] = Keyboard;
- devs[count - 1]->options =
- xf86addNewOption(devs[count - 1]->options,
- xnfstrdup("CoreKeyboard"), NULL);
- devs[count] = NULL;
- servlayoutp->inputs = devs;
- }
- }
-
- if (!foundKeyboard && xf86Info.forceInputDevices) {
- /* This shouldn't happen. */
- xf86Msg(X_ERROR, "Cannot locate a core keyboard device.\n");
- return FALSE;
- }
-
- if (pointerMsg) {
- if (implicitLayout)
- xf86Msg(X_DEFAULT, "No Layout section. Using the %s.\n",
- pointerMsg);
- else
- xf86Msg(X_DEFAULT, "The core pointer device wasn't specified "
- "explicitly in the layout.\n"
- "\tUsing the %s.\n", pointerMsg);
- }
-
- if (keyboardMsg) {
- if (implicitLayout)
- xf86Msg(X_DEFAULT, "No Layout section. Using the %s.\n",
- keyboardMsg);
- else
- xf86Msg(X_DEFAULT, "The core keyboard device wasn't specified "
- "explicitly in the layout.\n"
- "\tUsing the %s.\n", keyboardMsg);
- }
-
- if (!xf86Info.forceInputDevices && !(foundPointer && foundKeyboard)) {
-#if defined(CONFIG_HAL) || defined(CONFIG_UDEV)
- const char *config_backend;
-#if defined(CONFIG_HAL)
- config_backend = "HAL";
-#else
- config_backend = "udev";
-#endif
- xf86Msg(X_INFO, "The server relies on %s to provide the list of "
- "input devices.\n\tIf no devices become available, "
- "reconfigure %s or disable AutoAddDevices.\n",
- config_backend, config_backend);
-#else
- xf86Msg(X_WARNING, "Hotplugging requested but the server was "
- "compiled without a config backend. "
- "No input devices were configured, the server "
- "will start without any input devices.\n");
-#endif
- }
-
- return TRUE;
-}
-
-typedef enum {
- LAYOUT_ISOLATEDEVICE,
- LAYOUT_SINGLECARD
-} LayoutValues;
-
-static OptionInfoRec LayoutOptions[] = {
- { LAYOUT_ISOLATEDEVICE, "IsolateDevice", OPTV_STRING,
- {0}, FALSE },
- { LAYOUT_SINGLECARD, "SingleCard", OPTV_BOOLEAN,
- {0}, FALSE },
- { -1, NULL, OPTV_NONE,
- {0}, FALSE },
-};
-
-static Bool
-configInputDevices(XF86ConfLayoutPtr layout, serverLayoutPtr servlayoutp)
-{
- XF86ConfInputrefPtr irp;
- InputInfoPtr *indp;
- int count = 0;
-
- /*
- * Count the number of input devices.
- */
- irp = layout->lay_input_lst;
- while (irp) {
- count++;
- irp = (XF86ConfInputrefPtr)irp->list.next;
- }
- DebugF("Found %d input devices in the layout section %s\n",
- count, layout->lay_identifier);
- indp = xnfcalloc((count + 1), sizeof(InputInfoPtr));
- indp[count] = NULL;
- irp = layout->lay_input_lst;
- count = 0;
- while (irp) {
- indp[count] = xf86AllocateInput();
- if (!configInput(indp[count], irp->iref_inputdev, X_CONFIG)) {
- do {
- free(indp[count]);
- } while(count--);
- free(indp);
- return FALSE;
- }
- indp[count]->options = xf86OptionListMerge(indp[count]->options,
- irp->iref_option_lst);
- count++;
- irp = (XF86ConfInputrefPtr)irp->list.next;
- }
- servlayoutp->inputs = indp;
-
- return TRUE;
-}
-
-
-/*
- * figure out which layout is active, which screens are used in that layout,
- * which drivers and monitors are used in these screens
- */
-static Bool
-configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
- char *default_layout)
-{
- XF86ConfAdjacencyPtr adjp;
- XF86ConfInactivePtr idp;
- int saved_count, count = 0;
- int scrnum;
- XF86ConfLayoutPtr l;
- MessageType from;
- screenLayoutPtr slp;
- GDevPtr gdp;
- int i = 0, j;
-
- if (!servlayoutp)
- return FALSE;
-
- /*
- * which layout section is the active one?
- *
- * If there is a -layout command line option, use that one, otherwise
- * pick the first one.
- */
- from = X_DEFAULT;
- if (xf86LayoutName != NULL)
- from = X_CMDLINE;
- else if (default_layout) {
- xf86LayoutName = default_layout;
- from = X_CONFIG;
- }
- if (xf86LayoutName != NULL) {
- if ((l = xf86findLayout(xf86LayoutName, conf_layout)) == NULL) {
- xf86Msg(X_ERROR, "No ServerLayout section called \"%s\"\n",
- xf86LayoutName);
- return FALSE;
- }
- conf_layout = l;
- }
- xf86Msg(from, "ServerLayout \"%s\"\n", conf_layout->lay_identifier);
- adjp = conf_layout->lay_adjacency_lst;
-
- /*
- * we know that each screen is referenced exactly once on the left side
- * of a layout statement in the Layout section. So to allocate the right
- * size for the array we do a quick walk of the list to figure out how
- * many sections we have
- */
- while (adjp) {
- count++;
- adjp = (XF86ConfAdjacencyPtr)adjp->list.next;
- }
-
- DebugF("Found %d screens in the layout section %s",
- count, conf_layout->lay_identifier);
- if (!count) /* alloc enough storage even if no screen is specified */
- count = 1;
-
- slp = xnfcalloc(1, (count + 1) * sizeof(screenLayoutRec));
- slp[count].screen = NULL;
- /*
- * now that we have storage, loop over the list again and fill in our
- * data structure; at this point we do not fill in the adjacency
- * information as it is not clear if we need it at all
- */
- adjp = conf_layout->lay_adjacency_lst;
- count = 0;
- while (adjp) {
- slp[count].screen = xnfcalloc(1, sizeof(confScreenRec));
- if (adjp->adj_scrnum < 0)
- scrnum = count;
- else
- scrnum = adjp->adj_scrnum;
- if (!configScreen(slp[count].screen, adjp->adj_screen, scrnum,
- X_CONFIG)) {
- do {
- free(slp[count].screen);
- } while(count--);
- free(slp);
- return FALSE;
- }
- slp[count].x = adjp->adj_x;
- slp[count].y = adjp->adj_y;
- slp[count].refname = adjp->adj_refscreen;
- switch (adjp->adj_where) {
- case CONF_ADJ_OBSOLETE:
- slp[count].where = PosObsolete;
- slp[count].topname = adjp->adj_top_str;
- slp[count].bottomname = adjp->adj_bottom_str;
- slp[count].leftname = adjp->adj_left_str;
- slp[count].rightname = adjp->adj_right_str;
- break;
- case CONF_ADJ_ABSOLUTE:
- slp[count].where = PosAbsolute;
- break;
- case CONF_ADJ_RIGHTOF:
- slp[count].where = PosRightOf;
- break;
- case CONF_ADJ_LEFTOF:
- slp[count].where = PosLeftOf;
- break;
- case CONF_ADJ_ABOVE:
- slp[count].where = PosAbove;
- break;
- case CONF_ADJ_BELOW:
- slp[count].where = PosBelow;
- break;
- case CONF_ADJ_RELATIVE:
- slp[count].where = PosRelative;
- break;
- }
- count++;
- adjp = (XF86ConfAdjacencyPtr)adjp->list.next;
- }
-
- /* No screen was specified in the layout. take the first one from the
- * config file, or - if it is NULL - configScreen autogenerates one for
- * us */
- if (!count)
- {
- slp[0].screen = xnfcalloc(1, sizeof(confScreenRec));
- if (!configScreen(slp[0].screen, xf86configptr->conf_screen_lst,
- 0, X_CONFIG)) {
- free(slp[0].screen);
- free(slp);
- return FALSE;
- }
- }
-
- /* XXX Need to tie down the upper left screen. */
-
- /* Fill in the refscreen and top/bottom/left/right values */
- for (i = 0; i < count; i++) {
- for (j = 0; j < count; j++) {
- if (slp[i].refname &&
- strcmp(slp[i].refname, slp[j].screen->id) == 0) {
- slp[i].refscreen = slp[j].screen;
- }
- if (slp[i].topname &&
- strcmp(slp[i].topname, slp[j].screen->id) == 0) {
- slp[i].top = slp[j].screen;
- }
- if (slp[i].bottomname &&
- strcmp(slp[i].bottomname, slp[j].screen->id) == 0) {
- slp[i].bottom = slp[j].screen;
- }
- if (slp[i].leftname &&
- strcmp(slp[i].leftname, slp[j].screen->id) == 0) {
- slp[i].left = slp[j].screen;
- }
- if (slp[i].rightname &&
- strcmp(slp[i].rightname, slp[j].screen->id) == 0) {
- slp[i].right = slp[j].screen;
- }
- }
- if (slp[i].where != PosObsolete
- && slp[i].where != PosAbsolute
- && !slp[i].refscreen) {
- xf86Msg(X_ERROR,"Screen %s doesn't exist: deleting placement\n",
- slp[i].refname);
- slp[i].where = PosAbsolute;
- slp[i].x = 0;
- slp[i].y = 0;
- }
- }
-
- if (!count)
- saved_count = 1;
- else
- saved_count = count;
- /*
- * Count the number of inactive devices.
- */
- count = 0;
- idp = conf_layout->lay_inactive_lst;
- while (idp) {
- count++;
- idp = (XF86ConfInactivePtr)idp->list.next;
- }
- DebugF("Found %d inactive devices in the layout section %s\n",
- count, conf_layout->lay_identifier);
- gdp = xnfalloc((count + 1) * sizeof(GDevRec));
- gdp[count].identifier = NULL;
- idp = conf_layout->lay_inactive_lst;
- count = 0;
- while (idp) {
- if (!configDevice(&gdp[count], idp->inactive_device, FALSE))
- goto bail;
- count++;
- idp = (XF86ConfInactivePtr)idp->list.next;
- }
-
- if (!configInputDevices(conf_layout, servlayoutp))
- goto bail;
-
- servlayoutp->id = conf_layout->lay_identifier;
- servlayoutp->screens = slp;
- servlayoutp->inactives = gdp;
- servlayoutp->options = conf_layout->lay_option_lst;
- from = X_DEFAULT;
-
- return TRUE;
-
-bail:
- do {
- free(slp[saved_count].screen);
- } while(saved_count--);
- free(slp);
- free(gdp);
- return FALSE;
-}
-
-/*
- * No layout section, so find the first Screen section and set that up as
- * the only active screen.
- */
-static Bool
-configImpliedLayout(serverLayoutPtr servlayoutp, XF86ConfScreenPtr conf_screen,
- XF86ConfigPtr xf86configptr)
-{
- MessageType from;
- XF86ConfScreenPtr s;
- screenLayoutPtr slp;
- InputInfoPtr *indp;
- XF86ConfLayoutRec layout;
-
- if (!servlayoutp)
- return FALSE;
-
- /*
- * which screen section is the active one?
- *
- * If there is a -screen option, use that one, otherwise use the first
- * one.
- */
-
- from = X_CONFIG;
- if (xf86ScreenName != NULL) {
- if ((s = xf86findScreen(xf86ScreenName, conf_screen)) == NULL) {
- xf86Msg(X_ERROR, "No Screen section called \"%s\"\n",
- xf86ScreenName);
- return FALSE;
- }
- conf_screen = s;
- from = X_CMDLINE;
- }
-
- /* We have exactly one screen */
-
- slp = xnfcalloc(1, 2 * sizeof(screenLayoutRec));
- slp[0].screen = xnfcalloc(1, sizeof(confScreenRec));
- slp[1].screen = NULL;
- if (!configScreen(slp[0].screen, conf_screen, 0, from)) {
- free(slp);
- return FALSE;
- }
- servlayoutp->id = "(implicit)";
- servlayoutp->screens = slp;
- servlayoutp->inactives = xnfcalloc(1, sizeof(GDevRec));
- servlayoutp->options = NULL;
-
- memset(&layout, 0, sizeof(layout));
- layout.lay_identifier = servlayoutp->id;
- if (xf86layoutAddInputDevices(xf86configptr, &layout) > 0) {
- if (!configInputDevices(&layout, servlayoutp))
- return FALSE;
- from = X_DEFAULT;
- } else {
- /* Set up an empty input device list, then look for some core devices. */
- indp = xnfalloc(sizeof(InputInfoPtr));
- *indp = NULL;
- servlayoutp->inputs = indp;
- }
-
- return TRUE;
-}
-
-static Bool
-configXvAdaptor(confXvAdaptorPtr adaptor, XF86ConfVideoAdaptorPtr conf_adaptor)
-{
- int count = 0;
- XF86ConfVideoPortPtr conf_port;
-
- xf86Msg(X_CONFIG, "| |-->VideoAdaptor \"%s\"\n",
- conf_adaptor->va_identifier);
- adaptor->identifier = conf_adaptor->va_identifier;
- adaptor->options = conf_adaptor->va_option_lst;
- if (conf_adaptor->va_busid || conf_adaptor->va_driver) {
- xf86Msg(X_CONFIG, "| | Unsupported device type, skipping entry\n");
- return FALSE;
- }
-
- /*
- * figure out how many videoport subsections there are and fill them in
- */
- conf_port = conf_adaptor->va_port_lst;
- while(conf_port) {
- count++;
- conf_port = (XF86ConfVideoPortPtr)conf_port->list.next;
- }
- adaptor->ports = xnfalloc((count) * sizeof(confXvPortRec));
- adaptor->numports = count;
- count = 0;
- conf_port = conf_adaptor->va_port_lst;
- while(conf_port) {
- adaptor->ports[count].identifier = conf_port->vp_identifier;
- adaptor->ports[count].options = conf_port->vp_option_lst;
- count++;
- conf_port = (XF86ConfVideoPortPtr)conf_port->list.next;
- }
-
- return TRUE;
-}
-
-static Bool
-configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen, int scrnum,
- MessageType from)
-{
- int count = 0;
- XF86ConfDisplayPtr dispptr;
- XF86ConfAdaptorLinkPtr conf_adaptor;
- Bool defaultMonitor = FALSE;
- XF86ConfScreenRec local_conf_screen;
-
- if (!conf_screen) {
- memset(&local_conf_screen, 0, sizeof(local_conf_screen));
- conf_screen = &local_conf_screen;
- conf_screen->scrn_identifier = "Default Screen Section";
- xf86Msg(X_DEFAULT, "No screen section available. Using defaults.\n");
- }
-
- xf86Msg(from, "|-->Screen \"%s\" (%d)\n", conf_screen->scrn_identifier,
- scrnum);
- /*
- * now we fill in the elements of the screen
- */
- screenp->id = conf_screen->scrn_identifier;
- screenp->screennum = scrnum;
- screenp->defaultdepth = conf_screen->scrn_defaultdepth;
- screenp->defaultbpp = conf_screen->scrn_defaultbpp;
- screenp->defaultfbbpp = conf_screen->scrn_defaultfbbpp;
- screenp->monitor = xnfcalloc(1, sizeof(MonRec));
- /* If no monitor is specified, create a default one. */
- if (!conf_screen->scrn_monitor) {
- XF86ConfMonitorRec defMon;
-
- memset(&defMon, 0, sizeof(defMon));
- defMon.mon_identifier = "<default monitor>";
- if (!configMonitor(screenp->monitor, &defMon))
- return FALSE;
- defaultMonitor = TRUE;
- } else {
- if (!configMonitor(screenp->monitor,conf_screen->scrn_monitor))
- return FALSE;
- }
- /* Configure the device. If there isn't one configured, attach to the
- * first inactive one that we can configure. If there's none that work,
- * set it to NULL so that the section can be autoconfigured later */
- screenp->device = xnfcalloc(1, sizeof(GDevRec));
- if ((!conf_screen->scrn_device) && (xf86configptr->conf_device_lst)) {
- conf_screen->scrn_device = xf86configptr->conf_device_lst;
- xf86Msg(X_DEFAULT, "No device specified for screen \"%s\".\n"
- "\tUsing the first device section listed.\n", screenp->id);
- }
- if (configDevice(screenp->device,conf_screen->scrn_device, TRUE)) {
- screenp->device->myScreenSection = screenp;
- } else {
- screenp->device = NULL;
- }
- screenp->options = conf_screen->scrn_option_lst;
-
- /*
- * figure out how many display subsections there are and fill them in
- */
- dispptr = conf_screen->scrn_display_lst;
- while(dispptr) {
- count++;
- dispptr = (XF86ConfDisplayPtr)dispptr->list.next;
- }
- screenp->displays = xnfalloc((count) * sizeof(DispRec));
- screenp->numdisplays = count;
-
- /* Fill in the default Virtual size, if any */
- if (conf_screen->scrn_virtualX && conf_screen->scrn_virtualY) {
- for (count = 0, dispptr = conf_screen->scrn_display_lst;
- dispptr;
- dispptr = (XF86ConfDisplayPtr)dispptr->list.next, count++) {
- screenp->displays[count].virtualX = conf_screen->scrn_virtualX;
- screenp->displays[count].virtualY = conf_screen->scrn_virtualY;
- }
- }
-
- /* Now do the per-Display Virtual sizes */
- count = 0;
- dispptr = conf_screen->scrn_display_lst;
- while(dispptr) {
- configDisplay(&(screenp->displays[count]),dispptr);
- count++;
- dispptr = (XF86ConfDisplayPtr)dispptr->list.next;
- }
-
- /*
- * figure out how many videoadaptor references there are and fill them in
- */
- conf_adaptor = conf_screen->scrn_adaptor_lst;
- while(conf_adaptor) {
- count++;
- conf_adaptor = (XF86ConfAdaptorLinkPtr)conf_adaptor->list.next;
- }
- screenp->xvadaptors = xnfalloc((count) * sizeof(confXvAdaptorRec));
- screenp->numxvadaptors = 0;
- conf_adaptor = conf_screen->scrn_adaptor_lst;
- while(conf_adaptor) {
- if (configXvAdaptor(&(screenp->xvadaptors[screenp->numxvadaptors]),
- conf_adaptor->al_adaptor))
- screenp->numxvadaptors++;
- conf_adaptor = (XF86ConfAdaptorLinkPtr)conf_adaptor->list.next;
- }
-
- if (defaultMonitor) {
- xf86Msg(X_DEFAULT, "No monitor specified for screen \"%s\".\n"
- "\tUsing a default monitor configuration.\n", screenp->id);
- }
- return TRUE;
-}
-
-typedef enum {
- MON_REDUCEDBLANKING,
- MON_MAX_PIX_CLOCK,
-} MonitorValues;
-
-static OptionInfoRec MonitorOptions[] = {
- { MON_REDUCEDBLANKING, "ReducedBlanking", OPTV_BOOLEAN,
- {0}, FALSE },
- { MON_MAX_PIX_CLOCK, "MaxPixClock", OPTV_FREQ,
- {0}, FALSE },
- { -1, NULL, OPTV_NONE,
- {0}, FALSE },
-};
-
-static Bool
-configMonitor(MonPtr monitorp, XF86ConfMonitorPtr conf_monitor)
-{
- int count;
- DisplayModePtr mode,last = NULL;
- XF86ConfModeLinePtr cmodep;
- XF86ConfModesPtr modes;
- XF86ConfModesLinkPtr modeslnk = conf_monitor->mon_modes_sect_lst;
- Gamma zeros = {0.0, 0.0, 0.0};
- float badgamma = 0.0;
- double maxPixClock;
-
- xf86Msg(X_CONFIG, "| |-->Monitor \"%s\"\n",
- conf_monitor->mon_identifier);
- monitorp->id = conf_monitor->mon_identifier;
- monitorp->vendor = conf_monitor->mon_vendor;
- monitorp->model = conf_monitor->mon_modelname;
- monitorp->Modes = NULL;
- monitorp->Last = NULL;
- monitorp->gamma = zeros;
- monitorp->widthmm = conf_monitor->mon_width;
- monitorp->heightmm = conf_monitor->mon_height;
- monitorp->reducedblanking = FALSE;
- monitorp->maxPixClock = 0;
- monitorp->options = conf_monitor->mon_option_lst;
-
- /*
- * fill in the monitor structure
- */
- for( count = 0 ;
- count < conf_monitor->mon_n_hsync && count < MAX_HSYNC;
- count++) {
- monitorp->hsync[count].hi = conf_monitor->mon_hsync[count].hi;
- monitorp->hsync[count].lo = conf_monitor->mon_hsync[count].lo;
- }
- monitorp->nHsync = count;
- for( count = 0 ;
- count < conf_monitor->mon_n_vrefresh && count < MAX_VREFRESH;
- count++) {
- monitorp->vrefresh[count].hi = conf_monitor->mon_vrefresh[count].hi;
- monitorp->vrefresh[count].lo = conf_monitor->mon_vrefresh[count].lo;
- }
- monitorp->nVrefresh = count;
-
- /*
- * first we collect the mode lines from the UseModes directive
- */
- while(modeslnk)
- {
- modes = xf86findModes (modeslnk->ml_modes_str,
- xf86configptr->conf_modes_lst);
- modeslnk->ml_modes = modes;
-
-
- /* now add the modes found in the modes
- section to the list of modes for this
- monitor unless it has been added before
- because we are reusing the same section
- for another screen */
- if (xf86itemNotSublist(
- (GenericListPtr)conf_monitor->mon_modeline_lst,
- (GenericListPtr)modes->mon_modeline_lst)) {
- conf_monitor->mon_modeline_lst = (XF86ConfModeLinePtr)
- xf86addListItem(
- (GenericListPtr)conf_monitor->mon_modeline_lst,
- (GenericListPtr)modes->mon_modeline_lst);
- }
- modeslnk = modeslnk->list.next;
- }
-
- /*
- * we need to hook in the mode lines now
- * here both data structures use lists, only our internal one
- * is double linked
- */
- cmodep = conf_monitor->mon_modeline_lst;
- while( cmodep ) {
- mode = xnfcalloc(1, sizeof(DisplayModeRec));
- mode->type = 0;
- mode->Clock = cmodep->ml_clock;
- mode->HDisplay = cmodep->ml_hdisplay;
- mode->HSyncStart = cmodep->ml_hsyncstart;
- mode->HSyncEnd = cmodep->ml_hsyncend;
- mode->HTotal = cmodep->ml_htotal;
- mode->VDisplay = cmodep->ml_vdisplay;
- mode->VSyncStart = cmodep->ml_vsyncstart;
- mode->VSyncEnd = cmodep->ml_vsyncend;
- mode->VTotal = cmodep->ml_vtotal;
- mode->Flags = cmodep->ml_flags;
- mode->HSkew = cmodep->ml_hskew;
- mode->VScan = cmodep->ml_vscan;
- mode->name = xnfstrdup(cmodep->ml_identifier);
- if( last ) {
- mode->prev = last;
- last->next = mode;
- }
- else {
- /*
- * this is the first mode
- */
- monitorp->Modes = mode;
- mode->prev = NULL;
- }
- last = mode;
- cmodep = (XF86ConfModeLinePtr)cmodep->list.next;
- }
- if(last){
- last->next = NULL;
- }
- monitorp->Last = last;
-
- /* add the (VESA) default modes */
- if (! addDefaultModes(monitorp) )
- return FALSE;
-
- if (conf_monitor->mon_gamma_red > GAMMA_ZERO)
- monitorp->gamma.red = conf_monitor->mon_gamma_red;
- if (conf_monitor->mon_gamma_green > GAMMA_ZERO)
- monitorp->gamma.green = conf_monitor->mon_gamma_green;
- if (conf_monitor->mon_gamma_blue > GAMMA_ZERO)
- monitorp->gamma.blue = conf_monitor->mon_gamma_blue;
-
- /* Check that the gamma values are within range */
- if (monitorp->gamma.red > GAMMA_ZERO &&
- (monitorp->gamma.red < GAMMA_MIN ||
- monitorp->gamma.red > GAMMA_MAX)) {
- badgamma = monitorp->gamma.red;
- } else if (monitorp->gamma.green > GAMMA_ZERO &&
- (monitorp->gamma.green < GAMMA_MIN ||
- monitorp->gamma.green > GAMMA_MAX)) {
- badgamma = monitorp->gamma.green;
- } else if (monitorp->gamma.blue > GAMMA_ZERO &&
- (monitorp->gamma.blue < GAMMA_MIN ||
- monitorp->gamma.blue > GAMMA_MAX)) {
- badgamma = monitorp->gamma.blue;
- }
- if (badgamma > GAMMA_ZERO) {
- xf86ConfigError("Gamma value %.f is out of range (%.2f - %.1f)\n",
- badgamma, GAMMA_MIN, GAMMA_MAX);
- return FALSE;
- }
-
- xf86ProcessOptions(-1, monitorp->options, MonitorOptions);
- xf86GetOptValBool(MonitorOptions, MON_REDUCEDBLANKING,
- &monitorp->reducedblanking);
- if (xf86GetOptValFreq(MonitorOptions, MON_MAX_PIX_CLOCK, OPTUNITS_KHZ,
- &maxPixClock) == TRUE) {
- monitorp->maxPixClock = (int) maxPixClock;
- }
-
- return TRUE;
-}
-
-static int
-lookupVisual(const char *visname)
-{
- int i;
-
- if (!visname || !*visname)
- return -1;
-
- for (i = 0; i <= DirectColor; i++) {
- if (!xf86nameCompare(visname, xf86VisualNames[i]))
- break;
- }
-
- if (i <= DirectColor)
- return i;
-
- return -1;
-}
-
-
-static Bool
-configDisplay(DispPtr displayp, XF86ConfDisplayPtr conf_display)
-{
- int count = 0;
- XF86ModePtr modep;
-
- displayp->frameX0 = conf_display->disp_frameX0;
- displayp->frameY0 = conf_display->disp_frameY0;
- displayp->virtualX = conf_display->disp_virtualX;
- displayp->virtualY = conf_display->disp_virtualY;
- displayp->depth = conf_display->disp_depth;
- displayp->fbbpp = conf_display->disp_bpp;
- displayp->weight.red = conf_display->disp_weight.red;
- displayp->weight.green = conf_display->disp_weight.green;
- displayp->weight.blue = conf_display->disp_weight.blue;
- displayp->blackColour.red = conf_display->disp_black.red;
- displayp->blackColour.green = conf_display->disp_black.green;
- displayp->blackColour.blue = conf_display->disp_black.blue;
- displayp->whiteColour.red = conf_display->disp_white.red;
- displayp->whiteColour.green = conf_display->disp_white.green;
- displayp->whiteColour.blue = conf_display->disp_white.blue;
- displayp->options = conf_display->disp_option_lst;
- if (conf_display->disp_visual) {
- displayp->defaultVisual = lookupVisual(conf_display->disp_visual);
- if (displayp->defaultVisual == -1) {
- xf86ConfigError("Invalid visual name: \"%s\"",
- conf_display->disp_visual);
- return FALSE;
- }
- } else {
- displayp->defaultVisual = -1;
- }
-
- /*
- * now hook in the modes
- */
- modep = conf_display->disp_mode_lst;
- while(modep) {
- count++;
- modep = (XF86ModePtr)modep->list.next;
- }
- displayp->modes = xnfalloc((count+1) * sizeof(char*));
- modep = conf_display->disp_mode_lst;
- count = 0;
- while(modep) {
- displayp->modes[count] = modep->mode_name;
- count++;
- modep = (XF86ModePtr)modep->list.next;
- }
- displayp->modes[count] = NULL;
-
- return TRUE;
-}
-
-static Bool
-configDevice(GDevPtr devicep, XF86ConfDevicePtr conf_device, Bool active)
-{
- int i;
-
- if (!conf_device) {
- return FALSE;
- }
-
- if (active)
- xf86Msg(X_CONFIG, "| |-->Device \"%s\"\n",
- conf_device->dev_identifier);
- else
- xf86Msg(X_CONFIG, "|-->Inactive Device \"%s\"\n",
- conf_device->dev_identifier);
-
- devicep->identifier = conf_device->dev_identifier;
- devicep->vendor = conf_device->dev_vendor;
- devicep->board = conf_device->dev_board;
- devicep->chipset = conf_device->dev_chipset;
- devicep->ramdac = conf_device->dev_ramdac;
- devicep->driver = conf_device->dev_driver;
- devicep->active = active;
- devicep->videoRam = conf_device->dev_videoram;
- devicep->BiosBase = conf_device->dev_bios_base;
- devicep->MemBase = conf_device->dev_mem_base;
- devicep->IOBase = conf_device->dev_io_base;
- devicep->clockchip = conf_device->dev_clockchip;
- devicep->busID = conf_device->dev_busid;
- devicep->textClockFreq = conf_device->dev_textclockfreq;
- devicep->chipID = conf_device->dev_chipid;
- devicep->chipRev = conf_device->dev_chiprev;
- devicep->options = conf_device->dev_option_lst;
- devicep->irq = conf_device->dev_irq;
- devicep->screen = conf_device->dev_screen;
-
- for (i = 0; i < MAXDACSPEEDS; i++) {
- if (i < CONF_MAXDACSPEEDS)
- devicep->dacSpeeds[i] = conf_device->dev_dacSpeeds[i];
- else
- devicep->dacSpeeds[i] = 0;
- }
- devicep->numclocks = conf_device->dev_clocks;
- if (devicep->numclocks > MAXCLOCKS)
- devicep->numclocks = MAXCLOCKS;
- for (i = 0; i < devicep->numclocks; i++) {
- devicep->clock[i] = conf_device->dev_clock[i];
- }
- devicep->claimed = FALSE;
-
- return TRUE;
-}
-
-#ifdef XF86DRI
-static void
-configDRI(XF86ConfDRIPtr drip)
-{
- struct group *grp;
-
- xf86ConfigDRI.group = -1;
- xf86ConfigDRI.mode = 0;
-
- if (drip) {
- if (drip->dri_group_name) {
- if ((grp = getgrnam(drip->dri_group_name)))
- xf86ConfigDRI.group = grp->gr_gid;
- } else {
- if (drip->dri_group >= 0)
- xf86ConfigDRI.group = drip->dri_group;
- }
- xf86ConfigDRI.mode = drip->dri_mode;
- }
-}
-#endif
-
-static void
-configExtensions(XF86ConfExtensionsPtr conf_ext)
-{
- XF86OptionPtr o;
-
- if (conf_ext && conf_ext->ext_option_lst) {
- for (o = conf_ext->ext_option_lst; o; o = xf86NextOption(o)) {
- char *name = xf86OptionName(o);
- char *val = xf86OptionValue(o);
- char *n;
- Bool enable = TRUE;
-
- /* Handle "No<ExtensionName>" */
- n = xf86NormalizeName(name);
- if (strncmp(n, "no", 2) == 0) {
- name += 2;
- enable = FALSE;
- }
-
- if (!val ||
- xf86NameCmp(val, "enable") == 0 ||
- xf86NameCmp(val, "enabled") == 0 ||
- xf86NameCmp(val, "on") == 0 ||
- xf86NameCmp(val, "1") == 0 ||
- xf86NameCmp(val, "yes") == 0 ||
- xf86NameCmp(val, "true") == 0) {
- /* NOTHING NEEDED -- enabling is handled below */
- } else if (xf86NameCmp(val, "disable") == 0 ||
- xf86NameCmp(val, "disabled") == 0 ||
- xf86NameCmp(val, "off") == 0 ||
- xf86NameCmp(val, "0") == 0 ||
- xf86NameCmp(val, "no") == 0 ||
- xf86NameCmp(val, "false") == 0) {
- enable = !enable;
- } else {
- xf86Msg(X_WARNING, "Ignoring unrecognized value \"%s\"\n", val);
- free(n);
- continue;
- }
-
- if (EnableDisableExtension(name, enable)) {
- xf86Msg(X_CONFIG, "Extension \"%s\" is %s\n",
- name, enable ? "enabled" : "disabled");
- } else {
- xf86Msg(X_WARNING, "Ignoring unrecognized extension \"%s\"\n",
- name);
- }
- free(n);
- }
- }
-}
-
-static Bool
-configInput(InputInfoPtr inputp, XF86ConfInputPtr conf_input, MessageType from)
-{
- xf86Msg(from, "|-->Input Device \"%s\"\n", conf_input->inp_identifier);
- inputp->name = conf_input->inp_identifier;
- inputp->driver = conf_input->inp_driver;
- inputp->options = conf_input->inp_option_lst;
- inputp->attrs = NULL;
-
- return TRUE;
-}
-
-static Bool
-modeIsPresent(DisplayModePtr mode, MonPtr monitorp)
-{
- DisplayModePtr knownmodes = monitorp->Modes;
-
- /* all I can think of is a linear search... */
- while(knownmodes != NULL)
- {
- if(!strcmp(mode->name, knownmodes->name) &&
- !(knownmodes->type & M_T_DEFAULT))
- return TRUE;
- knownmodes = knownmodes->next;
- }
- return FALSE;
-}
-
-static Bool
-addDefaultModes(MonPtr monitorp)
-{
- DisplayModePtr mode;
- DisplayModePtr last = monitorp->Last;
- int i = 0;
-
- for (i = 0; i < xf86NumDefaultModes; i++)
- {
- mode = xf86DuplicateMode(&xf86DefaultModes[i]);
- if (!modeIsPresent(mode, monitorp))
- {
- monitorp->Modes = xf86ModesAdd(monitorp->Modes, mode);
- last = mode;
- } else {
- free(mode);
- }
- }
- monitorp->Last = last;
-
- return TRUE;
-}
-
-static void
-checkInput(serverLayoutPtr layout, Bool implicit_layout) {
- checkCoreInputDevices(layout, implicit_layout);
-
- /* Unless we're forcing input devices, disable mouse/kbd devices in the
- * config. Otherwise the same physical device is added multiple times,
- * leading to duplicate events.
- */
- if (!xf86Info.forceInputDevices && layout->inputs)
- {
- InputInfoPtr *dev = layout->inputs;
- BOOL warned = FALSE;
-
- while(*dev)
- {
- if (strcmp((*dev)->driver, "kbd") == 0 ||
- strcmp((*dev)->driver, "mouse") == 0 ||
- strcmp((*dev)->driver, "vmmouse") == 0)
- {
- InputInfoPtr *current;
- if (!warned)
- {
- xf86Msg(X_WARNING, "Hotplugging is on, devices using "
- "drivers 'kbd', 'mouse' or 'vmmouse' will be disabled.\n");
- warned = TRUE;
- }
-
- xf86Msg(X_WARNING, "Disabling %s\n", (*dev)->name);
-
- current = dev;
- free(*dev);
-
- do {
- *current = *(current + 1);
- current++;
- } while(*current);
- } else
- dev++;
- }
- }
-}
-
-/*
- * load the config file and fill the global data structure
- */
-ConfigStatus
-xf86HandleConfigFile(Bool autoconfig)
-{
- const char *filename, *dirname, *sysdirname;
- char *filesearch, *dirsearch;
- MessageType filefrom = X_DEFAULT;
- MessageType dirfrom = X_DEFAULT;
- char *scanptr;
- Bool singlecard = 0;
- Bool implicit_layout = FALSE;
-
- if (!autoconfig) {
- if (getuid() == 0) {
- filesearch = ROOT_CONFIGPATH;
- dirsearch = ROOT_CONFIGDIRPATH;
- } else {
- filesearch = USER_CONFIGPATH;
- dirsearch = USER_CONFIGDIRPATH;
- }
-
- if (xf86ConfigFile)
- filefrom = X_CMDLINE;
- if (xf86ConfigDir)
- dirfrom = X_CMDLINE;
-
- xf86initConfigFiles();
- sysdirname = xf86openConfigDirFiles(SYS_CONFIGDIRPATH, NULL,
- PROJECTROOT);
- dirname = xf86openConfigDirFiles(dirsearch, xf86ConfigDir, PROJECTROOT);
- filename = xf86openConfigFile(filesearch, xf86ConfigFile, PROJECTROOT);
- if (filename) {
- xf86MsgVerb(filefrom, 0, "Using config file: \"%s\"\n", filename);
- xf86ConfigFile = xnfstrdup(filename);
- } else {
- if (xf86ConfigFile)
- xf86Msg(X_ERROR, "Unable to locate/open config file: \"%s\"\n",
- xf86ConfigFile);
- }
- if (dirname) {
- xf86MsgVerb(dirfrom, 0, "Using config directory: \"%s\"\n",
- dirname);
- xf86ConfigDir = xnfstrdup(dirname);
- } else {
- if (xf86ConfigDir)
- xf86Msg(X_ERROR,
- "Unable to locate/open config directory: \"%s\"\n",
- xf86ConfigDir);
- }
- if (sysdirname)
- xf86MsgVerb(X_DEFAULT, 0, "Using system config directory \"%s\"\n",
- sysdirname);
- if (!filename && !dirname && !sysdirname)
- return CONFIG_NOFILE;
- }
-
- if ((xf86configptr = xf86readConfigFile ()) == NULL) {
- xf86Msg(X_ERROR, "Problem parsing the config file\n");
- return CONFIG_PARSE_ERROR;
- }
- xf86closeConfigFile ();
-
- /* Initialise a few things. */
-
- /*
- * now we convert part of the information contained in the parser
- * structures into our own structures.
- * The important part here is to figure out which Screen Sections
- * in the XF86Config file are active so that we can piece together
- * the modes that we need later down the road.
- * And while we are at it, we'll decode the rest of the stuff as well
- */
-
- /* First check if a layout section is present, and if it is valid. */
-
- if (xf86configptr->conf_layout_lst == NULL || xf86ScreenName != NULL) {
- if (xf86ScreenName == NULL) {
- xf86Msg(X_DEFAULT,
- "No Layout section. Using the first Screen section.\n");
- }
- if (!configImpliedLayout(&xf86ConfigLayout,
- xf86configptr->conf_screen_lst,
- xf86configptr)) {
- xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
- return CONFIG_PARSE_ERROR;
- }
- implicit_layout = TRUE;
- } else {
- if (xf86configptr->conf_flags != NULL) {
- char *dfltlayout = NULL;
- pointer optlist = xf86configptr->conf_flags->flg_option_lst;
-
- if (optlist && xf86FindOption(optlist, "defaultserverlayout"))
- dfltlayout = xf86SetStrOption(optlist, "defaultserverlayout", NULL);
- if (!configLayout(&xf86ConfigLayout, xf86configptr->conf_layout_lst,
- dfltlayout)) {
- xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
- return CONFIG_PARSE_ERROR;
- }
- } else {
- if (!configLayout(&xf86ConfigLayout, xf86configptr->conf_layout_lst,
- NULL)) {
- xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
- return CONFIG_PARSE_ERROR;
- }
- }
- }
-
- xf86ProcessOptions(-1, xf86ConfigLayout.options, LayoutOptions);
-
- if ((scanptr = xf86GetOptValString(LayoutOptions, LAYOUT_ISOLATEDEVICE))) {
- ; /* IsolateDevice specified; overrides SingleCard */
- } else {
- xf86GetOptValBool(LayoutOptions, LAYOUT_SINGLECARD, &singlecard);
- if (singlecard)
- scanptr = xf86ConfigLayout.screens->screen->device->busID;
- }
- if (scanptr) {
- if (strncmp(scanptr, "PCI:", 4) != 0) {
- xf86Msg(X_WARNING, "Bus types other than PCI not yet isolable.\n"
- "\tIgnoring IsolateDevice option.\n");
- } else
- xf86PciIsolateDevice(scanptr);
- }
-
- /* Now process everything else */
- if (!configServerFlags(xf86configptr->conf_flags,xf86ConfigLayout.options)){
- ErrorF ("Problem when converting the config data structures\n");
- return CONFIG_PARSE_ERROR;
- }
-
- configFiles(xf86configptr->conf_files);
- configExtensions(xf86configptr->conf_extensions);
-#ifdef XF86DRI
- configDRI(xf86configptr->conf_dri);
-#endif
-
- checkInput(&xf86ConfigLayout, implicit_layout);
-
- /*
- * Handle some command line options that can override some of the
- * ServerFlags settings.
- */
-#ifdef XF86VIDMODE
- if (xf86VidModeDisabled)
- xf86Info.vidModeEnabled = FALSE;
- if (xf86VidModeAllowNonLocal)
- xf86Info.vidModeAllowNonLocal = TRUE;
-#endif
-
- if (xf86AllowMouseOpenFail)
- xf86Info.allowMouseOpenFail = TRUE;
-
- return CONFIG_OK;
-}
-
-Bool
-xf86PathIsSafe(const char *path)
-{
- return (xf86pathIsSafe(path) != 0);
-}
+/*
+ * Loosely based on code bearing the following copyright:
+ *
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ */
+
+/*
+ * Copyright 1992-2003 by The XFree86 Project, Inc.
+ * Copyright 1997 by Metro Link, 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).
+ */
+
+/*
+ *
+ * Authors:
+ * Dirk Hohndel <hohndel@XFree86.Org>
+ * David Dawes <dawes@XFree86.Org>
+ * Marc La France <tsi@XFree86.Org>
+ * Egbert Eich <eich@XFree86.Org>
+ * ... and others
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifdef XF86DRI
+#include <sys/types.h>
+#include <grp.h>
+#endif
+
+#include "xf86.h"
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "xf86Config.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "configProcs.h"
+#include "globals.h"
+#include "extension.h"
+#include "xf86pciBus.h"
+
+#include "xf86Xinput.h"
+
+#include "xkbsrv.h"
+
+#include "picture.h"
+
+/*
+ * These paths define the way the config file search is done. The escape
+ * sequences are documented in parser/scan.c.
+ */
+#ifndef ROOT_CONFIGPATH
+#define ROOT_CONFIGPATH "%A," "%R," \
+ "/etc/X11/%R," "%P/etc/X11/%R," \
+ "%E," "%F," \
+ "/etc/X11/%F," "%P/etc/X11/%F," \
+ "/etc/X11/%X," "/etc/%X," \
+ "%P/etc/X11/%X.%H," \
+ "%P/etc/X11/%X," \
+ "%P/lib/X11/%X.%H," \
+ "%P/lib/X11/%X"
+#endif
+#ifndef USER_CONFIGPATH
+#define USER_CONFIGPATH "/etc/X11/%S," "%P/etc/X11/%S," \
+ "/etc/X11/%G," "%P/etc/X11/%G," \
+ "/etc/X11/%X," "/etc/%X," \
+ "%P/etc/X11/%X.%H," \
+ "%P/etc/X11/%X," \
+ "%P/lib/X11/%X.%H," \
+ "%P/lib/X11/%X"
+#endif
+#ifndef ROOT_CONFIGDIRPATH
+#define ROOT_CONFIGDIRPATH "%A," "%R," \
+ "/etc/X11/%R," "%C/X11/%R," \
+ "/etc/X11/%X," "%C/X11/%X"
+#endif
+#ifndef USER_CONFIGDIRPATH
+#define USER_CONFIGDIRPATH "/etc/X11/%R," "%C/X11/%R," \
+ "/etc/X11/%X," "%C/X11/%X"
+#endif
+#ifndef SYS_CONFIGDIRPATH
+#define SYS_CONFIGDIRPATH "/usr/share/X11/%X," "%D/X11/%X"
+#endif
+#ifndef PROJECTROOT
+#define PROJECTROOT "/usr/X11R6"
+#endif
+
+static ModuleDefault ModuleDefaults[] = {
+ {.name = "extmod", .toLoad = TRUE, .load_opt=NULL},
+#ifdef DBE
+ {.name = "dbe", .toLoad = TRUE, .load_opt=NULL},
+#endif
+#ifdef GLXEXT
+ {.name = "glx", .toLoad = TRUE, .load_opt=NULL},
+#endif
+#ifdef XRECORD
+ {.name = "record", .toLoad = TRUE, .load_opt=NULL},
+#endif
+#ifdef XF86DRI
+ {.name = "dri", .toLoad = TRUE, .load_opt=NULL},
+#endif
+#ifdef DRI2
+ {.name = "dri2", .toLoad = TRUE, .load_opt=NULL},
+#endif
+ {.name = NULL, .toLoad = FALSE, .load_opt=NULL}
+};
+
+
+/* Forward declarations */
+static Bool configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen,
+ int scrnum, MessageType from);
+static Bool configMonitor(MonPtr monitorp, XF86ConfMonitorPtr conf_monitor);
+static Bool configDevice(GDevPtr devicep, XF86ConfDevicePtr conf_device,
+ Bool active);
+static Bool configInput(InputInfoPtr pInfo, XF86ConfInputPtr conf_input,
+ MessageType from);
+static Bool configDisplay(DispPtr displayp, XF86ConfDisplayPtr conf_display);
+static Bool addDefaultModes(MonPtr monitorp);
+#ifdef XF86DRI
+static void configDRI(XF86ConfDRIPtr drip);
+#endif
+static void configExtensions(XF86ConfExtensionsPtr conf_ext);
+
+/*
+ * xf86GetPathElem --
+ * Extract a single element from the font path string starting at
+ * pnt. The font path element will be returned, and pnt will be
+ * updated to point to the start of the next element, or set to
+ * NULL if there are no more.
+ */
+static char *
+xf86GetPathElem(char **pnt)
+{
+ char *p1;
+
+ p1 = *pnt;
+ *pnt = index(*pnt, ',');
+ if (*pnt != NULL) {
+ **pnt = '\0';
+ *pnt += 1;
+ }
+ return p1;
+}
+
+/*
+ * xf86ValidateFontPath --
+ * Validates the user-specified font path. Each element that
+ * begins with a '/' is checked to make sure the directory exists.
+ * If the directory exists, the existence of a file named 'fonts.dir'
+ * is checked. If either check fails, an error is printed and the
+ * element is removed from the font path.
+ */
+
+#define DIR_FILE "/fonts.dir"
+static char *
+xf86ValidateFontPath(char *path)
+{
+ char *tmp_path, *out_pnt, *path_elem, *next, *p1, *dir_elem;
+ struct stat stat_buf;
+ int flag;
+ int dirlen;
+
+ tmp_path = calloc(1,strlen(path)+1);
+ out_pnt = tmp_path;
+ path_elem = NULL;
+ next = path;
+ while (next != NULL) {
+ path_elem = xf86GetPathElem(&next);
+ if (*path_elem == '/') {
+ dir_elem = xnfcalloc(1, strlen(path_elem) + 1);
+ if ((p1 = strchr(path_elem, ':')) != 0)
+ dirlen = p1 - path_elem;
+ else
+ dirlen = strlen(path_elem);
+ strncpy(dir_elem, path_elem, dirlen);
+ dir_elem[dirlen] = '\0';
+ flag = stat(dir_elem, &stat_buf);
+ if (flag == 0)
+ if (!S_ISDIR(stat_buf.st_mode))
+ flag = -1;
+ if (flag != 0) {
+ xf86Msg(X_WARNING, "The directory \"%s\" does not exist.\n", dir_elem);
+ xf86ErrorF("\tEntry deleted from font path.\n");
+ free(dir_elem);
+ continue;
+ }
+ else {
+ XNFasprintf(&p1, "%s%s", dir_elem, DIR_FILE);
+ flag = stat(p1, &stat_buf);
+ if (flag == 0)
+ if (!S_ISREG(stat_buf.st_mode))
+ flag = -1;
+ free(p1);
+ if (flag != 0) {
+ xf86Msg(X_WARNING,
+ "`fonts.dir' not found (or not valid) in \"%s\".\n",
+ dir_elem);
+ xf86ErrorF("\tEntry deleted from font path.\n");
+ xf86ErrorF("\t(Run 'mkfontdir' on \"%s\").\n", dir_elem);
+ free(dir_elem);
+ continue;
+ }
+ }
+ free(dir_elem);
+ }
+
+ /*
+ * Either an OK directory, or a font server name. So add it to
+ * the path.
+ */
+ if (out_pnt != tmp_path)
+ *out_pnt++ = ',';
+ strcat(out_pnt, path_elem);
+ out_pnt += strlen(path_elem);
+ }
+ return tmp_path;
+}
+
+
+/*
+ * use the datastructure that the parser provides and pick out the parts
+ * that we need at this point
+ */
+char **
+xf86ModulelistFromConfig(pointer **optlist)
+{
+ int count = 0, i = 0;
+ char **modulearray;
+ char *ignore[] = { "GLcore", "speedo", "bitmap", "drm",
+ "freetype", "type1",
+ NULL };
+ pointer *optarray;
+ XF86LoadPtr modp;
+ Bool found;
+
+ /*
+ * make sure the config file has been parsed and that we have a
+ * ModulePath set; if no ModulePath was given, use the default
+ * ModulePath
+ */
+ if (xf86configptr == NULL) {
+ xf86Msg(X_ERROR, "Cannot access global config data structure\n");
+ return NULL;
+ }
+
+ if (xf86configptr->conf_modules) {
+ /* Walk the disable list and let people know what we've parsed to
+ * not be loaded
+ */
+ modp = xf86configptr->conf_modules->mod_disable_lst;
+ while (modp) {
+ xf86Msg(X_WARNING, "\"%s\" will not be loaded unless you've specified it to be loaded elsewhere.\n", modp->load_name);
+ modp = (XF86LoadPtr) modp->list.next;
+ }
+ /*
+ * Walk the default settings table. For each module listed to be
+ * loaded, make sure it's in the mod_load_lst. If it's not, make
+ * sure it's not in the mod_no_load_lst. If it's not disabled,
+ * append it to mod_load_lst
+ */
+ for (i=0 ; ModuleDefaults[i].name != NULL ; i++) {
+ if (ModuleDefaults[i].toLoad == FALSE) {
+ xf86Msg(X_WARNING, "\"%s\" is not to be loaded by default. Skipping.\n", ModuleDefaults[i].name);
+ continue;
+ }
+ found = FALSE;
+ modp = xf86configptr->conf_modules->mod_load_lst;
+ while (modp) {
+ if (strcmp(modp->load_name, ModuleDefaults[i].name) == 0) {
+ xf86Msg(X_INFO, "\"%s\" will be loaded. This was enabled by default and also specified in the config file.\n", ModuleDefaults[i].name);
+ found = TRUE;
+ break;
+ }
+ modp = (XF86LoadPtr) modp->list.next;
+ }
+ if (found == FALSE) {
+ modp = xf86configptr->conf_modules->mod_disable_lst;
+ while (modp) {
+ if (strcmp(modp->load_name, ModuleDefaults[i].name) == 0) {
+ xf86Msg(X_INFO, "\"%s\" will be loaded even though the default is to disable it.\n", ModuleDefaults[i].name);
+ found = TRUE;
+ break;
+ }
+ modp = (XF86LoadPtr) modp->list.next;
+ }
+ }
+ if (found == FALSE) {
+ XF86LoadPtr ptr = (XF86LoadPtr)xf86configptr->conf_modules;
+ xf86addNewLoadDirective(ptr, ModuleDefaults[i].name, XF86_LOAD_MODULE, ModuleDefaults[i].load_opt);
+ xf86Msg(X_INFO, "\"%s\" will be loaded by default.\n", ModuleDefaults[i].name);
+ }
+ }
+ } else {
+ xf86configptr->conf_modules = xnfcalloc(1, sizeof(XF86ConfModuleRec));
+ for (i=0 ; ModuleDefaults[i].name != NULL ; i++) {
+ if (ModuleDefaults[i].toLoad == TRUE) {
+ XF86LoadPtr ptr = (XF86LoadPtr)xf86configptr->conf_modules;
+ xf86addNewLoadDirective(ptr, ModuleDefaults[i].name, XF86_LOAD_MODULE, ModuleDefaults[i].load_opt);
+ }
+ }
+ }
+
+ /*
+ * Walk the list of modules in the "Module" section to determine how
+ * many we have.
+ */
+ modp = xf86configptr->conf_modules->mod_load_lst;
+ while (modp) {
+ for (i = 0; ignore[i]; i++) {
+ if (strcmp(modp->load_name, ignore[i]) == 0)
+ modp->ignore = 1;
+ }
+ if (!modp->ignore)
+ count++;
+ modp = (XF86LoadPtr) modp->list.next;
+ }
+
+ /*
+ * allocate the memory and walk the list again to fill in the pointers
+ */
+ modulearray = xnfalloc((count + 1) * sizeof(char*));
+ optarray = xnfalloc((count + 1) * sizeof(pointer));
+ count = 0;
+ if (xf86configptr->conf_modules) {
+ modp = xf86configptr->conf_modules->mod_load_lst;
+ while (modp) {
+ if (!modp->ignore) {
+ modulearray[count] = modp->load_name;
+ optarray[count] = modp->load_opt;
+ count++;
+ }
+ modp = (XF86LoadPtr) modp->list.next;
+ }
+ }
+ modulearray[count] = NULL;
+ optarray[count] = NULL;
+ if (optlist)
+ *optlist = optarray;
+ else
+ free(optarray);
+ return modulearray;
+}
+
+
+char **
+xf86DriverlistFromConfig(void)
+{
+ int count = 0;
+ int j;
+ char **modulearray;
+ screenLayoutPtr slp;
+
+ /*
+ * make sure the config file has been parsed and that we have a
+ * ModulePath set; if no ModulePath was given, use the default
+ * ModulePath
+ */
+ if (xf86configptr == NULL) {
+ xf86Msg(X_ERROR, "Cannot access global config data structure\n");
+ return NULL;
+ }
+
+ /*
+ * Walk the list of driver lines in active "Device" sections to
+ * determine now many implicitly loaded modules there are.
+ *
+ */
+ if (xf86ConfigLayout.screens) {
+ slp = xf86ConfigLayout.screens;
+ while ((slp++)->screen) {
+ count++;
+ }
+ }
+
+ /*
+ * Handle the set of inactive "Device" sections.
+ */
+ j = 0;
+ while (xf86ConfigLayout.inactives[j++].identifier)
+ count++;
+
+ if (count == 0)
+ return NULL;
+
+ /*
+ * allocate the memory and walk the list again to fill in the pointers
+ */
+ modulearray = xnfalloc((count + 1) * sizeof(char*));
+ count = 0;
+ slp = xf86ConfigLayout.screens;
+ while (slp->screen) {
+ modulearray[count] = slp->screen->device->driver;
+ count++;
+ slp++;
+ }
+
+ j = 0;
+
+ while (xf86ConfigLayout.inactives[j].identifier)
+ modulearray[count++] = xf86ConfigLayout.inactives[j++].driver;
+
+ modulearray[count] = NULL;
+
+ /* Remove duplicates */
+ for (count = 0; modulearray[count] != NULL; count++) {
+ int i;
+
+ for (i = 0; i < count; i++)
+ if (xf86NameCmp(modulearray[i], modulearray[count]) == 0) {
+ modulearray[count] = "";
+ break;
+ }
+ }
+ return modulearray;
+}
+
+char **
+xf86InputDriverlistFromConfig(void)
+{
+ int count = 0;
+ char **modulearray;
+ InputInfoPtr *idp;
+
+ /*
+ * make sure the config file has been parsed and that we have a
+ * ModulePath set; if no ModulePath was given, use the default
+ * ModulePath
+ */
+ if (xf86configptr == NULL) {
+ xf86Msg(X_ERROR, "Cannot access global config data structure\n");
+ return NULL;
+ }
+
+ /*
+ * Walk the list of driver lines in active "InputDevice" sections to
+ * determine now many implicitly loaded modules there are.
+ */
+ if (xf86ConfigLayout.inputs) {
+ idp = xf86ConfigLayout.inputs;
+ while (*idp) {
+ count++;
+ idp++;
+ }
+ }
+
+ if (count == 0)
+ return NULL;
+
+ /*
+ * allocate the memory and walk the list again to fill in the pointers
+ */
+ modulearray = xnfalloc((count + 1) * sizeof(char*));
+ count = 0;
+ idp = xf86ConfigLayout.inputs;
+ while (idp && *idp) {
+ modulearray[count] = (*idp)->driver;
+ count++;
+ idp++;
+ }
+ modulearray[count] = NULL;
+
+ /* Remove duplicates */
+ for (count = 0; modulearray[count] != NULL; count++) {
+ int i;
+
+ for (i = 0; i < count; i++)
+ if (xf86NameCmp(modulearray[i], modulearray[count]) == 0) {
+ modulearray[count] = "";
+ break;
+ }
+ }
+ return modulearray;
+}
+
+static void
+fixup_video_driver_list(char **drivers)
+{
+ static const char *fallback[4] = { "vesa", "fbdev", "wsfb", NULL };
+ char **end, **drv;
+ char *x;
+ int i;
+
+ /* walk to the end of the list */
+ for (end = drivers; *end && **end; end++) ;
+ end--;
+
+ /*
+ * for each of the fallback drivers, if we find it in the list,
+ * swap it with the last available non-fallback driver.
+ */
+ for (i = 0; fallback[i]; i++) {
+ for (drv = drivers; drv != end; drv++) {
+ if (strstr(*drv, fallback[i])) {
+ x = *drv; *drv = *end; *end = x;
+ end--;
+ break;
+ }
+ }
+ }
+}
+
+static char **
+GenerateDriverlist(char * dirname)
+{
+ char **ret;
+ const char *subdirs[] = { dirname, NULL };
+ static const char *patlist[] = {"(.*)_drv\\.so", NULL};
+ ret = LoaderListDirs(subdirs, patlist);
+
+ /* fix up the probe order for video drivers */
+ if (strstr(dirname, "drivers") && ret != NULL)
+ fixup_video_driver_list(ret);
+
+ return ret;
+}
+
+char **
+xf86DriverlistFromCompile(void)
+{
+ static char **driverlist = NULL;
+
+ if (!driverlist)
+ driverlist = GenerateDriverlist("drivers");
+
+ return driverlist;
+}
+
+/*
+ * xf86ConfigError --
+ * Print a READABLE ErrorMessage!!! All information that is
+ * available is printed.
+ */
+static void
+xf86ConfigError(char *msg, ...)
+{
+ va_list ap;
+
+ ErrorF("\nConfig Error:\n");
+ va_start(ap, msg);
+ VErrorF(msg, ap);
+ va_end(ap);
+ ErrorF("\n");
+ return;
+}
+
+static void
+configFiles(XF86ConfFilesPtr fileconf)
+{
+ MessageType pathFrom;
+ Bool must_copy;
+ int size, countDirs;
+ char *temp_path, *log_buf, *start, *end;
+
+ /* FontPath */
+ must_copy = TRUE;
+
+ temp_path = defaultFontPath ? defaultFontPath : "";
+ if (xf86fpFlag)
+ pathFrom = X_CMDLINE;
+ else if (fileconf && fileconf->file_fontpath) {
+ pathFrom = X_CONFIG;
+ if (xf86Info.useDefaultFontPath) {
+ if (asprintf(&defaultFontPath, "%s%s%s", fileconf->file_fontpath,
+ *temp_path ? "," : "", temp_path) == -1)
+ defaultFontPath = NULL;
+ else
+ must_copy = FALSE;
+ }
+ else
+ defaultFontPath = fileconf->file_fontpath;
+ }
+ else
+ pathFrom = X_DEFAULT;
+ temp_path = defaultFontPath ? defaultFontPath : "";
+
+ /* xf86ValidateFontPath modifies its argument, but returns a copy of it. */
+ temp_path = must_copy ? xnfstrdup(defaultFontPath) : defaultFontPath;
+ defaultFontPath = xf86ValidateFontPath(temp_path);
+ free(temp_path);
+
+ /* make fontpath more readable in the logfiles */
+ countDirs = 1;
+ temp_path = defaultFontPath;
+ while ((temp_path = index(temp_path, ',')) != NULL) {
+ countDirs++;
+ temp_path++;
+ }
+
+ log_buf = xnfalloc(strlen(defaultFontPath) + (2 * countDirs) + 1);
+ temp_path = log_buf;
+ start = defaultFontPath;
+ while((end = index(start, ',')) != NULL) {
+ size = (end - start) + 1;
+ *(temp_path++) = '\t';
+ strncpy(temp_path, start, size);
+ temp_path += size;
+ *(temp_path++) = '\n';
+ start += size;
+ }
+ /* copy last entry */
+ *(temp_path++) = '\t';
+ strcpy(temp_path, start);
+ xf86Msg(pathFrom, "FontPath set to:\n%s\n", log_buf);
+ free(log_buf);
+
+ /* ModulePath */
+
+ if (fileconf) {
+ if (xf86ModPathFrom != X_CMDLINE && fileconf->file_modulepath) {
+ xf86ModulePath = fileconf->file_modulepath;
+ xf86ModPathFrom = X_CONFIG;
+ }
+ }
+
+ xf86Msg(xf86ModPathFrom, "ModulePath set to \"%s\"\n", xf86ModulePath);
+
+ if (!xf86xkbdirFlag && fileconf && fileconf->file_xkbdir) {
+ XkbBaseDirectory = fileconf->file_xkbdir;
+ xf86Msg(X_CONFIG, "XKB base directory set to \"%s\"\n",
+ XkbBaseDirectory);
+ }
+#if 0
+ /* LogFile */
+ /*
+ * XXX The problem with this is that the log file is already open.
+ * One option might be to copy the exiting contents to the new location.
+ * and re-open it. The down side is that the default location would
+ * already have been overwritten. Another option would be to start with
+ * unique temporary location, then copy it once the correct name is known.
+ * A problem with this is what happens if the server exits before that
+ * happens.
+ */
+ if (xf86LogFileFrom == X_DEFAULT && fileconf->file_logfile) {
+ xf86LogFile = fileconf->file_logfile;
+ xf86LogFileFrom = X_CONFIG;
+ }
+#endif
+
+ return;
+}
+
+typedef enum {
+ FLAG_NOTRAPSIGNALS,
+ FLAG_DONTVTSWITCH,
+ FLAG_DONTZAP,
+ FLAG_DONTZOOM,
+ FLAG_DISABLEVIDMODE,
+ FLAG_ALLOWNONLOCAL,
+ FLAG_ALLOWMOUSEOPENFAIL,
+ FLAG_VTSYSREQ,
+ FLAG_SAVER_BLANKTIME,
+ FLAG_DPMS_STANDBYTIME,
+ FLAG_DPMS_SUSPENDTIME,
+ FLAG_DPMS_OFFTIME,
+ FLAG_PIXMAP,
+ FLAG_PC98,
+ FLAG_NOPM,
+ FLAG_XINERAMA,
+ FLAG_LOG,
+ FLAG_RENDER_COLORMAP_MODE,
+ FLAG_RANDR,
+ FLAG_AIGLX,
+ FLAG_IGNORE_ABI,
+ FLAG_ALLOW_EMPTY_INPUT,
+ FLAG_USE_DEFAULT_FONT_PATH,
+ FLAG_AUTO_ADD_DEVICES,
+ FLAG_AUTO_ENABLE_DEVICES,
+ FLAG_GLX_VISUALS,
+ FLAG_DRI2,
+ FLAG_USE_SIGIO
+} FlagValues;
+
+/**
+ * NOTE: the last value for each entry is NOT the default. It is set to TRUE
+ * if the parser found the option in the config file.
+ */
+static OptionInfoRec FlagOptions[] = {
+ { FLAG_NOTRAPSIGNALS, "NoTrapSignals", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_DONTVTSWITCH, "DontVTSwitch", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_DONTZAP, "DontZap", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_DONTZOOM, "DontZoom", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_DISABLEVIDMODE, "DisableVidModeExtension", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_ALLOWNONLOCAL, "AllowNonLocalXvidtune", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_ALLOWMOUSEOPENFAIL, "AllowMouseOpenFail", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_VTSYSREQ, "VTSysReq", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_SAVER_BLANKTIME, "BlankTime" , OPTV_INTEGER,
+ {0}, FALSE },
+ { FLAG_DPMS_STANDBYTIME, "StandbyTime", OPTV_INTEGER,
+ {0}, FALSE },
+ { FLAG_DPMS_SUSPENDTIME, "SuspendTime", OPTV_INTEGER,
+ {0}, FALSE },
+ { FLAG_DPMS_OFFTIME, "OffTime", OPTV_INTEGER,
+ {0}, FALSE },
+ { FLAG_PIXMAP, "Pixmap", OPTV_INTEGER,
+ {0}, FALSE },
+ { FLAG_PC98, "PC98", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_NOPM, "NoPM", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_XINERAMA, "Xinerama", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_LOG, "Log", OPTV_STRING,
+ {0}, FALSE },
+ { FLAG_RENDER_COLORMAP_MODE, "RenderColormapMode", OPTV_STRING,
+ {0}, FALSE },
+ { FLAG_RANDR, "RandR", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_AIGLX, "AIGLX", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_IGNORE_ABI, "IgnoreABI", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_USE_DEFAULT_FONT_PATH, "UseDefaultFontPath", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_AUTO_ADD_DEVICES, "AutoAddDevices", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_AUTO_ENABLE_DEVICES, "AutoEnableDevices", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_GLX_VISUALS, "GlxVisuals", OPTV_STRING,
+ {0}, FALSE },
+ { FLAG_DRI2, "DRI2", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { FLAG_USE_SIGIO, "UseSIGIO", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { -1, NULL, OPTV_NONE,
+ {0}, FALSE },
+};
+
+#ifdef SUPPORT_PC98
+static Bool
+detectPC98(void)
+{
+ unsigned char buf[2];
+
+ if (xf86ReadBIOS(0xf8000, 0xe80, buf, 2) != 2)
+ return FALSE;
+ if ((buf[0] == 0x98) && (buf[1] == 0x21))
+ return TRUE;
+ else
+ return FALSE;
+}
+#endif
+
+static Bool
+configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
+{
+ XF86OptionPtr optp, tmp;
+ int i;
+ Pix24Flags pix24 = Pix24DontCare;
+ Bool value;
+ MessageType from;
+ const char *s;
+ XkbRMLVOSet set;
+ /* Default options. */
+ set.rules = "base";
+ set.model = "pc105";
+ set.layout = "us";
+ set.variant = NULL;
+ set.options = NULL;
+
+ /*
+ * Merge the ServerLayout and ServerFlags options. The former have
+ * precedence over the latter.
+ */
+ optp = NULL;
+ if (flagsconf && flagsconf->flg_option_lst)
+ optp = xf86optionListDup(flagsconf->flg_option_lst);
+ if (layoutopts) {
+ tmp = xf86optionListDup(layoutopts);
+ if (optp)
+ optp = xf86optionListMerge(optp, tmp);
+ else
+ optp = tmp;
+ }
+
+ xf86ProcessOptions(-1, optp, FlagOptions);
+
+ xf86GetOptValBool(FlagOptions, FLAG_NOTRAPSIGNALS, &xf86Info.notrapSignals);
+ xf86GetOptValBool(FlagOptions, FLAG_DONTVTSWITCH, &xf86Info.dontVTSwitch);
+ xf86GetOptValBool(FlagOptions, FLAG_DONTZAP, &xf86Info.dontZap);
+ xf86GetOptValBool(FlagOptions, FLAG_DONTZOOM, &xf86Info.dontZoom);
+
+ xf86GetOptValBool(FlagOptions, FLAG_IGNORE_ABI, &xf86Info.ignoreABI);
+ if (xf86Info.ignoreABI) {
+ xf86Msg(X_CONFIG, "Ignoring ABI Version\n");
+ }
+
+ if (xf86SIGIOSupported()) {
+ xf86Info.useSIGIO = xf86ReturnOptValBool(FlagOptions, FLAG_USE_SIGIO, USE_SIGIO_BY_DEFAULT);
+ if (xf86IsOptionSet(FlagOptions, FLAG_USE_SIGIO)) {
+ from = X_CONFIG;
+ } else {
+ from = X_DEFAULT;
+ }
+ if (!xf86Info.useSIGIO) {
+ xf86Msg(from, "Disabling SIGIO handlers for input devices\n");
+ } else if (from == X_CONFIG) {
+ xf86Msg(from, "Enabling SIGIO handlers for input devices\n");
+ }
+ } else {
+ xf86Info.useSIGIO = FALSE;
+ }
+
+ if (xf86IsOptionSet(FlagOptions, FLAG_AUTO_ADD_DEVICES)) {
+ xf86GetOptValBool(FlagOptions, FLAG_AUTO_ADD_DEVICES,
+ &xf86Info.autoAddDevices);
+ from = X_CONFIG;
+ }
+ else {
+ from = X_DEFAULT;
+ }
+ xf86Msg(from, "%sutomatically adding devices\n",
+ xf86Info.autoAddDevices ? "A" : "Not a");
+
+ if (xf86IsOptionSet(FlagOptions, FLAG_AUTO_ENABLE_DEVICES)) {
+ xf86GetOptValBool(FlagOptions, FLAG_AUTO_ENABLE_DEVICES,
+ &xf86Info.autoEnableDevices);
+ from = X_CONFIG;
+ }
+ else {
+ from = X_DEFAULT;
+ }
+ xf86Msg(from, "%sutomatically enabling devices\n",
+ xf86Info.autoEnableDevices ? "A" : "Not a");
+
+ /*
+ * Set things up based on the config file information. Some of these
+ * settings may be overridden later when the command line options are
+ * checked.
+ */
+#ifdef XF86VIDMODE
+ if (xf86GetOptValBool(FlagOptions, FLAG_DISABLEVIDMODE, &value))
+ xf86Info.vidModeEnabled = !value;
+ if (xf86GetOptValBool(FlagOptions, FLAG_ALLOWNONLOCAL, &value))
+ xf86Info.vidModeAllowNonLocal = value;
+#endif
+
+ if (xf86GetOptValBool(FlagOptions, FLAG_ALLOWMOUSEOPENFAIL, &value))
+ xf86Info.allowMouseOpenFail = value;
+
+ if (xf86GetOptValBool(FlagOptions, FLAG_VTSYSREQ, &value)) {
+#ifdef USE_VT_SYSREQ
+ xf86Info.vtSysreq = value;
+ xf86Msg(X_CONFIG, "VTSysReq %s\n", value ? "enabled" : "disabled");
+#else
+ if (value)
+ xf86Msg(X_WARNING, "VTSysReq is not supported on this OS\n");
+#endif
+ }
+
+ xf86Info.pmFlag = TRUE;
+ if (xf86GetOptValBool(FlagOptions, FLAG_NOPM, &value))
+ xf86Info.pmFlag = !value;
+ {
+ if ((s = xf86GetOptValString(FlagOptions, FLAG_LOG))) {
+ if (!xf86NameCmp(s,"flush")) {
+ xf86Msg(X_CONFIG, "Flushing logfile enabled\n");
+ xf86Info.log = LogFlush;
+ LogSetParameter(XLOG_FLUSH, TRUE);
+ } else if (!xf86NameCmp(s,"sync")) {
+ xf86Msg(X_CONFIG, "Syncing logfile enabled\n");
+ xf86Info.log = LogSync;
+ LogSetParameter(XLOG_FLUSH, TRUE);
+ LogSetParameter(XLOG_SYNC, TRUE);
+ } else {
+ xf86Msg(X_WARNING,"Unknown Log option\n");
+ }
+ }
+ }
+
+ {
+ if ((s = xf86GetOptValString(FlagOptions, FLAG_RENDER_COLORMAP_MODE))){
+ int policy = PictureParseCmapPolicy (s);
+ if (policy == PictureCmapPolicyInvalid)
+ xf86Msg(X_WARNING, "Unknown colormap policy \"%s\"\n", s);
+ else
+ {
+ xf86Msg(X_CONFIG, "Render colormap policy set to %s\n", s);
+ PictureCmapPolicy = policy;
+ }
+ }
+ }
+
+#ifdef RANDR
+ xf86Info.disableRandR = FALSE;
+ xf86Info.randRFrom = X_DEFAULT;
+ if (xf86GetOptValBool(FlagOptions, FLAG_RANDR, &value)) {
+ xf86Info.disableRandR = !value;
+ xf86Info.randRFrom = X_CONFIG;
+ }
+#endif
+
+ xf86Info.aiglx = TRUE;
+ xf86Info.aiglxFrom = X_DEFAULT;
+ if (xf86GetOptValBool(FlagOptions, FLAG_AIGLX, &value)) {
+ xf86Info.aiglx = value;
+ xf86Info.aiglxFrom = X_CONFIG;
+ }
+
+#ifdef GLXEXT
+ xf86Info.glxVisuals = XF86_GlxVisualsTypical;
+ xf86Info.glxVisualsFrom = X_DEFAULT;
+ if ((s = xf86GetOptValString(FlagOptions, FLAG_GLX_VISUALS))) {
+ if (!xf86NameCmp(s, "minimal")) {
+ xf86Info.glxVisuals = XF86_GlxVisualsMinimal;
+ } else if (!xf86NameCmp(s, "typical")) {
+ xf86Info.glxVisuals = XF86_GlxVisualsTypical;
+ } else if (!xf86NameCmp(s, "all")) {
+ xf86Info.glxVisuals = XF86_GlxVisualsAll;
+ } else {
+ xf86Msg(X_WARNING,"Unknown GlxVisuals option\n");
+ }
+ }
+
+ if (xf86GetOptValBool(FlagOptions, FLAG_AIGLX, &value)) {
+ xf86Info.aiglx = value;
+ xf86Info.aiglxFrom = X_CONFIG;
+ }
+#endif
+
+ /* if we're not hotplugging, force some input devices to exist */
+ xf86Info.forceInputDevices = !(xf86Info.autoAddDevices && xf86Info.autoEnableDevices);
+
+ /* when forcing input devices, we use kbd. otherwise evdev, so use the
+ * evdev rules set. */
+#if defined(linux)
+ if (!xf86Info.forceInputDevices)
+ set.rules = "evdev";
+#endif
+ XkbSetRulesDflts(&set);
+
+ xf86Info.useDefaultFontPath = TRUE;
+ xf86Info.useDefaultFontPathFrom = X_DEFAULT;
+ if (xf86GetOptValBool(FlagOptions, FLAG_USE_DEFAULT_FONT_PATH, &value)) {
+ xf86Info.useDefaultFontPath = value;
+ xf86Info.useDefaultFontPathFrom = X_CONFIG;
+ }
+
+/* Make sure that timers don't overflow CARD32's after multiplying */
+#define MAX_TIME_IN_MIN (0x7fffffff / MILLI_PER_MIN)
+
+ i = -1;
+ xf86GetOptValInteger(FlagOptions, FLAG_SAVER_BLANKTIME, &i);
+ if ((i >= 0) && (i < MAX_TIME_IN_MIN))
+ ScreenSaverTime = defaultScreenSaverTime = i * MILLI_PER_MIN;
+ else if (i != -1)
+ xf86ConfigError("BlankTime value %d outside legal range of 0 - %d minutes",
+ i, MAX_TIME_IN_MIN);
+
+#ifdef DPMSExtension
+ i = -1;
+ xf86GetOptValInteger(FlagOptions, FLAG_DPMS_STANDBYTIME, &i);
+ if ((i >= 0) && (i < MAX_TIME_IN_MIN))
+ DPMSStandbyTime = i * MILLI_PER_MIN;
+ else if (i != -1)
+ xf86ConfigError("StandbyTime value %d outside legal range of 0 - %d minutes",
+ i, MAX_TIME_IN_MIN);
+ i = -1;
+ xf86GetOptValInteger(FlagOptions, FLAG_DPMS_SUSPENDTIME, &i);
+ if ((i >= 0) && (i < MAX_TIME_IN_MIN))
+ DPMSSuspendTime = i * MILLI_PER_MIN;
+ else if (i != -1)
+ xf86ConfigError("SuspendTime value %d outside legal range of 0 - %d minutes",
+ i, MAX_TIME_IN_MIN);
+ i = -1;
+ xf86GetOptValInteger(FlagOptions, FLAG_DPMS_OFFTIME, &i);
+ if ((i >= 0) && (i < MAX_TIME_IN_MIN))
+ DPMSOffTime = i * MILLI_PER_MIN;
+ else if (i != -1)
+ xf86ConfigError("OffTime value %d outside legal range of 0 - %d minutes",
+ i, MAX_TIME_IN_MIN);
+#endif
+
+ i = -1;
+ xf86GetOptValInteger(FlagOptions, FLAG_PIXMAP, &i);
+ switch (i) {
+ case 24:
+ pix24 = Pix24Use24;
+ break;
+ case 32:
+ pix24 = Pix24Use32;
+ break;
+ case -1:
+ break;
+ default:
+ xf86ConfigError("Pixmap option's value (%d) must be 24 or 32\n", i);
+ return FALSE;
+ }
+ if (xf86Pix24 != Pix24DontCare) {
+ xf86Info.pixmap24 = xf86Pix24;
+ xf86Info.pix24From = X_CMDLINE;
+ } else if (pix24 != Pix24DontCare) {
+ xf86Info.pixmap24 = pix24;
+ xf86Info.pix24From = X_CONFIG;
+ } else {
+ xf86Info.pixmap24 = Pix24DontCare;
+ xf86Info.pix24From = X_DEFAULT;
+ }
+#ifdef SUPPORT_PC98
+ if (xf86GetOptValBool(FlagOptions, FLAG_PC98, &value)) {
+ xf86Info.pc98 = value;
+ if (value) {
+ xf86Msg(X_CONFIG, "Japanese PC98 architecture\n");
+ }
+ } else
+ if (detectPC98()) {
+ xf86Info.pc98 = TRUE;
+ xf86Msg(X_PROBED, "Japanese PC98 architecture\n");
+ }
+#endif
+
+#ifdef PANORAMIX
+ from = X_DEFAULT;
+ if (!noPanoramiXExtension)
+ from = X_CMDLINE;
+ else if (xf86GetOptValBool(FlagOptions, FLAG_XINERAMA, &value)) {
+ noPanoramiXExtension = !value;
+ from = X_CONFIG;
+ }
+ if (!noPanoramiXExtension)
+ xf86Msg(from, "Xinerama: enabled\n");
+#endif
+
+#ifdef DRI2
+ xf86Info.dri2 = FALSE;
+ xf86Info.dri2From = X_DEFAULT;
+ if (xf86GetOptValBool(FlagOptions, FLAG_DRI2, &value)) {
+ xf86Info.dri2 = value;
+ xf86Info.dri2From = X_CONFIG;
+ }
+#endif
+
+ return TRUE;
+}
+
+Bool xf86DRI2Enabled(void)
+{
+ return xf86Info.dri2;
+}
+
+/*
+ * Locate the core input devices. These can be specified/located in
+ * the following ways, in order of priority:
+ *
+ * 1. The InputDevices named by the -pointer and -keyboard command line
+ * options.
+ * 2. The "CorePointer" and "CoreKeyboard" InputDevices referred to by
+ * the active ServerLayout.
+ * 3. The first InputDevices marked as "CorePointer" and "CoreKeyboard".
+ * 4. The first InputDevices that use 'keyboard' or 'kbd' and a valid mouse
+ * driver (mouse, synaptics, evdev, vmmouse, void)
+ * 5. Default devices with an empty (default) configuration. These defaults
+ * will reference the 'mouse' and 'keyboard' drivers.
+ */
+
+static Bool
+checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
+{
+ InputInfoPtr corePointer = NULL, coreKeyboard = NULL;
+ Bool foundPointer = FALSE, foundKeyboard = FALSE;
+ const char *pointerMsg = NULL, *keyboardMsg = NULL;
+ InputInfoPtr *devs, /* iterator */
+ indp;
+ InputInfoRec Pointer = {}, Keyboard = {};
+ XF86ConfInputPtr confInput;
+ XF86ConfInputRec defPtr, defKbd;
+ int count = 0;
+ MessageType from = X_DEFAULT;
+ int found = 0;
+ const char *mousedrivers[] = { "mouse", "synaptics", "evdev", "vmmouse",
+ "void", NULL };
+
+ /*
+ * First check if a core pointer or core keyboard have been specified
+ * in the active ServerLayout. If more than one is specified for either,
+ * remove the core attribute from the later ones.
+ */
+ for (devs = servlayoutp->inputs; devs && *devs; devs++) {
+ indp = *devs;
+ if (indp->options &&
+ xf86CheckBoolOption(indp->options, "CorePointer", FALSE)) {
+ if (!corePointer) {
+ corePointer = indp;
+ } else {
+ xf86ReplaceBoolOption(indp->options, "CorePointer", FALSE);
+ xf86Msg(X_WARNING, "Duplicate core pointer devices. "
+ "Removing core pointer attribute from \"%s\"\n",
+ indp->name);
+ }
+ }
+ if (indp->options &&
+ xf86CheckBoolOption(indp->options, "CoreKeyboard", FALSE)) {
+ if (!coreKeyboard) {
+ coreKeyboard = indp;
+ } else {
+ xf86ReplaceBoolOption(indp->options, "CoreKeyboard", FALSE);
+ xf86Msg(X_WARNING, "Duplicate core keyboard devices. "
+ "Removing core keyboard attribute from \"%s\"\n",
+ indp->name);
+ }
+ }
+ count++;
+ }
+
+ confInput = NULL;
+
+ /* 1. Check for the -pointer command line option. */
+ if (xf86PointerName) {
+ confInput = xf86findInput(xf86PointerName,
+ xf86configptr->conf_input_lst);
+ if (!confInput) {
+ xf86Msg(X_ERROR, "No InputDevice section called \"%s\"\n",
+ xf86PointerName);
+ return FALSE;
+ }
+ from = X_CMDLINE;
+ /*
+ * If one was already specified in the ServerLayout, it needs to be
+ * removed.
+ */
+ if (corePointer) {
+ for (devs = servlayoutp->inputs; devs && *devs; devs++)
+ if (*devs == corePointer)
+ {
+ free(*devs);
+ *devs = (InputInfoPtr)0x1; /* ensure we dont skip next loop*/
+ break;
+ }
+ for (; devs && *devs; devs++)
+ devs[0] = devs[1];
+ count--;
+ }
+ corePointer = NULL;
+ foundPointer = TRUE;
+ }
+
+ /* 2. ServerLayout-specified core pointer. */
+ if (corePointer) {
+ foundPointer = TRUE;
+ from = X_CONFIG;
+ }
+
+ /* 3. First core pointer device. */
+ if (!foundPointer && (xf86Info.forceInputDevices || implicitLayout)) {
+ XF86ConfInputPtr p;
+
+ for (p = xf86configptr->conf_input_lst; p; p = p->list.next) {
+ if (p->inp_option_lst &&
+ xf86CheckBoolOption(p->inp_option_lst, "CorePointer", FALSE)) {
+ confInput = p;
+ foundPointer = TRUE;
+ from = X_DEFAULT;
+ pointerMsg = "first core pointer device";
+ break;
+ }
+ }
+ }
+
+ /* 4. First pointer with an allowed mouse driver. */
+ if (!foundPointer && xf86Info.forceInputDevices) {
+ const char **driver = mousedrivers;
+ confInput = xf86findInput(CONF_IMPLICIT_POINTER,
+ xf86configptr->conf_input_lst);
+ while (*driver && !confInput) {
+ confInput = xf86findInputByDriver(*driver,
+ xf86configptr->conf_input_lst);
+ driver++;
+ }
+ if (confInput) {
+ foundPointer = TRUE;
+ from = X_DEFAULT;
+ pointerMsg = "first mouse device";
+ }
+ }
+
+ /* 5. Built-in default. */
+ if (!foundPointer && xf86Info.forceInputDevices) {
+ memset(&defPtr, 0, sizeof(defPtr));
+ defPtr.inp_identifier = strdup("<default pointer>");
+ defPtr.inp_driver = strdup("mouse");
+ confInput = &defPtr;
+ foundPointer = TRUE;
+ from = X_DEFAULT;
+ pointerMsg = "default mouse configuration";
+ }
+
+ /* Add the core pointer device to the layout, and set it to Core. */
+ if (foundPointer && confInput) {
+ foundPointer = configInput(&Pointer, confInput, from);
+ if (foundPointer) {
+ count++;
+ devs = xnfrealloc(servlayoutp->inputs,
+ (count + 1) * sizeof(InputInfoPtr));
+ devs[count - 1] = xnfalloc(sizeof(InputInfoRec));
+ Pointer.fd = -1;
+ *devs[count - 1] = Pointer;
+ devs[count - 1]->options =
+ xf86addNewOption(devs[count -1]->options,
+ xnfstrdup("CorePointer"), NULL);
+ devs[count] = NULL;
+ servlayoutp->inputs = devs;
+ }
+ }
+
+ if (!foundPointer && xf86Info.forceInputDevices) {
+ /* This shouldn't happen. */
+ xf86Msg(X_ERROR, "Cannot locate a core pointer device.\n");
+ return FALSE;
+ }
+
+ /*
+ * always synthesize a 'mouse' section configured to send core
+ * events, unless a 'void' section is found, in which case the user
+ * probably wants to run footless.
+ *
+ * If you're using an evdev keyboard and expect a default mouse
+ * section ... deal.
+ */
+ for (devs = servlayoutp->inputs; devs && *devs; devs++) {
+ const char **driver = mousedrivers;
+ while(*driver) {
+ if (!strcmp((*devs)->driver, *driver)) {
+ found = 1;
+ break;
+ }
+ driver++;
+ }
+ }
+ if (!found && xf86Info.forceInputDevices) {
+ xf86Msg(X_INFO, "No default mouse found, adding one\n");
+ memset(&defPtr, 0, sizeof(defPtr));
+ defPtr.inp_identifier = strdup("<default pointer>");
+ defPtr.inp_driver = strdup("mouse");
+ confInput = &defPtr;
+ foundPointer = configInput(&Pointer, confInput, from);
+ if (foundPointer) {
+ count++;
+ devs = xnfrealloc(servlayoutp->inputs,
+ (count + 1) * sizeof(InputInfoPtr));
+ devs[count - 1] = xnfalloc(sizeof(InputInfoRec));
+ Pointer.fd = -1;
+ *devs[count - 1] = Pointer;
+ devs[count - 1]->options =
+ xf86addNewOption(NULL, xnfstrdup("AlwaysCore"), NULL);
+ devs[count] = NULL;
+ servlayoutp->inputs = devs;
+ }
+ }
+
+ confInput = NULL;
+
+ /* 1. Check for the -keyboard command line option. */
+ if (xf86KeyboardName) {
+ confInput = xf86findInput(xf86KeyboardName,
+ xf86configptr->conf_input_lst);
+ if (!confInput) {
+ xf86Msg(X_ERROR, "No InputDevice section called \"%s\"\n",
+ xf86KeyboardName);
+ return FALSE;
+ }
+ from = X_CMDLINE;
+ /*
+ * If one was already specified in the ServerLayout, it needs to be
+ * removed.
+ */
+ if (coreKeyboard) {
+ for (devs = servlayoutp->inputs; devs && *devs; devs++)
+ if (*devs == coreKeyboard)
+ {
+ free(*devs);
+ *devs = (InputInfoPtr)0x1; /* ensure we dont skip next loop */
+ break;
+ }
+ for (; devs && *devs; devs++)
+ devs[0] = devs[1];
+ count--;
+ }
+ coreKeyboard = NULL;
+ foundKeyboard = TRUE;
+ }
+
+ /* 2. ServerLayout-specified core keyboard. */
+ if (coreKeyboard) {
+ foundKeyboard = TRUE;
+ from = X_CONFIG;
+ }
+
+ /* 3. First core keyboard device. */
+ if (!foundKeyboard && (xf86Info.forceInputDevices || implicitLayout)) {
+ XF86ConfInputPtr p;
+
+ for (p = xf86configptr->conf_input_lst; p; p = p->list.next) {
+ if (p->inp_option_lst &&
+ xf86CheckBoolOption(p->inp_option_lst, "CoreKeyboard", FALSE)) {
+ confInput = p;
+ foundKeyboard = TRUE;
+ from = X_DEFAULT;
+ keyboardMsg = "first core keyboard device";
+ break;
+ }
+ }
+ }
+
+ /* 4. First keyboard with 'keyboard' or 'kbd' as the driver. */
+ if (!foundKeyboard && xf86Info.forceInputDevices) {
+ confInput = xf86findInput(CONF_IMPLICIT_KEYBOARD,
+ xf86configptr->conf_input_lst);
+ if (!confInput) {
+ confInput = xf86findInputByDriver("kbd",
+ xf86configptr->conf_input_lst);
+ }
+ if (confInput) {
+ foundKeyboard = TRUE;
+ from = X_DEFAULT;
+ keyboardMsg = "first keyboard device";
+ }
+ }
+
+ /* 5. Built-in default. */
+ if (!foundKeyboard && xf86Info.forceInputDevices) {
+ memset(&defKbd, 0, sizeof(defKbd));
+ defKbd.inp_identifier = strdup("<default keyboard>");
+ defKbd.inp_driver = strdup("kbd");
+ confInput = &defKbd;
+ foundKeyboard = TRUE;
+ keyboardMsg = "default keyboard configuration";
+ from = X_DEFAULT;
+ }
+
+ /* Add the core keyboard device to the layout, and set it to Core. */
+ if (foundKeyboard && confInput) {
+ foundKeyboard = configInput(&Keyboard, confInput, from);
+ if (foundKeyboard) {
+ count++;
+ devs = xnfrealloc(servlayoutp->inputs,
+ (count + 1) * sizeof(InputInfoPtr));
+ devs[count - 1] = xnfalloc(sizeof(InputInfoRec));
+ Keyboard.fd = -1;
+ *devs[count - 1] = Keyboard;
+ devs[count - 1]->options =
+ xf86addNewOption(devs[count - 1]->options,
+ xnfstrdup("CoreKeyboard"), NULL);
+ devs[count] = NULL;
+ servlayoutp->inputs = devs;
+ }
+ }
+
+ if (!foundKeyboard && xf86Info.forceInputDevices) {
+ /* This shouldn't happen. */
+ xf86Msg(X_ERROR, "Cannot locate a core keyboard device.\n");
+ return FALSE;
+ }
+
+ if (pointerMsg) {
+ if (implicitLayout)
+ xf86Msg(X_DEFAULT, "No Layout section. Using the %s.\n",
+ pointerMsg);
+ else
+ xf86Msg(X_DEFAULT, "The core pointer device wasn't specified "
+ "explicitly in the layout.\n"
+ "\tUsing the %s.\n", pointerMsg);
+ }
+
+ if (keyboardMsg) {
+ if (implicitLayout)
+ xf86Msg(X_DEFAULT, "No Layout section. Using the %s.\n",
+ keyboardMsg);
+ else
+ xf86Msg(X_DEFAULT, "The core keyboard device wasn't specified "
+ "explicitly in the layout.\n"
+ "\tUsing the %s.\n", keyboardMsg);
+ }
+
+ if (!xf86Info.forceInputDevices && !(foundPointer && foundKeyboard)) {
+#if defined(CONFIG_HAL) || defined(CONFIG_UDEV)
+ const char *config_backend;
+#if defined(CONFIG_HAL)
+ config_backend = "HAL";
+#else
+ config_backend = "udev";
+#endif
+ xf86Msg(X_INFO, "The server relies on %s to provide the list of "
+ "input devices.\n\tIf no devices become available, "
+ "reconfigure %s or disable AutoAddDevices.\n",
+ config_backend, config_backend);
+#else
+ xf86Msg(X_WARNING, "Hotplugging requested but the server was "
+ "compiled without a config backend. "
+ "No input devices were configured, the server "
+ "will start without any input devices.\n");
+#endif
+ }
+
+ return TRUE;
+}
+
+typedef enum {
+ LAYOUT_ISOLATEDEVICE,
+ LAYOUT_SINGLECARD
+} LayoutValues;
+
+static OptionInfoRec LayoutOptions[] = {
+ { LAYOUT_ISOLATEDEVICE, "IsolateDevice", OPTV_STRING,
+ {0}, FALSE },
+ { LAYOUT_SINGLECARD, "SingleCard", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { -1, NULL, OPTV_NONE,
+ {0}, FALSE },
+};
+
+static Bool
+configInputDevices(XF86ConfLayoutPtr layout, serverLayoutPtr servlayoutp)
+{
+ XF86ConfInputrefPtr irp;
+ InputInfoPtr *indp;
+ int count = 0;
+
+ /*
+ * Count the number of input devices.
+ */
+ irp = layout->lay_input_lst;
+ while (irp) {
+ count++;
+ irp = (XF86ConfInputrefPtr)irp->list.next;
+ }
+ DebugF("Found %d input devices in the layout section %s\n",
+ count, layout->lay_identifier);
+ indp = xnfcalloc((count + 1), sizeof(InputInfoPtr));
+ indp[count] = NULL;
+ irp = layout->lay_input_lst;
+ count = 0;
+ while (irp) {
+ indp[count] = xf86AllocateInput();
+ if (!configInput(indp[count], irp->iref_inputdev, X_CONFIG)) {
+ do {
+ free(indp[count]);
+ } while(count--);
+ free(indp);
+ return FALSE;
+ }
+ indp[count]->options = xf86OptionListMerge(indp[count]->options,
+ irp->iref_option_lst);
+ count++;
+ irp = (XF86ConfInputrefPtr)irp->list.next;
+ }
+ servlayoutp->inputs = indp;
+
+ return TRUE;
+}
+
+
+/*
+ * figure out which layout is active, which screens are used in that layout,
+ * which drivers and monitors are used in these screens
+ */
+static Bool
+configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
+ char *default_layout)
+{
+ XF86ConfAdjacencyPtr adjp;
+ XF86ConfInactivePtr idp;
+ int saved_count, count = 0;
+ int scrnum;
+ XF86ConfLayoutPtr l;
+ MessageType from;
+ screenLayoutPtr slp;
+ GDevPtr gdp;
+ int i = 0, j;
+
+ if (!servlayoutp)
+ return FALSE;
+
+ /*
+ * which layout section is the active one?
+ *
+ * If there is a -layout command line option, use that one, otherwise
+ * pick the first one.
+ */
+ from = X_DEFAULT;
+ if (xf86LayoutName != NULL)
+ from = X_CMDLINE;
+ else if (default_layout) {
+ xf86LayoutName = default_layout;
+ from = X_CONFIG;
+ }
+ if (xf86LayoutName != NULL) {
+ if ((l = xf86findLayout(xf86LayoutName, conf_layout)) == NULL) {
+ xf86Msg(X_ERROR, "No ServerLayout section called \"%s\"\n",
+ xf86LayoutName);
+ return FALSE;
+ }
+ conf_layout = l;
+ }
+ xf86Msg(from, "ServerLayout \"%s\"\n", conf_layout->lay_identifier);
+ adjp = conf_layout->lay_adjacency_lst;
+
+ /*
+ * we know that each screen is referenced exactly once on the left side
+ * of a layout statement in the Layout section. So to allocate the right
+ * size for the array we do a quick walk of the list to figure out how
+ * many sections we have
+ */
+ while (adjp) {
+ count++;
+ adjp = (XF86ConfAdjacencyPtr)adjp->list.next;
+ }
+
+ DebugF("Found %d screens in the layout section %s",
+ count, conf_layout->lay_identifier);
+ if (!count) /* alloc enough storage even if no screen is specified */
+ count = 1;
+
+ slp = xnfcalloc(1, (count + 1) * sizeof(screenLayoutRec));
+ slp[count].screen = NULL;
+ /*
+ * now that we have storage, loop over the list again and fill in our
+ * data structure; at this point we do not fill in the adjacency
+ * information as it is not clear if we need it at all
+ */
+ adjp = conf_layout->lay_adjacency_lst;
+ count = 0;
+ while (adjp) {
+ slp[count].screen = xnfcalloc(1, sizeof(confScreenRec));
+ if (adjp->adj_scrnum < 0)
+ scrnum = count;
+ else
+ scrnum = adjp->adj_scrnum;
+ if (!configScreen(slp[count].screen, adjp->adj_screen, scrnum,
+ X_CONFIG)) {
+ do {
+ free(slp[count].screen);
+ } while(count--);
+ free(slp);
+ return FALSE;
+ }
+ slp[count].x = adjp->adj_x;
+ slp[count].y = adjp->adj_y;
+ slp[count].refname = adjp->adj_refscreen;
+ switch (adjp->adj_where) {
+ case CONF_ADJ_OBSOLETE:
+ slp[count].where = PosObsolete;
+ slp[count].topname = adjp->adj_top_str;
+ slp[count].bottomname = adjp->adj_bottom_str;
+ slp[count].leftname = adjp->adj_left_str;
+ slp[count].rightname = adjp->adj_right_str;
+ break;
+ case CONF_ADJ_ABSOLUTE:
+ slp[count].where = PosAbsolute;
+ break;
+ case CONF_ADJ_RIGHTOF:
+ slp[count].where = PosRightOf;
+ break;
+ case CONF_ADJ_LEFTOF:
+ slp[count].where = PosLeftOf;
+ break;
+ case CONF_ADJ_ABOVE:
+ slp[count].where = PosAbove;
+ break;
+ case CONF_ADJ_BELOW:
+ slp[count].where = PosBelow;
+ break;
+ case CONF_ADJ_RELATIVE:
+ slp[count].where = PosRelative;
+ break;
+ }
+ count++;
+ adjp = (XF86ConfAdjacencyPtr)adjp->list.next;
+ }
+
+ /* No screen was specified in the layout. take the first one from the
+ * config file, or - if it is NULL - configScreen autogenerates one for
+ * us */
+ if (!count)
+ {
+ slp[0].screen = xnfcalloc(1, sizeof(confScreenRec));
+ if (!configScreen(slp[0].screen, xf86configptr->conf_screen_lst,
+ 0, X_CONFIG)) {
+ free(slp[0].screen);
+ free(slp);
+ return FALSE;
+ }
+ }
+
+ /* XXX Need to tie down the upper left screen. */
+
+ /* Fill in the refscreen and top/bottom/left/right values */
+ for (i = 0; i < count; i++) {
+ for (j = 0; j < count; j++) {
+ if (slp[i].refname &&
+ strcmp(slp[i].refname, slp[j].screen->id) == 0) {
+ slp[i].refscreen = slp[j].screen;
+ }
+ if (slp[i].topname &&
+ strcmp(slp[i].topname, slp[j].screen->id) == 0) {
+ slp[i].top = slp[j].screen;
+ }
+ if (slp[i].bottomname &&
+ strcmp(slp[i].bottomname, slp[j].screen->id) == 0) {
+ slp[i].bottom = slp[j].screen;
+ }
+ if (slp[i].leftname &&
+ strcmp(slp[i].leftname, slp[j].screen->id) == 0) {
+ slp[i].left = slp[j].screen;
+ }
+ if (slp[i].rightname &&
+ strcmp(slp[i].rightname, slp[j].screen->id) == 0) {
+ slp[i].right = slp[j].screen;
+ }
+ }
+ if (slp[i].where != PosObsolete
+ && slp[i].where != PosAbsolute
+ && !slp[i].refscreen) {
+ xf86Msg(X_ERROR,"Screen %s doesn't exist: deleting placement\n",
+ slp[i].refname);
+ slp[i].where = PosAbsolute;
+ slp[i].x = 0;
+ slp[i].y = 0;
+ }
+ }
+
+ if (!count)
+ saved_count = 1;
+ else
+ saved_count = count;
+ /*
+ * Count the number of inactive devices.
+ */
+ count = 0;
+ idp = conf_layout->lay_inactive_lst;
+ while (idp) {
+ count++;
+ idp = (XF86ConfInactivePtr)idp->list.next;
+ }
+ DebugF("Found %d inactive devices in the layout section %s\n",
+ count, conf_layout->lay_identifier);
+ gdp = xnfalloc((count + 1) * sizeof(GDevRec));
+ gdp[count].identifier = NULL;
+ idp = conf_layout->lay_inactive_lst;
+ count = 0;
+ while (idp) {
+ if (!configDevice(&gdp[count], idp->inactive_device, FALSE))
+ goto bail;
+ count++;
+ idp = (XF86ConfInactivePtr)idp->list.next;
+ }
+
+ if (!configInputDevices(conf_layout, servlayoutp))
+ goto bail;
+
+ servlayoutp->id = conf_layout->lay_identifier;
+ servlayoutp->screens = slp;
+ servlayoutp->inactives = gdp;
+ servlayoutp->options = conf_layout->lay_option_lst;
+ from = X_DEFAULT;
+
+ return TRUE;
+
+bail:
+ do {
+ free(slp[saved_count].screen);
+ } while(saved_count--);
+ free(slp);
+ free(gdp);
+ return FALSE;
+}
+
+/*
+ * No layout section, so find the first Screen section and set that up as
+ * the only active screen.
+ */
+static Bool
+configImpliedLayout(serverLayoutPtr servlayoutp, XF86ConfScreenPtr conf_screen,
+ XF86ConfigPtr xf86configptr)
+{
+ MessageType from;
+ XF86ConfScreenPtr s;
+ screenLayoutPtr slp;
+ InputInfoPtr *indp;
+ XF86ConfLayoutRec layout;
+
+ if (!servlayoutp)
+ return FALSE;
+
+ /*
+ * which screen section is the active one?
+ *
+ * If there is a -screen option, use that one, otherwise use the first
+ * one.
+ */
+
+ from = X_CONFIG;
+ if (xf86ScreenName != NULL) {
+ if ((s = xf86findScreen(xf86ScreenName, conf_screen)) == NULL) {
+ xf86Msg(X_ERROR, "No Screen section called \"%s\"\n",
+ xf86ScreenName);
+ return FALSE;
+ }
+ conf_screen = s;
+ from = X_CMDLINE;
+ }
+
+ /* We have exactly one screen */
+
+ slp = xnfcalloc(1, 2 * sizeof(screenLayoutRec));
+ slp[0].screen = xnfcalloc(1, sizeof(confScreenRec));
+ slp[1].screen = NULL;
+ if (!configScreen(slp[0].screen, conf_screen, 0, from)) {
+ free(slp);
+ return FALSE;
+ }
+ servlayoutp->id = "(implicit)";
+ servlayoutp->screens = slp;
+ servlayoutp->inactives = xnfcalloc(1, sizeof(GDevRec));
+ servlayoutp->options = NULL;
+
+ memset(&layout, 0, sizeof(layout));
+ layout.lay_identifier = servlayoutp->id;
+ if (xf86layoutAddInputDevices(xf86configptr, &layout) > 0) {
+ if (!configInputDevices(&layout, servlayoutp))
+ return FALSE;
+ from = X_DEFAULT;
+ } else {
+ /* Set up an empty input device list, then look for some core devices. */
+ indp = xnfalloc(sizeof(InputInfoPtr));
+ *indp = NULL;
+ servlayoutp->inputs = indp;
+ }
+
+ return TRUE;
+}
+
+static Bool
+configXvAdaptor(confXvAdaptorPtr adaptor, XF86ConfVideoAdaptorPtr conf_adaptor)
+{
+ int count = 0;
+ XF86ConfVideoPortPtr conf_port;
+
+ xf86Msg(X_CONFIG, "| |-->VideoAdaptor \"%s\"\n",
+ conf_adaptor->va_identifier);
+ adaptor->identifier = conf_adaptor->va_identifier;
+ adaptor->options = conf_adaptor->va_option_lst;
+ if (conf_adaptor->va_busid || conf_adaptor->va_driver) {
+ xf86Msg(X_CONFIG, "| | Unsupported device type, skipping entry\n");
+ return FALSE;
+ }
+
+ /*
+ * figure out how many videoport subsections there are and fill them in
+ */
+ conf_port = conf_adaptor->va_port_lst;
+ while(conf_port) {
+ count++;
+ conf_port = (XF86ConfVideoPortPtr)conf_port->list.next;
+ }
+ adaptor->ports = xnfalloc((count) * sizeof(confXvPortRec));
+ adaptor->numports = count;
+ count = 0;
+ conf_port = conf_adaptor->va_port_lst;
+ while(conf_port) {
+ adaptor->ports[count].identifier = conf_port->vp_identifier;
+ adaptor->ports[count].options = conf_port->vp_option_lst;
+ count++;
+ conf_port = (XF86ConfVideoPortPtr)conf_port->list.next;
+ }
+
+ return TRUE;
+}
+
+static Bool
+configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen, int scrnum,
+ MessageType from)
+{
+ int count = 0;
+ XF86ConfDisplayPtr dispptr;
+ XF86ConfAdaptorLinkPtr conf_adaptor;
+ Bool defaultMonitor = FALSE;
+ XF86ConfScreenRec local_conf_screen;
+
+ if (!conf_screen) {
+ memset(&local_conf_screen, 0, sizeof(local_conf_screen));
+ conf_screen = &local_conf_screen;
+ conf_screen->scrn_identifier = "Default Screen Section";
+ xf86Msg(X_DEFAULT, "No screen section available. Using defaults.\n");
+ }
+
+ xf86Msg(from, "|-->Screen \"%s\" (%d)\n", conf_screen->scrn_identifier,
+ scrnum);
+ /*
+ * now we fill in the elements of the screen
+ */
+ screenp->id = conf_screen->scrn_identifier;
+ screenp->screennum = scrnum;
+ screenp->defaultdepth = conf_screen->scrn_defaultdepth;
+ screenp->defaultbpp = conf_screen->scrn_defaultbpp;
+ screenp->defaultfbbpp = conf_screen->scrn_defaultfbbpp;
+ screenp->monitor = xnfcalloc(1, sizeof(MonRec));
+ /* If no monitor is specified, create a default one. */
+ if (!conf_screen->scrn_monitor) {
+ XF86ConfMonitorRec defMon;
+
+ memset(&defMon, 0, sizeof(defMon));
+ defMon.mon_identifier = "<default monitor>";
+ if (!configMonitor(screenp->monitor, &defMon))
+ return FALSE;
+ defaultMonitor = TRUE;
+ } else {
+ if (!configMonitor(screenp->monitor,conf_screen->scrn_monitor))
+ return FALSE;
+ }
+ /* Configure the device. If there isn't one configured, attach to the
+ * first inactive one that we can configure. If there's none that work,
+ * set it to NULL so that the section can be autoconfigured later */
+ screenp->device = xnfcalloc(1, sizeof(GDevRec));
+ if ((!conf_screen->scrn_device) && (xf86configptr->conf_device_lst)) {
+ conf_screen->scrn_device = xf86configptr->conf_device_lst;
+ xf86Msg(X_DEFAULT, "No device specified for screen \"%s\".\n"
+ "\tUsing the first device section listed.\n", screenp->id);
+ }
+ if (configDevice(screenp->device,conf_screen->scrn_device, TRUE)) {
+ screenp->device->myScreenSection = screenp;
+ } else {
+ screenp->device = NULL;
+ }
+ screenp->options = conf_screen->scrn_option_lst;
+
+ /*
+ * figure out how many display subsections there are and fill them in
+ */
+ dispptr = conf_screen->scrn_display_lst;
+ while(dispptr) {
+ count++;
+ dispptr = (XF86ConfDisplayPtr)dispptr->list.next;
+ }
+ screenp->displays = xnfalloc((count) * sizeof(DispRec));
+ screenp->numdisplays = count;
+
+ /* Fill in the default Virtual size, if any */
+ if (conf_screen->scrn_virtualX && conf_screen->scrn_virtualY) {
+ for (count = 0, dispptr = conf_screen->scrn_display_lst;
+ dispptr;
+ dispptr = (XF86ConfDisplayPtr)dispptr->list.next, count++) {
+ screenp->displays[count].virtualX = conf_screen->scrn_virtualX;
+ screenp->displays[count].virtualY = conf_screen->scrn_virtualY;
+ }
+ }
+
+ /* Now do the per-Display Virtual sizes */
+ count = 0;
+ dispptr = conf_screen->scrn_display_lst;
+ while(dispptr) {
+ configDisplay(&(screenp->displays[count]),dispptr);
+ count++;
+ dispptr = (XF86ConfDisplayPtr)dispptr->list.next;
+ }
+
+ /*
+ * figure out how many videoadaptor references there are and fill them in
+ */
+ conf_adaptor = conf_screen->scrn_adaptor_lst;
+ while(conf_adaptor) {
+ count++;
+ conf_adaptor = (XF86ConfAdaptorLinkPtr)conf_adaptor->list.next;
+ }
+ screenp->xvadaptors = xnfalloc((count) * sizeof(confXvAdaptorRec));
+ screenp->numxvadaptors = 0;
+ conf_adaptor = conf_screen->scrn_adaptor_lst;
+ while(conf_adaptor) {
+ if (configXvAdaptor(&(screenp->xvadaptors[screenp->numxvadaptors]),
+ conf_adaptor->al_adaptor))
+ screenp->numxvadaptors++;
+ conf_adaptor = (XF86ConfAdaptorLinkPtr)conf_adaptor->list.next;
+ }
+
+ if (defaultMonitor) {
+ xf86Msg(X_DEFAULT, "No monitor specified for screen \"%s\".\n"
+ "\tUsing a default monitor configuration.\n", screenp->id);
+ }
+ return TRUE;
+}
+
+typedef enum {
+ MON_REDUCEDBLANKING,
+ MON_MAX_PIX_CLOCK,
+} MonitorValues;
+
+static OptionInfoRec MonitorOptions[] = {
+ { MON_REDUCEDBLANKING, "ReducedBlanking", OPTV_BOOLEAN,
+ {0}, FALSE },
+ { MON_MAX_PIX_CLOCK, "MaxPixClock", OPTV_FREQ,
+ {0}, FALSE },
+ { -1, NULL, OPTV_NONE,
+ {0}, FALSE },
+};
+
+static Bool
+configMonitor(MonPtr monitorp, XF86ConfMonitorPtr conf_monitor)
+{
+ int count;
+ DisplayModePtr mode,last = NULL;
+ XF86ConfModeLinePtr cmodep;
+ XF86ConfModesPtr modes;
+ XF86ConfModesLinkPtr modeslnk = conf_monitor->mon_modes_sect_lst;
+ Gamma zeros = {0.0, 0.0, 0.0};
+ float badgamma = 0.0;
+ double maxPixClock;
+
+ xf86Msg(X_CONFIG, "| |-->Monitor \"%s\"\n",
+ conf_monitor->mon_identifier);
+ monitorp->id = conf_monitor->mon_identifier;
+ monitorp->vendor = conf_monitor->mon_vendor;
+ monitorp->model = conf_monitor->mon_modelname;
+ monitorp->Modes = NULL;
+ monitorp->Last = NULL;
+ monitorp->gamma = zeros;
+ monitorp->widthmm = conf_monitor->mon_width;
+ monitorp->heightmm = conf_monitor->mon_height;
+ monitorp->reducedblanking = FALSE;
+ monitorp->maxPixClock = 0;
+ monitorp->options = conf_monitor->mon_option_lst;
+
+ /*
+ * fill in the monitor structure
+ */
+ for( count = 0 ;
+ count < conf_monitor->mon_n_hsync && count < MAX_HSYNC;
+ count++) {
+ monitorp->hsync[count].hi = conf_monitor->mon_hsync[count].hi;
+ monitorp->hsync[count].lo = conf_monitor->mon_hsync[count].lo;
+ }
+ monitorp->nHsync = count;
+ for( count = 0 ;
+ count < conf_monitor->mon_n_vrefresh && count < MAX_VREFRESH;
+ count++) {
+ monitorp->vrefresh[count].hi = conf_monitor->mon_vrefresh[count].hi;
+ monitorp->vrefresh[count].lo = conf_monitor->mon_vrefresh[count].lo;
+ }
+ monitorp->nVrefresh = count;
+
+ /*
+ * first we collect the mode lines from the UseModes directive
+ */
+ while(modeslnk)
+ {
+ modes = xf86findModes (modeslnk->ml_modes_str,
+ xf86configptr->conf_modes_lst);
+ modeslnk->ml_modes = modes;
+
+
+ /* now add the modes found in the modes
+ section to the list of modes for this
+ monitor unless it has been added before
+ because we are reusing the same section
+ for another screen */
+ if (xf86itemNotSublist(
+ (GenericListPtr)conf_monitor->mon_modeline_lst,
+ (GenericListPtr)modes->mon_modeline_lst)) {
+ conf_monitor->mon_modeline_lst = (XF86ConfModeLinePtr)
+ xf86addListItem(
+ (GenericListPtr)conf_monitor->mon_modeline_lst,
+ (GenericListPtr)modes->mon_modeline_lst);
+ }
+ modeslnk = modeslnk->list.next;
+ }
+
+ /*
+ * we need to hook in the mode lines now
+ * here both data structures use lists, only our internal one
+ * is double linked
+ */
+ cmodep = conf_monitor->mon_modeline_lst;
+ while( cmodep ) {
+ mode = xnfcalloc(1, sizeof(DisplayModeRec));
+ mode->type = 0;
+ mode->Clock = cmodep->ml_clock;
+ mode->HDisplay = cmodep->ml_hdisplay;
+ mode->HSyncStart = cmodep->ml_hsyncstart;
+ mode->HSyncEnd = cmodep->ml_hsyncend;
+ mode->HTotal = cmodep->ml_htotal;
+ mode->VDisplay = cmodep->ml_vdisplay;
+ mode->VSyncStart = cmodep->ml_vsyncstart;
+ mode->VSyncEnd = cmodep->ml_vsyncend;
+ mode->VTotal = cmodep->ml_vtotal;
+ mode->Flags = cmodep->ml_flags;
+ mode->HSkew = cmodep->ml_hskew;
+ mode->VScan = cmodep->ml_vscan;
+ mode->name = xnfstrdup(cmodep->ml_identifier);
+ if( last ) {
+ mode->prev = last;
+ last->next = mode;
+ }
+ else {
+ /*
+ * this is the first mode
+ */
+ monitorp->Modes = mode;
+ mode->prev = NULL;
+ }
+ last = mode;
+ cmodep = (XF86ConfModeLinePtr)cmodep->list.next;
+ }
+ if(last){
+ last->next = NULL;
+ }
+ monitorp->Last = last;
+
+ /* add the (VESA) default modes */
+ if (! addDefaultModes(monitorp) )
+ return FALSE;
+
+ if (conf_monitor->mon_gamma_red > GAMMA_ZERO)
+ monitorp->gamma.red = conf_monitor->mon_gamma_red;
+ if (conf_monitor->mon_gamma_green > GAMMA_ZERO)
+ monitorp->gamma.green = conf_monitor->mon_gamma_green;
+ if (conf_monitor->mon_gamma_blue > GAMMA_ZERO)
+ monitorp->gamma.blue = conf_monitor->mon_gamma_blue;
+
+ /* Check that the gamma values are within range */
+ if (monitorp->gamma.red > GAMMA_ZERO &&
+ (monitorp->gamma.red < GAMMA_MIN ||
+ monitorp->gamma.red > GAMMA_MAX)) {
+ badgamma = monitorp->gamma.red;
+ } else if (monitorp->gamma.green > GAMMA_ZERO &&
+ (monitorp->gamma.green < GAMMA_MIN ||
+ monitorp->gamma.green > GAMMA_MAX)) {
+ badgamma = monitorp->gamma.green;
+ } else if (monitorp->gamma.blue > GAMMA_ZERO &&
+ (monitorp->gamma.blue < GAMMA_MIN ||
+ monitorp->gamma.blue > GAMMA_MAX)) {
+ badgamma = monitorp->gamma.blue;
+ }
+ if (badgamma > GAMMA_ZERO) {
+ xf86ConfigError("Gamma value %.f is out of range (%.2f - %.1f)\n",
+ badgamma, GAMMA_MIN, GAMMA_MAX);
+ return FALSE;
+ }
+
+ xf86ProcessOptions(-1, monitorp->options, MonitorOptions);
+ xf86GetOptValBool(MonitorOptions, MON_REDUCEDBLANKING,
+ &monitorp->reducedblanking);
+ if (xf86GetOptValFreq(MonitorOptions, MON_MAX_PIX_CLOCK, OPTUNITS_KHZ,
+ &maxPixClock) == TRUE) {
+ monitorp->maxPixClock = (int) maxPixClock;
+ }
+
+ return TRUE;
+}
+
+static int
+lookupVisual(const char *visname)
+{
+ int i;
+
+ if (!visname || !*visname)
+ return -1;
+
+ for (i = 0; i <= DirectColor; i++) {
+ if (!xf86nameCompare(visname, xf86VisualNames[i]))
+ break;
+ }
+
+ if (i <= DirectColor)
+ return i;
+
+ return -1;
+}
+
+
+static Bool
+configDisplay(DispPtr displayp, XF86ConfDisplayPtr conf_display)
+{
+ int count = 0;
+ XF86ModePtr modep;
+
+ displayp->frameX0 = conf_display->disp_frameX0;
+ displayp->frameY0 = conf_display->disp_frameY0;
+ displayp->virtualX = conf_display->disp_virtualX;
+ displayp->virtualY = conf_display->disp_virtualY;
+ displayp->depth = conf_display->disp_depth;
+ displayp->fbbpp = conf_display->disp_bpp;
+ displayp->weight.red = conf_display->disp_weight.red;
+ displayp->weight.green = conf_display->disp_weight.green;
+ displayp->weight.blue = conf_display->disp_weight.blue;
+ displayp->blackColour.red = conf_display->disp_black.red;
+ displayp->blackColour.green = conf_display->disp_black.green;
+ displayp->blackColour.blue = conf_display->disp_black.blue;
+ displayp->whiteColour.red = conf_display->disp_white.red;
+ displayp->whiteColour.green = conf_display->disp_white.green;
+ displayp->whiteColour.blue = conf_display->disp_white.blue;
+ displayp->options = conf_display->disp_option_lst;
+ if (conf_display->disp_visual) {
+ displayp->defaultVisual = lookupVisual(conf_display->disp_visual);
+ if (displayp->defaultVisual == -1) {
+ xf86ConfigError("Invalid visual name: \"%s\"",
+ conf_display->disp_visual);
+ return FALSE;
+ }
+ } else {
+ displayp->defaultVisual = -1;
+ }
+
+ /*
+ * now hook in the modes
+ */
+ modep = conf_display->disp_mode_lst;
+ while(modep) {
+ count++;
+ modep = (XF86ModePtr)modep->list.next;
+ }
+ displayp->modes = xnfalloc((count+1) * sizeof(char*));
+ modep = conf_display->disp_mode_lst;
+ count = 0;
+ while(modep) {
+ displayp->modes[count] = modep->mode_name;
+ count++;
+ modep = (XF86ModePtr)modep->list.next;
+ }
+ displayp->modes[count] = NULL;
+
+ return TRUE;
+}
+
+static Bool
+configDevice(GDevPtr devicep, XF86ConfDevicePtr conf_device, Bool active)
+{
+ int i;
+
+ if (!conf_device) {
+ return FALSE;
+ }
+
+ if (active)
+ xf86Msg(X_CONFIG, "| |-->Device \"%s\"\n",
+ conf_device->dev_identifier);
+ else
+ xf86Msg(X_CONFIG, "|-->Inactive Device \"%s\"\n",
+ conf_device->dev_identifier);
+
+ devicep->identifier = conf_device->dev_identifier;
+ devicep->vendor = conf_device->dev_vendor;
+ devicep->board = conf_device->dev_board;
+ devicep->chipset = conf_device->dev_chipset;
+ devicep->ramdac = conf_device->dev_ramdac;
+ devicep->driver = conf_device->dev_driver;
+ devicep->active = active;
+ devicep->videoRam = conf_device->dev_videoram;
+ devicep->BiosBase = conf_device->dev_bios_base;
+ devicep->MemBase = conf_device->dev_mem_base;
+ devicep->IOBase = conf_device->dev_io_base;
+ devicep->clockchip = conf_device->dev_clockchip;
+ devicep->busID = conf_device->dev_busid;
+ devicep->textClockFreq = conf_device->dev_textclockfreq;
+ devicep->chipID = conf_device->dev_chipid;
+ devicep->chipRev = conf_device->dev_chiprev;
+ devicep->options = conf_device->dev_option_lst;
+ devicep->irq = conf_device->dev_irq;
+ devicep->screen = conf_device->dev_screen;
+
+ for (i = 0; i < MAXDACSPEEDS; i++) {
+ if (i < CONF_MAXDACSPEEDS)
+ devicep->dacSpeeds[i] = conf_device->dev_dacSpeeds[i];
+ else
+ devicep->dacSpeeds[i] = 0;
+ }
+ devicep->numclocks = conf_device->dev_clocks;
+ if (devicep->numclocks > MAXCLOCKS)
+ devicep->numclocks = MAXCLOCKS;
+ for (i = 0; i < devicep->numclocks; i++) {
+ devicep->clock[i] = conf_device->dev_clock[i];
+ }
+ devicep->claimed = FALSE;
+
+ return TRUE;
+}
+
+#ifdef XF86DRI
+static void
+configDRI(XF86ConfDRIPtr drip)
+{
+ struct group *grp;
+
+ xf86ConfigDRI.group = -1;
+ xf86ConfigDRI.mode = 0;
+
+ if (drip) {
+ if (drip->dri_group_name) {
+ if ((grp = getgrnam(drip->dri_group_name)))
+ xf86ConfigDRI.group = grp->gr_gid;
+ } else {
+ if (drip->dri_group >= 0)
+ xf86ConfigDRI.group = drip->dri_group;
+ }
+ xf86ConfigDRI.mode = drip->dri_mode;
+ }
+}
+#endif
+
+static void
+configExtensions(XF86ConfExtensionsPtr conf_ext)
+{
+ XF86OptionPtr o;
+
+ if (conf_ext && conf_ext->ext_option_lst) {
+ for (o = conf_ext->ext_option_lst; o; o = xf86NextOption(o)) {
+ char *name = xf86OptionName(o);
+ char *val = xf86OptionValue(o);
+ char *n;
+ Bool enable = TRUE;
+
+ /* Handle "No<ExtensionName>" */
+ n = xf86NormalizeName(name);
+ if (strncmp(n, "no", 2) == 0) {
+ name += 2;
+ enable = FALSE;
+ }
+
+ if (!val ||
+ xf86NameCmp(val, "enable") == 0 ||
+ xf86NameCmp(val, "enabled") == 0 ||
+ xf86NameCmp(val, "on") == 0 ||
+ xf86NameCmp(val, "1") == 0 ||
+ xf86NameCmp(val, "yes") == 0 ||
+ xf86NameCmp(val, "true") == 0) {
+ /* NOTHING NEEDED -- enabling is handled below */
+ } else if (xf86NameCmp(val, "disable") == 0 ||
+ xf86NameCmp(val, "disabled") == 0 ||
+ xf86NameCmp(val, "off") == 0 ||
+ xf86NameCmp(val, "0") == 0 ||
+ xf86NameCmp(val, "no") == 0 ||
+ xf86NameCmp(val, "false") == 0) {
+ enable = !enable;
+ } else {
+ xf86Msg(X_WARNING, "Ignoring unrecognized value \"%s\"\n", val);
+ free(n);
+ continue;
+ }
+
+ if (EnableDisableExtension(name, enable)) {
+ xf86Msg(X_CONFIG, "Extension \"%s\" is %s\n",
+ name, enable ? "enabled" : "disabled");
+ } else {
+ xf86Msg(X_WARNING, "Ignoring unrecognized extension \"%s\"\n",
+ name);
+ }
+ free(n);
+ }
+ }
+}
+
+static Bool
+configInput(InputInfoPtr inputp, XF86ConfInputPtr conf_input, MessageType from)
+{
+ xf86Msg(from, "|-->Input Device \"%s\"\n", conf_input->inp_identifier);
+ inputp->name = conf_input->inp_identifier;
+ inputp->driver = conf_input->inp_driver;
+ inputp->options = conf_input->inp_option_lst;
+ inputp->attrs = NULL;
+
+ return TRUE;
+}
+
+static Bool
+modeIsPresent(DisplayModePtr mode, MonPtr monitorp)
+{
+ DisplayModePtr knownmodes = monitorp->Modes;
+
+ /* all I can think of is a linear search... */
+ while(knownmodes != NULL)
+ {
+ if(!strcmp(mode->name, knownmodes->name) &&
+ !(knownmodes->type & M_T_DEFAULT))
+ return TRUE;
+ knownmodes = knownmodes->next;
+ }
+ return FALSE;
+}
+
+static Bool
+addDefaultModes(MonPtr monitorp)
+{
+ DisplayModePtr mode;
+ DisplayModePtr last = monitorp->Last;
+ int i = 0;
+
+ for (i = 0; i < xf86NumDefaultModes; i++)
+ {
+ mode = xf86DuplicateMode(&xf86DefaultModes[i]);
+ if (!modeIsPresent(mode, monitorp))
+ {
+ monitorp->Modes = xf86ModesAdd(monitorp->Modes, mode);
+ last = mode;
+ } else {
+ free(mode);
+ }
+ }
+ monitorp->Last = last;
+
+ return TRUE;
+}
+
+static void
+checkInput(serverLayoutPtr layout, Bool implicit_layout) {
+ checkCoreInputDevices(layout, implicit_layout);
+
+ /* Unless we're forcing input devices, disable mouse/kbd devices in the
+ * config. Otherwise the same physical device is added multiple times,
+ * leading to duplicate events.
+ */
+ if (!xf86Info.forceInputDevices && layout->inputs)
+ {
+ InputInfoPtr *dev = layout->inputs;
+ BOOL warned = FALSE;
+
+ while(*dev)
+ {
+ if (strcmp((*dev)->driver, "kbd") == 0 ||
+ strcmp((*dev)->driver, "mouse") == 0 ||
+ strcmp((*dev)->driver, "vmmouse") == 0)
+ {
+ InputInfoPtr *current;
+ if (!warned)
+ {
+ xf86Msg(X_WARNING, "Hotplugging is on, devices using "
+ "drivers 'kbd', 'mouse' or 'vmmouse' will be disabled.\n");
+ warned = TRUE;
+ }
+
+ xf86Msg(X_WARNING, "Disabling %s\n", (*dev)->name);
+
+ current = dev;
+ free(*dev);
+
+ do {
+ *current = *(current + 1);
+ current++;
+ } while(*current);
+ } else
+ dev++;
+ }
+ }
+}
+
+/*
+ * load the config file and fill the global data structure
+ */
+ConfigStatus
+xf86HandleConfigFile(Bool autoconfig)
+{
+ const char *filename, *dirname, *sysdirname;
+ char *filesearch, *dirsearch;
+ MessageType filefrom = X_DEFAULT;
+ MessageType dirfrom = X_DEFAULT;
+ char *scanptr;
+ Bool singlecard = 0;
+ Bool implicit_layout = FALSE;
+
+ if (!autoconfig) {
+ if (getuid() == 0) {
+ filesearch = ROOT_CONFIGPATH;
+ dirsearch = ROOT_CONFIGDIRPATH;
+ } else {
+ filesearch = USER_CONFIGPATH;
+ dirsearch = USER_CONFIGDIRPATH;
+ }
+
+ if (xf86ConfigFile)
+ filefrom = X_CMDLINE;
+ if (xf86ConfigDir)
+ dirfrom = X_CMDLINE;
+
+ xf86initConfigFiles();
+ sysdirname = xf86openConfigDirFiles(SYS_CONFIGDIRPATH, NULL,
+ PROJECTROOT);
+ dirname = xf86openConfigDirFiles(dirsearch, xf86ConfigDir, PROJECTROOT);
+ filename = xf86openConfigFile(filesearch, xf86ConfigFile, PROJECTROOT);
+ if (filename) {
+ xf86MsgVerb(filefrom, 0, "Using config file: \"%s\"\n", filename);
+ xf86ConfigFile = xnfstrdup(filename);
+ } else {
+ if (xf86ConfigFile)
+ xf86Msg(X_ERROR, "Unable to locate/open config file: \"%s\"\n",
+ xf86ConfigFile);
+ }
+ if (dirname) {
+ xf86MsgVerb(dirfrom, 0, "Using config directory: \"%s\"\n",
+ dirname);
+ xf86ConfigDir = xnfstrdup(dirname);
+ } else {
+ if (xf86ConfigDir)
+ xf86Msg(X_ERROR,
+ "Unable to locate/open config directory: \"%s\"\n",
+ xf86ConfigDir);
+ }
+ if (sysdirname)
+ xf86MsgVerb(X_DEFAULT, 0, "Using system config directory \"%s\"\n",
+ sysdirname);
+ if (!filename && !dirname && !sysdirname)
+ return CONFIG_NOFILE;
+ }
+
+ if ((xf86configptr = xf86readConfigFile ()) == NULL) {
+ xf86Msg(X_ERROR, "Problem parsing the config file\n");
+ return CONFIG_PARSE_ERROR;
+ }
+ xf86closeConfigFile ();
+
+ /* Initialise a few things. */
+
+ /*
+ * now we convert part of the information contained in the parser
+ * structures into our own structures.
+ * The important part here is to figure out which Screen Sections
+ * in the XF86Config file are active so that we can piece together
+ * the modes that we need later down the road.
+ * And while we are at it, we'll decode the rest of the stuff as well
+ */
+
+ /* First check if a layout section is present, and if it is valid. */
+
+ if (xf86configptr->conf_layout_lst == NULL || xf86ScreenName != NULL) {
+ if (xf86ScreenName == NULL) {
+ xf86Msg(X_DEFAULT,
+ "No Layout section. Using the first Screen section.\n");
+ }
+ if (!configImpliedLayout(&xf86ConfigLayout,
+ xf86configptr->conf_screen_lst,
+ xf86configptr)) {
+ xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
+ return CONFIG_PARSE_ERROR;
+ }
+ implicit_layout = TRUE;
+ } else {
+ if (xf86configptr->conf_flags != NULL) {
+ char *dfltlayout = NULL;
+ pointer optlist = xf86configptr->conf_flags->flg_option_lst;
+
+ if (optlist && xf86FindOption(optlist, "defaultserverlayout"))
+ dfltlayout = xf86SetStrOption(optlist, "defaultserverlayout", NULL);
+ if (!configLayout(&xf86ConfigLayout, xf86configptr->conf_layout_lst,
+ dfltlayout)) {
+ xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
+ return CONFIG_PARSE_ERROR;
+ }
+ } else {
+ if (!configLayout(&xf86ConfigLayout, xf86configptr->conf_layout_lst,
+ NULL)) {
+ xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
+ return CONFIG_PARSE_ERROR;
+ }
+ }
+ }
+
+ xf86ProcessOptions(-1, xf86ConfigLayout.options, LayoutOptions);
+
+ if ((scanptr = xf86GetOptValString(LayoutOptions, LAYOUT_ISOLATEDEVICE))) {
+ ; /* IsolateDevice specified; overrides SingleCard */
+ } else {
+ xf86GetOptValBool(LayoutOptions, LAYOUT_SINGLECARD, &singlecard);
+ if (singlecard)
+ scanptr = xf86ConfigLayout.screens->screen->device->busID;
+ }
+ if (scanptr) {
+ if (strncmp(scanptr, "PCI:", 4) != 0) {
+ xf86Msg(X_WARNING, "Bus types other than PCI not yet isolable.\n"
+ "\tIgnoring IsolateDevice option.\n");
+ } else
+ xf86PciIsolateDevice(scanptr);
+ }
+
+ /* Now process everything else */
+ if (!configServerFlags(xf86configptr->conf_flags,xf86ConfigLayout.options)){
+ ErrorF ("Problem when converting the config data structures\n");
+ return CONFIG_PARSE_ERROR;
+ }
+
+ configFiles(xf86configptr->conf_files);
+ configExtensions(xf86configptr->conf_extensions);
+#ifdef XF86DRI
+ configDRI(xf86configptr->conf_dri);
+#endif
+
+ checkInput(&xf86ConfigLayout, implicit_layout);
+
+ /*
+ * Handle some command line options that can override some of the
+ * ServerFlags settings.
+ */
+#ifdef XF86VIDMODE
+ if (xf86VidModeDisabled)
+ xf86Info.vidModeEnabled = FALSE;
+ if (xf86VidModeAllowNonLocal)
+ xf86Info.vidModeAllowNonLocal = TRUE;
+#endif
+
+ if (xf86AllowMouseOpenFail)
+ xf86Info.allowMouseOpenFail = TRUE;
+
+ return CONFIG_OK;
+}
+
+Bool
+xf86PathIsSafe(const char *path)
+{
+ return (xf86pathIsSafe(path) != 0);
+}
diff --git a/xorg-server/hw/xfree86/common/xf86Configure.c b/xorg-server/hw/xfree86/common/xf86Configure.c
index aabb8e11b..ab0751507 100644
--- a/xorg-server/hw/xfree86/common/xf86Configure.c
+++ b/xorg-server/hw/xfree86/common/xf86Configure.c
@@ -1,755 +1,755 @@
-/*
- * Copyright 2000-2002 by Alan Hourihane, Flint Mountain, North Wales.
- *
- * 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 Alan Hourihane not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Alan Hourihane makes no representations
- * about the suitability of this software for any purpose. It is provided
- * "as is" without express or implied warranty.
- *
- * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: Alan Hourihane, alanh@fairlite.demon.co.uk
- *
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86.h"
-#include "xf86Config.h"
-#include "xf86_OSlib.h"
-#include "xf86Priv.h"
-#define IN_XSERVER
-#include "Configint.h"
-#include "xf86DDC.h"
-#include "xf86pciBus.h"
-#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
-#include "xf86Bus.h"
-#include "xf86Sbus.h"
-#endif
-#include "misc.h"
-
-typedef struct _DevToConfig {
- GDevRec GDev;
- struct pci_device * pVideo;
-#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
- sbusDevicePtr sVideo;
-#endif
- int iDriver;
-} DevToConfigRec, *DevToConfigPtr;
-
-static DevToConfigPtr DevToConfig = NULL;
-static int nDevToConfig = 0, CurrentDriver;
-
-xf86MonPtr ConfiguredMonitor;
-Bool xf86DoConfigurePass1 = TRUE;
-static Bool foundMouse = FALSE;
-
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
-static char *DFLT_MOUSE_DEV = "/dev/sysmouse";
-static char *DFLT_MOUSE_PROTO = "auto";
-#elif defined(linux)
-static char DFLT_MOUSE_DEV[] = "/dev/input/mice";
-static char DFLT_MOUSE_PROTO[] = "auto";
-#elif defined(WSCONS_SUPPORT)
-static char *DFLT_MOUSE_DEV = "/dev/wsmouse";
-static char *DFLT_MOUSE_PROTO = "wsmouse";
-#else
-static char *DFLT_MOUSE_DEV = "/dev/mouse";
-static char *DFLT_MOUSE_PROTO = "auto";
-#endif
-
-/*
- * This is called by the driver, either through xf86Match???Instances() or
- * directly. We allocate a GDevRec and fill it in as much as we can, letting
- * the caller fill in the rest and/or change it as it sees fit.
- */
-GDevPtr
-xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int chipset)
-{
- int ret, i, j;
-
- if (!xf86DoConfigure || !xf86DoConfigurePass1)
- return NULL;
-
- /* Check for duplicates */
- for (i = 0; i < nDevToConfig; i++) {
- switch (bus) {
- case BUS_PCI:
- ret = xf86PciConfigure(busData, DevToConfig[i].pVideo);
- break;
-#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
- case BUS_SBUS:
- ret = xf86SbusConfigure(busData, DevToConfig[i].sVideo);
- break;
-#endif
- default:
- return NULL;
- }
- if (ret == 0)
- goto out;
- }
-
- /* Allocate new structure occurrence */
- i = nDevToConfig++;
- DevToConfig =
- xnfrealloc(DevToConfig, nDevToConfig * sizeof(DevToConfigRec));
- memset(DevToConfig + i, 0, sizeof(DevToConfigRec));
-
- DevToConfig[i].GDev.chipID =
- DevToConfig[i].GDev.chipRev = DevToConfig[i].GDev.irq = -1;
-
- DevToConfig[i].iDriver = CurrentDriver;
-
- /* Fill in what we know, converting the driver name to lower case */
- DevToConfig[i].GDev.driver = xnfalloc(strlen(driver) + 1);
- for (j = 0; (DevToConfig[i].GDev.driver[j] = tolower(driver[j])); j++);
-
- switch (bus) {
- case BUS_PCI:
- xf86PciConfigureNewDev(busData, DevToConfig[i].pVideo,
- &DevToConfig[i].GDev, &chipset);
- break;
-#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
- case BUS_SBUS:
- xf86SbusConfigureNewDev(busData, DevToConfig[i].sVideo,
- &DevToConfig[i].GDev);
- break;
-#endif
- default:
- break;
- }
-
- /* Get driver's available options */
- if (xf86DriverList[CurrentDriver]->AvailableOptions)
- DevToConfig[i].GDev.options = (OptionInfoPtr)
- (*xf86DriverList[CurrentDriver]->AvailableOptions)(chipset,
- bus);
-
- return &DevToConfig[i].GDev;
-
-out:
- return NULL;
-}
-
-static XF86ConfInputPtr
-configureInputSection (void)
-{
- XF86ConfInputPtr mouse = NULL;
- parsePrologue (XF86ConfInputPtr, XF86ConfInputRec)
-
- ptr->inp_identifier = "Keyboard0";
- ptr->inp_driver = "kbd";
- ptr->list.next = NULL;
-
- /* Crude mechanism to auto-detect mouse (os dependent) */
- {
- int fd;
-
- fd = open(DFLT_MOUSE_DEV, 0);
- if (fd != -1) {
- foundMouse = TRUE;
- close(fd);
- }
- }
-
- mouse = calloc(1, sizeof(XF86ConfInputRec));
- mouse->inp_identifier = "Mouse0";
- mouse->inp_driver = "mouse";
- mouse->inp_option_lst =
- xf86addNewOption(mouse->inp_option_lst, strdup("Protocol"),
- strdup(DFLT_MOUSE_PROTO));
- mouse->inp_option_lst =
- xf86addNewOption(mouse->inp_option_lst, strdup("Device"),
- strdup(DFLT_MOUSE_DEV));
- mouse->inp_option_lst =
- xf86addNewOption(mouse->inp_option_lst, strdup("ZAxisMapping"),
- strdup("4 5 6 7"));
- ptr = (XF86ConfInputPtr)xf86addListItem((glp)ptr, (glp)mouse);
- return ptr;
-}
-
-static XF86ConfScreenPtr
-configureScreenSection (int screennum)
-{
- int i;
- int depths[] = { 1, 4, 8, 15, 16, 24/*, 32*/ };
- parsePrologue (XF86ConfScreenPtr, XF86ConfScreenRec)
-
- XNFasprintf(&ptr->scrn_identifier, "Screen%d", screennum);
- XNFasprintf(&ptr->scrn_monitor_str, "Monitor%d", screennum);
- XNFasprintf(&ptr->scrn_device_str, "Card%d", screennum);
-
- for (i=0; i<sizeof(depths)/sizeof(depths[0]); i++)
- {
- XF86ConfDisplayPtr display;
-
- display = calloc(1, sizeof(XF86ConfDisplayRec));
- display->disp_depth = depths[i];
- display->disp_black.red = display->disp_white.red = -1;
- display->disp_black.green = display->disp_white.green = -1;
- display->disp_black.blue = display->disp_white.blue = -1;
- ptr->scrn_display_lst = (XF86ConfDisplayPtr)xf86addListItem(
- (glp)ptr->scrn_display_lst, (glp)display);
- }
-
- return ptr;
-}
-
-static const char*
-optionTypeToString(OptionValueType type)
-{
- switch (type) {
- case OPTV_NONE:
- return "";
- case OPTV_INTEGER:
- return "<i>";
- case OPTV_STRING:
- return "<str>";
- case OPTV_ANYSTR:
- return "[<str>]";
- case OPTV_REAL:
- return "<f>";
- case OPTV_BOOLEAN:
- return "[<bool>]";
- case OPTV_FREQ:
- return "<freq>";
- case OPTV_PERCENT:
- return "<percent>";
- default:
- return "";
- }
-}
-
-static XF86ConfDevicePtr
-configureDeviceSection (int screennum)
-{
- OptionInfoPtr p;
- int i = 0;
- parsePrologue (XF86ConfDevicePtr, XF86ConfDeviceRec)
-
- /* Move device info to parser structure */
- if (asprintf(&ptr->dev_identifier, "Card%d", screennum) == -1)
- ptr->dev_identifier = NULL;
- ptr->dev_chipset = DevToConfig[screennum].GDev.chipset;
- ptr->dev_busid = DevToConfig[screennum].GDev.busID;
- ptr->dev_driver = DevToConfig[screennum].GDev.driver;
- ptr->dev_ramdac = DevToConfig[screennum].GDev.ramdac;
- for (i = 0; (i < MAXDACSPEEDS) && (i < CONF_MAXDACSPEEDS); i++)
- ptr->dev_dacSpeeds[i] = DevToConfig[screennum].GDev.dacSpeeds[i];
- ptr->dev_videoram = DevToConfig[screennum].GDev.videoRam;
- ptr->dev_textclockfreq = DevToConfig[screennum].GDev.textClockFreq;
- ptr->dev_bios_base = DevToConfig[screennum].GDev.BiosBase;
- ptr->dev_mem_base = DevToConfig[screennum].GDev.MemBase;
- ptr->dev_io_base = DevToConfig[screennum].GDev.IOBase;
- ptr->dev_clockchip = DevToConfig[screennum].GDev.clockchip;
- for (i = 0; (i < MAXCLOCKS) && (i < DevToConfig[screennum].GDev.numclocks); i++)
- ptr->dev_clock[i] = DevToConfig[screennum].GDev.clock[i];
- ptr->dev_clocks = i;
- ptr->dev_chipid = DevToConfig[screennum].GDev.chipID;
- ptr->dev_chiprev = DevToConfig[screennum].GDev.chipRev;
- ptr->dev_irq = DevToConfig[screennum].GDev.irq;
-
- /* Make sure older drivers don't segv */
- if (DevToConfig[screennum].GDev.options) {
- /* Fill in the available driver options for people to use */
- const char *descrip =
- " ### Available Driver options are:-\n"
- " ### Values: <i>: integer, <f>: float, "
- "<bool>: \"True\"/\"False\",\n"
- " ### <string>: \"String\", <freq>: \"<f> Hz/kHz/MHz\",\n"
- " ### <percent>: \"<f>%\"\n"
- " ### [arg]: arg optional\n";
- ptr->dev_comment = strdup(descrip);
- if (ptr->dev_comment) {
- for (p = DevToConfig[screennum].GDev.options;
- p->name != NULL; p++) {
- char *p_e;
- const char *prefix = " #Option ";
- const char *middle = " \t# ";
- const char *suffix = "\n";
- const char *opttype = optionTypeToString(p->type);
- char *optname;
- int len = strlen(ptr->dev_comment) + strlen(prefix) +
- strlen(middle) + strlen(suffix) + 1;
-
- if (asprintf(&optname, "\"%s\"", p->name) == -1)
- break;
-
- len += max(20, strlen(optname));
- len += strlen(opttype);
-
- ptr->dev_comment = realloc(ptr->dev_comment, len);
- if (!ptr->dev_comment)
- break;
- p_e = ptr->dev_comment + strlen(ptr->dev_comment);
- sprintf(p_e, "%s%-20s%s%s%s", prefix, optname, middle,
- opttype, suffix);
- free(optname);
- }
- }
- }
-
- return ptr;
-}
-
-static XF86ConfLayoutPtr
-configureLayoutSection (void)
-{
- int scrnum = 0;
- parsePrologue (XF86ConfLayoutPtr, XF86ConfLayoutRec)
-
- ptr->lay_identifier = "X.org Configured";
-
- {
- XF86ConfInputrefPtr iptr;
-
- iptr = malloc (sizeof (XF86ConfInputrefRec));
- iptr->list.next = NULL;
- iptr->iref_option_lst = NULL;
- iptr->iref_inputdev_str = "Mouse0";
- iptr->iref_option_lst =
- xf86addNewOption (iptr->iref_option_lst, strdup("CorePointer"), NULL);
- ptr->lay_input_lst = (XF86ConfInputrefPtr)
- xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr);
- }
-
- {
- XF86ConfInputrefPtr iptr;
-
- iptr = malloc (sizeof (XF86ConfInputrefRec));
- iptr->list.next = NULL;
- iptr->iref_option_lst = NULL;
- iptr->iref_inputdev_str = "Keyboard0";
- iptr->iref_option_lst =
- xf86addNewOption (iptr->iref_option_lst, strdup("CoreKeyboard"), NULL);
- ptr->lay_input_lst = (XF86ConfInputrefPtr)
- xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr);
- }
-
- for (scrnum = 0; scrnum < nDevToConfig; scrnum++) {
- XF86ConfAdjacencyPtr aptr;
-
- aptr = malloc (sizeof (XF86ConfAdjacencyRec));
- aptr->list.next = NULL;
- aptr->adj_x = 0;
- aptr->adj_y = 0;
- aptr->adj_scrnum = scrnum;
- XNFasprintf(&aptr->adj_screen_str, "Screen%d", scrnum);
- if (scrnum == 0) {
- aptr->adj_where = CONF_ADJ_ABSOLUTE;
- aptr->adj_refscreen = NULL;
- }
- else {
- aptr->adj_where = CONF_ADJ_RIGHTOF;
- XNFasprintf(&aptr->adj_refscreen, "Screen%d", scrnum - 1);
- }
- ptr->lay_adjacency_lst =
- (XF86ConfAdjacencyPtr)xf86addListItem((glp)ptr->lay_adjacency_lst,
- (glp)aptr);
- }
-
- return ptr;
-}
-
-static XF86ConfFlagsPtr
-configureFlagsSection (void)
-{
- parsePrologue (XF86ConfFlagsPtr, XF86ConfFlagsRec)
-
- return ptr;
-}
-
-static XF86ConfModulePtr
-configureModuleSection (void)
-{
- char **elist, **el;
- /* Find the list of extension & font modules. */
- const char *esubdirs[] = {
- "extensions",
- "fonts",
- NULL
- };
- parsePrologue (XF86ConfModulePtr, XF86ConfModuleRec)
-
- elist = LoaderListDirs(esubdirs, NULL);
- if (elist) {
- for (el = elist; *el; el++) {
- XF86LoadPtr module;
-
- module = calloc(1, sizeof(XF86LoadRec));
- module->load_name = *el;
- ptr->mod_load_lst = (XF86LoadPtr)xf86addListItem(
- (glp)ptr->mod_load_lst, (glp)module);
- }
- free(elist);
- }
-
- return ptr;
-}
-
-static XF86ConfFilesPtr
-configureFilesSection (void)
-{
- parsePrologue (XF86ConfFilesPtr, XF86ConfFilesRec)
-
- if (xf86ModulePath)
- ptr->file_modulepath = strdup(xf86ModulePath);
- if (defaultFontPath)
- ptr->file_fontpath = strdup(defaultFontPath);
-
- return ptr;
-}
-
-static XF86ConfMonitorPtr
-configureMonitorSection (int screennum)
-{
- parsePrologue (XF86ConfMonitorPtr, XF86ConfMonitorRec)
-
- XNFasprintf(&ptr->mon_identifier, "Monitor%d", screennum);
- ptr->mon_vendor = strdup("Monitor Vendor");
- ptr->mon_modelname = strdup("Monitor Model");
-
- return ptr;
-}
-
-/* Initialize Configure Monitor from Detailed Timing Block */
-static void handle_detailed_input(struct detailed_monitor_section *det_mon,
- void *data)
-{
- XF86ConfMonitorPtr ptr = (XF86ConfMonitorPtr) data;
-
- switch (det_mon->type) {
- case DS_NAME:
- ptr->mon_modelname = realloc(ptr->mon_modelname,
- strlen((char*)(det_mon->section.name)) +
- 1);
- strcpy(ptr->mon_modelname,
- (char*)(det_mon->section.name));
- break;
- case DS_RANGES:
- ptr->mon_hsync[ptr->mon_n_hsync].lo =
- det_mon->section.ranges.min_h;
- ptr->mon_hsync[ptr->mon_n_hsync].hi =
- det_mon->section.ranges.max_h;
- ptr->mon_n_vrefresh = 1;
- ptr->mon_vrefresh[ptr->mon_n_hsync].lo =
- det_mon->section.ranges.min_v;
- ptr->mon_vrefresh[ptr->mon_n_hsync].hi =
- det_mon->section.ranges.max_v;
- ptr->mon_n_hsync++;
- default:
- break;
- }
-}
-
-static XF86ConfMonitorPtr
-configureDDCMonitorSection (int screennum)
-{
- int len, mon_width, mon_height;
-#define displaySizeMaxLen 80
- char displaySize_string[displaySizeMaxLen];
- int displaySizeLen;
-
- parsePrologue (XF86ConfMonitorPtr, XF86ConfMonitorRec)
-
- XNFasprintf(&ptr->mon_identifier, "Monitor%d", screennum);
- ptr->mon_vendor = strdup(ConfiguredMonitor->vendor.name);
- XNFasprintf(&ptr->mon_modelname, "%x", ConfiguredMonitor->vendor.prod_id);
-
- /* features in centimetres, we want millimetres */
- mon_width = 10 * ConfiguredMonitor->features.hsize ;
- mon_height = 10 * ConfiguredMonitor->features.vsize ;
-
-#ifdef CONFIGURE_DISPLAYSIZE
- ptr->mon_width = mon_width;
- ptr->mon_height = mon_height;
-#else
- if (mon_width && mon_height) {
- /* when values available add DisplaySize option AS A COMMENT */
-
- displaySizeLen = snprintf(displaySize_string, displaySizeMaxLen,
- "\t#DisplaySize\t%5d %5d\t# mm\n",
- mon_width, mon_height);
-
- if (displaySizeLen>0 && displaySizeLen<displaySizeMaxLen) {
- if (ptr->mon_comment) {
- len = strlen(ptr->mon_comment);
- } else {
- len = 0;
- }
- if ((ptr->mon_comment =
- realloc(ptr->mon_comment, len + strlen(displaySize_string) + 1))) {
- strcpy(ptr->mon_comment + len, displaySize_string);
- }
- }
- }
-#endif /* def CONFIGURE_DISPLAYSIZE */
-
- xf86ForEachDetailedBlock(ConfiguredMonitor, handle_detailed_input,
- ptr);
-
- if (ConfiguredMonitor->features.dpms) {
- ptr->mon_option_lst = xf86addNewOption(ptr->mon_option_lst, strdup("DPMS"), NULL);
- }
-
- return ptr;
-}
-
-void
-DoConfigure(void)
-{
- int i,j, screennum = -1;
- char *home = NULL;
- char filename[PATH_MAX];
- char *addslash = "";
- XF86ConfigPtr xf86config = NULL;
- char **vlist, **vl;
- int *dev2screen;
-
- vlist = xf86DriverlistFromCompile();
-
- if (!vlist) {
- ErrorF("Missing output drivers. Configuration failed.\n");
- goto bail;
- }
-
- ErrorF("List of video drivers:\n");
- for (vl = vlist; *vl; vl++)
- ErrorF("\t%s\n", *vl);
-
- /* Load all the drivers that were found. */
- xf86LoadModules(vlist, NULL);
-
- free(vlist);
-
- for (i = 0; i < xf86NumDrivers; i++) {
- xorgHWFlags flags;
- if (!xf86DriverList[i]->driverFunc
- || !xf86DriverList[i]->driverFunc(NULL,
- GET_REQUIRED_HW_INTERFACES,
- &flags)
- || NEED_IO_ENABLED(flags)) {
- xorgHWAccess = TRUE;
- break;
- }
- }
- /* Enable full I/O access */
- if (xorgHWAccess) {
- if(!xf86EnableIO())
- /* oops, we have failed */
- xorgHWAccess = FALSE;
- }
-
- /* Create XF86Config file structure */
- xf86config = calloc(1, sizeof(XF86ConfigRec));
-
- /* Call all of the probe functions, reporting the results. */
- for (CurrentDriver = 0; CurrentDriver < xf86NumDrivers; CurrentDriver++) {
- xorgHWFlags flags;
- Bool found_screen;
- DriverRec * const drv = xf86DriverList[CurrentDriver];
-
- if (!xorgHWAccess) {
- if (!drv->driverFunc
- || !drv->driverFunc( NULL, GET_REQUIRED_HW_INTERFACES, &flags )
- || NEED_IO_ENABLED(flags))
- continue;
- }
-
- found_screen = xf86CallDriverProbe( drv, TRUE );
- if ( found_screen && drv->Identify ) {
- (*drv->Identify)(0);
- }
- }
-
- if (nDevToConfig <= 0) {
- ErrorF("No devices to configure. Configuration failed.\n");
- goto bail;
- }
-
- /* Add device, monitor and screen sections for detected devices */
- for (screennum = 0; screennum < nDevToConfig; screennum++) {
- XF86ConfDevicePtr DevicePtr;
- XF86ConfMonitorPtr MonitorPtr;
- XF86ConfScreenPtr ScreenPtr;
-
- DevicePtr = configureDeviceSection(screennum);
- xf86config->conf_device_lst = (XF86ConfDevicePtr)xf86addListItem(
- (glp)xf86config->conf_device_lst, (glp)DevicePtr);
- MonitorPtr = configureMonitorSection(screennum);
- xf86config->conf_monitor_lst = (XF86ConfMonitorPtr)xf86addListItem(
- (glp)xf86config->conf_monitor_lst, (glp)MonitorPtr);
- ScreenPtr = configureScreenSection(screennum);
- xf86config->conf_screen_lst = (XF86ConfScreenPtr)xf86addListItem(
- (glp)xf86config->conf_screen_lst, (glp)ScreenPtr);
- }
-
- xf86config->conf_files = configureFilesSection();
- xf86config->conf_modules = configureModuleSection();
- xf86config->conf_flags = configureFlagsSection();
- xf86config->conf_videoadaptor_lst = NULL;
- xf86config->conf_modes_lst = NULL;
- xf86config->conf_vendor_lst = NULL;
- xf86config->conf_dri = NULL;
- xf86config->conf_input_lst = configureInputSection();
- xf86config->conf_layout_lst = configureLayoutSection();
-
- home = getenv("HOME");
- if ((home == NULL) || (home[0] == '\0')) {
- home = "/";
- } else {
- /* Determine if trailing slash is present or needed */
- int l = strlen(home);
-
- if (home[l-1] != '/') {
- addslash = "/";
- }
- }
-
- snprintf(filename, sizeof(filename), "%s%s" XF86CONFIGFILE ".new",
- home, addslash);
-
- if (xf86writeConfigFile(filename, xf86config) == 0) {
- xf86Msg(X_ERROR, "Unable to write config file: \"%s\": %s\n",
- filename, strerror(errno));
- goto bail;
- }
-
- xf86DoConfigurePass1 = FALSE;
- /* Try to get DDC information filled in */
- xf86ConfigFile = filename;
- if (xf86HandleConfigFile(FALSE) != CONFIG_OK) {
- goto bail;
- }
-
- xf86DoConfigurePass1 = FALSE;
-
- dev2screen = xnfcalloc(1,xf86NumDrivers*sizeof(int));
-
- {
- Bool *driverProbed = xnfcalloc(1,xf86NumDrivers*sizeof(Bool));
- for (screennum = 0; screennum < nDevToConfig; screennum++) {
- int k,l,n,oldNumScreens;
-
- i = DevToConfig[screennum].iDriver;
-
- if (driverProbed[i]) continue;
- driverProbed[i] = TRUE;
-
- oldNumScreens = xf86NumScreens;
-
- xf86CallDriverProbe( xf86DriverList[i], FALSE );
-
- /* reorder */
- k = screennum > 0 ? screennum : 1;
- for (l = oldNumScreens; l < xf86NumScreens; l++) {
- /* is screen primary? */
- Bool primary = FALSE;
- for (n = 0; n<xf86Screens[l]->numEntities; n++) {
- if (xf86IsEntityPrimary(xf86Screens[l]->entityList[n])) {
- dev2screen[0] = l;
- primary = TRUE;
- break;
- }
- }
- if (primary) continue;
- /* not primary: assign it to next device of same driver */
- /*
- * NOTE: we assume that devices in DevToConfig
- * and xf86Screens[] have the same order except
- * for the primary device which always comes first.
- */
- for (; k < nDevToConfig; k++) {
- if (DevToConfig[k].iDriver == i) {
- dev2screen[k++] = l;
- break;
- }
- }
- }
- }
- free(driverProbed);
- }
-
-
- if (nDevToConfig != xf86NumScreens) {
- ErrorF("Number of created screens does not match number of detected"
- " devices.\n Configuration failed.\n");
- goto bail;
- }
-
- xf86PostProbe();
-
- for (j = 0; j < xf86NumScreens; j++) {
- xf86Screens[j]->scrnIndex = j;
- }
-
- xf86freeMonitorList(xf86config->conf_monitor_lst);
- xf86config->conf_monitor_lst = NULL;
- xf86freeScreenList(xf86config->conf_screen_lst);
- xf86config->conf_screen_lst = NULL;
- for (j = 0; j < xf86NumScreens; j++) {
- XF86ConfMonitorPtr MonitorPtr;
- XF86ConfScreenPtr ScreenPtr;
-
- ConfiguredMonitor = NULL;
-
- if ((*xf86Screens[dev2screen[j]]->PreInit)(xf86Screens[dev2screen[j]],
- PROBE_DETECT) &&
- ConfiguredMonitor) {
- MonitorPtr = configureDDCMonitorSection(j);
- } else {
- MonitorPtr = configureMonitorSection(j);
- }
- ScreenPtr = configureScreenSection(j);
- xf86config->conf_monitor_lst = (XF86ConfMonitorPtr)xf86addListItem(
- (glp)xf86config->conf_monitor_lst, (glp)MonitorPtr);
- xf86config->conf_screen_lst = (XF86ConfScreenPtr)xf86addListItem(
- (glp)xf86config->conf_screen_lst, (glp)ScreenPtr);
- }
-
- if (xf86writeConfigFile(filename, xf86config) == 0) {
- xf86Msg(X_ERROR, "Unable to write config file: \"%s\": %s\n",
- filename, strerror(errno));
- goto bail;
- }
-
- ErrorF("\n");
-
- if (!foundMouse) {
- ErrorF("\n"__XSERVERNAME__" is not able to detect your mouse.\n"
- "Edit the file and correct the Device.\n");
- } else {
- ErrorF("\n"__XSERVERNAME__" detected your mouse at device %s.\n"
- "Please check your config if the mouse is still not\n"
- "operational, as by default "__XSERVERNAME__
- " tries to autodetect\n"
- "the protocol.\n",DFLT_MOUSE_DEV);
- }
-
- if (xf86NumScreens > 1) {
- ErrorF("\n"__XSERVERNAME__
- " has configured a multihead system, please check your config.\n");
- }
-
- ErrorF("\nYour %s file is %s\n\n", XF86CONFIGFILE ,filename);
- ErrorF("To test the server, run 'X -config %s'\n\n", filename);
-
-bail:
- OsCleanup(TRUE);
- AbortDDX(EXIT_ERR_CONFIGURE);
- fflush(stderr);
- exit(0);
-}
+/*
+ * Copyright 2000-2002 by Alan Hourihane, Flint Mountain, North Wales.
+ *
+ * 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 Alan Hourihane not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Alan Hourihane makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Alan Hourihane, alanh@fairlite.demon.co.uk
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#include "xf86Config.h"
+#include "xf86_OSlib.h"
+#include "xf86Priv.h"
+#define IN_XSERVER
+#include "Configint.h"
+#include "xf86DDC.h"
+#include "xf86pciBus.h"
+#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
+#include "xf86Bus.h"
+#include "xf86Sbus.h"
+#endif
+#include "misc.h"
+
+typedef struct _DevToConfig {
+ GDevRec GDev;
+ struct pci_device * pVideo;
+#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
+ sbusDevicePtr sVideo;
+#endif
+ int iDriver;
+} DevToConfigRec, *DevToConfigPtr;
+
+static DevToConfigPtr DevToConfig = NULL;
+static int nDevToConfig = 0, CurrentDriver;
+
+xf86MonPtr ConfiguredMonitor;
+Bool xf86DoConfigurePass1 = TRUE;
+static Bool foundMouse = FALSE;
+
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
+static char *DFLT_MOUSE_DEV = "/dev/sysmouse";
+static char *DFLT_MOUSE_PROTO = "auto";
+#elif defined(linux)
+static char DFLT_MOUSE_DEV[] = "/dev/input/mice";
+static char DFLT_MOUSE_PROTO[] = "auto";
+#elif defined(WSCONS_SUPPORT)
+static char *DFLT_MOUSE_DEV = "/dev/wsmouse";
+static char *DFLT_MOUSE_PROTO = "wsmouse";
+#else
+static char *DFLT_MOUSE_DEV = "/dev/mouse";
+static char *DFLT_MOUSE_PROTO = "auto";
+#endif
+
+/*
+ * This is called by the driver, either through xf86Match???Instances() or
+ * directly. We allocate a GDevRec and fill it in as much as we can, letting
+ * the caller fill in the rest and/or change it as it sees fit.
+ */
+GDevPtr
+xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int chipset)
+{
+ int ret, i, j;
+
+ if (!xf86DoConfigure || !xf86DoConfigurePass1)
+ return NULL;
+
+ /* Check for duplicates */
+ for (i = 0; i < nDevToConfig; i++) {
+ switch (bus) {
+ case BUS_PCI:
+ ret = xf86PciConfigure(busData, DevToConfig[i].pVideo);
+ break;
+#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
+ case BUS_SBUS:
+ ret = xf86SbusConfigure(busData, DevToConfig[i].sVideo);
+ break;
+#endif
+ default:
+ return NULL;
+ }
+ if (ret == 0)
+ goto out;
+ }
+
+ /* Allocate new structure occurrence */
+ i = nDevToConfig++;
+ DevToConfig =
+ xnfrealloc(DevToConfig, nDevToConfig * sizeof(DevToConfigRec));
+ memset(DevToConfig + i, 0, sizeof(DevToConfigRec));
+
+ DevToConfig[i].GDev.chipID =
+ DevToConfig[i].GDev.chipRev = DevToConfig[i].GDev.irq = -1;
+
+ DevToConfig[i].iDriver = CurrentDriver;
+
+ /* Fill in what we know, converting the driver name to lower case */
+ DevToConfig[i].GDev.driver = xnfalloc(strlen(driver) + 1);
+ for (j = 0; (DevToConfig[i].GDev.driver[j] = tolower(driver[j])); j++);
+
+ switch (bus) {
+ case BUS_PCI:
+ xf86PciConfigureNewDev(busData, DevToConfig[i].pVideo,
+ &DevToConfig[i].GDev, &chipset);
+ break;
+#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
+ case BUS_SBUS:
+ xf86SbusConfigureNewDev(busData, DevToConfig[i].sVideo,
+ &DevToConfig[i].GDev);
+ break;
+#endif
+ default:
+ break;
+ }
+
+ /* Get driver's available options */
+ if (xf86DriverList[CurrentDriver]->AvailableOptions)
+ DevToConfig[i].GDev.options = (OptionInfoPtr)
+ (*xf86DriverList[CurrentDriver]->AvailableOptions)(chipset,
+ bus);
+
+ return &DevToConfig[i].GDev;
+
+out:
+ return NULL;
+}
+
+static XF86ConfInputPtr
+configureInputSection (void)
+{
+ XF86ConfInputPtr mouse = NULL;
+ parsePrologue (XF86ConfInputPtr, XF86ConfInputRec)
+
+ ptr->inp_identifier = "Keyboard0";
+ ptr->inp_driver = "kbd";
+ ptr->list.next = NULL;
+
+ /* Crude mechanism to auto-detect mouse (os dependent) */
+ {
+ int fd;
+
+ fd = open(DFLT_MOUSE_DEV, 0);
+ if (fd != -1) {
+ foundMouse = TRUE;
+ close(fd);
+ }
+ }
+
+ mouse = calloc(1, sizeof(XF86ConfInputRec));
+ mouse->inp_identifier = "Mouse0";
+ mouse->inp_driver = "mouse";
+ mouse->inp_option_lst =
+ xf86addNewOption(mouse->inp_option_lst, strdup("Protocol"),
+ strdup(DFLT_MOUSE_PROTO));
+ mouse->inp_option_lst =
+ xf86addNewOption(mouse->inp_option_lst, strdup("Device"),
+ strdup(DFLT_MOUSE_DEV));
+ mouse->inp_option_lst =
+ xf86addNewOption(mouse->inp_option_lst, strdup("ZAxisMapping"),
+ strdup("4 5 6 7"));
+ ptr = (XF86ConfInputPtr)xf86addListItem((glp)ptr, (glp)mouse);
+ return ptr;
+}
+
+static XF86ConfScreenPtr
+configureScreenSection (int screennum)
+{
+ int i;
+ int depths[] = { 1, 4, 8, 15, 16, 24/*, 32*/ };
+ parsePrologue (XF86ConfScreenPtr, XF86ConfScreenRec)
+
+ XNFasprintf(&ptr->scrn_identifier, "Screen%d", screennum);
+ XNFasprintf(&ptr->scrn_monitor_str, "Monitor%d", screennum);
+ XNFasprintf(&ptr->scrn_device_str, "Card%d", screennum);
+
+ for (i=0; i<sizeof(depths)/sizeof(depths[0]); i++)
+ {
+ XF86ConfDisplayPtr display;
+
+ display = calloc(1, sizeof(XF86ConfDisplayRec));
+ display->disp_depth = depths[i];
+ display->disp_black.red = display->disp_white.red = -1;
+ display->disp_black.green = display->disp_white.green = -1;
+ display->disp_black.blue = display->disp_white.blue = -1;
+ ptr->scrn_display_lst = (XF86ConfDisplayPtr)xf86addListItem(
+ (glp)ptr->scrn_display_lst, (glp)display);
+ }
+
+ return ptr;
+}
+
+static const char*
+optionTypeToString(OptionValueType type)
+{
+ switch (type) {
+ case OPTV_NONE:
+ return "";
+ case OPTV_INTEGER:
+ return "<i>";
+ case OPTV_STRING:
+ return "<str>";
+ case OPTV_ANYSTR:
+ return "[<str>]";
+ case OPTV_REAL:
+ return "<f>";
+ case OPTV_BOOLEAN:
+ return "[<bool>]";
+ case OPTV_FREQ:
+ return "<freq>";
+ case OPTV_PERCENT:
+ return "<percent>";
+ default:
+ return "";
+ }
+}
+
+static XF86ConfDevicePtr
+configureDeviceSection (int screennum)
+{
+ OptionInfoPtr p;
+ int i = 0;
+ parsePrologue (XF86ConfDevicePtr, XF86ConfDeviceRec)
+
+ /* Move device info to parser structure */
+ if (asprintf(&ptr->dev_identifier, "Card%d", screennum) == -1)
+ ptr->dev_identifier = NULL;
+ ptr->dev_chipset = DevToConfig[screennum].GDev.chipset;
+ ptr->dev_busid = DevToConfig[screennum].GDev.busID;
+ ptr->dev_driver = DevToConfig[screennum].GDev.driver;
+ ptr->dev_ramdac = DevToConfig[screennum].GDev.ramdac;
+ for (i = 0; (i < MAXDACSPEEDS) && (i < CONF_MAXDACSPEEDS); i++)
+ ptr->dev_dacSpeeds[i] = DevToConfig[screennum].GDev.dacSpeeds[i];
+ ptr->dev_videoram = DevToConfig[screennum].GDev.videoRam;
+ ptr->dev_textclockfreq = DevToConfig[screennum].GDev.textClockFreq;
+ ptr->dev_bios_base = DevToConfig[screennum].GDev.BiosBase;
+ ptr->dev_mem_base = DevToConfig[screennum].GDev.MemBase;
+ ptr->dev_io_base = DevToConfig[screennum].GDev.IOBase;
+ ptr->dev_clockchip = DevToConfig[screennum].GDev.clockchip;
+ for (i = 0; (i < MAXCLOCKS) && (i < DevToConfig[screennum].GDev.numclocks); i++)
+ ptr->dev_clock[i] = DevToConfig[screennum].GDev.clock[i];
+ ptr->dev_clocks = i;
+ ptr->dev_chipid = DevToConfig[screennum].GDev.chipID;
+ ptr->dev_chiprev = DevToConfig[screennum].GDev.chipRev;
+ ptr->dev_irq = DevToConfig[screennum].GDev.irq;
+
+ /* Make sure older drivers don't segv */
+ if (DevToConfig[screennum].GDev.options) {
+ /* Fill in the available driver options for people to use */
+ const char *descrip =
+ " ### Available Driver options are:-\n"
+ " ### Values: <i>: integer, <f>: float, "
+ "<bool>: \"True\"/\"False\",\n"
+ " ### <string>: \"String\", <freq>: \"<f> Hz/kHz/MHz\",\n"
+ " ### <percent>: \"<f>%\"\n"
+ " ### [arg]: arg optional\n";
+ ptr->dev_comment = strdup(descrip);
+ if (ptr->dev_comment) {
+ for (p = DevToConfig[screennum].GDev.options;
+ p->name != NULL; p++) {
+ char *p_e;
+ const char *prefix = " #Option ";
+ const char *middle = " \t# ";
+ const char *suffix = "\n";
+ const char *opttype = optionTypeToString(p->type);
+ char *optname;
+ int len = strlen(ptr->dev_comment) + strlen(prefix) +
+ strlen(middle) + strlen(suffix) + 1;
+
+ if (asprintf(&optname, "\"%s\"", p->name) == -1)
+ break;
+
+ len += max(20, strlen(optname));
+ len += strlen(opttype);
+
+ ptr->dev_comment = realloc(ptr->dev_comment, len);
+ if (!ptr->dev_comment)
+ break;
+ p_e = ptr->dev_comment + strlen(ptr->dev_comment);
+ sprintf(p_e, "%s%-20s%s%s%s", prefix, optname, middle,
+ opttype, suffix);
+ free(optname);
+ }
+ }
+ }
+
+ return ptr;
+}
+
+static XF86ConfLayoutPtr
+configureLayoutSection (void)
+{
+ int scrnum = 0;
+ parsePrologue (XF86ConfLayoutPtr, XF86ConfLayoutRec)
+
+ ptr->lay_identifier = "X.org Configured";
+
+ {
+ XF86ConfInputrefPtr iptr;
+
+ iptr = malloc (sizeof (XF86ConfInputrefRec));
+ iptr->list.next = NULL;
+ iptr->iref_option_lst = NULL;
+ iptr->iref_inputdev_str = "Mouse0";
+ iptr->iref_option_lst =
+ xf86addNewOption (iptr->iref_option_lst, strdup("CorePointer"), NULL);
+ ptr->lay_input_lst = (XF86ConfInputrefPtr)
+ xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr);
+ }
+
+ {
+ XF86ConfInputrefPtr iptr;
+
+ iptr = malloc (sizeof (XF86ConfInputrefRec));
+ iptr->list.next = NULL;
+ iptr->iref_option_lst = NULL;
+ iptr->iref_inputdev_str = "Keyboard0";
+ iptr->iref_option_lst =
+ xf86addNewOption (iptr->iref_option_lst, strdup("CoreKeyboard"), NULL);
+ ptr->lay_input_lst = (XF86ConfInputrefPtr)
+ xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr);
+ }
+
+ for (scrnum = 0; scrnum < nDevToConfig; scrnum++) {
+ XF86ConfAdjacencyPtr aptr;
+
+ aptr = malloc (sizeof (XF86ConfAdjacencyRec));
+ aptr->list.next = NULL;
+ aptr->adj_x = 0;
+ aptr->adj_y = 0;
+ aptr->adj_scrnum = scrnum;
+ XNFasprintf(&aptr->adj_screen_str, "Screen%d", scrnum);
+ if (scrnum == 0) {
+ aptr->adj_where = CONF_ADJ_ABSOLUTE;
+ aptr->adj_refscreen = NULL;
+ }
+ else {
+ aptr->adj_where = CONF_ADJ_RIGHTOF;
+ XNFasprintf(&aptr->adj_refscreen, "Screen%d", scrnum - 1);
+ }
+ ptr->lay_adjacency_lst =
+ (XF86ConfAdjacencyPtr)xf86addListItem((glp)ptr->lay_adjacency_lst,
+ (glp)aptr);
+ }
+
+ return ptr;
+}
+
+static XF86ConfFlagsPtr
+configureFlagsSection (void)
+{
+ parsePrologue (XF86ConfFlagsPtr, XF86ConfFlagsRec)
+
+ return ptr;
+}
+
+static XF86ConfModulePtr
+configureModuleSection (void)
+{
+ char **elist, **el;
+ /* Find the list of extension & font modules. */
+ const char *esubdirs[] = {
+ "extensions",
+ "fonts",
+ NULL
+ };
+ parsePrologue (XF86ConfModulePtr, XF86ConfModuleRec)
+
+ elist = LoaderListDirs(esubdirs, NULL);
+ if (elist) {
+ for (el = elist; *el; el++) {
+ XF86LoadPtr module;
+
+ module = calloc(1, sizeof(XF86LoadRec));
+ module->load_name = *el;
+ ptr->mod_load_lst = (XF86LoadPtr)xf86addListItem(
+ (glp)ptr->mod_load_lst, (glp)module);
+ }
+ free(elist);
+ }
+
+ return ptr;
+}
+
+static XF86ConfFilesPtr
+configureFilesSection (void)
+{
+ parsePrologue (XF86ConfFilesPtr, XF86ConfFilesRec)
+
+ if (xf86ModulePath)
+ ptr->file_modulepath = strdup(xf86ModulePath);
+ if (defaultFontPath)
+ ptr->file_fontpath = strdup(defaultFontPath);
+
+ return ptr;
+}
+
+static XF86ConfMonitorPtr
+configureMonitorSection (int screennum)
+{
+ parsePrologue (XF86ConfMonitorPtr, XF86ConfMonitorRec)
+
+ XNFasprintf(&ptr->mon_identifier, "Monitor%d", screennum);
+ ptr->mon_vendor = strdup("Monitor Vendor");
+ ptr->mon_modelname = strdup("Monitor Model");
+
+ return ptr;
+}
+
+/* Initialize Configure Monitor from Detailed Timing Block */
+static void handle_detailed_input(struct detailed_monitor_section *det_mon,
+ void *data)
+{
+ XF86ConfMonitorPtr ptr = (XF86ConfMonitorPtr) data;
+
+ switch (det_mon->type) {
+ case DS_NAME:
+ ptr->mon_modelname = realloc(ptr->mon_modelname,
+ strlen((char*)(det_mon->section.name)) +
+ 1);
+ strcpy(ptr->mon_modelname,
+ (char*)(det_mon->section.name));
+ break;
+ case DS_RANGES:
+ ptr->mon_hsync[ptr->mon_n_hsync].lo =
+ det_mon->section.ranges.min_h;
+ ptr->mon_hsync[ptr->mon_n_hsync].hi =
+ det_mon->section.ranges.max_h;
+ ptr->mon_n_vrefresh = 1;
+ ptr->mon_vrefresh[ptr->mon_n_hsync].lo =
+ det_mon->section.ranges.min_v;
+ ptr->mon_vrefresh[ptr->mon_n_hsync].hi =
+ det_mon->section.ranges.max_v;
+ ptr->mon_n_hsync++;
+ default:
+ break;
+ }
+}
+
+static XF86ConfMonitorPtr
+configureDDCMonitorSection (int screennum)
+{
+ int len, mon_width, mon_height;
+#define displaySizeMaxLen 80
+ char displaySize_string[displaySizeMaxLen];
+ int displaySizeLen;
+
+ parsePrologue (XF86ConfMonitorPtr, XF86ConfMonitorRec)
+
+ XNFasprintf(&ptr->mon_identifier, "Monitor%d", screennum);
+ ptr->mon_vendor = strdup(ConfiguredMonitor->vendor.name);
+ XNFasprintf(&ptr->mon_modelname, "%x", ConfiguredMonitor->vendor.prod_id);
+
+ /* features in centimetres, we want millimetres */
+ mon_width = 10 * ConfiguredMonitor->features.hsize ;
+ mon_height = 10 * ConfiguredMonitor->features.vsize ;
+
+#ifdef CONFIGURE_DISPLAYSIZE
+ ptr->mon_width = mon_width;
+ ptr->mon_height = mon_height;
+#else
+ if (mon_width && mon_height) {
+ /* when values available add DisplaySize option AS A COMMENT */
+
+ displaySizeLen = snprintf(displaySize_string, displaySizeMaxLen,
+ "\t#DisplaySize\t%5d %5d\t# mm\n",
+ mon_width, mon_height);
+
+ if (displaySizeLen>0 && displaySizeLen<displaySizeMaxLen) {
+ if (ptr->mon_comment) {
+ len = strlen(ptr->mon_comment);
+ } else {
+ len = 0;
+ }
+ if ((ptr->mon_comment =
+ realloc(ptr->mon_comment, len + strlen(displaySize_string) + 1))) {
+ strcpy(ptr->mon_comment + len, displaySize_string);
+ }
+ }
+ }
+#endif /* def CONFIGURE_DISPLAYSIZE */
+
+ xf86ForEachDetailedBlock(ConfiguredMonitor, handle_detailed_input,
+ ptr);
+
+ if (ConfiguredMonitor->features.dpms) {
+ ptr->mon_option_lst = xf86addNewOption(ptr->mon_option_lst, strdup("DPMS"), NULL);
+ }
+
+ return ptr;
+}
+
+void
+DoConfigure(void)
+{
+ int i,j, screennum = -1;
+ char *home = NULL;
+ char filename[PATH_MAX];
+ char *addslash = "";
+ XF86ConfigPtr xf86config = NULL;
+ char **vlist, **vl;
+ int *dev2screen;
+
+ vlist = xf86DriverlistFromCompile();
+
+ if (!vlist) {
+ ErrorF("Missing output drivers. Configuration failed.\n");
+ goto bail;
+ }
+
+ ErrorF("List of video drivers:\n");
+ for (vl = vlist; *vl; vl++)
+ ErrorF("\t%s\n", *vl);
+
+ /* Load all the drivers that were found. */
+ xf86LoadModules(vlist, NULL);
+
+ free(vlist);
+
+ for (i = 0; i < xf86NumDrivers; i++) {
+ xorgHWFlags flags;
+ if (!xf86DriverList[i]->driverFunc
+ || !xf86DriverList[i]->driverFunc(NULL,
+ GET_REQUIRED_HW_INTERFACES,
+ &flags)
+ || NEED_IO_ENABLED(flags)) {
+ xorgHWAccess = TRUE;
+ break;
+ }
+ }
+ /* Enable full I/O access */
+ if (xorgHWAccess) {
+ if(!xf86EnableIO())
+ /* oops, we have failed */
+ xorgHWAccess = FALSE;
+ }
+
+ /* Create XF86Config file structure */
+ xf86config = calloc(1, sizeof(XF86ConfigRec));
+
+ /* Call all of the probe functions, reporting the results. */
+ for (CurrentDriver = 0; CurrentDriver < xf86NumDrivers; CurrentDriver++) {
+ xorgHWFlags flags;
+ Bool found_screen;
+ DriverRec * const drv = xf86DriverList[CurrentDriver];
+
+ if (!xorgHWAccess) {
+ if (!drv->driverFunc
+ || !drv->driverFunc( NULL, GET_REQUIRED_HW_INTERFACES, &flags )
+ || NEED_IO_ENABLED(flags))
+ continue;
+ }
+
+ found_screen = xf86CallDriverProbe( drv, TRUE );
+ if ( found_screen && drv->Identify ) {
+ (*drv->Identify)(0);
+ }
+ }
+
+ if (nDevToConfig <= 0) {
+ ErrorF("No devices to configure. Configuration failed.\n");
+ goto bail;
+ }
+
+ /* Add device, monitor and screen sections for detected devices */
+ for (screennum = 0; screennum < nDevToConfig; screennum++) {
+ XF86ConfDevicePtr DevicePtr;
+ XF86ConfMonitorPtr MonitorPtr;
+ XF86ConfScreenPtr ScreenPtr;
+
+ DevicePtr = configureDeviceSection(screennum);
+ xf86config->conf_device_lst = (XF86ConfDevicePtr)xf86addListItem(
+ (glp)xf86config->conf_device_lst, (glp)DevicePtr);
+ MonitorPtr = configureMonitorSection(screennum);
+ xf86config->conf_monitor_lst = (XF86ConfMonitorPtr)xf86addListItem(
+ (glp)xf86config->conf_monitor_lst, (glp)MonitorPtr);
+ ScreenPtr = configureScreenSection(screennum);
+ xf86config->conf_screen_lst = (XF86ConfScreenPtr)xf86addListItem(
+ (glp)xf86config->conf_screen_lst, (glp)ScreenPtr);
+ }
+
+ xf86config->conf_files = configureFilesSection();
+ xf86config->conf_modules = configureModuleSection();
+ xf86config->conf_flags = configureFlagsSection();
+ xf86config->conf_videoadaptor_lst = NULL;
+ xf86config->conf_modes_lst = NULL;
+ xf86config->conf_vendor_lst = NULL;
+ xf86config->conf_dri = NULL;
+ xf86config->conf_input_lst = configureInputSection();
+ xf86config->conf_layout_lst = configureLayoutSection();
+
+ home = getenv("HOME");
+ if ((home == NULL) || (home[0] == '\0')) {
+ home = "/";
+ } else {
+ /* Determine if trailing slash is present or needed */
+ int l = strlen(home);
+
+ if (home[l-1] != '/') {
+ addslash = "/";
+ }
+ }
+
+ snprintf(filename, sizeof(filename), "%s%s" XF86CONFIGFILE ".new",
+ home, addslash);
+
+ if (xf86writeConfigFile(filename, xf86config) == 0) {
+ xf86Msg(X_ERROR, "Unable to write config file: \"%s\": %s\n",
+ filename, strerror(errno));
+ goto bail;
+ }
+
+ xf86DoConfigurePass1 = FALSE;
+ /* Try to get DDC information filled in */
+ xf86ConfigFile = filename;
+ if (xf86HandleConfigFile(FALSE) != CONFIG_OK) {
+ goto bail;
+ }
+
+ xf86DoConfigurePass1 = FALSE;
+
+ dev2screen = xnfcalloc(1,xf86NumDrivers*sizeof(int));
+
+ {
+ Bool *driverProbed = xnfcalloc(1,xf86NumDrivers*sizeof(Bool));
+ for (screennum = 0; screennum < nDevToConfig; screennum++) {
+ int k,l,n,oldNumScreens;
+
+ i = DevToConfig[screennum].iDriver;
+
+ if (driverProbed[i]) continue;
+ driverProbed[i] = TRUE;
+
+ oldNumScreens = xf86NumScreens;
+
+ xf86CallDriverProbe( xf86DriverList[i], FALSE );
+
+ /* reorder */
+ k = screennum > 0 ? screennum : 1;
+ for (l = oldNumScreens; l < xf86NumScreens; l++) {
+ /* is screen primary? */
+ Bool primary = FALSE;
+ for (n = 0; n<xf86Screens[l]->numEntities; n++) {
+ if (xf86IsEntityPrimary(xf86Screens[l]->entityList[n])) {
+ dev2screen[0] = l;
+ primary = TRUE;
+ break;
+ }
+ }
+ if (primary) continue;
+ /* not primary: assign it to next device of same driver */
+ /*
+ * NOTE: we assume that devices in DevToConfig
+ * and xf86Screens[] have the same order except
+ * for the primary device which always comes first.
+ */
+ for (; k < nDevToConfig; k++) {
+ if (DevToConfig[k].iDriver == i) {
+ dev2screen[k++] = l;
+ break;
+ }
+ }
+ }
+ }
+ free(driverProbed);
+ }
+
+
+ if (nDevToConfig != xf86NumScreens) {
+ ErrorF("Number of created screens does not match number of detected"
+ " devices.\n Configuration failed.\n");
+ goto bail;
+ }
+
+ xf86PostProbe();
+
+ for (j = 0; j < xf86NumScreens; j++) {
+ xf86Screens[j]->scrnIndex = j;
+ }
+
+ xf86freeMonitorList(xf86config->conf_monitor_lst);
+ xf86config->conf_monitor_lst = NULL;
+ xf86freeScreenList(xf86config->conf_screen_lst);
+ xf86config->conf_screen_lst = NULL;
+ for (j = 0; j < xf86NumScreens; j++) {
+ XF86ConfMonitorPtr MonitorPtr;
+ XF86ConfScreenPtr ScreenPtr;
+
+ ConfiguredMonitor = NULL;
+
+ if ((*xf86Screens[dev2screen[j]]->PreInit)(xf86Screens[dev2screen[j]],
+ PROBE_DETECT) &&
+ ConfiguredMonitor) {
+ MonitorPtr = configureDDCMonitorSection(j);
+ } else {
+ MonitorPtr = configureMonitorSection(j);
+ }
+ ScreenPtr = configureScreenSection(j);
+ xf86config->conf_monitor_lst = (XF86ConfMonitorPtr)xf86addListItem(
+ (glp)xf86config->conf_monitor_lst, (glp)MonitorPtr);
+ xf86config->conf_screen_lst = (XF86ConfScreenPtr)xf86addListItem(
+ (glp)xf86config->conf_screen_lst, (glp)ScreenPtr);
+ }
+
+ if (xf86writeConfigFile(filename, xf86config) == 0) {
+ xf86Msg(X_ERROR, "Unable to write config file: \"%s\": %s\n",
+ filename, strerror(errno));
+ goto bail;
+ }
+
+ ErrorF("\n");
+
+ if (!foundMouse) {
+ ErrorF("\n"__XSERVERNAME__" is not able to detect your mouse.\n"
+ "Edit the file and correct the Device.\n");
+ } else {
+ ErrorF("\n"__XSERVERNAME__" detected your mouse at device %s.\n"
+ "Please check your config if the mouse is still not\n"
+ "operational, as by default "__XSERVERNAME__
+ " tries to autodetect\n"
+ "the protocol.\n",DFLT_MOUSE_DEV);
+ }
+
+ if (xf86NumScreens > 1) {
+ ErrorF("\n"__XSERVERNAME__
+ " has configured a multihead system, please check your config.\n");
+ }
+
+ ErrorF("\nYour %s file is %s\n\n", XF86CONFIGFILE ,filename);
+ ErrorF("To test the server, run 'X -config %s'\n\n", filename);
+
+bail:
+ OsCleanup(TRUE);
+ AbortDDX(EXIT_ERR_CONFIGURE);
+ fflush(stderr);
+ exit(0);
+}
diff --git a/xorg-server/hw/xfree86/common/xf86Events.c b/xorg-server/hw/xfree86/common/xf86Events.c
index 72e969e6d..c4a4db9be 100644
--- a/xorg-server/hw/xfree86/common/xf86Events.c
+++ b/xorg-server/hw/xfree86/common/xf86Events.c
@@ -1,751 +1,751 @@
-/*
- * 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).
- */
-
-/* [JCH-96/01/21] Extended std reverse map to four buttons. */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xpoll.h>
-#include <X11/Xproto.h>
-#include "misc.h"
-#include "compiler.h"
-#include "xf86.h"
-#include "xf86Priv.h"
-#define XF86_OS_PRIVS
-#include "xf86_OSlib.h"
-#include <X11/keysym.h>
-
-#ifdef XFreeXDGA
-#include "dgaproc.h"
-#endif
-
-#include <X11/extensions/XI.h>
-#include <X11/extensions/XIproto.h>
-#include "inputstr.h"
-#include "xf86Xinput.h"
-
-#include "mi.h"
-#include "mipointer.h"
-
-#include "xkbsrv.h"
-#include "xkbstr.h"
-
-#ifdef DPMSExtension
-#include <X11/extensions/dpmsconst.h>
-#include "dpmsproc.h"
-#endif
-
-/*
- * This is a toggling variable:
- * FALSE = No VT switching keys have been pressed last time around
- * TRUE = Possible VT switch Pending
- * (DWH - 12/2/93)
- *
- * This has been generalised to work with Linux and *BSD+syscons (DHD)
- */
-
-Bool VTSwitchEnabled = TRUE; /* Allows run-time disabling for
- *BSD and for avoiding VT
- switches when using the DRI
- automatic full screen mode.*/
-
-extern fd_set EnabledDevices;
-
-#ifdef XF86PM
-extern void (*xf86OSPMClose)(void);
-#endif
-
-static void xf86VTSwitch(void);
-
-/*
- * Allow arbitrary drivers or other XFree86 code to register with our main
- * Wakeup handler.
- */
-typedef struct x_IHRec {
- int fd;
- InputHandlerProc ihproc;
- pointer data;
- Bool enabled;
- struct x_IHRec * next;
-} IHRec, *IHPtr;
-
-static IHPtr InputHandlers = NULL;
-
-
-Bool
-LegalModifier(unsigned int key, DeviceIntPtr pDev)
-{
- return TRUE;
-}
-
-/*
- * TimeSinceLastInputEvent --
- * Function used for screensaver purposes by the os module. Returns the
- * time in milliseconds since there last was any input.
- */
-int
-TimeSinceLastInputEvent(void)
-{
- if (xf86Info.lastEventTime == 0) {
- xf86Info.lastEventTime = GetTimeInMillis();
- }
- return GetTimeInMillis() - xf86Info.lastEventTime;
-}
-
-/*
- * SetTimeSinceLastInputEvent --
- * Set the lastEventTime to now.
- */
-void
-SetTimeSinceLastInputEvent(void)
-{
- xf86Info.lastEventTime = GetTimeInMillis();
-}
-
-/*
- * ProcessInputEvents --
- * Retrieve all waiting input events and pass them to DIX in their
- * correct chronological order. Only reads from the system pointer
- * and keyboard.
- */
-void
-ProcessInputEvents (void)
-{
- int x, y;
-
- mieqProcessInputEvents();
-
- /* FIXME: This is a problem if we have multiple pointers */
- miPointerGetPosition(inputInfo.pointer, &x, &y);
- xf86SetViewport(xf86Info.currentScreen, x, y);
-}
-
-/*
- * Handle keyboard events that cause some kind of "action"
- * (i.e., server termination, video mode changes, VT switches, etc.)
- */
-void
-xf86ProcessActionEvent(ActionEvent action, void *arg)
-{
- DebugF("ProcessActionEvent(%d,%x)\n", (int) action, arg);
- switch (action) {
- case ACTION_TERMINATE:
- if (!xf86Info.dontZap) {
-#ifdef XFreeXDGA
- DGAShutdown();
-#endif
- GiveUp(0);
- }
- break;
- case ACTION_NEXT_MODE:
- if (!xf86Info.dontZoom)
- xf86ZoomViewport(xf86Info.currentScreen, 1);
- break;
- case ACTION_PREV_MODE:
- if (!xf86Info.dontZoom)
- xf86ZoomViewport(xf86Info.currentScreen, -1);
- break;
- case ACTION_SWITCHSCREEN:
- if (VTSwitchEnabled && !xf86Info.dontVTSwitch && arg) {
- int vtno = *((int *) arg);
-
- if (vtno != xf86Info.vtno) {
- if (!xf86VTActivate(vtno)) {
- ErrorF("Failed to switch from vt%02d to vt%02d: %s\n",
- xf86Info.vtno, vtno, strerror(errno));
- }
- }
- }
- break;
- case ACTION_SWITCHSCREEN_NEXT:
- if (VTSwitchEnabled && !xf86Info.dontVTSwitch) {
- if (!xf86VTActivate(xf86Info.vtno + 1)) {
- /* If first try failed, assume this is the last VT and
- * try wrapping around to the first vt.
- */
- if (!xf86VTActivate(1)) {
- ErrorF("Failed to switch from vt%02d to next vt: %s\n",
- xf86Info.vtno, strerror(errno));
- }
- }
- }
- break;
- case ACTION_SWITCHSCREEN_PREV:
- if (VTSwitchEnabled && !xf86Info.dontVTSwitch && xf86Info.vtno > 0) {
- if (!xf86VTActivate(xf86Info.vtno - 1)) {
- /* Don't know what the maximum VT is, so can't wrap around */
- ErrorF("Failed to switch from vt%02d to previous vt: %s\n",
- xf86Info.vtno, strerror(errno));
- }
- }
- break;
- default:
- break;
- }
-}
-
-/*
- * xf86Wakeup --
- * Os wakeup handler.
- */
-
-/* ARGSUSED */
-void
-xf86Wakeup(pointer blockData, int err, pointer pReadmask)
-{
- fd_set* LastSelectMask = (fd_set*)pReadmask;
- fd_set devicesWithInput;
- InputInfoPtr pInfo;
-
- if (err >= 0) {
-
- XFD_ANDSET(&devicesWithInput, LastSelectMask, &EnabledDevices);
- if (XFD_ANYSET(&devicesWithInput)) {
- pInfo = xf86InputDevs;
- while (pInfo) {
- if (pInfo->read_input && pInfo->fd >= 0 &&
- (FD_ISSET(pInfo->fd, &devicesWithInput) != 0)) {
- int sigstate = xf86BlockSIGIO();
-
- /*
- * Remove the descriptior from the set because more than one
- * device may share the same file descriptor.
- */
- FD_CLR(pInfo->fd, &devicesWithInput);
-
- pInfo->read_input(pInfo);
- xf86UnblockSIGIO(sigstate);
- }
- pInfo = pInfo->next;
- }
- }
- }
-
- if (err >= 0) { /* we don't want the handlers called if select() */
- IHPtr ih; /* returned with an error condition, do we? */
-
- for (ih = InputHandlers; ih; ih = ih->next) {
- if (ih->enabled && ih->fd >= 0 && ih->ihproc &&
- (FD_ISSET(ih->fd, ((fd_set *)pReadmask)) != 0)) {
- ih->ihproc(ih->fd, ih->data);
- }
- }
- }
-
- if (xf86VTSwitchPending()) xf86VTSwitch();
-}
-
-
-/*
- * xf86SigioReadInput --
- * signal handler for the SIGIO signal.
- */
-static void
-xf86SigioReadInput(int fd, void *closure)
-{
- int errno_save = errno;
- InputInfoPtr pInfo = closure;
-
- pInfo->read_input(pInfo);
-
- errno = errno_save;
-}
-
-/*
- * xf86AddEnabledDevice --
- *
- */
-void
-xf86AddEnabledDevice(InputInfoPtr pInfo)
-{
- if (!xf86InstallSIGIOHandler (pInfo->fd, xf86SigioReadInput, pInfo)) {
- AddEnabledDevice(pInfo->fd);
- }
-}
-
-/*
- * xf86RemoveEnabledDevice --
- *
- */
-void
-xf86RemoveEnabledDevice(InputInfoPtr pInfo)
-{
- if (!xf86RemoveSIGIOHandler (pInfo->fd)) {
- RemoveEnabledDevice(pInfo->fd);
- }
-}
-
-static int *xf86SignalIntercept = NULL;
-
-void
-xf86InterceptSignals(int *signo)
-{
- if ((xf86SignalIntercept = signo))
- *signo = -1;
-}
-
-static void (*xf86SigIllHandler)(void) = NULL;
-
-void
-xf86InterceptSigIll(void (*sigillhandler)(void))
-{
- xf86SigIllHandler = sigillhandler;
-}
-
-/*
- * xf86SigWrapper --
- * Catch unexpected signals and exit or continue cleanly.
- */
-int
-xf86SigWrapper(int signo)
-{
- if ((signo == SIGILL) && xf86SigIllHandler) {
- (*xf86SigIllHandler)();
- return 0; /* continue */
- }
-
- if (xf86SignalIntercept && (*xf86SignalIntercept < 0)) {
- *xf86SignalIntercept = signo;
- return 0; /* continue */
- }
-
- xf86Info.caughtSignal = TRUE;
- return 1; /* abort */
-}
-
-/*
- * xf86PrintBacktrace --
- * Print a stack backtrace for debugging purposes.
- */
-void
-xf86PrintBacktrace(void)
-{
- xorg_backtrace();
-}
-
-static void
-xf86ReleaseKeys(DeviceIntPtr pDev)
-{
- KeyClassPtr keyc;
- int i, sigstate;
-
- if (!pDev || !pDev->key)
- return;
-
- keyc = pDev->key;
-
- /*
- * Hmm... here is the biggest hack of every time !
- * It may be possible that a switch-vt procedure has finished BEFORE
- * you released all keys neccessary to do this. That peculiar behavior
- * can fool the X-server pretty much, cause it assumes that some keys
- * were not released. TWM may stuck alsmost completly....
- * OK, what we are doing here is after returning from the vt-switch
- * exeplicitely unrelease all keyboard keys before the input-devices
- * are reenabled.
- */
-
- for (i = keyc->xkbInfo->desc->min_key_code;
- i < keyc->xkbInfo->desc->max_key_code;
- i++) {
- if (key_is_down(pDev, i, KEY_POSTED)) {
- sigstate = xf86BlockSIGIO ();
- QueueKeyboardEvents(pDev, KeyRelease, i, NULL);
- xf86UnblockSIGIO(sigstate);
- }
- }
-}
-
-/*
- * xf86VTSwitch --
- * Handle requests for switching the vt.
- */
-static void
-xf86VTSwitch(void)
-{
- int i;
- static int prevSIGIO;
- InputInfoPtr pInfo;
- IHPtr ih;
-
- DebugF("xf86VTSwitch()\n");
-
-#ifdef XFreeXDGA
- if(!DGAVTSwitch())
- return;
-#endif
-
- /*
- * Since all screens are currently all in the same state it is sufficient
- * check the first. This might change in future.
- */
- if (xf86Screens[0]->vtSema) {
-
- DebugF("xf86VTSwitch: Leaving, xf86Exiting is %s\n",
- BOOLTOSTRING((dispatchException & DE_TERMINATE) ? TRUE : FALSE));
-#ifdef DPMSExtension
- if (DPMSPowerLevel != DPMSModeOn)
- DPMSSet(serverClient, DPMSModeOn);
-#endif
- for (i = 0; i < xf86NumScreens; i++) {
- if (!(dispatchException & DE_TERMINATE))
- if (xf86Screens[i]->EnableDisableFBAccess)
- (*xf86Screens[i]->EnableDisableFBAccess) (i, FALSE);
- }
-
- /*
- * Keep the order: Disable Device > LeaveVT
- * EnterVT > EnableDevice
- */
- for (ih = InputHandlers; ih; ih = ih->next)
- xf86DisableInputHandler(ih);
- for (pInfo = xf86InputDevs; pInfo; pInfo = pInfo->next) {
- if (pInfo->dev) {
- xf86ReleaseKeys(pInfo->dev);
- ProcessInputEvents();
- DisableDevice(pInfo->dev, TRUE);
- }
- }
-
- prevSIGIO = xf86BlockSIGIO();
- for (i = 0; i < xf86NumScreens; i++)
- xf86Screens[i]->LeaveVT(i, 0);
-
- xf86AccessLeave(); /* We need this here, otherwise */
-
- if (!xf86VTSwitchAway()) {
- /*
- * switch failed
- */
-
- DebugF("xf86VTSwitch: Leave failed\n");
- xf86AccessEnter();
- for (i = 0; i < xf86NumScreens; i++) {
- if (!xf86Screens[i]->EnterVT(i, 0))
- FatalError("EnterVT failed for screen %d\n", i);
- }
- if (!(dispatchException & DE_TERMINATE)) {
- for (i = 0; i < xf86NumScreens; i++) {
- if (xf86Screens[i]->EnableDisableFBAccess)
- (*xf86Screens[i]->EnableDisableFBAccess) (i, TRUE);
- }
- }
- dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset);
-
- pInfo = xf86InputDevs;
- while (pInfo) {
- if (pInfo->dev)
- EnableDevice(pInfo->dev, TRUE);
- pInfo = pInfo->next;
- }
- for (ih = InputHandlers; ih; ih = ih->next)
- xf86EnableInputHandler(ih);
-
- xf86UnblockSIGIO(prevSIGIO);
-
- } else {
-#ifdef XF86PM
- if (xf86OSPMClose)
- xf86OSPMClose();
- xf86OSPMClose = NULL;
-#endif
-
- for (i = 0; i < xf86NumScreens; i++) {
- /*
- * zero all access functions to
- * trap calls when switched away.
- */
- xf86Screens[i]->vtSema = FALSE;
- }
- if (xorgHWAccess)
- xf86DisableIO();
- }
- } else {
- DebugF("xf86VTSwitch: Entering\n");
- if (!xf86VTSwitchTo()) return;
-
-#ifdef XF86PM
- xf86OSPMClose = xf86OSPMOpen();
-#endif
-
- if (xorgHWAccess)
- xf86EnableIO();
- xf86AccessEnter();
- for (i = 0; i < xf86NumScreens; i++) {
- xf86Screens[i]->vtSema = TRUE;
- if (!xf86Screens[i]->EnterVT(i, 0))
- FatalError("EnterVT failed for screen %d\n", i);
- }
- for (i = 0; i < xf86NumScreens; i++) {
- if (xf86Screens[i]->EnableDisableFBAccess)
- (*xf86Screens[i]->EnableDisableFBAccess)(i, TRUE);
- }
-
- /* Turn screen saver off when switching back */
- dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset);
-
- pInfo = xf86InputDevs;
- while (pInfo) {
- if (pInfo->dev)
- EnableDevice(pInfo->dev, TRUE);
- pInfo = pInfo->next;
- }
-
- for (ih = InputHandlers; ih; ih = ih->next)
- xf86EnableInputHandler(ih);
-
- xf86UnblockSIGIO(prevSIGIO);
- }
-}
-
-
-/* Input handler registration */
-
-static pointer
-addInputHandler(int fd, InputHandlerProc proc, pointer data)
-{
- IHPtr ih;
-
- if (fd < 0 || !proc)
- return NULL;
-
- ih = calloc(sizeof(*ih), 1);
- if (!ih)
- return NULL;
-
- ih->fd = fd;
- ih->ihproc = proc;
- ih->data = data;
- ih->enabled = TRUE;
-
- ih->next = InputHandlers;
- InputHandlers = ih;
-
- return ih;
-}
-
-pointer
-xf86AddInputHandler(int fd, InputHandlerProc proc, pointer data)
-{
- IHPtr ih = addInputHandler(fd, proc, data);
-
- if (ih)
- AddEnabledDevice(fd);
- return ih;
-}
-
-pointer
-xf86AddGeneralHandler(int fd, InputHandlerProc proc, pointer data)
-{
- IHPtr ih = addInputHandler(fd, proc, data);
-
- if (ih)
- AddGeneralSocket(fd);
- return ih;
-}
-
-/**
- * Set the handler for the console's fd. Replaces (and returns) the previous
- * handler or NULL, whichever appropriate.
- * proc may be NULL if the server should not handle events on the console.
- */
-InputHandlerProc
-xf86SetConsoleHandler(InputHandlerProc proc, pointer data)
-{
- static InputHandlerProc handler = NULL;
- InputHandlerProc old_handler = handler;
-
- if (old_handler)
- xf86RemoveGeneralHandler(old_handler);
-
- xf86AddGeneralHandler(xf86Info.consoleFd, proc, data);
- handler = proc;
-
- return old_handler;
-}
-
-static void
-removeInputHandler(IHPtr ih)
-{
- IHPtr p;
-
- if (ih == InputHandlers)
- InputHandlers = ih->next;
- else {
- p = InputHandlers;
- while (p && p->next != ih)
- p = p->next;
- if (ih)
- p->next = ih->next;
- }
- free(ih);
-}
-
-int
-xf86RemoveInputHandler(pointer handler)
-{
- IHPtr ih;
- int fd;
-
- if (!handler)
- return -1;
-
- ih = handler;
- fd = ih->fd;
-
- if (ih->fd >= 0)
- RemoveEnabledDevice(ih->fd);
- removeInputHandler(ih);
-
- return fd;
-}
-
-int
-xf86RemoveGeneralHandler(pointer handler)
-{
- IHPtr ih;
- int fd;
-
- if (!handler)
- return -1;
-
- ih = handler;
- fd = ih->fd;
-
- if (ih->fd >= 0)
- RemoveGeneralSocket(ih->fd);
- removeInputHandler(ih);
-
- return fd;
-}
-
-void
-xf86DisableInputHandler(pointer handler)
-{
- IHPtr ih;
-
- if (!handler)
- return;
-
- ih = handler;
- ih->enabled = FALSE;
- if (ih->fd >= 0)
- RemoveEnabledDevice(ih->fd);
-}
-
-void
-xf86DisableGeneralHandler(pointer handler)
-{
- IHPtr ih;
-
- if (!handler)
- return;
-
- ih = handler;
- ih->enabled = FALSE;
- if (ih->fd >= 0)
- RemoveGeneralSocket(ih->fd);
-}
-
-void
-xf86EnableInputHandler(pointer handler)
-{
- IHPtr ih;
-
- if (!handler)
- return;
-
- ih = handler;
- ih->enabled = TRUE;
- if (ih->fd >= 0)
- AddEnabledDevice(ih->fd);
-}
-
-void
-xf86EnableGeneralHandler(pointer handler)
-{
- IHPtr ih;
-
- if (!handler)
- return;
-
- ih = handler;
- ih->enabled = TRUE;
- if (ih->fd >= 0)
- AddGeneralSocket(ih->fd);
-}
-
-/*
- * As used currently by the DRI, the return value is ignored.
- */
-Bool
-xf86EnableVTSwitch(Bool new)
-{
- static Bool def = TRUE;
- Bool old;
-
- old = VTSwitchEnabled;
- if (!new) {
- /* Disable VT switching */
- def = VTSwitchEnabled;
- VTSwitchEnabled = FALSE;
- } else {
- /* Restore VT switching to default */
- VTSwitchEnabled = def;
- }
- return old;
-}
-
-void
-DDXRingBell(int volume, int pitch, int duration) {
- xf86OSRingBell(volume, pitch, duration);
-}
+/*
+ * 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).
+ */
+
+/* [JCH-96/01/21] Extended std reverse map to four buttons. */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xpoll.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "compiler.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#define XF86_OS_PRIVS
+#include "xf86_OSlib.h"
+#include <X11/keysym.h>
+
+#ifdef XFreeXDGA
+#include "dgaproc.h"
+#endif
+
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "inputstr.h"
+#include "xf86Xinput.h"
+
+#include "mi.h"
+#include "mipointer.h"
+
+#include "xkbsrv.h"
+#include "xkbstr.h"
+
+#ifdef DPMSExtension
+#include <X11/extensions/dpmsconst.h>
+#include "dpmsproc.h"
+#endif
+
+/*
+ * This is a toggling variable:
+ * FALSE = No VT switching keys have been pressed last time around
+ * TRUE = Possible VT switch Pending
+ * (DWH - 12/2/93)
+ *
+ * This has been generalised to work with Linux and *BSD+syscons (DHD)
+ */
+
+Bool VTSwitchEnabled = TRUE; /* Allows run-time disabling for
+ *BSD and for avoiding VT
+ switches when using the DRI
+ automatic full screen mode.*/
+
+extern fd_set EnabledDevices;
+
+#ifdef XF86PM
+extern void (*xf86OSPMClose)(void);
+#endif
+
+static void xf86VTSwitch(void);
+
+/*
+ * Allow arbitrary drivers or other XFree86 code to register with our main
+ * Wakeup handler.
+ */
+typedef struct x_IHRec {
+ int fd;
+ InputHandlerProc ihproc;
+ pointer data;
+ Bool enabled;
+ struct x_IHRec * next;
+} IHRec, *IHPtr;
+
+static IHPtr InputHandlers = NULL;
+
+
+Bool
+LegalModifier(unsigned int key, DeviceIntPtr pDev)
+{
+ return TRUE;
+}
+
+/*
+ * TimeSinceLastInputEvent --
+ * Function used for screensaver purposes by the os module. Returns the
+ * time in milliseconds since there last was any input.
+ */
+int
+TimeSinceLastInputEvent(void)
+{
+ if (xf86Info.lastEventTime == 0) {
+ xf86Info.lastEventTime = GetTimeInMillis();
+ }
+ return GetTimeInMillis() - xf86Info.lastEventTime;
+}
+
+/*
+ * SetTimeSinceLastInputEvent --
+ * Set the lastEventTime to now.
+ */
+void
+SetTimeSinceLastInputEvent(void)
+{
+ xf86Info.lastEventTime = GetTimeInMillis();
+}
+
+/*
+ * ProcessInputEvents --
+ * Retrieve all waiting input events and pass them to DIX in their
+ * correct chronological order. Only reads from the system pointer
+ * and keyboard.
+ */
+void
+ProcessInputEvents (void)
+{
+ int x, y;
+
+ mieqProcessInputEvents();
+
+ /* FIXME: This is a problem if we have multiple pointers */
+ miPointerGetPosition(inputInfo.pointer, &x, &y);
+ xf86SetViewport(xf86Info.currentScreen, x, y);
+}
+
+/*
+ * Handle keyboard events that cause some kind of "action"
+ * (i.e., server termination, video mode changes, VT switches, etc.)
+ */
+void
+xf86ProcessActionEvent(ActionEvent action, void *arg)
+{
+ DebugF("ProcessActionEvent(%d,%x)\n", (int) action, arg);
+ switch (action) {
+ case ACTION_TERMINATE:
+ if (!xf86Info.dontZap) {
+#ifdef XFreeXDGA
+ DGAShutdown();
+#endif
+ GiveUp(0);
+ }
+ break;
+ case ACTION_NEXT_MODE:
+ if (!xf86Info.dontZoom)
+ xf86ZoomViewport(xf86Info.currentScreen, 1);
+ break;
+ case ACTION_PREV_MODE:
+ if (!xf86Info.dontZoom)
+ xf86ZoomViewport(xf86Info.currentScreen, -1);
+ break;
+ case ACTION_SWITCHSCREEN:
+ if (VTSwitchEnabled && !xf86Info.dontVTSwitch && arg) {
+ int vtno = *((int *) arg);
+
+ if (vtno != xf86Info.vtno) {
+ if (!xf86VTActivate(vtno)) {
+ ErrorF("Failed to switch from vt%02d to vt%02d: %s\n",
+ xf86Info.vtno, vtno, strerror(errno));
+ }
+ }
+ }
+ break;
+ case ACTION_SWITCHSCREEN_NEXT:
+ if (VTSwitchEnabled && !xf86Info.dontVTSwitch) {
+ if (!xf86VTActivate(xf86Info.vtno + 1)) {
+ /* If first try failed, assume this is the last VT and
+ * try wrapping around to the first vt.
+ */
+ if (!xf86VTActivate(1)) {
+ ErrorF("Failed to switch from vt%02d to next vt: %s\n",
+ xf86Info.vtno, strerror(errno));
+ }
+ }
+ }
+ break;
+ case ACTION_SWITCHSCREEN_PREV:
+ if (VTSwitchEnabled && !xf86Info.dontVTSwitch && xf86Info.vtno > 0) {
+ if (!xf86VTActivate(xf86Info.vtno - 1)) {
+ /* Don't know what the maximum VT is, so can't wrap around */
+ ErrorF("Failed to switch from vt%02d to previous vt: %s\n",
+ xf86Info.vtno, strerror(errno));
+ }
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+/*
+ * xf86Wakeup --
+ * Os wakeup handler.
+ */
+
+/* ARGSUSED */
+void
+xf86Wakeup(pointer blockData, int err, pointer pReadmask)
+{
+ fd_set* LastSelectMask = (fd_set*)pReadmask;
+ fd_set devicesWithInput;
+ InputInfoPtr pInfo;
+
+ if (err >= 0) {
+
+ XFD_ANDSET(&devicesWithInput, LastSelectMask, &EnabledDevices);
+ if (XFD_ANYSET(&devicesWithInput)) {
+ pInfo = xf86InputDevs;
+ while (pInfo) {
+ if (pInfo->read_input && pInfo->fd >= 0 &&
+ (FD_ISSET(pInfo->fd, &devicesWithInput) != 0)) {
+ int sigstate = xf86BlockSIGIO();
+
+ /*
+ * Remove the descriptior from the set because more than one
+ * device may share the same file descriptor.
+ */
+ FD_CLR(pInfo->fd, &devicesWithInput);
+
+ pInfo->read_input(pInfo);
+ xf86UnblockSIGIO(sigstate);
+ }
+ pInfo = pInfo->next;
+ }
+ }
+ }
+
+ if (err >= 0) { /* we don't want the handlers called if select() */
+ IHPtr ih; /* returned with an error condition, do we? */
+
+ for (ih = InputHandlers; ih; ih = ih->next) {
+ if (ih->enabled && ih->fd >= 0 && ih->ihproc &&
+ (FD_ISSET(ih->fd, ((fd_set *)pReadmask)) != 0)) {
+ ih->ihproc(ih->fd, ih->data);
+ }
+ }
+ }
+
+ if (xf86VTSwitchPending()) xf86VTSwitch();
+}
+
+
+/*
+ * xf86SigioReadInput --
+ * signal handler for the SIGIO signal.
+ */
+static void
+xf86SigioReadInput(int fd, void *closure)
+{
+ int errno_save = errno;
+ InputInfoPtr pInfo = closure;
+
+ pInfo->read_input(pInfo);
+
+ errno = errno_save;
+}
+
+/*
+ * xf86AddEnabledDevice --
+ *
+ */
+void
+xf86AddEnabledDevice(InputInfoPtr pInfo)
+{
+ if (!xf86InstallSIGIOHandler (pInfo->fd, xf86SigioReadInput, pInfo)) {
+ AddEnabledDevice(pInfo->fd);
+ }
+}
+
+/*
+ * xf86RemoveEnabledDevice --
+ *
+ */
+void
+xf86RemoveEnabledDevice(InputInfoPtr pInfo)
+{
+ if (!xf86RemoveSIGIOHandler (pInfo->fd)) {
+ RemoveEnabledDevice(pInfo->fd);
+ }
+}
+
+static int *xf86SignalIntercept = NULL;
+
+void
+xf86InterceptSignals(int *signo)
+{
+ if ((xf86SignalIntercept = signo))
+ *signo = -1;
+}
+
+static void (*xf86SigIllHandler)(void) = NULL;
+
+void
+xf86InterceptSigIll(void (*sigillhandler)(void))
+{
+ xf86SigIllHandler = sigillhandler;
+}
+
+/*
+ * xf86SigWrapper --
+ * Catch unexpected signals and exit or continue cleanly.
+ */
+int
+xf86SigWrapper(int signo)
+{
+ if ((signo == SIGILL) && xf86SigIllHandler) {
+ (*xf86SigIllHandler)();
+ return 0; /* continue */
+ }
+
+ if (xf86SignalIntercept && (*xf86SignalIntercept < 0)) {
+ *xf86SignalIntercept = signo;
+ return 0; /* continue */
+ }
+
+ xf86Info.caughtSignal = TRUE;
+ return 1; /* abort */
+}
+
+/*
+ * xf86PrintBacktrace --
+ * Print a stack backtrace for debugging purposes.
+ */
+void
+xf86PrintBacktrace(void)
+{
+ xorg_backtrace();
+}
+
+static void
+xf86ReleaseKeys(DeviceIntPtr pDev)
+{
+ KeyClassPtr keyc;
+ int i, sigstate;
+
+ if (!pDev || !pDev->key)
+ return;
+
+ keyc = pDev->key;
+
+ /*
+ * Hmm... here is the biggest hack of every time !
+ * It may be possible that a switch-vt procedure has finished BEFORE
+ * you released all keys neccessary to do this. That peculiar behavior
+ * can fool the X-server pretty much, cause it assumes that some keys
+ * were not released. TWM may stuck alsmost completly....
+ * OK, what we are doing here is after returning from the vt-switch
+ * exeplicitely unrelease all keyboard keys before the input-devices
+ * are reenabled.
+ */
+
+ for (i = keyc->xkbInfo->desc->min_key_code;
+ i < keyc->xkbInfo->desc->max_key_code;
+ i++) {
+ if (key_is_down(pDev, i, KEY_POSTED)) {
+ sigstate = xf86BlockSIGIO ();
+ QueueKeyboardEvents(pDev, KeyRelease, i, NULL);
+ xf86UnblockSIGIO(sigstate);
+ }
+ }
+}
+
+/*
+ * xf86VTSwitch --
+ * Handle requests for switching the vt.
+ */
+static void
+xf86VTSwitch(void)
+{
+ int i;
+ static int prevSIGIO;
+ InputInfoPtr pInfo;
+ IHPtr ih;
+
+ DebugF("xf86VTSwitch()\n");
+
+#ifdef XFreeXDGA
+ if(!DGAVTSwitch())
+ return;
+#endif
+
+ /*
+ * Since all screens are currently all in the same state it is sufficient
+ * check the first. This might change in future.
+ */
+ if (xf86Screens[0]->vtSema) {
+
+ DebugF("xf86VTSwitch: Leaving, xf86Exiting is %s\n",
+ BOOLTOSTRING((dispatchException & DE_TERMINATE) ? TRUE : FALSE));
+#ifdef DPMSExtension
+ if (DPMSPowerLevel != DPMSModeOn)
+ DPMSSet(serverClient, DPMSModeOn);
+#endif
+ for (i = 0; i < xf86NumScreens; i++) {
+ if (!(dispatchException & DE_TERMINATE))
+ if (xf86Screens[i]->EnableDisableFBAccess)
+ (*xf86Screens[i]->EnableDisableFBAccess) (i, FALSE);
+ }
+
+ /*
+ * Keep the order: Disable Device > LeaveVT
+ * EnterVT > EnableDevice
+ */
+ for (ih = InputHandlers; ih; ih = ih->next)
+ xf86DisableInputHandler(ih);
+ for (pInfo = xf86InputDevs; pInfo; pInfo = pInfo->next) {
+ if (pInfo->dev) {
+ xf86ReleaseKeys(pInfo->dev);
+ ProcessInputEvents();
+ DisableDevice(pInfo->dev, TRUE);
+ }
+ }
+
+ prevSIGIO = xf86BlockSIGIO();
+ for (i = 0; i < xf86NumScreens; i++)
+ xf86Screens[i]->LeaveVT(i, 0);
+
+ xf86AccessLeave(); /* We need this here, otherwise */
+
+ if (!xf86VTSwitchAway()) {
+ /*
+ * switch failed
+ */
+
+ DebugF("xf86VTSwitch: Leave failed\n");
+ xf86AccessEnter();
+ for (i = 0; i < xf86NumScreens; i++) {
+ if (!xf86Screens[i]->EnterVT(i, 0))
+ FatalError("EnterVT failed for screen %d\n", i);
+ }
+ if (!(dispatchException & DE_TERMINATE)) {
+ for (i = 0; i < xf86NumScreens; i++) {
+ if (xf86Screens[i]->EnableDisableFBAccess)
+ (*xf86Screens[i]->EnableDisableFBAccess) (i, TRUE);
+ }
+ }
+ dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset);
+
+ pInfo = xf86InputDevs;
+ while (pInfo) {
+ if (pInfo->dev)
+ EnableDevice(pInfo->dev, TRUE);
+ pInfo = pInfo->next;
+ }
+ for (ih = InputHandlers; ih; ih = ih->next)
+ xf86EnableInputHandler(ih);
+
+ xf86UnblockSIGIO(prevSIGIO);
+
+ } else {
+#ifdef XF86PM
+ if (xf86OSPMClose)
+ xf86OSPMClose();
+ xf86OSPMClose = NULL;
+#endif
+
+ for (i = 0; i < xf86NumScreens; i++) {
+ /*
+ * zero all access functions to
+ * trap calls when switched away.
+ */
+ xf86Screens[i]->vtSema = FALSE;
+ }
+ if (xorgHWAccess)
+ xf86DisableIO();
+ }
+ } else {
+ DebugF("xf86VTSwitch: Entering\n");
+ if (!xf86VTSwitchTo()) return;
+
+#ifdef XF86PM
+ xf86OSPMClose = xf86OSPMOpen();
+#endif
+
+ if (xorgHWAccess)
+ xf86EnableIO();
+ xf86AccessEnter();
+ for (i = 0; i < xf86NumScreens; i++) {
+ xf86Screens[i]->vtSema = TRUE;
+ if (!xf86Screens[i]->EnterVT(i, 0))
+ FatalError("EnterVT failed for screen %d\n", i);
+ }
+ for (i = 0; i < xf86NumScreens; i++) {
+ if (xf86Screens[i]->EnableDisableFBAccess)
+ (*xf86Screens[i]->EnableDisableFBAccess)(i, TRUE);
+ }
+
+ /* Turn screen saver off when switching back */
+ dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset);
+
+ pInfo = xf86InputDevs;
+ while (pInfo) {
+ if (pInfo->dev)
+ EnableDevice(pInfo->dev, TRUE);
+ pInfo = pInfo->next;
+ }
+
+ for (ih = InputHandlers; ih; ih = ih->next)
+ xf86EnableInputHandler(ih);
+
+ xf86UnblockSIGIO(prevSIGIO);
+ }
+}
+
+
+/* Input handler registration */
+
+static pointer
+addInputHandler(int fd, InputHandlerProc proc, pointer data)
+{
+ IHPtr ih;
+
+ if (fd < 0 || !proc)
+ return NULL;
+
+ ih = calloc(sizeof(*ih), 1);
+ if (!ih)
+ return NULL;
+
+ ih->fd = fd;
+ ih->ihproc = proc;
+ ih->data = data;
+ ih->enabled = TRUE;
+
+ ih->next = InputHandlers;
+ InputHandlers = ih;
+
+ return ih;
+}
+
+pointer
+xf86AddInputHandler(int fd, InputHandlerProc proc, pointer data)
+{
+ IHPtr ih = addInputHandler(fd, proc, data);
+
+ if (ih)
+ AddEnabledDevice(fd);
+ return ih;
+}
+
+pointer
+xf86AddGeneralHandler(int fd, InputHandlerProc proc, pointer data)
+{
+ IHPtr ih = addInputHandler(fd, proc, data);
+
+ if (ih)
+ AddGeneralSocket(fd);
+ return ih;
+}
+
+/**
+ * Set the handler for the console's fd. Replaces (and returns) the previous
+ * handler or NULL, whichever appropriate.
+ * proc may be NULL if the server should not handle events on the console.
+ */
+InputHandlerProc
+xf86SetConsoleHandler(InputHandlerProc proc, pointer data)
+{
+ static InputHandlerProc handler = NULL;
+ InputHandlerProc old_handler = handler;
+
+ if (old_handler)
+ xf86RemoveGeneralHandler(old_handler);
+
+ xf86AddGeneralHandler(xf86Info.consoleFd, proc, data);
+ handler = proc;
+
+ return old_handler;
+}
+
+static void
+removeInputHandler(IHPtr ih)
+{
+ IHPtr p;
+
+ if (ih == InputHandlers)
+ InputHandlers = ih->next;
+ else {
+ p = InputHandlers;
+ while (p && p->next != ih)
+ p = p->next;
+ if (ih)
+ p->next = ih->next;
+ }
+ free(ih);
+}
+
+int
+xf86RemoveInputHandler(pointer handler)
+{
+ IHPtr ih;
+ int fd;
+
+ if (!handler)
+ return -1;
+
+ ih = handler;
+ fd = ih->fd;
+
+ if (ih->fd >= 0)
+ RemoveEnabledDevice(ih->fd);
+ removeInputHandler(ih);
+
+ return fd;
+}
+
+int
+xf86RemoveGeneralHandler(pointer handler)
+{
+ IHPtr ih;
+ int fd;
+
+ if (!handler)
+ return -1;
+
+ ih = handler;
+ fd = ih->fd;
+
+ if (ih->fd >= 0)
+ RemoveGeneralSocket(ih->fd);
+ removeInputHandler(ih);
+
+ return fd;
+}
+
+void
+xf86DisableInputHandler(pointer handler)
+{
+ IHPtr ih;
+
+ if (!handler)
+ return;
+
+ ih = handler;
+ ih->enabled = FALSE;
+ if (ih->fd >= 0)
+ RemoveEnabledDevice(ih->fd);
+}
+
+void
+xf86DisableGeneralHandler(pointer handler)
+{
+ IHPtr ih;
+
+ if (!handler)
+ return;
+
+ ih = handler;
+ ih->enabled = FALSE;
+ if (ih->fd >= 0)
+ RemoveGeneralSocket(ih->fd);
+}
+
+void
+xf86EnableInputHandler(pointer handler)
+{
+ IHPtr ih;
+
+ if (!handler)
+ return;
+
+ ih = handler;
+ ih->enabled = TRUE;
+ if (ih->fd >= 0)
+ AddEnabledDevice(ih->fd);
+}
+
+void
+xf86EnableGeneralHandler(pointer handler)
+{
+ IHPtr ih;
+
+ if (!handler)
+ return;
+
+ ih = handler;
+ ih->enabled = TRUE;
+ if (ih->fd >= 0)
+ AddGeneralSocket(ih->fd);
+}
+
+/*
+ * As used currently by the DRI, the return value is ignored.
+ */
+Bool
+xf86EnableVTSwitch(Bool new)
+{
+ static Bool def = TRUE;
+ Bool old;
+
+ old = VTSwitchEnabled;
+ if (!new) {
+ /* Disable VT switching */
+ def = VTSwitchEnabled;
+ VTSwitchEnabled = FALSE;
+ } else {
+ /* Restore VT switching to default */
+ VTSwitchEnabled = def;
+ }
+ return old;
+}
+
+void
+DDXRingBell(int volume, int pitch, int duration) {
+ xf86OSRingBell(volume, pitch, duration);
+}
diff --git a/xorg-server/hw/xfree86/common/xf86Helper.c b/xorg-server/hw/xfree86/common/xf86Helper.c
index a210df042..f8e6c8b41 100644
--- a/xorg-server/hw/xfree86/common/xf86Helper.c
+++ b/xorg-server/hw/xfree86/common/xf86Helper.c
@@ -1,1949 +1,1949 @@
-/*
- * Copyright (c) 1997-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).
- */
-
-/*
- * Authors: Dirk Hohndel <hohndel@XFree86.Org>
- * David Dawes <dawes@XFree86.Org>
- * ... and others
- *
- * This file includes the helper functions that the server provides for
- * different drivers.
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include "os.h"
-#include "servermd.h"
-#include "pixmapstr.h"
-#include "windowstr.h"
-#include "propertyst.h"
-#include "gcstruct.h"
-#include "loaderProcs.h"
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-#include "micmap.h"
-#include "xf86DDC.h"
-#include "xf86Xinput.h"
-#include "xf86InPriv.h"
-#include "mivalidate.h"
-#include "xf86Crtc.h"
-
-/* For xf86GetClocks */
-#if defined(CSRG_BASED) || defined(__GNU__)
-#define HAS_SETPRIORITY
-#include <sys/resource.h>
-#endif
-
-static int xf86ScrnInfoPrivateCount = 0;
-
-
-/* Add a pointer to a new DriverRec to xf86DriverList */
-
-void
-xf86AddDriver(DriverPtr driver, pointer module, int flags)
-{
- /* Don't add null entries */
- if (!driver)
- return;
-
- if (xf86DriverList == NULL)
- xf86NumDrivers = 0;
-
- xf86NumDrivers++;
- xf86DriverList = xnfrealloc(xf86DriverList,
- xf86NumDrivers * sizeof(DriverPtr));
- xf86DriverList[xf86NumDrivers - 1] = xnfalloc(sizeof(DriverRec));
- if (flags & HaveDriverFuncs)
- *xf86DriverList[xf86NumDrivers - 1] = *driver;
- else {
- (void) memset( xf86DriverList[xf86NumDrivers - 1], 0,
- sizeof( DriverRec ) );
- (void) memcpy( xf86DriverList[xf86NumDrivers - 1], driver,
- sizeof(DriverRec1));
-
- }
- xf86DriverList[xf86NumDrivers - 1]->module = module;
- xf86DriverList[xf86NumDrivers - 1]->refCount = 0;
-}
-
-void
-xf86DeleteDriver(int drvIndex)
-{
- if (xf86DriverList[drvIndex]
- && (!xf86DriverHasEntities(xf86DriverList[drvIndex]))) {
- if (xf86DriverList[drvIndex]->module)
- UnloadModule(xf86DriverList[drvIndex]->module);
- free(xf86DriverList[drvIndex]);
- xf86DriverList[drvIndex] = NULL;
- }
-}
-
-/* Add a pointer to a new InputDriverRec to xf86InputDriverList */
-
-void
-xf86AddInputDriver(InputDriverPtr driver, pointer module, int flags)
-{
- /* Don't add null entries */
- if (!driver)
- return;
-
- if (xf86InputDriverList == NULL)
- xf86NumInputDrivers = 0;
-
- xf86NumInputDrivers++;
- xf86InputDriverList = xnfrealloc(xf86InputDriverList,
- xf86NumInputDrivers * sizeof(InputDriverPtr));
- xf86InputDriverList[xf86NumInputDrivers - 1] =
- xnfalloc(sizeof(InputDriverRec));
- *xf86InputDriverList[xf86NumInputDrivers - 1] = *driver;
- xf86InputDriverList[xf86NumInputDrivers - 1]->module = module;
-}
-
-void
-xf86DeleteInputDriver(int drvIndex)
-{
- if (xf86InputDriverList[drvIndex] && xf86InputDriverList[drvIndex]->module)
- UnloadModule(xf86InputDriverList[drvIndex]->module);
- free(xf86InputDriverList[drvIndex]);
- xf86InputDriverList[drvIndex] = NULL;
-}
-
-InputDriverPtr
-xf86LookupInputDriver(const char *name)
-{
- int i;
-
- for (i = 0; i < xf86NumInputDrivers; i++) {
- if (xf86InputDriverList[i] && xf86InputDriverList[i]->driverName &&
- xf86NameCmp(name, xf86InputDriverList[i]->driverName) == 0)
- return xf86InputDriverList[i];
- }
- return NULL;
-}
-
-InputInfoPtr
-xf86LookupInput(const char *name)
-{
- InputInfoPtr p;
-
- for (p = xf86InputDevs; p != NULL; p = p->next) {
- if (strcmp(name, p->name) == 0)
- return p;
- }
-
- return NULL;
-}
-
-/* Allocate a new ScrnInfoRec in xf86Screens */
-
-ScrnInfoPtr
-xf86AllocateScreen(DriverPtr drv, int flags)
-{
- int i;
-
- if (xf86Screens == NULL)
- xf86NumScreens = 0;
-
- i = xf86NumScreens++;
- xf86Screens = xnfrealloc(xf86Screens, xf86NumScreens * sizeof(ScrnInfoPtr));
- xf86Screens[i] = xnfcalloc(sizeof(ScrnInfoRec), 1);
- xf86Screens[i]->scrnIndex = i; /* Changes when a screen is removed */
- xf86Screens[i]->origIndex = i; /* This never changes */
- xf86Screens[i]->privates = xnfcalloc(sizeof(DevUnion),
- xf86ScrnInfoPrivateCount);
- /*
- * EnableDisableFBAccess now gets initialized in InitOutput()
- * xf86Screens[i]->EnableDisableFBAccess = xf86EnableDisableFBAccess;
- */
-
- xf86Screens[i]->drv = drv;
- drv->refCount++;
- xf86Screens[i]->module = DuplicateModule(drv->module, NULL);
-
- xf86Screens[i]->DriverFunc = drv->driverFunc;
-
- return xf86Screens[i];
-}
-
-
-/*
- * Remove an entry from xf86Screens. Ideally it should free all allocated
- * data. To do this properly may require a driver hook.
- */
-
-void
-xf86DeleteScreen(int scrnIndex, int flags)
-{
- ScrnInfoPtr pScrn;
- int i;
-
- /* First check if the screen is valid */
- if (xf86NumScreens == 0 || xf86Screens == NULL)
- return;
-
- if (scrnIndex > xf86NumScreens - 1)
- return;
-
- if (!(pScrn = xf86Screens[scrnIndex]))
- return;
-
- /* If a FreeScreen function is defined, call it here */
- if (pScrn->FreeScreen != NULL)
- pScrn->FreeScreen(scrnIndex, 0);
-
- while (pScrn->modes)
- xf86DeleteMode(&pScrn->modes, pScrn->modes);
-
- while (pScrn->modePool)
- xf86DeleteMode(&pScrn->modePool, pScrn->modePool);
-
- xf86OptionListFree(pScrn->options);
-
- if (pScrn->module)
- UnloadModule(pScrn->module);
-
- if (pScrn->drv)
- pScrn->drv->refCount--;
-
- free(pScrn->privates);
-
- xf86ClearEntityListForScreen(scrnIndex);
-
- free(pScrn);
-
- /* Move the other entries down, updating their scrnIndex fields */
-
- xf86NumScreens--;
-
- for (i = scrnIndex; i < xf86NumScreens; i++) {
- xf86Screens[i] = xf86Screens[i + 1];
- xf86Screens[i]->scrnIndex = i;
- /* Also need to take care of the screen layout settings */
- }
-}
-
-/*
- * Allocate a private in ScrnInfoRec.
- */
-
-int
-xf86AllocateScrnInfoPrivateIndex(void)
-{
- int idx, i;
- ScrnInfoPtr pScr;
- DevUnion *nprivs;
-
- idx = xf86ScrnInfoPrivateCount++;
- for (i = 0; i < xf86NumScreens; i++) {
- pScr = xf86Screens[i];
- nprivs = xnfrealloc(pScr->privates,
- xf86ScrnInfoPrivateCount * sizeof(DevUnion));
- /* Zero the new private */
- memset(&nprivs[idx], 0, sizeof(DevUnion));
- pScr->privates = nprivs;
- }
- return idx;
-}
-
-Bool
-xf86AddPixFormat(ScrnInfoPtr pScrn, int depth, int bpp, int pad)
-{
- int i;
-
- if (pScrn->numFormats >= MAXFORMATS)
- return FALSE;
-
- if (bpp <= 0) {
- if (depth == 1)
- bpp = 1;
- else if (depth <= 8)
- bpp = 8;
- else if (depth <= 16)
- bpp = 16;
- else if (depth <= 32)
- bpp = 32;
- else
- return FALSE;
- }
- if (pad <= 0)
- pad = BITMAP_SCANLINE_PAD;
-
- i = pScrn->numFormats++;
- pScrn->formats[i].depth = depth;
- pScrn->formats[i].bitsPerPixel = bpp;
- pScrn->formats[i].scanlinePad = pad;
- return TRUE;
-}
-
-/*
- * Set the depth we are using based on (in the following order of preference):
- * - values given on the command line
- * - values given in the config file
- * - values provided by the driver
- * - an overall default when nothing else is given
- *
- * Also find a Display subsection matching the depth/bpp found.
- *
- * Sets the following ScrnInfoRec fields:
- * bitsPerPixel, pixmap24, depth, display, imageByteOrder,
- * bitmapScanlinePad, bitmapScanlineUnit, bitmapBitOrder, numFormats,
- * formats, fbFormat.
- */
-
-/* Can the screen handle 24 bpp pixmaps */
-#define DO_PIX24(f) ((f & Support24bppFb) || \
- ((f & Support32bppFb) && (f & SupportConvert24to32)))
-
-/* Can the screen handle 32 bpp pixmaps */
-#define DO_PIX32(f) ((f & Support32bppFb) || \
- ((f & Support24bppFb) && (f & SupportConvert32to24)))
-
-/* Does the screen prefer 32bpp fb for 24bpp pixmaps */
-#define CHOOSE32FOR24(f) ((f & Support32bppFb) && (f & SupportConvert24to32) \
- && (f & PreferConvert24to32))
-
-/* Does the screen prefer 24bpp fb for 32bpp pixmaps */
-#define CHOOSE24FOR32(f) ((f & Support24bppFb) && (f & SupportConvert32to24) \
- && (f & PreferConvert32to24))
-
-/* Can the screen handle 32bpp pixmaps for 24bpp fb */
-#define DO_PIX32FOR24(f) ((f & Support24bppFb) && (f & SupportConvert32to24))
-
-/* Can the screen handle 24bpp pixmaps for 32bpp fb */
-#define DO_PIX24FOR32(f) ((f & Support32bppFb) && (f & SupportConvert24to32))
-
-#ifndef GLOBAL_DEFAULT_DEPTH
-#define GLOBAL_DEFAULT_DEPTH 24
-#endif
-
-Bool
-xf86SetDepthBpp(ScrnInfoPtr scrp, int depth, int dummy, int fbbpp,
- int depth24flags)
-{
- int i;
- DispPtr disp;
- Pix24Flags pix24 = xf86Info.pixmap24;
- Bool nomatch = FALSE;
-
- scrp->bitsPerPixel = -1;
- scrp->depth = -1;
- scrp->pixmap24 = Pix24DontCare;
- scrp->bitsPerPixelFrom = X_DEFAULT;
- scrp->depthFrom = X_DEFAULT;
-
- if (xf86FbBpp > 0) {
- scrp->bitsPerPixel = xf86FbBpp;
- scrp->bitsPerPixelFrom = X_CMDLINE;
- }
-
- if (xf86Depth > 0) {
- scrp->depth = xf86Depth;
- scrp->depthFrom = X_CMDLINE;
- }
-
- if (xf86FbBpp < 0 && xf86Depth < 0) {
- if (scrp->confScreen->defaultfbbpp > 0) {
- scrp->bitsPerPixel = scrp->confScreen->defaultfbbpp;
- scrp->bitsPerPixelFrom = X_CONFIG;
- }
- if (scrp->confScreen->defaultdepth > 0) {
- scrp->depth = scrp->confScreen->defaultdepth;
- scrp->depthFrom = X_CONFIG;
- }
-
- if (scrp->confScreen->defaultfbbpp <= 0 &&
- scrp->confScreen->defaultdepth <= 0) {
- /*
- * Check for DefaultDepth and DefaultFbBpp options in the
- * Device sections.
- */
- int i;
- GDevPtr device;
- Bool found = FALSE;
-
- for (i = 0; i < scrp->numEntities; i++) {
- device = xf86GetDevFromEntity(scrp->entityList[i],
- scrp->entityInstanceList[i]);
- if (device && device->options) {
- if (xf86FindOption(device->options, "DefaultDepth")) {
- scrp->depth = xf86SetIntOption(device->options,
- "DefaultDepth", -1);
- scrp->depthFrom = X_CONFIG;
- found = TRUE;
- }
- if (xf86FindOption(device->options, "DefaultFbBpp")) {
- scrp->bitsPerPixel = xf86SetIntOption(device->options,
- "DefaultFbBpp",
- -1);
- scrp->bitsPerPixelFrom = X_CONFIG;
- found = TRUE;
- }
- }
- if (found)
- break;
- }
- }
- }
-
- /* If none of these is set, pick a default */
- if (scrp->bitsPerPixel < 0 && scrp->depth < 0) {
- if (fbbpp > 0 || depth > 0) {
- if (fbbpp > 0)
- scrp->bitsPerPixel = fbbpp;
- if (depth > 0)
- scrp->depth = depth;
- } else {
- scrp->depth = GLOBAL_DEFAULT_DEPTH;
- }
- }
-
- /* If any are not given, determine a default for the others */
-
- if (scrp->bitsPerPixel < 0) {
- /* The depth must be set */
- if (scrp->depth > -1) {
- if (scrp->depth == 1)
- scrp->bitsPerPixel = 1;
- else if (scrp->depth <= 4)
- scrp->bitsPerPixel = 4;
- else if (scrp->depth <= 8)
- scrp->bitsPerPixel = 8;
- else if (scrp->depth <= 16)
- scrp->bitsPerPixel = 16;
- else if (scrp->depth <= 24) {
- /*
- * Figure out if a choice is possible based on the depth24
- * and pix24 flags.
- */
- /* Check pix24 first */
- if (pix24 != Pix24DontCare) {
- if (pix24 == Pix24Use32) {
- if (DO_PIX32(depth24flags)) {
- if (CHOOSE24FOR32(depth24flags))
- scrp->bitsPerPixel = 24;
- else
- scrp->bitsPerPixel = 32;
- } else {
- nomatch = TRUE;
- }
- } else if (pix24 == Pix24Use24) {
- if (DO_PIX24(depth24flags)) {
- if (CHOOSE32FOR24(depth24flags))
- scrp->bitsPerPixel = 32;
- else
- scrp->bitsPerPixel = 24;
- } else {
- nomatch = TRUE;
- }
- }
- } else {
- if (DO_PIX32(depth24flags)) {
- if (CHOOSE24FOR32(depth24flags))
- scrp->bitsPerPixel = 24;
- else
- scrp->bitsPerPixel = 32;
- } else if (DO_PIX24(depth24flags)) {
- if (CHOOSE32FOR24(depth24flags))
- scrp->bitsPerPixel = 32;
- else
- scrp->bitsPerPixel = 24;
- }
- }
- } else if (scrp->depth <= 32)
- scrp->bitsPerPixel = 32;
- else {
- xf86DrvMsg(scrp->scrnIndex, X_ERROR,
- "Specified depth (%d) is greater than 32\n",
- scrp->depth);
- return FALSE;
- }
- } else {
- xf86DrvMsg(scrp->scrnIndex, X_ERROR,
- "xf86SetDepthBpp: internal error: depth and fbbpp"
- " are both not set\n");
- return FALSE;
- }
- if (scrp->bitsPerPixel < 0) {
- if (nomatch)
- xf86DrvMsg(scrp->scrnIndex, X_ERROR,
- "Driver can't support depth 24 pixmap format (%d)\n",
- PIX24TOBPP(pix24));
- else if ((depth24flags & (Support24bppFb | Support32bppFb)) ==
- NoDepth24Support)
- xf86DrvMsg(scrp->scrnIndex, X_ERROR,
- "Driver can't support depth 24\n");
- else
- xf86DrvMsg(scrp->scrnIndex, X_ERROR,
- "Can't find fbbpp for depth 24\n");
- return FALSE;
- }
- scrp->bitsPerPixelFrom = X_PROBED;
- }
-
- if (scrp->depth <= 0) {
- /* bitsPerPixel is already set */
- switch (scrp->bitsPerPixel) {
- case 32:
- scrp->depth = 24;
- break;
- default:
- /* 1, 4, 8, 16 and 24 */
- scrp->depth = scrp->bitsPerPixel;
- break;
- }
- scrp->depthFrom = X_PROBED;
- }
-
- /* Sanity checks */
- if (scrp->depth < 1 || scrp->depth > 32) {
- xf86DrvMsg(scrp->scrnIndex, X_ERROR,
- "Specified depth (%d) is not in the range 1-32\n",
- scrp->depth);
- return FALSE;
- }
- switch (scrp->bitsPerPixel) {
- case 1:
- case 4:
- case 8:
- case 16:
- case 24:
- case 32:
- break;
- default:
- xf86DrvMsg(scrp->scrnIndex, X_ERROR,
- "Specified fbbpp (%d) is not a permitted value\n",
- scrp->bitsPerPixel);
- return FALSE;
- }
- if (scrp->depth > scrp->bitsPerPixel) {
- xf86DrvMsg(scrp->scrnIndex, X_ERROR,
- "Specified depth (%d) is greater than the fbbpp (%d)\n",
- scrp->depth, scrp->bitsPerPixel);
- return FALSE;
- }
-
- /* set scrp->pixmap24 if the driver isn't flexible */
- if (scrp->bitsPerPixel == 24 && !DO_PIX32FOR24(depth24flags)) {
- scrp->pixmap24 = Pix24Use24;
- }
- if (scrp->bitsPerPixel == 32 && !DO_PIX24FOR32(depth24flags)) {
- scrp->pixmap24 = Pix24Use32;
- }
-
- /*
- * Find the Display subsection matching the depth/fbbpp and initialise
- * scrp->display with it.
- */
- for (i = 0, disp = scrp->confScreen->displays;
- i < scrp->confScreen->numdisplays; i++, disp++) {
- if ((disp->depth == scrp->depth && disp->fbbpp == scrp->bitsPerPixel)
- || (disp->depth == scrp->depth && disp->fbbpp <= 0)
- || (disp->fbbpp == scrp->bitsPerPixel && disp->depth <= 0)) {
- scrp->display = disp;
- break;
- }
- }
-
- /*
- * If an exact match can't be found, see if there is one with no
- * depth or fbbpp specified.
- */
- if (i == scrp->confScreen->numdisplays) {
- for (i = 0, disp = scrp->confScreen->displays;
- i < scrp->confScreen->numdisplays; i++, disp++) {
- if (disp->depth <= 0 && disp->fbbpp <= 0) {
- scrp->display = disp;
- break;
- }
- }
- }
-
- /*
- * If all else fails, create a default one.
- */
- if (i == scrp->confScreen->numdisplays) {
- scrp->confScreen->numdisplays++;
- scrp->confScreen->displays =
- xnfrealloc(scrp->confScreen->displays,
- scrp->confScreen->numdisplays * sizeof(DispRec));
- xf86DrvMsg(scrp->scrnIndex, X_INFO,
- "Creating default Display subsection in Screen section\n"
- "\t\"%s\" for depth/fbbpp %d/%d\n",
- scrp->confScreen->id, scrp->depth, scrp->bitsPerPixel);
- memset(&scrp->confScreen->displays[i], 0, sizeof(DispRec));
- scrp->confScreen->displays[i].blackColour.red = -1;
- scrp->confScreen->displays[i].blackColour.green = -1;
- scrp->confScreen->displays[i].blackColour.blue = -1;
- scrp->confScreen->displays[i].whiteColour.red = -1;
- scrp->confScreen->displays[i].whiteColour.green = -1;
- scrp->confScreen->displays[i].whiteColour.blue = -1;
- scrp->confScreen->displays[i].defaultVisual = -1;
- scrp->confScreen->displays[i].modes = xnfalloc(sizeof(char *));
- scrp->confScreen->displays[i].modes[0] = NULL;
- scrp->confScreen->displays[i].depth = depth;
- scrp->confScreen->displays[i].fbbpp = fbbpp;
- scrp->display = &scrp->confScreen->displays[i];
- }
-
- /*
- * Setup defaults for the display-wide attributes the framebuffer will
- * need. These defaults should eventually be set globally, and not
- * dependent on the screens.
- */
- scrp->imageByteOrder = IMAGE_BYTE_ORDER;
- scrp->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
- if (scrp->depth < 8) {
- /* Planar modes need these settings */
- scrp->bitmapScanlineUnit = 8;
- scrp->bitmapBitOrder = MSBFirst;
- } else {
- scrp->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
- scrp->bitmapBitOrder = BITMAP_BIT_ORDER;
- }
-
- /*
- * If an unusual depth is required, add it to scrp->formats. The formats
- * for the common depths are handled globally in InitOutput
- */
- switch (scrp->depth) {
- case 1:
- case 4:
- case 8:
- case 15:
- case 16:
- case 24:
- /* Common depths. Nothing to do for them */
- break;
- default:
- if (!xf86AddPixFormat(scrp, scrp->depth, 0, 0)) {
- xf86DrvMsg(scrp->scrnIndex, X_ERROR,
- "Can't add pixmap format for depth %d\n", scrp->depth);
- return FALSE;
- }
- }
-
- /* Initialise the framebuffer format for this screen */
- scrp->fbFormat.depth = scrp->depth;
- scrp->fbFormat.bitsPerPixel = scrp->bitsPerPixel;
- scrp->fbFormat.scanlinePad = BITMAP_SCANLINE_PAD;
-
- return TRUE;
-}
-
-/*
- * Print out the selected depth and bpp.
- */
-void
-xf86PrintDepthBpp(ScrnInfoPtr scrp)
-{
- xf86DrvMsg(scrp->scrnIndex, scrp->depthFrom, "Depth %d, ", scrp->depth);
- xf86Msg(scrp->bitsPerPixelFrom, "framebuffer bpp %d\n", scrp->bitsPerPixel);
-}
-
-/*
- * xf86SetWeight sets scrp->weight, scrp->mask, scrp->offset, and for depths
- * greater than MAX_PSEUDO_DEPTH also scrp->rgbBits.
- */
-Bool
-xf86SetWeight(ScrnInfoPtr scrp, rgb weight, rgb mask)
-{
- MessageType weightFrom = X_DEFAULT;
-
- scrp->weight.red = 0;
- scrp->weight.green = 0;
- scrp->weight.blue = 0;
-
- if (xf86Weight.red > 0 && xf86Weight.green > 0 && xf86Weight.blue > 0) {
- scrp->weight = xf86Weight;
- weightFrom = X_CMDLINE;
- } else if (scrp->display->weight.red > 0 && scrp->display->weight.green > 0
- && scrp->display->weight.blue > 0) {
- scrp->weight = scrp->display->weight;
- weightFrom = X_CONFIG;
- } else if (weight.red > 0 && weight.green > 0 && weight.blue > 0) {
- scrp->weight = weight;
- } else {
- switch (scrp->depth) {
- case 1:
- case 4:
- case 8:
- scrp->weight.red = scrp->weight.green =
- scrp->weight.blue = scrp->rgbBits;
- break;
- case 15:
- scrp->weight.red = scrp->weight.green = scrp->weight.blue = 5;
- break;
- case 16:
- scrp->weight.red = scrp->weight.blue = 5;
- scrp->weight.green = 6;
- break;
- case 18:
- scrp->weight.red = scrp->weight.green = scrp->weight.blue = 6;
- break;
- case 24:
- scrp->weight.red = scrp->weight.green = scrp->weight.blue = 8;
- break;
- case 30:
- scrp->weight.red = scrp->weight.green = scrp->weight.blue = 10;
- break;
- }
- }
-
- if (scrp->weight.red)
- xf86DrvMsg(scrp->scrnIndex, weightFrom, "RGB weight %d%d%d\n",
- (int)scrp->weight.red, (int)scrp->weight.green,
- (int)scrp->weight.blue);
-
- if (scrp->depth > MAX_PSEUDO_DEPTH &&
- (scrp->depth != scrp->weight.red + scrp->weight.green +
- scrp->weight.blue)) {
- xf86DrvMsg(scrp->scrnIndex, X_ERROR,
- "Weight given (%d%d%d) is inconsistent with the "
- "depth (%d)\n",
- (int)scrp->weight.red, (int)scrp->weight.green,
- (int)scrp->weight.blue, scrp->depth);
- return FALSE;
- }
- if (scrp->depth > MAX_PSEUDO_DEPTH && scrp->weight.red) {
- /*
- * XXX Does this even mean anything for TrueColor visuals?
- * If not, we shouldn't even be setting it here. However, this
- * matches the behaviour of 3.x versions of XFree86.
- */
- scrp->rgbBits = scrp->weight.red;
- if (scrp->weight.green > scrp->rgbBits)
- scrp->rgbBits = scrp->weight.green;
- if (scrp->weight.blue > scrp->rgbBits)
- scrp->rgbBits = scrp->weight.blue;
- }
-
- /* Set the mask and offsets */
- if (mask.red == 0 || mask.green == 0 || mask.blue == 0) {
- /* Default to a setting common to PC hardware */
- scrp->offset.red = scrp->weight.green + scrp->weight.blue;
- scrp->offset.green = scrp->weight.blue;
- scrp->offset.blue = 0;
- scrp->mask.red = ((1 << scrp->weight.red) - 1) << scrp->offset.red;
- scrp->mask.green = ((1 << scrp->weight.green) - 1)
- << scrp->offset.green;
- scrp->mask.blue = (1 << scrp->weight.blue) - 1;
- } else {
- /* Initialise to the values passed */
- scrp->mask.red = mask.red;
- scrp->mask.green = mask.green;
- scrp->mask.blue = mask.blue;
- scrp->offset.red = ffs(mask.red);
- scrp->offset.green = ffs(mask.green);
- scrp->offset.blue = ffs(mask.blue);
- }
- return TRUE;
-}
-
-Bool
-xf86SetDefaultVisual(ScrnInfoPtr scrp, int visual)
-{
- MessageType visualFrom = X_DEFAULT;
-
- if (defaultColorVisualClass >= 0) {
- scrp->defaultVisual = defaultColorVisualClass;
- visualFrom = X_CMDLINE;
- } else if (scrp->display->defaultVisual >= 0) {
- scrp->defaultVisual = scrp->display->defaultVisual;
- visualFrom = X_CONFIG;
- } else if (visual >= 0) {
- scrp->defaultVisual = visual;
- } else {
- if (scrp->depth == 1)
- scrp->defaultVisual = StaticGray;
- else if (scrp->depth == 4)
- scrp->defaultVisual = StaticColor;
- else if (scrp->depth <= MAX_PSEUDO_DEPTH)
- scrp->defaultVisual = PseudoColor;
- else
- scrp->defaultVisual = TrueColor;
- }
- switch (scrp->defaultVisual) {
- case StaticGray:
- case GrayScale:
- case StaticColor:
- case PseudoColor:
- case TrueColor:
- case DirectColor:
- xf86DrvMsg(scrp->scrnIndex, visualFrom, "Default visual is %s\n",
- xf86VisualNames[scrp->defaultVisual]);
- return TRUE;
- default:
-
- xf86DrvMsg(scrp->scrnIndex, X_ERROR,
- "Invalid default visual class (%d)\n", scrp->defaultVisual);
- return FALSE;
- }
-}
-
-#define TEST_GAMMA(g) \
- (g).red > GAMMA_ZERO || (g).green > GAMMA_ZERO || (g).blue > GAMMA_ZERO
-
-#define SET_GAMMA(g) \
- (g) > GAMMA_ZERO ? (g) : 1.0
-
-Bool
-xf86SetGamma(ScrnInfoPtr scrp, Gamma gamma)
-{
- MessageType from = X_DEFAULT;
-#if 0
- xf86MonPtr DDC = (xf86MonPtr)(scrp->monitor->DDC);
-#endif
- if (TEST_GAMMA(xf86Gamma)) {
- from = X_CMDLINE;
- scrp->gamma.red = SET_GAMMA(xf86Gamma.red);
- scrp->gamma.green = SET_GAMMA(xf86Gamma.green);
- scrp->gamma.blue = SET_GAMMA(xf86Gamma.blue);
- } else if (TEST_GAMMA(scrp->monitor->gamma)) {
- from = X_CONFIG;
- scrp->gamma.red = SET_GAMMA(scrp->monitor->gamma.red);
- scrp->gamma.green = SET_GAMMA(scrp->monitor->gamma.green);
- scrp->gamma.blue = SET_GAMMA(scrp->monitor->gamma.blue);
-#if 0
- } else if ( DDC && DDC->features.gamma > GAMMA_ZERO ) {
- from = X_PROBED;
- scrp->gamma.red = SET_GAMMA(DDC->features.gamma);
- scrp->gamma.green = SET_GAMMA(DDC->features.gamma);
- scrp->gamma.blue = SET_GAMMA(DDC->features.gamma);
- /* EDID structure version 2 gives optional seperate red, green & blue gamma values
- * in bytes 0x57-0x59 */
-#endif
- } else if (TEST_GAMMA(gamma)) {
- scrp->gamma.red = SET_GAMMA(gamma.red);
- scrp->gamma.green = SET_GAMMA(gamma.green);
- scrp->gamma.blue = SET_GAMMA(gamma.blue);
- } else {
- scrp->gamma.red = 1.0;
- scrp->gamma.green = 1.0;
- scrp->gamma.blue = 1.0;
- }
- /* Pretend we succeeded if we support better a gamma system.
- * This avoids a confusing message.
- */
- if (xf86_crtc_supports_gamma(scrp))
- return TRUE;
- xf86DrvMsg(scrp->scrnIndex, from,
- "Using gamma correction (%.1f, %.1f, %.1f)\n",
- scrp->gamma.red, scrp->gamma.green, scrp->gamma.blue);
-
- return TRUE;
-}
-
-#undef TEST_GAMMA
-#undef SET_GAMMA
-
-
-/*
- * Set the DPI from the command line option. XXX should allow it to be
- * calculated from the widthmm/heightmm values.
- */
-
-#undef MMPERINCH
-#define MMPERINCH 25.4
-
-void
-xf86SetDpi(ScrnInfoPtr pScrn, int x, int y)
-{
- MessageType from = X_DEFAULT;
- xf86MonPtr DDC = (xf86MonPtr)(pScrn->monitor->DDC);
- int ddcWidthmm, ddcHeightmm;
- int widthErr, heightErr;
-
- /* XXX Maybe there is no need for widthmm/heightmm in ScrnInfoRec */
- pScrn->widthmm = pScrn->monitor->widthmm;
- pScrn->heightmm = pScrn->monitor->heightmm;
-
- if (DDC && (DDC->features.hsize > 0 && DDC->features.vsize > 0) ) {
- /* DDC gives display size in mm for individual modes,
- * but cm for monitor
- */
- ddcWidthmm = DDC->features.hsize * 10; /* 10mm in 1cm */
- ddcHeightmm = DDC->features.vsize * 10; /* 10mm in 1cm */
- } else {
- ddcWidthmm = ddcHeightmm = 0;
- }
-
- if (monitorResolution > 0) {
- pScrn->xDpi = monitorResolution;
- pScrn->yDpi = monitorResolution;
- from = X_CMDLINE;
- } else if (pScrn->widthmm > 0 || pScrn->heightmm > 0) {
- from = X_CONFIG;
- if (pScrn->widthmm > 0) {
- pScrn->xDpi =
- (int)((double)pScrn->virtualX * MMPERINCH / pScrn->widthmm);
- }
- if (pScrn->heightmm > 0) {
- pScrn->yDpi =
- (int)((double)pScrn->virtualY * MMPERINCH / pScrn->heightmm);
- }
- if (pScrn->xDpi > 0 && pScrn->yDpi <= 0)
- pScrn->yDpi = pScrn->xDpi;
- if (pScrn->yDpi > 0 && pScrn->xDpi <= 0)
- pScrn->xDpi = pScrn->yDpi;
- xf86DrvMsg(pScrn->scrnIndex, from, "Display dimensions: (%d, %d) mm\n",
- pScrn->widthmm, pScrn->heightmm);
-
- /* Warn if config and probe disagree about display size */
- if ( ddcWidthmm && ddcHeightmm ) {
- if (pScrn->widthmm > 0) {
- widthErr = abs(ddcWidthmm - pScrn->widthmm);
- } else {
- widthErr = 0;
- }
- if (pScrn->heightmm > 0) {
- heightErr = abs(ddcHeightmm - pScrn->heightmm);
- } else {
- heightErr = 0;
- }
- if (widthErr>10 || heightErr>10) {
- /* Should include config file name for monitor here */
- xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
- "Probed monitor is %dx%d mm, using Displaysize %dx%d mm\n",
- ddcWidthmm,ddcHeightmm, pScrn->widthmm,pScrn->heightmm);
- }
- }
- } else if ( ddcWidthmm && ddcHeightmm ) {
- from = X_PROBED;
- xf86DrvMsg(pScrn->scrnIndex, from, "Display dimensions: (%d, %d) mm\n",
- ddcWidthmm, ddcHeightmm );
- pScrn->widthmm = ddcWidthmm;
- pScrn->heightmm = ddcHeightmm;
- if (pScrn->widthmm > 0) {
- pScrn->xDpi =
- (int)((double)pScrn->virtualX * MMPERINCH / pScrn->widthmm);
- }
- if (pScrn->heightmm > 0) {
- pScrn->yDpi =
- (int)((double)pScrn->virtualY * MMPERINCH / pScrn->heightmm);
- }
- if (pScrn->xDpi > 0 && pScrn->yDpi <= 0)
- pScrn->yDpi = pScrn->xDpi;
- if (pScrn->yDpi > 0 && pScrn->xDpi <= 0)
- pScrn->xDpi = pScrn->yDpi;
- } else {
- if (x > 0)
- pScrn->xDpi = x;
- else
- pScrn->xDpi = DEFAULT_DPI;
- if (y > 0)
- pScrn->yDpi = y;
- else
- pScrn->yDpi = DEFAULT_DPI;
- }
- xf86DrvMsg(pScrn->scrnIndex, from, "DPI set to (%d, %d)\n",
- pScrn->xDpi, pScrn->yDpi);
-}
-
-#undef MMPERINCH
-
-
-void
-xf86SetBlackWhitePixels(ScreenPtr pScreen)
-{
- if (xf86FlipPixels) {
- pScreen->whitePixel = 0;
- pScreen->blackPixel = 1;
- } else {
- pScreen->whitePixel = 1;
- pScreen->blackPixel = 0;
- }
-}
-
-/*
- * Function to enable/disable access to the frame buffer
- *
- * This is used when VT switching and when entering/leaving DGA direct mode.
- *
- * This has been rewritten again to eliminate the saved pixmap. The
- * devPrivate field in the screen pixmap is set to NULL to catch code
- * accidentally referencing the frame buffer while the X server is not
- * supposed to touch it.
- *
- * Here, we exchange the pixmap private data, rather than the pixmaps
- * themselves to avoid having to find and change any references to the screen
- * pixmap such as GC's, window privates etc. This also means that this code
- * does not need to know exactly how the pixmap pixels are accessed. Further,
- * this exchange is >not< done through the screen's ModifyPixmapHeader()
- * vector. This means the called frame buffer code layers can determine
- * whether they are switched in or out by keeping track of the root pixmap's
- * private data, and therefore don't need to access pScrnInfo->vtSema.
- */
-void
-xf86EnableDisableFBAccess(int scrnIndex, Bool enable)
-{
- ScrnInfoPtr pScrnInfo = xf86Screens[scrnIndex];
- ScreenPtr pScreen = pScrnInfo->pScreen;
- PixmapPtr pspix;
-
- pspix = (*pScreen->GetScreenPixmap) (pScreen);
- if (enable)
- {
- /*
- * Restore all of the clip lists on the screen
- */
- if (!xf86Resetting)
- SetRootClip (pScreen, TRUE);
-
- }
- else
- {
- /*
- * Empty all of the clip lists on the screen
- */
- SetRootClip (pScreen, FALSE);
- }
-}
-
-/* Print driver messages in the standard format */
-
-#undef PREFIX_SIZE
-#define PREFIX_SIZE 14
-
-void
-xf86VDrvMsgVerb(int scrnIndex, MessageType type, int verb, const char *format,
- va_list args)
-{
- char *tmpFormat;
-
- /* Prefix the scrnIndex name to the format string. */
- if (scrnIndex >= 0 && scrnIndex < xf86NumScreens &&
- xf86Screens[scrnIndex]->name) {
- tmpFormat = malloc(strlen(format) +
- strlen(xf86Screens[scrnIndex]->name) +
- PREFIX_SIZE + 1);
- if (!tmpFormat)
- return;
-
- snprintf(tmpFormat, PREFIX_SIZE + 1, "%s(%d): ",
- xf86Screens[scrnIndex]->name, scrnIndex);
-
- strcat(tmpFormat, format);
- LogVMessageVerb(type, verb, tmpFormat, args);
- free(tmpFormat);
- } else
- LogVMessageVerb(type, verb, format, args);
-}
-#undef PREFIX_SIZE
-
-/* Print driver messages, with verbose level specified directly */
-void
-xf86DrvMsgVerb(int scrnIndex, MessageType type, int verb, const char *format,
- ...)
-{
- va_list ap;
-
- va_start(ap, format);
- xf86VDrvMsgVerb(scrnIndex, type, verb, format, ap);
- va_end(ap);
-}
-
-/* Print driver messages, with verbose level of 1 (default) */
-void
-xf86DrvMsg(int scrnIndex, MessageType type, const char *format, ...)
-{
- va_list ap;
-
- va_start(ap, format);
- xf86VDrvMsgVerb(scrnIndex, type, 1, format, ap);
- va_end(ap);
-}
-
-/* Print input driver messages in the standard format of
- <driver>: <device name>: <message> */
-void
-xf86VIDrvMsgVerb(InputInfoPtr dev, MessageType type, int verb, const char *format,
- va_list args)
-{
- char *msg;
-
- if (asprintf(&msg, "%s: %s: %s", dev->drv->driverName, dev->name, format)
- == -1) {
- LogVMessageVerb(type, verb, "%s", args);
- } else {
- LogVMessageVerb(type, verb, msg, args);
- free(msg);
- }
-}
-
-/* Print input driver message, with verbose level specified directly */
-void
-xf86IDrvMsgVerb(InputInfoPtr dev, MessageType type, int verb, const char *format,
- ...)
-{
- va_list ap;
-
- va_start(ap, format);
- xf86VIDrvMsgVerb(dev, type, verb, format, ap);
- va_end(ap);
-}
-
-/* Print input driver messages, with verbose level of 1 (default) */
-void
-xf86IDrvMsg(InputInfoPtr dev, MessageType type, const char *format, ...)
-{
- va_list ap;
-
- va_start(ap, format);
- xf86VIDrvMsgVerb(dev, type, 1, format, ap);
- va_end(ap);
-}
-
-
-/* Print non-driver messages with verbose level specified directly */
-void
-xf86MsgVerb(MessageType type, int verb, const char *format, ...)
-{
- va_list ap;
-
- va_start(ap, format);
- LogVMessageVerb(type, verb, format, ap);
- va_end(ap);
-}
-
-/* Print non-driver messages with verbose level of 1 (default) */
-void
-xf86Msg(MessageType type, const char *format, ...)
-{
- va_list ap;
-
- va_start(ap, format);
- LogVMessageVerb(type, 1, format, ap);
- va_end(ap);
-}
-
-/* Just like ErrorF, but with the verbose level checked */
-void
-xf86ErrorFVerb(int verb, const char *format, ...)
-{
- va_list ap;
-
- va_start(ap, format);
- if (xf86Verbose >= verb || xf86LogVerbose >= verb)
- LogVWrite(verb, format, ap);
- va_end(ap);
-}
-
-/* Like xf86ErrorFVerb, but with an implied verbose level of 1 */
-void
-xf86ErrorF(const char *format, ...)
-{
- va_list ap;
-
- va_start(ap, format);
- if (xf86Verbose >= 1 || xf86LogVerbose >= 1)
- LogVWrite(1, format, ap);
- va_end(ap);
-}
-
-
-void
-xf86LogInit(void)
-{
- char *lf = NULL;
-
-#define LOGSUFFIX ".log"
-#define LOGOLDSUFFIX ".old"
-
- /* Get the log file name */
- if (xf86LogFileFrom == X_DEFAULT) {
- /* Append the display number and ".log" */
- if (asprintf(&lf, "%s%%s" LOGSUFFIX, xf86LogFile) == -1)
- FatalError("Cannot allocate space for the log file name\n");
- xf86LogFile = lf;
- }
-
- xf86LogFile = LogInit(xf86LogFile, LOGOLDSUFFIX);
- xf86LogFileWasOpened = TRUE;
-
- xf86SetVerbosity(xf86Verbose);
- xf86SetLogVerbosity(xf86LogVerbose);
-
-#undef LOGSUFFIX
-#undef LOGOLDSUFFIX
-
- free(lf);
-}
-
-void
-xf86CloseLog(enum ExitCode error)
-{
- LogClose(error);
-}
-
-
-/*
- * Drivers can use these for using their own SymTabRecs.
- */
-
-const char *
-xf86TokenToString(SymTabPtr table, int token)
-{
- int i;
-
- for (i = 0; table[i].token >= 0 && table[i].token != token; i++)
- ;
-
- if (table[i].token < 0)
- return NULL;
- else
- return table[i].name;
-}
-
-int
-xf86StringToToken(SymTabPtr table, const char *string)
-{
- int i;
-
- if (string == NULL)
- return -1;
-
- for (i = 0; table[i].token >= 0 && xf86NameCmp(string, table[i].name); i++)
- ;
-
- return table[i].token;
-}
-
-/*
- * helper to display the clocks found on a card
- */
-void
-xf86ShowClocks(ScrnInfoPtr scrp, MessageType from)
-{
- int j;
-
- xf86DrvMsg(scrp->scrnIndex, from, "Pixel clocks available:");
- for (j=0; j < scrp->numClocks; j++) {
- if ((j % 4) == 0) {
- xf86ErrorF("\n");
- xf86DrvMsg(scrp->scrnIndex, from, "pixel clocks:");
- }
- xf86ErrorF(" %7.3f", (double)scrp->clock[j] / 1000.0);
- }
- xf86ErrorF("\n");
-}
-
-
-/*
- * This prints out the driver identify message, including the names of
- * the supported chipsets.
- *
- * XXX This makes assumptions about the line width, etc. Maybe we could
- * use a more general "pretty print" function for messages.
- */
-void
-xf86PrintChipsets(const char *drvname, const char *drvmsg, SymTabPtr chips)
-{
- int len, i;
-
- len = 6 + strlen(drvname) + 2 + strlen(drvmsg) + 2;
- xf86Msg(X_INFO, "%s: %s:", drvname, drvmsg);
- for (i = 0; chips[i].name != NULL; i++) {
- if (i != 0) {
- xf86ErrorF(",");
- len++;
- }
- if (len + 2 + strlen(chips[i].name) < 78) {
- xf86ErrorF(" ");
- len++;
- } else {
- xf86ErrorF("\n\t");
- len = 8;
- }
- xf86ErrorF("%s", chips[i].name);
- len += strlen(chips[i].name);
- }
- xf86ErrorF("\n");
-}
-
-
-int
-xf86MatchDevice(const char *drivername, GDevPtr **sectlist)
-{
- GDevPtr gdp, *pgdp = NULL;
- confScreenPtr screensecptr;
- int i,j;
-
- if (sectlist)
- *sectlist = NULL;
-
- /*
- * This can happen when running Xorg -showopts and a module like ati
- * or vmware tries to load its submodules when xf86ConfigLayout is empty
- */
- if (!xf86ConfigLayout.screens)
- return 0;
-
- /*
- * This is a very important function that matches the device sections
- * as they show up in the config file with the drivers that the server
- * loads at run time.
- *
- * ChipProbe can call
- * int xf86MatchDevice(char * drivername, GDevPtr ** sectlist)
- * with its driver name. The function allocates an array of GDevPtr and
- * returns this via sectlist and returns the number of elements in
- * this list as return value. 0 means none found, -1 means fatal error.
- *
- * It can figure out which of the Device sections to use for which card
- * (using things like the Card statement, etc). For single headed servers
- * there will of course be just one such Device section.
- */
- i = 0;
-
- /*
- * first we need to loop over all the Screens sections to get to all
- * 'active' device sections
- */
- for (j=0; xf86ConfigLayout.screens[j].screen != NULL; j++) {
- screensecptr = xf86ConfigLayout.screens[j].screen;
- if ((screensecptr->device->driver != NULL)
- && (xf86NameCmp( screensecptr->device->driver,drivername) == 0)
- && (! screensecptr->device->claimed)) {
- /*
- * we have a matching driver that wasn't claimed, yet
- */
- pgdp = xnfrealloc(pgdp, (i + 2) * sizeof(GDevPtr));
- pgdp[i++] = screensecptr->device;
- }
- }
-
- /* Then handle the inactive devices */
- j = 0;
- while (xf86ConfigLayout.inactives[j].identifier) {
- gdp = &xf86ConfigLayout.inactives[j];
- if (gdp->driver && !gdp->claimed &&
- !xf86NameCmp(gdp->driver,drivername)) {
- /* we have a matching driver that wasn't claimed yet */
- pgdp = xnfrealloc(pgdp, (i + 2) * sizeof(GDevPtr));
- pgdp[i++] = gdp;
- }
- j++;
- }
-
- /*
- * make the array NULL terminated and return its address
- */
- if (i)
- pgdp[i] = NULL;
-
- if (sectlist)
- *sectlist = pgdp;
- else
- free(pgdp);
- return i;
-}
-
-/*
- * xf86GetClocks -- get the dot-clocks via a BIG BAD hack ...
- */
-void
-xf86GetClocks(ScrnInfoPtr pScrn, int num, Bool (*ClockFunc)(ScrnInfoPtr, int),
- void (*ProtectRegs)(ScrnInfoPtr, Bool),
- void (*BlankScreen)(ScrnInfoPtr, Bool), IOADDRESS vertsyncreg,
- int maskval, int knownclkindex, int knownclkvalue)
-{
- register int status = vertsyncreg;
- unsigned long i, cnt, rcnt, sync;
-
- /* First save registers that get written on */
- (*ClockFunc)(pScrn, CLK_REG_SAVE);
-
- if (num > MAXCLOCKS)
- num = MAXCLOCKS;
-
- for (i = 0; i < num; i++)
- {
- if (ProtectRegs)
- (*ProtectRegs)(pScrn, TRUE);
- if (!(*ClockFunc)(pScrn, i))
- {
- pScrn->clock[i] = -1;
- continue;
- }
- if (ProtectRegs)
- (*ProtectRegs)(pScrn, FALSE);
- if (BlankScreen)
- (*BlankScreen)(pScrn, FALSE);
-
- usleep(50000); /* let VCO stabilise */
-
- cnt = 0;
- sync = 200000;
-
- while ((inb(status) & maskval) == 0x00)
- if (sync-- == 0) goto finish;
- /* Something appears to be happening, so reset sync count */
- sync = 200000;
- while ((inb(status) & maskval) == maskval)
- if (sync-- == 0) goto finish;
- /* Something appears to be happening, so reset sync count */
- sync = 200000;
- while ((inb(status) & maskval) == 0x00)
- if (sync-- == 0) goto finish;
-
- for (rcnt = 0; rcnt < 5; rcnt++)
- {
- while (!(inb(status) & maskval))
- cnt++;
- while ((inb(status) & maskval))
- cnt++;
- }
-
-finish:
- pScrn->clock[i] = cnt ? cnt : -1;
- if (BlankScreen)
- (*BlankScreen)(pScrn, TRUE);
- }
-
- for (i = 0; i < num; i++)
- {
- if (i != knownclkindex)
- {
- if (pScrn->clock[i] == -1)
- {
- pScrn->clock[i] = 0;
- }
- else
- {
- pScrn->clock[i] = (int)(0.5 +
- (((float)knownclkvalue) * pScrn->clock[knownclkindex]) /
- (pScrn->clock[i]));
- /* Round to nearest 10KHz */
- pScrn->clock[i] += 5;
- pScrn->clock[i] /= 10;
- pScrn->clock[i] *= 10;
- }
- }
- }
-
- pScrn->clock[knownclkindex] = knownclkvalue;
- pScrn->numClocks = num;
-
- /* Restore registers that were written on */
- (*ClockFunc)(pScrn, CLK_REG_RESTORE);
-}
-
-const char *
-xf86GetVisualName(int visual)
-{
- if (visual < 0 || visual > DirectColor)
- return NULL;
-
- return xf86VisualNames[visual];
-}
-
-
-int
-xf86GetVerbosity(void)
-{
- return max(xf86Verbose, xf86LogVerbose);
-}
-
-Pix24Flags
-xf86GetPix24(void)
-{
- return xf86Info.pixmap24;
-}
-
-
-int
-xf86GetDepth(void)
-{
- return xf86Depth;
-}
-
-
-rgb
-xf86GetWeight(void)
-{
- return xf86Weight;
-}
-
-
-Gamma
-xf86GetGamma(void)
-{
- return xf86Gamma;
-}
-
-
-Bool
-xf86GetFlipPixels(void)
-{
- return xf86FlipPixels;
-}
-
-
-const char *
-xf86GetServerName(void)
-{
- return xf86ServerName;
-}
-
-
-Bool
-xf86ServerIsExiting(void)
-{
- return (dispatchException & DE_TERMINATE) == DE_TERMINATE;
-}
-
-
-Bool
-xf86ServerIsResetting(void)
-{
- return xf86Resetting;
-}
-
-
-Bool
-xf86ServerIsInitialising(void)
-{
- return xf86Initialising;
-}
-
-
-Bool
-xf86ServerIsOnlyDetecting(void)
-{
- return xf86DoConfigure;
-}
-
-
-Bool
-xf86CaughtSignal(void)
-{
- return xf86Info.caughtSignal;
-}
-
-
-Bool
-xf86GetVidModeAllowNonLocal(void)
-{
- return xf86Info.vidModeAllowNonLocal;
-}
-
-
-Bool
-xf86GetVidModeEnabled(void)
-{
- return xf86Info.vidModeEnabled;
-}
-
-Bool
-xf86GetModInDevAllowNonLocal(void)
-{
- return xf86Info.miscModInDevAllowNonLocal;
-}
-
-
-Bool
-xf86GetModInDevEnabled(void)
-{
- return xf86Info.miscModInDevEnabled;
-}
-
-
-Bool
-xf86GetAllowMouseOpenFail(void)
-{
- return xf86Info.allowMouseOpenFail;
-}
-
-
-Bool
-xf86IsPc98(void)
-{
-#if SUPPORT_PC98
- return xf86Info.pc98;
-#else
- return FALSE;
-#endif
-}
-
-void
-xf86DisableRandR(void)
-{
- xf86Info.disableRandR = TRUE;
- xf86Info.randRFrom = X_PROBED;
-}
-
-CARD32
-xf86GetModuleVersion(pointer module)
-{
- return (CARD32)LoaderGetModuleVersion(module);
-}
-
-pointer
-xf86LoadDrvSubModule(DriverPtr drv, const char *name)
-{
- pointer ret;
- int errmaj = 0, errmin = 0;
-
- ret = LoadSubModule(drv->module, name, NULL, NULL, NULL, NULL,
- &errmaj, &errmin);
- if (!ret)
- LoaderErrorMsg(NULL, name, errmaj, errmin);
- return ret;
-}
-
-pointer
-xf86LoadSubModule(ScrnInfoPtr pScrn, const char *name)
-{
- pointer ret;
- int errmaj = 0, errmin = 0;
-
- ret = LoadSubModule(pScrn->module, name, NULL, NULL, NULL, NULL,
- &errmaj, &errmin);
- if (!ret)
- LoaderErrorMsg(pScrn->name, name, errmaj, errmin);
- return ret;
-}
-
-/*
- * xf86LoadOneModule loads a single module.
- */
-pointer
-xf86LoadOneModule(char *name, pointer opt)
-{
- int errmaj, errmin;
- char *Name;
- pointer mod;
-
- if (!name)
- return NULL;
-
- /* Normalise the module name */
- Name = xf86NormalizeName(name);
-
- /* Skip empty names */
- if (Name == NULL)
- return NULL;
- if (*Name == '\0') {
- free(Name);
- return NULL;
- }
-
- mod = LoadModule(Name, NULL, NULL, NULL, opt, NULL, &errmaj, &errmin);
- if (!mod)
- LoaderErrorMsg(NULL, Name, errmaj, errmin);
- free(Name);
- return mod;
-}
-
-void
-xf86UnloadSubModule(pointer mod)
-{
- /*
- * This is disabled for now. The loader isn't smart enough yet to undo
- * relocations.
- */
-#if 0
- UnloadSubModule(mod);
-#endif
-}
-
-Bool
-xf86LoaderCheckSymbol(const char *name)
-{
- return LoaderSymbol(name) != NULL;
-}
-
-typedef enum {
- OPTION_BACKING_STORE
-} BSOpts;
-
-static const OptionInfoRec BSOptions[] = {
- { OPTION_BACKING_STORE, "BackingStore", OPTV_BOOLEAN, {0}, FALSE },
- { -1, NULL, OPTV_NONE, {0}, FALSE }
-};
-
-void
-xf86SetBackingStore(ScreenPtr pScreen)
-{
- Bool useBS = FALSE;
- MessageType from = X_DEFAULT;
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- OptionInfoPtr options;
-
- options = xnfalloc(sizeof(BSOptions));
- (void)memcpy(options, BSOptions, sizeof(BSOptions));
- xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options);
-
- /* check for commandline option here */
- if (xf86bsEnableFlag) {
- from = X_CMDLINE;
- useBS = TRUE;
- } else if (xf86bsDisableFlag) {
- from = X_CMDLINE;
- useBS = FALSE;
- } else {
- if (xf86GetOptValBool(options, OPTION_BACKING_STORE, &useBS))
- from = X_CONFIG;
- }
- free(options);
- pScreen->backingStoreSupport = useBS ? Always : NotUseful;
- if (serverGeneration == 1)
- xf86DrvMsg(pScreen->myNum, from, "Backing store %s\n",
- useBS ? "enabled" : "disabled");
-}
-
-
-typedef enum {
- OPTION_SILKEN_MOUSE
-} SMOpts;
-
-static const OptionInfoRec SMOptions[] = {
- { OPTION_SILKEN_MOUSE, "SilkenMouse", OPTV_BOOLEAN, {0}, FALSE },
- { -1, NULL, OPTV_NONE, {0}, FALSE }
-};
-
-void
-xf86SetSilkenMouse (ScreenPtr pScreen)
-{
- Bool useSM = TRUE;
- MessageType from = X_DEFAULT;
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- OptionInfoPtr options;
-
- options = xnfalloc(sizeof(SMOptions));
- (void)memcpy(options, SMOptions, sizeof(SMOptions));
- xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options);
-
- /* check for commandline option here */
- /* disable if screen shares resources */
- /* TODO VGA arb disable silken mouse */
- if (xf86silkenMouseDisableFlag) {
- from = X_CMDLINE;
- useSM = FALSE;
- } else {
- if (xf86GetOptValBool(options, OPTION_SILKEN_MOUSE, &useSM))
- from = X_CONFIG;
- }
- free(options);
- /*
- * XXX quick hack to report correctly for OSs that can't do SilkenMouse
- * yet. Should handle this differently so that alternate async methods
- * work correctly with this too.
- */
- pScrn->silkenMouse = useSM && xf86Info.useSIGIO && xf86SIGIOSupported();
- if (serverGeneration == 1)
- xf86DrvMsg(pScreen->myNum, from, "Silken mouse %s\n",
- pScrn->silkenMouse ? "enabled" : "disabled");
-}
-
-/* Wrote this function for the PM2 Xv driver, preliminary. */
-
-pointer
-xf86FindXvOptions(int scrnIndex, int adaptor_index, char *port_name,
- char **adaptor_name, pointer *adaptor_options)
-{
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
- confXvAdaptorPtr adaptor;
- int i;
-
- if (adaptor_index >= pScrn->confScreen->numxvadaptors) {
- if (adaptor_name) *adaptor_name = NULL;
- if (adaptor_options) *adaptor_options = NULL;
- return NULL;
- }
-
- adaptor = &pScrn->confScreen->xvadaptors[adaptor_index];
- if (adaptor_name) *adaptor_name = adaptor->identifier;
- if (adaptor_options) *adaptor_options = adaptor->options;
-
- for (i = 0; i < adaptor->numports; i++)
- if (!xf86NameCmp(adaptor->ports[i].identifier, port_name))
- return adaptor->ports[i].options;
-
- return NULL;
-}
-
-/* Rather than duplicate loader's get OS function, just include it directly */
-#define LoaderGetOS xf86GetOS
-#include "loader/os.c"
-
-static void
-xf86ConfigFbEntityInactive(EntityInfoPtr pEnt, EntityProc init,
- EntityProc enter, EntityProc leave, pointer private)
-{
- ScrnInfoPtr pScrn;
-
- if ((pScrn = xf86FindScreenForEntity(pEnt->index)))
- xf86RemoveEntityFromScreen(pScrn,pEnt->index);
- xf86SetEntityFuncs(pEnt->index,init,enter,leave,private);
-}
-
-ScrnInfoPtr
-xf86ConfigFbEntity(ScrnInfoPtr pScrn, int scrnFlag, int entityIndex,
- EntityProc init, EntityProc enter, EntityProc leave,
- pointer private)
-{
- EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex);
- if (!pEnt) return pScrn;
-
- if (!(pEnt->location.type == BUS_NONE)) {
- free(pEnt);
- return pScrn;
- }
-
- if (!pEnt->active) {
- xf86ConfigFbEntityInactive(pEnt, init, enter, leave, private);
- free(pEnt);
- return pScrn;
- }
-
- if (!pScrn)
- pScrn = xf86AllocateScreen(pEnt->driver,scrnFlag);
- xf86AddEntityToScreen(pScrn,entityIndex);
-
- xf86SetEntityFuncs(entityIndex,init,enter,leave,private);
-
- free(pEnt);
- return pScrn;
-}
-
-Bool
-xf86IsScreenPrimary(int scrnIndex)
-{
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
- int i;
-
- for (i=0 ; i < pScrn->numEntities; i++) {
- if (xf86IsEntityPrimary(i))
- return TRUE;
- }
- return FALSE;
-}
-
-int
-xf86RegisterRootWindowProperty(int ScrnIndex, Atom property, Atom type,
- int format, unsigned long len, pointer value )
-{
- RootWinPropPtr pNewProp = NULL, pRegProp;
- int i;
- Bool existing = FALSE;
-
- DebugF("xf86RegisterRootWindowProperty(%d, %ld, %ld, %d, %ld, %p)\n",
- ScrnIndex, property, type, format, len, value);
-
- if (ScrnIndex<0 || ScrnIndex>=xf86NumScreens) {
- return BadMatch;
- }
-
- if (xf86RegisteredPropertiesTable &&
- xf86RegisteredPropertiesTable[ScrnIndex]) {
- for (pNewProp = xf86RegisteredPropertiesTable[ScrnIndex];
- pNewProp; pNewProp = pNewProp->next) {
- if (strcmp(pNewProp->name, NameForAtom(property)) == 0)
- break;
- }
- }
-
- if (!pNewProp) {
- if ((pNewProp = (RootWinPropPtr)malloc(sizeof(RootWinProp))) == NULL) {
- return BadAlloc;
- }
- /*
- * We will put this property at the end of the list so that
- * the changes are made in the order they were requested.
- */
- pNewProp->next = NULL;
- } else {
- free(pNewProp->name);
- existing = TRUE;
- }
-
- pNewProp->name = xnfstrdup(NameForAtom(property));
- pNewProp->type = type;
- pNewProp->format = format;
- pNewProp->size = len;
- pNewProp->data = value;
-
- DebugF("new property filled\n");
-
- if (NULL==xf86RegisteredPropertiesTable) {
- DebugF("creating xf86RegisteredPropertiesTable[] size %d\n",
- xf86NumScreens);
- if ( NULL==(xf86RegisteredPropertiesTable=(RootWinPropPtr*)xnfcalloc(sizeof(RootWinProp),xf86NumScreens) )) {
- return BadAlloc;
- }
- for (i=0; i<xf86NumScreens; i++) {
- xf86RegisteredPropertiesTable[i] = NULL;
- }
- }
-
- DebugF("xf86RegisteredPropertiesTable %p\n",
- (void *)xf86RegisteredPropertiesTable);
- DebugF("xf86RegisteredPropertiesTable[%d] %p\n",
- ScrnIndex, (void *)xf86RegisteredPropertiesTable[ScrnIndex]);
-
- if (!existing) {
- if ( xf86RegisteredPropertiesTable[ScrnIndex] == NULL) {
- xf86RegisteredPropertiesTable[ScrnIndex] = pNewProp;
- } else {
- pRegProp = xf86RegisteredPropertiesTable[ScrnIndex];
- while (pRegProp->next != NULL) {
- DebugF("- next %p\n", (void *)pRegProp);
- pRegProp = pRegProp->next;
- }
- pRegProp->next = pNewProp;
- }
- }
- DebugF("xf86RegisterRootWindowProperty succeeded\n");
- return Success;
-}
-
-Bool
-xf86IsUnblank(int mode)
-{
- switch(mode) {
- case SCREEN_SAVER_OFF:
- case SCREEN_SAVER_FORCER:
- return TRUE;
- case SCREEN_SAVER_ON:
- case SCREEN_SAVER_CYCLE:
- return FALSE;
- default:
- xf86MsgVerb(X_WARNING, 0, "Unexpected save screen mode: %d\n", mode);
- return TRUE;
- }
-}
-
-void
-xf86MotionHistoryAllocate(InputInfoPtr pInfo)
-{
- AllocateMotionHistory(pInfo->dev);
-}
+/*
+ * Copyright (c) 1997-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).
+ */
+
+/*
+ * Authors: Dirk Hohndel <hohndel@XFree86.Org>
+ * David Dawes <dawes@XFree86.Org>
+ * ... and others
+ *
+ * This file includes the helper functions that the server provides for
+ * different drivers.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "os.h"
+#include "servermd.h"
+#include "pixmapstr.h"
+#include "windowstr.h"
+#include "propertyst.h"
+#include "gcstruct.h"
+#include "loaderProcs.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "micmap.h"
+#include "xf86DDC.h"
+#include "xf86Xinput.h"
+#include "xf86InPriv.h"
+#include "mivalidate.h"
+#include "xf86Crtc.h"
+
+/* For xf86GetClocks */
+#if defined(CSRG_BASED) || defined(__GNU__)
+#define HAS_SETPRIORITY
+#include <sys/resource.h>
+#endif
+
+static int xf86ScrnInfoPrivateCount = 0;
+
+
+/* Add a pointer to a new DriverRec to xf86DriverList */
+
+void
+xf86AddDriver(DriverPtr driver, pointer module, int flags)
+{
+ /* Don't add null entries */
+ if (!driver)
+ return;
+
+ if (xf86DriverList == NULL)
+ xf86NumDrivers = 0;
+
+ xf86NumDrivers++;
+ xf86DriverList = xnfrealloc(xf86DriverList,
+ xf86NumDrivers * sizeof(DriverPtr));
+ xf86DriverList[xf86NumDrivers - 1] = xnfalloc(sizeof(DriverRec));
+ if (flags & HaveDriverFuncs)
+ *xf86DriverList[xf86NumDrivers - 1] = *driver;
+ else {
+ (void) memset( xf86DriverList[xf86NumDrivers - 1], 0,
+ sizeof( DriverRec ) );
+ (void) memcpy( xf86DriverList[xf86NumDrivers - 1], driver,
+ sizeof(DriverRec1));
+
+ }
+ xf86DriverList[xf86NumDrivers - 1]->module = module;
+ xf86DriverList[xf86NumDrivers - 1]->refCount = 0;
+}
+
+void
+xf86DeleteDriver(int drvIndex)
+{
+ if (xf86DriverList[drvIndex]
+ && (!xf86DriverHasEntities(xf86DriverList[drvIndex]))) {
+ if (xf86DriverList[drvIndex]->module)
+ UnloadModule(xf86DriverList[drvIndex]->module);
+ free(xf86DriverList[drvIndex]);
+ xf86DriverList[drvIndex] = NULL;
+ }
+}
+
+/* Add a pointer to a new InputDriverRec to xf86InputDriverList */
+
+void
+xf86AddInputDriver(InputDriverPtr driver, pointer module, int flags)
+{
+ /* Don't add null entries */
+ if (!driver)
+ return;
+
+ if (xf86InputDriverList == NULL)
+ xf86NumInputDrivers = 0;
+
+ xf86NumInputDrivers++;
+ xf86InputDriverList = xnfrealloc(xf86InputDriverList,
+ xf86NumInputDrivers * sizeof(InputDriverPtr));
+ xf86InputDriverList[xf86NumInputDrivers - 1] =
+ xnfalloc(sizeof(InputDriverRec));
+ *xf86InputDriverList[xf86NumInputDrivers - 1] = *driver;
+ xf86InputDriverList[xf86NumInputDrivers - 1]->module = module;
+}
+
+void
+xf86DeleteInputDriver(int drvIndex)
+{
+ if (xf86InputDriverList[drvIndex] && xf86InputDriverList[drvIndex]->module)
+ UnloadModule(xf86InputDriverList[drvIndex]->module);
+ free(xf86InputDriverList[drvIndex]);
+ xf86InputDriverList[drvIndex] = NULL;
+}
+
+InputDriverPtr
+xf86LookupInputDriver(const char *name)
+{
+ int i;
+
+ for (i = 0; i < xf86NumInputDrivers; i++) {
+ if (xf86InputDriverList[i] && xf86InputDriverList[i]->driverName &&
+ xf86NameCmp(name, xf86InputDriverList[i]->driverName) == 0)
+ return xf86InputDriverList[i];
+ }
+ return NULL;
+}
+
+InputInfoPtr
+xf86LookupInput(const char *name)
+{
+ InputInfoPtr p;
+
+ for (p = xf86InputDevs; p != NULL; p = p->next) {
+ if (strcmp(name, p->name) == 0)
+ return p;
+ }
+
+ return NULL;
+}
+
+/* Allocate a new ScrnInfoRec in xf86Screens */
+
+ScrnInfoPtr
+xf86AllocateScreen(DriverPtr drv, int flags)
+{
+ int i;
+
+ if (xf86Screens == NULL)
+ xf86NumScreens = 0;
+
+ i = xf86NumScreens++;
+ xf86Screens = xnfrealloc(xf86Screens, xf86NumScreens * sizeof(ScrnInfoPtr));
+ xf86Screens[i] = xnfcalloc(sizeof(ScrnInfoRec), 1);
+ xf86Screens[i]->scrnIndex = i; /* Changes when a screen is removed */
+ xf86Screens[i]->origIndex = i; /* This never changes */
+ xf86Screens[i]->privates = xnfcalloc(sizeof(DevUnion),
+ xf86ScrnInfoPrivateCount);
+ /*
+ * EnableDisableFBAccess now gets initialized in InitOutput()
+ * xf86Screens[i]->EnableDisableFBAccess = xf86EnableDisableFBAccess;
+ */
+
+ xf86Screens[i]->drv = drv;
+ drv->refCount++;
+ xf86Screens[i]->module = DuplicateModule(drv->module, NULL);
+
+ xf86Screens[i]->DriverFunc = drv->driverFunc;
+
+ return xf86Screens[i];
+}
+
+
+/*
+ * Remove an entry from xf86Screens. Ideally it should free all allocated
+ * data. To do this properly may require a driver hook.
+ */
+
+void
+xf86DeleteScreen(int scrnIndex, int flags)
+{
+ ScrnInfoPtr pScrn;
+ int i;
+
+ /* First check if the screen is valid */
+ if (xf86NumScreens == 0 || xf86Screens == NULL)
+ return;
+
+ if (scrnIndex > xf86NumScreens - 1)
+ return;
+
+ if (!(pScrn = xf86Screens[scrnIndex]))
+ return;
+
+ /* If a FreeScreen function is defined, call it here */
+ if (pScrn->FreeScreen != NULL)
+ pScrn->FreeScreen(scrnIndex, 0);
+
+ while (pScrn->modes)
+ xf86DeleteMode(&pScrn->modes, pScrn->modes);
+
+ while (pScrn->modePool)
+ xf86DeleteMode(&pScrn->modePool, pScrn->modePool);
+
+ xf86OptionListFree(pScrn->options);
+
+ if (pScrn->module)
+ UnloadModule(pScrn->module);
+
+ if (pScrn->drv)
+ pScrn->drv->refCount--;
+
+ free(pScrn->privates);
+
+ xf86ClearEntityListForScreen(scrnIndex);
+
+ free(pScrn);
+
+ /* Move the other entries down, updating their scrnIndex fields */
+
+ xf86NumScreens--;
+
+ for (i = scrnIndex; i < xf86NumScreens; i++) {
+ xf86Screens[i] = xf86Screens[i + 1];
+ xf86Screens[i]->scrnIndex = i;
+ /* Also need to take care of the screen layout settings */
+ }
+}
+
+/*
+ * Allocate a private in ScrnInfoRec.
+ */
+
+int
+xf86AllocateScrnInfoPrivateIndex(void)
+{
+ int idx, i;
+ ScrnInfoPtr pScr;
+ DevUnion *nprivs;
+
+ idx = xf86ScrnInfoPrivateCount++;
+ for (i = 0; i < xf86NumScreens; i++) {
+ pScr = xf86Screens[i];
+ nprivs = xnfrealloc(pScr->privates,
+ xf86ScrnInfoPrivateCount * sizeof(DevUnion));
+ /* Zero the new private */
+ memset(&nprivs[idx], 0, sizeof(DevUnion));
+ pScr->privates = nprivs;
+ }
+ return idx;
+}
+
+Bool
+xf86AddPixFormat(ScrnInfoPtr pScrn, int depth, int bpp, int pad)
+{
+ int i;
+
+ if (pScrn->numFormats >= MAXFORMATS)
+ return FALSE;
+
+ if (bpp <= 0) {
+ if (depth == 1)
+ bpp = 1;
+ else if (depth <= 8)
+ bpp = 8;
+ else if (depth <= 16)
+ bpp = 16;
+ else if (depth <= 32)
+ bpp = 32;
+ else
+ return FALSE;
+ }
+ if (pad <= 0)
+ pad = BITMAP_SCANLINE_PAD;
+
+ i = pScrn->numFormats++;
+ pScrn->formats[i].depth = depth;
+ pScrn->formats[i].bitsPerPixel = bpp;
+ pScrn->formats[i].scanlinePad = pad;
+ return TRUE;
+}
+
+/*
+ * Set the depth we are using based on (in the following order of preference):
+ * - values given on the command line
+ * - values given in the config file
+ * - values provided by the driver
+ * - an overall default when nothing else is given
+ *
+ * Also find a Display subsection matching the depth/bpp found.
+ *
+ * Sets the following ScrnInfoRec fields:
+ * bitsPerPixel, pixmap24, depth, display, imageByteOrder,
+ * bitmapScanlinePad, bitmapScanlineUnit, bitmapBitOrder, numFormats,
+ * formats, fbFormat.
+ */
+
+/* Can the screen handle 24 bpp pixmaps */
+#define DO_PIX24(f) ((f & Support24bppFb) || \
+ ((f & Support32bppFb) && (f & SupportConvert24to32)))
+
+/* Can the screen handle 32 bpp pixmaps */
+#define DO_PIX32(f) ((f & Support32bppFb) || \
+ ((f & Support24bppFb) && (f & SupportConvert32to24)))
+
+/* Does the screen prefer 32bpp fb for 24bpp pixmaps */
+#define CHOOSE32FOR24(f) ((f & Support32bppFb) && (f & SupportConvert24to32) \
+ && (f & PreferConvert24to32))
+
+/* Does the screen prefer 24bpp fb for 32bpp pixmaps */
+#define CHOOSE24FOR32(f) ((f & Support24bppFb) && (f & SupportConvert32to24) \
+ && (f & PreferConvert32to24))
+
+/* Can the screen handle 32bpp pixmaps for 24bpp fb */
+#define DO_PIX32FOR24(f) ((f & Support24bppFb) && (f & SupportConvert32to24))
+
+/* Can the screen handle 24bpp pixmaps for 32bpp fb */
+#define DO_PIX24FOR32(f) ((f & Support32bppFb) && (f & SupportConvert24to32))
+
+#ifndef GLOBAL_DEFAULT_DEPTH
+#define GLOBAL_DEFAULT_DEPTH 24
+#endif
+
+Bool
+xf86SetDepthBpp(ScrnInfoPtr scrp, int depth, int dummy, int fbbpp,
+ int depth24flags)
+{
+ int i;
+ DispPtr disp;
+ Pix24Flags pix24 = xf86Info.pixmap24;
+ Bool nomatch = FALSE;
+
+ scrp->bitsPerPixel = -1;
+ scrp->depth = -1;
+ scrp->pixmap24 = Pix24DontCare;
+ scrp->bitsPerPixelFrom = X_DEFAULT;
+ scrp->depthFrom = X_DEFAULT;
+
+ if (xf86FbBpp > 0) {
+ scrp->bitsPerPixel = xf86FbBpp;
+ scrp->bitsPerPixelFrom = X_CMDLINE;
+ }
+
+ if (xf86Depth > 0) {
+ scrp->depth = xf86Depth;
+ scrp->depthFrom = X_CMDLINE;
+ }
+
+ if (xf86FbBpp < 0 && xf86Depth < 0) {
+ if (scrp->confScreen->defaultfbbpp > 0) {
+ scrp->bitsPerPixel = scrp->confScreen->defaultfbbpp;
+ scrp->bitsPerPixelFrom = X_CONFIG;
+ }
+ if (scrp->confScreen->defaultdepth > 0) {
+ scrp->depth = scrp->confScreen->defaultdepth;
+ scrp->depthFrom = X_CONFIG;
+ }
+
+ if (scrp->confScreen->defaultfbbpp <= 0 &&
+ scrp->confScreen->defaultdepth <= 0) {
+ /*
+ * Check for DefaultDepth and DefaultFbBpp options in the
+ * Device sections.
+ */
+ int i;
+ GDevPtr device;
+ Bool found = FALSE;
+
+ for (i = 0; i < scrp->numEntities; i++) {
+ device = xf86GetDevFromEntity(scrp->entityList[i],
+ scrp->entityInstanceList[i]);
+ if (device && device->options) {
+ if (xf86FindOption(device->options, "DefaultDepth")) {
+ scrp->depth = xf86SetIntOption(device->options,
+ "DefaultDepth", -1);
+ scrp->depthFrom = X_CONFIG;
+ found = TRUE;
+ }
+ if (xf86FindOption(device->options, "DefaultFbBpp")) {
+ scrp->bitsPerPixel = xf86SetIntOption(device->options,
+ "DefaultFbBpp",
+ -1);
+ scrp->bitsPerPixelFrom = X_CONFIG;
+ found = TRUE;
+ }
+ }
+ if (found)
+ break;
+ }
+ }
+ }
+
+ /* If none of these is set, pick a default */
+ if (scrp->bitsPerPixel < 0 && scrp->depth < 0) {
+ if (fbbpp > 0 || depth > 0) {
+ if (fbbpp > 0)
+ scrp->bitsPerPixel = fbbpp;
+ if (depth > 0)
+ scrp->depth = depth;
+ } else {
+ scrp->depth = GLOBAL_DEFAULT_DEPTH;
+ }
+ }
+
+ /* If any are not given, determine a default for the others */
+
+ if (scrp->bitsPerPixel < 0) {
+ /* The depth must be set */
+ if (scrp->depth > -1) {
+ if (scrp->depth == 1)
+ scrp->bitsPerPixel = 1;
+ else if (scrp->depth <= 4)
+ scrp->bitsPerPixel = 4;
+ else if (scrp->depth <= 8)
+ scrp->bitsPerPixel = 8;
+ else if (scrp->depth <= 16)
+ scrp->bitsPerPixel = 16;
+ else if (scrp->depth <= 24) {
+ /*
+ * Figure out if a choice is possible based on the depth24
+ * and pix24 flags.
+ */
+ /* Check pix24 first */
+ if (pix24 != Pix24DontCare) {
+ if (pix24 == Pix24Use32) {
+ if (DO_PIX32(depth24flags)) {
+ if (CHOOSE24FOR32(depth24flags))
+ scrp->bitsPerPixel = 24;
+ else
+ scrp->bitsPerPixel = 32;
+ } else {
+ nomatch = TRUE;
+ }
+ } else if (pix24 == Pix24Use24) {
+ if (DO_PIX24(depth24flags)) {
+ if (CHOOSE32FOR24(depth24flags))
+ scrp->bitsPerPixel = 32;
+ else
+ scrp->bitsPerPixel = 24;
+ } else {
+ nomatch = TRUE;
+ }
+ }
+ } else {
+ if (DO_PIX32(depth24flags)) {
+ if (CHOOSE24FOR32(depth24flags))
+ scrp->bitsPerPixel = 24;
+ else
+ scrp->bitsPerPixel = 32;
+ } else if (DO_PIX24(depth24flags)) {
+ if (CHOOSE32FOR24(depth24flags))
+ scrp->bitsPerPixel = 32;
+ else
+ scrp->bitsPerPixel = 24;
+ }
+ }
+ } else if (scrp->depth <= 32)
+ scrp->bitsPerPixel = 32;
+ else {
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "Specified depth (%d) is greater than 32\n",
+ scrp->depth);
+ return FALSE;
+ }
+ } else {
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "xf86SetDepthBpp: internal error: depth and fbbpp"
+ " are both not set\n");
+ return FALSE;
+ }
+ if (scrp->bitsPerPixel < 0) {
+ if (nomatch)
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "Driver can't support depth 24 pixmap format (%d)\n",
+ PIX24TOBPP(pix24));
+ else if ((depth24flags & (Support24bppFb | Support32bppFb)) ==
+ NoDepth24Support)
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "Driver can't support depth 24\n");
+ else
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "Can't find fbbpp for depth 24\n");
+ return FALSE;
+ }
+ scrp->bitsPerPixelFrom = X_PROBED;
+ }
+
+ if (scrp->depth <= 0) {
+ /* bitsPerPixel is already set */
+ switch (scrp->bitsPerPixel) {
+ case 32:
+ scrp->depth = 24;
+ break;
+ default:
+ /* 1, 4, 8, 16 and 24 */
+ scrp->depth = scrp->bitsPerPixel;
+ break;
+ }
+ scrp->depthFrom = X_PROBED;
+ }
+
+ /* Sanity checks */
+ if (scrp->depth < 1 || scrp->depth > 32) {
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "Specified depth (%d) is not in the range 1-32\n",
+ scrp->depth);
+ return FALSE;
+ }
+ switch (scrp->bitsPerPixel) {
+ case 1:
+ case 4:
+ case 8:
+ case 16:
+ case 24:
+ case 32:
+ break;
+ default:
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "Specified fbbpp (%d) is not a permitted value\n",
+ scrp->bitsPerPixel);
+ return FALSE;
+ }
+ if (scrp->depth > scrp->bitsPerPixel) {
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "Specified depth (%d) is greater than the fbbpp (%d)\n",
+ scrp->depth, scrp->bitsPerPixel);
+ return FALSE;
+ }
+
+ /* set scrp->pixmap24 if the driver isn't flexible */
+ if (scrp->bitsPerPixel == 24 && !DO_PIX32FOR24(depth24flags)) {
+ scrp->pixmap24 = Pix24Use24;
+ }
+ if (scrp->bitsPerPixel == 32 && !DO_PIX24FOR32(depth24flags)) {
+ scrp->pixmap24 = Pix24Use32;
+ }
+
+ /*
+ * Find the Display subsection matching the depth/fbbpp and initialise
+ * scrp->display with it.
+ */
+ for (i = 0, disp = scrp->confScreen->displays;
+ i < scrp->confScreen->numdisplays; i++, disp++) {
+ if ((disp->depth == scrp->depth && disp->fbbpp == scrp->bitsPerPixel)
+ || (disp->depth == scrp->depth && disp->fbbpp <= 0)
+ || (disp->fbbpp == scrp->bitsPerPixel && disp->depth <= 0)) {
+ scrp->display = disp;
+ break;
+ }
+ }
+
+ /*
+ * If an exact match can't be found, see if there is one with no
+ * depth or fbbpp specified.
+ */
+ if (i == scrp->confScreen->numdisplays) {
+ for (i = 0, disp = scrp->confScreen->displays;
+ i < scrp->confScreen->numdisplays; i++, disp++) {
+ if (disp->depth <= 0 && disp->fbbpp <= 0) {
+ scrp->display = disp;
+ break;
+ }
+ }
+ }
+
+ /*
+ * If all else fails, create a default one.
+ */
+ if (i == scrp->confScreen->numdisplays) {
+ scrp->confScreen->numdisplays++;
+ scrp->confScreen->displays =
+ xnfrealloc(scrp->confScreen->displays,
+ scrp->confScreen->numdisplays * sizeof(DispRec));
+ xf86DrvMsg(scrp->scrnIndex, X_INFO,
+ "Creating default Display subsection in Screen section\n"
+ "\t\"%s\" for depth/fbbpp %d/%d\n",
+ scrp->confScreen->id, scrp->depth, scrp->bitsPerPixel);
+ memset(&scrp->confScreen->displays[i], 0, sizeof(DispRec));
+ scrp->confScreen->displays[i].blackColour.red = -1;
+ scrp->confScreen->displays[i].blackColour.green = -1;
+ scrp->confScreen->displays[i].blackColour.blue = -1;
+ scrp->confScreen->displays[i].whiteColour.red = -1;
+ scrp->confScreen->displays[i].whiteColour.green = -1;
+ scrp->confScreen->displays[i].whiteColour.blue = -1;
+ scrp->confScreen->displays[i].defaultVisual = -1;
+ scrp->confScreen->displays[i].modes = xnfalloc(sizeof(char *));
+ scrp->confScreen->displays[i].modes[0] = NULL;
+ scrp->confScreen->displays[i].depth = depth;
+ scrp->confScreen->displays[i].fbbpp = fbbpp;
+ scrp->display = &scrp->confScreen->displays[i];
+ }
+
+ /*
+ * Setup defaults for the display-wide attributes the framebuffer will
+ * need. These defaults should eventually be set globally, and not
+ * dependent on the screens.
+ */
+ scrp->imageByteOrder = IMAGE_BYTE_ORDER;
+ scrp->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
+ if (scrp->depth < 8) {
+ /* Planar modes need these settings */
+ scrp->bitmapScanlineUnit = 8;
+ scrp->bitmapBitOrder = MSBFirst;
+ } else {
+ scrp->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
+ scrp->bitmapBitOrder = BITMAP_BIT_ORDER;
+ }
+
+ /*
+ * If an unusual depth is required, add it to scrp->formats. The formats
+ * for the common depths are handled globally in InitOutput
+ */
+ switch (scrp->depth) {
+ case 1:
+ case 4:
+ case 8:
+ case 15:
+ case 16:
+ case 24:
+ /* Common depths. Nothing to do for them */
+ break;
+ default:
+ if (!xf86AddPixFormat(scrp, scrp->depth, 0, 0)) {
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "Can't add pixmap format for depth %d\n", scrp->depth);
+ return FALSE;
+ }
+ }
+
+ /* Initialise the framebuffer format for this screen */
+ scrp->fbFormat.depth = scrp->depth;
+ scrp->fbFormat.bitsPerPixel = scrp->bitsPerPixel;
+ scrp->fbFormat.scanlinePad = BITMAP_SCANLINE_PAD;
+
+ return TRUE;
+}
+
+/*
+ * Print out the selected depth and bpp.
+ */
+void
+xf86PrintDepthBpp(ScrnInfoPtr scrp)
+{
+ xf86DrvMsg(scrp->scrnIndex, scrp->depthFrom, "Depth %d, ", scrp->depth);
+ xf86Msg(scrp->bitsPerPixelFrom, "framebuffer bpp %d\n", scrp->bitsPerPixel);
+}
+
+/*
+ * xf86SetWeight sets scrp->weight, scrp->mask, scrp->offset, and for depths
+ * greater than MAX_PSEUDO_DEPTH also scrp->rgbBits.
+ */
+Bool
+xf86SetWeight(ScrnInfoPtr scrp, rgb weight, rgb mask)
+{
+ MessageType weightFrom = X_DEFAULT;
+
+ scrp->weight.red = 0;
+ scrp->weight.green = 0;
+ scrp->weight.blue = 0;
+
+ if (xf86Weight.red > 0 && xf86Weight.green > 0 && xf86Weight.blue > 0) {
+ scrp->weight = xf86Weight;
+ weightFrom = X_CMDLINE;
+ } else if (scrp->display->weight.red > 0 && scrp->display->weight.green > 0
+ && scrp->display->weight.blue > 0) {
+ scrp->weight = scrp->display->weight;
+ weightFrom = X_CONFIG;
+ } else if (weight.red > 0 && weight.green > 0 && weight.blue > 0) {
+ scrp->weight = weight;
+ } else {
+ switch (scrp->depth) {
+ case 1:
+ case 4:
+ case 8:
+ scrp->weight.red = scrp->weight.green =
+ scrp->weight.blue = scrp->rgbBits;
+ break;
+ case 15:
+ scrp->weight.red = scrp->weight.green = scrp->weight.blue = 5;
+ break;
+ case 16:
+ scrp->weight.red = scrp->weight.blue = 5;
+ scrp->weight.green = 6;
+ break;
+ case 18:
+ scrp->weight.red = scrp->weight.green = scrp->weight.blue = 6;
+ break;
+ case 24:
+ scrp->weight.red = scrp->weight.green = scrp->weight.blue = 8;
+ break;
+ case 30:
+ scrp->weight.red = scrp->weight.green = scrp->weight.blue = 10;
+ break;
+ }
+ }
+
+ if (scrp->weight.red)
+ xf86DrvMsg(scrp->scrnIndex, weightFrom, "RGB weight %d%d%d\n",
+ (int)scrp->weight.red, (int)scrp->weight.green,
+ (int)scrp->weight.blue);
+
+ if (scrp->depth > MAX_PSEUDO_DEPTH &&
+ (scrp->depth != scrp->weight.red + scrp->weight.green +
+ scrp->weight.blue)) {
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "Weight given (%d%d%d) is inconsistent with the "
+ "depth (%d)\n",
+ (int)scrp->weight.red, (int)scrp->weight.green,
+ (int)scrp->weight.blue, scrp->depth);
+ return FALSE;
+ }
+ if (scrp->depth > MAX_PSEUDO_DEPTH && scrp->weight.red) {
+ /*
+ * XXX Does this even mean anything for TrueColor visuals?
+ * If not, we shouldn't even be setting it here. However, this
+ * matches the behaviour of 3.x versions of XFree86.
+ */
+ scrp->rgbBits = scrp->weight.red;
+ if (scrp->weight.green > scrp->rgbBits)
+ scrp->rgbBits = scrp->weight.green;
+ if (scrp->weight.blue > scrp->rgbBits)
+ scrp->rgbBits = scrp->weight.blue;
+ }
+
+ /* Set the mask and offsets */
+ if (mask.red == 0 || mask.green == 0 || mask.blue == 0) {
+ /* Default to a setting common to PC hardware */
+ scrp->offset.red = scrp->weight.green + scrp->weight.blue;
+ scrp->offset.green = scrp->weight.blue;
+ scrp->offset.blue = 0;
+ scrp->mask.red = ((1 << scrp->weight.red) - 1) << scrp->offset.red;
+ scrp->mask.green = ((1 << scrp->weight.green) - 1)
+ << scrp->offset.green;
+ scrp->mask.blue = (1 << scrp->weight.blue) - 1;
+ } else {
+ /* Initialise to the values passed */
+ scrp->mask.red = mask.red;
+ scrp->mask.green = mask.green;
+ scrp->mask.blue = mask.blue;
+ scrp->offset.red = ffs(mask.red);
+ scrp->offset.green = ffs(mask.green);
+ scrp->offset.blue = ffs(mask.blue);
+ }
+ return TRUE;
+}
+
+Bool
+xf86SetDefaultVisual(ScrnInfoPtr scrp, int visual)
+{
+ MessageType visualFrom = X_DEFAULT;
+
+ if (defaultColorVisualClass >= 0) {
+ scrp->defaultVisual = defaultColorVisualClass;
+ visualFrom = X_CMDLINE;
+ } else if (scrp->display->defaultVisual >= 0) {
+ scrp->defaultVisual = scrp->display->defaultVisual;
+ visualFrom = X_CONFIG;
+ } else if (visual >= 0) {
+ scrp->defaultVisual = visual;
+ } else {
+ if (scrp->depth == 1)
+ scrp->defaultVisual = StaticGray;
+ else if (scrp->depth == 4)
+ scrp->defaultVisual = StaticColor;
+ else if (scrp->depth <= MAX_PSEUDO_DEPTH)
+ scrp->defaultVisual = PseudoColor;
+ else
+ scrp->defaultVisual = TrueColor;
+ }
+ switch (scrp->defaultVisual) {
+ case StaticGray:
+ case GrayScale:
+ case StaticColor:
+ case PseudoColor:
+ case TrueColor:
+ case DirectColor:
+ xf86DrvMsg(scrp->scrnIndex, visualFrom, "Default visual is %s\n",
+ xf86VisualNames[scrp->defaultVisual]);
+ return TRUE;
+ default:
+
+ xf86DrvMsg(scrp->scrnIndex, X_ERROR,
+ "Invalid default visual class (%d)\n", scrp->defaultVisual);
+ return FALSE;
+ }
+}
+
+#define TEST_GAMMA(g) \
+ (g).red > GAMMA_ZERO || (g).green > GAMMA_ZERO || (g).blue > GAMMA_ZERO
+
+#define SET_GAMMA(g) \
+ (g) > GAMMA_ZERO ? (g) : 1.0
+
+Bool
+xf86SetGamma(ScrnInfoPtr scrp, Gamma gamma)
+{
+ MessageType from = X_DEFAULT;
+#if 0
+ xf86MonPtr DDC = (xf86MonPtr)(scrp->monitor->DDC);
+#endif
+ if (TEST_GAMMA(xf86Gamma)) {
+ from = X_CMDLINE;
+ scrp->gamma.red = SET_GAMMA(xf86Gamma.red);
+ scrp->gamma.green = SET_GAMMA(xf86Gamma.green);
+ scrp->gamma.blue = SET_GAMMA(xf86Gamma.blue);
+ } else if (TEST_GAMMA(scrp->monitor->gamma)) {
+ from = X_CONFIG;
+ scrp->gamma.red = SET_GAMMA(scrp->monitor->gamma.red);
+ scrp->gamma.green = SET_GAMMA(scrp->monitor->gamma.green);
+ scrp->gamma.blue = SET_GAMMA(scrp->monitor->gamma.blue);
+#if 0
+ } else if ( DDC && DDC->features.gamma > GAMMA_ZERO ) {
+ from = X_PROBED;
+ scrp->gamma.red = SET_GAMMA(DDC->features.gamma);
+ scrp->gamma.green = SET_GAMMA(DDC->features.gamma);
+ scrp->gamma.blue = SET_GAMMA(DDC->features.gamma);
+ /* EDID structure version 2 gives optional seperate red, green & blue gamma values
+ * in bytes 0x57-0x59 */
+#endif
+ } else if (TEST_GAMMA(gamma)) {
+ scrp->gamma.red = SET_GAMMA(gamma.red);
+ scrp->gamma.green = SET_GAMMA(gamma.green);
+ scrp->gamma.blue = SET_GAMMA(gamma.blue);
+ } else {
+ scrp->gamma.red = 1.0;
+ scrp->gamma.green = 1.0;
+ scrp->gamma.blue = 1.0;
+ }
+ /* Pretend we succeeded if we support better a gamma system.
+ * This avoids a confusing message.
+ */
+ if (xf86_crtc_supports_gamma(scrp))
+ return TRUE;
+ xf86DrvMsg(scrp->scrnIndex, from,
+ "Using gamma correction (%.1f, %.1f, %.1f)\n",
+ scrp->gamma.red, scrp->gamma.green, scrp->gamma.blue);
+
+ return TRUE;
+}
+
+#undef TEST_GAMMA
+#undef SET_GAMMA
+
+
+/*
+ * Set the DPI from the command line option. XXX should allow it to be
+ * calculated from the widthmm/heightmm values.
+ */
+
+#undef MMPERINCH
+#define MMPERINCH 25.4
+
+void
+xf86SetDpi(ScrnInfoPtr pScrn, int x, int y)
+{
+ MessageType from = X_DEFAULT;
+ xf86MonPtr DDC = (xf86MonPtr)(pScrn->monitor->DDC);
+ int ddcWidthmm, ddcHeightmm;
+ int widthErr, heightErr;
+
+ /* XXX Maybe there is no need for widthmm/heightmm in ScrnInfoRec */
+ pScrn->widthmm = pScrn->monitor->widthmm;
+ pScrn->heightmm = pScrn->monitor->heightmm;
+
+ if (DDC && (DDC->features.hsize > 0 && DDC->features.vsize > 0) ) {
+ /* DDC gives display size in mm for individual modes,
+ * but cm for monitor
+ */
+ ddcWidthmm = DDC->features.hsize * 10; /* 10mm in 1cm */
+ ddcHeightmm = DDC->features.vsize * 10; /* 10mm in 1cm */
+ } else {
+ ddcWidthmm = ddcHeightmm = 0;
+ }
+
+ if (monitorResolution > 0) {
+ pScrn->xDpi = monitorResolution;
+ pScrn->yDpi = monitorResolution;
+ from = X_CMDLINE;
+ } else if (pScrn->widthmm > 0 || pScrn->heightmm > 0) {
+ from = X_CONFIG;
+ if (pScrn->widthmm > 0) {
+ pScrn->xDpi =
+ (int)((double)pScrn->virtualX * MMPERINCH / pScrn->widthmm);
+ }
+ if (pScrn->heightmm > 0) {
+ pScrn->yDpi =
+ (int)((double)pScrn->virtualY * MMPERINCH / pScrn->heightmm);
+ }
+ if (pScrn->xDpi > 0 && pScrn->yDpi <= 0)
+ pScrn->yDpi = pScrn->xDpi;
+ if (pScrn->yDpi > 0 && pScrn->xDpi <= 0)
+ pScrn->xDpi = pScrn->yDpi;
+ xf86DrvMsg(pScrn->scrnIndex, from, "Display dimensions: (%d, %d) mm\n",
+ pScrn->widthmm, pScrn->heightmm);
+
+ /* Warn if config and probe disagree about display size */
+ if ( ddcWidthmm && ddcHeightmm ) {
+ if (pScrn->widthmm > 0) {
+ widthErr = abs(ddcWidthmm - pScrn->widthmm);
+ } else {
+ widthErr = 0;
+ }
+ if (pScrn->heightmm > 0) {
+ heightErr = abs(ddcHeightmm - pScrn->heightmm);
+ } else {
+ heightErr = 0;
+ }
+ if (widthErr>10 || heightErr>10) {
+ /* Should include config file name for monitor here */
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ "Probed monitor is %dx%d mm, using Displaysize %dx%d mm\n",
+ ddcWidthmm,ddcHeightmm, pScrn->widthmm,pScrn->heightmm);
+ }
+ }
+ } else if ( ddcWidthmm && ddcHeightmm ) {
+ from = X_PROBED;
+ xf86DrvMsg(pScrn->scrnIndex, from, "Display dimensions: (%d, %d) mm\n",
+ ddcWidthmm, ddcHeightmm );
+ pScrn->widthmm = ddcWidthmm;
+ pScrn->heightmm = ddcHeightmm;
+ if (pScrn->widthmm > 0) {
+ pScrn->xDpi =
+ (int)((double)pScrn->virtualX * MMPERINCH / pScrn->widthmm);
+ }
+ if (pScrn->heightmm > 0) {
+ pScrn->yDpi =
+ (int)((double)pScrn->virtualY * MMPERINCH / pScrn->heightmm);
+ }
+ if (pScrn->xDpi > 0 && pScrn->yDpi <= 0)
+ pScrn->yDpi = pScrn->xDpi;
+ if (pScrn->yDpi > 0 && pScrn->xDpi <= 0)
+ pScrn->xDpi = pScrn->yDpi;
+ } else {
+ if (x > 0)
+ pScrn->xDpi = x;
+ else
+ pScrn->xDpi = DEFAULT_DPI;
+ if (y > 0)
+ pScrn->yDpi = y;
+ else
+ pScrn->yDpi = DEFAULT_DPI;
+ }
+ xf86DrvMsg(pScrn->scrnIndex, from, "DPI set to (%d, %d)\n",
+ pScrn->xDpi, pScrn->yDpi);
+}
+
+#undef MMPERINCH
+
+
+void
+xf86SetBlackWhitePixels(ScreenPtr pScreen)
+{
+ if (xf86FlipPixels) {
+ pScreen->whitePixel = 0;
+ pScreen->blackPixel = 1;
+ } else {
+ pScreen->whitePixel = 1;
+ pScreen->blackPixel = 0;
+ }
+}
+
+/*
+ * Function to enable/disable access to the frame buffer
+ *
+ * This is used when VT switching and when entering/leaving DGA direct mode.
+ *
+ * This has been rewritten again to eliminate the saved pixmap. The
+ * devPrivate field in the screen pixmap is set to NULL to catch code
+ * accidentally referencing the frame buffer while the X server is not
+ * supposed to touch it.
+ *
+ * Here, we exchange the pixmap private data, rather than the pixmaps
+ * themselves to avoid having to find and change any references to the screen
+ * pixmap such as GC's, window privates etc. This also means that this code
+ * does not need to know exactly how the pixmap pixels are accessed. Further,
+ * this exchange is >not< done through the screen's ModifyPixmapHeader()
+ * vector. This means the called frame buffer code layers can determine
+ * whether they are switched in or out by keeping track of the root pixmap's
+ * private data, and therefore don't need to access pScrnInfo->vtSema.
+ */
+void
+xf86EnableDisableFBAccess(int scrnIndex, Bool enable)
+{
+ ScrnInfoPtr pScrnInfo = xf86Screens[scrnIndex];
+ ScreenPtr pScreen = pScrnInfo->pScreen;
+ PixmapPtr pspix;
+
+ pspix = (*pScreen->GetScreenPixmap) (pScreen);
+ if (enable)
+ {
+ /*
+ * Restore all of the clip lists on the screen
+ */
+ if (!xf86Resetting)
+ SetRootClip (pScreen, TRUE);
+
+ }
+ else
+ {
+ /*
+ * Empty all of the clip lists on the screen
+ */
+ SetRootClip (pScreen, FALSE);
+ }
+}
+
+/* Print driver messages in the standard format */
+
+#undef PREFIX_SIZE
+#define PREFIX_SIZE 14
+
+void
+xf86VDrvMsgVerb(int scrnIndex, MessageType type, int verb, const char *format,
+ va_list args)
+{
+ char *tmpFormat;
+
+ /* Prefix the scrnIndex name to the format string. */
+ if (scrnIndex >= 0 && scrnIndex < xf86NumScreens &&
+ xf86Screens[scrnIndex]->name) {
+ tmpFormat = malloc(strlen(format) +
+ strlen(xf86Screens[scrnIndex]->name) +
+ PREFIX_SIZE + 1);
+ if (!tmpFormat)
+ return;
+
+ snprintf(tmpFormat, PREFIX_SIZE + 1, "%s(%d): ",
+ xf86Screens[scrnIndex]->name, scrnIndex);
+
+ strcat(tmpFormat, format);
+ LogVMessageVerb(type, verb, tmpFormat, args);
+ free(tmpFormat);
+ } else
+ LogVMessageVerb(type, verb, format, args);
+}
+#undef PREFIX_SIZE
+
+/* Print driver messages, with verbose level specified directly */
+void
+xf86DrvMsgVerb(int scrnIndex, MessageType type, int verb, const char *format,
+ ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ xf86VDrvMsgVerb(scrnIndex, type, verb, format, ap);
+ va_end(ap);
+}
+
+/* Print driver messages, with verbose level of 1 (default) */
+void
+xf86DrvMsg(int scrnIndex, MessageType type, const char *format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ xf86VDrvMsgVerb(scrnIndex, type, 1, format, ap);
+ va_end(ap);
+}
+
+/* Print input driver messages in the standard format of
+ <driver>: <device name>: <message> */
+void
+xf86VIDrvMsgVerb(InputInfoPtr dev, MessageType type, int verb, const char *format,
+ va_list args)
+{
+ char *msg;
+
+ if (asprintf(&msg, "%s: %s: %s", dev->drv->driverName, dev->name, format)
+ == -1) {
+ LogVMessageVerb(type, verb, "%s", args);
+ } else {
+ LogVMessageVerb(type, verb, msg, args);
+ free(msg);
+ }
+}
+
+/* Print input driver message, with verbose level specified directly */
+void
+xf86IDrvMsgVerb(InputInfoPtr dev, MessageType type, int verb, const char *format,
+ ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ xf86VIDrvMsgVerb(dev, type, verb, format, ap);
+ va_end(ap);
+}
+
+/* Print input driver messages, with verbose level of 1 (default) */
+void
+xf86IDrvMsg(InputInfoPtr dev, MessageType type, const char *format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ xf86VIDrvMsgVerb(dev, type, 1, format, ap);
+ va_end(ap);
+}
+
+
+/* Print non-driver messages with verbose level specified directly */
+void
+xf86MsgVerb(MessageType type, int verb, const char *format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ LogVMessageVerb(type, verb, format, ap);
+ va_end(ap);
+}
+
+/* Print non-driver messages with verbose level of 1 (default) */
+void
+xf86Msg(MessageType type, const char *format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ LogVMessageVerb(type, 1, format, ap);
+ va_end(ap);
+}
+
+/* Just like ErrorF, but with the verbose level checked */
+void
+xf86ErrorFVerb(int verb, const char *format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ if (xf86Verbose >= verb || xf86LogVerbose >= verb)
+ LogVWrite(verb, format, ap);
+ va_end(ap);
+}
+
+/* Like xf86ErrorFVerb, but with an implied verbose level of 1 */
+void
+xf86ErrorF(const char *format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ if (xf86Verbose >= 1 || xf86LogVerbose >= 1)
+ LogVWrite(1, format, ap);
+ va_end(ap);
+}
+
+
+void
+xf86LogInit(void)
+{
+ char *lf = NULL;
+
+#define LOGSUFFIX ".log"
+#define LOGOLDSUFFIX ".old"
+
+ /* Get the log file name */
+ if (xf86LogFileFrom == X_DEFAULT) {
+ /* Append the display number and ".log" */
+ if (asprintf(&lf, "%s%%s" LOGSUFFIX, xf86LogFile) == -1)
+ FatalError("Cannot allocate space for the log file name\n");
+ xf86LogFile = lf;
+ }
+
+ xf86LogFile = LogInit(xf86LogFile, LOGOLDSUFFIX);
+ xf86LogFileWasOpened = TRUE;
+
+ xf86SetVerbosity(xf86Verbose);
+ xf86SetLogVerbosity(xf86LogVerbose);
+
+#undef LOGSUFFIX
+#undef LOGOLDSUFFIX
+
+ free(lf);
+}
+
+void
+xf86CloseLog(enum ExitCode error)
+{
+ LogClose(error);
+}
+
+
+/*
+ * Drivers can use these for using their own SymTabRecs.
+ */
+
+const char *
+xf86TokenToString(SymTabPtr table, int token)
+{
+ int i;
+
+ for (i = 0; table[i].token >= 0 && table[i].token != token; i++)
+ ;
+
+ if (table[i].token < 0)
+ return NULL;
+ else
+ return table[i].name;
+}
+
+int
+xf86StringToToken(SymTabPtr table, const char *string)
+{
+ int i;
+
+ if (string == NULL)
+ return -1;
+
+ for (i = 0; table[i].token >= 0 && xf86NameCmp(string, table[i].name); i++)
+ ;
+
+ return table[i].token;
+}
+
+/*
+ * helper to display the clocks found on a card
+ */
+void
+xf86ShowClocks(ScrnInfoPtr scrp, MessageType from)
+{
+ int j;
+
+ xf86DrvMsg(scrp->scrnIndex, from, "Pixel clocks available:");
+ for (j=0; j < scrp->numClocks; j++) {
+ if ((j % 4) == 0) {
+ xf86ErrorF("\n");
+ xf86DrvMsg(scrp->scrnIndex, from, "pixel clocks:");
+ }
+ xf86ErrorF(" %7.3f", (double)scrp->clock[j] / 1000.0);
+ }
+ xf86ErrorF("\n");
+}
+
+
+/*
+ * This prints out the driver identify message, including the names of
+ * the supported chipsets.
+ *
+ * XXX This makes assumptions about the line width, etc. Maybe we could
+ * use a more general "pretty print" function for messages.
+ */
+void
+xf86PrintChipsets(const char *drvname, const char *drvmsg, SymTabPtr chips)
+{
+ int len, i;
+
+ len = 6 + strlen(drvname) + 2 + strlen(drvmsg) + 2;
+ xf86Msg(X_INFO, "%s: %s:", drvname, drvmsg);
+ for (i = 0; chips[i].name != NULL; i++) {
+ if (i != 0) {
+ xf86ErrorF(",");
+ len++;
+ }
+ if (len + 2 + strlen(chips[i].name) < 78) {
+ xf86ErrorF(" ");
+ len++;
+ } else {
+ xf86ErrorF("\n\t");
+ len = 8;
+ }
+ xf86ErrorF("%s", chips[i].name);
+ len += strlen(chips[i].name);
+ }
+ xf86ErrorF("\n");
+}
+
+
+int
+xf86MatchDevice(const char *drivername, GDevPtr **sectlist)
+{
+ GDevPtr gdp, *pgdp = NULL;
+ confScreenPtr screensecptr;
+ int i,j;
+
+ if (sectlist)
+ *sectlist = NULL;
+
+ /*
+ * This can happen when running Xorg -showopts and a module like ati
+ * or vmware tries to load its submodules when xf86ConfigLayout is empty
+ */
+ if (!xf86ConfigLayout.screens)
+ return 0;
+
+ /*
+ * This is a very important function that matches the device sections
+ * as they show up in the config file with the drivers that the server
+ * loads at run time.
+ *
+ * ChipProbe can call
+ * int xf86MatchDevice(char * drivername, GDevPtr ** sectlist)
+ * with its driver name. The function allocates an array of GDevPtr and
+ * returns this via sectlist and returns the number of elements in
+ * this list as return value. 0 means none found, -1 means fatal error.
+ *
+ * It can figure out which of the Device sections to use for which card
+ * (using things like the Card statement, etc). For single headed servers
+ * there will of course be just one such Device section.
+ */
+ i = 0;
+
+ /*
+ * first we need to loop over all the Screens sections to get to all
+ * 'active' device sections
+ */
+ for (j=0; xf86ConfigLayout.screens[j].screen != NULL; j++) {
+ screensecptr = xf86ConfigLayout.screens[j].screen;
+ if ((screensecptr->device->driver != NULL)
+ && (xf86NameCmp( screensecptr->device->driver,drivername) == 0)
+ && (! screensecptr->device->claimed)) {
+ /*
+ * we have a matching driver that wasn't claimed, yet
+ */
+ pgdp = xnfrealloc(pgdp, (i + 2) * sizeof(GDevPtr));
+ pgdp[i++] = screensecptr->device;
+ }
+ }
+
+ /* Then handle the inactive devices */
+ j = 0;
+ while (xf86ConfigLayout.inactives[j].identifier) {
+ gdp = &xf86ConfigLayout.inactives[j];
+ if (gdp->driver && !gdp->claimed &&
+ !xf86NameCmp(gdp->driver,drivername)) {
+ /* we have a matching driver that wasn't claimed yet */
+ pgdp = xnfrealloc(pgdp, (i + 2) * sizeof(GDevPtr));
+ pgdp[i++] = gdp;
+ }
+ j++;
+ }
+
+ /*
+ * make the array NULL terminated and return its address
+ */
+ if (i)
+ pgdp[i] = NULL;
+
+ if (sectlist)
+ *sectlist = pgdp;
+ else
+ free(pgdp);
+ return i;
+}
+
+/*
+ * xf86GetClocks -- get the dot-clocks via a BIG BAD hack ...
+ */
+void
+xf86GetClocks(ScrnInfoPtr pScrn, int num, Bool (*ClockFunc)(ScrnInfoPtr, int),
+ void (*ProtectRegs)(ScrnInfoPtr, Bool),
+ void (*BlankScreen)(ScrnInfoPtr, Bool), IOADDRESS vertsyncreg,
+ int maskval, int knownclkindex, int knownclkvalue)
+{
+ register int status = vertsyncreg;
+ unsigned long i, cnt, rcnt, sync;
+
+ /* First save registers that get written on */
+ (*ClockFunc)(pScrn, CLK_REG_SAVE);
+
+ if (num > MAXCLOCKS)
+ num = MAXCLOCKS;
+
+ for (i = 0; i < num; i++)
+ {
+ if (ProtectRegs)
+ (*ProtectRegs)(pScrn, TRUE);
+ if (!(*ClockFunc)(pScrn, i))
+ {
+ pScrn->clock[i] = -1;
+ continue;
+ }
+ if (ProtectRegs)
+ (*ProtectRegs)(pScrn, FALSE);
+ if (BlankScreen)
+ (*BlankScreen)(pScrn, FALSE);
+
+ usleep(50000); /* let VCO stabilise */
+
+ cnt = 0;
+ sync = 200000;
+
+ while ((inb(status) & maskval) == 0x00)
+ if (sync-- == 0) goto finish;
+ /* Something appears to be happening, so reset sync count */
+ sync = 200000;
+ while ((inb(status) & maskval) == maskval)
+ if (sync-- == 0) goto finish;
+ /* Something appears to be happening, so reset sync count */
+ sync = 200000;
+ while ((inb(status) & maskval) == 0x00)
+ if (sync-- == 0) goto finish;
+
+ for (rcnt = 0; rcnt < 5; rcnt++)
+ {
+ while (!(inb(status) & maskval))
+ cnt++;
+ while ((inb(status) & maskval))
+ cnt++;
+ }
+
+finish:
+ pScrn->clock[i] = cnt ? cnt : -1;
+ if (BlankScreen)
+ (*BlankScreen)(pScrn, TRUE);
+ }
+
+ for (i = 0; i < num; i++)
+ {
+ if (i != knownclkindex)
+ {
+ if (pScrn->clock[i] == -1)
+ {
+ pScrn->clock[i] = 0;
+ }
+ else
+ {
+ pScrn->clock[i] = (int)(0.5 +
+ (((float)knownclkvalue) * pScrn->clock[knownclkindex]) /
+ (pScrn->clock[i]));
+ /* Round to nearest 10KHz */
+ pScrn->clock[i] += 5;
+ pScrn->clock[i] /= 10;
+ pScrn->clock[i] *= 10;
+ }
+ }
+ }
+
+ pScrn->clock[knownclkindex] = knownclkvalue;
+ pScrn->numClocks = num;
+
+ /* Restore registers that were written on */
+ (*ClockFunc)(pScrn, CLK_REG_RESTORE);
+}
+
+const char *
+xf86GetVisualName(int visual)
+{
+ if (visual < 0 || visual > DirectColor)
+ return NULL;
+
+ return xf86VisualNames[visual];
+}
+
+
+int
+xf86GetVerbosity(void)
+{
+ return max(xf86Verbose, xf86LogVerbose);
+}
+
+Pix24Flags
+xf86GetPix24(void)
+{
+ return xf86Info.pixmap24;
+}
+
+
+int
+xf86GetDepth(void)
+{
+ return xf86Depth;
+}
+
+
+rgb
+xf86GetWeight(void)
+{
+ return xf86Weight;
+}
+
+
+Gamma
+xf86GetGamma(void)
+{
+ return xf86Gamma;
+}
+
+
+Bool
+xf86GetFlipPixels(void)
+{
+ return xf86FlipPixels;
+}
+
+
+const char *
+xf86GetServerName(void)
+{
+ return xf86ServerName;
+}
+
+
+Bool
+xf86ServerIsExiting(void)
+{
+ return (dispatchException & DE_TERMINATE) == DE_TERMINATE;
+}
+
+
+Bool
+xf86ServerIsResetting(void)
+{
+ return xf86Resetting;
+}
+
+
+Bool
+xf86ServerIsInitialising(void)
+{
+ return xf86Initialising;
+}
+
+
+Bool
+xf86ServerIsOnlyDetecting(void)
+{
+ return xf86DoConfigure;
+}
+
+
+Bool
+xf86CaughtSignal(void)
+{
+ return xf86Info.caughtSignal;
+}
+
+
+Bool
+xf86GetVidModeAllowNonLocal(void)
+{
+ return xf86Info.vidModeAllowNonLocal;
+}
+
+
+Bool
+xf86GetVidModeEnabled(void)
+{
+ return xf86Info.vidModeEnabled;
+}
+
+Bool
+xf86GetModInDevAllowNonLocal(void)
+{
+ return xf86Info.miscModInDevAllowNonLocal;
+}
+
+
+Bool
+xf86GetModInDevEnabled(void)
+{
+ return xf86Info.miscModInDevEnabled;
+}
+
+
+Bool
+xf86GetAllowMouseOpenFail(void)
+{
+ return xf86Info.allowMouseOpenFail;
+}
+
+
+Bool
+xf86IsPc98(void)
+{
+#if SUPPORT_PC98
+ return xf86Info.pc98;
+#else
+ return FALSE;
+#endif
+}
+
+void
+xf86DisableRandR(void)
+{
+ xf86Info.disableRandR = TRUE;
+ xf86Info.randRFrom = X_PROBED;
+}
+
+CARD32
+xf86GetModuleVersion(pointer module)
+{
+ return (CARD32)LoaderGetModuleVersion(module);
+}
+
+pointer
+xf86LoadDrvSubModule(DriverPtr drv, const char *name)
+{
+ pointer ret;
+ int errmaj = 0, errmin = 0;
+
+ ret = LoadSubModule(drv->module, name, NULL, NULL, NULL, NULL,
+ &errmaj, &errmin);
+ if (!ret)
+ LoaderErrorMsg(NULL, name, errmaj, errmin);
+ return ret;
+}
+
+pointer
+xf86LoadSubModule(ScrnInfoPtr pScrn, const char *name)
+{
+ pointer ret;
+ int errmaj = 0, errmin = 0;
+
+ ret = LoadSubModule(pScrn->module, name, NULL, NULL, NULL, NULL,
+ &errmaj, &errmin);
+ if (!ret)
+ LoaderErrorMsg(pScrn->name, name, errmaj, errmin);
+ return ret;
+}
+
+/*
+ * xf86LoadOneModule loads a single module.
+ */
+pointer
+xf86LoadOneModule(char *name, pointer opt)
+{
+ int errmaj, errmin;
+ char *Name;
+ pointer mod;
+
+ if (!name)
+ return NULL;
+
+ /* Normalise the module name */
+ Name = xf86NormalizeName(name);
+
+ /* Skip empty names */
+ if (Name == NULL)
+ return NULL;
+ if (*Name == '\0') {
+ free(Name);
+ return NULL;
+ }
+
+ mod = LoadModule(Name, NULL, NULL, NULL, opt, NULL, &errmaj, &errmin);
+ if (!mod)
+ LoaderErrorMsg(NULL, Name, errmaj, errmin);
+ free(Name);
+ return mod;
+}
+
+void
+xf86UnloadSubModule(pointer mod)
+{
+ /*
+ * This is disabled for now. The loader isn't smart enough yet to undo
+ * relocations.
+ */
+#if 0
+ UnloadSubModule(mod);
+#endif
+}
+
+Bool
+xf86LoaderCheckSymbol(const char *name)
+{
+ return LoaderSymbol(name) != NULL;
+}
+
+typedef enum {
+ OPTION_BACKING_STORE
+} BSOpts;
+
+static const OptionInfoRec BSOptions[] = {
+ { OPTION_BACKING_STORE, "BackingStore", OPTV_BOOLEAN, {0}, FALSE },
+ { -1, NULL, OPTV_NONE, {0}, FALSE }
+};
+
+void
+xf86SetBackingStore(ScreenPtr pScreen)
+{
+ Bool useBS = FALSE;
+ MessageType from = X_DEFAULT;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ OptionInfoPtr options;
+
+ options = xnfalloc(sizeof(BSOptions));
+ (void)memcpy(options, BSOptions, sizeof(BSOptions));
+ xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options);
+
+ /* check for commandline option here */
+ if (xf86bsEnableFlag) {
+ from = X_CMDLINE;
+ useBS = TRUE;
+ } else if (xf86bsDisableFlag) {
+ from = X_CMDLINE;
+ useBS = FALSE;
+ } else {
+ if (xf86GetOptValBool(options, OPTION_BACKING_STORE, &useBS))
+ from = X_CONFIG;
+ }
+ free(options);
+ pScreen->backingStoreSupport = useBS ? Always : NotUseful;
+ if (serverGeneration == 1)
+ xf86DrvMsg(pScreen->myNum, from, "Backing store %s\n",
+ useBS ? "enabled" : "disabled");
+}
+
+
+typedef enum {
+ OPTION_SILKEN_MOUSE
+} SMOpts;
+
+static const OptionInfoRec SMOptions[] = {
+ { OPTION_SILKEN_MOUSE, "SilkenMouse", OPTV_BOOLEAN, {0}, FALSE },
+ { -1, NULL, OPTV_NONE, {0}, FALSE }
+};
+
+void
+xf86SetSilkenMouse (ScreenPtr pScreen)
+{
+ Bool useSM = TRUE;
+ MessageType from = X_DEFAULT;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ OptionInfoPtr options;
+
+ options = xnfalloc(sizeof(SMOptions));
+ (void)memcpy(options, SMOptions, sizeof(SMOptions));
+ xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options);
+
+ /* check for commandline option here */
+ /* disable if screen shares resources */
+ /* TODO VGA arb disable silken mouse */
+ if (xf86silkenMouseDisableFlag) {
+ from = X_CMDLINE;
+ useSM = FALSE;
+ } else {
+ if (xf86GetOptValBool(options, OPTION_SILKEN_MOUSE, &useSM))
+ from = X_CONFIG;
+ }
+ free(options);
+ /*
+ * XXX quick hack to report correctly for OSs that can't do SilkenMouse
+ * yet. Should handle this differently so that alternate async methods
+ * work correctly with this too.
+ */
+ pScrn->silkenMouse = useSM && xf86Info.useSIGIO && xf86SIGIOSupported();
+ if (serverGeneration == 1)
+ xf86DrvMsg(pScreen->myNum, from, "Silken mouse %s\n",
+ pScrn->silkenMouse ? "enabled" : "disabled");
+}
+
+/* Wrote this function for the PM2 Xv driver, preliminary. */
+
+pointer
+xf86FindXvOptions(int scrnIndex, int adaptor_index, char *port_name,
+ char **adaptor_name, pointer *adaptor_options)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ confXvAdaptorPtr adaptor;
+ int i;
+
+ if (adaptor_index >= pScrn->confScreen->numxvadaptors) {
+ if (adaptor_name) *adaptor_name = NULL;
+ if (adaptor_options) *adaptor_options = NULL;
+ return NULL;
+ }
+
+ adaptor = &pScrn->confScreen->xvadaptors[adaptor_index];
+ if (adaptor_name) *adaptor_name = adaptor->identifier;
+ if (adaptor_options) *adaptor_options = adaptor->options;
+
+ for (i = 0; i < adaptor->numports; i++)
+ if (!xf86NameCmp(adaptor->ports[i].identifier, port_name))
+ return adaptor->ports[i].options;
+
+ return NULL;
+}
+
+/* Rather than duplicate loader's get OS function, just include it directly */
+#define LoaderGetOS xf86GetOS
+#include "loader/os.c"
+
+static void
+xf86ConfigFbEntityInactive(EntityInfoPtr pEnt, EntityProc init,
+ EntityProc enter, EntityProc leave, pointer private)
+{
+ ScrnInfoPtr pScrn;
+
+ if ((pScrn = xf86FindScreenForEntity(pEnt->index)))
+ xf86RemoveEntityFromScreen(pScrn,pEnt->index);
+ xf86SetEntityFuncs(pEnt->index,init,enter,leave,private);
+}
+
+ScrnInfoPtr
+xf86ConfigFbEntity(ScrnInfoPtr pScrn, int scrnFlag, int entityIndex,
+ EntityProc init, EntityProc enter, EntityProc leave,
+ pointer private)
+{
+ EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex);
+ if (!pEnt) return pScrn;
+
+ if (!(pEnt->location.type == BUS_NONE)) {
+ free(pEnt);
+ return pScrn;
+ }
+
+ if (!pEnt->active) {
+ xf86ConfigFbEntityInactive(pEnt, init, enter, leave, private);
+ free(pEnt);
+ return pScrn;
+ }
+
+ if (!pScrn)
+ pScrn = xf86AllocateScreen(pEnt->driver,scrnFlag);
+ xf86AddEntityToScreen(pScrn,entityIndex);
+
+ xf86SetEntityFuncs(entityIndex,init,enter,leave,private);
+
+ free(pEnt);
+ return pScrn;
+}
+
+Bool
+xf86IsScreenPrimary(int scrnIndex)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ int i;
+
+ for (i=0 ; i < pScrn->numEntities; i++) {
+ if (xf86IsEntityPrimary(i))
+ return TRUE;
+ }
+ return FALSE;
+}
+
+int
+xf86RegisterRootWindowProperty(int ScrnIndex, Atom property, Atom type,
+ int format, unsigned long len, pointer value )
+{
+ RootWinPropPtr pNewProp = NULL, pRegProp;
+ int i;
+ Bool existing = FALSE;
+
+ DebugF("xf86RegisterRootWindowProperty(%d, %ld, %ld, %d, %ld, %p)\n",
+ ScrnIndex, property, type, format, len, value);
+
+ if (ScrnIndex<0 || ScrnIndex>=xf86NumScreens) {
+ return BadMatch;
+ }
+
+ if (xf86RegisteredPropertiesTable &&
+ xf86RegisteredPropertiesTable[ScrnIndex]) {
+ for (pNewProp = xf86RegisteredPropertiesTable[ScrnIndex];
+ pNewProp; pNewProp = pNewProp->next) {
+ if (strcmp(pNewProp->name, NameForAtom(property)) == 0)
+ break;
+ }
+ }
+
+ if (!pNewProp) {
+ if ((pNewProp = (RootWinPropPtr)malloc(sizeof(RootWinProp))) == NULL) {
+ return BadAlloc;
+ }
+ /*
+ * We will put this property at the end of the list so that
+ * the changes are made in the order they were requested.
+ */
+ pNewProp->next = NULL;
+ } else {
+ free(pNewProp->name);
+ existing = TRUE;
+ }
+
+ pNewProp->name = xnfstrdup(NameForAtom(property));
+ pNewProp->type = type;
+ pNewProp->format = format;
+ pNewProp->size = len;
+ pNewProp->data = value;
+
+ DebugF("new property filled\n");
+
+ if (NULL==xf86RegisteredPropertiesTable) {
+ DebugF("creating xf86RegisteredPropertiesTable[] size %d\n",
+ xf86NumScreens);
+ if ( NULL==(xf86RegisteredPropertiesTable=(RootWinPropPtr*)xnfcalloc(sizeof(RootWinProp),xf86NumScreens) )) {
+ return BadAlloc;
+ }
+ for (i=0; i<xf86NumScreens; i++) {
+ xf86RegisteredPropertiesTable[i] = NULL;
+ }
+ }
+
+ DebugF("xf86RegisteredPropertiesTable %p\n",
+ (void *)xf86RegisteredPropertiesTable);
+ DebugF("xf86RegisteredPropertiesTable[%d] %p\n",
+ ScrnIndex, (void *)xf86RegisteredPropertiesTable[ScrnIndex]);
+
+ if (!existing) {
+ if ( xf86RegisteredPropertiesTable[ScrnIndex] == NULL) {
+ xf86RegisteredPropertiesTable[ScrnIndex] = pNewProp;
+ } else {
+ pRegProp = xf86RegisteredPropertiesTable[ScrnIndex];
+ while (pRegProp->next != NULL) {
+ DebugF("- next %p\n", (void *)pRegProp);
+ pRegProp = pRegProp->next;
+ }
+ pRegProp->next = pNewProp;
+ }
+ }
+ DebugF("xf86RegisterRootWindowProperty succeeded\n");
+ return Success;
+}
+
+Bool
+xf86IsUnblank(int mode)
+{
+ switch(mode) {
+ case SCREEN_SAVER_OFF:
+ case SCREEN_SAVER_FORCER:
+ return TRUE;
+ case SCREEN_SAVER_ON:
+ case SCREEN_SAVER_CYCLE:
+ return FALSE;
+ default:
+ xf86MsgVerb(X_WARNING, 0, "Unexpected save screen mode: %d\n", mode);
+ return TRUE;
+ }
+}
+
+void
+xf86MotionHistoryAllocate(InputInfoPtr pInfo)
+{
+ AllocateMotionHistory(pInfo->dev);
+}
diff --git a/xorg-server/hw/xfree86/common/xf86Init.c b/xorg-server/hw/xfree86/common/xf86Init.c
index 94e1a5dbd..71926f8e7 100644
--- a/xorg-server/hw/xfree86/common/xf86Init.c
+++ b/xorg-server/hw/xfree86/common/xf86Init.c
@@ -1,1520 +1,1520 @@
-/*
- * Loosely based on code bearing the following copyright:
- *
- * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
- */
-/*
- * Copyright (c) 1992-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).
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <stdlib.h>
-#include <errno.h>
-
-#undef HAS_UTSNAME
-#if !defined(WIN32)
-#define HAS_UTSNAME 1
-#include <sys/utsname.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xmd.h>
-#include <X11/Xproto.h>
-#include <X11/Xatom.h>
-#include "input.h"
-#include "servermd.h"
-#include "windowstr.h"
-#include "scrnintstr.h"
-#include "site.h"
-#include "mi.h"
-
-#include "compiler.h"
-
-#include "loaderProcs.h"
-#ifdef XFreeXDGA
-#include "dgaproc.h"
-#endif
-
-#define XF86_OS_PRIVS
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86Config.h"
-#include "xf86_OSlib.h"
-#include "xf86cmap.h"
-#include "xorgVersion.h"
-#include "xf86Build.h"
-#include "mipointer.h"
-#include <X11/extensions/XI.h>
-#include <X11/extensions/XIproto.h>
-#include "xf86DDC.h"
-#include "xf86Xinput.h"
-#include "xf86InPriv.h"
-#include "picturestr.h"
-
-#include "xf86Bus.h"
-#include "xf86VGAarbiter.h"
-#include "globals.h"
-
-#ifdef DPMSExtension
-#include <X11/extensions/dpmsconst.h>
-#include "dpmsproc.h"
-#endif
-#include <hotplug.h>
-
-
-#ifdef XF86PM
-void (*xf86OSPMClose)(void) = NULL;
-#endif
-static Bool xorgHWOpenConsole = FALSE;
-
-/* Common pixmap formats */
-
-static PixmapFormatRec formats[MAXFORMATS] = {
- { 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 },
- { 32, 32, BITMAP_SCANLINE_PAD },
-};
-static int numFormats = 7;
-static Bool formatsDone = FALSE;
-
-#ifndef OSNAME
-#define OSNAME " unknown"
-#endif
-#ifndef OSVENDOR
-#define OSVENDOR ""
-#endif
-#ifndef PRE_RELEASE
-#define PRE_RELEASE XORG_VERSION_SNAP
-#endif
-
-static void
-xf86PrintBanner(void)
-{
-#if PRE_RELEASE
- xf86ErrorFVerb(0, "\n"
- "This is a pre-release version of the X server from " XVENDORNAME ".\n"
- "It is not supported in any way.\n"
- "Bugs may be filed in the bugzilla at http://bugs.freedesktop.org/.\n"
- "Select the \"xorg\" product for bugs you find in this release.\n"
- "Before reporting bugs in pre-release versions please check the\n"
- "latest version in the X.Org Foundation git repository.\n"
- "See http://wiki.x.org/wiki/GitPage for git access instructions.\n");
-#endif
- xf86ErrorFVerb(0, "\nX.Org X Server %d.%d.%d",
- XORG_VERSION_MAJOR,
- XORG_VERSION_MINOR,
- XORG_VERSION_PATCH);
-#if XORG_VERSION_SNAP > 0
- xf86ErrorFVerb(0, ".%d", XORG_VERSION_SNAP);
-#endif
-
-#if XORG_VERSION_SNAP >= 900
- /* When the minor number is 99, that signifies that the we are making
- * a release candidate for a major version. (X.0.0)
- * When the patch number is 99, that signifies that the we are making
- * a release candidate for a minor version. (X.Y.0)
- * When the patch number is < 99, then we are making a release
- * candidate for the next point release. (X.Y.Z)
- */
-#if XORG_VERSION_MINOR >= 99
- xf86ErrorFVerb(0, " (%d.0.0 RC %d)", XORG_VERSION_MAJOR+1,
- XORG_VERSION_SNAP - 900);
-#elif XORG_VERSION_PATCH == 99
- xf86ErrorFVerb(0, " (%d.%d.0 RC %d)", XORG_VERSION_MAJOR,
- XORG_VERSION_MINOR + 1, XORG_VERSION_SNAP - 900);
-#else
- xf86ErrorFVerb(0, " (%d.%d.%d RC %d)", XORG_VERSION_MAJOR,
- XORG_VERSION_MINOR, XORG_VERSION_PATCH + 1,
- XORG_VERSION_SNAP - 900);
-#endif
-#endif
-
-#ifdef XORG_CUSTOM_VERSION
- xf86ErrorFVerb(0, " (%s)", XORG_CUSTOM_VERSION);
-#endif
-#ifndef XORG_DATE
-# define XORG_DATE "Unknown"
-#endif
- xf86ErrorFVerb(0, "\nRelease Date: %s\n", XORG_DATE);
- xf86ErrorFVerb(0, "X Protocol Version %d, Revision %d\n",
- X_PROTOCOL, X_PROTOCOL_REVISION);
- xf86ErrorFVerb(0, "Build Operating System: %s %s\n", OSNAME, OSVENDOR);
-#ifdef HAS_UTSNAME
- {
- struct utsname name;
-
- /* Linux & BSD state that 0 is success, SysV (including Solaris, HP-UX,
- and Irix) and Single Unix Spec 3 just say that non-negative is success.
- All agree that failure is represented by a negative number.
- */
- if (uname(&name) >= 0) {
- xf86ErrorFVerb(0, "Current Operating System: %s %s %s %s %s\n",
- name.sysname, name.nodename, name.release, name.version, name.machine);
-#ifdef linux
- do {
- char buf[80];
- int fd = open("/proc/cmdline", O_RDONLY);
- if (fd != -1) {
- xf86ErrorFVerb(0, "Kernel command line: ");
- memset(buf, 0, 80);
- while (read(fd, buf, 80) > 0) {
- xf86ErrorFVerb(0, "%.80s", buf);
- memset(buf, 0, 80);
- }
- close(fd);
- }
- } while (0);
-#endif
- }
- }
-#endif
-#if defined(BUILD_DATE) && (BUILD_DATE > 19000000)
- {
- struct tm t;
- char buf[100];
-
- memset(&t, 0, sizeof(t));
- memset(buf, 0, sizeof(buf));
- t.tm_mday = BUILD_DATE % 100;
- t.tm_mon = (BUILD_DATE / 100) % 100 - 1;
- t.tm_year = BUILD_DATE / 10000 - 1900;
-#if defined(BUILD_TIME)
- t.tm_sec = BUILD_TIME % 100;
- t.tm_min = (BUILD_TIME / 100) % 100;
- t.tm_hour = (BUILD_TIME / 10000) % 100;
- if (strftime(buf, sizeof(buf), "%d %B %Y %I:%M:%S%p", &t))
- xf86ErrorFVerb(0, "Build Date: %s\n", buf);
-#else
- if (strftime(buf, sizeof(buf), "%d %B %Y", &t))
- xf86ErrorFVerb(0, "Build Date: %s\n", buf);
-#endif
- }
-#endif
-#if defined(BUILDERSTRING)
- xf86ErrorFVerb(0, "%s \n", BUILDERSTRING);
-#endif
- xf86ErrorFVerb(0, "Current version of pixman: %s\n",
- pixman_version_string());
- xf86ErrorFVerb(0, "\tBefore reporting problems, check "
- ""__VENDORDWEBSUPPORT__"\n"
- "\tto make sure that you have the latest version.\n");
-}
-
-static void
-xf86PrintMarkers(void)
-{
- LogPrintMarkers();
-}
-
-static Bool
-xf86CreateRootWindow(WindowPtr pWin)
-{
- int ret = TRUE;
- int err = Success;
- ScreenPtr pScreen = pWin->drawable.pScreen;
- RootWinPropPtr pProp;
- CreateWindowProcPtr CreateWindow = (CreateWindowProcPtr)
- dixLookupPrivate(&pScreen->devPrivates, xf86CreateRootWindowKey);
-
- DebugF("xf86CreateRootWindow(%p)\n", pWin);
-
- if ( pScreen->CreateWindow != xf86CreateRootWindow ) {
- /* Can't find hook we are hung on */
- xf86DrvMsg(pScreen->myNum, X_WARNING /* X_ERROR */,
- "xf86CreateRootWindow %p called when not in pScreen->CreateWindow %p n",
- (void *)xf86CreateRootWindow,
- (void *)pScreen->CreateWindow );
- }
-
- /* Unhook this function ... */
- pScreen->CreateWindow = CreateWindow;
- dixSetPrivate(&pScreen->devPrivates, xf86CreateRootWindowKey, NULL);
-
- /* ... and call the previous CreateWindow fuction, if any */
- if (NULL!=pScreen->CreateWindow) {
- ret = (*pScreen->CreateWindow)(pWin);
- }
-
- /* Now do our stuff */
- if (xf86RegisteredPropertiesTable != NULL) {
- if (pWin->parent == NULL && xf86RegisteredPropertiesTable != NULL) {
- for (pProp = xf86RegisteredPropertiesTable[pScreen->myNum];
- pProp != NULL && err==Success;
- pProp = pProp->next )
- {
- Atom prop;
-
- prop = MakeAtom(pProp->name, strlen(pProp->name), TRUE);
- err = dixChangeWindowProperty(serverClient, pWin,
- prop, pProp->type,
- pProp->format, PropModeReplace,
- pProp->size, pProp->data,
- FALSE);
- }
-
- /* Look at err */
- ret &= (err==Success);
-
- } else {
- xf86Msg(X_ERROR, "xf86CreateRootWindow unexpectedly called with "
- "non-root window %p (parent %p)\n",
- (void *)pWin, (void *)pWin->parent);
- ret = FALSE;
- }
- }
-
- DebugF("xf86CreateRootWindow() returns %d\n", ret);
- return ret;
-}
-
-
-static void
-InstallSignalHandlers(void)
-{
- /*
- * Install signal handler for unexpected signals
- */
- xf86Info.caughtSignal=FALSE;
- if (!xf86Info.notrapSignals) {
- OsRegisterSigWrapper(xf86SigWrapper);
- } else {
- signal(SIGSEGV, SIG_DFL);
- signal(SIGILL, SIG_DFL);
-#ifdef SIGEMT
- signal(SIGEMT, SIG_DFL);
-#endif
- signal(SIGFPE, SIG_DFL);
- signal(SIGBUS, SIG_DFL);
- signal(SIGSYS, SIG_DFL);
- signal(SIGXCPU, SIG_DFL);
- signal(SIGXFSZ, SIG_DFL);
- }
-}
-
-/*
- * InitOutput --
- * Initialize screenInfo for all actually accessible framebuffers.
- * That includes vt-manager setup, querying all possible devices and
- * collecting the pixmap formats.
- */
-void
-InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
-{
- int i, j, k, scr_index, was_blocked = 0;
- char **modulelist;
- pointer *optionlist;
- Pix24Flags screenpix24, pix24;
- MessageType pix24From = X_DEFAULT;
- Bool pix24Fail = FALSE;
- Bool autoconfig = FALSE;
- GDevPtr configured_device;
-
- xf86Initialising = TRUE;
-
- if (serverGeneration == 1) {
- if ((xf86ServerName = strrchr(argv[0], '/')) != 0)
- xf86ServerName++;
- else
- xf86ServerName = argv[0];
-
- xf86PrintBanner();
- xf86PrintMarkers();
- if (xf86LogFile) {
- time_t t;
- const char *ct;
- t = time(NULL);
- ct = ctime(&t);
- xf86MsgVerb(xf86LogFileFrom, 0, "Log file: \"%s\", Time: %s",
- xf86LogFile, ct);
- }
-
- /* Read and parse the config file */
- if (!xf86DoConfigure && !xf86DoShowOptions) {
- switch (xf86HandleConfigFile(FALSE)) {
- case CONFIG_OK:
- break;
- case CONFIG_PARSE_ERROR:
- xf86Msg(X_ERROR, "Error parsing the config file\n");
- return;
- case CONFIG_NOFILE:
- autoconfig = TRUE;
- break;
- }
- }
-
- InstallSignalHandlers();
-
- /* Initialise the loader */
- LoaderInit();
-
- /* Tell the loader the default module search path */
- LoaderSetPath(xf86ModulePath);
-
- if (xf86Info.ignoreABI) {
- LoaderSetOptions(LDR_OPT_ABI_MISMATCH_NONFATAL);
- }
-
- if (xf86DoShowOptions)
- DoShowOptions();
-
- /* Do a general bus probe. This will be a PCI probe for x86 platforms */
- xf86BusProbe();
-
- if (xf86DoConfigure)
- DoConfigure();
-
- if (autoconfig) {
- if (!xf86AutoConfig()) {
- xf86Msg(X_ERROR, "Auto configuration failed\n");
- return;
- }
- }
-
-#ifdef XF86PM
- xf86OSPMClose = xf86OSPMOpen();
-#endif
-
- /* Load all modules specified explicitly in the config file */
- if ((modulelist = xf86ModulelistFromConfig(&optionlist))) {
- xf86LoadModules(modulelist, optionlist);
- free(modulelist);
- free(optionlist);
- }
-
- /* Load all driver modules specified in the config file */
- /* If there aren't any specified in the config file, autoconfig them */
- /* FIXME: Does not handle multiple active screen sections, but I'm not
- * sure if we really want to handle that case*/
- configured_device = xf86ConfigLayout.screens->screen->device;
- if ((!configured_device) || (!configured_device->driver)) {
- if (!autoConfigDevice(configured_device)) {
- xf86Msg(X_ERROR, "Automatic driver configuration failed\n");
- return ;
- }
- }
- if ((modulelist = xf86DriverlistFromConfig())) {
- xf86LoadModules(modulelist, NULL);
- free(modulelist);
- }
-
- /* Load all input driver modules specified in the config file. */
- if ((modulelist = xf86InputDriverlistFromConfig())) {
- xf86LoadModules(modulelist, NULL);
- free(modulelist);
- }
-
- /*
- * It is expected that xf86AddDriver()/xf86AddInputDriver will be
- * called for each driver as it is loaded. Those functions save the
- * module pointers for drivers.
- * XXX Nothing keeps track of them for other modules.
- */
- /* XXX What do we do if not all of these could be loaded? */
-
- /*
- * At this point, xf86DriverList[] is all filled in with entries for
- * each of the drivers to try and xf86NumDrivers has the number of
- * drivers. If there are none, return now.
- */
-
- if (xf86NumDrivers == 0) {
- xf86Msg(X_ERROR, "No drivers available.\n");
- return;
- }
-
- /*
- * Call each of the Identify functions and call the driverFunc to check
- * if HW access is required. The Identify functions print out some
- * identifying information, and anything else that might be
- * needed at this early stage.
- */
-
- for (i = 0; i < xf86NumDrivers; i++) {
- if (xf86DriverList[i]->Identify != NULL)
- xf86DriverList[i]->Identify(0);
-
- if (!xorgHWAccess || !xorgHWOpenConsole) {
- xorgHWFlags flags;
- if(!xf86DriverList[i]->driverFunc
- || !xf86DriverList[i]->driverFunc(NULL,
- GET_REQUIRED_HW_INTERFACES,
- &flags))
- flags = HW_IO;
-
- if(NEED_IO_ENABLED(flags))
- xorgHWAccess = TRUE;
- if(!(flags & HW_SKIP_CONSOLE))
- xorgHWOpenConsole = TRUE;
- }
- }
-
- if (xorgHWOpenConsole)
- xf86OpenConsole();
- else
- xf86Info.dontVTSwitch = TRUE;
-
- if (xf86BusConfig() == FALSE)
- return;
-
- xf86PostProbe();
-
- /*
- * Sort the drivers to match the requested ording. Using a slow
- * bubble sort.
- */
- for (j = 0; j < xf86NumScreens - 1; j++) {
- for (i = 0; i < xf86NumScreens - j - 1; i++) {
- if (xf86Screens[i + 1]->confScreen->screennum <
- xf86Screens[i]->confScreen->screennum) {
- ScrnInfoPtr tmpScrn = xf86Screens[i + 1];
- xf86Screens[i + 1] = xf86Screens[i];
- xf86Screens[i] = tmpScrn;
- }
- }
- }
- /* Fix up the indexes */
- for (i = 0; i < xf86NumScreens; i++) {
- xf86Screens[i]->scrnIndex = i;
- }
-
- /*
- * Call the driver's PreInit()'s to complete initialisation for the first
- * generation.
- */
-
- for (i = 0; i < xf86NumScreens; i++) {
- xf86VGAarbiterScrnInit(xf86Screens[i]);
- xf86VGAarbiterLock(xf86Screens[i]);
- if (xf86Screens[i]->PreInit &&
- xf86Screens[i]->PreInit(xf86Screens[i], 0))
- xf86Screens[i]->configured = TRUE;
- xf86VGAarbiterUnlock(xf86Screens[i]);
- }
- for (i = 0; i < xf86NumScreens; i++)
- if (!xf86Screens[i]->configured)
- xf86DeleteScreen(i--, 0);
-
- /*
- * If no screens left, return now.
- */
-
- if (xf86NumScreens == 0) {
- xf86Msg(X_ERROR,
- "Screen(s) found, but none have a usable configuration.\n");
- return;
- }
-
- for (i = 0; i < xf86NumScreens; i++) {
- if (xf86Screens[i]->name == NULL) {
- XNFasprintf(&xf86Screens[i]->name, "screen%d", i);
- xf86MsgVerb(X_WARNING, 0,
- "Screen driver %d has no name set, using `%s'.\n",
- i, xf86Screens[i]->name);
- }
- }
-
- /* Remove (unload) drivers that are not required */
- for (i = 0; i < xf86NumDrivers; i++)
- if (xf86DriverList[i] && xf86DriverList[i]->refCount <= 0)
- xf86DeleteDriver(i);
-
- /*
- * At this stage we know how many screens there are.
- */
-
- for (i = 0; i < xf86NumScreens; i++)
- xf86InitViewport(xf86Screens[i]);
-
- /*
- * Collect all pixmap formats and check for conflicts at the display
- * level. Should we die here? Or just delete the offending screens?
- */
- screenpix24 = Pix24DontCare;
- for (i = 0; i < xf86NumScreens; i++) {
- if (xf86Screens[i]->imageByteOrder !=
- xf86Screens[0]->imageByteOrder)
- FatalError("Inconsistent display bitmapBitOrder. Exiting\n");
- if (xf86Screens[i]->bitmapScanlinePad !=
- xf86Screens[0]->bitmapScanlinePad)
- FatalError("Inconsistent display bitmapScanlinePad. Exiting\n");
- if (xf86Screens[i]->bitmapScanlineUnit !=
- xf86Screens[0]->bitmapScanlineUnit)
- FatalError("Inconsistent display bitmapScanlineUnit. Exiting\n");
- if (xf86Screens[i]->bitmapBitOrder !=
- xf86Screens[0]->bitmapBitOrder)
- FatalError("Inconsistent display bitmapBitOrder. Exiting\n");
-
- /* Determine the depth 24 pixmap format the screens would like */
- if (xf86Screens[i]->pixmap24 != Pix24DontCare) {
- if (screenpix24 == Pix24DontCare)
- screenpix24 = xf86Screens[i]->pixmap24;
- else if (screenpix24 != xf86Screens[i]->pixmap24)
- FatalError("Inconsistent depth 24 pixmap format. Exiting\n");
- }
- }
- /* check if screenpix24 is consistent with the config/cmdline */
- if (xf86Info.pixmap24 != Pix24DontCare) {
- pix24 = xf86Info.pixmap24;
- pix24From = xf86Info.pix24From;
- if (screenpix24 != Pix24DontCare && screenpix24 != xf86Info.pixmap24)
- pix24Fail = TRUE;
- } else if (screenpix24 != Pix24DontCare) {
- pix24 = screenpix24;
- pix24From = X_PROBED;
- } else
- pix24 = Pix24Use32;
-
- if (pix24Fail)
- FatalError("Screen(s) can't use the required depth 24 pixmap format"
- " (%d). Exiting\n", PIX24TOBPP(pix24));
-
- /* Initialise the depth 24 format */
- for (j = 0; j < numFormats && formats[j].depth != 24; j++)
- ;
- formats[j].bitsPerPixel = PIX24TOBPP(pix24);
-
- /* Collect additional formats */
- for (i = 0; i < xf86NumScreens; i++) {
- for (j = 0; j < xf86Screens[i]->numFormats; j++) {
- for (k = 0; ; k++) {
- if (k >= numFormats) {
- if (k >= MAXFORMATS)
- FatalError("Too many pixmap formats! Exiting\n");
- formats[k] = xf86Screens[i]->formats[j];
- numFormats++;
- break;
- }
- if (formats[k].depth == xf86Screens[i]->formats[j].depth) {
- if ((formats[k].bitsPerPixel ==
- xf86Screens[i]->formats[j].bitsPerPixel) &&
- (formats[k].scanlinePad ==
- xf86Screens[i]->formats[j].scanlinePad))
- break;
- FatalError("Inconsistent pixmap format for depth %d."
- " Exiting\n", formats[k].depth);
- }
- }
- }
- }
- formatsDone = TRUE;
-
- if (xf86Info.vtno >= 0 ) {
-#define VT_ATOM_NAME "XFree86_VT"
- Atom VTAtom=-1;
- CARD32 *VT = NULL;
- int ret;
-
- /* This memory needs to stay available until the screen has been
- initialized, and we can create the property for real.
- */
- if ( (VT = malloc(sizeof(CARD32)))==NULL ) {
- FatalError("Unable to make VT property - out of memory. Exiting...\n");
- }
- *VT = xf86Info.vtno;
-
- VTAtom = MakeAtom(VT_ATOM_NAME, sizeof(VT_ATOM_NAME) - 1, TRUE);
-
- for (i = 0, ret = Success; i < xf86NumScreens && ret == Success; i++) {
- ret = xf86RegisterRootWindowProperty(xf86Screens[i]->scrnIndex,
- VTAtom, XA_INTEGER, 32,
- 1, VT );
- if (ret != Success)
- xf86DrvMsg(xf86Screens[i]->scrnIndex, X_WARNING,
- "Failed to register VT property\n");
- }
- }
-
- /* If a screen uses depth 24, show what the pixmap format is */
- for (i = 0; i < xf86NumScreens; i++) {
- if (xf86Screens[i]->depth == 24) {
- xf86Msg(pix24From, "Depth 24 pixmap format is %d bpp\n",
- PIX24TOBPP(pix24));
- break;
- }
- }
- } else {
- /*
- * serverGeneration != 1; some OSs have to do things here, too.
- */
- if (xorgHWOpenConsole)
- xf86OpenConsole();
-
-#ifdef XF86PM
- /*
- should we reopen it here? We need to deal with an already opened
- device. We could leave this to the OS layer. For now we simply
- close it here
- */
- if (xf86OSPMClose)
- xf86OSPMClose();
- if ((xf86OSPMClose = xf86OSPMOpen()) != NULL)
- xf86MsgVerb(X_INFO, 3, "APM registered successfully\n");
-#endif
-
- /* Make sure full I/O access is enabled */
- if (xorgHWAccess)
- xf86EnableIO();
- }
-
- /*
- * Use the previously collected parts to setup pScreenInfo
- */
-
- pScreenInfo->imageByteOrder = xf86Screens[0]->imageByteOrder;
- pScreenInfo->bitmapScanlinePad = xf86Screens[0]->bitmapScanlinePad;
- pScreenInfo->bitmapScanlineUnit = xf86Screens[0]->bitmapScanlineUnit;
- pScreenInfo->bitmapBitOrder = xf86Screens[0]->bitmapBitOrder;
- pScreenInfo->numPixmapFormats = numFormats;
- for (i = 0; i < numFormats; i++)
- pScreenInfo->formats[i] = formats[i];
-
- /* Make sure the server's VT is active */
-
- if (serverGeneration != 1) {
- xf86Resetting = TRUE;
- /* All screens are in the same state, so just check the first */
- if (!xf86Screens[0]->vtSema) {
-#ifdef HAS_USL_VTS
- ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ);
-#endif
- xf86AccessEnter();
- was_blocked = xf86BlockSIGIO();
- }
- }
-
- for (i = 0; i < xf86NumScreens; i++)
- if (!xf86ColormapAllocatePrivates(xf86Screens[i]))
- FatalError("Cannot register DDX private keys");
-
- if (!dixRegisterPrivateKey(&xf86ScreenKeyRec, PRIVATE_SCREEN, 0) ||
- !dixRegisterPrivateKey(&xf86CreateRootWindowKeyRec, PRIVATE_SCREEN, 0))
- FatalError("Cannot register DDX private keys");
-
- for (i = 0; i < xf86NumScreens; i++) {
- xf86VGAarbiterLock(xf86Screens[i]);
- /*
- * Almost everything uses these defaults, and many of those that
- * don't, will wrap them.
- */
- xf86Screens[i]->EnableDisableFBAccess = xf86EnableDisableFBAccess;
-#ifdef XFreeXDGA
- xf86Screens[i]->SetDGAMode = xf86SetDGAMode;
-#endif
- xf86Screens[i]->DPMSSet = NULL;
- xf86Screens[i]->LoadPalette = NULL;
- xf86Screens[i]->SetOverscan = NULL;
- xf86Screens[i]->DriverFunc = NULL;
- xf86Screens[i]->pScreen = NULL;
- scr_index = AddScreen(xf86Screens[i]->ScreenInit, argc, argv);
- xf86VGAarbiterUnlock(xf86Screens[i]);
- if (scr_index == i) {
- /*
- * Hook in our ScrnInfoRec, and initialise some other pScreen
- * fields.
- */
- dixSetPrivate(&screenInfo.screens[scr_index]->devPrivates,
- xf86ScreenKey, xf86Screens[i]);
- xf86Screens[i]->pScreen = screenInfo.screens[scr_index];
- /* The driver should set this, but make sure it is set anyway */
- xf86Screens[i]->vtSema = TRUE;
- } else {
- /* This shouldn't normally happen */
- FatalError("AddScreen/ScreenInit failed for driver %d\n", i);
- }
-
- DebugF("InitOutput - xf86Screens[%d]->pScreen = %p\n",
- i, xf86Screens[i]->pScreen );
- DebugF("xf86Screens[%d]->pScreen->CreateWindow = %p\n",
- i, xf86Screens[i]->pScreen->CreateWindow );
-
- dixSetPrivate(&screenInfo.screens[scr_index]->devPrivates,
- xf86CreateRootWindowKey,
- xf86Screens[i]->pScreen->CreateWindow);
- xf86Screens[i]->pScreen->CreateWindow = xf86CreateRootWindow;
-
- if (PictureGetSubpixelOrder (xf86Screens[i]->pScreen) == SubPixelUnknown)
- {
- xf86MonPtr DDC = (xf86MonPtr)(xf86Screens[i]->monitor->DDC);
- PictureSetSubpixelOrder (xf86Screens[i]->pScreen,
- DDC ?
- (DDC->features.input_type ?
- SubPixelHorizontalRGB : SubPixelNone) :
- SubPixelUnknown);
- }
-#ifdef RANDR
- if (!xf86Info.disableRandR)
- xf86RandRInit (screenInfo.screens[scr_index]);
- xf86Msg(xf86Info.randRFrom, "RandR %s\n",
- xf86Info.disableRandR ? "disabled" : "enabled");
-#endif
- }
-
- xf86VGAarbiterWrapFunctions();
- xf86UnblockSIGIO(was_blocked);
-
- xf86InitOrigins();
-
- xf86Resetting = FALSE;
- xf86Initialising = FALSE;
-
- RegisterBlockAndWakeupHandlers((BlockHandlerProcPtr)NoopDDA, xf86Wakeup,
- NULL);
-}
-
-static InputInfoPtr
-duplicateDevice(InputInfoPtr pInfo)
-{
- InputInfoPtr dup = calloc(1, sizeof(InputInfoRec));
- if (dup) {
- dup->name = strdup(pInfo->name);
- dup->driver = strdup(pInfo->driver);
- dup->options = xf86OptionListDuplicate(pInfo->options);
- /* type_name is a const string */
- dup->type_name = pInfo->type_name;
- dup->fd = -1;
- }
- return dup;
-}
-
-/*
- * InitInput --
- * Initialize all supported input devices.
- */
-
-void
-InitInput(int argc, char **argv)
-{
- InputInfoPtr* pInfo;
- DeviceIntPtr dev;
-
- xf86Info.vtRequestsPending = FALSE;
-
- mieqInit();
-
- /* Initialize all configured input devices */
- for (pInfo = xf86ConfigLayout.inputs; pInfo && *pInfo; pInfo++) {
- InputInfoPtr dup;
- /* Replace obsolete keyboard driver with kbd */
- if (!xf86NameCmp((*pInfo)->driver, "keyboard")) {
- strcpy((*pInfo)->driver, "kbd");
- }
-
- /* Data passed into xf86NewInputDevice will be freed on shutdown.
- * Duplicate from xf86ConfigLayout.inputs, otherwise we don't have any
- * xorg.conf input devices in the second generation
- */
- dup = duplicateDevice(*pInfo);
-
- /* If one fails, the others will too */
- if (xf86NewInputDevice(dup, &dev, TRUE) == BadAlloc)
- break;
- }
-
- config_init();
-}
-
-void
-CloseInput (void)
-{
- config_fini();
- mieqFini();
-}
-
-/*
- * OsVendorInit --
- * OS/Vendor-specific initialisations. Called from OsInit(), which
- * is called by dix before establishing the well known sockets.
- */
-
-void
-OsVendorInit(void)
-{
- static Bool beenHere = FALSE;
-
- signal(SIGCHLD, SIG_DFL); /* Need to wait for child processes */
-
- if (!beenHere) {
- umask(022);
- xf86LogInit();
- }
-
- /* Set stderr to non-blocking. */
-#ifndef O_NONBLOCK
-#if defined(FNDELAY)
-#define O_NONBLOCK FNDELAY
-#elif defined(O_NDELAY)
-#define O_NONBLOCK O_NDELAY
-#endif
-
-#ifdef O_NONBLOCK
- if (!beenHere) {
- if (geteuid() == 0 && getuid() != geteuid())
- {
- int status;
-
- status = fcntl(fileno(stderr), F_GETFL, 0);
- if (status != -1) {
- fcntl(fileno(stderr), F_SETFL, status | O_NONBLOCK);
- }
- }
- }
-#endif
-#endif
-
- beenHere = TRUE;
-}
-
-/*
- * ddxGiveUp --
- * Device dependent cleanup. Called by by dix before normal server death.
- * For SYSV386 we must switch the terminal back to normal mode. No error-
- * checking here, since there should be restored as much as possible.
- */
-
-void
-ddxGiveUp(enum ExitCode error)
-{
- int i;
-
- xf86VGAarbiterFini();
-
-#ifdef XF86PM
- if (xf86OSPMClose)
- xf86OSPMClose();
- xf86OSPMClose = NULL;
-#endif
-
- for (i = 0; i < xf86NumScreens; i++) {
- /*
- * zero all access functions to
- * trap calls when switched away.
- */
- xf86Screens[i]->vtSema = FALSE;
- }
-
-#ifdef XFreeXDGA
- DGAShutdown();
-#endif
-
- if (xorgHWOpenConsole)
- xf86CloseConsole();
-
- xf86CloseLog(error);
-
- /* If an unexpected signal was caught, dump a core for debugging */
- if (xf86Info.caughtSignal)
- OsAbort();
-}
-
-
-
-/*
- * AbortDDX --
- * DDX - specific abort routine. Called by AbortServer(). The attempt is
- * made to restore all original setting of the displays. Also all devices
- * are closed.
- */
-
-void
-AbortDDX(enum ExitCode error)
-{
- int i;
-
- xf86BlockSIGIO();
-
- /*
- * try to restore the original video state
- */
-#ifdef DPMSExtension /* Turn screens back on */
- if (DPMSPowerLevel != DPMSModeOn)
- DPMSSet(serverClient, DPMSModeOn);
-#endif
- if (xf86Screens) {
- for (i = 0; i < xf86NumScreens; i++)
- if (xf86Screens[i]->vtSema) {
- /*
- * if we are aborting before ScreenInit() has finished
- * we might not have been wrapped yet. Therefore enable
- * screen explicitely.
- */
- xf86VGAarbiterLock(xf86Screens[i]);
- (xf86Screens[i]->LeaveVT)(i, 0);
- xf86VGAarbiterUnlock(xf86Screens[i]);
- }
- }
-
- xf86AccessLeave();
-
- /*
- * This is needed for an abnormal server exit, since the normal exit stuff
- * MUST also be performed (i.e. the vt must be left in a defined state)
- */
- ddxGiveUp(error);
-}
-
-void
-OsVendorFatalError(void)
-{
-#ifdef VENDORSUPPORT
- ErrorF("\nPlease refer to your Operating System Vendor support pages\n"
- "at %s for support on this crash.\n",VENDORSUPPORT);
-#else
- ErrorF("\nPlease consult the "XVENDORNAME" support \n"
- "\t at "__VENDORDWEBSUPPORT__"\n for help. \n");
-#endif
- if (xf86LogFile && xf86LogFileWasOpened)
- ErrorF("Please also check the log file at \"%s\" for additional "
- "information.\n", xf86LogFile);
- ErrorF("\n");
-}
-
-int
-xf86SetVerbosity(int verb)
-{
- int save = xf86Verbose;
-
- xf86Verbose = verb;
- LogSetParameter(XLOG_VERBOSITY, verb);
- return save;
-}
-
-int
-xf86SetLogVerbosity(int verb)
-{
- int save = xf86LogVerbose;
-
- xf86LogVerbose = verb;
- LogSetParameter(XLOG_FILE_VERBOSITY, verb);
- return save;
-}
-
-static void
-xf86PrintDefaultModulePath(void)
-{
- ErrorF("%s\n", DEFAULT_MODULE_PATH);
-}
-
-static void
-xf86PrintDefaultLibraryPath(void)
-{
- ErrorF("%s\n", DEFAULT_LIBRARY_PATH);
-}
-
-/*
- * ddxProcessArgument --
- * Process device-dependent command line args. Returns 0 if argument is
- * not device dependent, otherwise Count of number of elements of argv
- * that are part of a device dependent commandline option.
- *
- */
-
-/* ARGSUSED */
-int
-ddxProcessArgument(int argc, char **argv, int i)
-{
-#define CHECK_FOR_REQUIRED_ARGUMENT() \
- if (((i + 1) >= argc) || (!argv[i + 1])) { \
- ErrorF("Required argument to %s not specified\n", argv[i]); \
- UseMsg(); \
- FatalError("Required argument to %s not specified\n", argv[i]); \
- }
-
- /* First the options that are only allowed for root */
- if (!strcmp(argv[i], "-modulepath") || !strcmp(argv[i], "-logfile")) {
- if ( (geteuid() == 0) && (getuid() != 0) ) {
- FatalError("The '%s' option can only be used by root.\n", argv[i]);
- }
- else if (!strcmp(argv[i], "-modulepath"))
- {
- char *mp;
- CHECK_FOR_REQUIRED_ARGUMENT();
- mp = strdup(argv[i + 1]);
- if (!mp)
- FatalError("Can't allocate memory for ModulePath\n");
- xf86ModulePath = mp;
- xf86ModPathFrom = X_CMDLINE;
- return 2;
- }
- else if (!strcmp(argv[i], "-logfile"))
- {
- char *lf;
- CHECK_FOR_REQUIRED_ARGUMENT();
- lf = strdup(argv[i + 1]);
- if (!lf)
- FatalError("Can't allocate memory for LogFile\n");
- xf86LogFile = lf;
- xf86LogFileFrom = X_CMDLINE;
- return 2;
- }
- }
- if (!strcmp(argv[i], "-config") || !strcmp(argv[i], "-xf86config"))
- {
- CHECK_FOR_REQUIRED_ARGUMENT();
- if (getuid() != 0 && !xf86PathIsSafe(argv[i + 1])) {
- FatalError("\nInvalid argument for %s\n"
- "\tFor non-root users, the file specified with %s must be\n"
- "\ta relative path and must not contain any \"..\" elements.\n"
- "\tUsing default "__XCONFIGFILE__" search path.\n\n",
- argv[i], argv[i]);
- }
- xf86ConfigFile = argv[i + 1];
- return 2;
- }
- if (!strcmp(argv[i], "-configdir"))
- {
- CHECK_FOR_REQUIRED_ARGUMENT();
- if (getuid() != 0 && !xf86PathIsSafe(argv[i + 1])) {
- FatalError("\nInvalid argument for %s\n"
- "\tFor non-root users, the file specified with %s must be\n"
- "\ta relative path and must not contain any \"..\" elements.\n"
- "\tUsing default "__XCONFIGDIR__" search path.\n\n",
- argv[i], argv[i]);
- }
- xf86ConfigDir = argv[i + 1];
- return 2;
- }
- if (!strcmp(argv[i],"-flipPixels"))
- {
- xf86FlipPixels = TRUE;
- return 1;
- }
-#ifdef XF86VIDMODE
- if (!strcmp(argv[i],"-disableVidMode"))
- {
- xf86VidModeDisabled = TRUE;
- return 1;
- }
- if (!strcmp(argv[i],"-allowNonLocalXvidtune"))
- {
- xf86VidModeAllowNonLocal = TRUE;
- return 1;
- }
-#endif
- if (!strcmp(argv[i],"-allowMouseOpenFail"))
- {
- xf86AllowMouseOpenFail = TRUE;
- return 1;
- }
- if (!strcmp(argv[i],"-ignoreABI"))
- {
- LoaderSetOptions(LDR_OPT_ABI_MISMATCH_NONFATAL);
- return 1;
- }
- if (!strcmp(argv[i],"-verbose"))
- {
- if (++i < argc && argv[i])
- {
- char *end;
- long val;
- val = strtol(argv[i], &end, 0);
- if (*end == '\0')
- {
- xf86SetVerbosity(val);
- return 2;
- }
- }
- xf86SetVerbosity(++xf86Verbose);
- return 1;
- }
- if (!strcmp(argv[i],"-logverbose"))
- {
- if (++i < argc && argv[i])
- {
- char *end;
- long val;
- val = strtol(argv[i], &end, 0);
- if (*end == '\0')
- {
- xf86SetLogVerbosity(val);
- return 2;
- }
- }
- xf86SetLogVerbosity(++xf86LogVerbose);
- return 1;
- }
- if (!strcmp(argv[i],"-quiet"))
- {
- xf86SetVerbosity(-1);
- return 1;
- }
- if (!strcmp(argv[i],"-showconfig") || !strcmp(argv[i],"-version"))
- {
- xf86PrintBanner();
- exit(0);
- }
- if (!strcmp(argv[i],"-showDefaultModulePath"))
- {
- xf86PrintDefaultModulePath();
- exit(0);
- }
- if (!strcmp(argv[i],"-showDefaultLibPath"))
- {
- xf86PrintDefaultLibraryPath();
- exit(0);
- }
- /* Notice the -fp flag, but allow it to pass to the dix layer */
- if (!strcmp(argv[i], "-fp"))
- {
- xf86fpFlag = TRUE;
- return 0;
- }
- /* Notice the -bs flag, but allow it to pass to the dix layer */
- if (!strcmp(argv[i], "-bs"))
- {
- xf86bsDisableFlag = TRUE;
- return 0;
- }
- /* Notice the +bs flag, but allow it to pass to the dix layer */
- if (!strcmp(argv[i], "+bs"))
- {
- xf86bsEnableFlag = TRUE;
- return 0;
- }
- /* Notice the -s flag, but allow it to pass to the dix layer */
- if (!strcmp(argv[i], "-s"))
- {
- xf86sFlag = TRUE;
- return 0;
- }
- if (!strcmp(argv[i], "-pixmap24"))
- {
- xf86Pix24 = Pix24Use24;
- return 1;
- }
- if (!strcmp(argv[i], "-pixmap32"))
- {
- xf86Pix24 = Pix24Use32;
- return 1;
- }
- if (!strcmp(argv[i], "-fbbpp"))
- {
- int bpp;
- CHECK_FOR_REQUIRED_ARGUMENT();
- if (sscanf(argv[++i], "%d", &bpp) == 1)
- {
- xf86FbBpp = bpp;
- return 2;
- }
- else
- {
- ErrorF("Invalid fbbpp\n");
- return 0;
- }
- }
- if (!strcmp(argv[i], "-depth"))
- {
- int depth;
- CHECK_FOR_REQUIRED_ARGUMENT();
- if (sscanf(argv[++i], "%d", &depth) == 1)
- {
- xf86Depth = depth;
- return 2;
- }
- else
- {
- ErrorF("Invalid depth\n");
- return 0;
- }
- }
- if (!strcmp(argv[i], "-weight"))
- {
- int red, green, blue;
- CHECK_FOR_REQUIRED_ARGUMENT();
- if (sscanf(argv[++i], "%1d%1d%1d", &red, &green, &blue) == 3)
- {
- xf86Weight.red = red;
- xf86Weight.green = green;
- xf86Weight.blue = blue;
- return 2;
- }
- else
- {
- ErrorF("Invalid weighting\n");
- return 0;
- }
- }
- if (!strcmp(argv[i], "-gamma") || !strcmp(argv[i], "-rgamma") ||
- !strcmp(argv[i], "-ggamma") || !strcmp(argv[i], "-bgamma"))
- {
- double gamma;
- CHECK_FOR_REQUIRED_ARGUMENT();
- if (sscanf(argv[++i], "%lf", &gamma) == 1) {
- if (gamma < GAMMA_MIN || gamma > GAMMA_MAX) {
- ErrorF("gamma out of range, only %.2f <= gamma_value <= %.1f"
- " is valid\n", GAMMA_MIN, GAMMA_MAX);
- return 0;
- }
- if (!strcmp(argv[i-1], "-gamma"))
- xf86Gamma.red = xf86Gamma.green = xf86Gamma.blue = gamma;
- else if (!strcmp(argv[i-1], "-rgamma")) xf86Gamma.red = gamma;
- else if (!strcmp(argv[i-1], "-ggamma")) xf86Gamma.green = gamma;
- else if (!strcmp(argv[i-1], "-bgamma")) xf86Gamma.blue = gamma;
- return 2;
- }
- }
- if (!strcmp(argv[i], "-layout"))
- {
- CHECK_FOR_REQUIRED_ARGUMENT();
- xf86LayoutName = argv[++i];
- return 2;
- }
- if (!strcmp(argv[i], "-screen"))
- {
- CHECK_FOR_REQUIRED_ARGUMENT();
- xf86ScreenName = argv[++i];
- return 2;
- }
- if (!strcmp(argv[i], "-pointer"))
- {
- CHECK_FOR_REQUIRED_ARGUMENT();
- xf86PointerName = argv[++i];
- return 2;
- }
- if (!strcmp(argv[i], "-keyboard"))
- {
- CHECK_FOR_REQUIRED_ARGUMENT();
- xf86KeyboardName = argv[++i];
- return 2;
- }
- if (!strcmp(argv[i], "-nosilk"))
- {
- xf86silkenMouseDisableFlag = TRUE;
- return 1;
- }
-#ifdef HAVE_ACPI
- if (!strcmp(argv[i], "-noacpi"))
- {
- xf86acpiDisableFlag = TRUE;
- return 1;
- }
-#endif
- if (!strcmp(argv[i], "-configure"))
- {
- if (getuid() != 0 && geteuid() == 0) {
- ErrorF("The '-configure' option can only be used by root.\n");
- exit(1);
- }
- xf86DoConfigure = TRUE;
- xf86AllowMouseOpenFail = TRUE;
- return 1;
- }
- if (!strcmp(argv[i], "-showopts"))
- {
- if (getuid() != 0 && geteuid() == 0) {
- ErrorF("The '-showopts' option can only be used by root.\n");
- exit(1);
- }
- xf86DoShowOptions = TRUE;
- return 1;
- }
- if (!strcmp(argv[i], "-isolateDevice"))
- {
- CHECK_FOR_REQUIRED_ARGUMENT();
- if (strncmp(argv[++i], "PCI:", 4)) {
- FatalError("Bus types other than PCI not yet isolable\n");
- }
- xf86PciIsolateDevice(argv[i]);
- return 2;
- }
- /* Notice cmdline xkbdir, but pass to dix as well */
- if (!strcmp(argv[i], "-xkbdir"))
- {
- xf86xkbdirFlag = TRUE;
- return 0;
- }
-
- /* OS-specific processing */
- return xf86ProcessArgument(argc, argv, i);
-}
-
-/*
- * ddxUseMsg --
- * Print out correct use of device dependent commandline options.
- * Maybe the user now knows what really to do ...
- */
-
-void
-ddxUseMsg(void)
-{
- ErrorF("\n");
- ErrorF("\n");
- ErrorF("Device Dependent Usage\n");
- if (getuid() == 0 || geteuid() != 0)
- {
- ErrorF("-modulepath paths specify the module search path\n");
- ErrorF("-logfile file specify a log file name\n");
- ErrorF("-configure probe for devices and write an "__XCONFIGFILE__"\n");
- ErrorF("-showopts print available options for all installed drivers\n");
- }
- ErrorF("-config file specify a configuration file, relative to the\n");
- ErrorF(" "__XCONFIGFILE__" search path, only root can use absolute\n");
- ErrorF("-configdir dir specify a configuration directory, relative to the\n");
- ErrorF(" "__XCONFIGDIR__" search path, only root can use absolute\n");
- ErrorF("-verbose [n] verbose startup messages\n");
- ErrorF("-logverbose [n] verbose log messages\n");
- ErrorF("-quiet minimal startup messages\n");
- ErrorF("-pixmap24 use 24bpp pixmaps for depth 24\n");
- ErrorF("-pixmap32 use 32bpp pixmaps for depth 24\n");
- ErrorF("-fbbpp n set bpp for the framebuffer. Default: 8\n");
- ErrorF("-depth n set colour depth. Default: 8\n");
- ErrorF("-gamma f set gamma value (0.1 < f < 10.0) Default: 1.0\n");
- ErrorF("-rgamma f set gamma value for red phase\n");
- ErrorF("-ggamma f set gamma value for green phase\n");
- ErrorF("-bgamma f set gamma value for blue phase\n");
- ErrorF("-weight nnn set RGB weighting at 16 bpp. Default: 565\n");
- ErrorF("-layout name specify the ServerLayout section name\n");
- ErrorF("-screen name specify the Screen section name\n");
- ErrorF("-keyboard name specify the core keyboard InputDevice name\n");
- ErrorF("-pointer name specify the core pointer InputDevice name\n");
- ErrorF("-nosilk disable Silken Mouse\n");
- ErrorF("-flipPixels swap default black/white Pixel values\n");
-#ifdef XF86VIDMODE
- ErrorF("-disableVidMode disable mode adjustments with xvidtune\n");
- ErrorF("-allowNonLocalXvidtune allow xvidtune to be run as a non-local client\n");
-#endif
- ErrorF("-allowMouseOpenFail start server even if the mouse can't be initialized\n");
- ErrorF("-ignoreABI make module ABI mismatches non-fatal\n");
- ErrorF("-isolateDevice bus_id restrict device resets to bus_id (PCI only)\n");
- ErrorF("-version show the server version\n");
- ErrorF("-showDefaultModulePath show the server default module path\n");
- ErrorF("-showDefaultLibPath show the server default library path\n");
- /* OS-specific usage */
- xf86UseMsg();
- ErrorF("\n");
-}
-
-
-/*
- * xf86LoadModules iterates over a list that is being passed in.
- */
-Bool
-xf86LoadModules(char **list, pointer *optlist)
-{
- int errmaj, errmin;
- pointer opt;
- int i;
- char *name;
- Bool failed = FALSE;
-
- if (!list)
- return TRUE;
-
- for (i = 0; list[i] != NULL; i++) {
-
- /* Normalise the module name */
- name = xf86NormalizeName(list[i]);
-
- /* Skip empty names */
- if (name == NULL || *name == '\0') {
- free(name);
- continue;
- }
-
- /* Replace obsolete keyboard driver with kbd */
- if (!xf86NameCmp(name, "keyboard")) {
- strcpy(name, "kbd");
- }
-
- if (optlist)
- opt = optlist[i];
- else
- opt = NULL;
-
- if (!LoadModule(name, NULL, NULL, NULL, opt, NULL, &errmaj, &errmin)) {
- LoaderErrorMsg(NULL, name, errmaj, errmin);
- failed = TRUE;
- }
- free(name);
- }
- return !failed;
-}
-
-/* Pixmap format stuff */
-
-PixmapFormatPtr
-xf86GetPixFormat(ScrnInfoPtr pScrn, int depth)
-{
- int i;
- static PixmapFormatRec format; /* XXX not reentrant */
-
- /*
- * When the formats[] list initialisation isn't complete, check the
- * depth 24 pixmap config/cmdline options and screen-specified formats.
- */
-
- if (!formatsDone) {
- if (depth == 24) {
- Pix24Flags pix24 = Pix24DontCare;
-
- format.depth = 24;
- format.scanlinePad = BITMAP_SCANLINE_PAD;
- if (xf86Info.pixmap24 != Pix24DontCare)
- pix24 = xf86Info.pixmap24;
- else if (pScrn->pixmap24 != Pix24DontCare)
- pix24 = pScrn->pixmap24;
- if (pix24 == Pix24Use24)
- format.bitsPerPixel = 24;
- else
- format.bitsPerPixel = 32;
- return &format;
- }
- }
-
- for (i = 0; i < numFormats; i++)
- if (formats[i].depth == depth)
- break;
- if (i != numFormats)
- return &formats[i];
- else if (!formatsDone) {
- /* Check for screen-specified formats */
- for (i = 0; i < pScrn->numFormats; i++)
- if (pScrn->formats[i].depth == depth)
- break;
- if (i != pScrn->numFormats)
- return &pScrn->formats[i];
- }
- return NULL;
-}
-
-int
-xf86GetBppFromDepth(ScrnInfoPtr pScrn, int depth)
-{
- PixmapFormatPtr format;
-
-
- format = xf86GetPixFormat(pScrn, depth);
- if (format)
- return format->bitsPerPixel;
- else
- return 0;
-}
+/*
+ * Loosely based on code bearing the following copyright:
+ *
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ */
+/*
+ * Copyright (c) 1992-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).
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <stdlib.h>
+#include <errno.h>
+
+#undef HAS_UTSNAME
+#if !defined(WIN32)
+#define HAS_UTSNAME 1
+#include <sys/utsname.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include <X11/Xatom.h>
+#include "input.h"
+#include "servermd.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "site.h"
+#include "mi.h"
+
+#include "compiler.h"
+
+#include "loaderProcs.h"
+#ifdef XFreeXDGA
+#include "dgaproc.h"
+#endif
+
+#define XF86_OS_PRIVS
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86Config.h"
+#include "xf86_OSlib.h"
+#include "xf86cmap.h"
+#include "xorgVersion.h"
+#include "xf86Build.h"
+#include "mipointer.h"
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "xf86DDC.h"
+#include "xf86Xinput.h"
+#include "xf86InPriv.h"
+#include "picturestr.h"
+
+#include "xf86Bus.h"
+#include "xf86VGAarbiter.h"
+#include "globals.h"
+
+#ifdef DPMSExtension
+#include <X11/extensions/dpmsconst.h>
+#include "dpmsproc.h"
+#endif
+#include <hotplug.h>
+
+
+#ifdef XF86PM
+void (*xf86OSPMClose)(void) = NULL;
+#endif
+static Bool xorgHWOpenConsole = FALSE;
+
+/* Common pixmap formats */
+
+static PixmapFormatRec formats[MAXFORMATS] = {
+ { 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 },
+ { 32, 32, BITMAP_SCANLINE_PAD },
+};
+static int numFormats = 7;
+static Bool formatsDone = FALSE;
+
+#ifndef OSNAME
+#define OSNAME " unknown"
+#endif
+#ifndef OSVENDOR
+#define OSVENDOR ""
+#endif
+#ifndef PRE_RELEASE
+#define PRE_RELEASE XORG_VERSION_SNAP
+#endif
+
+static void
+xf86PrintBanner(void)
+{
+#if PRE_RELEASE
+ xf86ErrorFVerb(0, "\n"
+ "This is a pre-release version of the X server from " XVENDORNAME ".\n"
+ "It is not supported in any way.\n"
+ "Bugs may be filed in the bugzilla at http://bugs.freedesktop.org/.\n"
+ "Select the \"xorg\" product for bugs you find in this release.\n"
+ "Before reporting bugs in pre-release versions please check the\n"
+ "latest version in the X.Org Foundation git repository.\n"
+ "See http://wiki.x.org/wiki/GitPage for git access instructions.\n");
+#endif
+ xf86ErrorFVerb(0, "\nX.Org X Server %d.%d.%d",
+ XORG_VERSION_MAJOR,
+ XORG_VERSION_MINOR,
+ XORG_VERSION_PATCH);
+#if XORG_VERSION_SNAP > 0
+ xf86ErrorFVerb(0, ".%d", XORG_VERSION_SNAP);
+#endif
+
+#if XORG_VERSION_SNAP >= 900
+ /* When the minor number is 99, that signifies that the we are making
+ * a release candidate for a major version. (X.0.0)
+ * When the patch number is 99, that signifies that the we are making
+ * a release candidate for a minor version. (X.Y.0)
+ * When the patch number is < 99, then we are making a release
+ * candidate for the next point release. (X.Y.Z)
+ */
+#if XORG_VERSION_MINOR >= 99
+ xf86ErrorFVerb(0, " (%d.0.0 RC %d)", XORG_VERSION_MAJOR+1,
+ XORG_VERSION_SNAP - 900);
+#elif XORG_VERSION_PATCH == 99
+ xf86ErrorFVerb(0, " (%d.%d.0 RC %d)", XORG_VERSION_MAJOR,
+ XORG_VERSION_MINOR + 1, XORG_VERSION_SNAP - 900);
+#else
+ xf86ErrorFVerb(0, " (%d.%d.%d RC %d)", XORG_VERSION_MAJOR,
+ XORG_VERSION_MINOR, XORG_VERSION_PATCH + 1,
+ XORG_VERSION_SNAP - 900);
+#endif
+#endif
+
+#ifdef XORG_CUSTOM_VERSION
+ xf86ErrorFVerb(0, " (%s)", XORG_CUSTOM_VERSION);
+#endif
+#ifndef XORG_DATE
+# define XORG_DATE "Unknown"
+#endif
+ xf86ErrorFVerb(0, "\nRelease Date: %s\n", XORG_DATE);
+ xf86ErrorFVerb(0, "X Protocol Version %d, Revision %d\n",
+ X_PROTOCOL, X_PROTOCOL_REVISION);
+ xf86ErrorFVerb(0, "Build Operating System: %s %s\n", OSNAME, OSVENDOR);
+#ifdef HAS_UTSNAME
+ {
+ struct utsname name;
+
+ /* Linux & BSD state that 0 is success, SysV (including Solaris, HP-UX,
+ and Irix) and Single Unix Spec 3 just say that non-negative is success.
+ All agree that failure is represented by a negative number.
+ */
+ if (uname(&name) >= 0) {
+ xf86ErrorFVerb(0, "Current Operating System: %s %s %s %s %s\n",
+ name.sysname, name.nodename, name.release, name.version, name.machine);
+#ifdef linux
+ do {
+ char buf[80];
+ int fd = open("/proc/cmdline", O_RDONLY);
+ if (fd != -1) {
+ xf86ErrorFVerb(0, "Kernel command line: ");
+ memset(buf, 0, 80);
+ while (read(fd, buf, 80) > 0) {
+ xf86ErrorFVerb(0, "%.80s", buf);
+ memset(buf, 0, 80);
+ }
+ close(fd);
+ }
+ } while (0);
+#endif
+ }
+ }
+#endif
+#if defined(BUILD_DATE) && (BUILD_DATE > 19000000)
+ {
+ struct tm t;
+ char buf[100];
+
+ memset(&t, 0, sizeof(t));
+ memset(buf, 0, sizeof(buf));
+ t.tm_mday = BUILD_DATE % 100;
+ t.tm_mon = (BUILD_DATE / 100) % 100 - 1;
+ t.tm_year = BUILD_DATE / 10000 - 1900;
+#if defined(BUILD_TIME)
+ t.tm_sec = BUILD_TIME % 100;
+ t.tm_min = (BUILD_TIME / 100) % 100;
+ t.tm_hour = (BUILD_TIME / 10000) % 100;
+ if (strftime(buf, sizeof(buf), "%d %B %Y %I:%M:%S%p", &t))
+ xf86ErrorFVerb(0, "Build Date: %s\n", buf);
+#else
+ if (strftime(buf, sizeof(buf), "%d %B %Y", &t))
+ xf86ErrorFVerb(0, "Build Date: %s\n", buf);
+#endif
+ }
+#endif
+#if defined(BUILDERSTRING)
+ xf86ErrorFVerb(0, "%s \n", BUILDERSTRING);
+#endif
+ xf86ErrorFVerb(0, "Current version of pixman: %s\n",
+ pixman_version_string());
+ xf86ErrorFVerb(0, "\tBefore reporting problems, check "
+ ""__VENDORDWEBSUPPORT__"\n"
+ "\tto make sure that you have the latest version.\n");
+}
+
+static void
+xf86PrintMarkers(void)
+{
+ LogPrintMarkers();
+}
+
+static Bool
+xf86CreateRootWindow(WindowPtr pWin)
+{
+ int ret = TRUE;
+ int err = Success;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ RootWinPropPtr pProp;
+ CreateWindowProcPtr CreateWindow = (CreateWindowProcPtr)
+ dixLookupPrivate(&pScreen->devPrivates, xf86CreateRootWindowKey);
+
+ DebugF("xf86CreateRootWindow(%p)\n", pWin);
+
+ if ( pScreen->CreateWindow != xf86CreateRootWindow ) {
+ /* Can't find hook we are hung on */
+ xf86DrvMsg(pScreen->myNum, X_WARNING /* X_ERROR */,
+ "xf86CreateRootWindow %p called when not in pScreen->CreateWindow %p n",
+ (void *)xf86CreateRootWindow,
+ (void *)pScreen->CreateWindow );
+ }
+
+ /* Unhook this function ... */
+ pScreen->CreateWindow = CreateWindow;
+ dixSetPrivate(&pScreen->devPrivates, xf86CreateRootWindowKey, NULL);
+
+ /* ... and call the previous CreateWindow fuction, if any */
+ if (NULL!=pScreen->CreateWindow) {
+ ret = (*pScreen->CreateWindow)(pWin);
+ }
+
+ /* Now do our stuff */
+ if (xf86RegisteredPropertiesTable != NULL) {
+ if (pWin->parent == NULL && xf86RegisteredPropertiesTable != NULL) {
+ for (pProp = xf86RegisteredPropertiesTable[pScreen->myNum];
+ pProp != NULL && err==Success;
+ pProp = pProp->next )
+ {
+ Atom prop;
+
+ prop = MakeAtom(pProp->name, strlen(pProp->name), TRUE);
+ err = dixChangeWindowProperty(serverClient, pWin,
+ prop, pProp->type,
+ pProp->format, PropModeReplace,
+ pProp->size, pProp->data,
+ FALSE);
+ }
+
+ /* Look at err */
+ ret &= (err==Success);
+
+ } else {
+ xf86Msg(X_ERROR, "xf86CreateRootWindow unexpectedly called with "
+ "non-root window %p (parent %p)\n",
+ (void *)pWin, (void *)pWin->parent);
+ ret = FALSE;
+ }
+ }
+
+ DebugF("xf86CreateRootWindow() returns %d\n", ret);
+ return ret;
+}
+
+
+static void
+InstallSignalHandlers(void)
+{
+ /*
+ * Install signal handler for unexpected signals
+ */
+ xf86Info.caughtSignal=FALSE;
+ if (!xf86Info.notrapSignals) {
+ OsRegisterSigWrapper(xf86SigWrapper);
+ } else {
+ signal(SIGSEGV, SIG_DFL);
+ signal(SIGILL, SIG_DFL);
+#ifdef SIGEMT
+ signal(SIGEMT, SIG_DFL);
+#endif
+ signal(SIGFPE, SIG_DFL);
+ signal(SIGBUS, SIG_DFL);
+ signal(SIGSYS, SIG_DFL);
+ signal(SIGXCPU, SIG_DFL);
+ signal(SIGXFSZ, SIG_DFL);
+ }
+}
+
+/*
+ * InitOutput --
+ * Initialize screenInfo for all actually accessible framebuffers.
+ * That includes vt-manager setup, querying all possible devices and
+ * collecting the pixmap formats.
+ */
+void
+InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
+{
+ int i, j, k, scr_index, was_blocked = 0;
+ char **modulelist;
+ pointer *optionlist;
+ Pix24Flags screenpix24, pix24;
+ MessageType pix24From = X_DEFAULT;
+ Bool pix24Fail = FALSE;
+ Bool autoconfig = FALSE;
+ GDevPtr configured_device;
+
+ xf86Initialising = TRUE;
+
+ if (serverGeneration == 1) {
+ if ((xf86ServerName = strrchr(argv[0], '/')) != 0)
+ xf86ServerName++;
+ else
+ xf86ServerName = argv[0];
+
+ xf86PrintBanner();
+ xf86PrintMarkers();
+ if (xf86LogFile) {
+ time_t t;
+ const char *ct;
+ t = time(NULL);
+ ct = ctime(&t);
+ xf86MsgVerb(xf86LogFileFrom, 0, "Log file: \"%s\", Time: %s",
+ xf86LogFile, ct);
+ }
+
+ /* Read and parse the config file */
+ if (!xf86DoConfigure && !xf86DoShowOptions) {
+ switch (xf86HandleConfigFile(FALSE)) {
+ case CONFIG_OK:
+ break;
+ case CONFIG_PARSE_ERROR:
+ xf86Msg(X_ERROR, "Error parsing the config file\n");
+ return;
+ case CONFIG_NOFILE:
+ autoconfig = TRUE;
+ break;
+ }
+ }
+
+ InstallSignalHandlers();
+
+ /* Initialise the loader */
+ LoaderInit();
+
+ /* Tell the loader the default module search path */
+ LoaderSetPath(xf86ModulePath);
+
+ if (xf86Info.ignoreABI) {
+ LoaderSetOptions(LDR_OPT_ABI_MISMATCH_NONFATAL);
+ }
+
+ if (xf86DoShowOptions)
+ DoShowOptions();
+
+ /* Do a general bus probe. This will be a PCI probe for x86 platforms */
+ xf86BusProbe();
+
+ if (xf86DoConfigure)
+ DoConfigure();
+
+ if (autoconfig) {
+ if (!xf86AutoConfig()) {
+ xf86Msg(X_ERROR, "Auto configuration failed\n");
+ return;
+ }
+ }
+
+#ifdef XF86PM
+ xf86OSPMClose = xf86OSPMOpen();
+#endif
+
+ /* Load all modules specified explicitly in the config file */
+ if ((modulelist = xf86ModulelistFromConfig(&optionlist))) {
+ xf86LoadModules(modulelist, optionlist);
+ free(modulelist);
+ free(optionlist);
+ }
+
+ /* Load all driver modules specified in the config file */
+ /* If there aren't any specified in the config file, autoconfig them */
+ /* FIXME: Does not handle multiple active screen sections, but I'm not
+ * sure if we really want to handle that case*/
+ configured_device = xf86ConfigLayout.screens->screen->device;
+ if ((!configured_device) || (!configured_device->driver)) {
+ if (!autoConfigDevice(configured_device)) {
+ xf86Msg(X_ERROR, "Automatic driver configuration failed\n");
+ return ;
+ }
+ }
+ if ((modulelist = xf86DriverlistFromConfig())) {
+ xf86LoadModules(modulelist, NULL);
+ free(modulelist);
+ }
+
+ /* Load all input driver modules specified in the config file. */
+ if ((modulelist = xf86InputDriverlistFromConfig())) {
+ xf86LoadModules(modulelist, NULL);
+ free(modulelist);
+ }
+
+ /*
+ * It is expected that xf86AddDriver()/xf86AddInputDriver will be
+ * called for each driver as it is loaded. Those functions save the
+ * module pointers for drivers.
+ * XXX Nothing keeps track of them for other modules.
+ */
+ /* XXX What do we do if not all of these could be loaded? */
+
+ /*
+ * At this point, xf86DriverList[] is all filled in with entries for
+ * each of the drivers to try and xf86NumDrivers has the number of
+ * drivers. If there are none, return now.
+ */
+
+ if (xf86NumDrivers == 0) {
+ xf86Msg(X_ERROR, "No drivers available.\n");
+ return;
+ }
+
+ /*
+ * Call each of the Identify functions and call the driverFunc to check
+ * if HW access is required. The Identify functions print out some
+ * identifying information, and anything else that might be
+ * needed at this early stage.
+ */
+
+ for (i = 0; i < xf86NumDrivers; i++) {
+ if (xf86DriverList[i]->Identify != NULL)
+ xf86DriverList[i]->Identify(0);
+
+ if (!xorgHWAccess || !xorgHWOpenConsole) {
+ xorgHWFlags flags;
+ if(!xf86DriverList[i]->driverFunc
+ || !xf86DriverList[i]->driverFunc(NULL,
+ GET_REQUIRED_HW_INTERFACES,
+ &flags))
+ flags = HW_IO;
+
+ if(NEED_IO_ENABLED(flags))
+ xorgHWAccess = TRUE;
+ if(!(flags & HW_SKIP_CONSOLE))
+ xorgHWOpenConsole = TRUE;
+ }
+ }
+
+ if (xorgHWOpenConsole)
+ xf86OpenConsole();
+ else
+ xf86Info.dontVTSwitch = TRUE;
+
+ if (xf86BusConfig() == FALSE)
+ return;
+
+ xf86PostProbe();
+
+ /*
+ * Sort the drivers to match the requested ording. Using a slow
+ * bubble sort.
+ */
+ for (j = 0; j < xf86NumScreens - 1; j++) {
+ for (i = 0; i < xf86NumScreens - j - 1; i++) {
+ if (xf86Screens[i + 1]->confScreen->screennum <
+ xf86Screens[i]->confScreen->screennum) {
+ ScrnInfoPtr tmpScrn = xf86Screens[i + 1];
+ xf86Screens[i + 1] = xf86Screens[i];
+ xf86Screens[i] = tmpScrn;
+ }
+ }
+ }
+ /* Fix up the indexes */
+ for (i = 0; i < xf86NumScreens; i++) {
+ xf86Screens[i]->scrnIndex = i;
+ }
+
+ /*
+ * Call the driver's PreInit()'s to complete initialisation for the first
+ * generation.
+ */
+
+ for (i = 0; i < xf86NumScreens; i++) {
+ xf86VGAarbiterScrnInit(xf86Screens[i]);
+ xf86VGAarbiterLock(xf86Screens[i]);
+ if (xf86Screens[i]->PreInit &&
+ xf86Screens[i]->PreInit(xf86Screens[i], 0))
+ xf86Screens[i]->configured = TRUE;
+ xf86VGAarbiterUnlock(xf86Screens[i]);
+ }
+ for (i = 0; i < xf86NumScreens; i++)
+ if (!xf86Screens[i]->configured)
+ xf86DeleteScreen(i--, 0);
+
+ /*
+ * If no screens left, return now.
+ */
+
+ if (xf86NumScreens == 0) {
+ xf86Msg(X_ERROR,
+ "Screen(s) found, but none have a usable configuration.\n");
+ return;
+ }
+
+ for (i = 0; i < xf86NumScreens; i++) {
+ if (xf86Screens[i]->name == NULL) {
+ XNFasprintf(&xf86Screens[i]->name, "screen%d", i);
+ xf86MsgVerb(X_WARNING, 0,
+ "Screen driver %d has no name set, using `%s'.\n",
+ i, xf86Screens[i]->name);
+ }
+ }
+
+ /* Remove (unload) drivers that are not required */
+ for (i = 0; i < xf86NumDrivers; i++)
+ if (xf86DriverList[i] && xf86DriverList[i]->refCount <= 0)
+ xf86DeleteDriver(i);
+
+ /*
+ * At this stage we know how many screens there are.
+ */
+
+ for (i = 0; i < xf86NumScreens; i++)
+ xf86InitViewport(xf86Screens[i]);
+
+ /*
+ * Collect all pixmap formats and check for conflicts at the display
+ * level. Should we die here? Or just delete the offending screens?
+ */
+ screenpix24 = Pix24DontCare;
+ for (i = 0; i < xf86NumScreens; i++) {
+ if (xf86Screens[i]->imageByteOrder !=
+ xf86Screens[0]->imageByteOrder)
+ FatalError("Inconsistent display bitmapBitOrder. Exiting\n");
+ if (xf86Screens[i]->bitmapScanlinePad !=
+ xf86Screens[0]->bitmapScanlinePad)
+ FatalError("Inconsistent display bitmapScanlinePad. Exiting\n");
+ if (xf86Screens[i]->bitmapScanlineUnit !=
+ xf86Screens[0]->bitmapScanlineUnit)
+ FatalError("Inconsistent display bitmapScanlineUnit. Exiting\n");
+ if (xf86Screens[i]->bitmapBitOrder !=
+ xf86Screens[0]->bitmapBitOrder)
+ FatalError("Inconsistent display bitmapBitOrder. Exiting\n");
+
+ /* Determine the depth 24 pixmap format the screens would like */
+ if (xf86Screens[i]->pixmap24 != Pix24DontCare) {
+ if (screenpix24 == Pix24DontCare)
+ screenpix24 = xf86Screens[i]->pixmap24;
+ else if (screenpix24 != xf86Screens[i]->pixmap24)
+ FatalError("Inconsistent depth 24 pixmap format. Exiting\n");
+ }
+ }
+ /* check if screenpix24 is consistent with the config/cmdline */
+ if (xf86Info.pixmap24 != Pix24DontCare) {
+ pix24 = xf86Info.pixmap24;
+ pix24From = xf86Info.pix24From;
+ if (screenpix24 != Pix24DontCare && screenpix24 != xf86Info.pixmap24)
+ pix24Fail = TRUE;
+ } else if (screenpix24 != Pix24DontCare) {
+ pix24 = screenpix24;
+ pix24From = X_PROBED;
+ } else
+ pix24 = Pix24Use32;
+
+ if (pix24Fail)
+ FatalError("Screen(s) can't use the required depth 24 pixmap format"
+ " (%d). Exiting\n", PIX24TOBPP(pix24));
+
+ /* Initialise the depth 24 format */
+ for (j = 0; j < numFormats && formats[j].depth != 24; j++)
+ ;
+ formats[j].bitsPerPixel = PIX24TOBPP(pix24);
+
+ /* Collect additional formats */
+ for (i = 0; i < xf86NumScreens; i++) {
+ for (j = 0; j < xf86Screens[i]->numFormats; j++) {
+ for (k = 0; ; k++) {
+ if (k >= numFormats) {
+ if (k >= MAXFORMATS)
+ FatalError("Too many pixmap formats! Exiting\n");
+ formats[k] = xf86Screens[i]->formats[j];
+ numFormats++;
+ break;
+ }
+ if (formats[k].depth == xf86Screens[i]->formats[j].depth) {
+ if ((formats[k].bitsPerPixel ==
+ xf86Screens[i]->formats[j].bitsPerPixel) &&
+ (formats[k].scanlinePad ==
+ xf86Screens[i]->formats[j].scanlinePad))
+ break;
+ FatalError("Inconsistent pixmap format for depth %d."
+ " Exiting\n", formats[k].depth);
+ }
+ }
+ }
+ }
+ formatsDone = TRUE;
+
+ if (xf86Info.vtno >= 0 ) {
+#define VT_ATOM_NAME "XFree86_VT"
+ Atom VTAtom=-1;
+ CARD32 *VT = NULL;
+ int ret;
+
+ /* This memory needs to stay available until the screen has been
+ initialized, and we can create the property for real.
+ */
+ if ( (VT = malloc(sizeof(CARD32)))==NULL ) {
+ FatalError("Unable to make VT property - out of memory. Exiting...\n");
+ }
+ *VT = xf86Info.vtno;
+
+ VTAtom = MakeAtom(VT_ATOM_NAME, sizeof(VT_ATOM_NAME) - 1, TRUE);
+
+ for (i = 0, ret = Success; i < xf86NumScreens && ret == Success; i++) {
+ ret = xf86RegisterRootWindowProperty(xf86Screens[i]->scrnIndex,
+ VTAtom, XA_INTEGER, 32,
+ 1, VT );
+ if (ret != Success)
+ xf86DrvMsg(xf86Screens[i]->scrnIndex, X_WARNING,
+ "Failed to register VT property\n");
+ }
+ }
+
+ /* If a screen uses depth 24, show what the pixmap format is */
+ for (i = 0; i < xf86NumScreens; i++) {
+ if (xf86Screens[i]->depth == 24) {
+ xf86Msg(pix24From, "Depth 24 pixmap format is %d bpp\n",
+ PIX24TOBPP(pix24));
+ break;
+ }
+ }
+ } else {
+ /*
+ * serverGeneration != 1; some OSs have to do things here, too.
+ */
+ if (xorgHWOpenConsole)
+ xf86OpenConsole();
+
+#ifdef XF86PM
+ /*
+ should we reopen it here? We need to deal with an already opened
+ device. We could leave this to the OS layer. For now we simply
+ close it here
+ */
+ if (xf86OSPMClose)
+ xf86OSPMClose();
+ if ((xf86OSPMClose = xf86OSPMOpen()) != NULL)
+ xf86MsgVerb(X_INFO, 3, "APM registered successfully\n");
+#endif
+
+ /* Make sure full I/O access is enabled */
+ if (xorgHWAccess)
+ xf86EnableIO();
+ }
+
+ /*
+ * Use the previously collected parts to setup pScreenInfo
+ */
+
+ pScreenInfo->imageByteOrder = xf86Screens[0]->imageByteOrder;
+ pScreenInfo->bitmapScanlinePad = xf86Screens[0]->bitmapScanlinePad;
+ pScreenInfo->bitmapScanlineUnit = xf86Screens[0]->bitmapScanlineUnit;
+ pScreenInfo->bitmapBitOrder = xf86Screens[0]->bitmapBitOrder;
+ pScreenInfo->numPixmapFormats = numFormats;
+ for (i = 0; i < numFormats; i++)
+ pScreenInfo->formats[i] = formats[i];
+
+ /* Make sure the server's VT is active */
+
+ if (serverGeneration != 1) {
+ xf86Resetting = TRUE;
+ /* All screens are in the same state, so just check the first */
+ if (!xf86Screens[0]->vtSema) {
+#ifdef HAS_USL_VTS
+ ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ);
+#endif
+ xf86AccessEnter();
+ was_blocked = xf86BlockSIGIO();
+ }
+ }
+
+ for (i = 0; i < xf86NumScreens; i++)
+ if (!xf86ColormapAllocatePrivates(xf86Screens[i]))
+ FatalError("Cannot register DDX private keys");
+
+ if (!dixRegisterPrivateKey(&xf86ScreenKeyRec, PRIVATE_SCREEN, 0) ||
+ !dixRegisterPrivateKey(&xf86CreateRootWindowKeyRec, PRIVATE_SCREEN, 0))
+ FatalError("Cannot register DDX private keys");
+
+ for (i = 0; i < xf86NumScreens; i++) {
+ xf86VGAarbiterLock(xf86Screens[i]);
+ /*
+ * Almost everything uses these defaults, and many of those that
+ * don't, will wrap them.
+ */
+ xf86Screens[i]->EnableDisableFBAccess = xf86EnableDisableFBAccess;
+#ifdef XFreeXDGA
+ xf86Screens[i]->SetDGAMode = xf86SetDGAMode;
+#endif
+ xf86Screens[i]->DPMSSet = NULL;
+ xf86Screens[i]->LoadPalette = NULL;
+ xf86Screens[i]->SetOverscan = NULL;
+ xf86Screens[i]->DriverFunc = NULL;
+ xf86Screens[i]->pScreen = NULL;
+ scr_index = AddScreen(xf86Screens[i]->ScreenInit, argc, argv);
+ xf86VGAarbiterUnlock(xf86Screens[i]);
+ if (scr_index == i) {
+ /*
+ * Hook in our ScrnInfoRec, and initialise some other pScreen
+ * fields.
+ */
+ dixSetPrivate(&screenInfo.screens[scr_index]->devPrivates,
+ xf86ScreenKey, xf86Screens[i]);
+ xf86Screens[i]->pScreen = screenInfo.screens[scr_index];
+ /* The driver should set this, but make sure it is set anyway */
+ xf86Screens[i]->vtSema = TRUE;
+ } else {
+ /* This shouldn't normally happen */
+ FatalError("AddScreen/ScreenInit failed for driver %d\n", i);
+ }
+
+ DebugF("InitOutput - xf86Screens[%d]->pScreen = %p\n",
+ i, xf86Screens[i]->pScreen );
+ DebugF("xf86Screens[%d]->pScreen->CreateWindow = %p\n",
+ i, xf86Screens[i]->pScreen->CreateWindow );
+
+ dixSetPrivate(&screenInfo.screens[scr_index]->devPrivates,
+ xf86CreateRootWindowKey,
+ xf86Screens[i]->pScreen->CreateWindow);
+ xf86Screens[i]->pScreen->CreateWindow = xf86CreateRootWindow;
+
+ if (PictureGetSubpixelOrder (xf86Screens[i]->pScreen) == SubPixelUnknown)
+ {
+ xf86MonPtr DDC = (xf86MonPtr)(xf86Screens[i]->monitor->DDC);
+ PictureSetSubpixelOrder (xf86Screens[i]->pScreen,
+ DDC ?
+ (DDC->features.input_type ?
+ SubPixelHorizontalRGB : SubPixelNone) :
+ SubPixelUnknown);
+ }
+#ifdef RANDR
+ if (!xf86Info.disableRandR)
+ xf86RandRInit (screenInfo.screens[scr_index]);
+ xf86Msg(xf86Info.randRFrom, "RandR %s\n",
+ xf86Info.disableRandR ? "disabled" : "enabled");
+#endif
+ }
+
+ xf86VGAarbiterWrapFunctions();
+ xf86UnblockSIGIO(was_blocked);
+
+ xf86InitOrigins();
+
+ xf86Resetting = FALSE;
+ xf86Initialising = FALSE;
+
+ RegisterBlockAndWakeupHandlers((BlockHandlerProcPtr)NoopDDA, xf86Wakeup,
+ NULL);
+}
+
+static InputInfoPtr
+duplicateDevice(InputInfoPtr pInfo)
+{
+ InputInfoPtr dup = calloc(1, sizeof(InputInfoRec));
+ if (dup) {
+ dup->name = strdup(pInfo->name);
+ dup->driver = strdup(pInfo->driver);
+ dup->options = xf86OptionListDuplicate(pInfo->options);
+ /* type_name is a const string */
+ dup->type_name = pInfo->type_name;
+ dup->fd = -1;
+ }
+ return dup;
+}
+
+/*
+ * InitInput --
+ * Initialize all supported input devices.
+ */
+
+void
+InitInput(int argc, char **argv)
+{
+ InputInfoPtr* pInfo;
+ DeviceIntPtr dev;
+
+ xf86Info.vtRequestsPending = FALSE;
+
+ mieqInit();
+
+ /* Initialize all configured input devices */
+ for (pInfo = xf86ConfigLayout.inputs; pInfo && *pInfo; pInfo++) {
+ InputInfoPtr dup;
+ /* Replace obsolete keyboard driver with kbd */
+ if (!xf86NameCmp((*pInfo)->driver, "keyboard")) {
+ strcpy((*pInfo)->driver, "kbd");
+ }
+
+ /* Data passed into xf86NewInputDevice will be freed on shutdown.
+ * Duplicate from xf86ConfigLayout.inputs, otherwise we don't have any
+ * xorg.conf input devices in the second generation
+ */
+ dup = duplicateDevice(*pInfo);
+
+ /* If one fails, the others will too */
+ if (xf86NewInputDevice(dup, &dev, TRUE) == BadAlloc)
+ break;
+ }
+
+ config_init();
+}
+
+void
+CloseInput (void)
+{
+ config_fini();
+ mieqFini();
+}
+
+/*
+ * OsVendorInit --
+ * OS/Vendor-specific initialisations. Called from OsInit(), which
+ * is called by dix before establishing the well known sockets.
+ */
+
+void
+OsVendorInit(void)
+{
+ static Bool beenHere = FALSE;
+
+ signal(SIGCHLD, SIG_DFL); /* Need to wait for child processes */
+
+ if (!beenHere) {
+ umask(022);
+ xf86LogInit();
+ }
+
+ /* Set stderr to non-blocking. */
+#ifndef O_NONBLOCK
+#if defined(FNDELAY)
+#define O_NONBLOCK FNDELAY
+#elif defined(O_NDELAY)
+#define O_NONBLOCK O_NDELAY
+#endif
+
+#ifdef O_NONBLOCK
+ if (!beenHere) {
+ if (geteuid() == 0 && getuid() != geteuid())
+ {
+ int status;
+
+ status = fcntl(fileno(stderr), F_GETFL, 0);
+ if (status != -1) {
+ fcntl(fileno(stderr), F_SETFL, status | O_NONBLOCK);
+ }
+ }
+ }
+#endif
+#endif
+
+ beenHere = TRUE;
+}
+
+/*
+ * ddxGiveUp --
+ * Device dependent cleanup. Called by by dix before normal server death.
+ * For SYSV386 we must switch the terminal back to normal mode. No error-
+ * checking here, since there should be restored as much as possible.
+ */
+
+void
+ddxGiveUp(enum ExitCode error)
+{
+ int i;
+
+ xf86VGAarbiterFini();
+
+#ifdef XF86PM
+ if (xf86OSPMClose)
+ xf86OSPMClose();
+ xf86OSPMClose = NULL;
+#endif
+
+ for (i = 0; i < xf86NumScreens; i++) {
+ /*
+ * zero all access functions to
+ * trap calls when switched away.
+ */
+ xf86Screens[i]->vtSema = FALSE;
+ }
+
+#ifdef XFreeXDGA
+ DGAShutdown();
+#endif
+
+ if (xorgHWOpenConsole)
+ xf86CloseConsole();
+
+ xf86CloseLog(error);
+
+ /* If an unexpected signal was caught, dump a core for debugging */
+ if (xf86Info.caughtSignal)
+ OsAbort();
+}
+
+
+
+/*
+ * AbortDDX --
+ * DDX - specific abort routine. Called by AbortServer(). The attempt is
+ * made to restore all original setting of the displays. Also all devices
+ * are closed.
+ */
+
+void
+AbortDDX(enum ExitCode error)
+{
+ int i;
+
+ xf86BlockSIGIO();
+
+ /*
+ * try to restore the original video state
+ */
+#ifdef DPMSExtension /* Turn screens back on */
+ if (DPMSPowerLevel != DPMSModeOn)
+ DPMSSet(serverClient, DPMSModeOn);
+#endif
+ if (xf86Screens) {
+ for (i = 0; i < xf86NumScreens; i++)
+ if (xf86Screens[i]->vtSema) {
+ /*
+ * if we are aborting before ScreenInit() has finished
+ * we might not have been wrapped yet. Therefore enable
+ * screen explicitely.
+ */
+ xf86VGAarbiterLock(xf86Screens[i]);
+ (xf86Screens[i]->LeaveVT)(i, 0);
+ xf86VGAarbiterUnlock(xf86Screens[i]);
+ }
+ }
+
+ xf86AccessLeave();
+
+ /*
+ * This is needed for an abnormal server exit, since the normal exit stuff
+ * MUST also be performed (i.e. the vt must be left in a defined state)
+ */
+ ddxGiveUp(error);
+}
+
+void
+OsVendorFatalError(void)
+{
+#ifdef VENDORSUPPORT
+ ErrorF("\nPlease refer to your Operating System Vendor support pages\n"
+ "at %s for support on this crash.\n",VENDORSUPPORT);
+#else
+ ErrorF("\nPlease consult the "XVENDORNAME" support \n"
+ "\t at "__VENDORDWEBSUPPORT__"\n for help. \n");
+#endif
+ if (xf86LogFile && xf86LogFileWasOpened)
+ ErrorF("Please also check the log file at \"%s\" for additional "
+ "information.\n", xf86LogFile);
+ ErrorF("\n");
+}
+
+int
+xf86SetVerbosity(int verb)
+{
+ int save = xf86Verbose;
+
+ xf86Verbose = verb;
+ LogSetParameter(XLOG_VERBOSITY, verb);
+ return save;
+}
+
+int
+xf86SetLogVerbosity(int verb)
+{
+ int save = xf86LogVerbose;
+
+ xf86LogVerbose = verb;
+ LogSetParameter(XLOG_FILE_VERBOSITY, verb);
+ return save;
+}
+
+static void
+xf86PrintDefaultModulePath(void)
+{
+ ErrorF("%s\n", DEFAULT_MODULE_PATH);
+}
+
+static void
+xf86PrintDefaultLibraryPath(void)
+{
+ ErrorF("%s\n", DEFAULT_LIBRARY_PATH);
+}
+
+/*
+ * ddxProcessArgument --
+ * Process device-dependent command line args. Returns 0 if argument is
+ * not device dependent, otherwise Count of number of elements of argv
+ * that are part of a device dependent commandline option.
+ *
+ */
+
+/* ARGSUSED */
+int
+ddxProcessArgument(int argc, char **argv, int i)
+{
+#define CHECK_FOR_REQUIRED_ARGUMENT() \
+ if (((i + 1) >= argc) || (!argv[i + 1])) { \
+ ErrorF("Required argument to %s not specified\n", argv[i]); \
+ UseMsg(); \
+ FatalError("Required argument to %s not specified\n", argv[i]); \
+ }
+
+ /* First the options that are only allowed for root */
+ if (!strcmp(argv[i], "-modulepath") || !strcmp(argv[i], "-logfile")) {
+ if ( (geteuid() == 0) && (getuid() != 0) ) {
+ FatalError("The '%s' option can only be used by root.\n", argv[i]);
+ }
+ else if (!strcmp(argv[i], "-modulepath"))
+ {
+ char *mp;
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ mp = strdup(argv[i + 1]);
+ if (!mp)
+ FatalError("Can't allocate memory for ModulePath\n");
+ xf86ModulePath = mp;
+ xf86ModPathFrom = X_CMDLINE;
+ return 2;
+ }
+ else if (!strcmp(argv[i], "-logfile"))
+ {
+ char *lf;
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ lf = strdup(argv[i + 1]);
+ if (!lf)
+ FatalError("Can't allocate memory for LogFile\n");
+ xf86LogFile = lf;
+ xf86LogFileFrom = X_CMDLINE;
+ return 2;
+ }
+ }
+ if (!strcmp(argv[i], "-config") || !strcmp(argv[i], "-xf86config"))
+ {
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ if (getuid() != 0 && !xf86PathIsSafe(argv[i + 1])) {
+ FatalError("\nInvalid argument for %s\n"
+ "\tFor non-root users, the file specified with %s must be\n"
+ "\ta relative path and must not contain any \"..\" elements.\n"
+ "\tUsing default "__XCONFIGFILE__" search path.\n\n",
+ argv[i], argv[i]);
+ }
+ xf86ConfigFile = argv[i + 1];
+ return 2;
+ }
+ if (!strcmp(argv[i], "-configdir"))
+ {
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ if (getuid() != 0 && !xf86PathIsSafe(argv[i + 1])) {
+ FatalError("\nInvalid argument for %s\n"
+ "\tFor non-root users, the file specified with %s must be\n"
+ "\ta relative path and must not contain any \"..\" elements.\n"
+ "\tUsing default "__XCONFIGDIR__" search path.\n\n",
+ argv[i], argv[i]);
+ }
+ xf86ConfigDir = argv[i + 1];
+ return 2;
+ }
+ if (!strcmp(argv[i],"-flipPixels"))
+ {
+ xf86FlipPixels = TRUE;
+ return 1;
+ }
+#ifdef XF86VIDMODE
+ if (!strcmp(argv[i],"-disableVidMode"))
+ {
+ xf86VidModeDisabled = TRUE;
+ return 1;
+ }
+ if (!strcmp(argv[i],"-allowNonLocalXvidtune"))
+ {
+ xf86VidModeAllowNonLocal = TRUE;
+ return 1;
+ }
+#endif
+ if (!strcmp(argv[i],"-allowMouseOpenFail"))
+ {
+ xf86AllowMouseOpenFail = TRUE;
+ return 1;
+ }
+ if (!strcmp(argv[i],"-ignoreABI"))
+ {
+ LoaderSetOptions(LDR_OPT_ABI_MISMATCH_NONFATAL);
+ return 1;
+ }
+ if (!strcmp(argv[i],"-verbose"))
+ {
+ if (++i < argc && argv[i])
+ {
+ char *end;
+ long val;
+ val = strtol(argv[i], &end, 0);
+ if (*end == '\0')
+ {
+ xf86SetVerbosity(val);
+ return 2;
+ }
+ }
+ xf86SetVerbosity(++xf86Verbose);
+ return 1;
+ }
+ if (!strcmp(argv[i],"-logverbose"))
+ {
+ if (++i < argc && argv[i])
+ {
+ char *end;
+ long val;
+ val = strtol(argv[i], &end, 0);
+ if (*end == '\0')
+ {
+ xf86SetLogVerbosity(val);
+ return 2;
+ }
+ }
+ xf86SetLogVerbosity(++xf86LogVerbose);
+ return 1;
+ }
+ if (!strcmp(argv[i],"-quiet"))
+ {
+ xf86SetVerbosity(-1);
+ return 1;
+ }
+ if (!strcmp(argv[i],"-showconfig") || !strcmp(argv[i],"-version"))
+ {
+ xf86PrintBanner();
+ exit(0);
+ }
+ if (!strcmp(argv[i],"-showDefaultModulePath"))
+ {
+ xf86PrintDefaultModulePath();
+ exit(0);
+ }
+ if (!strcmp(argv[i],"-showDefaultLibPath"))
+ {
+ xf86PrintDefaultLibraryPath();
+ exit(0);
+ }
+ /* Notice the -fp flag, but allow it to pass to the dix layer */
+ if (!strcmp(argv[i], "-fp"))
+ {
+ xf86fpFlag = TRUE;
+ return 0;
+ }
+ /* Notice the -bs flag, but allow it to pass to the dix layer */
+ if (!strcmp(argv[i], "-bs"))
+ {
+ xf86bsDisableFlag = TRUE;
+ return 0;
+ }
+ /* Notice the +bs flag, but allow it to pass to the dix layer */
+ if (!strcmp(argv[i], "+bs"))
+ {
+ xf86bsEnableFlag = TRUE;
+ return 0;
+ }
+ /* Notice the -s flag, but allow it to pass to the dix layer */
+ if (!strcmp(argv[i], "-s"))
+ {
+ xf86sFlag = TRUE;
+ return 0;
+ }
+ if (!strcmp(argv[i], "-pixmap24"))
+ {
+ xf86Pix24 = Pix24Use24;
+ return 1;
+ }
+ if (!strcmp(argv[i], "-pixmap32"))
+ {
+ xf86Pix24 = Pix24Use32;
+ return 1;
+ }
+ if (!strcmp(argv[i], "-fbbpp"))
+ {
+ int bpp;
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ if (sscanf(argv[++i], "%d", &bpp) == 1)
+ {
+ xf86FbBpp = bpp;
+ return 2;
+ }
+ else
+ {
+ ErrorF("Invalid fbbpp\n");
+ return 0;
+ }
+ }
+ if (!strcmp(argv[i], "-depth"))
+ {
+ int depth;
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ if (sscanf(argv[++i], "%d", &depth) == 1)
+ {
+ xf86Depth = depth;
+ return 2;
+ }
+ else
+ {
+ ErrorF("Invalid depth\n");
+ return 0;
+ }
+ }
+ if (!strcmp(argv[i], "-weight"))
+ {
+ int red, green, blue;
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ if (sscanf(argv[++i], "%1d%1d%1d", &red, &green, &blue) == 3)
+ {
+ xf86Weight.red = red;
+ xf86Weight.green = green;
+ xf86Weight.blue = blue;
+ return 2;
+ }
+ else
+ {
+ ErrorF("Invalid weighting\n");
+ return 0;
+ }
+ }
+ if (!strcmp(argv[i], "-gamma") || !strcmp(argv[i], "-rgamma") ||
+ !strcmp(argv[i], "-ggamma") || !strcmp(argv[i], "-bgamma"))
+ {
+ double gamma;
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ if (sscanf(argv[++i], "%lf", &gamma) == 1) {
+ if (gamma < GAMMA_MIN || gamma > GAMMA_MAX) {
+ ErrorF("gamma out of range, only %.2f <= gamma_value <= %.1f"
+ " is valid\n", GAMMA_MIN, GAMMA_MAX);
+ return 0;
+ }
+ if (!strcmp(argv[i-1], "-gamma"))
+ xf86Gamma.red = xf86Gamma.green = xf86Gamma.blue = gamma;
+ else if (!strcmp(argv[i-1], "-rgamma")) xf86Gamma.red = gamma;
+ else if (!strcmp(argv[i-1], "-ggamma")) xf86Gamma.green = gamma;
+ else if (!strcmp(argv[i-1], "-bgamma")) xf86Gamma.blue = gamma;
+ return 2;
+ }
+ }
+ if (!strcmp(argv[i], "-layout"))
+ {
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ xf86LayoutName = argv[++i];
+ return 2;
+ }
+ if (!strcmp(argv[i], "-screen"))
+ {
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ xf86ScreenName = argv[++i];
+ return 2;
+ }
+ if (!strcmp(argv[i], "-pointer"))
+ {
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ xf86PointerName = argv[++i];
+ return 2;
+ }
+ if (!strcmp(argv[i], "-keyboard"))
+ {
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ xf86KeyboardName = argv[++i];
+ return 2;
+ }
+ if (!strcmp(argv[i], "-nosilk"))
+ {
+ xf86silkenMouseDisableFlag = TRUE;
+ return 1;
+ }
+#ifdef HAVE_ACPI
+ if (!strcmp(argv[i], "-noacpi"))
+ {
+ xf86acpiDisableFlag = TRUE;
+ return 1;
+ }
+#endif
+ if (!strcmp(argv[i], "-configure"))
+ {
+ if (getuid() != 0 && geteuid() == 0) {
+ ErrorF("The '-configure' option can only be used by root.\n");
+ exit(1);
+ }
+ xf86DoConfigure = TRUE;
+ xf86AllowMouseOpenFail = TRUE;
+ return 1;
+ }
+ if (!strcmp(argv[i], "-showopts"))
+ {
+ if (getuid() != 0 && geteuid() == 0) {
+ ErrorF("The '-showopts' option can only be used by root.\n");
+ exit(1);
+ }
+ xf86DoShowOptions = TRUE;
+ return 1;
+ }
+ if (!strcmp(argv[i], "-isolateDevice"))
+ {
+ CHECK_FOR_REQUIRED_ARGUMENT();
+ if (strncmp(argv[++i], "PCI:", 4)) {
+ FatalError("Bus types other than PCI not yet isolable\n");
+ }
+ xf86PciIsolateDevice(argv[i]);
+ return 2;
+ }
+ /* Notice cmdline xkbdir, but pass to dix as well */
+ if (!strcmp(argv[i], "-xkbdir"))
+ {
+ xf86xkbdirFlag = TRUE;
+ return 0;
+ }
+
+ /* OS-specific processing */
+ return xf86ProcessArgument(argc, argv, i);
+}
+
+/*
+ * ddxUseMsg --
+ * Print out correct use of device dependent commandline options.
+ * Maybe the user now knows what really to do ...
+ */
+
+void
+ddxUseMsg(void)
+{
+ ErrorF("\n");
+ ErrorF("\n");
+ ErrorF("Device Dependent Usage\n");
+ if (getuid() == 0 || geteuid() != 0)
+ {
+ ErrorF("-modulepath paths specify the module search path\n");
+ ErrorF("-logfile file specify a log file name\n");
+ ErrorF("-configure probe for devices and write an "__XCONFIGFILE__"\n");
+ ErrorF("-showopts print available options for all installed drivers\n");
+ }
+ ErrorF("-config file specify a configuration file, relative to the\n");
+ ErrorF(" "__XCONFIGFILE__" search path, only root can use absolute\n");
+ ErrorF("-configdir dir specify a configuration directory, relative to the\n");
+ ErrorF(" "__XCONFIGDIR__" search path, only root can use absolute\n");
+ ErrorF("-verbose [n] verbose startup messages\n");
+ ErrorF("-logverbose [n] verbose log messages\n");
+ ErrorF("-quiet minimal startup messages\n");
+ ErrorF("-pixmap24 use 24bpp pixmaps for depth 24\n");
+ ErrorF("-pixmap32 use 32bpp pixmaps for depth 24\n");
+ ErrorF("-fbbpp n set bpp for the framebuffer. Default: 8\n");
+ ErrorF("-depth n set colour depth. Default: 8\n");
+ ErrorF("-gamma f set gamma value (0.1 < f < 10.0) Default: 1.0\n");
+ ErrorF("-rgamma f set gamma value for red phase\n");
+ ErrorF("-ggamma f set gamma value for green phase\n");
+ ErrorF("-bgamma f set gamma value for blue phase\n");
+ ErrorF("-weight nnn set RGB weighting at 16 bpp. Default: 565\n");
+ ErrorF("-layout name specify the ServerLayout section name\n");
+ ErrorF("-screen name specify the Screen section name\n");
+ ErrorF("-keyboard name specify the core keyboard InputDevice name\n");
+ ErrorF("-pointer name specify the core pointer InputDevice name\n");
+ ErrorF("-nosilk disable Silken Mouse\n");
+ ErrorF("-flipPixels swap default black/white Pixel values\n");
+#ifdef XF86VIDMODE
+ ErrorF("-disableVidMode disable mode adjustments with xvidtune\n");
+ ErrorF("-allowNonLocalXvidtune allow xvidtune to be run as a non-local client\n");
+#endif
+ ErrorF("-allowMouseOpenFail start server even if the mouse can't be initialized\n");
+ ErrorF("-ignoreABI make module ABI mismatches non-fatal\n");
+ ErrorF("-isolateDevice bus_id restrict device resets to bus_id (PCI only)\n");
+ ErrorF("-version show the server version\n");
+ ErrorF("-showDefaultModulePath show the server default module path\n");
+ ErrorF("-showDefaultLibPath show the server default library path\n");
+ /* OS-specific usage */
+ xf86UseMsg();
+ ErrorF("\n");
+}
+
+
+/*
+ * xf86LoadModules iterates over a list that is being passed in.
+ */
+Bool
+xf86LoadModules(char **list, pointer *optlist)
+{
+ int errmaj, errmin;
+ pointer opt;
+ int i;
+ char *name;
+ Bool failed = FALSE;
+
+ if (!list)
+ return TRUE;
+
+ for (i = 0; list[i] != NULL; i++) {
+
+ /* Normalise the module name */
+ name = xf86NormalizeName(list[i]);
+
+ /* Skip empty names */
+ if (name == NULL || *name == '\0') {
+ free(name);
+ continue;
+ }
+
+ /* Replace obsolete keyboard driver with kbd */
+ if (!xf86NameCmp(name, "keyboard")) {
+ strcpy(name, "kbd");
+ }
+
+ if (optlist)
+ opt = optlist[i];
+ else
+ opt = NULL;
+
+ if (!LoadModule(name, NULL, NULL, NULL, opt, NULL, &errmaj, &errmin)) {
+ LoaderErrorMsg(NULL, name, errmaj, errmin);
+ failed = TRUE;
+ }
+ free(name);
+ }
+ return !failed;
+}
+
+/* Pixmap format stuff */
+
+PixmapFormatPtr
+xf86GetPixFormat(ScrnInfoPtr pScrn, int depth)
+{
+ int i;
+ static PixmapFormatRec format; /* XXX not reentrant */
+
+ /*
+ * When the formats[] list initialisation isn't complete, check the
+ * depth 24 pixmap config/cmdline options and screen-specified formats.
+ */
+
+ if (!formatsDone) {
+ if (depth == 24) {
+ Pix24Flags pix24 = Pix24DontCare;
+
+ format.depth = 24;
+ format.scanlinePad = BITMAP_SCANLINE_PAD;
+ if (xf86Info.pixmap24 != Pix24DontCare)
+ pix24 = xf86Info.pixmap24;
+ else if (pScrn->pixmap24 != Pix24DontCare)
+ pix24 = pScrn->pixmap24;
+ if (pix24 == Pix24Use24)
+ format.bitsPerPixel = 24;
+ else
+ format.bitsPerPixel = 32;
+ return &format;
+ }
+ }
+
+ for (i = 0; i < numFormats; i++)
+ if (formats[i].depth == depth)
+ break;
+ if (i != numFormats)
+ return &formats[i];
+ else if (!formatsDone) {
+ /* Check for screen-specified formats */
+ for (i = 0; i < pScrn->numFormats; i++)
+ if (pScrn->formats[i].depth == depth)
+ break;
+ if (i != pScrn->numFormats)
+ return &pScrn->formats[i];
+ }
+ return NULL;
+}
+
+int
+xf86GetBppFromDepth(ScrnInfoPtr pScrn, int depth)
+{
+ PixmapFormatPtr format;
+
+
+ format = xf86GetPixFormat(pScrn, depth);
+ if (format)
+ return format->bitsPerPixel;
+ else
+ return 0;
+}
diff --git a/xorg-server/hw/xfree86/common/xf86Module.h b/xorg-server/hw/xfree86/common/xf86Module.h
index f5f182b25..2a5c805c4 100644
--- a/xorg-server/hw/xfree86/common/xf86Module.h
+++ b/xorg-server/hw/xfree86/common/xf86Module.h
@@ -1,212 +1,212 @@
-/*
- * Copyright (c) 1997-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).
- */
-
-/*
- * This file contains the parts of the loader interface that are visible
- * to modules. This is the only loader-related header that modules should
- * include.
- *
- * It should include a bare minimum of other headers.
- *
- * Longer term, the module/loader code should probably live directly under
- * Xserver/.
- *
- * XXX This file arguably belongs in xfree86/loader/.
- */
-
-#ifndef _XF86MODULE_H
-#define _XF86MODULE_H
-
-#include "misc.h"
-#ifndef NULL
-#define NULL ((void *)0)
-#endif
-
-typedef enum {
- LD_RESOLV_IFDONE = 0, /* only check if no more
- delays pending */
- LD_RESOLV_NOW = 1, /* finish one delay step */
- LD_RESOLV_FORCE = 2 /* force checking... */
-} LoaderResolveOptions;
-
-#define DEFAULT_LIST ((char *)-1)
-
-/* This indicates a special module that doesn't have the usual entry point */
-#define EXTERN_MODULE ((pointer)-1)
-
-/* Built-in ABI classes. These definitions must not be changed. */
-#define ABI_CLASS_NONE NULL
-#define ABI_CLASS_ANSIC "X.Org ANSI C Emulation"
-#define ABI_CLASS_VIDEODRV "X.Org Video Driver"
-#define ABI_CLASS_XINPUT "X.Org XInput driver"
-#define ABI_CLASS_EXTENSION "X.Org Server Extension"
-#define ABI_CLASS_FONT "X.Org Font Renderer"
-
-#define ABI_MINOR_MASK 0x0000FFFF
-#define ABI_MAJOR_MASK 0xFFFF0000
-#define GET_ABI_MINOR(v) ((v) & ABI_MINOR_MASK)
-#define GET_ABI_MAJOR(v) (((v) & ABI_MAJOR_MASK) >> 16)
-#define SET_ABI_VERSION(maj, min) \
- ((((maj) << 16) & ABI_MAJOR_MASK) | ((min) & ABI_MINOR_MASK))
-
-/*
- * ABI versions. Each version has a major and minor revision. Modules
- * using lower minor revisions must work with servers of a higher minor
- * revision. There is no compatibility between different major revisions.
- * Whenever the ABI_ANSIC_VERSION is changed, the others must also be
- * changed. The minor revision mask is 0x0000FFFF and the major revision
- * mask is 0xFFFF0000.
- */
-#define ABI_ANSIC_VERSION SET_ABI_VERSION(0, 4)
-#define ABI_VIDEODRV_VERSION SET_ABI_VERSION(11, 0)
-#define ABI_XINPUT_VERSION SET_ABI_VERSION(13, 0)
-#define ABI_EXTENSION_VERSION SET_ABI_VERSION(5, 0)
-#define ABI_FONT_VERSION SET_ABI_VERSION(0, 6)
-
-#define MODINFOSTRING1 0xef23fdc5
-#define MODINFOSTRING2 0x10dc023a
-
-#ifndef MODULEVENDORSTRING
-#define MODULEVENDORSTRING "X.Org Foundation"
-#endif
-
-/* Error return codes for errmaj. New codes must only be added at the end. */
-typedef enum {
- LDR_NOERROR = 0,
- LDR_NOMEM, /* memory allocation failed */
- LDR_NOENT, /* Module file does not exist */
- LDR_NOSUBENT, /* pre-requsite file to be sub-loaded does not exist */
- LDR_NOSPACE, /* internal module array full */
- LDR_NOMODOPEN, /* module file could not be opened (check errmin) */
- LDR_UNKTYPE, /* file is not a recognized module type */
- LDR_NOLOAD, /* type specific loader failed */
- LDR_ONCEONLY, /* Module should only be loaded once (not an error) */
- LDR_NOPORTOPEN, /* could not open port (check errmin) */
- LDR_NOHARDWARE, /* could not query/initialize the hardware device */
- LDR_MISMATCH, /* the module didn't match the spec'd requirments */
- LDR_BADUSAGE, /* LoadModule is called with bad arguments */
- LDR_INVALID, /* The module doesn't have a valid ModuleData object */
- LDR_BADOS, /* The module doesn't support the OS */
- LDR_MODSPECIFIC /* A module-specific error in the SetupProc */
-} LoaderErrorCode;
-
-/*
- * Some common module classes. The moduleclass can be used to identify
- * that modules loaded are of the correct type. This is a finer
- * classification than the ABI classes even though the default set of
- * classes have the same names. For example, not all modules that require
- * the video driver ABI are themselves video drivers.
- */
-#define MOD_CLASS_NONE NULL
-#define MOD_CLASS_VIDEODRV "X.Org Video Driver"
-#define MOD_CLASS_XINPUT "X.Org XInput Driver"
-#define MOD_CLASS_FONT "X.Org Font Renderer"
-#define MOD_CLASS_EXTENSION "X.Org Server Extension"
-
-/* This structure is expected to be returned by the initfunc */
-typedef struct {
- const char * modname; /* name of module, e.g. "foo" */
- const char * vendor; /* vendor specific string */
- CARD32 _modinfo1_; /* constant MODINFOSTRING1/2 to find */
- CARD32 _modinfo2_; /* infoarea with a binary editor or sign tool */
- CARD32 xf86version; /* contains XF86_VERSION_CURRENT */
- CARD8 majorversion; /* module-specific major version */
- CARD8 minorversion; /* module-specific minor version */
- CARD16 patchlevel; /* module-specific patch level */
- const char * abiclass; /* ABI class that the module uses */
- CARD32 abiversion; /* ABI version */
- const char * moduleclass; /* module class description */
- CARD32 checksum[4]; /* contains a digital signature of the */
- /* version info structure */
-} XF86ModuleVersionInfo;
-
-/*
- * This structure can be used to callers of LoadModule and LoadSubModule to
- * specify version and/or ABI requirements.
- */
-typedef struct {
- CARD8 majorversion; /* module-specific major version */
- CARD8 minorversion; /* moudle-specific minor version */
- CARD16 patchlevel; /* module-specific patch level */
- const char * abiclass; /* ABI class that the module uses */
- CARD32 abiversion; /* ABI version */
- const char * moduleclass; /* module class */
-} XF86ModReqInfo;
-
-/* values to indicate unspecified fields in XF86ModReqInfo. */
-#define MAJOR_UNSPEC 0xFF
-#define MINOR_UNSPEC 0xFF
-#define PATCH_UNSPEC 0xFFFF
-#define ABI_VERS_UNSPEC 0xFFFFFFFF
-
-#define MODULE_VERSION_NUMERIC(maj, min, patch) \
- ((((maj) & 0xFF) << 24) | (((min) & 0xFF) << 16) | (patch & 0xFFFF))
-#define GET_MODULE_MAJOR_VERSION(vers) (((vers) >> 24) & 0xFF)
-#define GET_MODULE_MINOR_VERSION(vers) (((vers) >> 16) & 0xFF)
-#define GET_MODULE_PATCHLEVEL(vers) ((vers) & 0xFFFF)
-
-#define INITARGS void
-
-typedef void (*InitExtension)(INITARGS);
-
-typedef struct {
- InitExtension initFunc;
- const char * name;
- Bool *disablePtr;
- InitExtension setupFunc;
- const char ** initDependencies;
-} ExtensionModule;
-
-extern _X_EXPORT ExtensionModule *ExtensionModuleList;
-
-/* Prototypes for Loader functions that are exported to modules */
-extern _X_EXPORT pointer LoadSubModule(pointer, const char *, const char **,
- const char **, pointer, const XF86ModReqInfo *,
- int *, int *);
-extern _X_EXPORT void UnloadSubModule(pointer);
-extern _X_EXPORT void UnloadModule (pointer);
-extern _X_EXPORT pointer LoaderSymbol(const char *);
-extern _X_EXPORT char **LoaderListDirs(const char **, const char **);
-extern _X_EXPORT void LoaderFreeDirList(char **);
-extern _X_EXPORT void LoaderErrorMsg(const char *, const char *, int, int);
-extern _X_EXPORT void LoadExtension(ExtensionModule *, Bool);
-extern _X_EXPORT void LoaderGetOS(const char **name, int *major, int *minor, int *teeny);
-extern _X_EXPORT Bool LoaderShouldIgnoreABI(void);
-extern _X_EXPORT int LoaderGetABIVersion(const char *abiclass);
-
-typedef pointer (*ModuleSetupProc)(pointer, pointer, int *, int *);
-typedef void (*ModuleTearDownProc)(pointer);
-#define MODULESETUPPROTO(func) pointer func(pointer, pointer, int*, int*)
-#define MODULETEARDOWNPROTO(func) void func(pointer)
-
-typedef struct {
- XF86ModuleVersionInfo * vers;
- ModuleSetupProc setup;
- ModuleTearDownProc teardown;
-} XF86ModuleData;
-
-#endif /* _XF86STR_H */
+/*
+ * Copyright (c) 1997-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).
+ */
+
+/*
+ * This file contains the parts of the loader interface that are visible
+ * to modules. This is the only loader-related header that modules should
+ * include.
+ *
+ * It should include a bare minimum of other headers.
+ *
+ * Longer term, the module/loader code should probably live directly under
+ * Xserver/.
+ *
+ * XXX This file arguably belongs in xfree86/loader/.
+ */
+
+#ifndef _XF86MODULE_H
+#define _XF86MODULE_H
+
+#include "misc.h"
+#ifndef NULL
+#define NULL ((void *)0)
+#endif
+
+typedef enum {
+ LD_RESOLV_IFDONE = 0, /* only check if no more
+ delays pending */
+ LD_RESOLV_NOW = 1, /* finish one delay step */
+ LD_RESOLV_FORCE = 2 /* force checking... */
+} LoaderResolveOptions;
+
+#define DEFAULT_LIST ((char *)-1)
+
+/* This indicates a special module that doesn't have the usual entry point */
+#define EXTERN_MODULE ((pointer)-1)
+
+/* Built-in ABI classes. These definitions must not be changed. */
+#define ABI_CLASS_NONE NULL
+#define ABI_CLASS_ANSIC "X.Org ANSI C Emulation"
+#define ABI_CLASS_VIDEODRV "X.Org Video Driver"
+#define ABI_CLASS_XINPUT "X.Org XInput driver"
+#define ABI_CLASS_EXTENSION "X.Org Server Extension"
+#define ABI_CLASS_FONT "X.Org Font Renderer"
+
+#define ABI_MINOR_MASK 0x0000FFFF
+#define ABI_MAJOR_MASK 0xFFFF0000
+#define GET_ABI_MINOR(v) ((v) & ABI_MINOR_MASK)
+#define GET_ABI_MAJOR(v) (((v) & ABI_MAJOR_MASK) >> 16)
+#define SET_ABI_VERSION(maj, min) \
+ ((((maj) << 16) & ABI_MAJOR_MASK) | ((min) & ABI_MINOR_MASK))
+
+/*
+ * ABI versions. Each version has a major and minor revision. Modules
+ * using lower minor revisions must work with servers of a higher minor
+ * revision. There is no compatibility between different major revisions.
+ * Whenever the ABI_ANSIC_VERSION is changed, the others must also be
+ * changed. The minor revision mask is 0x0000FFFF and the major revision
+ * mask is 0xFFFF0000.
+ */
+#define ABI_ANSIC_VERSION SET_ABI_VERSION(0, 4)
+#define ABI_VIDEODRV_VERSION SET_ABI_VERSION(11, 0)
+#define ABI_XINPUT_VERSION SET_ABI_VERSION(13, 0)
+#define ABI_EXTENSION_VERSION SET_ABI_VERSION(5, 0)
+#define ABI_FONT_VERSION SET_ABI_VERSION(0, 6)
+
+#define MODINFOSTRING1 0xef23fdc5
+#define MODINFOSTRING2 0x10dc023a
+
+#ifndef MODULEVENDORSTRING
+#define MODULEVENDORSTRING "X.Org Foundation"
+#endif
+
+/* Error return codes for errmaj. New codes must only be added at the end. */
+typedef enum {
+ LDR_NOERROR = 0,
+ LDR_NOMEM, /* memory allocation failed */
+ LDR_NOENT, /* Module file does not exist */
+ LDR_NOSUBENT, /* pre-requsite file to be sub-loaded does not exist */
+ LDR_NOSPACE, /* internal module array full */
+ LDR_NOMODOPEN, /* module file could not be opened (check errmin) */
+ LDR_UNKTYPE, /* file is not a recognized module type */
+ LDR_NOLOAD, /* type specific loader failed */
+ LDR_ONCEONLY, /* Module should only be loaded once (not an error) */
+ LDR_NOPORTOPEN, /* could not open port (check errmin) */
+ LDR_NOHARDWARE, /* could not query/initialize the hardware device */
+ LDR_MISMATCH, /* the module didn't match the spec'd requirments */
+ LDR_BADUSAGE, /* LoadModule is called with bad arguments */
+ LDR_INVALID, /* The module doesn't have a valid ModuleData object */
+ LDR_BADOS, /* The module doesn't support the OS */
+ LDR_MODSPECIFIC /* A module-specific error in the SetupProc */
+} LoaderErrorCode;
+
+/*
+ * Some common module classes. The moduleclass can be used to identify
+ * that modules loaded are of the correct type. This is a finer
+ * classification than the ABI classes even though the default set of
+ * classes have the same names. For example, not all modules that require
+ * the video driver ABI are themselves video drivers.
+ */
+#define MOD_CLASS_NONE NULL
+#define MOD_CLASS_VIDEODRV "X.Org Video Driver"
+#define MOD_CLASS_XINPUT "X.Org XInput Driver"
+#define MOD_CLASS_FONT "X.Org Font Renderer"
+#define MOD_CLASS_EXTENSION "X.Org Server Extension"
+
+/* This structure is expected to be returned by the initfunc */
+typedef struct {
+ const char * modname; /* name of module, e.g. "foo" */
+ const char * vendor; /* vendor specific string */
+ CARD32 _modinfo1_; /* constant MODINFOSTRING1/2 to find */
+ CARD32 _modinfo2_; /* infoarea with a binary editor or sign tool */
+ CARD32 xf86version; /* contains XF86_VERSION_CURRENT */
+ CARD8 majorversion; /* module-specific major version */
+ CARD8 minorversion; /* module-specific minor version */
+ CARD16 patchlevel; /* module-specific patch level */
+ const char * abiclass; /* ABI class that the module uses */
+ CARD32 abiversion; /* ABI version */
+ const char * moduleclass; /* module class description */
+ CARD32 checksum[4]; /* contains a digital signature of the */
+ /* version info structure */
+} XF86ModuleVersionInfo;
+
+/*
+ * This structure can be used to callers of LoadModule and LoadSubModule to
+ * specify version and/or ABI requirements.
+ */
+typedef struct {
+ CARD8 majorversion; /* module-specific major version */
+ CARD8 minorversion; /* moudle-specific minor version */
+ CARD16 patchlevel; /* module-specific patch level */
+ const char * abiclass; /* ABI class that the module uses */
+ CARD32 abiversion; /* ABI version */
+ const char * moduleclass; /* module class */
+} XF86ModReqInfo;
+
+/* values to indicate unspecified fields in XF86ModReqInfo. */
+#define MAJOR_UNSPEC 0xFF
+#define MINOR_UNSPEC 0xFF
+#define PATCH_UNSPEC 0xFFFF
+#define ABI_VERS_UNSPEC 0xFFFFFFFF
+
+#define MODULE_VERSION_NUMERIC(maj, min, patch) \
+ ((((maj) & 0xFF) << 24) | (((min) & 0xFF) << 16) | (patch & 0xFFFF))
+#define GET_MODULE_MAJOR_VERSION(vers) (((vers) >> 24) & 0xFF)
+#define GET_MODULE_MINOR_VERSION(vers) (((vers) >> 16) & 0xFF)
+#define GET_MODULE_PATCHLEVEL(vers) ((vers) & 0xFFFF)
+
+#define INITARGS void
+
+typedef void (*InitExtension)(INITARGS);
+
+typedef struct {
+ InitExtension initFunc;
+ const char * name;
+ Bool *disablePtr;
+ InitExtension setupFunc;
+ const char ** initDependencies;
+} ExtensionModule;
+
+extern _X_EXPORT ExtensionModule *ExtensionModuleList;
+
+/* Prototypes for Loader functions that are exported to modules */
+extern _X_EXPORT pointer LoadSubModule(pointer, const char *, const char **,
+ const char **, pointer, const XF86ModReqInfo *,
+ int *, int *);
+extern _X_EXPORT void UnloadSubModule(pointer);
+extern _X_EXPORT void UnloadModule (pointer);
+extern _X_EXPORT pointer LoaderSymbol(const char *);
+extern _X_EXPORT char **LoaderListDirs(const char **, const char **);
+extern _X_EXPORT void LoaderFreeDirList(char **);
+extern _X_EXPORT void LoaderErrorMsg(const char *, const char *, int, int);
+extern _X_EXPORT void LoadExtension(ExtensionModule *, Bool);
+extern _X_EXPORT void LoaderGetOS(const char **name, int *major, int *minor, int *teeny);
+extern _X_EXPORT Bool LoaderShouldIgnoreABI(void);
+extern _X_EXPORT int LoaderGetABIVersion(const char *abiclass);
+
+typedef pointer (*ModuleSetupProc)(pointer, pointer, int *, int *);
+typedef void (*ModuleTearDownProc)(pointer);
+#define MODULESETUPPROTO(func) pointer func(pointer, pointer, int*, int*)
+#define MODULETEARDOWNPROTO(func) void func(pointer)
+
+typedef struct {
+ XF86ModuleVersionInfo * vers;
+ ModuleSetupProc setup;
+ ModuleTearDownProc teardown;
+} XF86ModuleData;
+
+#endif /* _XF86STR_H */
diff --git a/xorg-server/hw/xfree86/common/xf86Option.c b/xorg-server/hw/xfree86/common/xf86Option.c
index 576796d6c..a3a836fc1 100644
--- a/xorg-server/hw/xfree86/common/xf86Option.c
+++ b/xorg-server/hw/xfree86/common/xf86Option.c
@@ -1,916 +1,916 @@
-/*
- * Copyright (c) 1998-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).
- */
-
-/*
- * Author: David Dawes <dawes@xfree86.org>
- *
- * This file includes public option handling functions.
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <stdlib.h>
-#include <ctype.h>
-#include <X11/X.h>
-#include "os.h"
-#include "xf86.h"
-#include "xf86Xinput.h"
-#include "xf86Optrec.h"
-#include "xf86Parser.h"
-
-static Bool ParseOptionValue(int scrnIndex, pointer options, OptionInfoPtr p,
- Bool markUsed);
-
-/*
- * xf86CollectOptions collects the options from each of the config file
- * sections used by the screen and puts the combined list in pScrn->options.
- * This function requires that the following have been initialised:
- *
- * pScrn->confScreen
- * pScrn->Entities[i]->device
- * pScrn->display
- * pScrn->monitor
- *
- * The extraOpts parameter may optionally contain a list of additional options
- * to include.
- *
- * The order of precedence for options is:
- *
- * extraOpts, display, confScreen, monitor, device
- */
-
-void
-xf86CollectOptions(ScrnInfoPtr pScrn, pointer extraOpts)
-{
- XF86OptionPtr tmp;
- XF86OptionPtr extras = (XF86OptionPtr)extraOpts;
- GDevPtr device;
-
- int i;
-
- pScrn->options = NULL;
-
- for (i=pScrn->numEntities - 1; i >= 0; i--) {
- device = xf86GetDevFromEntity(pScrn->entityList[i],
- pScrn->entityInstanceList[i]);
- if (device && device->options) {
- tmp = xf86optionListDup(device->options);
- if (pScrn->options)
- xf86optionListMerge(pScrn->options,tmp);
- else
- pScrn->options = tmp;
- }
- }
- if (pScrn->monitor->options) {
- tmp = xf86optionListDup(pScrn->monitor->options);
- if (pScrn->options)
- pScrn->options = xf86optionListMerge(pScrn->options, tmp);
- else
- pScrn->options = tmp;
- }
- if (pScrn->confScreen->options) {
- tmp = xf86optionListDup(pScrn->confScreen->options);
- if (pScrn->options)
- pScrn->options = xf86optionListMerge(pScrn->options, tmp);
- else
- pScrn->options = tmp;
- }
- if (pScrn->display->options) {
- tmp = xf86optionListDup(pScrn->display->options);
- if (pScrn->options)
- pScrn->options = xf86optionListMerge(pScrn->options, tmp);
- else
- pScrn->options = tmp;
- }
- if (extras) {
- tmp = xf86optionListDup(extras);
- if (pScrn->options)
- pScrn->options = xf86optionListMerge(pScrn->options, tmp);
- else
- pScrn->options = tmp;
- }
-}
-
-/*
- * xf86CollectInputOptions collects extra options for an InputDevice (other
- * than those added by the config backend).
- * The options are merged into the existing ones and thus take precedence
- * over the others.
- */
-
-void
-xf86CollectInputOptions(InputInfoPtr pInfo, const char **defaultOpts)
-{
- if (defaultOpts) {
- XF86OptionPtr tmp =xf86optionListCreate(defaultOpts, -1, 0);
- if (pInfo->options)
- pInfo->options = xf86optionListMerge(tmp, pInfo->options);
- else
- pInfo->options = tmp;
- }
-}
-
-/**
- * Duplicate the option list passed in. The returned pointer will be a newly
- * allocated option list and must be freed by the caller.
- */
-pointer
-xf86OptionListDuplicate(pointer options)
-{
- pointer o = NULL;
-
- while (options)
- {
- o = xf86AddNewOption(o, xf86OptionName(options), xf86OptionValue(options));
- options = xf86nextOption(options);
- }
-
- return o;
-}
-
-
-/* Created for new XInput stuff -- essentially extensions to the parser */
-
-static int
-LookupIntOption(pointer optlist, const char *name, int deflt, Bool markUsed)
-{
- OptionInfoRec o;
-
- o.name = name;
- o.type = OPTV_INTEGER;
- if (ParseOptionValue(-1, optlist, &o, markUsed))
- deflt = o.value.num;
- return deflt;
-}
-
-
-static double
-LookupRealOption(pointer optlist, const char *name, double deflt,
- Bool markUsed)
-{
- OptionInfoRec o;
-
- o.name = name;
- o.type = OPTV_REAL;
- if (ParseOptionValue(-1, optlist, &o, markUsed))
- deflt = o.value.realnum;
- return deflt;
-}
-
-
-static char *
-LookupStrOption(pointer optlist, const char *name, char *deflt, Bool markUsed)
-{
- OptionInfoRec o;
-
- o.name = name;
- o.type = OPTV_STRING;
- if (ParseOptionValue(-1, optlist, &o, markUsed))
- deflt = o.value.str;
- if (deflt)
- return strdup(deflt);
- else
- return NULL;
-}
-
-
-static int
-LookupBoolOption(pointer optlist, const char *name, int deflt, Bool markUsed)
-{
- OptionInfoRec o;
-
- o.name = name;
- o.type = OPTV_BOOLEAN;
- if (ParseOptionValue(-1, optlist, &o, markUsed))
- deflt = o.value.bool;
- return deflt;
-}
-
-static double
-LookupPercentOption(pointer optlist, const char *name, double deflt, Bool markUsed)
-{
- OptionInfoRec o;
-
- o.name = name;
- o.type = OPTV_PERCENT;
- if (ParseOptionValue(-1, optlist, &o, markUsed))
- deflt = o.value.realnum;
- return deflt;
-}
-
-/* These xf86Set* functions are intended for use by non-screen specific code */
-
-int
-xf86SetIntOption(pointer optlist, const char *name, int deflt)
-{
- return LookupIntOption(optlist, name, deflt, TRUE);
-}
-
-
-double
-xf86SetRealOption(pointer optlist, const char *name, double deflt)
-{
- return LookupRealOption(optlist, name, deflt, TRUE);
-}
-
-
-char *
-xf86SetStrOption(pointer optlist, const char *name, char *deflt)
-{
- return LookupStrOption(optlist, name, deflt, TRUE);
-}
-
-
-int
-xf86SetBoolOption(pointer optlist, const char *name, int deflt)
-{
- return LookupBoolOption(optlist, name, deflt, TRUE);
-}
-
-double
-xf86SetPercentOption(pointer optlist, const char *name, double deflt)
-{
- return LookupPercentOption(optlist, name, deflt, TRUE);
-}
-
-/*
- * These are like the Set*Option functions, but they don't mark the options
- * as used.
- */
-int
-xf86CheckIntOption(pointer optlist, const char *name, int deflt)
-{
- return LookupIntOption(optlist, name, deflt, FALSE);
-}
-
-
-double
-xf86CheckRealOption(pointer optlist, const char *name, double deflt)
-{
- return LookupRealOption(optlist, name, deflt, FALSE);
-}
-
-
-char *
-xf86CheckStrOption(pointer optlist, const char *name, char *deflt)
-{
- return LookupStrOption(optlist, name, deflt, FALSE);
-}
-
-
-int
-xf86CheckBoolOption(pointer optlist, const char *name, int deflt)
-{
- return LookupBoolOption(optlist, name, deflt, FALSE);
-}
-
-
-double
-xf86CheckPercentOption(pointer optlist, const char *name, double deflt)
-{
- return LookupPercentOption(optlist, name, deflt, FALSE);
-}
-/*
- * addNewOption() has the required property of replacing the option value
- * if the option is already present.
- */
-pointer
-xf86ReplaceIntOption(pointer optlist, const char *name, const int val)
-{
- char tmp[16];
- sprintf(tmp,"%i",val);
- return xf86AddNewOption(optlist,name,tmp);
-}
-
-pointer
-xf86ReplaceRealOption(pointer optlist, const char *name, const double val)
-{
- char tmp[32];
- snprintf(tmp,32,"%f",val);
- return xf86AddNewOption(optlist,name,tmp);
-}
-
-pointer
-xf86ReplaceBoolOption(pointer optlist, const char *name, const Bool val)
-{
- return xf86AddNewOption(optlist,name,val?"True":"False");
-}
-
-pointer
-xf86ReplacePercentOption(pointer optlist, const char *name, const double val)
-{
- char tmp[16];
- sprintf(tmp, "%lf%%", val);
- return xf86AddNewOption(optlist,name,tmp);
-}
-
-pointer
-xf86ReplaceStrOption(pointer optlist, const char *name, const char* val)
-{
- return xf86AddNewOption(optlist,name,val);
-}
-
-pointer
-xf86AddNewOption(pointer head, const char *name, const char *val)
-{
- /* XXX These should actually be allocated in the parser library. */
- char *tmp = val ? strdup(val) : NULL;
- char *tmp_name = strdup(name);
-
- return xf86addNewOption(head, tmp_name, tmp);
-}
-
-
-pointer
-xf86NewOption(char *name, char *value)
-{
- return xf86newOption(name, value);
-}
-
-
-pointer
-xf86NextOption(pointer list)
-{
- return xf86nextOption(list);
-}
-
-pointer
-xf86OptionListCreate(const char **options, int count, int used)
-{
- return xf86optionListCreate(options, count, used);
-}
-
-pointer
-xf86OptionListMerge(pointer head, pointer tail)
-{
- return xf86optionListMerge(head, tail);
-}
-
-void
-xf86OptionListFree(pointer opt)
-{
- xf86optionListFree(opt);
-}
-
-char *
-xf86OptionName(pointer opt)
-{
- return xf86optionName(opt);
-}
-
-char *
-xf86OptionValue(pointer opt)
-{
- return xf86optionValue(opt);
-}
-
-void
-xf86OptionListReport(pointer parm)
-{
- XF86OptionPtr opts = parm;
-
- while(opts) {
- if (xf86optionValue(opts))
- xf86ErrorFVerb(5, "\tOption \"%s\" \"%s\"\n",
- xf86optionName(opts), xf86optionValue(opts));
- else
- xf86ErrorFVerb( 5, "\tOption \"%s\"\n", xf86optionName(opts));
- opts = xf86nextOption(opts);
- }
-}
-
-/* End of XInput-caused section */
-
-pointer
-xf86FindOption(pointer options, const char *name)
-{
- return xf86findOption(options, name);
-}
-
-
-char *
-xf86FindOptionValue(pointer options, const char *name)
-{
- return xf86findOptionValue(options, name);
-}
-
-
-void
-xf86MarkOptionUsed(pointer option)
-{
- if (option != NULL)
- ((XF86OptionPtr)option)->opt_used = TRUE;
-}
-
-
-void
-xf86MarkOptionUsedByName(pointer options, const char *name)
-{
- XF86OptionPtr opt;
-
- opt = xf86findOption(options, name);
- if (opt != NULL)
- opt->opt_used = TRUE;
-}
-
-Bool
-xf86CheckIfOptionUsed(pointer option)
-{
- if (option != NULL)
- return ((XF86OptionPtr)option)->opt_used;
- else
- return FALSE;
-}
-
-Bool
-xf86CheckIfOptionUsedByName(pointer options, const char *name)
-{
- XF86OptionPtr opt;
-
- opt = xf86findOption(options, name);
- if (opt != NULL)
- return opt->opt_used;
- else
- return FALSE;
-}
-
-void
-xf86ShowUnusedOptions(int scrnIndex, pointer options)
-{
- XF86OptionPtr opt = options;
-
- while (opt) {
- if (opt->opt_name && !opt->opt_used) {
- xf86DrvMsg(scrnIndex, X_WARNING, "Option \"%s\" is not used\n",
- opt->opt_name);
- }
- opt = opt->list.next;
- }
-}
-
-
-static Bool
-GetBoolValue(OptionInfoPtr p, const char *s)
-{
- return xf86getBoolValue(&p->value.bool, s);
-}
-
-static Bool
-ParseOptionValue(int scrnIndex, pointer options, OptionInfoPtr p,
- Bool markUsed)
-{
- char *s, *end;
- Bool wasUsed = FALSE;
-
- if ((s = xf86findOptionValue(options, p->name)) != NULL) {
- if (markUsed) {
- wasUsed = xf86CheckIfOptionUsedByName(options, p->name);
- xf86MarkOptionUsedByName(options, p->name);
- }
- switch (p->type) {
- case OPTV_INTEGER:
- if (*s == '\0') {
- if (markUsed) {
- xf86DrvMsg(scrnIndex, X_WARNING,
- "Option \"%s\" requires an integer value\n",
- p->name);
- }
- p->found = FALSE;
- } else {
- p->value.num = strtoul(s, &end, 0);
- if (*end == '\0') {
- p->found = TRUE;
- } else {
- if (markUsed) {
- xf86DrvMsg(scrnIndex, X_WARNING,
- "Option \"%s\" requires an integer value\n",
- p->name);
- }
- p->found = FALSE;
- }
- }
- break;
- case OPTV_STRING:
- if (*s == '\0') {
- if (markUsed) {
- xf86DrvMsg(scrnIndex, X_WARNING,
- "Option \"%s\" requires an string value\n",
- p->name);
- }
- p->found = FALSE;
- } else {
- p->value.str = s;
- p->found = TRUE;
- }
- break;
- case OPTV_ANYSTR:
- p->value.str = s;
- p->found = TRUE;
- break;
- case OPTV_REAL:
- if (*s == '\0') {
- if (markUsed) {
- xf86DrvMsg(scrnIndex, X_WARNING,
- "Option \"%s\" requires a floating point "
- "value\n", p->name);
- }
- p->found = FALSE;
- } else {
- p->value.realnum = strtod(s, &end);
- if (*end == '\0') {
- p->found = TRUE;
- } else {
- if (markUsed) {
- xf86DrvMsg(scrnIndex, X_WARNING,
- "Option \"%s\" requires a floating point "
- "value\n", p->name);
- }
- p->found = FALSE;
- }
- }
- break;
- case OPTV_BOOLEAN:
- if (GetBoolValue(p, s)) {
- p->found = TRUE;
- } else {
- if (markUsed) {
- xf86DrvMsg(scrnIndex, X_WARNING,
- "Option \"%s\" requires a boolean value\n",
- p->name);
- }
- p->found = FALSE;
- }
- break;
- case OPTV_PERCENT:
- {
- char tmp = 0;
- /* awkward match, but %% doesn't increase the match counter,
- * hence 100 looks the same as 100% to the caller of sccanf
- */
- if (sscanf(s, "%lf%c", &p->value.realnum, &tmp) != 2 || tmp != '%') {
- if (markUsed) {
- xf86DrvMsg(scrnIndex, X_WARNING,
- "Option \"%s\" requires a percent value\n", p->name);
- }
- p->found = FALSE;
- } else {
- p->found = TRUE;
- }
- }
- break;
- case OPTV_FREQ:
- if (*s == '\0') {
- if (markUsed) {
- xf86DrvMsg(scrnIndex, X_WARNING,
- "Option \"%s\" requires a frequency value\n",
- p->name);
- }
- p->found = FALSE;
- } else {
- double freq = strtod(s, &end);
- int units = 0;
-
- if (end != s) {
- p->found = TRUE;
- if (!xf86NameCmp(end, "Hz"))
- units = 1;
- else if (!xf86NameCmp(end, "kHz") ||
- !xf86NameCmp(end, "k"))
- units = 1000;
- else if (!xf86NameCmp(end, "MHz") ||
- !xf86NameCmp(end, "M"))
- units = 1000000;
- else {
- if (markUsed) {
- xf86DrvMsg(scrnIndex, X_WARNING,
- "Option \"%s\" requires a frequency value\n",
- p->name);
- }
- p->found = FALSE;
- }
- if (p->found)
- freq *= (double)units;
- } else {
- if (markUsed) {
- xf86DrvMsg(scrnIndex, X_WARNING,
- "Option \"%s\" requires a frequency value\n",
- p->name);
- }
- p->found = FALSE;
- }
- if (p->found) {
- p->value.freq.freq = freq;
- p->value.freq.units = units;
- }
- }
- break;
- case OPTV_NONE:
- /* Should never get here */
- p->found = FALSE;
- break;
- }
- if (p->found && markUsed) {
- int verb = 2;
- if (wasUsed)
- verb = 4;
- xf86DrvMsgVerb(scrnIndex, X_CONFIG, verb, "Option \"%s\"", p->name);
- if (!(p->type == OPTV_BOOLEAN && *s == 0)) {
- xf86ErrorFVerb(verb, " \"%s\"", s);
- }
- xf86ErrorFVerb(verb, "\n");
- }
- } else if (p->type == OPTV_BOOLEAN) {
- /* Look for matches with options with or without a "No" prefix. */
- char *n, *newn;
- OptionInfoRec opt;
-
- n = xf86NormalizeName(p->name);
- if (!n) {
- p->found = FALSE;
- return FALSE;
- }
- if (strncmp(n, "no", 2) == 0) {
- newn = n + 2;
- } else {
- free(n);
- if (asprintf(&n, "No%s", p->name) == -1) {
- p->found = FALSE;
- return FALSE;
- }
- newn = n;
- }
- if ((s = xf86findOptionValue(options, newn)) != NULL) {
- if (markUsed)
- xf86MarkOptionUsedByName(options, newn);
- if (GetBoolValue(&opt, s)) {
- p->value.bool = !opt.value.bool;
- p->found = TRUE;
- } else {
- xf86DrvMsg(scrnIndex, X_WARNING,
- "Option \"%s\" requires a boolean value\n", newn);
- p->found = FALSE;
- }
- } else {
- p->found = FALSE;
- }
- if (p->found && markUsed) {
- xf86DrvMsgVerb(scrnIndex, X_CONFIG, 2, "Option \"%s\"", newn);
- if (*s != 0) {
- xf86ErrorFVerb(2, " \"%s\"", s);
- }
- xf86ErrorFVerb(2, "\n");
- }
- free(n);
- } else {
- p->found = FALSE;
- }
- return p->found;
-}
-
-
-void
-xf86ProcessOptions(int scrnIndex, pointer options, OptionInfoPtr optinfo)
-{
- OptionInfoPtr p;
-
- for (p = optinfo; p->name != NULL; p++) {
- ParseOptionValue(scrnIndex, options, p, TRUE);
- }
-}
-
-
-OptionInfoPtr
-xf86TokenToOptinfo(const OptionInfoRec *table, int token)
-{
- const OptionInfoRec *p, *match = NULL, *set = NULL;
-
- if (!table) {
- ErrorF("xf86TokenToOptinfo: table is NULL\n");
- return NULL;
- }
-
- for (p = table; p->token >= 0; p++) {
- if (p->token == token) {
- match = p;
- if (p->found)
- set = p;
- }
- }
-
- if (set)
- return (OptionInfoPtr)set;
- else if (match)
- return (OptionInfoPtr)match;
- else
- return NULL;
-}
-
-
-const char *
-xf86TokenToOptName(const OptionInfoRec *table, int token)
-{
- const OptionInfoRec *p;
-
- p = xf86TokenToOptinfo(table, token);
- return p->name;
-}
-
-
-Bool
-xf86IsOptionSet(const OptionInfoRec *table, int token)
-{
- OptionInfoPtr p;
-
- p = xf86TokenToOptinfo(table, token);
- return p && p->found;
-}
-
-
-char *
-xf86GetOptValString(const OptionInfoRec *table, int token)
-{
- OptionInfoPtr p;
-
- p = xf86TokenToOptinfo(table, token);
- if (p && p->found)
- return p->value.str;
- else
- return NULL;
-}
-
-
-Bool
-xf86GetOptValInteger(const OptionInfoRec *table, int token, int *value)
-{
- OptionInfoPtr p;
-
- p = xf86TokenToOptinfo(table, token);
- if (p && p->found) {
- *value = p->value.num;
- return TRUE;
- } else
- return FALSE;
-}
-
-
-Bool
-xf86GetOptValULong(const OptionInfoRec *table, int token, unsigned long *value)
-{
- OptionInfoPtr p;
-
- p = xf86TokenToOptinfo(table, token);
- if (p && p->found) {
- *value = p->value.num;
- return TRUE;
- } else
- return FALSE;
-}
-
-
-Bool
-xf86GetOptValReal(const OptionInfoRec *table, int token, double *value)
-{
- OptionInfoPtr p;
-
- p = xf86TokenToOptinfo(table, token);
- if (p && p->found) {
- *value = p->value.realnum;
- return TRUE;
- } else
- return FALSE;
-}
-
-
-Bool
-xf86GetOptValFreq(const OptionInfoRec *table, int token,
- OptFreqUnits expectedUnits, double *value)
-{
- OptionInfoPtr p;
-
- p = xf86TokenToOptinfo(table, token);
- if (p && p->found) {
- if (p->value.freq.units > 0) {
- /* Units give, so the scaling is known. */
- switch (expectedUnits) {
- case OPTUNITS_HZ:
- *value = p->value.freq.freq;
- break;
- case OPTUNITS_KHZ:
- *value = p->value.freq.freq / 1000.0;
- break;
- case OPTUNITS_MHZ:
- *value = p->value.freq.freq / 1000000.0;
- break;
- }
- } else {
- /* No units given, so try to guess the scaling. */
- switch (expectedUnits) {
- case OPTUNITS_HZ:
- *value = p->value.freq.freq;
- break;
- case OPTUNITS_KHZ:
- if (p->value.freq.freq > 1000.0)
- *value = p->value.freq.freq / 1000.0;
- else
- *value = p->value.freq.freq;
- break;
- case OPTUNITS_MHZ:
- if (p->value.freq.freq > 1000000.0)
- *value = p->value.freq.freq / 1000000.0;
- else if (p->value.freq.freq > 1000.0)
- *value = p->value.freq.freq / 1000.0;
- else
- *value = p->value.freq.freq;
- }
- }
- return TRUE;
- } else
- return FALSE;
-}
-
-
-Bool
-xf86GetOptValBool(const OptionInfoRec *table, int token, Bool *value)
-{
- OptionInfoPtr p;
-
- p = xf86TokenToOptinfo(table, token);
- if (p && p->found) {
- *value = p->value.bool;
- return TRUE;
- } else
- return FALSE;
-}
-
-
-Bool
-xf86ReturnOptValBool(const OptionInfoRec *table, int token, Bool def)
-{
- OptionInfoPtr p;
-
- p = xf86TokenToOptinfo(table, token);
- if (p && p->found) {
- return p->value.bool;
- } else
- return def;
-}
-
-
-int
-xf86NameCmp(const char *s1, const char *s2)
-{
- return xf86nameCompare(s1, s2);
-}
-
-char *
-xf86NormalizeName(const char *s)
-{
- char *ret, *q;
- const char *p;
-
- if (s == NULL)
- return NULL;
-
- ret = malloc(strlen(s) + 1);
- for (p = s, q = ret; *p != 0; p++) {
- switch (*p) {
- case '_':
- case ' ':
- case '\t':
- continue;
- default:
- if (isupper(*p))
- *q++ = tolower(*p);
- else
- *q++ = *p;
- }
- }
- *q = '\0';
- return ret;
-}
+/*
+ * Copyright (c) 1998-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).
+ */
+
+/*
+ * Author: David Dawes <dawes@xfree86.org>
+ *
+ * This file includes public option handling functions.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <stdlib.h>
+#include <ctype.h>
+#include <X11/X.h>
+#include "os.h"
+#include "xf86.h"
+#include "xf86Xinput.h"
+#include "xf86Optrec.h"
+#include "xf86Parser.h"
+
+static Bool ParseOptionValue(int scrnIndex, pointer options, OptionInfoPtr p,
+ Bool markUsed);
+
+/*
+ * xf86CollectOptions collects the options from each of the config file
+ * sections used by the screen and puts the combined list in pScrn->options.
+ * This function requires that the following have been initialised:
+ *
+ * pScrn->confScreen
+ * pScrn->Entities[i]->device
+ * pScrn->display
+ * pScrn->monitor
+ *
+ * The extraOpts parameter may optionally contain a list of additional options
+ * to include.
+ *
+ * The order of precedence for options is:
+ *
+ * extraOpts, display, confScreen, monitor, device
+ */
+
+void
+xf86CollectOptions(ScrnInfoPtr pScrn, pointer extraOpts)
+{
+ XF86OptionPtr tmp;
+ XF86OptionPtr extras = (XF86OptionPtr)extraOpts;
+ GDevPtr device;
+
+ int i;
+
+ pScrn->options = NULL;
+
+ for (i=pScrn->numEntities - 1; i >= 0; i--) {
+ device = xf86GetDevFromEntity(pScrn->entityList[i],
+ pScrn->entityInstanceList[i]);
+ if (device && device->options) {
+ tmp = xf86optionListDup(device->options);
+ if (pScrn->options)
+ xf86optionListMerge(pScrn->options,tmp);
+ else
+ pScrn->options = tmp;
+ }
+ }
+ if (pScrn->monitor->options) {
+ tmp = xf86optionListDup(pScrn->monitor->options);
+ if (pScrn->options)
+ pScrn->options = xf86optionListMerge(pScrn->options, tmp);
+ else
+ pScrn->options = tmp;
+ }
+ if (pScrn->confScreen->options) {
+ tmp = xf86optionListDup(pScrn->confScreen->options);
+ if (pScrn->options)
+ pScrn->options = xf86optionListMerge(pScrn->options, tmp);
+ else
+ pScrn->options = tmp;
+ }
+ if (pScrn->display->options) {
+ tmp = xf86optionListDup(pScrn->display->options);
+ if (pScrn->options)
+ pScrn->options = xf86optionListMerge(pScrn->options, tmp);
+ else
+ pScrn->options = tmp;
+ }
+ if (extras) {
+ tmp = xf86optionListDup(extras);
+ if (pScrn->options)
+ pScrn->options = xf86optionListMerge(pScrn->options, tmp);
+ else
+ pScrn->options = tmp;
+ }
+}
+
+/*
+ * xf86CollectInputOptions collects extra options for an InputDevice (other
+ * than those added by the config backend).
+ * The options are merged into the existing ones and thus take precedence
+ * over the others.
+ */
+
+void
+xf86CollectInputOptions(InputInfoPtr pInfo, const char **defaultOpts)
+{
+ if (defaultOpts) {
+ XF86OptionPtr tmp =xf86optionListCreate(defaultOpts, -1, 0);
+ if (pInfo->options)
+ pInfo->options = xf86optionListMerge(tmp, pInfo->options);
+ else
+ pInfo->options = tmp;
+ }
+}
+
+/**
+ * Duplicate the option list passed in. The returned pointer will be a newly
+ * allocated option list and must be freed by the caller.
+ */
+pointer
+xf86OptionListDuplicate(pointer options)
+{
+ pointer o = NULL;
+
+ while (options)
+ {
+ o = xf86AddNewOption(o, xf86OptionName(options), xf86OptionValue(options));
+ options = xf86nextOption(options);
+ }
+
+ return o;
+}
+
+
+/* Created for new XInput stuff -- essentially extensions to the parser */
+
+static int
+LookupIntOption(pointer optlist, const char *name, int deflt, Bool markUsed)
+{
+ OptionInfoRec o;
+
+ o.name = name;
+ o.type = OPTV_INTEGER;
+ if (ParseOptionValue(-1, optlist, &o, markUsed))
+ deflt = o.value.num;
+ return deflt;
+}
+
+
+static double
+LookupRealOption(pointer optlist, const char *name, double deflt,
+ Bool markUsed)
+{
+ OptionInfoRec o;
+
+ o.name = name;
+ o.type = OPTV_REAL;
+ if (ParseOptionValue(-1, optlist, &o, markUsed))
+ deflt = o.value.realnum;
+ return deflt;
+}
+
+
+static char *
+LookupStrOption(pointer optlist, const char *name, char *deflt, Bool markUsed)
+{
+ OptionInfoRec o;
+
+ o.name = name;
+ o.type = OPTV_STRING;
+ if (ParseOptionValue(-1, optlist, &o, markUsed))
+ deflt = o.value.str;
+ if (deflt)
+ return strdup(deflt);
+ else
+ return NULL;
+}
+
+
+static int
+LookupBoolOption(pointer optlist, const char *name, int deflt, Bool markUsed)
+{
+ OptionInfoRec o;
+
+ o.name = name;
+ o.type = OPTV_BOOLEAN;
+ if (ParseOptionValue(-1, optlist, &o, markUsed))
+ deflt = o.value.bool;
+ return deflt;
+}
+
+static double
+LookupPercentOption(pointer optlist, const char *name, double deflt, Bool markUsed)
+{
+ OptionInfoRec o;
+
+ o.name = name;
+ o.type = OPTV_PERCENT;
+ if (ParseOptionValue(-1, optlist, &o, markUsed))
+ deflt = o.value.realnum;
+ return deflt;
+}
+
+/* These xf86Set* functions are intended for use by non-screen specific code */
+
+int
+xf86SetIntOption(pointer optlist, const char *name, int deflt)
+{
+ return LookupIntOption(optlist, name, deflt, TRUE);
+}
+
+
+double
+xf86SetRealOption(pointer optlist, const char *name, double deflt)
+{
+ return LookupRealOption(optlist, name, deflt, TRUE);
+}
+
+
+char *
+xf86SetStrOption(pointer optlist, const char *name, char *deflt)
+{
+ return LookupStrOption(optlist, name, deflt, TRUE);
+}
+
+
+int
+xf86SetBoolOption(pointer optlist, const char *name, int deflt)
+{
+ return LookupBoolOption(optlist, name, deflt, TRUE);
+}
+
+double
+xf86SetPercentOption(pointer optlist, const char *name, double deflt)
+{
+ return LookupPercentOption(optlist, name, deflt, TRUE);
+}
+
+/*
+ * These are like the Set*Option functions, but they don't mark the options
+ * as used.
+ */
+int
+xf86CheckIntOption(pointer optlist, const char *name, int deflt)
+{
+ return LookupIntOption(optlist, name, deflt, FALSE);
+}
+
+
+double
+xf86CheckRealOption(pointer optlist, const char *name, double deflt)
+{
+ return LookupRealOption(optlist, name, deflt, FALSE);
+}
+
+
+char *
+xf86CheckStrOption(pointer optlist, const char *name, char *deflt)
+{
+ return LookupStrOption(optlist, name, deflt, FALSE);
+}
+
+
+int
+xf86CheckBoolOption(pointer optlist, const char *name, int deflt)
+{
+ return LookupBoolOption(optlist, name, deflt, FALSE);
+}
+
+
+double
+xf86CheckPercentOption(pointer optlist, const char *name, double deflt)
+{
+ return LookupPercentOption(optlist, name, deflt, FALSE);
+}
+/*
+ * addNewOption() has the required property of replacing the option value
+ * if the option is already present.
+ */
+pointer
+xf86ReplaceIntOption(pointer optlist, const char *name, const int val)
+{
+ char tmp[16];
+ sprintf(tmp,"%i",val);
+ return xf86AddNewOption(optlist,name,tmp);
+}
+
+pointer
+xf86ReplaceRealOption(pointer optlist, const char *name, const double val)
+{
+ char tmp[32];
+ snprintf(tmp,32,"%f",val);
+ return xf86AddNewOption(optlist,name,tmp);
+}
+
+pointer
+xf86ReplaceBoolOption(pointer optlist, const char *name, const Bool val)
+{
+ return xf86AddNewOption(optlist,name,val?"True":"False");
+}
+
+pointer
+xf86ReplacePercentOption(pointer optlist, const char *name, const double val)
+{
+ char tmp[16];
+ sprintf(tmp, "%lf%%", val);
+ return xf86AddNewOption(optlist,name,tmp);
+}
+
+pointer
+xf86ReplaceStrOption(pointer optlist, const char *name, const char* val)
+{
+ return xf86AddNewOption(optlist,name,val);
+}
+
+pointer
+xf86AddNewOption(pointer head, const char *name, const char *val)
+{
+ /* XXX These should actually be allocated in the parser library. */
+ char *tmp = val ? strdup(val) : NULL;
+ char *tmp_name = strdup(name);
+
+ return xf86addNewOption(head, tmp_name, tmp);
+}
+
+
+pointer
+xf86NewOption(char *name, char *value)
+{
+ return xf86newOption(name, value);
+}
+
+
+pointer
+xf86NextOption(pointer list)
+{
+ return xf86nextOption(list);
+}
+
+pointer
+xf86OptionListCreate(const char **options, int count, int used)
+{
+ return xf86optionListCreate(options, count, used);
+}
+
+pointer
+xf86OptionListMerge(pointer head, pointer tail)
+{
+ return xf86optionListMerge(head, tail);
+}
+
+void
+xf86OptionListFree(pointer opt)
+{
+ xf86optionListFree(opt);
+}
+
+char *
+xf86OptionName(pointer opt)
+{
+ return xf86optionName(opt);
+}
+
+char *
+xf86OptionValue(pointer opt)
+{
+ return xf86optionValue(opt);
+}
+
+void
+xf86OptionListReport(pointer parm)
+{
+ XF86OptionPtr opts = parm;
+
+ while(opts) {
+ if (xf86optionValue(opts))
+ xf86ErrorFVerb(5, "\tOption \"%s\" \"%s\"\n",
+ xf86optionName(opts), xf86optionValue(opts));
+ else
+ xf86ErrorFVerb( 5, "\tOption \"%s\"\n", xf86optionName(opts));
+ opts = xf86nextOption(opts);
+ }
+}
+
+/* End of XInput-caused section */
+
+pointer
+xf86FindOption(pointer options, const char *name)
+{
+ return xf86findOption(options, name);
+}
+
+
+char *
+xf86FindOptionValue(pointer options, const char *name)
+{
+ return xf86findOptionValue(options, name);
+}
+
+
+void
+xf86MarkOptionUsed(pointer option)
+{
+ if (option != NULL)
+ ((XF86OptionPtr)option)->opt_used = TRUE;
+}
+
+
+void
+xf86MarkOptionUsedByName(pointer options, const char *name)
+{
+ XF86OptionPtr opt;
+
+ opt = xf86findOption(options, name);
+ if (opt != NULL)
+ opt->opt_used = TRUE;
+}
+
+Bool
+xf86CheckIfOptionUsed(pointer option)
+{
+ if (option != NULL)
+ return ((XF86OptionPtr)option)->opt_used;
+ else
+ return FALSE;
+}
+
+Bool
+xf86CheckIfOptionUsedByName(pointer options, const char *name)
+{
+ XF86OptionPtr opt;
+
+ opt = xf86findOption(options, name);
+ if (opt != NULL)
+ return opt->opt_used;
+ else
+ return FALSE;
+}
+
+void
+xf86ShowUnusedOptions(int scrnIndex, pointer options)
+{
+ XF86OptionPtr opt = options;
+
+ while (opt) {
+ if (opt->opt_name && !opt->opt_used) {
+ xf86DrvMsg(scrnIndex, X_WARNING, "Option \"%s\" is not used\n",
+ opt->opt_name);
+ }
+ opt = opt->list.next;
+ }
+}
+
+
+static Bool
+GetBoolValue(OptionInfoPtr p, const char *s)
+{
+ return xf86getBoolValue(&p->value.bool, s);
+}
+
+static Bool
+ParseOptionValue(int scrnIndex, pointer options, OptionInfoPtr p,
+ Bool markUsed)
+{
+ char *s, *end;
+ Bool wasUsed = FALSE;
+
+ if ((s = xf86findOptionValue(options, p->name)) != NULL) {
+ if (markUsed) {
+ wasUsed = xf86CheckIfOptionUsedByName(options, p->name);
+ xf86MarkOptionUsedByName(options, p->name);
+ }
+ switch (p->type) {
+ case OPTV_INTEGER:
+ if (*s == '\0') {
+ if (markUsed) {
+ xf86DrvMsg(scrnIndex, X_WARNING,
+ "Option \"%s\" requires an integer value\n",
+ p->name);
+ }
+ p->found = FALSE;
+ } else {
+ p->value.num = strtoul(s, &end, 0);
+ if (*end == '\0') {
+ p->found = TRUE;
+ } else {
+ if (markUsed) {
+ xf86DrvMsg(scrnIndex, X_WARNING,
+ "Option \"%s\" requires an integer value\n",
+ p->name);
+ }
+ p->found = FALSE;
+ }
+ }
+ break;
+ case OPTV_STRING:
+ if (*s == '\0') {
+ if (markUsed) {
+ xf86DrvMsg(scrnIndex, X_WARNING,
+ "Option \"%s\" requires an string value\n",
+ p->name);
+ }
+ p->found = FALSE;
+ } else {
+ p->value.str = s;
+ p->found = TRUE;
+ }
+ break;
+ case OPTV_ANYSTR:
+ p->value.str = s;
+ p->found = TRUE;
+ break;
+ case OPTV_REAL:
+ if (*s == '\0') {
+ if (markUsed) {
+ xf86DrvMsg(scrnIndex, X_WARNING,
+ "Option \"%s\" requires a floating point "
+ "value\n", p->name);
+ }
+ p->found = FALSE;
+ } else {
+ p->value.realnum = strtod(s, &end);
+ if (*end == '\0') {
+ p->found = TRUE;
+ } else {
+ if (markUsed) {
+ xf86DrvMsg(scrnIndex, X_WARNING,
+ "Option \"%s\" requires a floating point "
+ "value\n", p->name);
+ }
+ p->found = FALSE;
+ }
+ }
+ break;
+ case OPTV_BOOLEAN:
+ if (GetBoolValue(p, s)) {
+ p->found = TRUE;
+ } else {
+ if (markUsed) {
+ xf86DrvMsg(scrnIndex, X_WARNING,
+ "Option \"%s\" requires a boolean value\n",
+ p->name);
+ }
+ p->found = FALSE;
+ }
+ break;
+ case OPTV_PERCENT:
+ {
+ char tmp = 0;
+ /* awkward match, but %% doesn't increase the match counter,
+ * hence 100 looks the same as 100% to the caller of sccanf
+ */
+ if (sscanf(s, "%lf%c", &p->value.realnum, &tmp) != 2 || tmp != '%') {
+ if (markUsed) {
+ xf86DrvMsg(scrnIndex, X_WARNING,
+ "Option \"%s\" requires a percent value\n", p->name);
+ }
+ p->found = FALSE;
+ } else {
+ p->found = TRUE;
+ }
+ }
+ break;
+ case OPTV_FREQ:
+ if (*s == '\0') {
+ if (markUsed) {
+ xf86DrvMsg(scrnIndex, X_WARNING,
+ "Option \"%s\" requires a frequency value\n",
+ p->name);
+ }
+ p->found = FALSE;
+ } else {
+ double freq = strtod(s, &end);
+ int units = 0;
+
+ if (end != s) {
+ p->found = TRUE;
+ if (!xf86NameCmp(end, "Hz"))
+ units = 1;
+ else if (!xf86NameCmp(end, "kHz") ||
+ !xf86NameCmp(end, "k"))
+ units = 1000;
+ else if (!xf86NameCmp(end, "MHz") ||
+ !xf86NameCmp(end, "M"))
+ units = 1000000;
+ else {
+ if (markUsed) {
+ xf86DrvMsg(scrnIndex, X_WARNING,
+ "Option \"%s\" requires a frequency value\n",
+ p->name);
+ }
+ p->found = FALSE;
+ }
+ if (p->found)
+ freq *= (double)units;
+ } else {
+ if (markUsed) {
+ xf86DrvMsg(scrnIndex, X_WARNING,
+ "Option \"%s\" requires a frequency value\n",
+ p->name);
+ }
+ p->found = FALSE;
+ }
+ if (p->found) {
+ p->value.freq.freq = freq;
+ p->value.freq.units = units;
+ }
+ }
+ break;
+ case OPTV_NONE:
+ /* Should never get here */
+ p->found = FALSE;
+ break;
+ }
+ if (p->found && markUsed) {
+ int verb = 2;
+ if (wasUsed)
+ verb = 4;
+ xf86DrvMsgVerb(scrnIndex, X_CONFIG, verb, "Option \"%s\"", p->name);
+ if (!(p->type == OPTV_BOOLEAN && *s == 0)) {
+ xf86ErrorFVerb(verb, " \"%s\"", s);
+ }
+ xf86ErrorFVerb(verb, "\n");
+ }
+ } else if (p->type == OPTV_BOOLEAN) {
+ /* Look for matches with options with or without a "No" prefix. */
+ char *n, *newn;
+ OptionInfoRec opt;
+
+ n = xf86NormalizeName(p->name);
+ if (!n) {
+ p->found = FALSE;
+ return FALSE;
+ }
+ if (strncmp(n, "no", 2) == 0) {
+ newn = n + 2;
+ } else {
+ free(n);
+ if (asprintf(&n, "No%s", p->name) == -1) {
+ p->found = FALSE;
+ return FALSE;
+ }
+ newn = n;
+ }
+ if ((s = xf86findOptionValue(options, newn)) != NULL) {
+ if (markUsed)
+ xf86MarkOptionUsedByName(options, newn);
+ if (GetBoolValue(&opt, s)) {
+ p->value.bool = !opt.value.bool;
+ p->found = TRUE;
+ } else {
+ xf86DrvMsg(scrnIndex, X_WARNING,
+ "Option \"%s\" requires a boolean value\n", newn);
+ p->found = FALSE;
+ }
+ } else {
+ p->found = FALSE;
+ }
+ if (p->found && markUsed) {
+ xf86DrvMsgVerb(scrnIndex, X_CONFIG, 2, "Option \"%s\"", newn);
+ if (*s != 0) {
+ xf86ErrorFVerb(2, " \"%s\"", s);
+ }
+ xf86ErrorFVerb(2, "\n");
+ }
+ free(n);
+ } else {
+ p->found = FALSE;
+ }
+ return p->found;
+}
+
+
+void
+xf86ProcessOptions(int scrnIndex, pointer options, OptionInfoPtr optinfo)
+{
+ OptionInfoPtr p;
+
+ for (p = optinfo; p->name != NULL; p++) {
+ ParseOptionValue(scrnIndex, options, p, TRUE);
+ }
+}
+
+
+OptionInfoPtr
+xf86TokenToOptinfo(const OptionInfoRec *table, int token)
+{
+ const OptionInfoRec *p, *match = NULL, *set = NULL;
+
+ if (!table) {
+ ErrorF("xf86TokenToOptinfo: table is NULL\n");
+ return NULL;
+ }
+
+ for (p = table; p->token >= 0; p++) {
+ if (p->token == token) {
+ match = p;
+ if (p->found)
+ set = p;
+ }
+ }
+
+ if (set)
+ return (OptionInfoPtr)set;
+ else if (match)
+ return (OptionInfoPtr)match;
+ else
+ return NULL;
+}
+
+
+const char *
+xf86TokenToOptName(const OptionInfoRec *table, int token)
+{
+ const OptionInfoRec *p;
+
+ p = xf86TokenToOptinfo(table, token);
+ return p->name;
+}
+
+
+Bool
+xf86IsOptionSet(const OptionInfoRec *table, int token)
+{
+ OptionInfoPtr p;
+
+ p = xf86TokenToOptinfo(table, token);
+ return p && p->found;
+}
+
+
+char *
+xf86GetOptValString(const OptionInfoRec *table, int token)
+{
+ OptionInfoPtr p;
+
+ p = xf86TokenToOptinfo(table, token);
+ if (p && p->found)
+ return p->value.str;
+ else
+ return NULL;
+}
+
+
+Bool
+xf86GetOptValInteger(const OptionInfoRec *table, int token, int *value)
+{
+ OptionInfoPtr p;
+
+ p = xf86TokenToOptinfo(table, token);
+ if (p && p->found) {
+ *value = p->value.num;
+ return TRUE;
+ } else
+ return FALSE;
+}
+
+
+Bool
+xf86GetOptValULong(const OptionInfoRec *table, int token, unsigned long *value)
+{
+ OptionInfoPtr p;
+
+ p = xf86TokenToOptinfo(table, token);
+ if (p && p->found) {
+ *value = p->value.num;
+ return TRUE;
+ } else
+ return FALSE;
+}
+
+
+Bool
+xf86GetOptValReal(const OptionInfoRec *table, int token, double *value)
+{
+ OptionInfoPtr p;
+
+ p = xf86TokenToOptinfo(table, token);
+ if (p && p->found) {
+ *value = p->value.realnum;
+ return TRUE;
+ } else
+ return FALSE;
+}
+
+
+Bool
+xf86GetOptValFreq(const OptionInfoRec *table, int token,
+ OptFreqUnits expectedUnits, double *value)
+{
+ OptionInfoPtr p;
+
+ p = xf86TokenToOptinfo(table, token);
+ if (p && p->found) {
+ if (p->value.freq.units > 0) {
+ /* Units give, so the scaling is known. */
+ switch (expectedUnits) {
+ case OPTUNITS_HZ:
+ *value = p->value.freq.freq;
+ break;
+ case OPTUNITS_KHZ:
+ *value = p->value.freq.freq / 1000.0;
+ break;
+ case OPTUNITS_MHZ:
+ *value = p->value.freq.freq / 1000000.0;
+ break;
+ }
+ } else {
+ /* No units given, so try to guess the scaling. */
+ switch (expectedUnits) {
+ case OPTUNITS_HZ:
+ *value = p->value.freq.freq;
+ break;
+ case OPTUNITS_KHZ:
+ if (p->value.freq.freq > 1000.0)
+ *value = p->value.freq.freq / 1000.0;
+ else
+ *value = p->value.freq.freq;
+ break;
+ case OPTUNITS_MHZ:
+ if (p->value.freq.freq > 1000000.0)
+ *value = p->value.freq.freq / 1000000.0;
+ else if (p->value.freq.freq > 1000.0)
+ *value = p->value.freq.freq / 1000.0;
+ else
+ *value = p->value.freq.freq;
+ }
+ }
+ return TRUE;
+ } else
+ return FALSE;
+}
+
+
+Bool
+xf86GetOptValBool(const OptionInfoRec *table, int token, Bool *value)
+{
+ OptionInfoPtr p;
+
+ p = xf86TokenToOptinfo(table, token);
+ if (p && p->found) {
+ *value = p->value.bool;
+ return TRUE;
+ } else
+ return FALSE;
+}
+
+
+Bool
+xf86ReturnOptValBool(const OptionInfoRec *table, int token, Bool def)
+{
+ OptionInfoPtr p;
+
+ p = xf86TokenToOptinfo(table, token);
+ if (p && p->found) {
+ return p->value.bool;
+ } else
+ return def;
+}
+
+
+int
+xf86NameCmp(const char *s1, const char *s2)
+{
+ return xf86nameCompare(s1, s2);
+}
+
+char *
+xf86NormalizeName(const char *s)
+{
+ char *ret, *q;
+ const char *p;
+
+ if (s == NULL)
+ return NULL;
+
+ ret = malloc(strlen(s) + 1);
+ for (p = s, q = ret; *p != 0; p++) {
+ switch (*p) {
+ case '_':
+ case ' ':
+ case '\t':
+ continue;
+ default:
+ if (isupper(*p))
+ *q++ = tolower(*p);
+ else
+ *q++ = *p;
+ }
+ }
+ *q = '\0';
+ return ret;
+}
diff --git a/xorg-server/hw/xfree86/common/xf86Priv.h b/xorg-server/hw/xfree86/common/xf86Priv.h
index 436594ba6..1fe3d7e0d 100644
--- a/xorg-server/hw/xfree86/common/xf86Priv.h
+++ b/xorg-server/hw/xfree86/common/xf86Priv.h
@@ -1,154 +1,154 @@
-/*
- * Copyright (c) 1997-2002 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).
- */
-
-/*
- * This file contains declarations for private XFree86 functions and variables,
- * and definitions of private macros.
- *
- * "private" means not available to video drivers.
- */
-
-#ifndef _XF86PRIV_H
-#define _XF86PRIV_H
-
-#include "xf86Privstr.h"
-#include "propertyst.h"
-#include "input.h"
-
-/*
- * Parameters set ONLY from the command line options
- * The global state of these things is held in xf86InfoRec (when appropriate).
- */
-extern _X_EXPORT const char *xf86ConfigFile;
-extern _X_EXPORT const char *xf86ConfigDir;
-extern _X_EXPORT Bool xf86AllowMouseOpenFail;
-#ifdef XF86VIDMODE
-extern _X_EXPORT Bool xf86VidModeDisabled;
-extern _X_EXPORT Bool xf86VidModeAllowNonLocal;
-#endif
-extern _X_EXPORT Bool xf86fpFlag;
-extern _X_EXPORT Bool xf86sFlag;
-extern _X_EXPORT Bool xf86bsEnableFlag;
-extern _X_EXPORT Bool xf86bsDisableFlag;
-extern _X_EXPORT Bool xf86silkenMouseDisableFlag;
-extern _X_EXPORT Bool xf86xkbdirFlag;
-#ifdef HAVE_ACPI
-extern _X_EXPORT Bool xf86acpiDisableFlag;
-#endif
-extern _X_EXPORT char *xf86LayoutName;
-extern _X_EXPORT char *xf86ScreenName;
-extern _X_EXPORT char *xf86PointerName;
-extern _X_EXPORT char *xf86KeyboardName;
-extern _X_EXPORT int xf86FbBpp;
-extern _X_EXPORT int xf86Depth;
-extern _X_EXPORT Pix24Flags xf86Pix24;
-extern _X_EXPORT rgb xf86Weight;
-extern _X_EXPORT Bool xf86FlipPixels;
-extern _X_EXPORT Gamma xf86Gamma;
-extern _X_EXPORT char *xf86ServerName;
-
-/* Other parameters */
-
-extern _X_EXPORT xf86InfoRec xf86Info;
-extern _X_EXPORT const char *xf86ModulePath;
-extern _X_EXPORT MessageType xf86ModPathFrom;
-extern _X_EXPORT const char *xf86LogFile;
-extern _X_EXPORT MessageType xf86LogFileFrom;
-extern _X_EXPORT Bool xf86LogFileWasOpened;
-extern _X_EXPORT serverLayoutRec xf86ConfigLayout;
-
-extern _X_EXPORT DriverPtr *xf86DriverList;
-extern _X_EXPORT int xf86NumDrivers;
-extern _X_EXPORT Bool xf86Resetting;
-extern _X_EXPORT Bool xf86Initialising;
-extern _X_EXPORT int xf86NumScreens;
-extern _X_EXPORT const char *xf86VisualNames[];
-extern _X_EXPORT int xf86Verbose; /* verbosity level */
-extern _X_EXPORT int xf86LogVerbose; /* log file verbosity level */
-extern _X_EXPORT Bool xorgHWAccess;
-
-extern _X_EXPORT RootWinPropPtr *xf86RegisteredPropertiesTable;
-
-#ifndef DEFAULT_VERBOSE
-#define DEFAULT_VERBOSE 0
-#endif
-#ifndef DEFAULT_LOG_VERBOSE
-#define DEFAULT_LOG_VERBOSE 3
-#endif
-#ifndef DEFAULT_DPI
-#define DEFAULT_DPI 96
-#endif
-
-/* Function Prototypes */
-#ifndef _NO_XF86_PROTOTYPES
-
-/* xf86Bus.c */
-extern _X_EXPORT Bool xf86BusConfig(void);
-extern _X_EXPORT void xf86BusProbe(void);
-extern _X_EXPORT void xf86AccessEnter(void);
-extern _X_EXPORT void xf86AccessLeave(void);
-extern _X_EXPORT void xf86PostProbe(void);
-extern _X_EXPORT void xf86ClearEntityListForScreen(int scrnIndex);
-extern _X_EXPORT void xf86AddDevToEntity(int entityIndex, GDevPtr dev);
-
-/* xf86Config.c */
-
-extern _X_EXPORT Bool xf86PathIsSafe(const char *path);
-
-/* xf86DefaultModes */
-
-extern _X_EXPORT const DisplayModeRec xf86DefaultModes[];
-extern _X_EXPORT const int xf86NumDefaultModes;
-
-/* xf86Configure.c */
-extern _X_EXPORT void DoConfigure(void);
-
-/* xf86ShowOpts.c */
-extern _X_EXPORT void DoShowOptions(void);
-
-/* xf86Events.c */
-
-extern _X_EXPORT void xf86Wakeup(pointer blockData, int err, pointer pReadmask);
-extern _X_HIDDEN int xf86SigWrapper(int signo);
-extern _X_EXPORT void xf86HandlePMEvents(int fd, pointer data);
-extern _X_EXPORT int (*xf86PMGetEventFromOs)(int fd,pmEvent *events,int num);
-extern _X_EXPORT pmWait (*xf86PMConfirmEventToOs)(int fd,pmEvent event);
-
-/* xf86Helper.c */
-extern _X_EXPORT void xf86LogInit(void);
-extern _X_EXPORT void xf86CloseLog(enum ExitCode error);
-
-/* xf86Init.c */
-extern _X_EXPORT Bool xf86LoadModules(char **list, pointer *optlist);
-extern _X_EXPORT int xf86SetVerbosity(int verb);
-extern _X_EXPORT int xf86SetLogVerbosity(int verb);
-extern _X_EXPORT Bool xf86CallDriverProbe( struct _DriverRec * drv, Bool detect_only );
-
-#endif /* _NO_XF86_PROTOTYPES */
-
-
-#endif /* _XF86PRIV_H */
+/*
+ * Copyright (c) 1997-2002 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).
+ */
+
+/*
+ * This file contains declarations for private XFree86 functions and variables,
+ * and definitions of private macros.
+ *
+ * "private" means not available to video drivers.
+ */
+
+#ifndef _XF86PRIV_H
+#define _XF86PRIV_H
+
+#include "xf86Privstr.h"
+#include "propertyst.h"
+#include "input.h"
+
+/*
+ * Parameters set ONLY from the command line options
+ * The global state of these things is held in xf86InfoRec (when appropriate).
+ */
+extern _X_EXPORT const char *xf86ConfigFile;
+extern _X_EXPORT const char *xf86ConfigDir;
+extern _X_EXPORT Bool xf86AllowMouseOpenFail;
+#ifdef XF86VIDMODE
+extern _X_EXPORT Bool xf86VidModeDisabled;
+extern _X_EXPORT Bool xf86VidModeAllowNonLocal;
+#endif
+extern _X_EXPORT Bool xf86fpFlag;
+extern _X_EXPORT Bool xf86sFlag;
+extern _X_EXPORT Bool xf86bsEnableFlag;
+extern _X_EXPORT Bool xf86bsDisableFlag;
+extern _X_EXPORT Bool xf86silkenMouseDisableFlag;
+extern _X_EXPORT Bool xf86xkbdirFlag;
+#ifdef HAVE_ACPI
+extern _X_EXPORT Bool xf86acpiDisableFlag;
+#endif
+extern _X_EXPORT char *xf86LayoutName;
+extern _X_EXPORT char *xf86ScreenName;
+extern _X_EXPORT char *xf86PointerName;
+extern _X_EXPORT char *xf86KeyboardName;
+extern _X_EXPORT int xf86FbBpp;
+extern _X_EXPORT int xf86Depth;
+extern _X_EXPORT Pix24Flags xf86Pix24;
+extern _X_EXPORT rgb xf86Weight;
+extern _X_EXPORT Bool xf86FlipPixels;
+extern _X_EXPORT Gamma xf86Gamma;
+extern _X_EXPORT char *xf86ServerName;
+
+/* Other parameters */
+
+extern _X_EXPORT xf86InfoRec xf86Info;
+extern _X_EXPORT const char *xf86ModulePath;
+extern _X_EXPORT MessageType xf86ModPathFrom;
+extern _X_EXPORT const char *xf86LogFile;
+extern _X_EXPORT MessageType xf86LogFileFrom;
+extern _X_EXPORT Bool xf86LogFileWasOpened;
+extern _X_EXPORT serverLayoutRec xf86ConfigLayout;
+
+extern _X_EXPORT DriverPtr *xf86DriverList;
+extern _X_EXPORT int xf86NumDrivers;
+extern _X_EXPORT Bool xf86Resetting;
+extern _X_EXPORT Bool xf86Initialising;
+extern _X_EXPORT int xf86NumScreens;
+extern _X_EXPORT const char *xf86VisualNames[];
+extern _X_EXPORT int xf86Verbose; /* verbosity level */
+extern _X_EXPORT int xf86LogVerbose; /* log file verbosity level */
+extern _X_EXPORT Bool xorgHWAccess;
+
+extern _X_EXPORT RootWinPropPtr *xf86RegisteredPropertiesTable;
+
+#ifndef DEFAULT_VERBOSE
+#define DEFAULT_VERBOSE 0
+#endif
+#ifndef DEFAULT_LOG_VERBOSE
+#define DEFAULT_LOG_VERBOSE 3
+#endif
+#ifndef DEFAULT_DPI
+#define DEFAULT_DPI 96
+#endif
+
+/* Function Prototypes */
+#ifndef _NO_XF86_PROTOTYPES
+
+/* xf86Bus.c */
+extern _X_EXPORT Bool xf86BusConfig(void);
+extern _X_EXPORT void xf86BusProbe(void);
+extern _X_EXPORT void xf86AccessEnter(void);
+extern _X_EXPORT void xf86AccessLeave(void);
+extern _X_EXPORT void xf86PostProbe(void);
+extern _X_EXPORT void xf86ClearEntityListForScreen(int scrnIndex);
+extern _X_EXPORT void xf86AddDevToEntity(int entityIndex, GDevPtr dev);
+
+/* xf86Config.c */
+
+extern _X_EXPORT Bool xf86PathIsSafe(const char *path);
+
+/* xf86DefaultModes */
+
+extern _X_EXPORT const DisplayModeRec xf86DefaultModes[];
+extern _X_EXPORT const int xf86NumDefaultModes;
+
+/* xf86Configure.c */
+extern _X_EXPORT void DoConfigure(void);
+
+/* xf86ShowOpts.c */
+extern _X_EXPORT void DoShowOptions(void);
+
+/* xf86Events.c */
+
+extern _X_EXPORT void xf86Wakeup(pointer blockData, int err, pointer pReadmask);
+extern _X_HIDDEN int xf86SigWrapper(int signo);
+extern _X_EXPORT void xf86HandlePMEvents(int fd, pointer data);
+extern _X_EXPORT int (*xf86PMGetEventFromOs)(int fd,pmEvent *events,int num);
+extern _X_EXPORT pmWait (*xf86PMConfirmEventToOs)(int fd,pmEvent event);
+
+/* xf86Helper.c */
+extern _X_EXPORT void xf86LogInit(void);
+extern _X_EXPORT void xf86CloseLog(enum ExitCode error);
+
+/* xf86Init.c */
+extern _X_EXPORT Bool xf86LoadModules(char **list, pointer *optlist);
+extern _X_EXPORT int xf86SetVerbosity(int verb);
+extern _X_EXPORT int xf86SetLogVerbosity(int verb);
+extern _X_EXPORT Bool xf86CallDriverProbe( struct _DriverRec * drv, Bool detect_only );
+
+#endif /* _NO_XF86_PROTOTYPES */
+
+
+#endif /* _XF86PRIV_H */
diff --git a/xorg-server/hw/xfree86/common/xf86RandR.c b/xorg-server/hw/xfree86/common/xf86RandR.c
index e8e5a3696..4663d0366 100644
--- a/xorg-server/hw/xfree86/common/xf86RandR.c
+++ b/xorg-server/hw/xfree86/common/xf86RandR.c
@@ -1,485 +1,485 @@
-/*
- *
- * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
- *
- * 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 Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Keith Packard makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD 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_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include "os.h"
-#include "globals.h"
-#include "xf86.h"
-#include "xf86str.h"
-#include "xf86Priv.h"
-#include "xf86DDC.h"
-#include "mipointer.h"
-#include <randrstr.h>
-#include "inputstr.h"
-
-typedef struct _xf86RandRInfo {
- CreateScreenResourcesProcPtr CreateScreenResources;
- CloseScreenProcPtr CloseScreen;
- int virtualX;
- int virtualY;
- int mmWidth;
- int mmHeight;
- Rotation rotation;
-} XF86RandRInfoRec, *XF86RandRInfoPtr;
-
-static DevPrivateKeyRec xf86RandRKeyRec;
-static DevPrivateKey xf86RandRKey;
-
-#define XF86RANDRINFO(p) ((XF86RandRInfoPtr)dixLookupPrivate(&(p)->devPrivates, xf86RandRKey))
-
-static int
-xf86RandRModeRefresh (DisplayModePtr mode)
-{
- if (mode->VRefresh)
- return (int) (mode->VRefresh + 0.5);
- else if (mode->Clock == 0)
- return 0;
- else
- return (int) (mode->Clock * 1000.0 / mode->HTotal / mode->VTotal + 0.5);
-}
-
-static Bool
-xf86RandRGetInfo (ScreenPtr pScreen, Rotation *rotations)
-{
- RRScreenSizePtr pSize;
- ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
- XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
- DisplayModePtr mode;
- int refresh0 = 60;
- xorgRRModeMM RRModeMM;
-
- *rotations = RR_Rotate_0;
-
- for (mode = scrp->modes; mode != NULL ; mode = mode->next)
- {
- int refresh = xf86RandRModeRefresh (mode);
-
- if (mode == scrp->modes)
- refresh0 = refresh;
-
- RRModeMM.mode = mode;
- RRModeMM.virtX = randrp->virtualX;
- RRModeMM.virtY = randrp->virtualY;
- RRModeMM.mmWidth = randrp->mmWidth;
- RRModeMM.mmHeight = randrp->mmHeight;
-
- if(scrp->DriverFunc) {
- (*scrp->DriverFunc)(scrp, RR_GET_MODE_MM, &RRModeMM);
- }
-
- pSize = RRRegisterSize (pScreen,
- mode->HDisplay, mode->VDisplay,
- RRModeMM.mmWidth, RRModeMM.mmHeight);
- if (!pSize)
- return FALSE;
- RRRegisterRate (pScreen, pSize, refresh);
- if (mode == scrp->currentMode &&
- mode->HDisplay == scrp->virtualX && mode->VDisplay == scrp->virtualY)
- RRSetCurrentConfig (pScreen, randrp->rotation, refresh, pSize);
- if (mode->next == scrp->modes)
- break;
- }
- if (scrp->currentMode->HDisplay != randrp->virtualX ||
- scrp->currentMode->VDisplay != randrp->virtualY)
- {
- mode = scrp->modes;
-
- RRModeMM.mode = NULL;
- RRModeMM.virtX = randrp->virtualX;
- RRModeMM.virtY = randrp->virtualY;
- RRModeMM.mmWidth = randrp->mmWidth;
- RRModeMM.mmHeight = randrp->mmHeight;
-
- if(scrp->DriverFunc) {
- (*scrp->DriverFunc)(scrp, RR_GET_MODE_MM, &RRModeMM);
- }
-
- pSize = RRRegisterSize (pScreen,
- randrp->virtualX, randrp->virtualY,
- RRModeMM.mmWidth, RRModeMM.mmHeight);
- if (!pSize)
- return FALSE;
- RRRegisterRate (pScreen, pSize, refresh0);
- if (scrp->virtualX == randrp->virtualX &&
- scrp->virtualY == randrp->virtualY)
- {
- RRSetCurrentConfig (pScreen, randrp->rotation, refresh0, pSize);
- }
- }
-
- /* If there is driver support for randr, let it set our supported rotations */
- if(scrp->DriverFunc) {
- xorgRRRotation RRRotation;
-
- RRRotation.RRRotations = *rotations;
- if (!(*scrp->DriverFunc)(scrp, RR_GET_INFO, &RRRotation))
- return TRUE;
- *rotations = RRRotation.RRRotations;
- }
-
- return TRUE;
-}
-
-static Bool
-xf86RandRSetMode (ScreenPtr pScreen,
- DisplayModePtr mode,
- Bool useVirtual,
- int mmWidth,
- int mmHeight)
-{
- ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
- XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
- int oldWidth = pScreen->width;
- int oldHeight = pScreen->height;
- int oldmmWidth = pScreen->mmWidth;
- int oldmmHeight = pScreen->mmHeight;
- int oldVirtualX = scrp->virtualX;
- int oldVirtualY = scrp->virtualY;
- WindowPtr pRoot = pScreen->root;
- Bool ret = TRUE;
-
- if (pRoot && scrp->vtSema)
- (*scrp->EnableDisableFBAccess) (pScreen->myNum, FALSE);
- if (useVirtual)
- {
- scrp->virtualX = randrp->virtualX;
- scrp->virtualY = randrp->virtualY;
- }
- else
- {
- scrp->virtualX = mode->HDisplay;
- scrp->virtualY = mode->VDisplay;
- }
-
- /*
- * The DIX forgets the physical dimensions we passed into RRRegisterSize, so
- * reconstruct them if possible.
- */
- if(scrp->DriverFunc) {
- xorgRRModeMM RRModeMM;
-
- RRModeMM.mode = mode;
- RRModeMM.virtX = scrp->virtualX;
- RRModeMM.virtY = scrp->virtualY;
- RRModeMM.mmWidth = mmWidth;
- RRModeMM.mmHeight = mmHeight;
-
- (*scrp->DriverFunc)(scrp, RR_GET_MODE_MM, &RRModeMM);
-
- mmWidth = RRModeMM.mmWidth;
- mmHeight = RRModeMM.mmHeight;
- }
- if(randrp->rotation & (RR_Rotate_90 | RR_Rotate_270))
- {
- /* If the screen is rotated 90 or 270 degrees, swap the sizes. */
- pScreen->width = scrp->virtualY;
- pScreen->height = scrp->virtualX;
- pScreen->mmWidth = mmHeight;
- pScreen->mmHeight = mmWidth;
- }
- else
- {
- pScreen->width = scrp->virtualX;
- pScreen->height = scrp->virtualY;
- pScreen->mmWidth = mmWidth;
- pScreen->mmHeight = mmHeight;
- }
- if (!xf86SwitchMode (pScreen, mode))
- {
- pScreen->width = oldWidth;
- pScreen->height = oldHeight;
- pScreen->mmWidth = oldmmWidth;
- pScreen->mmHeight = oldmmHeight;
- scrp->virtualX = oldVirtualX;
- scrp->virtualY = oldVirtualY;
- ret = FALSE;
- }
- /*
- * Make sure the layout is correct
- */
- xf86ReconfigureLayout();
-
- /*
- * Make sure the whole screen is visible
- */
- xf86SetViewport (pScreen, pScreen->width, pScreen->height);
- xf86SetViewport (pScreen, 0, 0);
- if (pRoot && scrp->vtSema)
- (*scrp->EnableDisableFBAccess) (pScreen->myNum, TRUE);
- return ret;
-}
-
-static Bool
-xf86RandRSetConfig (ScreenPtr pScreen,
- Rotation rotation,
- int rate,
- RRScreenSizePtr pSize)
-{
- ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
- XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
- DisplayModePtr mode;
- int pos[MAXDEVICES][2];
- Bool useVirtual = FALSE;
- Rotation oldRotation = randrp->rotation;
- DeviceIntPtr dev;
- Bool view_adjusted = FALSE;
-
- for (dev = inputInfo.devices; dev; dev = dev->next)
- {
- if (!IsMaster(dev) && !IsFloating(dev))
- continue;
-
- miPointerGetPosition(dev, &pos[dev->id][0], &pos[dev->id][1]);
- }
-
- for (mode = scrp->modes; ; mode = mode->next)
- {
- if (mode->HDisplay == pSize->width &&
- mode->VDisplay == pSize->height &&
- (rate == 0 || xf86RandRModeRefresh (mode) == rate))
- break;
- if (mode->next == scrp->modes)
- {
- if (pSize->width == randrp->virtualX &&
- pSize->height == randrp->virtualY)
- {
- mode = scrp->modes;
- useVirtual = TRUE;
- break;
- }
- return FALSE;
- }
- }
-
- if (randrp->rotation != rotation) {
-
- /* Have the driver do its thing. */
- if (scrp->DriverFunc) {
- xorgRRRotation RRRotation;
- RRRotation.RRConfig.rotation = rotation;
- RRRotation.RRConfig.rate = rate;
- RRRotation.RRConfig.width = pSize->width;
- RRRotation.RRConfig.height = pSize->height;
-
- /*
- * Currently we need to rely on HW support for rotation.
- */
- if (!(*scrp->DriverFunc)(scrp, RR_SET_CONFIG, &RRRotation))
- return FALSE;
- } else
- return FALSE;
-
- randrp->rotation = rotation;
- }
-
- if (!xf86RandRSetMode (pScreen, mode, useVirtual, pSize->mmWidth, pSize->mmHeight)) {
- if(randrp->rotation != oldRotation) {
- /* Have the driver undo its thing. */
- if (scrp->DriverFunc) {
- xorgRRRotation RRRotation;
- RRRotation.RRConfig.rotation = oldRotation;
- RRRotation.RRConfig.rate = xf86RandRModeRefresh (scrp->currentMode);
- RRRotation.RRConfig.width = scrp->virtualX;
- RRRotation.RRConfig.height = scrp->virtualY;
- (*scrp->DriverFunc)(scrp, RR_SET_CONFIG, &RRRotation);
- }
-
- randrp->rotation = oldRotation;
- }
- return FALSE;
- }
-
- /*
- * Move the cursor back where it belongs; SwitchMode repositions it
- * FIXME: duplicated code, see modes/xf86RandR12.c
- */
- for (dev = inputInfo.devices; dev; dev = dev->next)
- {
- if (!IsMaster(dev) && !IsFloating(dev))
- continue;
-
- if (pScreen == miPointerGetScreen(dev)) {
- int px = pos[dev->id][0];
- int py = pos[dev->id][1];
-
- px = (px >= pScreen->width ? (pScreen->width - 1) : px);
- py = (py >= pScreen->height ? (pScreen->height - 1) : py);
-
- /* Setting the viewpoint makes only sense on one device */
- if (!view_adjusted && IsMaster(dev)) {
- xf86SetViewport(pScreen, px, py);
- view_adjusted = TRUE;
- }
-
- (*pScreen->SetCursorPosition) (dev, pScreen, px, py, FALSE);
- }
- }
-
- return TRUE;
-}
-
-/*
- * Wait until the screen is initialized before whacking the
- * sizes around; otherwise the screen pixmap will be allocated
- * at the current mode size rather than the maximum size
- */
-static Bool
-xf86RandRCreateScreenResources (ScreenPtr pScreen)
-{
- XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
-#if 0
- ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
- DisplayModePtr mode;
-#endif
-
- pScreen->CreateScreenResources = randrp->CreateScreenResources;
- if (!(*pScreen->CreateScreenResources) (pScreen))
- return FALSE;
-
-#if 0
- mode = scrp->currentMode;
- if (mode)
- xf86RandRSetMode (pScreen, mode, TRUE);
-#endif
-
- return TRUE;
-}
-
-/*
- * Reset size back to original
- */
-static Bool
-xf86RandRCloseScreen (int index, ScreenPtr pScreen)
-{
- ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
- XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
-
- scrp->virtualX = pScreen->width = randrp->virtualX;
- scrp->virtualY = pScreen->height = randrp->virtualY;
- scrp->currentMode = scrp->modes;
- pScreen->CloseScreen = randrp->CloseScreen;
- free(randrp);
- dixSetPrivate(&pScreen->devPrivates, xf86RandRKey, NULL);
- return (*pScreen->CloseScreen) (index, pScreen);
-}
-
-Rotation
-xf86GetRotation(ScreenPtr pScreen)
-{
- if (xf86RandRKey == NULL)
- return RR_Rotate_0;
-
- return XF86RANDRINFO(pScreen)->rotation;
-}
-
-/* Function to change RandR's idea of the virtual screen size */
-Bool
-xf86RandRSetNewVirtualAndDimensions(ScreenPtr pScreen,
- int newvirtX, int newvirtY, int newmmWidth, int newmmHeight,
- Bool resetMode)
-{
- XF86RandRInfoPtr randrp;
-
- if (xf86RandRKey == NULL)
- return FALSE;
-
- randrp = XF86RANDRINFO(pScreen);
- if (randrp == NULL)
- return FALSE;
-
- if (newvirtX > 0)
- randrp->virtualX = newvirtX;
-
- if (newvirtY > 0)
- randrp->virtualY = newvirtY;
-
- if (newmmWidth > 0)
- randrp->mmWidth = newmmWidth;
-
- if (newmmHeight > 0)
- randrp->mmHeight = newmmHeight;
-
- /* This is only for during server start */
- if (resetMode) {
- return (xf86RandRSetMode(pScreen,
- XF86SCRNINFO(pScreen)->currentMode,
- TRUE,
- pScreen->mmWidth, pScreen->mmHeight));
- }
-
- return TRUE;
-}
-
-Bool
-xf86RandRInit (ScreenPtr pScreen)
-{
- rrScrPrivPtr rp;
- XF86RandRInfoPtr randrp;
- ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
-
-#ifdef PANORAMIX
- /* XXX disable RandR when using Xinerama */
- if (!noPanoramiXExtension)
- return TRUE;
-#endif
-
- xf86RandRKey = &xf86RandRKeyRec;
-
- if (!dixRegisterPrivateKey(&xf86RandRKeyRec, PRIVATE_SCREEN, 0))
- return FALSE;
-
- randrp = malloc(sizeof (XF86RandRInfoRec));
- if (!randrp)
- return FALSE;
-
- if (!RRScreenInit (pScreen))
- {
- free(randrp);
- return FALSE;
- }
- rp = rrGetScrPriv(pScreen);
- rp->rrGetInfo = xf86RandRGetInfo;
- rp->rrSetConfig = xf86RandRSetConfig;
-
- randrp->virtualX = scrp->virtualX;
- randrp->virtualY = scrp->virtualY;
- randrp->mmWidth = pScreen->mmWidth;
- randrp->mmHeight = pScreen->mmHeight;
-
- randrp->CreateScreenResources = pScreen->CreateScreenResources;
- pScreen->CreateScreenResources = xf86RandRCreateScreenResources;
-
- randrp->CloseScreen = pScreen->CloseScreen;
- pScreen->CloseScreen = xf86RandRCloseScreen;
-
- randrp->rotation = RR_Rotate_0;
-
- dixSetPrivate(&pScreen->devPrivates, xf86RandRKey, randrp);
- return TRUE;
-}
-
-
+/*
+ *
+ * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * 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 Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "os.h"
+#include "globals.h"
+#include "xf86.h"
+#include "xf86str.h"
+#include "xf86Priv.h"
+#include "xf86DDC.h"
+#include "mipointer.h"
+#include <randrstr.h>
+#include "inputstr.h"
+
+typedef struct _xf86RandRInfo {
+ CreateScreenResourcesProcPtr CreateScreenResources;
+ CloseScreenProcPtr CloseScreen;
+ int virtualX;
+ int virtualY;
+ int mmWidth;
+ int mmHeight;
+ Rotation rotation;
+} XF86RandRInfoRec, *XF86RandRInfoPtr;
+
+static DevPrivateKeyRec xf86RandRKeyRec;
+static DevPrivateKey xf86RandRKey;
+
+#define XF86RANDRINFO(p) ((XF86RandRInfoPtr)dixLookupPrivate(&(p)->devPrivates, xf86RandRKey))
+
+static int
+xf86RandRModeRefresh (DisplayModePtr mode)
+{
+ if (mode->VRefresh)
+ return (int) (mode->VRefresh + 0.5);
+ else if (mode->Clock == 0)
+ return 0;
+ else
+ return (int) (mode->Clock * 1000.0 / mode->HTotal / mode->VTotal + 0.5);
+}
+
+static Bool
+xf86RandRGetInfo (ScreenPtr pScreen, Rotation *rotations)
+{
+ RRScreenSizePtr pSize;
+ ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
+ XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
+ DisplayModePtr mode;
+ int refresh0 = 60;
+ xorgRRModeMM RRModeMM;
+
+ *rotations = RR_Rotate_0;
+
+ for (mode = scrp->modes; mode != NULL ; mode = mode->next)
+ {
+ int refresh = xf86RandRModeRefresh (mode);
+
+ if (mode == scrp->modes)
+ refresh0 = refresh;
+
+ RRModeMM.mode = mode;
+ RRModeMM.virtX = randrp->virtualX;
+ RRModeMM.virtY = randrp->virtualY;
+ RRModeMM.mmWidth = randrp->mmWidth;
+ RRModeMM.mmHeight = randrp->mmHeight;
+
+ if(scrp->DriverFunc) {
+ (*scrp->DriverFunc)(scrp, RR_GET_MODE_MM, &RRModeMM);
+ }
+
+ pSize = RRRegisterSize (pScreen,
+ mode->HDisplay, mode->VDisplay,
+ RRModeMM.mmWidth, RRModeMM.mmHeight);
+ if (!pSize)
+ return FALSE;
+ RRRegisterRate (pScreen, pSize, refresh);
+ if (mode == scrp->currentMode &&
+ mode->HDisplay == scrp->virtualX && mode->VDisplay == scrp->virtualY)
+ RRSetCurrentConfig (pScreen, randrp->rotation, refresh, pSize);
+ if (mode->next == scrp->modes)
+ break;
+ }
+ if (scrp->currentMode->HDisplay != randrp->virtualX ||
+ scrp->currentMode->VDisplay != randrp->virtualY)
+ {
+ mode = scrp->modes;
+
+ RRModeMM.mode = NULL;
+ RRModeMM.virtX = randrp->virtualX;
+ RRModeMM.virtY = randrp->virtualY;
+ RRModeMM.mmWidth = randrp->mmWidth;
+ RRModeMM.mmHeight = randrp->mmHeight;
+
+ if(scrp->DriverFunc) {
+ (*scrp->DriverFunc)(scrp, RR_GET_MODE_MM, &RRModeMM);
+ }
+
+ pSize = RRRegisterSize (pScreen,
+ randrp->virtualX, randrp->virtualY,
+ RRModeMM.mmWidth, RRModeMM.mmHeight);
+ if (!pSize)
+ return FALSE;
+ RRRegisterRate (pScreen, pSize, refresh0);
+ if (scrp->virtualX == randrp->virtualX &&
+ scrp->virtualY == randrp->virtualY)
+ {
+ RRSetCurrentConfig (pScreen, randrp->rotation, refresh0, pSize);
+ }
+ }
+
+ /* If there is driver support for randr, let it set our supported rotations */
+ if(scrp->DriverFunc) {
+ xorgRRRotation RRRotation;
+
+ RRRotation.RRRotations = *rotations;
+ if (!(*scrp->DriverFunc)(scrp, RR_GET_INFO, &RRRotation))
+ return TRUE;
+ *rotations = RRRotation.RRRotations;
+ }
+
+ return TRUE;
+}
+
+static Bool
+xf86RandRSetMode (ScreenPtr pScreen,
+ DisplayModePtr mode,
+ Bool useVirtual,
+ int mmWidth,
+ int mmHeight)
+{
+ ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
+ XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
+ int oldWidth = pScreen->width;
+ int oldHeight = pScreen->height;
+ int oldmmWidth = pScreen->mmWidth;
+ int oldmmHeight = pScreen->mmHeight;
+ int oldVirtualX = scrp->virtualX;
+ int oldVirtualY = scrp->virtualY;
+ WindowPtr pRoot = pScreen->root;
+ Bool ret = TRUE;
+
+ if (pRoot && scrp->vtSema)
+ (*scrp->EnableDisableFBAccess) (pScreen->myNum, FALSE);
+ if (useVirtual)
+ {
+ scrp->virtualX = randrp->virtualX;
+ scrp->virtualY = randrp->virtualY;
+ }
+ else
+ {
+ scrp->virtualX = mode->HDisplay;
+ scrp->virtualY = mode->VDisplay;
+ }
+
+ /*
+ * The DIX forgets the physical dimensions we passed into RRRegisterSize, so
+ * reconstruct them if possible.
+ */
+ if(scrp->DriverFunc) {
+ xorgRRModeMM RRModeMM;
+
+ RRModeMM.mode = mode;
+ RRModeMM.virtX = scrp->virtualX;
+ RRModeMM.virtY = scrp->virtualY;
+ RRModeMM.mmWidth = mmWidth;
+ RRModeMM.mmHeight = mmHeight;
+
+ (*scrp->DriverFunc)(scrp, RR_GET_MODE_MM, &RRModeMM);
+
+ mmWidth = RRModeMM.mmWidth;
+ mmHeight = RRModeMM.mmHeight;
+ }
+ if(randrp->rotation & (RR_Rotate_90 | RR_Rotate_270))
+ {
+ /* If the screen is rotated 90 or 270 degrees, swap the sizes. */
+ pScreen->width = scrp->virtualY;
+ pScreen->height = scrp->virtualX;
+ pScreen->mmWidth = mmHeight;
+ pScreen->mmHeight = mmWidth;
+ }
+ else
+ {
+ pScreen->width = scrp->virtualX;
+ pScreen->height = scrp->virtualY;
+ pScreen->mmWidth = mmWidth;
+ pScreen->mmHeight = mmHeight;
+ }
+ if (!xf86SwitchMode (pScreen, mode))
+ {
+ pScreen->width = oldWidth;
+ pScreen->height = oldHeight;
+ pScreen->mmWidth = oldmmWidth;
+ pScreen->mmHeight = oldmmHeight;
+ scrp->virtualX = oldVirtualX;
+ scrp->virtualY = oldVirtualY;
+ ret = FALSE;
+ }
+ /*
+ * Make sure the layout is correct
+ */
+ xf86ReconfigureLayout();
+
+ /*
+ * Make sure the whole screen is visible
+ */
+ xf86SetViewport (pScreen, pScreen->width, pScreen->height);
+ xf86SetViewport (pScreen, 0, 0);
+ if (pRoot && scrp->vtSema)
+ (*scrp->EnableDisableFBAccess) (pScreen->myNum, TRUE);
+ return ret;
+}
+
+static Bool
+xf86RandRSetConfig (ScreenPtr pScreen,
+ Rotation rotation,
+ int rate,
+ RRScreenSizePtr pSize)
+{
+ ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
+ XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
+ DisplayModePtr mode;
+ int pos[MAXDEVICES][2];
+ Bool useVirtual = FALSE;
+ Rotation oldRotation = randrp->rotation;
+ DeviceIntPtr dev;
+ Bool view_adjusted = FALSE;
+
+ for (dev = inputInfo.devices; dev; dev = dev->next)
+ {
+ if (!IsMaster(dev) && !IsFloating(dev))
+ continue;
+
+ miPointerGetPosition(dev, &pos[dev->id][0], &pos[dev->id][1]);
+ }
+
+ for (mode = scrp->modes; ; mode = mode->next)
+ {
+ if (mode->HDisplay == pSize->width &&
+ mode->VDisplay == pSize->height &&
+ (rate == 0 || xf86RandRModeRefresh (mode) == rate))
+ break;
+ if (mode->next == scrp->modes)
+ {
+ if (pSize->width == randrp->virtualX &&
+ pSize->height == randrp->virtualY)
+ {
+ mode = scrp->modes;
+ useVirtual = TRUE;
+ break;
+ }
+ return FALSE;
+ }
+ }
+
+ if (randrp->rotation != rotation) {
+
+ /* Have the driver do its thing. */
+ if (scrp->DriverFunc) {
+ xorgRRRotation RRRotation;
+ RRRotation.RRConfig.rotation = rotation;
+ RRRotation.RRConfig.rate = rate;
+ RRRotation.RRConfig.width = pSize->width;
+ RRRotation.RRConfig.height = pSize->height;
+
+ /*
+ * Currently we need to rely on HW support for rotation.
+ */
+ if (!(*scrp->DriverFunc)(scrp, RR_SET_CONFIG, &RRRotation))
+ return FALSE;
+ } else
+ return FALSE;
+
+ randrp->rotation = rotation;
+ }
+
+ if (!xf86RandRSetMode (pScreen, mode, useVirtual, pSize->mmWidth, pSize->mmHeight)) {
+ if(randrp->rotation != oldRotation) {
+ /* Have the driver undo its thing. */
+ if (scrp->DriverFunc) {
+ xorgRRRotation RRRotation;
+ RRRotation.RRConfig.rotation = oldRotation;
+ RRRotation.RRConfig.rate = xf86RandRModeRefresh (scrp->currentMode);
+ RRRotation.RRConfig.width = scrp->virtualX;
+ RRRotation.RRConfig.height = scrp->virtualY;
+ (*scrp->DriverFunc)(scrp, RR_SET_CONFIG, &RRRotation);
+ }
+
+ randrp->rotation = oldRotation;
+ }
+ return FALSE;
+ }
+
+ /*
+ * Move the cursor back where it belongs; SwitchMode repositions it
+ * FIXME: duplicated code, see modes/xf86RandR12.c
+ */
+ for (dev = inputInfo.devices; dev; dev = dev->next)
+ {
+ if (!IsMaster(dev) && !IsFloating(dev))
+ continue;
+
+ if (pScreen == miPointerGetScreen(dev)) {
+ int px = pos[dev->id][0];
+ int py = pos[dev->id][1];
+
+ px = (px >= pScreen->width ? (pScreen->width - 1) : px);
+ py = (py >= pScreen->height ? (pScreen->height - 1) : py);
+
+ /* Setting the viewpoint makes only sense on one device */
+ if (!view_adjusted && IsMaster(dev)) {
+ xf86SetViewport(pScreen, px, py);
+ view_adjusted = TRUE;
+ }
+
+ (*pScreen->SetCursorPosition) (dev, pScreen, px, py, FALSE);
+ }
+ }
+
+ return TRUE;
+}
+
+/*
+ * Wait until the screen is initialized before whacking the
+ * sizes around; otherwise the screen pixmap will be allocated
+ * at the current mode size rather than the maximum size
+ */
+static Bool
+xf86RandRCreateScreenResources (ScreenPtr pScreen)
+{
+ XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
+#if 0
+ ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
+ DisplayModePtr mode;
+#endif
+
+ pScreen->CreateScreenResources = randrp->CreateScreenResources;
+ if (!(*pScreen->CreateScreenResources) (pScreen))
+ return FALSE;
+
+#if 0
+ mode = scrp->currentMode;
+ if (mode)
+ xf86RandRSetMode (pScreen, mode, TRUE);
+#endif
+
+ return TRUE;
+}
+
+/*
+ * Reset size back to original
+ */
+static Bool
+xf86RandRCloseScreen (int index, ScreenPtr pScreen)
+{
+ ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
+ XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
+
+ scrp->virtualX = pScreen->width = randrp->virtualX;
+ scrp->virtualY = pScreen->height = randrp->virtualY;
+ scrp->currentMode = scrp->modes;
+ pScreen->CloseScreen = randrp->CloseScreen;
+ free(randrp);
+ dixSetPrivate(&pScreen->devPrivates, xf86RandRKey, NULL);
+ return (*pScreen->CloseScreen) (index, pScreen);
+}
+
+Rotation
+xf86GetRotation(ScreenPtr pScreen)
+{
+ if (xf86RandRKey == NULL)
+ return RR_Rotate_0;
+
+ return XF86RANDRINFO(pScreen)->rotation;
+}
+
+/* Function to change RandR's idea of the virtual screen size */
+Bool
+xf86RandRSetNewVirtualAndDimensions(ScreenPtr pScreen,
+ int newvirtX, int newvirtY, int newmmWidth, int newmmHeight,
+ Bool resetMode)
+{
+ XF86RandRInfoPtr randrp;
+
+ if (xf86RandRKey == NULL)
+ return FALSE;
+
+ randrp = XF86RANDRINFO(pScreen);
+ if (randrp == NULL)
+ return FALSE;
+
+ if (newvirtX > 0)
+ randrp->virtualX = newvirtX;
+
+ if (newvirtY > 0)
+ randrp->virtualY = newvirtY;
+
+ if (newmmWidth > 0)
+ randrp->mmWidth = newmmWidth;
+
+ if (newmmHeight > 0)
+ randrp->mmHeight = newmmHeight;
+
+ /* This is only for during server start */
+ if (resetMode) {
+ return (xf86RandRSetMode(pScreen,
+ XF86SCRNINFO(pScreen)->currentMode,
+ TRUE,
+ pScreen->mmWidth, pScreen->mmHeight));
+ }
+
+ return TRUE;
+}
+
+Bool
+xf86RandRInit (ScreenPtr pScreen)
+{
+ rrScrPrivPtr rp;
+ XF86RandRInfoPtr randrp;
+ ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
+
+#ifdef PANORAMIX
+ /* XXX disable RandR when using Xinerama */
+ if (!noPanoramiXExtension)
+ return TRUE;
+#endif
+
+ xf86RandRKey = &xf86RandRKeyRec;
+
+ if (!dixRegisterPrivateKey(&xf86RandRKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
+ randrp = malloc(sizeof (XF86RandRInfoRec));
+ if (!randrp)
+ return FALSE;
+
+ if (!RRScreenInit (pScreen))
+ {
+ free(randrp);
+ return FALSE;
+ }
+ rp = rrGetScrPriv(pScreen);
+ rp->rrGetInfo = xf86RandRGetInfo;
+ rp->rrSetConfig = xf86RandRSetConfig;
+
+ randrp->virtualX = scrp->virtualX;
+ randrp->virtualY = scrp->virtualY;
+ randrp->mmWidth = pScreen->mmWidth;
+ randrp->mmHeight = pScreen->mmHeight;
+
+ randrp->CreateScreenResources = pScreen->CreateScreenResources;
+ pScreen->CreateScreenResources = xf86RandRCreateScreenResources;
+
+ randrp->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = xf86RandRCloseScreen;
+
+ randrp->rotation = RR_Rotate_0;
+
+ dixSetPrivate(&pScreen->devPrivates, xf86RandRKey, randrp);
+ return TRUE;
+}
+
+
diff --git a/xorg-server/hw/xfree86/common/xf86Xinput.c b/xorg-server/hw/xfree86/common/xf86Xinput.c
index a53531cc1..d22fdc8b9 100644
--- a/xorg-server/hw/xfree86/common/xf86Xinput.c
+++ b/xorg-server/hw/xfree86/common/xf86Xinput.c
@@ -1,1401 +1,1401 @@
-/*
- * Copyright 1995-1999 by Frederic Lepied, France. <Lepied@XFree86.org>
- *
- * 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 Frederic Lepied not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Frederic Lepied makes no
- * representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
- * FREDERIC LEPIED DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL FREDERIC LEPIED 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) 2000-2002 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,
- * 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).
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/Xfuncproto.h>
-#include <X11/Xmd.h>
-#include <X11/extensions/XI.h>
-#include <X11/extensions/XIproto.h>
-#include <X11/Xatom.h>
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86Config.h"
-#include "xf86Xinput.h"
-#include "xf86Optrec.h"
-#include "mipointer.h"
-#include "extinit.h"
-#include "loaderProcs.h"
-
-#include "exevents.h" /* AddInputDevice */
-#include "exglobals.h"
-#include "eventstr.h"
-#include "inpututils.h"
-
-#include <string.h> /* InputClassMatches */
-#ifdef HAVE_FNMATCH_H
-#include <fnmatch.h>
-#endif
-#ifdef HAVE_SYS_UTSNAME_H
-#include <sys/utsname.h>
-#endif
-
-#include <stdarg.h>
-#include <stdint.h> /* for int64_t */
-
-#include "mi.h"
-
-#include <ptrveloc.h> /* dix pointer acceleration */
-#include <xserver-properties.h>
-
-#ifdef XFreeXDGA
-#include "dgaproc.h"
-#endif
-
-#include "xkbsrv.h"
-
-/* Valuator verification macro */
-#define XI_VERIFY_VALUATORS(num_valuators) \
- if (num_valuators > MAX_VALUATORS) { \
- xf86Msg(X_ERROR, "%s: num_valuator %d is greater than" \
- " MAX_VALUATORS\n", __FUNCTION__, num_valuators); \
- return; \
- }
-
-static int
-xf86InputDevicePostInit(DeviceIntPtr dev);
-
-/**
- * Eval config and modify DeviceVelocityRec accordingly
- */
-static void
-ProcessVelocityConfiguration(DeviceIntPtr pDev, char* devname, pointer list,
- DeviceVelocityPtr s)
-{
- int tempi;
- float tempf;
- Atom float_prop = XIGetKnownProperty(XATOM_FLOAT);
- Atom prop;
-
- if(!s)
- return;
-
- /* common settings (available via device properties) */
- tempf = xf86SetRealOption(list, "ConstantDeceleration", 1.0);
- if (tempf > 1.0) {
- xf86Msg(X_CONFIG, "%s: (accel) constant deceleration by %.1f\n",
- devname, tempf);
- prop = XIGetKnownProperty(ACCEL_PROP_CONSTANT_DECELERATION);
- XIChangeDeviceProperty(pDev, prop, float_prop, 32,
- PropModeReplace, 1, &tempf, FALSE);
- }
-
- tempf = xf86SetRealOption(list, "AdaptiveDeceleration", 1.0);
- if (tempf > 1.0) {
- xf86Msg(X_CONFIG, "%s: (accel) adaptive deceleration by %.1f\n",
- devname, tempf);
- prop = XIGetKnownProperty(ACCEL_PROP_ADAPTIVE_DECELERATION);
- XIChangeDeviceProperty(pDev, prop, float_prop, 32,
- PropModeReplace, 1, &tempf, FALSE);
- }
-
- /* select profile by number */
- tempi = xf86SetIntOption(list, "AccelerationProfile",
- s->statistics.profile_number);
-
- prop = XIGetKnownProperty(ACCEL_PROP_PROFILE_NUMBER);
- if (XIChangeDeviceProperty(pDev, prop, XA_INTEGER, 32,
- PropModeReplace, 1, &tempi, FALSE) == Success) {
- xf86Msg(X_CONFIG, "%s: (accel) acceleration profile %i\n", devname,
- tempi);
- } else {
- xf86Msg(X_CONFIG, "%s: (accel) acceleration profile %i is unknown\n",
- devname, tempi);
- }
-
- /* set scaling */
- tempf = xf86SetRealOption(list, "ExpectedRate", 0);
- prop = XIGetKnownProperty(ACCEL_PROP_VELOCITY_SCALING);
- if (tempf > 0) {
- tempf = 1000.0 / tempf;
- XIChangeDeviceProperty(pDev, prop, float_prop, 32,
- PropModeReplace, 1, &tempf, FALSE);
- } else {
- tempf = xf86SetRealOption(list, "VelocityScale", s->corr_mul);
- XIChangeDeviceProperty(pDev, prop, float_prop, 32,
- PropModeReplace, 1, &tempf, FALSE);
- }
-
- tempi = xf86SetIntOption(list, "VelocityTrackerCount", -1);
- if (tempi > 1)
- InitTrackers(s, tempi);
-
- s->initial_range = xf86SetIntOption(list, "VelocityInitialRange",
- s->initial_range);
-
- s->max_diff = xf86SetRealOption(list, "VelocityAbsDiff", s->max_diff);
-
- tempf = xf86SetRealOption(list, "VelocityRelDiff", -1);
- if (tempf >= 0) {
- xf86Msg(X_CONFIG, "%s: (accel) max rel. velocity difference: %.1f%%\n",
- devname, tempf*100.0);
- s->max_rel_diff = tempf;
- }
-
- /* Configure softening. If const deceleration is used, this is expected
- * to provide better subpixel information so we enable
- * softening by default only if ConstantDeceleration is not used
- */
- s->use_softening = xf86SetBoolOption(list, "Softening",
- s->const_acceleration == 1.0);
-
- s->average_accel = xf86SetBoolOption(list, "AccelerationProfileAveraging",
- s->average_accel);
-
- s->reset_time = xf86SetIntOption(list, "VelocityReset", s->reset_time);
-}
-
-static void
-ApplyAccelerationSettings(DeviceIntPtr dev){
- int scheme, i;
- DeviceVelocityPtr pVel;
- InputInfoPtr pInfo = (InputInfoPtr)dev->public.devicePrivate;
- char* schemeStr;
-
- if (dev->valuator && dev->ptrfeed) {
- schemeStr = xf86SetStrOption(pInfo->options, "AccelerationScheme", "");
-
- scheme = dev->valuator->accelScheme.number;
-
- if (!xf86NameCmp(schemeStr, "predictable"))
- scheme = PtrAccelPredictable;
-
- if (!xf86NameCmp(schemeStr, "lightweight"))
- scheme = PtrAccelLightweight;
-
- if (!xf86NameCmp(schemeStr, "none"))
- scheme = PtrAccelNoOp;
-
- /* reinit scheme if needed */
- if (dev->valuator->accelScheme.number != scheme) {
- if (dev->valuator->accelScheme.AccelCleanupProc) {
- dev->valuator->accelScheme.AccelCleanupProc(dev);
- }
-
- if (InitPointerAccelerationScheme(dev, scheme)) {
- xf86Msg(X_CONFIG, "%s: (accel) selected scheme %s/%i\n",
- pInfo->name, schemeStr, scheme);
- } else {
- xf86Msg(X_CONFIG, "%s: (accel) could not init scheme %s\n",
- pInfo->name, schemeStr);
- scheme = dev->valuator->accelScheme.number;
- }
- } else {
- xf86Msg(X_CONFIG, "%s: (accel) keeping acceleration scheme %i\n",
- pInfo->name, scheme);
- }
-
- free(schemeStr);
-
- /* process special configuration */
- switch (scheme) {
- case PtrAccelPredictable:
- pVel = GetDevicePredictableAccelData(dev);
- ProcessVelocityConfiguration (dev, pInfo->name, pInfo->options,
- pVel);
- break;
- }
-
- i = xf86SetIntOption(pInfo->options, "AccelerationNumerator",
- dev->ptrfeed->ctrl.num);
- if (i >= 0)
- dev->ptrfeed->ctrl.num = i;
-
- i = xf86SetIntOption(pInfo->options, "AccelerationDenominator",
- dev->ptrfeed->ctrl.den);
- if (i > 0)
- dev->ptrfeed->ctrl.den = i;
-
- i = xf86SetIntOption(pInfo->options, "AccelerationThreshold",
- dev->ptrfeed->ctrl.threshold);
- if (i >= 0)
- dev->ptrfeed->ctrl.threshold = i;
-
- xf86Msg(X_CONFIG, "%s: (accel) acceleration factor: %.3f\n",
- pInfo->name, ((float)dev->ptrfeed->ctrl.num)/
- ((float)dev->ptrfeed->ctrl.den));
- xf86Msg(X_CONFIG, "%s: (accel) acceleration threshold: %i\n",
- pInfo->name, dev->ptrfeed->ctrl.threshold);
- }
-}
-
-/***********************************************************************
- *
- * xf86ProcessCommonOptions --
- *
- * Process global options.
- *
- ***********************************************************************
- */
-void
-xf86ProcessCommonOptions(InputInfoPtr pInfo,
- pointer list)
-{
- if (xf86SetBoolOption(list, "Floating", 0) ||
- !xf86SetBoolOption(list, "AlwaysCore", 1) ||
- !xf86SetBoolOption(list, "SendCoreEvents", 1) ||
- !xf86SetBoolOption(list, "CorePointer", 1) ||
- !xf86SetBoolOption(list, "CoreKeyboard", 1)) {
- xf86Msg(X_CONFIG, "%s: doesn't report core events\n", pInfo->name);
- } else {
- pInfo->flags |= XI86_ALWAYS_CORE;
- xf86Msg(X_CONFIG, "%s: always reports core events\n", pInfo->name);
- }
-}
-
-/***********************************************************************
- *
- * xf86ActivateDevice --
- *
- * Initialize an input device.
- *
- * Returns TRUE on success, or FALSE otherwise.
- ***********************************************************************
- */
-static DeviceIntPtr
-xf86ActivateDevice(InputInfoPtr pInfo)
-{
- DeviceIntPtr dev;
- Atom atom;
-
- dev = AddInputDevice(serverClient, pInfo->device_control, TRUE);
-
- if (dev == NULL)
- {
- xf86Msg(X_ERROR, "Too many input devices. Ignoring %s\n",
- pInfo->name);
- pInfo->dev = NULL;
- return NULL;
- }
-
- atom = MakeAtom(pInfo->type_name, strlen(pInfo->type_name), TRUE);
- AssignTypeAndName(dev, atom, pInfo->name);
- dev->public.devicePrivate = pInfo;
- pInfo->dev = dev;
-
- dev->coreEvents = pInfo->flags & XI86_ALWAYS_CORE;
- dev->type = SLAVE;
- dev->spriteInfo->spriteOwner = FALSE;
-
- dev->config_info = xf86SetStrOption(pInfo->options, "config_info", NULL);
-
- if (serverGeneration == 1)
- xf86Msg(X_INFO, "XINPUT: Adding extended input device \"%s\" (type: %s, id %d)\n",
- pInfo->name, pInfo->type_name, dev->id);
-
- return dev;
-}
-
-/****************************************************************************
- *
- * Caller: ProcXSetDeviceMode
- *
- * Change the mode of an extension device.
- * This function is used to change the mode of a device from reporting
- * relative motion to reporting absolute positional information, and
- * vice versa.
- * The default implementation below is that no such devices are supported.
- *
- ***********************************************************************
- */
-
-int
-SetDeviceMode (ClientPtr client, DeviceIntPtr dev, int mode)
-{
- InputInfoPtr pInfo = (InputInfoPtr)dev->public.devicePrivate;
-
- if (pInfo->switch_mode) {
- return (*pInfo->switch_mode)(client, dev, mode);
- }
- else
- return BadMatch;
-}
-
-
-/***********************************************************************
- *
- * Caller: ProcXSetDeviceValuators
- *
- * Set the value of valuators on an extension input device.
- * This function is used to set the initial value of valuators on
- * those input devices that are capable of reporting either relative
- * motion or an absolute position, and allow an initial position to be set.
- * The default implementation below is that no such devices are supported.
- *
- ***********************************************************************
- */
-
-int
-SetDeviceValuators (ClientPtr client, DeviceIntPtr dev, int *valuators,
- int first_valuator, int num_valuators)
-{
- InputInfoPtr pInfo = (InputInfoPtr) dev->public.devicePrivate;
-
- if (pInfo->set_device_valuators)
- return (*pInfo->set_device_valuators)(pInfo, valuators, first_valuator,
- num_valuators);
-
- return BadMatch;
-}
-
-
-/***********************************************************************
- *
- * Caller: ProcXChangeDeviceControl
- *
- * Change the specified device controls on an extension input device.
- *
- ***********************************************************************
- */
-
-int
-ChangeDeviceControl (ClientPtr client, DeviceIntPtr dev, xDeviceCtl *control)
-{
- InputInfoPtr pInfo = (InputInfoPtr)dev->public.devicePrivate;
-
- if (!pInfo->control_proc) {
- switch (control->control) {
- case DEVICE_CORE:
- case DEVICE_ABS_CALIB:
- case DEVICE_ABS_AREA:
- return BadMatch;
- case DEVICE_RESOLUTION:
- case DEVICE_ENABLE:
- return Success;
- default:
- return BadMatch;
- }
- }
- else {
- return (*pInfo->control_proc)(pInfo, control);
- }
-}
-
-/*
- * Get the operating system name from uname and store it statically to avoid
- * repeating the system call each time MatchOS is checked.
- */
-static const char *
-HostOS(void)
-{
-#ifdef HAVE_SYS_UTSNAME_H
- struct utsname name;
- static char host_os[sizeof(name.sysname)] = "";
-
- if (*host_os == '\0') {
- if (uname(&name) >= 0)
- strcpy(host_os, name.sysname);
- else {
- strncpy(host_os, "unknown", sizeof(host_os));
- host_os[sizeof(host_os)-1] = '\0';
- }
- }
- return host_os;
-#else
- return "";
-#endif
-}
-
-static int
-match_substring(const char *attr, const char *pattern)
-{
- return (strstr(attr, pattern)) ? 0 : -1;
-}
-
-#ifdef HAVE_FNMATCH_H
-static int
-match_pattern(const char *attr, const char *pattern)
-{
- return fnmatch(pattern, attr, 0);
-}
-#else
-#define match_pattern match_substring
-#endif
-
-#ifdef HAVE_FNMATCH_H
-static int
-match_path_pattern(const char *attr, const char *pattern)
-{
- return fnmatch(pattern, attr, FNM_PATHNAME);
-}
-#else
-#define match_path_pattern match_substring
-#endif
-
-/*
- * If no Layout section is found, xf86ServerLayout.id becomes "(implicit)"
- * It is convenient that "" in patterns means "no explicit layout"
- */
-static int
-match_string_implicit(const char *attr, const char *pattern)
-{
- if (strlen(pattern)) {
- return strcmp(attr, pattern);
- } else {
- return strcmp(attr,"(implicit)");
- }
-}
-
-/*
- * Match an attribute against a list of NULL terminated arrays of patterns.
- * If a pattern in each list entry is matched, return TRUE.
- */
-static Bool
-MatchAttrToken(const char *attr, struct list *patterns,
- int (*compare)(const char *attr, const char *pattern))
-{
- const xf86MatchGroup *group;
-
- /* If there are no patterns, accept the match */
- if (list_is_empty(patterns))
- return TRUE;
-
- /* If there are patterns but no attribute, reject the match */
- if (!attr)
- return FALSE;
-
- /*
- * Otherwise, iterate the list of patterns ensuring each entry has a
- * match. Each list entry is a separate Match line of the same type.
- */
- list_for_each_entry(group, patterns, entry) {
- char * const *cur;
- Bool match = FALSE;
-
- for (cur = group->values; *cur; cur++)
- if ((*compare)(attr, *cur) == 0) {
- match = TRUE;
- break;
- }
- if (!match)
- return FALSE;
- }
-
- /* All the entries in the list matched the attribute */
- return TRUE;
-}
-
-/*
- * Classes without any Match statements match all devices. Otherwise, all
- * statements must match.
- */
-static Bool
-InputClassMatches(const XF86ConfInputClassPtr iclass, const InputInfoPtr idev,
- const InputAttributes *attrs)
-{
- /* MatchProduct substring */
- if (!MatchAttrToken(attrs->product, &iclass->match_product, match_substring))
- return FALSE;
-
- /* MatchVendor substring */
- if (!MatchAttrToken(attrs->vendor, &iclass->match_vendor, match_substring))
- return FALSE;
-
- /* MatchDevicePath pattern */
- if (!MatchAttrToken(attrs->device, &iclass->match_device, match_path_pattern))
- return FALSE;
-
- /* MatchOS case-insensitive string */
- if (!MatchAttrToken(HostOS(), &iclass->match_os, strcasecmp))
- return FALSE;
-
- /* MatchPnPID pattern */
- if (!MatchAttrToken(attrs->pnp_id, &iclass->match_pnpid, match_pattern))
- return FALSE;
-
- /* MatchUSBID pattern */
- if (!MatchAttrToken(attrs->usb_id, &iclass->match_usbid, match_pattern))
- return FALSE;
-
- /* MatchDriver string */
- if (!MatchAttrToken(idev->driver, &iclass->match_driver, strcmp))
- return FALSE;
-
- /*
- * MatchTag string
- * See if any of the device's tags match any of the MatchTag tokens.
- */
- if (!list_is_empty(&iclass->match_tag)) {
- char * const *tag;
- Bool match;
-
- if (!attrs->tags)
- return FALSE;
- for (tag = attrs->tags, match = FALSE; *tag; tag++) {
- if (MatchAttrToken(*tag, &iclass->match_tag, strcmp)) {
- match = TRUE;
- break;
- }
- }
- if (!match)
- return FALSE;
- }
-
- /* MatchLayout string */
- if (!list_is_empty(&iclass->match_layout)) {
- if (!MatchAttrToken(xf86ConfigLayout.id,
- &iclass->match_layout, match_string_implicit))
- return FALSE;
- }
-
- /* MatchIs* booleans */
- if (iclass->is_keyboard.set &&
- iclass->is_keyboard.val != !!(attrs->flags & ATTR_KEYBOARD))
- return FALSE;
- if (iclass->is_pointer.set &&
- iclass->is_pointer.val != !!(attrs->flags & ATTR_POINTER))
- return FALSE;
- if (iclass->is_joystick.set &&
- iclass->is_joystick.val != !!(attrs->flags & ATTR_JOYSTICK))
- return FALSE;
- if (iclass->is_tablet.set &&
- iclass->is_tablet.val != !!(attrs->flags & ATTR_TABLET))
- return FALSE;
- if (iclass->is_touchpad.set &&
- iclass->is_touchpad.val != !!(attrs->flags & ATTR_TOUCHPAD))
- return FALSE;
- if (iclass->is_touchscreen.set &&
- iclass->is_touchscreen.val != !!(attrs->flags & ATTR_TOUCHSCREEN))
- return FALSE;
-
- return TRUE;
-}
-
-/*
- * Merge in any InputClass configurations. Options in each InputClass
- * section have more priority than the original device configuration as
- * well as any previous InputClass sections.
- */
-static int
-MergeInputClasses(const InputInfoPtr idev, const InputAttributes *attrs)
-{
- XF86ConfInputClassPtr cl;
- XF86OptionPtr classopts;
-
- for (cl = xf86configptr->conf_inputclass_lst; cl; cl = cl->list.next) {
- if (!InputClassMatches(cl, idev, attrs))
- continue;
-
- /* Collect class options and driver settings */
- classopts = xf86optionListDup(cl->option_lst);
- if (cl->driver) {
- free(idev->driver);
- idev->driver = xstrdup(cl->driver);
- if (!idev->driver) {
- xf86Msg(X_ERROR, "Failed to allocate memory while merging "
- "InputClass configuration");
- return BadAlloc;
- }
- classopts = xf86ReplaceStrOption(classopts, "driver",
- idev->driver);
- }
-
- /* Apply options to device with InputClass settings preferred. */
- xf86Msg(X_CONFIG, "%s: Applying InputClass \"%s\"\n",
- idev->name, cl->identifier);
- idev->options = xf86optionListMerge(idev->options, classopts);
- }
-
- return Success;
-}
-
-/*
- * Iterate the list of classes and look for Option "Ignore". Return the
- * value of the last matching class and holler when returning TRUE.
- */
-static Bool
-IgnoreInputClass(const InputInfoPtr idev, const InputAttributes *attrs)
-{
- XF86ConfInputClassPtr cl;
- Bool ignore = FALSE;
- const char *ignore_class;
-
- for (cl = xf86configptr->conf_inputclass_lst; cl; cl = cl->list.next) {
- if (!InputClassMatches(cl, idev, attrs))
- continue;
- if (xf86findOption(cl->option_lst, "Ignore")) {
- ignore = xf86CheckBoolOption(cl->option_lst, "Ignore", FALSE);
- ignore_class = cl->identifier;
- }
- }
-
- if (ignore)
- xf86Msg(X_CONFIG, "%s: Ignoring device from InputClass \"%s\"\n",
- idev->name, ignore_class);
- return ignore;
-}
-
-InputInfoPtr
-xf86AllocateInput(void)
-{
- InputInfoPtr pInfo;
-
- pInfo = calloc(sizeof(*pInfo), 1);
- if (!pInfo)
- return NULL;
-
- pInfo->fd = -1;
- pInfo->type_name = "UNKNOWN";
-
- return pInfo;
-}
-
-/* Append InputInfoRec to the tail of xf86InputDevs. */
-static void
-xf86AddInput(InputDriverPtr drv, InputInfoPtr pInfo)
-{
- InputInfoPtr *prev = NULL;
-
- pInfo->drv = drv;
- pInfo->module = DuplicateModule(drv->module, NULL);
-
- for (prev = &xf86InputDevs; *prev; prev = &(*prev)->next)
- ;
-
- *prev = pInfo;
- pInfo->next = NULL;
-
- xf86CollectInputOptions(pInfo, (const char**)drv->default_options);
- xf86OptionListReport(pInfo->options);
- xf86ProcessCommonOptions(pInfo, pInfo->options);
-}
-
-/*
- * Remove an entry from xf86InputDevs and free all the device's information.
- */
-void
-xf86DeleteInput(InputInfoPtr pInp, int flags)
-{
- /* First check if the inputdev is valid. */
- if (pInp == NULL)
- return;
-
- if (pInp->module)
- UnloadModule(pInp->module);
-
- /* This should *really* be handled in drv->UnInit(dev) call instead, but
- * if the driver forgets about it make sure we free it or at least crash
- * with flying colors */
- free(pInp->private);
-
- FreeInputAttributes(pInp->attrs);
-
- /* Remove the entry from the list. */
- if (pInp == xf86InputDevs)
- xf86InputDevs = pInp->next;
- else {
- InputInfoPtr p = xf86InputDevs;
- while (p && p->next != pInp)
- p = p->next;
- if (p)
- p->next = pInp->next;
- /* Else the entry wasn't in the xf86InputDevs list (ignore this). */
- }
-
- free(pInp->driver);
- free(pInp->name);
- xf86optionListFree(pInp->options);
- free(pInp);
-}
-
-/*
- * Apply backend-specific initialization. Invoked after ActiveteDevice(),
- * i.e. after the driver successfully completed DEVICE_INIT and the device
- * is advertised.
- * @param dev the device
- * @return Success or an error code
- */
-static int
-xf86InputDevicePostInit(DeviceIntPtr dev) {
- ApplyAccelerationSettings(dev);
- return Success;
-}
-
-/**
- * Create a new input device, activate and enable it.
- *
- * Possible return codes:
- * BadName .. a bad driver name was supplied.
- * BadImplementation ... The driver does not have a PreInit function. This
- * is a driver bug.
- * BadMatch .. device initialization failed.
- * BadAlloc .. too many input devices
- *
- * @param idev The device, already set up with identifier, driver, and the
- * options.
- * @param pdev Pointer to the new device, if Success was reported.
- * @param enable Enable the device after activating it.
- *
- * @return Success or an error code
- */
-_X_INTERNAL int
-xf86NewInputDevice(InputInfoPtr pInfo, DeviceIntPtr *pdev, BOOL enable)
-{
- InputDriverPtr drv = NULL;
- DeviceIntPtr dev = NULL;
- int rval;
-
- /* Memory leak for every attached device if we don't
- * test if the module is already loaded first */
- drv = xf86LookupInputDriver(pInfo->driver);
- if (!drv)
- if (xf86LoadOneModule(pInfo->driver, NULL))
- drv = xf86LookupInputDriver(pInfo->driver);
- if (!drv) {
- xf86Msg(X_ERROR, "No input driver matching `%s'\n", pInfo->driver);
- rval = BadName;
- goto unwind;
- }
-
- xf86Msg(X_INFO, "Using input driver '%s' for '%s'\n", drv->driverName, pInfo->name);
-
- if (!drv->PreInit) {
- xf86Msg(X_ERROR,
- "Input driver `%s' has no PreInit function (ignoring)\n",
- drv->driverName);
- rval = BadImplementation;
- goto unwind;
- }
-
- xf86AddInput(drv, pInfo);
-
- rval = drv->PreInit(drv, pInfo, 0);
-
- if (rval != Success) {
- xf86Msg(X_ERROR, "PreInit returned %d for \"%s\"\n", rval, pInfo->name);
- goto unwind;
- }
-
- if (!(dev = xf86ActivateDevice(pInfo)))
- {
- rval = BadAlloc;
- goto unwind;
- }
-
- rval = ActivateDevice(dev, TRUE);
- if (rval != Success)
- {
- xf86Msg(X_ERROR, "Couldn't init device \"%s\"\n", pInfo->name);
- RemoveDevice(dev, TRUE);
- goto unwind;
- }
-
- rval = xf86InputDevicePostInit(dev);
- if (rval != Success)
- {
- xf86Msg(X_ERROR, "Couldn't post-init device \"%s\"\n", pInfo->name);
- RemoveDevice(dev, TRUE);
- goto unwind;
- }
-
- /* Enable it if it's properly initialised and we're currently in the VT */
- if (enable && dev->inited && dev->startup && xf86Screens[0]->vtSema)
- {
- OsBlockSignals();
- EnableDevice(dev, TRUE);
- if (!dev->enabled)
- {
- OsReleaseSignals();
- xf86Msg(X_ERROR, "Couldn't init device \"%s\"\n", pInfo->name);
- RemoveDevice(dev, TRUE);
- rval = BadMatch;
- goto unwind;
- }
- /* send enter/leave event, update sprite window */
- CheckMotion(NULL, dev);
- OsReleaseSignals();
- }
-
- *pdev = dev;
- return Success;
-
-unwind:
- if(pInfo) {
- if(drv && drv->UnInit)
- drv->UnInit(drv, pInfo, 0);
- else
- xf86DeleteInput(pInfo, 0);
- }
- return rval;
-}
-
-int
-NewInputDeviceRequest (InputOption *options, InputAttributes *attrs,
- DeviceIntPtr *pdev)
-{
- InputInfoPtr pInfo = NULL;
- InputOption *option = NULL;
- int rval = Success;
- int is_auto = 0;
-
- pInfo = xf86AllocateInput();
- if (!pInfo)
- return BadAlloc;
-
- for (option = options; option; option = option->next) {
- if (strcasecmp(option->key, "driver") == 0) {
- if (pInfo->driver) {
- rval = BadRequest;
- goto unwind;
- }
- pInfo->driver = xstrdup(option->value);
- if (!pInfo->driver) {
- rval = BadAlloc;
- goto unwind;
- }
- }
-
- if (strcasecmp(option->key, "name") == 0 ||
- strcasecmp(option->key, "identifier") == 0) {
- if (pInfo->name) {
- rval = BadRequest;
- goto unwind;
- }
- pInfo->name = xstrdup(option->value);
- if (!pInfo->name) {
- rval = BadAlloc;
- goto unwind;
- }
- }
-
- if (strcmp(option->key, "_source") == 0 &&
- (strcmp(option->value, "server/hal") == 0 ||
- strcmp(option->value, "server/udev") == 0)) {
- is_auto = 1;
- if (!xf86Info.autoAddDevices) {
- rval = BadMatch;
- goto unwind;
- }
- }
- }
-
- for (option = options; option; option = option->next) {
- /* Steal option key/value strings from the provided list.
- * We need those strings, the InputOption list doesn't. */
- pInfo->options = xf86addNewOption(pInfo->options,
- option->key, option->value);
- option->key = NULL;
- option->value = NULL;
- }
-
- /* Apply InputClass settings */
- if (attrs) {
- if (IgnoreInputClass(pInfo, attrs)) {
- rval = BadIDChoice;
- goto unwind;
- }
-
- rval = MergeInputClasses(pInfo, attrs);
- if (rval != Success)
- goto unwind;
-
- pInfo->attrs = DuplicateInputAttributes(attrs);
- }
-
- if (!pInfo->driver || !pInfo->name) {
- xf86Msg(X_INFO, "No input driver/identifier specified (ignoring)\n");
- rval = BadRequest;
- goto unwind;
- }
-
- if (!pInfo->name) {
- xf86Msg(X_ERROR, "No device identifier specified (ignoring)\n");
- rval = BadMatch;
- goto unwind;
- }
-
- rval = xf86NewInputDevice(pInfo, pdev,
- (!is_auto || (is_auto && xf86Info.autoEnableDevices)));
-
- return rval;
-
-unwind:
- if (is_auto && !xf86Info.autoAddDevices)
- xf86Msg(X_INFO, "AutoAddDevices is off - not adding device.\n");
- xf86DeleteInput(pInfo, 0);
- return rval;
-}
-
-void
-DeleteInputDeviceRequest(DeviceIntPtr pDev)
-{
- InputInfoPtr pInfo = (InputInfoPtr) pDev->public.devicePrivate;
- InputDriverPtr drv = NULL;
- Bool isMaster = IsMaster(pDev);
-
- if (pInfo) /* need to get these before RemoveDevice */
- drv = pInfo->drv;
-
- OsBlockSignals();
- RemoveDevice(pDev, TRUE);
-
- if (!isMaster && pInfo != NULL)
- {
- if(drv->UnInit)
- drv->UnInit(drv, pInfo, 0);
- else
- xf86DeleteInput(pInfo, 0);
- }
- OsReleaseSignals();
-}
-
-/*
- * convenient functions to post events
- */
-
-void
-xf86PostMotionEvent(DeviceIntPtr device,
- int is_absolute,
- int first_valuator,
- int num_valuators,
- ...)
-{
- va_list var;
- int i = 0;
- ValuatorMask mask;
-
- XI_VERIFY_VALUATORS(num_valuators);
-
- valuator_mask_zero(&mask);
- va_start(var, num_valuators);
- for (i = 0; i < num_valuators; i++)
- valuator_mask_set(&mask, first_valuator + i, va_arg(var, int));
- va_end(var);
-
- xf86PostMotionEventM(device, is_absolute, &mask);
-}
-
-void
-xf86PostMotionEventP(DeviceIntPtr device,
- int is_absolute,
- int first_valuator,
- int num_valuators,
- const int *valuators)
-{
- ValuatorMask mask;
-
- XI_VERIFY_VALUATORS(num_valuators);
-
- valuator_mask_set_range(&mask, first_valuator, num_valuators, valuators);
- xf86PostMotionEventM(device, is_absolute, &mask);
-}
-
-void
-xf86PostMotionEventM(DeviceIntPtr device,
- int is_absolute,
- const ValuatorMask *mask)
-{
- int flags = 0;
-
- if (valuator_mask_num_valuators(mask) > 0)
- {
- if (is_absolute)
- flags = POINTER_ABSOLUTE;
- else
- flags = POINTER_RELATIVE | POINTER_ACCELERATE;
- }
-
-#if XFreeXDGA
- /* The evdev driver may not always send all axes across. */
- if (valuator_mask_isset(mask, 0) ||
- valuator_mask_isset(mask, 1))
- if (miPointerGetScreen(device)) {
- int index = miPointerGetScreen(device)->myNum;
- int dx = 0, dy = 0;
-
- if (valuator_mask_isset(mask, 0))
- {
- dx = valuator_mask_get(mask, 0);
- if (is_absolute)
- dx -= device->last.valuators[0];
- }
-
- if (valuator_mask_isset(mask, 1))
- {
- dy = valuator_mask_get(mask, 1);
- if (is_absolute)
- dy -= device->last.valuators[1];
- }
-
- if (DGAStealMotionEvent(device, index, dx, dy))
- return;
- }
-#endif
-
- QueuePointerEvents(device, MotionNotify, 0, flags, mask);
-}
-
-void
-xf86PostProximityEvent(DeviceIntPtr device,
- int is_in,
- int first_valuator,
- int num_valuators,
- ...)
-{
- va_list var;
- int i;
- ValuatorMask mask;
-
- XI_VERIFY_VALUATORS(num_valuators);
-
- valuator_mask_zero(&mask);
- va_start(var, num_valuators);
- for (i = 0; i < num_valuators; i++)
- valuator_mask_set(&mask, first_valuator + i, va_arg(var, int));
- va_end(var);
-
- xf86PostProximityEventM(device, is_in, &mask);
-}
-
-void
-xf86PostProximityEventP(DeviceIntPtr device,
- int is_in,
- int first_valuator,
- int num_valuators,
- const int *valuators)
-{
- ValuatorMask mask;
-
- XI_VERIFY_VALUATORS(num_valuators);
-
- valuator_mask_set_range(&mask, first_valuator, num_valuators, valuators);
- xf86PostProximityEventM(device, is_in, &mask);
-}
-
-void
-xf86PostProximityEventM(DeviceIntPtr device,
- int is_in,
- const ValuatorMask *mask)
-{
- QueueProximityEvents(device, is_in ? ProximityIn : ProximityOut, mask);
-}
-
-void
-xf86PostButtonEvent(DeviceIntPtr device,
- int is_absolute,
- int button,
- int is_down,
- int first_valuator,
- int num_valuators,
- ...)
-{
- va_list var;
- ValuatorMask mask;
- int i = 0;
-
- XI_VERIFY_VALUATORS(num_valuators);
-
- valuator_mask_zero(&mask);
-
- va_start(var, num_valuators);
- for (i = 0; i < num_valuators; i++)
- valuator_mask_set(&mask, first_valuator + i, va_arg(var, int));
- va_end(var);
-
- xf86PostButtonEventM(device, is_absolute, button, is_down, &mask);
-}
-
-void
-xf86PostButtonEventP(DeviceIntPtr device,
- int is_absolute,
- int button,
- int is_down,
- int first_valuator,
- int num_valuators,
- const int *valuators)
-{
- ValuatorMask mask;
-
- XI_VERIFY_VALUATORS(num_valuators);
-
- valuator_mask_set_range(&mask, first_valuator, num_valuators, valuators);
- xf86PostButtonEventM(device, is_absolute, button, is_down, &mask);
-}
-
-void
-xf86PostButtonEventM(DeviceIntPtr device,
- int is_absolute,
- int button,
- int is_down,
- const ValuatorMask *mask)
-{
- int flags = 0;
-
- if (valuator_mask_num_valuators(mask) > 0)
- {
- if (is_absolute)
- flags = POINTER_ABSOLUTE;
- else
- flags = POINTER_RELATIVE | POINTER_ACCELERATE;
- }
-
-#if XFreeXDGA
- if (miPointerGetScreen(device)) {
- int index = miPointerGetScreen(device)->myNum;
-
- if (DGAStealButtonEvent(device, index, button, is_down))
- return;
- }
-#endif
-
- QueuePointerEvents(device,
- is_down ? ButtonPress : ButtonRelease, button,
- flags, mask);
-}
-
-void
-xf86PostKeyEvent(DeviceIntPtr device,
- unsigned int key_code,
- int is_down,
- int is_absolute,
- int first_valuator,
- int num_valuators,
- ...)
-{
- va_list var;
- int i = 0;
- ValuatorMask mask;
-
- XI_VERIFY_VALUATORS(num_valuators);
-
- valuator_mask_zero(&mask);
-
- va_start(var, num_valuators);
- for (i = 0; i < num_valuators; i++)
- valuator_mask_set(&mask, first_valuator + i, va_arg(var, int));
- va_end(var);
-
- xf86PostKeyEventM(device, key_code, is_down, is_absolute, &mask);
-}
-
-void
-xf86PostKeyEventP(DeviceIntPtr device,
- unsigned int key_code,
- int is_down,
- int is_absolute,
- int first_valuator,
- int num_valuators,
- const int *valuators)
-{
- ValuatorMask mask;
-
- XI_VERIFY_VALUATORS(num_valuators);
-
- valuator_mask_set_range(&mask, first_valuator, num_valuators, valuators);
- xf86PostKeyEventM(device, key_code, is_down, is_absolute, &mask);
-}
-
-void
-xf86PostKeyEventM(DeviceIntPtr device,
- unsigned int key_code,
- int is_down,
- int is_absolute,
- const ValuatorMask *mask)
-{
-#if XFreeXDGA
- DeviceIntPtr pointer;
-
- /* Some pointers send key events, paired device is wrong then. */
- pointer = IsPointerDevice(device) ? device : GetPairedDevice(device);
- if (miPointerGetScreen(pointer)) {
- int index = miPointerGetScreen(pointer)->myNum;
-
- if (DGAStealKeyEvent(device, index, key_code, is_down))
- return;
- }
-#endif
-
- QueueKeyboardEvents(device,
- is_down ? KeyPress : KeyRelease,
- key_code, mask);
-}
-
-void
-xf86PostKeyboardEvent(DeviceIntPtr device,
- unsigned int key_code,
- int is_down)
-{
- ValuatorMask mask;
-
- valuator_mask_zero(&mask);
- xf86PostKeyEventM(device, key_code, is_down, 0, &mask);
-}
-
-InputInfoPtr
-xf86FirstLocalDevice(void)
-{
- return xf86InputDevs;
-}
-
-/*
- * Cx - raw data from touch screen
- * to_max - scaled highest dimension
- * (remember, this is of rows - 1 because of 0 origin)
- * to_min - scaled lowest dimension
- * from_max - highest raw value from touch screen calibration
- * from_min - lowest raw value from touch screen calibration
- *
- * This function is the same for X or Y coordinates.
- * You may have to reverse the high and low values to compensate for
- * different orgins on the touch screen vs X.
- *
- * e.g. to scale from device coordinates into screen coordinates, call
- * xf86ScaleAxis(x, 0, screen_width, dev_min, dev_max);
- */
-
-int
-xf86ScaleAxis(int Cx,
- int to_max,
- int to_min,
- int from_max,
- int from_min )
-{
- int X;
- int64_t to_width = to_max - to_min;
- int64_t from_width = from_max - from_min;
-
- if (from_width) {
- X = (int)(((to_width * (Cx - from_min)) / from_width) + to_min);
- }
- else {
- X = 0;
- ErrorF ("Divide by Zero in xf86ScaleAxis\n");
- }
-
- if (X > to_max)
- X = to_max;
- if (X < to_min)
- X = to_min;
-
- return X;
-}
-
-/*
- * This function checks the given screen against the current screen and
- * makes changes if appropriate. It should be called from an XInput driver's
- * ReadInput function before any events are posted, if the device is screen
- * specific like a touch screen.
- */
-void
-xf86XInputSetScreen(InputInfoPtr pInfo,
- int screen_number,
- int x,
- int y)
-{
- if (miPointerGetScreen(pInfo->dev) !=
- screenInfo.screens[screen_number]) {
- miPointerSetScreen(pInfo->dev, screen_number, x, y);
- }
-}
-
-
-void
-xf86InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, Atom label, int minval, int maxval,
- int resolution, int min_res, int max_res, int mode)
-{
- if (!dev || !dev->valuator)
- return;
-
- InitValuatorAxisStruct(dev, axnum, label, minval, maxval, resolution, min_res,
- max_res, mode);
-}
-
-/*
- * Set the valuator values to be in synch with dix/event.c
- * DefineInitialRootWindow().
- */
-void
-xf86InitValuatorDefaults(DeviceIntPtr dev, int axnum)
-{
- if (axnum == 0) {
- dev->valuator->axisVal[0] = screenInfo.screens[0]->width / 2;
- dev->last.valuators[0] = dev->valuator->axisVal[0];
- }
- else if (axnum == 1) {
- dev->valuator->axisVal[1] = screenInfo.screens[0]->height / 2;
- dev->last.valuators[1] = dev->valuator->axisVal[1];
- }
-}
-
-
-/**
- * Deactivate a device. Call this function from the driver if you receive a
- * read error or something else that spoils your day.
- * Device will be moved to the off_devices list, but it will still be there
- * until you really clean up after it.
- * Notifies the client about an inactive device.
- *
- * @param panic True if device is unrecoverable and needs to be removed.
- */
-void
-xf86DisableDevice(DeviceIntPtr dev, Bool panic)
-{
- if(!panic)
- {
- DisableDevice(dev, TRUE);
- } else
- {
- SendDevicePresenceEvent(dev->id, DeviceUnrecoverable);
- DeleteInputDeviceRequest(dev);
- }
-}
-
-/**
- * Reactivate a device. Call this function from the driver if you just found
- * out that the read error wasn't quite that bad after all.
- * Device will be re-activated, and an event sent to the client.
- */
-void
-xf86EnableDevice(DeviceIntPtr dev)
-{
- EnableDevice(dev, TRUE);
-}
-
-/* end of xf86Xinput.c */
+/*
+ * Copyright 1995-1999 by Frederic Lepied, France. <Lepied@XFree86.org>
+ *
+ * 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 Frederic Lepied not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Frederic Lepied makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * FREDERIC LEPIED DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL FREDERIC LEPIED 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) 2000-2002 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,
+ * 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).
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/Xfuncproto.h>
+#include <X11/Xmd.h>
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include <X11/Xatom.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86Config.h"
+#include "xf86Xinput.h"
+#include "xf86Optrec.h"
+#include "mipointer.h"
+#include "extinit.h"
+#include "loaderProcs.h"
+
+#include "exevents.h" /* AddInputDevice */
+#include "exglobals.h"
+#include "eventstr.h"
+#include "inpututils.h"
+
+#include <string.h> /* InputClassMatches */
+#ifdef HAVE_FNMATCH_H
+#include <fnmatch.h>
+#endif
+#ifdef HAVE_SYS_UTSNAME_H
+#include <sys/utsname.h>
+#endif
+
+#include <stdarg.h>
+#include <stdint.h> /* for int64_t */
+
+#include "mi.h"
+
+#include <ptrveloc.h> /* dix pointer acceleration */
+#include <xserver-properties.h>
+
+#ifdef XFreeXDGA
+#include "dgaproc.h"
+#endif
+
+#include "xkbsrv.h"
+
+/* Valuator verification macro */
+#define XI_VERIFY_VALUATORS(num_valuators) \
+ if (num_valuators > MAX_VALUATORS) { \
+ xf86Msg(X_ERROR, "%s: num_valuator %d is greater than" \
+ " MAX_VALUATORS\n", __FUNCTION__, num_valuators); \
+ return; \
+ }
+
+static int
+xf86InputDevicePostInit(DeviceIntPtr dev);
+
+/**
+ * Eval config and modify DeviceVelocityRec accordingly
+ */
+static void
+ProcessVelocityConfiguration(DeviceIntPtr pDev, char* devname, pointer list,
+ DeviceVelocityPtr s)
+{
+ int tempi;
+ float tempf;
+ Atom float_prop = XIGetKnownProperty(XATOM_FLOAT);
+ Atom prop;
+
+ if(!s)
+ return;
+
+ /* common settings (available via device properties) */
+ tempf = xf86SetRealOption(list, "ConstantDeceleration", 1.0);
+ if (tempf > 1.0) {
+ xf86Msg(X_CONFIG, "%s: (accel) constant deceleration by %.1f\n",
+ devname, tempf);
+ prop = XIGetKnownProperty(ACCEL_PROP_CONSTANT_DECELERATION);
+ XIChangeDeviceProperty(pDev, prop, float_prop, 32,
+ PropModeReplace, 1, &tempf, FALSE);
+ }
+
+ tempf = xf86SetRealOption(list, "AdaptiveDeceleration", 1.0);
+ if (tempf > 1.0) {
+ xf86Msg(X_CONFIG, "%s: (accel) adaptive deceleration by %.1f\n",
+ devname, tempf);
+ prop = XIGetKnownProperty(ACCEL_PROP_ADAPTIVE_DECELERATION);
+ XIChangeDeviceProperty(pDev, prop, float_prop, 32,
+ PropModeReplace, 1, &tempf, FALSE);
+ }
+
+ /* select profile by number */
+ tempi = xf86SetIntOption(list, "AccelerationProfile",
+ s->statistics.profile_number);
+
+ prop = XIGetKnownProperty(ACCEL_PROP_PROFILE_NUMBER);
+ if (XIChangeDeviceProperty(pDev, prop, XA_INTEGER, 32,
+ PropModeReplace, 1, &tempi, FALSE) == Success) {
+ xf86Msg(X_CONFIG, "%s: (accel) acceleration profile %i\n", devname,
+ tempi);
+ } else {
+ xf86Msg(X_CONFIG, "%s: (accel) acceleration profile %i is unknown\n",
+ devname, tempi);
+ }
+
+ /* set scaling */
+ tempf = xf86SetRealOption(list, "ExpectedRate", 0);
+ prop = XIGetKnownProperty(ACCEL_PROP_VELOCITY_SCALING);
+ if (tempf > 0) {
+ tempf = 1000.0 / tempf;
+ XIChangeDeviceProperty(pDev, prop, float_prop, 32,
+ PropModeReplace, 1, &tempf, FALSE);
+ } else {
+ tempf = xf86SetRealOption(list, "VelocityScale", s->corr_mul);
+ XIChangeDeviceProperty(pDev, prop, float_prop, 32,
+ PropModeReplace, 1, &tempf, FALSE);
+ }
+
+ tempi = xf86SetIntOption(list, "VelocityTrackerCount", -1);
+ if (tempi > 1)
+ InitTrackers(s, tempi);
+
+ s->initial_range = xf86SetIntOption(list, "VelocityInitialRange",
+ s->initial_range);
+
+ s->max_diff = xf86SetRealOption(list, "VelocityAbsDiff", s->max_diff);
+
+ tempf = xf86SetRealOption(list, "VelocityRelDiff", -1);
+ if (tempf >= 0) {
+ xf86Msg(X_CONFIG, "%s: (accel) max rel. velocity difference: %.1f%%\n",
+ devname, tempf*100.0);
+ s->max_rel_diff = tempf;
+ }
+
+ /* Configure softening. If const deceleration is used, this is expected
+ * to provide better subpixel information so we enable
+ * softening by default only if ConstantDeceleration is not used
+ */
+ s->use_softening = xf86SetBoolOption(list, "Softening",
+ s->const_acceleration == 1.0);
+
+ s->average_accel = xf86SetBoolOption(list, "AccelerationProfileAveraging",
+ s->average_accel);
+
+ s->reset_time = xf86SetIntOption(list, "VelocityReset", s->reset_time);
+}
+
+static void
+ApplyAccelerationSettings(DeviceIntPtr dev){
+ int scheme, i;
+ DeviceVelocityPtr pVel;
+ InputInfoPtr pInfo = (InputInfoPtr)dev->public.devicePrivate;
+ char* schemeStr;
+
+ if (dev->valuator && dev->ptrfeed) {
+ schemeStr = xf86SetStrOption(pInfo->options, "AccelerationScheme", "");
+
+ scheme = dev->valuator->accelScheme.number;
+
+ if (!xf86NameCmp(schemeStr, "predictable"))
+ scheme = PtrAccelPredictable;
+
+ if (!xf86NameCmp(schemeStr, "lightweight"))
+ scheme = PtrAccelLightweight;
+
+ if (!xf86NameCmp(schemeStr, "none"))
+ scheme = PtrAccelNoOp;
+
+ /* reinit scheme if needed */
+ if (dev->valuator->accelScheme.number != scheme) {
+ if (dev->valuator->accelScheme.AccelCleanupProc) {
+ dev->valuator->accelScheme.AccelCleanupProc(dev);
+ }
+
+ if (InitPointerAccelerationScheme(dev, scheme)) {
+ xf86Msg(X_CONFIG, "%s: (accel) selected scheme %s/%i\n",
+ pInfo->name, schemeStr, scheme);
+ } else {
+ xf86Msg(X_CONFIG, "%s: (accel) could not init scheme %s\n",
+ pInfo->name, schemeStr);
+ scheme = dev->valuator->accelScheme.number;
+ }
+ } else {
+ xf86Msg(X_CONFIG, "%s: (accel) keeping acceleration scheme %i\n",
+ pInfo->name, scheme);
+ }
+
+ free(schemeStr);
+
+ /* process special configuration */
+ switch (scheme) {
+ case PtrAccelPredictable:
+ pVel = GetDevicePredictableAccelData(dev);
+ ProcessVelocityConfiguration (dev, pInfo->name, pInfo->options,
+ pVel);
+ break;
+ }
+
+ i = xf86SetIntOption(pInfo->options, "AccelerationNumerator",
+ dev->ptrfeed->ctrl.num);
+ if (i >= 0)
+ dev->ptrfeed->ctrl.num = i;
+
+ i = xf86SetIntOption(pInfo->options, "AccelerationDenominator",
+ dev->ptrfeed->ctrl.den);
+ if (i > 0)
+ dev->ptrfeed->ctrl.den = i;
+
+ i = xf86SetIntOption(pInfo->options, "AccelerationThreshold",
+ dev->ptrfeed->ctrl.threshold);
+ if (i >= 0)
+ dev->ptrfeed->ctrl.threshold = i;
+
+ xf86Msg(X_CONFIG, "%s: (accel) acceleration factor: %.3f\n",
+ pInfo->name, ((float)dev->ptrfeed->ctrl.num)/
+ ((float)dev->ptrfeed->ctrl.den));
+ xf86Msg(X_CONFIG, "%s: (accel) acceleration threshold: %i\n",
+ pInfo->name, dev->ptrfeed->ctrl.threshold);
+ }
+}
+
+/***********************************************************************
+ *
+ * xf86ProcessCommonOptions --
+ *
+ * Process global options.
+ *
+ ***********************************************************************
+ */
+void
+xf86ProcessCommonOptions(InputInfoPtr pInfo,
+ pointer list)
+{
+ if (xf86SetBoolOption(list, "Floating", 0) ||
+ !xf86SetBoolOption(list, "AlwaysCore", 1) ||
+ !xf86SetBoolOption(list, "SendCoreEvents", 1) ||
+ !xf86SetBoolOption(list, "CorePointer", 1) ||
+ !xf86SetBoolOption(list, "CoreKeyboard", 1)) {
+ xf86Msg(X_CONFIG, "%s: doesn't report core events\n", pInfo->name);
+ } else {
+ pInfo->flags |= XI86_ALWAYS_CORE;
+ xf86Msg(X_CONFIG, "%s: always reports core events\n", pInfo->name);
+ }
+}
+
+/***********************************************************************
+ *
+ * xf86ActivateDevice --
+ *
+ * Initialize an input device.
+ *
+ * Returns TRUE on success, or FALSE otherwise.
+ ***********************************************************************
+ */
+static DeviceIntPtr
+xf86ActivateDevice(InputInfoPtr pInfo)
+{
+ DeviceIntPtr dev;
+ Atom atom;
+
+ dev = AddInputDevice(serverClient, pInfo->device_control, TRUE);
+
+ if (dev == NULL)
+ {
+ xf86Msg(X_ERROR, "Too many input devices. Ignoring %s\n",
+ pInfo->name);
+ pInfo->dev = NULL;
+ return NULL;
+ }
+
+ atom = MakeAtom(pInfo->type_name, strlen(pInfo->type_name), TRUE);
+ AssignTypeAndName(dev, atom, pInfo->name);
+ dev->public.devicePrivate = pInfo;
+ pInfo->dev = dev;
+
+ dev->coreEvents = pInfo->flags & XI86_ALWAYS_CORE;
+ dev->type = SLAVE;
+ dev->spriteInfo->spriteOwner = FALSE;
+
+ dev->config_info = xf86SetStrOption(pInfo->options, "config_info", NULL);
+
+ if (serverGeneration == 1)
+ xf86Msg(X_INFO, "XINPUT: Adding extended input device \"%s\" (type: %s, id %d)\n",
+ pInfo->name, pInfo->type_name, dev->id);
+
+ return dev;
+}
+
+/****************************************************************************
+ *
+ * Caller: ProcXSetDeviceMode
+ *
+ * Change the mode of an extension device.
+ * This function is used to change the mode of a device from reporting
+ * relative motion to reporting absolute positional information, and
+ * vice versa.
+ * The default implementation below is that no such devices are supported.
+ *
+ ***********************************************************************
+ */
+
+int
+SetDeviceMode (ClientPtr client, DeviceIntPtr dev, int mode)
+{
+ InputInfoPtr pInfo = (InputInfoPtr)dev->public.devicePrivate;
+
+ if (pInfo->switch_mode) {
+ return (*pInfo->switch_mode)(client, dev, mode);
+ }
+ else
+ return BadMatch;
+}
+
+
+/***********************************************************************
+ *
+ * Caller: ProcXSetDeviceValuators
+ *
+ * Set the value of valuators on an extension input device.
+ * This function is used to set the initial value of valuators on
+ * those input devices that are capable of reporting either relative
+ * motion or an absolute position, and allow an initial position to be set.
+ * The default implementation below is that no such devices are supported.
+ *
+ ***********************************************************************
+ */
+
+int
+SetDeviceValuators (ClientPtr client, DeviceIntPtr dev, int *valuators,
+ int first_valuator, int num_valuators)
+{
+ InputInfoPtr pInfo = (InputInfoPtr) dev->public.devicePrivate;
+
+ if (pInfo->set_device_valuators)
+ return (*pInfo->set_device_valuators)(pInfo, valuators, first_valuator,
+ num_valuators);
+
+ return BadMatch;
+}
+
+
+/***********************************************************************
+ *
+ * Caller: ProcXChangeDeviceControl
+ *
+ * Change the specified device controls on an extension input device.
+ *
+ ***********************************************************************
+ */
+
+int
+ChangeDeviceControl (ClientPtr client, DeviceIntPtr dev, xDeviceCtl *control)
+{
+ InputInfoPtr pInfo = (InputInfoPtr)dev->public.devicePrivate;
+
+ if (!pInfo->control_proc) {
+ switch (control->control) {
+ case DEVICE_CORE:
+ case DEVICE_ABS_CALIB:
+ case DEVICE_ABS_AREA:
+ return BadMatch;
+ case DEVICE_RESOLUTION:
+ case DEVICE_ENABLE:
+ return Success;
+ default:
+ return BadMatch;
+ }
+ }
+ else {
+ return (*pInfo->control_proc)(pInfo, control);
+ }
+}
+
+/*
+ * Get the operating system name from uname and store it statically to avoid
+ * repeating the system call each time MatchOS is checked.
+ */
+static const char *
+HostOS(void)
+{
+#ifdef HAVE_SYS_UTSNAME_H
+ struct utsname name;
+ static char host_os[sizeof(name.sysname)] = "";
+
+ if (*host_os == '\0') {
+ if (uname(&name) >= 0)
+ strcpy(host_os, name.sysname);
+ else {
+ strncpy(host_os, "unknown", sizeof(host_os));
+ host_os[sizeof(host_os)-1] = '\0';
+ }
+ }
+ return host_os;
+#else
+ return "";
+#endif
+}
+
+static int
+match_substring(const char *attr, const char *pattern)
+{
+ return (strstr(attr, pattern)) ? 0 : -1;
+}
+
+#ifdef HAVE_FNMATCH_H
+static int
+match_pattern(const char *attr, const char *pattern)
+{
+ return fnmatch(pattern, attr, 0);
+}
+#else
+#define match_pattern match_substring
+#endif
+
+#ifdef HAVE_FNMATCH_H
+static int
+match_path_pattern(const char *attr, const char *pattern)
+{
+ return fnmatch(pattern, attr, FNM_PATHNAME);
+}
+#else
+#define match_path_pattern match_substring
+#endif
+
+/*
+ * If no Layout section is found, xf86ServerLayout.id becomes "(implicit)"
+ * It is convenient that "" in patterns means "no explicit layout"
+ */
+static int
+match_string_implicit(const char *attr, const char *pattern)
+{
+ if (strlen(pattern)) {
+ return strcmp(attr, pattern);
+ } else {
+ return strcmp(attr,"(implicit)");
+ }
+}
+
+/*
+ * Match an attribute against a list of NULL terminated arrays of patterns.
+ * If a pattern in each list entry is matched, return TRUE.
+ */
+static Bool
+MatchAttrToken(const char *attr, struct list *patterns,
+ int (*compare)(const char *attr, const char *pattern))
+{
+ const xf86MatchGroup *group;
+
+ /* If there are no patterns, accept the match */
+ if (list_is_empty(patterns))
+ return TRUE;
+
+ /* If there are patterns but no attribute, reject the match */
+ if (!attr)
+ return FALSE;
+
+ /*
+ * Otherwise, iterate the list of patterns ensuring each entry has a
+ * match. Each list entry is a separate Match line of the same type.
+ */
+ list_for_each_entry(group, patterns, entry) {
+ char * const *cur;
+ Bool match = FALSE;
+
+ for (cur = group->values; *cur; cur++)
+ if ((*compare)(attr, *cur) == 0) {
+ match = TRUE;
+ break;
+ }
+ if (!match)
+ return FALSE;
+ }
+
+ /* All the entries in the list matched the attribute */
+ return TRUE;
+}
+
+/*
+ * Classes without any Match statements match all devices. Otherwise, all
+ * statements must match.
+ */
+static Bool
+InputClassMatches(const XF86ConfInputClassPtr iclass, const InputInfoPtr idev,
+ const InputAttributes *attrs)
+{
+ /* MatchProduct substring */
+ if (!MatchAttrToken(attrs->product, &iclass->match_product, match_substring))
+ return FALSE;
+
+ /* MatchVendor substring */
+ if (!MatchAttrToken(attrs->vendor, &iclass->match_vendor, match_substring))
+ return FALSE;
+
+ /* MatchDevicePath pattern */
+ if (!MatchAttrToken(attrs->device, &iclass->match_device, match_path_pattern))
+ return FALSE;
+
+ /* MatchOS case-insensitive string */
+ if (!MatchAttrToken(HostOS(), &iclass->match_os, strcasecmp))
+ return FALSE;
+
+ /* MatchPnPID pattern */
+ if (!MatchAttrToken(attrs->pnp_id, &iclass->match_pnpid, match_pattern))
+ return FALSE;
+
+ /* MatchUSBID pattern */
+ if (!MatchAttrToken(attrs->usb_id, &iclass->match_usbid, match_pattern))
+ return FALSE;
+
+ /* MatchDriver string */
+ if (!MatchAttrToken(idev->driver, &iclass->match_driver, strcmp))
+ return FALSE;
+
+ /*
+ * MatchTag string
+ * See if any of the device's tags match any of the MatchTag tokens.
+ */
+ if (!list_is_empty(&iclass->match_tag)) {
+ char * const *tag;
+ Bool match;
+
+ if (!attrs->tags)
+ return FALSE;
+ for (tag = attrs->tags, match = FALSE; *tag; tag++) {
+ if (MatchAttrToken(*tag, &iclass->match_tag, strcmp)) {
+ match = TRUE;
+ break;
+ }
+ }
+ if (!match)
+ return FALSE;
+ }
+
+ /* MatchLayout string */
+ if (!list_is_empty(&iclass->match_layout)) {
+ if (!MatchAttrToken(xf86ConfigLayout.id,
+ &iclass->match_layout, match_string_implicit))
+ return FALSE;
+ }
+
+ /* MatchIs* booleans */
+ if (iclass->is_keyboard.set &&
+ iclass->is_keyboard.val != !!(attrs->flags & ATTR_KEYBOARD))
+ return FALSE;
+ if (iclass->is_pointer.set &&
+ iclass->is_pointer.val != !!(attrs->flags & ATTR_POINTER))
+ return FALSE;
+ if (iclass->is_joystick.set &&
+ iclass->is_joystick.val != !!(attrs->flags & ATTR_JOYSTICK))
+ return FALSE;
+ if (iclass->is_tablet.set &&
+ iclass->is_tablet.val != !!(attrs->flags & ATTR_TABLET))
+ return FALSE;
+ if (iclass->is_touchpad.set &&
+ iclass->is_touchpad.val != !!(attrs->flags & ATTR_TOUCHPAD))
+ return FALSE;
+ if (iclass->is_touchscreen.set &&
+ iclass->is_touchscreen.val != !!(attrs->flags & ATTR_TOUCHSCREEN))
+ return FALSE;
+
+ return TRUE;
+}
+
+/*
+ * Merge in any InputClass configurations. Options in each InputClass
+ * section have more priority than the original device configuration as
+ * well as any previous InputClass sections.
+ */
+static int
+MergeInputClasses(const InputInfoPtr idev, const InputAttributes *attrs)
+{
+ XF86ConfInputClassPtr cl;
+ XF86OptionPtr classopts;
+
+ for (cl = xf86configptr->conf_inputclass_lst; cl; cl = cl->list.next) {
+ if (!InputClassMatches(cl, idev, attrs))
+ continue;
+
+ /* Collect class options and driver settings */
+ classopts = xf86optionListDup(cl->option_lst);
+ if (cl->driver) {
+ free(idev->driver);
+ idev->driver = xstrdup(cl->driver);
+ if (!idev->driver) {
+ xf86Msg(X_ERROR, "Failed to allocate memory while merging "
+ "InputClass configuration");
+ return BadAlloc;
+ }
+ classopts = xf86ReplaceStrOption(classopts, "driver",
+ idev->driver);
+ }
+
+ /* Apply options to device with InputClass settings preferred. */
+ xf86Msg(X_CONFIG, "%s: Applying InputClass \"%s\"\n",
+ idev->name, cl->identifier);
+ idev->options = xf86optionListMerge(idev->options, classopts);
+ }
+
+ return Success;
+}
+
+/*
+ * Iterate the list of classes and look for Option "Ignore". Return the
+ * value of the last matching class and holler when returning TRUE.
+ */
+static Bool
+IgnoreInputClass(const InputInfoPtr idev, const InputAttributes *attrs)
+{
+ XF86ConfInputClassPtr cl;
+ Bool ignore = FALSE;
+ const char *ignore_class;
+
+ for (cl = xf86configptr->conf_inputclass_lst; cl; cl = cl->list.next) {
+ if (!InputClassMatches(cl, idev, attrs))
+ continue;
+ if (xf86findOption(cl->option_lst, "Ignore")) {
+ ignore = xf86CheckBoolOption(cl->option_lst, "Ignore", FALSE);
+ ignore_class = cl->identifier;
+ }
+ }
+
+ if (ignore)
+ xf86Msg(X_CONFIG, "%s: Ignoring device from InputClass \"%s\"\n",
+ idev->name, ignore_class);
+ return ignore;
+}
+
+InputInfoPtr
+xf86AllocateInput(void)
+{
+ InputInfoPtr pInfo;
+
+ pInfo = calloc(sizeof(*pInfo), 1);
+ if (!pInfo)
+ return NULL;
+
+ pInfo->fd = -1;
+ pInfo->type_name = "UNKNOWN";
+
+ return pInfo;
+}
+
+/* Append InputInfoRec to the tail of xf86InputDevs. */
+static void
+xf86AddInput(InputDriverPtr drv, InputInfoPtr pInfo)
+{
+ InputInfoPtr *prev = NULL;
+
+ pInfo->drv = drv;
+ pInfo->module = DuplicateModule(drv->module, NULL);
+
+ for (prev = &xf86InputDevs; *prev; prev = &(*prev)->next)
+ ;
+
+ *prev = pInfo;
+ pInfo->next = NULL;
+
+ xf86CollectInputOptions(pInfo, (const char**)drv->default_options);
+ xf86OptionListReport(pInfo->options);
+ xf86ProcessCommonOptions(pInfo, pInfo->options);
+}
+
+/*
+ * Remove an entry from xf86InputDevs and free all the device's information.
+ */
+void
+xf86DeleteInput(InputInfoPtr pInp, int flags)
+{
+ /* First check if the inputdev is valid. */
+ if (pInp == NULL)
+ return;
+
+ if (pInp->module)
+ UnloadModule(pInp->module);
+
+ /* This should *really* be handled in drv->UnInit(dev) call instead, but
+ * if the driver forgets about it make sure we free it or at least crash
+ * with flying colors */
+ free(pInp->private);
+
+ FreeInputAttributes(pInp->attrs);
+
+ /* Remove the entry from the list. */
+ if (pInp == xf86InputDevs)
+ xf86InputDevs = pInp->next;
+ else {
+ InputInfoPtr p = xf86InputDevs;
+ while (p && p->next != pInp)
+ p = p->next;
+ if (p)
+ p->next = pInp->next;
+ /* Else the entry wasn't in the xf86InputDevs list (ignore this). */
+ }
+
+ free(pInp->driver);
+ free(pInp->name);
+ xf86optionListFree(pInp->options);
+ free(pInp);
+}
+
+/*
+ * Apply backend-specific initialization. Invoked after ActiveteDevice(),
+ * i.e. after the driver successfully completed DEVICE_INIT and the device
+ * is advertised.
+ * @param dev the device
+ * @return Success or an error code
+ */
+static int
+xf86InputDevicePostInit(DeviceIntPtr dev) {
+ ApplyAccelerationSettings(dev);
+ return Success;
+}
+
+/**
+ * Create a new input device, activate and enable it.
+ *
+ * Possible return codes:
+ * BadName .. a bad driver name was supplied.
+ * BadImplementation ... The driver does not have a PreInit function. This
+ * is a driver bug.
+ * BadMatch .. device initialization failed.
+ * BadAlloc .. too many input devices
+ *
+ * @param idev The device, already set up with identifier, driver, and the
+ * options.
+ * @param pdev Pointer to the new device, if Success was reported.
+ * @param enable Enable the device after activating it.
+ *
+ * @return Success or an error code
+ */
+_X_INTERNAL int
+xf86NewInputDevice(InputInfoPtr pInfo, DeviceIntPtr *pdev, BOOL enable)
+{
+ InputDriverPtr drv = NULL;
+ DeviceIntPtr dev = NULL;
+ int rval;
+
+ /* Memory leak for every attached device if we don't
+ * test if the module is already loaded first */
+ drv = xf86LookupInputDriver(pInfo->driver);
+ if (!drv)
+ if (xf86LoadOneModule(pInfo->driver, NULL))
+ drv = xf86LookupInputDriver(pInfo->driver);
+ if (!drv) {
+ xf86Msg(X_ERROR, "No input driver matching `%s'\n", pInfo->driver);
+ rval = BadName;
+ goto unwind;
+ }
+
+ xf86Msg(X_INFO, "Using input driver '%s' for '%s'\n", drv->driverName, pInfo->name);
+
+ if (!drv->PreInit) {
+ xf86Msg(X_ERROR,
+ "Input driver `%s' has no PreInit function (ignoring)\n",
+ drv->driverName);
+ rval = BadImplementation;
+ goto unwind;
+ }
+
+ xf86AddInput(drv, pInfo);
+
+ rval = drv->PreInit(drv, pInfo, 0);
+
+ if (rval != Success) {
+ xf86Msg(X_ERROR, "PreInit returned %d for \"%s\"\n", rval, pInfo->name);
+ goto unwind;
+ }
+
+ if (!(dev = xf86ActivateDevice(pInfo)))
+ {
+ rval = BadAlloc;
+ goto unwind;
+ }
+
+ rval = ActivateDevice(dev, TRUE);
+ if (rval != Success)
+ {
+ xf86Msg(X_ERROR, "Couldn't init device \"%s\"\n", pInfo->name);
+ RemoveDevice(dev, TRUE);
+ goto unwind;
+ }
+
+ rval = xf86InputDevicePostInit(dev);
+ if (rval != Success)
+ {
+ xf86Msg(X_ERROR, "Couldn't post-init device \"%s\"\n", pInfo->name);
+ RemoveDevice(dev, TRUE);
+ goto unwind;
+ }
+
+ /* Enable it if it's properly initialised and we're currently in the VT */
+ if (enable && dev->inited && dev->startup && xf86Screens[0]->vtSema)
+ {
+ OsBlockSignals();
+ EnableDevice(dev, TRUE);
+ if (!dev->enabled)
+ {
+ OsReleaseSignals();
+ xf86Msg(X_ERROR, "Couldn't init device \"%s\"\n", pInfo->name);
+ RemoveDevice(dev, TRUE);
+ rval = BadMatch;
+ goto unwind;
+ }
+ /* send enter/leave event, update sprite window */
+ CheckMotion(NULL, dev);
+ OsReleaseSignals();
+ }
+
+ *pdev = dev;
+ return Success;
+
+unwind:
+ if(pInfo) {
+ if(drv && drv->UnInit)
+ drv->UnInit(drv, pInfo, 0);
+ else
+ xf86DeleteInput(pInfo, 0);
+ }
+ return rval;
+}
+
+int
+NewInputDeviceRequest (InputOption *options, InputAttributes *attrs,
+ DeviceIntPtr *pdev)
+{
+ InputInfoPtr pInfo = NULL;
+ InputOption *option = NULL;
+ int rval = Success;
+ int is_auto = 0;
+
+ pInfo = xf86AllocateInput();
+ if (!pInfo)
+ return BadAlloc;
+
+ for (option = options; option; option = option->next) {
+ if (strcasecmp(option->key, "driver") == 0) {
+ if (pInfo->driver) {
+ rval = BadRequest;
+ goto unwind;
+ }
+ pInfo->driver = xstrdup(option->value);
+ if (!pInfo->driver) {
+ rval = BadAlloc;
+ goto unwind;
+ }
+ }
+
+ if (strcasecmp(option->key, "name") == 0 ||
+ strcasecmp(option->key, "identifier") == 0) {
+ if (pInfo->name) {
+ rval = BadRequest;
+ goto unwind;
+ }
+ pInfo->name = xstrdup(option->value);
+ if (!pInfo->name) {
+ rval = BadAlloc;
+ goto unwind;
+ }
+ }
+
+ if (strcmp(option->key, "_source") == 0 &&
+ (strcmp(option->value, "server/hal") == 0 ||
+ strcmp(option->value, "server/udev") == 0)) {
+ is_auto = 1;
+ if (!xf86Info.autoAddDevices) {
+ rval = BadMatch;
+ goto unwind;
+ }
+ }
+ }
+
+ for (option = options; option; option = option->next) {
+ /* Steal option key/value strings from the provided list.
+ * We need those strings, the InputOption list doesn't. */
+ pInfo->options = xf86addNewOption(pInfo->options,
+ option->key, option->value);
+ option->key = NULL;
+ option->value = NULL;
+ }
+
+ /* Apply InputClass settings */
+ if (attrs) {
+ if (IgnoreInputClass(pInfo, attrs)) {
+ rval = BadIDChoice;
+ goto unwind;
+ }
+
+ rval = MergeInputClasses(pInfo, attrs);
+ if (rval != Success)
+ goto unwind;
+
+ pInfo->attrs = DuplicateInputAttributes(attrs);
+ }
+
+ if (!pInfo->driver || !pInfo->name) {
+ xf86Msg(X_INFO, "No input driver/identifier specified (ignoring)\n");
+ rval = BadRequest;
+ goto unwind;
+ }
+
+ if (!pInfo->name) {
+ xf86Msg(X_ERROR, "No device identifier specified (ignoring)\n");
+ rval = BadMatch;
+ goto unwind;
+ }
+
+ rval = xf86NewInputDevice(pInfo, pdev,
+ (!is_auto || (is_auto && xf86Info.autoEnableDevices)));
+
+ return rval;
+
+unwind:
+ if (is_auto && !xf86Info.autoAddDevices)
+ xf86Msg(X_INFO, "AutoAddDevices is off - not adding device.\n");
+ xf86DeleteInput(pInfo, 0);
+ return rval;
+}
+
+void
+DeleteInputDeviceRequest(DeviceIntPtr pDev)
+{
+ InputInfoPtr pInfo = (InputInfoPtr) pDev->public.devicePrivate;
+ InputDriverPtr drv = NULL;
+ Bool isMaster = IsMaster(pDev);
+
+ if (pInfo) /* need to get these before RemoveDevice */
+ drv = pInfo->drv;
+
+ OsBlockSignals();
+ RemoveDevice(pDev, TRUE);
+
+ if (!isMaster && pInfo != NULL)
+ {
+ if(drv->UnInit)
+ drv->UnInit(drv, pInfo, 0);
+ else
+ xf86DeleteInput(pInfo, 0);
+ }
+ OsReleaseSignals();
+}
+
+/*
+ * convenient functions to post events
+ */
+
+void
+xf86PostMotionEvent(DeviceIntPtr device,
+ int is_absolute,
+ int first_valuator,
+ int num_valuators,
+ ...)
+{
+ va_list var;
+ int i = 0;
+ ValuatorMask mask;
+
+ XI_VERIFY_VALUATORS(num_valuators);
+
+ valuator_mask_zero(&mask);
+ va_start(var, num_valuators);
+ for (i = 0; i < num_valuators; i++)
+ valuator_mask_set(&mask, first_valuator + i, va_arg(var, int));
+ va_end(var);
+
+ xf86PostMotionEventM(device, is_absolute, &mask);
+}
+
+void
+xf86PostMotionEventP(DeviceIntPtr device,
+ int is_absolute,
+ int first_valuator,
+ int num_valuators,
+ const int *valuators)
+{
+ ValuatorMask mask;
+
+ XI_VERIFY_VALUATORS(num_valuators);
+
+ valuator_mask_set_range(&mask, first_valuator, num_valuators, valuators);
+ xf86PostMotionEventM(device, is_absolute, &mask);
+}
+
+void
+xf86PostMotionEventM(DeviceIntPtr device,
+ int is_absolute,
+ const ValuatorMask *mask)
+{
+ int flags = 0;
+
+ if (valuator_mask_num_valuators(mask) > 0)
+ {
+ if (is_absolute)
+ flags = POINTER_ABSOLUTE;
+ else
+ flags = POINTER_RELATIVE | POINTER_ACCELERATE;
+ }
+
+#if XFreeXDGA
+ /* The evdev driver may not always send all axes across. */
+ if (valuator_mask_isset(mask, 0) ||
+ valuator_mask_isset(mask, 1))
+ if (miPointerGetScreen(device)) {
+ int index = miPointerGetScreen(device)->myNum;
+ int dx = 0, dy = 0;
+
+ if (valuator_mask_isset(mask, 0))
+ {
+ dx = valuator_mask_get(mask, 0);
+ if (is_absolute)
+ dx -= device->last.valuators[0];
+ }
+
+ if (valuator_mask_isset(mask, 1))
+ {
+ dy = valuator_mask_get(mask, 1);
+ if (is_absolute)
+ dy -= device->last.valuators[1];
+ }
+
+ if (DGAStealMotionEvent(device, index, dx, dy))
+ return;
+ }
+#endif
+
+ QueuePointerEvents(device, MotionNotify, 0, flags, mask);
+}
+
+void
+xf86PostProximityEvent(DeviceIntPtr device,
+ int is_in,
+ int first_valuator,
+ int num_valuators,
+ ...)
+{
+ va_list var;
+ int i;
+ ValuatorMask mask;
+
+ XI_VERIFY_VALUATORS(num_valuators);
+
+ valuator_mask_zero(&mask);
+ va_start(var, num_valuators);
+ for (i = 0; i < num_valuators; i++)
+ valuator_mask_set(&mask, first_valuator + i, va_arg(var, int));
+ va_end(var);
+
+ xf86PostProximityEventM(device, is_in, &mask);
+}
+
+void
+xf86PostProximityEventP(DeviceIntPtr device,
+ int is_in,
+ int first_valuator,
+ int num_valuators,
+ const int *valuators)
+{
+ ValuatorMask mask;
+
+ XI_VERIFY_VALUATORS(num_valuators);
+
+ valuator_mask_set_range(&mask, first_valuator, num_valuators, valuators);
+ xf86PostProximityEventM(device, is_in, &mask);
+}
+
+void
+xf86PostProximityEventM(DeviceIntPtr device,
+ int is_in,
+ const ValuatorMask *mask)
+{
+ QueueProximityEvents(device, is_in ? ProximityIn : ProximityOut, mask);
+}
+
+void
+xf86PostButtonEvent(DeviceIntPtr device,
+ int is_absolute,
+ int button,
+ int is_down,
+ int first_valuator,
+ int num_valuators,
+ ...)
+{
+ va_list var;
+ ValuatorMask mask;
+ int i = 0;
+
+ XI_VERIFY_VALUATORS(num_valuators);
+
+ valuator_mask_zero(&mask);
+
+ va_start(var, num_valuators);
+ for (i = 0; i < num_valuators; i++)
+ valuator_mask_set(&mask, first_valuator + i, va_arg(var, int));
+ va_end(var);
+
+ xf86PostButtonEventM(device, is_absolute, button, is_down, &mask);
+}
+
+void
+xf86PostButtonEventP(DeviceIntPtr device,
+ int is_absolute,
+ int button,
+ int is_down,
+ int first_valuator,
+ int num_valuators,
+ const int *valuators)
+{
+ ValuatorMask mask;
+
+ XI_VERIFY_VALUATORS(num_valuators);
+
+ valuator_mask_set_range(&mask, first_valuator, num_valuators, valuators);
+ xf86PostButtonEventM(device, is_absolute, button, is_down, &mask);
+}
+
+void
+xf86PostButtonEventM(DeviceIntPtr device,
+ int is_absolute,
+ int button,
+ int is_down,
+ const ValuatorMask *mask)
+{
+ int flags = 0;
+
+ if (valuator_mask_num_valuators(mask) > 0)
+ {
+ if (is_absolute)
+ flags = POINTER_ABSOLUTE;
+ else
+ flags = POINTER_RELATIVE | POINTER_ACCELERATE;
+ }
+
+#if XFreeXDGA
+ if (miPointerGetScreen(device)) {
+ int index = miPointerGetScreen(device)->myNum;
+
+ if (DGAStealButtonEvent(device, index, button, is_down))
+ return;
+ }
+#endif
+
+ QueuePointerEvents(device,
+ is_down ? ButtonPress : ButtonRelease, button,
+ flags, mask);
+}
+
+void
+xf86PostKeyEvent(DeviceIntPtr device,
+ unsigned int key_code,
+ int is_down,
+ int is_absolute,
+ int first_valuator,
+ int num_valuators,
+ ...)
+{
+ va_list var;
+ int i = 0;
+ ValuatorMask mask;
+
+ XI_VERIFY_VALUATORS(num_valuators);
+
+ valuator_mask_zero(&mask);
+
+ va_start(var, num_valuators);
+ for (i = 0; i < num_valuators; i++)
+ valuator_mask_set(&mask, first_valuator + i, va_arg(var, int));
+ va_end(var);
+
+ xf86PostKeyEventM(device, key_code, is_down, is_absolute, &mask);
+}
+
+void
+xf86PostKeyEventP(DeviceIntPtr device,
+ unsigned int key_code,
+ int is_down,
+ int is_absolute,
+ int first_valuator,
+ int num_valuators,
+ const int *valuators)
+{
+ ValuatorMask mask;
+
+ XI_VERIFY_VALUATORS(num_valuators);
+
+ valuator_mask_set_range(&mask, first_valuator, num_valuators, valuators);
+ xf86PostKeyEventM(device, key_code, is_down, is_absolute, &mask);
+}
+
+void
+xf86PostKeyEventM(DeviceIntPtr device,
+ unsigned int key_code,
+ int is_down,
+ int is_absolute,
+ const ValuatorMask *mask)
+{
+#if XFreeXDGA
+ DeviceIntPtr pointer;
+
+ /* Some pointers send key events, paired device is wrong then. */
+ pointer = IsPointerDevice(device) ? device : GetPairedDevice(device);
+ if (miPointerGetScreen(pointer)) {
+ int index = miPointerGetScreen(pointer)->myNum;
+
+ if (DGAStealKeyEvent(device, index, key_code, is_down))
+ return;
+ }
+#endif
+
+ QueueKeyboardEvents(device,
+ is_down ? KeyPress : KeyRelease,
+ key_code, mask);
+}
+
+void
+xf86PostKeyboardEvent(DeviceIntPtr device,
+ unsigned int key_code,
+ int is_down)
+{
+ ValuatorMask mask;
+
+ valuator_mask_zero(&mask);
+ xf86PostKeyEventM(device, key_code, is_down, 0, &mask);
+}
+
+InputInfoPtr
+xf86FirstLocalDevice(void)
+{
+ return xf86InputDevs;
+}
+
+/*
+ * Cx - raw data from touch screen
+ * to_max - scaled highest dimension
+ * (remember, this is of rows - 1 because of 0 origin)
+ * to_min - scaled lowest dimension
+ * from_max - highest raw value from touch screen calibration
+ * from_min - lowest raw value from touch screen calibration
+ *
+ * This function is the same for X or Y coordinates.
+ * You may have to reverse the high and low values to compensate for
+ * different orgins on the touch screen vs X.
+ *
+ * e.g. to scale from device coordinates into screen coordinates, call
+ * xf86ScaleAxis(x, 0, screen_width, dev_min, dev_max);
+ */
+
+int
+xf86ScaleAxis(int Cx,
+ int to_max,
+ int to_min,
+ int from_max,
+ int from_min )
+{
+ int X;
+ int64_t to_width = to_max - to_min;
+ int64_t from_width = from_max - from_min;
+
+ if (from_width) {
+ X = (int)(((to_width * (Cx - from_min)) / from_width) + to_min);
+ }
+ else {
+ X = 0;
+ ErrorF ("Divide by Zero in xf86ScaleAxis\n");
+ }
+
+ if (X > to_max)
+ X = to_max;
+ if (X < to_min)
+ X = to_min;
+
+ return X;
+}
+
+/*
+ * This function checks the given screen against the current screen and
+ * makes changes if appropriate. It should be called from an XInput driver's
+ * ReadInput function before any events are posted, if the device is screen
+ * specific like a touch screen.
+ */
+void
+xf86XInputSetScreen(InputInfoPtr pInfo,
+ int screen_number,
+ int x,
+ int y)
+{
+ if (miPointerGetScreen(pInfo->dev) !=
+ screenInfo.screens[screen_number]) {
+ miPointerSetScreen(pInfo->dev, screen_number, x, y);
+ }
+}
+
+
+void
+xf86InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, Atom label, int minval, int maxval,
+ int resolution, int min_res, int max_res, int mode)
+{
+ if (!dev || !dev->valuator)
+ return;
+
+ InitValuatorAxisStruct(dev, axnum, label, minval, maxval, resolution, min_res,
+ max_res, mode);
+}
+
+/*
+ * Set the valuator values to be in synch with dix/event.c
+ * DefineInitialRootWindow().
+ */
+void
+xf86InitValuatorDefaults(DeviceIntPtr dev, int axnum)
+{
+ if (axnum == 0) {
+ dev->valuator->axisVal[0] = screenInfo.screens[0]->width / 2;
+ dev->last.valuators[0] = dev->valuator->axisVal[0];
+ }
+ else if (axnum == 1) {
+ dev->valuator->axisVal[1] = screenInfo.screens[0]->height / 2;
+ dev->last.valuators[1] = dev->valuator->axisVal[1];
+ }
+}
+
+
+/**
+ * Deactivate a device. Call this function from the driver if you receive a
+ * read error or something else that spoils your day.
+ * Device will be moved to the off_devices list, but it will still be there
+ * until you really clean up after it.
+ * Notifies the client about an inactive device.
+ *
+ * @param panic True if device is unrecoverable and needs to be removed.
+ */
+void
+xf86DisableDevice(DeviceIntPtr dev, Bool panic)
+{
+ if(!panic)
+ {
+ DisableDevice(dev, TRUE);
+ } else
+ {
+ SendDevicePresenceEvent(dev->id, DeviceUnrecoverable);
+ DeleteInputDeviceRequest(dev);
+ }
+}
+
+/**
+ * Reactivate a device. Call this function from the driver if you just found
+ * out that the read error wasn't quite that bad after all.
+ * Device will be re-activated, and an event sent to the client.
+ */
+void
+xf86EnableDevice(DeviceIntPtr dev)
+{
+ EnableDevice(dev, TRUE);
+}
+
+/* end of xf86Xinput.c */
diff --git a/xorg-server/hw/xfree86/common/xf86sbusBus.c b/xorg-server/hw/xfree86/common/xf86sbusBus.c
index 6e6ab948f..181c6ab00 100644
--- a/xorg-server/hw/xfree86/common/xf86sbusBus.c
+++ b/xorg-server/hw/xfree86/common/xf86sbusBus.c
@@ -1,714 +1,714 @@
-/*
- * SBUS bus-specific code.
- *
- * Copyright (C) 2000 Jakub Jelinek (jakub@redhat.com)
- *
- * 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
- * JAKUB JELINEK 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_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <ctype.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <X11/X.h>
-#include "os.h"
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-#include "xf86cmap.h"
-
-#include "xf86Bus.h"
-
-#include "xf86sbusBus.h"
-#include "xf86Sbus.h"
-
-Bool sbusSlotClaimed = FALSE;
-
-static int xf86nSbusInfo;
-
-static void
-CheckSbusDevice(const char *device, int fbNum)
-{
- int fd, i;
- struct fbgattr fbattr;
- sbusDevicePtr psdp;
-
- fd = open(device, O_RDONLY, 0);
- if (fd < 0)
- return;
- memset(&fbattr, 0, sizeof(fbattr));
- if (ioctl(fd, FBIOGATTR, &fbattr) < 0) {
- if (ioctl(fd, FBIOGTYPE, &fbattr.fbtype) < 0) {
- close(fd);
- return;
- }
- }
- close(fd);
- for (i = 0; sbusDeviceTable[i].devId; i++)
- if (sbusDeviceTable[i].fbType == fbattr.fbtype.fb_type)
- break;
- if (! sbusDeviceTable[i].devId)
- return;
- xf86SbusInfo = xnfrealloc(xf86SbusInfo, sizeof(psdp) * (++xf86nSbusInfo + 1));
- xf86SbusInfo[xf86nSbusInfo] = NULL;
- xf86SbusInfo[xf86nSbusInfo - 1] = psdp = xnfcalloc(sizeof (sbusDevice), 1);
- psdp->devId = sbusDeviceTable[i].devId;
- psdp->fbNum = fbNum;
- psdp->device = xnfstrdup(device);
- psdp->width = fbattr.fbtype.fb_width;
- psdp->height = fbattr.fbtype.fb_height;
- psdp->fd = -1;
-}
-
-void
-xf86SbusProbe(void)
-{
- int i, useProm = 0;
- char fbDevName[32];
- sbusDevicePtr psdp, *psdpp;
-
- xf86SbusInfo = malloc(sizeof(psdp));
- *xf86SbusInfo = NULL;
- for (i = 0; i < 32; i++) {
- sprintf(fbDevName, "/dev/fb%d", i);
- CheckSbusDevice(fbDevName, i);
- }
- if (sparcPromInit() >= 0) {
- useProm = 1;
- sparcPromAssignNodes();
- }
- for (psdpp = xf86SbusInfo; (psdp = *psdpp); psdpp++) {
- for (i = 0; sbusDeviceTable[i].devId; i++)
- if (sbusDeviceTable[i].devId == psdp->devId)
- psdp->descr = sbusDeviceTable[i].descr;
- /*
- * If we can use PROM information and found the PROM node for this
- * device, we can tell more about the card.
- */
- if (useProm && psdp->node.node) {
- char *prop, *promPath;
- int len, chiprev, vmsize;
-
- switch (psdp->devId) {
- case SBUS_DEVICE_MGX:
- prop = sparcPromGetProperty(&psdp->node, "fb_size", &len);
- if (prop && len == 4 && *(int *)prop == 0x400000)
- psdp->descr = "Quantum 3D MGXplus with 4M VRAM";
- break;
- case SBUS_DEVICE_CG6:
- chiprev = 0;
- vmsize = 0;
- prop = sparcPromGetProperty(&psdp->node, "chiprev", &len);
- if (prop && len == 4)
- chiprev = *(int *)prop;
- prop = sparcPromGetProperty(&psdp->node, "vmsize", &len);
- if (prop && len == 4)
- vmsize = *(int *)prop;
- switch (chiprev) {
- case 1:
- case 2:
- case 3:
- case 4:
- psdp->descr = "Sun Double width GX"; break;
- case 5:
- case 6:
- case 7:
- case 8:
- case 9:
- psdp->descr = "Sun Single width GX"; break;
- case 11:
- switch (vmsize) {
- case 2:
- psdp->descr = "Sun Turbo GX with 1M VSIMM"; break;
- case 4:
- psdp->descr = "Sun Turbo GX Plus"; break;
- default:
- psdp->descr = "Sun Turbo GX"; break;
- }
- }
- break;
- case SBUS_DEVICE_CG14:
- prop = sparcPromGetProperty(&psdp->node, "reg", &len);
- vmsize = 0;
- if (prop && !(len % 12) && len > 0)
- vmsize = *(int *)(prop + len - 4);
- switch (vmsize) {
- case 0x400000:
- psdp->descr = "Sun SX with 4M VSIMM"; break;
- case 0x800000:
- psdp->descr = "Sun SX with 8M VSIMM"; break;
- }
- break;
- case SBUS_DEVICE_LEO:
- prop = sparcPromGetProperty(&psdp->node, "model", &len);
- if (prop && len > 0 && !strstr(prop, "501-2503"))
- psdp->descr = "Sun Turbo ZX";
- break;
- case SBUS_DEVICE_TCX:
- if (sparcPromGetBool(&psdp->node, "tcx-8-bit"))
- psdp->descr = "Sun TCX (8bit)";
- else
- psdp->descr = "Sun TCX (S24)";
- break;
- case SBUS_DEVICE_FFB:
- prop = sparcPromGetProperty(&psdp->node, "name", &len);
- chiprev = 0;
- prop = sparcPromGetProperty(&psdp->node, "board_type", &len);
- if (prop && len == 4)
- chiprev = *(int *)prop;
- if (strstr (prop, "afb")) {
- if (chiprev == 3)
- psdp->descr = "Sun|Elite3D-M6 Horizontal";
- } else {
- switch (chiprev) {
- case 0x08:
- psdp->descr = "Sun FFB 67MHz Creator"; break;
- case 0x0b:
- psdp->descr = "Sun FFB 67MHz Creator 3D"; break;
- case 0x1b:
- psdp->descr = "Sun FFB 75MHz Creator 3D"; break;
- case 0x20:
- case 0x28:
- psdp->descr = "Sun FFB2 Vertical Creator"; break;
- case 0x23:
- case 0x2b:
- psdp->descr = "Sun FFB2 Vertical Creator 3D"; break;
- case 0x30:
- psdp->descr = "Sun FFB2+ Vertical Creator"; break;
- case 0x33:
- psdp->descr = "Sun FFB2+ Vertical Creator 3D"; break;
- case 0x40:
- case 0x48:
- psdp->descr = "Sun FFB2 Horizontal Creator"; break;
- case 0x43:
- case 0x4b:
- psdp->descr = "Sun FFB2 Horizontal Creator 3D"; break;
- }
- }
- break;
- }
-
- xf86Msg(X_PROBED, "SBUS:(0x%08x) %s", psdp->node.node, psdp->descr);
- promPath = sparcPromNode2Pathname (&psdp->node);
- if (promPath) {
- xf86ErrorF(" at %s", promPath);
- free(promPath);
- }
- } else
- xf86Msg(X_PROBED, "SBUS: %s", psdp->descr);
- xf86ErrorF("\n");
- }
- if (useProm)
- sparcPromClose();
-}
-
-/*
- * Parse a BUS ID string, and return the SBUS bus parameters if it was
- * in the correct format for a SBUS bus id.
- */
-
-Bool
-xf86ParseSbusBusString(const char *busID, int *fbNum)
-{
- /*
- * The format is assumed to be one of:
- * "fbN", e.g. "fb1", which means the device corresponding to /dev/fbN
- * "nameN", e.g. "cgsix0", which means Nth instance of card NAME
- * "/prompath", e.g. "/sbus@0,10001000/cgsix@3,0" which is PROM pathname
- * to the device.
- */
-
- const char *id;
- int i, len;
-
- if (StringToBusType(busID, &id) != BUS_SBUS)
- return FALSE;
-
- if (*id != '/') {
- if (!strncmp (id, "fb", 2)) {
- if (!isdigit(id[2]))
- return FALSE;
- *fbNum = atoi(id + 2);
- return TRUE;
- } else {
- sbusDevicePtr *psdpp;
- int devId;
-
- for (i = 0, len = 0; sbusDeviceTable[i].devId; i++) {
- len = strlen(sbusDeviceTable[i].promName);
- if (!strncmp (sbusDeviceTable[i].promName, id, len)
- && isdigit(id[len]))
- break;
- }
- devId = sbusDeviceTable[i].devId;
- if (!devId) return FALSE;
- i = atoi(id + len);
- for (psdpp = xf86SbusInfo; *psdpp; ++psdpp) {
- if ((*psdpp)->devId != devId)
- continue;
- if (!i) {
- *fbNum = (*psdpp)->fbNum;
- return TRUE;
- }
- i--;
- }
- }
- return FALSE;
- }
-
- if (sparcPromInit() >= 0) {
- i = sparcPromPathname2Node(id);
- sparcPromClose();
- if (i) {
- sbusDevicePtr *psdpp;
- for (psdpp = xf86SbusInfo; *psdpp; ++psdpp) {
- if ((*psdpp)->node.node == i) {
- *fbNum = (*psdpp)->fbNum;
- return TRUE;
- }
- }
- }
- }
- return FALSE;
-}
-
-/*
- * Compare a BUS ID string with a SBUS bus id. Return TRUE if they match.
- */
-
-Bool
-xf86CompareSbusBusString(const char *busID, int fbNum)
-{
- int iFbNum;
-
- if (xf86ParseSbusBusString(busID, &iFbNum)) {
- return fbNum == iFbNum;
- } else {
- return FALSE;
- }
-}
-
-/*
- * Check if the slot requested is free. If it is already in use, return FALSE.
- */
-
-Bool
-xf86CheckSbusSlot(int fbNum)
-{
- int i;
- EntityPtr p;
-
- for (i = 0; i < xf86NumEntities; i++) {
- p = xf86Entities[i];
- /* Check if this SBUS slot is taken */
- if (p->bus.type == BUS_SBUS && p->bus.id.sbus.fbNum == fbNum)
- return FALSE;
- }
-
- return TRUE;
-}
-
-/*
- * If the slot requested is already in use, return -1.
- * Otherwise, claim the slot for the screen requesting it.
- */
-
-int
-xf86ClaimSbusSlot(sbusDevicePtr psdp, DriverPtr drvp,
- GDevPtr dev, Bool active)
-{
- EntityPtr p = NULL;
-
- int num;
-
- if (xf86CheckSbusSlot(psdp->fbNum)) {
- num = xf86AllocateEntity();
- p = xf86Entities[num];
- p->driver = drvp;
- p->chipset = -1;
- p->bus.type = BUS_SBUS;
- xf86AddDevToEntity(num, dev);
- p->bus.id.sbus.fbNum = psdp->fbNum;
- p->active = active;
- p->inUse = FALSE;
- sbusSlotClaimed = TRUE;
- return num;
- } else
- return -1;
-}
-
-int
-xf86MatchSbusInstances(const char *driverName, int sbusDevId,
- GDevPtr *devList, int numDevs, DriverPtr drvp,
- int **foundEntities)
-{
- int i,j;
- sbusDevicePtr psdp, *psdpp;
- int numClaimedInstances = 0;
- int allocatedInstances = 0;
- int numFound = 0;
- GDevPtr devBus = NULL;
- GDevPtr dev = NULL;
- int *retEntities = NULL;
- int useProm = 0;
-
- struct Inst {
- sbusDevicePtr sbus;
- GDevPtr dev;
- Bool claimed; /* BusID matches with a device section */
- } *instances = NULL;
-
- *foundEntities = NULL;
- for (psdpp = xf86SbusInfo, psdp = *psdpp; psdp; psdp = *++psdpp) {
- if (psdp->devId != sbusDevId)
- continue;
- if (psdp->fd == -2)
- continue;
- ++allocatedInstances;
- instances = xnfrealloc(instances,
- allocatedInstances * sizeof(struct Inst));
- instances[allocatedInstances - 1].sbus = psdp;
- instances[allocatedInstances - 1].dev = NULL;
- instances[allocatedInstances - 1].claimed = FALSE;
- numFound++;
- }
-
- /*
- * This may be debatable, but if no SBUS devices with a matching vendor
- * type is found, return zero now. It is probably not desirable to
- * allow the config file to override this.
- */
- if (allocatedInstances <= 0) {
- free(instances);
- return 0;
- }
-
- if (sparcPromInit() >= 0)
- useProm = 1;
-
- if (xf86DoConfigure && xf86DoConfigurePass1) {
- GDevPtr pGDev;
- int actualcards = 0;
- for (i = 0; i < allocatedInstances; i++) {
- actualcards++;
- pGDev = xf86AddBusDeviceToConfigure(drvp->driverName, BUS_SBUS,
- instances[i].sbus, -1);
- if (pGDev) {
- /*
- * XF86Match???Instances() treat chipID and chipRev as
- * overrides, so clobber them here.
- */
- pGDev->chipID = pGDev->chipRev = -1;
- }
- }
- free(instances);
- if (useProm)
- sparcPromClose();
- return actualcards;
- }
-
- DebugF("%s instances found: %d\n", driverName, allocatedInstances);
-
- for (i = 0; i < allocatedInstances; i++) {
- char *promPath = NULL;
-
- psdp = instances[i].sbus;
- devBus = NULL;
- dev = NULL;
- if (useProm && psdp->node.node)
- promPath = sparcPromNode2Pathname(&psdp->node);
-
- for (j = 0; j < numDevs; j++) {
- if (devList[j]->busID && *devList[j]->busID) {
- if (xf86CompareSbusBusString(devList[j]->busID, psdp->fbNum)) {
- if (devBus)
- xf86MsgVerb(X_WARNING,0,
- "%s: More than one matching Device section for "
- "instance (BusID: %s) found: %s\n",
- driverName,devList[j]->identifier,
- devList[j]->busID);
- else
- devBus = devList[j];
- }
- } else {
- if (!dev && !devBus) {
- if (promPath)
- xf86Msg(X_PROBED, "Assigning device section with no busID to SBUS:%s\n",
- promPath);
- else
- xf86Msg(X_PROBED, "Assigning device section with no busID to SBUS:fb%d\n",
- psdp->fbNum);
- dev = devList[j];
- } else
- xf86MsgVerb(X_WARNING, 0,
- "%s: More than one matching Device section "
- "found: %s\n", driverName, devList[j]->identifier);
- }
- }
- if (devBus) dev = devBus; /* busID preferred */
- if (!dev && psdp->fd != -2) {
- if (promPath) {
- xf86MsgVerb(X_WARNING, 0, "%s: No matching Device section "
- "for instance (BusID SBUS:%s) found\n",
- driverName, promPath);
- } else
- xf86MsgVerb(X_WARNING, 0, "%s: No matching Device section "
- "for instance (BusID SBUS:fb%d) found\n",
- driverName, psdp->fbNum);
- } else if (dev) {
- numClaimedInstances++;
- instances[i].claimed = TRUE;
- instances[i].dev = dev;
- }
- free(promPath);
- }
-
- DebugF("%s instances found: %d\n", driverName, numClaimedInstances);
-
- /*
- * Of the claimed instances, check that another driver hasn't already
- * claimed its slot.
- */
- numFound = 0;
- for (i = 0; i < allocatedInstances && numClaimedInstances > 0; i++) {
- if (!instances[i].claimed)
- continue;
- psdp = instances[i].sbus;
- if (!xf86CheckSbusSlot(psdp->fbNum))
- continue;
-
- DebugF("%s: card at fb%d %08x is claimed by a Device section\n",
- driverName, psdp->fbNum, psdp->node.node);
-
- /* Allocate an entry in the lists to be returned */
- numFound++;
- retEntities = xnfrealloc(retEntities, numFound * sizeof(int));
- retEntities[numFound - 1]
- = xf86ClaimSbusSlot(psdp, drvp, instances[i].dev,instances[i].dev->active ?
- TRUE : FALSE);
- }
- free(instances);
- if (numFound > 0) {
- *foundEntities = retEntities;
- }
-
- if (useProm)
- sparcPromClose();
-
- return numFound;
-}
-
-/*
- * xf86GetSbusInfoForEntity() -- Get the sbusDevicePtr of entity.
- */
-sbusDevicePtr
-xf86GetSbusInfoForEntity(int entityIndex)
-{
- sbusDevicePtr *psdpp;
- EntityPtr p = xf86Entities[entityIndex];
-
- if (entityIndex >= xf86NumEntities
- || p->bus.type != BUS_SBUS) return NULL;
-
- for (psdpp = xf86SbusInfo; *psdpp != NULL; psdpp++) {
- if (p->bus.id.sbus.fbNum == (*psdpp)->fbNum)
- return *psdpp;
- }
- return NULL;
-}
-
-int
-xf86GetEntityForSbusInfo(sbusDevicePtr psdp)
-{
- int i;
-
- for (i = 0; i < xf86NumEntities; i++) {
- EntityPtr p = xf86Entities[i];
- if (p->bus.type != BUS_SBUS) continue;
-
- if (p->bus.id.sbus.fbNum == psdp->fbNum)
- return i;
- }
- return -1;
-}
-
-void
-xf86SbusUseBuiltinMode(ScrnInfoPtr pScrn, sbusDevicePtr psdp)
-{
- DisplayModePtr mode;
-
- mode = xnfcalloc(sizeof(DisplayModeRec), 1);
- mode->name = "current";
- mode->next = mode;
- mode->prev = mode;
- mode->type = M_T_BUILTIN;
- mode->Clock = 100000000;
- mode->HDisplay = psdp->width;
- mode->HSyncStart = psdp->width;
- mode->HSyncEnd = psdp->width;
- mode->HTotal = psdp->width;
- mode->VDisplay = psdp->height;
- mode->VSyncStart = psdp->height;
- mode->VSyncEnd = psdp->height;
- mode->VTotal = psdp->height;
- mode->SynthClock = mode->Clock;
- mode->CrtcHDisplay = mode->HDisplay;
- mode->CrtcHSyncStart = mode->HSyncStart;
- mode->CrtcHSyncEnd = mode->HSyncEnd;
- mode->CrtcHTotal = mode->HTotal;
- mode->CrtcVDisplay = mode->VDisplay;
- mode->CrtcVSyncStart = mode->VSyncStart;
- mode->CrtcVSyncEnd = mode->VSyncEnd;
- mode->CrtcVTotal = mode->VTotal;
- mode->CrtcHAdjusted = FALSE;
- mode->CrtcVAdjusted = FALSE;
- pScrn->modes = mode;
- pScrn->virtualX = psdp->width;
- pScrn->virtualY = psdp->height;
-}
-
-static sbusPaletteKeyIndex;
-static DevPrivateKey sbusPaletteKey = &sbusPaletteKeyIndex;
-typedef struct _sbusCmap {
- sbusDevicePtr psdp;
- CloseScreenProcPtr CloseScreen;
- Bool origCmapValid;
- unsigned char origRed[16];
- unsigned char origGreen[16];
- unsigned char origBlue[16];
-} sbusCmapRec, *sbusCmapPtr;
-
-#define SBUSCMAPPTR(pScreen) ((sbusCmapPtr) \
- dixLookupPrivate(&(pScreen)->devPrivates, sbusPaletteKey))
-
-static void
-xf86SbusCmapLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices,
- LOCO *colors, VisualPtr pVisual)
-{
- int i, index;
- sbusCmapPtr cmap;
- struct fbcmap fbcmap;
- unsigned char *data = malloc(numColors*3);
-
- cmap = SBUSCMAPPTR(pScrn->pScreen);
- if (!cmap) return;
- fbcmap.count = 0;
- fbcmap.index = indices[0];
- fbcmap.red = data;
- fbcmap.green = data + numColors;
- fbcmap.blue = fbcmap.green + numColors;
- for (i = 0; i < numColors; i++) {
- index = indices[i];
- if (fbcmap.count && index != fbcmap.index + fbcmap.count) {
- ioctl (cmap->psdp->fd, FBIOPUTCMAP, &fbcmap);
- fbcmap.count = 0;
- fbcmap.index = index;
- }
- fbcmap.red[fbcmap.count] = colors[index].red;
- fbcmap.green[fbcmap.count] = colors[index].green;
- fbcmap.blue[fbcmap.count++] = colors[index].blue;
- }
- ioctl (cmap->psdp->fd, FBIOPUTCMAP, &fbcmap);
- free(data);
-}
-
-static Bool
-xf86SbusCmapCloseScreen(int i, ScreenPtr pScreen)
-{
- sbusCmapPtr cmap;
- struct fbcmap fbcmap;
-
- cmap = SBUSCMAPPTR(pScreen);
- if (cmap->origCmapValid) {
- fbcmap.index = 0;
- fbcmap.count = 16;
- fbcmap.red = cmap->origRed;
- fbcmap.green = cmap->origGreen;
- fbcmap.blue = cmap->origBlue;
- ioctl (cmap->psdp->fd, FBIOPUTCMAP, &fbcmap);
- }
- pScreen->CloseScreen = cmap->CloseScreen;
- free(cmap);
- return (*pScreen->CloseScreen) (i, pScreen);
-}
-
-Bool
-xf86SbusHandleColormaps(ScreenPtr pScreen, sbusDevicePtr psdp)
-{
- sbusCmapPtr cmap;
- struct fbcmap fbcmap;
- unsigned char data[2];
-
- cmap = xnfcalloc(1, sizeof(sbusCmapRec));
- dixSetPrivate(&pScreen->devPrivates, sbusPaletteKey, cmap);
- cmap->psdp = psdp;
- fbcmap.index = 0;
- fbcmap.count = 16;
- fbcmap.red = cmap->origRed;
- fbcmap.green = cmap->origGreen;
- fbcmap.blue = cmap->origBlue;
- if (ioctl (psdp->fd, FBIOGETCMAP, &fbcmap) >= 0)
- cmap->origCmapValid = TRUE;
- fbcmap.index = 0;
- fbcmap.count = 2;
- fbcmap.red = data;
- fbcmap.green = data;
- fbcmap.blue = data;
- if (pScreen->whitePixel == 0) {
- data[0] = 255;
- data[1] = 0;
- } else {
- data[0] = 0;
- data[1] = 255;
- }
- ioctl (psdp->fd, FBIOPUTCMAP, &fbcmap);
- cmap->CloseScreen = pScreen->CloseScreen;
- pScreen->CloseScreen = xf86SbusCmapCloseScreen;
- return xf86HandleColormaps(pScreen, 256, 8,
- xf86SbusCmapLoadPalette, NULL, 0);
-}
-
-Bool
-xf86SbusConfigure(void *busData, sbusDevicePtr sBus)
-{
- if (sBus && sBus->fbNum == ((sbusDevicePtr) busData)->fbNum)
- return 0;
- return 1;
-}
-
-void
-xf86SbusConfigureNewDev(void *busData, sbusDevicePtr sBus, GDevRec *GDev)
-{
- char *promPath = NULL;
-
- sBus = (sbusDevicePtr) busData;
- GDev->identifier = sBus->descr;
- if (sparcPromInit() >= 0) {
- promPath = sparcPromNode2Pathname(&sBus->node);
- sparcPromClose();
- }
- if (promPath) {
- XNFasprintf(&GDev->busID, "SBUS:%s", promPath);
- free(promPath);
- } else {
- XNFasprintf(&GDev->busID, "SBUS:fb%d", sBus->fbNum);
- }
-}
+/*
+ * SBUS bus-specific code.
+ *
+ * Copyright (C) 2000 Jakub Jelinek (jakub@redhat.com)
+ *
+ * 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
+ * JAKUB JELINEK 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_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <ctype.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <X11/X.h>
+#include "os.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "xf86cmap.h"
+
+#include "xf86Bus.h"
+
+#include "xf86sbusBus.h"
+#include "xf86Sbus.h"
+
+Bool sbusSlotClaimed = FALSE;
+
+static int xf86nSbusInfo;
+
+static void
+CheckSbusDevice(const char *device, int fbNum)
+{
+ int fd, i;
+ struct fbgattr fbattr;
+ sbusDevicePtr psdp;
+
+ fd = open(device, O_RDONLY, 0);
+ if (fd < 0)
+ return;
+ memset(&fbattr, 0, sizeof(fbattr));
+ if (ioctl(fd, FBIOGATTR, &fbattr) < 0) {
+ if (ioctl(fd, FBIOGTYPE, &fbattr.fbtype) < 0) {
+ close(fd);
+ return;
+ }
+ }
+ close(fd);
+ for (i = 0; sbusDeviceTable[i].devId; i++)
+ if (sbusDeviceTable[i].fbType == fbattr.fbtype.fb_type)
+ break;
+ if (! sbusDeviceTable[i].devId)
+ return;
+ xf86SbusInfo = xnfrealloc(xf86SbusInfo, sizeof(psdp) * (++xf86nSbusInfo + 1));
+ xf86SbusInfo[xf86nSbusInfo] = NULL;
+ xf86SbusInfo[xf86nSbusInfo - 1] = psdp = xnfcalloc(sizeof (sbusDevice), 1);
+ psdp->devId = sbusDeviceTable[i].devId;
+ psdp->fbNum = fbNum;
+ psdp->device = xnfstrdup(device);
+ psdp->width = fbattr.fbtype.fb_width;
+ psdp->height = fbattr.fbtype.fb_height;
+ psdp->fd = -1;
+}
+
+void
+xf86SbusProbe(void)
+{
+ int i, useProm = 0;
+ char fbDevName[32];
+ sbusDevicePtr psdp, *psdpp;
+
+ xf86SbusInfo = malloc(sizeof(psdp));
+ *xf86SbusInfo = NULL;
+ for (i = 0; i < 32; i++) {
+ sprintf(fbDevName, "/dev/fb%d", i);
+ CheckSbusDevice(fbDevName, i);
+ }
+ if (sparcPromInit() >= 0) {
+ useProm = 1;
+ sparcPromAssignNodes();
+ }
+ for (psdpp = xf86SbusInfo; (psdp = *psdpp); psdpp++) {
+ for (i = 0; sbusDeviceTable[i].devId; i++)
+ if (sbusDeviceTable[i].devId == psdp->devId)
+ psdp->descr = sbusDeviceTable[i].descr;
+ /*
+ * If we can use PROM information and found the PROM node for this
+ * device, we can tell more about the card.
+ */
+ if (useProm && psdp->node.node) {
+ char *prop, *promPath;
+ int len, chiprev, vmsize;
+
+ switch (psdp->devId) {
+ case SBUS_DEVICE_MGX:
+ prop = sparcPromGetProperty(&psdp->node, "fb_size", &len);
+ if (prop && len == 4 && *(int *)prop == 0x400000)
+ psdp->descr = "Quantum 3D MGXplus with 4M VRAM";
+ break;
+ case SBUS_DEVICE_CG6:
+ chiprev = 0;
+ vmsize = 0;
+ prop = sparcPromGetProperty(&psdp->node, "chiprev", &len);
+ if (prop && len == 4)
+ chiprev = *(int *)prop;
+ prop = sparcPromGetProperty(&psdp->node, "vmsize", &len);
+ if (prop && len == 4)
+ vmsize = *(int *)prop;
+ switch (chiprev) {
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ psdp->descr = "Sun Double width GX"; break;
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ case 9:
+ psdp->descr = "Sun Single width GX"; break;
+ case 11:
+ switch (vmsize) {
+ case 2:
+ psdp->descr = "Sun Turbo GX with 1M VSIMM"; break;
+ case 4:
+ psdp->descr = "Sun Turbo GX Plus"; break;
+ default:
+ psdp->descr = "Sun Turbo GX"; break;
+ }
+ }
+ break;
+ case SBUS_DEVICE_CG14:
+ prop = sparcPromGetProperty(&psdp->node, "reg", &len);
+ vmsize = 0;
+ if (prop && !(len % 12) && len > 0)
+ vmsize = *(int *)(prop + len - 4);
+ switch (vmsize) {
+ case 0x400000:
+ psdp->descr = "Sun SX with 4M VSIMM"; break;
+ case 0x800000:
+ psdp->descr = "Sun SX with 8M VSIMM"; break;
+ }
+ break;
+ case SBUS_DEVICE_LEO:
+ prop = sparcPromGetProperty(&psdp->node, "model", &len);
+ if (prop && len > 0 && !strstr(prop, "501-2503"))
+ psdp->descr = "Sun Turbo ZX";
+ break;
+ case SBUS_DEVICE_TCX:
+ if (sparcPromGetBool(&psdp->node, "tcx-8-bit"))
+ psdp->descr = "Sun TCX (8bit)";
+ else
+ psdp->descr = "Sun TCX (S24)";
+ break;
+ case SBUS_DEVICE_FFB:
+ prop = sparcPromGetProperty(&psdp->node, "name", &len);
+ chiprev = 0;
+ prop = sparcPromGetProperty(&psdp->node, "board_type", &len);
+ if (prop && len == 4)
+ chiprev = *(int *)prop;
+ if (strstr (prop, "afb")) {
+ if (chiprev == 3)
+ psdp->descr = "Sun|Elite3D-M6 Horizontal";
+ } else {
+ switch (chiprev) {
+ case 0x08:
+ psdp->descr = "Sun FFB 67MHz Creator"; break;
+ case 0x0b:
+ psdp->descr = "Sun FFB 67MHz Creator 3D"; break;
+ case 0x1b:
+ psdp->descr = "Sun FFB 75MHz Creator 3D"; break;
+ case 0x20:
+ case 0x28:
+ psdp->descr = "Sun FFB2 Vertical Creator"; break;
+ case 0x23:
+ case 0x2b:
+ psdp->descr = "Sun FFB2 Vertical Creator 3D"; break;
+ case 0x30:
+ psdp->descr = "Sun FFB2+ Vertical Creator"; break;
+ case 0x33:
+ psdp->descr = "Sun FFB2+ Vertical Creator 3D"; break;
+ case 0x40:
+ case 0x48:
+ psdp->descr = "Sun FFB2 Horizontal Creator"; break;
+ case 0x43:
+ case 0x4b:
+ psdp->descr = "Sun FFB2 Horizontal Creator 3D"; break;
+ }
+ }
+ break;
+ }
+
+ xf86Msg(X_PROBED, "SBUS:(0x%08x) %s", psdp->node.node, psdp->descr);
+ promPath = sparcPromNode2Pathname (&psdp->node);
+ if (promPath) {
+ xf86ErrorF(" at %s", promPath);
+ free(promPath);
+ }
+ } else
+ xf86Msg(X_PROBED, "SBUS: %s", psdp->descr);
+ xf86ErrorF("\n");
+ }
+ if (useProm)
+ sparcPromClose();
+}
+
+/*
+ * Parse a BUS ID string, and return the SBUS bus parameters if it was
+ * in the correct format for a SBUS bus id.
+ */
+
+Bool
+xf86ParseSbusBusString(const char *busID, int *fbNum)
+{
+ /*
+ * The format is assumed to be one of:
+ * "fbN", e.g. "fb1", which means the device corresponding to /dev/fbN
+ * "nameN", e.g. "cgsix0", which means Nth instance of card NAME
+ * "/prompath", e.g. "/sbus@0,10001000/cgsix@3,0" which is PROM pathname
+ * to the device.
+ */
+
+ const char *id;
+ int i, len;
+
+ if (StringToBusType(busID, &id) != BUS_SBUS)
+ return FALSE;
+
+ if (*id != '/') {
+ if (!strncmp (id, "fb", 2)) {
+ if (!isdigit(id[2]))
+ return FALSE;
+ *fbNum = atoi(id + 2);
+ return TRUE;
+ } else {
+ sbusDevicePtr *psdpp;
+ int devId;
+
+ for (i = 0, len = 0; sbusDeviceTable[i].devId; i++) {
+ len = strlen(sbusDeviceTable[i].promName);
+ if (!strncmp (sbusDeviceTable[i].promName, id, len)
+ && isdigit(id[len]))
+ break;
+ }
+ devId = sbusDeviceTable[i].devId;
+ if (!devId) return FALSE;
+ i = atoi(id + len);
+ for (psdpp = xf86SbusInfo; *psdpp; ++psdpp) {
+ if ((*psdpp)->devId != devId)
+ continue;
+ if (!i) {
+ *fbNum = (*psdpp)->fbNum;
+ return TRUE;
+ }
+ i--;
+ }
+ }
+ return FALSE;
+ }
+
+ if (sparcPromInit() >= 0) {
+ i = sparcPromPathname2Node(id);
+ sparcPromClose();
+ if (i) {
+ sbusDevicePtr *psdpp;
+ for (psdpp = xf86SbusInfo; *psdpp; ++psdpp) {
+ if ((*psdpp)->node.node == i) {
+ *fbNum = (*psdpp)->fbNum;
+ return TRUE;
+ }
+ }
+ }
+ }
+ return FALSE;
+}
+
+/*
+ * Compare a BUS ID string with a SBUS bus id. Return TRUE if they match.
+ */
+
+Bool
+xf86CompareSbusBusString(const char *busID, int fbNum)
+{
+ int iFbNum;
+
+ if (xf86ParseSbusBusString(busID, &iFbNum)) {
+ return fbNum == iFbNum;
+ } else {
+ return FALSE;
+ }
+}
+
+/*
+ * Check if the slot requested is free. If it is already in use, return FALSE.
+ */
+
+Bool
+xf86CheckSbusSlot(int fbNum)
+{
+ int i;
+ EntityPtr p;
+
+ for (i = 0; i < xf86NumEntities; i++) {
+ p = xf86Entities[i];
+ /* Check if this SBUS slot is taken */
+ if (p->bus.type == BUS_SBUS && p->bus.id.sbus.fbNum == fbNum)
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/*
+ * If the slot requested is already in use, return -1.
+ * Otherwise, claim the slot for the screen requesting it.
+ */
+
+int
+xf86ClaimSbusSlot(sbusDevicePtr psdp, DriverPtr drvp,
+ GDevPtr dev, Bool active)
+{
+ EntityPtr p = NULL;
+
+ int num;
+
+ if (xf86CheckSbusSlot(psdp->fbNum)) {
+ num = xf86AllocateEntity();
+ p = xf86Entities[num];
+ p->driver = drvp;
+ p->chipset = -1;
+ p->bus.type = BUS_SBUS;
+ xf86AddDevToEntity(num, dev);
+ p->bus.id.sbus.fbNum = psdp->fbNum;
+ p->active = active;
+ p->inUse = FALSE;
+ sbusSlotClaimed = TRUE;
+ return num;
+ } else
+ return -1;
+}
+
+int
+xf86MatchSbusInstances(const char *driverName, int sbusDevId,
+ GDevPtr *devList, int numDevs, DriverPtr drvp,
+ int **foundEntities)
+{
+ int i,j;
+ sbusDevicePtr psdp, *psdpp;
+ int numClaimedInstances = 0;
+ int allocatedInstances = 0;
+ int numFound = 0;
+ GDevPtr devBus = NULL;
+ GDevPtr dev = NULL;
+ int *retEntities = NULL;
+ int useProm = 0;
+
+ struct Inst {
+ sbusDevicePtr sbus;
+ GDevPtr dev;
+ Bool claimed; /* BusID matches with a device section */
+ } *instances = NULL;
+
+ *foundEntities = NULL;
+ for (psdpp = xf86SbusInfo, psdp = *psdpp; psdp; psdp = *++psdpp) {
+ if (psdp->devId != sbusDevId)
+ continue;
+ if (psdp->fd == -2)
+ continue;
+ ++allocatedInstances;
+ instances = xnfrealloc(instances,
+ allocatedInstances * sizeof(struct Inst));
+ instances[allocatedInstances - 1].sbus = psdp;
+ instances[allocatedInstances - 1].dev = NULL;
+ instances[allocatedInstances - 1].claimed = FALSE;
+ numFound++;
+ }
+
+ /*
+ * This may be debatable, but if no SBUS devices with a matching vendor
+ * type is found, return zero now. It is probably not desirable to
+ * allow the config file to override this.
+ */
+ if (allocatedInstances <= 0) {
+ free(instances);
+ return 0;
+ }
+
+ if (sparcPromInit() >= 0)
+ useProm = 1;
+
+ if (xf86DoConfigure && xf86DoConfigurePass1) {
+ GDevPtr pGDev;
+ int actualcards = 0;
+ for (i = 0; i < allocatedInstances; i++) {
+ actualcards++;
+ pGDev = xf86AddBusDeviceToConfigure(drvp->driverName, BUS_SBUS,
+ instances[i].sbus, -1);
+ if (pGDev) {
+ /*
+ * XF86Match???Instances() treat chipID and chipRev as
+ * overrides, so clobber them here.
+ */
+ pGDev->chipID = pGDev->chipRev = -1;
+ }
+ }
+ free(instances);
+ if (useProm)
+ sparcPromClose();
+ return actualcards;
+ }
+
+ DebugF("%s instances found: %d\n", driverName, allocatedInstances);
+
+ for (i = 0; i < allocatedInstances; i++) {
+ char *promPath = NULL;
+
+ psdp = instances[i].sbus;
+ devBus = NULL;
+ dev = NULL;
+ if (useProm && psdp->node.node)
+ promPath = sparcPromNode2Pathname(&psdp->node);
+
+ for (j = 0; j < numDevs; j++) {
+ if (devList[j]->busID && *devList[j]->busID) {
+ if (xf86CompareSbusBusString(devList[j]->busID, psdp->fbNum)) {
+ if (devBus)
+ xf86MsgVerb(X_WARNING,0,
+ "%s: More than one matching Device section for "
+ "instance (BusID: %s) found: %s\n",
+ driverName,devList[j]->identifier,
+ devList[j]->busID);
+ else
+ devBus = devList[j];
+ }
+ } else {
+ if (!dev && !devBus) {
+ if (promPath)
+ xf86Msg(X_PROBED, "Assigning device section with no busID to SBUS:%s\n",
+ promPath);
+ else
+ xf86Msg(X_PROBED, "Assigning device section with no busID to SBUS:fb%d\n",
+ psdp->fbNum);
+ dev = devList[j];
+ } else
+ xf86MsgVerb(X_WARNING, 0,
+ "%s: More than one matching Device section "
+ "found: %s\n", driverName, devList[j]->identifier);
+ }
+ }
+ if (devBus) dev = devBus; /* busID preferred */
+ if (!dev && psdp->fd != -2) {
+ if (promPath) {
+ xf86MsgVerb(X_WARNING, 0, "%s: No matching Device section "
+ "for instance (BusID SBUS:%s) found\n",
+ driverName, promPath);
+ } else
+ xf86MsgVerb(X_WARNING, 0, "%s: No matching Device section "
+ "for instance (BusID SBUS:fb%d) found\n",
+ driverName, psdp->fbNum);
+ } else if (dev) {
+ numClaimedInstances++;
+ instances[i].claimed = TRUE;
+ instances[i].dev = dev;
+ }
+ free(promPath);
+ }
+
+ DebugF("%s instances found: %d\n", driverName, numClaimedInstances);
+
+ /*
+ * Of the claimed instances, check that another driver hasn't already
+ * claimed its slot.
+ */
+ numFound = 0;
+ for (i = 0; i < allocatedInstances && numClaimedInstances > 0; i++) {
+ if (!instances[i].claimed)
+ continue;
+ psdp = instances[i].sbus;
+ if (!xf86CheckSbusSlot(psdp->fbNum))
+ continue;
+
+ DebugF("%s: card at fb%d %08x is claimed by a Device section\n",
+ driverName, psdp->fbNum, psdp->node.node);
+
+ /* Allocate an entry in the lists to be returned */
+ numFound++;
+ retEntities = xnfrealloc(retEntities, numFound * sizeof(int));
+ retEntities[numFound - 1]
+ = xf86ClaimSbusSlot(psdp, drvp, instances[i].dev,instances[i].dev->active ?
+ TRUE : FALSE);
+ }
+ free(instances);
+ if (numFound > 0) {
+ *foundEntities = retEntities;
+ }
+
+ if (useProm)
+ sparcPromClose();
+
+ return numFound;
+}
+
+/*
+ * xf86GetSbusInfoForEntity() -- Get the sbusDevicePtr of entity.
+ */
+sbusDevicePtr
+xf86GetSbusInfoForEntity(int entityIndex)
+{
+ sbusDevicePtr *psdpp;
+ EntityPtr p = xf86Entities[entityIndex];
+
+ if (entityIndex >= xf86NumEntities
+ || p->bus.type != BUS_SBUS) return NULL;
+
+ for (psdpp = xf86SbusInfo; *psdpp != NULL; psdpp++) {
+ if (p->bus.id.sbus.fbNum == (*psdpp)->fbNum)
+ return *psdpp;
+ }
+ return NULL;
+}
+
+int
+xf86GetEntityForSbusInfo(sbusDevicePtr psdp)
+{
+ int i;
+
+ for (i = 0; i < xf86NumEntities; i++) {
+ EntityPtr p = xf86Entities[i];
+ if (p->bus.type != BUS_SBUS) continue;
+
+ if (p->bus.id.sbus.fbNum == psdp->fbNum)
+ return i;
+ }
+ return -1;
+}
+
+void
+xf86SbusUseBuiltinMode(ScrnInfoPtr pScrn, sbusDevicePtr psdp)
+{
+ DisplayModePtr mode;
+
+ mode = xnfcalloc(sizeof(DisplayModeRec), 1);
+ mode->name = "current";
+ mode->next = mode;
+ mode->prev = mode;
+ mode->type = M_T_BUILTIN;
+ mode->Clock = 100000000;
+ mode->HDisplay = psdp->width;
+ mode->HSyncStart = psdp->width;
+ mode->HSyncEnd = psdp->width;
+ mode->HTotal = psdp->width;
+ mode->VDisplay = psdp->height;
+ mode->VSyncStart = psdp->height;
+ mode->VSyncEnd = psdp->height;
+ mode->VTotal = psdp->height;
+ mode->SynthClock = mode->Clock;
+ mode->CrtcHDisplay = mode->HDisplay;
+ mode->CrtcHSyncStart = mode->HSyncStart;
+ mode->CrtcHSyncEnd = mode->HSyncEnd;
+ mode->CrtcHTotal = mode->HTotal;
+ mode->CrtcVDisplay = mode->VDisplay;
+ mode->CrtcVSyncStart = mode->VSyncStart;
+ mode->CrtcVSyncEnd = mode->VSyncEnd;
+ mode->CrtcVTotal = mode->VTotal;
+ mode->CrtcHAdjusted = FALSE;
+ mode->CrtcVAdjusted = FALSE;
+ pScrn->modes = mode;
+ pScrn->virtualX = psdp->width;
+ pScrn->virtualY = psdp->height;
+}
+
+static sbusPaletteKeyIndex;
+static DevPrivateKey sbusPaletteKey = &sbusPaletteKeyIndex;
+typedef struct _sbusCmap {
+ sbusDevicePtr psdp;
+ CloseScreenProcPtr CloseScreen;
+ Bool origCmapValid;
+ unsigned char origRed[16];
+ unsigned char origGreen[16];
+ unsigned char origBlue[16];
+} sbusCmapRec, *sbusCmapPtr;
+
+#define SBUSCMAPPTR(pScreen) ((sbusCmapPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, sbusPaletteKey))
+
+static void
+xf86SbusCmapLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices,
+ LOCO *colors, VisualPtr pVisual)
+{
+ int i, index;
+ sbusCmapPtr cmap;
+ struct fbcmap fbcmap;
+ unsigned char *data = malloc(numColors*3);
+
+ cmap = SBUSCMAPPTR(pScrn->pScreen);
+ if (!cmap) return;
+ fbcmap.count = 0;
+ fbcmap.index = indices[0];
+ fbcmap.red = data;
+ fbcmap.green = data + numColors;
+ fbcmap.blue = fbcmap.green + numColors;
+ for (i = 0; i < numColors; i++) {
+ index = indices[i];
+ if (fbcmap.count && index != fbcmap.index + fbcmap.count) {
+ ioctl (cmap->psdp->fd, FBIOPUTCMAP, &fbcmap);
+ fbcmap.count = 0;
+ fbcmap.index = index;
+ }
+ fbcmap.red[fbcmap.count] = colors[index].red;
+ fbcmap.green[fbcmap.count] = colors[index].green;
+ fbcmap.blue[fbcmap.count++] = colors[index].blue;
+ }
+ ioctl (cmap->psdp->fd, FBIOPUTCMAP, &fbcmap);
+ free(data);
+}
+
+static Bool
+xf86SbusCmapCloseScreen(int i, ScreenPtr pScreen)
+{
+ sbusCmapPtr cmap;
+ struct fbcmap fbcmap;
+
+ cmap = SBUSCMAPPTR(pScreen);
+ if (cmap->origCmapValid) {
+ fbcmap.index = 0;
+ fbcmap.count = 16;
+ fbcmap.red = cmap->origRed;
+ fbcmap.green = cmap->origGreen;
+ fbcmap.blue = cmap->origBlue;
+ ioctl (cmap->psdp->fd, FBIOPUTCMAP, &fbcmap);
+ }
+ pScreen->CloseScreen = cmap->CloseScreen;
+ free(cmap);
+ return (*pScreen->CloseScreen) (i, pScreen);
+}
+
+Bool
+xf86SbusHandleColormaps(ScreenPtr pScreen, sbusDevicePtr psdp)
+{
+ sbusCmapPtr cmap;
+ struct fbcmap fbcmap;
+ unsigned char data[2];
+
+ cmap = xnfcalloc(1, sizeof(sbusCmapRec));
+ dixSetPrivate(&pScreen->devPrivates, sbusPaletteKey, cmap);
+ cmap->psdp = psdp;
+ fbcmap.index = 0;
+ fbcmap.count = 16;
+ fbcmap.red = cmap->origRed;
+ fbcmap.green = cmap->origGreen;
+ fbcmap.blue = cmap->origBlue;
+ if (ioctl (psdp->fd, FBIOGETCMAP, &fbcmap) >= 0)
+ cmap->origCmapValid = TRUE;
+ fbcmap.index = 0;
+ fbcmap.count = 2;
+ fbcmap.red = data;
+ fbcmap.green = data;
+ fbcmap.blue = data;
+ if (pScreen->whitePixel == 0) {
+ data[0] = 255;
+ data[1] = 0;
+ } else {
+ data[0] = 0;
+ data[1] = 255;
+ }
+ ioctl (psdp->fd, FBIOPUTCMAP, &fbcmap);
+ cmap->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = xf86SbusCmapCloseScreen;
+ return xf86HandleColormaps(pScreen, 256, 8,
+ xf86SbusCmapLoadPalette, NULL, 0);
+}
+
+Bool
+xf86SbusConfigure(void *busData, sbusDevicePtr sBus)
+{
+ if (sBus && sBus->fbNum == ((sbusDevicePtr) busData)->fbNum)
+ return 0;
+ return 1;
+}
+
+void
+xf86SbusConfigureNewDev(void *busData, sbusDevicePtr sBus, GDevRec *GDev)
+{
+ char *promPath = NULL;
+
+ sBus = (sbusDevicePtr) busData;
+ GDev->identifier = sBus->descr;
+ if (sparcPromInit() >= 0) {
+ promPath = sparcPromNode2Pathname(&sBus->node);
+ sparcPromClose();
+ }
+ if (promPath) {
+ XNFasprintf(&GDev->busID, "SBUS:%s", promPath);
+ free(promPath);
+ } else {
+ XNFasprintf(&GDev->busID, "SBUS:fb%d", sBus->fbNum);
+ }
+}
diff --git a/xorg-server/hw/xfree86/common/xf86xv.c b/xorg-server/hw/xfree86/common/xf86xv.c
index 416842473..b46dfefed 100644
--- a/xorg-server/hw/xfree86/common/xf86xv.c
+++ b/xorg-server/hw/xfree86/common/xf86xv.c
@@ -1,2190 +1,2190 @@
-/*
- * XFree86 Xv DDX written by Mark Vojkovich (markv@valinux.com)
- */
-/*
- * Copyright (c) 1998-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).
- */
-
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "misc.h"
-#include "xf86.h"
-#include "xf86_OSproc.h"
-
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include "scrnintstr.h"
-#include "regionstr.h"
-#include "windowstr.h"
-#include "pixmapstr.h"
-#include "mivalidate.h"
-#include "validate.h"
-#include "resource.h"
-#include "gcstruct.h"
-#include "dixstruct.h"
-
-#include <X11/extensions/Xv.h>
-#include <X11/extensions/Xvproto.h>
-#include "xvdix.h"
-#include "xvmodproc.h"
-
-#include "xf86xvpriv.h"
-
-
-/* XvScreenRec fields */
-
-static Bool xf86XVCloseScreen(int, ScreenPtr);
-static int xf86XVQueryAdaptors(ScreenPtr, XvAdaptorPtr *, int *);
-
-/* XvAdaptorRec fields */
-
-static int xf86XVAllocatePort(unsigned long, XvPortPtr, XvPortPtr*);
-static int xf86XVFreePort(XvPortPtr);
-static int xf86XVPutVideo(ClientPtr, DrawablePtr,XvPortPtr, GCPtr,
- INT16, INT16, CARD16, CARD16,
- INT16, INT16, CARD16, CARD16);
-static int xf86XVPutStill(ClientPtr, DrawablePtr,XvPortPtr, GCPtr,
- INT16, INT16, CARD16, CARD16,
- INT16, INT16, CARD16, CARD16);
-static int xf86XVGetVideo(ClientPtr, DrawablePtr,XvPortPtr, GCPtr,
- INT16, INT16, CARD16, CARD16,
- INT16, INT16, CARD16, CARD16);
-static int xf86XVGetStill(ClientPtr, DrawablePtr,XvPortPtr, GCPtr,
- INT16, INT16, CARD16, CARD16,
- INT16, INT16, CARD16, CARD16);
-static int xf86XVStopVideo(ClientPtr, XvPortPtr, DrawablePtr);
-static int xf86XVSetPortAttribute(ClientPtr, XvPortPtr, Atom, INT32);
-static int xf86XVGetPortAttribute(ClientPtr, XvPortPtr, Atom, INT32*);
-static int xf86XVQueryBestSize(ClientPtr, XvPortPtr, CARD8,
- CARD16, CARD16,CARD16, CARD16,
- unsigned int*, unsigned int*);
-static int xf86XVPutImage(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
- INT16, INT16, CARD16, CARD16,
- INT16, INT16, CARD16, CARD16,
- XvImagePtr, unsigned char*, Bool,
- CARD16, CARD16);
-static int xf86XVQueryImageAttributes(ClientPtr, XvPortPtr, XvImagePtr,
- CARD16*, CARD16*, int*, int*);
-
-
-/* ScreenRec fields */
-
-static Bool xf86XVDestroyWindow(WindowPtr pWin);
-static void xf86XVWindowExposures(WindowPtr pWin, RegionPtr r1, RegionPtr r2);
-static void xf86XVPostValidateTree(WindowPtr pWin, WindowPtr pLayerWin, VTKind kind);
-static void xf86XVClipNotify(WindowPtr pWin, int dx, int dy);
-
-#define PostValidateTreeUndefined ((PostValidateTreeProcPtr)-1)
-
-/* ScrnInfoRec functions */
-
-static Bool xf86XVEnterVT(int, int);
-static void xf86XVLeaveVT(int, int);
-static void xf86XVAdjustFrame(int index, int x, int y, int flags);
-static void xf86XVModeSet(ScrnInfoPtr pScrn);
-
-/* misc */
-
-static Bool xf86XVInitAdaptors(ScreenPtr, XF86VideoAdaptorPtr*, int);
-
-
-static DevPrivateKeyRec XF86XVWindowKeyRec;
-#define XF86XVWindowKey (&XF86XVWindowKeyRec)
-
-DevPrivateKey XF86XvScreenKey;
-
-static unsigned long PortResource = 0;
-
-DevPrivateKey (*XvGetScreenKeyProc)(void) = NULL;
-unsigned long (*XvGetRTPortProc)(void) = NULL;
-int (*XvScreenInitProc)(ScreenPtr) = NULL;
-
-#define GET_XV_SCREEN(pScreen) \
- ((XvScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, XF86XvScreenKey))
-
-#define GET_XF86XV_SCREEN(pScreen) \
- ((XF86XVScreenPtr)(GET_XV_SCREEN(pScreen)->devPriv.ptr))
-
-#define GET_XF86XV_WINDOW(pWin) \
- ((XF86XVWindowPtr)dixLookupPrivate(&(pWin)->devPrivates, XF86XVWindowKey))
-
-static xf86XVInitGenericAdaptorPtr *GenDrivers = NULL;
-static int NumGenDrivers = 0;
-
-int
-xf86XVRegisterGenericAdaptorDriver(
- xf86XVInitGenericAdaptorPtr InitFunc
-){
- xf86XVInitGenericAdaptorPtr *newdrivers;
-
- newdrivers = realloc(GenDrivers, sizeof(xf86XVInitGenericAdaptorPtr) *
- (1 + NumGenDrivers));
- if (!newdrivers)
- return 0;
- GenDrivers = newdrivers;
-
- GenDrivers[NumGenDrivers++] = InitFunc;
-
- return 1;
-}
-
-int
-xf86XVListGenericAdaptors(
- ScrnInfoPtr pScrn,
- XF86VideoAdaptorPtr **adaptors
-){
- int i,j,n,num;
- XF86VideoAdaptorPtr *DrivAdap,*new;
-
- num = 0;
- *adaptors = NULL;
- /*
- * The v4l driver registers itself first, but can use surfaces registered
- * by other drivers. So, call the v4l driver last.
- */
- for (i = NumGenDrivers; --i >= 0; ) {
- DrivAdap = NULL;
- n = (*GenDrivers[i])(pScrn, &DrivAdap);
- if (0 == n)
- continue;
- new = realloc(*adaptors, sizeof(XF86VideoAdaptorPtr) * (num+n));
- if (NULL == new)
- continue;
- *adaptors = new;
- for (j = 0; j < n; j++, num++)
- (*adaptors)[num] = DrivAdap[j];
- }
- return num;
-}
-
-
-/**************** Offscreen surface stuff *******************/
-
-typedef struct {
- XF86OffscreenImagePtr images;
- int num;
-} OffscreenImageRec;
-
-static DevPrivateKeyRec OffscreenPrivateKeyRec;
-#define OffscreenPrivateKey (&OffscreenPrivateKeyRec)
-#define GetOffscreenImage(pScreen) ((OffscreenImageRec *) dixLookupPrivate(&(pScreen)->devPrivates, OffscreenPrivateKey))
-
-Bool
-xf86XVRegisterOffscreenImages(
- ScreenPtr pScreen,
- XF86OffscreenImagePtr images,
- int num
-){
- OffscreenImageRec *OffscreenImage;
- /* This function may be called before xf86XVScreenInit, so there's
- * no better place than this to call dixRegisterPrivateKey to ensure we
- * have space reserved. After the first call it is a no-op. */
- if(!dixRegisterPrivateKey(OffscreenPrivateKey, PRIVATE_SCREEN, sizeof(OffscreenImageRec)) ||
- !(OffscreenImage = GetOffscreenImage(pScreen)))
- /* Every X.org driver assumes this function always succeeds, so
- * just die on allocation failure. */
- FatalError("Could not allocate private storage for XV offscreen images.\n");
-
- OffscreenImage->num = num;
- OffscreenImage->images = images;
- return TRUE;
-}
-
-XF86OffscreenImagePtr
-xf86XVQueryOffscreenImages(
- ScreenPtr pScreen,
- int *num
-){
- OffscreenImageRec *OffscreenImage = GetOffscreenImage(pScreen);
- *num = OffscreenImage->num;
- return OffscreenImage->images;
-}
-
-
-XF86VideoAdaptorPtr
-xf86XVAllocateVideoAdaptorRec(ScrnInfoPtr pScrn)
-{
- return calloc(1, sizeof(XF86VideoAdaptorRec));
-}
-
-void
-xf86XVFreeVideoAdaptorRec(XF86VideoAdaptorPtr ptr)
-{
- free(ptr);
-}
-
-
-Bool
-xf86XVScreenInit(
- ScreenPtr pScreen,
- XF86VideoAdaptorPtr *adaptors,
- int num
-){
- ScrnInfoPtr pScrn;
- XF86XVScreenPtr ScreenPriv;
- XvScreenPtr pxvs;
-
- if(num <= 0 ||
- !XvGetScreenKeyProc || !XvGetRTPortProc || !XvScreenInitProc)
- return FALSE;
-
- if(Success != (*XvScreenInitProc)(pScreen)) return FALSE;
-
- if (!dixRegisterPrivateKey(&XF86XVWindowKeyRec, PRIVATE_WINDOW, 0))
- return FALSE;
-
- XF86XvScreenKey = (*XvGetScreenKeyProc)();
-
- PortResource = (*XvGetRTPortProc)();
-
- pxvs = GET_XV_SCREEN(pScreen);
-
- /* Anyone initializing the Xv layer must provide these two.
- The Xv di layer calls them without even checking if they exist! */
-
- pxvs->ddCloseScreen = xf86XVCloseScreen;
- pxvs->ddQueryAdaptors = xf86XVQueryAdaptors;
-
- /* The Xv di layer provides us with a private hook so that we don't
- have to allocate our own screen private. They also provide
- a CloseScreen hook so that we don't have to wrap it. I'm not
- sure that I appreciate that. */
-
- ScreenPriv = malloc(sizeof(XF86XVScreenRec));
- pxvs->devPriv.ptr = (pointer)ScreenPriv;
-
- if(!ScreenPriv) return FALSE;
-
- pScrn = xf86Screens[pScreen->myNum];
-
- ScreenPriv->DestroyWindow = pScreen->DestroyWindow;
- ScreenPriv->WindowExposures = pScreen->WindowExposures;
- ScreenPriv->PostValidateTree = PostValidateTreeUndefined;
- ScreenPriv->ClipNotify = pScreen->ClipNotify;
- ScreenPriv->EnterVT = pScrn->EnterVT;
- ScreenPriv->LeaveVT = pScrn->LeaveVT;
- ScreenPriv->AdjustFrame = pScrn->AdjustFrame;
- ScreenPriv->ModeSet = pScrn->ModeSet;
-
- pScreen->DestroyWindow = xf86XVDestroyWindow;
- pScreen->WindowExposures = xf86XVWindowExposures;
- pScreen->ClipNotify = xf86XVClipNotify;
- pScrn->EnterVT = xf86XVEnterVT;
- pScrn->LeaveVT = xf86XVLeaveVT;
- if(pScrn->AdjustFrame)
- pScrn->AdjustFrame = xf86XVAdjustFrame;
- pScrn->ModeSet = xf86XVModeSet;
-
- if(!xf86XVInitAdaptors(pScreen, adaptors, num))
- return FALSE;
-
- return TRUE;
-}
-
-static void
-xf86XVFreeAdaptor(XvAdaptorPtr pAdaptor)
-{
- int i;
-
- free(pAdaptor->name);
- pAdaptor->name = NULL;
-
- if(pAdaptor->pEncodings) {
- XvEncodingPtr pEncode = pAdaptor->pEncodings;
-
- for(i = 0; i < pAdaptor->nEncodings; i++, pEncode++)
- free(pEncode->name);
- free(pAdaptor->pEncodings);
- pAdaptor->pEncodings = NULL;
- }
-
- free(pAdaptor->pFormats);
- pAdaptor->pFormats = NULL;
-
- if(pAdaptor->pPorts) {
- XvPortPtr pPort = pAdaptor->pPorts;
- XvPortRecPrivatePtr pPriv;
-
- for(i = 0; i < pAdaptor->nPorts; i++, pPort++) {
- pPriv = (XvPortRecPrivatePtr)pPort->devPriv.ptr;
- if(pPriv) {
- if(pPriv->clientClip)
- RegionDestroy(pPriv->clientClip);
- if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
- RegionDestroy(pPriv->pCompositeClip);
- if (pPriv->ckeyFilled)
- RegionDestroy(pPriv->ckeyFilled);
- free(pPriv);
- }
- }
- free(pAdaptor->pPorts);
- pAdaptor->pPorts = NULL;
- }
-
- if(pAdaptor->pAttributes) {
- XvAttributePtr pAttribute = pAdaptor->pAttributes;
-
- for(i = 0; i < pAdaptor->nAttributes; i++, pAttribute++)
- free(pAttribute->name);
- free(pAdaptor->pAttributes);
- pAdaptor->pAttributes = NULL;
- }
-
- free(pAdaptor->pImages);
- free(pAdaptor->devPriv.ptr);
- pAdaptor->pImages = NULL;
- pAdaptor->devPriv.ptr = NULL;
-}
-
-static Bool
-xf86XVInitAdaptors(
- ScreenPtr pScreen,
- XF86VideoAdaptorPtr *infoPtr,
- int number
-) {
- XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- XF86VideoAdaptorPtr adaptorPtr;
- XvAdaptorPtr pAdaptor, pa;
- XvAdaptorRecPrivatePtr adaptorPriv;
- int na, numAdaptor;
- XvPortRecPrivatePtr portPriv;
- XvPortPtr pPort, pp;
- int numPort;
- XF86AttributePtr attributePtr;
- XvAttributePtr pAttribute, pat;
- XF86VideoFormatPtr formatPtr;
- XvFormatPtr pFormat, pf;
- int numFormat, totFormat;
- XF86VideoEncodingPtr encodingPtr;
- XvEncodingPtr pEncode, pe;
- XF86ImagePtr imagePtr;
- XvImagePtr pImage, pi;
- int numVisuals;
- VisualPtr pVisual;
- int i;
-
- pxvs->nAdaptors = 0;
- pxvs->pAdaptors = NULL;
-
- if(!(pAdaptor = calloc(number, sizeof(XvAdaptorRec))))
- return FALSE;
-
- for(pa = pAdaptor, na = 0, numAdaptor = 0; na < number; na++, adaptorPtr++) {
- adaptorPtr = infoPtr[na];
-
- if(!adaptorPtr->StopVideo || !adaptorPtr->SetPortAttribute ||
- !adaptorPtr->GetPortAttribute || !adaptorPtr->QueryBestSize)
- continue;
-
- /* client libs expect at least one encoding */
- if(!adaptorPtr->nEncodings || !adaptorPtr->pEncodings)
- continue;
-
- pa->type = adaptorPtr->type;
-
- if(!adaptorPtr->PutVideo && !adaptorPtr->GetVideo)
- pa->type &= ~XvVideoMask;
-
- if(!adaptorPtr->PutStill && !adaptorPtr->GetStill)
- pa->type &= ~XvStillMask;
-
- if(!adaptorPtr->PutImage || !adaptorPtr->QueryImageAttributes)
- pa->type &= ~XvImageMask;
-
- if(!adaptorPtr->PutVideo && !adaptorPtr->PutImage &&
- !adaptorPtr->PutStill)
- pa->type &= ~XvInputMask;
-
- if(!adaptorPtr->GetVideo && !adaptorPtr->GetStill)
- pa->type &= ~XvOutputMask;
-
- if(!(adaptorPtr->type & (XvPixmapMask | XvWindowMask)))
- continue;
- if(!(adaptorPtr->type & (XvImageMask | XvVideoMask | XvStillMask)))
- continue;
-
- pa->pScreen = pScreen;
- pa->ddAllocatePort = xf86XVAllocatePort;
- pa->ddFreePort = xf86XVFreePort;
- pa->ddPutVideo = xf86XVPutVideo;
- pa->ddPutStill = xf86XVPutStill;
- pa->ddGetVideo = xf86XVGetVideo;
- pa->ddGetStill = xf86XVGetStill;
- pa->ddStopVideo = xf86XVStopVideo;
- pa->ddPutImage = xf86XVPutImage;
- pa->ddSetPortAttribute = xf86XVSetPortAttribute;
- pa->ddGetPortAttribute = xf86XVGetPortAttribute;
- pa->ddQueryBestSize = xf86XVQueryBestSize;
- pa->ddQueryImageAttributes = xf86XVQueryImageAttributes;
- pa->name = strdup(adaptorPtr->name);
-
- if(adaptorPtr->nEncodings &&
- (pEncode = calloc(adaptorPtr->nEncodings, sizeof(XvEncodingRec)))) {
-
- for(pe = pEncode, encodingPtr = adaptorPtr->pEncodings, i = 0;
- i < adaptorPtr->nEncodings; pe++, i++, encodingPtr++)
- {
- pe->id = encodingPtr->id;
- pe->pScreen = pScreen;
- pe->name = strdup(encodingPtr->name);
- pe->width = encodingPtr->width;
- pe->height = encodingPtr->height;
- pe->rate.numerator = encodingPtr->rate.numerator;
- pe->rate.denominator = encodingPtr->rate.denominator;
- }
- pa->nEncodings = adaptorPtr->nEncodings;
- pa->pEncodings = pEncode;
- }
-
- if(adaptorPtr->nImages &&
- (pImage = calloc(adaptorPtr->nImages, sizeof(XvImageRec)))) {
-
- for(i = 0, pi = pImage, imagePtr = adaptorPtr->pImages;
- i < adaptorPtr->nImages; i++, pi++, imagePtr++)
- {
- pi->id = imagePtr->id;
- pi->type = imagePtr->type;
- pi->byte_order = imagePtr->byte_order;
- memcpy(pi->guid, imagePtr->guid, 16);
- pi->bits_per_pixel = imagePtr->bits_per_pixel;
- pi->format = imagePtr->format;
- pi->num_planes = imagePtr->num_planes;
- pi->depth = imagePtr->depth;
- pi->red_mask = imagePtr->red_mask;
- pi->green_mask = imagePtr->green_mask;
- pi->blue_mask = imagePtr->blue_mask;
- pi->y_sample_bits = imagePtr->y_sample_bits;
- pi->u_sample_bits = imagePtr->u_sample_bits;
- pi->v_sample_bits = imagePtr->v_sample_bits;
- pi->horz_y_period = imagePtr->horz_y_period;
- pi->horz_u_period = imagePtr->horz_u_period;
- pi->horz_v_period = imagePtr->horz_v_period;
- pi->vert_y_period = imagePtr->vert_y_period;
- pi->vert_u_period = imagePtr->vert_u_period;
- pi->vert_v_period = imagePtr->vert_v_period;
- memcpy(pi->component_order, imagePtr->component_order, 32);
- pi->scanline_order = imagePtr->scanline_order;
- }
- pa->nImages = adaptorPtr->nImages;
- pa->pImages = pImage;
- }
-
- if(adaptorPtr->nAttributes &&
- (pAttribute = calloc(adaptorPtr->nAttributes, sizeof(XvAttributeRec))))
- {
- for(pat = pAttribute, attributePtr = adaptorPtr->pAttributes, i = 0;
- i < adaptorPtr->nAttributes; pat++, i++, attributePtr++)
- {
- pat->flags = attributePtr->flags;
- pat->min_value = attributePtr->min_value;
- pat->max_value = attributePtr->max_value;
- pat->name = strdup(attributePtr->name);
- }
- pa->nAttributes = adaptorPtr->nAttributes;
- pa->pAttributes = pAttribute;
- }
-
-
- totFormat = adaptorPtr->nFormats;
-
- if(!(pFormat = calloc(totFormat, sizeof(XvFormatRec)))) {
- xf86XVFreeAdaptor(pa);
- continue;
- }
- for(pf = pFormat, i = 0, numFormat = 0, formatPtr = adaptorPtr->pFormats;
- i < adaptorPtr->nFormats; i++, formatPtr++)
- {
- numVisuals = pScreen->numVisuals;
- pVisual = pScreen->visuals;
-
- while(numVisuals--) {
- if((pVisual->class == formatPtr->class) &&
- (pVisual->nplanes == formatPtr->depth)) {
-
- if(numFormat >= totFormat) {
- void *moreSpace;
- totFormat *= 2;
- moreSpace = realloc(pFormat,
- totFormat * sizeof(XvFormatRec));
- if(!moreSpace) break;
- pFormat = moreSpace;
- pf = pFormat + numFormat;
- }
-
- pf->visual = pVisual->vid;
- pf->depth = formatPtr->depth;
-
- pf++;
- numFormat++;
- }
- pVisual++;
- }
- }
- pa->nFormats = numFormat;
- pa->pFormats = pFormat;
- if(!numFormat) {
- xf86XVFreeAdaptor(pa);
- continue;
- }
-
- if(!(adaptorPriv = calloc(1, sizeof(XvAdaptorRecPrivate)))) {
- xf86XVFreeAdaptor(pa);
- continue;
- }
-
- adaptorPriv->flags = adaptorPtr->flags;
- adaptorPriv->PutVideo = adaptorPtr->PutVideo;
- adaptorPriv->PutStill = adaptorPtr->PutStill;
- adaptorPriv->GetVideo = adaptorPtr->GetVideo;
- adaptorPriv->GetStill = adaptorPtr->GetStill;
- adaptorPriv->StopVideo = adaptorPtr->StopVideo;
- adaptorPriv->SetPortAttribute = adaptorPtr->SetPortAttribute;
- adaptorPriv->GetPortAttribute = adaptorPtr->GetPortAttribute;
- adaptorPriv->QueryBestSize = adaptorPtr->QueryBestSize;
- adaptorPriv->QueryImageAttributes = adaptorPtr->QueryImageAttributes;
- adaptorPriv->PutImage = adaptorPtr->PutImage;
- adaptorPriv->ReputImage = adaptorPtr->ReputImage; /* image/still */
-
- pa->devPriv.ptr = (pointer)adaptorPriv;
-
- if(!(pPort = calloc(adaptorPtr->nPorts, sizeof(XvPortRec)))) {
- xf86XVFreeAdaptor(pa);
- continue;
- }
- for(pp = pPort, i = 0, numPort = 0;
- i < adaptorPtr->nPorts; i++) {
-
- if(!(pp->id = FakeClientID(0)))
- continue;
-
- if(!(portPriv = calloc(1, sizeof(XvPortRecPrivate))))
- continue;
-
- if(!AddResource(pp->id, PortResource, pp)) {
- free(portPriv);
- continue;
- }
-
- pp->pAdaptor = pa;
- pp->pNotify = (XvPortNotifyPtr)NULL;
- pp->pDraw = (DrawablePtr)NULL;
- pp->client = (ClientPtr)NULL;
- pp->grab.client = (ClientPtr)NULL;
- pp->time = currentTime;
- pp->devPriv.ptr = portPriv;
-
- portPriv->pScrn = pScrn;
- portPriv->AdaptorRec = adaptorPriv;
- portPriv->DevPriv.ptr = adaptorPtr->pPortPrivates[i].ptr;
-
- pp++;
- numPort++;
- }
- pa->nPorts = numPort;
- pa->pPorts = pPort;
- if(!numPort) {
- xf86XVFreeAdaptor(pa);
- continue;
- }
-
- pa->base_id = pPort->id;
-
- pa++;
- numAdaptor++;
- }
-
- if(numAdaptor) {
- pxvs->nAdaptors = numAdaptor;
- pxvs->pAdaptors = pAdaptor;
- } else {
- free(pAdaptor);
- return FALSE;
- }
-
- return TRUE;
-}
-
-/* Video should be clipped to the intersection of the window cliplist
- and the client cliplist specified in the GC for which the video was
- initialized. When we need to reclip a window, the GC that started
- the video may not even be around anymore. That's why we save the
- client clip from the GC when the video is initialized. We then
- use xf86XVUpdateCompositeClip to calculate the new composite clip
- when we need it. This is different from what DEC did. They saved
- the GC and used it's clip list when they needed to reclip the window,
- even if the client clip was different from the one the video was
- initialized with. If the original GC was destroyed, they had to stop
- the video. I like the new method better (MArk).
-
- This function only works for windows. Will need to rewrite when
- (if) we support pixmap rendering.
-*/
-
-static void
-xf86XVUpdateCompositeClip(XvPortRecPrivatePtr portPriv)
-{
- RegionPtr pregWin, pCompositeClip;
- WindowPtr pWin;
- Bool freeCompClip = FALSE;
-
- if(portPriv->pCompositeClip)
- return;
-
- pWin = (WindowPtr)portPriv->pDraw;
-
- /* get window clip list */
- if(portPriv->subWindowMode == IncludeInferiors) {
- pregWin = NotClippedByChildren(pWin);
- freeCompClip = TRUE;
- } else
- pregWin = &pWin->clipList;
-
- if(!portPriv->clientClip) {
- portPriv->pCompositeClip = pregWin;
- portPriv->FreeCompositeClip = freeCompClip;
- return;
- }
-
- pCompositeClip = RegionCreate(NullBox, 1);
- RegionCopy(pCompositeClip, portPriv->clientClip);
- RegionTranslate(pCompositeClip,
- portPriv->pDraw->x, portPriv->pDraw->y);
- RegionIntersect(pCompositeClip, pregWin, pCompositeClip);
-
- portPriv->pCompositeClip = pCompositeClip;
- portPriv->FreeCompositeClip = TRUE;
-
- if(freeCompClip) {
- RegionDestroy(pregWin);
- }
-}
-
-/* Save the current clientClip and update the CompositeClip whenever
- we have a fresh GC */
-
-static void
-xf86XVCopyClip(
- XvPortRecPrivatePtr portPriv,
- GCPtr pGC
-){
- /* copy the new clip if it exists */
- if((pGC->clientClipType == CT_REGION) && pGC->clientClip) {
- if(!portPriv->clientClip)
- portPriv->clientClip = RegionCreate(NullBox, 1);
- /* Note: this is in window coordinates */
- RegionCopy(portPriv->clientClip, pGC->clientClip);
- RegionTranslate(portPriv->clientClip,
- pGC->clipOrg.x, pGC->clipOrg.y);
- } else if(portPriv->clientClip) { /* free the old clientClip */
- RegionDestroy(portPriv->clientClip);
- portPriv->clientClip = NULL;
- }
-
- /* get rid of the old clip list */
- if(portPriv->pCompositeClip && portPriv->FreeCompositeClip) {
- RegionDestroy(portPriv->pCompositeClip);
- }
-
- portPriv->pCompositeClip = pGC->pCompositeClip;
- portPriv->FreeCompositeClip = FALSE;
- portPriv->subWindowMode = pGC->subWindowMode;
-}
-
-static void
-xf86XVCopyCompositeClip(XvPortRecPrivatePtr portPriv,
- GCPtr pGC,
- DrawablePtr pDraw)
-{
- if (!portPriv->clientClip)
- portPriv->clientClip = RegionCreate(NullBox, 1);
- /* Keep the original GC composite clip around for ReputImage */
- RegionCopy(portPriv->clientClip, pGC->pCompositeClip);
- RegionTranslate(portPriv->clientClip,
- -pDraw->x, -pDraw->y);
-
- /* get rid of the old clip list */
- if (portPriv->pCompositeClip && portPriv->FreeCompositeClip)
- RegionDestroy(portPriv->pCompositeClip);
-
- portPriv->pCompositeClip = pGC->pCompositeClip;
- portPriv->FreeCompositeClip = FALSE;
- portPriv->subWindowMode = pGC->subWindowMode;
-}
-
-static int
-xf86XVRegetVideo(XvPortRecPrivatePtr portPriv)
-{
- RegionRec WinRegion;
- RegionRec ClipRegion;
- BoxRec WinBox;
- int ret = Success;
- Bool clippedAway = FALSE;
-
- xf86XVUpdateCompositeClip(portPriv);
-
- /* translate the video region to the screen */
- WinBox.x1 = portPriv->pDraw->x + portPriv->drw_x;
- WinBox.y1 = portPriv->pDraw->y + portPriv->drw_y;
- WinBox.x2 = WinBox.x1 + portPriv->drw_w;
- WinBox.y2 = WinBox.y1 + portPriv->drw_h;
-
- /* clip to the window composite clip */
- RegionInit(&WinRegion, &WinBox, 1);
- RegionNull(&ClipRegion);
- RegionIntersect(&ClipRegion, &WinRegion, portPriv->pCompositeClip);
-
- /* that's all if it's totally obscured */
- if(!RegionNotEmpty(&ClipRegion)) {
- clippedAway = TRUE;
- goto CLIP_VIDEO_BAILOUT;
- }
-
- if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
- }
-
- ret = (*portPriv->AdaptorRec->GetVideo)(portPriv->pScrn,
- portPriv->vid_x, portPriv->vid_y,
- WinBox.x1, WinBox.y1,
- portPriv->vid_w, portPriv->vid_h,
- portPriv->drw_w, portPriv->drw_h,
- &ClipRegion, portPriv->DevPriv.ptr,
- portPriv->pDraw);
-
- if(ret == Success)
- portPriv->isOn = XV_ON;
-
-CLIP_VIDEO_BAILOUT:
-
- if((clippedAway || (ret != Success)) && portPriv->isOn == XV_ON) {
- (*portPriv->AdaptorRec->StopVideo)(
- portPriv->pScrn, portPriv->DevPriv.ptr, FALSE);
- portPriv->isOn = XV_PENDING;
- }
-
- /* This clip was copied and only good for one shot */
- if(!portPriv->FreeCompositeClip)
- portPriv->pCompositeClip = NULL;
-
- RegionUninit(&WinRegion);
- RegionUninit(&ClipRegion);
-
- return ret;
-}
-
-
-static int
-xf86XVReputVideo(XvPortRecPrivatePtr portPriv)
-{
- RegionRec WinRegion;
- RegionRec ClipRegion;
- BoxRec WinBox;
- int ret = Success;
- Bool clippedAway = FALSE;
-
- xf86XVUpdateCompositeClip(portPriv);
-
- /* translate the video region to the screen */
- WinBox.x1 = portPriv->pDraw->x + portPriv->drw_x;
- WinBox.y1 = portPriv->pDraw->y + portPriv->drw_y;
- WinBox.x2 = WinBox.x1 + portPriv->drw_w;
- WinBox.y2 = WinBox.y1 + portPriv->drw_h;
-
- /* clip to the window composite clip */
- RegionInit(&WinRegion, &WinBox, 1);
- RegionNull(&ClipRegion);
- RegionIntersect(&ClipRegion, &WinRegion, portPriv->pCompositeClip);
-
- /* clip and translate to the viewport */
- if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
- RegionRec VPReg;
- BoxRec VPBox;
-
- VPBox.x1 = portPriv->pScrn->frameX0;
- VPBox.y1 = portPriv->pScrn->frameY0;
- VPBox.x2 = portPriv->pScrn->frameX1 + 1;
- VPBox.y2 = portPriv->pScrn->frameY1 + 1;
-
- RegionInit(&VPReg, &VPBox, 1);
- RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
- RegionUninit(&VPReg);
- }
-
- /* that's all if it's totally obscured */
- if(!RegionNotEmpty(&ClipRegion)) {
- clippedAway = TRUE;
- goto CLIP_VIDEO_BAILOUT;
- }
-
- /* bailout if we have to clip but the hardware doesn't support it */
- if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
- BoxPtr clipBox = RegionRects(&ClipRegion);
- if( (RegionNumRects(&ClipRegion) != 1) ||
- (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
- (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
- {
- clippedAway = TRUE;
- goto CLIP_VIDEO_BAILOUT;
- }
- }
-
- if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
- }
-
- ret = (*portPriv->AdaptorRec->PutVideo)(portPriv->pScrn,
- portPriv->vid_x, portPriv->vid_y,
- WinBox.x1, WinBox.y1,
- portPriv->vid_w, portPriv->vid_h,
- portPriv->drw_w, portPriv->drw_h,
- &ClipRegion, portPriv->DevPriv.ptr,
- portPriv->pDraw);
-
- if(ret == Success) portPriv->isOn = XV_ON;
-
-CLIP_VIDEO_BAILOUT:
-
- if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) {
- (*portPriv->AdaptorRec->StopVideo)(
- portPriv->pScrn, portPriv->DevPriv.ptr, FALSE);
- portPriv->isOn = XV_PENDING;
- }
-
- /* This clip was copied and only good for one shot */
- if(!portPriv->FreeCompositeClip)
- portPriv->pCompositeClip = NULL;
-
- RegionUninit(&WinRegion);
- RegionUninit(&ClipRegion);
-
- return ret;
-}
-
-/* Reput image/still */
-static int
-xf86XVReputImage(XvPortRecPrivatePtr portPriv)
-{
- RegionRec WinRegion;
- RegionRec ClipRegion;
- BoxRec WinBox;
- int ret = Success;
- Bool clippedAway = FALSE;
-
- xf86XVUpdateCompositeClip(portPriv);
-
- /* the clip can get smaller over time */
- RegionCopy(portPriv->clientClip, portPriv->pCompositeClip);
- RegionTranslate(portPriv->clientClip,
- -portPriv->pDraw->x, -portPriv->pDraw->y);
-
- /* translate the video region to the screen */
- WinBox.x1 = portPriv->pDraw->x + portPriv->drw_x;
- WinBox.y1 = portPriv->pDraw->y + portPriv->drw_y;
- WinBox.x2 = WinBox.x1 + portPriv->drw_w;
- WinBox.y2 = WinBox.y1 + portPriv->drw_h;
-
- /* clip to the window composite clip */
- RegionInit(&WinRegion, &WinBox, 1);
- RegionNull(&ClipRegion);
- RegionIntersect(&ClipRegion, &WinRegion, portPriv->pCompositeClip);
-
- /* clip and translate to the viewport */
- if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
- RegionRec VPReg;
- BoxRec VPBox;
-
- VPBox.x1 = portPriv->pScrn->frameX0;
- VPBox.y1 = portPriv->pScrn->frameY0;
- VPBox.x2 = portPriv->pScrn->frameX1 + 1;
- VPBox.y2 = portPriv->pScrn->frameY1 + 1;
-
- RegionInit(&VPReg, &VPBox, 1);
- RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
- RegionUninit(&VPReg);
- }
-
- /* that's all if it's totally obscured */
- if(!RegionNotEmpty(&ClipRegion)) {
- clippedAway = TRUE;
- goto CLIP_VIDEO_BAILOUT;
- }
-
- /* bailout if we have to clip but the hardware doesn't support it */
- if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
- BoxPtr clipBox = RegionRects(&ClipRegion);
- if( (RegionNumRects(&ClipRegion) != 1) ||
- (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
- (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
- {
- clippedAway = TRUE;
- goto CLIP_VIDEO_BAILOUT;
- }
- }
-
- if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
- }
-
- ret = (*portPriv->AdaptorRec->ReputImage)(portPriv->pScrn,
- portPriv->vid_x, portPriv->vid_y,
- WinBox.x1, WinBox.y1,
- portPriv->vid_w, portPriv->vid_h,
- portPriv->drw_w, portPriv->drw_h,
- &ClipRegion, portPriv->DevPriv.ptr,
- portPriv->pDraw);
-
- portPriv->isOn = (ret == Success) ? XV_ON : XV_OFF;
-
-CLIP_VIDEO_BAILOUT:
-
- if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) {
- (*portPriv->AdaptorRec->StopVideo)(
- portPriv->pScrn, portPriv->DevPriv.ptr, FALSE);
- portPriv->isOn = XV_PENDING;
- }
-
- /* This clip was copied and only good for one shot */
- if(!portPriv->FreeCompositeClip)
- portPriv->pCompositeClip = NULL;
-
- RegionUninit(&WinRegion);
- RegionUninit(&ClipRegion);
-
- return ret;
-}
-
-
-static int
-xf86XVReputAllVideo(WindowPtr pWin, pointer data)
-{
- XF86XVWindowPtr WinPriv = GET_XF86XV_WINDOW(pWin);
-
- while(WinPriv) {
- if(WinPriv->PortRec->type == XvInputMask)
- xf86XVReputVideo(WinPriv->PortRec);
- else
- xf86XVRegetVideo(WinPriv->PortRec);
- WinPriv = WinPriv->next;
- }
-
- return WT_WALKCHILDREN;
-}
-
-static int
-xf86XVEnlistPortInWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv)
-{
- XF86XVWindowPtr winPriv, PrivRoot;
-
- winPriv = PrivRoot = GET_XF86XV_WINDOW(pWin);
-
- /* Enlist our port in the window private */
- while(winPriv) {
- if(winPriv->PortRec == portPriv) /* we're already listed */
- break;
- winPriv = winPriv->next;
- }
-
- if(!winPriv) {
- winPriv = calloc(1, sizeof(XF86XVWindowRec));
- if(!winPriv) return BadAlloc;
- winPriv->PortRec = portPriv;
- winPriv->next = PrivRoot;
- dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey, winPriv);
- }
-
- portPriv->pDraw = (DrawablePtr)pWin;
-
- return Success;
-}
-
-
-static void
-xf86XVRemovePortFromWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv)
-{
- XF86XVWindowPtr winPriv, prevPriv = NULL;
- winPriv = GET_XF86XV_WINDOW(pWin);
-
- while(winPriv) {
- if(winPriv->PortRec == portPriv) {
- if(prevPriv)
- prevPriv->next = winPriv->next;
- else
- dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey,
- winPriv->next);
- free(winPriv);
- break;
- }
- prevPriv = winPriv;
- winPriv = winPriv->next;
- }
- portPriv->pDraw = NULL;
- if (portPriv->ckeyFilled) {
- RegionDestroy(portPriv->ckeyFilled);
- portPriv->ckeyFilled = NULL;
- }
- portPriv->clipChanged = FALSE;
-}
-
-static void
-xf86XVReputOrStopPort(XvPortRecPrivatePtr pPriv,
- WindowPtr pWin,
- Bool visible)
-{
- if (!visible) {
- if (pPriv->isOn == XV_ON) {
- (*pPriv->AdaptorRec->StopVideo)(pPriv->pScrn, pPriv->DevPriv.ptr, FALSE);
- pPriv->isOn = XV_PENDING;
- }
-
- if (!pPriv->type) /* overlaid still/image*/
- xf86XVRemovePortFromWindow(pWin, pPriv);
-
- return;
- }
-
- switch (pPriv->type) {
- case XvInputMask:
- xf86XVReputVideo(pPriv);
- break;
- case XvOutputMask:
- xf86XVRegetVideo(pPriv);
- break;
- default: /* overlaid still/image*/
- if (pPriv->AdaptorRec->ReputImage)
- xf86XVReputImage(pPriv);
- break;
- }
-}
-
-static void
-xf86XVReputOrStopAllPorts(ScrnInfoPtr pScrn, Bool onlyChanged)
-{
- ScreenPtr pScreen = pScrn->pScreen;
- XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
- XvAdaptorPtr pa;
- int c, i;
-
- for (c = pxvs->nAdaptors, pa = pxvs->pAdaptors; c > 0; c--, pa++) {
- XvPortPtr pPort = pa->pPorts;
-
- for (i = pa->nPorts; i > 0; i--, pPort++) {
- XvPortRecPrivatePtr pPriv = (XvPortRecPrivatePtr)pPort->devPriv.ptr;
- WindowPtr pWin = (WindowPtr)pPriv->pDraw;
- Bool visible;
-
- if (pPriv->isOn == XV_OFF || !pWin)
- continue;
-
- if (onlyChanged && !pPriv->clipChanged)
- continue;
-
- visible = pWin->visibility == VisibilityUnobscured ||
- pWin->visibility == VisibilityPartiallyObscured;
-
- /*
- * Stop and remove still/images if
- * ReputImage isn't supported.
- */
- if (!pPriv->type && !pPriv->AdaptorRec->ReputImage)
- visible = FALSE;
-
- xf86XVReputOrStopPort(pPriv, pWin, visible);
-
- pPriv->clipChanged = FALSE;
- }
- }
-}
-
-/**** ScreenRec fields ****/
-
-static Bool
-xf86XVDestroyWindow(WindowPtr pWin)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen);
- XF86XVWindowPtr tmp, WinPriv = GET_XF86XV_WINDOW(pWin);
- int ret;
-
- while(WinPriv) {
- XvPortRecPrivatePtr pPriv = WinPriv->PortRec;
-
- if(pPriv->isOn > XV_OFF) {
- (*pPriv->AdaptorRec->StopVideo)(
- pPriv->pScrn, pPriv->DevPriv.ptr, TRUE);
- pPriv->isOn = XV_OFF;
- }
-
- pPriv->pDraw = NULL;
- tmp = WinPriv;
- WinPriv = WinPriv->next;
- free(tmp);
- }
-
- dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey, NULL);
-
- pScreen->DestroyWindow = ScreenPriv->DestroyWindow;
- ret = (*pScreen->DestroyWindow)(pWin);
- pScreen->DestroyWindow = xf86XVDestroyWindow;
-
- return ret;
-}
-
-static void
-xf86XVPostValidateTree(WindowPtr pWin, WindowPtr pLayerWin, VTKind kind)
-{
- ScreenPtr pScreen;
- XF86XVScreenPtr ScreenPriv;
- ScrnInfoPtr pScrn;
-
- if (pWin)
- pScreen = pWin->drawable.pScreen;
- else
- pScreen = pLayerWin->drawable.pScreen;
-
- ScreenPriv = GET_XF86XV_SCREEN(pScreen);
- pScrn = xf86Screens[pScreen->myNum];
-
- xf86XVReputOrStopAllPorts(pScrn, TRUE);
-
- pScreen->PostValidateTree = ScreenPriv->PostValidateTree;
- if (pScreen->PostValidateTree) {
- (*pScreen->PostValidateTree)(pWin, pLayerWin, kind);
- }
- ScreenPriv->PostValidateTree = PostValidateTreeUndefined;
-}
-
-static void
-xf86XVWindowExposures(WindowPtr pWin, RegionPtr reg1, RegionPtr reg2)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen);
- XF86XVWindowPtr WinPriv = GET_XF86XV_WINDOW(pWin);
- XvPortRecPrivatePtr pPriv;
- Bool AreasExposed;
-
- AreasExposed = (WinPriv && reg1 && RegionNotEmpty(reg1));
-
- pScreen->WindowExposures = ScreenPriv->WindowExposures;
- (*pScreen->WindowExposures)(pWin, reg1, reg2);
- pScreen->WindowExposures = xf86XVWindowExposures;
-
- /* filter out XClearWindow/Area */
- if (!pWin->valdata) return;
-
- while(WinPriv) {
- Bool visible = TRUE;
-
- pPriv = WinPriv->PortRec;
-
- /*
- * Stop and remove still/images if areas were exposed and
- * ReputImage isn't supported.
- */
- if (!pPriv->type && !pPriv->AdaptorRec->ReputImage)
- visible = !AreasExposed;
-
- /*
- * Subtract exposed areas from overlaid image to match textured video
- * behavior.
- */
- if (!pPriv->type && pPriv->clientClip)
- RegionSubtract(pPriv->clientClip, pPriv->clientClip, reg1);
-
- if (visible && pPriv->ckeyFilled) {
- RegionRec tmp;
- RegionNull(&tmp);
- RegionCopy(&tmp, reg1);
- RegionTranslate(&tmp, pWin->drawable.x, pWin->drawable.y);
- RegionSubtract(pPriv->ckeyFilled, pPriv->ckeyFilled, &tmp);
- }
-
- WinPriv = WinPriv->next;
- xf86XVReputOrStopPort(pPriv, pWin, visible);
-
- pPriv->clipChanged = FALSE;
- }
-}
-
-static void
-xf86XVClipNotify(WindowPtr pWin, int dx, int dy)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen);
- XF86XVWindowPtr WinPriv = GET_XF86XV_WINDOW(pWin);
- XvPortRecPrivatePtr pPriv;
-
- while(WinPriv) {
- pPriv = WinPriv->PortRec;
-
- if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
- RegionDestroy(pPriv->pCompositeClip);
-
- pPriv->pCompositeClip = NULL;
-
- if (pPriv->AdaptorRec->ClipNotify)
- (*pPriv->AdaptorRec->ClipNotify)(pPriv->pScrn, pPriv->DevPriv.ptr,
- pWin, dx, dy);
-
- pPriv->clipChanged = TRUE;
-
- if (ScreenPriv->PostValidateTree == PostValidateTreeUndefined) {
- ScreenPriv->PostValidateTree = pScreen->PostValidateTree;
- pScreen->PostValidateTree = xf86XVPostValidateTree;
- }
-
- WinPriv = WinPriv->next;
- }
-
- if(ScreenPriv->ClipNotify) {
- pScreen->ClipNotify = ScreenPriv->ClipNotify;
- (*pScreen->ClipNotify)(pWin, dx, dy);
- pScreen->ClipNotify = xf86XVClipNotify;
- }
-}
-
-
-
-/**** Required XvScreenRec fields ****/
-
-static Bool
-xf86XVCloseScreen(int i, ScreenPtr pScreen)
-{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
- XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen);
- XvAdaptorPtr pa;
- int c;
-
- if(!ScreenPriv) return TRUE;
-
- pScreen->DestroyWindow = ScreenPriv->DestroyWindow;
- pScreen->WindowExposures = ScreenPriv->WindowExposures;
- pScreen->ClipNotify = ScreenPriv->ClipNotify;
-
- pScrn->EnterVT = ScreenPriv->EnterVT;
- pScrn->LeaveVT = ScreenPriv->LeaveVT;
- pScrn->AdjustFrame = ScreenPriv->AdjustFrame;
- pScrn->ModeSet = ScreenPriv->ModeSet;
-
- for(c = 0, pa = pxvs->pAdaptors; c < pxvs->nAdaptors; c++, pa++) {
- xf86XVFreeAdaptor(pa);
- }
-
- free(pxvs->pAdaptors);
- free(ScreenPriv);
- return TRUE;
-}
-
-
-static int
-xf86XVQueryAdaptors(
- ScreenPtr pScreen,
- XvAdaptorPtr *p_pAdaptors,
- int *p_nAdaptors
-){
- XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
-
- *p_nAdaptors = pxvs->nAdaptors;
- *p_pAdaptors = pxvs->pAdaptors;
-
- return Success;
-}
-
-
-/**** ScrnInfoRec fields ****/
-
-static Bool
-xf86XVEnterVT(int index, int flags)
-{
- ScrnInfoPtr pScrn = xf86Screens[index];
- ScreenPtr pScreen = screenInfo.screens[index];
- XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen);
- Bool ret;
-
- pScrn->EnterVT = ScreenPriv->EnterVT;
- ret = (*ScreenPriv->EnterVT)(index, flags);
- ScreenPriv->EnterVT = pScrn->EnterVT;
- pScrn->EnterVT = xf86XVEnterVT;
-
- if(ret) WalkTree(pScreen, xf86XVReputAllVideo, 0);
-
- return ret;
-}
-
-static void
-xf86XVLeaveVT(int index, int flags)
-{
- ScrnInfoPtr pScrn = xf86Screens[index];
- ScreenPtr pScreen = screenInfo.screens[index];
- XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
- XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen);
- XvAdaptorPtr pAdaptor;
- XvPortPtr pPort;
- XvPortRecPrivatePtr pPriv;
- int i, j;
-
- for(i = 0; i < pxvs->nAdaptors; i++) {
- pAdaptor = &pxvs->pAdaptors[i];
- for(j = 0; j < pAdaptor->nPorts; j++) {
- pPort = &pAdaptor->pPorts[j];
- pPriv = (XvPortRecPrivatePtr)pPort->devPriv.ptr;
- if(pPriv->isOn > XV_OFF) {
-
- (*pPriv->AdaptorRec->StopVideo)(
- pPriv->pScrn, pPriv->DevPriv.ptr, TRUE);
- pPriv->isOn = XV_OFF;
-
- if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
- RegionDestroy(pPriv->pCompositeClip);
-
- pPriv->pCompositeClip = NULL;
-
- if(!pPriv->type && pPriv->pDraw) { /* still */
- xf86XVRemovePortFromWindow((WindowPtr)pPriv->pDraw, pPriv);
- }
- }
- }
- }
-
- pScrn->LeaveVT = ScreenPriv->LeaveVT;
- (*ScreenPriv->LeaveVT)(index, flags);
- ScreenPriv->LeaveVT = pScrn->LeaveVT;
- pScrn->LeaveVT = xf86XVLeaveVT;
-}
-
-static void
-xf86XVAdjustFrame(int index, int x, int y, int flags)
-{
- ScrnInfoPtr pScrn = xf86Screens[index];
- ScreenPtr pScreen = pScrn->pScreen;
- XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen);
-
- if(ScreenPriv->AdjustFrame) {
- pScrn->AdjustFrame = ScreenPriv->AdjustFrame;
- (*pScrn->AdjustFrame)(index, x, y, flags);
- pScrn->AdjustFrame = xf86XVAdjustFrame;
- }
-
- xf86XVReputOrStopAllPorts(pScrn, FALSE);
-}
-
-static void
-xf86XVModeSet(ScrnInfoPtr pScrn)
-{
- ScreenPtr pScreen = pScrn->pScreen;
- XF86XVScreenPtr ScreenPriv;
-
- /* Can be called before pScrn->pScreen is set */
- if (!pScreen)
- return;
-
- ScreenPriv = GET_XF86XV_SCREEN(pScreen);
-
- if (ScreenPriv->ModeSet) {
- pScrn->ModeSet = ScreenPriv->ModeSet;
- (*pScrn->ModeSet)(pScrn);
- pScrn->ModeSet = xf86XVModeSet;
- }
-
- xf86XVReputOrStopAllPorts(pScrn, FALSE);
-}
-
-/**** XvAdaptorRec fields ****/
-
-static int
-xf86XVAllocatePort(
- unsigned long port,
- XvPortPtr pPort,
- XvPortPtr *ppPort
-){
- *ppPort = pPort;
- return Success;
-}
-
-
-
-static int
-xf86XVFreePort(XvPortPtr pPort)
-{
- return Success;
-}
-
-
-static int
-xf86XVPutVideo(
- ClientPtr client,
- DrawablePtr pDraw,
- XvPortPtr pPort,
- GCPtr pGC,
- INT16 vid_x, INT16 vid_y,
- CARD16 vid_w, CARD16 vid_h,
- INT16 drw_x, INT16 drw_y,
- CARD16 drw_w, CARD16 drw_h
-){
- XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
- int result;
-
- /* No dumping video to pixmaps... For now anyhow */
- if(pDraw->type != DRAWABLE_WINDOW) {
- pPort->pDraw = (DrawablePtr)NULL;
- return BadAlloc;
- }
-
- /* If we are changing windows, unregister our port in the old window */
- if(portPriv->pDraw && (portPriv->pDraw != pDraw))
- xf86XVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
-
- /* Register our port with the new window */
- result = xf86XVEnlistPortInWindow((WindowPtr)pDraw, portPriv);
- if(result != Success) return result;
-
- portPriv->type = XvInputMask;
-
- /* save a copy of these parameters */
- portPriv->vid_x = vid_x; portPriv->vid_y = vid_y;
- portPriv->vid_w = vid_w; portPriv->vid_h = vid_h;
- portPriv->drw_x = drw_x; portPriv->drw_y = drw_y;
- portPriv->drw_w = drw_w; portPriv->drw_h = drw_h;
-
- /* make sure we have the most recent copy of the clientClip */
- xf86XVCopyClip(portPriv, pGC);
-
- /* To indicate to the DI layer that we were successful */
- pPort->pDraw = pDraw;
-
- if(!portPriv->pScrn->vtSema) return Success; /* Success ? */
-
- return(xf86XVReputVideo(portPriv));
-}
-
-static int
-xf86XVPutStill(
- ClientPtr client,
- DrawablePtr pDraw,
- XvPortPtr pPort,
- GCPtr pGC,
- INT16 vid_x, INT16 vid_y,
- CARD16 vid_w, CARD16 vid_h,
- INT16 drw_x, INT16 drw_y,
- CARD16 drw_w, CARD16 drw_h
-){
- XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
- RegionRec WinRegion;
- RegionRec ClipRegion;
- BoxRec WinBox;
- int ret = Success;
- Bool clippedAway = FALSE;
-
- if (pDraw->type != DRAWABLE_WINDOW)
- return BadAlloc;
-
- if(!portPriv->pScrn->vtSema) return Success; /* Success ? */
-
- WinBox.x1 = pDraw->x + drw_x;
- WinBox.y1 = pDraw->y + drw_y;
- WinBox.x2 = WinBox.x1 + drw_w;
- WinBox.y2 = WinBox.y1 + drw_h;
-
- xf86XVCopyCompositeClip(portPriv, pGC, pDraw);
-
- RegionInit(&WinRegion, &WinBox, 1);
- RegionNull(&ClipRegion);
- RegionIntersect(&ClipRegion, &WinRegion, pGC->pCompositeClip);
-
- if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
- RegionRec VPReg;
- BoxRec VPBox;
-
- VPBox.x1 = portPriv->pScrn->frameX0;
- VPBox.y1 = portPriv->pScrn->frameY0;
- VPBox.x2 = portPriv->pScrn->frameX1 + 1;
- VPBox.y2 = portPriv->pScrn->frameY1 + 1;
-
- RegionInit(&VPReg, &VPBox, 1);
- RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
- RegionUninit(&VPReg);
- }
-
- if(portPriv->pDraw) {
- xf86XVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
- }
-
- if(!RegionNotEmpty(&ClipRegion)) {
- clippedAway = TRUE;
- goto PUT_STILL_BAILOUT;
- }
-
- if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
- BoxPtr clipBox = RegionRects(&ClipRegion);
- if( (RegionNumRects(&ClipRegion) != 1) ||
- (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
- (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
- {
- clippedAway = TRUE;
- goto PUT_STILL_BAILOUT;
- }
- }
-
- if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
- }
-
- ret = (*portPriv->AdaptorRec->PutStill)(portPriv->pScrn,
- vid_x, vid_y, WinBox.x1, WinBox.y1,
- vid_w, vid_h, drw_w, drw_h,
- &ClipRegion, portPriv->DevPriv.ptr,
- pDraw);
-
- if((ret == Success) &&
- (portPriv->AdaptorRec->flags & VIDEO_OVERLAID_STILLS)) {
-
- xf86XVEnlistPortInWindow((WindowPtr)pDraw, portPriv);
- portPriv->isOn = XV_ON;
- portPriv->vid_x = vid_x; portPriv->vid_y = vid_y;
- portPriv->vid_w = vid_w; portPriv->vid_h = vid_h;
- portPriv->drw_x = drw_x; portPriv->drw_y = drw_y;
- portPriv->drw_w = drw_w; portPriv->drw_h = drw_h;
- portPriv->type = 0; /* no mask means it's transient and should
- not be reput once it's removed */
- pPort->pDraw = pDraw; /* make sure we can get stop requests */
- }
-
-PUT_STILL_BAILOUT:
-
- if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) {
- (*portPriv->AdaptorRec->StopVideo)(
- portPriv->pScrn, portPriv->DevPriv.ptr, FALSE);
- portPriv->isOn = XV_PENDING;
- }
-
- /* This clip was copied and only good for one shot */
- if(!portPriv->FreeCompositeClip)
- portPriv->pCompositeClip = NULL;
-
- RegionUninit(&WinRegion);
- RegionUninit(&ClipRegion);
-
- return ret;
-}
-
-static int
-xf86XVGetVideo(
- ClientPtr client,
- DrawablePtr pDraw,
- XvPortPtr pPort,
- GCPtr pGC,
- INT16 vid_x, INT16 vid_y,
- CARD16 vid_w, CARD16 vid_h,
- INT16 drw_x, INT16 drw_y,
- CARD16 drw_w, CARD16 drw_h
-){
- XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
- int result;
-
- /* No pixmaps... For now anyhow */
- if(pDraw->type != DRAWABLE_WINDOW) {
- pPort->pDraw = (DrawablePtr)NULL;
- return BadAlloc;
- }
-
- /* If we are changing windows, unregister our port in the old window */
- if(portPriv->pDraw && (portPriv->pDraw != pDraw))
- xf86XVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
-
- /* Register our port with the new window */
- result = xf86XVEnlistPortInWindow((WindowPtr)pDraw, portPriv);
- if(result != Success) return result;
-
- portPriv->type = XvOutputMask;
-
- /* save a copy of these parameters */
- portPriv->vid_x = vid_x; portPriv->vid_y = vid_y;
- portPriv->vid_w = vid_w; portPriv->vid_h = vid_h;
- portPriv->drw_x = drw_x; portPriv->drw_y = drw_y;
- portPriv->drw_w = drw_w; portPriv->drw_h = drw_h;
-
- /* make sure we have the most recent copy of the clientClip */
- xf86XVCopyClip(portPriv, pGC);
-
- /* To indicate to the DI layer that we were successful */
- pPort->pDraw = pDraw;
-
- if(!portPriv->pScrn->vtSema) return Success; /* Success ? */
-
- return(xf86XVRegetVideo(portPriv));
-}
-
-static int
-xf86XVGetStill(
- ClientPtr client,
- DrawablePtr pDraw,
- XvPortPtr pPort,
- GCPtr pGC,
- INT16 vid_x, INT16 vid_y,
- CARD16 vid_w, CARD16 vid_h,
- INT16 drw_x, INT16 drw_y,
- CARD16 drw_w, CARD16 drw_h
-){
- XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
- RegionRec WinRegion;
- RegionRec ClipRegion;
- BoxRec WinBox;
- int ret = Success;
- Bool clippedAway = FALSE;
-
- if (pDraw->type != DRAWABLE_WINDOW)
- return BadAlloc;
-
- if(!portPriv->pScrn->vtSema) return Success; /* Success ? */
-
- WinBox.x1 = pDraw->x + drw_x;
- WinBox.y1 = pDraw->y + drw_y;
- WinBox.x2 = WinBox.x1 + drw_w;
- WinBox.y2 = WinBox.y1 + drw_h;
-
- RegionInit(&WinRegion, &WinBox, 1);
- RegionNull(&ClipRegion);
- RegionIntersect(&ClipRegion, &WinRegion, pGC->pCompositeClip);
-
- if(portPriv->pDraw) {
- xf86XVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
- }
-
- if(!RegionNotEmpty(&ClipRegion)) {
- clippedAway = TRUE;
- goto GET_STILL_BAILOUT;
- }
-
- if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
- }
-
- ret = (*portPriv->AdaptorRec->GetStill)(portPriv->pScrn,
- vid_x, vid_y, WinBox.x1, WinBox.y1,
- vid_w, vid_h, drw_w, drw_h,
- &ClipRegion, portPriv->DevPriv.ptr,
- pDraw);
-
-GET_STILL_BAILOUT:
-
- if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) {
- (*portPriv->AdaptorRec->StopVideo)(
- portPriv->pScrn, portPriv->DevPriv.ptr, FALSE);
- portPriv->isOn = XV_PENDING;
- }
-
- RegionUninit(&WinRegion);
- RegionUninit(&ClipRegion);
-
- return ret;
-}
-
-
-
-static int
-xf86XVStopVideo(
- ClientPtr client,
- XvPortPtr pPort,
- DrawablePtr pDraw
-){
- XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
-
- if(pDraw->type != DRAWABLE_WINDOW)
- return BadAlloc;
-
- xf86XVRemovePortFromWindow((WindowPtr)pDraw, portPriv);
-
- if(!portPriv->pScrn->vtSema) return Success; /* Success ? */
-
- /* Must free resources. */
-
- if(portPriv->isOn > XV_OFF) {
- (*portPriv->AdaptorRec->StopVideo)(
- portPriv->pScrn, portPriv->DevPriv.ptr, TRUE);
- portPriv->isOn = XV_OFF;
- }
-
- return Success;
-}
-
-static int
-xf86XVSetPortAttribute(
- ClientPtr client,
- XvPortPtr pPort,
- Atom attribute,
- INT32 value
-){
- XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
-
- return((*portPriv->AdaptorRec->SetPortAttribute)(portPriv->pScrn,
- attribute, value, portPriv->DevPriv.ptr));
-}
-
-
-static int
-xf86XVGetPortAttribute(
- ClientPtr client,
- XvPortPtr pPort,
- Atom attribute,
- INT32 *p_value
-){
- XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
-
- return((*portPriv->AdaptorRec->GetPortAttribute)(portPriv->pScrn,
- attribute, p_value, portPriv->DevPriv.ptr));
-}
-
-
-
-static int
-xf86XVQueryBestSize(
- ClientPtr client,
- XvPortPtr pPort,
- CARD8 motion,
- CARD16 vid_w, CARD16 vid_h,
- CARD16 drw_w, CARD16 drw_h,
- unsigned int *p_w, unsigned int *p_h
-){
- XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
-
- (*portPriv->AdaptorRec->QueryBestSize)(portPriv->pScrn,
- (Bool)motion, vid_w, vid_h, drw_w, drw_h,
- p_w, p_h, portPriv->DevPriv.ptr);
-
- return Success;
-}
-
-
-static int
-xf86XVPutImage(
- ClientPtr client,
- DrawablePtr pDraw,
- XvPortPtr pPort,
- GCPtr pGC,
- INT16 src_x, INT16 src_y,
- CARD16 src_w, CARD16 src_h,
- INT16 drw_x, INT16 drw_y,
- CARD16 drw_w, CARD16 drw_h,
- XvImagePtr format,
- unsigned char* data,
- Bool sync,
- CARD16 width, CARD16 height
-){
- XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
- RegionRec WinRegion;
- RegionRec ClipRegion;
- BoxRec WinBox;
- int ret = Success;
- Bool clippedAway = FALSE;
-
- if (pDraw->type != DRAWABLE_WINDOW)
- return BadAlloc;
-
- if(!portPriv->pScrn->vtSema) return Success; /* Success ? */
-
- xf86XVCopyCompositeClip(portPriv, pGC, pDraw);
-
- WinBox.x1 = pDraw->x + drw_x;
- WinBox.y1 = pDraw->y + drw_y;
- WinBox.x2 = WinBox.x1 + drw_w;
- WinBox.y2 = WinBox.y1 + drw_h;
-
- RegionInit(&WinRegion, &WinBox, 1);
- RegionNull(&ClipRegion);
- RegionIntersect(&ClipRegion, &WinRegion, pGC->pCompositeClip);
-
- if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
- RegionRec VPReg;
- BoxRec VPBox;
-
- VPBox.x1 = portPriv->pScrn->frameX0;
- VPBox.y1 = portPriv->pScrn->frameY0;
- VPBox.x2 = portPriv->pScrn->frameX1 + 1;
- VPBox.y2 = portPriv->pScrn->frameY1 + 1;
-
- RegionInit(&VPReg, &VPBox, 1);
- RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
- RegionUninit(&VPReg);
- }
-
- /* If we are changing windows, unregister our port in the old window */
- if(portPriv->pDraw && (portPriv->pDraw != pDraw))
- xf86XVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
-
- /* Register our port with the new window */
- ret = xf86XVEnlistPortInWindow((WindowPtr)pDraw, portPriv);
- if(ret != Success) goto PUT_IMAGE_BAILOUT;
-
- if(!RegionNotEmpty(&ClipRegion)) {
- clippedAway = TRUE;
- goto PUT_IMAGE_BAILOUT;
- }
-
- if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
- BoxPtr clipBox = RegionRects(&ClipRegion);
- if( (RegionNumRects(&ClipRegion) != 1) ||
- (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
- (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
- {
- clippedAway = TRUE;
- goto PUT_IMAGE_BAILOUT;
- }
- }
-
- if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
- }
-
- ret = (*portPriv->AdaptorRec->PutImage)(portPriv->pScrn,
- src_x, src_y, WinBox.x1, WinBox.y1,
- src_w, src_h, drw_w, drw_h, format->id, data, width, height,
- sync, &ClipRegion, portPriv->DevPriv.ptr,
- pDraw);
-
- if((ret == Success) &&
- (portPriv->AdaptorRec->flags & VIDEO_OVERLAID_IMAGES)) {
-
- portPriv->isOn = XV_ON;
- portPriv->vid_x = src_x; portPriv->vid_y = src_y;
- portPriv->vid_w = src_w; portPriv->vid_h = src_h;
- portPriv->drw_x = drw_x; portPriv->drw_y = drw_y;
- portPriv->drw_w = drw_w; portPriv->drw_h = drw_h;
- portPriv->type = 0; /* no mask means it's transient and should
- not be reput once it's removed */
- pPort->pDraw = pDraw; /* make sure we can get stop requests */
- }
-
-PUT_IMAGE_BAILOUT:
-
- if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) {
- (*portPriv->AdaptorRec->StopVideo)(
- portPriv->pScrn, portPriv->DevPriv.ptr, FALSE);
- portPriv->isOn = XV_PENDING;
- }
-
- /* This clip was copied and only good for one shot */
- if(!portPriv->FreeCompositeClip)
- portPriv->pCompositeClip = NULL;
-
- RegionUninit(&WinRegion);
- RegionUninit(&ClipRegion);
-
- return ret;
-}
-
-
-static int
-xf86XVQueryImageAttributes(
- ClientPtr client,
- XvPortPtr pPort,
- XvImagePtr format,
- CARD16 *width,
- CARD16 *height,
- int *pitches,
- int *offsets
-){
- XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
-
- return (*portPriv->AdaptorRec->QueryImageAttributes)(portPriv->pScrn,
- format->id, width, height, pitches, offsets);
-}
-
-void
-xf86XVFillKeyHelperDrawable (DrawablePtr pDraw, CARD32 key, RegionPtr fillboxes)
-{
- ScreenPtr pScreen = pDraw->pScreen;
- ChangeGCVal pval[2];
- BoxPtr pbox = RegionRects(fillboxes);
- int i, nbox = RegionNumRects(fillboxes);
- xRectangle *rects;
- GCPtr gc;
-
- if(!xf86Screens[pScreen->myNum]->vtSema) return;
-
- gc = GetScratchGC(pDraw->depth, pScreen);
- pval[0].val = key;
- pval[1].val = IncludeInferiors;
- (void) ChangeGC(NullClient, gc, GCForeground|GCSubwindowMode, pval);
- ValidateGC(pDraw, gc);
-
- rects = malloc(nbox * sizeof(xRectangle));
-
- for(i = 0; i < nbox; i++, pbox++)
- {
- rects[i].x = pbox->x1 - pDraw->x;
- rects[i].y = pbox->y1 - pDraw->y;
- rects[i].width = pbox->x2 - pbox->x1;
- rects[i].height = pbox->y2 - pbox->y1;
- }
-
- (*gc->ops->PolyFillRect)(pDraw, gc, nbox, rects);
-
- free(rects);
- FreeScratchGC (gc);
-}
-
-void
-xf86XVFillKeyHelper (ScreenPtr pScreen, CARD32 key, RegionPtr fillboxes)
-{
- xf86XVFillKeyHelperDrawable (&pScreen->root->drawable, key, fillboxes);
-}
-
-void
-xf86XVFillKeyHelperPort (DrawablePtr pDraw, pointer data, CARD32 key, RegionPtr clipboxes, Bool fillEverything)
-{
- WindowPtr pWin = (WindowPtr)pDraw;
- XF86XVWindowPtr WinPriv = GET_XF86XV_WINDOW(pWin);
- XvPortRecPrivatePtr portPriv = NULL;
- RegionRec reg;
- RegionPtr fillboxes;
-
- while (WinPriv) {
- XvPortRecPrivatePtr pPriv = WinPriv->PortRec;
-
- if (data == pPriv->DevPriv.ptr) {
- portPriv = pPriv;
- break;
- }
-
- WinPriv = WinPriv->next;
- }
-
- if (!portPriv)
- return;
-
- if (!portPriv->ckeyFilled)
- portPriv->ckeyFilled = RegionCreate(NULL, 0);
-
- if (!fillEverything) {
- RegionNull(&reg);
- fillboxes = &reg;
- RegionSubtract(fillboxes, clipboxes, portPriv->ckeyFilled);
-
- if (!RegionNotEmpty(fillboxes))
- goto out;
- } else
- fillboxes = clipboxes;
-
-
- RegionCopy(portPriv->ckeyFilled, clipboxes);
-
- xf86XVFillKeyHelperDrawable(pDraw, key, fillboxes);
-out:
- if (!fillEverything)
- RegionUninit(&reg);
-}
-
-
-/* xf86XVClipVideoHelper -
-
- Takes the dst box in standard X BoxRec form (top and left
- edges inclusive, bottom and right exclusive). The new dst
- box is returned. The source boundaries are given (x1, y1
- inclusive, x2, y2 exclusive) and returned are the new source
- boundaries in 16.16 fixed point.
-*/
-
-Bool
-xf86XVClipVideoHelper(
- BoxPtr dst,
- INT32 *xa,
- INT32 *xb,
- INT32 *ya,
- INT32 *yb,
- RegionPtr reg,
- INT32 width,
- INT32 height
-){
- double xsw, xdw, ysw, ydw;
- INT32 delta;
- BoxPtr extents = RegionExtents(reg);
- int diff;
-
- xsw = (*xb - *xa) << 16;
- xdw = dst->x2 - dst->x1;
- ysw = (*yb - *ya) << 16;
- ydw = dst->y2 - dst->y1;
-
- *xa <<= 16; *xb <<= 16;
- *ya <<= 16; *yb <<= 16;
-
- diff = extents->x1 - dst->x1;
- if (diff > 0) {
- dst->x1 = extents->x1;
- *xa += (diff * xsw) / xdw;
- }
- diff = dst->x2 - extents->x2;
- if (diff > 0) {
- dst->x2 = extents->x2;
- *xb -= (diff * xsw) / xdw;
- }
- diff = extents->y1 - dst->y1;
- if (diff > 0) {
- dst->y1 = extents->y1;
- *ya += (diff * ysw) / ydw;
- }
- diff = dst->y2 - extents->y2;
- if (diff > 0) {
- dst->y2 = extents->y2;
- *yb -= (diff * ysw) / ydw;
- }
-
- if (*xa < 0) {
- diff = (((-*xa) * xdw) + xsw - 1) / xsw;
- dst->x1 += diff;
- *xa += (diff * xsw) / xdw;
- }
- delta = *xb - (width << 16);
- if (delta > 0) {
- diff = ((delta * xdw) + xsw - 1) / xsw;
- dst->x2 -= diff;
- *xb -= (diff * xsw) / xdw;
- }
- if (*xa >= *xb) return FALSE;
-
- if (*ya < 0) {
- diff = (((-*ya) * ydw) + ysw - 1) / ysw;
- dst->y1 += diff;
- *ya += (diff * ysw) / ydw;
- }
- delta = *yb - (height << 16);
- if (delta > 0) {
- diff = ((delta * ydw) + ysw - 1) / ysw;
- dst->y2 -= diff;
- *yb -= (diff * ysw) / ydw;
- }
- if (*ya >= *yb) return FALSE;
-
- if ((dst->x1 > extents->x1) || (dst->x2 < extents->x2) ||
- (dst->y1 > extents->y1) || (dst->y2 < extents->y2))
- {
- RegionRec clipReg;
- RegionInit(&clipReg, dst, 1);
- RegionIntersect(reg, reg, &clipReg);
- RegionUninit(&clipReg);
- }
- return TRUE;
-}
-
-void
-xf86XVCopyYUV12ToPacked(
- const void *srcy,
- const void *srcv,
- const void *srcu,
- void *dst,
- int srcPitchy,
- int srcPitchuv,
- int dstPitch,
- int h,
- int w
-){
- CARD32 *Dst;
- const CARD8 *Y, *U, *V;
- int i, j;
-
- w >>= 1;
-
- for (j = 0; j < h; j++) {
- Dst = dst;
- Y = srcy; V = srcv; U = srcu;
- i = w;
- while (i >= 4) {
-#if X_BYTE_ORDER == X_LITTLE_ENDIAN
- Dst[0] = Y[0] | (Y[1] << 16) | (U[0] << 8) | (V[0] << 24);
- Dst[1] = Y[2] | (Y[3] << 16) | (U[1] << 8) | (V[1] << 24);
- Dst[2] = Y[4] | (Y[5] << 16) | (U[2] << 8) | (V[2] << 24);
- Dst[3] = Y[6] | (Y[7] << 16) | (U[3] << 8) | (V[3] << 24);
-#else
- /* This assumes a little-endian framebuffer */
- Dst[0] = (Y[0] << 24) | (Y[1] << 8) | (U[0] << 16) | V[0];
- Dst[1] = (Y[2] << 24) | (Y[3] << 8) | (U[1] << 16) | V[1];
- Dst[2] = (Y[4] << 24) | (Y[5] << 8) | (U[2] << 16) | V[2];
- Dst[3] = (Y[6] << 24) | (Y[7] << 8) | (U[3] << 16) | V[3];
-#endif
- Dst += 4; Y += 8; V += 4; U += 4;
- i -= 4;
- }
-
- while (i--) {
-#if X_BYTE_ORDER == X_LITTLE_ENDIAN
- Dst[0] = Y[0] | (Y[1] << 16) | (U[0] << 8) | (V[0] << 24);
-#else
- /* This assumes a little-endian framebuffer */
- Dst[0] = (Y[0] << 24) | (Y[1] << 8) | (U[0] << 16) | V[0];
-#endif
- Dst++; Y += 2; V++; U++;
- }
-
- dst = (CARD8 *)dst + dstPitch;
- srcy = (const CARD8 *)srcy + srcPitchy;
- if (j & 1) {
- srcu = (const CARD8 *)srcu + srcPitchuv;
- srcv = (const CARD8 *)srcv + srcPitchuv;
- }
- }
-}
-
-void
-xf86XVCopyPacked(
- const void *src,
- void *dst,
- int srcPitch,
- int dstPitch,
- int h,
- int w
-){
- const CARD32 *Src;
- CARD32 *Dst;
- int i;
-
- w >>= 1;
- while (--h >= 0) {
- do {
- Dst = dst; Src = src;
- i = w;
- while (i >= 4) {
- Dst[0] = Src[0];
- Dst[1] = Src[1];
- Dst[2] = Src[2];
- Dst[3] = Src[3];
- Dst += 4; Src += 4; i -= 4;
- }
- if (!i) break;
- Dst[0] = Src[0];
- if (i == 1) break;
- Dst[1] = Src[1];
- if (i == 2) break;
- Dst[2] = Src[2];
- } while (0);
-
- src = (const CARD8 *)src + srcPitch;
- dst = (CARD8 *)dst + dstPitch;
- }
-}
+/*
+ * XFree86 Xv DDX written by Mark Vojkovich (markv@valinux.com)
+ */
+/*
+ * Copyright (c) 1998-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).
+ */
+
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "scrnintstr.h"
+#include "regionstr.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "mivalidate.h"
+#include "validate.h"
+#include "resource.h"
+#include "gcstruct.h"
+#include "dixstruct.h"
+
+#include <X11/extensions/Xv.h>
+#include <X11/extensions/Xvproto.h>
+#include "xvdix.h"
+#include "xvmodproc.h"
+
+#include "xf86xvpriv.h"
+
+
+/* XvScreenRec fields */
+
+static Bool xf86XVCloseScreen(int, ScreenPtr);
+static int xf86XVQueryAdaptors(ScreenPtr, XvAdaptorPtr *, int *);
+
+/* XvAdaptorRec fields */
+
+static int xf86XVAllocatePort(unsigned long, XvPortPtr, XvPortPtr*);
+static int xf86XVFreePort(XvPortPtr);
+static int xf86XVPutVideo(ClientPtr, DrawablePtr,XvPortPtr, GCPtr,
+ INT16, INT16, CARD16, CARD16,
+ INT16, INT16, CARD16, CARD16);
+static int xf86XVPutStill(ClientPtr, DrawablePtr,XvPortPtr, GCPtr,
+ INT16, INT16, CARD16, CARD16,
+ INT16, INT16, CARD16, CARD16);
+static int xf86XVGetVideo(ClientPtr, DrawablePtr,XvPortPtr, GCPtr,
+ INT16, INT16, CARD16, CARD16,
+ INT16, INT16, CARD16, CARD16);
+static int xf86XVGetStill(ClientPtr, DrawablePtr,XvPortPtr, GCPtr,
+ INT16, INT16, CARD16, CARD16,
+ INT16, INT16, CARD16, CARD16);
+static int xf86XVStopVideo(ClientPtr, XvPortPtr, DrawablePtr);
+static int xf86XVSetPortAttribute(ClientPtr, XvPortPtr, Atom, INT32);
+static int xf86XVGetPortAttribute(ClientPtr, XvPortPtr, Atom, INT32*);
+static int xf86XVQueryBestSize(ClientPtr, XvPortPtr, CARD8,
+ CARD16, CARD16,CARD16, CARD16,
+ unsigned int*, unsigned int*);
+static int xf86XVPutImage(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
+ INT16, INT16, CARD16, CARD16,
+ INT16, INT16, CARD16, CARD16,
+ XvImagePtr, unsigned char*, Bool,
+ CARD16, CARD16);
+static int xf86XVQueryImageAttributes(ClientPtr, XvPortPtr, XvImagePtr,
+ CARD16*, CARD16*, int*, int*);
+
+
+/* ScreenRec fields */
+
+static Bool xf86XVDestroyWindow(WindowPtr pWin);
+static void xf86XVWindowExposures(WindowPtr pWin, RegionPtr r1, RegionPtr r2);
+static void xf86XVPostValidateTree(WindowPtr pWin, WindowPtr pLayerWin, VTKind kind);
+static void xf86XVClipNotify(WindowPtr pWin, int dx, int dy);
+
+#define PostValidateTreeUndefined ((PostValidateTreeProcPtr)-1)
+
+/* ScrnInfoRec functions */
+
+static Bool xf86XVEnterVT(int, int);
+static void xf86XVLeaveVT(int, int);
+static void xf86XVAdjustFrame(int index, int x, int y, int flags);
+static void xf86XVModeSet(ScrnInfoPtr pScrn);
+
+/* misc */
+
+static Bool xf86XVInitAdaptors(ScreenPtr, XF86VideoAdaptorPtr*, int);
+
+
+static DevPrivateKeyRec XF86XVWindowKeyRec;
+#define XF86XVWindowKey (&XF86XVWindowKeyRec)
+
+DevPrivateKey XF86XvScreenKey;
+
+static unsigned long PortResource = 0;
+
+DevPrivateKey (*XvGetScreenKeyProc)(void) = NULL;
+unsigned long (*XvGetRTPortProc)(void) = NULL;
+int (*XvScreenInitProc)(ScreenPtr) = NULL;
+
+#define GET_XV_SCREEN(pScreen) \
+ ((XvScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, XF86XvScreenKey))
+
+#define GET_XF86XV_SCREEN(pScreen) \
+ ((XF86XVScreenPtr)(GET_XV_SCREEN(pScreen)->devPriv.ptr))
+
+#define GET_XF86XV_WINDOW(pWin) \
+ ((XF86XVWindowPtr)dixLookupPrivate(&(pWin)->devPrivates, XF86XVWindowKey))
+
+static xf86XVInitGenericAdaptorPtr *GenDrivers = NULL;
+static int NumGenDrivers = 0;
+
+int
+xf86XVRegisterGenericAdaptorDriver(
+ xf86XVInitGenericAdaptorPtr InitFunc
+){
+ xf86XVInitGenericAdaptorPtr *newdrivers;
+
+ newdrivers = realloc(GenDrivers, sizeof(xf86XVInitGenericAdaptorPtr) *
+ (1 + NumGenDrivers));
+ if (!newdrivers)
+ return 0;
+ GenDrivers = newdrivers;
+
+ GenDrivers[NumGenDrivers++] = InitFunc;
+
+ return 1;
+}
+
+int
+xf86XVListGenericAdaptors(
+ ScrnInfoPtr pScrn,
+ XF86VideoAdaptorPtr **adaptors
+){
+ int i,j,n,num;
+ XF86VideoAdaptorPtr *DrivAdap,*new;
+
+ num = 0;
+ *adaptors = NULL;
+ /*
+ * The v4l driver registers itself first, but can use surfaces registered
+ * by other drivers. So, call the v4l driver last.
+ */
+ for (i = NumGenDrivers; --i >= 0; ) {
+ DrivAdap = NULL;
+ n = (*GenDrivers[i])(pScrn, &DrivAdap);
+ if (0 == n)
+ continue;
+ new = realloc(*adaptors, sizeof(XF86VideoAdaptorPtr) * (num+n));
+ if (NULL == new)
+ continue;
+ *adaptors = new;
+ for (j = 0; j < n; j++, num++)
+ (*adaptors)[num] = DrivAdap[j];
+ }
+ return num;
+}
+
+
+/**************** Offscreen surface stuff *******************/
+
+typedef struct {
+ XF86OffscreenImagePtr images;
+ int num;
+} OffscreenImageRec;
+
+static DevPrivateKeyRec OffscreenPrivateKeyRec;
+#define OffscreenPrivateKey (&OffscreenPrivateKeyRec)
+#define GetOffscreenImage(pScreen) ((OffscreenImageRec *) dixLookupPrivate(&(pScreen)->devPrivates, OffscreenPrivateKey))
+
+Bool
+xf86XVRegisterOffscreenImages(
+ ScreenPtr pScreen,
+ XF86OffscreenImagePtr images,
+ int num
+){
+ OffscreenImageRec *OffscreenImage;
+ /* This function may be called before xf86XVScreenInit, so there's
+ * no better place than this to call dixRegisterPrivateKey to ensure we
+ * have space reserved. After the first call it is a no-op. */
+ if(!dixRegisterPrivateKey(OffscreenPrivateKey, PRIVATE_SCREEN, sizeof(OffscreenImageRec)) ||
+ !(OffscreenImage = GetOffscreenImage(pScreen)))
+ /* Every X.org driver assumes this function always succeeds, so
+ * just die on allocation failure. */
+ FatalError("Could not allocate private storage for XV offscreen images.\n");
+
+ OffscreenImage->num = num;
+ OffscreenImage->images = images;
+ return TRUE;
+}
+
+XF86OffscreenImagePtr
+xf86XVQueryOffscreenImages(
+ ScreenPtr pScreen,
+ int *num
+){
+ OffscreenImageRec *OffscreenImage = GetOffscreenImage(pScreen);
+ *num = OffscreenImage->num;
+ return OffscreenImage->images;
+}
+
+
+XF86VideoAdaptorPtr
+xf86XVAllocateVideoAdaptorRec(ScrnInfoPtr pScrn)
+{
+ return calloc(1, sizeof(XF86VideoAdaptorRec));
+}
+
+void
+xf86XVFreeVideoAdaptorRec(XF86VideoAdaptorPtr ptr)
+{
+ free(ptr);
+}
+
+
+Bool
+xf86XVScreenInit(
+ ScreenPtr pScreen,
+ XF86VideoAdaptorPtr *adaptors,
+ int num
+){
+ ScrnInfoPtr pScrn;
+ XF86XVScreenPtr ScreenPriv;
+ XvScreenPtr pxvs;
+
+ if(num <= 0 ||
+ !XvGetScreenKeyProc || !XvGetRTPortProc || !XvScreenInitProc)
+ return FALSE;
+
+ if(Success != (*XvScreenInitProc)(pScreen)) return FALSE;
+
+ if (!dixRegisterPrivateKey(&XF86XVWindowKeyRec, PRIVATE_WINDOW, 0))
+ return FALSE;
+
+ XF86XvScreenKey = (*XvGetScreenKeyProc)();
+
+ PortResource = (*XvGetRTPortProc)();
+
+ pxvs = GET_XV_SCREEN(pScreen);
+
+ /* Anyone initializing the Xv layer must provide these two.
+ The Xv di layer calls them without even checking if they exist! */
+
+ pxvs->ddCloseScreen = xf86XVCloseScreen;
+ pxvs->ddQueryAdaptors = xf86XVQueryAdaptors;
+
+ /* The Xv di layer provides us with a private hook so that we don't
+ have to allocate our own screen private. They also provide
+ a CloseScreen hook so that we don't have to wrap it. I'm not
+ sure that I appreciate that. */
+
+ ScreenPriv = malloc(sizeof(XF86XVScreenRec));
+ pxvs->devPriv.ptr = (pointer)ScreenPriv;
+
+ if(!ScreenPriv) return FALSE;
+
+ pScrn = xf86Screens[pScreen->myNum];
+
+ ScreenPriv->DestroyWindow = pScreen->DestroyWindow;
+ ScreenPriv->WindowExposures = pScreen->WindowExposures;
+ ScreenPriv->PostValidateTree = PostValidateTreeUndefined;
+ ScreenPriv->ClipNotify = pScreen->ClipNotify;
+ ScreenPriv->EnterVT = pScrn->EnterVT;
+ ScreenPriv->LeaveVT = pScrn->LeaveVT;
+ ScreenPriv->AdjustFrame = pScrn->AdjustFrame;
+ ScreenPriv->ModeSet = pScrn->ModeSet;
+
+ pScreen->DestroyWindow = xf86XVDestroyWindow;
+ pScreen->WindowExposures = xf86XVWindowExposures;
+ pScreen->ClipNotify = xf86XVClipNotify;
+ pScrn->EnterVT = xf86XVEnterVT;
+ pScrn->LeaveVT = xf86XVLeaveVT;
+ if(pScrn->AdjustFrame)
+ pScrn->AdjustFrame = xf86XVAdjustFrame;
+ pScrn->ModeSet = xf86XVModeSet;
+
+ if(!xf86XVInitAdaptors(pScreen, adaptors, num))
+ return FALSE;
+
+ return TRUE;
+}
+
+static void
+xf86XVFreeAdaptor(XvAdaptorPtr pAdaptor)
+{
+ int i;
+
+ free(pAdaptor->name);
+ pAdaptor->name = NULL;
+
+ if(pAdaptor->pEncodings) {
+ XvEncodingPtr pEncode = pAdaptor->pEncodings;
+
+ for(i = 0; i < pAdaptor->nEncodings; i++, pEncode++)
+ free(pEncode->name);
+ free(pAdaptor->pEncodings);
+ pAdaptor->pEncodings = NULL;
+ }
+
+ free(pAdaptor->pFormats);
+ pAdaptor->pFormats = NULL;
+
+ if(pAdaptor->pPorts) {
+ XvPortPtr pPort = pAdaptor->pPorts;
+ XvPortRecPrivatePtr pPriv;
+
+ for(i = 0; i < pAdaptor->nPorts; i++, pPort++) {
+ pPriv = (XvPortRecPrivatePtr)pPort->devPriv.ptr;
+ if(pPriv) {
+ if(pPriv->clientClip)
+ RegionDestroy(pPriv->clientClip);
+ if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
+ RegionDestroy(pPriv->pCompositeClip);
+ if (pPriv->ckeyFilled)
+ RegionDestroy(pPriv->ckeyFilled);
+ free(pPriv);
+ }
+ }
+ free(pAdaptor->pPorts);
+ pAdaptor->pPorts = NULL;
+ }
+
+ if(pAdaptor->pAttributes) {
+ XvAttributePtr pAttribute = pAdaptor->pAttributes;
+
+ for(i = 0; i < pAdaptor->nAttributes; i++, pAttribute++)
+ free(pAttribute->name);
+ free(pAdaptor->pAttributes);
+ pAdaptor->pAttributes = NULL;
+ }
+
+ free(pAdaptor->pImages);
+ free(pAdaptor->devPriv.ptr);
+ pAdaptor->pImages = NULL;
+ pAdaptor->devPriv.ptr = NULL;
+}
+
+static Bool
+xf86XVInitAdaptors(
+ ScreenPtr pScreen,
+ XF86VideoAdaptorPtr *infoPtr,
+ int number
+) {
+ XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ XF86VideoAdaptorPtr adaptorPtr;
+ XvAdaptorPtr pAdaptor, pa;
+ XvAdaptorRecPrivatePtr adaptorPriv;
+ int na, numAdaptor;
+ XvPortRecPrivatePtr portPriv;
+ XvPortPtr pPort, pp;
+ int numPort;
+ XF86AttributePtr attributePtr;
+ XvAttributePtr pAttribute, pat;
+ XF86VideoFormatPtr formatPtr;
+ XvFormatPtr pFormat, pf;
+ int numFormat, totFormat;
+ XF86VideoEncodingPtr encodingPtr;
+ XvEncodingPtr pEncode, pe;
+ XF86ImagePtr imagePtr;
+ XvImagePtr pImage, pi;
+ int numVisuals;
+ VisualPtr pVisual;
+ int i;
+
+ pxvs->nAdaptors = 0;
+ pxvs->pAdaptors = NULL;
+
+ if(!(pAdaptor = calloc(number, sizeof(XvAdaptorRec))))
+ return FALSE;
+
+ for(pa = pAdaptor, na = 0, numAdaptor = 0; na < number; na++, adaptorPtr++) {
+ adaptorPtr = infoPtr[na];
+
+ if(!adaptorPtr->StopVideo || !adaptorPtr->SetPortAttribute ||
+ !adaptorPtr->GetPortAttribute || !adaptorPtr->QueryBestSize)
+ continue;
+
+ /* client libs expect at least one encoding */
+ if(!adaptorPtr->nEncodings || !adaptorPtr->pEncodings)
+ continue;
+
+ pa->type = adaptorPtr->type;
+
+ if(!adaptorPtr->PutVideo && !adaptorPtr->GetVideo)
+ pa->type &= ~XvVideoMask;
+
+ if(!adaptorPtr->PutStill && !adaptorPtr->GetStill)
+ pa->type &= ~XvStillMask;
+
+ if(!adaptorPtr->PutImage || !adaptorPtr->QueryImageAttributes)
+ pa->type &= ~XvImageMask;
+
+ if(!adaptorPtr->PutVideo && !adaptorPtr->PutImage &&
+ !adaptorPtr->PutStill)
+ pa->type &= ~XvInputMask;
+
+ if(!adaptorPtr->GetVideo && !adaptorPtr->GetStill)
+ pa->type &= ~XvOutputMask;
+
+ if(!(adaptorPtr->type & (XvPixmapMask | XvWindowMask)))
+ continue;
+ if(!(adaptorPtr->type & (XvImageMask | XvVideoMask | XvStillMask)))
+ continue;
+
+ pa->pScreen = pScreen;
+ pa->ddAllocatePort = xf86XVAllocatePort;
+ pa->ddFreePort = xf86XVFreePort;
+ pa->ddPutVideo = xf86XVPutVideo;
+ pa->ddPutStill = xf86XVPutStill;
+ pa->ddGetVideo = xf86XVGetVideo;
+ pa->ddGetStill = xf86XVGetStill;
+ pa->ddStopVideo = xf86XVStopVideo;
+ pa->ddPutImage = xf86XVPutImage;
+ pa->ddSetPortAttribute = xf86XVSetPortAttribute;
+ pa->ddGetPortAttribute = xf86XVGetPortAttribute;
+ pa->ddQueryBestSize = xf86XVQueryBestSize;
+ pa->ddQueryImageAttributes = xf86XVQueryImageAttributes;
+ pa->name = strdup(adaptorPtr->name);
+
+ if(adaptorPtr->nEncodings &&
+ (pEncode = calloc(adaptorPtr->nEncodings, sizeof(XvEncodingRec)))) {
+
+ for(pe = pEncode, encodingPtr = adaptorPtr->pEncodings, i = 0;
+ i < adaptorPtr->nEncodings; pe++, i++, encodingPtr++)
+ {
+ pe->id = encodingPtr->id;
+ pe->pScreen = pScreen;
+ pe->name = strdup(encodingPtr->name);
+ pe->width = encodingPtr->width;
+ pe->height = encodingPtr->height;
+ pe->rate.numerator = encodingPtr->rate.numerator;
+ pe->rate.denominator = encodingPtr->rate.denominator;
+ }
+ pa->nEncodings = adaptorPtr->nEncodings;
+ pa->pEncodings = pEncode;
+ }
+
+ if(adaptorPtr->nImages &&
+ (pImage = calloc(adaptorPtr->nImages, sizeof(XvImageRec)))) {
+
+ for(i = 0, pi = pImage, imagePtr = adaptorPtr->pImages;
+ i < adaptorPtr->nImages; i++, pi++, imagePtr++)
+ {
+ pi->id = imagePtr->id;
+ pi->type = imagePtr->type;
+ pi->byte_order = imagePtr->byte_order;
+ memcpy(pi->guid, imagePtr->guid, 16);
+ pi->bits_per_pixel = imagePtr->bits_per_pixel;
+ pi->format = imagePtr->format;
+ pi->num_planes = imagePtr->num_planes;
+ pi->depth = imagePtr->depth;
+ pi->red_mask = imagePtr->red_mask;
+ pi->green_mask = imagePtr->green_mask;
+ pi->blue_mask = imagePtr->blue_mask;
+ pi->y_sample_bits = imagePtr->y_sample_bits;
+ pi->u_sample_bits = imagePtr->u_sample_bits;
+ pi->v_sample_bits = imagePtr->v_sample_bits;
+ pi->horz_y_period = imagePtr->horz_y_period;
+ pi->horz_u_period = imagePtr->horz_u_period;
+ pi->horz_v_period = imagePtr->horz_v_period;
+ pi->vert_y_period = imagePtr->vert_y_period;
+ pi->vert_u_period = imagePtr->vert_u_period;
+ pi->vert_v_period = imagePtr->vert_v_period;
+ memcpy(pi->component_order, imagePtr->component_order, 32);
+ pi->scanline_order = imagePtr->scanline_order;
+ }
+ pa->nImages = adaptorPtr->nImages;
+ pa->pImages = pImage;
+ }
+
+ if(adaptorPtr->nAttributes &&
+ (pAttribute = calloc(adaptorPtr->nAttributes, sizeof(XvAttributeRec))))
+ {
+ for(pat = pAttribute, attributePtr = adaptorPtr->pAttributes, i = 0;
+ i < adaptorPtr->nAttributes; pat++, i++, attributePtr++)
+ {
+ pat->flags = attributePtr->flags;
+ pat->min_value = attributePtr->min_value;
+ pat->max_value = attributePtr->max_value;
+ pat->name = strdup(attributePtr->name);
+ }
+ pa->nAttributes = adaptorPtr->nAttributes;
+ pa->pAttributes = pAttribute;
+ }
+
+
+ totFormat = adaptorPtr->nFormats;
+
+ if(!(pFormat = calloc(totFormat, sizeof(XvFormatRec)))) {
+ xf86XVFreeAdaptor(pa);
+ continue;
+ }
+ for(pf = pFormat, i = 0, numFormat = 0, formatPtr = adaptorPtr->pFormats;
+ i < adaptorPtr->nFormats; i++, formatPtr++)
+ {
+ numVisuals = pScreen->numVisuals;
+ pVisual = pScreen->visuals;
+
+ while(numVisuals--) {
+ if((pVisual->class == formatPtr->class) &&
+ (pVisual->nplanes == formatPtr->depth)) {
+
+ if(numFormat >= totFormat) {
+ void *moreSpace;
+ totFormat *= 2;
+ moreSpace = realloc(pFormat,
+ totFormat * sizeof(XvFormatRec));
+ if(!moreSpace) break;
+ pFormat = moreSpace;
+ pf = pFormat + numFormat;
+ }
+
+ pf->visual = pVisual->vid;
+ pf->depth = formatPtr->depth;
+
+ pf++;
+ numFormat++;
+ }
+ pVisual++;
+ }
+ }
+ pa->nFormats = numFormat;
+ pa->pFormats = pFormat;
+ if(!numFormat) {
+ xf86XVFreeAdaptor(pa);
+ continue;
+ }
+
+ if(!(adaptorPriv = calloc(1, sizeof(XvAdaptorRecPrivate)))) {
+ xf86XVFreeAdaptor(pa);
+ continue;
+ }
+
+ adaptorPriv->flags = adaptorPtr->flags;
+ adaptorPriv->PutVideo = adaptorPtr->PutVideo;
+ adaptorPriv->PutStill = adaptorPtr->PutStill;
+ adaptorPriv->GetVideo = adaptorPtr->GetVideo;
+ adaptorPriv->GetStill = adaptorPtr->GetStill;
+ adaptorPriv->StopVideo = adaptorPtr->StopVideo;
+ adaptorPriv->SetPortAttribute = adaptorPtr->SetPortAttribute;
+ adaptorPriv->GetPortAttribute = adaptorPtr->GetPortAttribute;
+ adaptorPriv->QueryBestSize = adaptorPtr->QueryBestSize;
+ adaptorPriv->QueryImageAttributes = adaptorPtr->QueryImageAttributes;
+ adaptorPriv->PutImage = adaptorPtr->PutImage;
+ adaptorPriv->ReputImage = adaptorPtr->ReputImage; /* image/still */
+
+ pa->devPriv.ptr = (pointer)adaptorPriv;
+
+ if(!(pPort = calloc(adaptorPtr->nPorts, sizeof(XvPortRec)))) {
+ xf86XVFreeAdaptor(pa);
+ continue;
+ }
+ for(pp = pPort, i = 0, numPort = 0;
+ i < adaptorPtr->nPorts; i++) {
+
+ if(!(pp->id = FakeClientID(0)))
+ continue;
+
+ if(!(portPriv = calloc(1, sizeof(XvPortRecPrivate))))
+ continue;
+
+ if(!AddResource(pp->id, PortResource, pp)) {
+ free(portPriv);
+ continue;
+ }
+
+ pp->pAdaptor = pa;
+ pp->pNotify = (XvPortNotifyPtr)NULL;
+ pp->pDraw = (DrawablePtr)NULL;
+ pp->client = (ClientPtr)NULL;
+ pp->grab.client = (ClientPtr)NULL;
+ pp->time = currentTime;
+ pp->devPriv.ptr = portPriv;
+
+ portPriv->pScrn = pScrn;
+ portPriv->AdaptorRec = adaptorPriv;
+ portPriv->DevPriv.ptr = adaptorPtr->pPortPrivates[i].ptr;
+
+ pp++;
+ numPort++;
+ }
+ pa->nPorts = numPort;
+ pa->pPorts = pPort;
+ if(!numPort) {
+ xf86XVFreeAdaptor(pa);
+ continue;
+ }
+
+ pa->base_id = pPort->id;
+
+ pa++;
+ numAdaptor++;
+ }
+
+ if(numAdaptor) {
+ pxvs->nAdaptors = numAdaptor;
+ pxvs->pAdaptors = pAdaptor;
+ } else {
+ free(pAdaptor);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/* Video should be clipped to the intersection of the window cliplist
+ and the client cliplist specified in the GC for which the video was
+ initialized. When we need to reclip a window, the GC that started
+ the video may not even be around anymore. That's why we save the
+ client clip from the GC when the video is initialized. We then
+ use xf86XVUpdateCompositeClip to calculate the new composite clip
+ when we need it. This is different from what DEC did. They saved
+ the GC and used it's clip list when they needed to reclip the window,
+ even if the client clip was different from the one the video was
+ initialized with. If the original GC was destroyed, they had to stop
+ the video. I like the new method better (MArk).
+
+ This function only works for windows. Will need to rewrite when
+ (if) we support pixmap rendering.
+*/
+
+static void
+xf86XVUpdateCompositeClip(XvPortRecPrivatePtr portPriv)
+{
+ RegionPtr pregWin, pCompositeClip;
+ WindowPtr pWin;
+ Bool freeCompClip = FALSE;
+
+ if(portPriv->pCompositeClip)
+ return;
+
+ pWin = (WindowPtr)portPriv->pDraw;
+
+ /* get window clip list */
+ if(portPriv->subWindowMode == IncludeInferiors) {
+ pregWin = NotClippedByChildren(pWin);
+ freeCompClip = TRUE;
+ } else
+ pregWin = &pWin->clipList;
+
+ if(!portPriv->clientClip) {
+ portPriv->pCompositeClip = pregWin;
+ portPriv->FreeCompositeClip = freeCompClip;
+ return;
+ }
+
+ pCompositeClip = RegionCreate(NullBox, 1);
+ RegionCopy(pCompositeClip, portPriv->clientClip);
+ RegionTranslate(pCompositeClip,
+ portPriv->pDraw->x, portPriv->pDraw->y);
+ RegionIntersect(pCompositeClip, pregWin, pCompositeClip);
+
+ portPriv->pCompositeClip = pCompositeClip;
+ portPriv->FreeCompositeClip = TRUE;
+
+ if(freeCompClip) {
+ RegionDestroy(pregWin);
+ }
+}
+
+/* Save the current clientClip and update the CompositeClip whenever
+ we have a fresh GC */
+
+static void
+xf86XVCopyClip(
+ XvPortRecPrivatePtr portPriv,
+ GCPtr pGC
+){
+ /* copy the new clip if it exists */
+ if((pGC->clientClipType == CT_REGION) && pGC->clientClip) {
+ if(!portPriv->clientClip)
+ portPriv->clientClip = RegionCreate(NullBox, 1);
+ /* Note: this is in window coordinates */
+ RegionCopy(portPriv->clientClip, pGC->clientClip);
+ RegionTranslate(portPriv->clientClip,
+ pGC->clipOrg.x, pGC->clipOrg.y);
+ } else if(portPriv->clientClip) { /* free the old clientClip */
+ RegionDestroy(portPriv->clientClip);
+ portPriv->clientClip = NULL;
+ }
+
+ /* get rid of the old clip list */
+ if(portPriv->pCompositeClip && portPriv->FreeCompositeClip) {
+ RegionDestroy(portPriv->pCompositeClip);
+ }
+
+ portPriv->pCompositeClip = pGC->pCompositeClip;
+ portPriv->FreeCompositeClip = FALSE;
+ portPriv->subWindowMode = pGC->subWindowMode;
+}
+
+static void
+xf86XVCopyCompositeClip(XvPortRecPrivatePtr portPriv,
+ GCPtr pGC,
+ DrawablePtr pDraw)
+{
+ if (!portPriv->clientClip)
+ portPriv->clientClip = RegionCreate(NullBox, 1);
+ /* Keep the original GC composite clip around for ReputImage */
+ RegionCopy(portPriv->clientClip, pGC->pCompositeClip);
+ RegionTranslate(portPriv->clientClip,
+ -pDraw->x, -pDraw->y);
+
+ /* get rid of the old clip list */
+ if (portPriv->pCompositeClip && portPriv->FreeCompositeClip)
+ RegionDestroy(portPriv->pCompositeClip);
+
+ portPriv->pCompositeClip = pGC->pCompositeClip;
+ portPriv->FreeCompositeClip = FALSE;
+ portPriv->subWindowMode = pGC->subWindowMode;
+}
+
+static int
+xf86XVRegetVideo(XvPortRecPrivatePtr portPriv)
+{
+ RegionRec WinRegion;
+ RegionRec ClipRegion;
+ BoxRec WinBox;
+ int ret = Success;
+ Bool clippedAway = FALSE;
+
+ xf86XVUpdateCompositeClip(portPriv);
+
+ /* translate the video region to the screen */
+ WinBox.x1 = portPriv->pDraw->x + portPriv->drw_x;
+ WinBox.y1 = portPriv->pDraw->y + portPriv->drw_y;
+ WinBox.x2 = WinBox.x1 + portPriv->drw_w;
+ WinBox.y2 = WinBox.y1 + portPriv->drw_h;
+
+ /* clip to the window composite clip */
+ RegionInit(&WinRegion, &WinBox, 1);
+ RegionNull(&ClipRegion);
+ RegionIntersect(&ClipRegion, &WinRegion, portPriv->pCompositeClip);
+
+ /* that's all if it's totally obscured */
+ if(!RegionNotEmpty(&ClipRegion)) {
+ clippedAway = TRUE;
+ goto CLIP_VIDEO_BAILOUT;
+ }
+
+ if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
+ RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
+ }
+
+ ret = (*portPriv->AdaptorRec->GetVideo)(portPriv->pScrn,
+ portPriv->vid_x, portPriv->vid_y,
+ WinBox.x1, WinBox.y1,
+ portPriv->vid_w, portPriv->vid_h,
+ portPriv->drw_w, portPriv->drw_h,
+ &ClipRegion, portPriv->DevPriv.ptr,
+ portPriv->pDraw);
+
+ if(ret == Success)
+ portPriv->isOn = XV_ON;
+
+CLIP_VIDEO_BAILOUT:
+
+ if((clippedAway || (ret != Success)) && portPriv->isOn == XV_ON) {
+ (*portPriv->AdaptorRec->StopVideo)(
+ portPriv->pScrn, portPriv->DevPriv.ptr, FALSE);
+ portPriv->isOn = XV_PENDING;
+ }
+
+ /* This clip was copied and only good for one shot */
+ if(!portPriv->FreeCompositeClip)
+ portPriv->pCompositeClip = NULL;
+
+ RegionUninit(&WinRegion);
+ RegionUninit(&ClipRegion);
+
+ return ret;
+}
+
+
+static int
+xf86XVReputVideo(XvPortRecPrivatePtr portPriv)
+{
+ RegionRec WinRegion;
+ RegionRec ClipRegion;
+ BoxRec WinBox;
+ int ret = Success;
+ Bool clippedAway = FALSE;
+
+ xf86XVUpdateCompositeClip(portPriv);
+
+ /* translate the video region to the screen */
+ WinBox.x1 = portPriv->pDraw->x + portPriv->drw_x;
+ WinBox.y1 = portPriv->pDraw->y + portPriv->drw_y;
+ WinBox.x2 = WinBox.x1 + portPriv->drw_w;
+ WinBox.y2 = WinBox.y1 + portPriv->drw_h;
+
+ /* clip to the window composite clip */
+ RegionInit(&WinRegion, &WinBox, 1);
+ RegionNull(&ClipRegion);
+ RegionIntersect(&ClipRegion, &WinRegion, portPriv->pCompositeClip);
+
+ /* clip and translate to the viewport */
+ if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
+ RegionRec VPReg;
+ BoxRec VPBox;
+
+ VPBox.x1 = portPriv->pScrn->frameX0;
+ VPBox.y1 = portPriv->pScrn->frameY0;
+ VPBox.x2 = portPriv->pScrn->frameX1 + 1;
+ VPBox.y2 = portPriv->pScrn->frameY1 + 1;
+
+ RegionInit(&VPReg, &VPBox, 1);
+ RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
+ RegionUninit(&VPReg);
+ }
+
+ /* that's all if it's totally obscured */
+ if(!RegionNotEmpty(&ClipRegion)) {
+ clippedAway = TRUE;
+ goto CLIP_VIDEO_BAILOUT;
+ }
+
+ /* bailout if we have to clip but the hardware doesn't support it */
+ if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
+ BoxPtr clipBox = RegionRects(&ClipRegion);
+ if( (RegionNumRects(&ClipRegion) != 1) ||
+ (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
+ (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
+ {
+ clippedAway = TRUE;
+ goto CLIP_VIDEO_BAILOUT;
+ }
+ }
+
+ if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
+ RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
+ }
+
+ ret = (*portPriv->AdaptorRec->PutVideo)(portPriv->pScrn,
+ portPriv->vid_x, portPriv->vid_y,
+ WinBox.x1, WinBox.y1,
+ portPriv->vid_w, portPriv->vid_h,
+ portPriv->drw_w, portPriv->drw_h,
+ &ClipRegion, portPriv->DevPriv.ptr,
+ portPriv->pDraw);
+
+ if(ret == Success) portPriv->isOn = XV_ON;
+
+CLIP_VIDEO_BAILOUT:
+
+ if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) {
+ (*portPriv->AdaptorRec->StopVideo)(
+ portPriv->pScrn, portPriv->DevPriv.ptr, FALSE);
+ portPriv->isOn = XV_PENDING;
+ }
+
+ /* This clip was copied and only good for one shot */
+ if(!portPriv->FreeCompositeClip)
+ portPriv->pCompositeClip = NULL;
+
+ RegionUninit(&WinRegion);
+ RegionUninit(&ClipRegion);
+
+ return ret;
+}
+
+/* Reput image/still */
+static int
+xf86XVReputImage(XvPortRecPrivatePtr portPriv)
+{
+ RegionRec WinRegion;
+ RegionRec ClipRegion;
+ BoxRec WinBox;
+ int ret = Success;
+ Bool clippedAway = FALSE;
+
+ xf86XVUpdateCompositeClip(portPriv);
+
+ /* the clip can get smaller over time */
+ RegionCopy(portPriv->clientClip, portPriv->pCompositeClip);
+ RegionTranslate(portPriv->clientClip,
+ -portPriv->pDraw->x, -portPriv->pDraw->y);
+
+ /* translate the video region to the screen */
+ WinBox.x1 = portPriv->pDraw->x + portPriv->drw_x;
+ WinBox.y1 = portPriv->pDraw->y + portPriv->drw_y;
+ WinBox.x2 = WinBox.x1 + portPriv->drw_w;
+ WinBox.y2 = WinBox.y1 + portPriv->drw_h;
+
+ /* clip to the window composite clip */
+ RegionInit(&WinRegion, &WinBox, 1);
+ RegionNull(&ClipRegion);
+ RegionIntersect(&ClipRegion, &WinRegion, portPriv->pCompositeClip);
+
+ /* clip and translate to the viewport */
+ if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
+ RegionRec VPReg;
+ BoxRec VPBox;
+
+ VPBox.x1 = portPriv->pScrn->frameX0;
+ VPBox.y1 = portPriv->pScrn->frameY0;
+ VPBox.x2 = portPriv->pScrn->frameX1 + 1;
+ VPBox.y2 = portPriv->pScrn->frameY1 + 1;
+
+ RegionInit(&VPReg, &VPBox, 1);
+ RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
+ RegionUninit(&VPReg);
+ }
+
+ /* that's all if it's totally obscured */
+ if(!RegionNotEmpty(&ClipRegion)) {
+ clippedAway = TRUE;
+ goto CLIP_VIDEO_BAILOUT;
+ }
+
+ /* bailout if we have to clip but the hardware doesn't support it */
+ if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
+ BoxPtr clipBox = RegionRects(&ClipRegion);
+ if( (RegionNumRects(&ClipRegion) != 1) ||
+ (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
+ (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
+ {
+ clippedAway = TRUE;
+ goto CLIP_VIDEO_BAILOUT;
+ }
+ }
+
+ if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
+ RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
+ }
+
+ ret = (*portPriv->AdaptorRec->ReputImage)(portPriv->pScrn,
+ portPriv->vid_x, portPriv->vid_y,
+ WinBox.x1, WinBox.y1,
+ portPriv->vid_w, portPriv->vid_h,
+ portPriv->drw_w, portPriv->drw_h,
+ &ClipRegion, portPriv->DevPriv.ptr,
+ portPriv->pDraw);
+
+ portPriv->isOn = (ret == Success) ? XV_ON : XV_OFF;
+
+CLIP_VIDEO_BAILOUT:
+
+ if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) {
+ (*portPriv->AdaptorRec->StopVideo)(
+ portPriv->pScrn, portPriv->DevPriv.ptr, FALSE);
+ portPriv->isOn = XV_PENDING;
+ }
+
+ /* This clip was copied and only good for one shot */
+ if(!portPriv->FreeCompositeClip)
+ portPriv->pCompositeClip = NULL;
+
+ RegionUninit(&WinRegion);
+ RegionUninit(&ClipRegion);
+
+ return ret;
+}
+
+
+static int
+xf86XVReputAllVideo(WindowPtr pWin, pointer data)
+{
+ XF86XVWindowPtr WinPriv = GET_XF86XV_WINDOW(pWin);
+
+ while(WinPriv) {
+ if(WinPriv->PortRec->type == XvInputMask)
+ xf86XVReputVideo(WinPriv->PortRec);
+ else
+ xf86XVRegetVideo(WinPriv->PortRec);
+ WinPriv = WinPriv->next;
+ }
+
+ return WT_WALKCHILDREN;
+}
+
+static int
+xf86XVEnlistPortInWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv)
+{
+ XF86XVWindowPtr winPriv, PrivRoot;
+
+ winPriv = PrivRoot = GET_XF86XV_WINDOW(pWin);
+
+ /* Enlist our port in the window private */
+ while(winPriv) {
+ if(winPriv->PortRec == portPriv) /* we're already listed */
+ break;
+ winPriv = winPriv->next;
+ }
+
+ if(!winPriv) {
+ winPriv = calloc(1, sizeof(XF86XVWindowRec));
+ if(!winPriv) return BadAlloc;
+ winPriv->PortRec = portPriv;
+ winPriv->next = PrivRoot;
+ dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey, winPriv);
+ }
+
+ portPriv->pDraw = (DrawablePtr)pWin;
+
+ return Success;
+}
+
+
+static void
+xf86XVRemovePortFromWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv)
+{
+ XF86XVWindowPtr winPriv, prevPriv = NULL;
+ winPriv = GET_XF86XV_WINDOW(pWin);
+
+ while(winPriv) {
+ if(winPriv->PortRec == portPriv) {
+ if(prevPriv)
+ prevPriv->next = winPriv->next;
+ else
+ dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey,
+ winPriv->next);
+ free(winPriv);
+ break;
+ }
+ prevPriv = winPriv;
+ winPriv = winPriv->next;
+ }
+ portPriv->pDraw = NULL;
+ if (portPriv->ckeyFilled) {
+ RegionDestroy(portPriv->ckeyFilled);
+ portPriv->ckeyFilled = NULL;
+ }
+ portPriv->clipChanged = FALSE;
+}
+
+static void
+xf86XVReputOrStopPort(XvPortRecPrivatePtr pPriv,
+ WindowPtr pWin,
+ Bool visible)
+{
+ if (!visible) {
+ if (pPriv->isOn == XV_ON) {
+ (*pPriv->AdaptorRec->StopVideo)(pPriv->pScrn, pPriv->DevPriv.ptr, FALSE);
+ pPriv->isOn = XV_PENDING;
+ }
+
+ if (!pPriv->type) /* overlaid still/image*/
+ xf86XVRemovePortFromWindow(pWin, pPriv);
+
+ return;
+ }
+
+ switch (pPriv->type) {
+ case XvInputMask:
+ xf86XVReputVideo(pPriv);
+ break;
+ case XvOutputMask:
+ xf86XVRegetVideo(pPriv);
+ break;
+ default: /* overlaid still/image*/
+ if (pPriv->AdaptorRec->ReputImage)
+ xf86XVReputImage(pPriv);
+ break;
+ }
+}
+
+static void
+xf86XVReputOrStopAllPorts(ScrnInfoPtr pScrn, Bool onlyChanged)
+{
+ ScreenPtr pScreen = pScrn->pScreen;
+ XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
+ XvAdaptorPtr pa;
+ int c, i;
+
+ for (c = pxvs->nAdaptors, pa = pxvs->pAdaptors; c > 0; c--, pa++) {
+ XvPortPtr pPort = pa->pPorts;
+
+ for (i = pa->nPorts; i > 0; i--, pPort++) {
+ XvPortRecPrivatePtr pPriv = (XvPortRecPrivatePtr)pPort->devPriv.ptr;
+ WindowPtr pWin = (WindowPtr)pPriv->pDraw;
+ Bool visible;
+
+ if (pPriv->isOn == XV_OFF || !pWin)
+ continue;
+
+ if (onlyChanged && !pPriv->clipChanged)
+ continue;
+
+ visible = pWin->visibility == VisibilityUnobscured ||
+ pWin->visibility == VisibilityPartiallyObscured;
+
+ /*
+ * Stop and remove still/images if
+ * ReputImage isn't supported.
+ */
+ if (!pPriv->type && !pPriv->AdaptorRec->ReputImage)
+ visible = FALSE;
+
+ xf86XVReputOrStopPort(pPriv, pWin, visible);
+
+ pPriv->clipChanged = FALSE;
+ }
+ }
+}
+
+/**** ScreenRec fields ****/
+
+static Bool
+xf86XVDestroyWindow(WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen);
+ XF86XVWindowPtr tmp, WinPriv = GET_XF86XV_WINDOW(pWin);
+ int ret;
+
+ while(WinPriv) {
+ XvPortRecPrivatePtr pPriv = WinPriv->PortRec;
+
+ if(pPriv->isOn > XV_OFF) {
+ (*pPriv->AdaptorRec->StopVideo)(
+ pPriv->pScrn, pPriv->DevPriv.ptr, TRUE);
+ pPriv->isOn = XV_OFF;
+ }
+
+ pPriv->pDraw = NULL;
+ tmp = WinPriv;
+ WinPriv = WinPriv->next;
+ free(tmp);
+ }
+
+ dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey, NULL);
+
+ pScreen->DestroyWindow = ScreenPriv->DestroyWindow;
+ ret = (*pScreen->DestroyWindow)(pWin);
+ pScreen->DestroyWindow = xf86XVDestroyWindow;
+
+ return ret;
+}
+
+static void
+xf86XVPostValidateTree(WindowPtr pWin, WindowPtr pLayerWin, VTKind kind)
+{
+ ScreenPtr pScreen;
+ XF86XVScreenPtr ScreenPriv;
+ ScrnInfoPtr pScrn;
+
+ if (pWin)
+ pScreen = pWin->drawable.pScreen;
+ else
+ pScreen = pLayerWin->drawable.pScreen;
+
+ ScreenPriv = GET_XF86XV_SCREEN(pScreen);
+ pScrn = xf86Screens[pScreen->myNum];
+
+ xf86XVReputOrStopAllPorts(pScrn, TRUE);
+
+ pScreen->PostValidateTree = ScreenPriv->PostValidateTree;
+ if (pScreen->PostValidateTree) {
+ (*pScreen->PostValidateTree)(pWin, pLayerWin, kind);
+ }
+ ScreenPriv->PostValidateTree = PostValidateTreeUndefined;
+}
+
+static void
+xf86XVWindowExposures(WindowPtr pWin, RegionPtr reg1, RegionPtr reg2)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen);
+ XF86XVWindowPtr WinPriv = GET_XF86XV_WINDOW(pWin);
+ XvPortRecPrivatePtr pPriv;
+ Bool AreasExposed;
+
+ AreasExposed = (WinPriv && reg1 && RegionNotEmpty(reg1));
+
+ pScreen->WindowExposures = ScreenPriv->WindowExposures;
+ (*pScreen->WindowExposures)(pWin, reg1, reg2);
+ pScreen->WindowExposures = xf86XVWindowExposures;
+
+ /* filter out XClearWindow/Area */
+ if (!pWin->valdata) return;
+
+ while(WinPriv) {
+ Bool visible = TRUE;
+
+ pPriv = WinPriv->PortRec;
+
+ /*
+ * Stop and remove still/images if areas were exposed and
+ * ReputImage isn't supported.
+ */
+ if (!pPriv->type && !pPriv->AdaptorRec->ReputImage)
+ visible = !AreasExposed;
+
+ /*
+ * Subtract exposed areas from overlaid image to match textured video
+ * behavior.
+ */
+ if (!pPriv->type && pPriv->clientClip)
+ RegionSubtract(pPriv->clientClip, pPriv->clientClip, reg1);
+
+ if (visible && pPriv->ckeyFilled) {
+ RegionRec tmp;
+ RegionNull(&tmp);
+ RegionCopy(&tmp, reg1);
+ RegionTranslate(&tmp, pWin->drawable.x, pWin->drawable.y);
+ RegionSubtract(pPriv->ckeyFilled, pPriv->ckeyFilled, &tmp);
+ }
+
+ WinPriv = WinPriv->next;
+ xf86XVReputOrStopPort(pPriv, pWin, visible);
+
+ pPriv->clipChanged = FALSE;
+ }
+}
+
+static void
+xf86XVClipNotify(WindowPtr pWin, int dx, int dy)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen);
+ XF86XVWindowPtr WinPriv = GET_XF86XV_WINDOW(pWin);
+ XvPortRecPrivatePtr pPriv;
+
+ while(WinPriv) {
+ pPriv = WinPriv->PortRec;
+
+ if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
+ RegionDestroy(pPriv->pCompositeClip);
+
+ pPriv->pCompositeClip = NULL;
+
+ if (pPriv->AdaptorRec->ClipNotify)
+ (*pPriv->AdaptorRec->ClipNotify)(pPriv->pScrn, pPriv->DevPriv.ptr,
+ pWin, dx, dy);
+
+ pPriv->clipChanged = TRUE;
+
+ if (ScreenPriv->PostValidateTree == PostValidateTreeUndefined) {
+ ScreenPriv->PostValidateTree = pScreen->PostValidateTree;
+ pScreen->PostValidateTree = xf86XVPostValidateTree;
+ }
+
+ WinPriv = WinPriv->next;
+ }
+
+ if(ScreenPriv->ClipNotify) {
+ pScreen->ClipNotify = ScreenPriv->ClipNotify;
+ (*pScreen->ClipNotify)(pWin, dx, dy);
+ pScreen->ClipNotify = xf86XVClipNotify;
+ }
+}
+
+
+
+/**** Required XvScreenRec fields ****/
+
+static Bool
+xf86XVCloseScreen(int i, ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
+ XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen);
+ XvAdaptorPtr pa;
+ int c;
+
+ if(!ScreenPriv) return TRUE;
+
+ pScreen->DestroyWindow = ScreenPriv->DestroyWindow;
+ pScreen->WindowExposures = ScreenPriv->WindowExposures;
+ pScreen->ClipNotify = ScreenPriv->ClipNotify;
+
+ pScrn->EnterVT = ScreenPriv->EnterVT;
+ pScrn->LeaveVT = ScreenPriv->LeaveVT;
+ pScrn->AdjustFrame = ScreenPriv->AdjustFrame;
+ pScrn->ModeSet = ScreenPriv->ModeSet;
+
+ for(c = 0, pa = pxvs->pAdaptors; c < pxvs->nAdaptors; c++, pa++) {
+ xf86XVFreeAdaptor(pa);
+ }
+
+ free(pxvs->pAdaptors);
+ free(ScreenPriv);
+ return TRUE;
+}
+
+
+static int
+xf86XVQueryAdaptors(
+ ScreenPtr pScreen,
+ XvAdaptorPtr *p_pAdaptors,
+ int *p_nAdaptors
+){
+ XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
+
+ *p_nAdaptors = pxvs->nAdaptors;
+ *p_pAdaptors = pxvs->pAdaptors;
+
+ return Success;
+}
+
+
+/**** ScrnInfoRec fields ****/
+
+static Bool
+xf86XVEnterVT(int index, int flags)
+{
+ ScrnInfoPtr pScrn = xf86Screens[index];
+ ScreenPtr pScreen = screenInfo.screens[index];
+ XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen);
+ Bool ret;
+
+ pScrn->EnterVT = ScreenPriv->EnterVT;
+ ret = (*ScreenPriv->EnterVT)(index, flags);
+ ScreenPriv->EnterVT = pScrn->EnterVT;
+ pScrn->EnterVT = xf86XVEnterVT;
+
+ if(ret) WalkTree(pScreen, xf86XVReputAllVideo, 0);
+
+ return ret;
+}
+
+static void
+xf86XVLeaveVT(int index, int flags)
+{
+ ScrnInfoPtr pScrn = xf86Screens[index];
+ ScreenPtr pScreen = screenInfo.screens[index];
+ XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
+ XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen);
+ XvAdaptorPtr pAdaptor;
+ XvPortPtr pPort;
+ XvPortRecPrivatePtr pPriv;
+ int i, j;
+
+ for(i = 0; i < pxvs->nAdaptors; i++) {
+ pAdaptor = &pxvs->pAdaptors[i];
+ for(j = 0; j < pAdaptor->nPorts; j++) {
+ pPort = &pAdaptor->pPorts[j];
+ pPriv = (XvPortRecPrivatePtr)pPort->devPriv.ptr;
+ if(pPriv->isOn > XV_OFF) {
+
+ (*pPriv->AdaptorRec->StopVideo)(
+ pPriv->pScrn, pPriv->DevPriv.ptr, TRUE);
+ pPriv->isOn = XV_OFF;
+
+ if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
+ RegionDestroy(pPriv->pCompositeClip);
+
+ pPriv->pCompositeClip = NULL;
+
+ if(!pPriv->type && pPriv->pDraw) { /* still */
+ xf86XVRemovePortFromWindow((WindowPtr)pPriv->pDraw, pPriv);
+ }
+ }
+ }
+ }
+
+ pScrn->LeaveVT = ScreenPriv->LeaveVT;
+ (*ScreenPriv->LeaveVT)(index, flags);
+ ScreenPriv->LeaveVT = pScrn->LeaveVT;
+ pScrn->LeaveVT = xf86XVLeaveVT;
+}
+
+static void
+xf86XVAdjustFrame(int index, int x, int y, int flags)
+{
+ ScrnInfoPtr pScrn = xf86Screens[index];
+ ScreenPtr pScreen = pScrn->pScreen;
+ XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen);
+
+ if(ScreenPriv->AdjustFrame) {
+ pScrn->AdjustFrame = ScreenPriv->AdjustFrame;
+ (*pScrn->AdjustFrame)(index, x, y, flags);
+ pScrn->AdjustFrame = xf86XVAdjustFrame;
+ }
+
+ xf86XVReputOrStopAllPorts(pScrn, FALSE);
+}
+
+static void
+xf86XVModeSet(ScrnInfoPtr pScrn)
+{
+ ScreenPtr pScreen = pScrn->pScreen;
+ XF86XVScreenPtr ScreenPriv;
+
+ /* Can be called before pScrn->pScreen is set */
+ if (!pScreen)
+ return;
+
+ ScreenPriv = GET_XF86XV_SCREEN(pScreen);
+
+ if (ScreenPriv->ModeSet) {
+ pScrn->ModeSet = ScreenPriv->ModeSet;
+ (*pScrn->ModeSet)(pScrn);
+ pScrn->ModeSet = xf86XVModeSet;
+ }
+
+ xf86XVReputOrStopAllPorts(pScrn, FALSE);
+}
+
+/**** XvAdaptorRec fields ****/
+
+static int
+xf86XVAllocatePort(
+ unsigned long port,
+ XvPortPtr pPort,
+ XvPortPtr *ppPort
+){
+ *ppPort = pPort;
+ return Success;
+}
+
+
+
+static int
+xf86XVFreePort(XvPortPtr pPort)
+{
+ return Success;
+}
+
+
+static int
+xf86XVPutVideo(
+ ClientPtr client,
+ DrawablePtr pDraw,
+ XvPortPtr pPort,
+ GCPtr pGC,
+ INT16 vid_x, INT16 vid_y,
+ CARD16 vid_w, CARD16 vid_h,
+ INT16 drw_x, INT16 drw_y,
+ CARD16 drw_w, CARD16 drw_h
+){
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
+ int result;
+
+ /* No dumping video to pixmaps... For now anyhow */
+ if(pDraw->type != DRAWABLE_WINDOW) {
+ pPort->pDraw = (DrawablePtr)NULL;
+ return BadAlloc;
+ }
+
+ /* If we are changing windows, unregister our port in the old window */
+ if(portPriv->pDraw && (portPriv->pDraw != pDraw))
+ xf86XVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
+
+ /* Register our port with the new window */
+ result = xf86XVEnlistPortInWindow((WindowPtr)pDraw, portPriv);
+ if(result != Success) return result;
+
+ portPriv->type = XvInputMask;
+
+ /* save a copy of these parameters */
+ portPriv->vid_x = vid_x; portPriv->vid_y = vid_y;
+ portPriv->vid_w = vid_w; portPriv->vid_h = vid_h;
+ portPriv->drw_x = drw_x; portPriv->drw_y = drw_y;
+ portPriv->drw_w = drw_w; portPriv->drw_h = drw_h;
+
+ /* make sure we have the most recent copy of the clientClip */
+ xf86XVCopyClip(portPriv, pGC);
+
+ /* To indicate to the DI layer that we were successful */
+ pPort->pDraw = pDraw;
+
+ if(!portPriv->pScrn->vtSema) return Success; /* Success ? */
+
+ return(xf86XVReputVideo(portPriv));
+}
+
+static int
+xf86XVPutStill(
+ ClientPtr client,
+ DrawablePtr pDraw,
+ XvPortPtr pPort,
+ GCPtr pGC,
+ INT16 vid_x, INT16 vid_y,
+ CARD16 vid_w, CARD16 vid_h,
+ INT16 drw_x, INT16 drw_y,
+ CARD16 drw_w, CARD16 drw_h
+){
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
+ RegionRec WinRegion;
+ RegionRec ClipRegion;
+ BoxRec WinBox;
+ int ret = Success;
+ Bool clippedAway = FALSE;
+
+ if (pDraw->type != DRAWABLE_WINDOW)
+ return BadAlloc;
+
+ if(!portPriv->pScrn->vtSema) return Success; /* Success ? */
+
+ WinBox.x1 = pDraw->x + drw_x;
+ WinBox.y1 = pDraw->y + drw_y;
+ WinBox.x2 = WinBox.x1 + drw_w;
+ WinBox.y2 = WinBox.y1 + drw_h;
+
+ xf86XVCopyCompositeClip(portPriv, pGC, pDraw);
+
+ RegionInit(&WinRegion, &WinBox, 1);
+ RegionNull(&ClipRegion);
+ RegionIntersect(&ClipRegion, &WinRegion, pGC->pCompositeClip);
+
+ if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
+ RegionRec VPReg;
+ BoxRec VPBox;
+
+ VPBox.x1 = portPriv->pScrn->frameX0;
+ VPBox.y1 = portPriv->pScrn->frameY0;
+ VPBox.x2 = portPriv->pScrn->frameX1 + 1;
+ VPBox.y2 = portPriv->pScrn->frameY1 + 1;
+
+ RegionInit(&VPReg, &VPBox, 1);
+ RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
+ RegionUninit(&VPReg);
+ }
+
+ if(portPriv->pDraw) {
+ xf86XVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
+ }
+
+ if(!RegionNotEmpty(&ClipRegion)) {
+ clippedAway = TRUE;
+ goto PUT_STILL_BAILOUT;
+ }
+
+ if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
+ BoxPtr clipBox = RegionRects(&ClipRegion);
+ if( (RegionNumRects(&ClipRegion) != 1) ||
+ (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
+ (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
+ {
+ clippedAway = TRUE;
+ goto PUT_STILL_BAILOUT;
+ }
+ }
+
+ if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
+ RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
+ }
+
+ ret = (*portPriv->AdaptorRec->PutStill)(portPriv->pScrn,
+ vid_x, vid_y, WinBox.x1, WinBox.y1,
+ vid_w, vid_h, drw_w, drw_h,
+ &ClipRegion, portPriv->DevPriv.ptr,
+ pDraw);
+
+ if((ret == Success) &&
+ (portPriv->AdaptorRec->flags & VIDEO_OVERLAID_STILLS)) {
+
+ xf86XVEnlistPortInWindow((WindowPtr)pDraw, portPriv);
+ portPriv->isOn = XV_ON;
+ portPriv->vid_x = vid_x; portPriv->vid_y = vid_y;
+ portPriv->vid_w = vid_w; portPriv->vid_h = vid_h;
+ portPriv->drw_x = drw_x; portPriv->drw_y = drw_y;
+ portPriv->drw_w = drw_w; portPriv->drw_h = drw_h;
+ portPriv->type = 0; /* no mask means it's transient and should
+ not be reput once it's removed */
+ pPort->pDraw = pDraw; /* make sure we can get stop requests */
+ }
+
+PUT_STILL_BAILOUT:
+
+ if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) {
+ (*portPriv->AdaptorRec->StopVideo)(
+ portPriv->pScrn, portPriv->DevPriv.ptr, FALSE);
+ portPriv->isOn = XV_PENDING;
+ }
+
+ /* This clip was copied and only good for one shot */
+ if(!portPriv->FreeCompositeClip)
+ portPriv->pCompositeClip = NULL;
+
+ RegionUninit(&WinRegion);
+ RegionUninit(&ClipRegion);
+
+ return ret;
+}
+
+static int
+xf86XVGetVideo(
+ ClientPtr client,
+ DrawablePtr pDraw,
+ XvPortPtr pPort,
+ GCPtr pGC,
+ INT16 vid_x, INT16 vid_y,
+ CARD16 vid_w, CARD16 vid_h,
+ INT16 drw_x, INT16 drw_y,
+ CARD16 drw_w, CARD16 drw_h
+){
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
+ int result;
+
+ /* No pixmaps... For now anyhow */
+ if(pDraw->type != DRAWABLE_WINDOW) {
+ pPort->pDraw = (DrawablePtr)NULL;
+ return BadAlloc;
+ }
+
+ /* If we are changing windows, unregister our port in the old window */
+ if(portPriv->pDraw && (portPriv->pDraw != pDraw))
+ xf86XVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
+
+ /* Register our port with the new window */
+ result = xf86XVEnlistPortInWindow((WindowPtr)pDraw, portPriv);
+ if(result != Success) return result;
+
+ portPriv->type = XvOutputMask;
+
+ /* save a copy of these parameters */
+ portPriv->vid_x = vid_x; portPriv->vid_y = vid_y;
+ portPriv->vid_w = vid_w; portPriv->vid_h = vid_h;
+ portPriv->drw_x = drw_x; portPriv->drw_y = drw_y;
+ portPriv->drw_w = drw_w; portPriv->drw_h = drw_h;
+
+ /* make sure we have the most recent copy of the clientClip */
+ xf86XVCopyClip(portPriv, pGC);
+
+ /* To indicate to the DI layer that we were successful */
+ pPort->pDraw = pDraw;
+
+ if(!portPriv->pScrn->vtSema) return Success; /* Success ? */
+
+ return(xf86XVRegetVideo(portPriv));
+}
+
+static int
+xf86XVGetStill(
+ ClientPtr client,
+ DrawablePtr pDraw,
+ XvPortPtr pPort,
+ GCPtr pGC,
+ INT16 vid_x, INT16 vid_y,
+ CARD16 vid_w, CARD16 vid_h,
+ INT16 drw_x, INT16 drw_y,
+ CARD16 drw_w, CARD16 drw_h
+){
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
+ RegionRec WinRegion;
+ RegionRec ClipRegion;
+ BoxRec WinBox;
+ int ret = Success;
+ Bool clippedAway = FALSE;
+
+ if (pDraw->type != DRAWABLE_WINDOW)
+ return BadAlloc;
+
+ if(!portPriv->pScrn->vtSema) return Success; /* Success ? */
+
+ WinBox.x1 = pDraw->x + drw_x;
+ WinBox.y1 = pDraw->y + drw_y;
+ WinBox.x2 = WinBox.x1 + drw_w;
+ WinBox.y2 = WinBox.y1 + drw_h;
+
+ RegionInit(&WinRegion, &WinBox, 1);
+ RegionNull(&ClipRegion);
+ RegionIntersect(&ClipRegion, &WinRegion, pGC->pCompositeClip);
+
+ if(portPriv->pDraw) {
+ xf86XVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
+ }
+
+ if(!RegionNotEmpty(&ClipRegion)) {
+ clippedAway = TRUE;
+ goto GET_STILL_BAILOUT;
+ }
+
+ if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
+ RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
+ }
+
+ ret = (*portPriv->AdaptorRec->GetStill)(portPriv->pScrn,
+ vid_x, vid_y, WinBox.x1, WinBox.y1,
+ vid_w, vid_h, drw_w, drw_h,
+ &ClipRegion, portPriv->DevPriv.ptr,
+ pDraw);
+
+GET_STILL_BAILOUT:
+
+ if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) {
+ (*portPriv->AdaptorRec->StopVideo)(
+ portPriv->pScrn, portPriv->DevPriv.ptr, FALSE);
+ portPriv->isOn = XV_PENDING;
+ }
+
+ RegionUninit(&WinRegion);
+ RegionUninit(&ClipRegion);
+
+ return ret;
+}
+
+
+
+static int
+xf86XVStopVideo(
+ ClientPtr client,
+ XvPortPtr pPort,
+ DrawablePtr pDraw
+){
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
+
+ if(pDraw->type != DRAWABLE_WINDOW)
+ return BadAlloc;
+
+ xf86XVRemovePortFromWindow((WindowPtr)pDraw, portPriv);
+
+ if(!portPriv->pScrn->vtSema) return Success; /* Success ? */
+
+ /* Must free resources. */
+
+ if(portPriv->isOn > XV_OFF) {
+ (*portPriv->AdaptorRec->StopVideo)(
+ portPriv->pScrn, portPriv->DevPriv.ptr, TRUE);
+ portPriv->isOn = XV_OFF;
+ }
+
+ return Success;
+}
+
+static int
+xf86XVSetPortAttribute(
+ ClientPtr client,
+ XvPortPtr pPort,
+ Atom attribute,
+ INT32 value
+){
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
+
+ return((*portPriv->AdaptorRec->SetPortAttribute)(portPriv->pScrn,
+ attribute, value, portPriv->DevPriv.ptr));
+}
+
+
+static int
+xf86XVGetPortAttribute(
+ ClientPtr client,
+ XvPortPtr pPort,
+ Atom attribute,
+ INT32 *p_value
+){
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
+
+ return((*portPriv->AdaptorRec->GetPortAttribute)(portPriv->pScrn,
+ attribute, p_value, portPriv->DevPriv.ptr));
+}
+
+
+
+static int
+xf86XVQueryBestSize(
+ ClientPtr client,
+ XvPortPtr pPort,
+ CARD8 motion,
+ CARD16 vid_w, CARD16 vid_h,
+ CARD16 drw_w, CARD16 drw_h,
+ unsigned int *p_w, unsigned int *p_h
+){
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
+
+ (*portPriv->AdaptorRec->QueryBestSize)(portPriv->pScrn,
+ (Bool)motion, vid_w, vid_h, drw_w, drw_h,
+ p_w, p_h, portPriv->DevPriv.ptr);
+
+ return Success;
+}
+
+
+static int
+xf86XVPutImage(
+ ClientPtr client,
+ DrawablePtr pDraw,
+ XvPortPtr pPort,
+ GCPtr pGC,
+ INT16 src_x, INT16 src_y,
+ CARD16 src_w, CARD16 src_h,
+ INT16 drw_x, INT16 drw_y,
+ CARD16 drw_w, CARD16 drw_h,
+ XvImagePtr format,
+ unsigned char* data,
+ Bool sync,
+ CARD16 width, CARD16 height
+){
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
+ RegionRec WinRegion;
+ RegionRec ClipRegion;
+ BoxRec WinBox;
+ int ret = Success;
+ Bool clippedAway = FALSE;
+
+ if (pDraw->type != DRAWABLE_WINDOW)
+ return BadAlloc;
+
+ if(!portPriv->pScrn->vtSema) return Success; /* Success ? */
+
+ xf86XVCopyCompositeClip(portPriv, pGC, pDraw);
+
+ WinBox.x1 = pDraw->x + drw_x;
+ WinBox.y1 = pDraw->y + drw_y;
+ WinBox.x2 = WinBox.x1 + drw_w;
+ WinBox.y2 = WinBox.y1 + drw_h;
+
+ RegionInit(&WinRegion, &WinBox, 1);
+ RegionNull(&ClipRegion);
+ RegionIntersect(&ClipRegion, &WinRegion, pGC->pCompositeClip);
+
+ if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
+ RegionRec VPReg;
+ BoxRec VPBox;
+
+ VPBox.x1 = portPriv->pScrn->frameX0;
+ VPBox.y1 = portPriv->pScrn->frameY0;
+ VPBox.x2 = portPriv->pScrn->frameX1 + 1;
+ VPBox.y2 = portPriv->pScrn->frameY1 + 1;
+
+ RegionInit(&VPReg, &VPBox, 1);
+ RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
+ RegionUninit(&VPReg);
+ }
+
+ /* If we are changing windows, unregister our port in the old window */
+ if(portPriv->pDraw && (portPriv->pDraw != pDraw))
+ xf86XVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
+
+ /* Register our port with the new window */
+ ret = xf86XVEnlistPortInWindow((WindowPtr)pDraw, portPriv);
+ if(ret != Success) goto PUT_IMAGE_BAILOUT;
+
+ if(!RegionNotEmpty(&ClipRegion)) {
+ clippedAway = TRUE;
+ goto PUT_IMAGE_BAILOUT;
+ }
+
+ if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
+ BoxPtr clipBox = RegionRects(&ClipRegion);
+ if( (RegionNumRects(&ClipRegion) != 1) ||
+ (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
+ (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
+ {
+ clippedAway = TRUE;
+ goto PUT_IMAGE_BAILOUT;
+ }
+ }
+
+ if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
+ RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
+ }
+
+ ret = (*portPriv->AdaptorRec->PutImage)(portPriv->pScrn,
+ src_x, src_y, WinBox.x1, WinBox.y1,
+ src_w, src_h, drw_w, drw_h, format->id, data, width, height,
+ sync, &ClipRegion, portPriv->DevPriv.ptr,
+ pDraw);
+
+ if((ret == Success) &&
+ (portPriv->AdaptorRec->flags & VIDEO_OVERLAID_IMAGES)) {
+
+ portPriv->isOn = XV_ON;
+ portPriv->vid_x = src_x; portPriv->vid_y = src_y;
+ portPriv->vid_w = src_w; portPriv->vid_h = src_h;
+ portPriv->drw_x = drw_x; portPriv->drw_y = drw_y;
+ portPriv->drw_w = drw_w; portPriv->drw_h = drw_h;
+ portPriv->type = 0; /* no mask means it's transient and should
+ not be reput once it's removed */
+ pPort->pDraw = pDraw; /* make sure we can get stop requests */
+ }
+
+PUT_IMAGE_BAILOUT:
+
+ if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) {
+ (*portPriv->AdaptorRec->StopVideo)(
+ portPriv->pScrn, portPriv->DevPriv.ptr, FALSE);
+ portPriv->isOn = XV_PENDING;
+ }
+
+ /* This clip was copied and only good for one shot */
+ if(!portPriv->FreeCompositeClip)
+ portPriv->pCompositeClip = NULL;
+
+ RegionUninit(&WinRegion);
+ RegionUninit(&ClipRegion);
+
+ return ret;
+}
+
+
+static int
+xf86XVQueryImageAttributes(
+ ClientPtr client,
+ XvPortPtr pPort,
+ XvImagePtr format,
+ CARD16 *width,
+ CARD16 *height,
+ int *pitches,
+ int *offsets
+){
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
+
+ return (*portPriv->AdaptorRec->QueryImageAttributes)(portPriv->pScrn,
+ format->id, width, height, pitches, offsets);
+}
+
+void
+xf86XVFillKeyHelperDrawable (DrawablePtr pDraw, CARD32 key, RegionPtr fillboxes)
+{
+ ScreenPtr pScreen = pDraw->pScreen;
+ ChangeGCVal pval[2];
+ BoxPtr pbox = RegionRects(fillboxes);
+ int i, nbox = RegionNumRects(fillboxes);
+ xRectangle *rects;
+ GCPtr gc;
+
+ if(!xf86Screens[pScreen->myNum]->vtSema) return;
+
+ gc = GetScratchGC(pDraw->depth, pScreen);
+ pval[0].val = key;
+ pval[1].val = IncludeInferiors;
+ (void) ChangeGC(NullClient, gc, GCForeground|GCSubwindowMode, pval);
+ ValidateGC(pDraw, gc);
+
+ rects = malloc(nbox * sizeof(xRectangle));
+
+ for(i = 0; i < nbox; i++, pbox++)
+ {
+ rects[i].x = pbox->x1 - pDraw->x;
+ rects[i].y = pbox->y1 - pDraw->y;
+ rects[i].width = pbox->x2 - pbox->x1;
+ rects[i].height = pbox->y2 - pbox->y1;
+ }
+
+ (*gc->ops->PolyFillRect)(pDraw, gc, nbox, rects);
+
+ free(rects);
+ FreeScratchGC (gc);
+}
+
+void
+xf86XVFillKeyHelper (ScreenPtr pScreen, CARD32 key, RegionPtr fillboxes)
+{
+ xf86XVFillKeyHelperDrawable (&pScreen->root->drawable, key, fillboxes);
+}
+
+void
+xf86XVFillKeyHelperPort (DrawablePtr pDraw, pointer data, CARD32 key, RegionPtr clipboxes, Bool fillEverything)
+{
+ WindowPtr pWin = (WindowPtr)pDraw;
+ XF86XVWindowPtr WinPriv = GET_XF86XV_WINDOW(pWin);
+ XvPortRecPrivatePtr portPriv = NULL;
+ RegionRec reg;
+ RegionPtr fillboxes;
+
+ while (WinPriv) {
+ XvPortRecPrivatePtr pPriv = WinPriv->PortRec;
+
+ if (data == pPriv->DevPriv.ptr) {
+ portPriv = pPriv;
+ break;
+ }
+
+ WinPriv = WinPriv->next;
+ }
+
+ if (!portPriv)
+ return;
+
+ if (!portPriv->ckeyFilled)
+ portPriv->ckeyFilled = RegionCreate(NULL, 0);
+
+ if (!fillEverything) {
+ RegionNull(&reg);
+ fillboxes = &reg;
+ RegionSubtract(fillboxes, clipboxes, portPriv->ckeyFilled);
+
+ if (!RegionNotEmpty(fillboxes))
+ goto out;
+ } else
+ fillboxes = clipboxes;
+
+
+ RegionCopy(portPriv->ckeyFilled, clipboxes);
+
+ xf86XVFillKeyHelperDrawable(pDraw, key, fillboxes);
+out:
+ if (!fillEverything)
+ RegionUninit(&reg);
+}
+
+
+/* xf86XVClipVideoHelper -
+
+ Takes the dst box in standard X BoxRec form (top and left
+ edges inclusive, bottom and right exclusive). The new dst
+ box is returned. The source boundaries are given (x1, y1
+ inclusive, x2, y2 exclusive) and returned are the new source
+ boundaries in 16.16 fixed point.
+*/
+
+Bool
+xf86XVClipVideoHelper(
+ BoxPtr dst,
+ INT32 *xa,
+ INT32 *xb,
+ INT32 *ya,
+ INT32 *yb,
+ RegionPtr reg,
+ INT32 width,
+ INT32 height
+){
+ double xsw, xdw, ysw, ydw;
+ INT32 delta;
+ BoxPtr extents = RegionExtents(reg);
+ int diff;
+
+ xsw = (*xb - *xa) << 16;
+ xdw = dst->x2 - dst->x1;
+ ysw = (*yb - *ya) << 16;
+ ydw = dst->y2 - dst->y1;
+
+ *xa <<= 16; *xb <<= 16;
+ *ya <<= 16; *yb <<= 16;
+
+ diff = extents->x1 - dst->x1;
+ if (diff > 0) {
+ dst->x1 = extents->x1;
+ *xa += (diff * xsw) / xdw;
+ }
+ diff = dst->x2 - extents->x2;
+ if (diff > 0) {
+ dst->x2 = extents->x2;
+ *xb -= (diff * xsw) / xdw;
+ }
+ diff = extents->y1 - dst->y1;
+ if (diff > 0) {
+ dst->y1 = extents->y1;
+ *ya += (diff * ysw) / ydw;
+ }
+ diff = dst->y2 - extents->y2;
+ if (diff > 0) {
+ dst->y2 = extents->y2;
+ *yb -= (diff * ysw) / ydw;
+ }
+
+ if (*xa < 0) {
+ diff = (((-*xa) * xdw) + xsw - 1) / xsw;
+ dst->x1 += diff;
+ *xa += (diff * xsw) / xdw;
+ }
+ delta = *xb - (width << 16);
+ if (delta > 0) {
+ diff = ((delta * xdw) + xsw - 1) / xsw;
+ dst->x2 -= diff;
+ *xb -= (diff * xsw) / xdw;
+ }
+ if (*xa >= *xb) return FALSE;
+
+ if (*ya < 0) {
+ diff = (((-*ya) * ydw) + ysw - 1) / ysw;
+ dst->y1 += diff;
+ *ya += (diff * ysw) / ydw;
+ }
+ delta = *yb - (height << 16);
+ if (delta > 0) {
+ diff = ((delta * ydw) + ysw - 1) / ysw;
+ dst->y2 -= diff;
+ *yb -= (diff * ysw) / ydw;
+ }
+ if (*ya >= *yb) return FALSE;
+
+ if ((dst->x1 > extents->x1) || (dst->x2 < extents->x2) ||
+ (dst->y1 > extents->y1) || (dst->y2 < extents->y2))
+ {
+ RegionRec clipReg;
+ RegionInit(&clipReg, dst, 1);
+ RegionIntersect(reg, reg, &clipReg);
+ RegionUninit(&clipReg);
+ }
+ return TRUE;
+}
+
+void
+xf86XVCopyYUV12ToPacked(
+ const void *srcy,
+ const void *srcv,
+ const void *srcu,
+ void *dst,
+ int srcPitchy,
+ int srcPitchuv,
+ int dstPitch,
+ int h,
+ int w
+){
+ CARD32 *Dst;
+ const CARD8 *Y, *U, *V;
+ int i, j;
+
+ w >>= 1;
+
+ for (j = 0; j < h; j++) {
+ Dst = dst;
+ Y = srcy; V = srcv; U = srcu;
+ i = w;
+ while (i >= 4) {
+#if X_BYTE_ORDER == X_LITTLE_ENDIAN
+ Dst[0] = Y[0] | (Y[1] << 16) | (U[0] << 8) | (V[0] << 24);
+ Dst[1] = Y[2] | (Y[3] << 16) | (U[1] << 8) | (V[1] << 24);
+ Dst[2] = Y[4] | (Y[5] << 16) | (U[2] << 8) | (V[2] << 24);
+ Dst[3] = Y[6] | (Y[7] << 16) | (U[3] << 8) | (V[3] << 24);
+#else
+ /* This assumes a little-endian framebuffer */
+ Dst[0] = (Y[0] << 24) | (Y[1] << 8) | (U[0] << 16) | V[0];
+ Dst[1] = (Y[2] << 24) | (Y[3] << 8) | (U[1] << 16) | V[1];
+ Dst[2] = (Y[4] << 24) | (Y[5] << 8) | (U[2] << 16) | V[2];
+ Dst[3] = (Y[6] << 24) | (Y[7] << 8) | (U[3] << 16) | V[3];
+#endif
+ Dst += 4; Y += 8; V += 4; U += 4;
+ i -= 4;
+ }
+
+ while (i--) {
+#if X_BYTE_ORDER == X_LITTLE_ENDIAN
+ Dst[0] = Y[0] | (Y[1] << 16) | (U[0] << 8) | (V[0] << 24);
+#else
+ /* This assumes a little-endian framebuffer */
+ Dst[0] = (Y[0] << 24) | (Y[1] << 8) | (U[0] << 16) | V[0];
+#endif
+ Dst++; Y += 2; V++; U++;
+ }
+
+ dst = (CARD8 *)dst + dstPitch;
+ srcy = (const CARD8 *)srcy + srcPitchy;
+ if (j & 1) {
+ srcu = (const CARD8 *)srcu + srcPitchuv;
+ srcv = (const CARD8 *)srcv + srcPitchuv;
+ }
+ }
+}
+
+void
+xf86XVCopyPacked(
+ const void *src,
+ void *dst,
+ int srcPitch,
+ int dstPitch,
+ int h,
+ int w
+){
+ const CARD32 *Src;
+ CARD32 *Dst;
+ int i;
+
+ w >>= 1;
+ while (--h >= 0) {
+ do {
+ Dst = dst; Src = src;
+ i = w;
+ while (i >= 4) {
+ Dst[0] = Src[0];
+ Dst[1] = Src[1];
+ Dst[2] = Src[2];
+ Dst[3] = Src[3];
+ Dst += 4; Src += 4; i -= 4;
+ }
+ if (!i) break;
+ Dst[0] = Src[0];
+ if (i == 1) break;
+ Dst[1] = Src[1];
+ if (i == 2) break;
+ Dst[2] = Src[2];
+ } while (0);
+
+ src = (const CARD8 *)src + srcPitch;
+ dst = (CARD8 *)dst + dstPitch;
+ }
+}
diff --git a/xorg-server/hw/xfree86/ddc/ddcProperty.c b/xorg-server/hw/xfree86/ddc/ddcProperty.c
index 36ade8a5f..5d6eec927 100644
--- a/xorg-server/hw/xfree86/ddc/ddcProperty.c
+++ b/xorg-server/hw/xfree86/ddc/ddcProperty.c
@@ -1,124 +1,124 @@
-/*
- * Copyright 2006 Luc Verhaegen.
- *
- * 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
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86.h"
-#include "xf86DDC.h"
-#include <X11/Xatom.h>
-#include "property.h"
-#include "propertyst.h"
-#include <string.h>
-
-#define EDID1_ATOM_NAME "XFree86_DDC_EDID1_RAWDATA"
-#define EDID2_ATOM_NAME "XFree86_DDC_EDID2_RAWDATA"
-
-static void
-edidMakeAtom(int i, const char *name, CARD8 *data, int size)
-{
- Atom atom;
- unsigned char *atom_data;
-
- if (!(atom_data = malloc(size*sizeof(CARD8))))
- return;
-
- atom = MakeAtom(name, strlen(name), TRUE);
- memcpy(atom_data, data, size);
- xf86RegisterRootWindowProperty(i, atom, XA_INTEGER, 8, size, atom_data);
-}
-
-static void
-addRootWindowProperties(ScrnInfoPtr pScrn, xf86MonPtr DDC)
-{
- int i, scrnIndex = pScrn->scrnIndex;
- Bool makeEDID1prop = FALSE;
- Bool makeEDID2prop = FALSE;
-
- if (DDC->flags & MONITOR_DISPLAYID) {
- /* Don't bother, use RANDR already */
- return;
- } else if (DDC->ver.version == 1) {
- makeEDID1prop = TRUE;
- } else if (DDC->ver.version == 2) {
- int checksum1;
- int checksum2;
- makeEDID2prop = TRUE;
-
- /* Some monitors (eg Panasonic PanaSync4)
- * report version==2 because they used EDID v2 spec document,
- * although they use EDID v1 data structure :-(
- *
- * Try using checksum to determine when we have such a monitor.
- */
- checksum2 = 0;
- for (i = 0; i < 256; i++)
- checksum2 += DDC->rawData[i];
- if (checksum2 % 256) {
- xf86DrvMsg(scrnIndex, X_INFO, "Monitor EDID v2 checksum failed\n");
- xf86DrvMsg(scrnIndex, X_INFO,
- "XFree86_DDC_EDID2_RAWDATA property may be bad\n");
- checksum1 = 0;
- for (i = 0; i < 128; i++)
- checksum1 += DDC->rawData[i];
- if (!(checksum1 % 256)) {
- xf86DrvMsg(scrnIndex, X_INFO,
- "Monitor EDID v1 checksum passed,\n");
- xf86DrvMsg(scrnIndex, X_INFO,
- "XFree86_DDC_EDID1_RAWDATA property created\n");
- makeEDID1prop = TRUE;
- }
- }
- } else {
- xf86DrvMsg(scrnIndex, X_PROBED, "unexpected EDID version %d.%d\n",
- DDC->ver.version, DDC->ver.revision);
- return;
- }
-
- if (makeEDID1prop) {
- int size = 128 +
- (DDC->flags & EDID_COMPLETE_RAWDATA ? DDC->no_sections * 128 : 0);
-
- edidMakeAtom(scrnIndex, EDID1_ATOM_NAME, DDC->rawData, size);
- }
-
- if (makeEDID2prop)
- edidMakeAtom(scrnIndex, EDID2_ATOM_NAME, DDC->rawData, 256);
-}
-
-Bool
-xf86SetDDCproperties(ScrnInfoPtr pScrn, xf86MonPtr DDC)
-{
- if (!pScrn || !pScrn->monitor || !DDC)
- return FALSE;
-
- if (DDC->flags & MONITOR_DISPLAYID)
- ;
- else
- xf86EdidMonitorSet(pScrn->scrnIndex, pScrn->monitor, DDC);
-
- addRootWindowProperties(pScrn, DDC);
-
- return TRUE;
-}
+/*
+ * Copyright 2006 Luc Verhaegen.
+ *
+ * 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
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#include "xf86DDC.h"
+#include <X11/Xatom.h>
+#include "property.h"
+#include "propertyst.h"
+#include <string.h>
+
+#define EDID1_ATOM_NAME "XFree86_DDC_EDID1_RAWDATA"
+#define EDID2_ATOM_NAME "XFree86_DDC_EDID2_RAWDATA"
+
+static void
+edidMakeAtom(int i, const char *name, CARD8 *data, int size)
+{
+ Atom atom;
+ unsigned char *atom_data;
+
+ if (!(atom_data = malloc(size*sizeof(CARD8))))
+ return;
+
+ atom = MakeAtom(name, strlen(name), TRUE);
+ memcpy(atom_data, data, size);
+ xf86RegisterRootWindowProperty(i, atom, XA_INTEGER, 8, size, atom_data);
+}
+
+static void
+addRootWindowProperties(ScrnInfoPtr pScrn, xf86MonPtr DDC)
+{
+ int i, scrnIndex = pScrn->scrnIndex;
+ Bool makeEDID1prop = FALSE;
+ Bool makeEDID2prop = FALSE;
+
+ if (DDC->flags & MONITOR_DISPLAYID) {
+ /* Don't bother, use RANDR already */
+ return;
+ } else if (DDC->ver.version == 1) {
+ makeEDID1prop = TRUE;
+ } else if (DDC->ver.version == 2) {
+ int checksum1;
+ int checksum2;
+ makeEDID2prop = TRUE;
+
+ /* Some monitors (eg Panasonic PanaSync4)
+ * report version==2 because they used EDID v2 spec document,
+ * although they use EDID v1 data structure :-(
+ *
+ * Try using checksum to determine when we have such a monitor.
+ */
+ checksum2 = 0;
+ for (i = 0; i < 256; i++)
+ checksum2 += DDC->rawData[i];
+ if (checksum2 % 256) {
+ xf86DrvMsg(scrnIndex, X_INFO, "Monitor EDID v2 checksum failed\n");
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "XFree86_DDC_EDID2_RAWDATA property may be bad\n");
+ checksum1 = 0;
+ for (i = 0; i < 128; i++)
+ checksum1 += DDC->rawData[i];
+ if (!(checksum1 % 256)) {
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "Monitor EDID v1 checksum passed,\n");
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "XFree86_DDC_EDID1_RAWDATA property created\n");
+ makeEDID1prop = TRUE;
+ }
+ }
+ } else {
+ xf86DrvMsg(scrnIndex, X_PROBED, "unexpected EDID version %d.%d\n",
+ DDC->ver.version, DDC->ver.revision);
+ return;
+ }
+
+ if (makeEDID1prop) {
+ int size = 128 +
+ (DDC->flags & EDID_COMPLETE_RAWDATA ? DDC->no_sections * 128 : 0);
+
+ edidMakeAtom(scrnIndex, EDID1_ATOM_NAME, DDC->rawData, size);
+ }
+
+ if (makeEDID2prop)
+ edidMakeAtom(scrnIndex, EDID2_ATOM_NAME, DDC->rawData, 256);
+}
+
+Bool
+xf86SetDDCproperties(ScrnInfoPtr pScrn, xf86MonPtr DDC)
+{
+ if (!pScrn || !pScrn->monitor || !DDC)
+ return FALSE;
+
+ if (DDC->flags & MONITOR_DISPLAYID)
+ ;
+ else
+ xf86EdidMonitorSet(pScrn->scrnIndex, pScrn->monitor, DDC);
+
+ addRootWindowProperties(pScrn, DDC);
+
+ return TRUE;
+}
diff --git a/xorg-server/hw/xfree86/doc/Makefile.am b/xorg-server/hw/xfree86/doc/Makefile.am
index 9b46a82d5..1c3620abb 100644
--- a/xorg-server/hw/xfree86/doc/Makefile.am
+++ b/xorg-server/hw/xfree86/doc/Makefile.am
@@ -1,18 +1,18 @@
-
-if ENABLE_DEVEL_DOCS
-if HAVE_XMLTO
-
-# Main DocBook/XML files (DOCTYPE book)
-docbook = ddxDesign.xml
-
-# Generate DocBook/XML output formats with or without stylesheets
-include $(top_srcdir)/devbook.am
-
-endif HAVE_XMLTO
-endif ENABLE_DEVEL_DOCS
-
-EXTRA_DIST = \
- Registry \
- exa-driver.txt \
- README.DRIcomp \
- README.modes
+
+if ENABLE_DEVEL_DOCS
+if HAVE_XMLTO
+
+# Main DocBook/XML files (DOCTYPE book)
+docbook = ddxDesign.xml
+
+# Generate DocBook/XML output formats with or without stylesheets
+include $(top_srcdir)/devbook.am
+
+endif HAVE_XMLTO
+endif ENABLE_DEVEL_DOCS
+
+EXTRA_DIST = \
+ Registry \
+ exa-driver.txt \
+ README.DRIcomp \
+ README.modes
diff --git a/xorg-server/hw/xfree86/dri/dri.c b/xorg-server/hw/xfree86/dri/dri.c
index cf83c002e..1726960ae 100644
--- a/xorg-server/hw/xfree86/dri/dri.c
+++ b/xorg-server/hw/xfree86/dri/dri.c
@@ -1,2496 +1,2496 @@
-/**************************************************************************
-
-Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
-Copyright 2000 VA Linux Systems, 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, 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.
-
-**************************************************************************/
-
-/*
- * Authors:
- * Jens Owen <jens@tungstengraphics.com>
- * Rickard E. (Rik) Faith <faith@valinux.com>
- *
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86.h"
-#include <sys/time.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdio.h>
-#include <sys/ioctl.h>
-#include <errno.h>
-
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include "xf86drm.h"
-#include "misc.h"
-#include "dixstruct.h"
-#include "extnsionst.h"
-#include "colormapst.h"
-#include "cursorstr.h"
-#include "scrnintstr.h"
-#include "windowstr.h"
-#include "servermd.h"
-#define _XF86DRI_SERVER_
-#include <X11/dri/xf86driproto.h>
-#include "swaprep.h"
-#include "xf86str.h"
-#include "dri.h"
-#include "sarea.h"
-#include "dristruct.h"
-#include "mi.h"
-#include "mipointer.h"
-#include "xf86_OSproc.h"
-#include "inputstr.h"
-#include "xf86VGAarbiter.h"
-
-static int DRIEntPrivIndex = -1;
-static DevPrivateKeyRec DRIScreenPrivKeyRec;
-#define DRIScreenPrivKey (&DRIScreenPrivKeyRec)
-static DevPrivateKeyRec DRIWindowPrivKeyRec;
-#define DRIWindowPrivKey (&DRIWindowPrivKeyRec)
-static unsigned long DRIGeneration = 0;
-static unsigned int DRIDrawableValidationStamp = 0;
-
-static RESTYPE DRIDrawablePrivResType;
-static RESTYPE DRIContextPrivResType;
-static void DRIDestroyDummyContext(ScreenPtr pScreen, Bool hasCtxPriv);
-
-drmServerInfo DRIDRMServerInfo;
-
- /* Wrapper just like xf86DrvMsg, but
- without the verbosity level checking.
- This will make it easy to turn off some
- messages later, based on verbosity
- level. */
-
-/*
- * Since we're already referencing things from the XFree86 common layer in
- * this file, we'd might as well just call xf86VDrvMsgVerb, and have
- * consistent message formatting. The verbosity of these messages can be
- * easily changed here.
- */
-#define DRI_MSG_VERBOSITY 1
-static void
-DRIDrvMsg(int scrnIndex, MessageType type, const char *format, ...)
-{
- va_list ap;
-
- va_start(ap, format);
- xf86VDrvMsgVerb(scrnIndex, type, DRI_MSG_VERBOSITY, format, ap);
- va_end(ap);
-}
-
-
-static void
-DRIOpenDRMCleanup(DRIEntPrivPtr pDRIEntPriv)
-{
- if (pDRIEntPriv->pLSAREA != NULL) {
- drmUnmap(pDRIEntPriv->pLSAREA, pDRIEntPriv->sAreaSize);
- pDRIEntPriv->pLSAREA = NULL;
- }
- if (pDRIEntPriv->hLSAREA != 0) {
- drmRmMap(pDRIEntPriv->drmFD, pDRIEntPriv->hLSAREA);
- }
- if (pDRIEntPriv->drmFD >= 0) {
- drmClose(pDRIEntPriv->drmFD);
- pDRIEntPriv->drmFD = 0;
- }
-}
-
-int
-DRIMasterFD(ScrnInfoPtr pScrn)
-{
- return DRI_ENT_PRIV(pScrn)->drmFD;
-}
-
-void *
-DRIMasterSareaPointer(ScrnInfoPtr pScrn)
-{
- return DRI_ENT_PRIV(pScrn)->pLSAREA;
-}
-
-drm_handle_t
-DRIMasterSareaHandle(ScrnInfoPtr pScrn)
-{
- return DRI_ENT_PRIV(pScrn)->hLSAREA;
-}
-
-
-Bool
-DRIOpenDRMMaster(ScrnInfoPtr pScrn,
- unsigned long sAreaSize,
- const char *busID,
- const char *drmDriverName)
-{
- drmSetVersion saveSv, sv;
- Bool drmWasAvailable;
- DRIEntPrivPtr pDRIEntPriv;
- DRIEntPrivRec tmp;
- drmVersionPtr drmlibv;
- int drmlibmajor, drmlibminor;
- const char *openBusID;
- int count;
- int err;
-
- if (DRIEntPrivIndex == -1)
- DRIEntPrivIndex = xf86AllocateEntityPrivateIndex();
-
- pDRIEntPriv = DRI_ENT_PRIV(pScrn);
-
- if (pDRIEntPriv && pDRIEntPriv->drmFD != -1)
- return TRUE;
-
- drmWasAvailable = drmAvailable();
-
- memset(&tmp, 0, sizeof(tmp));
-
- /* Check the DRM lib version.
- * drmGetLibVersion was not supported in version 1.0, so check for
- * symbol first to avoid possible crash or hang.
- */
-
- drmlibmajor = 1;
- drmlibminor = 0;
- if (xf86LoaderCheckSymbol("drmGetLibVersion")) {
- drmlibv = drmGetLibVersion(-1);
- if (drmlibv != NULL) {
- drmlibmajor = drmlibv->version_major;
- drmlibminor = drmlibv->version_minor;
- drmFreeVersion(drmlibv);
- }
- }
-
- /* Check if the libdrm can handle falling back to loading based on name
- * if a busid string is passed.
- */
- openBusID = (drmlibmajor == 1 && drmlibminor >= 2) ? busID : NULL;
-
- tmp.drmFD = -1;
- sv.drm_di_major = 1;
- sv.drm_di_minor = 1;
- sv.drm_dd_major = -1;
-
- saveSv = sv;
- count = 10;
- while (count--) {
- tmp.drmFD = drmOpen(drmDriverName, openBusID);
-
- if (tmp.drmFD < 0) {
- DRIDrvMsg(-1, X_ERROR, "[drm] drmOpen failed.\n");
- goto out_err;
- }
-
- err = drmSetInterfaceVersion(tmp.drmFD, &sv);
-
- if (err != -EPERM)
- break;
-
- sv = saveSv;
- drmClose(tmp.drmFD);
- tmp.drmFD = -1;
- usleep(100000);
- }
-
- if (tmp.drmFD <= 0) {
- DRIDrvMsg(-1, X_ERROR, "[drm] DRM was busy with another master.\n");
- goto out_err;
- }
-
- if (!drmWasAvailable) {
- DRIDrvMsg(-1, X_INFO,
- "[drm] loaded kernel module for \"%s\" driver.\n",
- drmDriverName);
- }
-
- if (err != 0) {
- sv.drm_di_major = 1;
- sv.drm_di_minor = 0;
- }
-
- DRIDrvMsg(-1, X_INFO, "[drm] DRM interface version %d.%d\n",
- sv.drm_di_major, sv.drm_di_minor);
-
- if (sv.drm_di_major == 1 && sv.drm_di_minor >= 1)
- err = 0;
- else
- err = drmSetBusid(tmp.drmFD, busID);
-
- if (err) {
- DRIDrvMsg(-1, X_ERROR, "[drm] Could not set DRM device bus ID.\n");
- goto out_err;
- }
-
- /*
- * Create a lock-containing sarea.
- */
-
- if (drmAddMap( tmp.drmFD, 0, sAreaSize, DRM_SHM,
- DRM_CONTAINS_LOCK, &tmp.hLSAREA) < 0) {
- DRIDrvMsg(-1, X_INFO, "[drm] Could not create SAREA for DRM lock.\n");
- tmp.hLSAREA = 0;
- goto out_err;
- }
-
- if (drmMap( tmp.drmFD, tmp.hLSAREA, sAreaSize,
- (drmAddressPtr)(&tmp.pLSAREA)) < 0) {
- DRIDrvMsg(-1, X_INFO, "[drm] Mapping SAREA for DRM lock failed.\n");
- tmp.pLSAREA = NULL;
- goto out_err;
- }
-
- memset(tmp.pLSAREA, 0, sAreaSize);
-
- /*
- * Reserved contexts are handled by the first opened screen.
- */
-
- tmp.resOwner = NULL;
-
- if (!pDRIEntPriv)
- pDRIEntPriv = xnfcalloc(sizeof(*pDRIEntPriv), 1);
-
- if (!pDRIEntPriv) {
- DRIDrvMsg(-1, X_INFO, "[drm] Failed to allocate memory for "
- "DRM device.\n");
- goto out_err;
- }
- *pDRIEntPriv = tmp;
- xf86GetEntityPrivate((pScrn)->entityList[0],DRIEntPrivIndex)->ptr =
- pDRIEntPriv;
-
- DRIDrvMsg(-1, X_INFO, "[drm] DRM open master succeeded.\n");
- return TRUE;
-
- out_err:
-
- DRIOpenDRMCleanup(&tmp);
- return FALSE;
-}
-
-static void
-DRIClipNotifyAllDrawables(ScreenPtr pScreen);
-
-static void
-dri_crtc_notify(ScreenPtr pScreen)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- DRIClipNotifyAllDrawables(pScreen);
- xf86_unwrap_crtc_notify(pScreen, pDRIPriv->xf86_crtc_notify);
- xf86_crtc_notify(pScreen);
- pDRIPriv->xf86_crtc_notify = xf86_wrap_crtc_notify(pScreen, dri_crtc_notify);
-}
-
-Bool
-DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD)
-{
- DRIScreenPrivPtr pDRIPriv;
- drm_context_t * reserved;
- int reserved_count;
- int i;
- DRIEntPrivPtr pDRIEntPriv;
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- DRIContextFlags flags = 0;
- DRIContextPrivPtr pDRIContextPriv;
-
- /* If the DRI extension is disabled, do not initialize the DRI */
- if (noXFree86DRIExtension) {
- DRIDrvMsg(pScreen->myNum, X_WARNING,
- "Direct rendering has been disabled.\n");
- return FALSE;
- }
-
- if (!xf86VGAarbiterAllowDRI(pScreen)) {
- DRIDrvMsg(pScreen->myNum, X_WARNING,
- "Direct rendering is not supported when VGA arb is necessary for the device\n");
- return FALSE;
- }
-
-#ifdef PANORAMIX
- /*
- * If Xinerama is on, don't allow DRI to initialise. It won't be usable
- * anyway.
- */
- if (!noPanoramiXExtension) {
- DRIDrvMsg(pScreen->myNum, X_WARNING,
- "Direct rendering is not supported when Xinerama is enabled\n");
- return FALSE;
- }
-#endif
-
- if (!DRIOpenDRMMaster(pScrn, pDRIInfo->SAREASize,
- pDRIInfo->busIdString,
- pDRIInfo->drmDriverName))
- return FALSE;
-
- pDRIEntPriv = DRI_ENT_PRIV(pScrn);
-
- if (DRIGeneration != serverGeneration)
- DRIGeneration = serverGeneration;
-
- if (!dixRegisterPrivateKey(&DRIScreenPrivKeyRec, PRIVATE_SCREEN, 0))
- return FALSE;
- if (!dixRegisterPrivateKey(&DRIWindowPrivKeyRec, PRIVATE_WINDOW, 0))
- return FALSE;
-
- pDRIPriv = (DRIScreenPrivPtr) calloc(1, sizeof(DRIScreenPrivRec));
- if (!pDRIPriv) {
- dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
- return FALSE;
- }
-
- dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, pDRIPriv);
- pDRIPriv->drmFD = pDRIEntPriv->drmFD;
- pDRIPriv->directRenderingSupport = TRUE;
- pDRIPriv->pDriverInfo = pDRIInfo;
- pDRIPriv->nrWindows = 0;
- pDRIPriv->nrWindowsVisible = 0;
- pDRIPriv->fullscreen = NULL;
-
- pDRIPriv->createDummyCtx = pDRIInfo->createDummyCtx;
- pDRIPriv->createDummyCtxPriv = pDRIInfo->createDummyCtxPriv;
-
- pDRIPriv->grabbedDRILock = FALSE;
- pDRIPriv->drmSIGIOHandlerInstalled = FALSE;
- *pDRMFD = pDRIPriv->drmFD;
-
- if (pDRIEntPriv->sAreaGrabbed || pDRIInfo->allocSarea) {
-
- if (drmAddMap( pDRIPriv->drmFD,
- 0,
- pDRIPriv->pDriverInfo->SAREASize,
- DRM_SHM,
- 0,
- &pDRIPriv->hSAREA) < 0)
- {
- pDRIPriv->directRenderingSupport = FALSE;
- dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
- drmClose(pDRIPriv->drmFD);
- DRIDrvMsg(pScreen->myNum, X_INFO,
- "[drm] drmAddMap failed\n");
- return FALSE;
- }
- DRIDrvMsg(pScreen->myNum, X_INFO,
- "[drm] added %d byte SAREA at %p\n",
- pDRIPriv->pDriverInfo->SAREASize, pDRIPriv->hSAREA);
-
- /* Backwards compat. */
- if (drmMap( pDRIPriv->drmFD,
- pDRIPriv->hSAREA,
- pDRIPriv->pDriverInfo->SAREASize,
- (drmAddressPtr)(&pDRIPriv->pSAREA)) < 0)
- {
- pDRIPriv->directRenderingSupport = FALSE;
- dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
- drmClose(pDRIPriv->drmFD);
- DRIDrvMsg(pScreen->myNum, X_INFO,
- "[drm] drmMap failed\n");
- return FALSE;
- }
- DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] mapped SAREA %p to %p\n",
- pDRIPriv->hSAREA, pDRIPriv->pSAREA);
- memset(pDRIPriv->pSAREA, 0, pDRIPriv->pDriverInfo->SAREASize);
- } else {
- DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] Using the DRM lock "
- "SAREA also for drawables.\n");
- pDRIPriv->hSAREA = pDRIEntPriv->hLSAREA;
- pDRIPriv->pSAREA = (XF86DRISAREAPtr) pDRIEntPriv->pLSAREA;
- pDRIEntPriv->sAreaGrabbed = TRUE;
- }
-
- pDRIPriv->hLSAREA = pDRIEntPriv->hLSAREA;
- pDRIPriv->pLSAREA = pDRIEntPriv->pLSAREA;
-
- if (!pDRIPriv->pDriverInfo->dontMapFrameBuffer)
- {
- if (drmAddMap( pDRIPriv->drmFD,
- (uintptr_t)pDRIPriv->pDriverInfo->frameBufferPhysicalAddress,
- pDRIPriv->pDriverInfo->frameBufferSize,
- DRM_FRAME_BUFFER,
- 0,
- &pDRIPriv->pDriverInfo->hFrameBuffer) < 0)
- {
- pDRIPriv->directRenderingSupport = FALSE;
- dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
- drmUnmap(pDRIPriv->pSAREA, pDRIPriv->pDriverInfo->SAREASize);
- drmClose(pDRIPriv->drmFD);
- DRIDrvMsg(pScreen->myNum, X_INFO,
- "[drm] drmAddMap failed\n");
- return FALSE;
- }
- DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] framebuffer handle = %p\n",
- pDRIPriv->pDriverInfo->hFrameBuffer);
- } else {
- DRIDrvMsg(pScreen->myNum, X_INFO,
- "[drm] framebuffer mapped by ddx driver\n");
- }
-
- if (pDRIEntPriv->resOwner == NULL) {
- pDRIEntPriv->resOwner = pScreen;
-
- /* Add tags for reserved contexts */
- if ((reserved = drmGetReservedContextList(pDRIPriv->drmFD,
- &reserved_count))) {
- int i;
- void *tag;
-
- for (i = 0; i < reserved_count; i++) {
- tag = DRICreateContextPrivFromHandle(pScreen,
- reserved[i],
- DRI_CONTEXT_RESERVED);
- drmAddContextTag(pDRIPriv->drmFD, reserved[i], tag);
- }
- drmFreeReservedContextList(reserved);
- DRIDrvMsg(pScreen->myNum, X_INFO,
- "[drm] added %d reserved context%s for kernel\n",
- reserved_count, reserved_count > 1 ? "s" : "");
- }
- }
-
- /* validate max drawable table entry set by driver */
- if ((pDRIPriv->pDriverInfo->maxDrawableTableEntry <= 0) ||
- (pDRIPriv->pDriverInfo->maxDrawableTableEntry > SAREA_MAX_DRAWABLES)) {
- DRIDrvMsg(pScreen->myNum, X_ERROR,
- "Invalid max drawable table size set by driver: %d\n",
- pDRIPriv->pDriverInfo->maxDrawableTableEntry);
- }
-
- /* Initialize drawable tables (screen private and SAREA) */
- for( i=0; i < pDRIPriv->pDriverInfo->maxDrawableTableEntry; i++) {
- pDRIPriv->DRIDrawables[i] = NULL;
- pDRIPriv->pSAREA->drawableTable[i].stamp = 0;
- pDRIPriv->pSAREA->drawableTable[i].flags = 0;
- }
-
- pDRIPriv->pLockRefCount = &pDRIEntPriv->lockRefCount;
- pDRIPriv->pLockingContext = &pDRIEntPriv->lockingContext;
-
- if (!pDRIEntPriv->keepFDOpen)
- pDRIEntPriv->keepFDOpen = pDRIInfo->keepFDOpen;
-
- pDRIEntPriv->refCount++;
-
- /* Set up flags for DRICreateContextPriv */
- switch (pDRIInfo->driverSwapMethod) {
- case DRI_KERNEL_SWAP:
- flags = DRI_CONTEXT_2DONLY;
- break;
- case DRI_HIDE_X_CONTEXT:
- flags = DRI_CONTEXT_PRESERVED;
- break;
- }
-
- if (!(pDRIContextPriv = DRICreateContextPriv(pScreen,
- &pDRIPriv->myContext,
- flags))) {
- DRIDrvMsg(pScreen->myNum, X_ERROR,
- "failed to create server context\n");
- return FALSE;
- }
- pDRIPriv->myContextPriv = pDRIContextPriv;
-
- DRIDrvMsg(pScreen->myNum, X_INFO,
- "X context handle = %p\n", pDRIPriv->myContext);
-
- /* Now that we have created the X server's context, we can grab the
- * hardware lock for the X server.
- */
- DRILock(pScreen, 0);
- pDRIPriv->grabbedDRILock = TRUE;
-
- /* pointers so that we can prevent memory leaks later */
- pDRIPriv->hiddenContextStore = NULL;
- pDRIPriv->partial3DContextStore = NULL;
-
- switch(pDRIInfo->driverSwapMethod) {
- case DRI_HIDE_X_CONTEXT:
- /* Server will handle 3D swaps, and hide 2D swaps from kernel.
- * Register server context as a preserved context.
- */
-
- /* allocate memory for hidden context store */
- pDRIPriv->hiddenContextStore
- = (void *)calloc(1, pDRIInfo->contextSize);
- if (!pDRIPriv->hiddenContextStore) {
- DRIDrvMsg(pScreen->myNum, X_ERROR,
- "failed to allocate hidden context\n");
- DRIDestroyContextPriv(pDRIContextPriv);
- return FALSE;
- }
-
- /* allocate memory for partial 3D context store */
- pDRIPriv->partial3DContextStore
- = (void *)calloc(1, pDRIInfo->contextSize);
- if (!pDRIPriv->partial3DContextStore) {
- DRIDrvMsg(pScreen->myNum, X_ERROR,
- "[DRI] failed to allocate partial 3D context\n");
- free(pDRIPriv->hiddenContextStore);
- DRIDestroyContextPriv(pDRIContextPriv);
- return FALSE;
- }
-
- /* save initial context store */
- if (pDRIInfo->SwapContext) {
- (*pDRIInfo->SwapContext)(
- pScreen,
- DRI_NO_SYNC,
- DRI_2D_CONTEXT,
- pDRIPriv->hiddenContextStore,
- DRI_NO_CONTEXT,
- NULL);
- }
- /* fall through */
-
- case DRI_SERVER_SWAP:
- /* For swap methods of DRI_SERVER_SWAP and DRI_HIDE_X_CONTEXT
- * setup signal handler for receiving swap requests from kernel
- */
- if (!(pDRIPriv->drmSIGIOHandlerInstalled =
- drmInstallSIGIOHandler(pDRIPriv->drmFD, DRISwapContext))) {
- DRIDrvMsg(pScreen->myNum, X_ERROR,
- "[drm] failed to setup DRM signal handler\n");
- free(pDRIPriv->hiddenContextStore);
- free(pDRIPriv->partial3DContextStore);
- DRIDestroyContextPriv(pDRIContextPriv);
- return FALSE;
- } else {
- DRIDrvMsg(pScreen->myNum, X_INFO,
- "[drm] installed DRM signal handler\n");
- }
-
- default:
- break;
- }
-
- return TRUE;
-}
-
-Bool
-DRIFinishScreenInit(ScreenPtr pScreen)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo;
-
- /* Wrap DRI support */
- if (pDRIInfo->wrap.ValidateTree) {
- pDRIPriv->wrap.ValidateTree = pScreen->ValidateTree;
- pScreen->ValidateTree = pDRIInfo->wrap.ValidateTree;
- }
- if (pDRIInfo->wrap.PostValidateTree) {
- pDRIPriv->wrap.PostValidateTree = pScreen->PostValidateTree;
- pScreen->PostValidateTree = pDRIInfo->wrap.PostValidateTree;
- }
- if (pDRIInfo->wrap.WindowExposures) {
- pDRIPriv->wrap.WindowExposures = pScreen->WindowExposures;
- pScreen->WindowExposures = pDRIInfo->wrap.WindowExposures;
- }
-
- pDRIPriv->DestroyWindow = pScreen->DestroyWindow;
- pScreen->DestroyWindow = DRIDestroyWindow;
-
- pDRIPriv->xf86_crtc_notify = xf86_wrap_crtc_notify(pScreen,
- dri_crtc_notify);
-
- if (pDRIInfo->wrap.CopyWindow) {
- pDRIPriv->wrap.CopyWindow = pScreen->CopyWindow;
- pScreen->CopyWindow = pDRIInfo->wrap.CopyWindow;
- }
- if (pDRIInfo->wrap.ClipNotify) {
- pDRIPriv->wrap.ClipNotify = pScreen->ClipNotify;
- pScreen->ClipNotify = pDRIInfo->wrap.ClipNotify;
- }
- if (pDRIInfo->wrap.AdjustFrame) {
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- pDRIPriv->wrap.AdjustFrame = pScrn->AdjustFrame;
- pScrn->AdjustFrame = pDRIInfo->wrap.AdjustFrame;
- }
- pDRIPriv->wrapped = TRUE;
-
- DRIDrvMsg(pScreen->myNum, X_INFO, "[DRI] installation complete\n");
-
- return TRUE;
-}
-
-void
-DRICloseScreen(ScreenPtr pScreen)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- DRIInfoPtr pDRIInfo;
- drm_context_t * reserved;
- int reserved_count;
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- DRIEntPrivPtr pDRIEntPriv = DRI_ENT_PRIV(pScrn);
- Bool closeMaster;
-
- if (pDRIPriv) {
-
- pDRIInfo = pDRIPriv->pDriverInfo;
-
- if (pDRIPriv->wrapped) {
- /* Unwrap DRI Functions */
- if (pDRIInfo->wrap.ValidateTree) {
- pScreen->ValidateTree = pDRIPriv->wrap.ValidateTree;
- pDRIPriv->wrap.ValidateTree = NULL;
- }
- if (pDRIInfo->wrap.PostValidateTree) {
- pScreen->PostValidateTree = pDRIPriv->wrap.PostValidateTree;
- pDRIPriv->wrap.PostValidateTree = NULL;
- }
- if (pDRIInfo->wrap.WindowExposures) {
- pScreen->WindowExposures = pDRIPriv->wrap.WindowExposures;
- pDRIPriv->wrap.WindowExposures = NULL;
- }
- if (pDRIPriv->DestroyWindow) {
- pScreen->DestroyWindow = pDRIPriv->DestroyWindow;
- pDRIPriv->DestroyWindow = NULL;
- }
-
- xf86_unwrap_crtc_notify(pScreen, pDRIPriv->xf86_crtc_notify);
-
- if (pDRIInfo->wrap.CopyWindow) {
- pScreen->CopyWindow = pDRIPriv->wrap.CopyWindow;
- pDRIPriv->wrap.CopyWindow = NULL;
- }
- if (pDRIInfo->wrap.ClipNotify) {
- pScreen->ClipNotify = pDRIPriv->wrap.ClipNotify;
- pDRIPriv->wrap.ClipNotify = NULL;
- }
- if (pDRIInfo->wrap.AdjustFrame) {
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- pScrn->AdjustFrame = pDRIPriv->wrap.AdjustFrame;
- pDRIPriv->wrap.AdjustFrame = NULL;
- }
-
- pDRIPriv->wrapped = FALSE;
- }
-
- if (pDRIPriv->drmSIGIOHandlerInstalled) {
- if (!drmRemoveSIGIOHandler(pDRIPriv->drmFD)) {
- DRIDrvMsg(pScreen->myNum, X_ERROR,
- "[drm] failed to remove DRM signal handler\n");
- }
- }
-
- if (pDRIPriv->dummyCtxPriv && pDRIPriv->createDummyCtx) {
- DRIDestroyDummyContext(pScreen, pDRIPriv->createDummyCtxPriv);
- }
-
- if (!DRIDestroyContextPriv(pDRIPriv->myContextPriv)) {
- DRIDrvMsg(pScreen->myNum, X_ERROR,
- "failed to destroy server context\n");
- }
-
- /* Remove tags for reserved contexts */
- if (pDRIEntPriv->resOwner == pScreen) {
- pDRIEntPriv->resOwner = NULL;
-
- if ((reserved = drmGetReservedContextList(pDRIPriv->drmFD,
- &reserved_count))) {
- int i;
-
- for (i = 0; i < reserved_count; i++) {
- DRIDestroyContextPriv(drmGetContextTag(pDRIPriv->drmFD,
- reserved[i]));
- }
- drmFreeReservedContextList(reserved);
- DRIDrvMsg(pScreen->myNum, X_INFO,
- "[drm] removed %d reserved context%s for kernel\n",
- reserved_count, reserved_count > 1 ? "s" : "");
- }
- }
-
- /* Make sure signals get unblocked etc. */
- drmUnlock(pDRIPriv->drmFD, pDRIPriv->myContext);
- pDRIPriv->pLockRefCount = NULL;
- closeMaster = (--pDRIEntPriv->refCount == 0) &&
- !pDRIEntPriv->keepFDOpen;
- if (closeMaster || pDRIPriv->hSAREA != pDRIEntPriv->hLSAREA) {
- DRIDrvMsg(pScreen->myNum, X_INFO,
- "[drm] unmapping %d bytes of SAREA %p at %p\n",
- pDRIInfo->SAREASize,
- pDRIPriv->hSAREA,
- pDRIPriv->pSAREA);
- if (drmUnmap(pDRIPriv->pSAREA, pDRIInfo->SAREASize)) {
- DRIDrvMsg(pScreen->myNum, X_ERROR,
- "[drm] unable to unmap %d bytes"
- " of SAREA %p at %p\n",
- pDRIInfo->SAREASize,
- pDRIPriv->hSAREA,
- pDRIPriv->pSAREA);
- }
- } else {
- pDRIEntPriv->sAreaGrabbed = FALSE;
- }
-
- if (closeMaster || (pDRIEntPriv->drmFD != pDRIPriv->drmFD)) {
- drmClose(pDRIPriv->drmFD);
- if (pDRIEntPriv->drmFD == pDRIPriv->drmFD) {
- DRIDrvMsg(pScreen->myNum, X_INFO,
- "[drm] Closed DRM master.\n");
- pDRIEntPriv->drmFD = -1;
- }
- }
-
- free(pDRIPriv);
- dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
- }
-}
-
-#define DRM_MSG_VERBOSITY 3
-
-static int dri_drm_debug_print(const char *format, va_list ap)
-{
- xf86VDrvMsgVerb(-1, X_NONE, DRM_MSG_VERBOSITY, format, ap);
- return 0;
-}
-
-static void dri_drm_get_perms(gid_t *group, mode_t *mode)
-{
- *group = xf86ConfigDRI.group;
- *mode = xf86ConfigDRI.mode;
-}
-
-drmServerInfo DRIDRMServerInfo = {
- dri_drm_debug_print,
- xf86LoadKernelModule,
- dri_drm_get_perms,
-};
-
-Bool
-DRIExtensionInit(void)
-{
- if (DRIGeneration != serverGeneration) {
- return FALSE;
- }
-
- DRIDrawablePrivResType = CreateNewResourceType(DRIDrawablePrivDelete,
- "DRIDrawable");
- DRIContextPrivResType = CreateNewResourceType(DRIContextPrivDelete,
- "DRIContext");
-
- if (!DRIDrawablePrivResType || !DRIContextPrivResType)
- return FALSE;
-
- RegisterBlockAndWakeupHandlers(DRIBlockHandler, DRIWakeupHandler, NULL);
-
- return TRUE;
-}
-
-void
-DRIReset(void)
-{
- /*
- * This stub routine is called when the X Server recycles, resources
- * allocated by DRIExtensionInit need to be managed here.
- *
- * Currently this routine is a stub because all the interesting resources
- * are managed via the screen init process.
- */
-}
-
-Bool
-DRIQueryDirectRenderingCapable(ScreenPtr pScreen, Bool* isCapable)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- if (pDRIPriv)
- *isCapable = pDRIPriv->directRenderingSupport;
- else
- *isCapable = FALSE;
-
- return TRUE;
-}
-
-Bool
-DRIOpenConnection(ScreenPtr pScreen, drm_handle_t * hSAREA, char **busIdString)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- *hSAREA = pDRIPriv->hSAREA;
- *busIdString = pDRIPriv->pDriverInfo->busIdString;
-
- return TRUE;
-}
-
-Bool
-DRIAuthConnection(ScreenPtr pScreen, drm_magic_t magic)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- if (drmAuthMagic(pDRIPriv->drmFD, magic)) return FALSE;
- return TRUE;
-}
-
-Bool
-DRICloseConnection(ScreenPtr pScreen)
-{
- return TRUE;
-}
-
-Bool
-DRIGetClientDriverName(ScreenPtr pScreen,
- int *ddxDriverMajorVersion,
- int *ddxDriverMinorVersion,
- int *ddxDriverPatchVersion,
- char **clientDriverName)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- *ddxDriverMajorVersion = pDRIPriv->pDriverInfo->ddxDriverMajorVersion;
- *ddxDriverMinorVersion = pDRIPriv->pDriverInfo->ddxDriverMinorVersion;
- *ddxDriverPatchVersion = pDRIPriv->pDriverInfo->ddxDriverPatchVersion;
- *clientDriverName = pDRIPriv->pDriverInfo->clientDriverName;
-
- return TRUE;
-}
-
-/* DRICreateContextPriv and DRICreateContextPrivFromHandle are helper
- functions that layer on drmCreateContext and drmAddContextTag.
-
- DRICreateContextPriv always creates a kernel drm_context_t and then calls
- DRICreateContextPrivFromHandle to create a DRIContextPriv structure for
- DRI tracking. For the SIGIO handler, the drm_context_t is associated with
- DRIContextPrivPtr. Any special flags are stored in the DRIContextPriv
- area and are passed to the kernel (if necessary).
-
- DRICreateContextPriv returns a pointer to newly allocated
- DRIContextPriv, and returns the kernel drm_context_t in pHWContext. */
-
-DRIContextPrivPtr
-DRICreateContextPriv(ScreenPtr pScreen,
- drm_context_t * pHWContext,
- DRIContextFlags flags)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- if (drmCreateContext(pDRIPriv->drmFD, pHWContext)) {
- return NULL;
- }
-
- return DRICreateContextPrivFromHandle(pScreen, *pHWContext, flags);
-}
-
-DRIContextPrivPtr
-DRICreateContextPrivFromHandle(ScreenPtr pScreen,
- drm_context_t hHWContext,
- DRIContextFlags flags)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- DRIContextPrivPtr pDRIContextPriv;
- int contextPrivSize;
-
- contextPrivSize = sizeof(DRIContextPrivRec) +
- pDRIPriv->pDriverInfo->contextSize;
- if (!(pDRIContextPriv = calloc(1, contextPrivSize))) {
- return NULL;
- }
- pDRIContextPriv->pContextStore = (void *)(pDRIContextPriv + 1);
-
- drmAddContextTag(pDRIPriv->drmFD, hHWContext, pDRIContextPriv);
-
- pDRIContextPriv->hwContext = hHWContext;
- pDRIContextPriv->pScreen = pScreen;
- pDRIContextPriv->flags = flags;
- pDRIContextPriv->valid3D = FALSE;
-
- if (flags & DRI_CONTEXT_2DONLY) {
- if (drmSetContextFlags(pDRIPriv->drmFD,
- hHWContext,
- DRM_CONTEXT_2DONLY)) {
- DRIDrvMsg(pScreen->myNum, X_ERROR,
- "[drm] failed to set 2D context flag\n");
- DRIDestroyContextPriv(pDRIContextPriv);
- return NULL;
- }
- }
- if (flags & DRI_CONTEXT_PRESERVED) {
- if (drmSetContextFlags(pDRIPriv->drmFD,
- hHWContext,
- DRM_CONTEXT_PRESERVED)) {
- DRIDrvMsg(pScreen->myNum, X_ERROR,
- "[drm] failed to set preserved flag\n");
- DRIDestroyContextPriv(pDRIContextPriv);
- return NULL;
- }
- }
- return pDRIContextPriv;
-}
-
-Bool
-DRIDestroyContextPriv(DRIContextPrivPtr pDRIContextPriv)
-{
- DRIScreenPrivPtr pDRIPriv;
-
- if (!pDRIContextPriv) return TRUE;
-
- pDRIPriv = DRI_SCREEN_PRIV(pDRIContextPriv->pScreen);
-
- if (!(pDRIContextPriv->flags & DRI_CONTEXT_RESERVED)) {
- /* Don't delete reserved contexts from
- kernel area -- the kernel manages its
- reserved contexts itself. */
- if (drmDestroyContext(pDRIPriv->drmFD, pDRIContextPriv->hwContext))
- return FALSE;
- }
-
- /* Remove the tag last to prevent a race
- condition where the context has pending
- buffers. The context can't be re-used
- while in this thread, but buffers can be
- dispatched asynchronously. */
- drmDelContextTag(pDRIPriv->drmFD, pDRIContextPriv->hwContext);
- free(pDRIContextPriv);
- return TRUE;
-}
-
-static Bool
-DRICreateDummyContext(ScreenPtr pScreen, Bool needCtxPriv)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- DRIContextPrivPtr pDRIContextPriv;
- void *contextStore;
-
- if (!(pDRIContextPriv =
- DRICreateContextPriv(pScreen,
- &pDRIPriv->pSAREA->dummy_context, 0))) {
- return FALSE;
- }
-
- contextStore = DRIGetContextStore(pDRIContextPriv);
- if (pDRIPriv->pDriverInfo->CreateContext && needCtxPriv) {
- if (!pDRIPriv->pDriverInfo->CreateContext(pScreen, NULL,
- pDRIPriv->pSAREA->dummy_context,
- NULL,
- (DRIContextType)(long)contextStore)) {
- DRIDestroyContextPriv(pDRIContextPriv);
- return FALSE;
- }
- }
-
- pDRIPriv->dummyCtxPriv = pDRIContextPriv;
- return TRUE;
-}
-
-static void
-DRIDestroyDummyContext(ScreenPtr pScreen, Bool hasCtxPriv)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- DRIContextPrivPtr pDRIContextPriv = pDRIPriv->dummyCtxPriv;
- void *contextStore;
-
- if (!pDRIContextPriv) return;
- if (pDRIPriv->pDriverInfo->DestroyContext && hasCtxPriv) {
- contextStore = DRIGetContextStore(pDRIContextPriv);
- pDRIPriv->pDriverInfo->DestroyContext(pDRIContextPriv->pScreen,
- pDRIContextPriv->hwContext,
- (DRIContextType)(long)contextStore);
- }
-
- DRIDestroyContextPriv(pDRIPriv->dummyCtxPriv);
- pDRIPriv->dummyCtxPriv = NULL;
-}
-
-Bool
-DRICreateContext(ScreenPtr pScreen, VisualPtr visual,
- XID context, drm_context_t * pHWContext)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- DRIContextPrivPtr pDRIContextPriv;
- void *contextStore;
-
- if (pDRIPriv->createDummyCtx && !pDRIPriv->dummyCtxPriv) {
- if (!DRICreateDummyContext(pScreen, pDRIPriv->createDummyCtxPriv)) {
- DRIDrvMsg(pScreen->myNum, X_INFO,
- "[drm] Could not create dummy context\n");
- return FALSE;
- }
- }
-
- if (!(pDRIContextPriv = DRICreateContextPriv(pScreen, pHWContext, 0))) {
- return FALSE;
- }
-
- contextStore = DRIGetContextStore(pDRIContextPriv);
- if (pDRIPriv->pDriverInfo->CreateContext) {
- if (!((*pDRIPriv->pDriverInfo->CreateContext)(pScreen, NULL,
- *pHWContext, NULL,
- (DRIContextType)(long)contextStore))) {
- DRIDestroyContextPriv(pDRIContextPriv);
- return FALSE;
- }
- }
-
- /* track this in case the client dies before cleanup */
- AddResource(context, DRIContextPrivResType, (pointer)pDRIContextPriv);
-
- return TRUE;
-}
-
-Bool
-DRIDestroyContext(ScreenPtr pScreen, XID context)
-{
- FreeResourceByType(context, DRIContextPrivResType, FALSE);
-
- return TRUE;
-}
-
-/* DRIContextPrivDelete is called by the resource manager. */
-Bool
-DRIContextPrivDelete(pointer pResource, XID id)
-{
- DRIContextPrivPtr pDRIContextPriv = (DRIContextPrivPtr)pResource;
- DRIScreenPrivPtr pDRIPriv;
- void *contextStore;
-
- pDRIPriv = DRI_SCREEN_PRIV(pDRIContextPriv->pScreen);
- if (pDRIPriv->pDriverInfo->DestroyContext) {
- contextStore = DRIGetContextStore(pDRIContextPriv);
- pDRIPriv->pDriverInfo->DestroyContext(pDRIContextPriv->pScreen,
- pDRIContextPriv->hwContext,
- (DRIContextType)(long)contextStore);
- }
- return DRIDestroyContextPriv(pDRIContextPriv);
-}
-
-
-/* This walks the drawable timestamp array and invalidates all of them
- * in the case of transition from private to shared backbuffers. It's
- * not necessary for correctness, because DRIClipNotify gets called in
- * time to prevent any conflict, but the transition from
- * shared->private is sometimes missed if we don't do this.
- */
-static void
-DRIClipNotifyAllDrawables(ScreenPtr pScreen)
-{
- int i;
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- for( i=0; i < pDRIPriv->pDriverInfo->maxDrawableTableEntry; i++) {
- pDRIPriv->pSAREA->drawableTable[i].stamp = DRIDrawableValidationStamp++;
- }
-}
-
-
-static void
-DRITransitionToSharedBuffers(ScreenPtr pScreen)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo;
-
- DRIClipNotifyAllDrawables( pScreen );
-
- if (pDRIInfo->TransitionSingleToMulti3D)
- pDRIInfo->TransitionSingleToMulti3D( pScreen );
-}
-
-
-static void
-DRITransitionToPrivateBuffers(ScreenPtr pScreen)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo;
-
- DRIClipNotifyAllDrawables( pScreen );
-
- if (pDRIInfo->TransitionMultiToSingle3D)
- pDRIInfo->TransitionMultiToSingle3D( pScreen );
-}
-
-
-static void
-DRITransitionTo3d(ScreenPtr pScreen)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo;
-
- DRIClipNotifyAllDrawables( pScreen );
-
- if (pDRIInfo->TransitionTo3d)
- pDRIInfo->TransitionTo3d( pScreen );
-}
-
-static void
-DRITransitionTo2d(ScreenPtr pScreen)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo;
-
- DRIClipNotifyAllDrawables( pScreen );
-
- if (pDRIInfo->TransitionTo2d)
- pDRIInfo->TransitionTo2d( pScreen );
-}
-
-
-static int
-DRIDCNTreeTraversal(WindowPtr pWin, pointer data)
-{
- DRIDrawablePrivPtr pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
-
- if (pDRIDrawablePriv) {
- ScreenPtr pScreen = pWin->drawable.pScreen;
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- if (RegionNumRects(&pWin->clipList) > 0) {
- WindowPtr *pDRIWindows = (WindowPtr*)data;
- int i = 0;
-
- while (pDRIWindows[i])
- i++;
-
- pDRIWindows[i] = pWin;
-
- pDRIPriv->nrWalked++;
- }
-
- if (pDRIPriv->nrWindows == pDRIPriv->nrWalked)
- return WT_STOPWALKING;
- }
-
- return WT_WALKCHILDREN;
-}
-
-static void
-DRIDriverClipNotify(ScreenPtr pScreen)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- if (pDRIPriv->pDriverInfo->ClipNotify) {
- WindowPtr *pDRIWindows = calloc(sizeof(WindowPtr), pDRIPriv->nrWindows);
- DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo;
-
- if (pDRIPriv->nrWindows > 0) {
- pDRIPriv->nrWalked = 0;
- TraverseTree(pScreen->root, DRIDCNTreeTraversal,
- (pointer)pDRIWindows);
- }
-
- pDRIInfo->ClipNotify(pScreen, pDRIWindows, pDRIPriv->nrWindows);
-
- free(pDRIWindows);
- }
-}
-
-static void
-DRIIncreaseNumberVisible(ScreenPtr pScreen)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- switch (++pDRIPriv->nrWindowsVisible) {
- case 1:
- DRITransitionTo3d( pScreen );
- break;
- case 2:
- DRITransitionToSharedBuffers( pScreen );
- break;
- default:
- break;
- }
-
- DRIDriverClipNotify(pScreen);
-}
-
-static void
-DRIDecreaseNumberVisible(ScreenPtr pScreen)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- switch (--pDRIPriv->nrWindowsVisible) {
- case 0:
- DRITransitionTo2d( pScreen );
- break;
- case 1:
- DRITransitionToPrivateBuffers( pScreen );
- break;
- default:
- break;
- }
-
- DRIDriverClipNotify(pScreen);
-}
-
-Bool
-DRICreateDrawable(ScreenPtr pScreen, ClientPtr client, DrawablePtr pDrawable,
- drm_drawable_t * hHWDrawable)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- DRIDrawablePrivPtr pDRIDrawablePriv;
- WindowPtr pWin;
-
- if (pDrawable->type == DRAWABLE_WINDOW) {
- pWin = (WindowPtr)pDrawable;
- if ((pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin))) {
- pDRIDrawablePriv->refCount++;
-
- if (!pDRIDrawablePriv->hwDrawable) {
- drmCreateDrawable(pDRIPriv->drmFD, &pDRIDrawablePriv->hwDrawable);
- }
- }
- else {
- /* allocate a DRI Window Private record */
- if (!(pDRIDrawablePriv = malloc(sizeof(DRIDrawablePrivRec)))) {
- return FALSE;
- }
-
- /* Only create a drm_drawable_t once */
- if (drmCreateDrawable(pDRIPriv->drmFD,
- &pDRIDrawablePriv->hwDrawable)) {
- free(pDRIDrawablePriv);
- return FALSE;
- }
-
- /* add it to the list of DRI drawables for this screen */
- pDRIDrawablePriv->pScreen = pScreen;
- pDRIDrawablePriv->refCount = 1;
- pDRIDrawablePriv->drawableIndex = -1;
- pDRIDrawablePriv->nrects = RegionNumRects(&pWin->clipList);
-
- /* save private off of preallocated index */
- dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey,
- pDRIDrawablePriv);
- pDRIPriv->nrWindows++;
-
- if (pDRIDrawablePriv->nrects)
- DRIIncreaseNumberVisible(pScreen);
- }
-
- /* track this in case the client dies */
- AddResource(FakeClientID(client->index), DRIDrawablePrivResType,
- (pointer)(intptr_t)pDrawable->id);
-
- if (pDRIDrawablePriv->hwDrawable) {
- drmUpdateDrawableInfo(pDRIPriv->drmFD,
- pDRIDrawablePriv->hwDrawable,
- DRM_DRAWABLE_CLIPRECTS,
- RegionNumRects(&pWin->clipList),
- RegionRects(&pWin->clipList));
- *hHWDrawable = pDRIDrawablePriv->hwDrawable;
- }
- }
- else if (pDrawable->type != DRAWABLE_PIXMAP) { /* PBuffer */
- /* NOT_DONE */
- return FALSE;
- }
-
- return TRUE;
-}
-
-static void
-DRIDrawablePrivDestroy(WindowPtr pWin)
-{
- DRIDrawablePrivPtr pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
- ScreenPtr pScreen;
- DRIScreenPrivPtr pDRIPriv;
-
- if (!pDRIDrawablePriv)
- return;
-
- pScreen = pWin->drawable.pScreen;
- pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- if (pDRIDrawablePriv->drawableIndex != -1) {
- /* bump stamp to force outstanding 3D requests to resync */
- pDRIPriv->pSAREA->drawableTable[pDRIDrawablePriv->drawableIndex].stamp
- = DRIDrawableValidationStamp++;
-
- /* release drawable table entry */
- pDRIPriv->DRIDrawables[pDRIDrawablePriv->drawableIndex] = NULL;
- }
-
- pDRIPriv->nrWindows--;
-
- if (pDRIDrawablePriv->nrects)
- DRIDecreaseNumberVisible(pScreen);
-
- drmDestroyDrawable(pDRIPriv->drmFD, pDRIDrawablePriv->hwDrawable);
-
- free(pDRIDrawablePriv);
- dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey, NULL);
-}
-
-static Bool
-DRIDestroyDrawableCB(pointer value, XID id, pointer data)
-{
- if (value == data) {
- /* This calls back DRIDrawablePrivDelete which frees private area */
- FreeResourceByType(id, DRIDrawablePrivResType, FALSE);
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-Bool
-DRIDestroyDrawable(ScreenPtr pScreen, ClientPtr client, DrawablePtr pDrawable)
-{
- if (pDrawable->type == DRAWABLE_WINDOW) {
- LookupClientResourceComplex(client, DRIDrawablePrivResType,
- DRIDestroyDrawableCB,
- (pointer)(intptr_t)pDrawable->id);
- }
- else { /* pixmap (or for GLX 1.3, a PBuffer) */
- /* NOT_DONE */
- return FALSE;
- }
-
- return TRUE;
-}
-
-Bool
-DRIDrawablePrivDelete(pointer pResource, XID id)
-{
- WindowPtr pWin;
- int rc;
-
- /* For DRIDrawablePrivResType, the XID is the client's fake ID. The
- * important XID is the value in pResource. */
- id = (XID)(intptr_t)pResource;
- rc = dixLookupWindow(&pWin, id, serverClient, DixGetAttrAccess);
-
- if (rc == Success) {
- DRIDrawablePrivPtr pDRIDrwPriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
-
- if (!pDRIDrwPriv)
- return FALSE;
-
- if (--pDRIDrwPriv->refCount == 0)
- DRIDrawablePrivDestroy(pWin);
-
- return TRUE;
- }
- else { /* pixmap (or for GLX 1.3, a PBuffer) */
- /* NOT_DONE */
- return FALSE;
- }
-}
-
-Bool
-DRIGetDrawableInfo(ScreenPtr pScreen,
- DrawablePtr pDrawable,
- unsigned int* index,
- unsigned int* stamp,
- int* X,
- int* Y,
- int* W,
- int* H,
- int* numClipRects,
- drm_clip_rect_t ** pClipRects,
- int* backX,
- int* backY,
- int* numBackClipRects,
- drm_clip_rect_t ** pBackClipRects)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- DRIDrawablePrivPtr pDRIDrawablePriv, pOldDrawPriv;
- WindowPtr pWin, pOldWin;
- int i;
-
-#if 0
- printf("maxDrawableTableEntry = %d\n", pDRIPriv->pDriverInfo->maxDrawableTableEntry);
-#endif
-
- if (pDrawable->type == DRAWABLE_WINDOW) {
- pWin = (WindowPtr)pDrawable;
- if ((pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin))) {
-
- /* Manage drawable table */
- if (pDRIDrawablePriv->drawableIndex == -1) { /* load SAREA table */
-
- /* Search table for empty entry */
- i = 0;
- while (i < pDRIPriv->pDriverInfo->maxDrawableTableEntry) {
- if (!(pDRIPriv->DRIDrawables[i])) {
- pDRIPriv->DRIDrawables[i] = pDrawable;
- pDRIDrawablePriv->drawableIndex = i;
- pDRIPriv->pSAREA->drawableTable[i].stamp =
- DRIDrawableValidationStamp++;
- break;
- }
- i++;
- }
-
- /* Search table for oldest entry */
- if (i == pDRIPriv->pDriverInfo->maxDrawableTableEntry) {
- unsigned int oldestStamp = ~0;
- int oldestIndex = 0;
- i = pDRIPriv->pDriverInfo->maxDrawableTableEntry;
- while (i--) {
- if (pDRIPriv->pSAREA->drawableTable[i].stamp <
- oldestStamp) {
- oldestIndex = i;
- oldestStamp =
- pDRIPriv->pSAREA->drawableTable[i].stamp;
- }
- }
- pDRIDrawablePriv->drawableIndex = oldestIndex;
-
- /* release oldest drawable table entry */
- pOldWin = (WindowPtr)pDRIPriv->DRIDrawables[oldestIndex];
- pOldDrawPriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pOldWin);
- pOldDrawPriv->drawableIndex = -1;
-
- /* claim drawable table entry */
- pDRIPriv->DRIDrawables[oldestIndex] = pDrawable;
-
- /* validate SAREA entry */
- pDRIPriv->pSAREA->drawableTable[oldestIndex].stamp =
- DRIDrawableValidationStamp++;
-
- /* check for stamp wrap around */
- if (oldestStamp > DRIDrawableValidationStamp) {
-
- /* walk SAREA table and invalidate all drawables */
- for( i=0;
- i < pDRIPriv->pDriverInfo->maxDrawableTableEntry;
- i++) {
- pDRIPriv->pSAREA->drawableTable[i].stamp =
- DRIDrawableValidationStamp++;
- }
- }
- }
-
- /* If the driver wants to be notified when the index is
- * set for a drawable, let it know now.
- */
- if (pDRIPriv->pDriverInfo->SetDrawableIndex)
- pDRIPriv->pDriverInfo->SetDrawableIndex(pWin,
- pDRIDrawablePriv->drawableIndex);
-
- /* reinit drawable ID if window is visible */
- if ((pWin->viewable) &&
- (pDRIPriv->pDriverInfo->bufferRequests != DRI_NO_WINDOWS))
- {
- (*pDRIPriv->pDriverInfo->InitBuffers)(pWin,
- &pWin->clipList, pDRIDrawablePriv->drawableIndex);
- }
- }
-
- *index = pDRIDrawablePriv->drawableIndex;
- *stamp = pDRIPriv->pSAREA->drawableTable[*index].stamp;
- *X = (int)(pWin->drawable.x);
- *Y = (int)(pWin->drawable.y);
- *W = (int)(pWin->drawable.width);
- *H = (int)(pWin->drawable.height);
- *numClipRects = RegionNumRects(&pWin->clipList);
- *pClipRects = (drm_clip_rect_t *)RegionRects(&pWin->clipList);
-
- if (!*numClipRects && pDRIPriv->fullscreen) {
- /* use fake full-screen clip rect */
- pDRIPriv->fullscreen_rect.x1 = *X;
- pDRIPriv->fullscreen_rect.y1 = *Y;
- pDRIPriv->fullscreen_rect.x2 = *X + *W;
- pDRIPriv->fullscreen_rect.y2 = *Y + *H;
-
- *numClipRects = 1;
- *pClipRects = &pDRIPriv->fullscreen_rect;
- }
-
- *backX = *X;
- *backY = *Y;
-
- if (pDRIPriv->nrWindowsVisible == 1 && *numClipRects) {
- /* Use a single cliprect. */
-
- int x0 = *X;
- int y0 = *Y;
- int x1 = x0 + *W;
- int y1 = y0 + *H;
-
- if (x0 < 0) x0 = 0;
- if (y0 < 0) y0 = 0;
- if (x1 > pScreen->width) x1 = pScreen->width;
- if (y1 > pScreen->height) y1 = pScreen->height;
-
- if (y0 >= y1 || x0 >= x1) {
- *numBackClipRects = 0;
- *pBackClipRects = NULL;
- } else {
- pDRIPriv->private_buffer_rect.x1 = x0;
- pDRIPriv->private_buffer_rect.y1 = y0;
- pDRIPriv->private_buffer_rect.x2 = x1;
- pDRIPriv->private_buffer_rect.y2 = y1;
-
- *numBackClipRects = 1;
- *pBackClipRects = &(pDRIPriv->private_buffer_rect);
- }
- } else {
- /* Use the frontbuffer cliprects for back buffers. */
- *numBackClipRects = 0;
- *pBackClipRects = 0;
- }
- }
- else {
- /* Not a DRIDrawable */
- return FALSE;
- }
- }
- else { /* pixmap (or for GLX 1.3, a PBuffer) */
- /* NOT_DONE */
- return FALSE;
- }
-
- return TRUE;
-}
-
-Bool
-DRIGetDeviceInfo(ScreenPtr pScreen,
- drm_handle_t * hFrameBuffer,
- int* fbOrigin,
- int* fbSize,
- int* fbStride,
- int* devPrivateSize,
- void** pDevPrivate)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- *hFrameBuffer = pDRIPriv->pDriverInfo->hFrameBuffer;
- *fbOrigin = 0;
- *fbSize = pDRIPriv->pDriverInfo->frameBufferSize;
- *fbStride = pDRIPriv->pDriverInfo->frameBufferStride;
- *devPrivateSize = pDRIPriv->pDriverInfo->devPrivateSize;
- *pDevPrivate = pDRIPriv->pDriverInfo->devPrivate;
-
- return TRUE;
-}
-
-DRIInfoPtr
-DRICreateInfoRec(void)
-{
- DRIInfoPtr inforec = (DRIInfoPtr)calloc(1, sizeof(DRIInfoRec));
- if (!inforec) return NULL;
-
- /* Initialize defaults */
- inforec->busIdString = NULL;
-
- /* Wrapped function defaults */
- inforec->wrap.WakeupHandler = DRIDoWakeupHandler;
- inforec->wrap.BlockHandler = DRIDoBlockHandler;
- inforec->wrap.WindowExposures = DRIWindowExposures;
- inforec->wrap.CopyWindow = DRICopyWindow;
- inforec->wrap.ValidateTree = DRIValidateTree;
- inforec->wrap.PostValidateTree = DRIPostValidateTree;
- inforec->wrap.ClipNotify = DRIClipNotify;
- inforec->wrap.AdjustFrame = DRIAdjustFrame;
-
- inforec->TransitionTo2d = 0;
- inforec->TransitionTo3d = 0;
- inforec->SetDrawableIndex = 0;
-
- return inforec;
-}
-
-void
-DRIDestroyInfoRec(DRIInfoPtr DRIInfo)
-{
- free(DRIInfo->busIdString);
- free((char*)DRIInfo);
-}
-
-
-void
-DRIWakeupHandler(pointer wakeupData, int result, pointer pReadmask)
-{
- int i;
-
- for (i = 0; i < screenInfo.numScreens; i++) {
- ScreenPtr pScreen = screenInfo.screens[i];
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- if (pDRIPriv &&
- pDRIPriv->pDriverInfo->wrap.WakeupHandler)
- (*pDRIPriv->pDriverInfo->wrap.WakeupHandler)(i, wakeupData,
- result, pReadmask);
- }
-}
-
-void
-DRIBlockHandler(pointer blockData, OSTimePtr pTimeout, pointer pReadmask)
-{
- int i;
-
- for (i = 0; i < screenInfo.numScreens; i++) {
- ScreenPtr pScreen = screenInfo.screens[i];
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- if (pDRIPriv &&
- pDRIPriv->pDriverInfo->wrap.BlockHandler)
- (*pDRIPriv->pDriverInfo->wrap.BlockHandler)(i, blockData,
- pTimeout, pReadmask);
- }
-}
-
-void
-DRIDoWakeupHandler(int screenNum, pointer wakeupData,
- unsigned long result, pointer pReadmask)
-{
- ScreenPtr pScreen = screenInfo.screens[screenNum];
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- DRILock(pScreen, 0);
- if (pDRIPriv->pDriverInfo->driverSwapMethod == DRI_HIDE_X_CONTEXT) {
- /* hide X context by swapping 2D component here */
- (*pDRIPriv->pDriverInfo->SwapContext)(pScreen,
- DRI_3D_SYNC,
- DRI_2D_CONTEXT,
- pDRIPriv->partial3DContextStore,
- DRI_2D_CONTEXT,
- pDRIPriv->hiddenContextStore);
- }
-}
-
-void
-DRIDoBlockHandler(int screenNum, pointer blockData,
- pointer pTimeout, pointer pReadmask)
-{
- ScreenPtr pScreen = screenInfo.screens[screenNum];
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- if (pDRIPriv->pDriverInfo->driverSwapMethod == DRI_HIDE_X_CONTEXT) {
- /* hide X context by swapping 2D component here */
- (*pDRIPriv->pDriverInfo->SwapContext)(pScreen,
- DRI_2D_SYNC,
- DRI_NO_CONTEXT,
- NULL,
- DRI_2D_CONTEXT,
- pDRIPriv->partial3DContextStore);
- }
-
- if (pDRIPriv->windowsTouched)
- DRM_SPINUNLOCK(&pDRIPriv->pSAREA->drawable_lock, 1);
- pDRIPriv->windowsTouched = FALSE;
-
- DRIUnlock(pScreen);
-}
-
-void
-DRISwapContext(int drmFD, void *oldctx, void *newctx)
-{
- DRIContextPrivPtr oldContext = (DRIContextPrivPtr)oldctx;
- DRIContextPrivPtr newContext = (DRIContextPrivPtr)newctx;
- ScreenPtr pScreen = newContext->pScreen;
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- void* oldContextStore = NULL;
- DRIContextType oldContextType;
- void* newContextStore = NULL;
- DRIContextType newContextType;
- DRISyncType syncType;
-#ifdef DEBUG
- static int count = 0;
-
- if (!newContext) {
- DRIDrvMsg(pScreen->myNum, X_ERROR,
- "[DRI] Context Switch Error: oldContext=%x, newContext=%x\n",
- oldContext, newContext);
- return;
- }
-
- /* usefull for debugging, just print out after n context switches */
- if (!count || !(count % 1)) {
- DRIDrvMsg(pScreen->myNum, X_INFO,
- "[DRI] Context switch %5d from %p/0x%08x (%d)\n",
- count,
- oldContext,
- oldContext ? oldContext->flags : 0,
- oldContext ? oldContext->hwContext : -1);
- DRIDrvMsg(pScreen->myNum, X_INFO,
- "[DRI] Context switch %5d to %p/0x%08x (%d)\n",
- count,
- newContext,
- newContext ? newContext->flags : 0,
- newContext ? newContext->hwContext : -1);
- }
- ++count;
-#endif
-
- if (!pDRIPriv->pDriverInfo->SwapContext) {
- DRIDrvMsg(pScreen->myNum, X_ERROR,
- "[DRI] DDX driver missing context swap call back\n");
- return;
- }
-
- if (pDRIPriv->pDriverInfo->driverSwapMethod == DRI_HIDE_X_CONTEXT) {
-
- /* only 3D contexts are swapped in this case */
- if (oldContext) {
- oldContextStore = DRIGetContextStore(oldContext);
- oldContext->valid3D = TRUE;
- oldContextType = DRI_3D_CONTEXT;
- } else {
- oldContextType = DRI_NO_CONTEXT;
- }
- newContextStore = DRIGetContextStore(newContext);
- if ((newContext->valid3D) &&
- (newContext->hwContext != pDRIPriv->myContext)) {
- newContextType = DRI_3D_CONTEXT;
- }
- else {
- newContextType = DRI_2D_CONTEXT;
- }
- syncType = DRI_3D_SYNC;
- }
- else /* default: driverSwapMethod == DRI_SERVER_SWAP */ {
-
- /* optimize 2D context swaps */
-
- if (newContext->flags & DRI_CONTEXT_2DONLY) {
- /* go from 3D context to 2D context and only save 2D
- * subset of 3D state
- */
- oldContextStore = DRIGetContextStore(oldContext);
- oldContextType = DRI_2D_CONTEXT;
- newContextStore = DRIGetContextStore(newContext);
- newContextType = DRI_2D_CONTEXT;
- syncType = DRI_3D_SYNC;
- pDRIPriv->lastPartial3DContext = oldContext;
- }
- else if (oldContext->flags & DRI_CONTEXT_2DONLY) {
- if (pDRIPriv->lastPartial3DContext == newContext) {
- /* go from 2D context back to previous 3D context and
- * only restore 2D subset of previous 3D state
- */
- oldContextStore = DRIGetContextStore(oldContext);
- oldContextType = DRI_2D_CONTEXT;
- newContextStore = DRIGetContextStore(newContext);
- newContextType = DRI_2D_CONTEXT;
- syncType = DRI_2D_SYNC;
- }
- else {
- /* go from 2D context to a different 3D context */
-
- /* call DDX driver to do partial restore */
- oldContextStore = DRIGetContextStore(oldContext);
- newContextStore =
- DRIGetContextStore(pDRIPriv->lastPartial3DContext);
- (*pDRIPriv->pDriverInfo->SwapContext)(pScreen,
- DRI_2D_SYNC,
- DRI_2D_CONTEXT,
- oldContextStore,
- DRI_2D_CONTEXT,
- newContextStore);
-
- /* now setup for a complete 3D swap */
- oldContextStore = newContextStore;
- oldContext->valid3D = TRUE;
- oldContextType = DRI_3D_CONTEXT;
- newContextStore = DRIGetContextStore(newContext);
- if ((newContext->valid3D) &&
- (newContext->hwContext != pDRIPriv->myContext)) {
- newContextType = DRI_3D_CONTEXT;
- }
- else {
- newContextType = DRI_2D_CONTEXT;
- }
- syncType = DRI_NO_SYNC;
- }
- }
- else {
- /* now setup for a complete 3D swap */
- oldContextStore = newContextStore;
- oldContext->valid3D = TRUE;
- oldContextType = DRI_3D_CONTEXT;
- newContextStore = DRIGetContextStore(newContext);
- if ((newContext->valid3D) &&
- (newContext->hwContext != pDRIPriv->myContext)) {
- newContextType = DRI_3D_CONTEXT;
- }
- else {
- newContextType = DRI_2D_CONTEXT;
- }
- syncType = DRI_3D_SYNC;
- }
- }
-
- /* call DDX driver to perform the swap */
- (*pDRIPriv->pDriverInfo->SwapContext)(pScreen,
- syncType,
- oldContextType,
- oldContextStore,
- newContextType,
- newContextStore);
-}
-
-void*
-DRIGetContextStore(DRIContextPrivPtr context)
-{
- return((void *)context->pContextStore);
-}
-
-void
-DRIWindowExposures(WindowPtr pWin, RegionPtr prgn, RegionPtr bsreg)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- DRIDrawablePrivPtr pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
-
- if(pDRIDrawablePriv) {
- (*pDRIPriv->pDriverInfo->InitBuffers)(pWin, prgn,
- pDRIDrawablePriv->drawableIndex);
- }
-
- /* call lower wrapped functions */
- if (pDRIPriv && pDRIPriv->wrap.WindowExposures) {
-
- /* unwrap */
- pScreen->WindowExposures = pDRIPriv->wrap.WindowExposures;
-
- /* call lower layers */
- (*pScreen->WindowExposures)(pWin, prgn, bsreg);
-
- /* rewrap */
- pDRIPriv->wrap.WindowExposures = pScreen->WindowExposures;
- pScreen->WindowExposures = DRIWindowExposures;
- }
-}
-
-
-static int
-DRITreeTraversal(WindowPtr pWin, pointer data)
-{
- DRIDrawablePrivPtr pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
-
- if(pDRIDrawablePriv) {
- ScreenPtr pScreen = pWin->drawable.pScreen;
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- if(RegionNumRects(&(pWin->clipList)) > 0) {
- RegionPtr reg = (RegionPtr)data;
-
- RegionUnion(reg, reg, &(pWin->clipList));
- pDRIPriv->nrWalked++;
- }
-
- if(pDRIPriv->nrWindows == pDRIPriv->nrWalked)
- return WT_STOPWALKING;
- }
- return WT_WALKCHILDREN;
-}
-
-Bool
-DRIDestroyWindow(WindowPtr pWin)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- Bool retval = TRUE;
-
- DRIDrawablePrivDestroy(pWin);
-
- /* call lower wrapped functions */
- if(pDRIPriv->DestroyWindow) {
- /* unwrap */
- pScreen->DestroyWindow = pDRIPriv->DestroyWindow;
-
- /* call lower layers */
- retval = (*pScreen->DestroyWindow)(pWin);
-
- /* rewrap */
- pDRIPriv->DestroyWindow = pScreen->DestroyWindow;
- pScreen->DestroyWindow = DRIDestroyWindow;
- }
-
- return retval;
-}
-
-void
-DRICopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- if(!pDRIPriv) return;
-
- if(pDRIPriv->nrWindowsVisible > 0) {
- RegionRec reg;
-
- RegionNull(&reg);
- pDRIPriv->nrWalked = 0;
- TraverseTree(pWin, DRITreeTraversal, (pointer)(&reg));
-
- if(RegionNotEmpty(&reg)) {
- RegionTranslate(&reg, ptOldOrg.x - pWin->drawable.x,
- ptOldOrg.y - pWin->drawable.y);
- RegionIntersect(&reg, &reg, prgnSrc);
-
- /* The MoveBuffers interface is not ideal */
- (*pDRIPriv->pDriverInfo->MoveBuffers)(pWin, ptOldOrg, &reg,
- pDRIPriv->pDriverInfo->ddxDrawableTableEntry);
- }
-
- RegionUninit(&reg);
- }
-
- /* call lower wrapped functions */
- if(pDRIPriv->wrap.CopyWindow) {
- /* unwrap */
- pScreen->CopyWindow = pDRIPriv->wrap.CopyWindow;
-
- /* call lower layers */
- (*pScreen->CopyWindow)(pWin, ptOldOrg, prgnSrc);
-
- /* rewrap */
- pDRIPriv->wrap.CopyWindow = pScreen->CopyWindow;
- pScreen->CopyWindow = DRICopyWindow;
- }
-}
-
-static void
-DRIGetSecs(long *secs, long *usecs)
-{
- struct timeval tv;
-
- gettimeofday(&tv, NULL);
-
- *secs = tv.tv_sec;
- *usecs = tv.tv_usec;
-}
-
-static unsigned long
-DRIComputeMilliSeconds(unsigned long s_secs, unsigned long s_usecs,
- unsigned long f_secs, unsigned long f_usecs)
-{
- if (f_usecs < s_usecs) {
- --f_secs;
- f_usecs += 1000000;
- }
- return (f_secs - s_secs) * 1000 + (f_usecs - s_usecs) / 1000;
-}
-
-static void
-DRISpinLockTimeout(drmLock *lock, int val, unsigned long timeout /* in mS */)
-{
- int count = 10000;
-#if !defined(__alpha__) && !defined(__powerpc__)
- char ret;
-#else
- int ret;
-#endif
- long s_secs, s_usecs;
- long f_secs, f_usecs;
- long msecs;
- long prev = 0;
-
- DRIGetSecs(&s_secs, &s_usecs);
-
- do {
- DRM_SPINLOCK_COUNT(lock, val, count, ret);
- if (!ret) return; /* Got lock */
- DRIGetSecs(&f_secs, &f_usecs);
- msecs = DRIComputeMilliSeconds(s_secs, s_usecs, f_secs, f_usecs);
- if (msecs - prev < 250) count *= 2; /* Not more than 0.5S */
- } while (msecs < timeout);
-
- /* Didn't get lock, so take it. The worst
- that can happen is that there is some
- garbage written to the wrong part of the
- framebuffer that a refresh will repair.
- That's undesirable, but better than
- locking the server. This should be a
- very rare event. */
- DRM_SPINLOCK_TAKE(lock, val);
-}
-
-static void
-DRILockTree(ScreenPtr pScreen)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- if(!pDRIPriv) return;
-
- /* Restore the last known 3D context if the X context is hidden */
- if (pDRIPriv->pDriverInfo->driverSwapMethod == DRI_HIDE_X_CONTEXT) {
- (*pDRIPriv->pDriverInfo->SwapContext)(pScreen,
- DRI_2D_SYNC,
- DRI_NO_CONTEXT,
- NULL,
- DRI_2D_CONTEXT,
- pDRIPriv->partial3DContextStore);
- }
-
- /* Call kernel to release lock */
- DRIUnlock(pScreen);
-
- /* Grab drawable spin lock: a time out between 10 and 30 seconds is
- appropriate, since this should never time out except in the case of
- client death while the lock is being held. The timeout must be
- greater than any reasonable rendering time. */
- DRISpinLockTimeout(&pDRIPriv->pSAREA->drawable_lock, 1, 10000); /*10 secs*/
-
- /* Call kernel flush outstanding buffers and relock */
- DRILock(pScreen, DRM_LOCK_QUIESCENT|DRM_LOCK_FLUSH_ALL);
-
- /* Switch back to our 2D context if the X context is hidden */
- if (pDRIPriv->pDriverInfo->driverSwapMethod == DRI_HIDE_X_CONTEXT) {
- /* hide X context by swapping 2D component here */
- (*pDRIPriv->pDriverInfo->SwapContext)(pScreen,
- DRI_3D_SYNC,
- DRI_2D_CONTEXT,
- pDRIPriv->partial3DContextStore,
- DRI_2D_CONTEXT,
- pDRIPriv->hiddenContextStore);
- }
-}
-
-int
-DRIValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind)
-{
- ScreenPtr pScreen = pParent->drawable.pScreen;
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- int returnValue = 1; /* always return 1, not checked by dix/window.c */
-
- if(!pDRIPriv) return returnValue;
-
- /* call lower wrapped functions */
- if(pDRIPriv->wrap.ValidateTree) {
- /* unwrap */
- pScreen->ValidateTree = pDRIPriv->wrap.ValidateTree;
-
- /* call lower layers */
- returnValue = (*pScreen->ValidateTree)(pParent, pChild, kind);
-
- /* rewrap */
- pDRIPriv->wrap.ValidateTree = pScreen->ValidateTree;
- pScreen->ValidateTree = DRIValidateTree;
- }
-
- return returnValue;
-}
-
-void
-DRIPostValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind)
-{
- ScreenPtr pScreen;
- DRIScreenPrivPtr pDRIPriv;
-
- if (pParent) {
- pScreen = pParent->drawable.pScreen;
- } else {
- pScreen = pChild->drawable.pScreen;
- }
- if(!(pDRIPriv = DRI_SCREEN_PRIV(pScreen))) return;
-
- if (pDRIPriv->wrap.PostValidateTree) {
- /* unwrap */
- pScreen->PostValidateTree = pDRIPriv->wrap.PostValidateTree;
-
- /* call lower layers */
- (*pScreen->PostValidateTree)(pParent, pChild, kind);
-
- /* rewrap */
- pDRIPriv->wrap.PostValidateTree = pScreen->PostValidateTree;
- pScreen->PostValidateTree = DRIPostValidateTree;
- }
-}
-
-void
-DRIClipNotify(WindowPtr pWin, int dx, int dy)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- DRIDrawablePrivPtr pDRIDrawablePriv;
-
- if(!pDRIPriv) return;
-
- if ((pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin))) {
- int nrects = RegionNumRects(&pWin->clipList);
-
- if(!pDRIPriv->windowsTouched) {
- DRILockTree(pScreen);
- pDRIPriv->windowsTouched = TRUE;
- }
-
- if (nrects && !pDRIDrawablePriv->nrects)
- DRIIncreaseNumberVisible(pScreen);
- else if (!nrects && pDRIDrawablePriv->nrects)
- DRIDecreaseNumberVisible(pScreen);
- else
- DRIDriverClipNotify(pScreen);
-
- pDRIDrawablePriv->nrects = nrects;
-
- pDRIPriv->pSAREA->drawableTable[pDRIDrawablePriv->drawableIndex].stamp
- = DRIDrawableValidationStamp++;
-
- drmUpdateDrawableInfo(pDRIPriv->drmFD, pDRIDrawablePriv->hwDrawable,
- DRM_DRAWABLE_CLIPRECTS,
- nrects, RegionRects(&pWin->clipList));
- }
-
- /* call lower wrapped functions */
- if(pDRIPriv->wrap.ClipNotify) {
-
- /* unwrap */
- pScreen->ClipNotify = pDRIPriv->wrap.ClipNotify;
-
- /* call lower layers */
- (*pScreen->ClipNotify)(pWin, dx, dy);
-
- /* rewrap */
- pDRIPriv->wrap.ClipNotify = pScreen->ClipNotify;
- pScreen->ClipNotify = DRIClipNotify;
- }
-}
-
-CARD32
-DRIGetDrawableIndex(WindowPtr pWin)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- DRIDrawablePrivPtr pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
- CARD32 index;
-
- if (pDRIDrawablePriv) {
- index = pDRIDrawablePriv->drawableIndex;
- }
- else {
- index = pDRIPriv->pDriverInfo->ddxDrawableTableEntry;
- }
-
- return index;
-}
-
-unsigned int
-DRIGetDrawableStamp(ScreenPtr pScreen, CARD32 drawable_index)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- return pDRIPriv->pSAREA->drawableTable[drawable_index].stamp;
-}
-
-
-void
-DRIPrintDrawableLock(ScreenPtr pScreen, char *msg)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- ErrorF("%s: %d\n", msg, pDRIPriv->pSAREA->drawable_lock.lock);
-}
-
-void
-DRILock(ScreenPtr pScreen, int flags)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- if(!pDRIPriv || !pDRIPriv->pLockRefCount) return;
-
- if (!*pDRIPriv->pLockRefCount) {
- DRM_LOCK(pDRIPriv->drmFD, pDRIPriv->pLSAREA, pDRIPriv->myContext, flags);
- *pDRIPriv->pLockingContext = pDRIPriv->myContext;
- } else if (*pDRIPriv->pLockingContext != pDRIPriv->myContext) {
- DRIDrvMsg(pScreen->myNum, X_ERROR,
- "[DRI] Locking deadlock.\n"
- "\tAlready locked with context %d,\n"
- "\ttrying to lock with context %d.\n",
- pDRIPriv->pLockingContext,
- pDRIPriv->myContext);
- }
- (*pDRIPriv->pLockRefCount)++;
-}
-
-void
-DRIUnlock(ScreenPtr pScreen)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- if(!pDRIPriv || !pDRIPriv->pLockRefCount) return;
-
- if (*pDRIPriv->pLockRefCount > 0) {
- if (pDRIPriv->myContext != *pDRIPriv->pLockingContext) {
- DRIDrvMsg(pScreen->myNum, X_ERROR,
- "[DRI] Unlocking inconsistency:\n"
- "\tContext %d trying to unlock lock held by context %d\n",
- pDRIPriv->pLockingContext,
- pDRIPriv->myContext);
- }
- (*pDRIPriv->pLockRefCount)--;
- } else {
- DRIDrvMsg(pScreen->myNum, X_ERROR,
- "DRIUnlock called when not locked.\n");
- return;
- }
- if (! *pDRIPriv->pLockRefCount)
- DRM_UNLOCK(pDRIPriv->drmFD, pDRIPriv->pLSAREA, pDRIPriv->myContext);
-}
-
-void *
-DRIGetSAREAPrivate(ScreenPtr pScreen)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- if (!pDRIPriv) return 0;
-
- return (void *)(((char*)pDRIPriv->pSAREA)+sizeof(XF86DRISAREARec));
-}
-
-drm_context_t
-DRIGetContext(ScreenPtr pScreen)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- if (!pDRIPriv) return 0;
-
- return pDRIPriv->myContext;
-}
-
-void
-DRIGetTexOffsetFuncs(ScreenPtr pScreen,
- DRITexOffsetStartProcPtr *texOffsetStartFunc,
- DRITexOffsetFinishProcPtr *texOffsetFinishFunc)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- if (!pDRIPriv) return;
-
- *texOffsetStartFunc = pDRIPriv->pDriverInfo->texOffsetStart;
- *texOffsetFinishFunc = pDRIPriv->pDriverInfo->texOffsetFinish;
-}
-
-/* This lets get at the unwrapped functions so that they can correctly
- * call the lowerlevel functions, and choose whether they will be
- * called at every level of recursion (eg in validatetree).
- */
-DRIWrappedFuncsRec *
-DRIGetWrappedFuncs(ScreenPtr pScreen)
-{
- return &(DRI_SCREEN_PRIV(pScreen)->wrap);
-}
-
-/* note that this returns the library version, not the protocol version */
-void
-DRIQueryVersion(int *majorVersion,
- int *minorVersion,
- int *patchVersion)
-{
- *majorVersion = DRIINFO_MAJOR_VERSION;
- *minorVersion = DRIINFO_MINOR_VERSION;
- *patchVersion = DRIINFO_PATCH_VERSION;
-}
-
-static void
-_DRIAdjustFrame(ScrnInfoPtr pScrn, DRIScreenPrivPtr pDRIPriv, int x, int y)
-{
- pDRIPriv->pSAREA->frame.x = x;
- pDRIPriv->pSAREA->frame.y = y;
- pDRIPriv->pSAREA->frame.width = pScrn->frameX1 - x + 1;
- pDRIPriv->pSAREA->frame.height = pScrn->frameY1 - y + 1;
-}
-
-void
-DRIAdjustFrame(int scrnIndex, int x, int y, int flags)
-{
- ScreenPtr pScreen = screenInfo.screens[scrnIndex];
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- int px, py;
-
- if (!pDRIPriv || !pDRIPriv->pSAREA) {
- DRIDrvMsg(scrnIndex, X_ERROR, "[DRI] No SAREA (%p %p)\n",
- pDRIPriv, pDRIPriv ? pDRIPriv->pSAREA : NULL);
- return;
- }
-
- if (pDRIPriv->fullscreen) {
- /* Fix up frame */
- pScrn->frameX0 = pDRIPriv->pSAREA->frame.x;
- pScrn->frameY0 = pDRIPriv->pSAREA->frame.y;
- pScrn->frameX1 = pScrn->frameX0 + pDRIPriv->pSAREA->frame.width - 1;
- pScrn->frameY1 = pScrn->frameY0 + pDRIPriv->pSAREA->frame.height - 1;
-
- /* Fix up cursor */
- miPointerGetPosition(inputInfo.pointer, &px, &py);
- if (px < pScrn->frameX0) px = pScrn->frameX0;
- if (px > pScrn->frameX1) px = pScrn->frameX1;
- if (py < pScrn->frameY0) py = pScrn->frameY0;
- if (py > pScrn->frameY1) py = pScrn->frameY1;
- pScreen->SetCursorPosition(inputInfo.pointer, pScreen, px, py, TRUE);
- return;
- }
-
- if (pDRIPriv->wrap.AdjustFrame) {
- /* unwrap */
- pScrn->AdjustFrame = pDRIPriv->wrap.AdjustFrame;
- /* call lower layers */
- (*pScrn->AdjustFrame)(scrnIndex, x, y, flags);
- /* rewrap */
- pDRIPriv->wrap.AdjustFrame = pScrn->AdjustFrame;
- pScrn->AdjustFrame = DRIAdjustFrame;
- }
-
- _DRIAdjustFrame(pScrn, pDRIPriv, x, y);
-}
-
-/*
- * DRIMoveBuffersHelper swaps the regions rects in place leaving you
- * a region with the rects in the order that you need to blit them,
- * but it is possibly (likely) an invalid region afterwards. If you
- * need to use the region again for anything you have to call
- * REGION_VALIDATE on it, or better yet, save a copy first.
- */
-
-void
-DRIMoveBuffersHelper(
- ScreenPtr pScreen,
- int dx,
- int dy,
- int *xdir,
- int *ydir,
- RegionPtr reg
-)
-{
- BoxPtr extents, pbox, firstBox, lastBox;
- BoxRec tmpBox;
- int y, nbox;
-
- extents = RegionExtents(reg);
- nbox = RegionNumRects(reg);
- pbox = RegionRects(reg);
-
- if((dy > 0) && (dy < (extents->y2 - extents->y1))) {
- *ydir = -1;
- if(nbox > 1) {
- firstBox = pbox;
- lastBox = pbox + nbox - 1;
- while((unsigned long)firstBox < (unsigned long)lastBox) {
- tmpBox = *firstBox;
- *firstBox = *lastBox;
- *lastBox = tmpBox;
- firstBox++;
- lastBox--;
- }
- }
- } else *ydir = 1;
-
- if((dx > 0) && (dx < (extents->x2 - extents->x1))) {
- *xdir = -1;
- if(nbox > 1) {
- firstBox = lastBox = pbox;
- y = pbox->y1;
- while(--nbox) {
- pbox++;
- if(pbox->y1 == y) lastBox++;
- else {
- while((unsigned long)firstBox < (unsigned long)lastBox) {
- tmpBox = *firstBox;
- *firstBox = *lastBox;
- *lastBox = tmpBox;
- firstBox++;
- lastBox--;
- }
-
- firstBox = lastBox = pbox;
- y = pbox->y1;
- }
- }
- while((unsigned long)firstBox < (unsigned long)lastBox) {
- tmpBox = *firstBox;
- *firstBox = *lastBox;
- *lastBox = tmpBox;
- firstBox++;
- lastBox--;
- }
- }
- } else *xdir = 1;
-
-}
-
-char *
-DRICreatePCIBusID(const struct pci_device * dev)
-{
- char *busID;
-
- if (asprintf(&busID, "pci:%04x:%02x:%02x.%d",
- dev->domain, dev->bus, dev->dev, dev->func) == -1)
- return NULL;
-
- return busID;
-}
-
-static void drmSIGIOHandler(int interrupt, void *closure)
-{
- unsigned long key;
- void *value;
- ssize_t count;
- drm_ctx_t ctx;
- typedef void (*_drmCallback)(int, void *, void *);
- char buf[256];
- drm_context_t old;
- drm_context_t new;
- void *oldctx;
- void *newctx;
- char *pt;
- drmHashEntry *entry;
- void *hash_table;
-
- hash_table = drmGetHashTable();
-
- if (!hash_table) return;
- if (drmHashFirst(hash_table, &key, &value)) {
- entry = value;
- do {
-#if 0
- fprintf(stderr, "Trying %d\n", entry->fd);
-#endif
- if ((count = read(entry->fd, buf, sizeof(buf) - 1)) > 0) {
- buf[count] = '\0';
-#if 0
- fprintf(stderr, "Got %s\n", buf);
-#endif
-
- for (pt = buf; *pt != ' '; ++pt); /* Find first space */
- ++pt;
- old = strtol(pt, &pt, 0);
- new = strtol(pt, NULL, 0);
- oldctx = drmGetContextTag(entry->fd, old);
- newctx = drmGetContextTag(entry->fd, new);
-#if 0
- fprintf(stderr, "%d %d %p %p\n", old, new, oldctx, newctx);
-#endif
- ((_drmCallback)entry->f)(entry->fd, oldctx, newctx);
- ctx.handle = new;
- ioctl(entry->fd, DRM_IOCTL_NEW_CTX, &ctx);
- }
- } while (drmHashNext(hash_table, &key, &value));
- }
-}
-
-
-int drmInstallSIGIOHandler(int fd, void (*f)(int, void *, void *))
-{
- drmHashEntry *entry;
-
- entry = drmGetEntry(fd);
- entry->f = f;
-
- return xf86InstallSIGIOHandler(fd, drmSIGIOHandler, 0);
-}
-
-int drmRemoveSIGIOHandler(int fd)
-{
- drmHashEntry *entry = drmGetEntry(fd);
-
- entry->f = NULL;
-
- return xf86RemoveSIGIOHandler(fd);
-}
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright 2000 VA Linux Systems, 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, 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.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Jens Owen <jens@tungstengraphics.com>
+ * Rickard E. (Rik) Faith <faith@valinux.com>
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#include <sys/time.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdio.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "xf86drm.h"
+#include "misc.h"
+#include "dixstruct.h"
+#include "extnsionst.h"
+#include "colormapst.h"
+#include "cursorstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "servermd.h"
+#define _XF86DRI_SERVER_
+#include <X11/dri/xf86driproto.h>
+#include "swaprep.h"
+#include "xf86str.h"
+#include "dri.h"
+#include "sarea.h"
+#include "dristruct.h"
+#include "mi.h"
+#include "mipointer.h"
+#include "xf86_OSproc.h"
+#include "inputstr.h"
+#include "xf86VGAarbiter.h"
+
+static int DRIEntPrivIndex = -1;
+static DevPrivateKeyRec DRIScreenPrivKeyRec;
+#define DRIScreenPrivKey (&DRIScreenPrivKeyRec)
+static DevPrivateKeyRec DRIWindowPrivKeyRec;
+#define DRIWindowPrivKey (&DRIWindowPrivKeyRec)
+static unsigned long DRIGeneration = 0;
+static unsigned int DRIDrawableValidationStamp = 0;
+
+static RESTYPE DRIDrawablePrivResType;
+static RESTYPE DRIContextPrivResType;
+static void DRIDestroyDummyContext(ScreenPtr pScreen, Bool hasCtxPriv);
+
+drmServerInfo DRIDRMServerInfo;
+
+ /* Wrapper just like xf86DrvMsg, but
+ without the verbosity level checking.
+ This will make it easy to turn off some
+ messages later, based on verbosity
+ level. */
+
+/*
+ * Since we're already referencing things from the XFree86 common layer in
+ * this file, we'd might as well just call xf86VDrvMsgVerb, and have
+ * consistent message formatting. The verbosity of these messages can be
+ * easily changed here.
+ */
+#define DRI_MSG_VERBOSITY 1
+static void
+DRIDrvMsg(int scrnIndex, MessageType type, const char *format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ xf86VDrvMsgVerb(scrnIndex, type, DRI_MSG_VERBOSITY, format, ap);
+ va_end(ap);
+}
+
+
+static void
+DRIOpenDRMCleanup(DRIEntPrivPtr pDRIEntPriv)
+{
+ if (pDRIEntPriv->pLSAREA != NULL) {
+ drmUnmap(pDRIEntPriv->pLSAREA, pDRIEntPriv->sAreaSize);
+ pDRIEntPriv->pLSAREA = NULL;
+ }
+ if (pDRIEntPriv->hLSAREA != 0) {
+ drmRmMap(pDRIEntPriv->drmFD, pDRIEntPriv->hLSAREA);
+ }
+ if (pDRIEntPriv->drmFD >= 0) {
+ drmClose(pDRIEntPriv->drmFD);
+ pDRIEntPriv->drmFD = 0;
+ }
+}
+
+int
+DRIMasterFD(ScrnInfoPtr pScrn)
+{
+ return DRI_ENT_PRIV(pScrn)->drmFD;
+}
+
+void *
+DRIMasterSareaPointer(ScrnInfoPtr pScrn)
+{
+ return DRI_ENT_PRIV(pScrn)->pLSAREA;
+}
+
+drm_handle_t
+DRIMasterSareaHandle(ScrnInfoPtr pScrn)
+{
+ return DRI_ENT_PRIV(pScrn)->hLSAREA;
+}
+
+
+Bool
+DRIOpenDRMMaster(ScrnInfoPtr pScrn,
+ unsigned long sAreaSize,
+ const char *busID,
+ const char *drmDriverName)
+{
+ drmSetVersion saveSv, sv;
+ Bool drmWasAvailable;
+ DRIEntPrivPtr pDRIEntPriv;
+ DRIEntPrivRec tmp;
+ drmVersionPtr drmlibv;
+ int drmlibmajor, drmlibminor;
+ const char *openBusID;
+ int count;
+ int err;
+
+ if (DRIEntPrivIndex == -1)
+ DRIEntPrivIndex = xf86AllocateEntityPrivateIndex();
+
+ pDRIEntPriv = DRI_ENT_PRIV(pScrn);
+
+ if (pDRIEntPriv && pDRIEntPriv->drmFD != -1)
+ return TRUE;
+
+ drmWasAvailable = drmAvailable();
+
+ memset(&tmp, 0, sizeof(tmp));
+
+ /* Check the DRM lib version.
+ * drmGetLibVersion was not supported in version 1.0, so check for
+ * symbol first to avoid possible crash or hang.
+ */
+
+ drmlibmajor = 1;
+ drmlibminor = 0;
+ if (xf86LoaderCheckSymbol("drmGetLibVersion")) {
+ drmlibv = drmGetLibVersion(-1);
+ if (drmlibv != NULL) {
+ drmlibmajor = drmlibv->version_major;
+ drmlibminor = drmlibv->version_minor;
+ drmFreeVersion(drmlibv);
+ }
+ }
+
+ /* Check if the libdrm can handle falling back to loading based on name
+ * if a busid string is passed.
+ */
+ openBusID = (drmlibmajor == 1 && drmlibminor >= 2) ? busID : NULL;
+
+ tmp.drmFD = -1;
+ sv.drm_di_major = 1;
+ sv.drm_di_minor = 1;
+ sv.drm_dd_major = -1;
+
+ saveSv = sv;
+ count = 10;
+ while (count--) {
+ tmp.drmFD = drmOpen(drmDriverName, openBusID);
+
+ if (tmp.drmFD < 0) {
+ DRIDrvMsg(-1, X_ERROR, "[drm] drmOpen failed.\n");
+ goto out_err;
+ }
+
+ err = drmSetInterfaceVersion(tmp.drmFD, &sv);
+
+ if (err != -EPERM)
+ break;
+
+ sv = saveSv;
+ drmClose(tmp.drmFD);
+ tmp.drmFD = -1;
+ usleep(100000);
+ }
+
+ if (tmp.drmFD <= 0) {
+ DRIDrvMsg(-1, X_ERROR, "[drm] DRM was busy with another master.\n");
+ goto out_err;
+ }
+
+ if (!drmWasAvailable) {
+ DRIDrvMsg(-1, X_INFO,
+ "[drm] loaded kernel module for \"%s\" driver.\n",
+ drmDriverName);
+ }
+
+ if (err != 0) {
+ sv.drm_di_major = 1;
+ sv.drm_di_minor = 0;
+ }
+
+ DRIDrvMsg(-1, X_INFO, "[drm] DRM interface version %d.%d\n",
+ sv.drm_di_major, sv.drm_di_minor);
+
+ if (sv.drm_di_major == 1 && sv.drm_di_minor >= 1)
+ err = 0;
+ else
+ err = drmSetBusid(tmp.drmFD, busID);
+
+ if (err) {
+ DRIDrvMsg(-1, X_ERROR, "[drm] Could not set DRM device bus ID.\n");
+ goto out_err;
+ }
+
+ /*
+ * Create a lock-containing sarea.
+ */
+
+ if (drmAddMap( tmp.drmFD, 0, sAreaSize, DRM_SHM,
+ DRM_CONTAINS_LOCK, &tmp.hLSAREA) < 0) {
+ DRIDrvMsg(-1, X_INFO, "[drm] Could not create SAREA for DRM lock.\n");
+ tmp.hLSAREA = 0;
+ goto out_err;
+ }
+
+ if (drmMap( tmp.drmFD, tmp.hLSAREA, sAreaSize,
+ (drmAddressPtr)(&tmp.pLSAREA)) < 0) {
+ DRIDrvMsg(-1, X_INFO, "[drm] Mapping SAREA for DRM lock failed.\n");
+ tmp.pLSAREA = NULL;
+ goto out_err;
+ }
+
+ memset(tmp.pLSAREA, 0, sAreaSize);
+
+ /*
+ * Reserved contexts are handled by the first opened screen.
+ */
+
+ tmp.resOwner = NULL;
+
+ if (!pDRIEntPriv)
+ pDRIEntPriv = xnfcalloc(sizeof(*pDRIEntPriv), 1);
+
+ if (!pDRIEntPriv) {
+ DRIDrvMsg(-1, X_INFO, "[drm] Failed to allocate memory for "
+ "DRM device.\n");
+ goto out_err;
+ }
+ *pDRIEntPriv = tmp;
+ xf86GetEntityPrivate((pScrn)->entityList[0],DRIEntPrivIndex)->ptr =
+ pDRIEntPriv;
+
+ DRIDrvMsg(-1, X_INFO, "[drm] DRM open master succeeded.\n");
+ return TRUE;
+
+ out_err:
+
+ DRIOpenDRMCleanup(&tmp);
+ return FALSE;
+}
+
+static void
+DRIClipNotifyAllDrawables(ScreenPtr pScreen);
+
+static void
+dri_crtc_notify(ScreenPtr pScreen)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ DRIClipNotifyAllDrawables(pScreen);
+ xf86_unwrap_crtc_notify(pScreen, pDRIPriv->xf86_crtc_notify);
+ xf86_crtc_notify(pScreen);
+ pDRIPriv->xf86_crtc_notify = xf86_wrap_crtc_notify(pScreen, dri_crtc_notify);
+}
+
+Bool
+DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD)
+{
+ DRIScreenPrivPtr pDRIPriv;
+ drm_context_t * reserved;
+ int reserved_count;
+ int i;
+ DRIEntPrivPtr pDRIEntPriv;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ DRIContextFlags flags = 0;
+ DRIContextPrivPtr pDRIContextPriv;
+
+ /* If the DRI extension is disabled, do not initialize the DRI */
+ if (noXFree86DRIExtension) {
+ DRIDrvMsg(pScreen->myNum, X_WARNING,
+ "Direct rendering has been disabled.\n");
+ return FALSE;
+ }
+
+ if (!xf86VGAarbiterAllowDRI(pScreen)) {
+ DRIDrvMsg(pScreen->myNum, X_WARNING,
+ "Direct rendering is not supported when VGA arb is necessary for the device\n");
+ return FALSE;
+ }
+
+#ifdef PANORAMIX
+ /*
+ * If Xinerama is on, don't allow DRI to initialise. It won't be usable
+ * anyway.
+ */
+ if (!noPanoramiXExtension) {
+ DRIDrvMsg(pScreen->myNum, X_WARNING,
+ "Direct rendering is not supported when Xinerama is enabled\n");
+ return FALSE;
+ }
+#endif
+
+ if (!DRIOpenDRMMaster(pScrn, pDRIInfo->SAREASize,
+ pDRIInfo->busIdString,
+ pDRIInfo->drmDriverName))
+ return FALSE;
+
+ pDRIEntPriv = DRI_ENT_PRIV(pScrn);
+
+ if (DRIGeneration != serverGeneration)
+ DRIGeneration = serverGeneration;
+
+ if (!dixRegisterPrivateKey(&DRIScreenPrivKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+ if (!dixRegisterPrivateKey(&DRIWindowPrivKeyRec, PRIVATE_WINDOW, 0))
+ return FALSE;
+
+ pDRIPriv = (DRIScreenPrivPtr) calloc(1, sizeof(DRIScreenPrivRec));
+ if (!pDRIPriv) {
+ dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
+ return FALSE;
+ }
+
+ dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, pDRIPriv);
+ pDRIPriv->drmFD = pDRIEntPriv->drmFD;
+ pDRIPriv->directRenderingSupport = TRUE;
+ pDRIPriv->pDriverInfo = pDRIInfo;
+ pDRIPriv->nrWindows = 0;
+ pDRIPriv->nrWindowsVisible = 0;
+ pDRIPriv->fullscreen = NULL;
+
+ pDRIPriv->createDummyCtx = pDRIInfo->createDummyCtx;
+ pDRIPriv->createDummyCtxPriv = pDRIInfo->createDummyCtxPriv;
+
+ pDRIPriv->grabbedDRILock = FALSE;
+ pDRIPriv->drmSIGIOHandlerInstalled = FALSE;
+ *pDRMFD = pDRIPriv->drmFD;
+
+ if (pDRIEntPriv->sAreaGrabbed || pDRIInfo->allocSarea) {
+
+ if (drmAddMap( pDRIPriv->drmFD,
+ 0,
+ pDRIPriv->pDriverInfo->SAREASize,
+ DRM_SHM,
+ 0,
+ &pDRIPriv->hSAREA) < 0)
+ {
+ pDRIPriv->directRenderingSupport = FALSE;
+ dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
+ drmClose(pDRIPriv->drmFD);
+ DRIDrvMsg(pScreen->myNum, X_INFO,
+ "[drm] drmAddMap failed\n");
+ return FALSE;
+ }
+ DRIDrvMsg(pScreen->myNum, X_INFO,
+ "[drm] added %d byte SAREA at %p\n",
+ pDRIPriv->pDriverInfo->SAREASize, pDRIPriv->hSAREA);
+
+ /* Backwards compat. */
+ if (drmMap( pDRIPriv->drmFD,
+ pDRIPriv->hSAREA,
+ pDRIPriv->pDriverInfo->SAREASize,
+ (drmAddressPtr)(&pDRIPriv->pSAREA)) < 0)
+ {
+ pDRIPriv->directRenderingSupport = FALSE;
+ dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
+ drmClose(pDRIPriv->drmFD);
+ DRIDrvMsg(pScreen->myNum, X_INFO,
+ "[drm] drmMap failed\n");
+ return FALSE;
+ }
+ DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] mapped SAREA %p to %p\n",
+ pDRIPriv->hSAREA, pDRIPriv->pSAREA);
+ memset(pDRIPriv->pSAREA, 0, pDRIPriv->pDriverInfo->SAREASize);
+ } else {
+ DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] Using the DRM lock "
+ "SAREA also for drawables.\n");
+ pDRIPriv->hSAREA = pDRIEntPriv->hLSAREA;
+ pDRIPriv->pSAREA = (XF86DRISAREAPtr) pDRIEntPriv->pLSAREA;
+ pDRIEntPriv->sAreaGrabbed = TRUE;
+ }
+
+ pDRIPriv->hLSAREA = pDRIEntPriv->hLSAREA;
+ pDRIPriv->pLSAREA = pDRIEntPriv->pLSAREA;
+
+ if (!pDRIPriv->pDriverInfo->dontMapFrameBuffer)
+ {
+ if (drmAddMap( pDRIPriv->drmFD,
+ (uintptr_t)pDRIPriv->pDriverInfo->frameBufferPhysicalAddress,
+ pDRIPriv->pDriverInfo->frameBufferSize,
+ DRM_FRAME_BUFFER,
+ 0,
+ &pDRIPriv->pDriverInfo->hFrameBuffer) < 0)
+ {
+ pDRIPriv->directRenderingSupport = FALSE;
+ dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
+ drmUnmap(pDRIPriv->pSAREA, pDRIPriv->pDriverInfo->SAREASize);
+ drmClose(pDRIPriv->drmFD);
+ DRIDrvMsg(pScreen->myNum, X_INFO,
+ "[drm] drmAddMap failed\n");
+ return FALSE;
+ }
+ DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] framebuffer handle = %p\n",
+ pDRIPriv->pDriverInfo->hFrameBuffer);
+ } else {
+ DRIDrvMsg(pScreen->myNum, X_INFO,
+ "[drm] framebuffer mapped by ddx driver\n");
+ }
+
+ if (pDRIEntPriv->resOwner == NULL) {
+ pDRIEntPriv->resOwner = pScreen;
+
+ /* Add tags for reserved contexts */
+ if ((reserved = drmGetReservedContextList(pDRIPriv->drmFD,
+ &reserved_count))) {
+ int i;
+ void *tag;
+
+ for (i = 0; i < reserved_count; i++) {
+ tag = DRICreateContextPrivFromHandle(pScreen,
+ reserved[i],
+ DRI_CONTEXT_RESERVED);
+ drmAddContextTag(pDRIPriv->drmFD, reserved[i], tag);
+ }
+ drmFreeReservedContextList(reserved);
+ DRIDrvMsg(pScreen->myNum, X_INFO,
+ "[drm] added %d reserved context%s for kernel\n",
+ reserved_count, reserved_count > 1 ? "s" : "");
+ }
+ }
+
+ /* validate max drawable table entry set by driver */
+ if ((pDRIPriv->pDriverInfo->maxDrawableTableEntry <= 0) ||
+ (pDRIPriv->pDriverInfo->maxDrawableTableEntry > SAREA_MAX_DRAWABLES)) {
+ DRIDrvMsg(pScreen->myNum, X_ERROR,
+ "Invalid max drawable table size set by driver: %d\n",
+ pDRIPriv->pDriverInfo->maxDrawableTableEntry);
+ }
+
+ /* Initialize drawable tables (screen private and SAREA) */
+ for( i=0; i < pDRIPriv->pDriverInfo->maxDrawableTableEntry; i++) {
+ pDRIPriv->DRIDrawables[i] = NULL;
+ pDRIPriv->pSAREA->drawableTable[i].stamp = 0;
+ pDRIPriv->pSAREA->drawableTable[i].flags = 0;
+ }
+
+ pDRIPriv->pLockRefCount = &pDRIEntPriv->lockRefCount;
+ pDRIPriv->pLockingContext = &pDRIEntPriv->lockingContext;
+
+ if (!pDRIEntPriv->keepFDOpen)
+ pDRIEntPriv->keepFDOpen = pDRIInfo->keepFDOpen;
+
+ pDRIEntPriv->refCount++;
+
+ /* Set up flags for DRICreateContextPriv */
+ switch (pDRIInfo->driverSwapMethod) {
+ case DRI_KERNEL_SWAP:
+ flags = DRI_CONTEXT_2DONLY;
+ break;
+ case DRI_HIDE_X_CONTEXT:
+ flags = DRI_CONTEXT_PRESERVED;
+ break;
+ }
+
+ if (!(pDRIContextPriv = DRICreateContextPriv(pScreen,
+ &pDRIPriv->myContext,
+ flags))) {
+ DRIDrvMsg(pScreen->myNum, X_ERROR,
+ "failed to create server context\n");
+ return FALSE;
+ }
+ pDRIPriv->myContextPriv = pDRIContextPriv;
+
+ DRIDrvMsg(pScreen->myNum, X_INFO,
+ "X context handle = %p\n", pDRIPriv->myContext);
+
+ /* Now that we have created the X server's context, we can grab the
+ * hardware lock for the X server.
+ */
+ DRILock(pScreen, 0);
+ pDRIPriv->grabbedDRILock = TRUE;
+
+ /* pointers so that we can prevent memory leaks later */
+ pDRIPriv->hiddenContextStore = NULL;
+ pDRIPriv->partial3DContextStore = NULL;
+
+ switch(pDRIInfo->driverSwapMethod) {
+ case DRI_HIDE_X_CONTEXT:
+ /* Server will handle 3D swaps, and hide 2D swaps from kernel.
+ * Register server context as a preserved context.
+ */
+
+ /* allocate memory for hidden context store */
+ pDRIPriv->hiddenContextStore
+ = (void *)calloc(1, pDRIInfo->contextSize);
+ if (!pDRIPriv->hiddenContextStore) {
+ DRIDrvMsg(pScreen->myNum, X_ERROR,
+ "failed to allocate hidden context\n");
+ DRIDestroyContextPriv(pDRIContextPriv);
+ return FALSE;
+ }
+
+ /* allocate memory for partial 3D context store */
+ pDRIPriv->partial3DContextStore
+ = (void *)calloc(1, pDRIInfo->contextSize);
+ if (!pDRIPriv->partial3DContextStore) {
+ DRIDrvMsg(pScreen->myNum, X_ERROR,
+ "[DRI] failed to allocate partial 3D context\n");
+ free(pDRIPriv->hiddenContextStore);
+ DRIDestroyContextPriv(pDRIContextPriv);
+ return FALSE;
+ }
+
+ /* save initial context store */
+ if (pDRIInfo->SwapContext) {
+ (*pDRIInfo->SwapContext)(
+ pScreen,
+ DRI_NO_SYNC,
+ DRI_2D_CONTEXT,
+ pDRIPriv->hiddenContextStore,
+ DRI_NO_CONTEXT,
+ NULL);
+ }
+ /* fall through */
+
+ case DRI_SERVER_SWAP:
+ /* For swap methods of DRI_SERVER_SWAP and DRI_HIDE_X_CONTEXT
+ * setup signal handler for receiving swap requests from kernel
+ */
+ if (!(pDRIPriv->drmSIGIOHandlerInstalled =
+ drmInstallSIGIOHandler(pDRIPriv->drmFD, DRISwapContext))) {
+ DRIDrvMsg(pScreen->myNum, X_ERROR,
+ "[drm] failed to setup DRM signal handler\n");
+ free(pDRIPriv->hiddenContextStore);
+ free(pDRIPriv->partial3DContextStore);
+ DRIDestroyContextPriv(pDRIContextPriv);
+ return FALSE;
+ } else {
+ DRIDrvMsg(pScreen->myNum, X_INFO,
+ "[drm] installed DRM signal handler\n");
+ }
+
+ default:
+ break;
+ }
+
+ return TRUE;
+}
+
+Bool
+DRIFinishScreenInit(ScreenPtr pScreen)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo;
+
+ /* Wrap DRI support */
+ if (pDRIInfo->wrap.ValidateTree) {
+ pDRIPriv->wrap.ValidateTree = pScreen->ValidateTree;
+ pScreen->ValidateTree = pDRIInfo->wrap.ValidateTree;
+ }
+ if (pDRIInfo->wrap.PostValidateTree) {
+ pDRIPriv->wrap.PostValidateTree = pScreen->PostValidateTree;
+ pScreen->PostValidateTree = pDRIInfo->wrap.PostValidateTree;
+ }
+ if (pDRIInfo->wrap.WindowExposures) {
+ pDRIPriv->wrap.WindowExposures = pScreen->WindowExposures;
+ pScreen->WindowExposures = pDRIInfo->wrap.WindowExposures;
+ }
+
+ pDRIPriv->DestroyWindow = pScreen->DestroyWindow;
+ pScreen->DestroyWindow = DRIDestroyWindow;
+
+ pDRIPriv->xf86_crtc_notify = xf86_wrap_crtc_notify(pScreen,
+ dri_crtc_notify);
+
+ if (pDRIInfo->wrap.CopyWindow) {
+ pDRIPriv->wrap.CopyWindow = pScreen->CopyWindow;
+ pScreen->CopyWindow = pDRIInfo->wrap.CopyWindow;
+ }
+ if (pDRIInfo->wrap.ClipNotify) {
+ pDRIPriv->wrap.ClipNotify = pScreen->ClipNotify;
+ pScreen->ClipNotify = pDRIInfo->wrap.ClipNotify;
+ }
+ if (pDRIInfo->wrap.AdjustFrame) {
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ pDRIPriv->wrap.AdjustFrame = pScrn->AdjustFrame;
+ pScrn->AdjustFrame = pDRIInfo->wrap.AdjustFrame;
+ }
+ pDRIPriv->wrapped = TRUE;
+
+ DRIDrvMsg(pScreen->myNum, X_INFO, "[DRI] installation complete\n");
+
+ return TRUE;
+}
+
+void
+DRICloseScreen(ScreenPtr pScreen)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ DRIInfoPtr pDRIInfo;
+ drm_context_t * reserved;
+ int reserved_count;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ DRIEntPrivPtr pDRIEntPriv = DRI_ENT_PRIV(pScrn);
+ Bool closeMaster;
+
+ if (pDRIPriv) {
+
+ pDRIInfo = pDRIPriv->pDriverInfo;
+
+ if (pDRIPriv->wrapped) {
+ /* Unwrap DRI Functions */
+ if (pDRIInfo->wrap.ValidateTree) {
+ pScreen->ValidateTree = pDRIPriv->wrap.ValidateTree;
+ pDRIPriv->wrap.ValidateTree = NULL;
+ }
+ if (pDRIInfo->wrap.PostValidateTree) {
+ pScreen->PostValidateTree = pDRIPriv->wrap.PostValidateTree;
+ pDRIPriv->wrap.PostValidateTree = NULL;
+ }
+ if (pDRIInfo->wrap.WindowExposures) {
+ pScreen->WindowExposures = pDRIPriv->wrap.WindowExposures;
+ pDRIPriv->wrap.WindowExposures = NULL;
+ }
+ if (pDRIPriv->DestroyWindow) {
+ pScreen->DestroyWindow = pDRIPriv->DestroyWindow;
+ pDRIPriv->DestroyWindow = NULL;
+ }
+
+ xf86_unwrap_crtc_notify(pScreen, pDRIPriv->xf86_crtc_notify);
+
+ if (pDRIInfo->wrap.CopyWindow) {
+ pScreen->CopyWindow = pDRIPriv->wrap.CopyWindow;
+ pDRIPriv->wrap.CopyWindow = NULL;
+ }
+ if (pDRIInfo->wrap.ClipNotify) {
+ pScreen->ClipNotify = pDRIPriv->wrap.ClipNotify;
+ pDRIPriv->wrap.ClipNotify = NULL;
+ }
+ if (pDRIInfo->wrap.AdjustFrame) {
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ pScrn->AdjustFrame = pDRIPriv->wrap.AdjustFrame;
+ pDRIPriv->wrap.AdjustFrame = NULL;
+ }
+
+ pDRIPriv->wrapped = FALSE;
+ }
+
+ if (pDRIPriv->drmSIGIOHandlerInstalled) {
+ if (!drmRemoveSIGIOHandler(pDRIPriv->drmFD)) {
+ DRIDrvMsg(pScreen->myNum, X_ERROR,
+ "[drm] failed to remove DRM signal handler\n");
+ }
+ }
+
+ if (pDRIPriv->dummyCtxPriv && pDRIPriv->createDummyCtx) {
+ DRIDestroyDummyContext(pScreen, pDRIPriv->createDummyCtxPriv);
+ }
+
+ if (!DRIDestroyContextPriv(pDRIPriv->myContextPriv)) {
+ DRIDrvMsg(pScreen->myNum, X_ERROR,
+ "failed to destroy server context\n");
+ }
+
+ /* Remove tags for reserved contexts */
+ if (pDRIEntPriv->resOwner == pScreen) {
+ pDRIEntPriv->resOwner = NULL;
+
+ if ((reserved = drmGetReservedContextList(pDRIPriv->drmFD,
+ &reserved_count))) {
+ int i;
+
+ for (i = 0; i < reserved_count; i++) {
+ DRIDestroyContextPriv(drmGetContextTag(pDRIPriv->drmFD,
+ reserved[i]));
+ }
+ drmFreeReservedContextList(reserved);
+ DRIDrvMsg(pScreen->myNum, X_INFO,
+ "[drm] removed %d reserved context%s for kernel\n",
+ reserved_count, reserved_count > 1 ? "s" : "");
+ }
+ }
+
+ /* Make sure signals get unblocked etc. */
+ drmUnlock(pDRIPriv->drmFD, pDRIPriv->myContext);
+ pDRIPriv->pLockRefCount = NULL;
+ closeMaster = (--pDRIEntPriv->refCount == 0) &&
+ !pDRIEntPriv->keepFDOpen;
+ if (closeMaster || pDRIPriv->hSAREA != pDRIEntPriv->hLSAREA) {
+ DRIDrvMsg(pScreen->myNum, X_INFO,
+ "[drm] unmapping %d bytes of SAREA %p at %p\n",
+ pDRIInfo->SAREASize,
+ pDRIPriv->hSAREA,
+ pDRIPriv->pSAREA);
+ if (drmUnmap(pDRIPriv->pSAREA, pDRIInfo->SAREASize)) {
+ DRIDrvMsg(pScreen->myNum, X_ERROR,
+ "[drm] unable to unmap %d bytes"
+ " of SAREA %p at %p\n",
+ pDRIInfo->SAREASize,
+ pDRIPriv->hSAREA,
+ pDRIPriv->pSAREA);
+ }
+ } else {
+ pDRIEntPriv->sAreaGrabbed = FALSE;
+ }
+
+ if (closeMaster || (pDRIEntPriv->drmFD != pDRIPriv->drmFD)) {
+ drmClose(pDRIPriv->drmFD);
+ if (pDRIEntPriv->drmFD == pDRIPriv->drmFD) {
+ DRIDrvMsg(pScreen->myNum, X_INFO,
+ "[drm] Closed DRM master.\n");
+ pDRIEntPriv->drmFD = -1;
+ }
+ }
+
+ free(pDRIPriv);
+ dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
+ }
+}
+
+#define DRM_MSG_VERBOSITY 3
+
+static int dri_drm_debug_print(const char *format, va_list ap)
+{
+ xf86VDrvMsgVerb(-1, X_NONE, DRM_MSG_VERBOSITY, format, ap);
+ return 0;
+}
+
+static void dri_drm_get_perms(gid_t *group, mode_t *mode)
+{
+ *group = xf86ConfigDRI.group;
+ *mode = xf86ConfigDRI.mode;
+}
+
+drmServerInfo DRIDRMServerInfo = {
+ dri_drm_debug_print,
+ xf86LoadKernelModule,
+ dri_drm_get_perms,
+};
+
+Bool
+DRIExtensionInit(void)
+{
+ if (DRIGeneration != serverGeneration) {
+ return FALSE;
+ }
+
+ DRIDrawablePrivResType = CreateNewResourceType(DRIDrawablePrivDelete,
+ "DRIDrawable");
+ DRIContextPrivResType = CreateNewResourceType(DRIContextPrivDelete,
+ "DRIContext");
+
+ if (!DRIDrawablePrivResType || !DRIContextPrivResType)
+ return FALSE;
+
+ RegisterBlockAndWakeupHandlers(DRIBlockHandler, DRIWakeupHandler, NULL);
+
+ return TRUE;
+}
+
+void
+DRIReset(void)
+{
+ /*
+ * This stub routine is called when the X Server recycles, resources
+ * allocated by DRIExtensionInit need to be managed here.
+ *
+ * Currently this routine is a stub because all the interesting resources
+ * are managed via the screen init process.
+ */
+}
+
+Bool
+DRIQueryDirectRenderingCapable(ScreenPtr pScreen, Bool* isCapable)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ if (pDRIPriv)
+ *isCapable = pDRIPriv->directRenderingSupport;
+ else
+ *isCapable = FALSE;
+
+ return TRUE;
+}
+
+Bool
+DRIOpenConnection(ScreenPtr pScreen, drm_handle_t * hSAREA, char **busIdString)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ *hSAREA = pDRIPriv->hSAREA;
+ *busIdString = pDRIPriv->pDriverInfo->busIdString;
+
+ return TRUE;
+}
+
+Bool
+DRIAuthConnection(ScreenPtr pScreen, drm_magic_t magic)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ if (drmAuthMagic(pDRIPriv->drmFD, magic)) return FALSE;
+ return TRUE;
+}
+
+Bool
+DRICloseConnection(ScreenPtr pScreen)
+{
+ return TRUE;
+}
+
+Bool
+DRIGetClientDriverName(ScreenPtr pScreen,
+ int *ddxDriverMajorVersion,
+ int *ddxDriverMinorVersion,
+ int *ddxDriverPatchVersion,
+ char **clientDriverName)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ *ddxDriverMajorVersion = pDRIPriv->pDriverInfo->ddxDriverMajorVersion;
+ *ddxDriverMinorVersion = pDRIPriv->pDriverInfo->ddxDriverMinorVersion;
+ *ddxDriverPatchVersion = pDRIPriv->pDriverInfo->ddxDriverPatchVersion;
+ *clientDriverName = pDRIPriv->pDriverInfo->clientDriverName;
+
+ return TRUE;
+}
+
+/* DRICreateContextPriv and DRICreateContextPrivFromHandle are helper
+ functions that layer on drmCreateContext and drmAddContextTag.
+
+ DRICreateContextPriv always creates a kernel drm_context_t and then calls
+ DRICreateContextPrivFromHandle to create a DRIContextPriv structure for
+ DRI tracking. For the SIGIO handler, the drm_context_t is associated with
+ DRIContextPrivPtr. Any special flags are stored in the DRIContextPriv
+ area and are passed to the kernel (if necessary).
+
+ DRICreateContextPriv returns a pointer to newly allocated
+ DRIContextPriv, and returns the kernel drm_context_t in pHWContext. */
+
+DRIContextPrivPtr
+DRICreateContextPriv(ScreenPtr pScreen,
+ drm_context_t * pHWContext,
+ DRIContextFlags flags)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ if (drmCreateContext(pDRIPriv->drmFD, pHWContext)) {
+ return NULL;
+ }
+
+ return DRICreateContextPrivFromHandle(pScreen, *pHWContext, flags);
+}
+
+DRIContextPrivPtr
+DRICreateContextPrivFromHandle(ScreenPtr pScreen,
+ drm_context_t hHWContext,
+ DRIContextFlags flags)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ DRIContextPrivPtr pDRIContextPriv;
+ int contextPrivSize;
+
+ contextPrivSize = sizeof(DRIContextPrivRec) +
+ pDRIPriv->pDriverInfo->contextSize;
+ if (!(pDRIContextPriv = calloc(1, contextPrivSize))) {
+ return NULL;
+ }
+ pDRIContextPriv->pContextStore = (void *)(pDRIContextPriv + 1);
+
+ drmAddContextTag(pDRIPriv->drmFD, hHWContext, pDRIContextPriv);
+
+ pDRIContextPriv->hwContext = hHWContext;
+ pDRIContextPriv->pScreen = pScreen;
+ pDRIContextPriv->flags = flags;
+ pDRIContextPriv->valid3D = FALSE;
+
+ if (flags & DRI_CONTEXT_2DONLY) {
+ if (drmSetContextFlags(pDRIPriv->drmFD,
+ hHWContext,
+ DRM_CONTEXT_2DONLY)) {
+ DRIDrvMsg(pScreen->myNum, X_ERROR,
+ "[drm] failed to set 2D context flag\n");
+ DRIDestroyContextPriv(pDRIContextPriv);
+ return NULL;
+ }
+ }
+ if (flags & DRI_CONTEXT_PRESERVED) {
+ if (drmSetContextFlags(pDRIPriv->drmFD,
+ hHWContext,
+ DRM_CONTEXT_PRESERVED)) {
+ DRIDrvMsg(pScreen->myNum, X_ERROR,
+ "[drm] failed to set preserved flag\n");
+ DRIDestroyContextPriv(pDRIContextPriv);
+ return NULL;
+ }
+ }
+ return pDRIContextPriv;
+}
+
+Bool
+DRIDestroyContextPriv(DRIContextPrivPtr pDRIContextPriv)
+{
+ DRIScreenPrivPtr pDRIPriv;
+
+ if (!pDRIContextPriv) return TRUE;
+
+ pDRIPriv = DRI_SCREEN_PRIV(pDRIContextPriv->pScreen);
+
+ if (!(pDRIContextPriv->flags & DRI_CONTEXT_RESERVED)) {
+ /* Don't delete reserved contexts from
+ kernel area -- the kernel manages its
+ reserved contexts itself. */
+ if (drmDestroyContext(pDRIPriv->drmFD, pDRIContextPriv->hwContext))
+ return FALSE;
+ }
+
+ /* Remove the tag last to prevent a race
+ condition where the context has pending
+ buffers. The context can't be re-used
+ while in this thread, but buffers can be
+ dispatched asynchronously. */
+ drmDelContextTag(pDRIPriv->drmFD, pDRIContextPriv->hwContext);
+ free(pDRIContextPriv);
+ return TRUE;
+}
+
+static Bool
+DRICreateDummyContext(ScreenPtr pScreen, Bool needCtxPriv)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ DRIContextPrivPtr pDRIContextPriv;
+ void *contextStore;
+
+ if (!(pDRIContextPriv =
+ DRICreateContextPriv(pScreen,
+ &pDRIPriv->pSAREA->dummy_context, 0))) {
+ return FALSE;
+ }
+
+ contextStore = DRIGetContextStore(pDRIContextPriv);
+ if (pDRIPriv->pDriverInfo->CreateContext && needCtxPriv) {
+ if (!pDRIPriv->pDriverInfo->CreateContext(pScreen, NULL,
+ pDRIPriv->pSAREA->dummy_context,
+ NULL,
+ (DRIContextType)(long)contextStore)) {
+ DRIDestroyContextPriv(pDRIContextPriv);
+ return FALSE;
+ }
+ }
+
+ pDRIPriv->dummyCtxPriv = pDRIContextPriv;
+ return TRUE;
+}
+
+static void
+DRIDestroyDummyContext(ScreenPtr pScreen, Bool hasCtxPriv)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ DRIContextPrivPtr pDRIContextPriv = pDRIPriv->dummyCtxPriv;
+ void *contextStore;
+
+ if (!pDRIContextPriv) return;
+ if (pDRIPriv->pDriverInfo->DestroyContext && hasCtxPriv) {
+ contextStore = DRIGetContextStore(pDRIContextPriv);
+ pDRIPriv->pDriverInfo->DestroyContext(pDRIContextPriv->pScreen,
+ pDRIContextPriv->hwContext,
+ (DRIContextType)(long)contextStore);
+ }
+
+ DRIDestroyContextPriv(pDRIPriv->dummyCtxPriv);
+ pDRIPriv->dummyCtxPriv = NULL;
+}
+
+Bool
+DRICreateContext(ScreenPtr pScreen, VisualPtr visual,
+ XID context, drm_context_t * pHWContext)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ DRIContextPrivPtr pDRIContextPriv;
+ void *contextStore;
+
+ if (pDRIPriv->createDummyCtx && !pDRIPriv->dummyCtxPriv) {
+ if (!DRICreateDummyContext(pScreen, pDRIPriv->createDummyCtxPriv)) {
+ DRIDrvMsg(pScreen->myNum, X_INFO,
+ "[drm] Could not create dummy context\n");
+ return FALSE;
+ }
+ }
+
+ if (!(pDRIContextPriv = DRICreateContextPriv(pScreen, pHWContext, 0))) {
+ return FALSE;
+ }
+
+ contextStore = DRIGetContextStore(pDRIContextPriv);
+ if (pDRIPriv->pDriverInfo->CreateContext) {
+ if (!((*pDRIPriv->pDriverInfo->CreateContext)(pScreen, NULL,
+ *pHWContext, NULL,
+ (DRIContextType)(long)contextStore))) {
+ DRIDestroyContextPriv(pDRIContextPriv);
+ return FALSE;
+ }
+ }
+
+ /* track this in case the client dies before cleanup */
+ AddResource(context, DRIContextPrivResType, (pointer)pDRIContextPriv);
+
+ return TRUE;
+}
+
+Bool
+DRIDestroyContext(ScreenPtr pScreen, XID context)
+{
+ FreeResourceByType(context, DRIContextPrivResType, FALSE);
+
+ return TRUE;
+}
+
+/* DRIContextPrivDelete is called by the resource manager. */
+Bool
+DRIContextPrivDelete(pointer pResource, XID id)
+{
+ DRIContextPrivPtr pDRIContextPriv = (DRIContextPrivPtr)pResource;
+ DRIScreenPrivPtr pDRIPriv;
+ void *contextStore;
+
+ pDRIPriv = DRI_SCREEN_PRIV(pDRIContextPriv->pScreen);
+ if (pDRIPriv->pDriverInfo->DestroyContext) {
+ contextStore = DRIGetContextStore(pDRIContextPriv);
+ pDRIPriv->pDriverInfo->DestroyContext(pDRIContextPriv->pScreen,
+ pDRIContextPriv->hwContext,
+ (DRIContextType)(long)contextStore);
+ }
+ return DRIDestroyContextPriv(pDRIContextPriv);
+}
+
+
+/* This walks the drawable timestamp array and invalidates all of them
+ * in the case of transition from private to shared backbuffers. It's
+ * not necessary for correctness, because DRIClipNotify gets called in
+ * time to prevent any conflict, but the transition from
+ * shared->private is sometimes missed if we don't do this.
+ */
+static void
+DRIClipNotifyAllDrawables(ScreenPtr pScreen)
+{
+ int i;
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ for( i=0; i < pDRIPriv->pDriverInfo->maxDrawableTableEntry; i++) {
+ pDRIPriv->pSAREA->drawableTable[i].stamp = DRIDrawableValidationStamp++;
+ }
+}
+
+
+static void
+DRITransitionToSharedBuffers(ScreenPtr pScreen)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo;
+
+ DRIClipNotifyAllDrawables( pScreen );
+
+ if (pDRIInfo->TransitionSingleToMulti3D)
+ pDRIInfo->TransitionSingleToMulti3D( pScreen );
+}
+
+
+static void
+DRITransitionToPrivateBuffers(ScreenPtr pScreen)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo;
+
+ DRIClipNotifyAllDrawables( pScreen );
+
+ if (pDRIInfo->TransitionMultiToSingle3D)
+ pDRIInfo->TransitionMultiToSingle3D( pScreen );
+}
+
+
+static void
+DRITransitionTo3d(ScreenPtr pScreen)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo;
+
+ DRIClipNotifyAllDrawables( pScreen );
+
+ if (pDRIInfo->TransitionTo3d)
+ pDRIInfo->TransitionTo3d( pScreen );
+}
+
+static void
+DRITransitionTo2d(ScreenPtr pScreen)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo;
+
+ DRIClipNotifyAllDrawables( pScreen );
+
+ if (pDRIInfo->TransitionTo2d)
+ pDRIInfo->TransitionTo2d( pScreen );
+}
+
+
+static int
+DRIDCNTreeTraversal(WindowPtr pWin, pointer data)
+{
+ DRIDrawablePrivPtr pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
+
+ if (pDRIDrawablePriv) {
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ if (RegionNumRects(&pWin->clipList) > 0) {
+ WindowPtr *pDRIWindows = (WindowPtr*)data;
+ int i = 0;
+
+ while (pDRIWindows[i])
+ i++;
+
+ pDRIWindows[i] = pWin;
+
+ pDRIPriv->nrWalked++;
+ }
+
+ if (pDRIPriv->nrWindows == pDRIPriv->nrWalked)
+ return WT_STOPWALKING;
+ }
+
+ return WT_WALKCHILDREN;
+}
+
+static void
+DRIDriverClipNotify(ScreenPtr pScreen)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ if (pDRIPriv->pDriverInfo->ClipNotify) {
+ WindowPtr *pDRIWindows = calloc(sizeof(WindowPtr), pDRIPriv->nrWindows);
+ DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo;
+
+ if (pDRIPriv->nrWindows > 0) {
+ pDRIPriv->nrWalked = 0;
+ TraverseTree(pScreen->root, DRIDCNTreeTraversal,
+ (pointer)pDRIWindows);
+ }
+
+ pDRIInfo->ClipNotify(pScreen, pDRIWindows, pDRIPriv->nrWindows);
+
+ free(pDRIWindows);
+ }
+}
+
+static void
+DRIIncreaseNumberVisible(ScreenPtr pScreen)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ switch (++pDRIPriv->nrWindowsVisible) {
+ case 1:
+ DRITransitionTo3d( pScreen );
+ break;
+ case 2:
+ DRITransitionToSharedBuffers( pScreen );
+ break;
+ default:
+ break;
+ }
+
+ DRIDriverClipNotify(pScreen);
+}
+
+static void
+DRIDecreaseNumberVisible(ScreenPtr pScreen)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ switch (--pDRIPriv->nrWindowsVisible) {
+ case 0:
+ DRITransitionTo2d( pScreen );
+ break;
+ case 1:
+ DRITransitionToPrivateBuffers( pScreen );
+ break;
+ default:
+ break;
+ }
+
+ DRIDriverClipNotify(pScreen);
+}
+
+Bool
+DRICreateDrawable(ScreenPtr pScreen, ClientPtr client, DrawablePtr pDrawable,
+ drm_drawable_t * hHWDrawable)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ DRIDrawablePrivPtr pDRIDrawablePriv;
+ WindowPtr pWin;
+
+ if (pDrawable->type == DRAWABLE_WINDOW) {
+ pWin = (WindowPtr)pDrawable;
+ if ((pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin))) {
+ pDRIDrawablePriv->refCount++;
+
+ if (!pDRIDrawablePriv->hwDrawable) {
+ drmCreateDrawable(pDRIPriv->drmFD, &pDRIDrawablePriv->hwDrawable);
+ }
+ }
+ else {
+ /* allocate a DRI Window Private record */
+ if (!(pDRIDrawablePriv = malloc(sizeof(DRIDrawablePrivRec)))) {
+ return FALSE;
+ }
+
+ /* Only create a drm_drawable_t once */
+ if (drmCreateDrawable(pDRIPriv->drmFD,
+ &pDRIDrawablePriv->hwDrawable)) {
+ free(pDRIDrawablePriv);
+ return FALSE;
+ }
+
+ /* add it to the list of DRI drawables for this screen */
+ pDRIDrawablePriv->pScreen = pScreen;
+ pDRIDrawablePriv->refCount = 1;
+ pDRIDrawablePriv->drawableIndex = -1;
+ pDRIDrawablePriv->nrects = RegionNumRects(&pWin->clipList);
+
+ /* save private off of preallocated index */
+ dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey,
+ pDRIDrawablePriv);
+ pDRIPriv->nrWindows++;
+
+ if (pDRIDrawablePriv->nrects)
+ DRIIncreaseNumberVisible(pScreen);
+ }
+
+ /* track this in case the client dies */
+ AddResource(FakeClientID(client->index), DRIDrawablePrivResType,
+ (pointer)(intptr_t)pDrawable->id);
+
+ if (pDRIDrawablePriv->hwDrawable) {
+ drmUpdateDrawableInfo(pDRIPriv->drmFD,
+ pDRIDrawablePriv->hwDrawable,
+ DRM_DRAWABLE_CLIPRECTS,
+ RegionNumRects(&pWin->clipList),
+ RegionRects(&pWin->clipList));
+ *hHWDrawable = pDRIDrawablePriv->hwDrawable;
+ }
+ }
+ else if (pDrawable->type != DRAWABLE_PIXMAP) { /* PBuffer */
+ /* NOT_DONE */
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static void
+DRIDrawablePrivDestroy(WindowPtr pWin)
+{
+ DRIDrawablePrivPtr pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
+ ScreenPtr pScreen;
+ DRIScreenPrivPtr pDRIPriv;
+
+ if (!pDRIDrawablePriv)
+ return;
+
+ pScreen = pWin->drawable.pScreen;
+ pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ if (pDRIDrawablePriv->drawableIndex != -1) {
+ /* bump stamp to force outstanding 3D requests to resync */
+ pDRIPriv->pSAREA->drawableTable[pDRIDrawablePriv->drawableIndex].stamp
+ = DRIDrawableValidationStamp++;
+
+ /* release drawable table entry */
+ pDRIPriv->DRIDrawables[pDRIDrawablePriv->drawableIndex] = NULL;
+ }
+
+ pDRIPriv->nrWindows--;
+
+ if (pDRIDrawablePriv->nrects)
+ DRIDecreaseNumberVisible(pScreen);
+
+ drmDestroyDrawable(pDRIPriv->drmFD, pDRIDrawablePriv->hwDrawable);
+
+ free(pDRIDrawablePriv);
+ dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey, NULL);
+}
+
+static Bool
+DRIDestroyDrawableCB(pointer value, XID id, pointer data)
+{
+ if (value == data) {
+ /* This calls back DRIDrawablePrivDelete which frees private area */
+ FreeResourceByType(id, DRIDrawablePrivResType, FALSE);
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+Bool
+DRIDestroyDrawable(ScreenPtr pScreen, ClientPtr client, DrawablePtr pDrawable)
+{
+ if (pDrawable->type == DRAWABLE_WINDOW) {
+ LookupClientResourceComplex(client, DRIDrawablePrivResType,
+ DRIDestroyDrawableCB,
+ (pointer)(intptr_t)pDrawable->id);
+ }
+ else { /* pixmap (or for GLX 1.3, a PBuffer) */
+ /* NOT_DONE */
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+Bool
+DRIDrawablePrivDelete(pointer pResource, XID id)
+{
+ WindowPtr pWin;
+ int rc;
+
+ /* For DRIDrawablePrivResType, the XID is the client's fake ID. The
+ * important XID is the value in pResource. */
+ id = (XID)(intptr_t)pResource;
+ rc = dixLookupWindow(&pWin, id, serverClient, DixGetAttrAccess);
+
+ if (rc == Success) {
+ DRIDrawablePrivPtr pDRIDrwPriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
+
+ if (!pDRIDrwPriv)
+ return FALSE;
+
+ if (--pDRIDrwPriv->refCount == 0)
+ DRIDrawablePrivDestroy(pWin);
+
+ return TRUE;
+ }
+ else { /* pixmap (or for GLX 1.3, a PBuffer) */
+ /* NOT_DONE */
+ return FALSE;
+ }
+}
+
+Bool
+DRIGetDrawableInfo(ScreenPtr pScreen,
+ DrawablePtr pDrawable,
+ unsigned int* index,
+ unsigned int* stamp,
+ int* X,
+ int* Y,
+ int* W,
+ int* H,
+ int* numClipRects,
+ drm_clip_rect_t ** pClipRects,
+ int* backX,
+ int* backY,
+ int* numBackClipRects,
+ drm_clip_rect_t ** pBackClipRects)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ DRIDrawablePrivPtr pDRIDrawablePriv, pOldDrawPriv;
+ WindowPtr pWin, pOldWin;
+ int i;
+
+#if 0
+ printf("maxDrawableTableEntry = %d\n", pDRIPriv->pDriverInfo->maxDrawableTableEntry);
+#endif
+
+ if (pDrawable->type == DRAWABLE_WINDOW) {
+ pWin = (WindowPtr)pDrawable;
+ if ((pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin))) {
+
+ /* Manage drawable table */
+ if (pDRIDrawablePriv->drawableIndex == -1) { /* load SAREA table */
+
+ /* Search table for empty entry */
+ i = 0;
+ while (i < pDRIPriv->pDriverInfo->maxDrawableTableEntry) {
+ if (!(pDRIPriv->DRIDrawables[i])) {
+ pDRIPriv->DRIDrawables[i] = pDrawable;
+ pDRIDrawablePriv->drawableIndex = i;
+ pDRIPriv->pSAREA->drawableTable[i].stamp =
+ DRIDrawableValidationStamp++;
+ break;
+ }
+ i++;
+ }
+
+ /* Search table for oldest entry */
+ if (i == pDRIPriv->pDriverInfo->maxDrawableTableEntry) {
+ unsigned int oldestStamp = ~0;
+ int oldestIndex = 0;
+ i = pDRIPriv->pDriverInfo->maxDrawableTableEntry;
+ while (i--) {
+ if (pDRIPriv->pSAREA->drawableTable[i].stamp <
+ oldestStamp) {
+ oldestIndex = i;
+ oldestStamp =
+ pDRIPriv->pSAREA->drawableTable[i].stamp;
+ }
+ }
+ pDRIDrawablePriv->drawableIndex = oldestIndex;
+
+ /* release oldest drawable table entry */
+ pOldWin = (WindowPtr)pDRIPriv->DRIDrawables[oldestIndex];
+ pOldDrawPriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pOldWin);
+ pOldDrawPriv->drawableIndex = -1;
+
+ /* claim drawable table entry */
+ pDRIPriv->DRIDrawables[oldestIndex] = pDrawable;
+
+ /* validate SAREA entry */
+ pDRIPriv->pSAREA->drawableTable[oldestIndex].stamp =
+ DRIDrawableValidationStamp++;
+
+ /* check for stamp wrap around */
+ if (oldestStamp > DRIDrawableValidationStamp) {
+
+ /* walk SAREA table and invalidate all drawables */
+ for( i=0;
+ i < pDRIPriv->pDriverInfo->maxDrawableTableEntry;
+ i++) {
+ pDRIPriv->pSAREA->drawableTable[i].stamp =
+ DRIDrawableValidationStamp++;
+ }
+ }
+ }
+
+ /* If the driver wants to be notified when the index is
+ * set for a drawable, let it know now.
+ */
+ if (pDRIPriv->pDriverInfo->SetDrawableIndex)
+ pDRIPriv->pDriverInfo->SetDrawableIndex(pWin,
+ pDRIDrawablePriv->drawableIndex);
+
+ /* reinit drawable ID if window is visible */
+ if ((pWin->viewable) &&
+ (pDRIPriv->pDriverInfo->bufferRequests != DRI_NO_WINDOWS))
+ {
+ (*pDRIPriv->pDriverInfo->InitBuffers)(pWin,
+ &pWin->clipList, pDRIDrawablePriv->drawableIndex);
+ }
+ }
+
+ *index = pDRIDrawablePriv->drawableIndex;
+ *stamp = pDRIPriv->pSAREA->drawableTable[*index].stamp;
+ *X = (int)(pWin->drawable.x);
+ *Y = (int)(pWin->drawable.y);
+ *W = (int)(pWin->drawable.width);
+ *H = (int)(pWin->drawable.height);
+ *numClipRects = RegionNumRects(&pWin->clipList);
+ *pClipRects = (drm_clip_rect_t *)RegionRects(&pWin->clipList);
+
+ if (!*numClipRects && pDRIPriv->fullscreen) {
+ /* use fake full-screen clip rect */
+ pDRIPriv->fullscreen_rect.x1 = *X;
+ pDRIPriv->fullscreen_rect.y1 = *Y;
+ pDRIPriv->fullscreen_rect.x2 = *X + *W;
+ pDRIPriv->fullscreen_rect.y2 = *Y + *H;
+
+ *numClipRects = 1;
+ *pClipRects = &pDRIPriv->fullscreen_rect;
+ }
+
+ *backX = *X;
+ *backY = *Y;
+
+ if (pDRIPriv->nrWindowsVisible == 1 && *numClipRects) {
+ /* Use a single cliprect. */
+
+ int x0 = *X;
+ int y0 = *Y;
+ int x1 = x0 + *W;
+ int y1 = y0 + *H;
+
+ if (x0 < 0) x0 = 0;
+ if (y0 < 0) y0 = 0;
+ if (x1 > pScreen->width) x1 = pScreen->width;
+ if (y1 > pScreen->height) y1 = pScreen->height;
+
+ if (y0 >= y1 || x0 >= x1) {
+ *numBackClipRects = 0;
+ *pBackClipRects = NULL;
+ } else {
+ pDRIPriv->private_buffer_rect.x1 = x0;
+ pDRIPriv->private_buffer_rect.y1 = y0;
+ pDRIPriv->private_buffer_rect.x2 = x1;
+ pDRIPriv->private_buffer_rect.y2 = y1;
+
+ *numBackClipRects = 1;
+ *pBackClipRects = &(pDRIPriv->private_buffer_rect);
+ }
+ } else {
+ /* Use the frontbuffer cliprects for back buffers. */
+ *numBackClipRects = 0;
+ *pBackClipRects = 0;
+ }
+ }
+ else {
+ /* Not a DRIDrawable */
+ return FALSE;
+ }
+ }
+ else { /* pixmap (or for GLX 1.3, a PBuffer) */
+ /* NOT_DONE */
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+Bool
+DRIGetDeviceInfo(ScreenPtr pScreen,
+ drm_handle_t * hFrameBuffer,
+ int* fbOrigin,
+ int* fbSize,
+ int* fbStride,
+ int* devPrivateSize,
+ void** pDevPrivate)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ *hFrameBuffer = pDRIPriv->pDriverInfo->hFrameBuffer;
+ *fbOrigin = 0;
+ *fbSize = pDRIPriv->pDriverInfo->frameBufferSize;
+ *fbStride = pDRIPriv->pDriverInfo->frameBufferStride;
+ *devPrivateSize = pDRIPriv->pDriverInfo->devPrivateSize;
+ *pDevPrivate = pDRIPriv->pDriverInfo->devPrivate;
+
+ return TRUE;
+}
+
+DRIInfoPtr
+DRICreateInfoRec(void)
+{
+ DRIInfoPtr inforec = (DRIInfoPtr)calloc(1, sizeof(DRIInfoRec));
+ if (!inforec) return NULL;
+
+ /* Initialize defaults */
+ inforec->busIdString = NULL;
+
+ /* Wrapped function defaults */
+ inforec->wrap.WakeupHandler = DRIDoWakeupHandler;
+ inforec->wrap.BlockHandler = DRIDoBlockHandler;
+ inforec->wrap.WindowExposures = DRIWindowExposures;
+ inforec->wrap.CopyWindow = DRICopyWindow;
+ inforec->wrap.ValidateTree = DRIValidateTree;
+ inforec->wrap.PostValidateTree = DRIPostValidateTree;
+ inforec->wrap.ClipNotify = DRIClipNotify;
+ inforec->wrap.AdjustFrame = DRIAdjustFrame;
+
+ inforec->TransitionTo2d = 0;
+ inforec->TransitionTo3d = 0;
+ inforec->SetDrawableIndex = 0;
+
+ return inforec;
+}
+
+void
+DRIDestroyInfoRec(DRIInfoPtr DRIInfo)
+{
+ free(DRIInfo->busIdString);
+ free((char*)DRIInfo);
+}
+
+
+void
+DRIWakeupHandler(pointer wakeupData, int result, pointer pReadmask)
+{
+ int i;
+
+ for (i = 0; i < screenInfo.numScreens; i++) {
+ ScreenPtr pScreen = screenInfo.screens[i];
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ if (pDRIPriv &&
+ pDRIPriv->pDriverInfo->wrap.WakeupHandler)
+ (*pDRIPriv->pDriverInfo->wrap.WakeupHandler)(i, wakeupData,
+ result, pReadmask);
+ }
+}
+
+void
+DRIBlockHandler(pointer blockData, OSTimePtr pTimeout, pointer pReadmask)
+{
+ int i;
+
+ for (i = 0; i < screenInfo.numScreens; i++) {
+ ScreenPtr pScreen = screenInfo.screens[i];
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ if (pDRIPriv &&
+ pDRIPriv->pDriverInfo->wrap.BlockHandler)
+ (*pDRIPriv->pDriverInfo->wrap.BlockHandler)(i, blockData,
+ pTimeout, pReadmask);
+ }
+}
+
+void
+DRIDoWakeupHandler(int screenNum, pointer wakeupData,
+ unsigned long result, pointer pReadmask)
+{
+ ScreenPtr pScreen = screenInfo.screens[screenNum];
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ DRILock(pScreen, 0);
+ if (pDRIPriv->pDriverInfo->driverSwapMethod == DRI_HIDE_X_CONTEXT) {
+ /* hide X context by swapping 2D component here */
+ (*pDRIPriv->pDriverInfo->SwapContext)(pScreen,
+ DRI_3D_SYNC,
+ DRI_2D_CONTEXT,
+ pDRIPriv->partial3DContextStore,
+ DRI_2D_CONTEXT,
+ pDRIPriv->hiddenContextStore);
+ }
+}
+
+void
+DRIDoBlockHandler(int screenNum, pointer blockData,
+ pointer pTimeout, pointer pReadmask)
+{
+ ScreenPtr pScreen = screenInfo.screens[screenNum];
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ if (pDRIPriv->pDriverInfo->driverSwapMethod == DRI_HIDE_X_CONTEXT) {
+ /* hide X context by swapping 2D component here */
+ (*pDRIPriv->pDriverInfo->SwapContext)(pScreen,
+ DRI_2D_SYNC,
+ DRI_NO_CONTEXT,
+ NULL,
+ DRI_2D_CONTEXT,
+ pDRIPriv->partial3DContextStore);
+ }
+
+ if (pDRIPriv->windowsTouched)
+ DRM_SPINUNLOCK(&pDRIPriv->pSAREA->drawable_lock, 1);
+ pDRIPriv->windowsTouched = FALSE;
+
+ DRIUnlock(pScreen);
+}
+
+void
+DRISwapContext(int drmFD, void *oldctx, void *newctx)
+{
+ DRIContextPrivPtr oldContext = (DRIContextPrivPtr)oldctx;
+ DRIContextPrivPtr newContext = (DRIContextPrivPtr)newctx;
+ ScreenPtr pScreen = newContext->pScreen;
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ void* oldContextStore = NULL;
+ DRIContextType oldContextType;
+ void* newContextStore = NULL;
+ DRIContextType newContextType;
+ DRISyncType syncType;
+#ifdef DEBUG
+ static int count = 0;
+
+ if (!newContext) {
+ DRIDrvMsg(pScreen->myNum, X_ERROR,
+ "[DRI] Context Switch Error: oldContext=%x, newContext=%x\n",
+ oldContext, newContext);
+ return;
+ }
+
+ /* usefull for debugging, just print out after n context switches */
+ if (!count || !(count % 1)) {
+ DRIDrvMsg(pScreen->myNum, X_INFO,
+ "[DRI] Context switch %5d from %p/0x%08x (%d)\n",
+ count,
+ oldContext,
+ oldContext ? oldContext->flags : 0,
+ oldContext ? oldContext->hwContext : -1);
+ DRIDrvMsg(pScreen->myNum, X_INFO,
+ "[DRI] Context switch %5d to %p/0x%08x (%d)\n",
+ count,
+ newContext,
+ newContext ? newContext->flags : 0,
+ newContext ? newContext->hwContext : -1);
+ }
+ ++count;
+#endif
+
+ if (!pDRIPriv->pDriverInfo->SwapContext) {
+ DRIDrvMsg(pScreen->myNum, X_ERROR,
+ "[DRI] DDX driver missing context swap call back\n");
+ return;
+ }
+
+ if (pDRIPriv->pDriverInfo->driverSwapMethod == DRI_HIDE_X_CONTEXT) {
+
+ /* only 3D contexts are swapped in this case */
+ if (oldContext) {
+ oldContextStore = DRIGetContextStore(oldContext);
+ oldContext->valid3D = TRUE;
+ oldContextType = DRI_3D_CONTEXT;
+ } else {
+ oldContextType = DRI_NO_CONTEXT;
+ }
+ newContextStore = DRIGetContextStore(newContext);
+ if ((newContext->valid3D) &&
+ (newContext->hwContext != pDRIPriv->myContext)) {
+ newContextType = DRI_3D_CONTEXT;
+ }
+ else {
+ newContextType = DRI_2D_CONTEXT;
+ }
+ syncType = DRI_3D_SYNC;
+ }
+ else /* default: driverSwapMethod == DRI_SERVER_SWAP */ {
+
+ /* optimize 2D context swaps */
+
+ if (newContext->flags & DRI_CONTEXT_2DONLY) {
+ /* go from 3D context to 2D context and only save 2D
+ * subset of 3D state
+ */
+ oldContextStore = DRIGetContextStore(oldContext);
+ oldContextType = DRI_2D_CONTEXT;
+ newContextStore = DRIGetContextStore(newContext);
+ newContextType = DRI_2D_CONTEXT;
+ syncType = DRI_3D_SYNC;
+ pDRIPriv->lastPartial3DContext = oldContext;
+ }
+ else if (oldContext->flags & DRI_CONTEXT_2DONLY) {
+ if (pDRIPriv->lastPartial3DContext == newContext) {
+ /* go from 2D context back to previous 3D context and
+ * only restore 2D subset of previous 3D state
+ */
+ oldContextStore = DRIGetContextStore(oldContext);
+ oldContextType = DRI_2D_CONTEXT;
+ newContextStore = DRIGetContextStore(newContext);
+ newContextType = DRI_2D_CONTEXT;
+ syncType = DRI_2D_SYNC;
+ }
+ else {
+ /* go from 2D context to a different 3D context */
+
+ /* call DDX driver to do partial restore */
+ oldContextStore = DRIGetContextStore(oldContext);
+ newContextStore =
+ DRIGetContextStore(pDRIPriv->lastPartial3DContext);
+ (*pDRIPriv->pDriverInfo->SwapContext)(pScreen,
+ DRI_2D_SYNC,
+ DRI_2D_CONTEXT,
+ oldContextStore,
+ DRI_2D_CONTEXT,
+ newContextStore);
+
+ /* now setup for a complete 3D swap */
+ oldContextStore = newContextStore;
+ oldContext->valid3D = TRUE;
+ oldContextType = DRI_3D_CONTEXT;
+ newContextStore = DRIGetContextStore(newContext);
+ if ((newContext->valid3D) &&
+ (newContext->hwContext != pDRIPriv->myContext)) {
+ newContextType = DRI_3D_CONTEXT;
+ }
+ else {
+ newContextType = DRI_2D_CONTEXT;
+ }
+ syncType = DRI_NO_SYNC;
+ }
+ }
+ else {
+ /* now setup for a complete 3D swap */
+ oldContextStore = newContextStore;
+ oldContext->valid3D = TRUE;
+ oldContextType = DRI_3D_CONTEXT;
+ newContextStore = DRIGetContextStore(newContext);
+ if ((newContext->valid3D) &&
+ (newContext->hwContext != pDRIPriv->myContext)) {
+ newContextType = DRI_3D_CONTEXT;
+ }
+ else {
+ newContextType = DRI_2D_CONTEXT;
+ }
+ syncType = DRI_3D_SYNC;
+ }
+ }
+
+ /* call DDX driver to perform the swap */
+ (*pDRIPriv->pDriverInfo->SwapContext)(pScreen,
+ syncType,
+ oldContextType,
+ oldContextStore,
+ newContextType,
+ newContextStore);
+}
+
+void*
+DRIGetContextStore(DRIContextPrivPtr context)
+{
+ return((void *)context->pContextStore);
+}
+
+void
+DRIWindowExposures(WindowPtr pWin, RegionPtr prgn, RegionPtr bsreg)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ DRIDrawablePrivPtr pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
+
+ if(pDRIDrawablePriv) {
+ (*pDRIPriv->pDriverInfo->InitBuffers)(pWin, prgn,
+ pDRIDrawablePriv->drawableIndex);
+ }
+
+ /* call lower wrapped functions */
+ if (pDRIPriv && pDRIPriv->wrap.WindowExposures) {
+
+ /* unwrap */
+ pScreen->WindowExposures = pDRIPriv->wrap.WindowExposures;
+
+ /* call lower layers */
+ (*pScreen->WindowExposures)(pWin, prgn, bsreg);
+
+ /* rewrap */
+ pDRIPriv->wrap.WindowExposures = pScreen->WindowExposures;
+ pScreen->WindowExposures = DRIWindowExposures;
+ }
+}
+
+
+static int
+DRITreeTraversal(WindowPtr pWin, pointer data)
+{
+ DRIDrawablePrivPtr pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
+
+ if(pDRIDrawablePriv) {
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ if(RegionNumRects(&(pWin->clipList)) > 0) {
+ RegionPtr reg = (RegionPtr)data;
+
+ RegionUnion(reg, reg, &(pWin->clipList));
+ pDRIPriv->nrWalked++;
+ }
+
+ if(pDRIPriv->nrWindows == pDRIPriv->nrWalked)
+ return WT_STOPWALKING;
+ }
+ return WT_WALKCHILDREN;
+}
+
+Bool
+DRIDestroyWindow(WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ Bool retval = TRUE;
+
+ DRIDrawablePrivDestroy(pWin);
+
+ /* call lower wrapped functions */
+ if(pDRIPriv->DestroyWindow) {
+ /* unwrap */
+ pScreen->DestroyWindow = pDRIPriv->DestroyWindow;
+
+ /* call lower layers */
+ retval = (*pScreen->DestroyWindow)(pWin);
+
+ /* rewrap */
+ pDRIPriv->DestroyWindow = pScreen->DestroyWindow;
+ pScreen->DestroyWindow = DRIDestroyWindow;
+ }
+
+ return retval;
+}
+
+void
+DRICopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ if(!pDRIPriv) return;
+
+ if(pDRIPriv->nrWindowsVisible > 0) {
+ RegionRec reg;
+
+ RegionNull(&reg);
+ pDRIPriv->nrWalked = 0;
+ TraverseTree(pWin, DRITreeTraversal, (pointer)(&reg));
+
+ if(RegionNotEmpty(&reg)) {
+ RegionTranslate(&reg, ptOldOrg.x - pWin->drawable.x,
+ ptOldOrg.y - pWin->drawable.y);
+ RegionIntersect(&reg, &reg, prgnSrc);
+
+ /* The MoveBuffers interface is not ideal */
+ (*pDRIPriv->pDriverInfo->MoveBuffers)(pWin, ptOldOrg, &reg,
+ pDRIPriv->pDriverInfo->ddxDrawableTableEntry);
+ }
+
+ RegionUninit(&reg);
+ }
+
+ /* call lower wrapped functions */
+ if(pDRIPriv->wrap.CopyWindow) {
+ /* unwrap */
+ pScreen->CopyWindow = pDRIPriv->wrap.CopyWindow;
+
+ /* call lower layers */
+ (*pScreen->CopyWindow)(pWin, ptOldOrg, prgnSrc);
+
+ /* rewrap */
+ pDRIPriv->wrap.CopyWindow = pScreen->CopyWindow;
+ pScreen->CopyWindow = DRICopyWindow;
+ }
+}
+
+static void
+DRIGetSecs(long *secs, long *usecs)
+{
+ struct timeval tv;
+
+ gettimeofday(&tv, NULL);
+
+ *secs = tv.tv_sec;
+ *usecs = tv.tv_usec;
+}
+
+static unsigned long
+DRIComputeMilliSeconds(unsigned long s_secs, unsigned long s_usecs,
+ unsigned long f_secs, unsigned long f_usecs)
+{
+ if (f_usecs < s_usecs) {
+ --f_secs;
+ f_usecs += 1000000;
+ }
+ return (f_secs - s_secs) * 1000 + (f_usecs - s_usecs) / 1000;
+}
+
+static void
+DRISpinLockTimeout(drmLock *lock, int val, unsigned long timeout /* in mS */)
+{
+ int count = 10000;
+#if !defined(__alpha__) && !defined(__powerpc__)
+ char ret;
+#else
+ int ret;
+#endif
+ long s_secs, s_usecs;
+ long f_secs, f_usecs;
+ long msecs;
+ long prev = 0;
+
+ DRIGetSecs(&s_secs, &s_usecs);
+
+ do {
+ DRM_SPINLOCK_COUNT(lock, val, count, ret);
+ if (!ret) return; /* Got lock */
+ DRIGetSecs(&f_secs, &f_usecs);
+ msecs = DRIComputeMilliSeconds(s_secs, s_usecs, f_secs, f_usecs);
+ if (msecs - prev < 250) count *= 2; /* Not more than 0.5S */
+ } while (msecs < timeout);
+
+ /* Didn't get lock, so take it. The worst
+ that can happen is that there is some
+ garbage written to the wrong part of the
+ framebuffer that a refresh will repair.
+ That's undesirable, but better than
+ locking the server. This should be a
+ very rare event. */
+ DRM_SPINLOCK_TAKE(lock, val);
+}
+
+static void
+DRILockTree(ScreenPtr pScreen)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ if(!pDRIPriv) return;
+
+ /* Restore the last known 3D context if the X context is hidden */
+ if (pDRIPriv->pDriverInfo->driverSwapMethod == DRI_HIDE_X_CONTEXT) {
+ (*pDRIPriv->pDriverInfo->SwapContext)(pScreen,
+ DRI_2D_SYNC,
+ DRI_NO_CONTEXT,
+ NULL,
+ DRI_2D_CONTEXT,
+ pDRIPriv->partial3DContextStore);
+ }
+
+ /* Call kernel to release lock */
+ DRIUnlock(pScreen);
+
+ /* Grab drawable spin lock: a time out between 10 and 30 seconds is
+ appropriate, since this should never time out except in the case of
+ client death while the lock is being held. The timeout must be
+ greater than any reasonable rendering time. */
+ DRISpinLockTimeout(&pDRIPriv->pSAREA->drawable_lock, 1, 10000); /*10 secs*/
+
+ /* Call kernel flush outstanding buffers and relock */
+ DRILock(pScreen, DRM_LOCK_QUIESCENT|DRM_LOCK_FLUSH_ALL);
+
+ /* Switch back to our 2D context if the X context is hidden */
+ if (pDRIPriv->pDriverInfo->driverSwapMethod == DRI_HIDE_X_CONTEXT) {
+ /* hide X context by swapping 2D component here */
+ (*pDRIPriv->pDriverInfo->SwapContext)(pScreen,
+ DRI_3D_SYNC,
+ DRI_2D_CONTEXT,
+ pDRIPriv->partial3DContextStore,
+ DRI_2D_CONTEXT,
+ pDRIPriv->hiddenContextStore);
+ }
+}
+
+int
+DRIValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind)
+{
+ ScreenPtr pScreen = pParent->drawable.pScreen;
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ int returnValue = 1; /* always return 1, not checked by dix/window.c */
+
+ if(!pDRIPriv) return returnValue;
+
+ /* call lower wrapped functions */
+ if(pDRIPriv->wrap.ValidateTree) {
+ /* unwrap */
+ pScreen->ValidateTree = pDRIPriv->wrap.ValidateTree;
+
+ /* call lower layers */
+ returnValue = (*pScreen->ValidateTree)(pParent, pChild, kind);
+
+ /* rewrap */
+ pDRIPriv->wrap.ValidateTree = pScreen->ValidateTree;
+ pScreen->ValidateTree = DRIValidateTree;
+ }
+
+ return returnValue;
+}
+
+void
+DRIPostValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind)
+{
+ ScreenPtr pScreen;
+ DRIScreenPrivPtr pDRIPriv;
+
+ if (pParent) {
+ pScreen = pParent->drawable.pScreen;
+ } else {
+ pScreen = pChild->drawable.pScreen;
+ }
+ if(!(pDRIPriv = DRI_SCREEN_PRIV(pScreen))) return;
+
+ if (pDRIPriv->wrap.PostValidateTree) {
+ /* unwrap */
+ pScreen->PostValidateTree = pDRIPriv->wrap.PostValidateTree;
+
+ /* call lower layers */
+ (*pScreen->PostValidateTree)(pParent, pChild, kind);
+
+ /* rewrap */
+ pDRIPriv->wrap.PostValidateTree = pScreen->PostValidateTree;
+ pScreen->PostValidateTree = DRIPostValidateTree;
+ }
+}
+
+void
+DRIClipNotify(WindowPtr pWin, int dx, int dy)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ DRIDrawablePrivPtr pDRIDrawablePriv;
+
+ if(!pDRIPriv) return;
+
+ if ((pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin))) {
+ int nrects = RegionNumRects(&pWin->clipList);
+
+ if(!pDRIPriv->windowsTouched) {
+ DRILockTree(pScreen);
+ pDRIPriv->windowsTouched = TRUE;
+ }
+
+ if (nrects && !pDRIDrawablePriv->nrects)
+ DRIIncreaseNumberVisible(pScreen);
+ else if (!nrects && pDRIDrawablePriv->nrects)
+ DRIDecreaseNumberVisible(pScreen);
+ else
+ DRIDriverClipNotify(pScreen);
+
+ pDRIDrawablePriv->nrects = nrects;
+
+ pDRIPriv->pSAREA->drawableTable[pDRIDrawablePriv->drawableIndex].stamp
+ = DRIDrawableValidationStamp++;
+
+ drmUpdateDrawableInfo(pDRIPriv->drmFD, pDRIDrawablePriv->hwDrawable,
+ DRM_DRAWABLE_CLIPRECTS,
+ nrects, RegionRects(&pWin->clipList));
+ }
+
+ /* call lower wrapped functions */
+ if(pDRIPriv->wrap.ClipNotify) {
+
+ /* unwrap */
+ pScreen->ClipNotify = pDRIPriv->wrap.ClipNotify;
+
+ /* call lower layers */
+ (*pScreen->ClipNotify)(pWin, dx, dy);
+
+ /* rewrap */
+ pDRIPriv->wrap.ClipNotify = pScreen->ClipNotify;
+ pScreen->ClipNotify = DRIClipNotify;
+ }
+}
+
+CARD32
+DRIGetDrawableIndex(WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ DRIDrawablePrivPtr pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
+ CARD32 index;
+
+ if (pDRIDrawablePriv) {
+ index = pDRIDrawablePriv->drawableIndex;
+ }
+ else {
+ index = pDRIPriv->pDriverInfo->ddxDrawableTableEntry;
+ }
+
+ return index;
+}
+
+unsigned int
+DRIGetDrawableStamp(ScreenPtr pScreen, CARD32 drawable_index)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ return pDRIPriv->pSAREA->drawableTable[drawable_index].stamp;
+}
+
+
+void
+DRIPrintDrawableLock(ScreenPtr pScreen, char *msg)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ ErrorF("%s: %d\n", msg, pDRIPriv->pSAREA->drawable_lock.lock);
+}
+
+void
+DRILock(ScreenPtr pScreen, int flags)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ if(!pDRIPriv || !pDRIPriv->pLockRefCount) return;
+
+ if (!*pDRIPriv->pLockRefCount) {
+ DRM_LOCK(pDRIPriv->drmFD, pDRIPriv->pLSAREA, pDRIPriv->myContext, flags);
+ *pDRIPriv->pLockingContext = pDRIPriv->myContext;
+ } else if (*pDRIPriv->pLockingContext != pDRIPriv->myContext) {
+ DRIDrvMsg(pScreen->myNum, X_ERROR,
+ "[DRI] Locking deadlock.\n"
+ "\tAlready locked with context %d,\n"
+ "\ttrying to lock with context %d.\n",
+ pDRIPriv->pLockingContext,
+ pDRIPriv->myContext);
+ }
+ (*pDRIPriv->pLockRefCount)++;
+}
+
+void
+DRIUnlock(ScreenPtr pScreen)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ if(!pDRIPriv || !pDRIPriv->pLockRefCount) return;
+
+ if (*pDRIPriv->pLockRefCount > 0) {
+ if (pDRIPriv->myContext != *pDRIPriv->pLockingContext) {
+ DRIDrvMsg(pScreen->myNum, X_ERROR,
+ "[DRI] Unlocking inconsistency:\n"
+ "\tContext %d trying to unlock lock held by context %d\n",
+ pDRIPriv->pLockingContext,
+ pDRIPriv->myContext);
+ }
+ (*pDRIPriv->pLockRefCount)--;
+ } else {
+ DRIDrvMsg(pScreen->myNum, X_ERROR,
+ "DRIUnlock called when not locked.\n");
+ return;
+ }
+ if (! *pDRIPriv->pLockRefCount)
+ DRM_UNLOCK(pDRIPriv->drmFD, pDRIPriv->pLSAREA, pDRIPriv->myContext);
+}
+
+void *
+DRIGetSAREAPrivate(ScreenPtr pScreen)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ if (!pDRIPriv) return 0;
+
+ return (void *)(((char*)pDRIPriv->pSAREA)+sizeof(XF86DRISAREARec));
+}
+
+drm_context_t
+DRIGetContext(ScreenPtr pScreen)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ if (!pDRIPriv) return 0;
+
+ return pDRIPriv->myContext;
+}
+
+void
+DRIGetTexOffsetFuncs(ScreenPtr pScreen,
+ DRITexOffsetStartProcPtr *texOffsetStartFunc,
+ DRITexOffsetFinishProcPtr *texOffsetFinishFunc)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ if (!pDRIPriv) return;
+
+ *texOffsetStartFunc = pDRIPriv->pDriverInfo->texOffsetStart;
+ *texOffsetFinishFunc = pDRIPriv->pDriverInfo->texOffsetFinish;
+}
+
+/* This lets get at the unwrapped functions so that they can correctly
+ * call the lowerlevel functions, and choose whether they will be
+ * called at every level of recursion (eg in validatetree).
+ */
+DRIWrappedFuncsRec *
+DRIGetWrappedFuncs(ScreenPtr pScreen)
+{
+ return &(DRI_SCREEN_PRIV(pScreen)->wrap);
+}
+
+/* note that this returns the library version, not the protocol version */
+void
+DRIQueryVersion(int *majorVersion,
+ int *minorVersion,
+ int *patchVersion)
+{
+ *majorVersion = DRIINFO_MAJOR_VERSION;
+ *minorVersion = DRIINFO_MINOR_VERSION;
+ *patchVersion = DRIINFO_PATCH_VERSION;
+}
+
+static void
+_DRIAdjustFrame(ScrnInfoPtr pScrn, DRIScreenPrivPtr pDRIPriv, int x, int y)
+{
+ pDRIPriv->pSAREA->frame.x = x;
+ pDRIPriv->pSAREA->frame.y = y;
+ pDRIPriv->pSAREA->frame.width = pScrn->frameX1 - x + 1;
+ pDRIPriv->pSAREA->frame.height = pScrn->frameY1 - y + 1;
+}
+
+void
+DRIAdjustFrame(int scrnIndex, int x, int y, int flags)
+{
+ ScreenPtr pScreen = screenInfo.screens[scrnIndex];
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ int px, py;
+
+ if (!pDRIPriv || !pDRIPriv->pSAREA) {
+ DRIDrvMsg(scrnIndex, X_ERROR, "[DRI] No SAREA (%p %p)\n",
+ pDRIPriv, pDRIPriv ? pDRIPriv->pSAREA : NULL);
+ return;
+ }
+
+ if (pDRIPriv->fullscreen) {
+ /* Fix up frame */
+ pScrn->frameX0 = pDRIPriv->pSAREA->frame.x;
+ pScrn->frameY0 = pDRIPriv->pSAREA->frame.y;
+ pScrn->frameX1 = pScrn->frameX0 + pDRIPriv->pSAREA->frame.width - 1;
+ pScrn->frameY1 = pScrn->frameY0 + pDRIPriv->pSAREA->frame.height - 1;
+
+ /* Fix up cursor */
+ miPointerGetPosition(inputInfo.pointer, &px, &py);
+ if (px < pScrn->frameX0) px = pScrn->frameX0;
+ if (px > pScrn->frameX1) px = pScrn->frameX1;
+ if (py < pScrn->frameY0) py = pScrn->frameY0;
+ if (py > pScrn->frameY1) py = pScrn->frameY1;
+ pScreen->SetCursorPosition(inputInfo.pointer, pScreen, px, py, TRUE);
+ return;
+ }
+
+ if (pDRIPriv->wrap.AdjustFrame) {
+ /* unwrap */
+ pScrn->AdjustFrame = pDRIPriv->wrap.AdjustFrame;
+ /* call lower layers */
+ (*pScrn->AdjustFrame)(scrnIndex, x, y, flags);
+ /* rewrap */
+ pDRIPriv->wrap.AdjustFrame = pScrn->AdjustFrame;
+ pScrn->AdjustFrame = DRIAdjustFrame;
+ }
+
+ _DRIAdjustFrame(pScrn, pDRIPriv, x, y);
+}
+
+/*
+ * DRIMoveBuffersHelper swaps the regions rects in place leaving you
+ * a region with the rects in the order that you need to blit them,
+ * but it is possibly (likely) an invalid region afterwards. If you
+ * need to use the region again for anything you have to call
+ * REGION_VALIDATE on it, or better yet, save a copy first.
+ */
+
+void
+DRIMoveBuffersHelper(
+ ScreenPtr pScreen,
+ int dx,
+ int dy,
+ int *xdir,
+ int *ydir,
+ RegionPtr reg
+)
+{
+ BoxPtr extents, pbox, firstBox, lastBox;
+ BoxRec tmpBox;
+ int y, nbox;
+
+ extents = RegionExtents(reg);
+ nbox = RegionNumRects(reg);
+ pbox = RegionRects(reg);
+
+ if((dy > 0) && (dy < (extents->y2 - extents->y1))) {
+ *ydir = -1;
+ if(nbox > 1) {
+ firstBox = pbox;
+ lastBox = pbox + nbox - 1;
+ while((unsigned long)firstBox < (unsigned long)lastBox) {
+ tmpBox = *firstBox;
+ *firstBox = *lastBox;
+ *lastBox = tmpBox;
+ firstBox++;
+ lastBox--;
+ }
+ }
+ } else *ydir = 1;
+
+ if((dx > 0) && (dx < (extents->x2 - extents->x1))) {
+ *xdir = -1;
+ if(nbox > 1) {
+ firstBox = lastBox = pbox;
+ y = pbox->y1;
+ while(--nbox) {
+ pbox++;
+ if(pbox->y1 == y) lastBox++;
+ else {
+ while((unsigned long)firstBox < (unsigned long)lastBox) {
+ tmpBox = *firstBox;
+ *firstBox = *lastBox;
+ *lastBox = tmpBox;
+ firstBox++;
+ lastBox--;
+ }
+
+ firstBox = lastBox = pbox;
+ y = pbox->y1;
+ }
+ }
+ while((unsigned long)firstBox < (unsigned long)lastBox) {
+ tmpBox = *firstBox;
+ *firstBox = *lastBox;
+ *lastBox = tmpBox;
+ firstBox++;
+ lastBox--;
+ }
+ }
+ } else *xdir = 1;
+
+}
+
+char *
+DRICreatePCIBusID(const struct pci_device * dev)
+{
+ char *busID;
+
+ if (asprintf(&busID, "pci:%04x:%02x:%02x.%d",
+ dev->domain, dev->bus, dev->dev, dev->func) == -1)
+ return NULL;
+
+ return busID;
+}
+
+static void drmSIGIOHandler(int interrupt, void *closure)
+{
+ unsigned long key;
+ void *value;
+ ssize_t count;
+ drm_ctx_t ctx;
+ typedef void (*_drmCallback)(int, void *, void *);
+ char buf[256];
+ drm_context_t old;
+ drm_context_t new;
+ void *oldctx;
+ void *newctx;
+ char *pt;
+ drmHashEntry *entry;
+ void *hash_table;
+
+ hash_table = drmGetHashTable();
+
+ if (!hash_table) return;
+ if (drmHashFirst(hash_table, &key, &value)) {
+ entry = value;
+ do {
+#if 0
+ fprintf(stderr, "Trying %d\n", entry->fd);
+#endif
+ if ((count = read(entry->fd, buf, sizeof(buf) - 1)) > 0) {
+ buf[count] = '\0';
+#if 0
+ fprintf(stderr, "Got %s\n", buf);
+#endif
+
+ for (pt = buf; *pt != ' '; ++pt); /* Find first space */
+ ++pt;
+ old = strtol(pt, &pt, 0);
+ new = strtol(pt, NULL, 0);
+ oldctx = drmGetContextTag(entry->fd, old);
+ newctx = drmGetContextTag(entry->fd, new);
+#if 0
+ fprintf(stderr, "%d %d %p %p\n", old, new, oldctx, newctx);
+#endif
+ ((_drmCallback)entry->f)(entry->fd, oldctx, newctx);
+ ctx.handle = new;
+ ioctl(entry->fd, DRM_IOCTL_NEW_CTX, &ctx);
+ }
+ } while (drmHashNext(hash_table, &key, &value));
+ }
+}
+
+
+int drmInstallSIGIOHandler(int fd, void (*f)(int, void *, void *))
+{
+ drmHashEntry *entry;
+
+ entry = drmGetEntry(fd);
+ entry->f = f;
+
+ return xf86InstallSIGIOHandler(fd, drmSIGIOHandler, 0);
+}
+
+int drmRemoveSIGIOHandler(int fd)
+{
+ drmHashEntry *entry = drmGetEntry(fd);
+
+ entry->f = NULL;
+
+ return xf86RemoveSIGIOHandler(fd);
+}
diff --git a/xorg-server/hw/xfree86/dri/xf86dri.c b/xorg-server/hw/xfree86/dri/xf86dri.c
index ba9d5a1e4..e02644a30 100644
--- a/xorg-server/hw/xfree86/dri/xf86dri.c
+++ b/xorg-server/hw/xfree86/dri/xf86dri.c
@@ -1,662 +1,662 @@
-/**************************************************************************
-
-Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
-Copyright 2000 VA Linux Systems, 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, 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.
-
-**************************************************************************/
-
-/*
- * Authors:
- * Kevin E. Martin <martin@valinux.com>
- * Jens Owen <jens@tungstengraphics.com>
- * Rickard E. (Rik) Faith <faith@valinux.com>
- *
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <string.h>
-
-#include "xf86.h"
-
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include "misc.h"
-#include "dixstruct.h"
-#include "extnsionst.h"
-#include "colormapst.h"
-#include "cursorstr.h"
-#include "scrnintstr.h"
-#include "servermd.h"
-#define _XF86DRI_SERVER_
-#include <X11/dri/xf86driproto.h>
-#include "swaprep.h"
-#include "xf86str.h"
-#include "dri.h"
-#include "sarea.h"
-#include "dristruct.h"
-#include "xf86drm.h"
-#include "protocol-versions.h"
-
-static int DRIErrorBase;
-
-
-
-static void XF86DRIResetProc(ExtensionEntry* extEntry);
-
-static unsigned char DRIReqCode = 0;
-
-extern void XFree86DRIExtensionInit(void);
-
-/*ARGSUSED*/
-static void
-XF86DRIResetProc (
- ExtensionEntry* extEntry
-)
-{
- DRIReset();
-}
-
-static int
-ProcXF86DRIQueryVersion(
- register ClientPtr client
-)
-{
- xXF86DRIQueryVersionReply rep;
- register int n;
-
- REQUEST_SIZE_MATCH(xXF86DRIQueryVersionReq);
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.majorVersion = SERVER_XF86DRI_MAJOR_VERSION;
- rep.minorVersion = SERVER_XF86DRI_MINOR_VERSION;
- rep.patchVersion = SERVER_XF86DRI_PATCH_VERSION;
- if (client->swapped) {
- swaps(&rep.sequenceNumber, n);
- swapl(&rep.length, n);
- swaps(&rep.majorVersion, n);
- swaps(&rep.minorVersion, n);
- swapl(&rep.patchVersion, n);
- }
- WriteToClient(client, sizeof(xXF86DRIQueryVersionReply), (char *)&rep);
- return Success;
-}
-
-static int
-ProcXF86DRIQueryDirectRenderingCapable(
- register ClientPtr client
-)
-{
- xXF86DRIQueryDirectRenderingCapableReply rep;
- Bool isCapable;
- register int n;
-
- REQUEST(xXF86DRIQueryDirectRenderingCapableReq);
- REQUEST_SIZE_MATCH(xXF86DRIQueryDirectRenderingCapableReq);
- if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
- }
-
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
-
- if (!DRIQueryDirectRenderingCapable( screenInfo.screens[stuff->screen],
- &isCapable)) {
- return BadValue;
- }
- rep.isCapable = isCapable;
-
- if (!LocalClient(client) || client->swapped)
- rep.isCapable = 0;
-
- if (client->swapped) {
- swaps(&rep.sequenceNumber, n);
- swapl(&rep.length, n);
- }
-
- WriteToClient(client,
- sizeof(xXF86DRIQueryDirectRenderingCapableReply), (char *)&rep);
- return Success;
-}
-
-static int
-ProcXF86DRIOpenConnection(
- register ClientPtr client
-)
-{
- xXF86DRIOpenConnectionReply rep;
- drm_handle_t hSAREA;
- char* busIdString;
-
- REQUEST(xXF86DRIOpenConnectionReq);
- REQUEST_SIZE_MATCH(xXF86DRIOpenConnectionReq);
- if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
- }
-
- if (!DRIOpenConnection( screenInfo.screens[stuff->screen],
- &hSAREA,
- &busIdString)) {
- return BadValue;
- }
-
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.busIdStringLength = 0;
- if (busIdString)
- rep.busIdStringLength = strlen(busIdString);
- rep.length = bytes_to_int32(SIZEOF(xXF86DRIOpenConnectionReply) - SIZEOF(xGenericReply) +
- pad_to_int32(rep.busIdStringLength));
-
- rep.hSAREALow = (CARD32)(hSAREA & 0xffffffff);
-#if defined(LONG64) && !defined(__linux__)
- rep.hSAREAHigh = (CARD32)(hSAREA >> 32);
-#else
- rep.hSAREAHigh = 0;
-#endif
-
- WriteToClient(client, sizeof(xXF86DRIOpenConnectionReply), (char *)&rep);
- if (rep.busIdStringLength)
- WriteToClient(client, rep.busIdStringLength, busIdString);
- return Success;
-}
-
-static int
-ProcXF86DRIAuthConnection(
- register ClientPtr client
-)
-{
- xXF86DRIAuthConnectionReply rep;
-
- REQUEST(xXF86DRIAuthConnectionReq);
- REQUEST_SIZE_MATCH(xXF86DRIAuthConnectionReq);
- if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
- }
-
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.authenticated = 1;
-
- if (!DRIAuthConnection( screenInfo.screens[stuff->screen], stuff->magic)) {
- ErrorF("Failed to authenticate %lu\n", (unsigned long)stuff->magic);
- rep.authenticated = 0;
- }
- WriteToClient(client, sizeof(xXF86DRIAuthConnectionReply), (char *)&rep);
- return Success;
-}
-
-static int
-ProcXF86DRICloseConnection(
- register ClientPtr client
-)
-{
- REQUEST(xXF86DRICloseConnectionReq);
- REQUEST_SIZE_MATCH(xXF86DRICloseConnectionReq);
- if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
- }
-
- DRICloseConnection( screenInfo.screens[stuff->screen]);
-
- return Success;
-}
-
-static int
-ProcXF86DRIGetClientDriverName(
- register ClientPtr client
-)
-{
- xXF86DRIGetClientDriverNameReply rep;
- char* clientDriverName;
-
- REQUEST(xXF86DRIGetClientDriverNameReq);
- REQUEST_SIZE_MATCH(xXF86DRIGetClientDriverNameReq);
- if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
- }
-
- DRIGetClientDriverName( screenInfo.screens[stuff->screen],
- (int *)&rep.ddxDriverMajorVersion,
- (int *)&rep.ddxDriverMinorVersion,
- (int *)&rep.ddxDriverPatchVersion,
- &clientDriverName);
-
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.clientDriverNameLength = 0;
- if (clientDriverName)
- rep.clientDriverNameLength = strlen(clientDriverName);
- rep.length = bytes_to_int32(SIZEOF(xXF86DRIGetClientDriverNameReply) -
- SIZEOF(xGenericReply) +
- pad_to_int32(rep.clientDriverNameLength));
-
- WriteToClient(client,
- sizeof(xXF86DRIGetClientDriverNameReply), (char *)&rep);
- if (rep.clientDriverNameLength)
- WriteToClient(client,
- rep.clientDriverNameLength,
- clientDriverName);
- return Success;
-}
-
-static int
-ProcXF86DRICreateContext(
- register ClientPtr client
-)
-{
- xXF86DRICreateContextReply rep;
- ScreenPtr pScreen;
-
- REQUEST(xXF86DRICreateContextReq);
- REQUEST_SIZE_MATCH(xXF86DRICreateContextReq);
- if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
- }
-
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
-
- pScreen = screenInfo.screens[stuff->screen];
-
- if (!DRICreateContext( pScreen,
- NULL,
- stuff->context,
- (drm_context_t *)&rep.hHWContext)) {
- return BadValue;
- }
-
- WriteToClient(client, sizeof(xXF86DRICreateContextReply), (char *)&rep);
- return Success;
-}
-
-static int
-ProcXF86DRIDestroyContext(
- register ClientPtr client
-)
-{
- REQUEST(xXF86DRIDestroyContextReq);
- REQUEST_SIZE_MATCH(xXF86DRIDestroyContextReq);
- if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
- }
-
- if (!DRIDestroyContext( screenInfo.screens[stuff->screen],
- stuff->context)) {
- return BadValue;
- }
-
- return Success;
-}
-
-static int
-ProcXF86DRICreateDrawable(
- ClientPtr client
-)
-{
- xXF86DRICreateDrawableReply rep;
- DrawablePtr pDrawable;
- int rc;
-
- REQUEST(xXF86DRICreateDrawableReq);
- REQUEST_SIZE_MATCH(xXF86DRICreateDrawableReq);
- if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
- }
-
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
-
- rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
- DixReadAccess);
- if (rc != Success)
- return rc;
-
- if (!DRICreateDrawable(screenInfo.screens[stuff->screen], client,
- pDrawable, (drm_drawable_t *)&rep.hHWDrawable)) {
- return BadValue;
- }
-
- WriteToClient(client, sizeof(xXF86DRICreateDrawableReply), (char *)&rep);
- return Success;
-}
-
-static int
-ProcXF86DRIDestroyDrawable(
- register ClientPtr client
-)
-{
- REQUEST(xXF86DRIDestroyDrawableReq);
- DrawablePtr pDrawable;
- int rc;
- REQUEST_SIZE_MATCH(xXF86DRIDestroyDrawableReq);
-
- if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
- }
-
- rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
- DixReadAccess);
- if (rc != Success)
- return rc;
-
- if (!DRIDestroyDrawable(screenInfo.screens[stuff->screen], client,
- pDrawable)) {
- return BadValue;
- }
-
- return Success;
-}
-
-static int
-ProcXF86DRIGetDrawableInfo(
- register ClientPtr client
-)
-{
- xXF86DRIGetDrawableInfoReply rep;
- DrawablePtr pDrawable;
- int X, Y, W, H;
- drm_clip_rect_t * pClipRects, *pClippedRects;
- drm_clip_rect_t * pBackClipRects;
- int backX, backY, rc;
-
- REQUEST(xXF86DRIGetDrawableInfoReq);
- REQUEST_SIZE_MATCH(xXF86DRIGetDrawableInfoReq);
- if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
- }
-
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
-
- rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
- DixReadAccess);
- if (rc != Success)
- return rc;
-
- if (!DRIGetDrawableInfo( screenInfo.screens[stuff->screen],
- pDrawable,
- (unsigned int*)&rep.drawableTableIndex,
- (unsigned int*)&rep.drawableTableStamp,
- (int*)&X,
- (int*)&Y,
- (int*)&W,
- (int*)&H,
- (int*)&rep.numClipRects,
- &pClipRects,
- &backX,
- &backY,
- (int*)&rep.numBackClipRects,
- &pBackClipRects)) {
- return BadValue;
- }
-
- rep.drawableX = X;
- rep.drawableY = Y;
- rep.drawableWidth = W;
- rep.drawableHeight = H;
- rep.length = (SIZEOF(xXF86DRIGetDrawableInfoReply) -
- SIZEOF(xGenericReply));
-
- rep.backX = backX;
- rep.backY = backY;
-
- if (rep.numBackClipRects)
- rep.length += sizeof(drm_clip_rect_t) * rep.numBackClipRects;
-
- pClippedRects = pClipRects;
-
- if (rep.numClipRects) {
- /* Clip cliprects to screen dimensions (redirected windows) */
- pClippedRects = malloc(rep.numClipRects * sizeof(drm_clip_rect_t));
-
- if (pClippedRects) {
- ScreenPtr pScreen = screenInfo.screens[stuff->screen];
- int i, j;
-
- for (i = 0, j = 0; i < rep.numClipRects; i++) {
- pClippedRects[j].x1 = max(pClipRects[i].x1, 0);
- pClippedRects[j].y1 = max(pClipRects[i].y1, 0);
- pClippedRects[j].x2 = min(pClipRects[i].x2, pScreen->width);
- pClippedRects[j].y2 = min(pClipRects[i].y2, pScreen->height);
-
- if (pClippedRects[j].x1 < pClippedRects[j].x2 &&
- pClippedRects[j].y1 < pClippedRects[j].y2) {
- j++;
- }
- }
-
- rep.numClipRects = j;
- } else {
- rep.numClipRects = 0;
- }
-
- rep.length += sizeof(drm_clip_rect_t) * rep.numClipRects;
- }
-
- rep.length = bytes_to_int32(rep.length);
-
- WriteToClient(client, sizeof(xXF86DRIGetDrawableInfoReply), (char *)&rep);
-
- if (rep.numClipRects) {
- WriteToClient(client,
- sizeof(drm_clip_rect_t) * rep.numClipRects,
- (char *)pClippedRects);
- free(pClippedRects);
- }
-
- if (rep.numBackClipRects) {
- WriteToClient(client,
- sizeof(drm_clip_rect_t) * rep.numBackClipRects,
- (char *)pBackClipRects);
- }
-
- return Success;
-}
-
-static int
-ProcXF86DRIGetDeviceInfo(
- register ClientPtr client
-)
-{
- xXF86DRIGetDeviceInfoReply rep;
- drm_handle_t hFrameBuffer;
- void *pDevPrivate;
-
- REQUEST(xXF86DRIGetDeviceInfoReq);
- REQUEST_SIZE_MATCH(xXF86DRIGetDeviceInfoReq);
- if (stuff->screen >= screenInfo.numScreens) {
- client->errorValue = stuff->screen;
- return BadValue;
- }
-
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
-
- if (!DRIGetDeviceInfo( screenInfo.screens[stuff->screen],
- &hFrameBuffer,
- (int*)&rep.framebufferOrigin,
- (int*)&rep.framebufferSize,
- (int*)&rep.framebufferStride,
- (int*)&rep.devPrivateSize,
- &pDevPrivate)) {
- return BadValue;
- }
-
- rep.hFrameBufferLow = (CARD32)(hFrameBuffer & 0xffffffff);
-#if defined(LONG64) && !defined(__linux__)
- rep.hFrameBufferHigh = (CARD32)(hFrameBuffer >> 32);
-#else
- rep.hFrameBufferHigh = 0;
-#endif
-
- rep.length = 0;
- if (rep.devPrivateSize) {
- rep.length = bytes_to_int32(SIZEOF(xXF86DRIGetDeviceInfoReply) -
- SIZEOF(xGenericReply) +
- pad_to_int32(rep.devPrivateSize));
- }
-
- WriteToClient(client, sizeof(xXF86DRIGetDeviceInfoReply), (char *)&rep);
- if (rep.length) {
- WriteToClient(client, rep.devPrivateSize, (char *)pDevPrivate);
- }
- return Success;
-}
-
-static int
-ProcXF86DRIDispatch (
- register ClientPtr client
-)
-{
- REQUEST(xReq);
-
- switch (stuff->data)
- {
- case X_XF86DRIQueryVersion:
- return ProcXF86DRIQueryVersion(client);
- case X_XF86DRIQueryDirectRenderingCapable:
- return ProcXF86DRIQueryDirectRenderingCapable(client);
- }
-
- if (!LocalClient(client))
- return DRIErrorBase + XF86DRIClientNotLocal;
-
- switch (stuff->data)
- {
- case X_XF86DRIOpenConnection:
- return ProcXF86DRIOpenConnection(client);
- case X_XF86DRICloseConnection:
- return ProcXF86DRICloseConnection(client);
- case X_XF86DRIGetClientDriverName:
- return ProcXF86DRIGetClientDriverName(client);
- case X_XF86DRICreateContext:
- return ProcXF86DRICreateContext(client);
- case X_XF86DRIDestroyContext:
- return ProcXF86DRIDestroyContext(client);
- case X_XF86DRICreateDrawable:
- return ProcXF86DRICreateDrawable(client);
- case X_XF86DRIDestroyDrawable:
- return ProcXF86DRIDestroyDrawable(client);
- case X_XF86DRIGetDrawableInfo:
- return ProcXF86DRIGetDrawableInfo(client);
- case X_XF86DRIGetDeviceInfo:
- return ProcXF86DRIGetDeviceInfo(client);
- case X_XF86DRIAuthConnection:
- return ProcXF86DRIAuthConnection(client);
- /* {Open,Close}FullScreen are deprecated now */
- default:
- return BadRequest;
- }
-}
-
-static int
-SProcXF86DRIQueryVersion(
- register ClientPtr client
-)
-{
- register int n;
- REQUEST(xXF86DRIQueryVersionReq);
- swaps(&stuff->length, n);
- return ProcXF86DRIQueryVersion(client);
-}
-
-static int
-SProcXF86DRIQueryDirectRenderingCapable(
- register ClientPtr client
-)
-{
- register int n;
- REQUEST(xXF86DRIQueryDirectRenderingCapableReq);
- swaps(&stuff->length, n);
- swapl(&stuff->screen, n);
- return ProcXF86DRIQueryDirectRenderingCapable(client);
-}
-
-static int
-SProcXF86DRIDispatch (
- register ClientPtr client
-)
-{
- REQUEST(xReq);
-
- /*
- * Only local clients are allowed DRI access, but remote clients still need
- * these requests to find out cleanly.
- */
- switch (stuff->data)
- {
- case X_XF86DRIQueryVersion:
- return SProcXF86DRIQueryVersion(client);
- case X_XF86DRIQueryDirectRenderingCapable:
- return SProcXF86DRIQueryDirectRenderingCapable(client);
- default:
- return DRIErrorBase + XF86DRIClientNotLocal;
- }
-}
-
-void
-XFree86DRIExtensionInit(void)
-{
- ExtensionEntry* extEntry;
-
-#ifdef XF86DRI_EVENTS
- EventType = CreateNewResourceType(XF86DRIFreeEvents, "DRIEvent");
-#endif
-
- if (
- DRIExtensionInit() &&
-#ifdef XF86DRI_EVENTS
- EventType && ScreenPrivateIndex != -1 &&
-#endif
- (extEntry = AddExtension(XF86DRINAME,
- XF86DRINumberEvents,
- XF86DRINumberErrors,
- ProcXF86DRIDispatch,
- SProcXF86DRIDispatch,
- XF86DRIResetProc,
- StandardMinorOpcode))) {
- DRIReqCode = (unsigned char)extEntry->base;
- DRIErrorBase = extEntry->errorBase;
- }
-}
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright 2000 VA Linux Systems, 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, 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.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <martin@valinux.com>
+ * Jens Owen <jens@tungstengraphics.com>
+ * Rickard E. (Rik) Faith <faith@valinux.com>
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <string.h>
+
+#include "xf86.h"
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "dixstruct.h"
+#include "extnsionst.h"
+#include "colormapst.h"
+#include "cursorstr.h"
+#include "scrnintstr.h"
+#include "servermd.h"
+#define _XF86DRI_SERVER_
+#include <X11/dri/xf86driproto.h>
+#include "swaprep.h"
+#include "xf86str.h"
+#include "dri.h"
+#include "sarea.h"
+#include "dristruct.h"
+#include "xf86drm.h"
+#include "protocol-versions.h"
+
+static int DRIErrorBase;
+
+
+
+static void XF86DRIResetProc(ExtensionEntry* extEntry);
+
+static unsigned char DRIReqCode = 0;
+
+extern void XFree86DRIExtensionInit(void);
+
+/*ARGSUSED*/
+static void
+XF86DRIResetProc (
+ ExtensionEntry* extEntry
+)
+{
+ DRIReset();
+}
+
+static int
+ProcXF86DRIQueryVersion(
+ register ClientPtr client
+)
+{
+ xXF86DRIQueryVersionReply rep;
+ register int n;
+
+ REQUEST_SIZE_MATCH(xXF86DRIQueryVersionReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.majorVersion = SERVER_XF86DRI_MAJOR_VERSION;
+ rep.minorVersion = SERVER_XF86DRI_MINOR_VERSION;
+ rep.patchVersion = SERVER_XF86DRI_PATCH_VERSION;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swaps(&rep.majorVersion, n);
+ swaps(&rep.minorVersion, n);
+ swapl(&rep.patchVersion, n);
+ }
+ WriteToClient(client, sizeof(xXF86DRIQueryVersionReply), (char *)&rep);
+ return Success;
+}
+
+static int
+ProcXF86DRIQueryDirectRenderingCapable(
+ register ClientPtr client
+)
+{
+ xXF86DRIQueryDirectRenderingCapableReply rep;
+ Bool isCapable;
+ register int n;
+
+ REQUEST(xXF86DRIQueryDirectRenderingCapableReq);
+ REQUEST_SIZE_MATCH(xXF86DRIQueryDirectRenderingCapableReq);
+ if (stuff->screen >= screenInfo.numScreens) {
+ client->errorValue = stuff->screen;
+ return BadValue;
+ }
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ if (!DRIQueryDirectRenderingCapable( screenInfo.screens[stuff->screen],
+ &isCapable)) {
+ return BadValue;
+ }
+ rep.isCapable = isCapable;
+
+ if (!LocalClient(client) || client->swapped)
+ rep.isCapable = 0;
+
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ }
+
+ WriteToClient(client,
+ sizeof(xXF86DRIQueryDirectRenderingCapableReply), (char *)&rep);
+ return Success;
+}
+
+static int
+ProcXF86DRIOpenConnection(
+ register ClientPtr client
+)
+{
+ xXF86DRIOpenConnectionReply rep;
+ drm_handle_t hSAREA;
+ char* busIdString;
+
+ REQUEST(xXF86DRIOpenConnectionReq);
+ REQUEST_SIZE_MATCH(xXF86DRIOpenConnectionReq);
+ if (stuff->screen >= screenInfo.numScreens) {
+ client->errorValue = stuff->screen;
+ return BadValue;
+ }
+
+ if (!DRIOpenConnection( screenInfo.screens[stuff->screen],
+ &hSAREA,
+ &busIdString)) {
+ return BadValue;
+ }
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.busIdStringLength = 0;
+ if (busIdString)
+ rep.busIdStringLength = strlen(busIdString);
+ rep.length = bytes_to_int32(SIZEOF(xXF86DRIOpenConnectionReply) - SIZEOF(xGenericReply) +
+ pad_to_int32(rep.busIdStringLength));
+
+ rep.hSAREALow = (CARD32)(hSAREA & 0xffffffff);
+#if defined(LONG64) && !defined(__linux__)
+ rep.hSAREAHigh = (CARD32)(hSAREA >> 32);
+#else
+ rep.hSAREAHigh = 0;
+#endif
+
+ WriteToClient(client, sizeof(xXF86DRIOpenConnectionReply), (char *)&rep);
+ if (rep.busIdStringLength)
+ WriteToClient(client, rep.busIdStringLength, busIdString);
+ return Success;
+}
+
+static int
+ProcXF86DRIAuthConnection(
+ register ClientPtr client
+)
+{
+ xXF86DRIAuthConnectionReply rep;
+
+ REQUEST(xXF86DRIAuthConnectionReq);
+ REQUEST_SIZE_MATCH(xXF86DRIAuthConnectionReq);
+ if (stuff->screen >= screenInfo.numScreens) {
+ client->errorValue = stuff->screen;
+ return BadValue;
+ }
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.authenticated = 1;
+
+ if (!DRIAuthConnection( screenInfo.screens[stuff->screen], stuff->magic)) {
+ ErrorF("Failed to authenticate %lu\n", (unsigned long)stuff->magic);
+ rep.authenticated = 0;
+ }
+ WriteToClient(client, sizeof(xXF86DRIAuthConnectionReply), (char *)&rep);
+ return Success;
+}
+
+static int
+ProcXF86DRICloseConnection(
+ register ClientPtr client
+)
+{
+ REQUEST(xXF86DRICloseConnectionReq);
+ REQUEST_SIZE_MATCH(xXF86DRICloseConnectionReq);
+ if (stuff->screen >= screenInfo.numScreens) {
+ client->errorValue = stuff->screen;
+ return BadValue;
+ }
+
+ DRICloseConnection( screenInfo.screens[stuff->screen]);
+
+ return Success;
+}
+
+static int
+ProcXF86DRIGetClientDriverName(
+ register ClientPtr client
+)
+{
+ xXF86DRIGetClientDriverNameReply rep;
+ char* clientDriverName;
+
+ REQUEST(xXF86DRIGetClientDriverNameReq);
+ REQUEST_SIZE_MATCH(xXF86DRIGetClientDriverNameReq);
+ if (stuff->screen >= screenInfo.numScreens) {
+ client->errorValue = stuff->screen;
+ return BadValue;
+ }
+
+ DRIGetClientDriverName( screenInfo.screens[stuff->screen],
+ (int *)&rep.ddxDriverMajorVersion,
+ (int *)&rep.ddxDriverMinorVersion,
+ (int *)&rep.ddxDriverPatchVersion,
+ &clientDriverName);
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.clientDriverNameLength = 0;
+ if (clientDriverName)
+ rep.clientDriverNameLength = strlen(clientDriverName);
+ rep.length = bytes_to_int32(SIZEOF(xXF86DRIGetClientDriverNameReply) -
+ SIZEOF(xGenericReply) +
+ pad_to_int32(rep.clientDriverNameLength));
+
+ WriteToClient(client,
+ sizeof(xXF86DRIGetClientDriverNameReply), (char *)&rep);
+ if (rep.clientDriverNameLength)
+ WriteToClient(client,
+ rep.clientDriverNameLength,
+ clientDriverName);
+ return Success;
+}
+
+static int
+ProcXF86DRICreateContext(
+ register ClientPtr client
+)
+{
+ xXF86DRICreateContextReply rep;
+ ScreenPtr pScreen;
+
+ REQUEST(xXF86DRICreateContextReq);
+ REQUEST_SIZE_MATCH(xXF86DRICreateContextReq);
+ if (stuff->screen >= screenInfo.numScreens) {
+ client->errorValue = stuff->screen;
+ return BadValue;
+ }
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ pScreen = screenInfo.screens[stuff->screen];
+
+ if (!DRICreateContext( pScreen,
+ NULL,
+ stuff->context,
+ (drm_context_t *)&rep.hHWContext)) {
+ return BadValue;
+ }
+
+ WriteToClient(client, sizeof(xXF86DRICreateContextReply), (char *)&rep);
+ return Success;
+}
+
+static int
+ProcXF86DRIDestroyContext(
+ register ClientPtr client
+)
+{
+ REQUEST(xXF86DRIDestroyContextReq);
+ REQUEST_SIZE_MATCH(xXF86DRIDestroyContextReq);
+ if (stuff->screen >= screenInfo.numScreens) {
+ client->errorValue = stuff->screen;
+ return BadValue;
+ }
+
+ if (!DRIDestroyContext( screenInfo.screens[stuff->screen],
+ stuff->context)) {
+ return BadValue;
+ }
+
+ return Success;
+}
+
+static int
+ProcXF86DRICreateDrawable(
+ ClientPtr client
+)
+{
+ xXF86DRICreateDrawableReply rep;
+ DrawablePtr pDrawable;
+ int rc;
+
+ REQUEST(xXF86DRICreateDrawableReq);
+ REQUEST_SIZE_MATCH(xXF86DRICreateDrawableReq);
+ if (stuff->screen >= screenInfo.numScreens) {
+ client->errorValue = stuff->screen;
+ return BadValue;
+ }
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
+ DixReadAccess);
+ if (rc != Success)
+ return rc;
+
+ if (!DRICreateDrawable(screenInfo.screens[stuff->screen], client,
+ pDrawable, (drm_drawable_t *)&rep.hHWDrawable)) {
+ return BadValue;
+ }
+
+ WriteToClient(client, sizeof(xXF86DRICreateDrawableReply), (char *)&rep);
+ return Success;
+}
+
+static int
+ProcXF86DRIDestroyDrawable(
+ register ClientPtr client
+)
+{
+ REQUEST(xXF86DRIDestroyDrawableReq);
+ DrawablePtr pDrawable;
+ int rc;
+ REQUEST_SIZE_MATCH(xXF86DRIDestroyDrawableReq);
+
+ if (stuff->screen >= screenInfo.numScreens) {
+ client->errorValue = stuff->screen;
+ return BadValue;
+ }
+
+ rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
+ DixReadAccess);
+ if (rc != Success)
+ return rc;
+
+ if (!DRIDestroyDrawable(screenInfo.screens[stuff->screen], client,
+ pDrawable)) {
+ return BadValue;
+ }
+
+ return Success;
+}
+
+static int
+ProcXF86DRIGetDrawableInfo(
+ register ClientPtr client
+)
+{
+ xXF86DRIGetDrawableInfoReply rep;
+ DrawablePtr pDrawable;
+ int X, Y, W, H;
+ drm_clip_rect_t * pClipRects, *pClippedRects;
+ drm_clip_rect_t * pBackClipRects;
+ int backX, backY, rc;
+
+ REQUEST(xXF86DRIGetDrawableInfoReq);
+ REQUEST_SIZE_MATCH(xXF86DRIGetDrawableInfoReq);
+ if (stuff->screen >= screenInfo.numScreens) {
+ client->errorValue = stuff->screen;
+ return BadValue;
+ }
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
+ DixReadAccess);
+ if (rc != Success)
+ return rc;
+
+ if (!DRIGetDrawableInfo( screenInfo.screens[stuff->screen],
+ pDrawable,
+ (unsigned int*)&rep.drawableTableIndex,
+ (unsigned int*)&rep.drawableTableStamp,
+ (int*)&X,
+ (int*)&Y,
+ (int*)&W,
+ (int*)&H,
+ (int*)&rep.numClipRects,
+ &pClipRects,
+ &backX,
+ &backY,
+ (int*)&rep.numBackClipRects,
+ &pBackClipRects)) {
+ return BadValue;
+ }
+
+ rep.drawableX = X;
+ rep.drawableY = Y;
+ rep.drawableWidth = W;
+ rep.drawableHeight = H;
+ rep.length = (SIZEOF(xXF86DRIGetDrawableInfoReply) -
+ SIZEOF(xGenericReply));
+
+ rep.backX = backX;
+ rep.backY = backY;
+
+ if (rep.numBackClipRects)
+ rep.length += sizeof(drm_clip_rect_t) * rep.numBackClipRects;
+
+ pClippedRects = pClipRects;
+
+ if (rep.numClipRects) {
+ /* Clip cliprects to screen dimensions (redirected windows) */
+ pClippedRects = malloc(rep.numClipRects * sizeof(drm_clip_rect_t));
+
+ if (pClippedRects) {
+ ScreenPtr pScreen = screenInfo.screens[stuff->screen];
+ int i, j;
+
+ for (i = 0, j = 0; i < rep.numClipRects; i++) {
+ pClippedRects[j].x1 = max(pClipRects[i].x1, 0);
+ pClippedRects[j].y1 = max(pClipRects[i].y1, 0);
+ pClippedRects[j].x2 = min(pClipRects[i].x2, pScreen->width);
+ pClippedRects[j].y2 = min(pClipRects[i].y2, pScreen->height);
+
+ if (pClippedRects[j].x1 < pClippedRects[j].x2 &&
+ pClippedRects[j].y1 < pClippedRects[j].y2) {
+ j++;
+ }
+ }
+
+ rep.numClipRects = j;
+ } else {
+ rep.numClipRects = 0;
+ }
+
+ rep.length += sizeof(drm_clip_rect_t) * rep.numClipRects;
+ }
+
+ rep.length = bytes_to_int32(rep.length);
+
+ WriteToClient(client, sizeof(xXF86DRIGetDrawableInfoReply), (char *)&rep);
+
+ if (rep.numClipRects) {
+ WriteToClient(client,
+ sizeof(drm_clip_rect_t) * rep.numClipRects,
+ (char *)pClippedRects);
+ free(pClippedRects);
+ }
+
+ if (rep.numBackClipRects) {
+ WriteToClient(client,
+ sizeof(drm_clip_rect_t) * rep.numBackClipRects,
+ (char *)pBackClipRects);
+ }
+
+ return Success;
+}
+
+static int
+ProcXF86DRIGetDeviceInfo(
+ register ClientPtr client
+)
+{
+ xXF86DRIGetDeviceInfoReply rep;
+ drm_handle_t hFrameBuffer;
+ void *pDevPrivate;
+
+ REQUEST(xXF86DRIGetDeviceInfoReq);
+ REQUEST_SIZE_MATCH(xXF86DRIGetDeviceInfoReq);
+ if (stuff->screen >= screenInfo.numScreens) {
+ client->errorValue = stuff->screen;
+ return BadValue;
+ }
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ if (!DRIGetDeviceInfo( screenInfo.screens[stuff->screen],
+ &hFrameBuffer,
+ (int*)&rep.framebufferOrigin,
+ (int*)&rep.framebufferSize,
+ (int*)&rep.framebufferStride,
+ (int*)&rep.devPrivateSize,
+ &pDevPrivate)) {
+ return BadValue;
+ }
+
+ rep.hFrameBufferLow = (CARD32)(hFrameBuffer & 0xffffffff);
+#if defined(LONG64) && !defined(__linux__)
+ rep.hFrameBufferHigh = (CARD32)(hFrameBuffer >> 32);
+#else
+ rep.hFrameBufferHigh = 0;
+#endif
+
+ rep.length = 0;
+ if (rep.devPrivateSize) {
+ rep.length = bytes_to_int32(SIZEOF(xXF86DRIGetDeviceInfoReply) -
+ SIZEOF(xGenericReply) +
+ pad_to_int32(rep.devPrivateSize));
+ }
+
+ WriteToClient(client, sizeof(xXF86DRIGetDeviceInfoReply), (char *)&rep);
+ if (rep.length) {
+ WriteToClient(client, rep.devPrivateSize, (char *)pDevPrivate);
+ }
+ return Success;
+}
+
+static int
+ProcXF86DRIDispatch (
+ register ClientPtr client
+)
+{
+ REQUEST(xReq);
+
+ switch (stuff->data)
+ {
+ case X_XF86DRIQueryVersion:
+ return ProcXF86DRIQueryVersion(client);
+ case X_XF86DRIQueryDirectRenderingCapable:
+ return ProcXF86DRIQueryDirectRenderingCapable(client);
+ }
+
+ if (!LocalClient(client))
+ return DRIErrorBase + XF86DRIClientNotLocal;
+
+ switch (stuff->data)
+ {
+ case X_XF86DRIOpenConnection:
+ return ProcXF86DRIOpenConnection(client);
+ case X_XF86DRICloseConnection:
+ return ProcXF86DRICloseConnection(client);
+ case X_XF86DRIGetClientDriverName:
+ return ProcXF86DRIGetClientDriverName(client);
+ case X_XF86DRICreateContext:
+ return ProcXF86DRICreateContext(client);
+ case X_XF86DRIDestroyContext:
+ return ProcXF86DRIDestroyContext(client);
+ case X_XF86DRICreateDrawable:
+ return ProcXF86DRICreateDrawable(client);
+ case X_XF86DRIDestroyDrawable:
+ return ProcXF86DRIDestroyDrawable(client);
+ case X_XF86DRIGetDrawableInfo:
+ return ProcXF86DRIGetDrawableInfo(client);
+ case X_XF86DRIGetDeviceInfo:
+ return ProcXF86DRIGetDeviceInfo(client);
+ case X_XF86DRIAuthConnection:
+ return ProcXF86DRIAuthConnection(client);
+ /* {Open,Close}FullScreen are deprecated now */
+ default:
+ return BadRequest;
+ }
+}
+
+static int
+SProcXF86DRIQueryVersion(
+ register ClientPtr client
+)
+{
+ register int n;
+ REQUEST(xXF86DRIQueryVersionReq);
+ swaps(&stuff->length, n);
+ return ProcXF86DRIQueryVersion(client);
+}
+
+static int
+SProcXF86DRIQueryDirectRenderingCapable(
+ register ClientPtr client
+)
+{
+ register int n;
+ REQUEST(xXF86DRIQueryDirectRenderingCapableReq);
+ swaps(&stuff->length, n);
+ swapl(&stuff->screen, n);
+ return ProcXF86DRIQueryDirectRenderingCapable(client);
+}
+
+static int
+SProcXF86DRIDispatch (
+ register ClientPtr client
+)
+{
+ REQUEST(xReq);
+
+ /*
+ * Only local clients are allowed DRI access, but remote clients still need
+ * these requests to find out cleanly.
+ */
+ switch (stuff->data)
+ {
+ case X_XF86DRIQueryVersion:
+ return SProcXF86DRIQueryVersion(client);
+ case X_XF86DRIQueryDirectRenderingCapable:
+ return SProcXF86DRIQueryDirectRenderingCapable(client);
+ default:
+ return DRIErrorBase + XF86DRIClientNotLocal;
+ }
+}
+
+void
+XFree86DRIExtensionInit(void)
+{
+ ExtensionEntry* extEntry;
+
+#ifdef XF86DRI_EVENTS
+ EventType = CreateNewResourceType(XF86DRIFreeEvents, "DRIEvent");
+#endif
+
+ if (
+ DRIExtensionInit() &&
+#ifdef XF86DRI_EVENTS
+ EventType && ScreenPrivateIndex != -1 &&
+#endif
+ (extEntry = AddExtension(XF86DRINAME,
+ XF86DRINumberEvents,
+ XF86DRINumberErrors,
+ ProcXF86DRIDispatch,
+ SProcXF86DRIDispatch,
+ XF86DRIResetProc,
+ StandardMinorOpcode))) {
+ DRIReqCode = (unsigned char)extEntry->base;
+ DRIErrorBase = extEntry->errorBase;
+ }
+}
diff --git a/xorg-server/hw/xfree86/dri2/dri2.c b/xorg-server/hw/xfree86/dri2/dri2.c
index d96eba451..af3bcaefe 100644
--- a/xorg-server/hw/xfree86/dri2/dri2.c
+++ b/xorg-server/hw/xfree86/dri2/dri2.c
@@ -1,1242 +1,1242 @@
-/*
- * Copyright © 2007, 2008 Red Hat, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Soft-
- * ware"), to deal in the Software without restriction, including without
- * limitation the rights to use, copy, modify, merge, publish, distribute,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, provided that the above copyright
- * notice(s) and this permission notice appear in all copies of the Soft-
- * ware and that both the above copyright notice(s) and this permission
- * notice appear in supporting documentation.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
- * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
- * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
- * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
- * QUENTIAL 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 PERFOR-
- * MANCE OF THIS SOFTWARE.
- *
- * Except as contained in this notice, the name of a copyright holder shall
- * not be used in advertising or otherwise to promote the sale, use or
- * other dealings in this Software without prior written authorization of
- * the copyright holder.
- *
- * Authors:
- * Kristian Høgsberg (krh@redhat.com)
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <errno.h>
-#ifdef WITH_LIBDRM
-#include <xf86drm.h>
-#endif
-#include "xf86Module.h"
-#include "list.h"
-#include "scrnintstr.h"
-#include "windowstr.h"
-#include "dixstruct.h"
-#include "dri2.h"
-#include "xf86VGAarbiter.h"
-
-#include "xf86.h"
-
-CARD8 dri2_major; /* version of DRI2 supported by DDX */
-CARD8 dri2_minor;
-
-static DevPrivateKeyRec dri2ScreenPrivateKeyRec;
-#define dri2ScreenPrivateKey (&dri2ScreenPrivateKeyRec)
-
-static DevPrivateKeyRec dri2WindowPrivateKeyRec;
-#define dri2WindowPrivateKey (&dri2WindowPrivateKeyRec)
-
-static DevPrivateKeyRec dri2PixmapPrivateKeyRec;
-#define dri2PixmapPrivateKey (&dri2PixmapPrivateKeyRec)
-
-static RESTYPE dri2DrawableRes;
-
-typedef struct _DRI2Screen *DRI2ScreenPtr;
-
-typedef struct _DRI2Drawable {
- DRI2ScreenPtr dri2_screen;
- DrawablePtr drawable;
- struct list reference_list;
- int width;
- int height;
- DRI2BufferPtr *buffers;
- int bufferCount;
- unsigned int swapsPending;
- ClientPtr blockedClient;
- Bool blockedOnMsc;
- int swap_interval;
- CARD64 swap_count;
- int64_t target_sbc; /* -1 means no SBC wait outstanding */
- CARD64 last_swap_target; /* most recently queued swap target */
- CARD64 last_swap_msc; /* msc at completion of most recent swap */
- CARD64 last_swap_ust; /* ust at completion of most recent swap */
- int swap_limit; /* for N-buffering */
- unsigned long serialNumber;
- Bool needInvalidate;
-} DRI2DrawableRec, *DRI2DrawablePtr;
-
-typedef struct _DRI2Screen {
- ScreenPtr screen;
- int refcnt;
- unsigned int numDrivers;
- const char **driverNames;
- const char *deviceName;
- int fd;
- unsigned int lastSequence;
-
- DRI2CreateBufferProcPtr CreateBuffer;
- DRI2DestroyBufferProcPtr DestroyBuffer;
- DRI2CopyRegionProcPtr CopyRegion;
- DRI2ScheduleSwapProcPtr ScheduleSwap;
- DRI2GetMSCProcPtr GetMSC;
- DRI2ScheduleWaitMSCProcPtr ScheduleWaitMSC;
- DRI2AuthMagicProcPtr AuthMagic;
-
- HandleExposuresProcPtr HandleExposures;
-
- ConfigNotifyProcPtr ConfigNotify;
-} DRI2ScreenRec;
-
-static DRI2ScreenPtr
-DRI2GetScreen(ScreenPtr pScreen)
-{
- return dixLookupPrivate(&pScreen->devPrivates, dri2ScreenPrivateKey);
-}
-
-static DRI2DrawablePtr
-DRI2GetDrawable(DrawablePtr pDraw)
-{
- WindowPtr pWin;
- PixmapPtr pPixmap;
-
- switch (pDraw->type) {
- case DRAWABLE_WINDOW:
- pWin = (WindowPtr) pDraw;
- return dixLookupPrivate(&pWin->devPrivates, dri2WindowPrivateKey);
- case DRAWABLE_PIXMAP:
- pPixmap = (PixmapPtr) pDraw;
- return dixLookupPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey);
- default:
- return NULL;
- }
-}
-
-static unsigned long
-DRI2DrawableSerial(DrawablePtr pDraw)
-{
- ScreenPtr pScreen = pDraw->pScreen;
- PixmapPtr pPix;
-
- if (pDraw->type != DRAWABLE_WINDOW)
- return pDraw->serialNumber;
-
- pPix = pScreen->GetWindowPixmap((WindowPtr)pDraw);
- return pPix->drawable.serialNumber;
-}
-
-static DRI2DrawablePtr
-DRI2AllocateDrawable(DrawablePtr pDraw)
-{
- DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
- DRI2DrawablePtr pPriv;
- CARD64 ust;
- WindowPtr pWin;
- PixmapPtr pPixmap;
-
- pPriv = malloc(sizeof *pPriv);
- if (pPriv == NULL)
- return NULL;
-
- pPriv->dri2_screen = ds;
- pPriv->drawable = pDraw;
- pPriv->width = pDraw->width;
- pPriv->height = pDraw->height;
- pPriv->buffers = NULL;
- pPriv->bufferCount = 0;
- pPriv->swapsPending = 0;
- pPriv->blockedClient = NULL;
- pPriv->blockedOnMsc = FALSE;
- pPriv->swap_count = 0;
- pPriv->target_sbc = -1;
- pPriv->swap_interval = 1;
- /* Initialize last swap target from DDX if possible */
- if (!ds->GetMSC || !(*ds->GetMSC)(pDraw, &ust, &pPriv->last_swap_target))
- pPriv->last_swap_target = 0;
-
- pPriv->swap_limit = 1; /* default to double buffering */
- pPriv->last_swap_msc = 0;
- pPriv->last_swap_ust = 0;
- list_init(&pPriv->reference_list);
- pPriv->serialNumber = DRI2DrawableSerial(pDraw);
-
- if (pDraw->type == DRAWABLE_WINDOW) {
- pWin = (WindowPtr) pDraw;
- dixSetPrivate(&pWin->devPrivates, dri2WindowPrivateKey, pPriv);
- } else {
- pPixmap = (PixmapPtr) pDraw;
- dixSetPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey, pPriv);
- }
-
- return pPriv;
-}
-
-typedef struct DRI2DrawableRefRec {
- XID id;
- XID dri2_id;
- DRI2InvalidateProcPtr invalidate;
- void *priv;
- struct list link;
-} DRI2DrawableRefRec, *DRI2DrawableRefPtr;
-
-static DRI2DrawableRefPtr
-DRI2LookupDrawableRef(DRI2DrawablePtr pPriv, XID id)
-{
- DRI2DrawableRefPtr ref;
-
- list_for_each_entry(ref, &pPriv->reference_list, link) {
- if (ref->id == id)
- return ref;
- }
-
- return NULL;
-}
-
-static int
-DRI2AddDrawableRef(DRI2DrawablePtr pPriv, XID id, XID dri2_id,
- DRI2InvalidateProcPtr invalidate, void *priv)
-{
- DRI2DrawableRefPtr ref;
-
- ref = malloc(sizeof *ref);
- if (ref == NULL)
- return BadAlloc;
-
- if (!AddResource(dri2_id, dri2DrawableRes, pPriv)) {
- free(ref);
- return BadAlloc;
- }
- if (!DRI2LookupDrawableRef(pPriv, id))
- if (!AddResource(id, dri2DrawableRes, pPriv)) {
- FreeResourceByType(dri2_id, dri2DrawableRes, TRUE);
- free(ref);
- return BadAlloc;
- }
-
- ref->id = id;
- ref->dri2_id = dri2_id;
- ref->invalidate = invalidate;
- ref->priv = priv;
- list_add(&ref->link, &pPriv->reference_list);
-
- return Success;
-}
-
-int
-DRI2CreateDrawable(ClientPtr client, DrawablePtr pDraw, XID id,
- DRI2InvalidateProcPtr invalidate, void *priv)
-{
- DRI2DrawablePtr pPriv;
- XID dri2_id;
- int rc;
-
- pPriv = DRI2GetDrawable(pDraw);
- if (pPriv == NULL)
- pPriv = DRI2AllocateDrawable(pDraw);
- if (pPriv == NULL)
- return BadAlloc;
-
- dri2_id = FakeClientID(client->index);
- rc = DRI2AddDrawableRef(pPriv, id, dri2_id, invalidate, priv);
- if (rc != Success)
- return rc;
-
- return Success;
-}
-
-static int DRI2DrawableGone(pointer p, XID id)
-{
- DRI2DrawablePtr pPriv = p;
- DRI2ScreenPtr ds = pPriv->dri2_screen;
- DRI2DrawableRefPtr ref, next;
- WindowPtr pWin;
- PixmapPtr pPixmap;
- DrawablePtr pDraw;
- int i;
-
- list_for_each_entry_safe(ref, next, &pPriv->reference_list, link) {
- if (ref->dri2_id == id) {
- list_del(&ref->link);
- /* If this was the last ref under this X drawable XID,
- * unregister the X drawable resource. */
- if (!DRI2LookupDrawableRef(pPriv, ref->id))
- FreeResourceByType(ref->id, dri2DrawableRes, TRUE);
- free(ref);
- break;
- }
-
- if (ref->id == id) {
- list_del(&ref->link);
- FreeResourceByType(ref->dri2_id, dri2DrawableRes, TRUE);
- free(ref);
- }
- }
-
- if (!list_is_empty(&pPriv->reference_list))
- return Success;
-
- pDraw = pPriv->drawable;
- if (pDraw->type == DRAWABLE_WINDOW) {
- pWin = (WindowPtr) pDraw;
- dixSetPrivate(&pWin->devPrivates, dri2WindowPrivateKey, NULL);
- } else {
- pPixmap = (PixmapPtr) pDraw;
- dixSetPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey, NULL);
- }
-
- if (pPriv->buffers != NULL) {
- for (i = 0; i < pPriv->bufferCount; i++)
- (*ds->DestroyBuffer)(pDraw, pPriv->buffers[i]);
-
- free(pPriv->buffers);
- }
-
- free(pPriv);
-
- return Success;
-}
-
-static int
-find_attachment(DRI2DrawablePtr pPriv, unsigned attachment)
-{
- int i;
-
- if (pPriv->buffers == NULL) {
- return -1;
- }
-
- for (i = 0; i < pPriv->bufferCount; i++) {
- if ((pPriv->buffers[i] != NULL)
- && (pPriv->buffers[i]->attachment == attachment)) {
- return i;
- }
- }
-
- return -1;
-}
-
-static Bool
-allocate_or_reuse_buffer(DrawablePtr pDraw, DRI2ScreenPtr ds,
- DRI2DrawablePtr pPriv,
- unsigned int attachment, unsigned int format,
- int dimensions_match, DRI2BufferPtr *buffer)
-{
- int old_buf = find_attachment(pPriv, attachment);
-
- if ((old_buf < 0)
- || !dimensions_match
- || (pPriv->buffers[old_buf]->format != format)) {
- *buffer = (*ds->CreateBuffer)(pDraw, attachment, format);
- pPriv->serialNumber = DRI2DrawableSerial(pDraw);
- return TRUE;
-
- } else {
- *buffer = pPriv->buffers[old_buf];
- pPriv->buffers[old_buf] = NULL;
- return FALSE;
- }
-}
-
-static void
-update_dri2_drawable_buffers(DRI2DrawablePtr pPriv, DrawablePtr pDraw,
- DRI2BufferPtr *buffers, int out_count, int *width, int *height)
-{
- DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
- int i;
-
- if (pPriv->buffers != NULL) {
- for (i = 0; i < pPriv->bufferCount; i++) {
- if (pPriv->buffers[i] != NULL) {
- (*ds->DestroyBuffer)(pDraw, pPriv->buffers[i]);
- }
- }
-
- free(pPriv->buffers);
- }
-
- pPriv->buffers = buffers;
- pPriv->bufferCount = out_count;
- pPriv->width = pDraw->width;
- pPriv->height = pDraw->height;
- *width = pPriv->width;
- *height = pPriv->height;
-}
-
-static DRI2BufferPtr *
-do_get_buffers(DrawablePtr pDraw, int *width, int *height,
- unsigned int *attachments, int count, int *out_count,
- int has_format)
-{
- DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
- DRI2DrawablePtr pPriv = DRI2GetDrawable(pDraw);
- DRI2BufferPtr *buffers;
- int need_real_front = 0;
- int need_fake_front = 0;
- int have_fake_front = 0;
- int front_format = 0;
- int dimensions_match;
- int buffers_changed = 0;
- int i;
-
- if (!pPriv) {
- *width = pDraw->width;
- *height = pDraw->height;
- *out_count = 0;
- return NULL;
- }
-
- dimensions_match = (pDraw->width == pPriv->width)
- && (pDraw->height == pPriv->height)
- && (pPriv->serialNumber == DRI2DrawableSerial(pDraw));
-
- buffers = calloc((count + 1), sizeof(buffers[0]));
- if (!buffers)
- goto err_out;
-
- for (i = 0; i < count; i++) {
- const unsigned attachment = *(attachments++);
- const unsigned format = (has_format) ? *(attachments++) : 0;
-
- if (allocate_or_reuse_buffer(pDraw, ds, pPriv, attachment,
- format, dimensions_match,
- &buffers[i]))
- buffers_changed = 1;
-
- if (buffers[i] == NULL)
- goto err_out;
-
- /* If the drawable is a window and the front-buffer is requested,
- * silently add the fake front-buffer to the list of requested
- * attachments. The counting logic in the loop accounts for the case
- * where the client requests both the fake and real front-buffer.
- */
- if (attachment == DRI2BufferBackLeft) {
- need_real_front++;
- front_format = format;
- }
-
- if (attachment == DRI2BufferFrontLeft) {
- need_real_front--;
- front_format = format;
-
- if (pDraw->type == DRAWABLE_WINDOW) {
- need_fake_front++;
- }
- }
-
- if (pDraw->type == DRAWABLE_WINDOW) {
- if (attachment == DRI2BufferFakeFrontLeft) {
- need_fake_front--;
- have_fake_front = 1;
- }
- }
- }
-
- if (need_real_front > 0) {
- if (allocate_or_reuse_buffer(pDraw, ds, pPriv, DRI2BufferFrontLeft,
- front_format, dimensions_match,
- &buffers[i]))
- buffers_changed = 1;
-
- if (buffers[i] == NULL)
- goto err_out;
- i++;
- }
-
- if (need_fake_front > 0) {
- if (allocate_or_reuse_buffer(pDraw, ds, pPriv, DRI2BufferFakeFrontLeft,
- front_format, dimensions_match,
- &buffers[i]))
- buffers_changed = 1;
-
- if (buffers[i] == NULL)
- goto err_out;
-
- i++;
- have_fake_front = 1;
- }
-
- *out_count = i;
-
- update_dri2_drawable_buffers(pPriv, pDraw, buffers, *out_count, width, height);
-
- /* If the client is getting a fake front-buffer, pre-fill it with the
- * contents of the real front-buffer. This ensures correct operation of
- * applications that call glXWaitX before calling glDrawBuffer.
- */
- if (have_fake_front && buffers_changed) {
- BoxRec box;
- RegionRec region;
-
- box.x1 = 0;
- box.y1 = 0;
- box.x2 = pPriv->width;
- box.y2 = pPriv->height;
- RegionInit(&region, &box, 0);
-
- DRI2CopyRegion(pDraw, &region, DRI2BufferFakeFrontLeft,
- DRI2BufferFrontLeft);
- }
-
- pPriv->needInvalidate = TRUE;
-
- return pPriv->buffers;
-
-err_out:
-
- *out_count = 0;
-
- if (buffers) {
- for (i = 0; i < count; i++) {
- if (buffers[i] != NULL)
- (*ds->DestroyBuffer)(pDraw, buffers[i]);
- }
-
- free(buffers);
- buffers = NULL;
- }
-
- update_dri2_drawable_buffers(pPriv, pDraw, buffers, *out_count, width, height);
-
- return buffers;
-}
-
-DRI2BufferPtr *
-DRI2GetBuffers(DrawablePtr pDraw, int *width, int *height,
- unsigned int *attachments, int count, int *out_count)
-{
- return do_get_buffers(pDraw, width, height, attachments, count,
- out_count, FALSE);
-}
-
-DRI2BufferPtr *
-DRI2GetBuffersWithFormat(DrawablePtr pDraw, int *width, int *height,
- unsigned int *attachments, int count, int *out_count)
-{
- return do_get_buffers(pDraw, width, height, attachments, count,
- out_count, TRUE);
-}
-
-static void
-DRI2InvalidateDrawable(DrawablePtr pDraw)
-{
- DRI2DrawablePtr pPriv = DRI2GetDrawable(pDraw);
- DRI2DrawableRefPtr ref;
-
- if (!pPriv || !pPriv->needInvalidate)
- return;
-
- pPriv->needInvalidate = FALSE;
-
- list_for_each_entry(ref, &pPriv->reference_list, link)
- ref->invalidate(pDraw, ref->priv);
-}
-
-/*
- * In the direct rendered case, we throttle the clients that have more
- * than their share of outstanding swaps (and thus busy buffers) when a
- * new GetBuffers request is received. In the AIGLX case, we allow the
- * client to get the new buffers, but throttle when the next GLX request
- * comes in (see __glXDRIcontextWait()).
- */
-Bool
-DRI2ThrottleClient(ClientPtr client, DrawablePtr pDraw)
-{
- DRI2DrawablePtr pPriv;
-
- pPriv = DRI2GetDrawable(pDraw);
- if (pPriv == NULL)
- return FALSE;
-
- /* Throttle to swap limit */
- if ((pPriv->swapsPending >= pPriv->swap_limit) &&
- !pPriv->blockedClient) {
- ResetCurrentRequest(client);
- client->sequence--;
- IgnoreClient(client);
- pPriv->blockedClient = client;
- return TRUE;
- }
-
- return FALSE;
-}
-
-static void
-__DRI2BlockClient(ClientPtr client, DRI2DrawablePtr pPriv)
-{
- if (pPriv->blockedClient == NULL) {
- IgnoreClient(client);
- pPriv->blockedClient = client;
- }
-}
-
-void
-DRI2BlockClient(ClientPtr client, DrawablePtr pDraw)
-{
- DRI2DrawablePtr pPriv;
-
- pPriv = DRI2GetDrawable(pDraw);
- if (pPriv == NULL)
- return;
-
- __DRI2BlockClient(client, pPriv);
- pPriv->blockedOnMsc = TRUE;
-}
-
-int
-DRI2CopyRegion(DrawablePtr pDraw, RegionPtr pRegion,
- unsigned int dest, unsigned int src)
-{
- DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
- DRI2DrawablePtr pPriv;
- DRI2BufferPtr pDestBuffer, pSrcBuffer;
- int i;
-
- pPriv = DRI2GetDrawable(pDraw);
- if (pPriv == NULL)
- return BadDrawable;
-
- pDestBuffer = NULL;
- pSrcBuffer = NULL;
- for (i = 0; i < pPriv->bufferCount; i++)
- {
- if (pPriv->buffers[i]->attachment == dest)
- pDestBuffer = (DRI2BufferPtr) pPriv->buffers[i];
- if (pPriv->buffers[i]->attachment == src)
- pSrcBuffer = (DRI2BufferPtr) pPriv->buffers[i];
- }
- if (pSrcBuffer == NULL || pDestBuffer == NULL)
- return BadValue;
-
- (*ds->CopyRegion)(pDraw, pRegion, pDestBuffer, pSrcBuffer);
-
- return Success;
-}
-
-/* Can this drawable be page flipped? */
-Bool
-DRI2CanFlip(DrawablePtr pDraw)
-{
- ScreenPtr pScreen = pDraw->pScreen;
- WindowPtr pWin, pRoot;
- PixmapPtr pWinPixmap, pRootPixmap;
-
- if (pDraw->type == DRAWABLE_PIXMAP)
- return TRUE;
-
- pRoot = pScreen->root;
- pRootPixmap = pScreen->GetWindowPixmap(pRoot);
-
- pWin = (WindowPtr) pDraw;
- pWinPixmap = pScreen->GetWindowPixmap(pWin);
- if (pRootPixmap != pWinPixmap)
- return FALSE;
- if (!RegionEqual(&pWin->clipList, &pRoot->winSize))
- return FALSE;
-
- /* Does the window match the pixmap exactly? */
- if (pDraw->x != 0 ||
- pDraw->y != 0 ||
-#ifdef COMPOSITE
- pDraw->x != pWinPixmap->screen_x ||
- pDraw->y != pWinPixmap->screen_y ||
-#endif
- pDraw->width != pWinPixmap->drawable.width ||
- pDraw->height != pWinPixmap->drawable.height)
- return FALSE;
-
- return TRUE;
-}
-
-/* Can we do a pixmap exchange instead of a blit? */
-Bool
-DRI2CanExchange(DrawablePtr pDraw)
-{
- return FALSE;
-}
-
-void
-DRI2WaitMSCComplete(ClientPtr client, DrawablePtr pDraw, int frame,
- unsigned int tv_sec, unsigned int tv_usec)
-{
- DRI2DrawablePtr pPriv;
-
- pPriv = DRI2GetDrawable(pDraw);
- if (pPriv == NULL)
- return;
-
- ProcDRI2WaitMSCReply(client, ((CARD64)tv_sec * 1000000) + tv_usec,
- frame, pPriv->swap_count);
-
- if (pPriv->blockedClient)
- AttendClient(pPriv->blockedClient);
-
- pPriv->blockedClient = NULL;
- pPriv->blockedOnMsc = FALSE;
-}
-
-static void
-DRI2WakeClient(ClientPtr client, DrawablePtr pDraw, int frame,
- unsigned int tv_sec, unsigned int tv_usec)
-{
- ScreenPtr pScreen = pDraw->pScreen;
- DRI2DrawablePtr pPriv;
-
- pPriv = DRI2GetDrawable(pDraw);
- if (pPriv == NULL) {
- xf86DrvMsg(pScreen->myNum, X_ERROR,
- "[DRI2] %s: bad drawable\n", __func__);
- return;
- }
-
- /*
- * Swap completed.
- * Wake the client iff:
- * - it was waiting on SBC
- * - was blocked due to GLX make current
- * - was blocked due to swap throttling
- * - is not blocked due to an MSC wait
- */
- if (pPriv->target_sbc != -1 &&
- pPriv->target_sbc <= pPriv->swap_count) {
- ProcDRI2WaitMSCReply(client, ((CARD64)tv_sec * 1000000) + tv_usec,
- frame, pPriv->swap_count);
- pPriv->target_sbc = -1;
-
- AttendClient(pPriv->blockedClient);
- pPriv->blockedClient = NULL;
- } else if (pPriv->target_sbc == -1 && !pPriv->blockedOnMsc) {
- if (pPriv->blockedClient) {
- AttendClient(pPriv->blockedClient);
- pPriv->blockedClient = NULL;
- }
- }
-}
-
-void
-DRI2SwapComplete(ClientPtr client, DrawablePtr pDraw, int frame,
- unsigned int tv_sec, unsigned int tv_usec, int type,
- DRI2SwapEventPtr swap_complete, void *swap_data)
-{
- ScreenPtr pScreen = pDraw->pScreen;
- DRI2DrawablePtr pPriv;
- CARD64 ust = 0;
- BoxRec box;
- RegionRec region;
-
- pPriv = DRI2GetDrawable(pDraw);
- if (pPriv == NULL) {
- xf86DrvMsg(pScreen->myNum, X_ERROR,
- "[DRI2] %s: bad drawable\n", __func__);
- return;
- }
-
- pPriv->swapsPending--;
- pPriv->swap_count++;
-
- box.x1 = 0;
- box.y1 = 0;
- box.x2 = pDraw->width;
- box.y2 = pDraw->height;
- RegionInit(&region, &box, 0);
- DRI2CopyRegion(pDraw, &region, DRI2BufferFakeFrontLeft,
- DRI2BufferFrontLeft);
-
- ust = ((CARD64)tv_sec * 1000000) + tv_usec;
- if (swap_complete)
- swap_complete(client, swap_data, type, ust, frame, pPriv->swap_count);
-
- pPriv->last_swap_msc = frame;
- pPriv->last_swap_ust = ust;
-
- DRI2WakeClient(client, pDraw, frame, tv_sec, tv_usec);
-}
-
-Bool
-DRI2WaitSwap(ClientPtr client, DrawablePtr pDrawable)
-{
- DRI2DrawablePtr pPriv = DRI2GetDrawable(pDrawable);
-
- /* If we're currently waiting for a swap on this drawable, reset
- * the request and suspend the client. We only support one
- * blocked client per drawable. */
- if ((pPriv->swapsPending) &&
- pPriv->blockedClient == NULL) {
- ResetCurrentRequest(client);
- client->sequence--;
- __DRI2BlockClient(client, pPriv);
- return TRUE;
- }
-
- return FALSE;
-}
-
-int
-DRI2SwapBuffers(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
- CARD64 divisor, CARD64 remainder, CARD64 *swap_target,
- DRI2SwapEventPtr func, void *data)
-{
- ScreenPtr pScreen = pDraw->pScreen;
- DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
- DRI2DrawablePtr pPriv;
- DRI2BufferPtr pDestBuffer = NULL, pSrcBuffer = NULL;
- int ret, i;
- CARD64 ust, current_msc;
-
- pPriv = DRI2GetDrawable(pDraw);
- if (pPriv == NULL) {
- xf86DrvMsg(pScreen->myNum, X_ERROR,
- "[DRI2] %s: bad drawable\n", __func__);
- return BadDrawable;
- }
-
- for (i = 0; i < pPriv->bufferCount; i++) {
- if (pPriv->buffers[i]->attachment == DRI2BufferFrontLeft)
- pDestBuffer = (DRI2BufferPtr) pPriv->buffers[i];
- if (pPriv->buffers[i]->attachment == DRI2BufferBackLeft)
- pSrcBuffer = (DRI2BufferPtr) pPriv->buffers[i];
- }
- if (pSrcBuffer == NULL || pDestBuffer == NULL) {
- xf86DrvMsg(pScreen->myNum, X_ERROR,
- "[DRI2] %s: drawable has no back or front?\n", __func__);
- return BadDrawable;
- }
-
- /* Old DDX or no swap interval, just blit */
- if (!ds->ScheduleSwap || !pPriv->swap_interval) {
- BoxRec box;
- RegionRec region;
-
- box.x1 = 0;
- box.y1 = 0;
- box.x2 = pDraw->width;
- box.y2 = pDraw->height;
- RegionInit(&region, &box, 0);
-
- pPriv->swapsPending++;
-
- (*ds->CopyRegion)(pDraw, &region, pDestBuffer, pSrcBuffer);
- DRI2SwapComplete(client, pDraw, target_msc, 0, 0, DRI2_BLIT_COMPLETE,
- func, data);
- return Success;
- }
-
- /*
- * In the simple glXSwapBuffers case, all params will be 0, and we just
- * need to schedule a swap for the last swap target + the swap interval.
- */
- if (target_msc == 0 && divisor == 0 && remainder == 0) {
- /* If the current vblank count of the drawable's crtc is lower
- * than the count stored in last_swap_target from a previous swap
- * then reinitialize last_swap_target to the current crtc's msc,
- * otherwise the swap will hang. This will happen if the drawable
- * is moved to a crtc with a lower refresh rate, or a crtc that just
- * got enabled.
- */
- if (ds->GetMSC) {
- if (!(*ds->GetMSC)(pDraw, &ust, &current_msc))
- pPriv->last_swap_target = 0;
-
- if (current_msc < pPriv->last_swap_target)
- pPriv->last_swap_target = current_msc;
-
- }
-
- /*
- * Swap target for this swap is last swap target + swap interval since
- * we have to account for the current swap count, interval, and the
- * number of pending swaps.
- */
- *swap_target = pPriv->last_swap_target + pPriv->swap_interval;
-
- } else {
- /* glXSwapBuffersMscOML could have a 0 target_msc, honor it */
- *swap_target = target_msc;
- }
-
- pPriv->swapsPending++;
- ret = (*ds->ScheduleSwap)(client, pDraw, pDestBuffer, pSrcBuffer,
- swap_target, divisor, remainder, func, data);
- if (!ret) {
- pPriv->swapsPending--; /* didn't schedule */
- xf86DrvMsg(pScreen->myNum, X_ERROR,
- "[DRI2] %s: driver failed to schedule swap\n", __func__);
- return BadDrawable;
- }
-
- pPriv->last_swap_target = *swap_target;
-
- /* According to spec, return expected swapbuffers count SBC after this swap
- * will complete.
- */
- *swap_target = pPriv->swap_count + pPriv->swapsPending;
-
- DRI2InvalidateDrawable(pDraw);
-
- return Success;
-}
-
-void
-DRI2SwapInterval(DrawablePtr pDrawable, int interval)
-{
- ScreenPtr pScreen = pDrawable->pScreen;
- DRI2DrawablePtr pPriv = DRI2GetDrawable(pDrawable);
-
- if (pPriv == NULL) {
- xf86DrvMsg(pScreen->myNum, X_ERROR,
- "[DRI2] %s: bad drawable\n", __func__);
- return;
- }
-
- /* fixme: check against arbitrary max? */
- pPriv->swap_interval = interval;
-}
-
-int
-DRI2GetMSC(DrawablePtr pDraw, CARD64 *ust, CARD64 *msc, CARD64 *sbc)
-{
- ScreenPtr pScreen = pDraw->pScreen;
- DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
- DRI2DrawablePtr pPriv;
- Bool ret;
-
- pPriv = DRI2GetDrawable(pDraw);
- if (pPriv == NULL) {
- xf86DrvMsg(pScreen->myNum, X_ERROR,
- "[DRI2] %s: bad drawable\n", __func__);
- return BadDrawable;
- }
-
- if (!ds->GetMSC) {
- *ust = 0;
- *msc = 0;
- *sbc = pPriv->swap_count;
- return Success;
- }
-
- /*
- * Spec needs to be updated to include unmapped or redirected
- * drawables
- */
-
- ret = (*ds->GetMSC)(pDraw, ust, msc);
- if (!ret)
- return BadDrawable;
-
- *sbc = pPriv->swap_count;
-
- return Success;
-}
-
-int
-DRI2WaitMSC(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
- CARD64 divisor, CARD64 remainder)
-{
- DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
- DRI2DrawablePtr pPriv;
- Bool ret;
-
- pPriv = DRI2GetDrawable(pDraw);
- if (pPriv == NULL)
- return BadDrawable;
-
- /* Old DDX just completes immediately */
- if (!ds->ScheduleWaitMSC) {
- DRI2WaitMSCComplete(client, pDraw, target_msc, 0, 0);
-
- return Success;
- }
-
- ret = (*ds->ScheduleWaitMSC)(client, pDraw, target_msc, divisor, remainder);
- if (!ret)
- return BadDrawable;
-
- return Success;
-}
-
-int
-DRI2WaitSBC(ClientPtr client, DrawablePtr pDraw, CARD64 target_sbc)
-{
- DRI2DrawablePtr pPriv;
-
- pPriv = DRI2GetDrawable(pDraw);
- if (pPriv == NULL)
- return BadDrawable;
-
- /* target_sbc == 0 means to block until all pending swaps are
- * finished. Recalculate target_sbc to get that behaviour.
- */
- if (target_sbc == 0)
- target_sbc = pPriv->swap_count + pPriv->swapsPending;
-
- /* If current swap count already >= target_sbc, reply and
- * return immediately with (ust, msc, sbc) triplet of
- * most recent completed swap.
- */
- if (pPriv->swap_count >= target_sbc) {
- ProcDRI2WaitMSCReply(client, pPriv->last_swap_ust,
- pPriv->last_swap_msc, pPriv->swap_count);
- return Success;
- }
-
- pPriv->target_sbc = target_sbc;
- __DRI2BlockClient(client, pPriv);
-
- return Success;
-}
-
-Bool
-DRI2HasSwapControl(ScreenPtr pScreen)
-{
- DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
-
- return ds->ScheduleSwap && ds->GetMSC;
-}
-
-Bool
-DRI2Connect(ScreenPtr pScreen, unsigned int driverType, int *fd,
- const char **driverName, const char **deviceName)
-{
- DRI2ScreenPtr ds;
-
- if (!dixPrivateKeyRegistered(dri2ScreenPrivateKey))
- return FALSE;
-
- ds = DRI2GetScreen(pScreen);
- if (ds == NULL || driverType >= ds->numDrivers ||
- !ds->driverNames[driverType])
- return FALSE;
-
- *fd = ds->fd;
- *driverName = ds->driverNames[driverType];
- *deviceName = ds->deviceName;
-
- return TRUE;
-}
-
-Bool
-DRI2Authenticate(ScreenPtr pScreen, uint32_t magic)
-{
- DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
-
- if (ds == NULL || (*ds->AuthMagic)(ds->fd, magic))
- return FALSE;
-
- return TRUE;
-}
-
-static int
-DRI2ConfigNotify(WindowPtr pWin, int x, int y, int w, int h, int bw,
- WindowPtr pSib)
-{
- DrawablePtr pDraw = (DrawablePtr)pWin;
- ScreenPtr pScreen = pDraw->pScreen;
- DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
- DRI2DrawablePtr dd = DRI2GetDrawable(pDraw);
- int ret;
-
- if (ds->ConfigNotify) {
- pScreen->ConfigNotify = ds->ConfigNotify;
-
- ret = (*pScreen->ConfigNotify)(pWin, x, y, w, h, bw, pSib);
-
- ds->ConfigNotify = pScreen->ConfigNotify;
- pScreen->ConfigNotify = DRI2ConfigNotify;
- if (ret)
- return ret;
- }
-
- if (!dd || (dd->width == w && dd->height == h))
- return Success;
-
- DRI2InvalidateDrawable(pDraw);
- return Success;
-}
-
-Bool
-DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
-{
- DRI2ScreenPtr ds;
- const char* driverTypeNames[] = {
- "DRI", /* DRI2DriverDRI */
- "VDPAU", /* DRI2DriverVDPAU */
- };
- unsigned int i;
- CARD8 cur_minor;
-
- if (info->version < 3)
- return FALSE;
-
- if (!xf86VGAarbiterAllowDRI(pScreen)) {
- xf86DrvMsg(pScreen->myNum, X_WARNING,
- "[DRI2] Direct rendering is not supported when VGA arb is necessary for the device\n");
- return FALSE;
- }
-
- if (!dixRegisterPrivateKey(&dri2ScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
- return FALSE;
-
- if (!dixRegisterPrivateKey(&dri2WindowPrivateKeyRec, PRIVATE_WINDOW, 0))
- return FALSE;
-
- if (!dixRegisterPrivateKey(&dri2PixmapPrivateKeyRec, PRIVATE_PIXMAP, 0))
- return FALSE;
-
- ds = calloc(1, sizeof *ds);
- if (!ds)
- return FALSE;
-
- ds->screen = pScreen;
- ds->fd = info->fd;
- ds->deviceName = info->deviceName;
- dri2_major = 1;
-
- ds->CreateBuffer = info->CreateBuffer;
- ds->DestroyBuffer = info->DestroyBuffer;
- ds->CopyRegion = info->CopyRegion;
-
- if (info->version >= 4) {
- ds->ScheduleSwap = info->ScheduleSwap;
- ds->ScheduleWaitMSC = info->ScheduleWaitMSC;
- ds->GetMSC = info->GetMSC;
- cur_minor = 3;
- } else {
- cur_minor = 1;
- }
-
- if (info->version >= 5) {
- ds->AuthMagic = info->AuthMagic;
- }
-
- /*
- * if the driver doesn't provide an AuthMagic function or the info struct
- * version is too low, it relies on the old method (using libdrm) or fail
- */
- if (!ds->AuthMagic)
-#ifdef WITH_LIBDRM
- ds->AuthMagic = drmAuthMagic;
-#else
- goto err_out;
-#endif
-
- /* Initialize minor if needed and set to minimum provied by DDX */
- if (!dri2_minor || dri2_minor > cur_minor)
- dri2_minor = cur_minor;
-
- if (info->version == 3 || info->numDrivers == 0) {
- /* Driver too old: use the old-style driverName field */
- ds->numDrivers = 1;
- ds->driverNames = malloc(sizeof(*ds->driverNames));
- if (!ds->driverNames)
- goto err_out;
- ds->driverNames[0] = info->driverName;
- } else {
- ds->numDrivers = info->numDrivers;
- ds->driverNames = malloc(info->numDrivers * sizeof(*ds->driverNames));
- if (!ds->driverNames)
- goto err_out;
- memcpy(ds->driverNames, info->driverNames,
- info->numDrivers * sizeof(*ds->driverNames));
- }
-
- dixSetPrivate(&pScreen->devPrivates, dri2ScreenPrivateKey, ds);
-
- ds->ConfigNotify = pScreen->ConfigNotify;
- pScreen->ConfigNotify = DRI2ConfigNotify;
-
- xf86DrvMsg(pScreen->myNum, X_INFO, "[DRI2] Setup complete\n");
- for (i = 0; i < sizeof(driverTypeNames) / sizeof(driverTypeNames[0]); i++) {
- if (i < ds->numDrivers && ds->driverNames[i]) {
- xf86DrvMsg(pScreen->myNum, X_INFO, "[DRI2] %s driver: %s\n",
- driverTypeNames[i], ds->driverNames[i]);
- }
- }
-
- return TRUE;
-
-err_out:
- xf86DrvMsg(pScreen->myNum, X_WARNING,
- "[DRI2] Initialization failed for info version %d.\n", info->version);
- free(ds);
- return FALSE;
-}
-
-void
-DRI2CloseScreen(ScreenPtr pScreen)
-{
- DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
- pScreen->ConfigNotify = ds->ConfigNotify;
-
- free(ds->driverNames);
- free(ds);
- dixSetPrivate(&pScreen->devPrivates, dri2ScreenPrivateKey, NULL);
-}
-
-extern ExtensionModule dri2ExtensionModule;
-
-static pointer
-DRI2Setup(pointer module, pointer opts, int *errmaj, int *errmin)
-{
- static Bool setupDone = FALSE;
-
- dri2DrawableRes = CreateNewResourceType(DRI2DrawableGone, "DRI2Drawable");
-
- if (!setupDone)
- {
- setupDone = TRUE;
- LoadExtension(&dri2ExtensionModule, FALSE);
- }
- else
- {
- if (errmaj)
- *errmaj = LDR_ONCEONLY;
- }
-
- return (pointer) 1;
-}
-
-static XF86ModuleVersionInfo DRI2VersRec =
-{
- "dri2",
- MODULEVENDORSTRING,
- MODINFOSTRING1,
- MODINFOSTRING2,
- XORG_VERSION_CURRENT,
- 1, 2, 0,
- ABI_CLASS_EXTENSION,
- ABI_EXTENSION_VERSION,
- MOD_CLASS_NONE,
- { 0, 0, 0, 0 }
-};
-
-_X_EXPORT XF86ModuleData dri2ModuleData = { &DRI2VersRec, DRI2Setup, NULL };
-
-void
-DRI2Version(int *major, int *minor)
-{
- if (major != NULL)
- *major = DRI2VersRec.majorversion;
-
- if (minor != NULL)
- *minor = DRI2VersRec.minorversion;
-}
+/*
+ * Copyright © 2007, 2008 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Soft-
+ * ware"), to deal in the Software without restriction, including without
+ * limitation the rights to use, copy, modify, merge, publish, distribute,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, provided that the above copyright
+ * notice(s) and this permission notice appear in all copies of the Soft-
+ * ware and that both the above copyright notice(s) and this permission
+ * notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
+ * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
+ * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
+ * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
+ * QUENTIAL 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 PERFOR-
+ * MANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder shall
+ * not be used in advertising or otherwise to promote the sale, use or
+ * other dealings in this Software without prior written authorization of
+ * the copyright holder.
+ *
+ * Authors:
+ * Kristian Høgsberg (krh@redhat.com)
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <errno.h>
+#ifdef WITH_LIBDRM
+#include <xf86drm.h>
+#endif
+#include "xf86Module.h"
+#include "list.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "dixstruct.h"
+#include "dri2.h"
+#include "xf86VGAarbiter.h"
+
+#include "xf86.h"
+
+CARD8 dri2_major; /* version of DRI2 supported by DDX */
+CARD8 dri2_minor;
+
+static DevPrivateKeyRec dri2ScreenPrivateKeyRec;
+#define dri2ScreenPrivateKey (&dri2ScreenPrivateKeyRec)
+
+static DevPrivateKeyRec dri2WindowPrivateKeyRec;
+#define dri2WindowPrivateKey (&dri2WindowPrivateKeyRec)
+
+static DevPrivateKeyRec dri2PixmapPrivateKeyRec;
+#define dri2PixmapPrivateKey (&dri2PixmapPrivateKeyRec)
+
+static RESTYPE dri2DrawableRes;
+
+typedef struct _DRI2Screen *DRI2ScreenPtr;
+
+typedef struct _DRI2Drawable {
+ DRI2ScreenPtr dri2_screen;
+ DrawablePtr drawable;
+ struct list reference_list;
+ int width;
+ int height;
+ DRI2BufferPtr *buffers;
+ int bufferCount;
+ unsigned int swapsPending;
+ ClientPtr blockedClient;
+ Bool blockedOnMsc;
+ int swap_interval;
+ CARD64 swap_count;
+ int64_t target_sbc; /* -1 means no SBC wait outstanding */
+ CARD64 last_swap_target; /* most recently queued swap target */
+ CARD64 last_swap_msc; /* msc at completion of most recent swap */
+ CARD64 last_swap_ust; /* ust at completion of most recent swap */
+ int swap_limit; /* for N-buffering */
+ unsigned long serialNumber;
+ Bool needInvalidate;
+} DRI2DrawableRec, *DRI2DrawablePtr;
+
+typedef struct _DRI2Screen {
+ ScreenPtr screen;
+ int refcnt;
+ unsigned int numDrivers;
+ const char **driverNames;
+ const char *deviceName;
+ int fd;
+ unsigned int lastSequence;
+
+ DRI2CreateBufferProcPtr CreateBuffer;
+ DRI2DestroyBufferProcPtr DestroyBuffer;
+ DRI2CopyRegionProcPtr CopyRegion;
+ DRI2ScheduleSwapProcPtr ScheduleSwap;
+ DRI2GetMSCProcPtr GetMSC;
+ DRI2ScheduleWaitMSCProcPtr ScheduleWaitMSC;
+ DRI2AuthMagicProcPtr AuthMagic;
+
+ HandleExposuresProcPtr HandleExposures;
+
+ ConfigNotifyProcPtr ConfigNotify;
+} DRI2ScreenRec;
+
+static DRI2ScreenPtr
+DRI2GetScreen(ScreenPtr pScreen)
+{
+ return dixLookupPrivate(&pScreen->devPrivates, dri2ScreenPrivateKey);
+}
+
+static DRI2DrawablePtr
+DRI2GetDrawable(DrawablePtr pDraw)
+{
+ WindowPtr pWin;
+ PixmapPtr pPixmap;
+
+ switch (pDraw->type) {
+ case DRAWABLE_WINDOW:
+ pWin = (WindowPtr) pDraw;
+ return dixLookupPrivate(&pWin->devPrivates, dri2WindowPrivateKey);
+ case DRAWABLE_PIXMAP:
+ pPixmap = (PixmapPtr) pDraw;
+ return dixLookupPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey);
+ default:
+ return NULL;
+ }
+}
+
+static unsigned long
+DRI2DrawableSerial(DrawablePtr pDraw)
+{
+ ScreenPtr pScreen = pDraw->pScreen;
+ PixmapPtr pPix;
+
+ if (pDraw->type != DRAWABLE_WINDOW)
+ return pDraw->serialNumber;
+
+ pPix = pScreen->GetWindowPixmap((WindowPtr)pDraw);
+ return pPix->drawable.serialNumber;
+}
+
+static DRI2DrawablePtr
+DRI2AllocateDrawable(DrawablePtr pDraw)
+{
+ DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
+ DRI2DrawablePtr pPriv;
+ CARD64 ust;
+ WindowPtr pWin;
+ PixmapPtr pPixmap;
+
+ pPriv = malloc(sizeof *pPriv);
+ if (pPriv == NULL)
+ return NULL;
+
+ pPriv->dri2_screen = ds;
+ pPriv->drawable = pDraw;
+ pPriv->width = pDraw->width;
+ pPriv->height = pDraw->height;
+ pPriv->buffers = NULL;
+ pPriv->bufferCount = 0;
+ pPriv->swapsPending = 0;
+ pPriv->blockedClient = NULL;
+ pPriv->blockedOnMsc = FALSE;
+ pPriv->swap_count = 0;
+ pPriv->target_sbc = -1;
+ pPriv->swap_interval = 1;
+ /* Initialize last swap target from DDX if possible */
+ if (!ds->GetMSC || !(*ds->GetMSC)(pDraw, &ust, &pPriv->last_swap_target))
+ pPriv->last_swap_target = 0;
+
+ pPriv->swap_limit = 1; /* default to double buffering */
+ pPriv->last_swap_msc = 0;
+ pPriv->last_swap_ust = 0;
+ list_init(&pPriv->reference_list);
+ pPriv->serialNumber = DRI2DrawableSerial(pDraw);
+
+ if (pDraw->type == DRAWABLE_WINDOW) {
+ pWin = (WindowPtr) pDraw;
+ dixSetPrivate(&pWin->devPrivates, dri2WindowPrivateKey, pPriv);
+ } else {
+ pPixmap = (PixmapPtr) pDraw;
+ dixSetPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey, pPriv);
+ }
+
+ return pPriv;
+}
+
+typedef struct DRI2DrawableRefRec {
+ XID id;
+ XID dri2_id;
+ DRI2InvalidateProcPtr invalidate;
+ void *priv;
+ struct list link;
+} DRI2DrawableRefRec, *DRI2DrawableRefPtr;
+
+static DRI2DrawableRefPtr
+DRI2LookupDrawableRef(DRI2DrawablePtr pPriv, XID id)
+{
+ DRI2DrawableRefPtr ref;
+
+ list_for_each_entry(ref, &pPriv->reference_list, link) {
+ if (ref->id == id)
+ return ref;
+ }
+
+ return NULL;
+}
+
+static int
+DRI2AddDrawableRef(DRI2DrawablePtr pPriv, XID id, XID dri2_id,
+ DRI2InvalidateProcPtr invalidate, void *priv)
+{
+ DRI2DrawableRefPtr ref;
+
+ ref = malloc(sizeof *ref);
+ if (ref == NULL)
+ return BadAlloc;
+
+ if (!AddResource(dri2_id, dri2DrawableRes, pPriv)) {
+ free(ref);
+ return BadAlloc;
+ }
+ if (!DRI2LookupDrawableRef(pPriv, id))
+ if (!AddResource(id, dri2DrawableRes, pPriv)) {
+ FreeResourceByType(dri2_id, dri2DrawableRes, TRUE);
+ free(ref);
+ return BadAlloc;
+ }
+
+ ref->id = id;
+ ref->dri2_id = dri2_id;
+ ref->invalidate = invalidate;
+ ref->priv = priv;
+ list_add(&ref->link, &pPriv->reference_list);
+
+ return Success;
+}
+
+int
+DRI2CreateDrawable(ClientPtr client, DrawablePtr pDraw, XID id,
+ DRI2InvalidateProcPtr invalidate, void *priv)
+{
+ DRI2DrawablePtr pPriv;
+ XID dri2_id;
+ int rc;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL)
+ pPriv = DRI2AllocateDrawable(pDraw);
+ if (pPriv == NULL)
+ return BadAlloc;
+
+ dri2_id = FakeClientID(client->index);
+ rc = DRI2AddDrawableRef(pPriv, id, dri2_id, invalidate, priv);
+ if (rc != Success)
+ return rc;
+
+ return Success;
+}
+
+static int DRI2DrawableGone(pointer p, XID id)
+{
+ DRI2DrawablePtr pPriv = p;
+ DRI2ScreenPtr ds = pPriv->dri2_screen;
+ DRI2DrawableRefPtr ref, next;
+ WindowPtr pWin;
+ PixmapPtr pPixmap;
+ DrawablePtr pDraw;
+ int i;
+
+ list_for_each_entry_safe(ref, next, &pPriv->reference_list, link) {
+ if (ref->dri2_id == id) {
+ list_del(&ref->link);
+ /* If this was the last ref under this X drawable XID,
+ * unregister the X drawable resource. */
+ if (!DRI2LookupDrawableRef(pPriv, ref->id))
+ FreeResourceByType(ref->id, dri2DrawableRes, TRUE);
+ free(ref);
+ break;
+ }
+
+ if (ref->id == id) {
+ list_del(&ref->link);
+ FreeResourceByType(ref->dri2_id, dri2DrawableRes, TRUE);
+ free(ref);
+ }
+ }
+
+ if (!list_is_empty(&pPriv->reference_list))
+ return Success;
+
+ pDraw = pPriv->drawable;
+ if (pDraw->type == DRAWABLE_WINDOW) {
+ pWin = (WindowPtr) pDraw;
+ dixSetPrivate(&pWin->devPrivates, dri2WindowPrivateKey, NULL);
+ } else {
+ pPixmap = (PixmapPtr) pDraw;
+ dixSetPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey, NULL);
+ }
+
+ if (pPriv->buffers != NULL) {
+ for (i = 0; i < pPriv->bufferCount; i++)
+ (*ds->DestroyBuffer)(pDraw, pPriv->buffers[i]);
+
+ free(pPriv->buffers);
+ }
+
+ free(pPriv);
+
+ return Success;
+}
+
+static int
+find_attachment(DRI2DrawablePtr pPriv, unsigned attachment)
+{
+ int i;
+
+ if (pPriv->buffers == NULL) {
+ return -1;
+ }
+
+ for (i = 0; i < pPriv->bufferCount; i++) {
+ if ((pPriv->buffers[i] != NULL)
+ && (pPriv->buffers[i]->attachment == attachment)) {
+ return i;
+ }
+ }
+
+ return -1;
+}
+
+static Bool
+allocate_or_reuse_buffer(DrawablePtr pDraw, DRI2ScreenPtr ds,
+ DRI2DrawablePtr pPriv,
+ unsigned int attachment, unsigned int format,
+ int dimensions_match, DRI2BufferPtr *buffer)
+{
+ int old_buf = find_attachment(pPriv, attachment);
+
+ if ((old_buf < 0)
+ || !dimensions_match
+ || (pPriv->buffers[old_buf]->format != format)) {
+ *buffer = (*ds->CreateBuffer)(pDraw, attachment, format);
+ pPriv->serialNumber = DRI2DrawableSerial(pDraw);
+ return TRUE;
+
+ } else {
+ *buffer = pPriv->buffers[old_buf];
+ pPriv->buffers[old_buf] = NULL;
+ return FALSE;
+ }
+}
+
+static void
+update_dri2_drawable_buffers(DRI2DrawablePtr pPriv, DrawablePtr pDraw,
+ DRI2BufferPtr *buffers, int out_count, int *width, int *height)
+{
+ DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
+ int i;
+
+ if (pPriv->buffers != NULL) {
+ for (i = 0; i < pPriv->bufferCount; i++) {
+ if (pPriv->buffers[i] != NULL) {
+ (*ds->DestroyBuffer)(pDraw, pPriv->buffers[i]);
+ }
+ }
+
+ free(pPriv->buffers);
+ }
+
+ pPriv->buffers = buffers;
+ pPriv->bufferCount = out_count;
+ pPriv->width = pDraw->width;
+ pPriv->height = pDraw->height;
+ *width = pPriv->width;
+ *height = pPriv->height;
+}
+
+static DRI2BufferPtr *
+do_get_buffers(DrawablePtr pDraw, int *width, int *height,
+ unsigned int *attachments, int count, int *out_count,
+ int has_format)
+{
+ DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
+ DRI2DrawablePtr pPriv = DRI2GetDrawable(pDraw);
+ DRI2BufferPtr *buffers;
+ int need_real_front = 0;
+ int need_fake_front = 0;
+ int have_fake_front = 0;
+ int front_format = 0;
+ int dimensions_match;
+ int buffers_changed = 0;
+ int i;
+
+ if (!pPriv) {
+ *width = pDraw->width;
+ *height = pDraw->height;
+ *out_count = 0;
+ return NULL;
+ }
+
+ dimensions_match = (pDraw->width == pPriv->width)
+ && (pDraw->height == pPriv->height)
+ && (pPriv->serialNumber == DRI2DrawableSerial(pDraw));
+
+ buffers = calloc((count + 1), sizeof(buffers[0]));
+ if (!buffers)
+ goto err_out;
+
+ for (i = 0; i < count; i++) {
+ const unsigned attachment = *(attachments++);
+ const unsigned format = (has_format) ? *(attachments++) : 0;
+
+ if (allocate_or_reuse_buffer(pDraw, ds, pPriv, attachment,
+ format, dimensions_match,
+ &buffers[i]))
+ buffers_changed = 1;
+
+ if (buffers[i] == NULL)
+ goto err_out;
+
+ /* If the drawable is a window and the front-buffer is requested,
+ * silently add the fake front-buffer to the list of requested
+ * attachments. The counting logic in the loop accounts for the case
+ * where the client requests both the fake and real front-buffer.
+ */
+ if (attachment == DRI2BufferBackLeft) {
+ need_real_front++;
+ front_format = format;
+ }
+
+ if (attachment == DRI2BufferFrontLeft) {
+ need_real_front--;
+ front_format = format;
+
+ if (pDraw->type == DRAWABLE_WINDOW) {
+ need_fake_front++;
+ }
+ }
+
+ if (pDraw->type == DRAWABLE_WINDOW) {
+ if (attachment == DRI2BufferFakeFrontLeft) {
+ need_fake_front--;
+ have_fake_front = 1;
+ }
+ }
+ }
+
+ if (need_real_front > 0) {
+ if (allocate_or_reuse_buffer(pDraw, ds, pPriv, DRI2BufferFrontLeft,
+ front_format, dimensions_match,
+ &buffers[i]))
+ buffers_changed = 1;
+
+ if (buffers[i] == NULL)
+ goto err_out;
+ i++;
+ }
+
+ if (need_fake_front > 0) {
+ if (allocate_or_reuse_buffer(pDraw, ds, pPriv, DRI2BufferFakeFrontLeft,
+ front_format, dimensions_match,
+ &buffers[i]))
+ buffers_changed = 1;
+
+ if (buffers[i] == NULL)
+ goto err_out;
+
+ i++;
+ have_fake_front = 1;
+ }
+
+ *out_count = i;
+
+ update_dri2_drawable_buffers(pPriv, pDraw, buffers, *out_count, width, height);
+
+ /* If the client is getting a fake front-buffer, pre-fill it with the
+ * contents of the real front-buffer. This ensures correct operation of
+ * applications that call glXWaitX before calling glDrawBuffer.
+ */
+ if (have_fake_front && buffers_changed) {
+ BoxRec box;
+ RegionRec region;
+
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = pPriv->width;
+ box.y2 = pPriv->height;
+ RegionInit(&region, &box, 0);
+
+ DRI2CopyRegion(pDraw, &region, DRI2BufferFakeFrontLeft,
+ DRI2BufferFrontLeft);
+ }
+
+ pPriv->needInvalidate = TRUE;
+
+ return pPriv->buffers;
+
+err_out:
+
+ *out_count = 0;
+
+ if (buffers) {
+ for (i = 0; i < count; i++) {
+ if (buffers[i] != NULL)
+ (*ds->DestroyBuffer)(pDraw, buffers[i]);
+ }
+
+ free(buffers);
+ buffers = NULL;
+ }
+
+ update_dri2_drawable_buffers(pPriv, pDraw, buffers, *out_count, width, height);
+
+ return buffers;
+}
+
+DRI2BufferPtr *
+DRI2GetBuffers(DrawablePtr pDraw, int *width, int *height,
+ unsigned int *attachments, int count, int *out_count)
+{
+ return do_get_buffers(pDraw, width, height, attachments, count,
+ out_count, FALSE);
+}
+
+DRI2BufferPtr *
+DRI2GetBuffersWithFormat(DrawablePtr pDraw, int *width, int *height,
+ unsigned int *attachments, int count, int *out_count)
+{
+ return do_get_buffers(pDraw, width, height, attachments, count,
+ out_count, TRUE);
+}
+
+static void
+DRI2InvalidateDrawable(DrawablePtr pDraw)
+{
+ DRI2DrawablePtr pPriv = DRI2GetDrawable(pDraw);
+ DRI2DrawableRefPtr ref;
+
+ if (!pPriv || !pPriv->needInvalidate)
+ return;
+
+ pPriv->needInvalidate = FALSE;
+
+ list_for_each_entry(ref, &pPriv->reference_list, link)
+ ref->invalidate(pDraw, ref->priv);
+}
+
+/*
+ * In the direct rendered case, we throttle the clients that have more
+ * than their share of outstanding swaps (and thus busy buffers) when a
+ * new GetBuffers request is received. In the AIGLX case, we allow the
+ * client to get the new buffers, but throttle when the next GLX request
+ * comes in (see __glXDRIcontextWait()).
+ */
+Bool
+DRI2ThrottleClient(ClientPtr client, DrawablePtr pDraw)
+{
+ DRI2DrawablePtr pPriv;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL)
+ return FALSE;
+
+ /* Throttle to swap limit */
+ if ((pPriv->swapsPending >= pPriv->swap_limit) &&
+ !pPriv->blockedClient) {
+ ResetCurrentRequest(client);
+ client->sequence--;
+ IgnoreClient(client);
+ pPriv->blockedClient = client;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static void
+__DRI2BlockClient(ClientPtr client, DRI2DrawablePtr pPriv)
+{
+ if (pPriv->blockedClient == NULL) {
+ IgnoreClient(client);
+ pPriv->blockedClient = client;
+ }
+}
+
+void
+DRI2BlockClient(ClientPtr client, DrawablePtr pDraw)
+{
+ DRI2DrawablePtr pPriv;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL)
+ return;
+
+ __DRI2BlockClient(client, pPriv);
+ pPriv->blockedOnMsc = TRUE;
+}
+
+int
+DRI2CopyRegion(DrawablePtr pDraw, RegionPtr pRegion,
+ unsigned int dest, unsigned int src)
+{
+ DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
+ DRI2DrawablePtr pPriv;
+ DRI2BufferPtr pDestBuffer, pSrcBuffer;
+ int i;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL)
+ return BadDrawable;
+
+ pDestBuffer = NULL;
+ pSrcBuffer = NULL;
+ for (i = 0; i < pPriv->bufferCount; i++)
+ {
+ if (pPriv->buffers[i]->attachment == dest)
+ pDestBuffer = (DRI2BufferPtr) pPriv->buffers[i];
+ if (pPriv->buffers[i]->attachment == src)
+ pSrcBuffer = (DRI2BufferPtr) pPriv->buffers[i];
+ }
+ if (pSrcBuffer == NULL || pDestBuffer == NULL)
+ return BadValue;
+
+ (*ds->CopyRegion)(pDraw, pRegion, pDestBuffer, pSrcBuffer);
+
+ return Success;
+}
+
+/* Can this drawable be page flipped? */
+Bool
+DRI2CanFlip(DrawablePtr pDraw)
+{
+ ScreenPtr pScreen = pDraw->pScreen;
+ WindowPtr pWin, pRoot;
+ PixmapPtr pWinPixmap, pRootPixmap;
+
+ if (pDraw->type == DRAWABLE_PIXMAP)
+ return TRUE;
+
+ pRoot = pScreen->root;
+ pRootPixmap = pScreen->GetWindowPixmap(pRoot);
+
+ pWin = (WindowPtr) pDraw;
+ pWinPixmap = pScreen->GetWindowPixmap(pWin);
+ if (pRootPixmap != pWinPixmap)
+ return FALSE;
+ if (!RegionEqual(&pWin->clipList, &pRoot->winSize))
+ return FALSE;
+
+ /* Does the window match the pixmap exactly? */
+ if (pDraw->x != 0 ||
+ pDraw->y != 0 ||
+#ifdef COMPOSITE
+ pDraw->x != pWinPixmap->screen_x ||
+ pDraw->y != pWinPixmap->screen_y ||
+#endif
+ pDraw->width != pWinPixmap->drawable.width ||
+ pDraw->height != pWinPixmap->drawable.height)
+ return FALSE;
+
+ return TRUE;
+}
+
+/* Can we do a pixmap exchange instead of a blit? */
+Bool
+DRI2CanExchange(DrawablePtr pDraw)
+{
+ return FALSE;
+}
+
+void
+DRI2WaitMSCComplete(ClientPtr client, DrawablePtr pDraw, int frame,
+ unsigned int tv_sec, unsigned int tv_usec)
+{
+ DRI2DrawablePtr pPriv;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL)
+ return;
+
+ ProcDRI2WaitMSCReply(client, ((CARD64)tv_sec * 1000000) + tv_usec,
+ frame, pPriv->swap_count);
+
+ if (pPriv->blockedClient)
+ AttendClient(pPriv->blockedClient);
+
+ pPriv->blockedClient = NULL;
+ pPriv->blockedOnMsc = FALSE;
+}
+
+static void
+DRI2WakeClient(ClientPtr client, DrawablePtr pDraw, int frame,
+ unsigned int tv_sec, unsigned int tv_usec)
+{
+ ScreenPtr pScreen = pDraw->pScreen;
+ DRI2DrawablePtr pPriv;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[DRI2] %s: bad drawable\n", __func__);
+ return;
+ }
+
+ /*
+ * Swap completed.
+ * Wake the client iff:
+ * - it was waiting on SBC
+ * - was blocked due to GLX make current
+ * - was blocked due to swap throttling
+ * - is not blocked due to an MSC wait
+ */
+ if (pPriv->target_sbc != -1 &&
+ pPriv->target_sbc <= pPriv->swap_count) {
+ ProcDRI2WaitMSCReply(client, ((CARD64)tv_sec * 1000000) + tv_usec,
+ frame, pPriv->swap_count);
+ pPriv->target_sbc = -1;
+
+ AttendClient(pPriv->blockedClient);
+ pPriv->blockedClient = NULL;
+ } else if (pPriv->target_sbc == -1 && !pPriv->blockedOnMsc) {
+ if (pPriv->blockedClient) {
+ AttendClient(pPriv->blockedClient);
+ pPriv->blockedClient = NULL;
+ }
+ }
+}
+
+void
+DRI2SwapComplete(ClientPtr client, DrawablePtr pDraw, int frame,
+ unsigned int tv_sec, unsigned int tv_usec, int type,
+ DRI2SwapEventPtr swap_complete, void *swap_data)
+{
+ ScreenPtr pScreen = pDraw->pScreen;
+ DRI2DrawablePtr pPriv;
+ CARD64 ust = 0;
+ BoxRec box;
+ RegionRec region;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[DRI2] %s: bad drawable\n", __func__);
+ return;
+ }
+
+ pPriv->swapsPending--;
+ pPriv->swap_count++;
+
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = pDraw->width;
+ box.y2 = pDraw->height;
+ RegionInit(&region, &box, 0);
+ DRI2CopyRegion(pDraw, &region, DRI2BufferFakeFrontLeft,
+ DRI2BufferFrontLeft);
+
+ ust = ((CARD64)tv_sec * 1000000) + tv_usec;
+ if (swap_complete)
+ swap_complete(client, swap_data, type, ust, frame, pPriv->swap_count);
+
+ pPriv->last_swap_msc = frame;
+ pPriv->last_swap_ust = ust;
+
+ DRI2WakeClient(client, pDraw, frame, tv_sec, tv_usec);
+}
+
+Bool
+DRI2WaitSwap(ClientPtr client, DrawablePtr pDrawable)
+{
+ DRI2DrawablePtr pPriv = DRI2GetDrawable(pDrawable);
+
+ /* If we're currently waiting for a swap on this drawable, reset
+ * the request and suspend the client. We only support one
+ * blocked client per drawable. */
+ if ((pPriv->swapsPending) &&
+ pPriv->blockedClient == NULL) {
+ ResetCurrentRequest(client);
+ client->sequence--;
+ __DRI2BlockClient(client, pPriv);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+int
+DRI2SwapBuffers(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
+ CARD64 divisor, CARD64 remainder, CARD64 *swap_target,
+ DRI2SwapEventPtr func, void *data)
+{
+ ScreenPtr pScreen = pDraw->pScreen;
+ DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
+ DRI2DrawablePtr pPriv;
+ DRI2BufferPtr pDestBuffer = NULL, pSrcBuffer = NULL;
+ int ret, i;
+ CARD64 ust, current_msc;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[DRI2] %s: bad drawable\n", __func__);
+ return BadDrawable;
+ }
+
+ for (i = 0; i < pPriv->bufferCount; i++) {
+ if (pPriv->buffers[i]->attachment == DRI2BufferFrontLeft)
+ pDestBuffer = (DRI2BufferPtr) pPriv->buffers[i];
+ if (pPriv->buffers[i]->attachment == DRI2BufferBackLeft)
+ pSrcBuffer = (DRI2BufferPtr) pPriv->buffers[i];
+ }
+ if (pSrcBuffer == NULL || pDestBuffer == NULL) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[DRI2] %s: drawable has no back or front?\n", __func__);
+ return BadDrawable;
+ }
+
+ /* Old DDX or no swap interval, just blit */
+ if (!ds->ScheduleSwap || !pPriv->swap_interval) {
+ BoxRec box;
+ RegionRec region;
+
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = pDraw->width;
+ box.y2 = pDraw->height;
+ RegionInit(&region, &box, 0);
+
+ pPriv->swapsPending++;
+
+ (*ds->CopyRegion)(pDraw, &region, pDestBuffer, pSrcBuffer);
+ DRI2SwapComplete(client, pDraw, target_msc, 0, 0, DRI2_BLIT_COMPLETE,
+ func, data);
+ return Success;
+ }
+
+ /*
+ * In the simple glXSwapBuffers case, all params will be 0, and we just
+ * need to schedule a swap for the last swap target + the swap interval.
+ */
+ if (target_msc == 0 && divisor == 0 && remainder == 0) {
+ /* If the current vblank count of the drawable's crtc is lower
+ * than the count stored in last_swap_target from a previous swap
+ * then reinitialize last_swap_target to the current crtc's msc,
+ * otherwise the swap will hang. This will happen if the drawable
+ * is moved to a crtc with a lower refresh rate, or a crtc that just
+ * got enabled.
+ */
+ if (ds->GetMSC) {
+ if (!(*ds->GetMSC)(pDraw, &ust, &current_msc))
+ pPriv->last_swap_target = 0;
+
+ if (current_msc < pPriv->last_swap_target)
+ pPriv->last_swap_target = current_msc;
+
+ }
+
+ /*
+ * Swap target for this swap is last swap target + swap interval since
+ * we have to account for the current swap count, interval, and the
+ * number of pending swaps.
+ */
+ *swap_target = pPriv->last_swap_target + pPriv->swap_interval;
+
+ } else {
+ /* glXSwapBuffersMscOML could have a 0 target_msc, honor it */
+ *swap_target = target_msc;
+ }
+
+ pPriv->swapsPending++;
+ ret = (*ds->ScheduleSwap)(client, pDraw, pDestBuffer, pSrcBuffer,
+ swap_target, divisor, remainder, func, data);
+ if (!ret) {
+ pPriv->swapsPending--; /* didn't schedule */
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[DRI2] %s: driver failed to schedule swap\n", __func__);
+ return BadDrawable;
+ }
+
+ pPriv->last_swap_target = *swap_target;
+
+ /* According to spec, return expected swapbuffers count SBC after this swap
+ * will complete.
+ */
+ *swap_target = pPriv->swap_count + pPriv->swapsPending;
+
+ DRI2InvalidateDrawable(pDraw);
+
+ return Success;
+}
+
+void
+DRI2SwapInterval(DrawablePtr pDrawable, int interval)
+{
+ ScreenPtr pScreen = pDrawable->pScreen;
+ DRI2DrawablePtr pPriv = DRI2GetDrawable(pDrawable);
+
+ if (pPriv == NULL) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[DRI2] %s: bad drawable\n", __func__);
+ return;
+ }
+
+ /* fixme: check against arbitrary max? */
+ pPriv->swap_interval = interval;
+}
+
+int
+DRI2GetMSC(DrawablePtr pDraw, CARD64 *ust, CARD64 *msc, CARD64 *sbc)
+{
+ ScreenPtr pScreen = pDraw->pScreen;
+ DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
+ DRI2DrawablePtr pPriv;
+ Bool ret;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[DRI2] %s: bad drawable\n", __func__);
+ return BadDrawable;
+ }
+
+ if (!ds->GetMSC) {
+ *ust = 0;
+ *msc = 0;
+ *sbc = pPriv->swap_count;
+ return Success;
+ }
+
+ /*
+ * Spec needs to be updated to include unmapped or redirected
+ * drawables
+ */
+
+ ret = (*ds->GetMSC)(pDraw, ust, msc);
+ if (!ret)
+ return BadDrawable;
+
+ *sbc = pPriv->swap_count;
+
+ return Success;
+}
+
+int
+DRI2WaitMSC(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
+ CARD64 divisor, CARD64 remainder)
+{
+ DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
+ DRI2DrawablePtr pPriv;
+ Bool ret;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL)
+ return BadDrawable;
+
+ /* Old DDX just completes immediately */
+ if (!ds->ScheduleWaitMSC) {
+ DRI2WaitMSCComplete(client, pDraw, target_msc, 0, 0);
+
+ return Success;
+ }
+
+ ret = (*ds->ScheduleWaitMSC)(client, pDraw, target_msc, divisor, remainder);
+ if (!ret)
+ return BadDrawable;
+
+ return Success;
+}
+
+int
+DRI2WaitSBC(ClientPtr client, DrawablePtr pDraw, CARD64 target_sbc)
+{
+ DRI2DrawablePtr pPriv;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL)
+ return BadDrawable;
+
+ /* target_sbc == 0 means to block until all pending swaps are
+ * finished. Recalculate target_sbc to get that behaviour.
+ */
+ if (target_sbc == 0)
+ target_sbc = pPriv->swap_count + pPriv->swapsPending;
+
+ /* If current swap count already >= target_sbc, reply and
+ * return immediately with (ust, msc, sbc) triplet of
+ * most recent completed swap.
+ */
+ if (pPriv->swap_count >= target_sbc) {
+ ProcDRI2WaitMSCReply(client, pPriv->last_swap_ust,
+ pPriv->last_swap_msc, pPriv->swap_count);
+ return Success;
+ }
+
+ pPriv->target_sbc = target_sbc;
+ __DRI2BlockClient(client, pPriv);
+
+ return Success;
+}
+
+Bool
+DRI2HasSwapControl(ScreenPtr pScreen)
+{
+ DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
+
+ return ds->ScheduleSwap && ds->GetMSC;
+}
+
+Bool
+DRI2Connect(ScreenPtr pScreen, unsigned int driverType, int *fd,
+ const char **driverName, const char **deviceName)
+{
+ DRI2ScreenPtr ds;
+
+ if (!dixPrivateKeyRegistered(dri2ScreenPrivateKey))
+ return FALSE;
+
+ ds = DRI2GetScreen(pScreen);
+ if (ds == NULL || driverType >= ds->numDrivers ||
+ !ds->driverNames[driverType])
+ return FALSE;
+
+ *fd = ds->fd;
+ *driverName = ds->driverNames[driverType];
+ *deviceName = ds->deviceName;
+
+ return TRUE;
+}
+
+Bool
+DRI2Authenticate(ScreenPtr pScreen, uint32_t magic)
+{
+ DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
+
+ if (ds == NULL || (*ds->AuthMagic)(ds->fd, magic))
+ return FALSE;
+
+ return TRUE;
+}
+
+static int
+DRI2ConfigNotify(WindowPtr pWin, int x, int y, int w, int h, int bw,
+ WindowPtr pSib)
+{
+ DrawablePtr pDraw = (DrawablePtr)pWin;
+ ScreenPtr pScreen = pDraw->pScreen;
+ DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
+ DRI2DrawablePtr dd = DRI2GetDrawable(pDraw);
+ int ret;
+
+ if (ds->ConfigNotify) {
+ pScreen->ConfigNotify = ds->ConfigNotify;
+
+ ret = (*pScreen->ConfigNotify)(pWin, x, y, w, h, bw, pSib);
+
+ ds->ConfigNotify = pScreen->ConfigNotify;
+ pScreen->ConfigNotify = DRI2ConfigNotify;
+ if (ret)
+ return ret;
+ }
+
+ if (!dd || (dd->width == w && dd->height == h))
+ return Success;
+
+ DRI2InvalidateDrawable(pDraw);
+ return Success;
+}
+
+Bool
+DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
+{
+ DRI2ScreenPtr ds;
+ const char* driverTypeNames[] = {
+ "DRI", /* DRI2DriverDRI */
+ "VDPAU", /* DRI2DriverVDPAU */
+ };
+ unsigned int i;
+ CARD8 cur_minor;
+
+ if (info->version < 3)
+ return FALSE;
+
+ if (!xf86VGAarbiterAllowDRI(pScreen)) {
+ xf86DrvMsg(pScreen->myNum, X_WARNING,
+ "[DRI2] Direct rendering is not supported when VGA arb is necessary for the device\n");
+ return FALSE;
+ }
+
+ if (!dixRegisterPrivateKey(&dri2ScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
+ if (!dixRegisterPrivateKey(&dri2WindowPrivateKeyRec, PRIVATE_WINDOW, 0))
+ return FALSE;
+
+ if (!dixRegisterPrivateKey(&dri2PixmapPrivateKeyRec, PRIVATE_PIXMAP, 0))
+ return FALSE;
+
+ ds = calloc(1, sizeof *ds);
+ if (!ds)
+ return FALSE;
+
+ ds->screen = pScreen;
+ ds->fd = info->fd;
+ ds->deviceName = info->deviceName;
+ dri2_major = 1;
+
+ ds->CreateBuffer = info->CreateBuffer;
+ ds->DestroyBuffer = info->DestroyBuffer;
+ ds->CopyRegion = info->CopyRegion;
+
+ if (info->version >= 4) {
+ ds->ScheduleSwap = info->ScheduleSwap;
+ ds->ScheduleWaitMSC = info->ScheduleWaitMSC;
+ ds->GetMSC = info->GetMSC;
+ cur_minor = 3;
+ } else {
+ cur_minor = 1;
+ }
+
+ if (info->version >= 5) {
+ ds->AuthMagic = info->AuthMagic;
+ }
+
+ /*
+ * if the driver doesn't provide an AuthMagic function or the info struct
+ * version is too low, it relies on the old method (using libdrm) or fail
+ */
+ if (!ds->AuthMagic)
+#ifdef WITH_LIBDRM
+ ds->AuthMagic = drmAuthMagic;
+#else
+ goto err_out;
+#endif
+
+ /* Initialize minor if needed and set to minimum provied by DDX */
+ if (!dri2_minor || dri2_minor > cur_minor)
+ dri2_minor = cur_minor;
+
+ if (info->version == 3 || info->numDrivers == 0) {
+ /* Driver too old: use the old-style driverName field */
+ ds->numDrivers = 1;
+ ds->driverNames = malloc(sizeof(*ds->driverNames));
+ if (!ds->driverNames)
+ goto err_out;
+ ds->driverNames[0] = info->driverName;
+ } else {
+ ds->numDrivers = info->numDrivers;
+ ds->driverNames = malloc(info->numDrivers * sizeof(*ds->driverNames));
+ if (!ds->driverNames)
+ goto err_out;
+ memcpy(ds->driverNames, info->driverNames,
+ info->numDrivers * sizeof(*ds->driverNames));
+ }
+
+ dixSetPrivate(&pScreen->devPrivates, dri2ScreenPrivateKey, ds);
+
+ ds->ConfigNotify = pScreen->ConfigNotify;
+ pScreen->ConfigNotify = DRI2ConfigNotify;
+
+ xf86DrvMsg(pScreen->myNum, X_INFO, "[DRI2] Setup complete\n");
+ for (i = 0; i < sizeof(driverTypeNames) / sizeof(driverTypeNames[0]); i++) {
+ if (i < ds->numDrivers && ds->driverNames[i]) {
+ xf86DrvMsg(pScreen->myNum, X_INFO, "[DRI2] %s driver: %s\n",
+ driverTypeNames[i], ds->driverNames[i]);
+ }
+ }
+
+ return TRUE;
+
+err_out:
+ xf86DrvMsg(pScreen->myNum, X_WARNING,
+ "[DRI2] Initialization failed for info version %d.\n", info->version);
+ free(ds);
+ return FALSE;
+}
+
+void
+DRI2CloseScreen(ScreenPtr pScreen)
+{
+ DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
+ pScreen->ConfigNotify = ds->ConfigNotify;
+
+ free(ds->driverNames);
+ free(ds);
+ dixSetPrivate(&pScreen->devPrivates, dri2ScreenPrivateKey, NULL);
+}
+
+extern ExtensionModule dri2ExtensionModule;
+
+static pointer
+DRI2Setup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+ static Bool setupDone = FALSE;
+
+ dri2DrawableRes = CreateNewResourceType(DRI2DrawableGone, "DRI2Drawable");
+
+ if (!setupDone)
+ {
+ setupDone = TRUE;
+ LoadExtension(&dri2ExtensionModule, FALSE);
+ }
+ else
+ {
+ if (errmaj)
+ *errmaj = LDR_ONCEONLY;
+ }
+
+ return (pointer) 1;
+}
+
+static XF86ModuleVersionInfo DRI2VersRec =
+{
+ "dri2",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 1, 2, 0,
+ ABI_CLASS_EXTENSION,
+ ABI_EXTENSION_VERSION,
+ MOD_CLASS_NONE,
+ { 0, 0, 0, 0 }
+};
+
+_X_EXPORT XF86ModuleData dri2ModuleData = { &DRI2VersRec, DRI2Setup, NULL };
+
+void
+DRI2Version(int *major, int *minor)
+{
+ if (major != NULL)
+ *major = DRI2VersRec.majorversion;
+
+ if (minor != NULL)
+ *minor = DRI2VersRec.minorversion;
+}
diff --git a/xorg-server/hw/xfree86/fbdevhw/fbdevhw.c b/xorg-server/hw/xfree86/fbdevhw/fbdevhw.c
index d98c40be9..dee731be4 100644
--- a/xorg-server/hw/xfree86/fbdevhw/fbdevhw.c
+++ b/xorg-server/hw/xfree86/fbdevhw/fbdevhw.c
@@ -1,905 +1,905 @@
-/* all driver need this */
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <string.h>
-
-#include "xf86.h"
-#include "xf86_OSproc.h"
-
-/* pci stuff */
-#include "xf86PciInfo.h"
-#include "xf86Pci.h"
-
-#include "xf86cmap.h"
-
-#include "fbdevhw.h"
-#include "fbpriv.h"
-#include "globals.h"
-#include <X11/extensions/dpmsconst.h>
-
-#define PAGE_MASK (~(getpagesize() - 1))
-
-static XF86ModuleVersionInfo fbdevHWVersRec =
-{
- "fbdevhw",
- MODULEVENDORSTRING,
- MODINFOSTRING1,
- MODINFOSTRING2,
- XORG_VERSION_CURRENT,
- 0, 0, 2,
- ABI_CLASS_VIDEODRV,
- ABI_VIDEODRV_VERSION,
- MOD_CLASS_NONE,
- {0,0,0,0}
-};
-
-_X_EXPORT XF86ModuleData fbdevhwModuleData = {
- &fbdevHWVersRec,
- NULL,
- NULL
-};
-
-#include <fcntl.h>
-#include <errno.h>
-#include <sys/mman.h>
-#include <sys/ioctl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-/* -------------------------------------------------------------------- */
-/* our private data, and two functions to allocate/free this */
-
-#define FBDEVHWPTRLVAL(p) (p)->privates[fbdevHWPrivateIndex].ptr
-#define FBDEVHWPTR(p) ((fbdevHWPtr)(FBDEVHWPTRLVAL(p)))
-
-static int fbdevHWPrivateIndex = -1;
-
-typedef struct {
- /* framebuffer device: filename (/dev/fb*), handle, more */
- char* device;
- int fd;
- void* fbmem;
- unsigned int fbmem_len;
- unsigned int fboff;
- char* mmio;
- unsigned int mmio_len;
-
- /* current hardware state */
- struct fb_fix_screeninfo fix;
- struct fb_var_screeninfo var;
-
- /* saved video mode */
- struct fb_var_screeninfo saved_var;
-
- /* buildin video mode */
- DisplayModeRec buildin;
-
-} fbdevHWRec, *fbdevHWPtr;
-
-Bool
-fbdevHWGetRec(ScrnInfoPtr pScrn)
-{
- fbdevHWPtr fPtr;
-
- if (fbdevHWPrivateIndex < 0)
- fbdevHWPrivateIndex = xf86AllocateScrnInfoPrivateIndex();
-
- if (FBDEVHWPTR(pScrn) != NULL)
- return TRUE;
-
- fPtr = FBDEVHWPTRLVAL(pScrn) = xnfcalloc(sizeof(fbdevHWRec), 1);
- return TRUE;
-}
-
-void
-fbdevHWFreeRec(ScrnInfoPtr pScrn)
-{
- if (fbdevHWPrivateIndex < 0)
- return;
- if (FBDEVHWPTR(pScrn) == NULL)
- return;
- free(FBDEVHWPTR(pScrn));
- FBDEVHWPTRLVAL(pScrn) = NULL;
-}
-
-int
-fbdevHWGetFD(ScrnInfoPtr pScrn)
-{
- fbdevHWPtr fPtr;
-
- fbdevHWGetRec(pScrn);
- fPtr = FBDEVHWPTR(pScrn);
-
- return fPtr->fd;
-}
-
-/* -------------------------------------------------------------------- */
-/* some helpers for printing debug informations */
-
-#if DEBUG
-static void
-print_fbdev_mode(char *txt, struct fb_var_screeninfo *var)
-{
- ErrorF( "fbdev %s mode:\t%d %d %d %d %d %d %d %d %d %d %d:%d:%d\n",
- txt,var->pixclock,
- var->xres, var->right_margin, var->hsync_len, var->left_margin,
- var->yres, var->lower_margin, var->vsync_len, var->upper_margin,
- var->bits_per_pixel,
- var->red.length, var->green.length, var->blue.length);
-}
-
-static void
-print_xfree_mode(char *txt, DisplayModePtr mode)
-{
- ErrorF( "xfree %s mode:\t%d %d %d %d %d %d %d %d %d\n",
- txt,mode->Clock,
- mode->HDisplay, mode->HSyncStart, mode->HSyncEnd, mode->HTotal,
- mode->VDisplay, mode->VSyncStart, mode->VSyncEnd, mode->VTotal);
-}
-#endif
-
-/* -------------------------------------------------------------------- */
-/* Convert timings between the XFree and the Frame Buffer Device */
-
-static void
-xfree2fbdev_fblayout(ScrnInfoPtr pScrn, struct fb_var_screeninfo *var)
-{
- var->xres_virtual = pScrn->displayWidth ? pScrn->displayWidth :
- pScrn->virtualX;
- var->yres_virtual = pScrn->virtualY;
- var->bits_per_pixel = pScrn->bitsPerPixel;
- if (pScrn->defaultVisual == TrueColor ||
- pScrn->defaultVisual == DirectColor) {
- var->red.length = pScrn->weight.red;
- var->green.length = pScrn->weight.green;
- var->blue.length = pScrn->weight.blue;
- } else {
- var->red.length = 8;
- var->green.length = 8;
- var->blue.length = 8;
- }
-}
-
-static void
-xfree2fbdev_timing(DisplayModePtr mode, struct fb_var_screeninfo *var)
-{
- var->xres = mode->HDisplay;
- var->yres = mode->VDisplay;
- if (var->xres_virtual < var->xres)
- var->xres_virtual = var->xres;
- if (var->yres_virtual < var->yres)
- var->yres_virtual = var->yres;
- var->xoffset = var->yoffset = 0;
- var->pixclock = mode->Clock ? 1000000000/mode->Clock : 0;
- var->right_margin = mode->HSyncStart-mode->HDisplay;
- var->hsync_len = mode->HSyncEnd-mode->HSyncStart;
- var->left_margin = mode->HTotal-mode->HSyncEnd;
- var->lower_margin = mode->VSyncStart-mode->VDisplay;
- var->vsync_len = mode->VSyncEnd-mode->VSyncStart;
- var->upper_margin = mode->VTotal-mode->VSyncEnd;
- var->sync = 0;
- if (mode->Flags & V_PHSYNC)
- var->sync |= FB_SYNC_HOR_HIGH_ACT;
- if (mode->Flags & V_PVSYNC)
- var->sync |= FB_SYNC_VERT_HIGH_ACT;
- if (mode->Flags & V_PCSYNC)
- var->sync |= FB_SYNC_COMP_HIGH_ACT;
- if (mode->Flags & V_BCAST)
- var->sync |= FB_SYNC_BROADCAST;
- if (mode->Flags & V_INTERLACE)
- var->vmode = FB_VMODE_INTERLACED;
- else if (mode->Flags & V_DBLSCAN)
- var->vmode = FB_VMODE_DOUBLE;
- else
- var->vmode = FB_VMODE_NONINTERLACED;
-}
-
-static Bool
-fbdev_modes_equal(struct fb_var_screeninfo *set, struct fb_var_screeninfo *req)
-{
- return (set->xres_virtual >= req->xres_virtual &&
- set->yres_virtual >= req->yres_virtual &&
- set->bits_per_pixel == req->bits_per_pixel &&
- set->red.length == req->red.length &&
- set->green.length == req->green.length &&
- set->blue.length == req->blue.length &&
- set->xres == req->xres && set->yres == req->yres &&
- set->right_margin == req->right_margin &&
- set->hsync_len == req->hsync_len &&
- set->left_margin == req->left_margin &&
- set->lower_margin == req->lower_margin &&
- set->vsync_len == req->vsync_len &&
- set->upper_margin == req->upper_margin &&
- set->sync == req->sync && set->vmode == req->vmode);
-}
-
-static void
-fbdev2xfree_timing(struct fb_var_screeninfo *var, DisplayModePtr mode)
-{
- mode->Clock = var->pixclock ? 1000000000/var->pixclock : 0;
- mode->HDisplay = var->xres;
- mode->HSyncStart = mode->HDisplay+var->right_margin;
- mode->HSyncEnd = mode->HSyncStart+var->hsync_len;
- mode->HTotal = mode->HSyncEnd+var->left_margin;
- mode->VDisplay = var->yres;
- mode->VSyncStart = mode->VDisplay+var->lower_margin;
- mode->VSyncEnd = mode->VSyncStart+var->vsync_len;
- mode->VTotal = mode->VSyncEnd+var->upper_margin;
- mode->Flags = 0;
- mode->Flags |= var->sync & FB_SYNC_HOR_HIGH_ACT ? V_PHSYNC : V_NHSYNC;
- mode->Flags |= var->sync & FB_SYNC_VERT_HIGH_ACT ? V_PVSYNC : V_NVSYNC;
- mode->Flags |= var->sync & FB_SYNC_COMP_HIGH_ACT ? V_PCSYNC : V_NCSYNC;
- if (var->sync & FB_SYNC_BROADCAST)
- mode->Flags |= V_BCAST;
- if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED)
- mode->Flags |= V_INTERLACE;
- else if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE)
- mode->Flags |= V_DBLSCAN;
- mode->SynthClock = mode->Clock;
- mode->CrtcHDisplay = mode->HDisplay;
- mode->CrtcHSyncStart = mode->HSyncStart;
- mode->CrtcHSyncEnd = mode->HSyncEnd;
- mode->CrtcHTotal = mode->HTotal;
- mode->CrtcVDisplay = mode->VDisplay;
- mode->CrtcVSyncStart = mode->VSyncStart;
- mode->CrtcVSyncEnd = mode->VSyncEnd;
- mode->CrtcVTotal = mode->VTotal;
- mode->CrtcHAdjusted = FALSE;
- mode->CrtcVAdjusted = FALSE;
-}
-
-
-/* -------------------------------------------------------------------- */
-/* open correct framebuffer device */
-
-/**
- * Try to find the framebuffer device for a given PCI device
- */
-static int
-fbdev_open_pci(struct pci_device * pPci, char **namep)
-{
- struct fb_fix_screeninfo fix;
- char filename[256];
- int fd, i;
-
- for (i = 0; i < 8; i++) {
- sprintf(filename,
- "/sys/bus/pci/devices/%04x:%02x:%02x.%d/graphics/fb%d",
- pPci->domain, pPci->bus, pPci->dev, pPci->func, i);
-
- fd = open(filename, O_RDONLY, 0);
- if (fd < 0) {
- sprintf(filename,
- "/sys/bus/pci/devices/%04x:%02x:%02x.%d/graphics:fb%d",
- pPci->domain, pPci->bus, pPci->dev, pPci->func, i);
- fd = open(filename, O_RDONLY, 0);
- }
- if (fd >= 0) {
- close(fd);
- sprintf(filename, "/dev/fb%d", i);
-
- fd = open(filename, O_RDWR, 0);
- if (fd != -1) {
- if (ioctl(fd, FBIOGET_FSCREENINFO, (void*) & fix) != -1) {
- if (namep) {
- *namep = xnfalloc(16);
- strncpy(*namep,fix.id,16);
- }
-
- return fd;
- }
- close(fd);
- }
- }
- }
-
- if (namep)
- *namep = NULL;
-
- xf86DrvMsg(-1, X_ERROR, "Unable to find a valid framebuffer device\n");
- return -1;
-}
-
-static int
-fbdev_open(int scrnIndex, char *dev, char** namep)
-{
- struct fb_fix_screeninfo fix;
- int fd;
-
- /* try argument (from XF86Config) first */
- if (dev) {
- fd = open(dev,O_RDWR,0);
- } else {
- /* second: environment variable */
- dev = getenv("FRAMEBUFFER");
- if ((NULL == dev) || ((fd = open(dev,O_RDWR,0)) == -1)) {
- /* last try: default device */
- dev = "/dev/fb0";
- fd = open(dev,O_RDWR,0);
- }
- }
-
- if (fd == -1) {
- xf86DrvMsg(scrnIndex, X_ERROR,
- "open %s: %s\n", dev, strerror(errno));
- return -1;
- }
-
- if (namep) {
- if (-1 == ioctl(fd,FBIOGET_FSCREENINFO,(void*)(&fix))) {
- *namep = NULL;
- xf86DrvMsg(scrnIndex, X_ERROR,
- "FBIOGET_FSCREENINFO: %s\n", strerror(errno));
- return -1;
- } else {
- *namep = xnfalloc(16);
- strncpy(*namep,fix.id,16);
- }
- }
- return fd;
-}
-
-/* -------------------------------------------------------------------- */
-
-Bool
-fbdevHWProbe(struct pci_device * pPci, char *device,char **namep)
-{
- int fd;
-
- if (pPci)
- fd = fbdev_open_pci(pPci,namep);
- else
- fd = fbdev_open(-1,device,namep);
-
- if (-1 == fd)
- return FALSE;
- close(fd);
- return TRUE;
-}
-
-Bool
-fbdevHWInit(ScrnInfoPtr pScrn, struct pci_device * pPci, char *device)
-{
- fbdevHWPtr fPtr;
-
- fbdevHWGetRec(pScrn);
- fPtr = FBDEVHWPTR(pScrn);
-
- /* open device */
- if (pPci)
- fPtr->fd = fbdev_open_pci(pPci,NULL);
- else
- fPtr->fd = fbdev_open(pScrn->scrnIndex,device,NULL);
- if (-1 == fPtr->fd) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "Failed to open framebuffer device, consult warnings"
- " and/or errors above for possible reasons\n"
- "\t(you may have to look at the server log to see"
- " warnings)\n");
- return FALSE;
- }
-
- /* get current fb device settings */
- if (-1 == ioctl(fPtr->fd,FBIOGET_FSCREENINFO,(void*)(&fPtr->fix))) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "ioctl FBIOGET_FSCREENINFO: %s\n",
- strerror(errno));
- return FALSE;
- }
- if (-1 == ioctl(fPtr->fd,FBIOGET_VSCREENINFO,(void*)(&fPtr->var))) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "ioctl FBIOGET_VSCREENINFO: %s\n",
- strerror(errno));
- return FALSE;
- }
-
- /* we can use the current settings as "buildin mode" */
- fbdev2xfree_timing(&fPtr->var, &fPtr->buildin);
- fPtr->buildin.name = "current";
- fPtr->buildin.next = &fPtr->buildin;
- fPtr->buildin.prev = &fPtr->buildin;
- fPtr->buildin.type |= M_T_BUILTIN;
-
- return TRUE;
-}
-
-char*
-fbdevHWGetName(ScrnInfoPtr pScrn)
-{
- fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
- return fPtr->fix.id;
-}
-
-int
-fbdevHWGetDepth(ScrnInfoPtr pScrn, int *fbbpp)
-{
- fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
-
- if (fbbpp)
- *fbbpp = fPtr->var.bits_per_pixel;
-
- if (fPtr->fix.visual == FB_VISUAL_TRUECOLOR ||
- fPtr->fix.visual == FB_VISUAL_DIRECTCOLOR)
- return fPtr->var.red.length+fPtr->var.green.length+
- fPtr->var.blue.length;
- else
- return fPtr->var.bits_per_pixel;
-}
-
-int
-fbdevHWGetLineLength(ScrnInfoPtr pScrn)
-{
- fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
-
- if (fPtr->fix.line_length)
- return fPtr->fix.line_length;
- else
- return fPtr->var.xres_virtual*fPtr->var.bits_per_pixel/8;
-}
-
-int
-fbdevHWGetType(ScrnInfoPtr pScrn)
-{
- fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
- return fPtr->fix.type;
-}
-
-int
-fbdevHWGetVidmem(ScrnInfoPtr pScrn)
-{
- fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
- return fPtr->fix.smem_len;
-}
-
-static Bool
-fbdevHWSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode, Bool check)
-{
- fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
- struct fb_var_screeninfo req_var = fPtr->var, set_var;
-
- xfree2fbdev_fblayout(pScrn, &req_var);
- xfree2fbdev_timing(mode, &req_var);
-
-#if DEBUG
- print_xfree_mode("init", mode);
- print_fbdev_mode("init", &req_var);
-#endif
-
- set_var = req_var;
-
- if (check)
- set_var.activate = FB_ACTIVATE_TEST;
-
- if (0 != ioctl(fPtr->fd, FBIOPUT_VSCREENINFO, (void*)(&set_var))) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "FBIOPUT_VSCREENINFO: %s\n", strerror(errno));
- return FALSE;
- }
-
- if (!fbdev_modes_equal(&set_var, &req_var)) {
- if (!check)
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "FBIOPUT_VSCREENINFO succeeded but modified "
- "mode\n");
-#if DEBUG
- print_fbdev_mode("returned", &set_var);
-#endif
- return FALSE;
- }
-
- if (!check)
- fPtr->var = set_var;
-
- return TRUE;
-}
-
-void
-fbdevHWSetVideoModes(ScrnInfoPtr pScrn)
-{
- char **modename;
- DisplayModePtr mode,this,last = pScrn->modes;
-
- if (NULL == pScrn->display->modes)
- return;
-
- pScrn->virtualX = pScrn->display->virtualX;
- pScrn->virtualY = pScrn->display->virtualY;
-
- for (modename = pScrn->display->modes; *modename != NULL; modename++) {
- for (mode = pScrn->monitor->Modes; mode != NULL; mode = mode->next)
- if (0 == strcmp(mode->name,*modename))
- break;
- if (NULL == mode) {
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "\tmode \"%s\" not found\n", *modename);
- continue;
- }
-
- if (!fbdevHWSetMode(pScrn, mode, TRUE)) {
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "\tmode \"%s\" test failed\n", *modename);
- continue;
- }
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "\tmode \"%s\" ok\n", *modename);
-
- if (pScrn->virtualX < mode->HDisplay)
- pScrn->virtualX = mode->HDisplay;
- if (pScrn->virtualY < mode->VDisplay)
- pScrn->virtualY = mode->VDisplay;
-
- if (NULL == pScrn->modes) {
- this = pScrn->modes = xf86DuplicateMode(mode);
- this->next = this;
- this->prev = this;
- } else {
- this = xf86DuplicateMode(mode);
- this->next = pScrn->modes;
- this->prev = last;
- last->next = this;
- pScrn->modes->prev = this;
- }
- last = this;
- }
-}
-
-DisplayModePtr
-fbdevHWGetBuildinMode(ScrnInfoPtr pScrn)
-{
- fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
- return &fPtr->buildin;
-}
-
-void
-fbdevHWUseBuildinMode(ScrnInfoPtr pScrn)
-{
- fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
-
- pScrn->modes = &fPtr->buildin;
- pScrn->virtualX = pScrn->display->virtualX;
- pScrn->virtualY = pScrn->display->virtualY;
- if (pScrn->virtualX < fPtr->buildin.HDisplay)
- pScrn->virtualX = fPtr->buildin.HDisplay;
- if (pScrn->virtualY < fPtr->buildin.VDisplay)
- pScrn->virtualY = fPtr->buildin.VDisplay;
-}
-
-/* -------------------------------------------------------------------- */
-
-static void
-calculateFbmem_len(fbdevHWPtr fPtr)
-{
- fPtr->fboff = (unsigned long) fPtr->fix.smem_start & ~PAGE_MASK;
- fPtr->fbmem_len = (fPtr->fboff+fPtr->fix.smem_len+~PAGE_MASK) &
- PAGE_MASK;
-}
-
-
-void*
-fbdevHWMapVidmem(ScrnInfoPtr pScrn)
-{
- fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
-
- if (NULL == fPtr->fbmem) {
- calculateFbmem_len(fPtr);
- fPtr->fbmem = mmap(NULL, fPtr->fbmem_len, PROT_READ | PROT_WRITE,
- MAP_SHARED, fPtr->fd, 0);
- if (-1 == (long)fPtr->fbmem) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "mmap fbmem: %s\n", strerror(errno));
- fPtr->fbmem = NULL;
- } else {
- /* Perhaps we'd better add fboff to fbmem and return 0 in
- fbdevHWLinearOffset()? Of course we then need to mask
- fPtr->fbmem with PAGE_MASK in fbdevHWUnmapVidmem() as
- well. [geert] */
- }
- }
- pScrn->memPhysBase = (unsigned long)fPtr->fix.smem_start & (unsigned long)(PAGE_MASK);
- pScrn->fbOffset = (unsigned long)fPtr->fix.smem_start & (unsigned long)(~PAGE_MASK);
- return fPtr->fbmem;
-}
-
-int
-fbdevHWLinearOffset(ScrnInfoPtr pScrn)
-{
- fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
-
- return fPtr->fboff;
-}
-
-Bool
-fbdevHWUnmapVidmem(ScrnInfoPtr pScrn)
-{
- fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
-
- if (NULL != fPtr->fbmem) {
- if (-1 == munmap(fPtr->fbmem, fPtr->fbmem_len))
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "munmap fbmem: %s\n", strerror(errno));
- fPtr->fbmem = NULL;
- }
- return TRUE;
-}
-
-void*
-fbdevHWMapMMIO(ScrnInfoPtr pScrn)
-{
- unsigned int mmio_off;
-
- fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
-
- if (NULL == fPtr->mmio) {
- /* tell the kernel not to use accels to speed up console scrolling */
- fPtr->var.accel_flags = 0;
- if (0 != ioctl(fPtr->fd,FBIOPUT_VSCREENINFO,(void*)(&fPtr->var))) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "FBIOPUT_VSCREENINFO: %s\n", strerror(errno));
- return FALSE;
- }
- mmio_off = (unsigned long) fPtr->fix.mmio_start & ~PAGE_MASK;
- fPtr->mmio_len = (mmio_off+fPtr->fix.mmio_len+~PAGE_MASK) &
- PAGE_MASK;
- if (NULL == fPtr->fbmem)
- calculateFbmem_len(fPtr);
- fPtr->mmio = mmap(NULL, fPtr->mmio_len, PROT_READ | PROT_WRITE,
- MAP_SHARED, fPtr->fd, fPtr->fbmem_len);
- if (-1 == (long)fPtr->mmio) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "mmap mmio: %s\n", strerror(errno));
- fPtr->mmio = NULL;
- } else
- fPtr->mmio += mmio_off;
- }
- return fPtr->mmio;
-}
-
-Bool
-fbdevHWUnmapMMIO(ScrnInfoPtr pScrn)
-{
- fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
-
- if (NULL != fPtr->mmio) {
- if (-1 == munmap((void *)((unsigned long)fPtr->mmio & PAGE_MASK), fPtr->mmio_len))
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "munmap mmio: %s\n", strerror(errno));
- fPtr->mmio = NULL;
- /* FIXME: restore var.accel_flags [geert] */
- }
- return TRUE;
-}
-
-/* -------------------------------------------------------------------- */
-
-Bool
-fbdevHWModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
-{
- fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
-
- pScrn->vtSema = TRUE;
-
- /* set */
- if (!fbdevHWSetMode(pScrn, mode, FALSE))
- return FALSE;
-
- /* read back */
- if (0 != ioctl(fPtr->fd,FBIOGET_FSCREENINFO,(void*)(&fPtr->fix))) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "FBIOGET_FSCREENINFO: %s\n", strerror(errno));
- return FALSE;
- }
- if (0 != ioctl(fPtr->fd,FBIOGET_VSCREENINFO,(void*)(&fPtr->var))) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "FBIOGET_VSCREENINFO: %s\n", strerror(errno));
- return FALSE;
- }
-
- if (pScrn->defaultVisual == TrueColor ||
- pScrn->defaultVisual == DirectColor) {
- /* XXX: This is a hack, but it should be a NOP for all the setups that
- * worked before and actually seems to fix some others...
- */
- pScrn->offset.red = fPtr->var.red.offset;
- pScrn->offset.green = fPtr->var.green.offset;
- pScrn->offset.blue = fPtr->var.blue.offset;
- pScrn->mask.red = ((1 << fPtr->var.red.length) - 1) << fPtr->var.red.offset;
- pScrn->mask.green = ((1 << fPtr->var.green.length) - 1) << fPtr->var.green.offset;
- pScrn->mask.blue = ((1 << fPtr->var.blue.length) - 1) << fPtr->var.blue.offset;
- }
-
- return TRUE;
-}
-
-/* -------------------------------------------------------------------- */
-/* video mode save/restore */
-void
-fbdevHWSave(ScrnInfoPtr pScrn)
-{
- fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
-
- if (0 != ioctl(fPtr->fd,FBIOGET_VSCREENINFO,(void*)(&fPtr->saved_var)))
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "FBIOGET_VSCREENINFO: %s\n", strerror(errno));
-}
-
-void
-fbdevHWRestore(ScrnInfoPtr pScrn)
-{
- fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
-
- if (0 != ioctl(fPtr->fd,FBIOPUT_VSCREENINFO,(void*)(&fPtr->saved_var)))
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "FBIOPUT_VSCREENINFO: %s\n", strerror(errno));
-}
-
-/* -------------------------------------------------------------------- */
-/* callback for xf86HandleColormaps */
-
-void
-fbdevHWLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices,
- LOCO *colors, VisualPtr pVisual)
-{
- fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
- struct fb_cmap cmap;
- unsigned short red,green,blue;
- int i;
-
- cmap.len = 1;
- cmap.red = &red;
- cmap.green = &green;
- cmap.blue = &blue;
- cmap.transp = NULL;
- for (i = 0; i < numColors; i++) {
- cmap.start = indices[i];
- red = (colors[indices[i]].red << 8) |
- colors[indices[i]].red;
- green = (colors[indices[i]].green << 8) |
- colors[indices[i]].green;
- blue = (colors[indices[i]].blue << 8) |
- colors[indices[i]].blue;
- if (-1 == ioctl(fPtr->fd,FBIOPUTCMAP,(void*)&cmap))
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "FBIOPUTCMAP: %s\n", strerror(errno));
- }
-}
-
-/* -------------------------------------------------------------------- */
-/* these can be hooked directly into ScrnInfoRec */
-
-ModeStatus
-fbdevHWValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
-{
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
-
- if (!fbdevHWSetMode(pScrn, mode, TRUE))
- return MODE_BAD;
-
- return MODE_OK;
-}
-
-Bool
-fbdevHWSwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
-{
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
-
-
- if (!fbdevHWSetMode(pScrn, mode, FALSE))
- return FALSE;
-
- return TRUE;
-}
-
-void
-fbdevHWAdjustFrame(int scrnIndex, int x, int y, int flags)
-{
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
- fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
-
- if ( x < 0 || x + fPtr->var.xres > fPtr->var.xres_virtual ||
- y < 0 || y + fPtr->var.yres > fPtr->var.yres_virtual )
- return;
-
- fPtr->var.xoffset = x;
- fPtr->var.yoffset = y;
- if (-1 == ioctl(fPtr->fd,FBIOPAN_DISPLAY,(void*)&fPtr->var))
- xf86DrvMsgVerb(scrnIndex, X_WARNING, 5,
- "FBIOPAN_DISPLAY: %s\n", strerror(errno));
-}
-
-Bool
-fbdevHWEnterVT(int scrnIndex, int flags)
-{
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
-
- if (!fbdevHWModeInit(pScrn, pScrn->currentMode))
- return FALSE;
- fbdevHWAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
- return TRUE;
-}
-
-void
-fbdevHWLeaveVT(int scrnIndex, int flags)
-{
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
-
- fbdevHWRestore(pScrn);
-}
-
-void
-fbdevHWDPMSSet(ScrnInfoPtr pScrn, int mode, int flags)
-{
- fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
- unsigned long fbmode;
-
- if (!pScrn->vtSema)
- return;
-
- switch (mode) {
- case DPMSModeOn:
- fbmode = 0;
- break;
- case DPMSModeStandby:
- fbmode = 2;
- break;
- case DPMSModeSuspend:
- fbmode = 3;
- break;
- case DPMSModeOff:
- fbmode = 4;
- break;
- default:
- return;
- }
-
- if (-1 == ioctl(fPtr->fd, FBIOBLANK, (void *)fbmode))
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "FBIOBLANK: %s\n", strerror(errno));
-}
-
-Bool
-fbdevHWSaveScreen(ScreenPtr pScreen, int mode)
-{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
- unsigned long unblank;
-
- if (!pScrn->vtSema)
- return TRUE;
-
- unblank = xf86IsUnblank(mode);
-
- if (-1 == ioctl(fPtr->fd, FBIOBLANK, (void *)(1-unblank))) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "FBIOBLANK: %s\n", strerror(errno));
- return FALSE;
- }
-
- return TRUE;
-}
-
-xf86SwitchModeProc *
-fbdevHWSwitchModeWeak(void) { return fbdevHWSwitchMode; }
-
-xf86AdjustFrameProc *
-fbdevHWAdjustFrameWeak(void) { return fbdevHWAdjustFrame; }
-
-xf86EnterVTProc *
-fbdevHWEnterVTWeak(void) { return fbdevHWEnterVT; }
-
-xf86LeaveVTProc *
-fbdevHWLeaveVTWeak(void) { return fbdevHWLeaveVT; }
-
-xf86ValidModeProc *
-fbdevHWValidModeWeak(void) { return fbdevHWValidMode; }
-
-xf86DPMSSetProc *
-fbdevHWDPMSSetWeak(void) { return fbdevHWDPMSSet; }
-
-xf86LoadPaletteProc *
-fbdevHWLoadPaletteWeak(void) { return fbdevHWLoadPalette; }
-
-SaveScreenProcPtr
-fbdevHWSaveScreenWeak(void) { return fbdevHWSaveScreen; }
+/* all driver need this */
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <string.h>
+
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+/* pci stuff */
+#include "xf86PciInfo.h"
+#include "xf86Pci.h"
+
+#include "xf86cmap.h"
+
+#include "fbdevhw.h"
+#include "fbpriv.h"
+#include "globals.h"
+#include <X11/extensions/dpmsconst.h>
+
+#define PAGE_MASK (~(getpagesize() - 1))
+
+static XF86ModuleVersionInfo fbdevHWVersRec =
+{
+ "fbdevhw",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 0, 0, 2,
+ ABI_CLASS_VIDEODRV,
+ ABI_VIDEODRV_VERSION,
+ MOD_CLASS_NONE,
+ {0,0,0,0}
+};
+
+_X_EXPORT XF86ModuleData fbdevhwModuleData = {
+ &fbdevHWVersRec,
+ NULL,
+ NULL
+};
+
+#include <fcntl.h>
+#include <errno.h>
+#include <sys/mman.h>
+#include <sys/ioctl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+/* -------------------------------------------------------------------- */
+/* our private data, and two functions to allocate/free this */
+
+#define FBDEVHWPTRLVAL(p) (p)->privates[fbdevHWPrivateIndex].ptr
+#define FBDEVHWPTR(p) ((fbdevHWPtr)(FBDEVHWPTRLVAL(p)))
+
+static int fbdevHWPrivateIndex = -1;
+
+typedef struct {
+ /* framebuffer device: filename (/dev/fb*), handle, more */
+ char* device;
+ int fd;
+ void* fbmem;
+ unsigned int fbmem_len;
+ unsigned int fboff;
+ char* mmio;
+ unsigned int mmio_len;
+
+ /* current hardware state */
+ struct fb_fix_screeninfo fix;
+ struct fb_var_screeninfo var;
+
+ /* saved video mode */
+ struct fb_var_screeninfo saved_var;
+
+ /* buildin video mode */
+ DisplayModeRec buildin;
+
+} fbdevHWRec, *fbdevHWPtr;
+
+Bool
+fbdevHWGetRec(ScrnInfoPtr pScrn)
+{
+ fbdevHWPtr fPtr;
+
+ if (fbdevHWPrivateIndex < 0)
+ fbdevHWPrivateIndex = xf86AllocateScrnInfoPrivateIndex();
+
+ if (FBDEVHWPTR(pScrn) != NULL)
+ return TRUE;
+
+ fPtr = FBDEVHWPTRLVAL(pScrn) = xnfcalloc(sizeof(fbdevHWRec), 1);
+ return TRUE;
+}
+
+void
+fbdevHWFreeRec(ScrnInfoPtr pScrn)
+{
+ if (fbdevHWPrivateIndex < 0)
+ return;
+ if (FBDEVHWPTR(pScrn) == NULL)
+ return;
+ free(FBDEVHWPTR(pScrn));
+ FBDEVHWPTRLVAL(pScrn) = NULL;
+}
+
+int
+fbdevHWGetFD(ScrnInfoPtr pScrn)
+{
+ fbdevHWPtr fPtr;
+
+ fbdevHWGetRec(pScrn);
+ fPtr = FBDEVHWPTR(pScrn);
+
+ return fPtr->fd;
+}
+
+/* -------------------------------------------------------------------- */
+/* some helpers for printing debug informations */
+
+#if DEBUG
+static void
+print_fbdev_mode(char *txt, struct fb_var_screeninfo *var)
+{
+ ErrorF( "fbdev %s mode:\t%d %d %d %d %d %d %d %d %d %d %d:%d:%d\n",
+ txt,var->pixclock,
+ var->xres, var->right_margin, var->hsync_len, var->left_margin,
+ var->yres, var->lower_margin, var->vsync_len, var->upper_margin,
+ var->bits_per_pixel,
+ var->red.length, var->green.length, var->blue.length);
+}
+
+static void
+print_xfree_mode(char *txt, DisplayModePtr mode)
+{
+ ErrorF( "xfree %s mode:\t%d %d %d %d %d %d %d %d %d\n",
+ txt,mode->Clock,
+ mode->HDisplay, mode->HSyncStart, mode->HSyncEnd, mode->HTotal,
+ mode->VDisplay, mode->VSyncStart, mode->VSyncEnd, mode->VTotal);
+}
+#endif
+
+/* -------------------------------------------------------------------- */
+/* Convert timings between the XFree and the Frame Buffer Device */
+
+static void
+xfree2fbdev_fblayout(ScrnInfoPtr pScrn, struct fb_var_screeninfo *var)
+{
+ var->xres_virtual = pScrn->displayWidth ? pScrn->displayWidth :
+ pScrn->virtualX;
+ var->yres_virtual = pScrn->virtualY;
+ var->bits_per_pixel = pScrn->bitsPerPixel;
+ if (pScrn->defaultVisual == TrueColor ||
+ pScrn->defaultVisual == DirectColor) {
+ var->red.length = pScrn->weight.red;
+ var->green.length = pScrn->weight.green;
+ var->blue.length = pScrn->weight.blue;
+ } else {
+ var->red.length = 8;
+ var->green.length = 8;
+ var->blue.length = 8;
+ }
+}
+
+static void
+xfree2fbdev_timing(DisplayModePtr mode, struct fb_var_screeninfo *var)
+{
+ var->xres = mode->HDisplay;
+ var->yres = mode->VDisplay;
+ if (var->xres_virtual < var->xres)
+ var->xres_virtual = var->xres;
+ if (var->yres_virtual < var->yres)
+ var->yres_virtual = var->yres;
+ var->xoffset = var->yoffset = 0;
+ var->pixclock = mode->Clock ? 1000000000/mode->Clock : 0;
+ var->right_margin = mode->HSyncStart-mode->HDisplay;
+ var->hsync_len = mode->HSyncEnd-mode->HSyncStart;
+ var->left_margin = mode->HTotal-mode->HSyncEnd;
+ var->lower_margin = mode->VSyncStart-mode->VDisplay;
+ var->vsync_len = mode->VSyncEnd-mode->VSyncStart;
+ var->upper_margin = mode->VTotal-mode->VSyncEnd;
+ var->sync = 0;
+ if (mode->Flags & V_PHSYNC)
+ var->sync |= FB_SYNC_HOR_HIGH_ACT;
+ if (mode->Flags & V_PVSYNC)
+ var->sync |= FB_SYNC_VERT_HIGH_ACT;
+ if (mode->Flags & V_PCSYNC)
+ var->sync |= FB_SYNC_COMP_HIGH_ACT;
+ if (mode->Flags & V_BCAST)
+ var->sync |= FB_SYNC_BROADCAST;
+ if (mode->Flags & V_INTERLACE)
+ var->vmode = FB_VMODE_INTERLACED;
+ else if (mode->Flags & V_DBLSCAN)
+ var->vmode = FB_VMODE_DOUBLE;
+ else
+ var->vmode = FB_VMODE_NONINTERLACED;
+}
+
+static Bool
+fbdev_modes_equal(struct fb_var_screeninfo *set, struct fb_var_screeninfo *req)
+{
+ return (set->xres_virtual >= req->xres_virtual &&
+ set->yres_virtual >= req->yres_virtual &&
+ set->bits_per_pixel == req->bits_per_pixel &&
+ set->red.length == req->red.length &&
+ set->green.length == req->green.length &&
+ set->blue.length == req->blue.length &&
+ set->xres == req->xres && set->yres == req->yres &&
+ set->right_margin == req->right_margin &&
+ set->hsync_len == req->hsync_len &&
+ set->left_margin == req->left_margin &&
+ set->lower_margin == req->lower_margin &&
+ set->vsync_len == req->vsync_len &&
+ set->upper_margin == req->upper_margin &&
+ set->sync == req->sync && set->vmode == req->vmode);
+}
+
+static void
+fbdev2xfree_timing(struct fb_var_screeninfo *var, DisplayModePtr mode)
+{
+ mode->Clock = var->pixclock ? 1000000000/var->pixclock : 0;
+ mode->HDisplay = var->xres;
+ mode->HSyncStart = mode->HDisplay+var->right_margin;
+ mode->HSyncEnd = mode->HSyncStart+var->hsync_len;
+ mode->HTotal = mode->HSyncEnd+var->left_margin;
+ mode->VDisplay = var->yres;
+ mode->VSyncStart = mode->VDisplay+var->lower_margin;
+ mode->VSyncEnd = mode->VSyncStart+var->vsync_len;
+ mode->VTotal = mode->VSyncEnd+var->upper_margin;
+ mode->Flags = 0;
+ mode->Flags |= var->sync & FB_SYNC_HOR_HIGH_ACT ? V_PHSYNC : V_NHSYNC;
+ mode->Flags |= var->sync & FB_SYNC_VERT_HIGH_ACT ? V_PVSYNC : V_NVSYNC;
+ mode->Flags |= var->sync & FB_SYNC_COMP_HIGH_ACT ? V_PCSYNC : V_NCSYNC;
+ if (var->sync & FB_SYNC_BROADCAST)
+ mode->Flags |= V_BCAST;
+ if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED)
+ mode->Flags |= V_INTERLACE;
+ else if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE)
+ mode->Flags |= V_DBLSCAN;
+ mode->SynthClock = mode->Clock;
+ mode->CrtcHDisplay = mode->HDisplay;
+ mode->CrtcHSyncStart = mode->HSyncStart;
+ mode->CrtcHSyncEnd = mode->HSyncEnd;
+ mode->CrtcHTotal = mode->HTotal;
+ mode->CrtcVDisplay = mode->VDisplay;
+ mode->CrtcVSyncStart = mode->VSyncStart;
+ mode->CrtcVSyncEnd = mode->VSyncEnd;
+ mode->CrtcVTotal = mode->VTotal;
+ mode->CrtcHAdjusted = FALSE;
+ mode->CrtcVAdjusted = FALSE;
+}
+
+
+/* -------------------------------------------------------------------- */
+/* open correct framebuffer device */
+
+/**
+ * Try to find the framebuffer device for a given PCI device
+ */
+static int
+fbdev_open_pci(struct pci_device * pPci, char **namep)
+{
+ struct fb_fix_screeninfo fix;
+ char filename[256];
+ int fd, i;
+
+ for (i = 0; i < 8; i++) {
+ sprintf(filename,
+ "/sys/bus/pci/devices/%04x:%02x:%02x.%d/graphics/fb%d",
+ pPci->domain, pPci->bus, pPci->dev, pPci->func, i);
+
+ fd = open(filename, O_RDONLY, 0);
+ if (fd < 0) {
+ sprintf(filename,
+ "/sys/bus/pci/devices/%04x:%02x:%02x.%d/graphics:fb%d",
+ pPci->domain, pPci->bus, pPci->dev, pPci->func, i);
+ fd = open(filename, O_RDONLY, 0);
+ }
+ if (fd >= 0) {
+ close(fd);
+ sprintf(filename, "/dev/fb%d", i);
+
+ fd = open(filename, O_RDWR, 0);
+ if (fd != -1) {
+ if (ioctl(fd, FBIOGET_FSCREENINFO, (void*) & fix) != -1) {
+ if (namep) {
+ *namep = xnfalloc(16);
+ strncpy(*namep,fix.id,16);
+ }
+
+ return fd;
+ }
+ close(fd);
+ }
+ }
+ }
+
+ if (namep)
+ *namep = NULL;
+
+ xf86DrvMsg(-1, X_ERROR, "Unable to find a valid framebuffer device\n");
+ return -1;
+}
+
+static int
+fbdev_open(int scrnIndex, char *dev, char** namep)
+{
+ struct fb_fix_screeninfo fix;
+ int fd;
+
+ /* try argument (from XF86Config) first */
+ if (dev) {
+ fd = open(dev,O_RDWR,0);
+ } else {
+ /* second: environment variable */
+ dev = getenv("FRAMEBUFFER");
+ if ((NULL == dev) || ((fd = open(dev,O_RDWR,0)) == -1)) {
+ /* last try: default device */
+ dev = "/dev/fb0";
+ fd = open(dev,O_RDWR,0);
+ }
+ }
+
+ if (fd == -1) {
+ xf86DrvMsg(scrnIndex, X_ERROR,
+ "open %s: %s\n", dev, strerror(errno));
+ return -1;
+ }
+
+ if (namep) {
+ if (-1 == ioctl(fd,FBIOGET_FSCREENINFO,(void*)(&fix))) {
+ *namep = NULL;
+ xf86DrvMsg(scrnIndex, X_ERROR,
+ "FBIOGET_FSCREENINFO: %s\n", strerror(errno));
+ return -1;
+ } else {
+ *namep = xnfalloc(16);
+ strncpy(*namep,fix.id,16);
+ }
+ }
+ return fd;
+}
+
+/* -------------------------------------------------------------------- */
+
+Bool
+fbdevHWProbe(struct pci_device * pPci, char *device,char **namep)
+{
+ int fd;
+
+ if (pPci)
+ fd = fbdev_open_pci(pPci,namep);
+ else
+ fd = fbdev_open(-1,device,namep);
+
+ if (-1 == fd)
+ return FALSE;
+ close(fd);
+ return TRUE;
+}
+
+Bool
+fbdevHWInit(ScrnInfoPtr pScrn, struct pci_device * pPci, char *device)
+{
+ fbdevHWPtr fPtr;
+
+ fbdevHWGetRec(pScrn);
+ fPtr = FBDEVHWPTR(pScrn);
+
+ /* open device */
+ if (pPci)
+ fPtr->fd = fbdev_open_pci(pPci,NULL);
+ else
+ fPtr->fd = fbdev_open(pScrn->scrnIndex,device,NULL);
+ if (-1 == fPtr->fd) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Failed to open framebuffer device, consult warnings"
+ " and/or errors above for possible reasons\n"
+ "\t(you may have to look at the server log to see"
+ " warnings)\n");
+ return FALSE;
+ }
+
+ /* get current fb device settings */
+ if (-1 == ioctl(fPtr->fd,FBIOGET_FSCREENINFO,(void*)(&fPtr->fix))) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "ioctl FBIOGET_FSCREENINFO: %s\n",
+ strerror(errno));
+ return FALSE;
+ }
+ if (-1 == ioctl(fPtr->fd,FBIOGET_VSCREENINFO,(void*)(&fPtr->var))) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "ioctl FBIOGET_VSCREENINFO: %s\n",
+ strerror(errno));
+ return FALSE;
+ }
+
+ /* we can use the current settings as "buildin mode" */
+ fbdev2xfree_timing(&fPtr->var, &fPtr->buildin);
+ fPtr->buildin.name = "current";
+ fPtr->buildin.next = &fPtr->buildin;
+ fPtr->buildin.prev = &fPtr->buildin;
+ fPtr->buildin.type |= M_T_BUILTIN;
+
+ return TRUE;
+}
+
+char*
+fbdevHWGetName(ScrnInfoPtr pScrn)
+{
+ fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
+ return fPtr->fix.id;
+}
+
+int
+fbdevHWGetDepth(ScrnInfoPtr pScrn, int *fbbpp)
+{
+ fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
+
+ if (fbbpp)
+ *fbbpp = fPtr->var.bits_per_pixel;
+
+ if (fPtr->fix.visual == FB_VISUAL_TRUECOLOR ||
+ fPtr->fix.visual == FB_VISUAL_DIRECTCOLOR)
+ return fPtr->var.red.length+fPtr->var.green.length+
+ fPtr->var.blue.length;
+ else
+ return fPtr->var.bits_per_pixel;
+}
+
+int
+fbdevHWGetLineLength(ScrnInfoPtr pScrn)
+{
+ fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
+
+ if (fPtr->fix.line_length)
+ return fPtr->fix.line_length;
+ else
+ return fPtr->var.xres_virtual*fPtr->var.bits_per_pixel/8;
+}
+
+int
+fbdevHWGetType(ScrnInfoPtr pScrn)
+{
+ fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
+ return fPtr->fix.type;
+}
+
+int
+fbdevHWGetVidmem(ScrnInfoPtr pScrn)
+{
+ fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
+ return fPtr->fix.smem_len;
+}
+
+static Bool
+fbdevHWSetMode(ScrnInfoPtr pScrn, DisplayModePtr mode, Bool check)
+{
+ fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
+ struct fb_var_screeninfo req_var = fPtr->var, set_var;
+
+ xfree2fbdev_fblayout(pScrn, &req_var);
+ xfree2fbdev_timing(mode, &req_var);
+
+#if DEBUG
+ print_xfree_mode("init", mode);
+ print_fbdev_mode("init", &req_var);
+#endif
+
+ set_var = req_var;
+
+ if (check)
+ set_var.activate = FB_ACTIVATE_TEST;
+
+ if (0 != ioctl(fPtr->fd, FBIOPUT_VSCREENINFO, (void*)(&set_var))) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "FBIOPUT_VSCREENINFO: %s\n", strerror(errno));
+ return FALSE;
+ }
+
+ if (!fbdev_modes_equal(&set_var, &req_var)) {
+ if (!check)
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "FBIOPUT_VSCREENINFO succeeded but modified "
+ "mode\n");
+#if DEBUG
+ print_fbdev_mode("returned", &set_var);
+#endif
+ return FALSE;
+ }
+
+ if (!check)
+ fPtr->var = set_var;
+
+ return TRUE;
+}
+
+void
+fbdevHWSetVideoModes(ScrnInfoPtr pScrn)
+{
+ char **modename;
+ DisplayModePtr mode,this,last = pScrn->modes;
+
+ if (NULL == pScrn->display->modes)
+ return;
+
+ pScrn->virtualX = pScrn->display->virtualX;
+ pScrn->virtualY = pScrn->display->virtualY;
+
+ for (modename = pScrn->display->modes; *modename != NULL; modename++) {
+ for (mode = pScrn->monitor->Modes; mode != NULL; mode = mode->next)
+ if (0 == strcmp(mode->name,*modename))
+ break;
+ if (NULL == mode) {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "\tmode \"%s\" not found\n", *modename);
+ continue;
+ }
+
+ if (!fbdevHWSetMode(pScrn, mode, TRUE)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "\tmode \"%s\" test failed\n", *modename);
+ continue;
+ }
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "\tmode \"%s\" ok\n", *modename);
+
+ if (pScrn->virtualX < mode->HDisplay)
+ pScrn->virtualX = mode->HDisplay;
+ if (pScrn->virtualY < mode->VDisplay)
+ pScrn->virtualY = mode->VDisplay;
+
+ if (NULL == pScrn->modes) {
+ this = pScrn->modes = xf86DuplicateMode(mode);
+ this->next = this;
+ this->prev = this;
+ } else {
+ this = xf86DuplicateMode(mode);
+ this->next = pScrn->modes;
+ this->prev = last;
+ last->next = this;
+ pScrn->modes->prev = this;
+ }
+ last = this;
+ }
+}
+
+DisplayModePtr
+fbdevHWGetBuildinMode(ScrnInfoPtr pScrn)
+{
+ fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
+ return &fPtr->buildin;
+}
+
+void
+fbdevHWUseBuildinMode(ScrnInfoPtr pScrn)
+{
+ fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
+
+ pScrn->modes = &fPtr->buildin;
+ pScrn->virtualX = pScrn->display->virtualX;
+ pScrn->virtualY = pScrn->display->virtualY;
+ if (pScrn->virtualX < fPtr->buildin.HDisplay)
+ pScrn->virtualX = fPtr->buildin.HDisplay;
+ if (pScrn->virtualY < fPtr->buildin.VDisplay)
+ pScrn->virtualY = fPtr->buildin.VDisplay;
+}
+
+/* -------------------------------------------------------------------- */
+
+static void
+calculateFbmem_len(fbdevHWPtr fPtr)
+{
+ fPtr->fboff = (unsigned long) fPtr->fix.smem_start & ~PAGE_MASK;
+ fPtr->fbmem_len = (fPtr->fboff+fPtr->fix.smem_len+~PAGE_MASK) &
+ PAGE_MASK;
+}
+
+
+void*
+fbdevHWMapVidmem(ScrnInfoPtr pScrn)
+{
+ fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
+
+ if (NULL == fPtr->fbmem) {
+ calculateFbmem_len(fPtr);
+ fPtr->fbmem = mmap(NULL, fPtr->fbmem_len, PROT_READ | PROT_WRITE,
+ MAP_SHARED, fPtr->fd, 0);
+ if (-1 == (long)fPtr->fbmem) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "mmap fbmem: %s\n", strerror(errno));
+ fPtr->fbmem = NULL;
+ } else {
+ /* Perhaps we'd better add fboff to fbmem and return 0 in
+ fbdevHWLinearOffset()? Of course we then need to mask
+ fPtr->fbmem with PAGE_MASK in fbdevHWUnmapVidmem() as
+ well. [geert] */
+ }
+ }
+ pScrn->memPhysBase = (unsigned long)fPtr->fix.smem_start & (unsigned long)(PAGE_MASK);
+ pScrn->fbOffset = (unsigned long)fPtr->fix.smem_start & (unsigned long)(~PAGE_MASK);
+ return fPtr->fbmem;
+}
+
+int
+fbdevHWLinearOffset(ScrnInfoPtr pScrn)
+{
+ fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
+
+ return fPtr->fboff;
+}
+
+Bool
+fbdevHWUnmapVidmem(ScrnInfoPtr pScrn)
+{
+ fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
+
+ if (NULL != fPtr->fbmem) {
+ if (-1 == munmap(fPtr->fbmem, fPtr->fbmem_len))
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "munmap fbmem: %s\n", strerror(errno));
+ fPtr->fbmem = NULL;
+ }
+ return TRUE;
+}
+
+void*
+fbdevHWMapMMIO(ScrnInfoPtr pScrn)
+{
+ unsigned int mmio_off;
+
+ fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
+
+ if (NULL == fPtr->mmio) {
+ /* tell the kernel not to use accels to speed up console scrolling */
+ fPtr->var.accel_flags = 0;
+ if (0 != ioctl(fPtr->fd,FBIOPUT_VSCREENINFO,(void*)(&fPtr->var))) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "FBIOPUT_VSCREENINFO: %s\n", strerror(errno));
+ return FALSE;
+ }
+ mmio_off = (unsigned long) fPtr->fix.mmio_start & ~PAGE_MASK;
+ fPtr->mmio_len = (mmio_off+fPtr->fix.mmio_len+~PAGE_MASK) &
+ PAGE_MASK;
+ if (NULL == fPtr->fbmem)
+ calculateFbmem_len(fPtr);
+ fPtr->mmio = mmap(NULL, fPtr->mmio_len, PROT_READ | PROT_WRITE,
+ MAP_SHARED, fPtr->fd, fPtr->fbmem_len);
+ if (-1 == (long)fPtr->mmio) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "mmap mmio: %s\n", strerror(errno));
+ fPtr->mmio = NULL;
+ } else
+ fPtr->mmio += mmio_off;
+ }
+ return fPtr->mmio;
+}
+
+Bool
+fbdevHWUnmapMMIO(ScrnInfoPtr pScrn)
+{
+ fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
+
+ if (NULL != fPtr->mmio) {
+ if (-1 == munmap((void *)((unsigned long)fPtr->mmio & PAGE_MASK), fPtr->mmio_len))
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "munmap mmio: %s\n", strerror(errno));
+ fPtr->mmio = NULL;
+ /* FIXME: restore var.accel_flags [geert] */
+ }
+ return TRUE;
+}
+
+/* -------------------------------------------------------------------- */
+
+Bool
+fbdevHWModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
+{
+ fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
+
+ pScrn->vtSema = TRUE;
+
+ /* set */
+ if (!fbdevHWSetMode(pScrn, mode, FALSE))
+ return FALSE;
+
+ /* read back */
+ if (0 != ioctl(fPtr->fd,FBIOGET_FSCREENINFO,(void*)(&fPtr->fix))) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "FBIOGET_FSCREENINFO: %s\n", strerror(errno));
+ return FALSE;
+ }
+ if (0 != ioctl(fPtr->fd,FBIOGET_VSCREENINFO,(void*)(&fPtr->var))) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "FBIOGET_VSCREENINFO: %s\n", strerror(errno));
+ return FALSE;
+ }
+
+ if (pScrn->defaultVisual == TrueColor ||
+ pScrn->defaultVisual == DirectColor) {
+ /* XXX: This is a hack, but it should be a NOP for all the setups that
+ * worked before and actually seems to fix some others...
+ */
+ pScrn->offset.red = fPtr->var.red.offset;
+ pScrn->offset.green = fPtr->var.green.offset;
+ pScrn->offset.blue = fPtr->var.blue.offset;
+ pScrn->mask.red = ((1 << fPtr->var.red.length) - 1) << fPtr->var.red.offset;
+ pScrn->mask.green = ((1 << fPtr->var.green.length) - 1) << fPtr->var.green.offset;
+ pScrn->mask.blue = ((1 << fPtr->var.blue.length) - 1) << fPtr->var.blue.offset;
+ }
+
+ return TRUE;
+}
+
+/* -------------------------------------------------------------------- */
+/* video mode save/restore */
+void
+fbdevHWSave(ScrnInfoPtr pScrn)
+{
+ fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
+
+ if (0 != ioctl(fPtr->fd,FBIOGET_VSCREENINFO,(void*)(&fPtr->saved_var)))
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "FBIOGET_VSCREENINFO: %s\n", strerror(errno));
+}
+
+void
+fbdevHWRestore(ScrnInfoPtr pScrn)
+{
+ fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
+
+ if (0 != ioctl(fPtr->fd,FBIOPUT_VSCREENINFO,(void*)(&fPtr->saved_var)))
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "FBIOPUT_VSCREENINFO: %s\n", strerror(errno));
+}
+
+/* -------------------------------------------------------------------- */
+/* callback for xf86HandleColormaps */
+
+void
+fbdevHWLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices,
+ LOCO *colors, VisualPtr pVisual)
+{
+ fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
+ struct fb_cmap cmap;
+ unsigned short red,green,blue;
+ int i;
+
+ cmap.len = 1;
+ cmap.red = &red;
+ cmap.green = &green;
+ cmap.blue = &blue;
+ cmap.transp = NULL;
+ for (i = 0; i < numColors; i++) {
+ cmap.start = indices[i];
+ red = (colors[indices[i]].red << 8) |
+ colors[indices[i]].red;
+ green = (colors[indices[i]].green << 8) |
+ colors[indices[i]].green;
+ blue = (colors[indices[i]].blue << 8) |
+ colors[indices[i]].blue;
+ if (-1 == ioctl(fPtr->fd,FBIOPUTCMAP,(void*)&cmap))
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "FBIOPUTCMAP: %s\n", strerror(errno));
+ }
+}
+
+/* -------------------------------------------------------------------- */
+/* these can be hooked directly into ScrnInfoRec */
+
+ModeStatus
+fbdevHWValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+
+ if (!fbdevHWSetMode(pScrn, mode, TRUE))
+ return MODE_BAD;
+
+ return MODE_OK;
+}
+
+Bool
+fbdevHWSwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+
+
+ if (!fbdevHWSetMode(pScrn, mode, FALSE))
+ return FALSE;
+
+ return TRUE;
+}
+
+void
+fbdevHWAdjustFrame(int scrnIndex, int x, int y, int flags)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
+
+ if ( x < 0 || x + fPtr->var.xres > fPtr->var.xres_virtual ||
+ y < 0 || y + fPtr->var.yres > fPtr->var.yres_virtual )
+ return;
+
+ fPtr->var.xoffset = x;
+ fPtr->var.yoffset = y;
+ if (-1 == ioctl(fPtr->fd,FBIOPAN_DISPLAY,(void*)&fPtr->var))
+ xf86DrvMsgVerb(scrnIndex, X_WARNING, 5,
+ "FBIOPAN_DISPLAY: %s\n", strerror(errno));
+}
+
+Bool
+fbdevHWEnterVT(int scrnIndex, int flags)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+
+ if (!fbdevHWModeInit(pScrn, pScrn->currentMode))
+ return FALSE;
+ fbdevHWAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
+ return TRUE;
+}
+
+void
+fbdevHWLeaveVT(int scrnIndex, int flags)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+
+ fbdevHWRestore(pScrn);
+}
+
+void
+fbdevHWDPMSSet(ScrnInfoPtr pScrn, int mode, int flags)
+{
+ fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
+ unsigned long fbmode;
+
+ if (!pScrn->vtSema)
+ return;
+
+ switch (mode) {
+ case DPMSModeOn:
+ fbmode = 0;
+ break;
+ case DPMSModeStandby:
+ fbmode = 2;
+ break;
+ case DPMSModeSuspend:
+ fbmode = 3;
+ break;
+ case DPMSModeOff:
+ fbmode = 4;
+ break;
+ default:
+ return;
+ }
+
+ if (-1 == ioctl(fPtr->fd, FBIOBLANK, (void *)fbmode))
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "FBIOBLANK: %s\n", strerror(errno));
+}
+
+Bool
+fbdevHWSaveScreen(ScreenPtr pScreen, int mode)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
+ unsigned long unblank;
+
+ if (!pScrn->vtSema)
+ return TRUE;
+
+ unblank = xf86IsUnblank(mode);
+
+ if (-1 == ioctl(fPtr->fd, FBIOBLANK, (void *)(1-unblank))) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "FBIOBLANK: %s\n", strerror(errno));
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+xf86SwitchModeProc *
+fbdevHWSwitchModeWeak(void) { return fbdevHWSwitchMode; }
+
+xf86AdjustFrameProc *
+fbdevHWAdjustFrameWeak(void) { return fbdevHWAdjustFrame; }
+
+xf86EnterVTProc *
+fbdevHWEnterVTWeak(void) { return fbdevHWEnterVT; }
+
+xf86LeaveVTProc *
+fbdevHWLeaveVTWeak(void) { return fbdevHWLeaveVT; }
+
+xf86ValidModeProc *
+fbdevHWValidModeWeak(void) { return fbdevHWValidMode; }
+
+xf86DPMSSetProc *
+fbdevHWDPMSSetWeak(void) { return fbdevHWDPMSSet; }
+
+xf86LoadPaletteProc *
+fbdevHWLoadPaletteWeak(void) { return fbdevHWLoadPalette; }
+
+SaveScreenProcPtr
+fbdevHWSaveScreenWeak(void) { return fbdevHWSaveScreen; }
diff --git a/xorg-server/hw/xfree86/loader/Makefile.am b/xorg-server/hw/xfree86/loader/Makefile.am
index 07529b7b0..ebe0c813a 100644
--- a/xorg-server/hw/xfree86/loader/Makefile.am
+++ b/xorg-server/hw/xfree86/loader/Makefile.am
@@ -1,21 +1,21 @@
-noinst_LTLIBRARIES = libloader.la
-
-INCLUDES = $(XORG_INCS) -I$(srcdir)/../parser -I$(top_srcdir)/miext/cw \
- -I$(srcdir)/../ddc -I$(srcdir)/../i2c -I$(srcdir)/../modes \
- -I$(srcdir)/../ramdac
-
-#AM_LDFLAGS = -r
-AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
-
-EXTRA_DIST = \
- loader.h \
- loaderProcs.h
-
-libloader_la_SOURCES = \
- loader.c \
- loaderProcs.h \
- loadext.c \
- loadmod.c \
- os.c
-
-libloader_la_LIBADD = $(DLOPEN_LIBS)
+noinst_LTLIBRARIES = libloader.la
+
+INCLUDES = $(XORG_INCS) -I$(srcdir)/../parser -I$(top_srcdir)/miext/cw \
+ -I$(srcdir)/../ddc -I$(srcdir)/../i2c -I$(srcdir)/../modes \
+ -I$(srcdir)/../ramdac
+
+#AM_LDFLAGS = -r
+AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
+
+EXTRA_DIST = \
+ loader.h \
+ loaderProcs.h
+
+libloader_la_SOURCES = \
+ loader.c \
+ loaderProcs.h \
+ loadext.c \
+ loadmod.c \
+ os.c
+
+libloader_la_LIBADD = $(DLOPEN_LIBS)
diff --git a/xorg-server/hw/xfree86/loader/loadmod.c b/xorg-server/hw/xfree86/loader/loadmod.c
index cf231c1f0..9f820993a 100644
--- a/xorg-server/hw/xfree86/loader/loadmod.c
+++ b/xorg-server/hw/xfree86/loader/loadmod.c
@@ -1,1253 +1,1253 @@
-/*
- * Copyright 1995-1998 by Metro Link, Inc.
- *
- * 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 Metro Link, Inc. not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Metro Link, Inc. makes no
- * representations about the suitability of this software for any purpose.
- * It is provided "as is" without express or implied warranty.
- *
- * METRO LINK, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL METRO LINK, INC. 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) 1997-2002 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).
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "os.h"
-/* For stat() and related stuff */
-#define NO_OSLIB_PROTOTYPES
-#include "xf86_OSlib.h"
-#define LOADERDECLARATIONS
-#include "loaderProcs.h"
-#include "misc.h"
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86Xinput.h"
-#include "loader.h"
-#include "xf86Optrec.h"
-
-#include <sys/types.h>
-#include <regex.h>
-#include <dirent.h>
-#include <limits.h>
-
-typedef struct _pattern {
- const char *pattern;
- regex_t rex;
-} PatternRec, *PatternPtr;
-
-/* Prototypes for static functions */
-static char *FindModule(const char *, const char *, const char **,
- PatternPtr);
-static Bool CheckVersion(const char *, XF86ModuleVersionInfo *,
- const XF86ModReqInfo *);
-static void UnloadModuleOrDriver(ModuleDescPtr mod);
-static char *LoaderGetCanonicalName(const char *, PatternPtr);
-static void RemoveChild(ModuleDescPtr);
-static ModuleDescPtr doLoadModule(const char *, const char *, const char **,
- const char **, pointer,
- const XF86ModReqInfo *, int *, int *);
-
-const ModuleVersions LoaderVersionInfo = {
- XORG_VERSION_CURRENT,
- ABI_ANSIC_VERSION,
- ABI_VIDEODRV_VERSION,
- ABI_XINPUT_VERSION,
- ABI_EXTENSION_VERSION,
- ABI_FONT_VERSION
-};
-
-static void
-FreeStringList(char **paths)
-{
- char **p;
-
- if (!paths)
- return;
-
- for (p = paths; *p; p++)
- free(*p);
-
- free(paths);
-}
-
-static char **defaultPathList = NULL;
-
-static Bool
-PathIsAbsolute(const char *path)
-{
- return *path == '/';
-}
-
-/*
- * Convert a comma-separated path into a NULL-terminated array of path
- * elements, rejecting any that are not full absolute paths, and appending
- * a '/' when it isn't already present.
- */
-static char **
-InitPathList(const char *path)
-{
- char *fullpath = NULL;
- char *elem = NULL;
- char **list = NULL, **save = NULL;
- int len;
- int addslash;
- int n = 0;
-
- if (!path)
- return defaultPathList;
-
- fullpath = strdup(path);
- if (!fullpath)
- return NULL;
- elem = strtok(fullpath, ",");
- while (elem) {
- if (PathIsAbsolute(elem))
- {
- len = strlen(elem);
- addslash = (elem[len - 1] != '/');
- if (addslash)
- len++;
- save = list;
- list = realloc(list, (n + 2) * sizeof(char *));
- if (!list) {
- if (save) {
- save[n] = NULL;
- FreeStringList(save);
- }
- free(fullpath);
- return NULL;
- }
- list[n] = malloc(len + 1);
- if (!list[n]) {
- FreeStringList(list);
- free(fullpath);
- return NULL;
- }
- strcpy(list[n], elem);
- if (addslash) {
- list[n][len - 1] = '/';
- list[n][len] = '\0';
- }
- n++;
- }
- elem = strtok(NULL, ",");
- }
- if (list)
- list[n] = NULL;
- free(fullpath);
- return list;
-}
-
-static void
-FreePathList(char **pathlist)
-{
- if (pathlist && pathlist != defaultPathList)
- FreeStringList(pathlist);
-}
-
-void
-LoaderSetPath(const char *path)
-{
- if (!path)
- return;
-
- defaultPathList = InitPathList(path);
-}
-
-/* Standard set of module subdirectories to search, in order of preference */
-static const char *stdSubdirs[] = {
- "",
- "input/",
- "drivers/",
- "multimedia/",
- "extensions/",
- "internal/",
- NULL
-};
-
-/*
- * Standard set of module name patterns to check, in order of preference
- * These are regular expressions (suitable for use with POSIX regex(3)).
- *
- * This list assumes that you're an ELFish platform and therefore your
- * shared libraries are named something.so. If we're ever nuts enough
- * to port this DDX to, say, Darwin, we'll need to fix this.
- */
-static PatternRec stdPatterns[] = {
- {"^lib(.*)\\.so$",},
- {"(.*)_drv\\.so$",},
- {"(.*)\\.so$",},
- {NULL,}
-};
-
-static PatternPtr
-InitPatterns(const char **patternlist)
-{
- char errmsg[80];
- int i, e;
- PatternPtr patterns = NULL;
- PatternPtr p = NULL;
- static int firstTime = 1;
- const char **s;
-
- if (firstTime) {
- /* precompile stdPatterns */
- firstTime = 0;
- for (p = stdPatterns; p->pattern; p++)
- if ((e = regcomp(&p->rex, p->pattern, REG_EXTENDED)) != 0) {
- regerror(e, &p->rex, errmsg, sizeof(errmsg));
- FatalError("InitPatterns: regcomp error for `%s': %s\n",
- p->pattern, errmsg);
- }
- }
-
- if (patternlist) {
- for (i = 0, s = patternlist; *s; i++, s++)
- if (*s == DEFAULT_LIST)
- i += sizeof(stdPatterns) / sizeof(stdPatterns[0]) - 1 - 1;
- patterns = malloc((i + 1) * sizeof(PatternRec));
- if (!patterns) {
- return NULL;
- }
- for (i = 0, s = patternlist; *s; i++, s++)
- if (*s != DEFAULT_LIST) {
- p = patterns + i;
- p->pattern = *s;
- if ((e = regcomp(&p->rex, p->pattern, REG_EXTENDED)) != 0) {
- regerror(e, &p->rex, errmsg, sizeof(errmsg));
- ErrorF("InitPatterns: regcomp error for `%s': %s\n",
- p->pattern, errmsg);
- i--;
- }
- } else {
- for (p = stdPatterns; p->pattern; p++, i++)
- patterns[i] = *p;
- if (p != stdPatterns)
- i--;
- }
- patterns[i].pattern = NULL;
- } else
- patterns = stdPatterns;
- return patterns;
-}
-
-static void
-FreePatterns(PatternPtr patterns)
-{
- if (patterns && patterns != stdPatterns)
- free(patterns);
-}
-
-static const char **
-InitSubdirs(const char **subdirlist)
-{
- int i;
- const char **tmp_subdirlist = NULL;
- char **subdirs = NULL;
- const char **s, **stmp = NULL;
- const char *osname;
- const char *slash;
- int oslen = 0, len;
- Bool indefault;
-
- if (subdirlist == NULL) {
- subdirlist = tmp_subdirlist = malloc(2 * sizeof(char *));
- if (subdirlist == NULL)
- return NULL;
- subdirlist[0] = DEFAULT_LIST;
- subdirlist[1] = NULL;
- }
-
- LoaderGetOS(&osname, NULL, NULL, NULL);
- oslen = strlen(osname);
-
- {
- /* Count number of entries and check for invalid paths */
- for (i = 0, s = subdirlist; *s; i++, s++) {
- if (*s == DEFAULT_LIST) {
- i += sizeof(stdSubdirs) / sizeof(stdSubdirs[0]) - 1 - 1;
- } else {
- /*
- * Path validity check. Don't allow absolute paths, or
- * paths containing "..". To catch absolute paths on
- * platforms that use driver letters, don't allow the ':'
- * character to appear at all.
- */
- if (**s == '/' || **s == '\\' || strchr(*s, ':') ||
- strstr(*s, "..")) {
- xf86Msg(X_ERROR, "InitSubdirs: Bad subdir: \"%s\"\n", *s);
- free(tmp_subdirlist);
- return NULL;
- }
- }
- }
- subdirs = malloc((i * 2 + 1) * sizeof(char *));
- if (!subdirs) {
- free(tmp_subdirlist);
- return NULL;
- }
- i = 0;
- s = subdirlist;
- indefault = FALSE;
- while (*s) {
- if (*s == DEFAULT_LIST) {
- /* Divert to the default list */
- indefault = TRUE;
- stmp = ++s;
- s = stdSubdirs;
- }
- len = strlen(*s);
- if (**s && (*s)[len - 1] != '/') {
- slash = "/";
- len++;
- } else
- slash = "";
- len += oslen + 2;
- if (!(subdirs[i] = malloc(len))) {
- while (--i >= 0)
- free(subdirs[i]);
- free(subdirs);
- free(tmp_subdirlist);
- return NULL;
- }
- /* tack on the OS name */
- sprintf(subdirs[i], "%s%s%s/", *s, slash, osname);
- i++;
- /* path as given */
- subdirs[i] = strdup(*s);
- i++;
- s++;
- if (indefault && !s) {
- /* revert back to the main list */
- indefault = FALSE;
- s = stmp;
- }
- }
- subdirs[i] = NULL;
- }
- free(tmp_subdirlist);
- return (const char **)subdirs;
-}
-
-static void
-FreeSubdirs(const char **subdirs)
-{
- const char **s;
-
- if (subdirs) {
- for (s = subdirs; *s; s++)
- free((char *)*s);
- free(subdirs);
- }
-}
-
-static char *
-FindModuleInSubdir(const char *dirpath, const char *module)
-{
- struct dirent *direntry = NULL;
- DIR *dir = NULL;
- char *ret = NULL, tmpBuf[PATH_MAX];
- struct stat stat_buf;
-
- dir = opendir(dirpath);
- if (!dir)
- return NULL;
-
- while ((direntry = readdir(dir))) {
- if (direntry->d_name[0] == '.')
- continue;
- snprintf(tmpBuf, PATH_MAX, "%s%s/", dirpath, direntry->d_name);
- /* the stat with the appended / fails for normal files,
- and works for sub dirs fine, looks a bit strange in strace
- but does seem to work */
- if ((stat(tmpBuf, &stat_buf) == 0) && S_ISDIR(stat_buf.st_mode)) {
- if ((ret = FindModuleInSubdir(tmpBuf, module)))
- break;
- continue;
- }
-
- snprintf(tmpBuf, PATH_MAX, "lib%s.so", module);
- if (strcmp(direntry->d_name, tmpBuf) == 0) {
- if (asprintf(&ret, "%s%s", dirpath, tmpBuf) == -1)
- ret = NULL;
- break;
- }
-
- snprintf(tmpBuf, PATH_MAX, "%s_drv.so", module);
- if (strcmp(direntry->d_name, tmpBuf) == 0) {
- if (asprintf(&ret, "%s%s", dirpath, tmpBuf) == -1)
- ret = NULL;
- break;
- }
-
- snprintf(tmpBuf, PATH_MAX, "%s.so", module);
- if (strcmp(direntry->d_name, tmpBuf) == 0) {
- if (asprintf(&ret, "%s%s", dirpath, tmpBuf) == -1)
- ret = NULL;
- break;
- }
- }
-
- closedir(dir);
- return ret;
-}
-
-static char *
-FindModule(const char *module, const char *dirname, const char **subdirlist,
- PatternPtr patterns)
-{
- char buf[PATH_MAX + 1];
- char *dirpath = NULL;
- char *name = NULL;
- int dirlen;
- const char **subdirs = NULL;
- const char **s;
-
- dirpath = (char *)dirname;
- if (strlen(dirpath) > PATH_MAX)
- return NULL;
-
- subdirs = InitSubdirs(subdirlist);
- if (!subdirs)
- return NULL;
-
- for (s = subdirs; *s; s++) {
- if ((dirlen = strlen(dirpath) + strlen(*s)) > PATH_MAX)
- continue;
- strcpy(buf, dirpath);
- strcat(buf, *s);
- if ((name = FindModuleInSubdir(buf, module)))
- break;
- }
-
- FreeSubdirs(subdirs);
- if (dirpath != dirname)
- free(dirpath);
-
- return name;
-}
-
-char **
-LoaderListDirs(const char **subdirlist, const char **patternlist)
-{
- char buf[PATH_MAX + 1];
- char **pathlist;
- char **elem;
- const char **subdirs;
- const char **s;
- PatternPtr patterns;
- PatternPtr p;
- DIR *d;
- struct dirent *dp;
- regmatch_t match[2];
- struct stat stat_buf;
- int len, dirlen;
- char *fp;
- char **listing = NULL;
- char **save;
- char **ret = NULL;
- int n = 0;
-
- if (!(pathlist = InitPathList(NULL)))
- return NULL;
- if (!(subdirs = InitSubdirs(subdirlist)))
- goto bail;
- if (!(patterns = InitPatterns(patternlist)))
- goto bail;
-
- for (elem = pathlist; *elem; elem++) {
- for (s = subdirs; *s; s++) {
- if ((dirlen = strlen(*elem) + strlen(*s)) > PATH_MAX)
- continue;
- strcpy(buf, *elem);
- strcat(buf, *s);
- fp = buf + dirlen;
- if (stat(buf, &stat_buf) == 0 && S_ISDIR(stat_buf.st_mode) &&
- (d = opendir(buf))) {
- if (buf[dirlen - 1] != '/') {
- buf[dirlen++] = '/';
- fp++;
- }
- while ((dp = readdir(d))) {
- if (dirlen + strlen(dp->d_name) > PATH_MAX)
- continue;
- strcpy(fp, dp->d_name);
- if (!(stat(buf, &stat_buf) == 0 &&
- S_ISREG(stat_buf.st_mode)))
- continue;
- for (p = patterns; p->pattern; p++) {
- if (regexec(&p->rex, dp->d_name, 2, match, 0) == 0 &&
- match[1].rm_so != -1) {
- len = match[1].rm_eo - match[1].rm_so;
- save = listing;
- listing = realloc(listing,
- (n + 2) * sizeof(char *));
- if (!listing) {
- if (save) {
- save[n] = NULL;
- FreeStringList(save);
- }
- closedir(d);
- goto bail;
- }
- listing[n] = malloc(len + 1);
- if (!listing[n]) {
- FreeStringList(listing);
- closedir(d);
- goto bail;
- }
- strncpy(listing[n], dp->d_name + match[1].rm_so,
- len);
- listing[n][len] = '\0';
- n++;
- break;
- }
- }
- }
- closedir(d);
- }
- }
- }
- if (listing)
- listing[n] = NULL;
- ret = listing;
-
-bail:
- FreePatterns(patterns);
- FreeSubdirs(subdirs);
- FreePathList(pathlist);
- return ret;
-}
-
-void
-LoaderFreeDirList(char **list)
-{
- FreeStringList(list);
-}
-
-static Bool
-CheckVersion(const char *module, XF86ModuleVersionInfo * data,
- const XF86ModReqInfo * req)
-{
- int vercode[4];
- char verstr[4];
- long ver = data->xf86version;
- MessageType errtype;
-
- xf86Msg(X_INFO, "Module %s: vendor=\"%s\"\n",
- data->modname ? data->modname : "UNKNOWN!",
- data->vendor ? data->vendor : "UNKNOWN!");
-
- /* Check for the different scheme used in XFree86 4.0.x releases:
- * ((((((((major << 7) | minor) << 7) | subminor) << 5) | beta) << 5) | alpha)
- * Since it wasn't used in 4.1.0 or later, limit to versions in the 4.0.x
- * range, which limits the overlap with the new version scheme to conflicts
- * with 6.71.8.764 through 6.72.39.934.
- */
- if ((ver > (4 << 24)) && (ver < ( (4 << 24) + (1 << 17)))) {
- /* 4.0.x and earlier */
- verstr[1] = verstr[3] = 0;
- verstr[2] = (ver & 0x1f) ? (ver & 0x1f) + 'a' - 1 : 0;
- ver >>= 5;
- verstr[0] = (ver & 0x1f) ? (ver & 0x1f) + 'A' - 1 : 0;
- ver >>= 5;
- vercode[2] = ver & 0x7f;
- ver >>= 7;
- vercode[1] = ver & 0x7f;
- ver >>= 7;
- vercode[0] = ver;
- xf86ErrorF("\tcompiled for %d.%d", vercode[0], vercode[1]);
- if (vercode[2] != 0)
- xf86ErrorF(".%d", vercode[2]);
- xf86ErrorF("%s%s, module version = %d.%d.%d\n", verstr, verstr + 2,
- data->majorversion, data->minorversion, data->patchlevel);
- } else {
- vercode[0] = ver / 10000000;
- vercode[1] = (ver / 100000) % 100;
- vercode[2] = (ver / 1000) % 100;
- vercode[3] = ver % 1000;
- xf86ErrorF("\tcompiled for %d.%d.%d", vercode[0], vercode[1],
- vercode[2]);
- if (vercode[3] != 0)
- xf86ErrorF(".%d", vercode[3]);
- xf86ErrorF(", module version = %d.%d.%d\n", data->majorversion,
- data->minorversion, data->patchlevel);
- }
-
- if (data->moduleclass)
- xf86ErrorFVerb(2, "\tModule class: %s\n", data->moduleclass);
-
- ver = -1;
- if (data->abiclass) {
- int abimaj, abimin;
- int vermaj, vermin;
-
- if (!strcmp(data->abiclass, ABI_CLASS_ANSIC))
- ver = LoaderVersionInfo.ansicVersion;
- else if (!strcmp(data->abiclass, ABI_CLASS_VIDEODRV))
- ver = LoaderVersionInfo.videodrvVersion;
- else if (!strcmp(data->abiclass, ABI_CLASS_XINPUT))
- ver = LoaderVersionInfo.xinputVersion;
- else if (!strcmp(data->abiclass, ABI_CLASS_EXTENSION))
- ver = LoaderVersionInfo.extensionVersion;
- else if (!strcmp(data->abiclass, ABI_CLASS_FONT))
- ver = LoaderVersionInfo.fontVersion;
-
- abimaj = GET_ABI_MAJOR(data->abiversion);
- abimin = GET_ABI_MINOR(data->abiversion);
- xf86ErrorFVerb(2, "\tABI class: %s, version %d.%d\n",
- data->abiclass, abimaj, abimin);
- if (ver != -1) {
- vermaj = GET_ABI_MAJOR(ver);
- vermin = GET_ABI_MINOR(ver);
- if (abimaj != vermaj) {
- if (LoaderOptions & LDR_OPT_ABI_MISMATCH_NONFATAL)
- errtype = X_WARNING;
- else
- errtype = X_ERROR;
- xf86MsgVerb(errtype, 0,
- "module ABI major version (%d) doesn't"
- " match the server's version (%d)\n",
- abimaj, vermaj);
- if (!(LoaderOptions & LDR_OPT_ABI_MISMATCH_NONFATAL))
- return FALSE;
- } else if (abimin > vermin) {
- if (LoaderOptions & LDR_OPT_ABI_MISMATCH_NONFATAL)
- errtype = X_WARNING;
- else
- errtype = X_ERROR;
- xf86MsgVerb(errtype, 0,
- "module ABI minor version (%d) is "
- "newer than the server's version "
- "(%d)\n", abimin, vermin);
- if (!(LoaderOptions & LDR_OPT_ABI_MISMATCH_NONFATAL))
- return FALSE;
- }
- }
- }
-
- /* Check against requirements that the caller has specified */
- if (req) {
- if (req->majorversion != MAJOR_UNSPEC) {
- if (data->majorversion != req->majorversion) {
- xf86MsgVerb(X_WARNING, 2, "module major version (%d) "
- "doesn't match required major version (%d)\n",
- data->majorversion, req->majorversion);
- return FALSE;
- } else if (req->minorversion != MINOR_UNSPEC) {
- if (data->minorversion < req->minorversion) {
- xf86MsgVerb(X_WARNING, 2, "module minor version (%d) "
- "is less than the required minor version (%d)\n",
- data->minorversion, req->minorversion);
- return FALSE;
- } else if (data->minorversion == req->minorversion &&
- req->patchlevel != PATCH_UNSPEC) {
- if (data->patchlevel < req->patchlevel) {
- xf86MsgVerb(X_WARNING, 2, "module patch level (%d) "
- "is less than the required patch level (%d)\n",
- data->patchlevel, req->patchlevel);
- return FALSE;
- }
- }
- }
- }
- if (req->moduleclass) {
- if (!data->moduleclass ||
- strcmp(req->moduleclass, data->moduleclass)) {
- xf86MsgVerb(X_WARNING, 2, "Module class (%s) doesn't match "
- "the required class (%s)\n",
- data->moduleclass ? data->moduleclass : "<NONE>",
- req->moduleclass);
- return FALSE;
- }
- } else if (req->abiclass != ABI_CLASS_NONE) {
- if (!data->abiclass || strcmp(req->abiclass, data->abiclass)) {
- xf86MsgVerb(X_WARNING, 2, "ABI class (%s) doesn't match the "
- "required ABI class (%s)\n",
- data->abiclass ? data->abiclass : "<NONE>",
- req->abiclass);
- return FALSE;
- }
- }
- if ((req->abiclass != ABI_CLASS_NONE) &&
- req->abiversion != ABI_VERS_UNSPEC) {
- int reqmaj, reqmin, maj, min;
-
- reqmaj = GET_ABI_MAJOR(req->abiversion);
- reqmin = GET_ABI_MINOR(req->abiversion);
- maj = GET_ABI_MAJOR(data->abiversion);
- min = GET_ABI_MINOR(data->abiversion);
- if (maj != reqmaj) {
- xf86MsgVerb(X_WARNING, 2, "ABI major version (%d) doesn't "
- "match the required ABI major version (%d)\n",
- maj, reqmaj);
- return FALSE;
- }
- /* XXX Maybe this should be the other way around? */
- if (min > reqmin) {
- xf86MsgVerb(X_WARNING, 2, "module ABI minor version (%d) "
- "is newer than that available (%d)\n", min, reqmin);
- return FALSE;
- }
- }
- }
- return TRUE;
-}
-
-static ModuleDescPtr
-AddSibling(ModuleDescPtr head, ModuleDescPtr new)
-{
- new->sib = head;
- return new;
-}
-
-pointer
-LoadSubModule(pointer _parent, const char *module,
- const char **subdirlist, const char **patternlist,
- pointer options, const XF86ModReqInfo * modreq,
- int *errmaj, int *errmin)
-{
- ModuleDescPtr submod;
- ModuleDescPtr parent = (ModuleDescPtr)_parent;
-
- xf86MsgVerb(X_INFO, 3, "Loading sub module \"%s\"\n", module);
-
- if (PathIsAbsolute(module)) {
- xf86Msg(X_ERROR,
- "LoadSubModule: Absolute module path not permitted: \"%s\"\n",
- module);
- if (errmaj)
- *errmaj = LDR_BADUSAGE;
- if (errmin)
- *errmin = 0;
- return NULL;
- }
-
- submod = doLoadModule(module, NULL, subdirlist, patternlist, options,
- modreq, errmaj, errmin);
- if (submod && submod != (ModuleDescPtr) 1) {
- parent->child = AddSibling(parent->child, submod);
- submod->parent = parent;
- }
- return submod;
-}
-
-static ModuleDescPtr
-NewModuleDesc(const char *name)
-{
- ModuleDescPtr mdp = calloc(1, sizeof(ModuleDesc));
-
- if (mdp)
- mdp->name = xstrdup(name);
-
- return mdp;
-}
-
-ModuleDescPtr
-DuplicateModule(ModuleDescPtr mod, ModuleDescPtr parent)
-{
- ModuleDescPtr ret;
- int errmaj, errmin;
-
- if (!mod)
- return NULL;
-
- ret = NewModuleDesc(mod->name);
- if (ret == NULL)
- return NULL;
-
- if (!(ret->handle = LoaderOpen(mod->path, &errmaj, &errmin))) {
- free(ret);
- return NULL;
- }
-
- ret->SetupProc = mod->SetupProc;
- ret->TearDownProc = mod->TearDownProc;
- ret->TearDownData = NULL;
- ret->child = DuplicateModule(mod->child, ret);
- ret->sib = DuplicateModule(mod->sib, parent);
- ret->parent = parent;
- ret->VersionInfo = mod->VersionInfo;
- ret->path = strdup(mod->path);
-
- return ret;
-}
-
-static const char *compiled_in_modules[] = {
- "ddc",
- "i2c",
- "ramdac",
- NULL
-};
-
-static ModuleDescPtr
-doLoadModule(const char *module, const char *path, const char **subdirlist,
- const char **patternlist, pointer options,
- const XF86ModReqInfo * modreq,
- int *errmaj, int *errmin)
-{
- XF86ModuleData *initdata = NULL;
- char **pathlist = NULL;
- char *found = NULL;
- char *name = NULL;
- char **path_elem = NULL;
- char *p = NULL;
- ModuleDescPtr ret = NULL;
- PatternPtr patterns = NULL;
- int noncanonical = 0;
- char *m = NULL;
- const char **cim;
-
- xf86MsgVerb(X_INFO, 3, "LoadModule: \"%s\"", module);
-
- patterns = InitPatterns(patternlist);
- name = LoaderGetCanonicalName(module, patterns);
- noncanonical = (name && strcmp(module, name) != 0);
- if (noncanonical) {
- xf86ErrorFVerb(3, " (%s)\n", name);
- xf86MsgVerb(X_WARNING, 1,
- "LoadModule: given non-canonical module name \"%s\"\n",
- module);
- m = name;
- } else {
- xf86ErrorFVerb(3, "\n");
- m = (char *)module;
- }
-
- for (cim = compiled_in_modules; *cim; cim++)
- if (!strcmp (m, *cim))
- {
- xf86MsgVerb(X_INFO, 3, "Module \"%s\" already built-in\n", m);
- ret = (ModuleDescPtr) 1;
- goto LoadModule_exit;
- }
-
- if (!name) {
- if (errmaj)
- *errmaj = LDR_BADUSAGE;
- if (errmin)
- *errmin = 0;
- goto LoadModule_fail;
- }
- ret = NewModuleDesc(name);
- if (!ret) {
- if (errmaj)
- *errmaj = LDR_NOMEM;
- if (errmin)
- *errmin = 0;
- goto LoadModule_fail;
- }
-
- pathlist = InitPathList(path);
- if (!pathlist) {
- /* This could be a malloc failure too */
- if (errmaj)
- *errmaj = LDR_BADUSAGE;
- if (errmin)
- *errmin = 1;
- goto LoadModule_fail;
- }
-
- /*
- * if the module name is not a full pathname, we need to
- * check the elements in the path
- */
- if (PathIsAbsolute(module))
- found = xstrdup(module);
- path_elem = pathlist;
- while (!found && *path_elem != NULL) {
- found = FindModule(m, *path_elem, subdirlist, patterns);
- path_elem++;
- /*
- * When the module name isn't the canonical name, search for the
- * former if no match was found for the latter.
- */
- if (!*path_elem && m == name) {
- path_elem = pathlist;
- m = (char *)module;
- }
- }
-
- /*
- * did we find the module?
- */
- if (!found) {
- xf86Msg(X_WARNING, "Warning, couldn't open module %s\n", module);
- if (errmaj)
- *errmaj = LDR_NOENT;
- if (errmin)
- *errmin = 0;
- goto LoadModule_fail;
- }
- ret->handle = LoaderOpen(found, errmaj, errmin);
- if (ret->handle < 0)
- goto LoadModule_fail;
- ret->path = strdup(found);
-
- /* drop any explicit suffix from the module name */
- p = strchr(name, '.');
- if (p)
- *p = '\0';
-
- /*
- * now check if the special data object <modulename>ModuleData is
- * present.
- */
- if (asprintf(&p, "%sModuleData", name) == -1) {
- p = NULL;
- if (errmaj)
- *errmaj = LDR_NOMEM;
- if (errmin)
- *errmin = 0;
- goto LoadModule_fail;
- }
- initdata = LoaderSymbol(p);
- if (initdata) {
- ModuleSetupProc setup;
- ModuleTearDownProc teardown;
- XF86ModuleVersionInfo *vers;
-
- vers = initdata->vers;
- setup = initdata->setup;
- teardown = initdata->teardown;
-
- if (vers) {
- if (!CheckVersion(module, vers, modreq)) {
- if (errmaj)
- *errmaj = LDR_MISMATCH;
- if (errmin)
- *errmin = 0;
- goto LoadModule_fail;
- }
- } else {
- xf86Msg(X_ERROR,
- "LoadModule: Module %s does not supply"
- " version information\n", module);
- if (errmaj)
- *errmaj = LDR_INVALID;
- if (errmin)
- *errmin = 0;
- goto LoadModule_fail;
- }
- if (setup)
- ret->SetupProc = setup;
- if (teardown)
- ret->TearDownProc = teardown;
- ret->VersionInfo = vers;
- } else {
- /* No initdata is OK for external modules */
- if (options == EXTERN_MODULE)
- goto LoadModule_exit;
-
- /* no initdata, fail the load */
- xf86Msg(X_ERROR, "LoadModule: Module %s does not have a %s "
- "data object.\n", module, p);
- if (errmaj)
- *errmaj = LDR_INVALID;
- if (errmin)
- *errmin = 0;
- goto LoadModule_fail;
- }
- if (ret->SetupProc) {
- ret->TearDownData = ret->SetupProc(ret, options, errmaj, errmin);
- if (!ret->TearDownData) {
- goto LoadModule_fail;
- }
- } else if (options) {
- xf86Msg(X_WARNING, "Module Options present, but no SetupProc "
- "available for %s\n", module);
- }
- goto LoadModule_exit;
-
- LoadModule_fail:
- UnloadModule(ret);
- ret = NULL;
-
- LoadModule_exit:
- FreePathList(pathlist);
- FreePatterns(patterns);
- free(found);
- free(name);
- free(p);
-
- return ret;
-}
-
-/*
- * LoadModule: load a module
- *
- * module The module name. Normally this is not a filename but the
- * module's "canonical name. A full pathname is, however,
- * also accepted.
- * path A comma separated list of module directories.
- * subdirlist A NULL terminated list of subdirectories to search. When
- * NULL, the default "stdSubdirs" list is used. The default
- * list is also substituted for entries with value DEFAULT_LIST.
- * patternlist A NULL terminated list of regular expressions used to find
- * module filenames. Each regex should contain exactly one
- * subexpression that corresponds to the canonical module name.
- * When NULL, the default "stdPatterns" list is used. The
- * default list is also substituted for entries with value
- * DEFAULT_LIST.
- * options A NULL terminated list of Options that are passed to the
- * module's SetupProc function.
- * modreq An optional XF86ModReqInfo* containing
- * version/ABI/vendor-ABI requirements to check for when
- * loading the module. The following fields of the
- * XF86ModReqInfo struct are checked:
- * majorversion - must match the module's majorversion exactly
- * minorversion - the module's minorversion must be >= this
- * patchlevel - the module's minorversion.patchlevel must be
- * >= this. Patchlevel is ignored when
- * minorversion is not set.
- * abiclass - (string) must match the module's abiclass
- * abiversion - must be consistent with the module's
- * abiversion (major equal, minor no older)
- * moduleclass - string must match the module's moduleclass
- * string
- * "don't care" values are ~0 for numbers, and NULL for strings
- * errmaj Major error return.
- * errmin Minor error return.
- *
- */
-ModuleDescPtr
-LoadModule(const char *module, const char *path, const char **subdirlist,
- const char **patternlist, pointer options,
- const XF86ModReqInfo * modreq, int *errmaj, int *errmin)
-{
- return doLoadModule(module, path, subdirlist, patternlist, options,
- modreq, errmaj, errmin);
-}
-
-void
-UnloadModule(pointer mod)
-{
- UnloadModuleOrDriver((ModuleDescPtr)mod);
-}
-
-static void
-UnloadModuleOrDriver(ModuleDescPtr mod)
-{
- if (mod == (ModuleDescPtr) 1)
- return;
-
- if (mod == NULL || mod->name == NULL)
- return;
-
- xf86MsgVerb(X_INFO, 3, "UnloadModule: \"%s\"\n", mod->name);
-
- if ((mod->TearDownProc) && (mod->TearDownData))
- mod->TearDownProc(mod->TearDownData);
- LoaderUnload(mod->name, mod->handle);
-
- if (mod->child)
- UnloadModuleOrDriver(mod->child);
- if (mod->sib)
- UnloadModuleOrDriver(mod->sib);
- free(mod->path);
- free(mod->name);
- free(mod);
-}
-
-void
-UnloadSubModule(pointer _mod)
-{
- ModuleDescPtr mod = (ModuleDescPtr)_mod;
-
- if (mod == NULL || mod->name == NULL)
- return;
-
- xf86MsgVerb(X_INFO, 3, "UnloadSubModule: \"%s\"\n", mod->name);
-
- if ((mod->TearDownProc) && (mod->TearDownData))
- mod->TearDownProc(mod->TearDownData);
- LoaderUnload(mod->name, mod->handle);
-
- RemoveChild(mod);
-
- if (mod->child)
- UnloadModuleOrDriver(mod->child);
-
- free(mod->path);
- free(mod->name);
- free(mod);
-}
-
-static void
-RemoveChild(ModuleDescPtr child)
-{
- ModuleDescPtr mdp;
- ModuleDescPtr prevsib;
- ModuleDescPtr parent;
-
- if (!child->parent)
- return;
-
- parent = child->parent;
- if (parent->child == child) {
- parent->child = child->sib;
- return;
- }
-
- prevsib = parent->child;
- mdp = prevsib->sib;
- while (mdp && mdp != child) {
- prevsib = mdp;
- mdp = mdp->sib;
- }
- if (mdp == child)
- prevsib->sib = child->sib;
- return;
-}
-
-void
-LoaderErrorMsg(const char *name, const char *modname, int errmaj, int errmin)
-{
- const char *msg;
- MessageType type = X_ERROR;
-
- switch (errmaj) {
- case LDR_NOERROR:
- msg = "no error";
- break;
- case LDR_NOMEM:
- msg = "out of memory";
- break;
- case LDR_NOENT:
- msg = "module does not exist";
- break;
- case LDR_NOSUBENT:
- msg = "a required submodule could not be loaded";
- break;
- case LDR_NOSPACE:
- msg = "too many modules";
- break;
- case LDR_NOMODOPEN:
- msg = "open failed";
- break;
- case LDR_UNKTYPE:
- msg = "unknown module type";
- break;
- case LDR_NOLOAD:
- msg = "loader failed";
- break;
- case LDR_ONCEONLY:
- msg = "already loaded";
- type = X_INFO;
- break;
- case LDR_NOPORTOPEN:
- msg = "port open failed";
- break;
- case LDR_NOHARDWARE:
- msg = "no hardware found";
- break;
- case LDR_MISMATCH:
- msg = "module requirement mismatch";
- break;
- case LDR_BADUSAGE:
- msg = "invalid argument(s) to LoadModule()";
- break;
- case LDR_INVALID:
- msg = "invalid module";
- break;
- case LDR_BADOS:
- msg = "module doesn't support this OS";
- break;
- case LDR_MODSPECIFIC:
- msg = "module-specific error";
- break;
- default:
- msg = "unknown error";
- }
- if (name)
- xf86Msg(type, "%s: Failed to load module \"%s\" (%s, %d)\n",
- name, modname, msg, errmin);
- else
- xf86Msg(type, "Failed to load module \"%s\" (%s, %d)\n",
- modname, msg, errmin);
-}
-
-/* Given a module path or file name, return the module's canonical name */
-static char *
-LoaderGetCanonicalName(const char *modname, PatternPtr patterns)
-{
- char *str;
- const char *s;
- int len;
- PatternPtr p;
- regmatch_t match[2];
-
- /* Strip off any leading path */
- s = strrchr(modname, '/');
- if (s == NULL)
- s = modname;
- else
- s++;
-
- /* Find the first regex that is matched */
- for (p = patterns; p->pattern; p++)
- if (regexec(&p->rex, s, 2, match, 0) == 0 && match[1].rm_so != -1) {
- len = match[1].rm_eo - match[1].rm_so;
- str = malloc(len + 1);
- if (!str)
- return NULL;
- strncpy(str, s + match[1].rm_so, len);
- str[len] = '\0';
- return str;
- }
-
- /* If there is no match, return the whole name minus the leading path */
- return strdup(s);
-}
-
-/*
- * Return the module version information.
- */
-unsigned long
-LoaderGetModuleVersion(ModuleDescPtr mod)
-{
- if (!mod || mod == (ModuleDescPtr) 1 || !mod->VersionInfo)
- return 0;
-
- return MODULE_VERSION_NUMERIC(mod->VersionInfo->majorversion,
- mod->VersionInfo->minorversion,
- mod->VersionInfo->patchlevel);
-}
+/*
+ * Copyright 1995-1998 by Metro Link, Inc.
+ *
+ * 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 Metro Link, Inc. not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Metro Link, Inc. makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ *
+ * METRO LINK, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL METRO LINK, INC. 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) 1997-2002 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).
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "os.h"
+/* For stat() and related stuff */
+#define NO_OSLIB_PROTOTYPES
+#include "xf86_OSlib.h"
+#define LOADERDECLARATIONS
+#include "loaderProcs.h"
+#include "misc.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86Xinput.h"
+#include "loader.h"
+#include "xf86Optrec.h"
+
+#include <sys/types.h>
+#include <regex.h>
+#include <dirent.h>
+#include <limits.h>
+
+typedef struct _pattern {
+ const char *pattern;
+ regex_t rex;
+} PatternRec, *PatternPtr;
+
+/* Prototypes for static functions */
+static char *FindModule(const char *, const char *, const char **,
+ PatternPtr);
+static Bool CheckVersion(const char *, XF86ModuleVersionInfo *,
+ const XF86ModReqInfo *);
+static void UnloadModuleOrDriver(ModuleDescPtr mod);
+static char *LoaderGetCanonicalName(const char *, PatternPtr);
+static void RemoveChild(ModuleDescPtr);
+static ModuleDescPtr doLoadModule(const char *, const char *, const char **,
+ const char **, pointer,
+ const XF86ModReqInfo *, int *, int *);
+
+const ModuleVersions LoaderVersionInfo = {
+ XORG_VERSION_CURRENT,
+ ABI_ANSIC_VERSION,
+ ABI_VIDEODRV_VERSION,
+ ABI_XINPUT_VERSION,
+ ABI_EXTENSION_VERSION,
+ ABI_FONT_VERSION
+};
+
+static void
+FreeStringList(char **paths)
+{
+ char **p;
+
+ if (!paths)
+ return;
+
+ for (p = paths; *p; p++)
+ free(*p);
+
+ free(paths);
+}
+
+static char **defaultPathList = NULL;
+
+static Bool
+PathIsAbsolute(const char *path)
+{
+ return *path == '/';
+}
+
+/*
+ * Convert a comma-separated path into a NULL-terminated array of path
+ * elements, rejecting any that are not full absolute paths, and appending
+ * a '/' when it isn't already present.
+ */
+static char **
+InitPathList(const char *path)
+{
+ char *fullpath = NULL;
+ char *elem = NULL;
+ char **list = NULL, **save = NULL;
+ int len;
+ int addslash;
+ int n = 0;
+
+ if (!path)
+ return defaultPathList;
+
+ fullpath = strdup(path);
+ if (!fullpath)
+ return NULL;
+ elem = strtok(fullpath, ",");
+ while (elem) {
+ if (PathIsAbsolute(elem))
+ {
+ len = strlen(elem);
+ addslash = (elem[len - 1] != '/');
+ if (addslash)
+ len++;
+ save = list;
+ list = realloc(list, (n + 2) * sizeof(char *));
+ if (!list) {
+ if (save) {
+ save[n] = NULL;
+ FreeStringList(save);
+ }
+ free(fullpath);
+ return NULL;
+ }
+ list[n] = malloc(len + 1);
+ if (!list[n]) {
+ FreeStringList(list);
+ free(fullpath);
+ return NULL;
+ }
+ strcpy(list[n], elem);
+ if (addslash) {
+ list[n][len - 1] = '/';
+ list[n][len] = '\0';
+ }
+ n++;
+ }
+ elem = strtok(NULL, ",");
+ }
+ if (list)
+ list[n] = NULL;
+ free(fullpath);
+ return list;
+}
+
+static void
+FreePathList(char **pathlist)
+{
+ if (pathlist && pathlist != defaultPathList)
+ FreeStringList(pathlist);
+}
+
+void
+LoaderSetPath(const char *path)
+{
+ if (!path)
+ return;
+
+ defaultPathList = InitPathList(path);
+}
+
+/* Standard set of module subdirectories to search, in order of preference */
+static const char *stdSubdirs[] = {
+ "",
+ "input/",
+ "drivers/",
+ "multimedia/",
+ "extensions/",
+ "internal/",
+ NULL
+};
+
+/*
+ * Standard set of module name patterns to check, in order of preference
+ * These are regular expressions (suitable for use with POSIX regex(3)).
+ *
+ * This list assumes that you're an ELFish platform and therefore your
+ * shared libraries are named something.so. If we're ever nuts enough
+ * to port this DDX to, say, Darwin, we'll need to fix this.
+ */
+static PatternRec stdPatterns[] = {
+ {"^lib(.*)\\.so$",},
+ {"(.*)_drv\\.so$",},
+ {"(.*)\\.so$",},
+ {NULL,}
+};
+
+static PatternPtr
+InitPatterns(const char **patternlist)
+{
+ char errmsg[80];
+ int i, e;
+ PatternPtr patterns = NULL;
+ PatternPtr p = NULL;
+ static int firstTime = 1;
+ const char **s;
+
+ if (firstTime) {
+ /* precompile stdPatterns */
+ firstTime = 0;
+ for (p = stdPatterns; p->pattern; p++)
+ if ((e = regcomp(&p->rex, p->pattern, REG_EXTENDED)) != 0) {
+ regerror(e, &p->rex, errmsg, sizeof(errmsg));
+ FatalError("InitPatterns: regcomp error for `%s': %s\n",
+ p->pattern, errmsg);
+ }
+ }
+
+ if (patternlist) {
+ for (i = 0, s = patternlist; *s; i++, s++)
+ if (*s == DEFAULT_LIST)
+ i += sizeof(stdPatterns) / sizeof(stdPatterns[0]) - 1 - 1;
+ patterns = malloc((i + 1) * sizeof(PatternRec));
+ if (!patterns) {
+ return NULL;
+ }
+ for (i = 0, s = patternlist; *s; i++, s++)
+ if (*s != DEFAULT_LIST) {
+ p = patterns + i;
+ p->pattern = *s;
+ if ((e = regcomp(&p->rex, p->pattern, REG_EXTENDED)) != 0) {
+ regerror(e, &p->rex, errmsg, sizeof(errmsg));
+ ErrorF("InitPatterns: regcomp error for `%s': %s\n",
+ p->pattern, errmsg);
+ i--;
+ }
+ } else {
+ for (p = stdPatterns; p->pattern; p++, i++)
+ patterns[i] = *p;
+ if (p != stdPatterns)
+ i--;
+ }
+ patterns[i].pattern = NULL;
+ } else
+ patterns = stdPatterns;
+ return patterns;
+}
+
+static void
+FreePatterns(PatternPtr patterns)
+{
+ if (patterns && patterns != stdPatterns)
+ free(patterns);
+}
+
+static const char **
+InitSubdirs(const char **subdirlist)
+{
+ int i;
+ const char **tmp_subdirlist = NULL;
+ char **subdirs = NULL;
+ const char **s, **stmp = NULL;
+ const char *osname;
+ const char *slash;
+ int oslen = 0, len;
+ Bool indefault;
+
+ if (subdirlist == NULL) {
+ subdirlist = tmp_subdirlist = malloc(2 * sizeof(char *));
+ if (subdirlist == NULL)
+ return NULL;
+ subdirlist[0] = DEFAULT_LIST;
+ subdirlist[1] = NULL;
+ }
+
+ LoaderGetOS(&osname, NULL, NULL, NULL);
+ oslen = strlen(osname);
+
+ {
+ /* Count number of entries and check for invalid paths */
+ for (i = 0, s = subdirlist; *s; i++, s++) {
+ if (*s == DEFAULT_LIST) {
+ i += sizeof(stdSubdirs) / sizeof(stdSubdirs[0]) - 1 - 1;
+ } else {
+ /*
+ * Path validity check. Don't allow absolute paths, or
+ * paths containing "..". To catch absolute paths on
+ * platforms that use driver letters, don't allow the ':'
+ * character to appear at all.
+ */
+ if (**s == '/' || **s == '\\' || strchr(*s, ':') ||
+ strstr(*s, "..")) {
+ xf86Msg(X_ERROR, "InitSubdirs: Bad subdir: \"%s\"\n", *s);
+ free(tmp_subdirlist);
+ return NULL;
+ }
+ }
+ }
+ subdirs = malloc((i * 2 + 1) * sizeof(char *));
+ if (!subdirs) {
+ free(tmp_subdirlist);
+ return NULL;
+ }
+ i = 0;
+ s = subdirlist;
+ indefault = FALSE;
+ while (*s) {
+ if (*s == DEFAULT_LIST) {
+ /* Divert to the default list */
+ indefault = TRUE;
+ stmp = ++s;
+ s = stdSubdirs;
+ }
+ len = strlen(*s);
+ if (**s && (*s)[len - 1] != '/') {
+ slash = "/";
+ len++;
+ } else
+ slash = "";
+ len += oslen + 2;
+ if (!(subdirs[i] = malloc(len))) {
+ while (--i >= 0)
+ free(subdirs[i]);
+ free(subdirs);
+ free(tmp_subdirlist);
+ return NULL;
+ }
+ /* tack on the OS name */
+ sprintf(subdirs[i], "%s%s%s/", *s, slash, osname);
+ i++;
+ /* path as given */
+ subdirs[i] = strdup(*s);
+ i++;
+ s++;
+ if (indefault && !s) {
+ /* revert back to the main list */
+ indefault = FALSE;
+ s = stmp;
+ }
+ }
+ subdirs[i] = NULL;
+ }
+ free(tmp_subdirlist);
+ return (const char **)subdirs;
+}
+
+static void
+FreeSubdirs(const char **subdirs)
+{
+ const char **s;
+
+ if (subdirs) {
+ for (s = subdirs; *s; s++)
+ free((char *)*s);
+ free(subdirs);
+ }
+}
+
+static char *
+FindModuleInSubdir(const char *dirpath, const char *module)
+{
+ struct dirent *direntry = NULL;
+ DIR *dir = NULL;
+ char *ret = NULL, tmpBuf[PATH_MAX];
+ struct stat stat_buf;
+
+ dir = opendir(dirpath);
+ if (!dir)
+ return NULL;
+
+ while ((direntry = readdir(dir))) {
+ if (direntry->d_name[0] == '.')
+ continue;
+ snprintf(tmpBuf, PATH_MAX, "%s%s/", dirpath, direntry->d_name);
+ /* the stat with the appended / fails for normal files,
+ and works for sub dirs fine, looks a bit strange in strace
+ but does seem to work */
+ if ((stat(tmpBuf, &stat_buf) == 0) && S_ISDIR(stat_buf.st_mode)) {
+ if ((ret = FindModuleInSubdir(tmpBuf, module)))
+ break;
+ continue;
+ }
+
+ snprintf(tmpBuf, PATH_MAX, "lib%s.so", module);
+ if (strcmp(direntry->d_name, tmpBuf) == 0) {
+ if (asprintf(&ret, "%s%s", dirpath, tmpBuf) == -1)
+ ret = NULL;
+ break;
+ }
+
+ snprintf(tmpBuf, PATH_MAX, "%s_drv.so", module);
+ if (strcmp(direntry->d_name, tmpBuf) == 0) {
+ if (asprintf(&ret, "%s%s", dirpath, tmpBuf) == -1)
+ ret = NULL;
+ break;
+ }
+
+ snprintf(tmpBuf, PATH_MAX, "%s.so", module);
+ if (strcmp(direntry->d_name, tmpBuf) == 0) {
+ if (asprintf(&ret, "%s%s", dirpath, tmpBuf) == -1)
+ ret = NULL;
+ break;
+ }
+ }
+
+ closedir(dir);
+ return ret;
+}
+
+static char *
+FindModule(const char *module, const char *dirname, const char **subdirlist,
+ PatternPtr patterns)
+{
+ char buf[PATH_MAX + 1];
+ char *dirpath = NULL;
+ char *name = NULL;
+ int dirlen;
+ const char **subdirs = NULL;
+ const char **s;
+
+ dirpath = (char *)dirname;
+ if (strlen(dirpath) > PATH_MAX)
+ return NULL;
+
+ subdirs = InitSubdirs(subdirlist);
+ if (!subdirs)
+ return NULL;
+
+ for (s = subdirs; *s; s++) {
+ if ((dirlen = strlen(dirpath) + strlen(*s)) > PATH_MAX)
+ continue;
+ strcpy(buf, dirpath);
+ strcat(buf, *s);
+ if ((name = FindModuleInSubdir(buf, module)))
+ break;
+ }
+
+ FreeSubdirs(subdirs);
+ if (dirpath != dirname)
+ free(dirpath);
+
+ return name;
+}
+
+char **
+LoaderListDirs(const char **subdirlist, const char **patternlist)
+{
+ char buf[PATH_MAX + 1];
+ char **pathlist;
+ char **elem;
+ const char **subdirs;
+ const char **s;
+ PatternPtr patterns;
+ PatternPtr p;
+ DIR *d;
+ struct dirent *dp;
+ regmatch_t match[2];
+ struct stat stat_buf;
+ int len, dirlen;
+ char *fp;
+ char **listing = NULL;
+ char **save;
+ char **ret = NULL;
+ int n = 0;
+
+ if (!(pathlist = InitPathList(NULL)))
+ return NULL;
+ if (!(subdirs = InitSubdirs(subdirlist)))
+ goto bail;
+ if (!(patterns = InitPatterns(patternlist)))
+ goto bail;
+
+ for (elem = pathlist; *elem; elem++) {
+ for (s = subdirs; *s; s++) {
+ if ((dirlen = strlen(*elem) + strlen(*s)) > PATH_MAX)
+ continue;
+ strcpy(buf, *elem);
+ strcat(buf, *s);
+ fp = buf + dirlen;
+ if (stat(buf, &stat_buf) == 0 && S_ISDIR(stat_buf.st_mode) &&
+ (d = opendir(buf))) {
+ if (buf[dirlen - 1] != '/') {
+ buf[dirlen++] = '/';
+ fp++;
+ }
+ while ((dp = readdir(d))) {
+ if (dirlen + strlen(dp->d_name) > PATH_MAX)
+ continue;
+ strcpy(fp, dp->d_name);
+ if (!(stat(buf, &stat_buf) == 0 &&
+ S_ISREG(stat_buf.st_mode)))
+ continue;
+ for (p = patterns; p->pattern; p++) {
+ if (regexec(&p->rex, dp->d_name, 2, match, 0) == 0 &&
+ match[1].rm_so != -1) {
+ len = match[1].rm_eo - match[1].rm_so;
+ save = listing;
+ listing = realloc(listing,
+ (n + 2) * sizeof(char *));
+ if (!listing) {
+ if (save) {
+ save[n] = NULL;
+ FreeStringList(save);
+ }
+ closedir(d);
+ goto bail;
+ }
+ listing[n] = malloc(len + 1);
+ if (!listing[n]) {
+ FreeStringList(listing);
+ closedir(d);
+ goto bail;
+ }
+ strncpy(listing[n], dp->d_name + match[1].rm_so,
+ len);
+ listing[n][len] = '\0';
+ n++;
+ break;
+ }
+ }
+ }
+ closedir(d);
+ }
+ }
+ }
+ if (listing)
+ listing[n] = NULL;
+ ret = listing;
+
+bail:
+ FreePatterns(patterns);
+ FreeSubdirs(subdirs);
+ FreePathList(pathlist);
+ return ret;
+}
+
+void
+LoaderFreeDirList(char **list)
+{
+ FreeStringList(list);
+}
+
+static Bool
+CheckVersion(const char *module, XF86ModuleVersionInfo * data,
+ const XF86ModReqInfo * req)
+{
+ int vercode[4];
+ char verstr[4];
+ long ver = data->xf86version;
+ MessageType errtype;
+
+ xf86Msg(X_INFO, "Module %s: vendor=\"%s\"\n",
+ data->modname ? data->modname : "UNKNOWN!",
+ data->vendor ? data->vendor : "UNKNOWN!");
+
+ /* Check for the different scheme used in XFree86 4.0.x releases:
+ * ((((((((major << 7) | minor) << 7) | subminor) << 5) | beta) << 5) | alpha)
+ * Since it wasn't used in 4.1.0 or later, limit to versions in the 4.0.x
+ * range, which limits the overlap with the new version scheme to conflicts
+ * with 6.71.8.764 through 6.72.39.934.
+ */
+ if ((ver > (4 << 24)) && (ver < ( (4 << 24) + (1 << 17)))) {
+ /* 4.0.x and earlier */
+ verstr[1] = verstr[3] = 0;
+ verstr[2] = (ver & 0x1f) ? (ver & 0x1f) + 'a' - 1 : 0;
+ ver >>= 5;
+ verstr[0] = (ver & 0x1f) ? (ver & 0x1f) + 'A' - 1 : 0;
+ ver >>= 5;
+ vercode[2] = ver & 0x7f;
+ ver >>= 7;
+ vercode[1] = ver & 0x7f;
+ ver >>= 7;
+ vercode[0] = ver;
+ xf86ErrorF("\tcompiled for %d.%d", vercode[0], vercode[1]);
+ if (vercode[2] != 0)
+ xf86ErrorF(".%d", vercode[2]);
+ xf86ErrorF("%s%s, module version = %d.%d.%d\n", verstr, verstr + 2,
+ data->majorversion, data->minorversion, data->patchlevel);
+ } else {
+ vercode[0] = ver / 10000000;
+ vercode[1] = (ver / 100000) % 100;
+ vercode[2] = (ver / 1000) % 100;
+ vercode[3] = ver % 1000;
+ xf86ErrorF("\tcompiled for %d.%d.%d", vercode[0], vercode[1],
+ vercode[2]);
+ if (vercode[3] != 0)
+ xf86ErrorF(".%d", vercode[3]);
+ xf86ErrorF(", module version = %d.%d.%d\n", data->majorversion,
+ data->minorversion, data->patchlevel);
+ }
+
+ if (data->moduleclass)
+ xf86ErrorFVerb(2, "\tModule class: %s\n", data->moduleclass);
+
+ ver = -1;
+ if (data->abiclass) {
+ int abimaj, abimin;
+ int vermaj, vermin;
+
+ if (!strcmp(data->abiclass, ABI_CLASS_ANSIC))
+ ver = LoaderVersionInfo.ansicVersion;
+ else if (!strcmp(data->abiclass, ABI_CLASS_VIDEODRV))
+ ver = LoaderVersionInfo.videodrvVersion;
+ else if (!strcmp(data->abiclass, ABI_CLASS_XINPUT))
+ ver = LoaderVersionInfo.xinputVersion;
+ else if (!strcmp(data->abiclass, ABI_CLASS_EXTENSION))
+ ver = LoaderVersionInfo.extensionVersion;
+ else if (!strcmp(data->abiclass, ABI_CLASS_FONT))
+ ver = LoaderVersionInfo.fontVersion;
+
+ abimaj = GET_ABI_MAJOR(data->abiversion);
+ abimin = GET_ABI_MINOR(data->abiversion);
+ xf86ErrorFVerb(2, "\tABI class: %s, version %d.%d\n",
+ data->abiclass, abimaj, abimin);
+ if (ver != -1) {
+ vermaj = GET_ABI_MAJOR(ver);
+ vermin = GET_ABI_MINOR(ver);
+ if (abimaj != vermaj) {
+ if (LoaderOptions & LDR_OPT_ABI_MISMATCH_NONFATAL)
+ errtype = X_WARNING;
+ else
+ errtype = X_ERROR;
+ xf86MsgVerb(errtype, 0,
+ "module ABI major version (%d) doesn't"
+ " match the server's version (%d)\n",
+ abimaj, vermaj);
+ if (!(LoaderOptions & LDR_OPT_ABI_MISMATCH_NONFATAL))
+ return FALSE;
+ } else if (abimin > vermin) {
+ if (LoaderOptions & LDR_OPT_ABI_MISMATCH_NONFATAL)
+ errtype = X_WARNING;
+ else
+ errtype = X_ERROR;
+ xf86MsgVerb(errtype, 0,
+ "module ABI minor version (%d) is "
+ "newer than the server's version "
+ "(%d)\n", abimin, vermin);
+ if (!(LoaderOptions & LDR_OPT_ABI_MISMATCH_NONFATAL))
+ return FALSE;
+ }
+ }
+ }
+
+ /* Check against requirements that the caller has specified */
+ if (req) {
+ if (req->majorversion != MAJOR_UNSPEC) {
+ if (data->majorversion != req->majorversion) {
+ xf86MsgVerb(X_WARNING, 2, "module major version (%d) "
+ "doesn't match required major version (%d)\n",
+ data->majorversion, req->majorversion);
+ return FALSE;
+ } else if (req->minorversion != MINOR_UNSPEC) {
+ if (data->minorversion < req->minorversion) {
+ xf86MsgVerb(X_WARNING, 2, "module minor version (%d) "
+ "is less than the required minor version (%d)\n",
+ data->minorversion, req->minorversion);
+ return FALSE;
+ } else if (data->minorversion == req->minorversion &&
+ req->patchlevel != PATCH_UNSPEC) {
+ if (data->patchlevel < req->patchlevel) {
+ xf86MsgVerb(X_WARNING, 2, "module patch level (%d) "
+ "is less than the required patch level (%d)\n",
+ data->patchlevel, req->patchlevel);
+ return FALSE;
+ }
+ }
+ }
+ }
+ if (req->moduleclass) {
+ if (!data->moduleclass ||
+ strcmp(req->moduleclass, data->moduleclass)) {
+ xf86MsgVerb(X_WARNING, 2, "Module class (%s) doesn't match "
+ "the required class (%s)\n",
+ data->moduleclass ? data->moduleclass : "<NONE>",
+ req->moduleclass);
+ return FALSE;
+ }
+ } else if (req->abiclass != ABI_CLASS_NONE) {
+ if (!data->abiclass || strcmp(req->abiclass, data->abiclass)) {
+ xf86MsgVerb(X_WARNING, 2, "ABI class (%s) doesn't match the "
+ "required ABI class (%s)\n",
+ data->abiclass ? data->abiclass : "<NONE>",
+ req->abiclass);
+ return FALSE;
+ }
+ }
+ if ((req->abiclass != ABI_CLASS_NONE) &&
+ req->abiversion != ABI_VERS_UNSPEC) {
+ int reqmaj, reqmin, maj, min;
+
+ reqmaj = GET_ABI_MAJOR(req->abiversion);
+ reqmin = GET_ABI_MINOR(req->abiversion);
+ maj = GET_ABI_MAJOR(data->abiversion);
+ min = GET_ABI_MINOR(data->abiversion);
+ if (maj != reqmaj) {
+ xf86MsgVerb(X_WARNING, 2, "ABI major version (%d) doesn't "
+ "match the required ABI major version (%d)\n",
+ maj, reqmaj);
+ return FALSE;
+ }
+ /* XXX Maybe this should be the other way around? */
+ if (min > reqmin) {
+ xf86MsgVerb(X_WARNING, 2, "module ABI minor version (%d) "
+ "is newer than that available (%d)\n", min, reqmin);
+ return FALSE;
+ }
+ }
+ }
+ return TRUE;
+}
+
+static ModuleDescPtr
+AddSibling(ModuleDescPtr head, ModuleDescPtr new)
+{
+ new->sib = head;
+ return new;
+}
+
+pointer
+LoadSubModule(pointer _parent, const char *module,
+ const char **subdirlist, const char **patternlist,
+ pointer options, const XF86ModReqInfo * modreq,
+ int *errmaj, int *errmin)
+{
+ ModuleDescPtr submod;
+ ModuleDescPtr parent = (ModuleDescPtr)_parent;
+
+ xf86MsgVerb(X_INFO, 3, "Loading sub module \"%s\"\n", module);
+
+ if (PathIsAbsolute(module)) {
+ xf86Msg(X_ERROR,
+ "LoadSubModule: Absolute module path not permitted: \"%s\"\n",
+ module);
+ if (errmaj)
+ *errmaj = LDR_BADUSAGE;
+ if (errmin)
+ *errmin = 0;
+ return NULL;
+ }
+
+ submod = doLoadModule(module, NULL, subdirlist, patternlist, options,
+ modreq, errmaj, errmin);
+ if (submod && submod != (ModuleDescPtr) 1) {
+ parent->child = AddSibling(parent->child, submod);
+ submod->parent = parent;
+ }
+ return submod;
+}
+
+static ModuleDescPtr
+NewModuleDesc(const char *name)
+{
+ ModuleDescPtr mdp = calloc(1, sizeof(ModuleDesc));
+
+ if (mdp)
+ mdp->name = xstrdup(name);
+
+ return mdp;
+}
+
+ModuleDescPtr
+DuplicateModule(ModuleDescPtr mod, ModuleDescPtr parent)
+{
+ ModuleDescPtr ret;
+ int errmaj, errmin;
+
+ if (!mod)
+ return NULL;
+
+ ret = NewModuleDesc(mod->name);
+ if (ret == NULL)
+ return NULL;
+
+ if (!(ret->handle = LoaderOpen(mod->path, &errmaj, &errmin))) {
+ free(ret);
+ return NULL;
+ }
+
+ ret->SetupProc = mod->SetupProc;
+ ret->TearDownProc = mod->TearDownProc;
+ ret->TearDownData = NULL;
+ ret->child = DuplicateModule(mod->child, ret);
+ ret->sib = DuplicateModule(mod->sib, parent);
+ ret->parent = parent;
+ ret->VersionInfo = mod->VersionInfo;
+ ret->path = strdup(mod->path);
+
+ return ret;
+}
+
+static const char *compiled_in_modules[] = {
+ "ddc",
+ "i2c",
+ "ramdac",
+ NULL
+};
+
+static ModuleDescPtr
+doLoadModule(const char *module, const char *path, const char **subdirlist,
+ const char **patternlist, pointer options,
+ const XF86ModReqInfo * modreq,
+ int *errmaj, int *errmin)
+{
+ XF86ModuleData *initdata = NULL;
+ char **pathlist = NULL;
+ char *found = NULL;
+ char *name = NULL;
+ char **path_elem = NULL;
+ char *p = NULL;
+ ModuleDescPtr ret = NULL;
+ PatternPtr patterns = NULL;
+ int noncanonical = 0;
+ char *m = NULL;
+ const char **cim;
+
+ xf86MsgVerb(X_INFO, 3, "LoadModule: \"%s\"", module);
+
+ patterns = InitPatterns(patternlist);
+ name = LoaderGetCanonicalName(module, patterns);
+ noncanonical = (name && strcmp(module, name) != 0);
+ if (noncanonical) {
+ xf86ErrorFVerb(3, " (%s)\n", name);
+ xf86MsgVerb(X_WARNING, 1,
+ "LoadModule: given non-canonical module name \"%s\"\n",
+ module);
+ m = name;
+ } else {
+ xf86ErrorFVerb(3, "\n");
+ m = (char *)module;
+ }
+
+ for (cim = compiled_in_modules; *cim; cim++)
+ if (!strcmp (m, *cim))
+ {
+ xf86MsgVerb(X_INFO, 3, "Module \"%s\" already built-in\n", m);
+ ret = (ModuleDescPtr) 1;
+ goto LoadModule_exit;
+ }
+
+ if (!name) {
+ if (errmaj)
+ *errmaj = LDR_BADUSAGE;
+ if (errmin)
+ *errmin = 0;
+ goto LoadModule_fail;
+ }
+ ret = NewModuleDesc(name);
+ if (!ret) {
+ if (errmaj)
+ *errmaj = LDR_NOMEM;
+ if (errmin)
+ *errmin = 0;
+ goto LoadModule_fail;
+ }
+
+ pathlist = InitPathList(path);
+ if (!pathlist) {
+ /* This could be a malloc failure too */
+ if (errmaj)
+ *errmaj = LDR_BADUSAGE;
+ if (errmin)
+ *errmin = 1;
+ goto LoadModule_fail;
+ }
+
+ /*
+ * if the module name is not a full pathname, we need to
+ * check the elements in the path
+ */
+ if (PathIsAbsolute(module))
+ found = xstrdup(module);
+ path_elem = pathlist;
+ while (!found && *path_elem != NULL) {
+ found = FindModule(m, *path_elem, subdirlist, patterns);
+ path_elem++;
+ /*
+ * When the module name isn't the canonical name, search for the
+ * former if no match was found for the latter.
+ */
+ if (!*path_elem && m == name) {
+ path_elem = pathlist;
+ m = (char *)module;
+ }
+ }
+
+ /*
+ * did we find the module?
+ */
+ if (!found) {
+ xf86Msg(X_WARNING, "Warning, couldn't open module %s\n", module);
+ if (errmaj)
+ *errmaj = LDR_NOENT;
+ if (errmin)
+ *errmin = 0;
+ goto LoadModule_fail;
+ }
+ ret->handle = LoaderOpen(found, errmaj, errmin);
+ if (ret->handle < 0)
+ goto LoadModule_fail;
+ ret->path = strdup(found);
+
+ /* drop any explicit suffix from the module name */
+ p = strchr(name, '.');
+ if (p)
+ *p = '\0';
+
+ /*
+ * now check if the special data object <modulename>ModuleData is
+ * present.
+ */
+ if (asprintf(&p, "%sModuleData", name) == -1) {
+ p = NULL;
+ if (errmaj)
+ *errmaj = LDR_NOMEM;
+ if (errmin)
+ *errmin = 0;
+ goto LoadModule_fail;
+ }
+ initdata = LoaderSymbol(p);
+ if (initdata) {
+ ModuleSetupProc setup;
+ ModuleTearDownProc teardown;
+ XF86ModuleVersionInfo *vers;
+
+ vers = initdata->vers;
+ setup = initdata->setup;
+ teardown = initdata->teardown;
+
+ if (vers) {
+ if (!CheckVersion(module, vers, modreq)) {
+ if (errmaj)
+ *errmaj = LDR_MISMATCH;
+ if (errmin)
+ *errmin = 0;
+ goto LoadModule_fail;
+ }
+ } else {
+ xf86Msg(X_ERROR,
+ "LoadModule: Module %s does not supply"
+ " version information\n", module);
+ if (errmaj)
+ *errmaj = LDR_INVALID;
+ if (errmin)
+ *errmin = 0;
+ goto LoadModule_fail;
+ }
+ if (setup)
+ ret->SetupProc = setup;
+ if (teardown)
+ ret->TearDownProc = teardown;
+ ret->VersionInfo = vers;
+ } else {
+ /* No initdata is OK for external modules */
+ if (options == EXTERN_MODULE)
+ goto LoadModule_exit;
+
+ /* no initdata, fail the load */
+ xf86Msg(X_ERROR, "LoadModule: Module %s does not have a %s "
+ "data object.\n", module, p);
+ if (errmaj)
+ *errmaj = LDR_INVALID;
+ if (errmin)
+ *errmin = 0;
+ goto LoadModule_fail;
+ }
+ if (ret->SetupProc) {
+ ret->TearDownData = ret->SetupProc(ret, options, errmaj, errmin);
+ if (!ret->TearDownData) {
+ goto LoadModule_fail;
+ }
+ } else if (options) {
+ xf86Msg(X_WARNING, "Module Options present, but no SetupProc "
+ "available for %s\n", module);
+ }
+ goto LoadModule_exit;
+
+ LoadModule_fail:
+ UnloadModule(ret);
+ ret = NULL;
+
+ LoadModule_exit:
+ FreePathList(pathlist);
+ FreePatterns(patterns);
+ free(found);
+ free(name);
+ free(p);
+
+ return ret;
+}
+
+/*
+ * LoadModule: load a module
+ *
+ * module The module name. Normally this is not a filename but the
+ * module's "canonical name. A full pathname is, however,
+ * also accepted.
+ * path A comma separated list of module directories.
+ * subdirlist A NULL terminated list of subdirectories to search. When
+ * NULL, the default "stdSubdirs" list is used. The default
+ * list is also substituted for entries with value DEFAULT_LIST.
+ * patternlist A NULL terminated list of regular expressions used to find
+ * module filenames. Each regex should contain exactly one
+ * subexpression that corresponds to the canonical module name.
+ * When NULL, the default "stdPatterns" list is used. The
+ * default list is also substituted for entries with value
+ * DEFAULT_LIST.
+ * options A NULL terminated list of Options that are passed to the
+ * module's SetupProc function.
+ * modreq An optional XF86ModReqInfo* containing
+ * version/ABI/vendor-ABI requirements to check for when
+ * loading the module. The following fields of the
+ * XF86ModReqInfo struct are checked:
+ * majorversion - must match the module's majorversion exactly
+ * minorversion - the module's minorversion must be >= this
+ * patchlevel - the module's minorversion.patchlevel must be
+ * >= this. Patchlevel is ignored when
+ * minorversion is not set.
+ * abiclass - (string) must match the module's abiclass
+ * abiversion - must be consistent with the module's
+ * abiversion (major equal, minor no older)
+ * moduleclass - string must match the module's moduleclass
+ * string
+ * "don't care" values are ~0 for numbers, and NULL for strings
+ * errmaj Major error return.
+ * errmin Minor error return.
+ *
+ */
+ModuleDescPtr
+LoadModule(const char *module, const char *path, const char **subdirlist,
+ const char **patternlist, pointer options,
+ const XF86ModReqInfo * modreq, int *errmaj, int *errmin)
+{
+ return doLoadModule(module, path, subdirlist, patternlist, options,
+ modreq, errmaj, errmin);
+}
+
+void
+UnloadModule(pointer mod)
+{
+ UnloadModuleOrDriver((ModuleDescPtr)mod);
+}
+
+static void
+UnloadModuleOrDriver(ModuleDescPtr mod)
+{
+ if (mod == (ModuleDescPtr) 1)
+ return;
+
+ if (mod == NULL || mod->name == NULL)
+ return;
+
+ xf86MsgVerb(X_INFO, 3, "UnloadModule: \"%s\"\n", mod->name);
+
+ if ((mod->TearDownProc) && (mod->TearDownData))
+ mod->TearDownProc(mod->TearDownData);
+ LoaderUnload(mod->name, mod->handle);
+
+ if (mod->child)
+ UnloadModuleOrDriver(mod->child);
+ if (mod->sib)
+ UnloadModuleOrDriver(mod->sib);
+ free(mod->path);
+ free(mod->name);
+ free(mod);
+}
+
+void
+UnloadSubModule(pointer _mod)
+{
+ ModuleDescPtr mod = (ModuleDescPtr)_mod;
+
+ if (mod == NULL || mod->name == NULL)
+ return;
+
+ xf86MsgVerb(X_INFO, 3, "UnloadSubModule: \"%s\"\n", mod->name);
+
+ if ((mod->TearDownProc) && (mod->TearDownData))
+ mod->TearDownProc(mod->TearDownData);
+ LoaderUnload(mod->name, mod->handle);
+
+ RemoveChild(mod);
+
+ if (mod->child)
+ UnloadModuleOrDriver(mod->child);
+
+ free(mod->path);
+ free(mod->name);
+ free(mod);
+}
+
+static void
+RemoveChild(ModuleDescPtr child)
+{
+ ModuleDescPtr mdp;
+ ModuleDescPtr prevsib;
+ ModuleDescPtr parent;
+
+ if (!child->parent)
+ return;
+
+ parent = child->parent;
+ if (parent->child == child) {
+ parent->child = child->sib;
+ return;
+ }
+
+ prevsib = parent->child;
+ mdp = prevsib->sib;
+ while (mdp && mdp != child) {
+ prevsib = mdp;
+ mdp = mdp->sib;
+ }
+ if (mdp == child)
+ prevsib->sib = child->sib;
+ return;
+}
+
+void
+LoaderErrorMsg(const char *name, const char *modname, int errmaj, int errmin)
+{
+ const char *msg;
+ MessageType type = X_ERROR;
+
+ switch (errmaj) {
+ case LDR_NOERROR:
+ msg = "no error";
+ break;
+ case LDR_NOMEM:
+ msg = "out of memory";
+ break;
+ case LDR_NOENT:
+ msg = "module does not exist";
+ break;
+ case LDR_NOSUBENT:
+ msg = "a required submodule could not be loaded";
+ break;
+ case LDR_NOSPACE:
+ msg = "too many modules";
+ break;
+ case LDR_NOMODOPEN:
+ msg = "open failed";
+ break;
+ case LDR_UNKTYPE:
+ msg = "unknown module type";
+ break;
+ case LDR_NOLOAD:
+ msg = "loader failed";
+ break;
+ case LDR_ONCEONLY:
+ msg = "already loaded";
+ type = X_INFO;
+ break;
+ case LDR_NOPORTOPEN:
+ msg = "port open failed";
+ break;
+ case LDR_NOHARDWARE:
+ msg = "no hardware found";
+ break;
+ case LDR_MISMATCH:
+ msg = "module requirement mismatch";
+ break;
+ case LDR_BADUSAGE:
+ msg = "invalid argument(s) to LoadModule()";
+ break;
+ case LDR_INVALID:
+ msg = "invalid module";
+ break;
+ case LDR_BADOS:
+ msg = "module doesn't support this OS";
+ break;
+ case LDR_MODSPECIFIC:
+ msg = "module-specific error";
+ break;
+ default:
+ msg = "unknown error";
+ }
+ if (name)
+ xf86Msg(type, "%s: Failed to load module \"%s\" (%s, %d)\n",
+ name, modname, msg, errmin);
+ else
+ xf86Msg(type, "Failed to load module \"%s\" (%s, %d)\n",
+ modname, msg, errmin);
+}
+
+/* Given a module path or file name, return the module's canonical name */
+static char *
+LoaderGetCanonicalName(const char *modname, PatternPtr patterns)
+{
+ char *str;
+ const char *s;
+ int len;
+ PatternPtr p;
+ regmatch_t match[2];
+
+ /* Strip off any leading path */
+ s = strrchr(modname, '/');
+ if (s == NULL)
+ s = modname;
+ else
+ s++;
+
+ /* Find the first regex that is matched */
+ for (p = patterns; p->pattern; p++)
+ if (regexec(&p->rex, s, 2, match, 0) == 0 && match[1].rm_so != -1) {
+ len = match[1].rm_eo - match[1].rm_so;
+ str = malloc(len + 1);
+ if (!str)
+ return NULL;
+ strncpy(str, s + match[1].rm_so, len);
+ str[len] = '\0';
+ return str;
+ }
+
+ /* If there is no match, return the whole name minus the leading path */
+ return strdup(s);
+}
+
+/*
+ * Return the module version information.
+ */
+unsigned long
+LoaderGetModuleVersion(ModuleDescPtr mod)
+{
+ if (!mod || mod == (ModuleDescPtr) 1 || !mod->VersionInfo)
+ return 0;
+
+ return MODULE_VERSION_NUMERIC(mod->VersionInfo->majorversion,
+ mod->VersionInfo->minorversion,
+ mod->VersionInfo->patchlevel);
+}
diff --git a/xorg-server/hw/xfree86/man/xorg.conf.man b/xorg-server/hw/xfree86/man/xorg.conf.man
index 5379fdc45..f406f82bb 100644
--- a/xorg-server/hw/xfree86/man/xorg.conf.man
+++ b/xorg-server/hw/xfree86/man/xorg.conf.man
@@ -1,2495 +1,2495 @@
-.\" shorthand for double quote that works everywhere.
-.ds q \N'34'
-.TH __xconfigfile__ __filemansuffix__ __vendorversion__
-.SH NAME
-__xconfigfile__ and __xconfigdir__ \- configuration files for
-__xservername__ X server
-.SH INTRODUCTION
-.B __xservername__
-supports several mechanisms for supplying/obtaining configuration and
-run-time parameters: command line options, environment variables, the
-__xconfigfile__ and __xconfigdir__ configuration files, auto-detection,
-and fallback defaults. When the same information is supplied in more
-than one way, the highest precedence mechanism is used. The list of
-mechanisms is ordered from highest precedence to lowest. Note that not
-all parameters can be supplied via all methods. The available command
-line options and environment variables (and some defaults) are
-described in the Xserver(__appmansuffix__) and
-__xservername__(__appmansuffix__) manual pages. Most configuration file
-parameters, with their defaults, are described below. Driver and module
-specific configuration parameters are described in the relevant driver
-or module manual page.
-.SH DESCRIPTION
-.B __xservername__
-uses a configuration file called
-.I __xconfigfile__
-and files ending in the suffix
-.I .conf
-from the directory
-.I __xconfigdir__
-for its initial setup.
-The
-.I __xconfigfile__
-configuration file is searched for in the following places when the
-server is started as a normal user:
-.PP
-.RS 4
-.nf
-.IR /etc/X11/ <cmdline>
-.IR __projectroot__/etc/X11/ <cmdline>
-.IB /etc/X11/ $XORGCONFIG
-.IB __projectroot__/etc/X11/ $XORGCONFIG
-.I /etc/X11/__xconfigfile__
-.I /etc/__xconfigfile__
-.IR __projectroot__/etc/X11/__xconfigfile__. <hostname>
-.I __projectroot__/etc/X11/__xconfigfile__
-.IR __projectroot__/lib/X11/__xconfigfile__. <hostname>
-.I __projectroot__/lib/X11/__xconfigfile__
-.fi
-.RE
-.PP
-where
-.I <cmdline>
-is a relative path (with no \(lq..\(rq components) specified with the
-.B \-config
-command line option,
-.B $XORGCONFIG
-is the relative path (with no \(lq..\(rq components) specified by that
-environment variable, and
-.I <hostname>
-is the machine's hostname as reported by
-.BR gethostname (__libmansuffix__).
-.PP
-When the __xservername__ server is started by the \(lqroot\(rq user, the config file
-search locations are as follows:
-.PP
-.RS 4
-.nf
-<cmdline>
-.IR /etc/X11/ <cmdline>
-.IR __projectroot__/etc/X11/ <cmdline>
-.B $XORGCONFIG
-.IB /etc/X11/ $XORGCONFIG
-.IB __projectroot__/etc/X11/ $XORGCONFIG
-.I /etc/X11/__xconfigfile__
-.I /etc/__xconfigfile__
-.IR __projectroot__/etc/X11/__xconfigfile__. <hostname>
-.I __projectroot__/etc/X11/__xconfigfile__
-.IR __projectroot__/lib/X11/__xconfigfile__. <hostname>
-.I __projectroot__/lib/X11/__xconfigfile__
-.fi
-.RE
-.PP
-where
-.I <cmdline>
-is the path specified with the
-.B \-config
-command line option (which may be absolute or relative),
-.B $XORGCONFIG
-is the path specified by that
-environment variable (absolute or relative),
-.B $HOME
-is the path specified by that environment variable (usually the home
-directory), and
-.I <hostname>
-is the machine's hostname as reported by
-.BR gethostname (__libmansuffix__).
-.PP
-Additional configuration files are searched for in the following
-directories when the server is started as a normal user:
-.PP
-.RS 4
-.nf
-.IR /etc/X11/ <cmdline>
-.IR __sysconfdir__/X11/ <cmdline>
-.I /etc/X11/__xconfigdir__
-.I __sysconfdir__/X11/__xconfigdir__
-.fi
-.RE
-.PP
-where
-.I <cmdline>
-is a relative path (with no \(lq..\(rq components) specified with the
-.B \-configdir
-command line option.
-.PP
-When the __xservername__ server is started by the \(lqroot\(rq user, the
-config directory search locations are as follows:
-.PP
-.RS 4
-.nf
-<cmdline>
-.IR /etc/X11/ <cmdline>
-.IR __sysconfdir__/X11/ <cmdline>
-.I /etc/X11/__xconfigdir__
-.I __sysconfdir__/X11/__xconfigdir__
-.fi
-.RE
-.PP
-where
-.I <cmdline>
-is the path specified with the
-.B \-configdir
-command line option (which may be absolute or relative).
-.PP
-Finally, configuration files will also be searched for in directories
-reserved for system use. These are to separate configuration files from
-the vendor or 3rd party packages from those of local administration.
-These files are found in the following directories:
-.PP
-.RS 4
-.nf
-.I /usr/share/X11/__xconfigdir__
-.I __datadir__/X11/__xconfigdir__
-.fi
-.RE
-.PP
-The
-.I __xconfigfile__
-and
-.I __xconfigdir__
-files are composed of a number of sections which may be present in any order,
-or omitted to use default configuration values.
-Each section has the form:
-.PP
-.RS 4
-.nf
-.BI "Section \*q" SectionName \*q
-.RI " " SectionEntry
- ...
-.B EndSection
-.fi
-.RE
-.PP
-The section names are:
-.PP
-.RS 4
-.nf
-.BR "Files " "File pathnames"
-.BR "ServerFlags " "Server flags"
-.BR "Module " "Dynamic module loading"
-.BR "Extensions " "Extension enabling"
-.BR "InputDevice " "Input device description"
-.BR "InputClass " "Input class description"
-.BR "Device " "Graphics device description"
-.BR "VideoAdaptor " "Xv video adaptor description"
-.BR "Monitor " "Monitor description"
-.BR "Modes " "Video modes descriptions"
-.BR "Screen " "Screen configuration"
-.BR "ServerLayout " "Overall layout"
-.BR "DRI " "DRI\-specific configuration"
-.BR "Vendor " "Vendor\-specific configuration"
-.fi
-.RE
-.PP
-The following obsolete section names are still recognised for compatibility
-purposes.
-In new config files, the
-.B InputDevice
-section should be used instead.
-.PP
-.RS 4
-.nf
-.BR "Keyboard " "Keyboard configuration"
-.BR "Pointer " "Pointer/mouse configuration"
-.fi
-.RE
-.PP
-The old
-.B XInput
-section is no longer recognised.
-.PP
-The
-.B ServerLayout
-sections are at the highest level.
-They bind together the input and output devices that will be used in a session.
-The input devices are described in the
-.B InputDevice
-sections.
-Output devices usually consist of multiple independent components (e.g.,
-a graphics board and a monitor).
-These multiple components are bound together in the
-.B Screen
-sections, and it is these that are referenced by the
-.B ServerLayout
-section.
-Each
-.B Screen
-section binds together a graphics board and a monitor.
-The graphics boards are described in the
-.B Device
-sections, and the monitors are described in the
-.B Monitor
-sections.
-.PP
-Config file keywords are case\-insensitive, and \(lq_\(rq characters are
-ignored.
-Most strings (including
-.B Option
-names) are also case-insensitive, and insensitive to white space and
-\(lq_\(rq characters.
-.PP
-Each config file entry usually takes up a single line in the file. They
-consist of a keyword, which is possibly followed by one or more arguments,
-with the number and types of the arguments depending on the keyword.
-The argument types are:
-.PP
-.RS 4
-.nf
-.BR "Integer " "an integer number in decimal, hex or octal"
-.BR "Real " "a floating point number"
-.BR "String " "a string enclosed in double quote marks (\*q)"
-.fi
-.RE
-.PP
-Note: hex integer values must be prefixed with \(lq0x\(rq, and octal values
-with \(lq0\(rq.
-.PP
-A special keyword called
-.B Option
-may be used to provide free\-form data to various components of the server.
-The
-.B Option
-keyword takes either one or two string arguments.
-The first is the option name, and the optional second argument is the
-option value.
-Some commonly used option value types include:
-.PP
-.RS 4
-.nf
-.BR "Integer " "an integer number in decimal, hex or octal"
-.BR "Real " "a floating point number"
-.BR "String " "a sequence of characters"
-.BR "Boolean " "a boolean value (see below)"
-.BR "Frequency " "a frequency value (see below)"
-.fi
-.RE
-.PP
-Note that
-.I all
-.B Option
-values, not just strings, must be enclosed in quotes.
-.PP
-Boolean options may optionally have a value specified.
-When no value is specified, the option's value is
-.BR TRUE .
-The following boolean option values are recognised as
-.BR TRUE :
-.PP
-.RS 4
-.BR 1 ,
-.BR on ,
-.BR true ,
-.B yes
-.RE
-.PP
-and the following boolean option values are recognised as
-.BR FALSE :
-.PP
-.RS 4
-.BR 0 ,
-.BR off ,
-.BR false ,
-.B no
-.RE
-.PP
-If an option name is prefixed with
-.RB \*q No \*q,
-then the option value is negated.
-.PP
-Example: the following option entries are equivalent:
-.PP
-.RS 4
-.nf
-.B "Option \*qAccel\*q \*qOff\*q"
-.B "Option \*qNoAccel\*q"
-.B "Option \*qNoAccel\*q \*qOn\*q"
-.B "Option \*qAccel\*q \*qfalse\*q"
-.B "Option \*qAccel\*q \*qno\*q"
-.fi
-.RE
-.PP
-Frequency option values consist of a real number that is optionally
-followed by one of the following frequency units:
-.PP
-.RS 4
-.BR Hz ,
-.BR k ,
-.BR kHz ,
-.BR M ,
-.B MHz
-.RE
-.PP
-When the unit name is omitted, the correct units will be determined from
-the value and the expectations of the appropriate range of the value.
-It is recommended that the units always be specified when using frequency
-option values to avoid any errors in determining the value.
-.SH "FILES SECTION"
-The
-.B Files
-section is used to specify some path names required by the server.
-Some of these paths can also be set from the command line (see
-.BR Xserver (__appmansuffix__)
-and
-.BR __xservername__ (__appmansuffix__)).
-The command line settings override the values specified in the config
-file.
-The
-.B Files
-section is optional, as are all of the entries that may appear in it.
-.PP
-The entries that can appear in this section are:
-.TP 7
-.BI "FontPath \*q" path \*q
-sets the search path for fonts.
-This path is a comma separated list of font path elements which the __xservername__
-server searches for font databases.
-Multiple
-.B FontPath
-entries may be specified, and they will be concatenated to build up the
-fontpath used by the server. Font path elements can be absolute
-directory paths, catalogue directories or a font server identifier. The
-formats of the later two are explained below:
-.PP
-.RS 7
-Catalogue directories:
-.PP
-.RS 4
-Catalogue directories can be specified using the prefix \fBcatalogue:\fR
-before the directory name. The directory can then be populated with
-symlinks pointing to the real font directories, using the following
-syntax in the symlink name:
-.PP
-.RS 4
-.IR <identifier> : [attribute]: pri= <priority>
-.RE
-.PP
-where
-.I <identifier>
-is an alphanumeric identifier,
-.I [attribute]
-is an attribute which will be passed to the underlying FPE and
-.I <priority>
-is a number used to order the fontfile FPEs. Examples:
-.PP
-.RS 4
-.nf
-.I 75dpi:unscaled:pri=20 -> /usr/share/X11/fonts/75dpi
-.I gscript:pri=60 -> /usr/share/fonts/default/ghostscript
-.I misc:unscaled:pri=10 \-> /usr/share/X11/fonts/misc
-.fi
-.PP
-.RE .RE .RE
-.PP
-.RS 7
-Font server identifiers:
-.PP
-.RS 4
-Font server identifiers have the form:
-.RS 4
-.PP
-.IR <trans> / <hostname> : <port\-number>
-.RE
-.PP
-where
-.I <trans>
-is the transport type to use to connect to the font server (e.g.,
-.B unix
-for UNIX\-domain sockets or
-.B tcp
-for a TCP/IP connection),
-.I <hostname>
-is the hostname of the machine running the font server, and
-.I <port\-number>
-is the port number that the font server is listening on (usually 7100).
-.RE
-.PP
-When this entry is not specified in the config file, the server falls back
-to the compiled\-in default font path, which contains the following
-font path elements (which can be set inside a catalogue directory):
-.PP
-.RS 4
-.nf
-.I __datadir__/fonts/X11/misc/
-.I __datadir__/fonts/X11/TTF/
-.I __datadir__/fonts/X11/OTF/
-.I __datadir__/fonts/X11/Type1/
-.I __datadir__/fonts/X11/100dpi/
-.I __datadir__/fonts/X11/75dpi/
-.fi
-.RE
-.PP
-Font path elements that are found to be invalid are removed from the
-font path when the server starts up.
-.RE
-.TP 7
-.BI "ModulePath \*q" path \*q
-sets the search path for loadable __xservername__ server modules.
-This path is a comma separated list of directories which the __xservername__ server
-searches for loadable modules loading in the order specified.
-Multiple
-.B ModulePath
-entries may be specified, and they will be concatenated to build the
-module search path used by the server. The default module path is
-.PP
-.RS 11
-__modulepath__
-.RE
-.\" The LogFile keyword is not currently implemented
-.ig
-.TP 7
-.BI "LogFile \*q" path \*q
-sets the name of the __xservername__ server log file.
-The default log file name is
-.PP
-.RS 11
-.RI __logdir__/__xservername__. <n> .log
-.RE
-.PP
-.RS 7
-where
-.I <n>
-is the display number for the __xservername__ server.
-..
-.TP 7
-.BI "XkbDir \*q" path \*q
-sets the base directory for keyboard layout files. The
-.B \-xkbdir
-command line option can be used to override this. The default directory is
-.PP
-.RS 11
-__xkbdir__
-.RE
-.SH "SERVERFLAGS SECTION"
-In addition to options specific to this section (described below), the
-.B ServerFlags
-section is used to specify some global
-__xservername__ server options.
-All of the entries in this section are
-.BR Options ,
-although for compatibility purposes some of the old style entries are
-still recognised.
-Those old style entries are not documented here, and using them is
-discouraged.
-The
-.B ServerFlags
-section is optional, as are the entries that may be specified in it.
-.PP
-.B Options
-specified in this section (with the exception of the
-.B \*qDefaultServerLayout\*q
-.BR Option )
-may be overridden by
-.B Options
-specified in the active
-.B ServerLayout
-section.
-Options with command line equivalents are overridden when their command
-line equivalent is used.
-The options recognised by this section are:
-.TP 7
-.BI "Option \*qDefaultServerLayout\*q \*q" layout\-id \*q
-This specifies the default
-.B ServerLayout
-section to use in the absence of the
-.B \-layout
-command line option.
-.TP 7
-.BI "Option \*qNoTrapSignals\*q \*q" boolean \*q
-This prevents the __xservername__ server from trapping a range of unexpected fatal
-signals and exiting cleanly.
-Instead, the __xservername__ server will die and drop core where the fault occurred.
-The default behaviour is for the __xservername__ server to exit cleanly, but still drop a
-core file.
-In general you never want to use this option unless you are debugging an __xservername__
-server problem and know how to deal with the consequences.
-.TP 7
-.BI "Option \*qUseSIGIO\*q \*q" boolean \*q
-This controls whether the __xservername__ server requests that events from
-input devices be reported via a SIGIO signal handler (also known as SIGPOLL
-on some platforms), or only reported via the standard select(3) loop.
-The default behaviour is platform specific. In general you do not want to
-use this option unless you are debugging the __xservername__ server, or
-working around a specific bug until it is fixed, and understand the
-consequences.
-.TP 7
-.BI "Option \*qDontVTSwitch\*q \*q" boolean \*q
-This disallows the use of the
-.BI Ctrl+Alt+F n
-sequence (where
-.RI F n
-refers to one of the numbered function keys).
-That sequence is normally used to switch to another \*qvirtual terminal\*q
-on operating systems that have this feature.
-When this option is enabled, that key sequence has no special meaning and
-is passed to clients.
-Default: off.
-.TP 7
-.BI "Option \*qDontZap\*q \*q" boolean \*q
-This disallows the use of the
-.B Terminate_Server
-XKB action (usually on Ctrl+Alt+Backspace, depending on XKB options).
-This action is normally used to terminate the __xservername__ server.
-When this option is enabled, the action has no effect.
-Default: off.
-.TP 7
-.BI "Option \*qDontZoom\*q \*q" boolean \*q
-This disallows the use of the
-.B Ctrl+Alt+Keypad\-Plus
-and
-.B Ctrl+Alt+Keypad\-Minus
-sequences.
-These sequences allows you to switch between video modes.
-When this option is enabled, those key sequences have no special meaning
-and are passed to clients.
-Default: off.
-.TP 7
-.BI "Option \*qDisableVidModeExtension\*q \*q" boolean \*q
-This disables the parts of the VidMode extension used by the xvidtune client
-that can be used to change the video modes.
-Default: the VidMode extension is enabled.
-.TP 7
-.BI "Option \*qAllowNonLocalXvidtune\*q \*q" boolean \*q
-This allows the xvidtune client (and other clients that use the VidMode
-extension) to connect from another host.
-Default: off.
-.TP 7
-.BI "Option \*qAllowMouseOpenFail\*q \*q" boolean \*q
-This tells the mousedrv(__drivermansuffix__) and vmmouse(__drivermansuffix__)
-drivers to not report failure if the mouse device can't be opened/initialised.
-It has no effect on the evdev(__drivermansuffix__) or other drivers.
-Default: false.
-.TP 7
-.BI "Option \*qVTSysReq\*q \*q" boolean \*q
-enables the SYSV\-style VT switch sequence for non\-SYSV systems
-which support VT switching.
-This sequence is
-.B Alt\-SysRq
-followed by a function key
-.RB ( Fn ).
-This prevents the __xservername__ server trapping the
-keys used for the default VT switch sequence, which means that clients can
-access them.
-Default: off.
-.TP 7
-.BI "Option \*qBlankTime\*q \*q" time \*q
-sets the inactivity timeout for the
-.B blank
-phase of the screensaver.
-.I time
-is in minutes.
-This is equivalent to the __xservername__ server's
-.B \-s
-flag, and the value can be changed at run\-time with
-.BR xset(__appmansuffix__).
-Default: 10 minutes.
-.TP 7
-.BI "Option \*qStandbyTime\*q \*q" time \*q
-sets the inactivity timeout for the
-.B standby
-phase of DPMS mode.
-.I time
-is in minutes, and the value can be changed at run\-time with
-.BR xset(__appmansuffix__).
-Default: 10 minutes.
-This is only suitable for VESA DPMS compatible monitors, and may not be
-supported by all video drivers.
-It is only enabled for screens that have the
-.B \*qDPMS\*q
-option set (see the MONITOR section below).
-.TP 7
-.BI "Option \*qSuspendTime\*q \*q" time \*q
-sets the inactivity timeout for the
-.B suspend
-phase of DPMS mode.
-.I time
-is in minutes, and the value can be changed at run\-time with
-.BR xset(__appmansuffix__).
-Default: 10 minutes.
-This is only suitable for VESA DPMS compatible monitors, and may not be
-supported by all video drivers.
-It is only enabled for screens that have the
-.B \*qDPMS\*q
-option set (see the MONITOR section below).
-.TP 7
-.BI "Option \*qOffTime\*q \*q" time \*q
-sets the inactivity timeout for the
-.B off
-phase of DPMS mode.
-.I time
-is in minutes, and the value can be changed at run\-time with
-.BR xset(__appmansuffix__).
-Default: 10 minutes.
-This is only suitable for VESA DPMS compatible monitors, and may not be
-supported by all video drivers.
-It is only enabled for screens that have the
-.B \*qDPMS\*q
-option set (see the MONITOR section below).
-.TP 7
-.BI "Option \*qPixmap\*q \*q" bpp \*q
-This sets the pixmap format to use for depth 24.
-Allowed values for
-.I bpp
-are 24 and 32.
-Default: 32 unless driver constraints don't allow this (which is rare).
-Note: some clients don't behave well when this value is set to 24.
-.TP 7
-.BI "Option \*qPC98\*q \*q" boolean \*q
-Specify that the machine is a Japanese PC\-98 machine.
-This should not be enabled for anything other than the Japanese\-specific
-PC\-98 architecture.
-Default: auto\-detected.
-.TP 7
-.BI "Option \*qNoPM\*q \*q" boolean \*q
-Disables something to do with power management events.
-Default: PM enabled on platforms that support it.
-.TP 7
-.BI "Option \*qXinerama\*q \*q" boolean \*q
-enable or disable XINERAMA extension.
-Default is disabled.
-.TP 7
-.BI "Option \*qAIGLX\*q \*q" boolean \*q
-enable or disable AIGLX. AIGLX is enabled by default.
-.TP 7
-.BI "Option \*qDRI2\*q \*q" boolean \*q
-enable or disable DRI2. DRI2 is disabled by default.
-.TP 7
-.BI "Option \*qGlxVisuals\*q \*q" string \*q
-This option controls how many GLX visuals the GLX modules sets up.
-The default value is
-.BR "typical" ,
-which will setup up a typical subset of
-the GLXFBConfigs provided by the driver as GLX visuals. Other options are
-.BR "minimal" ,
-which will set up the minimal set allowed by the GLX specification and
-.BR "all"
-which will setup GLX visuals for all GLXFBConfigs.
-.TP 7
-.BI "Option \*qUseDefaultFontPath\*q \*q" boolean \*q
-Include the default font path even if other paths are specified in
-xorg.conf. If enabled, other font paths are included as well. Enabled by
-default.
-.TP 7
-.BI "Option \*qIgnoreABI\*q \*q" boolean \*q
-Allow modules built for a different, potentially incompatible version of
-the X server to load. Disabled by default.
-.TP 7
-.BI "Option \*qAutoAddDevices\*q \*q" boolean \*q
-If this option is disabled, then no devices will be added from HAL events.
-Enabled by default.
-.TP 7
-.BI "Option \*qAutoEnableDevices\*q \*q" boolean \*q
-If this option is disabled, then the devices will be added (and the
-DevicePresenceNotify event sent), but not enabled, thus leaving policy up
-to the client.
-Enabled by default.
-.TP 7
-.BI "Option \*qLog\*q \*q" string \*q
-This option controls whether the log is flushed and/or synced to disk after
-each message.
-Possible values are
-.B flush
-or
-.BR sync .
-Unset by default.
-.SH "MODULE SECTION"
-The
-.B Module
-section is used to specify which __xservername__ server modules should be loaded.
-This section is ignored when the __xservername__ server is built in static form.
-The type of modules normally loaded in this section are __xservername__ server
-extension modules.
-Most other module types are loaded automatically when they are needed via
-other mechanisms.
-The
-.B Module
-section is optional, as are all of the entries that may be specified in
-it.
-.PP
-Entries in this section may be in two forms.
-The first and most commonly used form is an entry that uses the
-.B Load
-keyword, as described here:
-.TP 7
-.BI "Load \*q" modulename \*q
-This instructs the server to load the module called
-.IR modulename .
-The module name given should be the module's standard name, not the
-module file name.
-The standard name is case\-sensitive, and does not include the \(lqlib\(rq
-prefix, or the \(lq.a\(rq, \(lq.o\(rq, or \(lq.so\(rq suffixes.
-.PP
-.RS 7
-Example: the DRI extension module can be loaded with the following entry:
-.PP
-.RS 4
-.B "Load \*qdri\*q"
-.RE
-.RE
-.TP 7
-.BI "Disable \*q" modulename \*q
-This instructs the server to not load the module called
-.IR modulename .
-Some modules are loaded by default in the server, and this overrides that
-default. If a
-.B Load
-instruction is given for the same module, it overrides the
-.B Disable
-instruction and the module is loaded. The module name given should be the
-module's standard name, not the module file name. As with the
-.B Load
-instruction, the standard name is case-sensitive, and does not include the
-"lib" prefix, or the ".a", ".o", or ".so" suffixes.
-.PP
-The second form of entry is a
-.BR SubSection,
-with the subsection name being the module name, and the contents of the
-.B SubSection
-being
-.B Options
-that are passed to the module when it is loaded.
-.PP
-Example: the extmod module (which contains a miscellaneous group of
-server extensions) can be loaded, with the XFree86\-DGA extension
-disabled by using the following entry:
-.PP
-.RS 4
-.nf
-.B "SubSection \*qextmod\*q"
-.B " Option \*qomit XFree86\-DGA\*q"
-.B EndSubSection
-.fi
-.RE
-.PP
-Modules are searched for in each directory specified in the
-.B ModulePath
-search path, and in the drivers, extensions, input, internal, and
-multimedia subdirectories of each of those directories.
-In addition to this, operating system specific subdirectories of all
-the above are searched first if they exist.
-.PP
-To see what extension modules are available, check the extensions
-subdirectory under:
-.PP
-.RS 4
-.nf
-__modulepath__
-.fi
-.RE
-.PP
-The \(lqextmod\(rq, \(lqdbe\(rq, \(lqdri\(rq, \(lqdri2\(rq, \(lqglx\(rq,
-and \(lqrecord\(rq extension modules are loaded automatically, if they
-are present, unless disabled with \*qDisable\*q entries.
-It is recommended
-that at very least the \(lqextmod\(rq extension module be loaded.
-If it isn't, some commonly used server extensions (like the SHAPE
-extension) will not be available.
-.SH "EXTENSIONS SECTION"
-The
-.B Extensions
-section is used to specify which X11 protocol extensions should be enabled
-or disabled.
-The
-.B Extensions
-section is optional, as are all of the entries that may be specified in
-it.
-.PP
-Entries in this section are listed as Option statements with the name of
-the extension as the first argument, and a boolean value as the second.
-The extension name is case\-sensitive, and matches the form shown in the output
-of \*qXorg -extension ?\*q.
-.PP
-.RS 7
-Example: the MIT-SHM extension can be disabled with the following entry:
-.PP
-.RS 4
-.nf
-.B "Section \*qExtensions\*q"
-.B " Option \*qMIT-SHM\*q \*qDisable\*q"
-.B "EndSection"
-.fi
-.RE
-.RE
-.SH "INPUTDEVICE SECTION"
-The config file may have multiple
-.B InputDevice
-sections.
-Recent X servers employ HAL or udev backends for input device enumeration
-and input hotplugging. It is usually not
-necessary to provide
-.B InputDevice
-sections in the xorg.conf if hotplugging is in use. If hotplugging is
-enabled,
-.B InputDevice
-sections using the
-.B mouse, kbd
-and
-.B vmmouse
-driver will be ignored.
-.PP
-If hotplugging is disabled, there will normally
-be at least two: one for the core (primary) keyboard
-and one for the core pointer.
-If either of these two is missing, a default configuration for the missing
-ones will be used. In the absence of an explicitly specified core input
-device, the first
-.B InputDevice
-marked as
-.B CorePointer
-(or
-.BR CoreKeyboard )
-is used.
-If there is no match there, the first
-.B InputDevice
-that uses the \(lqmouse\(rq (or \(lqkbd\(rq) driver is used.
-The final fallback is to use built\-in default configurations.
-Currently the default configuration may not work as expected on all platforms.
-.PP
-.B InputDevice
-sections have the following format:
-.PP
-.RS 4
-.nf
-.B "Section \*qInputDevice\*q"
-.BI " Identifier \*q" name \*q
-.BI " Driver \*q" inputdriver \*q
-.I " options"
-.I " ..."
-.B "EndSection"
-.fi
-.RE
-.PP
-The
-.B Identifier
-and
-.B Driver
-entries are required in all
-.B InputDevice
-sections.
-All other entries are optional.
-.PP
-The
-.B Identifier
-entry specifies the unique name for this input device.
-The
-.B Driver
-entry specifies the name of the driver to use for this input device.
-When using the loadable server, the input driver module
-.RI \*q inputdriver \*q
-will be loaded for each active
-.B InputDevice
-section.
-An
-.B InputDevice
-section is considered active if it is referenced by an active
-.B ServerLayout
-section, if it is referenced by the
-.B \-keyboard
-or
-.B \-pointer
-command line options, or if it is selected implicitly as the core pointer
-or keyboard device in the absence of such explicit references.
-The most commonly used input drivers are
-.BR evdev (__drivermansuffix__)
-on Linux systems, and
-.BR kbd (__drivermansuffix__)
-and
-.BR mousedrv (__drivermansuffix__)
-on other platforms.
-.PP
-.PP
-.B InputDevice
-sections recognise some driver\-independent
-.BR Options ,
-which are described here.
-See the individual input driver manual pages for a description of the
-device\-specific options.
-.TP 7
-.BI "Option \*qAutoServerLayout\*q \*q" boolean \*q
-Always add the device to the ServerLayout section used by this instance of
-the server. This affects implied layouts as well as explicit layouts
-specified in the configuration and/or on the command line.
-.TP 7
-.BI "Option \*qCorePointer\*q"
-Deprecated, see
-.B Floating
-.TP 7
-.BI "Option \*qCoreKeyboard\*q"
-Deprecated, see
-.B Floating
-.TP 7
-.BI "Option \*qAlwaysCore\*q \*q" boolean \*q
-Deprecated, see
-.B Floating
-.TP 7
-.BI "Option \*qSendCoreEvents\*q \*q" boolean \*q
-Deprecated, see
-.B Floating
-
-.TP 7
-.BI "Option \*qFloating\*q \*q" boolean \*q
-When enabled, the input device is set up floating and does not
-report events through any master device or control a cursor. The device is
-only available to clients using the X Input Extension API. This option is
-disabled by default.
-The options
-.B CorePointer,
-.B CoreKeyboard,
-.B AlwaysCore,
-and
-.B SendCoreEvents,
-are the inverse of option
-.B Floating
-(i.e.
-.B SendCoreEvents \*qon\*q
-is equivalent to
-.B Floating \*qoff\*q
-).
-
-This option controls the startup behavior only, a device
-may be reattached or set floating at runtime.
-.PP
-For pointing devices, the following options control how the pointer
-is accelerated or decelerated with respect to physical device motion. Most of
-these can be adjusted at runtime, see the xinput(1) man page for details. Only
-the most important acceleration options are discussed here.
-.TP 7
-.BI "Option \*qAccelerationProfile\*q \*q" integer \*q
-Select the profile. In layman's terms, the profile constitutes the "feeling" of
-the acceleration. More formally, it defines how the transfer function (actual
-acceleration as a function of current device velocity and acceleration controls)
-is constructed. This is mainly a matter of personal preference.
-.PP
-.RS 6
-.nf
-.B " 0 classic (mostly compatible)"
-.B "-1 none (only constant deceleration is applied)"
-.B " 1 device-dependent"
-.B " 2 polynomial (polynomial function)"
-.B " 3 smooth linear (soft knee, then linear)"
-.B " 4 simple (normal when slow, otherwise accelerated)"
-.B " 5 power (power function)"
-.B " 6 linear (more speed, more acceleration)"
-.B " 7 limited (like linear, but maxes out at threshold)"
-.fi
-.RE
-.TP 7
-.BI "Option \*qConstantDeceleration\*q \*q" real \*q
-Makes the pointer go
-.B deceleration
-times slower than normal. Most useful for high-resolution devices.
-.TP 7
-.BI "Option \*qAdaptiveDeceleration\*q \*q" real \*q
-Allows to actually decelerate the pointer when going slow. At most, it will be
-.B adaptive deceleration
-times slower. Enables precise pointer placement without sacrificing speed.
-.TP 7
-.BI "Option \*qAccelerationScheme\*q \*q" string \*q
-Selects the scheme, which is the underlying algorithm.
-.PP
-.RS 7
-.nf
-.B "predictable default algorithm (behaving more predictable)"
-.B "lightweight old acceleration code (as specified in the X protocol spec)"
-.B "none no acceleration or deceleration"
-.fi
-.RE
-.TP 7
-.BI "Option \*qAccelerationNumerator\*q \*q" integer \*q
-.TP 7
-.BI "Option \*qAccelerationDenominator\*q \*q" integer \*q
-Set numerator and denominator of the acceleration factor. The acceleration
-factor is a rational which, together with threshold, can be used to tweak
-profiles to suit the users needs. The
-.B simple
-and
-.B limited
-profiles use it directly (i.e. they accelerate by the factor), for other
-profiles it should hold that a higher acceleration factor leads to a faster
-pointer. Typically, 1 is unaccelerated and values up to 5 are sensible.
-.TP 7
-.BI "Option \*qAccelerationThreshold\*q \*q" integer \*q
-Set the threshold, which is roughly the velocity (usually device units per 10
-ms) required for acceleration to become effective. The precise effect varies
-with the profile however.
-
-.SH "INPUTCLASS SECTION"
-The config file may have multiple
-.B InputClass
-sections.
-These sections are optional and are used to provide configuration for a
-class of input devices as they are automatically added. An input device can
-match more than one
-.B InputClass
-section. Each class can override settings from a previous class, so it is
-best to arrange the sections with the most generic matches first.
-.PP
-.B InputClass
-sections have the following format:
-.PP
-.RS 4
-.nf
-.B "Section \*qInputClass\*q"
-.BI " Identifier \*q" name \*q
-.I " entries"
-.I " ..."
-.I " options"
-.I " ..."
-.B "EndSection"
-.fi
-.RE
-.PP
-The
-.B Identifier
-entry is required in all
-.B InputClass
-sections.
-All other entries are optional.
-.PP
-The
-.B Identifier
-entry specifies the unique name for this input class.
-The
-.B Driver
-entry specifies the name of the driver to use for this input device.
-After all classes have been examined, the
-.RI \*q inputdriver \*q
-module from the first
-.B Driver
-entry will be enabled when using the loadable server.
-.PP
-When an input device is automatically added, its characteristics are
-checked against all
-.B InputClass
-sections. Each section can contain optional entries to narrow the match
-of the class. If none of the optional entries appear, the
-.B InputClass
-section is generic and will match any input device. If more than one of
-these entries appear, they all must match for the configuration to apply.
-.PP
-There are two types of match entries used in
-.B InputClass
-sections. The first allows various tokens to be matched against attributes
-of the device. An entry can be constructed to match attributes from different
-devices by separating arguments with a '|' character. Multiple entries of the
-same type may be supplied to add multiple matching conditions on the same
-attribute. For example:
-.PP
-.RS 4
-.nf
-.B "Section \*qInputClass\*q"
-.B " Identifier \*qMy Class\*q"
-.B " # product string must contain example and
-.B " # either gizmo or gadget
-.B " MatchProduct \*qexample\*q
-.B " MatchProduct \*qgizmo|gadget\*q
-.I " ..."
-.B "EndSection"
-.fi
-.RE
-.TP 7
-.BI "MatchProduct \*q" matchproduct \*q
-This entry can be used to check if the substring
-.RI \*q matchproduct \*q
-occurs in the device's product name.
-.TP 7
-.BI "MatchVendor \*q" matchvendor \*q
-This entry can be used to check if the substring
-.RI \*q matchvendor \*q
-occurs in the device's vendor name.
-.TP 7
-.BI "MatchDevicePath \*q" matchdevice \*q
-This entry can be used to check if the device file matches the
-.RI \*q matchdevice \*q
-pathname pattern.
-.TP 7
-.BI "MatchOS \*q" matchos \*q
-This entry can be used to check if the operating system matches the
-case-insensitive
-.RI \*q matchos \*q
-string. This entry is only supported on platforms providing the
-.BR uname (2)
-system call.
-.TP 7
-.BI "MatchPnPID \*q" matchpnp \*q
-The device's Plug and Play (PnP) ID can be checked against the
-.RI \*q matchpnp \*q
-shell wildcard pattern.
-.TP 7
-.BI "MatchUSBID \*q" matchusb \*q
-The device's USB ID can be checked against the
-.RI \*q matchusb \*q
-shell wildcard pattern. The ID is constructed as lowercase hexadecimal numbers
-separated by a ':'. This is the same format as the
-.BR lsusb (8)
-program.
-.TP 7
-.BI "MatchDriver \*q" matchdriver \*q
-Check the case-sensitive string
-.RI \*q matchdriver \*q
-against the currently configured driver of the device. Ordering of sections
-using this entry is important since it will not match unless the driver has
-been set by the config backend or a previous
-.B InputClass
-section.
-.TP 7
-.BI "MatchTag \*q" matchtag \*q
-This entry can be used to check if tags assigned by the config backend
-matches the
-.RI \*q matchtag \*q
-pattern. A match is found if at least one of the tags given in
-.RI \*q matchtag \*q
-matches at least one of the tags assigned by the backend.
-.TP 7
-.BI "MatchLayout \*q" matchlayout \*q
-Check the case-sensitive string
-.RI \*q matchlayout \*q
-against the currently active
-.B ServerLayout
-section. The empty string "" matches an implicit layout which appears
-if no named
-.B ServerLayout
-sections have been found.
-.PP
-The second type of entry is used to match device types. These entries take a
-boolean argument similar to
-.B Option
-entries.
-.TP 7
-.BI "MatchIsKeyboard \*q" bool \*q
-.TP 7
-.BI "MatchIsPointer \*q" bool \*q
-.TP 7
-.BI "MatchIsJoystick \*q" bool \*q
-.TP 7
-.BI "MatchIsTablet \*q" bool \*q
-.TP 7
-.BI "MatchIsTouchpad \*q" bool \*q
-.TP 7
-.BI "MatchIsTouchscreen \*q" bool \*q
-.PP
-When an input device has been matched to the
-.B InputClass
-section, any
-.B Option
-entries are applied to the device. One
-.B InputClass
-specific
-.B Option
-is recognized. See the
-.B InputDevice
-section above for a description of the remaining
-.B Option
-entries.
-.TP 7
-.BI "Option \*qIgnore\*q \*q" boolean \*q
-This optional entry specifies that the device should be ignored entirely,
-and not added to the server. This can be useful when the device is handled
-by another program and no X events should be generated.
-.SH "DEVICE SECTION"
-The config file may have multiple
-.B Device
-sections.
-There must be at least one, for the video card being used.
-.PP
-.B Device
-sections have the following format:
-.PP
-.RS 4
-.nf
-.B "Section \*qDevice\*q"
-.BI " Identifier \*q" name \*q
-.BI " Driver \*q" driver \*q
-.I " entries"
-.I " ..."
-.B "EndSection"
-.fi
-.RE
-.PP
-The
-.B Identifier
-and
-.B Driver
-entries are required in all
-.B Device
-sections. All other entries are optional.
-.PP
-The
-.B Identifier
-entry specifies the unique name for this graphics device.
-The
-.B Driver
-entry specifies the name of the driver to use for this graphics device.
-When using the loadable server, the driver module
-.RI \*q driver \*q
-will be loaded for each active
-.B Device
-section.
-A
-.B Device
-section is considered active if it is referenced by an active
-.B Screen
-section.
-.PP
-.B Device
-sections recognise some driver\-independent entries and
-.BR Options ,
-which are described here.
-Not all drivers make use of these
-driver\-independent entries, and many of those that do don't require them
-to be specified because the information is auto\-detected.
-See the individual graphics driver manual pages for further information
-about this, and for a description of the device\-specific options.
-Note that most of the
-.B Options
-listed here (but not the other entries) may be specified in the
-.B Screen
-section instead of here in the
-.B Device
-section.
-.TP 7
-.BI "BusID \*q" bus\-id \*q
-This specifies the bus location of the graphics card.
-For PCI/AGP cards,
-the
-.I bus\-id
-string has the form
-.BI PCI: bus : device : function
-(e.g., \(lqPCI:1:0:0\(rq might be appropriate for an AGP card).
-This field is usually optional in single-head configurations when using
-the primary graphics card.
-In multi-head configurations, or when using a secondary graphics card in a
-single-head configuration, this entry is mandatory.
-Its main purpose is to make an unambiguous connection between the device
-section and the hardware it is representing.
-This information can usually be found by running the pciaccess tool
-scanpci.
-.TP 7
-.BI "Screen " number
-This option is mandatory for cards where a single PCI entity can drive more
-than one display (i.e., multiple CRTCs sharing a single graphics accelerator
-and video memory).
-One
-.B Device
-section is required for each head, and this
-parameter determines which head each of the
-.B Device
-sections applies to.
-The legal values of
-.I number
-range from 0 to one less than the total number of heads per entity.
-Most drivers require that the primary screen (0) be present.
-.TP 7
-.BI "Chipset \*q" chipset \*q
-This usually optional entry specifies the chipset used on the graphics
-board.
-In most cases this entry is not required because the drivers will probe the
-hardware to determine the chipset type.
-Don't specify it unless the driver-specific documentation recommends that you
-do.
-.TP 7
-.BI "Ramdac \*q" ramdac\-type \*q
-This optional entry specifies the type of RAMDAC used on the graphics
-board.
-This is only used by a few of the drivers, and in most cases it is not
-required because the drivers will probe the hardware to determine the
-RAMDAC type where possible.
-Don't specify it unless the driver-specific documentation recommends that you
-do.
-.TP 7
-.BI "DacSpeed " speed
-.TP 7
-.BI "DacSpeed " "speed\-8 speed\-16 speed\-24 speed\-32"
-This optional entry specifies the RAMDAC speed rating (which is usually
-printed on the RAMDAC chip).
-The speed is in MHz.
-When one value is given, it applies to all framebuffer pixel sizes.
-When multiple values are given, they apply to the framebuffer pixel sizes
-8, 16, 24 and 32 respectively.
-This is not used by many drivers, and only needs to be specified when the
-speed rating of the RAMDAC is different from the defaults built in to
-driver, or when the driver can't auto-detect the correct defaults.
-Don't specify it unless the driver-specific documentation recommends that you
-do.
-.TP 7
-.BI "Clocks " "clock ..."
-specifies the pixel that are on your graphics board.
-The clocks are in MHz, and may be specified as a floating point number.
-The value is stored internally to the nearest kHz.
-The ordering of the clocks is important.
-It must match the order in which they are selected on the graphics board.
-Multiple
-.B Clocks
-lines may be specified, and each is concatenated to form the list.
-Most drivers do not use this entry, and it is only required for some older
-boards with non-programmable clocks.
-Don't specify this entry unless the driver-specific documentation explicitly
-recommends that you do.
-.TP
-.BI "ClockChip \*q" clockchip\-type \*q
-This optional entry is used to specify the clock chip type on graphics
-boards which have a programmable clock generator.
-Only a few __xservername__ drivers support programmable clock chips.
-For details, see the appropriate driver manual page.
-.TP 7
-.BI "VideoRam " "mem"
-This optional entry specifies the amount of video ram that is installed
-on the graphics board.
-This is measured in kBytes.
-In most cases this is not required because the __xservername__ server probes
-the graphics board to determine this quantity.
-The driver-specific documentation should indicate when it might be needed.
-.TP 7
-.BI "BiosBase " "baseaddress"
-This optional entry specifies the base address of the video BIOS for
-the VGA board.
-This address is normally auto-detected, and should only be specified if the
-driver-specific documentation recommends it.
-.TP 7
-.BI "MemBase " "baseaddress"
-This optional entry specifies the memory base address of a graphics
-board's linear frame buffer.
-This entry is not used by many drivers, and it should only be specified if
-the driver-specific documentation recommends it.
-.TP 7
-.BI "IOBase " "baseaddress"
-This optional entry specifies the IO base address.
-This entry is not used by many drivers, and it should only be specified if
-the driver-specific documentation recommends it.
-.TP 7
-.BI "ChipID " "id"
-This optional entry specifies a numerical ID representing the chip type.
-For PCI cards, it is usually the device ID.
-This can be used to override the auto-detection, but that should only be done
-when the driver-specific documentation recommends it.
-.TP 7
-.BI "ChipRev " "rev"
-This optional entry specifies the chip revision number.
-This can be used to override the auto-detection, but that should only be done
-when the driver-specific documentation recommends it.
-.TP 7
-.BI "TextClockFreq " "freq"
-This optional entry specifies the pixel clock frequency that is used
-for the regular text mode.
-The frequency is specified in MHz.
-This is rarely used.
-.TP 7
-.BI "Option \*qModeDebug\*q \*q" boolean \*q
-Enable printing of additional debugging information about modesetting to
-the server log.
-.ig
-.TP 7
-This optional entry allows an IRQ number to be specified.
-..
-.TP 7
-.B Options
-Option flags may be specified in the
-.B Device
-sections.
-These include driver\-specific options and driver\-independent options.
-The former are described in the driver\-specific documentation.
-Some of the latter are described below in the section about the
-.B Screen
-section, and they may also be included here.
-
-.SH "VIDEOADAPTOR SECTION"
-Nobody wants to say how this works.
-Maybe nobody knows ...
-
-.SH "MONITOR SECTION"
-The config file may have multiple
-.B Monitor
-sections.
-There should normally be at least one, for the monitor being used,
-but a default configuration will be created when one isn't specified.
-.PP
-.B Monitor
-sections have the following format:
-.PP
-.RS 4
-.nf
-.B "Section \*qMonitor\*q"
-.BI " Identifier \*q" name \*q
-.I " entries"
-.I " ..."
-.B "EndSection"
-.fi
-.RE
-.PP
-The only mandatory entry in a
-.B Monitor
-section is the
-.B Identifier
-entry.
-.PP
-The
-.B Identifier
-entry specifies the unique name for this monitor.
-The
-.B Monitor
-section may be used to provide information about the specifications of the
-monitor, monitor-specific
-.BR Options ,
-and information about the video modes to use with the monitor.
-.PP
-With RandR 1.2-enabled drivers, monitor sections may be tied to specific
-outputs of the video card. Using the name of the output defined by the video
-driver plus the identifier of a monitor section, one associates a monitor
-section with an output by adding an option to the Device section in the
-following format:
-
-.B Option \*qMonitor-outputname\*q \*qmonitorsection\*q
-
-(for example,
-.B Option \*qMonitor-VGA\*q \*qVGA monitor\*q
-for a VGA output)
-.PP
-In the absence of specific association of monitor sections to outputs, if a
-monitor section is present the server will associate it with an output to
-preserve compatibility for previous single-head configurations.
-.PP
-Specifying video modes is optional because the server will use the DDC or other
-information provided by the monitor to automatically configure the list of
-modes available.
-When modes are specified explicitly in the
-.B Monitor
-section (with the
-.BR Modes ,
-.BR ModeLine ,
-or
-.B UseModes
-keywords), built-in modes with the same names are not included.
-Built-in modes with different names are, however, still implicitly included,
-when they meet the requirements of the monitor.
-.PP
-The entries that may be used in
-.B Monitor
-sections are described below.
-.TP 7
-.BI "VendorName \*q" vendor \*q
-This optional entry specifies the monitor's manufacturer.
-.TP 7
-.BI "ModelName \*q" model \*q
-This optional entry specifies the monitor's model.
-.TP 7
-.BI "HorizSync " "horizsync\-range"
-gives the range(s) of horizontal sync frequencies supported by the
-monitor.
-.I horizsync\-range
-may be a comma separated list of either discrete values or ranges of
-values.
-A range of values is two values separated by a dash.
-By default the values are in units of kHz.
-They may be specified in MHz or Hz
-if
-.B MHz
-or
-.B Hz
-is added to the end of the line.
-The data given here is used by the __xservername__ server to determine if video
-modes are within the specifications of the monitor.
-This information should be available in the monitor's handbook.
-If this entry is omitted, a default range of 28\-33kHz is used.
-.TP 7
-.BI "VertRefresh " "vertrefresh\-range"
-gives the range(s) of vertical refresh frequencies supported by the
-monitor.
-.I vertrefresh\-range
-may be a comma separated list of either discrete values or ranges of
-values.
-A range of values is two values separated by a dash.
-By default the values are in units of Hz.
-They may be specified in MHz or kHz
-if
-.B MHz
-or
-.B kHz
-is added to the end of the line.
-The data given here is used by the __xservername__ server to determine if video
-modes are within the specifications of the monitor.
-This information should be available in the monitor's handbook.
-If this entry is omitted, a default range of 43\-72Hz is used.
-.TP 7
-.BI "DisplaySize " "width height"
-This optional entry gives the width and height, in millimetres, of the
-picture area of the monitor.
-If given this is used to calculate the horizontal and vertical pitch (DPI) of
-the screen.
-.TP 7
-.BI "Gamma " "gamma\-value"
-.TP 7
-.BI "Gamma " "red\-gamma green\-gamma blue\-gamma"
-This is an optional entry that can be used to specify the gamma correction
-for the monitor.
-It may be specified as either a single value or as three separate RGB values.
-The values should be in the range 0.1 to 10.0, and the default is 1.0.
-Not all drivers are capable of using this information.
-.TP 7
-.BI "UseModes \*q" modesection\-id \*q
-Include the set of modes listed in the
-.B Modes
-section called
-.IR modesection\-id.
-This makes all of the modes defined in that section available for use by
-this monitor.
-.TP 7
-.BI "Mode \*q" name \*q
-This is an optional multi-line entry that can be used to provide
-definitions for video modes for the monitor.
-In most cases this isn't necessary because the built-in set of VESA standard
-modes will be sufficient.
-The
-.B Mode
-keyword indicates the start of a multi-line video mode description.
-The mode description is terminated with the
-.B EndMode
-keyword.
-The mode description consists of the following entries:
-.RS 7
-.TP 4
-.BI "DotClock " clock
-is the dot (pixel) clock rate to be used for the mode.
-.TP 4
-.BI "HTimings " "hdisp hsyncstart hsyncend htotal"
-specifies the horizontal timings for the mode.
-.TP 4
-.BI "VTimings " "vdisp vsyncstart vsyncend vtotal"
-specifies the vertical timings for the mode.
-.TP 4
-.BI "Flags \*q" flag \*q " ..."
-specifies an optional set of mode flags, each of which is a separate
-string in double quotes.
-.B \*qInterlace\*q
-indicates that the mode is interlaced.
-.B \*qDoubleScan\*q
-indicates a mode where each scanline is doubled.
-.B \*q+HSync\*q
-and
-.B \*q\-HSync\*q
-can be used to select the polarity of the HSync signal.
-.B \*q+VSync\*q
-and
-.B \*q\-VSync\*q
-can be used to select the polarity of the VSync signal.
-.B \*qComposite\*q
-can be used to specify composite sync on hardware where this is supported.
-Additionally, on some hardware,
-.B \*q+CSync\*q
-and
-.B \*q\-CSync\*q
-may be used to select the composite sync polarity.
-.TP 4
-.BI "HSkew " hskew
-specifies the number of pixels (towards the right edge of the screen) by
-which the display enable signal is to be skewed.
-Not all drivers use this information.
-This option might become necessary to override the default value supplied
-by the server (if any).
-\(lqRoving\(rq horizontal lines indicate this value needs to be increased.
-If the last few pixels on a scan line appear on the left of the screen,
-this value should be decreased.
-.TP 4
-.BI "VScan " vscan
-specifies the number of times each scanline is painted on the screen.
-Not all drivers use this information.
-Values less than 1 are treated as 1, which is the default.
-Generally, the
-.B \*qDoubleScan\*q
-.B Flag
-mentioned above doubles this value.
-.RE
-.TP 7
-.BI "ModeLine \*q" name \*q " mode\-description"
-This entry is a more compact version of the
-.B Mode
-entry, and it also can be used to specify video modes for the monitor.
-is a single line format for specifying video modes.
-In most cases this isn't necessary because the built\-in set of VESA
-standard modes will be sufficient.
-.PP
-.RS 7
-The
-.I mode\-description
-is in four sections, the first three of which are mandatory.
-The first is the dot (pixel) clock.
-This is a single number specifying the pixel clock rate for the mode in
-MHz.
-The second section is a list of four numbers specifying the horizontal
-timings.
-These numbers are the
-.IR hdisp ,
-.IR hsyncstart ,
-.IR hsyncend ,
-and
-.I htotal
-values.
-The third section is a list of four numbers specifying the vertical
-timings.
-These numbers are the
-.IR vdisp ,
-.IR vsyncstart ,
-.IR vsyncend ,
-and
-.I vtotal
-values.
-The final section is a list of flags specifying other characteristics of
-the mode.
-.B Interlace
-indicates that the mode is interlaced.
-.B DoubleScan
-indicates a mode where each scanline is doubled.
-.B +HSync
-and
-.B \-HSync
-can be used to select the polarity of the HSync signal.
-.B +VSync
-and
-.B \-VSync
-can be used to select the polarity of the VSync signal.
-.B Composite
-can be used to specify composite sync on hardware where this is supported.
-Additionally, on some hardware,
-.B +CSync
-and
-.B \-CSync
-may be used to select the composite sync polarity.
-The
-.B HSkew
-and
-.B VScan
-options mentioned above in the
-.B Modes
-entry description can also be used here.
-.RE
-.TP 7
-.BI "Option " "\*qDPMS\*q " \*qbool\*q
-This option controls whether the server should enable the DPMS extension
-for power management for this screen. The default is to enable the
-extension.
-.TP 7
-.BI "Option " "\*qSyncOnGreen\*q " \*qbool\*q
-This option controls whether the video card should drive the sync signal
-on the green color pin. Not all cards support this option, and most
-monitors do not require it. The default is off.
-.TP 7
-.BI "Option " "\*qPrimary\*q " \*qbool\*q
-This optional entry specifies that the monitor should be treated as the primary
-monitor. (RandR 1.2-supporting drivers only)
-.TP 7
-.BI "Option " "\*qPreferredMode\*q " \*qstring\*q
-This optional entry specifies a mode to be marked as the preferred initial mode
-of the monitor.
-(RandR 1.2-supporting drivers only)
-.TP 7
-.BI "Option " "\*qPosition\*q " "\*qx y\*q"
-This optional entry specifies the position of the monitor within the X
-screen.
-(RandR 1.2-supporting drivers only)
-.TP 7
-.BI "Option " "\*qLeftOf\*q " \*qoutput\*q
-This optional entry specifies that the monitor should be positioned to the
-left of the output (not monitor) of the given name.
-(RandR 1.2-supporting drivers only)
-.TP 7
-.BI "Option " "\*qRightOf\*q " \*qoutput\*q
-This optional entry specifies that the monitor should be positioned to the
-right of the output (not monitor) of the given name.
-(RandR 1.2-supporting drivers only)
-.TP 7
-.BI "Option " "\*qAbove\*q " \*qoutput\*q
-This optional entry specifies that the monitor should be positioned above the
-output (not monitor) of the given name.
-(RandR 1.2-supporting drivers only)
-.TP 7
-.BI "Option " "\*qBelow\*q " \*qoutput\*q
-This optional entry specifies that the monitor should be positioned below the
-output (not monitor) of the given name.
-(RandR 1.2-supporting drivers only)
-.TP 7
-.BI "Option " "\*qEnable\*q " \*qbool\*q
-This optional entry specifies whether the monitor should be turned on
-at startup. By default, the server will attempt to enable all connected
-monitors.
-(RandR 1.2-supporting drivers only)
-.TP 7
-.BI "Option " "\*qDefaultModes\*q " \*qbool\*q
-This optional entry specifies whether the server should add supported default
-modes to the list of modes offered on this monitor. By default, the server
-will add default modes; you should only disable this if you can guarantee
-that EDID will be available at all times, or if you have added custom modelines
-which the server can use.
-(RandR 1.2-supporting drivers only)
-.TP 7
-.BI "Option " "\*qMinClock\*q " \*qfrequency\*q
-This optional entry specifies the minimum dot clock, in kHz, that is supported
-by the monitor.
-.TP 7
-.BI "Option " "\*qMaxClock\*q " \*qfrequency\*q
-This optional entry specifies the maximum dot clock, in kHz, that is supported
-by the monitor.
-.TP 7
-.BI "Option " "\*qIgnore\*q " \*qbool\*q
-This optional entry specifies that the monitor should be ignored entirely,
-and not reported through RandR. This is useful if the hardware reports the
-presence of outputs that don't exist.
-(RandR 1.2-supporting drivers only)
-.TP 7
-.BI "Option " "\*qRotate\*q " \*qrotation\*q
-This optional entry specifies the initial rotation of the given monitor.
-Valid values for rotation are \*qnormal\*q, \*qleft\*q, \*qright\*q, and
-\*qinverted\*q.
-(RandR 1.2-supporting drivers only)
-
-.SH "MODES SECTION"
-The config file may have multiple
-.B Modes
-sections, or none.
-These sections provide a way of defining sets of video modes independently
-of the
-.B Monitor
-sections.
-.B Monitor
-sections may include the definitions provided in these sections by
-using the
-.B UseModes
-keyword.
-In most cases the
-.B Modes
-sections are not necessary because the built\-in set of VESA standard modes
-will be sufficient.
-.PP
-.B Modes
-sections have the following format:
-.PP
-.RS 4
-.nf
-.B "Section \*qModes\*q"
-.BI " Identifier \*q" name \*q
-.I " entries"
-.I " ..."
-.B "EndSection"
-.fi
-.RE
-.PP
-The
-.B Identifier
-entry specifies the unique name for this set of mode descriptions.
-The other entries permitted in
-.B Modes
-sections are the
-.B Mode
-and
-.B ModeLine
-entries that are described above in the
-.B Monitor
-section.
-.SH "SCREEN SECTION"
-The config file may have multiple
-.B Screen
-sections.
-There must be at least one, for the \(lqscreen\(rq being used.
-A \(lqscreen\(rq represents the binding of a graphics device
-.RB ( Device
-section) and a monitor
-.RB ( Monitor
-section).
-A
-.B Screen
-section is considered \(lqactive\(rq if it is referenced by an active
-.B ServerLayout
-section or by the
-.B \-screen
-command line option.
-If neither of those is present, the first
-.B Screen
-section found in the config file is considered the active one.
-.PP
-.B Screen
-sections have the following format:
-.PP
-.RS 4
-.nf
-.B "Section \*qScreen\*q"
-.BI " Identifier \*q" name \*q
-.BI " Device \*q" devid \*q
-.BI " Monitor \*q" monid \*q
-.I " entries"
-.I " ..."
-.BI " SubSection \*qDisplay\*q"
-.I " entries"
-.I " ...
-.B " EndSubSection"
-.I " ..."
-.B "EndSection"
-.fi
-.RE
-.PP
-The
-.B Identifier
-and
-.B Device
-entries are mandatory.
-All others are optional.
-.PP
-The
-.B Identifier
-entry specifies the unique name for this screen.
-The
-.B Screen
-section provides information specific to the whole screen, including
-screen\-specific
-.BR Options .
-In multi\-head configurations, there will be multiple active
-.B Screen
-sections, one for each head.
-The entries available
-for this section are:
-.TP 7
-.BI "Device \*q" device\-id \*q
-This mandatory entry specifies the
-.B Device
-section to be used for this screen.
-This is what ties a specific graphics card to a screen.
-The
-.I device\-id
-must match the
-.B Identifier
-of a
-.B Device
-section in the config file.
-.TP 7
-.BI "Monitor \*q" monitor\-id \*q
-specifies which monitor description is to be used for this screen.
-If a
-.B Monitor
-name is not specified, a default configuration is used.
-Currently the default configuration may not function as expected on all
-platforms.
-.TP 7
-.BI "VideoAdaptor \*q" xv\-id \*q
-specifies an optional Xv video adaptor description to be used with this
-screen.
-.TP 7
-.BI "DefaultDepth " depth
-specifies which color depth the server should use by default.
-The
-.B \-depth
-command line option can be used to override this.
-If neither is specified, the default depth is driver\-specific, but in most
-cases is 8.
-.TP 7
-.BI "DefaultFbBpp " bpp
-specifies which framebuffer layout to use by default.
-The
-.B \-fbbpp
-command line option can be used to override this.
-In most cases the driver will chose the best default value for this.
-The only case where there is even a choice in this value is for depth 24,
-where some hardware supports both a packed 24 bit framebuffer layout and a
-sparse 32 bit framebuffer layout.
-.TP 7
-.B Options
-Various
-.B Option
-flags may be specified in the
-.B Screen
-section.
-Some are driver\-specific and are described in the driver documentation.
-Others are driver\-independent, and will eventually be described here.
-.\" XXX These should really be in an xaa man page.
-.TP 7
-.BI "Option \*qAccel\*q"
-Enables XAA (X Acceleration Architecture), a mechanism that makes video cards'
-2D hardware acceleration available to the __xservername__ server.
-This option is on by default, but it may be necessary to turn it off if
-there are bugs in the driver.
-There are many options to disable specific accelerated operations, listed
-below.
-Note that disabling an operation will have no effect if the operation is
-not accelerated (whether due to lack of support in the hardware or in the
-driver).
-.TP 7
-.BI "Option \*qInitPrimary\*q \*q" boolean \*q
-Use the Int10 module to initialize the primary graphics card.
-Normally, only secondary cards are soft-booted using the Int10 module, as the
-primary card has already been initialized by the BIOS at boot time.
-Default: false.
-.TP 7
-.BI "Option \*qNoInt10\*q \*q" boolean \*q
-Disables the Int10 module, a module that uses the int10 call to the BIOS
-of the graphics card to initialize it.
-Default: false.
-.TP 7
-.BI "Option \*qNoMTRR\*q"
-Disables MTRR (Memory Type Range Register) support, a feature of modern
-processors which can improve video performance by a factor of up to 2.5.
-Some hardware has buggy MTRR support, and some video drivers have been
-known to exhibit problems when MTRR's are used.
-.TP 7
-.BI "Option \*qXaaNoCPUToScreenColorExpandFill\*q"
-Disables accelerated rectangular expansion blits from source patterns
-stored in system memory (using a memory\-mapped aperture).
-.TP 7
-.BI "Option \*qXaaNoColor8x8PatternFillRect\*q"
-Disables accelerated fills of a rectangular region with a full\-color
-pattern.
-.TP 7
-.BI "Option \*qXaaNoColor8x8PatternFillTrap\*q"
-Disables accelerated fills of a trapezoidal region with a full\-color
-pattern.
-.TP 7
-.BI "Option \*qXaaNoDashedBresenhamLine\*q"
-Disables accelerated dashed Bresenham line draws.
-.TP 7
-.BI "Option \*qXaaNoDashedTwoPointLine\*q"
-Disables accelerated dashed line draws between two arbitrary points.
-.TP 7
-.BI "Option \*qXaaNoImageWriteRect\*q"
-Disables accelerated transfers of full\-color rectangular patterns from
-system memory to video memory (using a memory\-mapped aperture).
-.TP 7
-.BI "Option \*qXaaNoMono8x8PatternFillRect\*q"
-Disables accelerated fills of a rectangular region with a monochrome
-pattern.
-.TP 7
-.BI "Option \*qXaaNoMono8x8PatternFillTrap\*q"
-Disables accelerated fills of a trapezoidal region with a monochrome
-pattern.
-.TP 7
-.BI "Option \*qXaaNoOffscreenPixmaps\*q"
-Disables accelerated draws into pixmaps stored in offscreen video memory.
-.TP 7
-.BI "Option \*qXaaNoPixmapCache\*q"
-Disables caching of patterns in offscreen video memory.
-.TP 7
-.BI "Option \*qXaaNoScanlineCPUToScreenColorExpandFill\*q"
-Disables accelerated rectangular expansion blits from source patterns
-stored in system memory (one scan line at a time).
-.TP 7
-.BI "Option \*qXaaNoScanlineImageWriteRect\*q"
-Disables accelerated transfers of full\-color rectangular patterns from
-system memory to video memory (one scan line at a time).
-.TP 7
-.BI "Option \*qXaaNoScreenToScreenColorExpandFill\*q"
-Disables accelerated rectangular expansion blits from source patterns
-stored in offscreen video memory.
-.TP 7
-.BI "Option \*qXaaNoScreenToScreenCopy\*q"
-Disables accelerated copies of rectangular regions from one part of
-video memory to another part of video memory.
-.TP 7
-.BI "Option \*qXaaNoSolidBresenhamLine\*q"
-Disables accelerated solid Bresenham line draws.
-.TP 7
-.BI "Option \*qXaaNoSolidFillRect\*q"
-Disables accelerated solid\-color fills of rectangles.
-.TP 7
-.BI "Option \*qXaaNoSolidFillTrap\*q"
-Disables accelerated solid\-color fills of Bresenham trapezoids.
-.TP 7
-.BI "Option \*qXaaNoSolidHorVertLine\*q"
-Disables accelerated solid horizontal and vertical line draws.
-.TP 7
-.BI "Option \*qXaaNoSolidTwoPointLine\*q"
-Disables accelerated solid line draws between two arbitrary points.
-.PP
-Each
-.B Screen
-section may optionally contain one or more
-.B Display
-subsections.
-Those subsections provide depth/fbbpp specific configuration information,
-and the one chosen depends on the depth and/or fbbpp that is being used for
-the screen.
-The
-.B Display
-subsection format is described in the section below.
-
-.SH "DISPLAY SUBSECTION"
-Each
-.B Screen
-section may have multiple
-.B Display
-subsections.
-The \(lqactive\(rq
-.B Display
-subsection is the first that matches the depth and/or fbbpp values being
-used, or failing that, the first that has neither a depth or fbbpp value
-specified.
-The
-.B Display
-subsections are optional.
-When there isn't one that matches the depth and/or fbbpp values being used,
-all the parameters that can be specified here fall back to their defaults.
-.PP
-.B Display
-subsections have the following format:
-.PP
-.RS 4
-.nf
-.B " SubSection \*qDisplay\*q"
-.BI " Depth " depth
-.I " entries"
-.I " ..."
-.B " EndSubSection"
-.fi
-.RE
-.TP 7
-.BI "Depth " depth
-This entry specifies what colour depth the
-.B Display
-subsection is to be used for.
-This entry is usually specified, but it may be omitted to create a match\-all
-.B Display
-subsection or when wishing to match only against the
-.B FbBpp
-parameter.
-The range of
-.I depth
-values that are allowed depends on the driver.
-Most drivers support 8, 15, 16 and 24.
-Some also support 1 and/or 4, and some may support other values (like 30).
-Note:
-.I depth
-means the number of bits in a pixel that are actually used to determine
-the pixel colour.
-32 is not a valid
-.I depth
-value.
-Most hardware that uses 32 bits per pixel only uses 24 of them to hold the
-colour information, which means that the colour depth is 24, not 32.
-.TP 7
-.BI "FbBpp " bpp
-This entry specifies the framebuffer format this
-.B Display
-subsection is to be used for.
-This entry is only needed when providing depth 24 configurations that allow
-a choice between a 24 bpp packed framebuffer format and a 32bpp sparse
-framebuffer format.
-In most cases this entry should not be used.
-.TP 7
-.BI "Weight " "red\-weight green\-weight blue\-weight"
-This optional entry specifies the relative RGB weighting to be used
-for a screen is being used at depth 16 for drivers that allow multiple
-formats.
-This may also be specified from the command line with the
-.B \-weight
-option (see
-.BR __xservername__(__appmansuffix__)).
-.TP 7
-.BI "Virtual " "xdim ydim"
-This optional entry specifies the virtual screen resolution to be used.
-.I xdim
-must be a multiple of either 8 or 16 for most drivers, and a multiple
-of 32 when running in monochrome mode.
-The given value will be rounded down if this is not the case.
-Video modes which are too large for the specified virtual size will be
-rejected.
-If this entry is not present, the virtual screen resolution will be set to
-accommodate all the valid video modes given in the
-.B Modes
-entry.
-Some drivers/hardware combinations do not support virtual screens.
-Refer to the appropriate driver\-specific documentation for details.
-.TP 7
-.BI "ViewPort " "x0 y0"
-This optional entry sets the upper left corner of the initial display.
-This is only relevant when the virtual screen resolution is different
-from the resolution of the initial video mode.
-If this entry is not given, then the initial display will be centered in
-the virtual display area.
-.TP 7
-.BI "Modes \*q" mode\-name \*q " ..."
-This optional entry specifies the list of video modes to use.
-Each
-.I mode\-name
-specified must be in double quotes.
-They must correspond to those specified or referenced in the appropriate
-.B Monitor
-section (including implicitly referenced built\-in VESA standard modes).
-The server will delete modes from this list which don't satisfy various
-requirements.
-The first valid mode in this list will be the default display mode for
-startup.
-The list of valid modes is converted internally into a circular list.
-It is possible to switch to the next mode with
-.B Ctrl+Alt+Keypad\-Plus
-and to the previous mode with
-.BR Ctrl+Alt+Keypad\-Minus .
-When this entry is omitted, the valid modes referenced by the appropriate
-.B Monitor
-section will be used. If the
-.B Monitor
-section contains no modes, then the selection will be taken from the
-built-in VESA standard modes.
-.TP 7
-.BI "Visual \*q" visual\-name \*q
-This optional entry sets the default root visual type.
-This may also be specified from the command line (see the
-.BR Xserver(__appmansuffix__)
-man page).
-The visual types available for depth 8 are (default is
-.BR PseudoColor ):
-.PP
-.RS 11
-.nf
-.B StaticGray
-.B GrayScale
-.B StaticColor
-.B PseudoColor
-.B TrueColor
-.B DirectColor
-.fi
-.RE
-.PP
-.RS 7
-The visual type available for the depths 15, 16 and 24 are (default is
-.BR TrueColor ):
-.PP
-.RS 4
-.nf
-.B TrueColor
-.B DirectColor
-.fi
-.RE
-.PP
-Not all drivers support
-.B DirectColor
-at these depths.
-.PP
-The visual types available for the depth 4 are (default is
-.BR StaticColor ):
-.PP
-.RS 4
-.nf
-.B StaticGray
-.B GrayScale
-.B StaticColor
-.B PseudoColor
-.fi
-.RE
-.PP
-The visual type available for the depth 1 (monochrome) is
-.BR StaticGray .
-.RE
-.TP 7
-.BI "Black " "red green blue"
-This optional entry allows the \(lqblack\(rq colour to be specified.
-This is only supported at depth 1.
-The default is black.
-.TP 7
-.BI "White " "red green blue"
-This optional entry allows the \(lqwhite\(rq colour to be specified.
-This is only supported at depth 1.
-The default is white.
-.TP 7
-.B Options
-Option flags may be specified in the
-.B Display
-subsections.
-These may include driver\-specific options and driver\-independent options.
-The former are described in the driver\-specific documentation.
-Some of the latter are described above in the section about the
-.B Screen
-section, and they may also be included here.
-.SH "SERVERLAYOUT SECTION"
-The config file may have multiple
-.B ServerLayout
-sections.
-A \(lqserver layout\(rq represents the binding of one or more screens
-.RB ( Screen
-sections) and one or more input devices
-.RB ( InputDevice
-sections) to form a complete configuration.
-In multi\-head configurations, it also specifies the relative layout of the
-heads.
-A
-.B ServerLayout
-section is considered \(lqactive\(rq if it is referenced by the
-.B \-layout
-command line option or by an
-.B "Option \*qDefaultServerLayout\*q"
-entry in the
-.B ServerFlags
-section (the former takes precedence over the latter).
-If those options are not used, the first
-.B ServerLayout
-section found in the config file is considered the active one.
-If no
-.B ServerLayout
-sections are present, the single active screen and two active (core)
-input devices are selected as described in the relevant sections above.
-.PP
-.B ServerLayout
-sections have the following format:
-.PP
-.RS 4
-.nf
-.B "Section \*qServerLayout\*q"
-.BI " Identifier \*q" name \*q
-.BI " Screen \*q" screen\-id \*q
-.I " ..."
-.BI " InputDevice \*q" idev\-id \*q
-.I " ..."
-.I " options"
-.I " ..."
-.B "EndSection"
-.fi
-.RE
-.PP
-Each
-.B ServerLayout
-section must have an
-.B Identifier
-entry and at least one
-.B Screen
-entry.
-.PP
-The
-.B Identifier
-entry specifies the unique name for this server layout.
-The
-.B ServerLayout
-section provides information specific to the whole session, including
-session\-specific
-.BR Options .
-The
-.B ServerFlags
-options (described above) may be specified here, and ones given here
-override those given in the
-.B ServerFlags
-section.
-.PP
-The entries that may be used in this section are described here.
-.TP 7
-.BI "Screen " "screen\-num" " \*qscreen\-id\*q " "position\-information"
-One of these entries must be given for each screen being used in
-a session.
-The
-.I screen\-id
-field is mandatory, and specifies the
-.B Screen
-section being referenced.
-The
-.I screen\-num
-field is optional, and may be used to specify the screen number
-in multi\-head configurations.
-When this field is omitted, the screens will be numbered in the order that
-they are listed in.
-The numbering starts from 0, and must be consecutive.
-The
-.I position\-information
-field describes the way multiple screens are positioned.
-There are a number of different ways that this information can be provided:
-.RS 7
-.TP 4
-.I "x y"
-.TP 4
-.BI "Absolute " "x y"
-These both specify that the upper left corner's coordinates are
-.RI ( x , y ).
-The
-.B Absolute
-keyword is optional.
-Some older versions of XFree86 (4.2 and earlier) don't recognise the
-.B Absolute
-keyword, so it's safest to just specify the coordinates without it.
-.TP 4
-.BI "RightOf \*q" screen\-id \*q
-.TP 4
-.BI "LeftOf \*q" screen\-id \*q
-.TP 4
-.BI "Above \*q" screen\-id \*q
-.TP 4
-.BI "Below \*q" screen\-id \*q
-.TP 4
-.BI "Relative \*q" screen\-id \*q " x y"
-These give the screen's location relative to another screen.
-The first four position the screen immediately to the right, left, above or
-below the other screen.
-When positioning to the right or left, the top edges are aligned.
-When positioning above or below, the left edges are aligned.
-The
-.B Relative
-form specifies the offset of the screen's origin (upper left corner)
-relative to the origin of another screen.
-.RE
-.TP 7
-.BI "InputDevice \*q" idev\-id "\*q \*q" option \*q " ..."
-One of these entries should be given for each input device being used in
-a session.
-Normally at least two are required, one each for the core pointer and
-keyboard devices.
-If either of those is missing, suitable
-.B InputDevice
-entries are searched for using the method described above in the
-.B INPUTDEVICE
-section. The
-.I idev\-id
-field is mandatory, and specifies the name of the
-.B InputDevice
-section being referenced.
-Multiple
-.I option
-fields may be specified, each in double quotes.
-The options permitted here are any that may also be given in the
-.B InputDevice
-sections.
-Normally only session\-specific input device options would be used here.
-The most commonly used options are:
-.PP
-.RS 11
-.nf
-.B \*qCorePointer\*q
-.B \*qCoreKeyboard\*q
-.B \*qSendCoreEvents\*q
-.fi
-.RE
-.PP
-.RS 7
-and the first two should normally be used to indicate the core pointer
-and core keyboard devices respectively.
-.RE
-.TP 7
-.B Options
-In addition to the following, any option permitted in the
-.B ServerFlags
-section may also be specified here.
-When the same option appears in both places, the value given here overrides
-the one given in the
-.B ServerFlags
-section.
-.TP 7
-.BI "Option \*qIsolateDevice\*q \*q" bus\-id \*q
-Restrict device resets to the specified
-.IR bus\-id .
-See the
-.B BusID
-option (described in
-.BR "DEVICE SECTION" ,
-above) for the format of the
-.I bus\-id
-parameter.
-This option overrides
-.BR SingleCard ,
-if specified.
-At present, only PCI devices can be isolated in this manner.
-.TP 7
-.BI "Option \*qSingleCard\*q \*q" boolean \*q
-As
-.BR IsolateDevice ,
-except that the bus ID of the first device in the layout is used.
-.PP
-Here is an example of a
-.B ServerLayout
-section for a dual headed configuration with two mice:
-.PP
-.RS 4
-.nf
-.B "Section \*qServerLayout\*q"
-.B " Identifier \*qLayout 1\*q"
-.B " Screen \*qMGA 1\*q"
-.B " Screen \*qMGA 2\*q RightOf \*qMGA 1\*q"
-.B " InputDevice \*qKeyboard 1\*q \*qCoreKeyboard\*q"
-.B " InputDevice \*qMouse 1\*q \*qCorePointer\*q"
-.B " InputDevice \*qMouse 2\*q \*qSendCoreEvents\*q"
-.B " Option \*qBlankTime\*q \*q5\*q"
-.B "EndSection"
-.fi
-.RE
-.SH "DRI SECTION"
-This optional section is used to provide some information for the
-Direct Rendering Infrastructure.
-Details about the format of this section can be found on-line at
-.IR <http://dri.freedesktop.org/> .
-.SH "VENDOR SECTION"
-The optional
-.B Vendor
-section may be used to provide vendor\-specific configuration information.
-Multiple
-.B Vendor
-sections may be present, and they may contain an
-.B Identifier
-entry and multiple
-.B Option
-flags.
-The data therein is not used in this release.
-.PP
-.SH "SEE ALSO"
-General:
-.BR X (__miscmansuffix__),
-.BR Xserver (__appmansuffix__),
-.BR __xservername__ (__appmansuffix__),
-.BR cvt (__appmansuffix__),
-.BR gtf (__appmansuffix__).
-.PP
-.B "Not all modules or interfaces are available on all platforms."
-.PP
-Display drivers:
-.BR apm (__drivermansuffix__),
-.BR ati (__drivermansuffix__),
-.BR chips (__drivermansuffix__),
-.BR cirrus (__drivermansuffix__),
-.BR cyrix (__drivermansuffix__),
-.BR fbdev (__drivermansuffix__),
-.BR glide (__drivermansuffix__),
-.BR glint (__drivermansuffix__),
-.BR i128 (__drivermansuffix__),
-.BR i740 (__drivermansuffix__),
-.BR imstt (__drivermansuffix__),
-.BR intel (__drivermansuffix__),
-.BR mga (__drivermansuffix__),
-.BR neomagic (__drivermansuffix__),
-.BR nv (__drivermansuffix__),
-.BR openchrome (__drivermansuffix__),
-.BR r128 (__drivermansuffix__),
-.BR radeon (__drivermansuffix__),
-.BR rendition (__drivermansuffix__),
-.BR savage (__drivermansuffix__),
-.BR s3virge (__drivermansuffix__),
-.BR siliconmotion (__drivermansuffix__),
-.BR sis (__drivermansuffix__),
-.BR sisusb (__drivermansuffix__),
-.BR sunbw2 (__drivermansuffix__),
-.BR suncg14 (__drivermansuffix__),
-.BR suncg3 (__drivermansuffix__),
-.BR suncg6 (__drivermansuffix__),
-.BR sunffb (__drivermansuffix__),
-.BR sunleo (__drivermansuffix__),
-.BR suntcx (__drivermansuffix__),
-.BR tdfx (__drivermansuffix__),
-.\" .BR tga (__drivermansuffix__),
-.BR trident (__drivermansuffix__),
-.BR tseng (__drivermansuffix__),
-.BR vesa (__drivermansuffix__),
-.BR vmware (__drivermansuffix__),
-.BR voodoo (__drivermansuffix__),
-.BR wsfb (__drivermansuffix__),
-.BR xgi (__drivermansuffix__),
-.BR xgixp (__drivermansuffix__).
-.PP
-Input drivers:
-.BR acecad (__drivermansuffix__),
-.BR citron (__drivermansuffix__),
-.BR elographics (__drivermansuffix__),
-.BR evdev (__drivermansuffix__),
-.BR fpit (__drivermansuffix__),
-.BR joystick (__drivermansuffix__),
-.BR kbd (__drivermansuffix__),
-.BR mousedrv (__drivermansuffix__),
-.BR mutouch (__drivermansuffix__),
-.BR penmount (__drivermansuffix__),
-.BR synaptics (__drivermansuffix__),
-.BR vmmouse (__drivermansuffix__),
-.BR void (__drivermansuffix__),
-.BR wacom (__drivermansuffix__).
-.PP
-Other modules and interfaces:
-.BR exa (__drivermansuffix__),
-.BR fbdevhw (__drivermansuffix__),
-.\" .BR shadowfb (__drivermansuffix__),
-.BR v4l (__drivermansuffix__).
-.br
-.SH AUTHORS
-This manual page was largely rewritten by David Dawes
-.IR <dawes@xfree86.org> .
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH __xconfigfile__ __filemansuffix__ __vendorversion__
+.SH NAME
+__xconfigfile__ and __xconfigdir__ \- configuration files for
+__xservername__ X server
+.SH INTRODUCTION
+.B __xservername__
+supports several mechanisms for supplying/obtaining configuration and
+run-time parameters: command line options, environment variables, the
+__xconfigfile__ and __xconfigdir__ configuration files, auto-detection,
+and fallback defaults. When the same information is supplied in more
+than one way, the highest precedence mechanism is used. The list of
+mechanisms is ordered from highest precedence to lowest. Note that not
+all parameters can be supplied via all methods. The available command
+line options and environment variables (and some defaults) are
+described in the Xserver(__appmansuffix__) and
+__xservername__(__appmansuffix__) manual pages. Most configuration file
+parameters, with their defaults, are described below. Driver and module
+specific configuration parameters are described in the relevant driver
+or module manual page.
+.SH DESCRIPTION
+.B __xservername__
+uses a configuration file called
+.I __xconfigfile__
+and files ending in the suffix
+.I .conf
+from the directory
+.I __xconfigdir__
+for its initial setup.
+The
+.I __xconfigfile__
+configuration file is searched for in the following places when the
+server is started as a normal user:
+.PP
+.RS 4
+.nf
+.IR /etc/X11/ <cmdline>
+.IR __projectroot__/etc/X11/ <cmdline>
+.IB /etc/X11/ $XORGCONFIG
+.IB __projectroot__/etc/X11/ $XORGCONFIG
+.I /etc/X11/__xconfigfile__
+.I /etc/__xconfigfile__
+.IR __projectroot__/etc/X11/__xconfigfile__. <hostname>
+.I __projectroot__/etc/X11/__xconfigfile__
+.IR __projectroot__/lib/X11/__xconfigfile__. <hostname>
+.I __projectroot__/lib/X11/__xconfigfile__
+.fi
+.RE
+.PP
+where
+.I <cmdline>
+is a relative path (with no \(lq..\(rq components) specified with the
+.B \-config
+command line option,
+.B $XORGCONFIG
+is the relative path (with no \(lq..\(rq components) specified by that
+environment variable, and
+.I <hostname>
+is the machine's hostname as reported by
+.BR gethostname (__libmansuffix__).
+.PP
+When the __xservername__ server is started by the \(lqroot\(rq user, the config file
+search locations are as follows:
+.PP
+.RS 4
+.nf
+<cmdline>
+.IR /etc/X11/ <cmdline>
+.IR __projectroot__/etc/X11/ <cmdline>
+.B $XORGCONFIG
+.IB /etc/X11/ $XORGCONFIG
+.IB __projectroot__/etc/X11/ $XORGCONFIG
+.I /etc/X11/__xconfigfile__
+.I /etc/__xconfigfile__
+.IR __projectroot__/etc/X11/__xconfigfile__. <hostname>
+.I __projectroot__/etc/X11/__xconfigfile__
+.IR __projectroot__/lib/X11/__xconfigfile__. <hostname>
+.I __projectroot__/lib/X11/__xconfigfile__
+.fi
+.RE
+.PP
+where
+.I <cmdline>
+is the path specified with the
+.B \-config
+command line option (which may be absolute or relative),
+.B $XORGCONFIG
+is the path specified by that
+environment variable (absolute or relative),
+.B $HOME
+is the path specified by that environment variable (usually the home
+directory), and
+.I <hostname>
+is the machine's hostname as reported by
+.BR gethostname (__libmansuffix__).
+.PP
+Additional configuration files are searched for in the following
+directories when the server is started as a normal user:
+.PP
+.RS 4
+.nf
+.IR /etc/X11/ <cmdline>
+.IR __sysconfdir__/X11/ <cmdline>
+.I /etc/X11/__xconfigdir__
+.I __sysconfdir__/X11/__xconfigdir__
+.fi
+.RE
+.PP
+where
+.I <cmdline>
+is a relative path (with no \(lq..\(rq components) specified with the
+.B \-configdir
+command line option.
+.PP
+When the __xservername__ server is started by the \(lqroot\(rq user, the
+config directory search locations are as follows:
+.PP
+.RS 4
+.nf
+<cmdline>
+.IR /etc/X11/ <cmdline>
+.IR __sysconfdir__/X11/ <cmdline>
+.I /etc/X11/__xconfigdir__
+.I __sysconfdir__/X11/__xconfigdir__
+.fi
+.RE
+.PP
+where
+.I <cmdline>
+is the path specified with the
+.B \-configdir
+command line option (which may be absolute or relative).
+.PP
+Finally, configuration files will also be searched for in directories
+reserved for system use. These are to separate configuration files from
+the vendor or 3rd party packages from those of local administration.
+These files are found in the following directories:
+.PP
+.RS 4
+.nf
+.I /usr/share/X11/__xconfigdir__
+.I __datadir__/X11/__xconfigdir__
+.fi
+.RE
+.PP
+The
+.I __xconfigfile__
+and
+.I __xconfigdir__
+files are composed of a number of sections which may be present in any order,
+or omitted to use default configuration values.
+Each section has the form:
+.PP
+.RS 4
+.nf
+.BI "Section \*q" SectionName \*q
+.RI " " SectionEntry
+ ...
+.B EndSection
+.fi
+.RE
+.PP
+The section names are:
+.PP
+.RS 4
+.nf
+.BR "Files " "File pathnames"
+.BR "ServerFlags " "Server flags"
+.BR "Module " "Dynamic module loading"
+.BR "Extensions " "Extension enabling"
+.BR "InputDevice " "Input device description"
+.BR "InputClass " "Input class description"
+.BR "Device " "Graphics device description"
+.BR "VideoAdaptor " "Xv video adaptor description"
+.BR "Monitor " "Monitor description"
+.BR "Modes " "Video modes descriptions"
+.BR "Screen " "Screen configuration"
+.BR "ServerLayout " "Overall layout"
+.BR "DRI " "DRI\-specific configuration"
+.BR "Vendor " "Vendor\-specific configuration"
+.fi
+.RE
+.PP
+The following obsolete section names are still recognised for compatibility
+purposes.
+In new config files, the
+.B InputDevice
+section should be used instead.
+.PP
+.RS 4
+.nf
+.BR "Keyboard " "Keyboard configuration"
+.BR "Pointer " "Pointer/mouse configuration"
+.fi
+.RE
+.PP
+The old
+.B XInput
+section is no longer recognised.
+.PP
+The
+.B ServerLayout
+sections are at the highest level.
+They bind together the input and output devices that will be used in a session.
+The input devices are described in the
+.B InputDevice
+sections.
+Output devices usually consist of multiple independent components (e.g.,
+a graphics board and a monitor).
+These multiple components are bound together in the
+.B Screen
+sections, and it is these that are referenced by the
+.B ServerLayout
+section.
+Each
+.B Screen
+section binds together a graphics board and a monitor.
+The graphics boards are described in the
+.B Device
+sections, and the monitors are described in the
+.B Monitor
+sections.
+.PP
+Config file keywords are case\-insensitive, and \(lq_\(rq characters are
+ignored.
+Most strings (including
+.B Option
+names) are also case-insensitive, and insensitive to white space and
+\(lq_\(rq characters.
+.PP
+Each config file entry usually takes up a single line in the file. They
+consist of a keyword, which is possibly followed by one or more arguments,
+with the number and types of the arguments depending on the keyword.
+The argument types are:
+.PP
+.RS 4
+.nf
+.BR "Integer " "an integer number in decimal, hex or octal"
+.BR "Real " "a floating point number"
+.BR "String " "a string enclosed in double quote marks (\*q)"
+.fi
+.RE
+.PP
+Note: hex integer values must be prefixed with \(lq0x\(rq, and octal values
+with \(lq0\(rq.
+.PP
+A special keyword called
+.B Option
+may be used to provide free\-form data to various components of the server.
+The
+.B Option
+keyword takes either one or two string arguments.
+The first is the option name, and the optional second argument is the
+option value.
+Some commonly used option value types include:
+.PP
+.RS 4
+.nf
+.BR "Integer " "an integer number in decimal, hex or octal"
+.BR "Real " "a floating point number"
+.BR "String " "a sequence of characters"
+.BR "Boolean " "a boolean value (see below)"
+.BR "Frequency " "a frequency value (see below)"
+.fi
+.RE
+.PP
+Note that
+.I all
+.B Option
+values, not just strings, must be enclosed in quotes.
+.PP
+Boolean options may optionally have a value specified.
+When no value is specified, the option's value is
+.BR TRUE .
+The following boolean option values are recognised as
+.BR TRUE :
+.PP
+.RS 4
+.BR 1 ,
+.BR on ,
+.BR true ,
+.B yes
+.RE
+.PP
+and the following boolean option values are recognised as
+.BR FALSE :
+.PP
+.RS 4
+.BR 0 ,
+.BR off ,
+.BR false ,
+.B no
+.RE
+.PP
+If an option name is prefixed with
+.RB \*q No \*q,
+then the option value is negated.
+.PP
+Example: the following option entries are equivalent:
+.PP
+.RS 4
+.nf
+.B "Option \*qAccel\*q \*qOff\*q"
+.B "Option \*qNoAccel\*q"
+.B "Option \*qNoAccel\*q \*qOn\*q"
+.B "Option \*qAccel\*q \*qfalse\*q"
+.B "Option \*qAccel\*q \*qno\*q"
+.fi
+.RE
+.PP
+Frequency option values consist of a real number that is optionally
+followed by one of the following frequency units:
+.PP
+.RS 4
+.BR Hz ,
+.BR k ,
+.BR kHz ,
+.BR M ,
+.B MHz
+.RE
+.PP
+When the unit name is omitted, the correct units will be determined from
+the value and the expectations of the appropriate range of the value.
+It is recommended that the units always be specified when using frequency
+option values to avoid any errors in determining the value.
+.SH "FILES SECTION"
+The
+.B Files
+section is used to specify some path names required by the server.
+Some of these paths can also be set from the command line (see
+.BR Xserver (__appmansuffix__)
+and
+.BR __xservername__ (__appmansuffix__)).
+The command line settings override the values specified in the config
+file.
+The
+.B Files
+section is optional, as are all of the entries that may appear in it.
+.PP
+The entries that can appear in this section are:
+.TP 7
+.BI "FontPath \*q" path \*q
+sets the search path for fonts.
+This path is a comma separated list of font path elements which the __xservername__
+server searches for font databases.
+Multiple
+.B FontPath
+entries may be specified, and they will be concatenated to build up the
+fontpath used by the server. Font path elements can be absolute
+directory paths, catalogue directories or a font server identifier. The
+formats of the later two are explained below:
+.PP
+.RS 7
+Catalogue directories:
+.PP
+.RS 4
+Catalogue directories can be specified using the prefix \fBcatalogue:\fR
+before the directory name. The directory can then be populated with
+symlinks pointing to the real font directories, using the following
+syntax in the symlink name:
+.PP
+.RS 4
+.IR <identifier> : [attribute]: pri= <priority>
+.RE
+.PP
+where
+.I <identifier>
+is an alphanumeric identifier,
+.I [attribute]
+is an attribute which will be passed to the underlying FPE and
+.I <priority>
+is a number used to order the fontfile FPEs. Examples:
+.PP
+.RS 4
+.nf
+.I 75dpi:unscaled:pri=20 -> /usr/share/X11/fonts/75dpi
+.I gscript:pri=60 -> /usr/share/fonts/default/ghostscript
+.I misc:unscaled:pri=10 \-> /usr/share/X11/fonts/misc
+.fi
+.PP
+.RE .RE .RE
+.PP
+.RS 7
+Font server identifiers:
+.PP
+.RS 4
+Font server identifiers have the form:
+.RS 4
+.PP
+.IR <trans> / <hostname> : <port\-number>
+.RE
+.PP
+where
+.I <trans>
+is the transport type to use to connect to the font server (e.g.,
+.B unix
+for UNIX\-domain sockets or
+.B tcp
+for a TCP/IP connection),
+.I <hostname>
+is the hostname of the machine running the font server, and
+.I <port\-number>
+is the port number that the font server is listening on (usually 7100).
+.RE
+.PP
+When this entry is not specified in the config file, the server falls back
+to the compiled\-in default font path, which contains the following
+font path elements (which can be set inside a catalogue directory):
+.PP
+.RS 4
+.nf
+.I __datadir__/fonts/X11/misc/
+.I __datadir__/fonts/X11/TTF/
+.I __datadir__/fonts/X11/OTF/
+.I __datadir__/fonts/X11/Type1/
+.I __datadir__/fonts/X11/100dpi/
+.I __datadir__/fonts/X11/75dpi/
+.fi
+.RE
+.PP
+Font path elements that are found to be invalid are removed from the
+font path when the server starts up.
+.RE
+.TP 7
+.BI "ModulePath \*q" path \*q
+sets the search path for loadable __xservername__ server modules.
+This path is a comma separated list of directories which the __xservername__ server
+searches for loadable modules loading in the order specified.
+Multiple
+.B ModulePath
+entries may be specified, and they will be concatenated to build the
+module search path used by the server. The default module path is
+.PP
+.RS 11
+__modulepath__
+.RE
+.\" The LogFile keyword is not currently implemented
+.ig
+.TP 7
+.BI "LogFile \*q" path \*q
+sets the name of the __xservername__ server log file.
+The default log file name is
+.PP
+.RS 11
+.RI __logdir__/__xservername__. <n> .log
+.RE
+.PP
+.RS 7
+where
+.I <n>
+is the display number for the __xservername__ server.
+..
+.TP 7
+.BI "XkbDir \*q" path \*q
+sets the base directory for keyboard layout files. The
+.B \-xkbdir
+command line option can be used to override this. The default directory is
+.PP
+.RS 11
+__xkbdir__
+.RE
+.SH "SERVERFLAGS SECTION"
+In addition to options specific to this section (described below), the
+.B ServerFlags
+section is used to specify some global
+__xservername__ server options.
+All of the entries in this section are
+.BR Options ,
+although for compatibility purposes some of the old style entries are
+still recognised.
+Those old style entries are not documented here, and using them is
+discouraged.
+The
+.B ServerFlags
+section is optional, as are the entries that may be specified in it.
+.PP
+.B Options
+specified in this section (with the exception of the
+.B \*qDefaultServerLayout\*q
+.BR Option )
+may be overridden by
+.B Options
+specified in the active
+.B ServerLayout
+section.
+Options with command line equivalents are overridden when their command
+line equivalent is used.
+The options recognised by this section are:
+.TP 7
+.BI "Option \*qDefaultServerLayout\*q \*q" layout\-id \*q
+This specifies the default
+.B ServerLayout
+section to use in the absence of the
+.B \-layout
+command line option.
+.TP 7
+.BI "Option \*qNoTrapSignals\*q \*q" boolean \*q
+This prevents the __xservername__ server from trapping a range of unexpected fatal
+signals and exiting cleanly.
+Instead, the __xservername__ server will die and drop core where the fault occurred.
+The default behaviour is for the __xservername__ server to exit cleanly, but still drop a
+core file.
+In general you never want to use this option unless you are debugging an __xservername__
+server problem and know how to deal with the consequences.
+.TP 7
+.BI "Option \*qUseSIGIO\*q \*q" boolean \*q
+This controls whether the __xservername__ server requests that events from
+input devices be reported via a SIGIO signal handler (also known as SIGPOLL
+on some platforms), or only reported via the standard select(3) loop.
+The default behaviour is platform specific. In general you do not want to
+use this option unless you are debugging the __xservername__ server, or
+working around a specific bug until it is fixed, and understand the
+consequences.
+.TP 7
+.BI "Option \*qDontVTSwitch\*q \*q" boolean \*q
+This disallows the use of the
+.BI Ctrl+Alt+F n
+sequence (where
+.RI F n
+refers to one of the numbered function keys).
+That sequence is normally used to switch to another \*qvirtual terminal\*q
+on operating systems that have this feature.
+When this option is enabled, that key sequence has no special meaning and
+is passed to clients.
+Default: off.
+.TP 7
+.BI "Option \*qDontZap\*q \*q" boolean \*q
+This disallows the use of the
+.B Terminate_Server
+XKB action (usually on Ctrl+Alt+Backspace, depending on XKB options).
+This action is normally used to terminate the __xservername__ server.
+When this option is enabled, the action has no effect.
+Default: off.
+.TP 7
+.BI "Option \*qDontZoom\*q \*q" boolean \*q
+This disallows the use of the
+.B Ctrl+Alt+Keypad\-Plus
+and
+.B Ctrl+Alt+Keypad\-Minus
+sequences.
+These sequences allows you to switch between video modes.
+When this option is enabled, those key sequences have no special meaning
+and are passed to clients.
+Default: off.
+.TP 7
+.BI "Option \*qDisableVidModeExtension\*q \*q" boolean \*q
+This disables the parts of the VidMode extension used by the xvidtune client
+that can be used to change the video modes.
+Default: the VidMode extension is enabled.
+.TP 7
+.BI "Option \*qAllowNonLocalXvidtune\*q \*q" boolean \*q
+This allows the xvidtune client (and other clients that use the VidMode
+extension) to connect from another host.
+Default: off.
+.TP 7
+.BI "Option \*qAllowMouseOpenFail\*q \*q" boolean \*q
+This tells the mousedrv(__drivermansuffix__) and vmmouse(__drivermansuffix__)
+drivers to not report failure if the mouse device can't be opened/initialised.
+It has no effect on the evdev(__drivermansuffix__) or other drivers.
+Default: false.
+.TP 7
+.BI "Option \*qVTSysReq\*q \*q" boolean \*q
+enables the SYSV\-style VT switch sequence for non\-SYSV systems
+which support VT switching.
+This sequence is
+.B Alt\-SysRq
+followed by a function key
+.RB ( Fn ).
+This prevents the __xservername__ server trapping the
+keys used for the default VT switch sequence, which means that clients can
+access them.
+Default: off.
+.TP 7
+.BI "Option \*qBlankTime\*q \*q" time \*q
+sets the inactivity timeout for the
+.B blank
+phase of the screensaver.
+.I time
+is in minutes.
+This is equivalent to the __xservername__ server's
+.B \-s
+flag, and the value can be changed at run\-time with
+.BR xset(__appmansuffix__).
+Default: 10 minutes.
+.TP 7
+.BI "Option \*qStandbyTime\*q \*q" time \*q
+sets the inactivity timeout for the
+.B standby
+phase of DPMS mode.
+.I time
+is in minutes, and the value can be changed at run\-time with
+.BR xset(__appmansuffix__).
+Default: 10 minutes.
+This is only suitable for VESA DPMS compatible monitors, and may not be
+supported by all video drivers.
+It is only enabled for screens that have the
+.B \*qDPMS\*q
+option set (see the MONITOR section below).
+.TP 7
+.BI "Option \*qSuspendTime\*q \*q" time \*q
+sets the inactivity timeout for the
+.B suspend
+phase of DPMS mode.
+.I time
+is in minutes, and the value can be changed at run\-time with
+.BR xset(__appmansuffix__).
+Default: 10 minutes.
+This is only suitable for VESA DPMS compatible monitors, and may not be
+supported by all video drivers.
+It is only enabled for screens that have the
+.B \*qDPMS\*q
+option set (see the MONITOR section below).
+.TP 7
+.BI "Option \*qOffTime\*q \*q" time \*q
+sets the inactivity timeout for the
+.B off
+phase of DPMS mode.
+.I time
+is in minutes, and the value can be changed at run\-time with
+.BR xset(__appmansuffix__).
+Default: 10 minutes.
+This is only suitable for VESA DPMS compatible monitors, and may not be
+supported by all video drivers.
+It is only enabled for screens that have the
+.B \*qDPMS\*q
+option set (see the MONITOR section below).
+.TP 7
+.BI "Option \*qPixmap\*q \*q" bpp \*q
+This sets the pixmap format to use for depth 24.
+Allowed values for
+.I bpp
+are 24 and 32.
+Default: 32 unless driver constraints don't allow this (which is rare).
+Note: some clients don't behave well when this value is set to 24.
+.TP 7
+.BI "Option \*qPC98\*q \*q" boolean \*q
+Specify that the machine is a Japanese PC\-98 machine.
+This should not be enabled for anything other than the Japanese\-specific
+PC\-98 architecture.
+Default: auto\-detected.
+.TP 7
+.BI "Option \*qNoPM\*q \*q" boolean \*q
+Disables something to do with power management events.
+Default: PM enabled on platforms that support it.
+.TP 7
+.BI "Option \*qXinerama\*q \*q" boolean \*q
+enable or disable XINERAMA extension.
+Default is disabled.
+.TP 7
+.BI "Option \*qAIGLX\*q \*q" boolean \*q
+enable or disable AIGLX. AIGLX is enabled by default.
+.TP 7
+.BI "Option \*qDRI2\*q \*q" boolean \*q
+enable or disable DRI2. DRI2 is disabled by default.
+.TP 7
+.BI "Option \*qGlxVisuals\*q \*q" string \*q
+This option controls how many GLX visuals the GLX modules sets up.
+The default value is
+.BR "typical" ,
+which will setup up a typical subset of
+the GLXFBConfigs provided by the driver as GLX visuals. Other options are
+.BR "minimal" ,
+which will set up the minimal set allowed by the GLX specification and
+.BR "all"
+which will setup GLX visuals for all GLXFBConfigs.
+.TP 7
+.BI "Option \*qUseDefaultFontPath\*q \*q" boolean \*q
+Include the default font path even if other paths are specified in
+xorg.conf. If enabled, other font paths are included as well. Enabled by
+default.
+.TP 7
+.BI "Option \*qIgnoreABI\*q \*q" boolean \*q
+Allow modules built for a different, potentially incompatible version of
+the X server to load. Disabled by default.
+.TP 7
+.BI "Option \*qAutoAddDevices\*q \*q" boolean \*q
+If this option is disabled, then no devices will be added from HAL events.
+Enabled by default.
+.TP 7
+.BI "Option \*qAutoEnableDevices\*q \*q" boolean \*q
+If this option is disabled, then the devices will be added (and the
+DevicePresenceNotify event sent), but not enabled, thus leaving policy up
+to the client.
+Enabled by default.
+.TP 7
+.BI "Option \*qLog\*q \*q" string \*q
+This option controls whether the log is flushed and/or synced to disk after
+each message.
+Possible values are
+.B flush
+or
+.BR sync .
+Unset by default.
+.SH "MODULE SECTION"
+The
+.B Module
+section is used to specify which __xservername__ server modules should be loaded.
+This section is ignored when the __xservername__ server is built in static form.
+The type of modules normally loaded in this section are __xservername__ server
+extension modules.
+Most other module types are loaded automatically when they are needed via
+other mechanisms.
+The
+.B Module
+section is optional, as are all of the entries that may be specified in
+it.
+.PP
+Entries in this section may be in two forms.
+The first and most commonly used form is an entry that uses the
+.B Load
+keyword, as described here:
+.TP 7
+.BI "Load \*q" modulename \*q
+This instructs the server to load the module called
+.IR modulename .
+The module name given should be the module's standard name, not the
+module file name.
+The standard name is case\-sensitive, and does not include the \(lqlib\(rq
+prefix, or the \(lq.a\(rq, \(lq.o\(rq, or \(lq.so\(rq suffixes.
+.PP
+.RS 7
+Example: the DRI extension module can be loaded with the following entry:
+.PP
+.RS 4
+.B "Load \*qdri\*q"
+.RE
+.RE
+.TP 7
+.BI "Disable \*q" modulename \*q
+This instructs the server to not load the module called
+.IR modulename .
+Some modules are loaded by default in the server, and this overrides that
+default. If a
+.B Load
+instruction is given for the same module, it overrides the
+.B Disable
+instruction and the module is loaded. The module name given should be the
+module's standard name, not the module file name. As with the
+.B Load
+instruction, the standard name is case-sensitive, and does not include the
+"lib" prefix, or the ".a", ".o", or ".so" suffixes.
+.PP
+The second form of entry is a
+.BR SubSection,
+with the subsection name being the module name, and the contents of the
+.B SubSection
+being
+.B Options
+that are passed to the module when it is loaded.
+.PP
+Example: the extmod module (which contains a miscellaneous group of
+server extensions) can be loaded, with the XFree86\-DGA extension
+disabled by using the following entry:
+.PP
+.RS 4
+.nf
+.B "SubSection \*qextmod\*q"
+.B " Option \*qomit XFree86\-DGA\*q"
+.B EndSubSection
+.fi
+.RE
+.PP
+Modules are searched for in each directory specified in the
+.B ModulePath
+search path, and in the drivers, extensions, input, internal, and
+multimedia subdirectories of each of those directories.
+In addition to this, operating system specific subdirectories of all
+the above are searched first if they exist.
+.PP
+To see what extension modules are available, check the extensions
+subdirectory under:
+.PP
+.RS 4
+.nf
+__modulepath__
+.fi
+.RE
+.PP
+The \(lqextmod\(rq, \(lqdbe\(rq, \(lqdri\(rq, \(lqdri2\(rq, \(lqglx\(rq,
+and \(lqrecord\(rq extension modules are loaded automatically, if they
+are present, unless disabled with \*qDisable\*q entries.
+It is recommended
+that at very least the \(lqextmod\(rq extension module be loaded.
+If it isn't, some commonly used server extensions (like the SHAPE
+extension) will not be available.
+.SH "EXTENSIONS SECTION"
+The
+.B Extensions
+section is used to specify which X11 protocol extensions should be enabled
+or disabled.
+The
+.B Extensions
+section is optional, as are all of the entries that may be specified in
+it.
+.PP
+Entries in this section are listed as Option statements with the name of
+the extension as the first argument, and a boolean value as the second.
+The extension name is case\-sensitive, and matches the form shown in the output
+of \*qXorg -extension ?\*q.
+.PP
+.RS 7
+Example: the MIT-SHM extension can be disabled with the following entry:
+.PP
+.RS 4
+.nf
+.B "Section \*qExtensions\*q"
+.B " Option \*qMIT-SHM\*q \*qDisable\*q"
+.B "EndSection"
+.fi
+.RE
+.RE
+.SH "INPUTDEVICE SECTION"
+The config file may have multiple
+.B InputDevice
+sections.
+Recent X servers employ HAL or udev backends for input device enumeration
+and input hotplugging. It is usually not
+necessary to provide
+.B InputDevice
+sections in the xorg.conf if hotplugging is in use. If hotplugging is
+enabled,
+.B InputDevice
+sections using the
+.B mouse, kbd
+and
+.B vmmouse
+driver will be ignored.
+.PP
+If hotplugging is disabled, there will normally
+be at least two: one for the core (primary) keyboard
+and one for the core pointer.
+If either of these two is missing, a default configuration for the missing
+ones will be used. In the absence of an explicitly specified core input
+device, the first
+.B InputDevice
+marked as
+.B CorePointer
+(or
+.BR CoreKeyboard )
+is used.
+If there is no match there, the first
+.B InputDevice
+that uses the \(lqmouse\(rq (or \(lqkbd\(rq) driver is used.
+The final fallback is to use built\-in default configurations.
+Currently the default configuration may not work as expected on all platforms.
+.PP
+.B InputDevice
+sections have the following format:
+.PP
+.RS 4
+.nf
+.B "Section \*qInputDevice\*q"
+.BI " Identifier \*q" name \*q
+.BI " Driver \*q" inputdriver \*q
+.I " options"
+.I " ..."
+.B "EndSection"
+.fi
+.RE
+.PP
+The
+.B Identifier
+and
+.B Driver
+entries are required in all
+.B InputDevice
+sections.
+All other entries are optional.
+.PP
+The
+.B Identifier
+entry specifies the unique name for this input device.
+The
+.B Driver
+entry specifies the name of the driver to use for this input device.
+When using the loadable server, the input driver module
+.RI \*q inputdriver \*q
+will be loaded for each active
+.B InputDevice
+section.
+An
+.B InputDevice
+section is considered active if it is referenced by an active
+.B ServerLayout
+section, if it is referenced by the
+.B \-keyboard
+or
+.B \-pointer
+command line options, or if it is selected implicitly as the core pointer
+or keyboard device in the absence of such explicit references.
+The most commonly used input drivers are
+.BR evdev (__drivermansuffix__)
+on Linux systems, and
+.BR kbd (__drivermansuffix__)
+and
+.BR mousedrv (__drivermansuffix__)
+on other platforms.
+.PP
+.PP
+.B InputDevice
+sections recognise some driver\-independent
+.BR Options ,
+which are described here.
+See the individual input driver manual pages for a description of the
+device\-specific options.
+.TP 7
+.BI "Option \*qAutoServerLayout\*q \*q" boolean \*q
+Always add the device to the ServerLayout section used by this instance of
+the server. This affects implied layouts as well as explicit layouts
+specified in the configuration and/or on the command line.
+.TP 7
+.BI "Option \*qCorePointer\*q"
+Deprecated, see
+.B Floating
+.TP 7
+.BI "Option \*qCoreKeyboard\*q"
+Deprecated, see
+.B Floating
+.TP 7
+.BI "Option \*qAlwaysCore\*q \*q" boolean \*q
+Deprecated, see
+.B Floating
+.TP 7
+.BI "Option \*qSendCoreEvents\*q \*q" boolean \*q
+Deprecated, see
+.B Floating
+
+.TP 7
+.BI "Option \*qFloating\*q \*q" boolean \*q
+When enabled, the input device is set up floating and does not
+report events through any master device or control a cursor. The device is
+only available to clients using the X Input Extension API. This option is
+disabled by default.
+The options
+.B CorePointer,
+.B CoreKeyboard,
+.B AlwaysCore,
+and
+.B SendCoreEvents,
+are the inverse of option
+.B Floating
+(i.e.
+.B SendCoreEvents \*qon\*q
+is equivalent to
+.B Floating \*qoff\*q
+).
+
+This option controls the startup behavior only, a device
+may be reattached or set floating at runtime.
+.PP
+For pointing devices, the following options control how the pointer
+is accelerated or decelerated with respect to physical device motion. Most of
+these can be adjusted at runtime, see the xinput(1) man page for details. Only
+the most important acceleration options are discussed here.
+.TP 7
+.BI "Option \*qAccelerationProfile\*q \*q" integer \*q
+Select the profile. In layman's terms, the profile constitutes the "feeling" of
+the acceleration. More formally, it defines how the transfer function (actual
+acceleration as a function of current device velocity and acceleration controls)
+is constructed. This is mainly a matter of personal preference.
+.PP
+.RS 6
+.nf
+.B " 0 classic (mostly compatible)"
+.B "-1 none (only constant deceleration is applied)"
+.B " 1 device-dependent"
+.B " 2 polynomial (polynomial function)"
+.B " 3 smooth linear (soft knee, then linear)"
+.B " 4 simple (normal when slow, otherwise accelerated)"
+.B " 5 power (power function)"
+.B " 6 linear (more speed, more acceleration)"
+.B " 7 limited (like linear, but maxes out at threshold)"
+.fi
+.RE
+.TP 7
+.BI "Option \*qConstantDeceleration\*q \*q" real \*q
+Makes the pointer go
+.B deceleration
+times slower than normal. Most useful for high-resolution devices.
+.TP 7
+.BI "Option \*qAdaptiveDeceleration\*q \*q" real \*q
+Allows to actually decelerate the pointer when going slow. At most, it will be
+.B adaptive deceleration
+times slower. Enables precise pointer placement without sacrificing speed.
+.TP 7
+.BI "Option \*qAccelerationScheme\*q \*q" string \*q
+Selects the scheme, which is the underlying algorithm.
+.PP
+.RS 7
+.nf
+.B "predictable default algorithm (behaving more predictable)"
+.B "lightweight old acceleration code (as specified in the X protocol spec)"
+.B "none no acceleration or deceleration"
+.fi
+.RE
+.TP 7
+.BI "Option \*qAccelerationNumerator\*q \*q" integer \*q
+.TP 7
+.BI "Option \*qAccelerationDenominator\*q \*q" integer \*q
+Set numerator and denominator of the acceleration factor. The acceleration
+factor is a rational which, together with threshold, can be used to tweak
+profiles to suit the users needs. The
+.B simple
+and
+.B limited
+profiles use it directly (i.e. they accelerate by the factor), for other
+profiles it should hold that a higher acceleration factor leads to a faster
+pointer. Typically, 1 is unaccelerated and values up to 5 are sensible.
+.TP 7
+.BI "Option \*qAccelerationThreshold\*q \*q" integer \*q
+Set the threshold, which is roughly the velocity (usually device units per 10
+ms) required for acceleration to become effective. The precise effect varies
+with the profile however.
+
+.SH "INPUTCLASS SECTION"
+The config file may have multiple
+.B InputClass
+sections.
+These sections are optional and are used to provide configuration for a
+class of input devices as they are automatically added. An input device can
+match more than one
+.B InputClass
+section. Each class can override settings from a previous class, so it is
+best to arrange the sections with the most generic matches first.
+.PP
+.B InputClass
+sections have the following format:
+.PP
+.RS 4
+.nf
+.B "Section \*qInputClass\*q"
+.BI " Identifier \*q" name \*q
+.I " entries"
+.I " ..."
+.I " options"
+.I " ..."
+.B "EndSection"
+.fi
+.RE
+.PP
+The
+.B Identifier
+entry is required in all
+.B InputClass
+sections.
+All other entries are optional.
+.PP
+The
+.B Identifier
+entry specifies the unique name for this input class.
+The
+.B Driver
+entry specifies the name of the driver to use for this input device.
+After all classes have been examined, the
+.RI \*q inputdriver \*q
+module from the first
+.B Driver
+entry will be enabled when using the loadable server.
+.PP
+When an input device is automatically added, its characteristics are
+checked against all
+.B InputClass
+sections. Each section can contain optional entries to narrow the match
+of the class. If none of the optional entries appear, the
+.B InputClass
+section is generic and will match any input device. If more than one of
+these entries appear, they all must match for the configuration to apply.
+.PP
+There are two types of match entries used in
+.B InputClass
+sections. The first allows various tokens to be matched against attributes
+of the device. An entry can be constructed to match attributes from different
+devices by separating arguments with a '|' character. Multiple entries of the
+same type may be supplied to add multiple matching conditions on the same
+attribute. For example:
+.PP
+.RS 4
+.nf
+.B "Section \*qInputClass\*q"
+.B " Identifier \*qMy Class\*q"
+.B " # product string must contain example and
+.B " # either gizmo or gadget
+.B " MatchProduct \*qexample\*q
+.B " MatchProduct \*qgizmo|gadget\*q
+.I " ..."
+.B "EndSection"
+.fi
+.RE
+.TP 7
+.BI "MatchProduct \*q" matchproduct \*q
+This entry can be used to check if the substring
+.RI \*q matchproduct \*q
+occurs in the device's product name.
+.TP 7
+.BI "MatchVendor \*q" matchvendor \*q
+This entry can be used to check if the substring
+.RI \*q matchvendor \*q
+occurs in the device's vendor name.
+.TP 7
+.BI "MatchDevicePath \*q" matchdevice \*q
+This entry can be used to check if the device file matches the
+.RI \*q matchdevice \*q
+pathname pattern.
+.TP 7
+.BI "MatchOS \*q" matchos \*q
+This entry can be used to check if the operating system matches the
+case-insensitive
+.RI \*q matchos \*q
+string. This entry is only supported on platforms providing the
+.BR uname (2)
+system call.
+.TP 7
+.BI "MatchPnPID \*q" matchpnp \*q
+The device's Plug and Play (PnP) ID can be checked against the
+.RI \*q matchpnp \*q
+shell wildcard pattern.
+.TP 7
+.BI "MatchUSBID \*q" matchusb \*q
+The device's USB ID can be checked against the
+.RI \*q matchusb \*q
+shell wildcard pattern. The ID is constructed as lowercase hexadecimal numbers
+separated by a ':'. This is the same format as the
+.BR lsusb (8)
+program.
+.TP 7
+.BI "MatchDriver \*q" matchdriver \*q
+Check the case-sensitive string
+.RI \*q matchdriver \*q
+against the currently configured driver of the device. Ordering of sections
+using this entry is important since it will not match unless the driver has
+been set by the config backend or a previous
+.B InputClass
+section.
+.TP 7
+.BI "MatchTag \*q" matchtag \*q
+This entry can be used to check if tags assigned by the config backend
+matches the
+.RI \*q matchtag \*q
+pattern. A match is found if at least one of the tags given in
+.RI \*q matchtag \*q
+matches at least one of the tags assigned by the backend.
+.TP 7
+.BI "MatchLayout \*q" matchlayout \*q
+Check the case-sensitive string
+.RI \*q matchlayout \*q
+against the currently active
+.B ServerLayout
+section. The empty string "" matches an implicit layout which appears
+if no named
+.B ServerLayout
+sections have been found.
+.PP
+The second type of entry is used to match device types. These entries take a
+boolean argument similar to
+.B Option
+entries.
+.TP 7
+.BI "MatchIsKeyboard \*q" bool \*q
+.TP 7
+.BI "MatchIsPointer \*q" bool \*q
+.TP 7
+.BI "MatchIsJoystick \*q" bool \*q
+.TP 7
+.BI "MatchIsTablet \*q" bool \*q
+.TP 7
+.BI "MatchIsTouchpad \*q" bool \*q
+.TP 7
+.BI "MatchIsTouchscreen \*q" bool \*q
+.PP
+When an input device has been matched to the
+.B InputClass
+section, any
+.B Option
+entries are applied to the device. One
+.B InputClass
+specific
+.B Option
+is recognized. See the
+.B InputDevice
+section above for a description of the remaining
+.B Option
+entries.
+.TP 7
+.BI "Option \*qIgnore\*q \*q" boolean \*q
+This optional entry specifies that the device should be ignored entirely,
+and not added to the server. This can be useful when the device is handled
+by another program and no X events should be generated.
+.SH "DEVICE SECTION"
+The config file may have multiple
+.B Device
+sections.
+There must be at least one, for the video card being used.
+.PP
+.B Device
+sections have the following format:
+.PP
+.RS 4
+.nf
+.B "Section \*qDevice\*q"
+.BI " Identifier \*q" name \*q
+.BI " Driver \*q" driver \*q
+.I " entries"
+.I " ..."
+.B "EndSection"
+.fi
+.RE
+.PP
+The
+.B Identifier
+and
+.B Driver
+entries are required in all
+.B Device
+sections. All other entries are optional.
+.PP
+The
+.B Identifier
+entry specifies the unique name for this graphics device.
+The
+.B Driver
+entry specifies the name of the driver to use for this graphics device.
+When using the loadable server, the driver module
+.RI \*q driver \*q
+will be loaded for each active
+.B Device
+section.
+A
+.B Device
+section is considered active if it is referenced by an active
+.B Screen
+section.
+.PP
+.B Device
+sections recognise some driver\-independent entries and
+.BR Options ,
+which are described here.
+Not all drivers make use of these
+driver\-independent entries, and many of those that do don't require them
+to be specified because the information is auto\-detected.
+See the individual graphics driver manual pages for further information
+about this, and for a description of the device\-specific options.
+Note that most of the
+.B Options
+listed here (but not the other entries) may be specified in the
+.B Screen
+section instead of here in the
+.B Device
+section.
+.TP 7
+.BI "BusID \*q" bus\-id \*q
+This specifies the bus location of the graphics card.
+For PCI/AGP cards,
+the
+.I bus\-id
+string has the form
+.BI PCI: bus : device : function
+(e.g., \(lqPCI:1:0:0\(rq might be appropriate for an AGP card).
+This field is usually optional in single-head configurations when using
+the primary graphics card.
+In multi-head configurations, or when using a secondary graphics card in a
+single-head configuration, this entry is mandatory.
+Its main purpose is to make an unambiguous connection between the device
+section and the hardware it is representing.
+This information can usually be found by running the pciaccess tool
+scanpci.
+.TP 7
+.BI "Screen " number
+This option is mandatory for cards where a single PCI entity can drive more
+than one display (i.e., multiple CRTCs sharing a single graphics accelerator
+and video memory).
+One
+.B Device
+section is required for each head, and this
+parameter determines which head each of the
+.B Device
+sections applies to.
+The legal values of
+.I number
+range from 0 to one less than the total number of heads per entity.
+Most drivers require that the primary screen (0) be present.
+.TP 7
+.BI "Chipset \*q" chipset \*q
+This usually optional entry specifies the chipset used on the graphics
+board.
+In most cases this entry is not required because the drivers will probe the
+hardware to determine the chipset type.
+Don't specify it unless the driver-specific documentation recommends that you
+do.
+.TP 7
+.BI "Ramdac \*q" ramdac\-type \*q
+This optional entry specifies the type of RAMDAC used on the graphics
+board.
+This is only used by a few of the drivers, and in most cases it is not
+required because the drivers will probe the hardware to determine the
+RAMDAC type where possible.
+Don't specify it unless the driver-specific documentation recommends that you
+do.
+.TP 7
+.BI "DacSpeed " speed
+.TP 7
+.BI "DacSpeed " "speed\-8 speed\-16 speed\-24 speed\-32"
+This optional entry specifies the RAMDAC speed rating (which is usually
+printed on the RAMDAC chip).
+The speed is in MHz.
+When one value is given, it applies to all framebuffer pixel sizes.
+When multiple values are given, they apply to the framebuffer pixel sizes
+8, 16, 24 and 32 respectively.
+This is not used by many drivers, and only needs to be specified when the
+speed rating of the RAMDAC is different from the defaults built in to
+driver, or when the driver can't auto-detect the correct defaults.
+Don't specify it unless the driver-specific documentation recommends that you
+do.
+.TP 7
+.BI "Clocks " "clock ..."
+specifies the pixel that are on your graphics board.
+The clocks are in MHz, and may be specified as a floating point number.
+The value is stored internally to the nearest kHz.
+The ordering of the clocks is important.
+It must match the order in which they are selected on the graphics board.
+Multiple
+.B Clocks
+lines may be specified, and each is concatenated to form the list.
+Most drivers do not use this entry, and it is only required for some older
+boards with non-programmable clocks.
+Don't specify this entry unless the driver-specific documentation explicitly
+recommends that you do.
+.TP
+.BI "ClockChip \*q" clockchip\-type \*q
+This optional entry is used to specify the clock chip type on graphics
+boards which have a programmable clock generator.
+Only a few __xservername__ drivers support programmable clock chips.
+For details, see the appropriate driver manual page.
+.TP 7
+.BI "VideoRam " "mem"
+This optional entry specifies the amount of video ram that is installed
+on the graphics board.
+This is measured in kBytes.
+In most cases this is not required because the __xservername__ server probes
+the graphics board to determine this quantity.
+The driver-specific documentation should indicate when it might be needed.
+.TP 7
+.BI "BiosBase " "baseaddress"
+This optional entry specifies the base address of the video BIOS for
+the VGA board.
+This address is normally auto-detected, and should only be specified if the
+driver-specific documentation recommends it.
+.TP 7
+.BI "MemBase " "baseaddress"
+This optional entry specifies the memory base address of a graphics
+board's linear frame buffer.
+This entry is not used by many drivers, and it should only be specified if
+the driver-specific documentation recommends it.
+.TP 7
+.BI "IOBase " "baseaddress"
+This optional entry specifies the IO base address.
+This entry is not used by many drivers, and it should only be specified if
+the driver-specific documentation recommends it.
+.TP 7
+.BI "ChipID " "id"
+This optional entry specifies a numerical ID representing the chip type.
+For PCI cards, it is usually the device ID.
+This can be used to override the auto-detection, but that should only be done
+when the driver-specific documentation recommends it.
+.TP 7
+.BI "ChipRev " "rev"
+This optional entry specifies the chip revision number.
+This can be used to override the auto-detection, but that should only be done
+when the driver-specific documentation recommends it.
+.TP 7
+.BI "TextClockFreq " "freq"
+This optional entry specifies the pixel clock frequency that is used
+for the regular text mode.
+The frequency is specified in MHz.
+This is rarely used.
+.TP 7
+.BI "Option \*qModeDebug\*q \*q" boolean \*q
+Enable printing of additional debugging information about modesetting to
+the server log.
+.ig
+.TP 7
+This optional entry allows an IRQ number to be specified.
+..
+.TP 7
+.B Options
+Option flags may be specified in the
+.B Device
+sections.
+These include driver\-specific options and driver\-independent options.
+The former are described in the driver\-specific documentation.
+Some of the latter are described below in the section about the
+.B Screen
+section, and they may also be included here.
+
+.SH "VIDEOADAPTOR SECTION"
+Nobody wants to say how this works.
+Maybe nobody knows ...
+
+.SH "MONITOR SECTION"
+The config file may have multiple
+.B Monitor
+sections.
+There should normally be at least one, for the monitor being used,
+but a default configuration will be created when one isn't specified.
+.PP
+.B Monitor
+sections have the following format:
+.PP
+.RS 4
+.nf
+.B "Section \*qMonitor\*q"
+.BI " Identifier \*q" name \*q
+.I " entries"
+.I " ..."
+.B "EndSection"
+.fi
+.RE
+.PP
+The only mandatory entry in a
+.B Monitor
+section is the
+.B Identifier
+entry.
+.PP
+The
+.B Identifier
+entry specifies the unique name for this monitor.
+The
+.B Monitor
+section may be used to provide information about the specifications of the
+monitor, monitor-specific
+.BR Options ,
+and information about the video modes to use with the monitor.
+.PP
+With RandR 1.2-enabled drivers, monitor sections may be tied to specific
+outputs of the video card. Using the name of the output defined by the video
+driver plus the identifier of a monitor section, one associates a monitor
+section with an output by adding an option to the Device section in the
+following format:
+
+.B Option \*qMonitor-outputname\*q \*qmonitorsection\*q
+
+(for example,
+.B Option \*qMonitor-VGA\*q \*qVGA monitor\*q
+for a VGA output)
+.PP
+In the absence of specific association of monitor sections to outputs, if a
+monitor section is present the server will associate it with an output to
+preserve compatibility for previous single-head configurations.
+.PP
+Specifying video modes is optional because the server will use the DDC or other
+information provided by the monitor to automatically configure the list of
+modes available.
+When modes are specified explicitly in the
+.B Monitor
+section (with the
+.BR Modes ,
+.BR ModeLine ,
+or
+.B UseModes
+keywords), built-in modes with the same names are not included.
+Built-in modes with different names are, however, still implicitly included,
+when they meet the requirements of the monitor.
+.PP
+The entries that may be used in
+.B Monitor
+sections are described below.
+.TP 7
+.BI "VendorName \*q" vendor \*q
+This optional entry specifies the monitor's manufacturer.
+.TP 7
+.BI "ModelName \*q" model \*q
+This optional entry specifies the monitor's model.
+.TP 7
+.BI "HorizSync " "horizsync\-range"
+gives the range(s) of horizontal sync frequencies supported by the
+monitor.
+.I horizsync\-range
+may be a comma separated list of either discrete values or ranges of
+values.
+A range of values is two values separated by a dash.
+By default the values are in units of kHz.
+They may be specified in MHz or Hz
+if
+.B MHz
+or
+.B Hz
+is added to the end of the line.
+The data given here is used by the __xservername__ server to determine if video
+modes are within the specifications of the monitor.
+This information should be available in the monitor's handbook.
+If this entry is omitted, a default range of 28\-33kHz is used.
+.TP 7
+.BI "VertRefresh " "vertrefresh\-range"
+gives the range(s) of vertical refresh frequencies supported by the
+monitor.
+.I vertrefresh\-range
+may be a comma separated list of either discrete values or ranges of
+values.
+A range of values is two values separated by a dash.
+By default the values are in units of Hz.
+They may be specified in MHz or kHz
+if
+.B MHz
+or
+.B kHz
+is added to the end of the line.
+The data given here is used by the __xservername__ server to determine if video
+modes are within the specifications of the monitor.
+This information should be available in the monitor's handbook.
+If this entry is omitted, a default range of 43\-72Hz is used.
+.TP 7
+.BI "DisplaySize " "width height"
+This optional entry gives the width and height, in millimetres, of the
+picture area of the monitor.
+If given this is used to calculate the horizontal and vertical pitch (DPI) of
+the screen.
+.TP 7
+.BI "Gamma " "gamma\-value"
+.TP 7
+.BI "Gamma " "red\-gamma green\-gamma blue\-gamma"
+This is an optional entry that can be used to specify the gamma correction
+for the monitor.
+It may be specified as either a single value or as three separate RGB values.
+The values should be in the range 0.1 to 10.0, and the default is 1.0.
+Not all drivers are capable of using this information.
+.TP 7
+.BI "UseModes \*q" modesection\-id \*q
+Include the set of modes listed in the
+.B Modes
+section called
+.IR modesection\-id.
+This makes all of the modes defined in that section available for use by
+this monitor.
+.TP 7
+.BI "Mode \*q" name \*q
+This is an optional multi-line entry that can be used to provide
+definitions for video modes for the monitor.
+In most cases this isn't necessary because the built-in set of VESA standard
+modes will be sufficient.
+The
+.B Mode
+keyword indicates the start of a multi-line video mode description.
+The mode description is terminated with the
+.B EndMode
+keyword.
+The mode description consists of the following entries:
+.RS 7
+.TP 4
+.BI "DotClock " clock
+is the dot (pixel) clock rate to be used for the mode.
+.TP 4
+.BI "HTimings " "hdisp hsyncstart hsyncend htotal"
+specifies the horizontal timings for the mode.
+.TP 4
+.BI "VTimings " "vdisp vsyncstart vsyncend vtotal"
+specifies the vertical timings for the mode.
+.TP 4
+.BI "Flags \*q" flag \*q " ..."
+specifies an optional set of mode flags, each of which is a separate
+string in double quotes.
+.B \*qInterlace\*q
+indicates that the mode is interlaced.
+.B \*qDoubleScan\*q
+indicates a mode where each scanline is doubled.
+.B \*q+HSync\*q
+and
+.B \*q\-HSync\*q
+can be used to select the polarity of the HSync signal.
+.B \*q+VSync\*q
+and
+.B \*q\-VSync\*q
+can be used to select the polarity of the VSync signal.
+.B \*qComposite\*q
+can be used to specify composite sync on hardware where this is supported.
+Additionally, on some hardware,
+.B \*q+CSync\*q
+and
+.B \*q\-CSync\*q
+may be used to select the composite sync polarity.
+.TP 4
+.BI "HSkew " hskew
+specifies the number of pixels (towards the right edge of the screen) by
+which the display enable signal is to be skewed.
+Not all drivers use this information.
+This option might become necessary to override the default value supplied
+by the server (if any).
+\(lqRoving\(rq horizontal lines indicate this value needs to be increased.
+If the last few pixels on a scan line appear on the left of the screen,
+this value should be decreased.
+.TP 4
+.BI "VScan " vscan
+specifies the number of times each scanline is painted on the screen.
+Not all drivers use this information.
+Values less than 1 are treated as 1, which is the default.
+Generally, the
+.B \*qDoubleScan\*q
+.B Flag
+mentioned above doubles this value.
+.RE
+.TP 7
+.BI "ModeLine \*q" name \*q " mode\-description"
+This entry is a more compact version of the
+.B Mode
+entry, and it also can be used to specify video modes for the monitor.
+is a single line format for specifying video modes.
+In most cases this isn't necessary because the built\-in set of VESA
+standard modes will be sufficient.
+.PP
+.RS 7
+The
+.I mode\-description
+is in four sections, the first three of which are mandatory.
+The first is the dot (pixel) clock.
+This is a single number specifying the pixel clock rate for the mode in
+MHz.
+The second section is a list of four numbers specifying the horizontal
+timings.
+These numbers are the
+.IR hdisp ,
+.IR hsyncstart ,
+.IR hsyncend ,
+and
+.I htotal
+values.
+The third section is a list of four numbers specifying the vertical
+timings.
+These numbers are the
+.IR vdisp ,
+.IR vsyncstart ,
+.IR vsyncend ,
+and
+.I vtotal
+values.
+The final section is a list of flags specifying other characteristics of
+the mode.
+.B Interlace
+indicates that the mode is interlaced.
+.B DoubleScan
+indicates a mode where each scanline is doubled.
+.B +HSync
+and
+.B \-HSync
+can be used to select the polarity of the HSync signal.
+.B +VSync
+and
+.B \-VSync
+can be used to select the polarity of the VSync signal.
+.B Composite
+can be used to specify composite sync on hardware where this is supported.
+Additionally, on some hardware,
+.B +CSync
+and
+.B \-CSync
+may be used to select the composite sync polarity.
+The
+.B HSkew
+and
+.B VScan
+options mentioned above in the
+.B Modes
+entry description can also be used here.
+.RE
+.TP 7
+.BI "Option " "\*qDPMS\*q " \*qbool\*q
+This option controls whether the server should enable the DPMS extension
+for power management for this screen. The default is to enable the
+extension.
+.TP 7
+.BI "Option " "\*qSyncOnGreen\*q " \*qbool\*q
+This option controls whether the video card should drive the sync signal
+on the green color pin. Not all cards support this option, and most
+monitors do not require it. The default is off.
+.TP 7
+.BI "Option " "\*qPrimary\*q " \*qbool\*q
+This optional entry specifies that the monitor should be treated as the primary
+monitor. (RandR 1.2-supporting drivers only)
+.TP 7
+.BI "Option " "\*qPreferredMode\*q " \*qstring\*q
+This optional entry specifies a mode to be marked as the preferred initial mode
+of the monitor.
+(RandR 1.2-supporting drivers only)
+.TP 7
+.BI "Option " "\*qPosition\*q " "\*qx y\*q"
+This optional entry specifies the position of the monitor within the X
+screen.
+(RandR 1.2-supporting drivers only)
+.TP 7
+.BI "Option " "\*qLeftOf\*q " \*qoutput\*q
+This optional entry specifies that the monitor should be positioned to the
+left of the output (not monitor) of the given name.
+(RandR 1.2-supporting drivers only)
+.TP 7
+.BI "Option " "\*qRightOf\*q " \*qoutput\*q
+This optional entry specifies that the monitor should be positioned to the
+right of the output (not monitor) of the given name.
+(RandR 1.2-supporting drivers only)
+.TP 7
+.BI "Option " "\*qAbove\*q " \*qoutput\*q
+This optional entry specifies that the monitor should be positioned above the
+output (not monitor) of the given name.
+(RandR 1.2-supporting drivers only)
+.TP 7
+.BI "Option " "\*qBelow\*q " \*qoutput\*q
+This optional entry specifies that the monitor should be positioned below the
+output (not monitor) of the given name.
+(RandR 1.2-supporting drivers only)
+.TP 7
+.BI "Option " "\*qEnable\*q " \*qbool\*q
+This optional entry specifies whether the monitor should be turned on
+at startup. By default, the server will attempt to enable all connected
+monitors.
+(RandR 1.2-supporting drivers only)
+.TP 7
+.BI "Option " "\*qDefaultModes\*q " \*qbool\*q
+This optional entry specifies whether the server should add supported default
+modes to the list of modes offered on this monitor. By default, the server
+will add default modes; you should only disable this if you can guarantee
+that EDID will be available at all times, or if you have added custom modelines
+which the server can use.
+(RandR 1.2-supporting drivers only)
+.TP 7
+.BI "Option " "\*qMinClock\*q " \*qfrequency\*q
+This optional entry specifies the minimum dot clock, in kHz, that is supported
+by the monitor.
+.TP 7
+.BI "Option " "\*qMaxClock\*q " \*qfrequency\*q
+This optional entry specifies the maximum dot clock, in kHz, that is supported
+by the monitor.
+.TP 7
+.BI "Option " "\*qIgnore\*q " \*qbool\*q
+This optional entry specifies that the monitor should be ignored entirely,
+and not reported through RandR. This is useful if the hardware reports the
+presence of outputs that don't exist.
+(RandR 1.2-supporting drivers only)
+.TP 7
+.BI "Option " "\*qRotate\*q " \*qrotation\*q
+This optional entry specifies the initial rotation of the given monitor.
+Valid values for rotation are \*qnormal\*q, \*qleft\*q, \*qright\*q, and
+\*qinverted\*q.
+(RandR 1.2-supporting drivers only)
+
+.SH "MODES SECTION"
+The config file may have multiple
+.B Modes
+sections, or none.
+These sections provide a way of defining sets of video modes independently
+of the
+.B Monitor
+sections.
+.B Monitor
+sections may include the definitions provided in these sections by
+using the
+.B UseModes
+keyword.
+In most cases the
+.B Modes
+sections are not necessary because the built\-in set of VESA standard modes
+will be sufficient.
+.PP
+.B Modes
+sections have the following format:
+.PP
+.RS 4
+.nf
+.B "Section \*qModes\*q"
+.BI " Identifier \*q" name \*q
+.I " entries"
+.I " ..."
+.B "EndSection"
+.fi
+.RE
+.PP
+The
+.B Identifier
+entry specifies the unique name for this set of mode descriptions.
+The other entries permitted in
+.B Modes
+sections are the
+.B Mode
+and
+.B ModeLine
+entries that are described above in the
+.B Monitor
+section.
+.SH "SCREEN SECTION"
+The config file may have multiple
+.B Screen
+sections.
+There must be at least one, for the \(lqscreen\(rq being used.
+A \(lqscreen\(rq represents the binding of a graphics device
+.RB ( Device
+section) and a monitor
+.RB ( Monitor
+section).
+A
+.B Screen
+section is considered \(lqactive\(rq if it is referenced by an active
+.B ServerLayout
+section or by the
+.B \-screen
+command line option.
+If neither of those is present, the first
+.B Screen
+section found in the config file is considered the active one.
+.PP
+.B Screen
+sections have the following format:
+.PP
+.RS 4
+.nf
+.B "Section \*qScreen\*q"
+.BI " Identifier \*q" name \*q
+.BI " Device \*q" devid \*q
+.BI " Monitor \*q" monid \*q
+.I " entries"
+.I " ..."
+.BI " SubSection \*qDisplay\*q"
+.I " entries"
+.I " ...
+.B " EndSubSection"
+.I " ..."
+.B "EndSection"
+.fi
+.RE
+.PP
+The
+.B Identifier
+and
+.B Device
+entries are mandatory.
+All others are optional.
+.PP
+The
+.B Identifier
+entry specifies the unique name for this screen.
+The
+.B Screen
+section provides information specific to the whole screen, including
+screen\-specific
+.BR Options .
+In multi\-head configurations, there will be multiple active
+.B Screen
+sections, one for each head.
+The entries available
+for this section are:
+.TP 7
+.BI "Device \*q" device\-id \*q
+This mandatory entry specifies the
+.B Device
+section to be used for this screen.
+This is what ties a specific graphics card to a screen.
+The
+.I device\-id
+must match the
+.B Identifier
+of a
+.B Device
+section in the config file.
+.TP 7
+.BI "Monitor \*q" monitor\-id \*q
+specifies which monitor description is to be used for this screen.
+If a
+.B Monitor
+name is not specified, a default configuration is used.
+Currently the default configuration may not function as expected on all
+platforms.
+.TP 7
+.BI "VideoAdaptor \*q" xv\-id \*q
+specifies an optional Xv video adaptor description to be used with this
+screen.
+.TP 7
+.BI "DefaultDepth " depth
+specifies which color depth the server should use by default.
+The
+.B \-depth
+command line option can be used to override this.
+If neither is specified, the default depth is driver\-specific, but in most
+cases is 8.
+.TP 7
+.BI "DefaultFbBpp " bpp
+specifies which framebuffer layout to use by default.
+The
+.B \-fbbpp
+command line option can be used to override this.
+In most cases the driver will chose the best default value for this.
+The only case where there is even a choice in this value is for depth 24,
+where some hardware supports both a packed 24 bit framebuffer layout and a
+sparse 32 bit framebuffer layout.
+.TP 7
+.B Options
+Various
+.B Option
+flags may be specified in the
+.B Screen
+section.
+Some are driver\-specific and are described in the driver documentation.
+Others are driver\-independent, and will eventually be described here.
+.\" XXX These should really be in an xaa man page.
+.TP 7
+.BI "Option \*qAccel\*q"
+Enables XAA (X Acceleration Architecture), a mechanism that makes video cards'
+2D hardware acceleration available to the __xservername__ server.
+This option is on by default, but it may be necessary to turn it off if
+there are bugs in the driver.
+There are many options to disable specific accelerated operations, listed
+below.
+Note that disabling an operation will have no effect if the operation is
+not accelerated (whether due to lack of support in the hardware or in the
+driver).
+.TP 7
+.BI "Option \*qInitPrimary\*q \*q" boolean \*q
+Use the Int10 module to initialize the primary graphics card.
+Normally, only secondary cards are soft-booted using the Int10 module, as the
+primary card has already been initialized by the BIOS at boot time.
+Default: false.
+.TP 7
+.BI "Option \*qNoInt10\*q \*q" boolean \*q
+Disables the Int10 module, a module that uses the int10 call to the BIOS
+of the graphics card to initialize it.
+Default: false.
+.TP 7
+.BI "Option \*qNoMTRR\*q"
+Disables MTRR (Memory Type Range Register) support, a feature of modern
+processors which can improve video performance by a factor of up to 2.5.
+Some hardware has buggy MTRR support, and some video drivers have been
+known to exhibit problems when MTRR's are used.
+.TP 7
+.BI "Option \*qXaaNoCPUToScreenColorExpandFill\*q"
+Disables accelerated rectangular expansion blits from source patterns
+stored in system memory (using a memory\-mapped aperture).
+.TP 7
+.BI "Option \*qXaaNoColor8x8PatternFillRect\*q"
+Disables accelerated fills of a rectangular region with a full\-color
+pattern.
+.TP 7
+.BI "Option \*qXaaNoColor8x8PatternFillTrap\*q"
+Disables accelerated fills of a trapezoidal region with a full\-color
+pattern.
+.TP 7
+.BI "Option \*qXaaNoDashedBresenhamLine\*q"
+Disables accelerated dashed Bresenham line draws.
+.TP 7
+.BI "Option \*qXaaNoDashedTwoPointLine\*q"
+Disables accelerated dashed line draws between two arbitrary points.
+.TP 7
+.BI "Option \*qXaaNoImageWriteRect\*q"
+Disables accelerated transfers of full\-color rectangular patterns from
+system memory to video memory (using a memory\-mapped aperture).
+.TP 7
+.BI "Option \*qXaaNoMono8x8PatternFillRect\*q"
+Disables accelerated fills of a rectangular region with a monochrome
+pattern.
+.TP 7
+.BI "Option \*qXaaNoMono8x8PatternFillTrap\*q"
+Disables accelerated fills of a trapezoidal region with a monochrome
+pattern.
+.TP 7
+.BI "Option \*qXaaNoOffscreenPixmaps\*q"
+Disables accelerated draws into pixmaps stored in offscreen video memory.
+.TP 7
+.BI "Option \*qXaaNoPixmapCache\*q"
+Disables caching of patterns in offscreen video memory.
+.TP 7
+.BI "Option \*qXaaNoScanlineCPUToScreenColorExpandFill\*q"
+Disables accelerated rectangular expansion blits from source patterns
+stored in system memory (one scan line at a time).
+.TP 7
+.BI "Option \*qXaaNoScanlineImageWriteRect\*q"
+Disables accelerated transfers of full\-color rectangular patterns from
+system memory to video memory (one scan line at a time).
+.TP 7
+.BI "Option \*qXaaNoScreenToScreenColorExpandFill\*q"
+Disables accelerated rectangular expansion blits from source patterns
+stored in offscreen video memory.
+.TP 7
+.BI "Option \*qXaaNoScreenToScreenCopy\*q"
+Disables accelerated copies of rectangular regions from one part of
+video memory to another part of video memory.
+.TP 7
+.BI "Option \*qXaaNoSolidBresenhamLine\*q"
+Disables accelerated solid Bresenham line draws.
+.TP 7
+.BI "Option \*qXaaNoSolidFillRect\*q"
+Disables accelerated solid\-color fills of rectangles.
+.TP 7
+.BI "Option \*qXaaNoSolidFillTrap\*q"
+Disables accelerated solid\-color fills of Bresenham trapezoids.
+.TP 7
+.BI "Option \*qXaaNoSolidHorVertLine\*q"
+Disables accelerated solid horizontal and vertical line draws.
+.TP 7
+.BI "Option \*qXaaNoSolidTwoPointLine\*q"
+Disables accelerated solid line draws between two arbitrary points.
+.PP
+Each
+.B Screen
+section may optionally contain one or more
+.B Display
+subsections.
+Those subsections provide depth/fbbpp specific configuration information,
+and the one chosen depends on the depth and/or fbbpp that is being used for
+the screen.
+The
+.B Display
+subsection format is described in the section below.
+
+.SH "DISPLAY SUBSECTION"
+Each
+.B Screen
+section may have multiple
+.B Display
+subsections.
+The \(lqactive\(rq
+.B Display
+subsection is the first that matches the depth and/or fbbpp values being
+used, or failing that, the first that has neither a depth or fbbpp value
+specified.
+The
+.B Display
+subsections are optional.
+When there isn't one that matches the depth and/or fbbpp values being used,
+all the parameters that can be specified here fall back to their defaults.
+.PP
+.B Display
+subsections have the following format:
+.PP
+.RS 4
+.nf
+.B " SubSection \*qDisplay\*q"
+.BI " Depth " depth
+.I " entries"
+.I " ..."
+.B " EndSubSection"
+.fi
+.RE
+.TP 7
+.BI "Depth " depth
+This entry specifies what colour depth the
+.B Display
+subsection is to be used for.
+This entry is usually specified, but it may be omitted to create a match\-all
+.B Display
+subsection or when wishing to match only against the
+.B FbBpp
+parameter.
+The range of
+.I depth
+values that are allowed depends on the driver.
+Most drivers support 8, 15, 16 and 24.
+Some also support 1 and/or 4, and some may support other values (like 30).
+Note:
+.I depth
+means the number of bits in a pixel that are actually used to determine
+the pixel colour.
+32 is not a valid
+.I depth
+value.
+Most hardware that uses 32 bits per pixel only uses 24 of them to hold the
+colour information, which means that the colour depth is 24, not 32.
+.TP 7
+.BI "FbBpp " bpp
+This entry specifies the framebuffer format this
+.B Display
+subsection is to be used for.
+This entry is only needed when providing depth 24 configurations that allow
+a choice between a 24 bpp packed framebuffer format and a 32bpp sparse
+framebuffer format.
+In most cases this entry should not be used.
+.TP 7
+.BI "Weight " "red\-weight green\-weight blue\-weight"
+This optional entry specifies the relative RGB weighting to be used
+for a screen is being used at depth 16 for drivers that allow multiple
+formats.
+This may also be specified from the command line with the
+.B \-weight
+option (see
+.BR __xservername__(__appmansuffix__)).
+.TP 7
+.BI "Virtual " "xdim ydim"
+This optional entry specifies the virtual screen resolution to be used.
+.I xdim
+must be a multiple of either 8 or 16 for most drivers, and a multiple
+of 32 when running in monochrome mode.
+The given value will be rounded down if this is not the case.
+Video modes which are too large for the specified virtual size will be
+rejected.
+If this entry is not present, the virtual screen resolution will be set to
+accommodate all the valid video modes given in the
+.B Modes
+entry.
+Some drivers/hardware combinations do not support virtual screens.
+Refer to the appropriate driver\-specific documentation for details.
+.TP 7
+.BI "ViewPort " "x0 y0"
+This optional entry sets the upper left corner of the initial display.
+This is only relevant when the virtual screen resolution is different
+from the resolution of the initial video mode.
+If this entry is not given, then the initial display will be centered in
+the virtual display area.
+.TP 7
+.BI "Modes \*q" mode\-name \*q " ..."
+This optional entry specifies the list of video modes to use.
+Each
+.I mode\-name
+specified must be in double quotes.
+They must correspond to those specified or referenced in the appropriate
+.B Monitor
+section (including implicitly referenced built\-in VESA standard modes).
+The server will delete modes from this list which don't satisfy various
+requirements.
+The first valid mode in this list will be the default display mode for
+startup.
+The list of valid modes is converted internally into a circular list.
+It is possible to switch to the next mode with
+.B Ctrl+Alt+Keypad\-Plus
+and to the previous mode with
+.BR Ctrl+Alt+Keypad\-Minus .
+When this entry is omitted, the valid modes referenced by the appropriate
+.B Monitor
+section will be used. If the
+.B Monitor
+section contains no modes, then the selection will be taken from the
+built-in VESA standard modes.
+.TP 7
+.BI "Visual \*q" visual\-name \*q
+This optional entry sets the default root visual type.
+This may also be specified from the command line (see the
+.BR Xserver(__appmansuffix__)
+man page).
+The visual types available for depth 8 are (default is
+.BR PseudoColor ):
+.PP
+.RS 11
+.nf
+.B StaticGray
+.B GrayScale
+.B StaticColor
+.B PseudoColor
+.B TrueColor
+.B DirectColor
+.fi
+.RE
+.PP
+.RS 7
+The visual type available for the depths 15, 16 and 24 are (default is
+.BR TrueColor ):
+.PP
+.RS 4
+.nf
+.B TrueColor
+.B DirectColor
+.fi
+.RE
+.PP
+Not all drivers support
+.B DirectColor
+at these depths.
+.PP
+The visual types available for the depth 4 are (default is
+.BR StaticColor ):
+.PP
+.RS 4
+.nf
+.B StaticGray
+.B GrayScale
+.B StaticColor
+.B PseudoColor
+.fi
+.RE
+.PP
+The visual type available for the depth 1 (monochrome) is
+.BR StaticGray .
+.RE
+.TP 7
+.BI "Black " "red green blue"
+This optional entry allows the \(lqblack\(rq colour to be specified.
+This is only supported at depth 1.
+The default is black.
+.TP 7
+.BI "White " "red green blue"
+This optional entry allows the \(lqwhite\(rq colour to be specified.
+This is only supported at depth 1.
+The default is white.
+.TP 7
+.B Options
+Option flags may be specified in the
+.B Display
+subsections.
+These may include driver\-specific options and driver\-independent options.
+The former are described in the driver\-specific documentation.
+Some of the latter are described above in the section about the
+.B Screen
+section, and they may also be included here.
+.SH "SERVERLAYOUT SECTION"
+The config file may have multiple
+.B ServerLayout
+sections.
+A \(lqserver layout\(rq represents the binding of one or more screens
+.RB ( Screen
+sections) and one or more input devices
+.RB ( InputDevice
+sections) to form a complete configuration.
+In multi\-head configurations, it also specifies the relative layout of the
+heads.
+A
+.B ServerLayout
+section is considered \(lqactive\(rq if it is referenced by the
+.B \-layout
+command line option or by an
+.B "Option \*qDefaultServerLayout\*q"
+entry in the
+.B ServerFlags
+section (the former takes precedence over the latter).
+If those options are not used, the first
+.B ServerLayout
+section found in the config file is considered the active one.
+If no
+.B ServerLayout
+sections are present, the single active screen and two active (core)
+input devices are selected as described in the relevant sections above.
+.PP
+.B ServerLayout
+sections have the following format:
+.PP
+.RS 4
+.nf
+.B "Section \*qServerLayout\*q"
+.BI " Identifier \*q" name \*q
+.BI " Screen \*q" screen\-id \*q
+.I " ..."
+.BI " InputDevice \*q" idev\-id \*q
+.I " ..."
+.I " options"
+.I " ..."
+.B "EndSection"
+.fi
+.RE
+.PP
+Each
+.B ServerLayout
+section must have an
+.B Identifier
+entry and at least one
+.B Screen
+entry.
+.PP
+The
+.B Identifier
+entry specifies the unique name for this server layout.
+The
+.B ServerLayout
+section provides information specific to the whole session, including
+session\-specific
+.BR Options .
+The
+.B ServerFlags
+options (described above) may be specified here, and ones given here
+override those given in the
+.B ServerFlags
+section.
+.PP
+The entries that may be used in this section are described here.
+.TP 7
+.BI "Screen " "screen\-num" " \*qscreen\-id\*q " "position\-information"
+One of these entries must be given for each screen being used in
+a session.
+The
+.I screen\-id
+field is mandatory, and specifies the
+.B Screen
+section being referenced.
+The
+.I screen\-num
+field is optional, and may be used to specify the screen number
+in multi\-head configurations.
+When this field is omitted, the screens will be numbered in the order that
+they are listed in.
+The numbering starts from 0, and must be consecutive.
+The
+.I position\-information
+field describes the way multiple screens are positioned.
+There are a number of different ways that this information can be provided:
+.RS 7
+.TP 4
+.I "x y"
+.TP 4
+.BI "Absolute " "x y"
+These both specify that the upper left corner's coordinates are
+.RI ( x , y ).
+The
+.B Absolute
+keyword is optional.
+Some older versions of XFree86 (4.2 and earlier) don't recognise the
+.B Absolute
+keyword, so it's safest to just specify the coordinates without it.
+.TP 4
+.BI "RightOf \*q" screen\-id \*q
+.TP 4
+.BI "LeftOf \*q" screen\-id \*q
+.TP 4
+.BI "Above \*q" screen\-id \*q
+.TP 4
+.BI "Below \*q" screen\-id \*q
+.TP 4
+.BI "Relative \*q" screen\-id \*q " x y"
+These give the screen's location relative to another screen.
+The first four position the screen immediately to the right, left, above or
+below the other screen.
+When positioning to the right or left, the top edges are aligned.
+When positioning above or below, the left edges are aligned.
+The
+.B Relative
+form specifies the offset of the screen's origin (upper left corner)
+relative to the origin of another screen.
+.RE
+.TP 7
+.BI "InputDevice \*q" idev\-id "\*q \*q" option \*q " ..."
+One of these entries should be given for each input device being used in
+a session.
+Normally at least two are required, one each for the core pointer and
+keyboard devices.
+If either of those is missing, suitable
+.B InputDevice
+entries are searched for using the method described above in the
+.B INPUTDEVICE
+section. The
+.I idev\-id
+field is mandatory, and specifies the name of the
+.B InputDevice
+section being referenced.
+Multiple
+.I option
+fields may be specified, each in double quotes.
+The options permitted here are any that may also be given in the
+.B InputDevice
+sections.
+Normally only session\-specific input device options would be used here.
+The most commonly used options are:
+.PP
+.RS 11
+.nf
+.B \*qCorePointer\*q
+.B \*qCoreKeyboard\*q
+.B \*qSendCoreEvents\*q
+.fi
+.RE
+.PP
+.RS 7
+and the first two should normally be used to indicate the core pointer
+and core keyboard devices respectively.
+.RE
+.TP 7
+.B Options
+In addition to the following, any option permitted in the
+.B ServerFlags
+section may also be specified here.
+When the same option appears in both places, the value given here overrides
+the one given in the
+.B ServerFlags
+section.
+.TP 7
+.BI "Option \*qIsolateDevice\*q \*q" bus\-id \*q
+Restrict device resets to the specified
+.IR bus\-id .
+See the
+.B BusID
+option (described in
+.BR "DEVICE SECTION" ,
+above) for the format of the
+.I bus\-id
+parameter.
+This option overrides
+.BR SingleCard ,
+if specified.
+At present, only PCI devices can be isolated in this manner.
+.TP 7
+.BI "Option \*qSingleCard\*q \*q" boolean \*q
+As
+.BR IsolateDevice ,
+except that the bus ID of the first device in the layout is used.
+.PP
+Here is an example of a
+.B ServerLayout
+section for a dual headed configuration with two mice:
+.PP
+.RS 4
+.nf
+.B "Section \*qServerLayout\*q"
+.B " Identifier \*qLayout 1\*q"
+.B " Screen \*qMGA 1\*q"
+.B " Screen \*qMGA 2\*q RightOf \*qMGA 1\*q"
+.B " InputDevice \*qKeyboard 1\*q \*qCoreKeyboard\*q"
+.B " InputDevice \*qMouse 1\*q \*qCorePointer\*q"
+.B " InputDevice \*qMouse 2\*q \*qSendCoreEvents\*q"
+.B " Option \*qBlankTime\*q \*q5\*q"
+.B "EndSection"
+.fi
+.RE
+.SH "DRI SECTION"
+This optional section is used to provide some information for the
+Direct Rendering Infrastructure.
+Details about the format of this section can be found on-line at
+.IR <http://dri.freedesktop.org/> .
+.SH "VENDOR SECTION"
+The optional
+.B Vendor
+section may be used to provide vendor\-specific configuration information.
+Multiple
+.B Vendor
+sections may be present, and they may contain an
+.B Identifier
+entry and multiple
+.B Option
+flags.
+The data therein is not used in this release.
+.PP
+.SH "SEE ALSO"
+General:
+.BR X (__miscmansuffix__),
+.BR Xserver (__appmansuffix__),
+.BR __xservername__ (__appmansuffix__),
+.BR cvt (__appmansuffix__),
+.BR gtf (__appmansuffix__).
+.PP
+.B "Not all modules or interfaces are available on all platforms."
+.PP
+Display drivers:
+.BR apm (__drivermansuffix__),
+.BR ati (__drivermansuffix__),
+.BR chips (__drivermansuffix__),
+.BR cirrus (__drivermansuffix__),
+.BR cyrix (__drivermansuffix__),
+.BR fbdev (__drivermansuffix__),
+.BR glide (__drivermansuffix__),
+.BR glint (__drivermansuffix__),
+.BR i128 (__drivermansuffix__),
+.BR i740 (__drivermansuffix__),
+.BR imstt (__drivermansuffix__),
+.BR intel (__drivermansuffix__),
+.BR mga (__drivermansuffix__),
+.BR neomagic (__drivermansuffix__),
+.BR nv (__drivermansuffix__),
+.BR openchrome (__drivermansuffix__),
+.BR r128 (__drivermansuffix__),
+.BR radeon (__drivermansuffix__),
+.BR rendition (__drivermansuffix__),
+.BR savage (__drivermansuffix__),
+.BR s3virge (__drivermansuffix__),
+.BR siliconmotion (__drivermansuffix__),
+.BR sis (__drivermansuffix__),
+.BR sisusb (__drivermansuffix__),
+.BR sunbw2 (__drivermansuffix__),
+.BR suncg14 (__drivermansuffix__),
+.BR suncg3 (__drivermansuffix__),
+.BR suncg6 (__drivermansuffix__),
+.BR sunffb (__drivermansuffix__),
+.BR sunleo (__drivermansuffix__),
+.BR suntcx (__drivermansuffix__),
+.BR tdfx (__drivermansuffix__),
+.\" .BR tga (__drivermansuffix__),
+.BR trident (__drivermansuffix__),
+.BR tseng (__drivermansuffix__),
+.BR vesa (__drivermansuffix__),
+.BR vmware (__drivermansuffix__),
+.BR voodoo (__drivermansuffix__),
+.BR wsfb (__drivermansuffix__),
+.BR xgi (__drivermansuffix__),
+.BR xgixp (__drivermansuffix__).
+.PP
+Input drivers:
+.BR acecad (__drivermansuffix__),
+.BR citron (__drivermansuffix__),
+.BR elographics (__drivermansuffix__),
+.BR evdev (__drivermansuffix__),
+.BR fpit (__drivermansuffix__),
+.BR joystick (__drivermansuffix__),
+.BR kbd (__drivermansuffix__),
+.BR mousedrv (__drivermansuffix__),
+.BR mutouch (__drivermansuffix__),
+.BR penmount (__drivermansuffix__),
+.BR synaptics (__drivermansuffix__),
+.BR vmmouse (__drivermansuffix__),
+.BR void (__drivermansuffix__),
+.BR wacom (__drivermansuffix__).
+.PP
+Other modules and interfaces:
+.BR exa (__drivermansuffix__),
+.BR fbdevhw (__drivermansuffix__),
+.\" .BR shadowfb (__drivermansuffix__),
+.BR v4l (__drivermansuffix__).
+.br
+.SH AUTHORS
+This manual page was largely rewritten by David Dawes
+.IR <dawes@xfree86.org> .
diff --git a/xorg-server/hw/xfree86/modes/xf86Crtc.h b/xorg-server/hw/xfree86/modes/xf86Crtc.h
index 5dfcec280..68a968cc2 100644
--- a/xorg-server/hw/xfree86/modes/xf86Crtc.h
+++ b/xorg-server/hw/xfree86/modes/xf86Crtc.h
@@ -1,972 +1,972 @@
-/*
- * Copyright © 2006 Keith Packard
- *
- * 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 copyright holders not be used in advertising or
- * publicity pertaining to distribution of the software without specific,
- * written prior permission. The copyright holders make no representations
- * about the suitability of this software for any purpose. It is provided "as
- * is" without express or implied warranty.
- *
- * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE COPYRIGHT HOLDERS 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.
- */
-#ifndef _XF86CRTC_H_
-#define _XF86CRTC_H_
-
-#include <edid.h>
-#include "randrstr.h"
-#if XF86_MODES_RENAME
-#include "xf86Rename.h"
-#endif
-#include "xf86Modes.h"
-#include "xf86Cursor.h"
-#include "xf86i2c.h"
-#include "damage.h"
-#include "picturestr.h"
-
-/* Compat definitions for older X Servers. */
-#ifndef M_T_PREFERRED
-#define M_T_PREFERRED 0x08
-#endif
-#ifndef M_T_DRIVER
-#define M_T_DRIVER 0x40
-#endif
-#ifndef M_T_USERPREF
-#define M_T_USERPREF 0x80
-#endif
-#ifndef HARDWARE_CURSOR_ARGB
-#define HARDWARE_CURSOR_ARGB 0x00004000
-#endif
-
-typedef struct _xf86Crtc xf86CrtcRec, *xf86CrtcPtr;
-typedef struct _xf86Output xf86OutputRec, *xf86OutputPtr;
-
-/* define a standard for connector types */
-typedef enum _xf86ConnectorType {
- XF86ConnectorNone,
- XF86ConnectorVGA,
- XF86ConnectorDVI_I,
- XF86ConnectorDVI_D,
- XF86ConnectorDVI_A,
- XF86ConnectorComposite,
- XF86ConnectorSvideo,
- XF86ConnectorComponent,
- XF86ConnectorLFP,
- XF86ConnectorProprietary,
- XF86ConnectorHDMI,
- XF86ConnectorDisplayPort,
-} xf86ConnectorType;
-
-typedef enum _xf86OutputStatus {
- XF86OutputStatusConnected,
- XF86OutputStatusDisconnected,
- XF86OutputStatusUnknown
-} xf86OutputStatus;
-
-typedef struct _xf86CrtcFuncs {
- /**
- * Turns the crtc on/off, or sets intermediate power levels if available.
- *
- * Unsupported intermediate modes drop to the lower power setting. If the
- * mode is DPMSModeOff, the crtc must be disabled sufficiently for it to
- * be safe to call mode_set.
- */
- void
- (*dpms)(xf86CrtcPtr crtc,
- int mode);
-
- /**
- * Saves the crtc's state for restoration on VT switch.
- */
- void
- (*save)(xf86CrtcPtr crtc);
-
- /**
- * Restore's the crtc's state at VT switch.
- */
- void
- (*restore)(xf86CrtcPtr crtc);
-
- /**
- * Lock CRTC prior to mode setting, mostly for DRI.
- * Returns whether unlock is needed
- */
- Bool
- (*lock) (xf86CrtcPtr crtc);
-
- /**
- * Unlock CRTC after mode setting, mostly for DRI
- */
- void
- (*unlock) (xf86CrtcPtr crtc);
-
- /**
- * Callback to adjust the mode to be set in the CRTC.
- *
- * This allows a CRTC to adjust the clock or even the entire set of
- * timings, which is used for panels with fixed timings or for
- * buses with clock limitations.
- */
- Bool
- (*mode_fixup)(xf86CrtcPtr crtc,
- DisplayModePtr mode,
- DisplayModePtr adjusted_mode);
-
- /**
- * Prepare CRTC for an upcoming mode set.
- */
- void
- (*prepare)(xf86CrtcPtr crtc);
-
- /**
- * Callback for setting up a video mode after fixups have been made.
- */
- void
- (*mode_set)(xf86CrtcPtr crtc,
- DisplayModePtr mode,
- DisplayModePtr adjusted_mode,
- int x, int y);
-
- /**
- * Commit mode changes to a CRTC
- */
- void
- (*commit)(xf86CrtcPtr crtc);
-
- /* Set the color ramps for the CRTC to the given values. */
- void
- (*gamma_set)(xf86CrtcPtr crtc, CARD16 *red, CARD16 *green, CARD16 *blue,
- int size);
-
- /**
- * Allocate the shadow area, delay the pixmap creation until needed
- */
- void *
- (*shadow_allocate) (xf86CrtcPtr crtc, int width, int height);
-
- /**
- * Create shadow pixmap for rotation support
- */
- PixmapPtr
- (*shadow_create) (xf86CrtcPtr crtc, void *data, int width, int height);
-
- /**
- * Destroy shadow pixmap
- */
- void
- (*shadow_destroy) (xf86CrtcPtr crtc, PixmapPtr pPixmap, void *data);
-
- /**
- * Set cursor colors
- */
- void
- (*set_cursor_colors) (xf86CrtcPtr crtc, int bg, int fg);
-
- /**
- * Set cursor position
- */
- void
- (*set_cursor_position) (xf86CrtcPtr crtc, int x, int y);
-
- /**
- * Show cursor
- */
- void
- (*show_cursor) (xf86CrtcPtr crtc);
-
- /**
- * Hide cursor
- */
- void
- (*hide_cursor) (xf86CrtcPtr crtc);
-
- /**
- * Load monochrome image
- */
- void
- (*load_cursor_image) (xf86CrtcPtr crtc, CARD8 *image);
-
- /**
- * Load ARGB image
- */
- void
- (*load_cursor_argb) (xf86CrtcPtr crtc, CARD32 *image);
-
- /**
- * Clean up driver-specific bits of the crtc
- */
- void
- (*destroy) (xf86CrtcPtr crtc);
-
- /**
- * Less fine-grained mode setting entry point for kernel modesetting
- */
- Bool
- (*set_mode_major)(xf86CrtcPtr crtc, DisplayModePtr mode,
- Rotation rotation, int x, int y);
-
- /**
- * Callback for panning. Doesn't change the mode.
- * Added in ABI version 2
- */
- void
- (*set_origin)(xf86CrtcPtr crtc, int x, int y);
-
-} xf86CrtcFuncsRec, *xf86CrtcFuncsPtr;
-
-#define XF86_CRTC_VERSION 3
-
-struct _xf86Crtc {
- /**
- * ABI versioning
- */
- int version;
-
- /**
- * Associated ScrnInfo
- */
- ScrnInfoPtr scrn;
-
- /**
- * Desired state of this CRTC
- *
- * Set when this CRTC should be driving one or more outputs
- */
- Bool enabled;
-
- /**
- * Active mode
- *
- * This reflects the mode as set in the CRTC currently
- * It will be cleared when the VT is not active or
- * during server startup
- */
- DisplayModeRec mode;
- Rotation rotation;
- PixmapPtr rotatedPixmap;
- void *rotatedData;
-
- /**
- * Position on screen
- *
- * Locates this CRTC within the frame buffer
- */
- int x, y;
-
- /**
- * Desired mode
- *
- * This is set to the requested mode, independent of
- * whether the VT is active. In particular, it receives
- * the startup configured mode and saves the active mode
- * on VT switch.
- */
- DisplayModeRec desiredMode;
- Rotation desiredRotation;
- int desiredX, desiredY;
-
- /** crtc-specific functions */
- const xf86CrtcFuncsRec *funcs;
-
- /**
- * Driver private
- *
- * Holds driver-private information
- */
- void *driver_private;
-
-#ifdef RANDR_12_INTERFACE
- /**
- * RandR crtc
- *
- * When RandR 1.2 is available, this
- * points at the associated crtc object
- */
- RRCrtcPtr randr_crtc;
-#else
- void *randr_crtc;
-#endif
-
- /**
- * Current cursor is ARGB
- */
- Bool cursor_argb;
- /**
- * Track whether cursor is within CRTC range
- */
- Bool cursor_in_range;
- /**
- * Track state of cursor associated with this CRTC
- */
- Bool cursor_shown;
-
- /**
- * Current transformation matrix
- */
- PictTransform crtc_to_framebuffer;
- /* framebuffer_to_crtc was removed in ABI 2 */
- struct pict_f_transform f_crtc_to_framebuffer; /* ABI 2 */
- struct pict_f_transform f_framebuffer_to_crtc; /* ABI 2 */
- PictFilterPtr filter; /* ABI 2 */
- xFixed *params; /* ABI 2 */
- int nparams; /* ABI 2 */
- int filter_width; /* ABI 2 */
- int filter_height; /* ABI 2 */
- Bool transform_in_use;
- RRTransformRec transform; /* ABI 2 */
- Bool transformPresent; /* ABI 2 */
- RRTransformRec desiredTransform; /* ABI 2 */
- Bool desiredTransformPresent; /* ABI 2 */
- /**
- * Bounding box in screen space
- */
- BoxRec bounds;
- /**
- * Panning:
- * TotalArea: total panning area, larger than CRTC's size
- * TrackingArea: Area of the pointer for which the CRTC is panned
- * border: Borders of the displayed CRTC area which induces panning if the pointer reaches them
- * Added in ABI version 2
- */
- BoxRec panningTotalArea;
- BoxRec panningTrackingArea;
- INT16 panningBorder[4];
-
- /**
- * Current gamma, especially useful after initial config.
- * Added in ABI version 3
- */
- CARD16 *gamma_red;
- CARD16 *gamma_green;
- CARD16 *gamma_blue;
- int gamma_size;
-
- /**
- * Actual state of this CRTC
- *
- * Set to TRUE after modesetting, set to FALSE if no outputs are connected
- * Added in ABI version 3
- */
- Bool active;
- /**
- * Clear the shadow
- */
- Bool shadowClear;
-};
-
-typedef struct _xf86OutputFuncs {
- /**
- * Called to allow the output a chance to create properties after the
- * RandR objects have been created.
- */
- void
- (*create_resources)(xf86OutputPtr output);
-
- /**
- * Turns the output on/off, or sets intermediate power levels if available.
- *
- * Unsupported intermediate modes drop to the lower power setting. If the
- * mode is DPMSModeOff, the output must be disabled, as the DPLL may be
- * disabled afterwards.
- */
- void
- (*dpms)(xf86OutputPtr output,
- int mode);
-
- /**
- * Saves the output's state for restoration on VT switch.
- */
- void
- (*save)(xf86OutputPtr output);
-
- /**
- * Restore's the output's state at VT switch.
- */
- void
- (*restore)(xf86OutputPtr output);
-
- /**
- * Callback for testing a video mode for a given output.
- *
- * This function should only check for cases where a mode can't be supported
- * on the output specifically, and not represent generic CRTC limitations.
- *
- * \return MODE_OK if the mode is valid, or another MODE_* otherwise.
- */
- int
- (*mode_valid)(xf86OutputPtr output,
- DisplayModePtr pMode);
-
- /**
- * Callback to adjust the mode to be set in the CRTC.
- *
- * This allows an output to adjust the clock or even the entire set of
- * timings, which is used for panels with fixed timings or for
- * buses with clock limitations.
- */
- Bool
- (*mode_fixup)(xf86OutputPtr output,
- DisplayModePtr mode,
- DisplayModePtr adjusted_mode);
-
- /**
- * Callback for preparing mode changes on an output
- */
- void
- (*prepare)(xf86OutputPtr output);
-
- /**
- * Callback for committing mode changes on an output
- */
- void
- (*commit)(xf86OutputPtr output);
-
- /**
- * Callback for setting up a video mode after fixups have been made.
- *
- * This is only called while the output is disabled. The dpms callback
- * must be all that's necessary for the output, to turn the output on
- * after this function is called.
- */
- void
- (*mode_set)(xf86OutputPtr output,
- DisplayModePtr mode,
- DisplayModePtr adjusted_mode);
-
- /**
- * Probe for a connected output, and return detect_status.
- */
- xf86OutputStatus
- (*detect)(xf86OutputPtr output);
-
- /**
- * Query the device for the modes it provides.
- *
- * This function may also update MonInfo, mm_width, and mm_height.
- *
- * \return singly-linked list of modes or NULL if no modes found.
- */
- DisplayModePtr
- (*get_modes)(xf86OutputPtr output);
-
-#ifdef RANDR_12_INTERFACE
- /**
- * Callback when an output's property has changed.
- */
- Bool
- (*set_property)(xf86OutputPtr output,
- Atom property,
- RRPropertyValuePtr value);
-#endif
-#ifdef RANDR_13_INTERFACE
- /**
- * Callback to get an updated property value
- */
- Bool
- (*get_property)(xf86OutputPtr output,
- Atom property);
-#endif
-#ifdef RANDR_GET_CRTC_INTERFACE
- /**
- * Callback to get current CRTC for a given output
- */
- xf86CrtcPtr
- (*get_crtc)(xf86OutputPtr output);
-#endif
- /**
- * Clean up driver-specific bits of the output
- */
- void
- (*destroy) (xf86OutputPtr output);
-} xf86OutputFuncsRec, *xf86OutputFuncsPtr;
-
-
-#define XF86_OUTPUT_VERSION 2
-
-struct _xf86Output {
- /**
- * ABI versioning
- */
- int version;
-
- /**
- * Associated ScrnInfo
- */
- ScrnInfoPtr scrn;
-
- /**
- * Currently connected crtc (if any)
- *
- * If this output is not in use, this field will be NULL.
- */
- xf86CrtcPtr crtc;
-
- /**
- * Possible CRTCs for this output as a mask of crtc indices
- */
- CARD32 possible_crtcs;
-
- /**
- * Possible outputs to share the same CRTC as a mask of output indices
- */
- CARD32 possible_clones;
-
- /**
- * Whether this output can support interlaced modes
- */
- Bool interlaceAllowed;
-
- /**
- * Whether this output can support double scan modes
- */
- Bool doubleScanAllowed;
-
- /**
- * List of available modes on this output.
- *
- * This should be the list from get_modes(), plus perhaps additional
- * compatible modes added later.
- */
- DisplayModePtr probed_modes;
-
- /**
- * Options parsed from the related monitor section
- */
- OptionInfoPtr options;
-
- /**
- * Configured monitor section
- */
- XF86ConfMonitorPtr conf_monitor;
-
- /**
- * Desired initial position
- */
- int initial_x, initial_y;
-
- /**
- * Desired initial rotation
- */
- Rotation initial_rotation;
-
- /**
- * Current connection status
- *
- * This indicates whether a monitor is known to be connected
- * to this output or not, or whether there is no way to tell
- */
- xf86OutputStatus status;
-
- /** EDID monitor information */
- xf86MonPtr MonInfo;
-
- /** subpixel order */
- int subpixel_order;
-
- /** Physical size of the currently attached output device. */
- int mm_width, mm_height;
-
- /** Output name */
- char *name;
-
- /** output-specific functions */
- const xf86OutputFuncsRec *funcs;
-
- /** driver private information */
- void *driver_private;
-
- /** Whether to use the old per-screen Monitor config section */
- Bool use_screen_monitor;
-
-#ifdef RANDR_12_INTERFACE
- /**
- * RandR 1.2 output structure.
- *
- * When RandR 1.2 is available, this points at the associated
- * RandR output structure and is created when this output is created
- */
- RROutputPtr randr_output;
-#else
- void *randr_output;
-#endif
- /**
- * Desired initial panning
- * Added in ABI version 2
- */
- BoxRec initialTotalArea;
- BoxRec initialTrackingArea;
- INT16 initialBorder[4];
-};
-
-typedef struct _xf86CrtcConfigFuncs {
- /**
- * Requests that the driver resize the screen.
- *
- * The driver is responsible for updating scrn->virtualX and scrn->virtualY.
- * If the requested size cannot be set, the driver should leave those values
- * alone and return FALSE.
- *
- * A naive driver that cannot reallocate the screen may simply change
- * virtual[XY]. A more advanced driver will want to also change the
- * devPrivate.ptr and devKind of the screen pixmap, update any offscreen
- * pixmaps it may have moved, and change pScrn->displayWidth.
- */
- Bool
- (*resize)(ScrnInfoPtr scrn,
- int width,
- int height);
-} xf86CrtcConfigFuncsRec, *xf86CrtcConfigFuncsPtr;
-
-typedef void (*xf86_crtc_notify_proc_ptr) (ScreenPtr pScreen);
-
-typedef struct _xf86CrtcConfig {
- int num_output;
- xf86OutputPtr *output;
- /**
- * compat_output is used whenever we deal
- * with legacy code that only understands a single
- * output. pScrn->modes will be loaded from this output,
- * adjust frame will whack this output, etc.
- */
- int compat_output;
-
- int num_crtc;
- xf86CrtcPtr *crtc;
-
- int minWidth, minHeight;
- int maxWidth, maxHeight;
-
- /* For crtc-based rotation */
- DamagePtr rotation_damage;
- Bool rotation_damage_registered;
-
- /* DGA */
- unsigned int dga_flags;
- unsigned long dga_address;
- DGAModePtr dga_modes;
- int dga_nmode;
- int dga_width, dga_height, dga_stride;
- DisplayModePtr dga_save_mode;
-
- const xf86CrtcConfigFuncsRec *funcs;
-
- CreateScreenResourcesProcPtr CreateScreenResources;
-
- CloseScreenProcPtr CloseScreen;
-
- /* Cursor information */
- xf86CursorInfoPtr cursor_info;
- CursorPtr cursor;
- CARD8 *cursor_image;
- Bool cursor_on;
- CARD32 cursor_fg, cursor_bg;
-
- /**
- * Options parsed from the related device section
- */
- OptionInfoPtr options;
-
- Bool debug_modes;
-
- /* wrap screen BlockHandler for rotation */
- ScreenBlockHandlerProcPtr BlockHandler;
-
- /* callback when crtc configuration changes */
- xf86_crtc_notify_proc_ptr xf86_crtc_notify;
-
-} xf86CrtcConfigRec, *xf86CrtcConfigPtr;
-
-extern _X_EXPORT int xf86CrtcConfigPrivateIndex;
-
-#define XF86_CRTC_CONFIG_PTR(p) ((xf86CrtcConfigPtr) ((p)->privates[xf86CrtcConfigPrivateIndex].ptr))
-
-static _X_INLINE xf86OutputPtr
-xf86CompatOutput(ScrnInfoPtr pScrn)
-{
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
- return config->output[config->compat_output];
-}
-
-static _X_INLINE xf86CrtcPtr
-xf86CompatCrtc(ScrnInfoPtr pScrn)
-{
- xf86OutputPtr compat_output = xf86CompatOutput(pScrn);
- if (!compat_output)
- return NULL;
- return compat_output->crtc;
-}
-
-static _X_INLINE RRCrtcPtr
-xf86CompatRRCrtc(ScrnInfoPtr pScrn)
-{
- xf86CrtcPtr compat_crtc = xf86CompatCrtc(pScrn);
- if (!compat_crtc)
- return NULL;
- return compat_crtc->randr_crtc;
-}
-
-
-/*
- * Initialize xf86CrtcConfig structure
- */
-
-extern _X_EXPORT void
-xf86CrtcConfigInit (ScrnInfoPtr scrn,
- const xf86CrtcConfigFuncsRec *funcs);
-
-extern _X_EXPORT void
-xf86CrtcSetSizeRange (ScrnInfoPtr scrn,
- int minWidth, int minHeight,
- int maxWidth, int maxHeight);
-
-/*
- * Crtc functions
- */
-extern _X_EXPORT xf86CrtcPtr
-xf86CrtcCreate (ScrnInfoPtr scrn,
- const xf86CrtcFuncsRec *funcs);
-
-extern _X_EXPORT void
-xf86CrtcDestroy (xf86CrtcPtr crtc);
-
-
-/**
- * Sets the given video mode on the given crtc
- */
-
-extern _X_EXPORT Bool
-xf86CrtcSetModeTransform (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation,
- RRTransformPtr transform, int x, int y);
-
-extern _X_EXPORT Bool
-xf86CrtcSetMode (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation,
- int x, int y);
-
-extern _X_EXPORT void
-xf86CrtcSetOrigin (xf86CrtcPtr crtc, int x, int y);
-
-/*
- * Assign crtc rotation during mode set
- */
-extern _X_EXPORT Bool
-xf86CrtcRotate (xf86CrtcPtr crtc);
-
-/*
- * Clean up any rotation data, used when a crtc is turned off
- * as well as when rotation is disabled.
- */
-extern _X_EXPORT void
-xf86RotateDestroy (xf86CrtcPtr crtc);
-
-/*
- * free shadow memory allocated for all crtcs
- */
-extern _X_EXPORT void
-xf86RotateFreeShadow(ScrnInfoPtr pScrn);
-
-/*
- * Clean up rotation during CloseScreen
- */
-extern _X_EXPORT void
-xf86RotateCloseScreen (ScreenPtr pScreen);
-
-/**
- * Return whether any output is assigned to the crtc
- */
-extern _X_EXPORT Bool
-xf86CrtcInUse (xf86CrtcPtr crtc);
-
-/*
- * Output functions
- */
-extern _X_EXPORT xf86OutputPtr
-xf86OutputCreate (ScrnInfoPtr scrn,
- const xf86OutputFuncsRec *funcs,
- const char *name);
-
-extern _X_EXPORT void
-xf86OutputUseScreenMonitor (xf86OutputPtr output, Bool use_screen_monitor);
-
-extern _X_EXPORT Bool
-xf86OutputRename (xf86OutputPtr output, const char *name);
-
-extern _X_EXPORT void
-xf86OutputDestroy (xf86OutputPtr output);
-
-extern _X_EXPORT void
-xf86ProbeOutputModes (ScrnInfoPtr pScrn, int maxX, int maxY);
-
-extern _X_EXPORT void
-xf86SetScrnInfoModes (ScrnInfoPtr pScrn);
-
-#ifdef RANDR_13_INTERFACE
-# define ScreenInitRetType int
-#else
-# define ScreenInitRetType Bool
-#endif
-
-extern _X_EXPORT ScreenInitRetType
-xf86CrtcScreenInit (ScreenPtr pScreen);
-
-extern _X_EXPORT Bool
-xf86InitialConfiguration (ScrnInfoPtr pScrn, Bool canGrow);
-
-extern _X_EXPORT void
-xf86DPMSSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags);
-
-extern _X_EXPORT Bool
-xf86SaveScreen(ScreenPtr pScreen, int mode);
-
-extern _X_EXPORT void
-xf86DisableUnusedFunctions(ScrnInfoPtr pScrn);
-
-extern _X_EXPORT DisplayModePtr
-xf86OutputFindClosestMode (xf86OutputPtr output, DisplayModePtr desired);
-
-extern _X_EXPORT Bool
-xf86SetSingleMode (ScrnInfoPtr pScrn, DisplayModePtr desired, Rotation rotation);
-
-/**
- * Set the EDID information for the specified output
- */
-extern _X_EXPORT void
-xf86OutputSetEDID (xf86OutputPtr output, xf86MonPtr edid_mon);
-
-/**
- * Return the list of modes supported by the EDID information
- * stored in 'output'
- */
-extern _X_EXPORT DisplayModePtr
-xf86OutputGetEDIDModes (xf86OutputPtr output);
-
-extern _X_EXPORT xf86MonPtr
-xf86OutputGetEDID (xf86OutputPtr output, I2CBusPtr pDDCBus);
-
-/**
- * Initialize dga for this screen
- */
-
-#ifdef XFreeXDGA
-extern _X_EXPORT Bool
-xf86DiDGAInit (ScreenPtr pScreen, unsigned long dga_address);
-
-/* this is the real function, used only internally */
-_X_INTERNAL Bool
-_xf86_di_dga_init_internal (ScreenPtr pScreen);
-
-/**
- * Re-initialize dga for this screen (as when the set of modes changes)
- */
-
-extern _X_EXPORT Bool
-xf86DiDGAReInit (ScreenPtr pScreen);
-#endif
-
-/* This is the real function, used only internally */
-_X_INTERNAL Bool
-_xf86_di_dga_reinit_internal (ScreenPtr pScreen);
-
-/*
- * Set the subpixel order reported for the screen using
- * the information from the outputs
- */
-
-extern _X_EXPORT void
-xf86CrtcSetScreenSubpixelOrder (ScreenPtr pScreen);
-
-/*
- * Get a standard string name for a connector type
- */
-extern _X_EXPORT char *
-xf86ConnectorGetName(xf86ConnectorType connector);
-
-/*
- * Using the desired mode information in each crtc, set
- * modes (used in EnterVT functions, or at server startup)
- */
-
-extern _X_EXPORT Bool
-xf86SetDesiredModes (ScrnInfoPtr pScrn);
-
-/**
- * Initialize the CRTC-based cursor code. CRTC function vectors must
- * contain relevant cursor setting functions.
- *
- * Driver should call this from ScreenInit function
- */
-extern _X_EXPORT Bool
-xf86_cursors_init (ScreenPtr screen, int max_width, int max_height, int flags);
-
-/**
- * Called when anything on the screen is reconfigured.
- *
- * Reloads cursor images as needed, then adjusts cursor positions.
- *
- * Driver should call this from crtc commit function.
- */
-extern _X_EXPORT void
-xf86_reload_cursors (ScreenPtr screen);
-
-/**
- * Called from EnterVT to turn the cursors back on
- */
-extern _X_EXPORT void
-xf86_show_cursors (ScrnInfoPtr scrn);
-
-/**
- * Called by the driver to turn cursors off
- */
-extern _X_EXPORT void
-xf86_hide_cursors (ScrnInfoPtr scrn);
-
-/**
- * Clean up CRTC-based cursor code. Driver must call this at CloseScreen time.
- */
-extern _X_EXPORT void
-xf86_cursors_fini (ScreenPtr screen);
-
-/*
- * For overlay video, compute the relevant CRTC and
- * clip video to that.
- * wraps xf86XVClipVideoHelper()
- */
-
-extern _X_EXPORT Bool
-xf86_crtc_clip_video_helper(ScrnInfoPtr pScrn,
- xf86CrtcPtr *crtc_ret,
- xf86CrtcPtr desired_crtc,
- BoxPtr dst,
- INT32 *xa,
- INT32 *xb,
- INT32 *ya,
- INT32 *yb,
- RegionPtr reg,
- INT32 width,
- INT32 height);
-
-extern _X_EXPORT xf86_crtc_notify_proc_ptr
-xf86_wrap_crtc_notify (ScreenPtr pScreen, xf86_crtc_notify_proc_ptr new);
-
-extern _X_EXPORT void
-xf86_unwrap_crtc_notify(ScreenPtr pScreen, xf86_crtc_notify_proc_ptr old);
-
-extern _X_EXPORT void
-xf86_crtc_notify(ScreenPtr pScreen);
-
-/**
- * Gamma
- */
-
-extern _X_EXPORT Bool
-xf86_crtc_supports_gamma(ScrnInfoPtr pScrn);
-
-#endif /* _XF86CRTC_H_ */
+/*
+ * Copyright © 2006 Keith Packard
+ *
+ * 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 copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no representations
+ * about the suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS 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.
+ */
+#ifndef _XF86CRTC_H_
+#define _XF86CRTC_H_
+
+#include <edid.h>
+#include "randrstr.h"
+#if XF86_MODES_RENAME
+#include "xf86Rename.h"
+#endif
+#include "xf86Modes.h"
+#include "xf86Cursor.h"
+#include "xf86i2c.h"
+#include "damage.h"
+#include "picturestr.h"
+
+/* Compat definitions for older X Servers. */
+#ifndef M_T_PREFERRED
+#define M_T_PREFERRED 0x08
+#endif
+#ifndef M_T_DRIVER
+#define M_T_DRIVER 0x40
+#endif
+#ifndef M_T_USERPREF
+#define M_T_USERPREF 0x80
+#endif
+#ifndef HARDWARE_CURSOR_ARGB
+#define HARDWARE_CURSOR_ARGB 0x00004000
+#endif
+
+typedef struct _xf86Crtc xf86CrtcRec, *xf86CrtcPtr;
+typedef struct _xf86Output xf86OutputRec, *xf86OutputPtr;
+
+/* define a standard for connector types */
+typedef enum _xf86ConnectorType {
+ XF86ConnectorNone,
+ XF86ConnectorVGA,
+ XF86ConnectorDVI_I,
+ XF86ConnectorDVI_D,
+ XF86ConnectorDVI_A,
+ XF86ConnectorComposite,
+ XF86ConnectorSvideo,
+ XF86ConnectorComponent,
+ XF86ConnectorLFP,
+ XF86ConnectorProprietary,
+ XF86ConnectorHDMI,
+ XF86ConnectorDisplayPort,
+} xf86ConnectorType;
+
+typedef enum _xf86OutputStatus {
+ XF86OutputStatusConnected,
+ XF86OutputStatusDisconnected,
+ XF86OutputStatusUnknown
+} xf86OutputStatus;
+
+typedef struct _xf86CrtcFuncs {
+ /**
+ * Turns the crtc on/off, or sets intermediate power levels if available.
+ *
+ * Unsupported intermediate modes drop to the lower power setting. If the
+ * mode is DPMSModeOff, the crtc must be disabled sufficiently for it to
+ * be safe to call mode_set.
+ */
+ void
+ (*dpms)(xf86CrtcPtr crtc,
+ int mode);
+
+ /**
+ * Saves the crtc's state for restoration on VT switch.
+ */
+ void
+ (*save)(xf86CrtcPtr crtc);
+
+ /**
+ * Restore's the crtc's state at VT switch.
+ */
+ void
+ (*restore)(xf86CrtcPtr crtc);
+
+ /**
+ * Lock CRTC prior to mode setting, mostly for DRI.
+ * Returns whether unlock is needed
+ */
+ Bool
+ (*lock) (xf86CrtcPtr crtc);
+
+ /**
+ * Unlock CRTC after mode setting, mostly for DRI
+ */
+ void
+ (*unlock) (xf86CrtcPtr crtc);
+
+ /**
+ * Callback to adjust the mode to be set in the CRTC.
+ *
+ * This allows a CRTC to adjust the clock or even the entire set of
+ * timings, which is used for panels with fixed timings or for
+ * buses with clock limitations.
+ */
+ Bool
+ (*mode_fixup)(xf86CrtcPtr crtc,
+ DisplayModePtr mode,
+ DisplayModePtr adjusted_mode);
+
+ /**
+ * Prepare CRTC for an upcoming mode set.
+ */
+ void
+ (*prepare)(xf86CrtcPtr crtc);
+
+ /**
+ * Callback for setting up a video mode after fixups have been made.
+ */
+ void
+ (*mode_set)(xf86CrtcPtr crtc,
+ DisplayModePtr mode,
+ DisplayModePtr adjusted_mode,
+ int x, int y);
+
+ /**
+ * Commit mode changes to a CRTC
+ */
+ void
+ (*commit)(xf86CrtcPtr crtc);
+
+ /* Set the color ramps for the CRTC to the given values. */
+ void
+ (*gamma_set)(xf86CrtcPtr crtc, CARD16 *red, CARD16 *green, CARD16 *blue,
+ int size);
+
+ /**
+ * Allocate the shadow area, delay the pixmap creation until needed
+ */
+ void *
+ (*shadow_allocate) (xf86CrtcPtr crtc, int width, int height);
+
+ /**
+ * Create shadow pixmap for rotation support
+ */
+ PixmapPtr
+ (*shadow_create) (xf86CrtcPtr crtc, void *data, int width, int height);
+
+ /**
+ * Destroy shadow pixmap
+ */
+ void
+ (*shadow_destroy) (xf86CrtcPtr crtc, PixmapPtr pPixmap, void *data);
+
+ /**
+ * Set cursor colors
+ */
+ void
+ (*set_cursor_colors) (xf86CrtcPtr crtc, int bg, int fg);
+
+ /**
+ * Set cursor position
+ */
+ void
+ (*set_cursor_position) (xf86CrtcPtr crtc, int x, int y);
+
+ /**
+ * Show cursor
+ */
+ void
+ (*show_cursor) (xf86CrtcPtr crtc);
+
+ /**
+ * Hide cursor
+ */
+ void
+ (*hide_cursor) (xf86CrtcPtr crtc);
+
+ /**
+ * Load monochrome image
+ */
+ void
+ (*load_cursor_image) (xf86CrtcPtr crtc, CARD8 *image);
+
+ /**
+ * Load ARGB image
+ */
+ void
+ (*load_cursor_argb) (xf86CrtcPtr crtc, CARD32 *image);
+
+ /**
+ * Clean up driver-specific bits of the crtc
+ */
+ void
+ (*destroy) (xf86CrtcPtr crtc);
+
+ /**
+ * Less fine-grained mode setting entry point for kernel modesetting
+ */
+ Bool
+ (*set_mode_major)(xf86CrtcPtr crtc, DisplayModePtr mode,
+ Rotation rotation, int x, int y);
+
+ /**
+ * Callback for panning. Doesn't change the mode.
+ * Added in ABI version 2
+ */
+ void
+ (*set_origin)(xf86CrtcPtr crtc, int x, int y);
+
+} xf86CrtcFuncsRec, *xf86CrtcFuncsPtr;
+
+#define XF86_CRTC_VERSION 3
+
+struct _xf86Crtc {
+ /**
+ * ABI versioning
+ */
+ int version;
+
+ /**
+ * Associated ScrnInfo
+ */
+ ScrnInfoPtr scrn;
+
+ /**
+ * Desired state of this CRTC
+ *
+ * Set when this CRTC should be driving one or more outputs
+ */
+ Bool enabled;
+
+ /**
+ * Active mode
+ *
+ * This reflects the mode as set in the CRTC currently
+ * It will be cleared when the VT is not active or
+ * during server startup
+ */
+ DisplayModeRec mode;
+ Rotation rotation;
+ PixmapPtr rotatedPixmap;
+ void *rotatedData;
+
+ /**
+ * Position on screen
+ *
+ * Locates this CRTC within the frame buffer
+ */
+ int x, y;
+
+ /**
+ * Desired mode
+ *
+ * This is set to the requested mode, independent of
+ * whether the VT is active. In particular, it receives
+ * the startup configured mode and saves the active mode
+ * on VT switch.
+ */
+ DisplayModeRec desiredMode;
+ Rotation desiredRotation;
+ int desiredX, desiredY;
+
+ /** crtc-specific functions */
+ const xf86CrtcFuncsRec *funcs;
+
+ /**
+ * Driver private
+ *
+ * Holds driver-private information
+ */
+ void *driver_private;
+
+#ifdef RANDR_12_INTERFACE
+ /**
+ * RandR crtc
+ *
+ * When RandR 1.2 is available, this
+ * points at the associated crtc object
+ */
+ RRCrtcPtr randr_crtc;
+#else
+ void *randr_crtc;
+#endif
+
+ /**
+ * Current cursor is ARGB
+ */
+ Bool cursor_argb;
+ /**
+ * Track whether cursor is within CRTC range
+ */
+ Bool cursor_in_range;
+ /**
+ * Track state of cursor associated with this CRTC
+ */
+ Bool cursor_shown;
+
+ /**
+ * Current transformation matrix
+ */
+ PictTransform crtc_to_framebuffer;
+ /* framebuffer_to_crtc was removed in ABI 2 */
+ struct pict_f_transform f_crtc_to_framebuffer; /* ABI 2 */
+ struct pict_f_transform f_framebuffer_to_crtc; /* ABI 2 */
+ PictFilterPtr filter; /* ABI 2 */
+ xFixed *params; /* ABI 2 */
+ int nparams; /* ABI 2 */
+ int filter_width; /* ABI 2 */
+ int filter_height; /* ABI 2 */
+ Bool transform_in_use;
+ RRTransformRec transform; /* ABI 2 */
+ Bool transformPresent; /* ABI 2 */
+ RRTransformRec desiredTransform; /* ABI 2 */
+ Bool desiredTransformPresent; /* ABI 2 */
+ /**
+ * Bounding box in screen space
+ */
+ BoxRec bounds;
+ /**
+ * Panning:
+ * TotalArea: total panning area, larger than CRTC's size
+ * TrackingArea: Area of the pointer for which the CRTC is panned
+ * border: Borders of the displayed CRTC area which induces panning if the pointer reaches them
+ * Added in ABI version 2
+ */
+ BoxRec panningTotalArea;
+ BoxRec panningTrackingArea;
+ INT16 panningBorder[4];
+
+ /**
+ * Current gamma, especially useful after initial config.
+ * Added in ABI version 3
+ */
+ CARD16 *gamma_red;
+ CARD16 *gamma_green;
+ CARD16 *gamma_blue;
+ int gamma_size;
+
+ /**
+ * Actual state of this CRTC
+ *
+ * Set to TRUE after modesetting, set to FALSE if no outputs are connected
+ * Added in ABI version 3
+ */
+ Bool active;
+ /**
+ * Clear the shadow
+ */
+ Bool shadowClear;
+};
+
+typedef struct _xf86OutputFuncs {
+ /**
+ * Called to allow the output a chance to create properties after the
+ * RandR objects have been created.
+ */
+ void
+ (*create_resources)(xf86OutputPtr output);
+
+ /**
+ * Turns the output on/off, or sets intermediate power levels if available.
+ *
+ * Unsupported intermediate modes drop to the lower power setting. If the
+ * mode is DPMSModeOff, the output must be disabled, as the DPLL may be
+ * disabled afterwards.
+ */
+ void
+ (*dpms)(xf86OutputPtr output,
+ int mode);
+
+ /**
+ * Saves the output's state for restoration on VT switch.
+ */
+ void
+ (*save)(xf86OutputPtr output);
+
+ /**
+ * Restore's the output's state at VT switch.
+ */
+ void
+ (*restore)(xf86OutputPtr output);
+
+ /**
+ * Callback for testing a video mode for a given output.
+ *
+ * This function should only check for cases where a mode can't be supported
+ * on the output specifically, and not represent generic CRTC limitations.
+ *
+ * \return MODE_OK if the mode is valid, or another MODE_* otherwise.
+ */
+ int
+ (*mode_valid)(xf86OutputPtr output,
+ DisplayModePtr pMode);
+
+ /**
+ * Callback to adjust the mode to be set in the CRTC.
+ *
+ * This allows an output to adjust the clock or even the entire set of
+ * timings, which is used for panels with fixed timings or for
+ * buses with clock limitations.
+ */
+ Bool
+ (*mode_fixup)(xf86OutputPtr output,
+ DisplayModePtr mode,
+ DisplayModePtr adjusted_mode);
+
+ /**
+ * Callback for preparing mode changes on an output
+ */
+ void
+ (*prepare)(xf86OutputPtr output);
+
+ /**
+ * Callback for committing mode changes on an output
+ */
+ void
+ (*commit)(xf86OutputPtr output);
+
+ /**
+ * Callback for setting up a video mode after fixups have been made.
+ *
+ * This is only called while the output is disabled. The dpms callback
+ * must be all that's necessary for the output, to turn the output on
+ * after this function is called.
+ */
+ void
+ (*mode_set)(xf86OutputPtr output,
+ DisplayModePtr mode,
+ DisplayModePtr adjusted_mode);
+
+ /**
+ * Probe for a connected output, and return detect_status.
+ */
+ xf86OutputStatus
+ (*detect)(xf86OutputPtr output);
+
+ /**
+ * Query the device for the modes it provides.
+ *
+ * This function may also update MonInfo, mm_width, and mm_height.
+ *
+ * \return singly-linked list of modes or NULL if no modes found.
+ */
+ DisplayModePtr
+ (*get_modes)(xf86OutputPtr output);
+
+#ifdef RANDR_12_INTERFACE
+ /**
+ * Callback when an output's property has changed.
+ */
+ Bool
+ (*set_property)(xf86OutputPtr output,
+ Atom property,
+ RRPropertyValuePtr value);
+#endif
+#ifdef RANDR_13_INTERFACE
+ /**
+ * Callback to get an updated property value
+ */
+ Bool
+ (*get_property)(xf86OutputPtr output,
+ Atom property);
+#endif
+#ifdef RANDR_GET_CRTC_INTERFACE
+ /**
+ * Callback to get current CRTC for a given output
+ */
+ xf86CrtcPtr
+ (*get_crtc)(xf86OutputPtr output);
+#endif
+ /**
+ * Clean up driver-specific bits of the output
+ */
+ void
+ (*destroy) (xf86OutputPtr output);
+} xf86OutputFuncsRec, *xf86OutputFuncsPtr;
+
+
+#define XF86_OUTPUT_VERSION 2
+
+struct _xf86Output {
+ /**
+ * ABI versioning
+ */
+ int version;
+
+ /**
+ * Associated ScrnInfo
+ */
+ ScrnInfoPtr scrn;
+
+ /**
+ * Currently connected crtc (if any)
+ *
+ * If this output is not in use, this field will be NULL.
+ */
+ xf86CrtcPtr crtc;
+
+ /**
+ * Possible CRTCs for this output as a mask of crtc indices
+ */
+ CARD32 possible_crtcs;
+
+ /**
+ * Possible outputs to share the same CRTC as a mask of output indices
+ */
+ CARD32 possible_clones;
+
+ /**
+ * Whether this output can support interlaced modes
+ */
+ Bool interlaceAllowed;
+
+ /**
+ * Whether this output can support double scan modes
+ */
+ Bool doubleScanAllowed;
+
+ /**
+ * List of available modes on this output.
+ *
+ * This should be the list from get_modes(), plus perhaps additional
+ * compatible modes added later.
+ */
+ DisplayModePtr probed_modes;
+
+ /**
+ * Options parsed from the related monitor section
+ */
+ OptionInfoPtr options;
+
+ /**
+ * Configured monitor section
+ */
+ XF86ConfMonitorPtr conf_monitor;
+
+ /**
+ * Desired initial position
+ */
+ int initial_x, initial_y;
+
+ /**
+ * Desired initial rotation
+ */
+ Rotation initial_rotation;
+
+ /**
+ * Current connection status
+ *
+ * This indicates whether a monitor is known to be connected
+ * to this output or not, or whether there is no way to tell
+ */
+ xf86OutputStatus status;
+
+ /** EDID monitor information */
+ xf86MonPtr MonInfo;
+
+ /** subpixel order */
+ int subpixel_order;
+
+ /** Physical size of the currently attached output device. */
+ int mm_width, mm_height;
+
+ /** Output name */
+ char *name;
+
+ /** output-specific functions */
+ const xf86OutputFuncsRec *funcs;
+
+ /** driver private information */
+ void *driver_private;
+
+ /** Whether to use the old per-screen Monitor config section */
+ Bool use_screen_monitor;
+
+#ifdef RANDR_12_INTERFACE
+ /**
+ * RandR 1.2 output structure.
+ *
+ * When RandR 1.2 is available, this points at the associated
+ * RandR output structure and is created when this output is created
+ */
+ RROutputPtr randr_output;
+#else
+ void *randr_output;
+#endif
+ /**
+ * Desired initial panning
+ * Added in ABI version 2
+ */
+ BoxRec initialTotalArea;
+ BoxRec initialTrackingArea;
+ INT16 initialBorder[4];
+};
+
+typedef struct _xf86CrtcConfigFuncs {
+ /**
+ * Requests that the driver resize the screen.
+ *
+ * The driver is responsible for updating scrn->virtualX and scrn->virtualY.
+ * If the requested size cannot be set, the driver should leave those values
+ * alone and return FALSE.
+ *
+ * A naive driver that cannot reallocate the screen may simply change
+ * virtual[XY]. A more advanced driver will want to also change the
+ * devPrivate.ptr and devKind of the screen pixmap, update any offscreen
+ * pixmaps it may have moved, and change pScrn->displayWidth.
+ */
+ Bool
+ (*resize)(ScrnInfoPtr scrn,
+ int width,
+ int height);
+} xf86CrtcConfigFuncsRec, *xf86CrtcConfigFuncsPtr;
+
+typedef void (*xf86_crtc_notify_proc_ptr) (ScreenPtr pScreen);
+
+typedef struct _xf86CrtcConfig {
+ int num_output;
+ xf86OutputPtr *output;
+ /**
+ * compat_output is used whenever we deal
+ * with legacy code that only understands a single
+ * output. pScrn->modes will be loaded from this output,
+ * adjust frame will whack this output, etc.
+ */
+ int compat_output;
+
+ int num_crtc;
+ xf86CrtcPtr *crtc;
+
+ int minWidth, minHeight;
+ int maxWidth, maxHeight;
+
+ /* For crtc-based rotation */
+ DamagePtr rotation_damage;
+ Bool rotation_damage_registered;
+
+ /* DGA */
+ unsigned int dga_flags;
+ unsigned long dga_address;
+ DGAModePtr dga_modes;
+ int dga_nmode;
+ int dga_width, dga_height, dga_stride;
+ DisplayModePtr dga_save_mode;
+
+ const xf86CrtcConfigFuncsRec *funcs;
+
+ CreateScreenResourcesProcPtr CreateScreenResources;
+
+ CloseScreenProcPtr CloseScreen;
+
+ /* Cursor information */
+ xf86CursorInfoPtr cursor_info;
+ CursorPtr cursor;
+ CARD8 *cursor_image;
+ Bool cursor_on;
+ CARD32 cursor_fg, cursor_bg;
+
+ /**
+ * Options parsed from the related device section
+ */
+ OptionInfoPtr options;
+
+ Bool debug_modes;
+
+ /* wrap screen BlockHandler for rotation */
+ ScreenBlockHandlerProcPtr BlockHandler;
+
+ /* callback when crtc configuration changes */
+ xf86_crtc_notify_proc_ptr xf86_crtc_notify;
+
+} xf86CrtcConfigRec, *xf86CrtcConfigPtr;
+
+extern _X_EXPORT int xf86CrtcConfigPrivateIndex;
+
+#define XF86_CRTC_CONFIG_PTR(p) ((xf86CrtcConfigPtr) ((p)->privates[xf86CrtcConfigPrivateIndex].ptr))
+
+static _X_INLINE xf86OutputPtr
+xf86CompatOutput(ScrnInfoPtr pScrn)
+{
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+ return config->output[config->compat_output];
+}
+
+static _X_INLINE xf86CrtcPtr
+xf86CompatCrtc(ScrnInfoPtr pScrn)
+{
+ xf86OutputPtr compat_output = xf86CompatOutput(pScrn);
+ if (!compat_output)
+ return NULL;
+ return compat_output->crtc;
+}
+
+static _X_INLINE RRCrtcPtr
+xf86CompatRRCrtc(ScrnInfoPtr pScrn)
+{
+ xf86CrtcPtr compat_crtc = xf86CompatCrtc(pScrn);
+ if (!compat_crtc)
+ return NULL;
+ return compat_crtc->randr_crtc;
+}
+
+
+/*
+ * Initialize xf86CrtcConfig structure
+ */
+
+extern _X_EXPORT void
+xf86CrtcConfigInit (ScrnInfoPtr scrn,
+ const xf86CrtcConfigFuncsRec *funcs);
+
+extern _X_EXPORT void
+xf86CrtcSetSizeRange (ScrnInfoPtr scrn,
+ int minWidth, int minHeight,
+ int maxWidth, int maxHeight);
+
+/*
+ * Crtc functions
+ */
+extern _X_EXPORT xf86CrtcPtr
+xf86CrtcCreate (ScrnInfoPtr scrn,
+ const xf86CrtcFuncsRec *funcs);
+
+extern _X_EXPORT void
+xf86CrtcDestroy (xf86CrtcPtr crtc);
+
+
+/**
+ * Sets the given video mode on the given crtc
+ */
+
+extern _X_EXPORT Bool
+xf86CrtcSetModeTransform (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation,
+ RRTransformPtr transform, int x, int y);
+
+extern _X_EXPORT Bool
+xf86CrtcSetMode (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation,
+ int x, int y);
+
+extern _X_EXPORT void
+xf86CrtcSetOrigin (xf86CrtcPtr crtc, int x, int y);
+
+/*
+ * Assign crtc rotation during mode set
+ */
+extern _X_EXPORT Bool
+xf86CrtcRotate (xf86CrtcPtr crtc);
+
+/*
+ * Clean up any rotation data, used when a crtc is turned off
+ * as well as when rotation is disabled.
+ */
+extern _X_EXPORT void
+xf86RotateDestroy (xf86CrtcPtr crtc);
+
+/*
+ * free shadow memory allocated for all crtcs
+ */
+extern _X_EXPORT void
+xf86RotateFreeShadow(ScrnInfoPtr pScrn);
+
+/*
+ * Clean up rotation during CloseScreen
+ */
+extern _X_EXPORT void
+xf86RotateCloseScreen (ScreenPtr pScreen);
+
+/**
+ * Return whether any output is assigned to the crtc
+ */
+extern _X_EXPORT Bool
+xf86CrtcInUse (xf86CrtcPtr crtc);
+
+/*
+ * Output functions
+ */
+extern _X_EXPORT xf86OutputPtr
+xf86OutputCreate (ScrnInfoPtr scrn,
+ const xf86OutputFuncsRec *funcs,
+ const char *name);
+
+extern _X_EXPORT void
+xf86OutputUseScreenMonitor (xf86OutputPtr output, Bool use_screen_monitor);
+
+extern _X_EXPORT Bool
+xf86OutputRename (xf86OutputPtr output, const char *name);
+
+extern _X_EXPORT void
+xf86OutputDestroy (xf86OutputPtr output);
+
+extern _X_EXPORT void
+xf86ProbeOutputModes (ScrnInfoPtr pScrn, int maxX, int maxY);
+
+extern _X_EXPORT void
+xf86SetScrnInfoModes (ScrnInfoPtr pScrn);
+
+#ifdef RANDR_13_INTERFACE
+# define ScreenInitRetType int
+#else
+# define ScreenInitRetType Bool
+#endif
+
+extern _X_EXPORT ScreenInitRetType
+xf86CrtcScreenInit (ScreenPtr pScreen);
+
+extern _X_EXPORT Bool
+xf86InitialConfiguration (ScrnInfoPtr pScrn, Bool canGrow);
+
+extern _X_EXPORT void
+xf86DPMSSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags);
+
+extern _X_EXPORT Bool
+xf86SaveScreen(ScreenPtr pScreen, int mode);
+
+extern _X_EXPORT void
+xf86DisableUnusedFunctions(ScrnInfoPtr pScrn);
+
+extern _X_EXPORT DisplayModePtr
+xf86OutputFindClosestMode (xf86OutputPtr output, DisplayModePtr desired);
+
+extern _X_EXPORT Bool
+xf86SetSingleMode (ScrnInfoPtr pScrn, DisplayModePtr desired, Rotation rotation);
+
+/**
+ * Set the EDID information for the specified output
+ */
+extern _X_EXPORT void
+xf86OutputSetEDID (xf86OutputPtr output, xf86MonPtr edid_mon);
+
+/**
+ * Return the list of modes supported by the EDID information
+ * stored in 'output'
+ */
+extern _X_EXPORT DisplayModePtr
+xf86OutputGetEDIDModes (xf86OutputPtr output);
+
+extern _X_EXPORT xf86MonPtr
+xf86OutputGetEDID (xf86OutputPtr output, I2CBusPtr pDDCBus);
+
+/**
+ * Initialize dga for this screen
+ */
+
+#ifdef XFreeXDGA
+extern _X_EXPORT Bool
+xf86DiDGAInit (ScreenPtr pScreen, unsigned long dga_address);
+
+/* this is the real function, used only internally */
+_X_INTERNAL Bool
+_xf86_di_dga_init_internal (ScreenPtr pScreen);
+
+/**
+ * Re-initialize dga for this screen (as when the set of modes changes)
+ */
+
+extern _X_EXPORT Bool
+xf86DiDGAReInit (ScreenPtr pScreen);
+#endif
+
+/* This is the real function, used only internally */
+_X_INTERNAL Bool
+_xf86_di_dga_reinit_internal (ScreenPtr pScreen);
+
+/*
+ * Set the subpixel order reported for the screen using
+ * the information from the outputs
+ */
+
+extern _X_EXPORT void
+xf86CrtcSetScreenSubpixelOrder (ScreenPtr pScreen);
+
+/*
+ * Get a standard string name for a connector type
+ */
+extern _X_EXPORT char *
+xf86ConnectorGetName(xf86ConnectorType connector);
+
+/*
+ * Using the desired mode information in each crtc, set
+ * modes (used in EnterVT functions, or at server startup)
+ */
+
+extern _X_EXPORT Bool
+xf86SetDesiredModes (ScrnInfoPtr pScrn);
+
+/**
+ * Initialize the CRTC-based cursor code. CRTC function vectors must
+ * contain relevant cursor setting functions.
+ *
+ * Driver should call this from ScreenInit function
+ */
+extern _X_EXPORT Bool
+xf86_cursors_init (ScreenPtr screen, int max_width, int max_height, int flags);
+
+/**
+ * Called when anything on the screen is reconfigured.
+ *
+ * Reloads cursor images as needed, then adjusts cursor positions.
+ *
+ * Driver should call this from crtc commit function.
+ */
+extern _X_EXPORT void
+xf86_reload_cursors (ScreenPtr screen);
+
+/**
+ * Called from EnterVT to turn the cursors back on
+ */
+extern _X_EXPORT void
+xf86_show_cursors (ScrnInfoPtr scrn);
+
+/**
+ * Called by the driver to turn cursors off
+ */
+extern _X_EXPORT void
+xf86_hide_cursors (ScrnInfoPtr scrn);
+
+/**
+ * Clean up CRTC-based cursor code. Driver must call this at CloseScreen time.
+ */
+extern _X_EXPORT void
+xf86_cursors_fini (ScreenPtr screen);
+
+/*
+ * For overlay video, compute the relevant CRTC and
+ * clip video to that.
+ * wraps xf86XVClipVideoHelper()
+ */
+
+extern _X_EXPORT Bool
+xf86_crtc_clip_video_helper(ScrnInfoPtr pScrn,
+ xf86CrtcPtr *crtc_ret,
+ xf86CrtcPtr desired_crtc,
+ BoxPtr dst,
+ INT32 *xa,
+ INT32 *xb,
+ INT32 *ya,
+ INT32 *yb,
+ RegionPtr reg,
+ INT32 width,
+ INT32 height);
+
+extern _X_EXPORT xf86_crtc_notify_proc_ptr
+xf86_wrap_crtc_notify (ScreenPtr pScreen, xf86_crtc_notify_proc_ptr new);
+
+extern _X_EXPORT void
+xf86_unwrap_crtc_notify(ScreenPtr pScreen, xf86_crtc_notify_proc_ptr old);
+
+extern _X_EXPORT void
+xf86_crtc_notify(ScreenPtr pScreen);
+
+/**
+ * Gamma
+ */
+
+extern _X_EXPORT Bool
+xf86_crtc_supports_gamma(ScrnInfoPtr pScrn);
+
+#endif /* _XF86CRTC_H_ */
diff --git a/xorg-server/hw/xfree86/modes/xf86Cursors.c b/xorg-server/hw/xfree86/modes/xf86Cursors.c
index 5562f29cc..066744744 100644
--- a/xorg-server/hw/xfree86/modes/xf86Cursors.c
+++ b/xorg-server/hw/xfree86/modes/xf86Cursors.c
@@ -1,688 +1,688 @@
-/*
- * Copyright © 2007 Keith Packard
- * Copyright © 2010 Aaron Plattner
- *
- * 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 copyright holders not be used in advertising or
- * publicity pertaining to distribution of the software without specific,
- * written prior permission. The copyright holders make no representations
- * about the suitability of this software for any purpose. It is provided "as
- * is" without express or implied warranty.
- *
- * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE COPYRIGHT HOLDERS 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_XORG_CONFIG_H
-#include <xorg-config.h>
-#else
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#endif
-
-#include <stddef.h>
-#include <string.h>
-#include <stdio.h>
-
-#include "xf86.h"
-#include "xf86DDC.h"
-#include "xf86Crtc.h"
-#include "xf86Modes.h"
-#include "xf86RandR12.h"
-#include "xf86CursorPriv.h"
-#include "X11/extensions/render.h"
-#include "X11/extensions/dpmsconst.h"
-#include "X11/Xatom.h"
-#include "picturestr.h"
-#include "cursorstr.h"
-#include "inputstr.h"
-
-/*
- * Given a screen coordinate, rotate back to a cursor source coordinate
- */
-static void
-xf86_crtc_rotate_coord (Rotation rotation,
- int width,
- int height,
- int x_dst,
- int y_dst,
- int *x_src,
- int *y_src)
-{
- int t;
-
- switch (rotation & 0xf) {
- case RR_Rotate_0:
- break;
- case RR_Rotate_90:
- t = x_dst;
- x_dst = height - y_dst - 1;
- y_dst = t;
- break;
- case RR_Rotate_180:
- x_dst = width - x_dst - 1;
- y_dst = height - y_dst - 1;
- break;
- case RR_Rotate_270:
- t = x_dst;
- x_dst = y_dst;
- y_dst = width - t - 1;
- break;
- }
- if (rotation & RR_Reflect_X)
- x_dst = width - x_dst - 1;
- if (rotation & RR_Reflect_Y)
- y_dst = height - y_dst - 1;
- *x_src = x_dst;
- *y_src = y_dst;
-}
-
-/*
- * Given a cursor source coordinate, rotate to a screen coordinate
- */
-static void
-xf86_crtc_rotate_coord_back (Rotation rotation,
- int width,
- int height,
- int x_dst,
- int y_dst,
- int *x_src,
- int *y_src)
-{
- int t;
-
- if (rotation & RR_Reflect_X)
- x_dst = width - x_dst - 1;
- if (rotation & RR_Reflect_Y)
- y_dst = height - y_dst - 1;
-
- switch (rotation & 0xf) {
- case RR_Rotate_0:
- break;
- case RR_Rotate_90:
- t = x_dst;
- x_dst = y_dst;
- y_dst = width - t - 1;
- break;
- case RR_Rotate_180:
- x_dst = width - x_dst - 1;
- y_dst = height - y_dst - 1;
- break;
- case RR_Rotate_270:
- t = x_dst;
- x_dst = height - y_dst - 1;
- y_dst = t;
- break;
- }
- *x_src = x_dst;
- *y_src = y_dst;
-}
-
-struct cursor_bit {
- CARD8 *byte;
- char bitpos;
-};
-
-/*
- * Convert an x coordinate to a position within the cursor bitmap
- */
-static struct cursor_bit
-cursor_bitpos (CARD8 *image, xf86CursorInfoPtr cursor_info, int x, int y,
- Bool mask)
-{
- const int flags = cursor_info->Flags;
- const Bool interleaved =
- !!(flags & (HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1 |
- HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_8 |
- HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_16 |
- HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_32 |
- HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64));
- const int width = cursor_info->MaxWidth;
- const int height = cursor_info->MaxHeight;
- const int stride = interleaved ? width / 4 : width / 8;
-
- struct cursor_bit ret;
-
- image += y * stride;
-
- if (flags & HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK)
- mask = !mask;
- if (flags & HARDWARE_CURSOR_NIBBLE_SWAPPED)
- x = (x & ~3) | (3 - (x & 3));
- if (((flags & HARDWARE_CURSOR_BIT_ORDER_MSBFIRST) == 0) ==
- (X_BYTE_ORDER == X_BIG_ENDIAN))
- x = (x & ~7) | (7 - (x & 7));
- if (flags & HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1)
- x = (x << 1) + mask;
- else if (flags & HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_8)
- x = ((x & ~7) << 1) | (mask << 3) | (x & 7);
- else if (flags & HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_16)
- x = ((x & ~15) << 1) | (mask << 4) | (x & 15);
- else if (flags & HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_32)
- x = ((x & ~31) << 1) | (mask << 5) | (x & 31);
- else if (flags & HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64)
- x = ((x & ~63) << 1) | (mask << 6) | (x & 63);
- else if (mask)
- image += stride * height;
-
- ret.byte = image + (x / 8);
- ret.bitpos = x & 7;
-
- return ret;
-}
-
-/*
- * Fetch one bit from a cursor bitmap
- */
-static CARD8
-get_bit (CARD8 *image, xf86CursorInfoPtr cursor_info, int x, int y, Bool mask)
-{
- struct cursor_bit bit = cursor_bitpos(image, cursor_info, x, y, mask);
- return (*bit.byte >> bit.bitpos) & 1;
-}
-
-/*
- * Set one bit in a cursor bitmap
- */
-static void
-set_bit (CARD8 *image, xf86CursorInfoPtr cursor_info, int x, int y, Bool mask)
-{
- struct cursor_bit bit = cursor_bitpos(image, cursor_info, x, y, mask);
- *bit.byte |= 1 << bit.bitpos;
-}
-
-/*
- * Load a two color cursor into a driver that supports only ARGB cursors
- */
-static void
-xf86_crtc_convert_cursor_to_argb (xf86CrtcPtr crtc, unsigned char *src)
-{
- ScrnInfoPtr scrn = crtc->scrn;
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
- xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
- CARD32 *cursor_image = (CARD32 *) xf86_config->cursor_image;
- int x, y;
- int xin, yin;
- int flags = cursor_info->Flags;
- CARD32 bits;
-
-#ifdef ARGB_CURSOR
- crtc->cursor_argb = FALSE;
-#endif
-
- for (y = 0; y < cursor_info->MaxHeight; y++)
- for (x = 0; x < cursor_info->MaxWidth; x++)
- {
- xf86_crtc_rotate_coord (crtc->rotation,
- cursor_info->MaxWidth,
- cursor_info->MaxHeight,
- x, y, &xin, &yin);
- if (get_bit (src, cursor_info, xin, yin, TRUE) ==
- ((flags & HARDWARE_CURSOR_INVERT_MASK) == 0))
- {
- if (get_bit (src, cursor_info, xin, yin, FALSE))
- bits = xf86_config->cursor_fg;
- else
- bits = xf86_config->cursor_bg;
- }
- else
- bits = 0;
- cursor_image[y * cursor_info->MaxWidth + x] = bits;
- }
- crtc->funcs->load_cursor_argb (crtc, cursor_image);
-}
-
-/*
- * Set the colors for a two-color cursor (ignore for ARGB cursors)
- */
-static void
-xf86_set_cursor_colors (ScrnInfoPtr scrn, int bg, int fg)
-{
- ScreenPtr screen = scrn->pScreen;
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
- CursorPtr cursor = xf86_config->cursor;
- int c;
- CARD8 *bits = cursor ?
- dixLookupPrivate(&cursor->devPrivates, CursorScreenKey(screen))
- : NULL;
-
- /* Save ARGB versions of these colors */
- xf86_config->cursor_fg = (CARD32) fg | 0xff000000;
- xf86_config->cursor_bg = (CARD32) bg | 0xff000000;
-
- for (c = 0; c < xf86_config->num_crtc; c++)
- {
- xf86CrtcPtr crtc = xf86_config->crtc[c];
-
- if (crtc->enabled && !crtc->cursor_argb)
- {
- if (crtc->funcs->load_cursor_image)
- crtc->funcs->set_cursor_colors (crtc, bg, fg);
- else if (bits)
- xf86_crtc_convert_cursor_to_argb (crtc, bits);
- }
- }
-}
-
-static void
-xf86_crtc_hide_cursor (xf86CrtcPtr crtc)
-{
- if (crtc->cursor_shown)
- {
- crtc->funcs->hide_cursor (crtc);
- crtc->cursor_shown = FALSE;
- }
-}
-
-void
-xf86_hide_cursors (ScrnInfoPtr scrn)
-{
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
- int c;
-
- xf86_config->cursor_on = FALSE;
- for (c = 0; c < xf86_config->num_crtc; c++)
- {
- xf86CrtcPtr crtc = xf86_config->crtc[c];
-
- if (crtc->enabled)
- xf86_crtc_hide_cursor (crtc);
- }
-}
-
-static void
-xf86_crtc_show_cursor (xf86CrtcPtr crtc)
-{
- if (!crtc->cursor_shown && crtc->cursor_in_range)
- {
- crtc->funcs->show_cursor (crtc);
- crtc->cursor_shown = TRUE;
- }
-}
-
-void
-xf86_show_cursors (ScrnInfoPtr scrn)
-{
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
- int c;
-
- xf86_config->cursor_on = TRUE;
- for (c = 0; c < xf86_config->num_crtc; c++)
- {
- xf86CrtcPtr crtc = xf86_config->crtc[c];
-
- if (crtc->enabled)
- xf86_crtc_show_cursor (crtc);
- }
-}
-
-static void
-xf86_crtc_set_cursor_position (xf86CrtcPtr crtc, int x, int y)
-{
- ScrnInfoPtr scrn = crtc->scrn;
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
- xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
- DisplayModePtr mode = &crtc->mode;
- Bool in_range;
- int dx, dy;
-
- /*
- * Transform position of cursor on screen
- */
- if (crtc->transform_in_use)
- {
- ScreenPtr screen = scrn->pScreen;
- xf86CursorScreenPtr ScreenPriv =
- (xf86CursorScreenPtr)dixLookupPrivate(&screen->devPrivates,
- xf86CursorScreenKey);
- struct pict_f_vector v;
-
- v.v[0] = (x + ScreenPriv->HotX) + 0.5;
- v.v[1] = (y + ScreenPriv->HotY) + 0.5;
- v.v[2] = 1;
- pixman_f_transform_point (&crtc->f_framebuffer_to_crtc, &v);
- /* cursor will have 0.5 added to it already so floor is sufficent */
- x = floor (v.v[0]);
- y = floor (v.v[1]);
- /*
- * Transform position of cursor upper left corner
- */
- xf86_crtc_rotate_coord_back (crtc->rotation,
- cursor_info->MaxWidth,
- cursor_info->MaxHeight,
- ScreenPriv->HotX, ScreenPriv->HotY, &dx, &dy);
- x -= dx;
- y -= dy;
- }
- else
- {
- x -= crtc->x;
- y -= crtc->y;
- }
-
- /*
- * Disable the cursor when it is outside the viewport
- */
- in_range = TRUE;
- if (x >= mode->HDisplay || y >= mode->VDisplay ||
- x <= -cursor_info->MaxWidth || y <= -cursor_info->MaxHeight)
- {
- in_range = FALSE;
- x = 0;
- y = 0;
- }
-
- crtc->cursor_in_range = in_range;
-
- if (in_range)
- {
- crtc->funcs->set_cursor_position (crtc, x, y);
- xf86_crtc_show_cursor (crtc);
- }
- else
- xf86_crtc_hide_cursor (crtc);
-}
-
-static void
-xf86_set_cursor_position (ScrnInfoPtr scrn, int x, int y)
-{
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
- int c;
-
- /* undo what xf86HWCurs did to the coordinates */
- x += scrn->frameX0;
- y += scrn->frameY0;
- for (c = 0; c < xf86_config->num_crtc; c++)
- {
- xf86CrtcPtr crtc = xf86_config->crtc[c];
-
- if (crtc->enabled)
- xf86_crtc_set_cursor_position (crtc, x, y);
- }
-}
-
-/*
- * Load a two-color cursor into a crtc, performing rotation as needed
- */
-static void
-xf86_crtc_load_cursor_image (xf86CrtcPtr crtc, CARD8 *src)
-{
- ScrnInfoPtr scrn = crtc->scrn;
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
- xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
- CARD8 *cursor_image;
-
-#ifdef ARGB_CURSOR
- crtc->cursor_argb = FALSE;
-#endif
-
- if (crtc->rotation == RR_Rotate_0)
- cursor_image = src;
- else
- {
- int x, y;
- int xin, yin;
- int stride = cursor_info->MaxWidth >> 2;
-
- cursor_image = xf86_config->cursor_image;
- memset(cursor_image, 0, cursor_info->MaxHeight * stride);
-
- for (y = 0; y < cursor_info->MaxHeight; y++)
- for (x = 0; x < cursor_info->MaxWidth; x++)
- {
- xf86_crtc_rotate_coord (crtc->rotation,
- cursor_info->MaxWidth,
- cursor_info->MaxHeight,
- x, y, &xin, &yin);
- if (get_bit(src, cursor_info, xin, yin, FALSE))
- set_bit(cursor_image, cursor_info, x, y, FALSE);
- if (get_bit(src, cursor_info, xin, yin, TRUE))
- set_bit(cursor_image, cursor_info, x, y, TRUE);
- }
- }
- crtc->funcs->load_cursor_image (crtc, cursor_image);
-}
-
-/*
- * Load a cursor image into all active CRTCs
- */
-static void
-xf86_load_cursor_image (ScrnInfoPtr scrn, unsigned char *src)
-{
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
- int c;
-
- for (c = 0; c < xf86_config->num_crtc; c++)
- {
- xf86CrtcPtr crtc = xf86_config->crtc[c];
-
- if (crtc->enabled)
- {
- if (crtc->funcs->load_cursor_image)
- xf86_crtc_load_cursor_image (crtc, src);
- else if (crtc->funcs->load_cursor_argb)
- xf86_crtc_convert_cursor_to_argb (crtc, src);
- }
- }
-}
-
-static Bool
-xf86_use_hw_cursor (ScreenPtr screen, CursorPtr cursor)
-{
- ScrnInfoPtr scrn = xf86Screens[screen->myNum];
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
- xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
-
- ++cursor->refcnt;
- if (xf86_config->cursor)
- FreeCursor (xf86_config->cursor, None);
- xf86_config->cursor = cursor;
-
- if (cursor->bits->width > cursor_info->MaxWidth ||
- cursor->bits->height> cursor_info->MaxHeight)
- return FALSE;
-
- return TRUE;
-}
-
-static Bool
-xf86_use_hw_cursor_argb (ScreenPtr screen, CursorPtr cursor)
-{
- ScrnInfoPtr scrn = xf86Screens[screen->myNum];
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
- xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
-
- ++cursor->refcnt;
- if (xf86_config->cursor)
- FreeCursor (xf86_config->cursor, None);
- xf86_config->cursor = cursor;
-
- /* Make sure ARGB support is available */
- if ((cursor_info->Flags & HARDWARE_CURSOR_ARGB) == 0)
- return FALSE;
-
- if (cursor->bits->width > cursor_info->MaxWidth ||
- cursor->bits->height> cursor_info->MaxHeight)
- return FALSE;
-
- return TRUE;
-}
-
-static void
-xf86_crtc_load_cursor_argb (xf86CrtcPtr crtc, CursorPtr cursor)
-{
- ScrnInfoPtr scrn = crtc->scrn;
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
- xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
- CARD32 *cursor_image = (CARD32 *) xf86_config->cursor_image;
- CARD32 *cursor_source = (CARD32 *) cursor->bits->argb;
- int x, y;
- int xin, yin;
- CARD32 bits;
- int source_width = cursor->bits->width;
- int source_height = cursor->bits->height;
- int image_width = cursor_info->MaxWidth;
- int image_height = cursor_info->MaxHeight;
-
- for (y = 0; y < image_height; y++)
- for (x = 0; x < image_width; x++)
- {
- xf86_crtc_rotate_coord (crtc->rotation, image_width, image_height,
- x, y, &xin, &yin);
- if (xin < source_width && yin < source_height)
- bits = cursor_source[yin * source_width + xin];
- else
- bits = 0;
- cursor_image[y * image_width + x] = bits;
- }
-
- crtc->funcs->load_cursor_argb (crtc, cursor_image);
-}
-
-static void
-xf86_load_cursor_argb (ScrnInfoPtr scrn, CursorPtr cursor)
-{
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
- int c;
-
- for (c = 0; c < xf86_config->num_crtc; c++)
- {
- xf86CrtcPtr crtc = xf86_config->crtc[c];
-
- if (crtc->enabled)
- xf86_crtc_load_cursor_argb (crtc, cursor);
- }
-}
-
-Bool
-xf86_cursors_init (ScreenPtr screen, int max_width, int max_height, int flags)
-{
- ScrnInfoPtr scrn = xf86Screens[screen->myNum];
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
- xf86CursorInfoPtr cursor_info;
-
- cursor_info = xf86CreateCursorInfoRec();
- if (!cursor_info)
- return FALSE;
-
- xf86_config->cursor_image = malloc(max_width * max_height * 4);
-
- if (!xf86_config->cursor_image)
- {
- xf86DestroyCursorInfoRec (cursor_info);
- return FALSE;
- }
-
- xf86_config->cursor_info = cursor_info;
-
- cursor_info->MaxWidth = max_width;
- cursor_info->MaxHeight = max_height;
- cursor_info->Flags = flags;
-
- cursor_info->SetCursorColors = xf86_set_cursor_colors;
- cursor_info->SetCursorPosition = xf86_set_cursor_position;
- cursor_info->LoadCursorImage = xf86_load_cursor_image;
- cursor_info->HideCursor = xf86_hide_cursors;
- cursor_info->ShowCursor = xf86_show_cursors;
- cursor_info->UseHWCursor = xf86_use_hw_cursor;
-#ifdef ARGB_CURSOR
- if (flags & HARDWARE_CURSOR_ARGB)
- {
- cursor_info->UseHWCursorARGB = xf86_use_hw_cursor_argb;
- cursor_info->LoadCursorARGB = xf86_load_cursor_argb;
- }
-#endif
-
- xf86_config->cursor = NULL;
- xf86_hide_cursors (scrn);
-
- return xf86InitCursor (screen, cursor_info);
-}
-
-/**
- * Called when anything on the screen is reconfigured.
- *
- * Reloads cursor images as needed, then adjusts cursor positions
- */
-
-void
-xf86_reload_cursors (ScreenPtr screen)
-{
- ScrnInfoPtr scrn;
- xf86CrtcConfigPtr xf86_config;
- xf86CursorInfoPtr cursor_info;
- CursorPtr cursor;
- int x, y;
- xf86CursorScreenPtr cursor_screen_priv;
-
- /* initial mode setting will not have set a screen yet.
- May be called before the devices are initialised.
- */
- if (!screen || !inputInfo.pointer)
- return;
- cursor_screen_priv = dixLookupPrivate(&screen->devPrivates,
- xf86CursorScreenKey);
- /* return if HW cursor is inactive, to avoid displaying two cursors */
- if (!cursor_screen_priv || !cursor_screen_priv->isUp)
- return;
-
- scrn = xf86Screens[screen->myNum];
- xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
-
- /* make sure the cursor code has been initialized */
- cursor_info = xf86_config->cursor_info;
- if (!cursor_info)
- return;
-
- cursor = xf86_config->cursor;
- GetSpritePosition (inputInfo.pointer, &x, &y);
- if (!(cursor_info->Flags & HARDWARE_CURSOR_UPDATE_UNHIDDEN))
- (*cursor_info->HideCursor)(scrn);
-
- if (cursor)
- {
- void *src = dixLookupPrivate(&cursor->devPrivates, CursorScreenKey(screen));
-#ifdef ARGB_CURSOR
- if (cursor->bits->argb && cursor_info->LoadCursorARGB)
- (*cursor_info->LoadCursorARGB) (scrn, cursor);
- else if (src)
-#endif
- (*cursor_info->LoadCursorImage)(scrn, src);
-
- x += scrn->frameX0 + cursor_screen_priv->HotX;
- y += scrn->frameY0 + cursor_screen_priv->HotY;
- (*cursor_info->SetCursorPosition)(scrn, x, y);
- }
-}
-
-/**
- * Clean up CRTC-based cursor code
- */
-void
-xf86_cursors_fini (ScreenPtr screen)
-{
- ScrnInfoPtr scrn = xf86Screens[screen->myNum];
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
-
- if (xf86_config->cursor_info)
- {
- xf86DestroyCursorInfoRec (xf86_config->cursor_info);
- xf86_config->cursor_info = NULL;
- }
- free(xf86_config->cursor_image);
- xf86_config->cursor_image = NULL;
- if (xf86_config->cursor)
- {
- FreeCursor (xf86_config->cursor, None);
- xf86_config->cursor = NULL;
- }
-}
+/*
+ * Copyright © 2007 Keith Packard
+ * Copyright © 2010 Aaron Plattner
+ *
+ * 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 copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no representations
+ * about the suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS 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_XORG_CONFIG_H
+#include <xorg-config.h>
+#else
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#endif
+
+#include <stddef.h>
+#include <string.h>
+#include <stdio.h>
+
+#include "xf86.h"
+#include "xf86DDC.h"
+#include "xf86Crtc.h"
+#include "xf86Modes.h"
+#include "xf86RandR12.h"
+#include "xf86CursorPriv.h"
+#include "X11/extensions/render.h"
+#include "X11/extensions/dpmsconst.h"
+#include "X11/Xatom.h"
+#include "picturestr.h"
+#include "cursorstr.h"
+#include "inputstr.h"
+
+/*
+ * Given a screen coordinate, rotate back to a cursor source coordinate
+ */
+static void
+xf86_crtc_rotate_coord (Rotation rotation,
+ int width,
+ int height,
+ int x_dst,
+ int y_dst,
+ int *x_src,
+ int *y_src)
+{
+ int t;
+
+ switch (rotation & 0xf) {
+ case RR_Rotate_0:
+ break;
+ case RR_Rotate_90:
+ t = x_dst;
+ x_dst = height - y_dst - 1;
+ y_dst = t;
+ break;
+ case RR_Rotate_180:
+ x_dst = width - x_dst - 1;
+ y_dst = height - y_dst - 1;
+ break;
+ case RR_Rotate_270:
+ t = x_dst;
+ x_dst = y_dst;
+ y_dst = width - t - 1;
+ break;
+ }
+ if (rotation & RR_Reflect_X)
+ x_dst = width - x_dst - 1;
+ if (rotation & RR_Reflect_Y)
+ y_dst = height - y_dst - 1;
+ *x_src = x_dst;
+ *y_src = y_dst;
+}
+
+/*
+ * Given a cursor source coordinate, rotate to a screen coordinate
+ */
+static void
+xf86_crtc_rotate_coord_back (Rotation rotation,
+ int width,
+ int height,
+ int x_dst,
+ int y_dst,
+ int *x_src,
+ int *y_src)
+{
+ int t;
+
+ if (rotation & RR_Reflect_X)
+ x_dst = width - x_dst - 1;
+ if (rotation & RR_Reflect_Y)
+ y_dst = height - y_dst - 1;
+
+ switch (rotation & 0xf) {
+ case RR_Rotate_0:
+ break;
+ case RR_Rotate_90:
+ t = x_dst;
+ x_dst = y_dst;
+ y_dst = width - t - 1;
+ break;
+ case RR_Rotate_180:
+ x_dst = width - x_dst - 1;
+ y_dst = height - y_dst - 1;
+ break;
+ case RR_Rotate_270:
+ t = x_dst;
+ x_dst = height - y_dst - 1;
+ y_dst = t;
+ break;
+ }
+ *x_src = x_dst;
+ *y_src = y_dst;
+}
+
+struct cursor_bit {
+ CARD8 *byte;
+ char bitpos;
+};
+
+/*
+ * Convert an x coordinate to a position within the cursor bitmap
+ */
+static struct cursor_bit
+cursor_bitpos (CARD8 *image, xf86CursorInfoPtr cursor_info, int x, int y,
+ Bool mask)
+{
+ const int flags = cursor_info->Flags;
+ const Bool interleaved =
+ !!(flags & (HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1 |
+ HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_8 |
+ HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_16 |
+ HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_32 |
+ HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64));
+ const int width = cursor_info->MaxWidth;
+ const int height = cursor_info->MaxHeight;
+ const int stride = interleaved ? width / 4 : width / 8;
+
+ struct cursor_bit ret;
+
+ image += y * stride;
+
+ if (flags & HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK)
+ mask = !mask;
+ if (flags & HARDWARE_CURSOR_NIBBLE_SWAPPED)
+ x = (x & ~3) | (3 - (x & 3));
+ if (((flags & HARDWARE_CURSOR_BIT_ORDER_MSBFIRST) == 0) ==
+ (X_BYTE_ORDER == X_BIG_ENDIAN))
+ x = (x & ~7) | (7 - (x & 7));
+ if (flags & HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1)
+ x = (x << 1) + mask;
+ else if (flags & HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_8)
+ x = ((x & ~7) << 1) | (mask << 3) | (x & 7);
+ else if (flags & HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_16)
+ x = ((x & ~15) << 1) | (mask << 4) | (x & 15);
+ else if (flags & HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_32)
+ x = ((x & ~31) << 1) | (mask << 5) | (x & 31);
+ else if (flags & HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64)
+ x = ((x & ~63) << 1) | (mask << 6) | (x & 63);
+ else if (mask)
+ image += stride * height;
+
+ ret.byte = image + (x / 8);
+ ret.bitpos = x & 7;
+
+ return ret;
+}
+
+/*
+ * Fetch one bit from a cursor bitmap
+ */
+static CARD8
+get_bit (CARD8 *image, xf86CursorInfoPtr cursor_info, int x, int y, Bool mask)
+{
+ struct cursor_bit bit = cursor_bitpos(image, cursor_info, x, y, mask);
+ return (*bit.byte >> bit.bitpos) & 1;
+}
+
+/*
+ * Set one bit in a cursor bitmap
+ */
+static void
+set_bit (CARD8 *image, xf86CursorInfoPtr cursor_info, int x, int y, Bool mask)
+{
+ struct cursor_bit bit = cursor_bitpos(image, cursor_info, x, y, mask);
+ *bit.byte |= 1 << bit.bitpos;
+}
+
+/*
+ * Load a two color cursor into a driver that supports only ARGB cursors
+ */
+static void
+xf86_crtc_convert_cursor_to_argb (xf86CrtcPtr crtc, unsigned char *src)
+{
+ ScrnInfoPtr scrn = crtc->scrn;
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+ xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
+ CARD32 *cursor_image = (CARD32 *) xf86_config->cursor_image;
+ int x, y;
+ int xin, yin;
+ int flags = cursor_info->Flags;
+ CARD32 bits;
+
+#ifdef ARGB_CURSOR
+ crtc->cursor_argb = FALSE;
+#endif
+
+ for (y = 0; y < cursor_info->MaxHeight; y++)
+ for (x = 0; x < cursor_info->MaxWidth; x++)
+ {
+ xf86_crtc_rotate_coord (crtc->rotation,
+ cursor_info->MaxWidth,
+ cursor_info->MaxHeight,
+ x, y, &xin, &yin);
+ if (get_bit (src, cursor_info, xin, yin, TRUE) ==
+ ((flags & HARDWARE_CURSOR_INVERT_MASK) == 0))
+ {
+ if (get_bit (src, cursor_info, xin, yin, FALSE))
+ bits = xf86_config->cursor_fg;
+ else
+ bits = xf86_config->cursor_bg;
+ }
+ else
+ bits = 0;
+ cursor_image[y * cursor_info->MaxWidth + x] = bits;
+ }
+ crtc->funcs->load_cursor_argb (crtc, cursor_image);
+}
+
+/*
+ * Set the colors for a two-color cursor (ignore for ARGB cursors)
+ */
+static void
+xf86_set_cursor_colors (ScrnInfoPtr scrn, int bg, int fg)
+{
+ ScreenPtr screen = scrn->pScreen;
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+ CursorPtr cursor = xf86_config->cursor;
+ int c;
+ CARD8 *bits = cursor ?
+ dixLookupPrivate(&cursor->devPrivates, CursorScreenKey(screen))
+ : NULL;
+
+ /* Save ARGB versions of these colors */
+ xf86_config->cursor_fg = (CARD32) fg | 0xff000000;
+ xf86_config->cursor_bg = (CARD32) bg | 0xff000000;
+
+ for (c = 0; c < xf86_config->num_crtc; c++)
+ {
+ xf86CrtcPtr crtc = xf86_config->crtc[c];
+
+ if (crtc->enabled && !crtc->cursor_argb)
+ {
+ if (crtc->funcs->load_cursor_image)
+ crtc->funcs->set_cursor_colors (crtc, bg, fg);
+ else if (bits)
+ xf86_crtc_convert_cursor_to_argb (crtc, bits);
+ }
+ }
+}
+
+static void
+xf86_crtc_hide_cursor (xf86CrtcPtr crtc)
+{
+ if (crtc->cursor_shown)
+ {
+ crtc->funcs->hide_cursor (crtc);
+ crtc->cursor_shown = FALSE;
+ }
+}
+
+void
+xf86_hide_cursors (ScrnInfoPtr scrn)
+{
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+ int c;
+
+ xf86_config->cursor_on = FALSE;
+ for (c = 0; c < xf86_config->num_crtc; c++)
+ {
+ xf86CrtcPtr crtc = xf86_config->crtc[c];
+
+ if (crtc->enabled)
+ xf86_crtc_hide_cursor (crtc);
+ }
+}
+
+static void
+xf86_crtc_show_cursor (xf86CrtcPtr crtc)
+{
+ if (!crtc->cursor_shown && crtc->cursor_in_range)
+ {
+ crtc->funcs->show_cursor (crtc);
+ crtc->cursor_shown = TRUE;
+ }
+}
+
+void
+xf86_show_cursors (ScrnInfoPtr scrn)
+{
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+ int c;
+
+ xf86_config->cursor_on = TRUE;
+ for (c = 0; c < xf86_config->num_crtc; c++)
+ {
+ xf86CrtcPtr crtc = xf86_config->crtc[c];
+
+ if (crtc->enabled)
+ xf86_crtc_show_cursor (crtc);
+ }
+}
+
+static void
+xf86_crtc_set_cursor_position (xf86CrtcPtr crtc, int x, int y)
+{
+ ScrnInfoPtr scrn = crtc->scrn;
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+ xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
+ DisplayModePtr mode = &crtc->mode;
+ Bool in_range;
+ int dx, dy;
+
+ /*
+ * Transform position of cursor on screen
+ */
+ if (crtc->transform_in_use)
+ {
+ ScreenPtr screen = scrn->pScreen;
+ xf86CursorScreenPtr ScreenPriv =
+ (xf86CursorScreenPtr)dixLookupPrivate(&screen->devPrivates,
+ xf86CursorScreenKey);
+ struct pict_f_vector v;
+
+ v.v[0] = (x + ScreenPriv->HotX) + 0.5;
+ v.v[1] = (y + ScreenPriv->HotY) + 0.5;
+ v.v[2] = 1;
+ pixman_f_transform_point (&crtc->f_framebuffer_to_crtc, &v);
+ /* cursor will have 0.5 added to it already so floor is sufficent */
+ x = floor (v.v[0]);
+ y = floor (v.v[1]);
+ /*
+ * Transform position of cursor upper left corner
+ */
+ xf86_crtc_rotate_coord_back (crtc->rotation,
+ cursor_info->MaxWidth,
+ cursor_info->MaxHeight,
+ ScreenPriv->HotX, ScreenPriv->HotY, &dx, &dy);
+ x -= dx;
+ y -= dy;
+ }
+ else
+ {
+ x -= crtc->x;
+ y -= crtc->y;
+ }
+
+ /*
+ * Disable the cursor when it is outside the viewport
+ */
+ in_range = TRUE;
+ if (x >= mode->HDisplay || y >= mode->VDisplay ||
+ x <= -cursor_info->MaxWidth || y <= -cursor_info->MaxHeight)
+ {
+ in_range = FALSE;
+ x = 0;
+ y = 0;
+ }
+
+ crtc->cursor_in_range = in_range;
+
+ if (in_range)
+ {
+ crtc->funcs->set_cursor_position (crtc, x, y);
+ xf86_crtc_show_cursor (crtc);
+ }
+ else
+ xf86_crtc_hide_cursor (crtc);
+}
+
+static void
+xf86_set_cursor_position (ScrnInfoPtr scrn, int x, int y)
+{
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+ int c;
+
+ /* undo what xf86HWCurs did to the coordinates */
+ x += scrn->frameX0;
+ y += scrn->frameY0;
+ for (c = 0; c < xf86_config->num_crtc; c++)
+ {
+ xf86CrtcPtr crtc = xf86_config->crtc[c];
+
+ if (crtc->enabled)
+ xf86_crtc_set_cursor_position (crtc, x, y);
+ }
+}
+
+/*
+ * Load a two-color cursor into a crtc, performing rotation as needed
+ */
+static void
+xf86_crtc_load_cursor_image (xf86CrtcPtr crtc, CARD8 *src)
+{
+ ScrnInfoPtr scrn = crtc->scrn;
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+ xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
+ CARD8 *cursor_image;
+
+#ifdef ARGB_CURSOR
+ crtc->cursor_argb = FALSE;
+#endif
+
+ if (crtc->rotation == RR_Rotate_0)
+ cursor_image = src;
+ else
+ {
+ int x, y;
+ int xin, yin;
+ int stride = cursor_info->MaxWidth >> 2;
+
+ cursor_image = xf86_config->cursor_image;
+ memset(cursor_image, 0, cursor_info->MaxHeight * stride);
+
+ for (y = 0; y < cursor_info->MaxHeight; y++)
+ for (x = 0; x < cursor_info->MaxWidth; x++)
+ {
+ xf86_crtc_rotate_coord (crtc->rotation,
+ cursor_info->MaxWidth,
+ cursor_info->MaxHeight,
+ x, y, &xin, &yin);
+ if (get_bit(src, cursor_info, xin, yin, FALSE))
+ set_bit(cursor_image, cursor_info, x, y, FALSE);
+ if (get_bit(src, cursor_info, xin, yin, TRUE))
+ set_bit(cursor_image, cursor_info, x, y, TRUE);
+ }
+ }
+ crtc->funcs->load_cursor_image (crtc, cursor_image);
+}
+
+/*
+ * Load a cursor image into all active CRTCs
+ */
+static void
+xf86_load_cursor_image (ScrnInfoPtr scrn, unsigned char *src)
+{
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+ int c;
+
+ for (c = 0; c < xf86_config->num_crtc; c++)
+ {
+ xf86CrtcPtr crtc = xf86_config->crtc[c];
+
+ if (crtc->enabled)
+ {
+ if (crtc->funcs->load_cursor_image)
+ xf86_crtc_load_cursor_image (crtc, src);
+ else if (crtc->funcs->load_cursor_argb)
+ xf86_crtc_convert_cursor_to_argb (crtc, src);
+ }
+ }
+}
+
+static Bool
+xf86_use_hw_cursor (ScreenPtr screen, CursorPtr cursor)
+{
+ ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+ xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
+
+ ++cursor->refcnt;
+ if (xf86_config->cursor)
+ FreeCursor (xf86_config->cursor, None);
+ xf86_config->cursor = cursor;
+
+ if (cursor->bits->width > cursor_info->MaxWidth ||
+ cursor->bits->height> cursor_info->MaxHeight)
+ return FALSE;
+
+ return TRUE;
+}
+
+static Bool
+xf86_use_hw_cursor_argb (ScreenPtr screen, CursorPtr cursor)
+{
+ ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+ xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
+
+ ++cursor->refcnt;
+ if (xf86_config->cursor)
+ FreeCursor (xf86_config->cursor, None);
+ xf86_config->cursor = cursor;
+
+ /* Make sure ARGB support is available */
+ if ((cursor_info->Flags & HARDWARE_CURSOR_ARGB) == 0)
+ return FALSE;
+
+ if (cursor->bits->width > cursor_info->MaxWidth ||
+ cursor->bits->height> cursor_info->MaxHeight)
+ return FALSE;
+
+ return TRUE;
+}
+
+static void
+xf86_crtc_load_cursor_argb (xf86CrtcPtr crtc, CursorPtr cursor)
+{
+ ScrnInfoPtr scrn = crtc->scrn;
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+ xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
+ CARD32 *cursor_image = (CARD32 *) xf86_config->cursor_image;
+ CARD32 *cursor_source = (CARD32 *) cursor->bits->argb;
+ int x, y;
+ int xin, yin;
+ CARD32 bits;
+ int source_width = cursor->bits->width;
+ int source_height = cursor->bits->height;
+ int image_width = cursor_info->MaxWidth;
+ int image_height = cursor_info->MaxHeight;
+
+ for (y = 0; y < image_height; y++)
+ for (x = 0; x < image_width; x++)
+ {
+ xf86_crtc_rotate_coord (crtc->rotation, image_width, image_height,
+ x, y, &xin, &yin);
+ if (xin < source_width && yin < source_height)
+ bits = cursor_source[yin * source_width + xin];
+ else
+ bits = 0;
+ cursor_image[y * image_width + x] = bits;
+ }
+
+ crtc->funcs->load_cursor_argb (crtc, cursor_image);
+}
+
+static void
+xf86_load_cursor_argb (ScrnInfoPtr scrn, CursorPtr cursor)
+{
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+ int c;
+
+ for (c = 0; c < xf86_config->num_crtc; c++)
+ {
+ xf86CrtcPtr crtc = xf86_config->crtc[c];
+
+ if (crtc->enabled)
+ xf86_crtc_load_cursor_argb (crtc, cursor);
+ }
+}
+
+Bool
+xf86_cursors_init (ScreenPtr screen, int max_width, int max_height, int flags)
+{
+ ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+ xf86CursorInfoPtr cursor_info;
+
+ cursor_info = xf86CreateCursorInfoRec();
+ if (!cursor_info)
+ return FALSE;
+
+ xf86_config->cursor_image = malloc(max_width * max_height * 4);
+
+ if (!xf86_config->cursor_image)
+ {
+ xf86DestroyCursorInfoRec (cursor_info);
+ return FALSE;
+ }
+
+ xf86_config->cursor_info = cursor_info;
+
+ cursor_info->MaxWidth = max_width;
+ cursor_info->MaxHeight = max_height;
+ cursor_info->Flags = flags;
+
+ cursor_info->SetCursorColors = xf86_set_cursor_colors;
+ cursor_info->SetCursorPosition = xf86_set_cursor_position;
+ cursor_info->LoadCursorImage = xf86_load_cursor_image;
+ cursor_info->HideCursor = xf86_hide_cursors;
+ cursor_info->ShowCursor = xf86_show_cursors;
+ cursor_info->UseHWCursor = xf86_use_hw_cursor;
+#ifdef ARGB_CURSOR
+ if (flags & HARDWARE_CURSOR_ARGB)
+ {
+ cursor_info->UseHWCursorARGB = xf86_use_hw_cursor_argb;
+ cursor_info->LoadCursorARGB = xf86_load_cursor_argb;
+ }
+#endif
+
+ xf86_config->cursor = NULL;
+ xf86_hide_cursors (scrn);
+
+ return xf86InitCursor (screen, cursor_info);
+}
+
+/**
+ * Called when anything on the screen is reconfigured.
+ *
+ * Reloads cursor images as needed, then adjusts cursor positions
+ */
+
+void
+xf86_reload_cursors (ScreenPtr screen)
+{
+ ScrnInfoPtr scrn;
+ xf86CrtcConfigPtr xf86_config;
+ xf86CursorInfoPtr cursor_info;
+ CursorPtr cursor;
+ int x, y;
+ xf86CursorScreenPtr cursor_screen_priv;
+
+ /* initial mode setting will not have set a screen yet.
+ May be called before the devices are initialised.
+ */
+ if (!screen || !inputInfo.pointer)
+ return;
+ cursor_screen_priv = dixLookupPrivate(&screen->devPrivates,
+ xf86CursorScreenKey);
+ /* return if HW cursor is inactive, to avoid displaying two cursors */
+ if (!cursor_screen_priv || !cursor_screen_priv->isUp)
+ return;
+
+ scrn = xf86Screens[screen->myNum];
+ xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+
+ /* make sure the cursor code has been initialized */
+ cursor_info = xf86_config->cursor_info;
+ if (!cursor_info)
+ return;
+
+ cursor = xf86_config->cursor;
+ GetSpritePosition (inputInfo.pointer, &x, &y);
+ if (!(cursor_info->Flags & HARDWARE_CURSOR_UPDATE_UNHIDDEN))
+ (*cursor_info->HideCursor)(scrn);
+
+ if (cursor)
+ {
+ void *src = dixLookupPrivate(&cursor->devPrivates, CursorScreenKey(screen));
+#ifdef ARGB_CURSOR
+ if (cursor->bits->argb && cursor_info->LoadCursorARGB)
+ (*cursor_info->LoadCursorARGB) (scrn, cursor);
+ else if (src)
+#endif
+ (*cursor_info->LoadCursorImage)(scrn, src);
+
+ x += scrn->frameX0 + cursor_screen_priv->HotX;
+ y += scrn->frameY0 + cursor_screen_priv->HotY;
+ (*cursor_info->SetCursorPosition)(scrn, x, y);
+ }
+}
+
+/**
+ * Clean up CRTC-based cursor code
+ */
+void
+xf86_cursors_fini (ScreenPtr screen)
+{
+ ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+
+ if (xf86_config->cursor_info)
+ {
+ xf86DestroyCursorInfoRec (xf86_config->cursor_info);
+ xf86_config->cursor_info = NULL;
+ }
+ free(xf86_config->cursor_image);
+ xf86_config->cursor_image = NULL;
+ if (xf86_config->cursor)
+ {
+ FreeCursor (xf86_config->cursor, None);
+ xf86_config->cursor = NULL;
+ }
+}
diff --git a/xorg-server/hw/xfree86/modes/xf86RandR12.c b/xorg-server/hw/xfree86/modes/xf86RandR12.c
index 6d676363b..cb20d1c35 100644
--- a/xorg-server/hw/xfree86/modes/xf86RandR12.c
+++ b/xorg-server/hw/xfree86/modes/xf86RandR12.c
@@ -1,1823 +1,1823 @@
-/*
- * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
- *
- * 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 copyright holders not be used in advertising or
- * publicity pertaining to distribution of the software without specific,
- * written prior permission. The copyright holders make no representations
- * about the suitability of this software for any purpose. It is provided "as
- * is" without express or implied warranty.
- *
- * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE COPYRIGHT HOLDERS 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_XORG_CONFIG_H
-#include <xorg-config.h>
-#else
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#endif
-
-#include "xf86.h"
-#include "os.h"
-#include "globals.h"
-#include "xf86Priv.h"
-#include "xf86DDC.h"
-#include "mipointer.h"
-#include "windowstr.h"
-#include "inputstr.h"
-#include <randrstr.h>
-#include <X11/extensions/render.h>
-
-#include "xf86Crtc.h"
-#include "xf86RandR12.h"
-
-typedef struct _xf86RandR12Info {
- int virtualX;
- int virtualY;
- int mmWidth;
- int mmHeight;
- int maxX;
- int maxY;
- int pointerX;
- int pointerY;
- Rotation rotation; /* current mode */
- Rotation supported_rotations; /* driver supported */
-
- /* Used to wrap EnterVT so we can re-probe the outputs when a laptop unsuspends
- * (actually, any time that we switch back into our VT).
- *
- * See https://bugs.freedesktop.org/show_bug.cgi?id=21554
- */
- xf86EnterVTProc *orig_EnterVT;
-} XF86RandRInfoRec, *XF86RandRInfoPtr;
-
-#ifdef RANDR_12_INTERFACE
-static Bool xf86RandR12Init12 (ScreenPtr pScreen);
-static Bool xf86RandR12CreateScreenResources12 (ScreenPtr pScreen);
-#endif
-
-static int xf86RandR12Generation;
-
-static DevPrivateKeyRec xf86RandR12KeyRec;
-static DevPrivateKey xf86RandR12Key;
-#define XF86RANDRINFO(p) ((XF86RandRInfoPtr) \
- dixLookupPrivate(&(p)->devPrivates, xf86RandR12Key))
-
-
-static int
-xf86RandR12ModeRefresh (DisplayModePtr mode)
-{
- if (mode->VRefresh)
- return (int) (mode->VRefresh + 0.5);
- else
- return (int) (mode->Clock * 1000.0 / mode->HTotal / mode->VTotal + 0.5);
-}
-
-/* Adapt panning area; return TRUE if panning area was valid without adaption */
-static int
-xf86RandR13VerifyPanningArea (xf86CrtcPtr crtc, int screenWidth, int screenHeight)
-{
- int ret = TRUE;
-
- if (crtc->version < 2)
- return FALSE;
-
- if (crtc->panningTotalArea.x2 <= crtc->panningTotalArea.x1) {
- /* Panning in X is disabled */
- if (crtc->panningTotalArea.x1 || crtc->panningTotalArea.x2)
- /* Illegal configuration -> fail/disable */
- ret = FALSE;
- crtc->panningTotalArea.x1 = crtc->panningTotalArea.x2 = 0;
- crtc->panningTrackingArea.x1 = crtc->panningTrackingArea.x2 = 0;
- crtc->panningBorder[0] = crtc->panningBorder[2] = 0;
- } else {
- /* Panning in X is enabled */
- if (crtc->panningTotalArea.x1 < 0) {
- /* Panning region outside screen -> move inside */
- crtc->panningTotalArea.x2 -= crtc->panningTotalArea.x1;
- crtc->panningTotalArea.x1 = 0;
- ret = FALSE;
- }
- if (crtc->panningTotalArea.x2 < crtc->panningTotalArea.x1 + crtc->mode.HDisplay) {
- /* Panning region smaller than displayed area -> crop to displayed area */
- crtc->panningTotalArea.x2 = crtc->panningTotalArea.x1 + crtc->mode.HDisplay;
- ret = FALSE;
- }
- if (crtc->panningTotalArea.x2 > screenWidth) {
- /* Panning region larger than screen -> move inside, then crop to screen */
- crtc->panningTotalArea.x1 -= crtc->panningTotalArea.x2 - screenWidth;
- crtc->panningTotalArea.x2 = screenWidth;
- ret = FALSE;
- if (crtc->panningTotalArea.x1 < 0)
- crtc->panningTotalArea.x1 = 0;
- }
- if (crtc->panningBorder[0] + crtc->panningBorder[2] > crtc->mode.HDisplay) {
- /* Borders too large -> set to 0 */
- crtc->panningBorder[0] = crtc->panningBorder[2] = 0;
- ret = FALSE;
- }
- }
-
- if (crtc->panningTotalArea.y2 <= crtc->panningTotalArea.y1) {
- /* Panning in Y is disabled */
- if (crtc->panningTotalArea.y1 || crtc->panningTotalArea.y2)
- /* Illegal configuration -> fail/disable */
- ret = FALSE;
- crtc->panningTotalArea.y1 = crtc->panningTotalArea.y2 = 0;
- crtc->panningTrackingArea.y1 = crtc->panningTrackingArea.y2 = 0;
- crtc->panningBorder[1] = crtc->panningBorder[3] = 0;
- } else {
- /* Panning in Y is enabled */
- if (crtc->panningTotalArea.y1 < 0) {
- /* Panning region outside screen -> move inside */
- crtc->panningTotalArea.y2 -= crtc->panningTotalArea.y1;
- crtc->panningTotalArea.y1 = 0;
- ret = FALSE;
- }
- if (crtc->panningTotalArea.y2 < crtc->panningTotalArea.y1 + crtc->mode.VDisplay) {
- /* Panning region smaller than displayed area -> crop to displayed area */
- crtc->panningTotalArea.y2 = crtc->panningTotalArea.y1 + crtc->mode.VDisplay;
- ret = FALSE;
- }
- if (crtc->panningTotalArea.y2 > screenHeight) {
- /* Panning region larger than screen -> move inside, then crop to screen */
- crtc->panningTotalArea.y1 -= crtc->panningTotalArea.y2 - screenHeight;
- crtc->panningTotalArea.y2 = screenHeight;
- ret = FALSE;
- if (crtc->panningTotalArea.y1 < 0)
- crtc->panningTotalArea.y1 = 0;
- }
- if (crtc->panningBorder[1] + crtc->panningBorder[3] > crtc->mode.VDisplay) {
- /* Borders too large -> set to 0 */
- crtc->panningBorder[1] = crtc->panningBorder[3] = 0;
- ret = FALSE;
- }
- }
-
- return ret;
-}
-
-/*
- * The heart of the panning operation:
- *
- * Given a frame buffer position (fb_x, fb_y),
- * and a crtc position (crtc_x, crtc_y),
- * and a transform matrix which maps frame buffer to crtc,
- * compute a panning position (pan_x, pan_y) that
- * makes the resulting transform line those two up
- */
-
-static void
-xf86ComputeCrtcPan (Bool transform_in_use,
- struct pixman_f_transform *m,
- double screen_x, double screen_y,
- double crtc_x, double crtc_y,
- int old_pan_x, int old_pan_y,
- int *new_pan_x, int *new_pan_y)
-{
- if (transform_in_use) {
- /*
- * Given the current transform, M, the current position
- * on the Screen, S, and the desired position on the CRTC,
- * C, compute a translation, T, such that:
- *
- * M T S = C
- *
- * where T is of the form
- *
- * | 1 0 dx |
- * | 0 1 dy |
- * | 0 0 1 |
- *
- * M T S =
- * | M00 Sx + M01 Sy + M00 dx + M01 dy + M02 | | Cx F |
- * | M10 Sx + M11 Sy + M10 dx + M11 dy + M12 | = | Cy F |
- * | M20 Sx + M21 Sy + M20 dx + M21 dy + M22 | | F |
- *
- * R = M S
- *
- * Cx F = M00 dx + M01 dy + R0
- * Cy F = M10 dx + M11 dy + R1
- * F = M20 dx + M21 dy + R2
- *
- * Zero out dx, then dy
- *
- * F (Cx M10 - Cy M00) =
- * (M10 M01 - M00 M11) dy + M10 R0 - M00 R1
- * F (M10 - Cy M20) =
- * (M10 M21 - M20 M11) dy + M10 R2 - M20 R1
- *
- * F (Cx M11 - Cy M01) =
- * (M11 M00 - M01 M10) dx + M11 R0 - M01 R1
- * F (M11 - Cy M21) =
- * (M11 M20 - M21 M10) dx + M11 R2 - M21 R1
- *
- * Make some temporaries
- *
- * T = | Cx M10 - Cy M00 |
- * | Cx M11 - Cy M01 |
- *
- * U = | M10 M01 - M00 M11 |
- * | M11 M00 - M01 M10 |
- *
- * Q = | M10 R0 - M00 R1 |
- * | M11 R0 - M01 R1 |
- *
- * P = | M10 - Cy M20 |
- * | M11 - Cy M21 |
- *
- * W = | M10 M21 - M20 M11 |
- * | M11 M20 - M21 M10 |
- *
- * V = | M10 R2 - M20 R1 |
- * | M11 R2 - M21 R1 |
- *
- * Rewrite:
- *
- * F T0 = U0 dy + Q0
- * F P0 = W0 dy + V0
- * F T1 = U1 dx + Q1
- * F P1 = W1 dx + V1
- *
- * Solve for F (two ways)
- *
- * F (W0 T0 - U0 P0) = W0 Q0 - U0 V0
- *
- * W0 Q0 - U0 V0
- * F = -------------
- * W0 T0 - U0 P0
- *
- * F (W1 T1 - U1 P1) = W1 Q1 - U1 V1
- *
- * W1 Q1 - U1 V1
- * F = -------------
- * W1 T1 - U1 P1
- *
- * We'll use which ever solution works (denominator != 0)
- *
- * Finally, solve for dx and dy:
- *
- * dx = (F T1 - Q1) / U1
- * dx = (F P1 - V1) / W1
- *
- * dy = (F T0 - Q0) / U0
- * dy = (F P0 - V0) / W0
- */
- double r[3];
- double q[2], u[2], t[2], v[2], w[2], p[2];
- double f;
- struct pict_f_vector d;
- int i;
-
- /* Get the un-normalized crtc coordinates again */
- for (i = 0; i < 3; i++)
- r[i] = m->m[i][0] * screen_x + m->m[i][1] * screen_y + m->m[i][2];
-
- /* Combine values into temporaries */
- for (i = 0; i < 2; i++) {
- q[i] = m->m[1][i] * r[0] - m->m[0][i] * r[1];
- u[i] = m->m[1][i] * m->m[0][1-i] - m->m[0][i] * m->m[1][1-i];
- t[i] = m->m[1][i] * crtc_x - m->m[0][i] * crtc_y;
-
- v[i] = m->m[1][i] * r[2] - m->m[2][i] * r[1];
- w[i] = m->m[1][i] * m->m[2][1-i] - m->m[2][i] * m->m[1][1-i];
- p[i] = m->m[1][i] - m->m[2][i] * crtc_y;
- }
-
- /* Find a way to compute f */
- f = 0;
- for (i = 0; i < 2; i++) {
- double a = w[i] * q[i] - u[i] * v[i];
- double b = w[i] * t[i] - u[i] * p[i];
- if (b != 0) {
- f = a/b;
- break;
- }
- }
-
- /* Solve for the resulting transform vector */
- for (i = 0; i < 2; i++) {
- if (u[i])
- d.v[1-i] = (t[i] * f - q[i]) / u[i];
- else if (w[1])
- d.v[1-i] = (p[i] * f - v[i]) / w[i];
- else
- d.v[1-i] = 0;
- }
- *new_pan_x = old_pan_x - floor (d.v[0] + 0.5);
- *new_pan_y = old_pan_y - floor (d.v[1] + 0.5);
- } else {
- *new_pan_x = screen_x - crtc_x;
- *new_pan_y = screen_y - crtc_y;
- }
-}
-
-static void
-xf86RandR13Pan (xf86CrtcPtr crtc, int x, int y)
-{
- int newX, newY;
- int width, height;
- Bool panned = FALSE;
-
- if (crtc->version < 2)
- return;
-
- if (! crtc->enabled ||
- (crtc->panningTotalArea.x2 <= crtc->panningTotalArea.x1 &&
- crtc->panningTotalArea.y2 <= crtc->panningTotalArea.y1))
- return;
-
- newX = crtc->x;
- newY = crtc->y;
- width = crtc->mode.HDisplay;
- height = crtc->mode.VDisplay;
-
- if ((crtc->panningTrackingArea.x2 <= crtc->panningTrackingArea.x1 ||
- (x >= crtc->panningTrackingArea.x1 && x < crtc->panningTrackingArea.x2)) &&
- (crtc->panningTrackingArea.y2 <= crtc->panningTrackingArea.y1 ||
- (y >= crtc->panningTrackingArea.y1 && y < crtc->panningTrackingArea.y2)))
- {
- struct pict_f_vector c;
-
- /*
- * Pre-clip the mouse position to the panning area so that we don't
- * push the crtc outside. This doesn't deal with changes to the
- * panning values, only mouse position changes.
- */
- if (crtc->panningTotalArea.x2 > crtc->panningTotalArea.x1)
- {
- if (x < crtc->panningTotalArea.x1)
- x = crtc->panningTotalArea.x1;
- if (x >= crtc->panningTotalArea.x2)
- x = crtc->panningTotalArea.x2 - 1;
- }
- if (crtc->panningTotalArea.y2 > crtc->panningTotalArea.y1)
- {
- if (y < crtc->panningTotalArea.y1)
- y = crtc->panningTotalArea.y1;
- if (y >= crtc->panningTotalArea.y2)
- y = crtc->panningTotalArea.y2 - 1;
- }
-
- c.v[0] = x;
- c.v[1] = y;
- c.v[2] = 1.0;
- if (crtc->transform_in_use) {
- pixman_f_transform_point(&crtc->f_framebuffer_to_crtc, &c);
- } else {
- c.v[0] -= crtc->x;
- c.v[1] -= crtc->y;
- }
-
- if (crtc->panningTotalArea.x2 > crtc->panningTotalArea.x1) {
- if (c.v[0] < crtc->panningBorder[0]) {
- c.v[0] = crtc->panningBorder[0];
- panned = TRUE;
- }
- if (c.v[0] >= width - crtc->panningBorder[2]) {
- c.v[0] = width - crtc->panningBorder[2] - 1;
- panned = TRUE;
- }
- }
- if (crtc->panningTotalArea.y2 > crtc->panningTotalArea.y1) {
- if (c.v[1] < crtc->panningBorder[1]) {
- c.v[1] = crtc->panningBorder[1];
- panned = TRUE;
- }
- if (c.v[1] >= height - crtc->panningBorder[3]) {
- c.v[1] = height - crtc->panningBorder[3] - 1;
- panned = TRUE;
- }
- }
- if (panned)
- xf86ComputeCrtcPan (crtc->transform_in_use,
- &crtc->f_framebuffer_to_crtc,
- x, y, c.v[0], c.v[1],
- newX, newY, &newX, &newY);
- }
-
- /*
- * Ensure that the crtc is within the panning region.
- *
- * XXX This computation only works when we do not have a transform
- * in use.
- */
- if (!crtc->transform_in_use)
- {
- /* Validate against [xy]1 after [xy]2, to be sure that results are > 0 for [xy]1 > 0 */
- if (crtc->panningTotalArea.x2 > crtc->panningTotalArea.x1) {
- if (newX > crtc->panningTotalArea.x2 - width)
- newX = crtc->panningTotalArea.x2 - width;
- if (newX < crtc->panningTotalArea.x1)
- newX = crtc->panningTotalArea.x1;
- }
- if (crtc->panningTotalArea.y2 > crtc->panningTotalArea.y1) {
- if (newY > crtc->panningTotalArea.y2 - height)
- newY = crtc->panningTotalArea.y2 - height;
- if (newY < crtc->panningTotalArea.y1)
- newY = crtc->panningTotalArea.y1;
- }
- }
- if (newX != crtc->x || newY != crtc->y)
- xf86CrtcSetOrigin (crtc, newX, newY);
-}
-
-static Bool
-xf86RandR12GetInfo (ScreenPtr pScreen, Rotation *rotations)
-{
- RRScreenSizePtr pSize;
- ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
- XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
- DisplayModePtr mode;
- int refresh0 = 60;
- int maxX = 0, maxY = 0;
-
- *rotations = randrp->supported_rotations;
-
- if (randrp->virtualX == -1 || randrp->virtualY == -1)
- {
- randrp->virtualX = scrp->virtualX;
- randrp->virtualY = scrp->virtualY;
- }
-
- /* Re-probe the outputs for new monitors or modes */
- if (scrp->vtSema)
- {
- xf86ProbeOutputModes (scrp, 0, 0);
- xf86SetScrnInfoModes (scrp);
- }
-
- for (mode = scrp->modes; ; mode = mode->next)
- {
- int refresh = xf86RandR12ModeRefresh (mode);
- if (randrp->maxX == 0 || randrp->maxY == 0)
- {
- if (maxX < mode->HDisplay)
- maxX = mode->HDisplay;
- if (maxY < mode->VDisplay)
- maxY = mode->VDisplay;
- }
- if (mode == scrp->modes)
- refresh0 = refresh;
- pSize = RRRegisterSize (pScreen,
- mode->HDisplay, mode->VDisplay,
- randrp->mmWidth, randrp->mmHeight);
- if (!pSize)
- return FALSE;
- RRRegisterRate (pScreen, pSize, refresh);
-
- if (xf86ModesEqual(mode, scrp->currentMode))
- {
- RRSetCurrentConfig (pScreen, randrp->rotation, refresh, pSize);
- }
- if (mode->next == scrp->modes)
- break;
- }
-
- if (randrp->maxX == 0 || randrp->maxY == 0)
- {
- randrp->maxX = maxX;
- randrp->maxY = maxY;
- }
-
- return TRUE;
-}
-
-static Bool
-xf86RandR12SetMode (ScreenPtr pScreen,
- DisplayModePtr mode,
- Bool useVirtual,
- int mmWidth,
- int mmHeight)
-{
- ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
- XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
- int oldWidth = pScreen->width;
- int oldHeight = pScreen->height;
- int oldmmWidth = pScreen->mmWidth;
- int oldmmHeight = pScreen->mmHeight;
- WindowPtr pRoot = pScreen->root;
- DisplayModePtr currentMode = NULL;
- Bool ret = TRUE;
-
- if (pRoot)
- (*scrp->EnableDisableFBAccess) (pScreen->myNum, FALSE);
- if (useVirtual)
- {
- scrp->virtualX = randrp->virtualX;
- scrp->virtualY = randrp->virtualY;
- }
- else
- {
- scrp->virtualX = mode->HDisplay;
- scrp->virtualY = mode->VDisplay;
- }
-
- if(randrp->rotation & (RR_Rotate_90 | RR_Rotate_270))
- {
- /* If the screen is rotated 90 or 270 degrees, swap the sizes. */
- pScreen->width = scrp->virtualY;
- pScreen->height = scrp->virtualX;
- pScreen->mmWidth = mmHeight;
- pScreen->mmHeight = mmWidth;
- }
- else
- {
- pScreen->width = scrp->virtualX;
- pScreen->height = scrp->virtualY;
- pScreen->mmWidth = mmWidth;
- pScreen->mmHeight = mmHeight;
- }
- if (scrp->currentMode == mode) {
- /* Save current mode */
- currentMode = scrp->currentMode;
- /* Reset, just so we ensure the drivers SwitchMode is called */
- scrp->currentMode = NULL;
- }
- /*
- * We know that if the driver failed to SwitchMode to the rotated
- * version, then it should revert back to it's prior mode.
- */
- if (!xf86SwitchMode (pScreen, mode))
- {
- ret = FALSE;
- scrp->virtualX = pScreen->width = oldWidth;
- scrp->virtualY = pScreen->height = oldHeight;
- pScreen->mmWidth = oldmmWidth;
- pScreen->mmHeight = oldmmHeight;
- scrp->currentMode = currentMode;
- }
-
- /*
- * Make sure the layout is correct
- */
- xf86ReconfigureLayout();
-
- /*
- * Make sure the whole screen is visible
- */
- xf86SetViewport (pScreen, pScreen->width, pScreen->height);
- xf86SetViewport (pScreen, 0, 0);
- if (pRoot)
- (*scrp->EnableDisableFBAccess) (pScreen->myNum, TRUE);
- return ret;
-}
-
-Bool
-xf86RandR12SetConfig (ScreenPtr pScreen,
- Rotation rotation,
- int rate,
- RRScreenSizePtr pSize)
-{
- ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
- XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
- DisplayModePtr mode;
- int pos[MAXDEVICES][2];
- Bool useVirtual = FALSE;
- int maxX = 0, maxY = 0;
- Rotation oldRotation = randrp->rotation;
- DeviceIntPtr dev;
- Bool view_adjusted = FALSE;
-
- randrp->rotation = rotation;
-
- if (randrp->virtualX == -1 || randrp->virtualY == -1)
- {
- randrp->virtualX = scrp->virtualX;
- randrp->virtualY = scrp->virtualY;
- }
-
- for (dev = inputInfo.devices; dev; dev = dev->next)
- {
- if (!IsMaster(dev) && !IsFloating(dev))
- continue;
-
- miPointerGetPosition(dev, &pos[dev->id][0], &pos[dev->id][1]);
- }
-
- for (mode = scrp->modes; ; mode = mode->next)
- {
- if (randrp->maxX == 0 || randrp->maxY == 0)
- {
- if (maxX < mode->HDisplay)
- maxX = mode->HDisplay;
- if (maxY < mode->VDisplay)
- maxY = mode->VDisplay;
- }
- if (mode->HDisplay == pSize->width &&
- mode->VDisplay == pSize->height &&
- (rate == 0 || xf86RandR12ModeRefresh (mode) == rate))
- break;
- if (mode->next == scrp->modes)
- {
- if (pSize->width == randrp->virtualX &&
- pSize->height == randrp->virtualY)
- {
- mode = scrp->modes;
- useVirtual = TRUE;
- break;
- }
- if (randrp->maxX == 0 || randrp->maxY == 0)
- {
- randrp->maxX = maxX;
- randrp->maxY = maxY;
- }
- return FALSE;
- }
- }
-
- if (randrp->maxX == 0 || randrp->maxY == 0)
- {
- randrp->maxX = maxX;
- randrp->maxY = maxY;
- }
-
- if (!xf86RandR12SetMode (pScreen, mode, useVirtual, pSize->mmWidth,
- pSize->mmHeight)) {
- randrp->rotation = oldRotation;
- return FALSE;
- }
-
- /*
- * Move the cursor back where it belongs; SwitchMode repositions it
- * FIXME: duplicated code, see modes/xf86RandR12.c
- */
- for (dev = inputInfo.devices; dev; dev = dev->next)
- {
- if (!IsMaster(dev) && !IsFloating(dev))
- continue;
-
- if (pScreen == miPointerGetScreen(dev)) {
- int px = pos[dev->id][0];
- int py = pos[dev->id][1];
-
- px = (px >= pScreen->width ? (pScreen->width - 1) : px);
- py = (py >= pScreen->height ? (pScreen->height - 1) : py);
-
- /* Setting the viewpoint makes only sense on one device */
- if (!view_adjusted && IsMaster(dev)) {
- xf86SetViewport(pScreen, px, py);
- view_adjusted = TRUE;
- }
-
- (*pScreen->SetCursorPosition) (dev, pScreen, px, py, FALSE);
- }
- }
-
- return TRUE;
-}
-
-static Bool
-xf86RandR12ScreenSetSize (ScreenPtr pScreen,
- CARD16 width,
- CARD16 height,
- CARD32 mmWidth,
- CARD32 mmHeight)
-{
- XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
- ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen);
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
- WindowPtr pRoot = pScreen->root;
- PixmapPtr pScrnPix;
- Bool ret = FALSE;
- int c;
-
- if (xf86RandR12Key) {
- if (randrp->virtualX == -1 || randrp->virtualY == -1)
- {
- randrp->virtualX = pScrn->virtualX;
- randrp->virtualY = pScrn->virtualY;
- }
- }
- if (pRoot && pScrn->vtSema)
- (*pScrn->EnableDisableFBAccess) (pScreen->myNum, FALSE);
-
- /* Let the driver update virtualX and virtualY */
- if (!(*config->funcs->resize)(pScrn, width, height))
- goto finish;
-
- ret = TRUE;
- /* Update panning information */
- for (c = 0; c < config->num_crtc; c++) {
- xf86CrtcPtr crtc = config->crtc[c];
- if (crtc->panningTotalArea.x2 > crtc->panningTotalArea.x1 ||
- crtc->panningTotalArea.y2 > crtc->panningTotalArea.y1) {
- if (crtc->panningTotalArea.x2 > crtc->panningTrackingArea.x1)
- crtc->panningTotalArea.x2 += width - pScreen->width;
- if (crtc->panningTotalArea.y2 > crtc->panningTrackingArea.y1)
- crtc->panningTotalArea.y2 += height - pScreen->height;
- if (crtc->panningTrackingArea.x2 > crtc->panningTrackingArea.x1)
- crtc->panningTrackingArea.x2 += width - pScreen->width;
- if (crtc->panningTrackingArea.y2 > crtc->panningTrackingArea.y1)
- crtc->panningTrackingArea.y2 += height - pScreen->height;
- xf86RandR13VerifyPanningArea (crtc, width, height);
- xf86RandR13Pan (crtc, randrp->pointerX, randrp->pointerY);
- }
- }
-
- pScrnPix = (*pScreen->GetScreenPixmap)(pScreen);
- pScreen->width = pScrnPix->drawable.width = width;
- pScreen->height = pScrnPix->drawable.height = height;
- randrp->mmWidth = pScreen->mmWidth = mmWidth;
- randrp->mmHeight = pScreen->mmHeight = mmHeight;
-
- xf86SetViewport (pScreen, pScreen->width-1, pScreen->height-1);
- xf86SetViewport (pScreen, 0, 0);
-
-finish:
- if (pRoot && pScrn->vtSema)
- (*pScrn->EnableDisableFBAccess) (pScreen->myNum, TRUE);
-#if RANDR_12_INTERFACE
- if (xf86RandR12Key && pScreen->root && ret)
- RRScreenSizeNotify (pScreen);
-#endif
- return ret;
-}
-
-Rotation
-xf86RandR12GetRotation(ScreenPtr pScreen)
-{
- XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
-
- return randrp->rotation;
-}
-
-Bool
-xf86RandR12CreateScreenResources (ScreenPtr pScreen)
-{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- xf86CrtcConfigPtr config;
- XF86RandRInfoPtr randrp;
- int c;
- int width, height;
- int mmWidth, mmHeight;
-#ifdef PANORAMIX
- /* XXX disable RandR when using Xinerama */
- if (!noPanoramiXExtension)
- return TRUE;
-#endif
-
- config = XF86_CRTC_CONFIG_PTR(pScrn);
- randrp = XF86RANDRINFO(pScreen);
- /*
- * Compute size of screen
- */
- width = 0; height = 0;
- for (c = 0; c < config->num_crtc; c++)
- {
- xf86CrtcPtr crtc = config->crtc[c];
- int crtc_width = crtc->x + xf86ModeWidth (&crtc->mode, crtc->rotation);
- int crtc_height = crtc->y + xf86ModeHeight (&crtc->mode, crtc->rotation);
-
- if (crtc->enabled) {
- if (crtc_width > width)
- width = crtc_width;
- if (crtc_height > height)
- height = crtc_height;
- if (crtc->panningTotalArea.x2 > width)
- width = crtc->panningTotalArea.x2;
- if (crtc->panningTotalArea.y2 > height)
- height = crtc->panningTotalArea.y2;
- }
- }
-
- if (width && height)
- {
- /*
- * Compute physical size of screen
- */
- if (monitorResolution)
- {
- mmWidth = width * 25.4 / monitorResolution;
- mmHeight = height * 25.4 / monitorResolution;
- }
- else
- {
- xf86OutputPtr output = xf86CompatOutput(pScrn);
-
- if (output &&
- output->conf_monitor &&
- (output->conf_monitor->mon_width > 0 &&
- output->conf_monitor->mon_height > 0))
- {
- /*
- * Prefer user configured DisplaySize
- */
- mmWidth = output->conf_monitor->mon_width;
- mmHeight = output->conf_monitor->mon_height;
- }
- else
- {
- /*
- * Otherwise, just set the screen to DEFAULT_DPI
- */
- mmWidth = width * 25.4 / DEFAULT_DPI;
- mmHeight = height * 25.4 / DEFAULT_DPI;
- }
- }
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "Setting screen physical size to %d x %d\n",
- mmWidth, mmHeight);
- /*
- * This is the initial setting of the screen size.
- * We have to pre-set it here, otherwise panning would be adapted
- * to the new screen size.
- */
- pScreen->width = width;
- pScreen->height = height;
- xf86RandR12ScreenSetSize (pScreen,
- width,
- height,
- mmWidth,
- mmHeight);
- }
-
- if (xf86RandR12Key == NULL)
- return TRUE;
-
- if (randrp->virtualX == -1 || randrp->virtualY == -1)
- {
- randrp->virtualX = pScrn->virtualX;
- randrp->virtualY = pScrn->virtualY;
- }
- xf86CrtcSetScreenSubpixelOrder (pScreen);
-#if RANDR_12_INTERFACE
- if (xf86RandR12CreateScreenResources12 (pScreen))
- return TRUE;
-#endif
- return TRUE;
-}
-
-
-Bool
-xf86RandR12Init (ScreenPtr pScreen)
-{
- rrScrPrivPtr rp;
- XF86RandRInfoPtr randrp;
-
-#ifdef PANORAMIX
- /* XXX disable RandR when using Xinerama */
- if (!noPanoramiXExtension)
- {
- if (xf86NumScreens == 1)
- noPanoramiXExtension = TRUE;
- else
- return TRUE;
- }
-#endif
-
- if (xf86RandR12Generation != serverGeneration)
- xf86RandR12Generation = serverGeneration;
-
- xf86RandR12Key = &xf86RandR12KeyRec;
- if (!dixRegisterPrivateKey(&xf86RandR12KeyRec, PRIVATE_SCREEN, 0))
- return FALSE;
-
- randrp = malloc(sizeof (XF86RandRInfoRec));
- if (!randrp)
- return FALSE;
-
- if (!RRScreenInit(pScreen))
- {
- free(randrp);
- return FALSE;
- }
- rp = rrGetScrPriv(pScreen);
- rp->rrGetInfo = xf86RandR12GetInfo;
- rp->rrSetConfig = xf86RandR12SetConfig;
-
- randrp->virtualX = -1;
- randrp->virtualY = -1;
- randrp->mmWidth = pScreen->mmWidth;
- randrp->mmHeight = pScreen->mmHeight;
-
- randrp->rotation = RR_Rotate_0; /* initial rotated mode */
-
- randrp->supported_rotations = RR_Rotate_0;
-
- randrp->maxX = randrp->maxY = 0;
-
- dixSetPrivate(&pScreen->devPrivates, xf86RandR12Key, randrp);
-
-#if RANDR_12_INTERFACE
- if (!xf86RandR12Init12 (pScreen))
- return FALSE;
-#endif
- return TRUE;
-}
-
-void
-xf86RandR12CloseScreen (ScreenPtr pScreen)
-{
- XF86RandRInfoPtr randrp;
-
- if (xf86RandR12Key == NULL)
- return;
-
- randrp = XF86RANDRINFO(pScreen);
-#if RANDR_12_INTERFACE
- xf86Screens[pScreen->myNum]->EnterVT = randrp->orig_EnterVT;
-#endif
-
- free(randrp);
-}
-
-void
-xf86RandR12SetRotations (ScreenPtr pScreen, Rotation rotations)
-{
- XF86RandRInfoPtr randrp;
-#if RANDR_12_INTERFACE
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- int c;
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
-#endif
-
- if (xf86RandR12Key == NULL)
- return;
-
- randrp = XF86RANDRINFO(pScreen);
-#if RANDR_12_INTERFACE
- for (c = 0; c < config->num_crtc; c++) {
- xf86CrtcPtr crtc = config->crtc[c];
-
- RRCrtcSetRotations (crtc->randr_crtc, rotations);
- }
-#endif
- randrp->supported_rotations = rotations;
-}
-
-void
-xf86RandR12SetTransformSupport (ScreenPtr pScreen, Bool transforms)
-{
- XF86RandRInfoPtr randrp;
-#if RANDR_13_INTERFACE
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- int c;
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
-#endif
-
- if (xf86RandR12Key == NULL)
- return;
-
- randrp = XF86RANDRINFO(pScreen);
-#if RANDR_13_INTERFACE
- for (c = 0; c < config->num_crtc; c++) {
- xf86CrtcPtr crtc = config->crtc[c];
-
- RRCrtcSetTransformSupport (crtc->randr_crtc, transforms);
- }
-#endif
-}
-
-void
-xf86RandR12GetOriginalVirtualSize(ScrnInfoPtr pScrn, int *x, int *y)
-{
- ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex];
-
- if (xf86RandR12Generation != serverGeneration ||
- XF86RANDRINFO(pScreen)->virtualX == -1)
- {
- *x = pScrn->virtualX;
- *y = pScrn->virtualY;
- } else {
- XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
-
- *x = randrp->virtualX;
- *y = randrp->virtualY;
- }
-}
-
-#if RANDR_12_INTERFACE
-
-#define FLAG_BITS (RR_HSyncPositive | \
- RR_HSyncNegative | \
- RR_VSyncPositive | \
- RR_VSyncNegative | \
- RR_Interlace | \
- RR_DoubleScan | \
- RR_CSync | \
- RR_CSyncPositive | \
- RR_CSyncNegative | \
- RR_HSkewPresent | \
- RR_BCast | \
- RR_PixelMultiplex | \
- RR_DoubleClock | \
- RR_ClockDivideBy2)
-
-static Bool
-xf86RandRModeMatches (RRModePtr randr_mode,
- DisplayModePtr mode)
-{
-#if 0
- if (match_name)
- {
- /* check for same name */
- int len = strlen (mode->name);
- if (randr_mode->mode.nameLength != len) return FALSE;
- if (memcmp (randr_mode->name, mode->name, len) != 0) return FALSE;
- }
-#endif
-
- /* check for same timings */
- if (randr_mode->mode.dotClock / 1000 != mode->Clock) return FALSE;
- if (randr_mode->mode.width != mode->HDisplay) return FALSE;
- if (randr_mode->mode.hSyncStart != mode->HSyncStart) return FALSE;
- if (randr_mode->mode.hSyncEnd != mode->HSyncEnd) return FALSE;
- if (randr_mode->mode.hTotal != mode->HTotal) return FALSE;
- if (randr_mode->mode.hSkew != mode->HSkew) return FALSE;
- if (randr_mode->mode.height != mode->VDisplay) return FALSE;
- if (randr_mode->mode.vSyncStart != mode->VSyncStart) return FALSE;
- if (randr_mode->mode.vSyncEnd != mode->VSyncEnd) return FALSE;
- if (randr_mode->mode.vTotal != mode->VTotal) return FALSE;
-
- /* check for same flags (using only the XF86 valid flag bits) */
- if ((randr_mode->mode.modeFlags & FLAG_BITS) != (mode->Flags & FLAG_BITS))
- return FALSE;
-
- /* everything matches */
- return TRUE;
-}
-
-static Bool
-xf86RandR12CrtcNotify (RRCrtcPtr randr_crtc)
-{
- ScreenPtr pScreen = randr_crtc->pScreen;
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
- RRModePtr randr_mode = NULL;
- int x;
- int y;
- Rotation rotation;
- int numOutputs;
- RROutputPtr *randr_outputs;
- RROutputPtr randr_output;
- xf86CrtcPtr crtc = randr_crtc->devPrivate;
- xf86OutputPtr output;
- int i, j;
- DisplayModePtr mode = &crtc->mode;
- Bool ret;
-
- randr_outputs = malloc(config->num_output * sizeof (RROutputPtr));
- if (!randr_outputs)
- return FALSE;
- x = crtc->x;
- y = crtc->y;
- rotation = crtc->rotation;
- numOutputs = 0;
- randr_mode = NULL;
- for (i = 0; i < config->num_output; i++)
- {
- output = config->output[i];
- if (output->crtc == crtc)
- {
- randr_output = output->randr_output;
- randr_outputs[numOutputs++] = randr_output;
- /*
- * We make copies of modes, so pointer equality
- * isn't sufficient
- */
- for (j = 0; j < randr_output->numModes + randr_output->numUserModes; j++)
- {
- RRModePtr m = (j < randr_output->numModes ?
- randr_output->modes[j] :
- randr_output->userModes[j-randr_output->numModes]);
-
- if (xf86RandRModeMatches (m, mode))
- {
- randr_mode = m;
- break;
- }
- }
- }
- }
- ret = RRCrtcNotify (randr_crtc, randr_mode, x, y,
- rotation,
- crtc->transformPresent ? &crtc->transform : NULL,
- numOutputs, randr_outputs);
- free(randr_outputs);
- return ret;
-}
-
-/*
- * Convert a RandR mode to a DisplayMode
- */
-static void
-xf86RandRModeConvert (ScrnInfoPtr scrn,
- RRModePtr randr_mode,
- DisplayModePtr mode)
-{
- memset(mode, 0, sizeof(DisplayModeRec));
- mode->status = MODE_OK;
-
- mode->Clock = randr_mode->mode.dotClock / 1000;
-
- mode->HDisplay = randr_mode->mode.width;
- mode->HSyncStart = randr_mode->mode.hSyncStart;
- mode->HSyncEnd = randr_mode->mode.hSyncEnd;
- mode->HTotal = randr_mode->mode.hTotal;
- mode->HSkew = randr_mode->mode.hSkew;
-
- mode->VDisplay = randr_mode->mode.height;
- mode->VSyncStart = randr_mode->mode.vSyncStart;
- mode->VSyncEnd = randr_mode->mode.vSyncEnd;
- mode->VTotal = randr_mode->mode.vTotal;
- mode->VScan = 0;
-
- mode->Flags = randr_mode->mode.modeFlags & FLAG_BITS;
-
- xf86SetModeCrtc (mode, scrn->adjustFlags);
-}
-
-static Bool
-xf86RandR12CrtcSet (ScreenPtr pScreen,
- RRCrtcPtr randr_crtc,
- RRModePtr randr_mode,
- int x,
- int y,
- Rotation rotation,
- int num_randr_outputs,
- RROutputPtr *randr_outputs)
-{
- XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
- xf86CrtcPtr crtc = randr_crtc->devPrivate;
- RRTransformPtr transform;
- Bool changed = FALSE;
- int o, ro;
- xf86CrtcPtr *save_crtcs;
- Bool save_enabled = crtc->enabled;
-
- if (!crtc->scrn->vtSema)
- return FALSE;
-
- save_crtcs = malloc(config->num_output * sizeof (xf86CrtcPtr));
- if ((randr_mode != NULL) != crtc->enabled)
- changed = TRUE;
- else if (randr_mode && !xf86RandRModeMatches (randr_mode, &crtc->mode))
- changed = TRUE;
-
- if (rotation != crtc->rotation)
- changed = TRUE;
-
- transform = RRCrtcGetTransform (randr_crtc);
- if ((transform != NULL) != crtc->transformPresent)
- changed = TRUE;
- else if (transform && memcmp (&transform->transform, &crtc->transform.transform,
- sizeof (transform->transform)) != 0)
- changed = TRUE;
-
- if (x != crtc->x || y != crtc->y)
- changed = TRUE;
- for (o = 0; o < config->num_output; o++)
- {
- xf86OutputPtr output = config->output[o];
- xf86CrtcPtr new_crtc;
-
- save_crtcs[o] = output->crtc;
-
- if (output->crtc == crtc)
- new_crtc = NULL;
- else
- new_crtc = output->crtc;
- for (ro = 0; ro < num_randr_outputs; ro++)
- if (output->randr_output == randr_outputs[ro])
- {
- new_crtc = crtc;
- break;
- }
- if (new_crtc != output->crtc)
- {
- changed = TRUE;
- output->crtc = new_crtc;
- }
- }
- for (ro = 0; ro < num_randr_outputs; ro++)
- if (randr_outputs[ro]->pendingProperties)
- changed = TRUE;
-
- /* XXX need device-independent mode setting code through an API */
- if (changed)
- {
- crtc->enabled = randr_mode != NULL;
-
- if (randr_mode)
- {
- DisplayModeRec mode;
- RRTransformPtr transform = RRCrtcGetTransform (randr_crtc);
-
- xf86RandRModeConvert (pScrn, randr_mode, &mode);
- if (!xf86CrtcSetModeTransform (crtc, &mode, rotation, transform, x, y))
- {
- crtc->enabled = save_enabled;
- for (o = 0; o < config->num_output; o++)
- {
- xf86OutputPtr output = config->output[o];
- output->crtc = save_crtcs[o];
- }
- free(save_crtcs);
- return FALSE;
- }
- xf86RandR13VerifyPanningArea (crtc, pScreen->width, pScreen->height);
- xf86RandR13Pan (crtc, randrp->pointerX, randrp->pointerY);
- /*
- * Save the last successful setting for EnterVT
- */
- crtc->desiredMode = mode;
- crtc->desiredRotation = rotation;
- if (transform) {
- crtc->desiredTransform = *transform;
- crtc->desiredTransformPresent = TRUE;
- } else
- crtc->desiredTransformPresent = FALSE;
-
- crtc->desiredX = x;
- crtc->desiredY = y;
- }
- xf86DisableUnusedFunctions (pScrn);
- }
- free(save_crtcs);
- return xf86RandR12CrtcNotify (randr_crtc);
-}
-
-static Bool
-xf86RandR12CrtcSetGamma (ScreenPtr pScreen,
- RRCrtcPtr randr_crtc)
-{
- xf86CrtcPtr crtc = randr_crtc->devPrivate;
-
- if (crtc->funcs->gamma_set == NULL)
- return FALSE;
-
- if (!crtc->scrn->vtSema)
- return TRUE;
-
- /* Realloc local gamma if needed. */
- if (randr_crtc->gammaSize != crtc->gamma_size) {
- CARD16 *tmp_ptr;
- tmp_ptr = realloc(crtc->gamma_red, 3 * crtc->gamma_size * sizeof (CARD16));
- if (!tmp_ptr)
- return FALSE;
- crtc->gamma_red = tmp_ptr;
- crtc->gamma_green = crtc->gamma_red + crtc->gamma_size;
- crtc->gamma_blue = crtc->gamma_green + crtc->gamma_size;
- }
-
- crtc->gamma_size = randr_crtc->gammaSize;
- memcpy (crtc->gamma_red, randr_crtc->gammaRed, crtc->gamma_size * sizeof (CARD16));
- memcpy (crtc->gamma_green, randr_crtc->gammaGreen, crtc->gamma_size * sizeof (CARD16));
- memcpy (crtc->gamma_blue, randr_crtc->gammaBlue, crtc->gamma_size * sizeof (CARD16));
-
- /* Only set it when the crtc is actually running.
- * Otherwise it will be set when it's activated.
- */
- if (crtc->active)
- crtc->funcs->gamma_set(crtc, crtc->gamma_red, crtc->gamma_green,
- crtc->gamma_blue, crtc->gamma_size);
-
- return TRUE;
-}
-
-static Bool
-xf86RandR12CrtcGetGamma (ScreenPtr pScreen,
- RRCrtcPtr randr_crtc)
-{
- xf86CrtcPtr crtc = randr_crtc->devPrivate;
-
- if (!crtc->gamma_size)
- return FALSE;
-
- if (!crtc->gamma_red || !crtc->gamma_green || !crtc->gamma_blue)
- return FALSE;
-
- /* Realloc randr gamma if needed. */
- if (randr_crtc->gammaSize != crtc->gamma_size) {
- CARD16 *tmp_ptr;
- tmp_ptr = realloc(randr_crtc->gammaRed, 3 * crtc->gamma_size * sizeof (CARD16));
- if (!tmp_ptr)
- return FALSE;
- randr_crtc->gammaRed = tmp_ptr;
- randr_crtc->gammaGreen = randr_crtc->gammaRed + crtc->gamma_size;
- randr_crtc->gammaBlue = randr_crtc->gammaGreen + crtc->gamma_size;
- }
- randr_crtc->gammaSize = crtc->gamma_size;
- memcpy (randr_crtc->gammaRed, crtc->gamma_red, crtc->gamma_size * sizeof (CARD16));
- memcpy (randr_crtc->gammaGreen, crtc->gamma_green, crtc->gamma_size * sizeof (CARD16));
- memcpy (randr_crtc->gammaBlue, crtc->gamma_blue, crtc->gamma_size * sizeof (CARD16));
-
- return TRUE;
-}
-
-static Bool
-xf86RandR12OutputSetProperty (ScreenPtr pScreen,
- RROutputPtr randr_output,
- Atom property,
- RRPropertyValuePtr value)
-{
- xf86OutputPtr output = randr_output->devPrivate;
-
- /* If we don't have any property handler, then we don't care what the
- * user is setting properties to.
- */
- if (output->funcs->set_property == NULL)
- return TRUE;
-
- /*
- * This function gets called even when vtSema is FALSE, as
- * drivers will need to remember the correct value to apply
- * when the VT switch occurs
- */
- return output->funcs->set_property(output, property, value);
-}
-
-static Bool
-xf86RandR13OutputGetProperty (ScreenPtr pScreen,
- RROutputPtr randr_output,
- Atom property)
-{
- xf86OutputPtr output = randr_output->devPrivate;
-
- if (output->funcs->get_property == NULL)
- return TRUE;
-
- /* Should be safe even w/o vtSema */
- return output->funcs->get_property(output, property);
-}
-
-static Bool
-xf86RandR12OutputValidateMode (ScreenPtr pScreen,
- RROutputPtr randr_output,
- RRModePtr randr_mode)
-{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- xf86OutputPtr output = randr_output->devPrivate;
- DisplayModeRec mode;
-
- xf86RandRModeConvert (pScrn, randr_mode, &mode);
- /*
- * This function may be called when vtSema is FALSE, so
- * the underlying function must either avoid touching the hardware
- * or return FALSE when vtSema is FALSE
- */
- if (output->funcs->mode_valid (output, &mode) != MODE_OK)
- return FALSE;
- return TRUE;
-}
-
-static void
-xf86RandR12ModeDestroy (ScreenPtr pScreen, RRModePtr randr_mode)
-{
-}
-
-/**
- * Given a list of xf86 modes and a RandR Output object, construct
- * RandR modes and assign them to the output
- */
-static Bool
-xf86RROutputSetModes (RROutputPtr randr_output, DisplayModePtr modes)
-{
- DisplayModePtr mode;
- RRModePtr *rrmodes = NULL;
- int nmode = 0;
- int npreferred = 0;
- Bool ret = TRUE;
- int pref;
-
- for (mode = modes; mode; mode = mode->next)
- nmode++;
-
- if (nmode) {
- rrmodes = malloc(nmode * sizeof (RRModePtr));
-
- if (!rrmodes)
- return FALSE;
- nmode = 0;
-
- for (pref = 1; pref >= 0; pref--) {
- for (mode = modes; mode; mode = mode->next) {
- if ((pref != 0) == ((mode->type & M_T_PREFERRED) != 0)) {
- xRRModeInfo modeInfo;
- RRModePtr rrmode;
-
- modeInfo.nameLength = strlen (mode->name);
- modeInfo.width = mode->HDisplay;
- modeInfo.dotClock = mode->Clock * 1000;
- modeInfo.hSyncStart = mode->HSyncStart;
- modeInfo.hSyncEnd = mode->HSyncEnd;
- modeInfo.hTotal = mode->HTotal;
- modeInfo.hSkew = mode->HSkew;
-
- modeInfo.height = mode->VDisplay;
- modeInfo.vSyncStart = mode->VSyncStart;
- modeInfo.vSyncEnd = mode->VSyncEnd;
- modeInfo.vTotal = mode->VTotal;
- modeInfo.modeFlags = mode->Flags;
-
- rrmode = RRModeGet (&modeInfo, mode->name);
- if (rrmode) {
- rrmodes[nmode++] = rrmode;
- npreferred += pref;
- }
- }
- }
- }
- }
-
- ret = RROutputSetModes (randr_output, rrmodes, nmode, npreferred);
- free(rrmodes);
- return ret;
-}
-
-/*
- * Mirror the current mode configuration to RandR
- */
-static Bool
-xf86RandR12SetInfo12 (ScreenPtr pScreen)
-{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
- RROutputPtr *clones;
- RRCrtcPtr *crtcs;
- int ncrtc;
- int o, c, l;
- RRCrtcPtr randr_crtc;
- int nclone;
-
- clones = malloc(config->num_output * sizeof (RROutputPtr));
- crtcs = malloc(config->num_crtc * sizeof (RRCrtcPtr));
- for (o = 0; o < config->num_output; o++)
- {
- xf86OutputPtr output = config->output[o];
-
- ncrtc = 0;
- for (c = 0; c < config->num_crtc; c++)
- if (output->possible_crtcs & (1 << c))
- crtcs[ncrtc++] = config->crtc[c]->randr_crtc;
-
- if (output->crtc)
- randr_crtc = output->crtc->randr_crtc;
- else
- randr_crtc = NULL;
-
- if (!RROutputSetCrtcs (output->randr_output, crtcs, ncrtc))
- {
- free(crtcs);
- free(clones);
- return FALSE;
- }
-
- RROutputSetPhysicalSize(output->randr_output,
- output->mm_width,
- output->mm_height);
- xf86RROutputSetModes (output->randr_output, output->probed_modes);
-
- switch (output->status) {
- case XF86OutputStatusConnected:
- RROutputSetConnection (output->randr_output, RR_Connected);
- break;
- case XF86OutputStatusDisconnected:
- RROutputSetConnection (output->randr_output, RR_Disconnected);
- break;
- case XF86OutputStatusUnknown:
- RROutputSetConnection (output->randr_output, RR_UnknownConnection);
- break;
- }
-
- RROutputSetSubpixelOrder (output->randr_output, output->subpixel_order);
-
- /*
- * Valid clones
- */
- nclone = 0;
- for (l = 0; l < config->num_output; l++)
- {
- xf86OutputPtr clone = config->output[l];
-
- if (l != o && (output->possible_clones & (1 << l)))
- clones[nclone++] = clone->randr_output;
- }
- if (!RROutputSetClones (output->randr_output, clones, nclone))
- {
- free(crtcs);
- free(clones);
- return FALSE;
- }
- }
- free(crtcs);
- free(clones);
- return TRUE;
-}
-
-
-
-/*
- * Query the hardware for the current state, then mirror
- * that to RandR
- */
-static Bool
-xf86RandR12GetInfo12 (ScreenPtr pScreen, Rotation *rotations)
-{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
-
- if (!pScrn->vtSema)
- return TRUE;
- xf86ProbeOutputModes (pScrn, 0, 0);
- xf86SetScrnInfoModes (pScrn);
- return xf86RandR12SetInfo12 (pScreen);
-}
-
-static Bool
-xf86RandR12CreateObjects12 (ScreenPtr pScreen)
-{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
- int c;
- int o;
-
- if (!RRInit ())
- return FALSE;
-
- /*
- * Configure crtcs
- */
- for (c = 0; c < config->num_crtc; c++)
- {
- xf86CrtcPtr crtc = config->crtc[c];
-
- crtc->randr_crtc = RRCrtcCreate (pScreen, crtc);
- RRCrtcGammaSetSize (crtc->randr_crtc, 256);
- }
- /*
- * Configure outputs
- */
- for (o = 0; o < config->num_output; o++)
- {
- xf86OutputPtr output = config->output[o];
-
- output->randr_output = RROutputCreate (pScreen, output->name,
- strlen (output->name),
- output);
-
- if (output->funcs->create_resources != NULL)
- output->funcs->create_resources(output);
- RRPostPendingProperties (output->randr_output);
- }
- return TRUE;
-}
-
-static Bool
-xf86RandR12CreateScreenResources12 (ScreenPtr pScreen)
-{
- int c;
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
-
- if (xf86RandR12Key == NULL)
- return TRUE;
-
- for (c = 0; c < config->num_crtc; c++)
- xf86RandR12CrtcNotify (config->crtc[c]->randr_crtc);
-
- RRScreenSetSizeRange (pScreen, config->minWidth, config->minHeight,
- config->maxWidth, config->maxHeight);
- return TRUE;
-}
-
-/*
- * Something happened within the screen configuration due
- * to DGA, VidMode or hot key. Tell RandR
- */
-
-void
-xf86RandR12TellChanged (ScreenPtr pScreen)
-{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
- int c;
-
- if (xf86RandR12Key == NULL)
- return;
-
- xf86RandR12SetInfo12 (pScreen);
- for (c = 0; c < config->num_crtc; c++)
- xf86RandR12CrtcNotify (config->crtc[c]->randr_crtc);
-
- RRTellChanged (pScreen);
-}
-
-static void
-xf86RandR12PointerMoved (int scrnIndex, int x, int y)
-{
- ScreenPtr pScreen = screenInfo.screens[scrnIndex];
- ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen);
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
- XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
- int c;
-
- randrp->pointerX = x;
- randrp->pointerY = y;
- for (c = 0; c < config->num_crtc; c++)
- xf86RandR13Pan (config->crtc[c], x, y);
-}
-
-static Bool
-xf86RandR13GetPanning (ScreenPtr pScreen,
- RRCrtcPtr randr_crtc,
- BoxPtr totalArea,
- BoxPtr trackingArea,
- INT16 *border)
-{
- xf86CrtcPtr crtc = randr_crtc->devPrivate;
-
- if (crtc->version < 2)
- return FALSE;
- if (totalArea)
- memcpy (totalArea, &crtc->panningTotalArea, sizeof(BoxRec));
- if (trackingArea)
- memcpy (trackingArea, &crtc->panningTrackingArea, sizeof(BoxRec));
- if (border)
- memcpy (border, crtc->panningBorder, 4*sizeof(INT16));
-
- return TRUE;
-}
-
-static Bool
-xf86RandR13SetPanning (ScreenPtr pScreen,
- RRCrtcPtr randr_crtc,
- BoxPtr totalArea,
- BoxPtr trackingArea,
- INT16 *border)
-{
- XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
- xf86CrtcPtr crtc = randr_crtc->devPrivate;
- BoxRec oldTotalArea;
- BoxRec oldTrackingArea;
- INT16 oldBorder[4];
-
-
- if (crtc->version < 2)
- return FALSE;
-
- memcpy (&oldTotalArea, &crtc->panningTotalArea, sizeof(BoxRec));
- memcpy (&oldTrackingArea, &crtc->panningTrackingArea, sizeof(BoxRec));
- memcpy (oldBorder, crtc->panningBorder, 4*sizeof(INT16));
-
- if (totalArea)
- memcpy (&crtc->panningTotalArea, totalArea, sizeof(BoxRec));
- if (trackingArea)
- memcpy (&crtc->panningTrackingArea, trackingArea, sizeof(BoxRec));
- if (border)
- memcpy (crtc->panningBorder, border, 4*sizeof(INT16));
-
- if (xf86RandR13VerifyPanningArea (crtc, pScreen->width, pScreen->height)) {
- xf86RandR13Pan (crtc, randrp->pointerX, randrp->pointerY);
- return TRUE;
- } else {
- /* Restore old settings */
- memcpy (&crtc->panningTotalArea, &oldTotalArea, sizeof(BoxRec));
- memcpy (&crtc->panningTrackingArea, &oldTrackingArea, sizeof(BoxRec));
- memcpy (crtc->panningBorder, oldBorder, 4*sizeof(INT16));
- return FALSE;
- }
-}
-
-/*
- * Compatibility with XF86VidMode's gamma changer. This necessarily clobbers
- * any per-crtc setup. You asked for it...
- */
-
-static void
-gamma_to_ramp(float gamma, CARD16 *ramp, int size)
-{
- int i;
-
- for (i = 0; i < size; i++) {
- if (gamma == 1.0)
- ramp[i] = i << 8;
- else
- ramp[i] = (CARD16)(pow((double)i / (double)(size - 1), 1. / gamma)
- * (double)(size - 1) * 256);
- }
-}
-
-static int
-xf86RandR12ChangeGamma(int scrnIndex, Gamma gamma)
-{
- CARD16 *points, *red, *green, *blue;
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
- RRCrtcPtr crtc = xf86CompatRRCrtc(pScrn);
- int size;
-
- if (!crtc)
- return Success;
-
- size = max(0, crtc->gammaSize);
- if (!size)
- return Success;
-
- points = calloc(size, 3 * sizeof(CARD16));
- if (!points)
- return BadAlloc;
-
- red = points;
- green = points + size;
- blue = points + 2 * size;
-
- gamma_to_ramp(gamma.red, red, size);
- gamma_to_ramp(gamma.green, green, size);
- gamma_to_ramp(gamma.blue, blue, size);
- RRCrtcGammaSet(crtc, red, green, blue);
-
- free(points);
-
- pScrn->gamma = gamma;
-
- return Success;
-}
-
-static Bool
-xf86RandR12EnterVT (int screen_index, int flags)
-{
- ScreenPtr pScreen = screenInfo.screens[screen_index];
- ScrnInfoPtr pScrn = xf86Screens[screen_index];
- XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
- rrScrPrivPtr rp = rrGetScrPriv(pScreen);
- Bool ret;
- int i;
-
- if (randrp->orig_EnterVT) {
- pScrn->EnterVT = randrp->orig_EnterVT;
- ret = pScrn->EnterVT (screen_index, flags);
- randrp->orig_EnterVT = pScrn->EnterVT;
- pScrn->EnterVT = xf86RandR12EnterVT;
- if (!ret)
- return FALSE;
- }
-
- /* reload gamma */
- for (i = 0; i < rp->numCrtcs; i++)
- xf86RandR12CrtcSetGamma(pScreen, rp->crtcs[i]);
-
- return RRGetInfo (pScreen, TRUE); /* force a re-probe of outputs and notify clients about changes */
-}
-
-static Bool
-xf86RandR12Init12 (ScreenPtr pScreen)
-{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- rrScrPrivPtr rp = rrGetScrPriv(pScreen);
- XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
- int i;
-
- rp->rrGetInfo = xf86RandR12GetInfo12;
- rp->rrScreenSetSize = xf86RandR12ScreenSetSize;
- rp->rrCrtcSet = xf86RandR12CrtcSet;
- rp->rrCrtcSetGamma = xf86RandR12CrtcSetGamma;
- rp->rrCrtcGetGamma = xf86RandR12CrtcGetGamma;
- rp->rrOutputSetProperty = xf86RandR12OutputSetProperty;
- rp->rrOutputValidateMode = xf86RandR12OutputValidateMode;
-#if RANDR_13_INTERFACE
- rp->rrOutputGetProperty = xf86RandR13OutputGetProperty;
- rp->rrGetPanning = xf86RandR13GetPanning;
- rp->rrSetPanning = xf86RandR13SetPanning;
-#endif
- rp->rrModeDestroy = xf86RandR12ModeDestroy;
- rp->rrSetConfig = NULL;
- pScrn->PointerMoved = xf86RandR12PointerMoved;
- pScrn->ChangeGamma = xf86RandR12ChangeGamma;
-
- randrp->orig_EnterVT = pScrn->EnterVT;
- pScrn->EnterVT = xf86RandR12EnterVT;
-
- if (!xf86RandR12CreateObjects12 (pScreen))
- return FALSE;
-
- /*
- * Configure output modes
- */
- if (!xf86RandR12SetInfo12 (pScreen))
- return FALSE;
- for (i = 0; i < rp->numCrtcs; i++) {
- xf86RandR12CrtcGetGamma(pScreen, rp->crtcs[i]);
- }
- return TRUE;
-}
-
-#endif
-
-Bool
-xf86RandR12PreInit (ScrnInfoPtr pScrn)
-{
- return TRUE;
-}
+/*
+ * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * 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 copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no representations
+ * about the suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS 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_XORG_CONFIG_H
+#include <xorg-config.h>
+#else
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#endif
+
+#include "xf86.h"
+#include "os.h"
+#include "globals.h"
+#include "xf86Priv.h"
+#include "xf86DDC.h"
+#include "mipointer.h"
+#include "windowstr.h"
+#include "inputstr.h"
+#include <randrstr.h>
+#include <X11/extensions/render.h>
+
+#include "xf86Crtc.h"
+#include "xf86RandR12.h"
+
+typedef struct _xf86RandR12Info {
+ int virtualX;
+ int virtualY;
+ int mmWidth;
+ int mmHeight;
+ int maxX;
+ int maxY;
+ int pointerX;
+ int pointerY;
+ Rotation rotation; /* current mode */
+ Rotation supported_rotations; /* driver supported */
+
+ /* Used to wrap EnterVT so we can re-probe the outputs when a laptop unsuspends
+ * (actually, any time that we switch back into our VT).
+ *
+ * See https://bugs.freedesktop.org/show_bug.cgi?id=21554
+ */
+ xf86EnterVTProc *orig_EnterVT;
+} XF86RandRInfoRec, *XF86RandRInfoPtr;
+
+#ifdef RANDR_12_INTERFACE
+static Bool xf86RandR12Init12 (ScreenPtr pScreen);
+static Bool xf86RandR12CreateScreenResources12 (ScreenPtr pScreen);
+#endif
+
+static int xf86RandR12Generation;
+
+static DevPrivateKeyRec xf86RandR12KeyRec;
+static DevPrivateKey xf86RandR12Key;
+#define XF86RANDRINFO(p) ((XF86RandRInfoPtr) \
+ dixLookupPrivate(&(p)->devPrivates, xf86RandR12Key))
+
+
+static int
+xf86RandR12ModeRefresh (DisplayModePtr mode)
+{
+ if (mode->VRefresh)
+ return (int) (mode->VRefresh + 0.5);
+ else
+ return (int) (mode->Clock * 1000.0 / mode->HTotal / mode->VTotal + 0.5);
+}
+
+/* Adapt panning area; return TRUE if panning area was valid without adaption */
+static int
+xf86RandR13VerifyPanningArea (xf86CrtcPtr crtc, int screenWidth, int screenHeight)
+{
+ int ret = TRUE;
+
+ if (crtc->version < 2)
+ return FALSE;
+
+ if (crtc->panningTotalArea.x2 <= crtc->panningTotalArea.x1) {
+ /* Panning in X is disabled */
+ if (crtc->panningTotalArea.x1 || crtc->panningTotalArea.x2)
+ /* Illegal configuration -> fail/disable */
+ ret = FALSE;
+ crtc->panningTotalArea.x1 = crtc->panningTotalArea.x2 = 0;
+ crtc->panningTrackingArea.x1 = crtc->panningTrackingArea.x2 = 0;
+ crtc->panningBorder[0] = crtc->panningBorder[2] = 0;
+ } else {
+ /* Panning in X is enabled */
+ if (crtc->panningTotalArea.x1 < 0) {
+ /* Panning region outside screen -> move inside */
+ crtc->panningTotalArea.x2 -= crtc->panningTotalArea.x1;
+ crtc->panningTotalArea.x1 = 0;
+ ret = FALSE;
+ }
+ if (crtc->panningTotalArea.x2 < crtc->panningTotalArea.x1 + crtc->mode.HDisplay) {
+ /* Panning region smaller than displayed area -> crop to displayed area */
+ crtc->panningTotalArea.x2 = crtc->panningTotalArea.x1 + crtc->mode.HDisplay;
+ ret = FALSE;
+ }
+ if (crtc->panningTotalArea.x2 > screenWidth) {
+ /* Panning region larger than screen -> move inside, then crop to screen */
+ crtc->panningTotalArea.x1 -= crtc->panningTotalArea.x2 - screenWidth;
+ crtc->panningTotalArea.x2 = screenWidth;
+ ret = FALSE;
+ if (crtc->panningTotalArea.x1 < 0)
+ crtc->panningTotalArea.x1 = 0;
+ }
+ if (crtc->panningBorder[0] + crtc->panningBorder[2] > crtc->mode.HDisplay) {
+ /* Borders too large -> set to 0 */
+ crtc->panningBorder[0] = crtc->panningBorder[2] = 0;
+ ret = FALSE;
+ }
+ }
+
+ if (crtc->panningTotalArea.y2 <= crtc->panningTotalArea.y1) {
+ /* Panning in Y is disabled */
+ if (crtc->panningTotalArea.y1 || crtc->panningTotalArea.y2)
+ /* Illegal configuration -> fail/disable */
+ ret = FALSE;
+ crtc->panningTotalArea.y1 = crtc->panningTotalArea.y2 = 0;
+ crtc->panningTrackingArea.y1 = crtc->panningTrackingArea.y2 = 0;
+ crtc->panningBorder[1] = crtc->panningBorder[3] = 0;
+ } else {
+ /* Panning in Y is enabled */
+ if (crtc->panningTotalArea.y1 < 0) {
+ /* Panning region outside screen -> move inside */
+ crtc->panningTotalArea.y2 -= crtc->panningTotalArea.y1;
+ crtc->panningTotalArea.y1 = 0;
+ ret = FALSE;
+ }
+ if (crtc->panningTotalArea.y2 < crtc->panningTotalArea.y1 + crtc->mode.VDisplay) {
+ /* Panning region smaller than displayed area -> crop to displayed area */
+ crtc->panningTotalArea.y2 = crtc->panningTotalArea.y1 + crtc->mode.VDisplay;
+ ret = FALSE;
+ }
+ if (crtc->panningTotalArea.y2 > screenHeight) {
+ /* Panning region larger than screen -> move inside, then crop to screen */
+ crtc->panningTotalArea.y1 -= crtc->panningTotalArea.y2 - screenHeight;
+ crtc->panningTotalArea.y2 = screenHeight;
+ ret = FALSE;
+ if (crtc->panningTotalArea.y1 < 0)
+ crtc->panningTotalArea.y1 = 0;
+ }
+ if (crtc->panningBorder[1] + crtc->panningBorder[3] > crtc->mode.VDisplay) {
+ /* Borders too large -> set to 0 */
+ crtc->panningBorder[1] = crtc->panningBorder[3] = 0;
+ ret = FALSE;
+ }
+ }
+
+ return ret;
+}
+
+/*
+ * The heart of the panning operation:
+ *
+ * Given a frame buffer position (fb_x, fb_y),
+ * and a crtc position (crtc_x, crtc_y),
+ * and a transform matrix which maps frame buffer to crtc,
+ * compute a panning position (pan_x, pan_y) that
+ * makes the resulting transform line those two up
+ */
+
+static void
+xf86ComputeCrtcPan (Bool transform_in_use,
+ struct pixman_f_transform *m,
+ double screen_x, double screen_y,
+ double crtc_x, double crtc_y,
+ int old_pan_x, int old_pan_y,
+ int *new_pan_x, int *new_pan_y)
+{
+ if (transform_in_use) {
+ /*
+ * Given the current transform, M, the current position
+ * on the Screen, S, and the desired position on the CRTC,
+ * C, compute a translation, T, such that:
+ *
+ * M T S = C
+ *
+ * where T is of the form
+ *
+ * | 1 0 dx |
+ * | 0 1 dy |
+ * | 0 0 1 |
+ *
+ * M T S =
+ * | M00 Sx + M01 Sy + M00 dx + M01 dy + M02 | | Cx F |
+ * | M10 Sx + M11 Sy + M10 dx + M11 dy + M12 | = | Cy F |
+ * | M20 Sx + M21 Sy + M20 dx + M21 dy + M22 | | F |
+ *
+ * R = M S
+ *
+ * Cx F = M00 dx + M01 dy + R0
+ * Cy F = M10 dx + M11 dy + R1
+ * F = M20 dx + M21 dy + R2
+ *
+ * Zero out dx, then dy
+ *
+ * F (Cx M10 - Cy M00) =
+ * (M10 M01 - M00 M11) dy + M10 R0 - M00 R1
+ * F (M10 - Cy M20) =
+ * (M10 M21 - M20 M11) dy + M10 R2 - M20 R1
+ *
+ * F (Cx M11 - Cy M01) =
+ * (M11 M00 - M01 M10) dx + M11 R0 - M01 R1
+ * F (M11 - Cy M21) =
+ * (M11 M20 - M21 M10) dx + M11 R2 - M21 R1
+ *
+ * Make some temporaries
+ *
+ * T = | Cx M10 - Cy M00 |
+ * | Cx M11 - Cy M01 |
+ *
+ * U = | M10 M01 - M00 M11 |
+ * | M11 M00 - M01 M10 |
+ *
+ * Q = | M10 R0 - M00 R1 |
+ * | M11 R0 - M01 R1 |
+ *
+ * P = | M10 - Cy M20 |
+ * | M11 - Cy M21 |
+ *
+ * W = | M10 M21 - M20 M11 |
+ * | M11 M20 - M21 M10 |
+ *
+ * V = | M10 R2 - M20 R1 |
+ * | M11 R2 - M21 R1 |
+ *
+ * Rewrite:
+ *
+ * F T0 = U0 dy + Q0
+ * F P0 = W0 dy + V0
+ * F T1 = U1 dx + Q1
+ * F P1 = W1 dx + V1
+ *
+ * Solve for F (two ways)
+ *
+ * F (W0 T0 - U0 P0) = W0 Q0 - U0 V0
+ *
+ * W0 Q0 - U0 V0
+ * F = -------------
+ * W0 T0 - U0 P0
+ *
+ * F (W1 T1 - U1 P1) = W1 Q1 - U1 V1
+ *
+ * W1 Q1 - U1 V1
+ * F = -------------
+ * W1 T1 - U1 P1
+ *
+ * We'll use which ever solution works (denominator != 0)
+ *
+ * Finally, solve for dx and dy:
+ *
+ * dx = (F T1 - Q1) / U1
+ * dx = (F P1 - V1) / W1
+ *
+ * dy = (F T0 - Q0) / U0
+ * dy = (F P0 - V0) / W0
+ */
+ double r[3];
+ double q[2], u[2], t[2], v[2], w[2], p[2];
+ double f;
+ struct pict_f_vector d;
+ int i;
+
+ /* Get the un-normalized crtc coordinates again */
+ for (i = 0; i < 3; i++)
+ r[i] = m->m[i][0] * screen_x + m->m[i][1] * screen_y + m->m[i][2];
+
+ /* Combine values into temporaries */
+ for (i = 0; i < 2; i++) {
+ q[i] = m->m[1][i] * r[0] - m->m[0][i] * r[1];
+ u[i] = m->m[1][i] * m->m[0][1-i] - m->m[0][i] * m->m[1][1-i];
+ t[i] = m->m[1][i] * crtc_x - m->m[0][i] * crtc_y;
+
+ v[i] = m->m[1][i] * r[2] - m->m[2][i] * r[1];
+ w[i] = m->m[1][i] * m->m[2][1-i] - m->m[2][i] * m->m[1][1-i];
+ p[i] = m->m[1][i] - m->m[2][i] * crtc_y;
+ }
+
+ /* Find a way to compute f */
+ f = 0;
+ for (i = 0; i < 2; i++) {
+ double a = w[i] * q[i] - u[i] * v[i];
+ double b = w[i] * t[i] - u[i] * p[i];
+ if (b != 0) {
+ f = a/b;
+ break;
+ }
+ }
+
+ /* Solve for the resulting transform vector */
+ for (i = 0; i < 2; i++) {
+ if (u[i])
+ d.v[1-i] = (t[i] * f - q[i]) / u[i];
+ else if (w[1])
+ d.v[1-i] = (p[i] * f - v[i]) / w[i];
+ else
+ d.v[1-i] = 0;
+ }
+ *new_pan_x = old_pan_x - floor (d.v[0] + 0.5);
+ *new_pan_y = old_pan_y - floor (d.v[1] + 0.5);
+ } else {
+ *new_pan_x = screen_x - crtc_x;
+ *new_pan_y = screen_y - crtc_y;
+ }
+}
+
+static void
+xf86RandR13Pan (xf86CrtcPtr crtc, int x, int y)
+{
+ int newX, newY;
+ int width, height;
+ Bool panned = FALSE;
+
+ if (crtc->version < 2)
+ return;
+
+ if (! crtc->enabled ||
+ (crtc->panningTotalArea.x2 <= crtc->panningTotalArea.x1 &&
+ crtc->panningTotalArea.y2 <= crtc->panningTotalArea.y1))
+ return;
+
+ newX = crtc->x;
+ newY = crtc->y;
+ width = crtc->mode.HDisplay;
+ height = crtc->mode.VDisplay;
+
+ if ((crtc->panningTrackingArea.x2 <= crtc->panningTrackingArea.x1 ||
+ (x >= crtc->panningTrackingArea.x1 && x < crtc->panningTrackingArea.x2)) &&
+ (crtc->panningTrackingArea.y2 <= crtc->panningTrackingArea.y1 ||
+ (y >= crtc->panningTrackingArea.y1 && y < crtc->panningTrackingArea.y2)))
+ {
+ struct pict_f_vector c;
+
+ /*
+ * Pre-clip the mouse position to the panning area so that we don't
+ * push the crtc outside. This doesn't deal with changes to the
+ * panning values, only mouse position changes.
+ */
+ if (crtc->panningTotalArea.x2 > crtc->panningTotalArea.x1)
+ {
+ if (x < crtc->panningTotalArea.x1)
+ x = crtc->panningTotalArea.x1;
+ if (x >= crtc->panningTotalArea.x2)
+ x = crtc->panningTotalArea.x2 - 1;
+ }
+ if (crtc->panningTotalArea.y2 > crtc->panningTotalArea.y1)
+ {
+ if (y < crtc->panningTotalArea.y1)
+ y = crtc->panningTotalArea.y1;
+ if (y >= crtc->panningTotalArea.y2)
+ y = crtc->panningTotalArea.y2 - 1;
+ }
+
+ c.v[0] = x;
+ c.v[1] = y;
+ c.v[2] = 1.0;
+ if (crtc->transform_in_use) {
+ pixman_f_transform_point(&crtc->f_framebuffer_to_crtc, &c);
+ } else {
+ c.v[0] -= crtc->x;
+ c.v[1] -= crtc->y;
+ }
+
+ if (crtc->panningTotalArea.x2 > crtc->panningTotalArea.x1) {
+ if (c.v[0] < crtc->panningBorder[0]) {
+ c.v[0] = crtc->panningBorder[0];
+ panned = TRUE;
+ }
+ if (c.v[0] >= width - crtc->panningBorder[2]) {
+ c.v[0] = width - crtc->panningBorder[2] - 1;
+ panned = TRUE;
+ }
+ }
+ if (crtc->panningTotalArea.y2 > crtc->panningTotalArea.y1) {
+ if (c.v[1] < crtc->panningBorder[1]) {
+ c.v[1] = crtc->panningBorder[1];
+ panned = TRUE;
+ }
+ if (c.v[1] >= height - crtc->panningBorder[3]) {
+ c.v[1] = height - crtc->panningBorder[3] - 1;
+ panned = TRUE;
+ }
+ }
+ if (panned)
+ xf86ComputeCrtcPan (crtc->transform_in_use,
+ &crtc->f_framebuffer_to_crtc,
+ x, y, c.v[0], c.v[1],
+ newX, newY, &newX, &newY);
+ }
+
+ /*
+ * Ensure that the crtc is within the panning region.
+ *
+ * XXX This computation only works when we do not have a transform
+ * in use.
+ */
+ if (!crtc->transform_in_use)
+ {
+ /* Validate against [xy]1 after [xy]2, to be sure that results are > 0 for [xy]1 > 0 */
+ if (crtc->panningTotalArea.x2 > crtc->panningTotalArea.x1) {
+ if (newX > crtc->panningTotalArea.x2 - width)
+ newX = crtc->panningTotalArea.x2 - width;
+ if (newX < crtc->panningTotalArea.x1)
+ newX = crtc->panningTotalArea.x1;
+ }
+ if (crtc->panningTotalArea.y2 > crtc->panningTotalArea.y1) {
+ if (newY > crtc->panningTotalArea.y2 - height)
+ newY = crtc->panningTotalArea.y2 - height;
+ if (newY < crtc->panningTotalArea.y1)
+ newY = crtc->panningTotalArea.y1;
+ }
+ }
+ if (newX != crtc->x || newY != crtc->y)
+ xf86CrtcSetOrigin (crtc, newX, newY);
+}
+
+static Bool
+xf86RandR12GetInfo (ScreenPtr pScreen, Rotation *rotations)
+{
+ RRScreenSizePtr pSize;
+ ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
+ XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
+ DisplayModePtr mode;
+ int refresh0 = 60;
+ int maxX = 0, maxY = 0;
+
+ *rotations = randrp->supported_rotations;
+
+ if (randrp->virtualX == -1 || randrp->virtualY == -1)
+ {
+ randrp->virtualX = scrp->virtualX;
+ randrp->virtualY = scrp->virtualY;
+ }
+
+ /* Re-probe the outputs for new monitors or modes */
+ if (scrp->vtSema)
+ {
+ xf86ProbeOutputModes (scrp, 0, 0);
+ xf86SetScrnInfoModes (scrp);
+ }
+
+ for (mode = scrp->modes; ; mode = mode->next)
+ {
+ int refresh = xf86RandR12ModeRefresh (mode);
+ if (randrp->maxX == 0 || randrp->maxY == 0)
+ {
+ if (maxX < mode->HDisplay)
+ maxX = mode->HDisplay;
+ if (maxY < mode->VDisplay)
+ maxY = mode->VDisplay;
+ }
+ if (mode == scrp->modes)
+ refresh0 = refresh;
+ pSize = RRRegisterSize (pScreen,
+ mode->HDisplay, mode->VDisplay,
+ randrp->mmWidth, randrp->mmHeight);
+ if (!pSize)
+ return FALSE;
+ RRRegisterRate (pScreen, pSize, refresh);
+
+ if (xf86ModesEqual(mode, scrp->currentMode))
+ {
+ RRSetCurrentConfig (pScreen, randrp->rotation, refresh, pSize);
+ }
+ if (mode->next == scrp->modes)
+ break;
+ }
+
+ if (randrp->maxX == 0 || randrp->maxY == 0)
+ {
+ randrp->maxX = maxX;
+ randrp->maxY = maxY;
+ }
+
+ return TRUE;
+}
+
+static Bool
+xf86RandR12SetMode (ScreenPtr pScreen,
+ DisplayModePtr mode,
+ Bool useVirtual,
+ int mmWidth,
+ int mmHeight)
+{
+ ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
+ XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
+ int oldWidth = pScreen->width;
+ int oldHeight = pScreen->height;
+ int oldmmWidth = pScreen->mmWidth;
+ int oldmmHeight = pScreen->mmHeight;
+ WindowPtr pRoot = pScreen->root;
+ DisplayModePtr currentMode = NULL;
+ Bool ret = TRUE;
+
+ if (pRoot)
+ (*scrp->EnableDisableFBAccess) (pScreen->myNum, FALSE);
+ if (useVirtual)
+ {
+ scrp->virtualX = randrp->virtualX;
+ scrp->virtualY = randrp->virtualY;
+ }
+ else
+ {
+ scrp->virtualX = mode->HDisplay;
+ scrp->virtualY = mode->VDisplay;
+ }
+
+ if(randrp->rotation & (RR_Rotate_90 | RR_Rotate_270))
+ {
+ /* If the screen is rotated 90 or 270 degrees, swap the sizes. */
+ pScreen->width = scrp->virtualY;
+ pScreen->height = scrp->virtualX;
+ pScreen->mmWidth = mmHeight;
+ pScreen->mmHeight = mmWidth;
+ }
+ else
+ {
+ pScreen->width = scrp->virtualX;
+ pScreen->height = scrp->virtualY;
+ pScreen->mmWidth = mmWidth;
+ pScreen->mmHeight = mmHeight;
+ }
+ if (scrp->currentMode == mode) {
+ /* Save current mode */
+ currentMode = scrp->currentMode;
+ /* Reset, just so we ensure the drivers SwitchMode is called */
+ scrp->currentMode = NULL;
+ }
+ /*
+ * We know that if the driver failed to SwitchMode to the rotated
+ * version, then it should revert back to it's prior mode.
+ */
+ if (!xf86SwitchMode (pScreen, mode))
+ {
+ ret = FALSE;
+ scrp->virtualX = pScreen->width = oldWidth;
+ scrp->virtualY = pScreen->height = oldHeight;
+ pScreen->mmWidth = oldmmWidth;
+ pScreen->mmHeight = oldmmHeight;
+ scrp->currentMode = currentMode;
+ }
+
+ /*
+ * Make sure the layout is correct
+ */
+ xf86ReconfigureLayout();
+
+ /*
+ * Make sure the whole screen is visible
+ */
+ xf86SetViewport (pScreen, pScreen->width, pScreen->height);
+ xf86SetViewport (pScreen, 0, 0);
+ if (pRoot)
+ (*scrp->EnableDisableFBAccess) (pScreen->myNum, TRUE);
+ return ret;
+}
+
+Bool
+xf86RandR12SetConfig (ScreenPtr pScreen,
+ Rotation rotation,
+ int rate,
+ RRScreenSizePtr pSize)
+{
+ ScrnInfoPtr scrp = XF86SCRNINFO(pScreen);
+ XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
+ DisplayModePtr mode;
+ int pos[MAXDEVICES][2];
+ Bool useVirtual = FALSE;
+ int maxX = 0, maxY = 0;
+ Rotation oldRotation = randrp->rotation;
+ DeviceIntPtr dev;
+ Bool view_adjusted = FALSE;
+
+ randrp->rotation = rotation;
+
+ if (randrp->virtualX == -1 || randrp->virtualY == -1)
+ {
+ randrp->virtualX = scrp->virtualX;
+ randrp->virtualY = scrp->virtualY;
+ }
+
+ for (dev = inputInfo.devices; dev; dev = dev->next)
+ {
+ if (!IsMaster(dev) && !IsFloating(dev))
+ continue;
+
+ miPointerGetPosition(dev, &pos[dev->id][0], &pos[dev->id][1]);
+ }
+
+ for (mode = scrp->modes; ; mode = mode->next)
+ {
+ if (randrp->maxX == 0 || randrp->maxY == 0)
+ {
+ if (maxX < mode->HDisplay)
+ maxX = mode->HDisplay;
+ if (maxY < mode->VDisplay)
+ maxY = mode->VDisplay;
+ }
+ if (mode->HDisplay == pSize->width &&
+ mode->VDisplay == pSize->height &&
+ (rate == 0 || xf86RandR12ModeRefresh (mode) == rate))
+ break;
+ if (mode->next == scrp->modes)
+ {
+ if (pSize->width == randrp->virtualX &&
+ pSize->height == randrp->virtualY)
+ {
+ mode = scrp->modes;
+ useVirtual = TRUE;
+ break;
+ }
+ if (randrp->maxX == 0 || randrp->maxY == 0)
+ {
+ randrp->maxX = maxX;
+ randrp->maxY = maxY;
+ }
+ return FALSE;
+ }
+ }
+
+ if (randrp->maxX == 0 || randrp->maxY == 0)
+ {
+ randrp->maxX = maxX;
+ randrp->maxY = maxY;
+ }
+
+ if (!xf86RandR12SetMode (pScreen, mode, useVirtual, pSize->mmWidth,
+ pSize->mmHeight)) {
+ randrp->rotation = oldRotation;
+ return FALSE;
+ }
+
+ /*
+ * Move the cursor back where it belongs; SwitchMode repositions it
+ * FIXME: duplicated code, see modes/xf86RandR12.c
+ */
+ for (dev = inputInfo.devices; dev; dev = dev->next)
+ {
+ if (!IsMaster(dev) && !IsFloating(dev))
+ continue;
+
+ if (pScreen == miPointerGetScreen(dev)) {
+ int px = pos[dev->id][0];
+ int py = pos[dev->id][1];
+
+ px = (px >= pScreen->width ? (pScreen->width - 1) : px);
+ py = (py >= pScreen->height ? (pScreen->height - 1) : py);
+
+ /* Setting the viewpoint makes only sense on one device */
+ if (!view_adjusted && IsMaster(dev)) {
+ xf86SetViewport(pScreen, px, py);
+ view_adjusted = TRUE;
+ }
+
+ (*pScreen->SetCursorPosition) (dev, pScreen, px, py, FALSE);
+ }
+ }
+
+ return TRUE;
+}
+
+static Bool
+xf86RandR12ScreenSetSize (ScreenPtr pScreen,
+ CARD16 width,
+ CARD16 height,
+ CARD32 mmWidth,
+ CARD32 mmHeight)
+{
+ XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
+ ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen);
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+ WindowPtr pRoot = pScreen->root;
+ PixmapPtr pScrnPix;
+ Bool ret = FALSE;
+ int c;
+
+ if (xf86RandR12Key) {
+ if (randrp->virtualX == -1 || randrp->virtualY == -1)
+ {
+ randrp->virtualX = pScrn->virtualX;
+ randrp->virtualY = pScrn->virtualY;
+ }
+ }
+ if (pRoot && pScrn->vtSema)
+ (*pScrn->EnableDisableFBAccess) (pScreen->myNum, FALSE);
+
+ /* Let the driver update virtualX and virtualY */
+ if (!(*config->funcs->resize)(pScrn, width, height))
+ goto finish;
+
+ ret = TRUE;
+ /* Update panning information */
+ for (c = 0; c < config->num_crtc; c++) {
+ xf86CrtcPtr crtc = config->crtc[c];
+ if (crtc->panningTotalArea.x2 > crtc->panningTotalArea.x1 ||
+ crtc->panningTotalArea.y2 > crtc->panningTotalArea.y1) {
+ if (crtc->panningTotalArea.x2 > crtc->panningTrackingArea.x1)
+ crtc->panningTotalArea.x2 += width - pScreen->width;
+ if (crtc->panningTotalArea.y2 > crtc->panningTrackingArea.y1)
+ crtc->panningTotalArea.y2 += height - pScreen->height;
+ if (crtc->panningTrackingArea.x2 > crtc->panningTrackingArea.x1)
+ crtc->panningTrackingArea.x2 += width - pScreen->width;
+ if (crtc->panningTrackingArea.y2 > crtc->panningTrackingArea.y1)
+ crtc->panningTrackingArea.y2 += height - pScreen->height;
+ xf86RandR13VerifyPanningArea (crtc, width, height);
+ xf86RandR13Pan (crtc, randrp->pointerX, randrp->pointerY);
+ }
+ }
+
+ pScrnPix = (*pScreen->GetScreenPixmap)(pScreen);
+ pScreen->width = pScrnPix->drawable.width = width;
+ pScreen->height = pScrnPix->drawable.height = height;
+ randrp->mmWidth = pScreen->mmWidth = mmWidth;
+ randrp->mmHeight = pScreen->mmHeight = mmHeight;
+
+ xf86SetViewport (pScreen, pScreen->width-1, pScreen->height-1);
+ xf86SetViewport (pScreen, 0, 0);
+
+finish:
+ if (pRoot && pScrn->vtSema)
+ (*pScrn->EnableDisableFBAccess) (pScreen->myNum, TRUE);
+#if RANDR_12_INTERFACE
+ if (xf86RandR12Key && pScreen->root && ret)
+ RRScreenSizeNotify (pScreen);
+#endif
+ return ret;
+}
+
+Rotation
+xf86RandR12GetRotation(ScreenPtr pScreen)
+{
+ XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
+
+ return randrp->rotation;
+}
+
+Bool
+xf86RandR12CreateScreenResources (ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ xf86CrtcConfigPtr config;
+ XF86RandRInfoPtr randrp;
+ int c;
+ int width, height;
+ int mmWidth, mmHeight;
+#ifdef PANORAMIX
+ /* XXX disable RandR when using Xinerama */
+ if (!noPanoramiXExtension)
+ return TRUE;
+#endif
+
+ config = XF86_CRTC_CONFIG_PTR(pScrn);
+ randrp = XF86RANDRINFO(pScreen);
+ /*
+ * Compute size of screen
+ */
+ width = 0; height = 0;
+ for (c = 0; c < config->num_crtc; c++)
+ {
+ xf86CrtcPtr crtc = config->crtc[c];
+ int crtc_width = crtc->x + xf86ModeWidth (&crtc->mode, crtc->rotation);
+ int crtc_height = crtc->y + xf86ModeHeight (&crtc->mode, crtc->rotation);
+
+ if (crtc->enabled) {
+ if (crtc_width > width)
+ width = crtc_width;
+ if (crtc_height > height)
+ height = crtc_height;
+ if (crtc->panningTotalArea.x2 > width)
+ width = crtc->panningTotalArea.x2;
+ if (crtc->panningTotalArea.y2 > height)
+ height = crtc->panningTotalArea.y2;
+ }
+ }
+
+ if (width && height)
+ {
+ /*
+ * Compute physical size of screen
+ */
+ if (monitorResolution)
+ {
+ mmWidth = width * 25.4 / monitorResolution;
+ mmHeight = height * 25.4 / monitorResolution;
+ }
+ else
+ {
+ xf86OutputPtr output = xf86CompatOutput(pScrn);
+
+ if (output &&
+ output->conf_monitor &&
+ (output->conf_monitor->mon_width > 0 &&
+ output->conf_monitor->mon_height > 0))
+ {
+ /*
+ * Prefer user configured DisplaySize
+ */
+ mmWidth = output->conf_monitor->mon_width;
+ mmHeight = output->conf_monitor->mon_height;
+ }
+ else
+ {
+ /*
+ * Otherwise, just set the screen to DEFAULT_DPI
+ */
+ mmWidth = width * 25.4 / DEFAULT_DPI;
+ mmHeight = height * 25.4 / DEFAULT_DPI;
+ }
+ }
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Setting screen physical size to %d x %d\n",
+ mmWidth, mmHeight);
+ /*
+ * This is the initial setting of the screen size.
+ * We have to pre-set it here, otherwise panning would be adapted
+ * to the new screen size.
+ */
+ pScreen->width = width;
+ pScreen->height = height;
+ xf86RandR12ScreenSetSize (pScreen,
+ width,
+ height,
+ mmWidth,
+ mmHeight);
+ }
+
+ if (xf86RandR12Key == NULL)
+ return TRUE;
+
+ if (randrp->virtualX == -1 || randrp->virtualY == -1)
+ {
+ randrp->virtualX = pScrn->virtualX;
+ randrp->virtualY = pScrn->virtualY;
+ }
+ xf86CrtcSetScreenSubpixelOrder (pScreen);
+#if RANDR_12_INTERFACE
+ if (xf86RandR12CreateScreenResources12 (pScreen))
+ return TRUE;
+#endif
+ return TRUE;
+}
+
+
+Bool
+xf86RandR12Init (ScreenPtr pScreen)
+{
+ rrScrPrivPtr rp;
+ XF86RandRInfoPtr randrp;
+
+#ifdef PANORAMIX
+ /* XXX disable RandR when using Xinerama */
+ if (!noPanoramiXExtension)
+ {
+ if (xf86NumScreens == 1)
+ noPanoramiXExtension = TRUE;
+ else
+ return TRUE;
+ }
+#endif
+
+ if (xf86RandR12Generation != serverGeneration)
+ xf86RandR12Generation = serverGeneration;
+
+ xf86RandR12Key = &xf86RandR12KeyRec;
+ if (!dixRegisterPrivateKey(&xf86RandR12KeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
+ randrp = malloc(sizeof (XF86RandRInfoRec));
+ if (!randrp)
+ return FALSE;
+
+ if (!RRScreenInit(pScreen))
+ {
+ free(randrp);
+ return FALSE;
+ }
+ rp = rrGetScrPriv(pScreen);
+ rp->rrGetInfo = xf86RandR12GetInfo;
+ rp->rrSetConfig = xf86RandR12SetConfig;
+
+ randrp->virtualX = -1;
+ randrp->virtualY = -1;
+ randrp->mmWidth = pScreen->mmWidth;
+ randrp->mmHeight = pScreen->mmHeight;
+
+ randrp->rotation = RR_Rotate_0; /* initial rotated mode */
+
+ randrp->supported_rotations = RR_Rotate_0;
+
+ randrp->maxX = randrp->maxY = 0;
+
+ dixSetPrivate(&pScreen->devPrivates, xf86RandR12Key, randrp);
+
+#if RANDR_12_INTERFACE
+ if (!xf86RandR12Init12 (pScreen))
+ return FALSE;
+#endif
+ return TRUE;
+}
+
+void
+xf86RandR12CloseScreen (ScreenPtr pScreen)
+{
+ XF86RandRInfoPtr randrp;
+
+ if (xf86RandR12Key == NULL)
+ return;
+
+ randrp = XF86RANDRINFO(pScreen);
+#if RANDR_12_INTERFACE
+ xf86Screens[pScreen->myNum]->EnterVT = randrp->orig_EnterVT;
+#endif
+
+ free(randrp);
+}
+
+void
+xf86RandR12SetRotations (ScreenPtr pScreen, Rotation rotations)
+{
+ XF86RandRInfoPtr randrp;
+#if RANDR_12_INTERFACE
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ int c;
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+#endif
+
+ if (xf86RandR12Key == NULL)
+ return;
+
+ randrp = XF86RANDRINFO(pScreen);
+#if RANDR_12_INTERFACE
+ for (c = 0; c < config->num_crtc; c++) {
+ xf86CrtcPtr crtc = config->crtc[c];
+
+ RRCrtcSetRotations (crtc->randr_crtc, rotations);
+ }
+#endif
+ randrp->supported_rotations = rotations;
+}
+
+void
+xf86RandR12SetTransformSupport (ScreenPtr pScreen, Bool transforms)
+{
+ XF86RandRInfoPtr randrp;
+#if RANDR_13_INTERFACE
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ int c;
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+#endif
+
+ if (xf86RandR12Key == NULL)
+ return;
+
+ randrp = XF86RANDRINFO(pScreen);
+#if RANDR_13_INTERFACE
+ for (c = 0; c < config->num_crtc; c++) {
+ xf86CrtcPtr crtc = config->crtc[c];
+
+ RRCrtcSetTransformSupport (crtc->randr_crtc, transforms);
+ }
+#endif
+}
+
+void
+xf86RandR12GetOriginalVirtualSize(ScrnInfoPtr pScrn, int *x, int *y)
+{
+ ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex];
+
+ if (xf86RandR12Generation != serverGeneration ||
+ XF86RANDRINFO(pScreen)->virtualX == -1)
+ {
+ *x = pScrn->virtualX;
+ *y = pScrn->virtualY;
+ } else {
+ XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
+
+ *x = randrp->virtualX;
+ *y = randrp->virtualY;
+ }
+}
+
+#if RANDR_12_INTERFACE
+
+#define FLAG_BITS (RR_HSyncPositive | \
+ RR_HSyncNegative | \
+ RR_VSyncPositive | \
+ RR_VSyncNegative | \
+ RR_Interlace | \
+ RR_DoubleScan | \
+ RR_CSync | \
+ RR_CSyncPositive | \
+ RR_CSyncNegative | \
+ RR_HSkewPresent | \
+ RR_BCast | \
+ RR_PixelMultiplex | \
+ RR_DoubleClock | \
+ RR_ClockDivideBy2)
+
+static Bool
+xf86RandRModeMatches (RRModePtr randr_mode,
+ DisplayModePtr mode)
+{
+#if 0
+ if (match_name)
+ {
+ /* check for same name */
+ int len = strlen (mode->name);
+ if (randr_mode->mode.nameLength != len) return FALSE;
+ if (memcmp (randr_mode->name, mode->name, len) != 0) return FALSE;
+ }
+#endif
+
+ /* check for same timings */
+ if (randr_mode->mode.dotClock / 1000 != mode->Clock) return FALSE;
+ if (randr_mode->mode.width != mode->HDisplay) return FALSE;
+ if (randr_mode->mode.hSyncStart != mode->HSyncStart) return FALSE;
+ if (randr_mode->mode.hSyncEnd != mode->HSyncEnd) return FALSE;
+ if (randr_mode->mode.hTotal != mode->HTotal) return FALSE;
+ if (randr_mode->mode.hSkew != mode->HSkew) return FALSE;
+ if (randr_mode->mode.height != mode->VDisplay) return FALSE;
+ if (randr_mode->mode.vSyncStart != mode->VSyncStart) return FALSE;
+ if (randr_mode->mode.vSyncEnd != mode->VSyncEnd) return FALSE;
+ if (randr_mode->mode.vTotal != mode->VTotal) return FALSE;
+
+ /* check for same flags (using only the XF86 valid flag bits) */
+ if ((randr_mode->mode.modeFlags & FLAG_BITS) != (mode->Flags & FLAG_BITS))
+ return FALSE;
+
+ /* everything matches */
+ return TRUE;
+}
+
+static Bool
+xf86RandR12CrtcNotify (RRCrtcPtr randr_crtc)
+{
+ ScreenPtr pScreen = randr_crtc->pScreen;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+ RRModePtr randr_mode = NULL;
+ int x;
+ int y;
+ Rotation rotation;
+ int numOutputs;
+ RROutputPtr *randr_outputs;
+ RROutputPtr randr_output;
+ xf86CrtcPtr crtc = randr_crtc->devPrivate;
+ xf86OutputPtr output;
+ int i, j;
+ DisplayModePtr mode = &crtc->mode;
+ Bool ret;
+
+ randr_outputs = malloc(config->num_output * sizeof (RROutputPtr));
+ if (!randr_outputs)
+ return FALSE;
+ x = crtc->x;
+ y = crtc->y;
+ rotation = crtc->rotation;
+ numOutputs = 0;
+ randr_mode = NULL;
+ for (i = 0; i < config->num_output; i++)
+ {
+ output = config->output[i];
+ if (output->crtc == crtc)
+ {
+ randr_output = output->randr_output;
+ randr_outputs[numOutputs++] = randr_output;
+ /*
+ * We make copies of modes, so pointer equality
+ * isn't sufficient
+ */
+ for (j = 0; j < randr_output->numModes + randr_output->numUserModes; j++)
+ {
+ RRModePtr m = (j < randr_output->numModes ?
+ randr_output->modes[j] :
+ randr_output->userModes[j-randr_output->numModes]);
+
+ if (xf86RandRModeMatches (m, mode))
+ {
+ randr_mode = m;
+ break;
+ }
+ }
+ }
+ }
+ ret = RRCrtcNotify (randr_crtc, randr_mode, x, y,
+ rotation,
+ crtc->transformPresent ? &crtc->transform : NULL,
+ numOutputs, randr_outputs);
+ free(randr_outputs);
+ return ret;
+}
+
+/*
+ * Convert a RandR mode to a DisplayMode
+ */
+static void
+xf86RandRModeConvert (ScrnInfoPtr scrn,
+ RRModePtr randr_mode,
+ DisplayModePtr mode)
+{
+ memset(mode, 0, sizeof(DisplayModeRec));
+ mode->status = MODE_OK;
+
+ mode->Clock = randr_mode->mode.dotClock / 1000;
+
+ mode->HDisplay = randr_mode->mode.width;
+ mode->HSyncStart = randr_mode->mode.hSyncStart;
+ mode->HSyncEnd = randr_mode->mode.hSyncEnd;
+ mode->HTotal = randr_mode->mode.hTotal;
+ mode->HSkew = randr_mode->mode.hSkew;
+
+ mode->VDisplay = randr_mode->mode.height;
+ mode->VSyncStart = randr_mode->mode.vSyncStart;
+ mode->VSyncEnd = randr_mode->mode.vSyncEnd;
+ mode->VTotal = randr_mode->mode.vTotal;
+ mode->VScan = 0;
+
+ mode->Flags = randr_mode->mode.modeFlags & FLAG_BITS;
+
+ xf86SetModeCrtc (mode, scrn->adjustFlags);
+}
+
+static Bool
+xf86RandR12CrtcSet (ScreenPtr pScreen,
+ RRCrtcPtr randr_crtc,
+ RRModePtr randr_mode,
+ int x,
+ int y,
+ Rotation rotation,
+ int num_randr_outputs,
+ RROutputPtr *randr_outputs)
+{
+ XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+ xf86CrtcPtr crtc = randr_crtc->devPrivate;
+ RRTransformPtr transform;
+ Bool changed = FALSE;
+ int o, ro;
+ xf86CrtcPtr *save_crtcs;
+ Bool save_enabled = crtc->enabled;
+
+ if (!crtc->scrn->vtSema)
+ return FALSE;
+
+ save_crtcs = malloc(config->num_output * sizeof (xf86CrtcPtr));
+ if ((randr_mode != NULL) != crtc->enabled)
+ changed = TRUE;
+ else if (randr_mode && !xf86RandRModeMatches (randr_mode, &crtc->mode))
+ changed = TRUE;
+
+ if (rotation != crtc->rotation)
+ changed = TRUE;
+
+ transform = RRCrtcGetTransform (randr_crtc);
+ if ((transform != NULL) != crtc->transformPresent)
+ changed = TRUE;
+ else if (transform && memcmp (&transform->transform, &crtc->transform.transform,
+ sizeof (transform->transform)) != 0)
+ changed = TRUE;
+
+ if (x != crtc->x || y != crtc->y)
+ changed = TRUE;
+ for (o = 0; o < config->num_output; o++)
+ {
+ xf86OutputPtr output = config->output[o];
+ xf86CrtcPtr new_crtc;
+
+ save_crtcs[o] = output->crtc;
+
+ if (output->crtc == crtc)
+ new_crtc = NULL;
+ else
+ new_crtc = output->crtc;
+ for (ro = 0; ro < num_randr_outputs; ro++)
+ if (output->randr_output == randr_outputs[ro])
+ {
+ new_crtc = crtc;
+ break;
+ }
+ if (new_crtc != output->crtc)
+ {
+ changed = TRUE;
+ output->crtc = new_crtc;
+ }
+ }
+ for (ro = 0; ro < num_randr_outputs; ro++)
+ if (randr_outputs[ro]->pendingProperties)
+ changed = TRUE;
+
+ /* XXX need device-independent mode setting code through an API */
+ if (changed)
+ {
+ crtc->enabled = randr_mode != NULL;
+
+ if (randr_mode)
+ {
+ DisplayModeRec mode;
+ RRTransformPtr transform = RRCrtcGetTransform (randr_crtc);
+
+ xf86RandRModeConvert (pScrn, randr_mode, &mode);
+ if (!xf86CrtcSetModeTransform (crtc, &mode, rotation, transform, x, y))
+ {
+ crtc->enabled = save_enabled;
+ for (o = 0; o < config->num_output; o++)
+ {
+ xf86OutputPtr output = config->output[o];
+ output->crtc = save_crtcs[o];
+ }
+ free(save_crtcs);
+ return FALSE;
+ }
+ xf86RandR13VerifyPanningArea (crtc, pScreen->width, pScreen->height);
+ xf86RandR13Pan (crtc, randrp->pointerX, randrp->pointerY);
+ /*
+ * Save the last successful setting for EnterVT
+ */
+ crtc->desiredMode = mode;
+ crtc->desiredRotation = rotation;
+ if (transform) {
+ crtc->desiredTransform = *transform;
+ crtc->desiredTransformPresent = TRUE;
+ } else
+ crtc->desiredTransformPresent = FALSE;
+
+ crtc->desiredX = x;
+ crtc->desiredY = y;
+ }
+ xf86DisableUnusedFunctions (pScrn);
+ }
+ free(save_crtcs);
+ return xf86RandR12CrtcNotify (randr_crtc);
+}
+
+static Bool
+xf86RandR12CrtcSetGamma (ScreenPtr pScreen,
+ RRCrtcPtr randr_crtc)
+{
+ xf86CrtcPtr crtc = randr_crtc->devPrivate;
+
+ if (crtc->funcs->gamma_set == NULL)
+ return FALSE;
+
+ if (!crtc->scrn->vtSema)
+ return TRUE;
+
+ /* Realloc local gamma if needed. */
+ if (randr_crtc->gammaSize != crtc->gamma_size) {
+ CARD16 *tmp_ptr;
+ tmp_ptr = realloc(crtc->gamma_red, 3 * crtc->gamma_size * sizeof (CARD16));
+ if (!tmp_ptr)
+ return FALSE;
+ crtc->gamma_red = tmp_ptr;
+ crtc->gamma_green = crtc->gamma_red + crtc->gamma_size;
+ crtc->gamma_blue = crtc->gamma_green + crtc->gamma_size;
+ }
+
+ crtc->gamma_size = randr_crtc->gammaSize;
+ memcpy (crtc->gamma_red, randr_crtc->gammaRed, crtc->gamma_size * sizeof (CARD16));
+ memcpy (crtc->gamma_green, randr_crtc->gammaGreen, crtc->gamma_size * sizeof (CARD16));
+ memcpy (crtc->gamma_blue, randr_crtc->gammaBlue, crtc->gamma_size * sizeof (CARD16));
+
+ /* Only set it when the crtc is actually running.
+ * Otherwise it will be set when it's activated.
+ */
+ if (crtc->active)
+ crtc->funcs->gamma_set(crtc, crtc->gamma_red, crtc->gamma_green,
+ crtc->gamma_blue, crtc->gamma_size);
+
+ return TRUE;
+}
+
+static Bool
+xf86RandR12CrtcGetGamma (ScreenPtr pScreen,
+ RRCrtcPtr randr_crtc)
+{
+ xf86CrtcPtr crtc = randr_crtc->devPrivate;
+
+ if (!crtc->gamma_size)
+ return FALSE;
+
+ if (!crtc->gamma_red || !crtc->gamma_green || !crtc->gamma_blue)
+ return FALSE;
+
+ /* Realloc randr gamma if needed. */
+ if (randr_crtc->gammaSize != crtc->gamma_size) {
+ CARD16 *tmp_ptr;
+ tmp_ptr = realloc(randr_crtc->gammaRed, 3 * crtc->gamma_size * sizeof (CARD16));
+ if (!tmp_ptr)
+ return FALSE;
+ randr_crtc->gammaRed = tmp_ptr;
+ randr_crtc->gammaGreen = randr_crtc->gammaRed + crtc->gamma_size;
+ randr_crtc->gammaBlue = randr_crtc->gammaGreen + crtc->gamma_size;
+ }
+ randr_crtc->gammaSize = crtc->gamma_size;
+ memcpy (randr_crtc->gammaRed, crtc->gamma_red, crtc->gamma_size * sizeof (CARD16));
+ memcpy (randr_crtc->gammaGreen, crtc->gamma_green, crtc->gamma_size * sizeof (CARD16));
+ memcpy (randr_crtc->gammaBlue, crtc->gamma_blue, crtc->gamma_size * sizeof (CARD16));
+
+ return TRUE;
+}
+
+static Bool
+xf86RandR12OutputSetProperty (ScreenPtr pScreen,
+ RROutputPtr randr_output,
+ Atom property,
+ RRPropertyValuePtr value)
+{
+ xf86OutputPtr output = randr_output->devPrivate;
+
+ /* If we don't have any property handler, then we don't care what the
+ * user is setting properties to.
+ */
+ if (output->funcs->set_property == NULL)
+ return TRUE;
+
+ /*
+ * This function gets called even when vtSema is FALSE, as
+ * drivers will need to remember the correct value to apply
+ * when the VT switch occurs
+ */
+ return output->funcs->set_property(output, property, value);
+}
+
+static Bool
+xf86RandR13OutputGetProperty (ScreenPtr pScreen,
+ RROutputPtr randr_output,
+ Atom property)
+{
+ xf86OutputPtr output = randr_output->devPrivate;
+
+ if (output->funcs->get_property == NULL)
+ return TRUE;
+
+ /* Should be safe even w/o vtSema */
+ return output->funcs->get_property(output, property);
+}
+
+static Bool
+xf86RandR12OutputValidateMode (ScreenPtr pScreen,
+ RROutputPtr randr_output,
+ RRModePtr randr_mode)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ xf86OutputPtr output = randr_output->devPrivate;
+ DisplayModeRec mode;
+
+ xf86RandRModeConvert (pScrn, randr_mode, &mode);
+ /*
+ * This function may be called when vtSema is FALSE, so
+ * the underlying function must either avoid touching the hardware
+ * or return FALSE when vtSema is FALSE
+ */
+ if (output->funcs->mode_valid (output, &mode) != MODE_OK)
+ return FALSE;
+ return TRUE;
+}
+
+static void
+xf86RandR12ModeDestroy (ScreenPtr pScreen, RRModePtr randr_mode)
+{
+}
+
+/**
+ * Given a list of xf86 modes and a RandR Output object, construct
+ * RandR modes and assign them to the output
+ */
+static Bool
+xf86RROutputSetModes (RROutputPtr randr_output, DisplayModePtr modes)
+{
+ DisplayModePtr mode;
+ RRModePtr *rrmodes = NULL;
+ int nmode = 0;
+ int npreferred = 0;
+ Bool ret = TRUE;
+ int pref;
+
+ for (mode = modes; mode; mode = mode->next)
+ nmode++;
+
+ if (nmode) {
+ rrmodes = malloc(nmode * sizeof (RRModePtr));
+
+ if (!rrmodes)
+ return FALSE;
+ nmode = 0;
+
+ for (pref = 1; pref >= 0; pref--) {
+ for (mode = modes; mode; mode = mode->next) {
+ if ((pref != 0) == ((mode->type & M_T_PREFERRED) != 0)) {
+ xRRModeInfo modeInfo;
+ RRModePtr rrmode;
+
+ modeInfo.nameLength = strlen (mode->name);
+ modeInfo.width = mode->HDisplay;
+ modeInfo.dotClock = mode->Clock * 1000;
+ modeInfo.hSyncStart = mode->HSyncStart;
+ modeInfo.hSyncEnd = mode->HSyncEnd;
+ modeInfo.hTotal = mode->HTotal;
+ modeInfo.hSkew = mode->HSkew;
+
+ modeInfo.height = mode->VDisplay;
+ modeInfo.vSyncStart = mode->VSyncStart;
+ modeInfo.vSyncEnd = mode->VSyncEnd;
+ modeInfo.vTotal = mode->VTotal;
+ modeInfo.modeFlags = mode->Flags;
+
+ rrmode = RRModeGet (&modeInfo, mode->name);
+ if (rrmode) {
+ rrmodes[nmode++] = rrmode;
+ npreferred += pref;
+ }
+ }
+ }
+ }
+ }
+
+ ret = RROutputSetModes (randr_output, rrmodes, nmode, npreferred);
+ free(rrmodes);
+ return ret;
+}
+
+/*
+ * Mirror the current mode configuration to RandR
+ */
+static Bool
+xf86RandR12SetInfo12 (ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+ RROutputPtr *clones;
+ RRCrtcPtr *crtcs;
+ int ncrtc;
+ int o, c, l;
+ RRCrtcPtr randr_crtc;
+ int nclone;
+
+ clones = malloc(config->num_output * sizeof (RROutputPtr));
+ crtcs = malloc(config->num_crtc * sizeof (RRCrtcPtr));
+ for (o = 0; o < config->num_output; o++)
+ {
+ xf86OutputPtr output = config->output[o];
+
+ ncrtc = 0;
+ for (c = 0; c < config->num_crtc; c++)
+ if (output->possible_crtcs & (1 << c))
+ crtcs[ncrtc++] = config->crtc[c]->randr_crtc;
+
+ if (output->crtc)
+ randr_crtc = output->crtc->randr_crtc;
+ else
+ randr_crtc = NULL;
+
+ if (!RROutputSetCrtcs (output->randr_output, crtcs, ncrtc))
+ {
+ free(crtcs);
+ free(clones);
+ return FALSE;
+ }
+
+ RROutputSetPhysicalSize(output->randr_output,
+ output->mm_width,
+ output->mm_height);
+ xf86RROutputSetModes (output->randr_output, output->probed_modes);
+
+ switch (output->status) {
+ case XF86OutputStatusConnected:
+ RROutputSetConnection (output->randr_output, RR_Connected);
+ break;
+ case XF86OutputStatusDisconnected:
+ RROutputSetConnection (output->randr_output, RR_Disconnected);
+ break;
+ case XF86OutputStatusUnknown:
+ RROutputSetConnection (output->randr_output, RR_UnknownConnection);
+ break;
+ }
+
+ RROutputSetSubpixelOrder (output->randr_output, output->subpixel_order);
+
+ /*
+ * Valid clones
+ */
+ nclone = 0;
+ for (l = 0; l < config->num_output; l++)
+ {
+ xf86OutputPtr clone = config->output[l];
+
+ if (l != o && (output->possible_clones & (1 << l)))
+ clones[nclone++] = clone->randr_output;
+ }
+ if (!RROutputSetClones (output->randr_output, clones, nclone))
+ {
+ free(crtcs);
+ free(clones);
+ return FALSE;
+ }
+ }
+ free(crtcs);
+ free(clones);
+ return TRUE;
+}
+
+
+
+/*
+ * Query the hardware for the current state, then mirror
+ * that to RandR
+ */
+static Bool
+xf86RandR12GetInfo12 (ScreenPtr pScreen, Rotation *rotations)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+
+ if (!pScrn->vtSema)
+ return TRUE;
+ xf86ProbeOutputModes (pScrn, 0, 0);
+ xf86SetScrnInfoModes (pScrn);
+ return xf86RandR12SetInfo12 (pScreen);
+}
+
+static Bool
+xf86RandR12CreateObjects12 (ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+ int c;
+ int o;
+
+ if (!RRInit ())
+ return FALSE;
+
+ /*
+ * Configure crtcs
+ */
+ for (c = 0; c < config->num_crtc; c++)
+ {
+ xf86CrtcPtr crtc = config->crtc[c];
+
+ crtc->randr_crtc = RRCrtcCreate (pScreen, crtc);
+ RRCrtcGammaSetSize (crtc->randr_crtc, 256);
+ }
+ /*
+ * Configure outputs
+ */
+ for (o = 0; o < config->num_output; o++)
+ {
+ xf86OutputPtr output = config->output[o];
+
+ output->randr_output = RROutputCreate (pScreen, output->name,
+ strlen (output->name),
+ output);
+
+ if (output->funcs->create_resources != NULL)
+ output->funcs->create_resources(output);
+ RRPostPendingProperties (output->randr_output);
+ }
+ return TRUE;
+}
+
+static Bool
+xf86RandR12CreateScreenResources12 (ScreenPtr pScreen)
+{
+ int c;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+
+ if (xf86RandR12Key == NULL)
+ return TRUE;
+
+ for (c = 0; c < config->num_crtc; c++)
+ xf86RandR12CrtcNotify (config->crtc[c]->randr_crtc);
+
+ RRScreenSetSizeRange (pScreen, config->minWidth, config->minHeight,
+ config->maxWidth, config->maxHeight);
+ return TRUE;
+}
+
+/*
+ * Something happened within the screen configuration due
+ * to DGA, VidMode or hot key. Tell RandR
+ */
+
+void
+xf86RandR12TellChanged (ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+ int c;
+
+ if (xf86RandR12Key == NULL)
+ return;
+
+ xf86RandR12SetInfo12 (pScreen);
+ for (c = 0; c < config->num_crtc; c++)
+ xf86RandR12CrtcNotify (config->crtc[c]->randr_crtc);
+
+ RRTellChanged (pScreen);
+}
+
+static void
+xf86RandR12PointerMoved (int scrnIndex, int x, int y)
+{
+ ScreenPtr pScreen = screenInfo.screens[scrnIndex];
+ ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen);
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+ XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
+ int c;
+
+ randrp->pointerX = x;
+ randrp->pointerY = y;
+ for (c = 0; c < config->num_crtc; c++)
+ xf86RandR13Pan (config->crtc[c], x, y);
+}
+
+static Bool
+xf86RandR13GetPanning (ScreenPtr pScreen,
+ RRCrtcPtr randr_crtc,
+ BoxPtr totalArea,
+ BoxPtr trackingArea,
+ INT16 *border)
+{
+ xf86CrtcPtr crtc = randr_crtc->devPrivate;
+
+ if (crtc->version < 2)
+ return FALSE;
+ if (totalArea)
+ memcpy (totalArea, &crtc->panningTotalArea, sizeof(BoxRec));
+ if (trackingArea)
+ memcpy (trackingArea, &crtc->panningTrackingArea, sizeof(BoxRec));
+ if (border)
+ memcpy (border, crtc->panningBorder, 4*sizeof(INT16));
+
+ return TRUE;
+}
+
+static Bool
+xf86RandR13SetPanning (ScreenPtr pScreen,
+ RRCrtcPtr randr_crtc,
+ BoxPtr totalArea,
+ BoxPtr trackingArea,
+ INT16 *border)
+{
+ XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
+ xf86CrtcPtr crtc = randr_crtc->devPrivate;
+ BoxRec oldTotalArea;
+ BoxRec oldTrackingArea;
+ INT16 oldBorder[4];
+
+
+ if (crtc->version < 2)
+ return FALSE;
+
+ memcpy (&oldTotalArea, &crtc->panningTotalArea, sizeof(BoxRec));
+ memcpy (&oldTrackingArea, &crtc->panningTrackingArea, sizeof(BoxRec));
+ memcpy (oldBorder, crtc->panningBorder, 4*sizeof(INT16));
+
+ if (totalArea)
+ memcpy (&crtc->panningTotalArea, totalArea, sizeof(BoxRec));
+ if (trackingArea)
+ memcpy (&crtc->panningTrackingArea, trackingArea, sizeof(BoxRec));
+ if (border)
+ memcpy (crtc->panningBorder, border, 4*sizeof(INT16));
+
+ if (xf86RandR13VerifyPanningArea (crtc, pScreen->width, pScreen->height)) {
+ xf86RandR13Pan (crtc, randrp->pointerX, randrp->pointerY);
+ return TRUE;
+ } else {
+ /* Restore old settings */
+ memcpy (&crtc->panningTotalArea, &oldTotalArea, sizeof(BoxRec));
+ memcpy (&crtc->panningTrackingArea, &oldTrackingArea, sizeof(BoxRec));
+ memcpy (crtc->panningBorder, oldBorder, 4*sizeof(INT16));
+ return FALSE;
+ }
+}
+
+/*
+ * Compatibility with XF86VidMode's gamma changer. This necessarily clobbers
+ * any per-crtc setup. You asked for it...
+ */
+
+static void
+gamma_to_ramp(float gamma, CARD16 *ramp, int size)
+{
+ int i;
+
+ for (i = 0; i < size; i++) {
+ if (gamma == 1.0)
+ ramp[i] = i << 8;
+ else
+ ramp[i] = (CARD16)(pow((double)i / (double)(size - 1), 1. / gamma)
+ * (double)(size - 1) * 256);
+ }
+}
+
+static int
+xf86RandR12ChangeGamma(int scrnIndex, Gamma gamma)
+{
+ CARD16 *points, *red, *green, *blue;
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ RRCrtcPtr crtc = xf86CompatRRCrtc(pScrn);
+ int size;
+
+ if (!crtc)
+ return Success;
+
+ size = max(0, crtc->gammaSize);
+ if (!size)
+ return Success;
+
+ points = calloc(size, 3 * sizeof(CARD16));
+ if (!points)
+ return BadAlloc;
+
+ red = points;
+ green = points + size;
+ blue = points + 2 * size;
+
+ gamma_to_ramp(gamma.red, red, size);
+ gamma_to_ramp(gamma.green, green, size);
+ gamma_to_ramp(gamma.blue, blue, size);
+ RRCrtcGammaSet(crtc, red, green, blue);
+
+ free(points);
+
+ pScrn->gamma = gamma;
+
+ return Success;
+}
+
+static Bool
+xf86RandR12EnterVT (int screen_index, int flags)
+{
+ ScreenPtr pScreen = screenInfo.screens[screen_index];
+ ScrnInfoPtr pScrn = xf86Screens[screen_index];
+ XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
+ rrScrPrivPtr rp = rrGetScrPriv(pScreen);
+ Bool ret;
+ int i;
+
+ if (randrp->orig_EnterVT) {
+ pScrn->EnterVT = randrp->orig_EnterVT;
+ ret = pScrn->EnterVT (screen_index, flags);
+ randrp->orig_EnterVT = pScrn->EnterVT;
+ pScrn->EnterVT = xf86RandR12EnterVT;
+ if (!ret)
+ return FALSE;
+ }
+
+ /* reload gamma */
+ for (i = 0; i < rp->numCrtcs; i++)
+ xf86RandR12CrtcSetGamma(pScreen, rp->crtcs[i]);
+
+ return RRGetInfo (pScreen, TRUE); /* force a re-probe of outputs and notify clients about changes */
+}
+
+static Bool
+xf86RandR12Init12 (ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ rrScrPrivPtr rp = rrGetScrPriv(pScreen);
+ XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
+ int i;
+
+ rp->rrGetInfo = xf86RandR12GetInfo12;
+ rp->rrScreenSetSize = xf86RandR12ScreenSetSize;
+ rp->rrCrtcSet = xf86RandR12CrtcSet;
+ rp->rrCrtcSetGamma = xf86RandR12CrtcSetGamma;
+ rp->rrCrtcGetGamma = xf86RandR12CrtcGetGamma;
+ rp->rrOutputSetProperty = xf86RandR12OutputSetProperty;
+ rp->rrOutputValidateMode = xf86RandR12OutputValidateMode;
+#if RANDR_13_INTERFACE
+ rp->rrOutputGetProperty = xf86RandR13OutputGetProperty;
+ rp->rrGetPanning = xf86RandR13GetPanning;
+ rp->rrSetPanning = xf86RandR13SetPanning;
+#endif
+ rp->rrModeDestroy = xf86RandR12ModeDestroy;
+ rp->rrSetConfig = NULL;
+ pScrn->PointerMoved = xf86RandR12PointerMoved;
+ pScrn->ChangeGamma = xf86RandR12ChangeGamma;
+
+ randrp->orig_EnterVT = pScrn->EnterVT;
+ pScrn->EnterVT = xf86RandR12EnterVT;
+
+ if (!xf86RandR12CreateObjects12 (pScreen))
+ return FALSE;
+
+ /*
+ * Configure output modes
+ */
+ if (!xf86RandR12SetInfo12 (pScreen))
+ return FALSE;
+ for (i = 0; i < rp->numCrtcs; i++) {
+ xf86RandR12CrtcGetGamma(pScreen, rp->crtcs[i]);
+ }
+ return TRUE;
+}
+
+#endif
+
+Bool
+xf86RandR12PreInit (ScrnInfoPtr pScrn)
+{
+ return TRUE;
+}
diff --git a/xorg-server/hw/xfree86/modes/xf86Rotate.c b/xorg-server/hw/xfree86/modes/xf86Rotate.c
index 655857597..57c3499ac 100644
--- a/xorg-server/hw/xfree86/modes/xf86Rotate.c
+++ b/xorg-server/hw/xfree86/modes/xf86Rotate.c
@@ -1,525 +1,525 @@
-/*
- * Copyright © 2006 Keith Packard
- *
- * 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 copyright holders not be used in advertising or
- * publicity pertaining to distribution of the software without specific,
- * written prior permission. The copyright holders make no representations
- * about the suitability of this software for any purpose. It is provided "as
- * is" without express or implied warranty.
- *
- * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE COPYRIGHT HOLDERS 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_XORG_CONFIG_H
-#include <xorg-config.h>
-#else
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#endif
-
-#include <stddef.h>
-#include <string.h>
-#include <stdio.h>
-
-#include "xf86.h"
-#include "xf86DDC.h"
-#include "fb.h"
-#include "windowstr.h"
-#include "xf86Crtc.h"
-#include "xf86Modes.h"
-#include "xf86RandR12.h"
-#include "X11/extensions/render.h"
-#include "X11/extensions/dpmsconst.h"
-#include "X11/Xatom.h"
-
-/* borrowed from composite extension, move to Render and publish? */
-
-static VisualPtr
-compGetWindowVisual (WindowPtr pWin)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- VisualID vid = wVisual (pWin);
- int i;
-
- for (i = 0; i < pScreen->numVisuals; i++)
- if (pScreen->visuals[i].vid == vid)
- return &pScreen->visuals[i];
- return 0;
-}
-
-static PictFormatPtr
-compWindowFormat (WindowPtr pWin)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
-
- return PictureMatchVisual (pScreen, pWin->drawable.depth,
- compGetWindowVisual (pWin));
-}
-
-#define F(x) IntToxFixed(x)
-
-#define toF(x) ((float) (x) / 65536.0f)
-
-static void
-xf86RotateCrtcRedisplay (xf86CrtcPtr crtc, RegionPtr region)
-{
- ScrnInfoPtr scrn = crtc->scrn;
- ScreenPtr screen = scrn->pScreen;
- WindowPtr root = screen->root;
- PixmapPtr dst_pixmap = crtc->rotatedPixmap;
- PictFormatPtr format = compWindowFormat (screen->root);
- int error;
- PicturePtr src, dst;
- int n = RegionNumRects(region);
- BoxPtr b = RegionRects(region);
- XID include_inferiors = IncludeInferiors;
-
- src = CreatePicture (None,
- &root->drawable,
- format,
- CPSubwindowMode,
- &include_inferiors,
- serverClient,
- &error);
- if (!src)
- return;
-
- dst = CreatePicture (None,
- &dst_pixmap->drawable,
- format,
- 0L,
- NULL,
- serverClient,
- &error);
- if (!dst)
- return;
-
- error = SetPictureTransform (src, &crtc->crtc_to_framebuffer);
- if (error)
- return;
- if (crtc->transform_in_use && crtc->filter)
- SetPicturePictFilter (src, crtc->filter,
- crtc->params, crtc->nparams);
-
- if (crtc->shadowClear)
- {
- CompositePicture (PictOpSrc,
- src, NULL, dst,
- 0, 0, 0, 0, 0, 0,
- crtc->mode.HDisplay, crtc->mode.VDisplay);
- crtc->shadowClear = FALSE;
- }
- else
- {
- while (n--)
- {
- BoxRec dst_box;
-
- dst_box = *b;
- dst_box.x1 -= crtc->filter_width >> 1;
- dst_box.x2 += crtc->filter_width >> 1;
- dst_box.y1 -= crtc->filter_height >> 1;
- dst_box.y2 += crtc->filter_height >> 1;
- pixman_f_transform_bounds (&crtc->f_framebuffer_to_crtc, &dst_box);
- CompositePicture (PictOpSrc,
- src, NULL, dst,
- dst_box.x1, dst_box.y1, 0, 0, dst_box.x1, dst_box.y1,
- dst_box.x2 - dst_box.x1,
- dst_box.y2 - dst_box.y1);
- b++;
- }
- }
- FreePicture (src, None);
- FreePicture (dst, None);
-}
-
-static void
-xf86CrtcDamageShadow (xf86CrtcPtr crtc)
-{
- ScrnInfoPtr pScrn = crtc->scrn;
- BoxRec damage_box;
- RegionRec damage_region;
- ScreenPtr pScreen = pScrn->pScreen;
-
- damage_box.x1 = 0;
- damage_box.x2 = crtc->mode.HDisplay;
- damage_box.y1 = 0;
- damage_box.y2 = crtc->mode.VDisplay;
- if (!pixman_transform_bounds (&crtc->crtc_to_framebuffer, &damage_box))
- {
- damage_box.x1 = 0;
- damage_box.y1 = 0;
- damage_box.x2 = pScreen->width;
- damage_box.y2 = pScreen->height;
- }
- if (damage_box.x1 < 0) damage_box.x1 = 0;
- if (damage_box.y1 < 0) damage_box.y1 = 0;
- if (damage_box.x2 > pScreen->width) damage_box.x2 = pScreen->width;
- if (damage_box.y2 > pScreen->height) damage_box.y2 = pScreen->height;
- RegionInit(&damage_region, &damage_box, 1);
- DamageDamageRegion (&(*pScreen->GetScreenPixmap)(pScreen)->drawable,
- &damage_region);
- RegionUninit(&damage_region);
- crtc->shadowClear = TRUE;
-}
-
-static void
-xf86RotatePrepare (ScreenPtr pScreen)
-{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
- int c;
-
- for (c = 0; c < xf86_config->num_crtc; c++)
- {
- xf86CrtcPtr crtc = xf86_config->crtc[c];
-
- if (crtc->rotatedData && !crtc->rotatedPixmap)
- {
- crtc->rotatedPixmap = crtc->funcs->shadow_create (crtc,
- crtc->rotatedData,
- crtc->mode.HDisplay,
- crtc->mode.VDisplay);
- if (!xf86_config->rotation_damage_registered)
- {
- /* Hook damage to screen pixmap */
- DamageRegister (&(*pScreen->GetScreenPixmap)(pScreen)->drawable,
- xf86_config->rotation_damage);
- xf86_config->rotation_damage_registered = TRUE;
- EnableLimitedSchedulingLatency();
- }
-
- xf86CrtcDamageShadow (crtc);
- }
- }
-}
-
-static Bool
-xf86RotateRedisplay(ScreenPtr pScreen)
-{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
- DamagePtr damage = xf86_config->rotation_damage;
- RegionPtr region;
-
- if (!damage)
- return FALSE;
- xf86RotatePrepare (pScreen);
- region = DamageRegion(damage);
- if (RegionNotEmpty(region))
- {
- int c;
- SourceValidateProcPtr SourceValidate;
-
- /*
- * SourceValidate is used by the software cursor code
- * to pull the cursor off of the screen when reading
- * bits from the frame buffer. Bypassing this function
- * leaves the software cursor in place
- */
- SourceValidate = pScreen->SourceValidate;
- pScreen->SourceValidate = NULL;
-
- for (c = 0; c < xf86_config->num_crtc; c++)
- {
- xf86CrtcPtr crtc = xf86_config->crtc[c];
-
- if (crtc->transform_in_use && crtc->enabled)
- {
- RegionRec crtc_damage;
-
- /* compute portion of damage that overlaps crtc */
- RegionInit(&crtc_damage, &crtc->bounds, 1);
- RegionIntersect(&crtc_damage, &crtc_damage, region);
-
- /* update damaged region */
- if (RegionNotEmpty(&crtc_damage))
- xf86RotateCrtcRedisplay (crtc, &crtc_damage);
-
- RegionUninit(&crtc_damage);
- }
- }
- pScreen->SourceValidate = SourceValidate;
- DamageEmpty(damage);
- }
- return TRUE;
-}
-
-static void
-xf86RotateBlockHandler(int screenNum, pointer blockData,
- pointer pTimeout, pointer pReadmask)
-{
- ScreenPtr pScreen = screenInfo.screens[screenNum];
- ScrnInfoPtr pScrn = xf86Screens[screenNum];
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
- Bool rotation_active;
-
- rotation_active = xf86RotateRedisplay(pScreen);
- pScreen->BlockHandler = xf86_config->BlockHandler;
- (*pScreen->BlockHandler) (screenNum, blockData, pTimeout, pReadmask);
- /* cannot avoid re-wrapping until all wrapping is audited */
- xf86_config->BlockHandler = pScreen->BlockHandler;
- pScreen->BlockHandler = xf86RotateBlockHandler;
-}
-
-void
-xf86RotateDestroy (xf86CrtcPtr crtc)
-{
- ScrnInfoPtr pScrn = crtc->scrn;
- ScreenPtr pScreen = pScrn->pScreen;
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
- int c;
-
- /* Free memory from rotation */
- if (crtc->rotatedPixmap || crtc->rotatedData)
- {
- crtc->funcs->shadow_destroy (crtc, crtc->rotatedPixmap, crtc->rotatedData);
- crtc->rotatedPixmap = NULL;
- crtc->rotatedData = NULL;
- }
-
- for (c = 0; c < xf86_config->num_crtc; c++)
- if (xf86_config->crtc[c]->transform_in_use)
- return;
-
- /*
- * Clean up damage structures when no crtcs are rotated
- */
- if (xf86_config->rotation_damage)
- {
- /* Free damage structure */
- if (xf86_config->rotation_damage_registered)
- {
- DamageUnregister (&(*pScreen->GetScreenPixmap)(pScreen)->drawable,
- xf86_config->rotation_damage);
- xf86_config->rotation_damage_registered = FALSE;
- DisableLimitedSchedulingLatency();
- }
- DamageDestroy (xf86_config->rotation_damage);
- xf86_config->rotation_damage = NULL;
- }
-}
-
-void
-xf86RotateFreeShadow(ScrnInfoPtr pScrn)
-{
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
- int c;
-
- for (c = 0; c < config->num_crtc; c++) {
- xf86CrtcPtr crtc = config->crtc[c];
-
- if (crtc->rotatedPixmap || crtc->rotatedData) {
- crtc->funcs->shadow_destroy(crtc, crtc->rotatedPixmap,
- crtc->rotatedData);
- crtc->rotatedPixmap = NULL;
- crtc->rotatedData = NULL;
- }
- }
-}
-
-void
-xf86RotateCloseScreen (ScreenPtr screen)
-{
- ScrnInfoPtr scrn = xf86Screens[screen->myNum];
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
- int c;
-
- for (c = 0; c < xf86_config->num_crtc; c++)
- xf86RotateDestroy (xf86_config->crtc[c]);
-}
-
-static Bool
-xf86CrtcFitsScreen (xf86CrtcPtr crtc, struct pict_f_transform *crtc_to_fb)
-{
- ScrnInfoPtr pScrn = crtc->scrn;
- BoxRec b;
-
- /* When called before PreInit, the driver is
- * presumably doing load detect
- */
- if (pScrn->virtualX == 0 || pScrn->virtualY == 0)
- return TRUE;
-
- b.x1 = 0;
- b.y1 = 0;
- b.x2 = crtc->mode.HDisplay;
- b.y2 = crtc->mode.VDisplay;
- if (crtc_to_fb)
- pixman_f_transform_bounds (crtc_to_fb, &b);
- else {
- b.x1 += crtc->x;
- b.y1 += crtc->y;
- b.x2 += crtc->x;
- b.y2 += crtc->y;
- }
-
- return (0 <= b.x1 && b.x2 <= pScrn->virtualX &&
- 0 <= b.y1 && b.y2 <= pScrn->virtualY);
-}
-
-Bool
-xf86CrtcRotate (xf86CrtcPtr crtc)
-{
- ScrnInfoPtr pScrn = crtc->scrn;
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
- /* if this is called during ScreenInit() we don't have pScrn->pScreen yet */
- ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex];
- PictTransform crtc_to_fb;
- struct pict_f_transform f_crtc_to_fb, f_fb_to_crtc;
- xFixed *new_params = NULL;
- int new_nparams = 0;
- PictFilterPtr new_filter = NULL;
- int new_width = 0;
- int new_height = 0;
- RRTransformPtr transform = NULL;
- Bool damage = FALSE;
-
- if (crtc->transformPresent)
- transform = &crtc->transform;
-
- if (!RRTransformCompute (crtc->x, crtc->y,
- crtc->mode.HDisplay, crtc->mode.VDisplay,
- crtc->rotation,
- transform,
-
- &crtc_to_fb,
- &f_crtc_to_fb,
- &f_fb_to_crtc) &&
- xf86CrtcFitsScreen (crtc, &f_crtc_to_fb))
- {
- /*
- * If the untranslated transformation is the identity,
- * disable the shadow buffer
- */
- xf86RotateDestroy (crtc);
- crtc->transform_in_use = FALSE;
- free(new_params);
- new_params = NULL;
- new_nparams = 0;
- new_filter = NULL;
- new_width = 0;
- new_height = 0;
- }
- else
- {
- /*
- * these are the size of the shadow pixmap, which
- * matches the mode, not the pre-rotated copy in the
- * frame buffer
- */
- int width = crtc->mode.HDisplay;
- int height = crtc->mode.VDisplay;
- void *shadowData = crtc->rotatedData;
- PixmapPtr shadow = crtc->rotatedPixmap;
- int old_width = shadow ? shadow->drawable.width : 0;
- int old_height = shadow ? shadow->drawable.height : 0;
-
- /* Allocate memory for rotation */
- if (old_width != width || old_height != height)
- {
- if (shadow || shadowData)
- {
- crtc->funcs->shadow_destroy (crtc, shadow, shadowData);
- crtc->rotatedPixmap = NULL;
- crtc->rotatedData = NULL;
- }
- shadowData = crtc->funcs->shadow_allocate (crtc, width, height);
- if (!shadowData)
- goto bail1;
- crtc->rotatedData = shadowData;
- /* shadow will be damaged in xf86RotatePrepare */
- }
- else
- {
- /* mark shadowed area as damaged so it will be repainted */
- damage = TRUE;
- }
-
- if (!xf86_config->rotation_damage)
- {
- /* Create damage structure */
- xf86_config->rotation_damage = DamageCreate (NULL, NULL,
- DamageReportNone,
- TRUE, pScreen, pScreen);
- if (!xf86_config->rotation_damage)
- goto bail2;
-
- /* Wrap block handler */
- if (!xf86_config->BlockHandler) {
- xf86_config->BlockHandler = pScreen->BlockHandler;
- pScreen->BlockHandler = xf86RotateBlockHandler;
- }
- }
-#ifdef RANDR_12_INTERFACE
- if (transform)
- {
- if (transform->nparams) {
- new_params = malloc(transform->nparams * sizeof (xFixed));
- if (new_params) {
- memcpy (new_params, transform->params,
- transform->nparams * sizeof (xFixed));
- new_nparams = transform->nparams;
- new_filter = transform->filter;
- }
- } else
- new_filter = transform->filter;
- if (new_filter)
- {
- new_width = new_filter->width;
- new_height = new_filter->height;
- }
- }
-#endif
-
- if (0)
- {
- bail2:
- if (shadow || shadowData)
- {
- crtc->funcs->shadow_destroy (crtc, shadow, shadowData);
- crtc->rotatedPixmap = NULL;
- crtc->rotatedData = NULL;
- }
- bail1:
- if (old_width && old_height)
- crtc->rotatedPixmap = crtc->funcs->shadow_create (crtc,
- NULL,
- old_width,
- old_height);
- return FALSE;
- }
- crtc->transform_in_use = TRUE;
- }
- crtc->crtc_to_framebuffer = crtc_to_fb;
- crtc->f_crtc_to_framebuffer = f_crtc_to_fb;
- crtc->f_framebuffer_to_crtc = f_fb_to_crtc;
- free(crtc->params);
- crtc->params = new_params;
- crtc->nparams = new_nparams;
- crtc->filter = new_filter;
- crtc->filter_width = new_width;
- crtc->filter_height = new_height;
- crtc->bounds.x1 = 0;
- crtc->bounds.x2 = crtc->mode.HDisplay;
- crtc->bounds.y1 = 0;
- crtc->bounds.y2 = crtc->mode.VDisplay;
- pixman_f_transform_bounds (&f_crtc_to_fb, &crtc->bounds);
-
- if (damage)
- xf86CrtcDamageShadow (crtc);
-
- /* All done */
- return TRUE;
-}
+/*
+ * Copyright © 2006 Keith Packard
+ *
+ * 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 copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no representations
+ * about the suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS 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_XORG_CONFIG_H
+#include <xorg-config.h>
+#else
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#endif
+
+#include <stddef.h>
+#include <string.h>
+#include <stdio.h>
+
+#include "xf86.h"
+#include "xf86DDC.h"
+#include "fb.h"
+#include "windowstr.h"
+#include "xf86Crtc.h"
+#include "xf86Modes.h"
+#include "xf86RandR12.h"
+#include "X11/extensions/render.h"
+#include "X11/extensions/dpmsconst.h"
+#include "X11/Xatom.h"
+
+/* borrowed from composite extension, move to Render and publish? */
+
+static VisualPtr
+compGetWindowVisual (WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ VisualID vid = wVisual (pWin);
+ int i;
+
+ for (i = 0; i < pScreen->numVisuals; i++)
+ if (pScreen->visuals[i].vid == vid)
+ return &pScreen->visuals[i];
+ return 0;
+}
+
+static PictFormatPtr
+compWindowFormat (WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ return PictureMatchVisual (pScreen, pWin->drawable.depth,
+ compGetWindowVisual (pWin));
+}
+
+#define F(x) IntToxFixed(x)
+
+#define toF(x) ((float) (x) / 65536.0f)
+
+static void
+xf86RotateCrtcRedisplay (xf86CrtcPtr crtc, RegionPtr region)
+{
+ ScrnInfoPtr scrn = crtc->scrn;
+ ScreenPtr screen = scrn->pScreen;
+ WindowPtr root = screen->root;
+ PixmapPtr dst_pixmap = crtc->rotatedPixmap;
+ PictFormatPtr format = compWindowFormat (screen->root);
+ int error;
+ PicturePtr src, dst;
+ int n = RegionNumRects(region);
+ BoxPtr b = RegionRects(region);
+ XID include_inferiors = IncludeInferiors;
+
+ src = CreatePicture (None,
+ &root->drawable,
+ format,
+ CPSubwindowMode,
+ &include_inferiors,
+ serverClient,
+ &error);
+ if (!src)
+ return;
+
+ dst = CreatePicture (None,
+ &dst_pixmap->drawable,
+ format,
+ 0L,
+ NULL,
+ serverClient,
+ &error);
+ if (!dst)
+ return;
+
+ error = SetPictureTransform (src, &crtc->crtc_to_framebuffer);
+ if (error)
+ return;
+ if (crtc->transform_in_use && crtc->filter)
+ SetPicturePictFilter (src, crtc->filter,
+ crtc->params, crtc->nparams);
+
+ if (crtc->shadowClear)
+ {
+ CompositePicture (PictOpSrc,
+ src, NULL, dst,
+ 0, 0, 0, 0, 0, 0,
+ crtc->mode.HDisplay, crtc->mode.VDisplay);
+ crtc->shadowClear = FALSE;
+ }
+ else
+ {
+ while (n--)
+ {
+ BoxRec dst_box;
+
+ dst_box = *b;
+ dst_box.x1 -= crtc->filter_width >> 1;
+ dst_box.x2 += crtc->filter_width >> 1;
+ dst_box.y1 -= crtc->filter_height >> 1;
+ dst_box.y2 += crtc->filter_height >> 1;
+ pixman_f_transform_bounds (&crtc->f_framebuffer_to_crtc, &dst_box);
+ CompositePicture (PictOpSrc,
+ src, NULL, dst,
+ dst_box.x1, dst_box.y1, 0, 0, dst_box.x1, dst_box.y1,
+ dst_box.x2 - dst_box.x1,
+ dst_box.y2 - dst_box.y1);
+ b++;
+ }
+ }
+ FreePicture (src, None);
+ FreePicture (dst, None);
+}
+
+static void
+xf86CrtcDamageShadow (xf86CrtcPtr crtc)
+{
+ ScrnInfoPtr pScrn = crtc->scrn;
+ BoxRec damage_box;
+ RegionRec damage_region;
+ ScreenPtr pScreen = pScrn->pScreen;
+
+ damage_box.x1 = 0;
+ damage_box.x2 = crtc->mode.HDisplay;
+ damage_box.y1 = 0;
+ damage_box.y2 = crtc->mode.VDisplay;
+ if (!pixman_transform_bounds (&crtc->crtc_to_framebuffer, &damage_box))
+ {
+ damage_box.x1 = 0;
+ damage_box.y1 = 0;
+ damage_box.x2 = pScreen->width;
+ damage_box.y2 = pScreen->height;
+ }
+ if (damage_box.x1 < 0) damage_box.x1 = 0;
+ if (damage_box.y1 < 0) damage_box.y1 = 0;
+ if (damage_box.x2 > pScreen->width) damage_box.x2 = pScreen->width;
+ if (damage_box.y2 > pScreen->height) damage_box.y2 = pScreen->height;
+ RegionInit(&damage_region, &damage_box, 1);
+ DamageDamageRegion (&(*pScreen->GetScreenPixmap)(pScreen)->drawable,
+ &damage_region);
+ RegionUninit(&damage_region);
+ crtc->shadowClear = TRUE;
+}
+
+static void
+xf86RotatePrepare (ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
+ int c;
+
+ for (c = 0; c < xf86_config->num_crtc; c++)
+ {
+ xf86CrtcPtr crtc = xf86_config->crtc[c];
+
+ if (crtc->rotatedData && !crtc->rotatedPixmap)
+ {
+ crtc->rotatedPixmap = crtc->funcs->shadow_create (crtc,
+ crtc->rotatedData,
+ crtc->mode.HDisplay,
+ crtc->mode.VDisplay);
+ if (!xf86_config->rotation_damage_registered)
+ {
+ /* Hook damage to screen pixmap */
+ DamageRegister (&(*pScreen->GetScreenPixmap)(pScreen)->drawable,
+ xf86_config->rotation_damage);
+ xf86_config->rotation_damage_registered = TRUE;
+ EnableLimitedSchedulingLatency();
+ }
+
+ xf86CrtcDamageShadow (crtc);
+ }
+ }
+}
+
+static Bool
+xf86RotateRedisplay(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
+ DamagePtr damage = xf86_config->rotation_damage;
+ RegionPtr region;
+
+ if (!damage)
+ return FALSE;
+ xf86RotatePrepare (pScreen);
+ region = DamageRegion(damage);
+ if (RegionNotEmpty(region))
+ {
+ int c;
+ SourceValidateProcPtr SourceValidate;
+
+ /*
+ * SourceValidate is used by the software cursor code
+ * to pull the cursor off of the screen when reading
+ * bits from the frame buffer. Bypassing this function
+ * leaves the software cursor in place
+ */
+ SourceValidate = pScreen->SourceValidate;
+ pScreen->SourceValidate = NULL;
+
+ for (c = 0; c < xf86_config->num_crtc; c++)
+ {
+ xf86CrtcPtr crtc = xf86_config->crtc[c];
+
+ if (crtc->transform_in_use && crtc->enabled)
+ {
+ RegionRec crtc_damage;
+
+ /* compute portion of damage that overlaps crtc */
+ RegionInit(&crtc_damage, &crtc->bounds, 1);
+ RegionIntersect(&crtc_damage, &crtc_damage, region);
+
+ /* update damaged region */
+ if (RegionNotEmpty(&crtc_damage))
+ xf86RotateCrtcRedisplay (crtc, &crtc_damage);
+
+ RegionUninit(&crtc_damage);
+ }
+ }
+ pScreen->SourceValidate = SourceValidate;
+ DamageEmpty(damage);
+ }
+ return TRUE;
+}
+
+static void
+xf86RotateBlockHandler(int screenNum, pointer blockData,
+ pointer pTimeout, pointer pReadmask)
+{
+ ScreenPtr pScreen = screenInfo.screens[screenNum];
+ ScrnInfoPtr pScrn = xf86Screens[screenNum];
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
+ Bool rotation_active;
+
+ rotation_active = xf86RotateRedisplay(pScreen);
+ pScreen->BlockHandler = xf86_config->BlockHandler;
+ (*pScreen->BlockHandler) (screenNum, blockData, pTimeout, pReadmask);
+ /* cannot avoid re-wrapping until all wrapping is audited */
+ xf86_config->BlockHandler = pScreen->BlockHandler;
+ pScreen->BlockHandler = xf86RotateBlockHandler;
+}
+
+void
+xf86RotateDestroy (xf86CrtcPtr crtc)
+{
+ ScrnInfoPtr pScrn = crtc->scrn;
+ ScreenPtr pScreen = pScrn->pScreen;
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
+ int c;
+
+ /* Free memory from rotation */
+ if (crtc->rotatedPixmap || crtc->rotatedData)
+ {
+ crtc->funcs->shadow_destroy (crtc, crtc->rotatedPixmap, crtc->rotatedData);
+ crtc->rotatedPixmap = NULL;
+ crtc->rotatedData = NULL;
+ }
+
+ for (c = 0; c < xf86_config->num_crtc; c++)
+ if (xf86_config->crtc[c]->transform_in_use)
+ return;
+
+ /*
+ * Clean up damage structures when no crtcs are rotated
+ */
+ if (xf86_config->rotation_damage)
+ {
+ /* Free damage structure */
+ if (xf86_config->rotation_damage_registered)
+ {
+ DamageUnregister (&(*pScreen->GetScreenPixmap)(pScreen)->drawable,
+ xf86_config->rotation_damage);
+ xf86_config->rotation_damage_registered = FALSE;
+ DisableLimitedSchedulingLatency();
+ }
+ DamageDestroy (xf86_config->rotation_damage);
+ xf86_config->rotation_damage = NULL;
+ }
+}
+
+void
+xf86RotateFreeShadow(ScrnInfoPtr pScrn)
+{
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+ int c;
+
+ for (c = 0; c < config->num_crtc; c++) {
+ xf86CrtcPtr crtc = config->crtc[c];
+
+ if (crtc->rotatedPixmap || crtc->rotatedData) {
+ crtc->funcs->shadow_destroy(crtc, crtc->rotatedPixmap,
+ crtc->rotatedData);
+ crtc->rotatedPixmap = NULL;
+ crtc->rotatedData = NULL;
+ }
+ }
+}
+
+void
+xf86RotateCloseScreen (ScreenPtr screen)
+{
+ ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+ int c;
+
+ for (c = 0; c < xf86_config->num_crtc; c++)
+ xf86RotateDestroy (xf86_config->crtc[c]);
+}
+
+static Bool
+xf86CrtcFitsScreen (xf86CrtcPtr crtc, struct pict_f_transform *crtc_to_fb)
+{
+ ScrnInfoPtr pScrn = crtc->scrn;
+ BoxRec b;
+
+ /* When called before PreInit, the driver is
+ * presumably doing load detect
+ */
+ if (pScrn->virtualX == 0 || pScrn->virtualY == 0)
+ return TRUE;
+
+ b.x1 = 0;
+ b.y1 = 0;
+ b.x2 = crtc->mode.HDisplay;
+ b.y2 = crtc->mode.VDisplay;
+ if (crtc_to_fb)
+ pixman_f_transform_bounds (crtc_to_fb, &b);
+ else {
+ b.x1 += crtc->x;
+ b.y1 += crtc->y;
+ b.x2 += crtc->x;
+ b.y2 += crtc->y;
+ }
+
+ return (0 <= b.x1 && b.x2 <= pScrn->virtualX &&
+ 0 <= b.y1 && b.y2 <= pScrn->virtualY);
+}
+
+Bool
+xf86CrtcRotate (xf86CrtcPtr crtc)
+{
+ ScrnInfoPtr pScrn = crtc->scrn;
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
+ /* if this is called during ScreenInit() we don't have pScrn->pScreen yet */
+ ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex];
+ PictTransform crtc_to_fb;
+ struct pict_f_transform f_crtc_to_fb, f_fb_to_crtc;
+ xFixed *new_params = NULL;
+ int new_nparams = 0;
+ PictFilterPtr new_filter = NULL;
+ int new_width = 0;
+ int new_height = 0;
+ RRTransformPtr transform = NULL;
+ Bool damage = FALSE;
+
+ if (crtc->transformPresent)
+ transform = &crtc->transform;
+
+ if (!RRTransformCompute (crtc->x, crtc->y,
+ crtc->mode.HDisplay, crtc->mode.VDisplay,
+ crtc->rotation,
+ transform,
+
+ &crtc_to_fb,
+ &f_crtc_to_fb,
+ &f_fb_to_crtc) &&
+ xf86CrtcFitsScreen (crtc, &f_crtc_to_fb))
+ {
+ /*
+ * If the untranslated transformation is the identity,
+ * disable the shadow buffer
+ */
+ xf86RotateDestroy (crtc);
+ crtc->transform_in_use = FALSE;
+ free(new_params);
+ new_params = NULL;
+ new_nparams = 0;
+ new_filter = NULL;
+ new_width = 0;
+ new_height = 0;
+ }
+ else
+ {
+ /*
+ * these are the size of the shadow pixmap, which
+ * matches the mode, not the pre-rotated copy in the
+ * frame buffer
+ */
+ int width = crtc->mode.HDisplay;
+ int height = crtc->mode.VDisplay;
+ void *shadowData = crtc->rotatedData;
+ PixmapPtr shadow = crtc->rotatedPixmap;
+ int old_width = shadow ? shadow->drawable.width : 0;
+ int old_height = shadow ? shadow->drawable.height : 0;
+
+ /* Allocate memory for rotation */
+ if (old_width != width || old_height != height)
+ {
+ if (shadow || shadowData)
+ {
+ crtc->funcs->shadow_destroy (crtc, shadow, shadowData);
+ crtc->rotatedPixmap = NULL;
+ crtc->rotatedData = NULL;
+ }
+ shadowData = crtc->funcs->shadow_allocate (crtc, width, height);
+ if (!shadowData)
+ goto bail1;
+ crtc->rotatedData = shadowData;
+ /* shadow will be damaged in xf86RotatePrepare */
+ }
+ else
+ {
+ /* mark shadowed area as damaged so it will be repainted */
+ damage = TRUE;
+ }
+
+ if (!xf86_config->rotation_damage)
+ {
+ /* Create damage structure */
+ xf86_config->rotation_damage = DamageCreate (NULL, NULL,
+ DamageReportNone,
+ TRUE, pScreen, pScreen);
+ if (!xf86_config->rotation_damage)
+ goto bail2;
+
+ /* Wrap block handler */
+ if (!xf86_config->BlockHandler) {
+ xf86_config->BlockHandler = pScreen->BlockHandler;
+ pScreen->BlockHandler = xf86RotateBlockHandler;
+ }
+ }
+#ifdef RANDR_12_INTERFACE
+ if (transform)
+ {
+ if (transform->nparams) {
+ new_params = malloc(transform->nparams * sizeof (xFixed));
+ if (new_params) {
+ memcpy (new_params, transform->params,
+ transform->nparams * sizeof (xFixed));
+ new_nparams = transform->nparams;
+ new_filter = transform->filter;
+ }
+ } else
+ new_filter = transform->filter;
+ if (new_filter)
+ {
+ new_width = new_filter->width;
+ new_height = new_filter->height;
+ }
+ }
+#endif
+
+ if (0)
+ {
+ bail2:
+ if (shadow || shadowData)
+ {
+ crtc->funcs->shadow_destroy (crtc, shadow, shadowData);
+ crtc->rotatedPixmap = NULL;
+ crtc->rotatedData = NULL;
+ }
+ bail1:
+ if (old_width && old_height)
+ crtc->rotatedPixmap = crtc->funcs->shadow_create (crtc,
+ NULL,
+ old_width,
+ old_height);
+ return FALSE;
+ }
+ crtc->transform_in_use = TRUE;
+ }
+ crtc->crtc_to_framebuffer = crtc_to_fb;
+ crtc->f_crtc_to_framebuffer = f_crtc_to_fb;
+ crtc->f_framebuffer_to_crtc = f_fb_to_crtc;
+ free(crtc->params);
+ crtc->params = new_params;
+ crtc->nparams = new_nparams;
+ crtc->filter = new_filter;
+ crtc->filter_width = new_width;
+ crtc->filter_height = new_height;
+ crtc->bounds.x1 = 0;
+ crtc->bounds.x2 = crtc->mode.HDisplay;
+ crtc->bounds.y1 = 0;
+ crtc->bounds.y2 = crtc->mode.VDisplay;
+ pixman_f_transform_bounds (&f_crtc_to_fb, &crtc->bounds);
+
+ if (damage)
+ xf86CrtcDamageShadow (crtc);
+
+ /* All done */
+ return TRUE;
+}
diff --git a/xorg-server/hw/xfree86/os-support/bsd/bsd_init.c b/xorg-server/hw/xfree86/os-support/bsd/bsd_init.c
index 7775e5dff..123eb17d1 100644
--- a/xorg-server/hw/xfree86/os-support/bsd/bsd_init.c
+++ b/xorg-server/hw/xfree86/os-support/bsd/bsd_init.c
@@ -1,756 +1,756 @@
-/*
- * Copyright 1992 by Rich Murphey <Rich@Rice.edu>
- * Copyright 1993 by David Wexelblat <dwex@goblin.org>
- *
- * 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 names of Rich Murphey and David Wexelblat
- * not be used in advertising or publicity pertaining to distribution of
- * the software without specific, written prior permission. Rich Murphey and
- * David Wexelblat make no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
- * implied warranty.
- *
- * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO
- * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT 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_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-
-#include "compiler.h"
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-
-#include <sys/utsname.h>
-#include <sys/ioctl.h>
-#include <stdlib.h>
-#include <errno.h>
-
-static Bool KeepTty = FALSE;
-static int devConsoleFd = -1;
-#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
-static int VTnum = -1;
-static int initialVT = -1;
-static Bool ShareVTs = FALSE;
-#endif
-
-#ifdef PCCONS_SUPPORT
-/* Stock 0.1 386bsd pccons console driver interface */
-#define PCCONS_CONSOLE_DEV1 "/dev/ttyv0"
-#define PCCONS_CONSOLE_DEV2 "/dev/vga"
-#define PCCONS_CONSOLE_MODE O_RDWR|O_NDELAY
-#endif
-
-#ifdef SYSCONS_SUPPORT
-/* The FreeBSD 1.1 version syscons driver uses /dev/ttyv0 */
-#define SYSCONS_CONSOLE_DEV1 "/dev/ttyv0"
-#define SYSCONS_CONSOLE_DEV2 "/dev/vga"
-#define SYSCONS_CONSOLE_MODE O_RDWR|O_NDELAY
-#endif
-
-#ifdef PCVT_SUPPORT
-/* Hellmuth Michaelis' pcvt driver */
-#ifndef __OpenBSD__
-# define PCVT_CONSOLE_DEV "/dev/ttyv0"
-#else
-# define PCVT_CONSOLE_DEV "/dev/ttyC0"
-#endif
-#define PCVT_CONSOLE_MODE O_RDWR|O_NDELAY
-#endif
-
-#if defined(WSCONS_SUPPORT) && defined(__NetBSD__)
-/* NetBSD's new console driver */
-#define WSCONS_PCVT_COMPAT_CONSOLE_DEV "/dev/ttyE0"
-#endif
-
-#ifdef __GLIBC__
-#define setpgrp setpgid
-#endif
-
-#define CHECK_DRIVER_MSG \
- "Check your kernel's console driver configuration and /dev entries"
-
-static char *supported_drivers[] = {
-#ifdef PCCONS_SUPPORT
- "pccons (with X support)",
-#endif
-#ifdef SYSCONS_SUPPORT
- "syscons",
-#endif
-#ifdef PCVT_SUPPORT
- "pcvt",
-#endif
-#ifdef WSCONS_SUPPORT
- "wscons",
-#endif
-};
-
-
-/*
- * Functions to probe for the existance of a supported console driver.
- * Any function returns either a valid file descriptor (driver probed
- * succesfully), -1 (driver not found), or uses FatalError() if the
- * driver was found but proved to not support the required mode to run
- * an X server.
- */
-
-typedef int (*xf86ConsOpen_t)(void);
-
-#ifdef PCCONS_SUPPORT
-static int xf86OpenPccons(void);
-#endif /* PCCONS_SUPPORT */
-
-#ifdef SYSCONS_SUPPORT
-static int xf86OpenSyscons(void);
-#endif /* SYSCONS_SUPPORT */
-
-#ifdef PCVT_SUPPORT
-static int xf86OpenPcvt(void);
-#endif /* PCVT_SUPPORT */
-
-#ifdef WSCONS_SUPPORT
-static int xf86OpenWScons(void);
-#endif
-
-/*
- * The sequence of the driver probes is important; start with the
- * driver that is best distinguishable, and end with the most generic
- * driver. (Otherwise, pcvt would also probe as syscons, and either
- * pcvt or syscons might succesfully probe as pccons.)
- */
-static xf86ConsOpen_t xf86ConsTab[] = {
-#ifdef PCVT_SUPPORT
- xf86OpenPcvt,
-#endif
-#ifdef SYSCONS_SUPPORT
- xf86OpenSyscons,
-#endif
-#ifdef PCCONS_SUPPORT
- xf86OpenPccons,
-#endif
-#ifdef WSCONS_SUPPORT
- xf86OpenWScons,
-#endif
- (xf86ConsOpen_t)NULL
-};
-
-
-void
-xf86OpenConsole()
-{
- int i, fd = -1;
- xf86ConsOpen_t *driver;
-#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
- int result;
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
- struct utsname uts;
-#endif
- vtmode_t vtmode;
-#endif
-
- if (serverGeneration == 1)
- {
- /* check if we are run with euid==0 */
- if (geteuid() != 0)
- {
- FatalError("xf86OpenConsole: Server must be suid root");
- }
-
- if (!KeepTty)
- {
- /*
- * detaching the controlling tty solves problems of kbd character
- * loss. This is not interesting for CO driver, because it is
- * exclusive.
- */
- setpgrp(0, getpid());
- if ((i = open("/dev/tty",O_RDWR)) >= 0)
- {
- ioctl(i,TIOCNOTTY,(char *)0);
- close(i);
- }
- }
-
- /* detect which driver we are running on */
- for (driver = xf86ConsTab; *driver; driver++)
- {
- if ((fd = (*driver)()) >= 0)
- break;
- }
-
- /* Check that a supported console driver was found */
- if (fd < 0)
- {
- char cons_drivers[80] = {0, };
- for (i = 0; i < sizeof(supported_drivers) / sizeof(char *); i++)
- {
- if (i)
- {
- strcat(cons_drivers, ", ");
- }
- strcat(cons_drivers, supported_drivers[i]);
- }
- FatalError(
- "%s: No console driver found\n\tSupported drivers: %s\n\t%s",
- "xf86OpenConsole", cons_drivers, CHECK_DRIVER_MSG);
- }
-#if 0 /* stdin is already closed in OsInit() */
- fclose(stdin);
-#endif
- xf86Info.consoleFd = fd;
- xf86Info.screenFd = fd;
-
- switch (xf86Info.consType)
- {
-#ifdef PCCONS_SUPPORT
- case PCCONS:
- if (ioctl (xf86Info.consoleFd, CONSOLE_X_MODE_ON, 0) < 0)
- {
- FatalError("%s: CONSOLE_X_MODE_ON failed (%s)\n%s",
- "xf86OpenConsole", strerror(errno),
- CHECK_DRIVER_MSG);
- }
- /*
- * Hack to prevent keyboard hanging when syslogd closes
- * /dev/console
- */
- if ((devConsoleFd = open("/dev/console", O_WRONLY,0)) < 0)
- {
- xf86Msg(X_WARNING,
- "xf86OpenConsole: couldn't open /dev/console (%s)\n",
- strerror(errno));
- }
- break;
-#endif
-#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
- case SYSCONS:
- /* as of FreeBSD 2.2.8, syscons driver does not need the #1 vt
- * switching anymore. Here we check for FreeBSD 3.1 and up.
- * Add cases for other *BSD that behave the same.
- */
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
- uname (&uts);
- i = atof(uts.release) * 100;
- if (i >= 310) goto acquire_vt;
-#endif
- /* otherwise fall through */
- case PCVT:
-#if !(defined(__NetBSD__) && (__NetBSD_Version__ >= 200000000))
- /*
- * First activate the #1 VT. This is a hack to allow a server
- * to be started while another one is active. There should be
- * a better way.
- */
- if (initialVT != 1) {
-
- if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, 1) != 0)
- {
- xf86Msg(X_WARNING,
- "xf86OpenConsole: VT_ACTIVATE failed\n");
- }
- sleep(1);
- }
-#endif
-acquire_vt:
- if (!ShareVTs) {
- /*
- * now get the VT
- */
- SYSCALL(result =
- ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno));
- if (result != 0)
- {
- xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
- }
- SYSCALL(result =
- ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno));
- if (result != 0)
- {
- xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
- }
-
- signal(SIGUSR1, xf86VTRequest);
-
- vtmode.mode = VT_PROCESS;
- vtmode.relsig = SIGUSR1;
- vtmode.acqsig = SIGUSR1;
- vtmode.frsig = SIGUSR1;
- if (ioctl(xf86Info.consoleFd, VT_SETMODE, &vtmode) < 0)
- {
- FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed");
- }
- #if !defined(USE_DEV_IO) && !defined(USE_I386_IOPL)
- if (ioctl(xf86Info.consoleFd, KDENABIO, 0) < 0)
- {
- FatalError("xf86OpenConsole: KDENABIO failed (%s)",
- strerror(errno));
- }
- #endif
- if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0)
- {
- FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed");
- }
- } else { /* ShareVTs */
- close(xf86Info.consoleFd);
- }
- break;
-#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
-#ifdef WSCONS_SUPPORT
- case WSCONS:
- /* Nothing to do */
- break;
-#endif
- }
- }
- else
- {
- /* serverGeneration != 1 */
-#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
- if (!ShareVTs) if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT)
- {
- if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
- {
- xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
- }
- }
-#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
- }
- return;
-}
-
-
-#ifdef PCCONS_SUPPORT
-
-static int
-xf86OpenPccons()
-{
- int fd = -1;
-
- if ((fd = open(PCCONS_CONSOLE_DEV1, PCCONS_CONSOLE_MODE, 0))
- >= 0 ||
- (fd = open(PCCONS_CONSOLE_DEV2, PCCONS_CONSOLE_MODE, 0))
- >= 0)
- {
- if (ioctl(fd, CONSOLE_X_MODE_OFF, 0) < 0)
- {
- FatalError(
- "%s: CONSOLE_X_MODE_OFF failed (%s)\n%s\n%s",
- "xf86OpenPccons",
- strerror(errno),
- "Was expecting pccons driver with X support",
- CHECK_DRIVER_MSG);
- }
- xf86Info.consType = PCCONS;
- xf86Msg(X_PROBED, "Using pccons driver with X support\n");
- }
- return fd;
-}
-
-#endif /* PCCONS_SUPPORT */
-
-#ifdef SYSCONS_SUPPORT
-
-static int
-xf86OpenSyscons()
-{
- int fd = -1;
- vtmode_t vtmode;
- char vtname[12];
- struct stat status;
- long syscons_version;
- MessageType from;
-
- /* Check for syscons */
- if ((fd = open(SYSCONS_CONSOLE_DEV1, SYSCONS_CONSOLE_MODE, 0)) >= 0
- || (fd = open(SYSCONS_CONSOLE_DEV2, SYSCONS_CONSOLE_MODE, 0)) >= 0)
- {
- if (ioctl(fd, VT_GETMODE, &vtmode) >= 0)
- {
- /* Get syscons version */
- if (ioctl(fd, CONS_GETVERS, &syscons_version) < 0)
- {
- syscons_version = 0;
- }
-
- xf86Info.vtno = VTnum;
- from = X_CMDLINE;
-
-#ifdef VT_GETACTIVE
- if (ioctl(fd, VT_GETACTIVE, &initialVT) < 0)
- initialVT = -1;
-#endif
- if (ShareVTs)
- xf86Info.vtno = initialVT;
-
- if (xf86Info.vtno == -1)
- {
- /*
- * For old syscons versions (<0x100), VT_OPENQRY returns
- * the current VT rather than the next free VT. In this
- * case, the server gets started on the current VT instead
- * of the next free VT.
- */
-
-#if 0
- /* check for the fixed VT_OPENQRY */
- if (syscons_version >= 0x100)
- {
-#endif
- if (ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0)
- {
- /* No free VTs */
- xf86Info.vtno = -1;
- }
-#if 0
- }
-#endif
-
- if (xf86Info.vtno == -1)
- {
- /*
- * All VTs are in use. If initialVT was found, use it.
- * Otherwise, if stdin is a VT, use that one.
- * XXX stdin is already closed, so this won't work.
- */
- if (initialVT != -1)
- {
- xf86Info.vtno = initialVT;
- }
- else if ((fstat(0, &status) >= 0)
- && S_ISCHR(status.st_mode)
- && (ioctl(0, VT_GETMODE, &vtmode) >= 0))
- {
- /* stdin is a VT */
- xf86Info.vtno = minor(status.st_rdev) + 1;
- }
- else
- {
- if (syscons_version >= 0x100)
- {
- FatalError("%s: Cannot find a free VT",
- "xf86OpenSyscons");
- }
- /* Should no longer reach here */
- FatalError("%s: %s %s\n\t%s %s",
- "xf86OpenSyscons",
- "syscons versions prior to 1.0 require",
- "either the",
- "server's stdin be a VT",
- "or the use of the vtxx server option");
- }
- }
- from = X_PROBED;
- }
-
- close(fd);
-#ifndef __OpenBSD__
- sprintf(vtname, "/dev/ttyv%01x", xf86Info.vtno - 1);
-#else
- sprintf(vtname, "/dev/ttyC%01x", xf86Info.vtno - 1);
-#endif
- if ((fd = open(vtname, SYSCONS_CONSOLE_MODE, 0)) < 0)
- {
- FatalError("xf86OpenSyscons: Cannot open %s (%s)",
- vtname, strerror(errno));
- }
- if (ioctl(fd, VT_GETMODE, &vtmode) < 0)
- {
- FatalError("xf86OpenSyscons: VT_GETMODE failed");
- }
- xf86Info.consType = SYSCONS;
- xf86Msg(X_PROBED, "Using syscons driver with X support");
- if (syscons_version >= 0x100)
- {
- xf86ErrorF(" (version %ld.%ld)\n", syscons_version >> 8,
- syscons_version & 0xFF);
- }
- else
- {
- xf86ErrorF(" (version 0.x)\n");
- }
- xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno);
- }
- else
- {
- /* VT_GETMODE failed, probably not syscons */
- close(fd);
- fd = -1;
- }
- }
- return fd;
-}
-
-#endif /* SYSCONS_SUPPORT */
-
-
-#ifdef PCVT_SUPPORT
-
-static int
-xf86OpenPcvt()
-{
- /* This looks much like syscons, since pcvt is API compatible */
- int fd = -1;
- vtmode_t vtmode;
- char vtname[12], *vtprefix;
- struct stat status;
- struct pcvtid pcvt_version;
-
-#ifndef __OpenBSD__
- vtprefix = "/dev/ttyv";
-#else
- vtprefix = "/dev/ttyC";
-#endif
-
- fd = open(PCVT_CONSOLE_DEV, PCVT_CONSOLE_MODE, 0);
-#ifdef WSCONS_PCVT_COMPAT_CONSOLE_DEV
- if (fd < 0)
- {
- fd = open(WSCONS_PCVT_COMPAT_CONSOLE_DEV, PCVT_CONSOLE_MODE, 0);
- vtprefix = "/dev/ttyE";
- }
-#endif
- if (fd >= 0)
- {
- if (ioctl(fd, VGAPCVTID, &pcvt_version) >= 0)
- {
- if(ioctl(fd, VT_GETMODE, &vtmode) < 0)
- {
- FatalError("%s: VT_GETMODE failed\n%s%s\n%s",
- "xf86OpenPcvt",
- "Found pcvt driver but X11 seems to be",
- " not supported.", CHECK_DRIVER_MSG);
- }
-
- xf86Info.vtno = VTnum;
-
- if (ioctl(fd, VT_GETACTIVE, &initialVT) < 0)
- initialVT = -1;
-
- if (xf86Info.vtno == -1)
- {
- if (ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0)
- {
- /* No free VTs */
- xf86Info.vtno = -1;
- }
-
- if (xf86Info.vtno == -1)
- {
- /*
- * All VTs are in use. If initialVT was found, use it.
- * Otherwise, if stdin is a VT, use that one.
- * XXX stdin is already closed, so this won't work.
- */
- if (initialVT != -1)
- {
- xf86Info.vtno = initialVT;
- }
- else if ((fstat(0, &status) >= 0)
- && S_ISCHR(status.st_mode)
- && (ioctl(0, VT_GETMODE, &vtmode) >= 0))
- {
- /* stdin is a VT */
- xf86Info.vtno = minor(status.st_rdev) + 1;
- }
- else
- {
- FatalError("%s: Cannot find a free VT",
- "xf86OpenPcvt");
- }
- }
- }
-
- close(fd);
- sprintf(vtname, "%s%01x", vtprefix, xf86Info.vtno - 1);
- if ((fd = open(vtname, PCVT_CONSOLE_MODE, 0)) < 0)
- {
- ErrorF("xf86OpenPcvt: Cannot open %s (%s)",
- vtname, strerror(errno));
- xf86Info.vtno = initialVT;
- sprintf(vtname, "%s%01x", vtprefix, xf86Info.vtno - 1);
- if ((fd = open(vtname, PCVT_CONSOLE_MODE, 0)) < 0) {
- FatalError("xf86OpenPcvt: Cannot open %s (%s)",
- vtname, strerror(errno));
- }
- }
- if (ioctl(fd, VT_GETMODE, &vtmode) < 0)
- {
- FatalError("xf86OpenPcvt: VT_GETMODE failed");
- }
- xf86Info.consType = PCVT;
-#ifdef WSCONS_SUPPORT
- xf86Msg(X_PROBED,
- "Using wscons driver on %s in pcvt compatibility mode "
- "(version %d.%d)\n", vtname,
- pcvt_version.rmajor, pcvt_version.rminor);
-#else
- xf86Msg(X_PROBED, "Using pcvt driver (version %d.%d)\n",
- pcvt_version.rmajor, pcvt_version.rminor);
-#endif
- }
- else
- {
- /* Not pcvt */
- close(fd);
- fd = -1;
- }
- }
- return fd;
-}
-
-#endif /* PCVT_SUPPORT */
-
-#ifdef WSCONS_SUPPORT
-
-static int
-xf86OpenWScons()
-{
- int fd = -1;
- int mode = WSDISPLAYIO_MODE_MAPPED;
- int i;
- char ttyname[16];
-
- /* XXX Is this ok? */
- for (i = 0; i < 8; i++) {
-#if defined(__NetBSD__)
- sprintf(ttyname, "/dev/ttyE%d", i);
-#elif defined(__OpenBSD__)
- sprintf(ttyname, "/dev/ttyC%x", i);
-#endif
- if ((fd = open(ttyname, 2)) != -1)
- break;
- }
- if (fd != -1) {
- if (ioctl(fd, WSDISPLAYIO_SMODE, &mode) < 0) {
- FatalError("%s: WSDISPLAYIO_MODE_MAPPED failed (%s)\n%s",
- "xf86OpenConsole", strerror(errno),
- CHECK_DRIVER_MSG);
- }
- xf86Info.consType = WSCONS;
- xf86Msg(X_PROBED, "Using wscons driver\n");
- }
- return fd;
-}
-
-#endif /* WSCONS_SUPPORT */
-
-void
-xf86CloseConsole()
-{
-#if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT)
- struct vt_mode VT;
-#endif
-
- if (ShareVTs) return;
-
- switch (xf86Info.consType)
- {
-#ifdef PCCONS_SUPPORT
- case PCCONS:
- ioctl (xf86Info.consoleFd, CONSOLE_X_MODE_OFF, 0);
- break;
-#endif /* PCCONS_SUPPORT */
-#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
- case SYSCONS:
- case PCVT:
- ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT); /* Back to text mode */
- if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1)
- {
- VT.mode = VT_AUTO;
- ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* dflt vt handling */
- }
-#if !defined(OpenBSD) && !defined(USE_DEV_IO) && !defined(USE_I386_IOPL)
- if (ioctl(xf86Info.consoleFd, KDDISABIO, 0) < 0)
- {
- xf86FatalError("xf86CloseConsole: KDDISABIO failed (%s)",
- strerror(errno));
- }
-#endif
- if (initialVT != -1)
- ioctl(xf86Info.consoleFd, VT_ACTIVATE, initialVT);
- break;
-#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
-#ifdef WSCONS_SUPPORT
- case WSCONS:
- {
- int mode = WSDISPLAYIO_MODE_EMUL;
- ioctl(xf86Info.screenFd, WSDISPLAYIO_SMODE, &mode);
- break;
- }
-#endif
- }
-
- if (xf86Info.screenFd != xf86Info.consoleFd)
- {
- close(xf86Info.screenFd);
- close(xf86Info.consoleFd);
- if ((xf86Info.consoleFd = open("/dev/console",O_RDONLY,0)) <0)
- {
- xf86FatalError("xf86CloseConsole: Cannot open /dev/console (%s)",
- strerror(errno));
- }
- }
- close(xf86Info.consoleFd);
- if (devConsoleFd >= 0)
- close(devConsoleFd);
- return;
-}
-
-int
-xf86ProcessArgument(int argc, char *argv[], int i)
-{
- /*
- * Keep server from detaching from controlling tty. This is useful
- * when debugging (so the server can receive keyboard signals.
- */
- if (!strcmp(argv[i], "-keeptty"))
- {
- KeepTty = TRUE;
- return 1;
- }
-#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
- if (!strcmp(argv[i], "-sharevts"))
- {
- ShareVTs = TRUE;
- return 1;
- }
- if ((argv[i][0] == 'v') && (argv[i][1] == 't'))
- {
- if (sscanf(argv[i], "vt%2d", &VTnum) == 0 ||
- VTnum < 1 || VTnum > 12)
- {
- UseMsg();
- VTnum = -1;
- return 0;
- }
- return 1;
- }
-#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
- return 0;
-}
-
-void
-xf86UseMsg()
-{
-#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
- ErrorF("vtXX use the specified VT number (1-12)\n");
- ErrorF("-sharevts share VTs with another X server\n");
-#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
- ErrorF("-keeptty ");
- ErrorF("don't detach controlling tty (for debugging only)\n");
- return;
-}
+/*
+ * Copyright 1992 by Rich Murphey <Rich@Rice.edu>
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * 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 names of Rich Murphey and David Wexelblat
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. Rich Murphey and
+ * David Wexelblat make no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT 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_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+#include <sys/utsname.h>
+#include <sys/ioctl.h>
+#include <stdlib.h>
+#include <errno.h>
+
+static Bool KeepTty = FALSE;
+static int devConsoleFd = -1;
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+static int VTnum = -1;
+static int initialVT = -1;
+static Bool ShareVTs = FALSE;
+#endif
+
+#ifdef PCCONS_SUPPORT
+/* Stock 0.1 386bsd pccons console driver interface */
+#define PCCONS_CONSOLE_DEV1 "/dev/ttyv0"
+#define PCCONS_CONSOLE_DEV2 "/dev/vga"
+#define PCCONS_CONSOLE_MODE O_RDWR|O_NDELAY
+#endif
+
+#ifdef SYSCONS_SUPPORT
+/* The FreeBSD 1.1 version syscons driver uses /dev/ttyv0 */
+#define SYSCONS_CONSOLE_DEV1 "/dev/ttyv0"
+#define SYSCONS_CONSOLE_DEV2 "/dev/vga"
+#define SYSCONS_CONSOLE_MODE O_RDWR|O_NDELAY
+#endif
+
+#ifdef PCVT_SUPPORT
+/* Hellmuth Michaelis' pcvt driver */
+#ifndef __OpenBSD__
+# define PCVT_CONSOLE_DEV "/dev/ttyv0"
+#else
+# define PCVT_CONSOLE_DEV "/dev/ttyC0"
+#endif
+#define PCVT_CONSOLE_MODE O_RDWR|O_NDELAY
+#endif
+
+#if defined(WSCONS_SUPPORT) && defined(__NetBSD__)
+/* NetBSD's new console driver */
+#define WSCONS_PCVT_COMPAT_CONSOLE_DEV "/dev/ttyE0"
+#endif
+
+#ifdef __GLIBC__
+#define setpgrp setpgid
+#endif
+
+#define CHECK_DRIVER_MSG \
+ "Check your kernel's console driver configuration and /dev entries"
+
+static char *supported_drivers[] = {
+#ifdef PCCONS_SUPPORT
+ "pccons (with X support)",
+#endif
+#ifdef SYSCONS_SUPPORT
+ "syscons",
+#endif
+#ifdef PCVT_SUPPORT
+ "pcvt",
+#endif
+#ifdef WSCONS_SUPPORT
+ "wscons",
+#endif
+};
+
+
+/*
+ * Functions to probe for the existance of a supported console driver.
+ * Any function returns either a valid file descriptor (driver probed
+ * succesfully), -1 (driver not found), or uses FatalError() if the
+ * driver was found but proved to not support the required mode to run
+ * an X server.
+ */
+
+typedef int (*xf86ConsOpen_t)(void);
+
+#ifdef PCCONS_SUPPORT
+static int xf86OpenPccons(void);
+#endif /* PCCONS_SUPPORT */
+
+#ifdef SYSCONS_SUPPORT
+static int xf86OpenSyscons(void);
+#endif /* SYSCONS_SUPPORT */
+
+#ifdef PCVT_SUPPORT
+static int xf86OpenPcvt(void);
+#endif /* PCVT_SUPPORT */
+
+#ifdef WSCONS_SUPPORT
+static int xf86OpenWScons(void);
+#endif
+
+/*
+ * The sequence of the driver probes is important; start with the
+ * driver that is best distinguishable, and end with the most generic
+ * driver. (Otherwise, pcvt would also probe as syscons, and either
+ * pcvt or syscons might succesfully probe as pccons.)
+ */
+static xf86ConsOpen_t xf86ConsTab[] = {
+#ifdef PCVT_SUPPORT
+ xf86OpenPcvt,
+#endif
+#ifdef SYSCONS_SUPPORT
+ xf86OpenSyscons,
+#endif
+#ifdef PCCONS_SUPPORT
+ xf86OpenPccons,
+#endif
+#ifdef WSCONS_SUPPORT
+ xf86OpenWScons,
+#endif
+ (xf86ConsOpen_t)NULL
+};
+
+
+void
+xf86OpenConsole()
+{
+ int i, fd = -1;
+ xf86ConsOpen_t *driver;
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ int result;
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+ struct utsname uts;
+#endif
+ vtmode_t vtmode;
+#endif
+
+ if (serverGeneration == 1)
+ {
+ /* check if we are run with euid==0 */
+ if (geteuid() != 0)
+ {
+ FatalError("xf86OpenConsole: Server must be suid root");
+ }
+
+ if (!KeepTty)
+ {
+ /*
+ * detaching the controlling tty solves problems of kbd character
+ * loss. This is not interesting for CO driver, because it is
+ * exclusive.
+ */
+ setpgrp(0, getpid());
+ if ((i = open("/dev/tty",O_RDWR)) >= 0)
+ {
+ ioctl(i,TIOCNOTTY,(char *)0);
+ close(i);
+ }
+ }
+
+ /* detect which driver we are running on */
+ for (driver = xf86ConsTab; *driver; driver++)
+ {
+ if ((fd = (*driver)()) >= 0)
+ break;
+ }
+
+ /* Check that a supported console driver was found */
+ if (fd < 0)
+ {
+ char cons_drivers[80] = {0, };
+ for (i = 0; i < sizeof(supported_drivers) / sizeof(char *); i++)
+ {
+ if (i)
+ {
+ strcat(cons_drivers, ", ");
+ }
+ strcat(cons_drivers, supported_drivers[i]);
+ }
+ FatalError(
+ "%s: No console driver found\n\tSupported drivers: %s\n\t%s",
+ "xf86OpenConsole", cons_drivers, CHECK_DRIVER_MSG);
+ }
+#if 0 /* stdin is already closed in OsInit() */
+ fclose(stdin);
+#endif
+ xf86Info.consoleFd = fd;
+ xf86Info.screenFd = fd;
+
+ switch (xf86Info.consType)
+ {
+#ifdef PCCONS_SUPPORT
+ case PCCONS:
+ if (ioctl (xf86Info.consoleFd, CONSOLE_X_MODE_ON, 0) < 0)
+ {
+ FatalError("%s: CONSOLE_X_MODE_ON failed (%s)\n%s",
+ "xf86OpenConsole", strerror(errno),
+ CHECK_DRIVER_MSG);
+ }
+ /*
+ * Hack to prevent keyboard hanging when syslogd closes
+ * /dev/console
+ */
+ if ((devConsoleFd = open("/dev/console", O_WRONLY,0)) < 0)
+ {
+ xf86Msg(X_WARNING,
+ "xf86OpenConsole: couldn't open /dev/console (%s)\n",
+ strerror(errno));
+ }
+ break;
+#endif
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ case SYSCONS:
+ /* as of FreeBSD 2.2.8, syscons driver does not need the #1 vt
+ * switching anymore. Here we check for FreeBSD 3.1 and up.
+ * Add cases for other *BSD that behave the same.
+ */
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+ uname (&uts);
+ i = atof(uts.release) * 100;
+ if (i >= 310) goto acquire_vt;
+#endif
+ /* otherwise fall through */
+ case PCVT:
+#if !(defined(__NetBSD__) && (__NetBSD_Version__ >= 200000000))
+ /*
+ * First activate the #1 VT. This is a hack to allow a server
+ * to be started while another one is active. There should be
+ * a better way.
+ */
+ if (initialVT != 1) {
+
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, 1) != 0)
+ {
+ xf86Msg(X_WARNING,
+ "xf86OpenConsole: VT_ACTIVATE failed\n");
+ }
+ sleep(1);
+ }
+#endif
+acquire_vt:
+ if (!ShareVTs) {
+ /*
+ * now get the VT
+ */
+ SYSCALL(result =
+ ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno));
+ if (result != 0)
+ {
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
+ }
+ SYSCALL(result =
+ ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno));
+ if (result != 0)
+ {
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
+ }
+
+ signal(SIGUSR1, xf86VTRequest);
+
+ vtmode.mode = VT_PROCESS;
+ vtmode.relsig = SIGUSR1;
+ vtmode.acqsig = SIGUSR1;
+ vtmode.frsig = SIGUSR1;
+ if (ioctl(xf86Info.consoleFd, VT_SETMODE, &vtmode) < 0)
+ {
+ FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed");
+ }
+ #if !defined(USE_DEV_IO) && !defined(USE_I386_IOPL)
+ if (ioctl(xf86Info.consoleFd, KDENABIO, 0) < 0)
+ {
+ FatalError("xf86OpenConsole: KDENABIO failed (%s)",
+ strerror(errno));
+ }
+ #endif
+ if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0)
+ {
+ FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed");
+ }
+ } else { /* ShareVTs */
+ close(xf86Info.consoleFd);
+ }
+ break;
+#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
+#ifdef WSCONS_SUPPORT
+ case WSCONS:
+ /* Nothing to do */
+ break;
+#endif
+ }
+ }
+ else
+ {
+ /* serverGeneration != 1 */
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ if (!ShareVTs) if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT)
+ {
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
+ {
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
+ }
+ }
+#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
+ }
+ return;
+}
+
+
+#ifdef PCCONS_SUPPORT
+
+static int
+xf86OpenPccons()
+{
+ int fd = -1;
+
+ if ((fd = open(PCCONS_CONSOLE_DEV1, PCCONS_CONSOLE_MODE, 0))
+ >= 0 ||
+ (fd = open(PCCONS_CONSOLE_DEV2, PCCONS_CONSOLE_MODE, 0))
+ >= 0)
+ {
+ if (ioctl(fd, CONSOLE_X_MODE_OFF, 0) < 0)
+ {
+ FatalError(
+ "%s: CONSOLE_X_MODE_OFF failed (%s)\n%s\n%s",
+ "xf86OpenPccons",
+ strerror(errno),
+ "Was expecting pccons driver with X support",
+ CHECK_DRIVER_MSG);
+ }
+ xf86Info.consType = PCCONS;
+ xf86Msg(X_PROBED, "Using pccons driver with X support\n");
+ }
+ return fd;
+}
+
+#endif /* PCCONS_SUPPORT */
+
+#ifdef SYSCONS_SUPPORT
+
+static int
+xf86OpenSyscons()
+{
+ int fd = -1;
+ vtmode_t vtmode;
+ char vtname[12];
+ struct stat status;
+ long syscons_version;
+ MessageType from;
+
+ /* Check for syscons */
+ if ((fd = open(SYSCONS_CONSOLE_DEV1, SYSCONS_CONSOLE_MODE, 0)) >= 0
+ || (fd = open(SYSCONS_CONSOLE_DEV2, SYSCONS_CONSOLE_MODE, 0)) >= 0)
+ {
+ if (ioctl(fd, VT_GETMODE, &vtmode) >= 0)
+ {
+ /* Get syscons version */
+ if (ioctl(fd, CONS_GETVERS, &syscons_version) < 0)
+ {
+ syscons_version = 0;
+ }
+
+ xf86Info.vtno = VTnum;
+ from = X_CMDLINE;
+
+#ifdef VT_GETACTIVE
+ if (ioctl(fd, VT_GETACTIVE, &initialVT) < 0)
+ initialVT = -1;
+#endif
+ if (ShareVTs)
+ xf86Info.vtno = initialVT;
+
+ if (xf86Info.vtno == -1)
+ {
+ /*
+ * For old syscons versions (<0x100), VT_OPENQRY returns
+ * the current VT rather than the next free VT. In this
+ * case, the server gets started on the current VT instead
+ * of the next free VT.
+ */
+
+#if 0
+ /* check for the fixed VT_OPENQRY */
+ if (syscons_version >= 0x100)
+ {
+#endif
+ if (ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0)
+ {
+ /* No free VTs */
+ xf86Info.vtno = -1;
+ }
+#if 0
+ }
+#endif
+
+ if (xf86Info.vtno == -1)
+ {
+ /*
+ * All VTs are in use. If initialVT was found, use it.
+ * Otherwise, if stdin is a VT, use that one.
+ * XXX stdin is already closed, so this won't work.
+ */
+ if (initialVT != -1)
+ {
+ xf86Info.vtno = initialVT;
+ }
+ else if ((fstat(0, &status) >= 0)
+ && S_ISCHR(status.st_mode)
+ && (ioctl(0, VT_GETMODE, &vtmode) >= 0))
+ {
+ /* stdin is a VT */
+ xf86Info.vtno = minor(status.st_rdev) + 1;
+ }
+ else
+ {
+ if (syscons_version >= 0x100)
+ {
+ FatalError("%s: Cannot find a free VT",
+ "xf86OpenSyscons");
+ }
+ /* Should no longer reach here */
+ FatalError("%s: %s %s\n\t%s %s",
+ "xf86OpenSyscons",
+ "syscons versions prior to 1.0 require",
+ "either the",
+ "server's stdin be a VT",
+ "or the use of the vtxx server option");
+ }
+ }
+ from = X_PROBED;
+ }
+
+ close(fd);
+#ifndef __OpenBSD__
+ sprintf(vtname, "/dev/ttyv%01x", xf86Info.vtno - 1);
+#else
+ sprintf(vtname, "/dev/ttyC%01x", xf86Info.vtno - 1);
+#endif
+ if ((fd = open(vtname, SYSCONS_CONSOLE_MODE, 0)) < 0)
+ {
+ FatalError("xf86OpenSyscons: Cannot open %s (%s)",
+ vtname, strerror(errno));
+ }
+ if (ioctl(fd, VT_GETMODE, &vtmode) < 0)
+ {
+ FatalError("xf86OpenSyscons: VT_GETMODE failed");
+ }
+ xf86Info.consType = SYSCONS;
+ xf86Msg(X_PROBED, "Using syscons driver with X support");
+ if (syscons_version >= 0x100)
+ {
+ xf86ErrorF(" (version %ld.%ld)\n", syscons_version >> 8,
+ syscons_version & 0xFF);
+ }
+ else
+ {
+ xf86ErrorF(" (version 0.x)\n");
+ }
+ xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno);
+ }
+ else
+ {
+ /* VT_GETMODE failed, probably not syscons */
+ close(fd);
+ fd = -1;
+ }
+ }
+ return fd;
+}
+
+#endif /* SYSCONS_SUPPORT */
+
+
+#ifdef PCVT_SUPPORT
+
+static int
+xf86OpenPcvt()
+{
+ /* This looks much like syscons, since pcvt is API compatible */
+ int fd = -1;
+ vtmode_t vtmode;
+ char vtname[12], *vtprefix;
+ struct stat status;
+ struct pcvtid pcvt_version;
+
+#ifndef __OpenBSD__
+ vtprefix = "/dev/ttyv";
+#else
+ vtprefix = "/dev/ttyC";
+#endif
+
+ fd = open(PCVT_CONSOLE_DEV, PCVT_CONSOLE_MODE, 0);
+#ifdef WSCONS_PCVT_COMPAT_CONSOLE_DEV
+ if (fd < 0)
+ {
+ fd = open(WSCONS_PCVT_COMPAT_CONSOLE_DEV, PCVT_CONSOLE_MODE, 0);
+ vtprefix = "/dev/ttyE";
+ }
+#endif
+ if (fd >= 0)
+ {
+ if (ioctl(fd, VGAPCVTID, &pcvt_version) >= 0)
+ {
+ if(ioctl(fd, VT_GETMODE, &vtmode) < 0)
+ {
+ FatalError("%s: VT_GETMODE failed\n%s%s\n%s",
+ "xf86OpenPcvt",
+ "Found pcvt driver but X11 seems to be",
+ " not supported.", CHECK_DRIVER_MSG);
+ }
+
+ xf86Info.vtno = VTnum;
+
+ if (ioctl(fd, VT_GETACTIVE, &initialVT) < 0)
+ initialVT = -1;
+
+ if (xf86Info.vtno == -1)
+ {
+ if (ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0)
+ {
+ /* No free VTs */
+ xf86Info.vtno = -1;
+ }
+
+ if (xf86Info.vtno == -1)
+ {
+ /*
+ * All VTs are in use. If initialVT was found, use it.
+ * Otherwise, if stdin is a VT, use that one.
+ * XXX stdin is already closed, so this won't work.
+ */
+ if (initialVT != -1)
+ {
+ xf86Info.vtno = initialVT;
+ }
+ else if ((fstat(0, &status) >= 0)
+ && S_ISCHR(status.st_mode)
+ && (ioctl(0, VT_GETMODE, &vtmode) >= 0))
+ {
+ /* stdin is a VT */
+ xf86Info.vtno = minor(status.st_rdev) + 1;
+ }
+ else
+ {
+ FatalError("%s: Cannot find a free VT",
+ "xf86OpenPcvt");
+ }
+ }
+ }
+
+ close(fd);
+ sprintf(vtname, "%s%01x", vtprefix, xf86Info.vtno - 1);
+ if ((fd = open(vtname, PCVT_CONSOLE_MODE, 0)) < 0)
+ {
+ ErrorF("xf86OpenPcvt: Cannot open %s (%s)",
+ vtname, strerror(errno));
+ xf86Info.vtno = initialVT;
+ sprintf(vtname, "%s%01x", vtprefix, xf86Info.vtno - 1);
+ if ((fd = open(vtname, PCVT_CONSOLE_MODE, 0)) < 0) {
+ FatalError("xf86OpenPcvt: Cannot open %s (%s)",
+ vtname, strerror(errno));
+ }
+ }
+ if (ioctl(fd, VT_GETMODE, &vtmode) < 0)
+ {
+ FatalError("xf86OpenPcvt: VT_GETMODE failed");
+ }
+ xf86Info.consType = PCVT;
+#ifdef WSCONS_SUPPORT
+ xf86Msg(X_PROBED,
+ "Using wscons driver on %s in pcvt compatibility mode "
+ "(version %d.%d)\n", vtname,
+ pcvt_version.rmajor, pcvt_version.rminor);
+#else
+ xf86Msg(X_PROBED, "Using pcvt driver (version %d.%d)\n",
+ pcvt_version.rmajor, pcvt_version.rminor);
+#endif
+ }
+ else
+ {
+ /* Not pcvt */
+ close(fd);
+ fd = -1;
+ }
+ }
+ return fd;
+}
+
+#endif /* PCVT_SUPPORT */
+
+#ifdef WSCONS_SUPPORT
+
+static int
+xf86OpenWScons()
+{
+ int fd = -1;
+ int mode = WSDISPLAYIO_MODE_MAPPED;
+ int i;
+ char ttyname[16];
+
+ /* XXX Is this ok? */
+ for (i = 0; i < 8; i++) {
+#if defined(__NetBSD__)
+ sprintf(ttyname, "/dev/ttyE%d", i);
+#elif defined(__OpenBSD__)
+ sprintf(ttyname, "/dev/ttyC%x", i);
+#endif
+ if ((fd = open(ttyname, 2)) != -1)
+ break;
+ }
+ if (fd != -1) {
+ if (ioctl(fd, WSDISPLAYIO_SMODE, &mode) < 0) {
+ FatalError("%s: WSDISPLAYIO_MODE_MAPPED failed (%s)\n%s",
+ "xf86OpenConsole", strerror(errno),
+ CHECK_DRIVER_MSG);
+ }
+ xf86Info.consType = WSCONS;
+ xf86Msg(X_PROBED, "Using wscons driver\n");
+ }
+ return fd;
+}
+
+#endif /* WSCONS_SUPPORT */
+
+void
+xf86CloseConsole()
+{
+#if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT)
+ struct vt_mode VT;
+#endif
+
+ if (ShareVTs) return;
+
+ switch (xf86Info.consType)
+ {
+#ifdef PCCONS_SUPPORT
+ case PCCONS:
+ ioctl (xf86Info.consoleFd, CONSOLE_X_MODE_OFF, 0);
+ break;
+#endif /* PCCONS_SUPPORT */
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ case SYSCONS:
+ case PCVT:
+ ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT); /* Back to text mode */
+ if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1)
+ {
+ VT.mode = VT_AUTO;
+ ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* dflt vt handling */
+ }
+#if !defined(OpenBSD) && !defined(USE_DEV_IO) && !defined(USE_I386_IOPL)
+ if (ioctl(xf86Info.consoleFd, KDDISABIO, 0) < 0)
+ {
+ xf86FatalError("xf86CloseConsole: KDDISABIO failed (%s)",
+ strerror(errno));
+ }
+#endif
+ if (initialVT != -1)
+ ioctl(xf86Info.consoleFd, VT_ACTIVATE, initialVT);
+ break;
+#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
+#ifdef WSCONS_SUPPORT
+ case WSCONS:
+ {
+ int mode = WSDISPLAYIO_MODE_EMUL;
+ ioctl(xf86Info.screenFd, WSDISPLAYIO_SMODE, &mode);
+ break;
+ }
+#endif
+ }
+
+ if (xf86Info.screenFd != xf86Info.consoleFd)
+ {
+ close(xf86Info.screenFd);
+ close(xf86Info.consoleFd);
+ if ((xf86Info.consoleFd = open("/dev/console",O_RDONLY,0)) <0)
+ {
+ xf86FatalError("xf86CloseConsole: Cannot open /dev/console (%s)",
+ strerror(errno));
+ }
+ }
+ close(xf86Info.consoleFd);
+ if (devConsoleFd >= 0)
+ close(devConsoleFd);
+ return;
+}
+
+int
+xf86ProcessArgument(int argc, char *argv[], int i)
+{
+ /*
+ * Keep server from detaching from controlling tty. This is useful
+ * when debugging (so the server can receive keyboard signals.
+ */
+ if (!strcmp(argv[i], "-keeptty"))
+ {
+ KeepTty = TRUE;
+ return 1;
+ }
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ if (!strcmp(argv[i], "-sharevts"))
+ {
+ ShareVTs = TRUE;
+ return 1;
+ }
+ if ((argv[i][0] == 'v') && (argv[i][1] == 't'))
+ {
+ if (sscanf(argv[i], "vt%2d", &VTnum) == 0 ||
+ VTnum < 1 || VTnum > 12)
+ {
+ UseMsg();
+ VTnum = -1;
+ return 0;
+ }
+ return 1;
+ }
+#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
+ return 0;
+}
+
+void
+xf86UseMsg()
+{
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ ErrorF("vtXX use the specified VT number (1-12)\n");
+ ErrorF("-sharevts share VTs with another X server\n");
+#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
+ ErrorF("-keeptty ");
+ ErrorF("don't detach controlling tty (for debugging only)\n");
+ return;
+}
diff --git a/xorg-server/hw/xfree86/os-support/linux/lnx_init.c b/xorg-server/hw/xfree86/os-support/linux/lnx_init.c
index 647c05c3a..77dfb2f16 100644
--- a/xorg-server/hw/xfree86/os-support/linux/lnx_init.c
+++ b/xorg-server/hw/xfree86/os-support/linux/lnx_init.c
@@ -1,345 +1,345 @@
-/*
- * Copyright 1992 by Orest Zborowski <obz@Kodak.com>
- * Copyright 1993 by David Wexelblat <dwex@goblin.org>
- *
- * 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 names of Orest Zborowski and David Wexelblat
- * not be used in advertising or publicity pertaining to distribution of
- * the software without specific, written prior permission. Orest Zborowski
- * and David Wexelblat make no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
- * implied warranty.
- *
- * OREST ZBOROWSKI AND DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD
- * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS, IN NO EVENT SHALL OREST ZBOROWSKI OR DAVID WEXELBLAT 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_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xmd.h>
-
-#include "compiler.h"
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-
-#include <sys/stat.h>
-
-static Bool KeepTty = FALSE;
-static Bool VTSwitch = TRUE;
-static Bool ShareVTs = FALSE;
-static int activeVT = -1;
-
-static char vtname[11];
-static struct termios tty_attr; /* tty state to restore */
-static int tty_mode; /* kbd mode to restore */
-
-static void *console_handler;
-
-static void
-drain_console(int fd, void *closure)
-{
- errno = 0;
- if (tcflush(fd, TCIOFLUSH) == -1 && errno == EIO) {
- xf86RemoveGeneralHandler(console_handler);
- console_handler = NULL;
- }
-}
-
-static void
-switch_to(int vt, const char *from)
-{
- int ret;
-
- SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_ACTIVATE, vt));
- if (ret < 0)
- FatalError("%s: VT_ACTIVATE failed: %s\n", from, strerror(errno));
-
- SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_WAITACTIVE, vt));
- if (ret < 0)
- FatalError("%s: VT_WAITACTIVE failed: %s\n", from, strerror(errno));
-}
-
-void
-xf86OpenConsole(void)
-{
- int i, fd = -1, ret;
- struct vt_mode VT;
- struct vt_stat vts;
- MessageType from = X_PROBED;
- char *tty0[] = { "/dev/tty0", "/dev/vc/0", NULL };
- char *vcs[] = { "/dev/vc/%d", "/dev/tty%d", NULL };
-
- if (serverGeneration == 1) {
-
- /* when KeepTty check if we're run with euid==0 */
- if (KeepTty && geteuid() != 0)
- FatalError("xf86OpenConsole:"
- " Server must be suid root for option \"KeepTTY\"\n");
-
- /*
- * setup the virtual terminal manager
- */
- if (xf86Info.vtno != -1) {
- from = X_CMDLINE;
- } else {
-
- i=0;
- while (tty0[i] != NULL) {
- if ((fd = open(tty0[i],O_WRONLY,0)) >= 0)
- break;
- i++;
- }
-
- if (fd < 0)
- FatalError(
- "xf86OpenConsole: Cannot open /dev/tty0 (%s)\n",
- strerror(errno));
-
- if (ShareVTs)
- {
- SYSCALL(ret = ioctl(fd, VT_GETSTATE, &vts));
- if (ret < 0)
- FatalError("xf86OpenConsole: Cannot find the current"
- " VT (%s)\n", strerror(errno));
- xf86Info.vtno = vts.v_active;
- } else {
- SYSCALL(ret = ioctl(fd, VT_OPENQRY, &xf86Info.vtno));
- if (ret < 0)
- FatalError("xf86OpenConsole: Cannot find a free VT: "
- "%s\n", strerror(errno));
- if (xf86Info.vtno == -1)
- FatalError("xf86OpenConsole: Cannot find a free VT\n");
- }
- close(fd);
- }
-
- xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno);
-
- if (!KeepTty) {
- pid_t ppid = getppid();
- pid_t ppgid;
- ppgid = getpgid(ppid);
-
- /*
- * change to parent process group that pgid != pid so
- * that setsid() doesn't fail and we become process
- * group leader
- */
- if (setpgid(0,ppgid) < 0)
- xf86Msg(X_WARNING, "xf86OpenConsole: setpgid failed: %s\n",
- strerror(errno));
-
- /* become process group leader */
- if ((setsid() < 0))
- xf86Msg(X_WARNING, "xf86OpenConsole: setsid failed: %s\n",
- strerror(errno));
- }
-
- i=0;
- while (vcs[i] != NULL) {
- sprintf(vtname, vcs[i], xf86Info.vtno); /* /dev/tty1-64 */
- if ((xf86Info.consoleFd = open(vtname, O_RDWR|O_NDELAY, 0)) >= 0)
- break;
- i++;
- }
-
- if (xf86Info.consoleFd < 0)
- FatalError("xf86OpenConsole: Cannot open virtual console"
- " %d (%s)\n", xf86Info.vtno, strerror(errno));
-
- /*
- * Linux doesn't switch to an active vt after the last close of a vt,
- * so we do this ourselves by remembering which is active now.
- */
- SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_GETSTATE, &vts));
- if (ret < 0)
- xf86Msg(X_WARNING,"xf86OpenConsole: VT_GETSTATE failed: %s\n",
- strerror(errno));
- else
- activeVT = vts.v_active;
-
-#if 0
- if (!KeepTty) {
- /*
- * Detach from the controlling tty to avoid char loss
- */
- if ((i = open("/dev/tty",O_RDWR)) >= 0) {
- SYSCALL(ioctl(i, TIOCNOTTY, 0));
- close(i);
- }
- }
-#endif
-
- if (!ShareVTs)
- {
- struct termios nTty;
-
- /*
- * now get the VT. This _must_ succeed, or else fail completely.
- */
- switch_to(xf86Info.vtno, "xf86OpenConsole");
-
- SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_GETMODE, &VT));
- if (ret < 0)
- FatalError("xf86OpenConsole: VT_GETMODE failed %s\n",
- strerror(errno));
-
- signal(SIGUSR1, xf86VTRequest);
-
- VT.mode = VT_PROCESS;
- VT.relsig = SIGUSR1;
- VT.acqsig = SIGUSR1;
-
- SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_SETMODE, &VT));
- if (ret < 0)
- FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed: %s\n",
- strerror(errno));
-
- SYSCALL(ret = ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS));
- if (ret < 0)
- FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed %s\n",
- strerror(errno));
-
- tcgetattr(xf86Info.consoleFd, &tty_attr);
- SYSCALL(ioctl(xf86Info.consoleFd, KDGKBMODE, &tty_mode));
-
- SYSCALL(ret = ioctl(xf86Info.consoleFd, KDSKBMODE, K_RAW));
- if (ret < 0)
- FatalError("xf86OpenConsole: KDSKBMODE K_RAW failed %s\n",
- strerror(errno));
-
- nTty = tty_attr;
- nTty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
- nTty.c_oflag = 0;
- nTty.c_cflag = CREAD | CS8;
- nTty.c_lflag = 0;
- nTty.c_cc[VTIME]=0;
- nTty.c_cc[VMIN]=1;
- cfsetispeed(&nTty, 9600);
- cfsetospeed(&nTty, 9600);
- tcsetattr(xf86Info.consoleFd, TCSANOW, &nTty);
-
- /* need to keep the buffer clean, else the kernel gets angry */
- xf86SetConsoleHandler(drain_console, NULL);
-
- /* we really should have a InitOSInputDevices() function instead
- * of Init?$#*&Device(). So I just place it here */
- }
- } else { /* serverGeneration != 1 */
- if (!ShareVTs && VTSwitch)
- {
- /* now get the VT */
- switch_to(xf86Info.vtno, "xf86OpenConsole");
- }
- }
-}
-
-void
-xf86CloseConsole(void)
-{
- struct vt_mode VT;
- int ret;
-
- if (ShareVTs) {
- close(xf86Info.consoleFd);
- return;
- }
-
- if (console_handler) {
- xf86RemoveGeneralHandler(console_handler);
- console_handler = NULL;
- };
-
- /* Back to text mode ... */
- SYSCALL(ret = ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT));
- if (ret < 0)
- xf86Msg(X_WARNING, "xf86CloseConsole: KDSETMODE failed: %s\n",
- strerror(errno));
-
- SYSCALL(ioctl(xf86Info.consoleFd, KDSKBMODE, tty_mode));
- tcsetattr(xf86Info.consoleFd, TCSANOW, &tty_attr);
-
- SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_GETMODE, &VT));
- if (ret < 0)
- xf86Msg(X_WARNING, "xf86CloseConsole: VT_GETMODE failed: %s\n",
- strerror(errno));
- else {
- /* set dflt vt handling */
- VT.mode = VT_AUTO;
- SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_SETMODE, &VT));
- if (ret < 0)
- xf86Msg(X_WARNING, "xf86CloseConsole: VT_SETMODE failed: %s\n",
- strerror(errno));
- }
-
- if (VTSwitch)
- {
- /*
- * Perform a switch back to the active VT when we were started
- */
- if (activeVT >= 0) {
- switch_to(activeVT, "xf86CloseConsole");
- activeVT = -1;
- }
- }
- close(xf86Info.consoleFd); /* make the vt-manager happy */
-}
-
-int
-xf86ProcessArgument(int argc, char *argv[], int i)
-{
- /*
- * Keep server from detaching from controlling tty. This is useful
- * when debugging (so the server can receive keyboard signals.
- */
- if (!strcmp(argv[i], "-keeptty"))
- {
- KeepTty = TRUE;
- return 1;
- }
- if (!strcmp(argv[i], "-novtswitch"))
- {
- VTSwitch = FALSE;
- return 1;
- }
- if (!strcmp(argv[i], "-sharevts"))
- {
- ShareVTs = TRUE;
- return 1;
- }
- if ((argv[i][0] == 'v') && (argv[i][1] == 't'))
- {
- if (sscanf(argv[i], "vt%2d", &xf86Info.vtno) == 0)
- {
- UseMsg();
- xf86Info.vtno = -1;
- return 0;
- }
- return 1;
- }
- return 0;
-}
-
-void
-xf86UseMsg(void)
-{
- ErrorF("vtXX use the specified VT number\n");
- ErrorF("-keeptty ");
- ErrorF("don't detach controlling tty (for debugging only)\n");
- ErrorF("-novtswitch don't immediately switch to new VT\n");
- ErrorF("-sharevts share VTs with another X server\n");
-}
+/*
+ * Copyright 1992 by Orest Zborowski <obz@Kodak.com>
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * 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 names of Orest Zborowski and David Wexelblat
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. Orest Zborowski
+ * and David Wexelblat make no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * OREST ZBOROWSKI AND DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL OREST ZBOROWSKI OR DAVID WEXELBLAT 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_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+#include <sys/stat.h>
+
+static Bool KeepTty = FALSE;
+static Bool VTSwitch = TRUE;
+static Bool ShareVTs = FALSE;
+static int activeVT = -1;
+
+static char vtname[11];
+static struct termios tty_attr; /* tty state to restore */
+static int tty_mode; /* kbd mode to restore */
+
+static void *console_handler;
+
+static void
+drain_console(int fd, void *closure)
+{
+ errno = 0;
+ if (tcflush(fd, TCIOFLUSH) == -1 && errno == EIO) {
+ xf86RemoveGeneralHandler(console_handler);
+ console_handler = NULL;
+ }
+}
+
+static void
+switch_to(int vt, const char *from)
+{
+ int ret;
+
+ SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_ACTIVATE, vt));
+ if (ret < 0)
+ FatalError("%s: VT_ACTIVATE failed: %s\n", from, strerror(errno));
+
+ SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_WAITACTIVE, vt));
+ if (ret < 0)
+ FatalError("%s: VT_WAITACTIVE failed: %s\n", from, strerror(errno));
+}
+
+void
+xf86OpenConsole(void)
+{
+ int i, fd = -1, ret;
+ struct vt_mode VT;
+ struct vt_stat vts;
+ MessageType from = X_PROBED;
+ char *tty0[] = { "/dev/tty0", "/dev/vc/0", NULL };
+ char *vcs[] = { "/dev/vc/%d", "/dev/tty%d", NULL };
+
+ if (serverGeneration == 1) {
+
+ /* when KeepTty check if we're run with euid==0 */
+ if (KeepTty && geteuid() != 0)
+ FatalError("xf86OpenConsole:"
+ " Server must be suid root for option \"KeepTTY\"\n");
+
+ /*
+ * setup the virtual terminal manager
+ */
+ if (xf86Info.vtno != -1) {
+ from = X_CMDLINE;
+ } else {
+
+ i=0;
+ while (tty0[i] != NULL) {
+ if ((fd = open(tty0[i],O_WRONLY,0)) >= 0)
+ break;
+ i++;
+ }
+
+ if (fd < 0)
+ FatalError(
+ "xf86OpenConsole: Cannot open /dev/tty0 (%s)\n",
+ strerror(errno));
+
+ if (ShareVTs)
+ {
+ SYSCALL(ret = ioctl(fd, VT_GETSTATE, &vts));
+ if (ret < 0)
+ FatalError("xf86OpenConsole: Cannot find the current"
+ " VT (%s)\n", strerror(errno));
+ xf86Info.vtno = vts.v_active;
+ } else {
+ SYSCALL(ret = ioctl(fd, VT_OPENQRY, &xf86Info.vtno));
+ if (ret < 0)
+ FatalError("xf86OpenConsole: Cannot find a free VT: "
+ "%s\n", strerror(errno));
+ if (xf86Info.vtno == -1)
+ FatalError("xf86OpenConsole: Cannot find a free VT\n");
+ }
+ close(fd);
+ }
+
+ xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno);
+
+ if (!KeepTty) {
+ pid_t ppid = getppid();
+ pid_t ppgid;
+ ppgid = getpgid(ppid);
+
+ /*
+ * change to parent process group that pgid != pid so
+ * that setsid() doesn't fail and we become process
+ * group leader
+ */
+ if (setpgid(0,ppgid) < 0)
+ xf86Msg(X_WARNING, "xf86OpenConsole: setpgid failed: %s\n",
+ strerror(errno));
+
+ /* become process group leader */
+ if ((setsid() < 0))
+ xf86Msg(X_WARNING, "xf86OpenConsole: setsid failed: %s\n",
+ strerror(errno));
+ }
+
+ i=0;
+ while (vcs[i] != NULL) {
+ sprintf(vtname, vcs[i], xf86Info.vtno); /* /dev/tty1-64 */
+ if ((xf86Info.consoleFd = open(vtname, O_RDWR|O_NDELAY, 0)) >= 0)
+ break;
+ i++;
+ }
+
+ if (xf86Info.consoleFd < 0)
+ FatalError("xf86OpenConsole: Cannot open virtual console"
+ " %d (%s)\n", xf86Info.vtno, strerror(errno));
+
+ /*
+ * Linux doesn't switch to an active vt after the last close of a vt,
+ * so we do this ourselves by remembering which is active now.
+ */
+ SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_GETSTATE, &vts));
+ if (ret < 0)
+ xf86Msg(X_WARNING,"xf86OpenConsole: VT_GETSTATE failed: %s\n",
+ strerror(errno));
+ else
+ activeVT = vts.v_active;
+
+#if 0
+ if (!KeepTty) {
+ /*
+ * Detach from the controlling tty to avoid char loss
+ */
+ if ((i = open("/dev/tty",O_RDWR)) >= 0) {
+ SYSCALL(ioctl(i, TIOCNOTTY, 0));
+ close(i);
+ }
+ }
+#endif
+
+ if (!ShareVTs)
+ {
+ struct termios nTty;
+
+ /*
+ * now get the VT. This _must_ succeed, or else fail completely.
+ */
+ switch_to(xf86Info.vtno, "xf86OpenConsole");
+
+ SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_GETMODE, &VT));
+ if (ret < 0)
+ FatalError("xf86OpenConsole: VT_GETMODE failed %s\n",
+ strerror(errno));
+
+ signal(SIGUSR1, xf86VTRequest);
+
+ VT.mode = VT_PROCESS;
+ VT.relsig = SIGUSR1;
+ VT.acqsig = SIGUSR1;
+
+ SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_SETMODE, &VT));
+ if (ret < 0)
+ FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed: %s\n",
+ strerror(errno));
+
+ SYSCALL(ret = ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS));
+ if (ret < 0)
+ FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed %s\n",
+ strerror(errno));
+
+ tcgetattr(xf86Info.consoleFd, &tty_attr);
+ SYSCALL(ioctl(xf86Info.consoleFd, KDGKBMODE, &tty_mode));
+
+ SYSCALL(ret = ioctl(xf86Info.consoleFd, KDSKBMODE, K_RAW));
+ if (ret < 0)
+ FatalError("xf86OpenConsole: KDSKBMODE K_RAW failed %s\n",
+ strerror(errno));
+
+ nTty = tty_attr;
+ nTty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
+ nTty.c_oflag = 0;
+ nTty.c_cflag = CREAD | CS8;
+ nTty.c_lflag = 0;
+ nTty.c_cc[VTIME]=0;
+ nTty.c_cc[VMIN]=1;
+ cfsetispeed(&nTty, 9600);
+ cfsetospeed(&nTty, 9600);
+ tcsetattr(xf86Info.consoleFd, TCSANOW, &nTty);
+
+ /* need to keep the buffer clean, else the kernel gets angry */
+ xf86SetConsoleHandler(drain_console, NULL);
+
+ /* we really should have a InitOSInputDevices() function instead
+ * of Init?$#*&Device(). So I just place it here */
+ }
+ } else { /* serverGeneration != 1 */
+ if (!ShareVTs && VTSwitch)
+ {
+ /* now get the VT */
+ switch_to(xf86Info.vtno, "xf86OpenConsole");
+ }
+ }
+}
+
+void
+xf86CloseConsole(void)
+{
+ struct vt_mode VT;
+ int ret;
+
+ if (ShareVTs) {
+ close(xf86Info.consoleFd);
+ return;
+ }
+
+ if (console_handler) {
+ xf86RemoveGeneralHandler(console_handler);
+ console_handler = NULL;
+ };
+
+ /* Back to text mode ... */
+ SYSCALL(ret = ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT));
+ if (ret < 0)
+ xf86Msg(X_WARNING, "xf86CloseConsole: KDSETMODE failed: %s\n",
+ strerror(errno));
+
+ SYSCALL(ioctl(xf86Info.consoleFd, KDSKBMODE, tty_mode));
+ tcsetattr(xf86Info.consoleFd, TCSANOW, &tty_attr);
+
+ SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_GETMODE, &VT));
+ if (ret < 0)
+ xf86Msg(X_WARNING, "xf86CloseConsole: VT_GETMODE failed: %s\n",
+ strerror(errno));
+ else {
+ /* set dflt vt handling */
+ VT.mode = VT_AUTO;
+ SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_SETMODE, &VT));
+ if (ret < 0)
+ xf86Msg(X_WARNING, "xf86CloseConsole: VT_SETMODE failed: %s\n",
+ strerror(errno));
+ }
+
+ if (VTSwitch)
+ {
+ /*
+ * Perform a switch back to the active VT when we were started
+ */
+ if (activeVT >= 0) {
+ switch_to(activeVT, "xf86CloseConsole");
+ activeVT = -1;
+ }
+ }
+ close(xf86Info.consoleFd); /* make the vt-manager happy */
+}
+
+int
+xf86ProcessArgument(int argc, char *argv[], int i)
+{
+ /*
+ * Keep server from detaching from controlling tty. This is useful
+ * when debugging (so the server can receive keyboard signals.
+ */
+ if (!strcmp(argv[i], "-keeptty"))
+ {
+ KeepTty = TRUE;
+ return 1;
+ }
+ if (!strcmp(argv[i], "-novtswitch"))
+ {
+ VTSwitch = FALSE;
+ return 1;
+ }
+ if (!strcmp(argv[i], "-sharevts"))
+ {
+ ShareVTs = TRUE;
+ return 1;
+ }
+ if ((argv[i][0] == 'v') && (argv[i][1] == 't'))
+ {
+ if (sscanf(argv[i], "vt%2d", &xf86Info.vtno) == 0)
+ {
+ UseMsg();
+ xf86Info.vtno = -1;
+ return 0;
+ }
+ return 1;
+ }
+ return 0;
+}
+
+void
+xf86UseMsg(void)
+{
+ ErrorF("vtXX use the specified VT number\n");
+ ErrorF("-keeptty ");
+ ErrorF("don't detach controlling tty (for debugging only)\n");
+ ErrorF("-novtswitch don't immediately switch to new VT\n");
+ ErrorF("-sharevts share VTs with another X server\n");
+}
diff --git a/xorg-server/hw/xfree86/ramdac/xf86Cursor.c b/xorg-server/hw/xfree86/ramdac/xf86Cursor.c
index 6eab1a3dd..24c91cc37 100644
--- a/xorg-server/hw/xfree86/ramdac/xf86Cursor.c
+++ b/xorg-server/hw/xfree86/ramdac/xf86Cursor.c
@@ -1,475 +1,475 @@
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86.h"
-#include "xf86CursorPriv.h"
-#include "colormapst.h"
-#include "cursorstr.h"
-
-/* FIXME: This was added with the ABI change of the miPointerSpriteFuncs for
- * MPX.
- * inputInfo is needed to pass the core pointer as the default argument into
- * the cursor functions.
- *
- * Externing inputInfo is not the nice way to do it but it works.
- */
-#include "inputstr.h"
-extern InputInfo inputInfo;
-
-DevPrivateKeyRec xf86CursorScreenKeyRec;
-
-/* sprite functions */
-
-static Bool xf86CursorRealizeCursor(DeviceIntPtr, ScreenPtr, CursorPtr);
-static Bool xf86CursorUnrealizeCursor(DeviceIntPtr, ScreenPtr, CursorPtr);
-static void xf86CursorSetCursor(DeviceIntPtr, ScreenPtr, CursorPtr, int, int);
-static void xf86CursorMoveCursor(DeviceIntPtr, ScreenPtr, int, int);
-static Bool xf86DeviceCursorInitialize(DeviceIntPtr, ScreenPtr);
-static void xf86DeviceCursorCleanup(DeviceIntPtr, ScreenPtr);
-
-static miPointerSpriteFuncRec xf86CursorSpriteFuncs = {
- xf86CursorRealizeCursor,
- xf86CursorUnrealizeCursor,
- xf86CursorSetCursor,
- xf86CursorMoveCursor,
- xf86DeviceCursorInitialize,
- xf86DeviceCursorCleanup
-};
-
-/* Screen functions */
-
-static void xf86CursorInstallColormap(ColormapPtr);
-static void xf86CursorRecolorCursor(DeviceIntPtr pDev, ScreenPtr, CursorPtr, Bool);
-static Bool xf86CursorCloseScreen(int, ScreenPtr);
-static void xf86CursorQueryBestSize(int, unsigned short*, unsigned short*,
- ScreenPtr);
-
-/* ScrnInfoRec functions */
-
-static void xf86CursorEnableDisableFBAccess(int, Bool);
-static Bool xf86CursorSwitchMode(int, DisplayModePtr,int);
-
-Bool
-xf86InitCursor(
- ScreenPtr pScreen,
- xf86CursorInfoPtr infoPtr
-)
-{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- xf86CursorScreenPtr ScreenPriv;
- miPointerScreenPtr PointPriv;
-
- if (!xf86InitHardwareCursor(pScreen, infoPtr))
- return FALSE;
-
- if (!dixRegisterPrivateKey(&xf86CursorScreenKeyRec, PRIVATE_SCREEN, 0))
- return FALSE;
-
- ScreenPriv = calloc(1, sizeof(xf86CursorScreenRec));
- if (!ScreenPriv)
- return FALSE;
-
- dixSetPrivate(&pScreen->devPrivates, xf86CursorScreenKey, ScreenPriv);
-
- ScreenPriv->SWCursor = TRUE;
- ScreenPriv->isUp = FALSE;
- ScreenPriv->CurrentCursor = NULL;
- ScreenPriv->CursorInfoPtr = infoPtr;
- ScreenPriv->PalettedCursor = FALSE;
- ScreenPriv->pInstalledMap = NULL;
-
- ScreenPriv->CloseScreen = pScreen->CloseScreen;
- pScreen->CloseScreen = xf86CursorCloseScreen;
- ScreenPriv->QueryBestSize = pScreen->QueryBestSize;
- pScreen->QueryBestSize = xf86CursorQueryBestSize;
- ScreenPriv->RecolorCursor = pScreen->RecolorCursor;
- pScreen->RecolorCursor = xf86CursorRecolorCursor;
-
- if ((infoPtr->pScrn->bitsPerPixel == 8) &&
- !(infoPtr->Flags & HARDWARE_CURSOR_TRUECOLOR_AT_8BPP)) {
- ScreenPriv->InstallColormap = pScreen->InstallColormap;
- pScreen->InstallColormap = xf86CursorInstallColormap;
- ScreenPriv->PalettedCursor = TRUE;
- }
-
- PointPriv = dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey);
-
- ScreenPriv->showTransparent = PointPriv->showTransparent;
- if (infoPtr->Flags & HARDWARE_CURSOR_SHOW_TRANSPARENT)
- PointPriv->showTransparent = TRUE;
- else
- PointPriv->showTransparent = FALSE;
- ScreenPriv->spriteFuncs = PointPriv->spriteFuncs;
- PointPriv->spriteFuncs = &xf86CursorSpriteFuncs;
-
- ScreenPriv->EnableDisableFBAccess = pScrn->EnableDisableFBAccess;
- ScreenPriv->SwitchMode = pScrn->SwitchMode;
-
- ScreenPriv->ForceHWCursorCount = 0;
- ScreenPriv->HWCursorForced = FALSE;
-
- pScrn->EnableDisableFBAccess = xf86CursorEnableDisableFBAccess;
- if (pScrn->SwitchMode)
- pScrn->SwitchMode = xf86CursorSwitchMode;
-
- return TRUE;
-}
-
-/***** Screen functions *****/
-
-static Bool
-xf86CursorCloseScreen(int i, ScreenPtr pScreen)
-{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- miPointerScreenPtr PointPriv = (miPointerScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, miPointerScreenKey);
- xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, xf86CursorScreenKey);
-
- if (ScreenPriv->isUp && pScrn->vtSema)
- xf86SetCursor(pScreen, NullCursor, ScreenPriv->x, ScreenPriv->y);
-
- if (ScreenPriv->CurrentCursor)
- FreeCursor(ScreenPriv->CurrentCursor, None);
-
- pScreen->CloseScreen = ScreenPriv->CloseScreen;
- pScreen->QueryBestSize = ScreenPriv->QueryBestSize;
- pScreen->RecolorCursor = ScreenPriv->RecolorCursor;
- if (ScreenPriv->InstallColormap)
- pScreen->InstallColormap = ScreenPriv->InstallColormap;
-
- PointPriv->spriteFuncs = ScreenPriv->spriteFuncs;
- PointPriv->showTransparent = ScreenPriv->showTransparent;
-
- pScrn->EnableDisableFBAccess = ScreenPriv->EnableDisableFBAccess;
- pScrn->SwitchMode = ScreenPriv->SwitchMode;
-
- free(ScreenPriv->transparentData);
- free(ScreenPriv);
-
- return (*pScreen->CloseScreen)(i, pScreen);
-}
-
-static void
-xf86CursorQueryBestSize(
- int class,
- unsigned short *width,
- unsigned short *height,
- ScreenPtr pScreen)
-{
- xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, xf86CursorScreenKey);
-
- if (class == CursorShape) {
- if(*width > ScreenPriv->CursorInfoPtr->MaxWidth)
- *width = ScreenPriv->CursorInfoPtr->MaxWidth;
- if(*height > ScreenPriv->CursorInfoPtr->MaxHeight)
- *height = ScreenPriv->CursorInfoPtr->MaxHeight;
- } else
- (*ScreenPriv->QueryBestSize)(class, width, height, pScreen);
-}
-
-static void
-xf86CursorInstallColormap(ColormapPtr pMap)
-{
- xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
- &pMap->pScreen->devPrivates, xf86CursorScreenKey);
-
- ScreenPriv->pInstalledMap = pMap;
-
- (*ScreenPriv->InstallColormap)(pMap);
-}
-
-static void
-xf86CursorRecolorCursor(
- DeviceIntPtr pDev,
- ScreenPtr pScreen,
- CursorPtr pCurs,
- Bool displayed)
-{
- xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, xf86CursorScreenKey);
-
- if (!displayed)
- return;
-
- if (ScreenPriv->SWCursor)
- (*ScreenPriv->RecolorCursor)(pDev, pScreen, pCurs, displayed);
- else
- xf86RecolorCursor(pScreen, pCurs, displayed);
-}
-
-/***** ScrnInfoRec functions *********/
-
-static void
-xf86CursorEnableDisableFBAccess(
- int index,
- Bool enable)
-{
- DeviceIntPtr pDev = inputInfo.pointer;
-
- ScreenPtr pScreen = screenInfo.screens[index];
- xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, xf86CursorScreenKey);
-
- if (!enable && ScreenPriv->CurrentCursor != NullCursor) {
- CursorPtr currentCursor = ScreenPriv->CurrentCursor;
- xf86CursorSetCursor(pDev, pScreen, NullCursor, ScreenPriv->x,
- ScreenPriv->y);
- ScreenPriv->isUp = FALSE;
- ScreenPriv->SWCursor = TRUE;
- ScreenPriv->SavedCursor = currentCursor;
- }
-
- if (ScreenPriv->EnableDisableFBAccess)
- (*ScreenPriv->EnableDisableFBAccess)(index, enable);
-
- if (enable && ScreenPriv->SavedCursor)
- {
- /*
- * Re-set current cursor so drivers can react to FB access having been
- * temporarily disabled.
- */
- xf86CursorSetCursor(pDev, pScreen, ScreenPriv->SavedCursor,
- ScreenPriv->x, ScreenPriv->y);
- ScreenPriv->SavedCursor = NULL;
- }
-}
-
-static Bool
-xf86CursorSwitchMode(int index, DisplayModePtr mode, int flags)
-{
- Bool ret;
- ScreenPtr pScreen = screenInfo.screens[index];
- xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, xf86CursorScreenKey);
-
- if (ScreenPriv->isUp) {
- xf86SetCursor(pScreen, NullCursor, ScreenPriv->x, ScreenPriv->y);
- ScreenPriv->isUp = FALSE;
- }
-
- ret = (*ScreenPriv->SwitchMode)(index, mode, flags);
-
- /*
- * Cannot restore cursor here because the new frame[XY][01] haven't been
- * calculated yet. However, because the hardware cursor was removed above,
- * ensure the cursor is repainted by miPointerWarpCursor().
- */
- ScreenPriv->CursorToRestore = ScreenPriv->CurrentCursor;
- miPointerSetWaitForUpdate(pScreen, FALSE); /* Force cursor repaint */
-
- return ret;
-}
-
-/****** miPointerSpriteFunctions *******/
-
-static Bool
-xf86CursorRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCurs)
-{
- xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, xf86CursorScreenKey);
-
- if (pCurs->refcnt <= 1)
- dixSetPrivate(&pCurs->devPrivates, CursorScreenKey(pScreen), NULL);
-
- return (*ScreenPriv->spriteFuncs->RealizeCursor)(pDev, pScreen, pCurs);
-}
-
-static Bool
-xf86CursorUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
- CursorPtr pCurs)
-{
- xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, xf86CursorScreenKey);
-
- if (pCurs->refcnt <= 1) {
- free(dixLookupPrivate(&pCurs->devPrivates, CursorScreenKey(pScreen)));
- dixSetPrivate(&pCurs->devPrivates, CursorScreenKey(pScreen), NULL);
- }
-
- return (*ScreenPriv->spriteFuncs->UnrealizeCursor)(pDev, pScreen, pCurs);
-}
-
-static void
-xf86CursorSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCurs,
- int x, int y)
-{
- xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, xf86CursorScreenKey);
- xf86CursorInfoPtr infoPtr = ScreenPriv->CursorInfoPtr;
-
- if (pCurs == NullCursor) { /* means we're supposed to remove the cursor */
- if (ScreenPriv->SWCursor ||
- !(GetMaster(pDev, MASTER_POINTER) == inputInfo.pointer))
- (*ScreenPriv->spriteFuncs->SetCursor)(pDev, pScreen, NullCursor, x, y);
- else if (ScreenPriv->isUp) {
- xf86SetCursor(pScreen, NullCursor, x, y);
- ScreenPriv->isUp = FALSE;
- }
- if (ScreenPriv->CurrentCursor)
- FreeCursor(ScreenPriv->CurrentCursor, None);
- ScreenPriv->CurrentCursor = NullCursor;
- return;
- }
-
- /* only update for VCP, otherwise we get cursor jumps when removing a
- sprite. The second cursor is never HW rendered anyway. */
- if (GetMaster(pDev, MASTER_POINTER) == inputInfo.pointer)
- {
- pCurs->refcnt++;
- if (ScreenPriv->CurrentCursor)
- FreeCursor(ScreenPriv->CurrentCursor, None);
- ScreenPriv->CurrentCursor = pCurs;
- ScreenPriv->x = x;
- ScreenPriv->y = y;
- ScreenPriv->CursorToRestore = NULL;
- ScreenPriv->HotX = pCurs->bits->xhot;
- ScreenPriv->HotY = pCurs->bits->yhot;
-
- if (!infoPtr->pScrn->vtSema)
- ScreenPriv->SavedCursor = pCurs;
-
- if (infoPtr->pScrn->vtSema && (ScreenPriv->ForceHWCursorCount || ((
-#ifdef ARGB_CURSOR
- pCurs->bits->argb && infoPtr->UseHWCursorARGB &&
- (*infoPtr->UseHWCursorARGB) (pScreen, pCurs) ) || (
- pCurs->bits->argb == 0 &&
-#endif
- (pCurs->bits->height <= infoPtr->MaxHeight) &&
- (pCurs->bits->width <= infoPtr->MaxWidth) &&
- (!infoPtr->UseHWCursor || (*infoPtr->UseHWCursor)(pScreen, pCurs))))))
- {
-
- if (ScreenPriv->SWCursor) /* remove the SW cursor */
- (*ScreenPriv->spriteFuncs->SetCursor)(pDev, pScreen, NullCursor, x, y);
-
- xf86SetCursor(pScreen, pCurs, x, y);
- ScreenPriv->SWCursor = FALSE;
- ScreenPriv->isUp = TRUE;
-
- miPointerSetWaitForUpdate(pScreen, !infoPtr->pScrn->silkenMouse);
- return;
- }
-
- miPointerSetWaitForUpdate(pScreen, TRUE);
-
- if (ScreenPriv->isUp) {
- /* Remove the HW cursor, or make it transparent */
- if (infoPtr->Flags & HARDWARE_CURSOR_SHOW_TRANSPARENT) {
- xf86SetTransparentCursor(pScreen);
- } else {
- xf86SetCursor(pScreen, NullCursor, x, y);
- ScreenPriv->isUp = FALSE;
- }
- }
-
- if (!ScreenPriv->SWCursor)
- ScreenPriv->SWCursor = TRUE;
-
- }
-
- if (pCurs->bits->emptyMask && !ScreenPriv->showTransparent)
- pCurs = NullCursor;
-
- (*ScreenPriv->spriteFuncs->SetCursor)(pDev, pScreen, pCurs, x, y);
-}
-
-static void
-xf86CursorMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
-{
- xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, xf86CursorScreenKey);
-
- /* only update coordinate state for first sprite, otherwise we get jumps
- when removing a sprite. The second sprite is never HW rendered anyway */
- if (GetMaster(pDev, MASTER_POINTER) == inputInfo.pointer)
- {
- ScreenPriv->x = x;
- ScreenPriv->y = y;
-
- if (ScreenPriv->CursorToRestore)
- xf86CursorSetCursor(pDev, pScreen, ScreenPriv->CursorToRestore, x, y);
- else if (ScreenPriv->SWCursor)
- (*ScreenPriv->spriteFuncs->MoveCursor)(pDev, pScreen, x, y);
- else if (ScreenPriv->isUp)
- xf86MoveCursor(pScreen, x, y);
- } else
- (*ScreenPriv->spriteFuncs->MoveCursor)(pDev, pScreen, x, y);
-}
-
-void
-xf86ForceHWCursor (ScreenPtr pScreen, Bool on)
-{
- DeviceIntPtr pDev = inputInfo.pointer;
- xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, xf86CursorScreenKey);
-
- if (on)
- {
- if (ScreenPriv->ForceHWCursorCount++ == 0)
- {
- if (ScreenPriv->SWCursor && ScreenPriv->CurrentCursor)
- {
- ScreenPriv->HWCursorForced = TRUE;
- xf86CursorSetCursor (pDev, pScreen, ScreenPriv->CurrentCursor,
- ScreenPriv->x, ScreenPriv->y);
- }
- else
- ScreenPriv->HWCursorForced = FALSE;
- }
- }
- else
- {
- if (--ScreenPriv->ForceHWCursorCount == 0)
- {
- if (ScreenPriv->HWCursorForced && ScreenPriv->CurrentCursor)
- xf86CursorSetCursor (pDev, pScreen, ScreenPriv->CurrentCursor,
- ScreenPriv->x, ScreenPriv->y);
- }
- }
-}
-
-xf86CursorInfoPtr
-xf86CreateCursorInfoRec(void)
-{
- return calloc(1, sizeof(xf86CursorInfoRec));
-}
-
-void
-xf86DestroyCursorInfoRec(xf86CursorInfoPtr infoPtr)
-{
- free(infoPtr);
-}
-
-/**
- * New cursor has been created. Do your initalizations here.
- */
-static Bool
-xf86DeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScreen)
-{
- int ret;
- xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, xf86CursorScreenKey);
-
- /* Init SW cursor */
- ret = (*ScreenPriv->spriteFuncs->DeviceCursorInitialize)(pDev, pScreen);
-
- return ret;
-}
-
-/**
- * Cursor has been removed. Clean up after yourself.
- */
-static void
-xf86DeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScreen)
-{
- xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
- &pScreen->devPrivates, xf86CursorScreenKey);
-
- /* Clean up SW cursor */
- (*ScreenPriv->spriteFuncs->DeviceCursorCleanup)(pDev, pScreen);
-}
-
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#include "xf86CursorPriv.h"
+#include "colormapst.h"
+#include "cursorstr.h"
+
+/* FIXME: This was added with the ABI change of the miPointerSpriteFuncs for
+ * MPX.
+ * inputInfo is needed to pass the core pointer as the default argument into
+ * the cursor functions.
+ *
+ * Externing inputInfo is not the nice way to do it but it works.
+ */
+#include "inputstr.h"
+extern InputInfo inputInfo;
+
+DevPrivateKeyRec xf86CursorScreenKeyRec;
+
+/* sprite functions */
+
+static Bool xf86CursorRealizeCursor(DeviceIntPtr, ScreenPtr, CursorPtr);
+static Bool xf86CursorUnrealizeCursor(DeviceIntPtr, ScreenPtr, CursorPtr);
+static void xf86CursorSetCursor(DeviceIntPtr, ScreenPtr, CursorPtr, int, int);
+static void xf86CursorMoveCursor(DeviceIntPtr, ScreenPtr, int, int);
+static Bool xf86DeviceCursorInitialize(DeviceIntPtr, ScreenPtr);
+static void xf86DeviceCursorCleanup(DeviceIntPtr, ScreenPtr);
+
+static miPointerSpriteFuncRec xf86CursorSpriteFuncs = {
+ xf86CursorRealizeCursor,
+ xf86CursorUnrealizeCursor,
+ xf86CursorSetCursor,
+ xf86CursorMoveCursor,
+ xf86DeviceCursorInitialize,
+ xf86DeviceCursorCleanup
+};
+
+/* Screen functions */
+
+static void xf86CursorInstallColormap(ColormapPtr);
+static void xf86CursorRecolorCursor(DeviceIntPtr pDev, ScreenPtr, CursorPtr, Bool);
+static Bool xf86CursorCloseScreen(int, ScreenPtr);
+static void xf86CursorQueryBestSize(int, unsigned short*, unsigned short*,
+ ScreenPtr);
+
+/* ScrnInfoRec functions */
+
+static void xf86CursorEnableDisableFBAccess(int, Bool);
+static Bool xf86CursorSwitchMode(int, DisplayModePtr,int);
+
+Bool
+xf86InitCursor(
+ ScreenPtr pScreen,
+ xf86CursorInfoPtr infoPtr
+)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ xf86CursorScreenPtr ScreenPriv;
+ miPointerScreenPtr PointPriv;
+
+ if (!xf86InitHardwareCursor(pScreen, infoPtr))
+ return FALSE;
+
+ if (!dixRegisterPrivateKey(&xf86CursorScreenKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
+ ScreenPriv = calloc(1, sizeof(xf86CursorScreenRec));
+ if (!ScreenPriv)
+ return FALSE;
+
+ dixSetPrivate(&pScreen->devPrivates, xf86CursorScreenKey, ScreenPriv);
+
+ ScreenPriv->SWCursor = TRUE;
+ ScreenPriv->isUp = FALSE;
+ ScreenPriv->CurrentCursor = NULL;
+ ScreenPriv->CursorInfoPtr = infoPtr;
+ ScreenPriv->PalettedCursor = FALSE;
+ ScreenPriv->pInstalledMap = NULL;
+
+ ScreenPriv->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = xf86CursorCloseScreen;
+ ScreenPriv->QueryBestSize = pScreen->QueryBestSize;
+ pScreen->QueryBestSize = xf86CursorQueryBestSize;
+ ScreenPriv->RecolorCursor = pScreen->RecolorCursor;
+ pScreen->RecolorCursor = xf86CursorRecolorCursor;
+
+ if ((infoPtr->pScrn->bitsPerPixel == 8) &&
+ !(infoPtr->Flags & HARDWARE_CURSOR_TRUECOLOR_AT_8BPP)) {
+ ScreenPriv->InstallColormap = pScreen->InstallColormap;
+ pScreen->InstallColormap = xf86CursorInstallColormap;
+ ScreenPriv->PalettedCursor = TRUE;
+ }
+
+ PointPriv = dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey);
+
+ ScreenPriv->showTransparent = PointPriv->showTransparent;
+ if (infoPtr->Flags & HARDWARE_CURSOR_SHOW_TRANSPARENT)
+ PointPriv->showTransparent = TRUE;
+ else
+ PointPriv->showTransparent = FALSE;
+ ScreenPriv->spriteFuncs = PointPriv->spriteFuncs;
+ PointPriv->spriteFuncs = &xf86CursorSpriteFuncs;
+
+ ScreenPriv->EnableDisableFBAccess = pScrn->EnableDisableFBAccess;
+ ScreenPriv->SwitchMode = pScrn->SwitchMode;
+
+ ScreenPriv->ForceHWCursorCount = 0;
+ ScreenPriv->HWCursorForced = FALSE;
+
+ pScrn->EnableDisableFBAccess = xf86CursorEnableDisableFBAccess;
+ if (pScrn->SwitchMode)
+ pScrn->SwitchMode = xf86CursorSwitchMode;
+
+ return TRUE;
+}
+
+/***** Screen functions *****/
+
+static Bool
+xf86CursorCloseScreen(int i, ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ miPointerScreenPtr PointPriv = (miPointerScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, miPointerScreenKey);
+ xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, xf86CursorScreenKey);
+
+ if (ScreenPriv->isUp && pScrn->vtSema)
+ xf86SetCursor(pScreen, NullCursor, ScreenPriv->x, ScreenPriv->y);
+
+ if (ScreenPriv->CurrentCursor)
+ FreeCursor(ScreenPriv->CurrentCursor, None);
+
+ pScreen->CloseScreen = ScreenPriv->CloseScreen;
+ pScreen->QueryBestSize = ScreenPriv->QueryBestSize;
+ pScreen->RecolorCursor = ScreenPriv->RecolorCursor;
+ if (ScreenPriv->InstallColormap)
+ pScreen->InstallColormap = ScreenPriv->InstallColormap;
+
+ PointPriv->spriteFuncs = ScreenPriv->spriteFuncs;
+ PointPriv->showTransparent = ScreenPriv->showTransparent;
+
+ pScrn->EnableDisableFBAccess = ScreenPriv->EnableDisableFBAccess;
+ pScrn->SwitchMode = ScreenPriv->SwitchMode;
+
+ free(ScreenPriv->transparentData);
+ free(ScreenPriv);
+
+ return (*pScreen->CloseScreen)(i, pScreen);
+}
+
+static void
+xf86CursorQueryBestSize(
+ int class,
+ unsigned short *width,
+ unsigned short *height,
+ ScreenPtr pScreen)
+{
+ xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, xf86CursorScreenKey);
+
+ if (class == CursorShape) {
+ if(*width > ScreenPriv->CursorInfoPtr->MaxWidth)
+ *width = ScreenPriv->CursorInfoPtr->MaxWidth;
+ if(*height > ScreenPriv->CursorInfoPtr->MaxHeight)
+ *height = ScreenPriv->CursorInfoPtr->MaxHeight;
+ } else
+ (*ScreenPriv->QueryBestSize)(class, width, height, pScreen);
+}
+
+static void
+xf86CursorInstallColormap(ColormapPtr pMap)
+{
+ xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
+ &pMap->pScreen->devPrivates, xf86CursorScreenKey);
+
+ ScreenPriv->pInstalledMap = pMap;
+
+ (*ScreenPriv->InstallColormap)(pMap);
+}
+
+static void
+xf86CursorRecolorCursor(
+ DeviceIntPtr pDev,
+ ScreenPtr pScreen,
+ CursorPtr pCurs,
+ Bool displayed)
+{
+ xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, xf86CursorScreenKey);
+
+ if (!displayed)
+ return;
+
+ if (ScreenPriv->SWCursor)
+ (*ScreenPriv->RecolorCursor)(pDev, pScreen, pCurs, displayed);
+ else
+ xf86RecolorCursor(pScreen, pCurs, displayed);
+}
+
+/***** ScrnInfoRec functions *********/
+
+static void
+xf86CursorEnableDisableFBAccess(
+ int index,
+ Bool enable)
+{
+ DeviceIntPtr pDev = inputInfo.pointer;
+
+ ScreenPtr pScreen = screenInfo.screens[index];
+ xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, xf86CursorScreenKey);
+
+ if (!enable && ScreenPriv->CurrentCursor != NullCursor) {
+ CursorPtr currentCursor = ScreenPriv->CurrentCursor;
+ xf86CursorSetCursor(pDev, pScreen, NullCursor, ScreenPriv->x,
+ ScreenPriv->y);
+ ScreenPriv->isUp = FALSE;
+ ScreenPriv->SWCursor = TRUE;
+ ScreenPriv->SavedCursor = currentCursor;
+ }
+
+ if (ScreenPriv->EnableDisableFBAccess)
+ (*ScreenPriv->EnableDisableFBAccess)(index, enable);
+
+ if (enable && ScreenPriv->SavedCursor)
+ {
+ /*
+ * Re-set current cursor so drivers can react to FB access having been
+ * temporarily disabled.
+ */
+ xf86CursorSetCursor(pDev, pScreen, ScreenPriv->SavedCursor,
+ ScreenPriv->x, ScreenPriv->y);
+ ScreenPriv->SavedCursor = NULL;
+ }
+}
+
+static Bool
+xf86CursorSwitchMode(int index, DisplayModePtr mode, int flags)
+{
+ Bool ret;
+ ScreenPtr pScreen = screenInfo.screens[index];
+ xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, xf86CursorScreenKey);
+
+ if (ScreenPriv->isUp) {
+ xf86SetCursor(pScreen, NullCursor, ScreenPriv->x, ScreenPriv->y);
+ ScreenPriv->isUp = FALSE;
+ }
+
+ ret = (*ScreenPriv->SwitchMode)(index, mode, flags);
+
+ /*
+ * Cannot restore cursor here because the new frame[XY][01] haven't been
+ * calculated yet. However, because the hardware cursor was removed above,
+ * ensure the cursor is repainted by miPointerWarpCursor().
+ */
+ ScreenPriv->CursorToRestore = ScreenPriv->CurrentCursor;
+ miPointerSetWaitForUpdate(pScreen, FALSE); /* Force cursor repaint */
+
+ return ret;
+}
+
+/****** miPointerSpriteFunctions *******/
+
+static Bool
+xf86CursorRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCurs)
+{
+ xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, xf86CursorScreenKey);
+
+ if (pCurs->refcnt <= 1)
+ dixSetPrivate(&pCurs->devPrivates, CursorScreenKey(pScreen), NULL);
+
+ return (*ScreenPriv->spriteFuncs->RealizeCursor)(pDev, pScreen, pCurs);
+}
+
+static Bool
+xf86CursorUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
+ CursorPtr pCurs)
+{
+ xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, xf86CursorScreenKey);
+
+ if (pCurs->refcnt <= 1) {
+ free(dixLookupPrivate(&pCurs->devPrivates, CursorScreenKey(pScreen)));
+ dixSetPrivate(&pCurs->devPrivates, CursorScreenKey(pScreen), NULL);
+ }
+
+ return (*ScreenPriv->spriteFuncs->UnrealizeCursor)(pDev, pScreen, pCurs);
+}
+
+static void
+xf86CursorSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCurs,
+ int x, int y)
+{
+ xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, xf86CursorScreenKey);
+ xf86CursorInfoPtr infoPtr = ScreenPriv->CursorInfoPtr;
+
+ if (pCurs == NullCursor) { /* means we're supposed to remove the cursor */
+ if (ScreenPriv->SWCursor ||
+ !(GetMaster(pDev, MASTER_POINTER) == inputInfo.pointer))
+ (*ScreenPriv->spriteFuncs->SetCursor)(pDev, pScreen, NullCursor, x, y);
+ else if (ScreenPriv->isUp) {
+ xf86SetCursor(pScreen, NullCursor, x, y);
+ ScreenPriv->isUp = FALSE;
+ }
+ if (ScreenPriv->CurrentCursor)
+ FreeCursor(ScreenPriv->CurrentCursor, None);
+ ScreenPriv->CurrentCursor = NullCursor;
+ return;
+ }
+
+ /* only update for VCP, otherwise we get cursor jumps when removing a
+ sprite. The second cursor is never HW rendered anyway. */
+ if (GetMaster(pDev, MASTER_POINTER) == inputInfo.pointer)
+ {
+ pCurs->refcnt++;
+ if (ScreenPriv->CurrentCursor)
+ FreeCursor(ScreenPriv->CurrentCursor, None);
+ ScreenPriv->CurrentCursor = pCurs;
+ ScreenPriv->x = x;
+ ScreenPriv->y = y;
+ ScreenPriv->CursorToRestore = NULL;
+ ScreenPriv->HotX = pCurs->bits->xhot;
+ ScreenPriv->HotY = pCurs->bits->yhot;
+
+ if (!infoPtr->pScrn->vtSema)
+ ScreenPriv->SavedCursor = pCurs;
+
+ if (infoPtr->pScrn->vtSema && (ScreenPriv->ForceHWCursorCount || ((
+#ifdef ARGB_CURSOR
+ pCurs->bits->argb && infoPtr->UseHWCursorARGB &&
+ (*infoPtr->UseHWCursorARGB) (pScreen, pCurs) ) || (
+ pCurs->bits->argb == 0 &&
+#endif
+ (pCurs->bits->height <= infoPtr->MaxHeight) &&
+ (pCurs->bits->width <= infoPtr->MaxWidth) &&
+ (!infoPtr->UseHWCursor || (*infoPtr->UseHWCursor)(pScreen, pCurs))))))
+ {
+
+ if (ScreenPriv->SWCursor) /* remove the SW cursor */
+ (*ScreenPriv->spriteFuncs->SetCursor)(pDev, pScreen, NullCursor, x, y);
+
+ xf86SetCursor(pScreen, pCurs, x, y);
+ ScreenPriv->SWCursor = FALSE;
+ ScreenPriv->isUp = TRUE;
+
+ miPointerSetWaitForUpdate(pScreen, !infoPtr->pScrn->silkenMouse);
+ return;
+ }
+
+ miPointerSetWaitForUpdate(pScreen, TRUE);
+
+ if (ScreenPriv->isUp) {
+ /* Remove the HW cursor, or make it transparent */
+ if (infoPtr->Flags & HARDWARE_CURSOR_SHOW_TRANSPARENT) {
+ xf86SetTransparentCursor(pScreen);
+ } else {
+ xf86SetCursor(pScreen, NullCursor, x, y);
+ ScreenPriv->isUp = FALSE;
+ }
+ }
+
+ if (!ScreenPriv->SWCursor)
+ ScreenPriv->SWCursor = TRUE;
+
+ }
+
+ if (pCurs->bits->emptyMask && !ScreenPriv->showTransparent)
+ pCurs = NullCursor;
+
+ (*ScreenPriv->spriteFuncs->SetCursor)(pDev, pScreen, pCurs, x, y);
+}
+
+static void
+xf86CursorMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
+{
+ xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, xf86CursorScreenKey);
+
+ /* only update coordinate state for first sprite, otherwise we get jumps
+ when removing a sprite. The second sprite is never HW rendered anyway */
+ if (GetMaster(pDev, MASTER_POINTER) == inputInfo.pointer)
+ {
+ ScreenPriv->x = x;
+ ScreenPriv->y = y;
+
+ if (ScreenPriv->CursorToRestore)
+ xf86CursorSetCursor(pDev, pScreen, ScreenPriv->CursorToRestore, x, y);
+ else if (ScreenPriv->SWCursor)
+ (*ScreenPriv->spriteFuncs->MoveCursor)(pDev, pScreen, x, y);
+ else if (ScreenPriv->isUp)
+ xf86MoveCursor(pScreen, x, y);
+ } else
+ (*ScreenPriv->spriteFuncs->MoveCursor)(pDev, pScreen, x, y);
+}
+
+void
+xf86ForceHWCursor (ScreenPtr pScreen, Bool on)
+{
+ DeviceIntPtr pDev = inputInfo.pointer;
+ xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, xf86CursorScreenKey);
+
+ if (on)
+ {
+ if (ScreenPriv->ForceHWCursorCount++ == 0)
+ {
+ if (ScreenPriv->SWCursor && ScreenPriv->CurrentCursor)
+ {
+ ScreenPriv->HWCursorForced = TRUE;
+ xf86CursorSetCursor (pDev, pScreen, ScreenPriv->CurrentCursor,
+ ScreenPriv->x, ScreenPriv->y);
+ }
+ else
+ ScreenPriv->HWCursorForced = FALSE;
+ }
+ }
+ else
+ {
+ if (--ScreenPriv->ForceHWCursorCount == 0)
+ {
+ if (ScreenPriv->HWCursorForced && ScreenPriv->CurrentCursor)
+ xf86CursorSetCursor (pDev, pScreen, ScreenPriv->CurrentCursor,
+ ScreenPriv->x, ScreenPriv->y);
+ }
+ }
+}
+
+xf86CursorInfoPtr
+xf86CreateCursorInfoRec(void)
+{
+ return calloc(1, sizeof(xf86CursorInfoRec));
+}
+
+void
+xf86DestroyCursorInfoRec(xf86CursorInfoPtr infoPtr)
+{
+ free(infoPtr);
+}
+
+/**
+ * New cursor has been created. Do your initalizations here.
+ */
+static Bool
+xf86DeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScreen)
+{
+ int ret;
+ xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, xf86CursorScreenKey);
+
+ /* Init SW cursor */
+ ret = (*ScreenPriv->spriteFuncs->DeviceCursorInitialize)(pDev, pScreen);
+
+ return ret;
+}
+
+/**
+ * Cursor has been removed. Clean up after yourself.
+ */
+static void
+xf86DeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScreen)
+{
+ xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, xf86CursorScreenKey);
+
+ /* Clean up SW cursor */
+ (*ScreenPriv->spriteFuncs->DeviceCursorCleanup)(pDev, pScreen);
+}
+
diff --git a/xorg-server/hw/xfree86/sdksyms.sh b/xorg-server/hw/xfree86/sdksyms.sh
index 6f5082ae5..18bb73523 100644
--- a/xorg-server/hw/xfree86/sdksyms.sh
+++ b/xorg-server/hw/xfree86/sdksyms.sh
@@ -1,425 +1,425 @@
-#!/bin/sh
-
-cat > sdksyms.c << EOF
-/* This file is automatically generated by sdksyms.sh. */
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-
-/* These must be included first */
-#include "misc.h"
-#include "miscstruct.h"
-
-
-/* render/Makefile.am */
-#include "picture.h"
-#include "mipict.h"
-#include "glyphstr.h"
-#include "picturestr.h"
-
-
-/* fb/Makefile.am -- module */
-/*
-#include "fb.h"
-#include "fbrop.h"
-#include "fboverlay.h"
-#include "wfbrename.h"
-#include "fbpict.h"
- */
-
-
-/* miext/shadow/Makefile.am -- module */
-/*
-#include "shadow.h"
- */
-
-
-/* miext/damage/Makefile.am */
-#include "damage.h"
-#include "damagestr.h"
-
-/* miext/sync/Makefile.am */
-#include "misync.h"
-#include "misyncstr.h"
-
-/* Xext/Makefile.am -- half is module, half is builtin */
-/*
-#include "xvdix.h"
-#include "xvmcext.h"
- */
-#include "geext.h"
-#include "geint.h"
-#include "shmint.h"
-#include "syncsdk.h"
-#if XINERAMA
-# include "panoramiXsrv.h"
-# include "panoramiX.h"
-#endif
-
-
-/* hw/xfree86/int10/Makefile.am -- module */
-/*
-#include "xf86int10.h"
- */
-
-
-/* hw/xfree86/i2c/Makefile.am -- "mostly" modules */
-#include "xf86i2c.h"
-/*
-#include "bt829.h"
-#include "fi1236.h"
-#include "msp3430.h"
-#include "tda8425.h"
-#include "tda9850.h"
-#include "tda9885.h"
-#include "uda1380.h"
-#include "i2c_def.h"
- */
-
-
-/* hw/xfree86/modes/Makefile.am */
-#include "xf86Crtc.h"
-#include "xf86Modes.h"
-#include "xf86RandR12.h"
-/* #include "xf86Rename.h" */
-
-
-/* hw/xfree86/ddc/Makefile.am */
-#include "edid.h"
-#include "xf86DDC.h"
-
-
-/* hw/xfree86/dri2/Makefile.am -- module */
-/*
-#if DRI2
-# include "dri2.h"
-#endif
- */
-
-
-/* hw/xfree86/vgahw/Makefile.am -- module */
-/*
-#include "vgaHW.h"
- */
-
-
-/* hw/xfree86/fbdevhw/Makefile.am -- module */
-/*
-#include "fbdevhw.h"
- */
-
-
-/* hw/xfree86/common/Makefile.am */
-#include "compiler.h"
-#include "fourcc.h"
-#include "xf86.h"
-#include "xf86Module.h"
-#include "xf86Opt.h"
-#include "xf86PciInfo.h"
-#include "xf86Priv.h"
-#include "xf86Privstr.h"
-#include "xf86cmap.h"
-#include "xf86fbman.h"
-#include "xf86str.h"
-#include "xf86Xinput.h"
-#include "xf86VGAarbiter.h"
-#include "xisb.h"
-#if XV
-# include "xf86xv.h"
-# include "xf86xvmc.h"
-# include "xf86xvpriv.h"
-#endif
-/* XF86VidMode code is in libextmod module */
-/*
-#if XF86VIDMODE
-# include "vidmodeproc.h"
-#endif
- */
-#include "xorgVersion.h"
-#if defined(__sparc__) || defined(__sparc)
-# include "xf86sbusBus.h"
-#endif
-
-
-/* hw/xfree86/ramdac/Makefile.am */
-#include "BT.h"
-#include "IBM.h"
-#include "TI.h"
-#include "xf86Cursor.h"
-#include "xf86RamDac.h"
-
-
-/* hw/xfree86/shadowfb/Makefile.am -- module */
-/*
-#include "shadowfb.h"
- */
-
-
-/* hw/xfree86/os-support/solaris/Makefile.am */
-#if defined(sun386)
-# include "agpgart.h"
-#endif
-
-
-/* hw/xfree86/os-support/Makefile.am */
-#include "xf86_OSproc.h"
-#include "xf86_OSlib.h"
-
-
-/* hw/xfree86/os-support/bus/Makefile.am */
-#include "xf86Pci.h"
-#if defined(__sparc__) || defined(__sparc)
-# include "xf86Sbus.h"
-#endif
-
-
-/* hw/xfree86/xaa/Makefile.am -- module */
-/*
-#include "xaa.h"
-#include "xaalocal.h"
-#include "xaarop.h"
- */
-
-
-/* hw/xfree86/dixmods/extmod/Makefile.am -- module */
-/*
-#include "dgaproc.h"
- */
-
-
-/* hw/xfree86/parser/Makefile.am */
-#include "xf86Parser.h"
-#include "xf86Optrec.h"
-
-
-/* hw/xfree86/vbe/Makefile.am -- module */
-/*
-#include "vbe.h"
-#include "vbeModes.h"
- */
-
-
-/* hw/xfree86/dri/Makefile.am -- module */
-/*
-#if XF86DRI
-# include "dri.h"
-# include "sarea.h"
-# include "dristruct.h"
-#endif
- */
-
-
-/* mi/Makefile.am */
-#include "micmap.h"
-#include "miline.h"
-#include "mipointer.h"
-#include "mi.h"
-#include "mibstore.h"
-#include "migc.h"
-#include "mipointrst.h"
-#include "mizerarc.h"
-#include "micoord.h"
-#include "mifillarc.h"
-#include "mispans.h"
-#include "miwideline.h"
-#include "mistruct.h"
-#include "mifpoly.h"
-#include "mioverlay.h"
-
-
-/* randr/Makefile.am */
-#include "randrstr.h"
-#include "rrtransform.h"
-
-
-/* dbe/Makefile.am -- module */
-/*
-#include "dbestruct.h"
- */
-
-
-/* exa/Makefile.am -- module */
-/*
-#include "exa.h"
- */
-
-
-/* xfixes/Makefile.am */
-#include "xfixes.h"
-
-
-/* include/Makefile.am */
-#include "XIstubs.h"
-#include "Xprintf.h"
-#include "closestr.h"
-#include "closure.h"
-#include "colormap.h"
-#include "colormapst.h"
-#include "hotplug.h"
-#include "client.h"
-#include "cursor.h"
-#include "cursorstr.h"
-#include "dix.h"
-#include "dixaccess.h"
-#include "dixevents.h"
-#include "dixfont.h"
-#include "dixfontstr.h"
-#include "dixgrabs.h"
-#include "dixstruct.h"
-#include "exevents.h"
-#include "extension.h"
-#include "extinit.h"
-#include "extnsionst.h"
-#include "gc.h"
-#include "gcstruct.h"
-#include "globals.h"
-#include "input.h"
-#include "inputstr.h"
-/* already included */
-/*
-#include "misc.h"
-#include "miscstruct.h"
- */
-#include "opaque.h"
-#include "os.h"
-#include "pixmap.h"
-#include "pixmapstr.h"
-#include "privates.h"
-#include "property.h"
-#include "propertyst.h"
-#include "ptrveloc.h"
-#include "region.h"
-#include "regionstr.h"
-#include "registry.h"
-#include "resource.h"
-#include "rgb.h"
-#include "screenint.h"
-#include "scrnintstr.h"
-#include "selection.h"
-#include "servermd.h"
-#include "site.h"
-#include "swaprep.h"
-#include "swapreq.h"
-#include "validate.h"
-#include "window.h"
-#include "windowstr.h"
-#include "xace.h"
-#include "xkbfile.h"
-#include "xkbsrv.h"
-#include "xkbstr.h"
-#include "xkbrules.h"
-#include "xserver-properties.h"
-
-EOF
-
-topdir=$1
-shift
-LC_ALL=C
-export LC_ALL
-${CPP:-cpp} "$@" -DXorgLoader sdksyms.c | ${AWK:-awk} -v topdir=$topdir '
-BEGIN {
- sdk = 0;
- print("/*");
- print(" * These symbols are referenced to ensure they");
- print(" * will be available in the X Server binary.");
- print(" */");
- printf("/* topdir=%s */\n", topdir);
- print("_X_HIDDEN void *xorg_symbols[] = {");
-
- printf("sdksyms.c:") > "sdksyms.dep";
-}
-/^# [0-9]+ "/ {
- # Process text after a include in a relative path or when the
- # processed file has a basename matching $top_srcdir.
- # Note that indexing starts at 1; 0 means no match, and there
- # is a starting ".
- sdk = $3 !~ /^"\// || index($3, topdir) == 2;
-
- if (sdk && $3 ~ /\.h"$/) {
- # remove quotes
- gsub(/"/, "", $3);
- line = $2;
- header = $3;
- if (! headers[$3]) {
- printf(" \\\n %s", $3) >> "sdksyms.dep";
- headers[$3] = 1;
- }
- }
- next;
-}
-
-/^extern[ ]/ {
- if (sdk) {
- n = 3;
-
- # skip attribute, if any
- while ($n ~ /^(__attribute__|__global)/ ||
- # skip modifiers, if any
- $n ~ /^\*?(unsigned|const|volatile|struct)$/ ||
- # skip pointer
- $n ~ /^[a-zA-Z0-9_]*\*$/)
- n++;
-
- # type specifier may not be set, as in
- # extern _X_EXPORT unsigned name(...)
- if ($n !~ /[^a-zA-Z0-9_]/)
- n++;
-
- # go back if we are at the parameter list already
- if ($n ~ /^[(]([^*].*)?$/)
- n--;
-
- # match
- # extern _X_EXPORT type (* name[])(...)
- if ($n ~ /^[^a-zA-Z0-9_]+$/)
- n++;
-
- # match
- # extern _X_EXPORT const name *const ...
- if ($n ~ /^([^a-zA-Z0-9_]+)?const$/)
- n++;
-
- # actual name may be in the next line, as in
- # extern _X_EXPORT type
- # possibly ending with a *
- # name(...)
- if ($n == "" || $n ~ /^\*+$/) {
- getline;
- n = 1;
- }
-
- # dont modify $0 or $n
- symbol = $n;
-
- # remove starting non word chars
- sub(/^[^a-zA-Z0-9_]+/, "",symbol);
-
- # remove from first non word to end of line
- sub(/[^a-zA-Z0-9_].*/, "", symbol);
-
- #print;
- printf(" (void *) &%-50s /* %s:%s */\n", symbol ",", header, line);
- }
-}
-
-{
- line++;
-}
-
-END {
- print("};");
-
- print("") >> "sdksyms.dep";
-}' > _sdksyms.c
-
-STATUS=$?
-
-cat _sdksyms.c >> sdksyms.c
-rm _sdksyms.c
-
-[ $? != 0 ] && exit $?
-
-exit $STATUS
+#!/bin/sh
+
+cat > sdksyms.c << EOF
+/* This file is automatically generated by sdksyms.sh. */
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+
+/* These must be included first */
+#include "misc.h"
+#include "miscstruct.h"
+
+
+/* render/Makefile.am */
+#include "picture.h"
+#include "mipict.h"
+#include "glyphstr.h"
+#include "picturestr.h"
+
+
+/* fb/Makefile.am -- module */
+/*
+#include "fb.h"
+#include "fbrop.h"
+#include "fboverlay.h"
+#include "wfbrename.h"
+#include "fbpict.h"
+ */
+
+
+/* miext/shadow/Makefile.am -- module */
+/*
+#include "shadow.h"
+ */
+
+
+/* miext/damage/Makefile.am */
+#include "damage.h"
+#include "damagestr.h"
+
+/* miext/sync/Makefile.am */
+#include "misync.h"
+#include "misyncstr.h"
+
+/* Xext/Makefile.am -- half is module, half is builtin */
+/*
+#include "xvdix.h"
+#include "xvmcext.h"
+ */
+#include "geext.h"
+#include "geint.h"
+#include "shmint.h"
+#include "syncsdk.h"
+#if XINERAMA
+# include "panoramiXsrv.h"
+# include "panoramiX.h"
+#endif
+
+
+/* hw/xfree86/int10/Makefile.am -- module */
+/*
+#include "xf86int10.h"
+ */
+
+
+/* hw/xfree86/i2c/Makefile.am -- "mostly" modules */
+#include "xf86i2c.h"
+/*
+#include "bt829.h"
+#include "fi1236.h"
+#include "msp3430.h"
+#include "tda8425.h"
+#include "tda9850.h"
+#include "tda9885.h"
+#include "uda1380.h"
+#include "i2c_def.h"
+ */
+
+
+/* hw/xfree86/modes/Makefile.am */
+#include "xf86Crtc.h"
+#include "xf86Modes.h"
+#include "xf86RandR12.h"
+/* #include "xf86Rename.h" */
+
+
+/* hw/xfree86/ddc/Makefile.am */
+#include "edid.h"
+#include "xf86DDC.h"
+
+
+/* hw/xfree86/dri2/Makefile.am -- module */
+/*
+#if DRI2
+# include "dri2.h"
+#endif
+ */
+
+
+/* hw/xfree86/vgahw/Makefile.am -- module */
+/*
+#include "vgaHW.h"
+ */
+
+
+/* hw/xfree86/fbdevhw/Makefile.am -- module */
+/*
+#include "fbdevhw.h"
+ */
+
+
+/* hw/xfree86/common/Makefile.am */
+#include "compiler.h"
+#include "fourcc.h"
+#include "xf86.h"
+#include "xf86Module.h"
+#include "xf86Opt.h"
+#include "xf86PciInfo.h"
+#include "xf86Priv.h"
+#include "xf86Privstr.h"
+#include "xf86cmap.h"
+#include "xf86fbman.h"
+#include "xf86str.h"
+#include "xf86Xinput.h"
+#include "xf86VGAarbiter.h"
+#include "xisb.h"
+#if XV
+# include "xf86xv.h"
+# include "xf86xvmc.h"
+# include "xf86xvpriv.h"
+#endif
+/* XF86VidMode code is in libextmod module */
+/*
+#if XF86VIDMODE
+# include "vidmodeproc.h"
+#endif
+ */
+#include "xorgVersion.h"
+#if defined(__sparc__) || defined(__sparc)
+# include "xf86sbusBus.h"
+#endif
+
+
+/* hw/xfree86/ramdac/Makefile.am */
+#include "BT.h"
+#include "IBM.h"
+#include "TI.h"
+#include "xf86Cursor.h"
+#include "xf86RamDac.h"
+
+
+/* hw/xfree86/shadowfb/Makefile.am -- module */
+/*
+#include "shadowfb.h"
+ */
+
+
+/* hw/xfree86/os-support/solaris/Makefile.am */
+#if defined(sun386)
+# include "agpgart.h"
+#endif
+
+
+/* hw/xfree86/os-support/Makefile.am */
+#include "xf86_OSproc.h"
+#include "xf86_OSlib.h"
+
+
+/* hw/xfree86/os-support/bus/Makefile.am */
+#include "xf86Pci.h"
+#if defined(__sparc__) || defined(__sparc)
+# include "xf86Sbus.h"
+#endif
+
+
+/* hw/xfree86/xaa/Makefile.am -- module */
+/*
+#include "xaa.h"
+#include "xaalocal.h"
+#include "xaarop.h"
+ */
+
+
+/* hw/xfree86/dixmods/extmod/Makefile.am -- module */
+/*
+#include "dgaproc.h"
+ */
+
+
+/* hw/xfree86/parser/Makefile.am */
+#include "xf86Parser.h"
+#include "xf86Optrec.h"
+
+
+/* hw/xfree86/vbe/Makefile.am -- module */
+/*
+#include "vbe.h"
+#include "vbeModes.h"
+ */
+
+
+/* hw/xfree86/dri/Makefile.am -- module */
+/*
+#if XF86DRI
+# include "dri.h"
+# include "sarea.h"
+# include "dristruct.h"
+#endif
+ */
+
+
+/* mi/Makefile.am */
+#include "micmap.h"
+#include "miline.h"
+#include "mipointer.h"
+#include "mi.h"
+#include "mibstore.h"
+#include "migc.h"
+#include "mipointrst.h"
+#include "mizerarc.h"
+#include "micoord.h"
+#include "mifillarc.h"
+#include "mispans.h"
+#include "miwideline.h"
+#include "mistruct.h"
+#include "mifpoly.h"
+#include "mioverlay.h"
+
+
+/* randr/Makefile.am */
+#include "randrstr.h"
+#include "rrtransform.h"
+
+
+/* dbe/Makefile.am -- module */
+/*
+#include "dbestruct.h"
+ */
+
+
+/* exa/Makefile.am -- module */
+/*
+#include "exa.h"
+ */
+
+
+/* xfixes/Makefile.am */
+#include "xfixes.h"
+
+
+/* include/Makefile.am */
+#include "XIstubs.h"
+#include "Xprintf.h"
+#include "closestr.h"
+#include "closure.h"
+#include "colormap.h"
+#include "colormapst.h"
+#include "hotplug.h"
+#include "client.h"
+#include "cursor.h"
+#include "cursorstr.h"
+#include "dix.h"
+#include "dixaccess.h"
+#include "dixevents.h"
+#include "dixfont.h"
+#include "dixfontstr.h"
+#include "dixgrabs.h"
+#include "dixstruct.h"
+#include "exevents.h"
+#include "extension.h"
+#include "extinit.h"
+#include "extnsionst.h"
+#include "gc.h"
+#include "gcstruct.h"
+#include "globals.h"
+#include "input.h"
+#include "inputstr.h"
+/* already included */
+/*
+#include "misc.h"
+#include "miscstruct.h"
+ */
+#include "opaque.h"
+#include "os.h"
+#include "pixmap.h"
+#include "pixmapstr.h"
+#include "privates.h"
+#include "property.h"
+#include "propertyst.h"
+#include "ptrveloc.h"
+#include "region.h"
+#include "regionstr.h"
+#include "registry.h"
+#include "resource.h"
+#include "rgb.h"
+#include "screenint.h"
+#include "scrnintstr.h"
+#include "selection.h"
+#include "servermd.h"
+#include "site.h"
+#include "swaprep.h"
+#include "swapreq.h"
+#include "validate.h"
+#include "window.h"
+#include "windowstr.h"
+#include "xace.h"
+#include "xkbfile.h"
+#include "xkbsrv.h"
+#include "xkbstr.h"
+#include "xkbrules.h"
+#include "xserver-properties.h"
+
+EOF
+
+topdir=$1
+shift
+LC_ALL=C
+export LC_ALL
+${CPP:-cpp} "$@" -DXorgLoader sdksyms.c | ${AWK:-awk} -v topdir=$topdir '
+BEGIN {
+ sdk = 0;
+ print("/*");
+ print(" * These symbols are referenced to ensure they");
+ print(" * will be available in the X Server binary.");
+ print(" */");
+ printf("/* topdir=%s */\n", topdir);
+ print("_X_HIDDEN void *xorg_symbols[] = {");
+
+ printf("sdksyms.c:") > "sdksyms.dep";
+}
+/^# [0-9]+ "/ {
+ # Process text after a include in a relative path or when the
+ # processed file has a basename matching $top_srcdir.
+ # Note that indexing starts at 1; 0 means no match, and there
+ # is a starting ".
+ sdk = $3 !~ /^"\// || index($3, topdir) == 2;
+
+ if (sdk && $3 ~ /\.h"$/) {
+ # remove quotes
+ gsub(/"/, "", $3);
+ line = $2;
+ header = $3;
+ if (! headers[$3]) {
+ printf(" \\\n %s", $3) >> "sdksyms.dep";
+ headers[$3] = 1;
+ }
+ }
+ next;
+}
+
+/^extern[ ]/ {
+ if (sdk) {
+ n = 3;
+
+ # skip attribute, if any
+ while ($n ~ /^(__attribute__|__global)/ ||
+ # skip modifiers, if any
+ $n ~ /^\*?(unsigned|const|volatile|struct)$/ ||
+ # skip pointer
+ $n ~ /^[a-zA-Z0-9_]*\*$/)
+ n++;
+
+ # type specifier may not be set, as in
+ # extern _X_EXPORT unsigned name(...)
+ if ($n !~ /[^a-zA-Z0-9_]/)
+ n++;
+
+ # go back if we are at the parameter list already
+ if ($n ~ /^[(]([^*].*)?$/)
+ n--;
+
+ # match
+ # extern _X_EXPORT type (* name[])(...)
+ if ($n ~ /^[^a-zA-Z0-9_]+$/)
+ n++;
+
+ # match
+ # extern _X_EXPORT const name *const ...
+ if ($n ~ /^([^a-zA-Z0-9_]+)?const$/)
+ n++;
+
+ # actual name may be in the next line, as in
+ # extern _X_EXPORT type
+ # possibly ending with a *
+ # name(...)
+ if ($n == "" || $n ~ /^\*+$/) {
+ getline;
+ n = 1;
+ }
+
+ # dont modify $0 or $n
+ symbol = $n;
+
+ # remove starting non word chars
+ sub(/^[^a-zA-Z0-9_]+/, "",symbol);
+
+ # remove from first non word to end of line
+ sub(/[^a-zA-Z0-9_].*/, "", symbol);
+
+ #print;
+ printf(" (void *) &%-50s /* %s:%s */\n", symbol ",", header, line);
+ }
+}
+
+{
+ line++;
+}
+
+END {
+ print("};");
+
+ print("") >> "sdksyms.dep";
+}' > _sdksyms.c
+
+STATUS=$?
+
+cat _sdksyms.c >> sdksyms.c
+rm _sdksyms.c
+
+[ $? != 0 ] && exit $?
+
+exit $STATUS
diff --git a/xorg-server/hw/xfree86/vbe/vbe.c b/xorg-server/hw/xfree86/vbe/vbe.c
index 082cfae4f..04132d956 100644
--- a/xorg-server/hw/xfree86/vbe/vbe.c
+++ b/xorg-server/hw/xfree86/vbe/vbe.c
@@ -1,1089 +1,1089 @@
-
-/*
- * XFree86 vbe module
- * Copyright 2000 Egbert Eich
- *
- * The mode query/save/set/restore functions from the vesa driver
- * have been moved here.
- * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com)
- * Authors: Paulo César Pereira de Andrade <pcpa@conectiva.com.br>
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <string.h>
-
-#include "xf86.h"
-#include "vbe.h"
-#include <X11/extensions/dpmsconst.h>
-
-#define VERSION(x) VBE_VERSION_MAJOR(x),VBE_VERSION_MINOR(x)
-
-#if X_BYTE_ORDER == X_LITTLE_ENDIAN
-#define B_O16(x) (x)
-#define B_O32(x) (x)
-#else
-#define B_O16(x) ((((x) & 0xff) << 8) | (((x) & 0xff) >> 8))
-#define B_O32(x) ((((x) & 0xff) << 24) | (((x) & 0xff00) << 8) \
- | (((x) & 0xff0000) >> 8) | (((x) & 0xff000000) >> 24))
-#endif
-#define L_ADD(x) (B_O32(x) & 0xffff) + ((B_O32(x) >> 12) & 0xffff00)
-
-#define FARP(p) (((unsigned)(p & 0xffff0000) >> 12) | (p & 0xffff))
-#define R16(v) ((v) & 0xffff)
-
-static unsigned char * vbeReadEDID(vbeInfoPtr pVbe);
-static Bool vbeProbeDDC(vbeInfoPtr pVbe);
-
-static const char vbeVersionString[] = "VBE2";
-
-vbeInfoPtr
-VBEInit(xf86Int10InfoPtr pInt, int entityIndex)
-{
- return VBEExtendedInit(pInt, entityIndex, 0);
-}
-
-vbeInfoPtr
-VBEExtendedInit(xf86Int10InfoPtr pInt, int entityIndex, int Flags)
-{
- int RealOff;
- pointer page = NULL;
- ScrnInfoPtr pScrn = xf86FindScreenForEntity(entityIndex);
- vbeControllerInfoPtr vbe = NULL;
- Bool init_int10 = FALSE;
- vbeInfoPtr vip = NULL;
- int screen;
-
- if (!pScrn) return NULL;
- screen = pScrn->scrnIndex;
-
- if (!pInt) {
- if (!xf86LoadSubModule(pScrn, "int10"))
- goto error;
-
- xf86DrvMsg(screen,X_INFO,"initializing int10\n");
- pInt = xf86ExtendedInitInt10(entityIndex,Flags);
- if (!pInt)
- goto error;
- init_int10 = TRUE;
- }
-
- page = xf86Int10AllocPages(pInt,1,&RealOff);
- if (!page) goto error;
- vbe = (vbeControllerInfoPtr) page;
- memcpy(vbe->VbeSignature,vbeVersionString,4);
-
- pInt->ax = 0x4F00;
- pInt->es = SEG_ADDR(RealOff);
- pInt->di = SEG_OFF(RealOff);
- pInt->num = 0x10;
-
- xf86ExecX86int10(pInt);
-
- if ((pInt->ax & 0xff) != 0x4f) {
- xf86DrvMsgVerb(screen,X_INFO,3,"VESA BIOS not detected\n");
- goto error;
- }
-
- switch (pInt->ax & 0xff00) {
- case 0:
- xf86DrvMsg(screen,X_INFO,"VESA BIOS detected\n");
- break;
- case 0x100:
- xf86DrvMsg(screen,X_INFO,"VESA BIOS function failed\n");
- goto error;
- case 0x200:
- xf86DrvMsg(screen,X_INFO,"VESA BIOS not supported\n");
- goto error;
- case 0x300:
- xf86DrvMsg(screen,X_INFO,"VESA BIOS not supported in current mode\n");
- goto error;
- default:
- xf86DrvMsg(screen,X_INFO,"Invalid\n");
- goto error;
- }
-
- xf86DrvMsgVerb(screen, X_INFO, 4,
- "VbeVersion is %d, OemStringPtr is 0x%08lx,\n"
- "\tOemVendorNamePtr is 0x%08lx, OemProductNamePtr is 0x%08lx,\n"
- "\tOemProductRevPtr is 0x%08lx\n",
- vbe->VbeVersion, (unsigned long)vbe->OemStringPtr,
- (unsigned long)vbe->OemVendorNamePtr,
- (unsigned long)vbe->OemProductNamePtr,
- (unsigned long)vbe->OemProductRevPtr);
-
- xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE Version %i.%i\n",
- VERSION(vbe->VbeVersion));
- xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE Total Mem: %i kB\n",
- vbe->TotalMem * 64);
- xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE OEM: %s\n",
- (CARD8*)xf86int10Addr(pInt,L_ADD(vbe->OemStringPtr)));
-
- if (B_O16(vbe->VbeVersion) >= 0x200) {
- xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE OEM Software Rev: %i.%i\n",
- VERSION(vbe->OemSoftwareRev));
- if (vbe->OemVendorNamePtr)
- xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE OEM Vendor: %s\n",
- (CARD8*)xf86int10Addr(pInt,L_ADD(vbe->OemVendorNamePtr)));
- if (vbe->OemProductNamePtr)
- xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE OEM Product: %s\n",
- (CARD8*)xf86int10Addr(pInt,L_ADD(vbe->OemProductNamePtr)));
- if (vbe->OemProductRevPtr)
- xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE OEM Product Rev: %s\n",
- (CARD8*)xf86int10Addr(pInt,L_ADD(vbe->OemProductRevPtr)));
- }
- vip = (vbeInfoPtr)xnfalloc(sizeof(vbeInfoRec));
- vip->version = B_O16(vbe->VbeVersion);
- vip->pInt10 = pInt;
- vip->ddc = DDC_UNCHECKED;
- vip->memory = page;
- vip->real_mode_base = RealOff;
- vip->num_pages = 1;
- vip->init_int10 = init_int10;
-
- return vip;
-
- error:
- if (page)
- xf86Int10FreePages(pInt, page, 1);
- if (init_int10)
- xf86FreeInt10(pInt);
- return NULL;
-}
-
-void
-vbeFree(vbeInfoPtr pVbe)
-{
- if (!pVbe)
- return;
-
- xf86Int10FreePages(pVbe->pInt10,pVbe->memory,pVbe->num_pages);
- /* If we have initalized int10 we ought to free it, too */
- if (pVbe->init_int10)
- xf86FreeInt10(pVbe->pInt10);
- free(pVbe);
- return;
-}
-
-static Bool
-vbeProbeDDC(vbeInfoPtr pVbe)
-{
- char *ddc_level;
- int screen = pVbe->pInt10->scrnIndex;
-
- if (pVbe->ddc == DDC_NONE)
- return FALSE;
- if (pVbe->ddc != DDC_UNCHECKED)
- return TRUE;
-
- pVbe->pInt10->ax = 0x4F15;
- pVbe->pInt10->bx = 0;
- pVbe->pInt10->cx = 0;
- pVbe->pInt10->es = 0;
- pVbe->pInt10->di = 0;
- pVbe->pInt10->num = 0x10;
-
- xf86ExecX86int10(pVbe->pInt10);
-
- if ((pVbe->pInt10->ax & 0xff) != 0x4f) {
- xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE DDC not supported\n");
- pVbe->ddc = DDC_NONE;
- return FALSE;
- }
-
- switch ((pVbe->pInt10->ax >> 8) & 0xff) {
- case 0:
- xf86DrvMsg(screen,X_INFO,"VESA VBE DDC supported\n");
- switch (pVbe->pInt10->bx & 0x3) {
- case 0:
- ddc_level = " none";
- pVbe->ddc = DDC_NONE;
- break;
- case 1:
- ddc_level = " 1";
- pVbe->ddc = DDC_1;
- break;
- case 2:
- ddc_level = " 2";
- pVbe->ddc = DDC_2;
- break;
- case 3:
- ddc_level = " 1 + 2";
- pVbe->ddc = DDC_1_2;
- break;
- default:
- ddc_level = "";
- pVbe->ddc = DDC_NONE;
- break;
- }
- xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE DDC Level%s\n",ddc_level);
- if (pVbe->pInt10->bx & 0x4) {
- xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE DDC Screen blanked"
- "for data transfer\n");
- pVbe->ddc_blank = TRUE;
- } else
- pVbe->ddc_blank = FALSE;
-
- xf86DrvMsgVerb(screen,X_INFO,3,
- "VESA VBE DDC transfer in appr. %x sec.\n",
- (pVbe->pInt10->bx >> 8) & 0xff);
- }
-
- return TRUE;
-}
-
-typedef enum {
- VBEOPT_NOVBE,
- VBEOPT_NODDC
-} VBEOpts;
-
-static const OptionInfoRec VBEOptions[] = {
- { VBEOPT_NOVBE, "NoVBE", OPTV_BOOLEAN, {0}, FALSE },
- { VBEOPT_NODDC, "NoDDC", OPTV_BOOLEAN, {0}, FALSE },
- { -1, NULL, OPTV_NONE, {0}, FALSE },
-};
-
-static unsigned char *
-vbeReadEDID(vbeInfoPtr pVbe)
-{
- int RealOff = pVbe->real_mode_base;
- pointer page = pVbe->memory;
- unsigned char *tmp = NULL;
- Bool novbe = FALSE;
- Bool noddc = FALSE;
- int screen = pVbe->pInt10->scrnIndex;
- OptionInfoPtr options;
-
- if (!page) return NULL;
-
- options = xnfalloc(sizeof(VBEOptions));
- (void)memcpy(options, VBEOptions, sizeof(VBEOptions));
- xf86ProcessOptions(screen, xf86Screens[screen]->options, options);
- xf86GetOptValBool(options, VBEOPT_NOVBE, &novbe);
- xf86GetOptValBool(options, VBEOPT_NODDC, &noddc);
- free(options);
- if (novbe || noddc) return NULL;
-
- if (!vbeProbeDDC(pVbe)) goto error;
-
- memset(page,0,sizeof(vbeInfoPtr));
- strcpy(page,vbeVersionString);
-
- pVbe->pInt10->ax = 0x4F15;
- pVbe->pInt10->bx = 0x01;
- pVbe->pInt10->cx = 0;
- pVbe->pInt10->dx = 0;
- pVbe->pInt10->es = SEG_ADDR(RealOff);
- pVbe->pInt10->di = SEG_OFF(RealOff);
- pVbe->pInt10->num = 0x10;
-
- xf86ExecX86int10(pVbe->pInt10);
-
- if ((pVbe->pInt10->ax & 0xff) != 0x4f) {
- xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE DDC invalid\n");
- goto error;
- }
- switch (pVbe->pInt10->ax & 0xff00) {
- case 0x0:
- xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE DDC read successfully\n");
- tmp = (unsigned char *)xnfalloc(128);
- memcpy(tmp,page,128);
- break;
- case 0x100:
- xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE DDC read failed\n");
- break;
- default:
- xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE DDC unkown failure %i\n",
- pVbe->pInt10->ax & 0xff00);
- break;
- }
-
- error:
- return tmp;
-}
-
-xf86MonPtr
-vbeDoEDID(vbeInfoPtr pVbe, pointer pDDCModule)
-{
- xf86MonPtr pMonitor;
- pointer pModule;
- unsigned char *DDC_data = NULL;
-
- if (!pVbe) return NULL;
- if (pVbe->version < 0x200)
- return NULL;
-
- if (!(pModule = pDDCModule)) {
- pModule =
- xf86LoadSubModule(xf86Screens[pVbe->pInt10->scrnIndex], "ddc");
- if (!pModule)
- return NULL;
- }
-
- DDC_data = vbeReadEDID(pVbe);
-
- if (!DDC_data)
- return NULL;
-
- pMonitor = xf86InterpretEDID(pVbe->pInt10->scrnIndex, DDC_data);
-
- if (!pDDCModule)
- xf86UnloadSubModule(pModule);
- return pMonitor;
-}
-
-#define GET_UNALIGNED2(x) \
- ((*(CARD16*)(x)) | (*(((CARD16*)(x) + 1))) << 16)
-
-VbeInfoBlock *
-VBEGetVBEInfo(vbeInfoPtr pVbe)
-{
- VbeInfoBlock *block = NULL;
- int i, pStr, pModes;
- char *str;
- CARD16 major, *modes;
-
- memset(pVbe->memory, 0, sizeof(VbeInfoBlock));
-
- /*
- Input:
- AH := 4Fh Super VGA support
- AL := 00h Return Super VGA information
- ES:DI := Pointer to buffer
-
- Output:
- AX := status
- (All other registers are preserved)
- */
-
- ((char*)pVbe->memory)[0] = 'V';
- ((char*)pVbe->memory)[1] = 'B';
- ((char*)pVbe->memory)[2] = 'E';
- ((char*)pVbe->memory)[3] = '2';
-
- pVbe->pInt10->num = 0x10;
- pVbe->pInt10->ax = 0x4f00;
- pVbe->pInt10->es = SEG_ADDR(pVbe->real_mode_base);
- pVbe->pInt10->di = SEG_OFF(pVbe->real_mode_base);
- xf86ExecX86int10(pVbe->pInt10);
-
- if (R16(pVbe->pInt10->ax) != 0x4f)
- return NULL;
-
- block = calloc(sizeof(VbeInfoBlock), 1);
- block->VESASignature[0] = ((char*)pVbe->memory)[0];
- block->VESASignature[1] = ((char*)pVbe->memory)[1];
- block->VESASignature[2] = ((char*)pVbe->memory)[2];
- block->VESASignature[3] = ((char*)pVbe->memory)[3];
-
- block->VESAVersion = *(CARD16*)(((char*)pVbe->memory) + 4);
- major = (unsigned)block->VESAVersion >> 8;
-
- pStr = GET_UNALIGNED2((((char*)pVbe->memory) + 6));
- str = xf86int10Addr(pVbe->pInt10, FARP(pStr));
- block->OEMStringPtr = strdup(str);
-
- block->Capabilities[0] = ((char*)pVbe->memory)[10];
- block->Capabilities[1] = ((char*)pVbe->memory)[11];
- block->Capabilities[2] = ((char*)pVbe->memory)[12];
- block->Capabilities[3] = ((char*)pVbe->memory)[13];
-
- pModes = GET_UNALIGNED2((((char*)pVbe->memory) + 14));
- modes = xf86int10Addr(pVbe->pInt10, FARP(pModes));
- i = 0;
- while (modes[i] != 0xffff)
- i++;
- block->VideoModePtr = malloc(sizeof(CARD16) * (i + 1));
- memcpy(block->VideoModePtr, modes, sizeof(CARD16) * i);
- block->VideoModePtr[i] = 0xffff;
-
- block->TotalMemory = *(CARD16*)(((char*)pVbe->memory) + 18);
-
- if (major < 2)
- memcpy(&block->OemSoftwareRev, ((char*)pVbe->memory) + 20, 236);
- else {
- block->OemSoftwareRev = *(CARD16*)(((char*)pVbe->memory) + 20);
- pStr = GET_UNALIGNED2((((char*)pVbe->memory) + 22));
- str = xf86int10Addr(pVbe->pInt10, FARP(pStr));
- block->OemVendorNamePtr = strdup(str);
- pStr = GET_UNALIGNED2((((char*)pVbe->memory) + 26));
- str = xf86int10Addr(pVbe->pInt10, FARP(pStr));
- block->OemProductNamePtr = strdup(str);
- pStr = GET_UNALIGNED2((((char*)pVbe->memory) + 30));
- str = xf86int10Addr(pVbe->pInt10, FARP(pStr));
- block->OemProductRevPtr = strdup(str);
- memcpy(&block->Reserved, ((char*)pVbe->memory) + 34, 222);
- memcpy(&block->OemData, ((char*)pVbe->memory) + 256, 256);
- }
-
- return block;
-}
-
-void
-VBEFreeVBEInfo(VbeInfoBlock *block)
-{
- free(block->OEMStringPtr);
- free(block->VideoModePtr);
- if (((unsigned)block->VESAVersion >> 8) >= 2) {
- free(block->OemVendorNamePtr);
- free(block->OemProductNamePtr);
- free(block->OemProductRevPtr);
- }
- free(block);
-}
-
-Bool
-VBESetVBEMode(vbeInfoPtr pVbe, int mode, VbeCRTCInfoBlock *block)
-{
- /*
- Input:
- AH := 4Fh Super VGA support
- AL := 02h Set Super VGA video mode
- BX := Video mode
- D0-D8 := Mode number
- D9-D10 := Reserved (must be 0)
- D11 := 0 Use current default refresh rate
- := 1 Use user specified CRTC values for refresh rate
- D12-13 Reserved for VBE/AF (must be 0)
- D14 := 0 Use windowed frame buffer model
- := 1 Use linear/flat frame buffer model
- D15 := 0 Clear video memory
- := 1 Don't clear video memory
- ES:DI := Pointer to VbeCRTCInfoBlock structure
-
- Output: AX = Status
- (All other registers are preserved)
- */
- pVbe->pInt10->num = 0x10;
- pVbe->pInt10->ax = 0x4f02;
- pVbe->pInt10->bx = mode;
- if (block) {
- pVbe->pInt10->bx |= 1 << 11;
- memcpy(pVbe->memory, block, sizeof(VbeCRTCInfoBlock));
- pVbe->pInt10->es = SEG_ADDR(pVbe->real_mode_base);
- pVbe->pInt10->di = SEG_OFF(pVbe->real_mode_base);
- } else
- pVbe->pInt10->bx &= ~(1 << 11);
-
- xf86ExecX86int10(pVbe->pInt10);
-
- return (R16(pVbe->pInt10->ax) == 0x4f);
-}
-
-Bool
-VBEGetVBEMode(vbeInfoPtr pVbe, int *mode)
-{
- /*
- Input:
- AH := 4Fh Super VGA support
- AL := 03h Return current video mode
-
- Output:
- AX := Status
- BX := Current video mode
- (All other registers are preserved)
- */
- pVbe->pInt10->num = 0x10;
- pVbe->pInt10->ax = 0x4f03;
-
- xf86ExecX86int10(pVbe->pInt10);
-
- if (R16(pVbe->pInt10->ax) == 0x4f) {
- *mode = R16(pVbe->pInt10->bx);
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-VbeModeInfoBlock *
-VBEGetModeInfo(vbeInfoPtr pVbe, int mode)
-{
- VbeModeInfoBlock *block = NULL;
-
- memset(pVbe->memory, 0, sizeof(VbeModeInfoBlock));
-
- /*
- Input:
- AH := 4Fh Super VGA support
- AL := 01h Return Super VGA mode information
- CX := Super VGA video mode
- (mode number must be one of those returned by Function 0)
- ES:DI := Pointer to buffer
-
- Output:
- AX := status
- (All other registers are preserved)
- */
- pVbe->pInt10->num = 0x10;
- pVbe->pInt10->ax = 0x4f01;
- pVbe->pInt10->cx = mode;
- pVbe->pInt10->es = SEG_ADDR(pVbe->real_mode_base);
- pVbe->pInt10->di = SEG_OFF(pVbe->real_mode_base);
- xf86ExecX86int10(pVbe->pInt10);
- if (R16(pVbe->pInt10->ax) != 0x4f)
- return NULL;
-
- block = malloc(sizeof(VbeModeInfoBlock));
- if (block)
- memcpy(block, pVbe->memory, sizeof(*block));
-
- return block;
-}
-
-void
-VBEFreeModeInfo(VbeModeInfoBlock *block)
-{
- free(block);
-}
-
-Bool
-VBESaveRestore(vbeInfoPtr pVbe, vbeSaveRestoreFunction function,
- pointer *memory, int *size, int *real_mode_pages)
-{
- /*
- Input:
- AH := 4Fh Super VGA support
- AL := 04h Save/restore Super VGA video state
- DL := 00h Return save/restore state buffer size
- CX := Requested states
- D0 = Save/restore video hardware state
- D1 = Save/restore video BIOS data state
- D2 = Save/restore video DAC state
- D3 = Save/restore Super VGA state
-
- Output:
- AX = Status
- BX = Number of 64-byte blocks to hold the state buffer
- (All other registers are preserved)
-
-
- Input:
- AH := 4Fh Super VGA support
- AL := 04h Save/restore Super VGA video state
- DL := 01h Save Super VGA video state
- CX := Requested states (see above)
- ES:BX := Pointer to buffer
-
- Output:
- AX := Status
- (All other registers are preserved)
-
-
- Input:
- AH := 4Fh Super VGA support
- AL := 04h Save/restore Super VGA video state
- DL := 02h Restore Super VGA video state
- CX := Requested states (see above)
- ES:BX := Pointer to buffer
-
- Output:
- AX := Status
- (All other registers are preserved)
- */
-
- if ((pVbe->version & 0xff00) > 0x100) {
- int screen = pVbe->pInt10->scrnIndex;
- if (function == MODE_QUERY ||
- (function == MODE_SAVE && !*memory)) {
- /* Query amount of memory to save state */
-
- pVbe->pInt10->num = 0x10;
- pVbe->pInt10->ax = 0x4f04;
- pVbe->pInt10->dx = 0;
- pVbe->pInt10->cx = 0x000f;
- xf86ExecX86int10(pVbe->pInt10);
- if (R16(pVbe->pInt10->ax) != 0x4f)
- return FALSE;
-
- if (function == MODE_SAVE) {
- int npages = (R16(pVbe->pInt10->bx) * 64) / 4096 + 1;
- if ((*memory = xf86Int10AllocPages(pVbe->pInt10, npages,
- real_mode_pages)) == NULL) {
- xf86DrvMsg(screen, X_ERROR,
- "Cannot allocate memory to save SVGA state.\n");
- return FALSE;
- }
- }
- *size = pVbe->pInt10->bx * 64;
- }
-
- /* Save/Restore Super VGA state */
- if (function != MODE_QUERY) {
-
- if (!*memory) return FALSE;
- pVbe->pInt10->num = 0x10;
- pVbe->pInt10->ax = 0x4f04;
- switch (function) {
- case MODE_SAVE:
- pVbe->pInt10->dx = 1;
- break;
- case MODE_RESTORE:
- pVbe->pInt10->dx = 2;
- break;
- case MODE_QUERY:
- return FALSE;
- }
- pVbe->pInt10->cx = 0x000f;
-
- pVbe->pInt10->es = SEG_ADDR(*real_mode_pages);
- pVbe->pInt10->bx = SEG_OFF(*real_mode_pages);
- xf86ExecX86int10(pVbe->pInt10);
- return (R16(pVbe->pInt10->ax) == 0x4f);
-
- }
- }
- return TRUE;
-}
-
-Bool
-VBEBankSwitch(vbeInfoPtr pVbe, unsigned int iBank, int window)
-{
- /*
- Input:
- AH := 4Fh Super VGA support
- AL := 05h
-
- Output:
- */
- pVbe->pInt10->num = 0x10;
- pVbe->pInt10->ax = 0x4f05;
- pVbe->pInt10->bx = window;
- pVbe->pInt10->dx = iBank;
- xf86ExecX86int10(pVbe->pInt10);
-
- if (R16(pVbe->pInt10->ax) != 0x4f)
- return FALSE;
-
- return TRUE;
-}
-
-Bool
-VBESetGetLogicalScanlineLength(vbeInfoPtr pVbe, vbeScanwidthCommand command,
- int width, int *pixels, int *bytes, int *max)
-{
- if (command < SCANWID_SET || command > SCANWID_GET_MAX)
- return FALSE;
-
- /*
- Input:
- AX := 4F06h VBE Set/Get Logical Scan Line Length
- BL := 00h Set Scan Line Length in Pixels
- := 01h Get Scan Line Length
- := 02h Set Scan Line Length in Bytes
- := 03h Get Maximum Scan Line Length
- CX := If BL=00h Desired Width in Pixels
- If BL=02h Desired Width in Bytes
- (Ignored for Get Functions)
-
- Output:
- AX := VBE Return Status
- BX := Bytes Per Scan Line
- CX := Actual Pixels Per Scan Line
- (truncated to nearest complete pixel)
- DX := Maximum Number of Scan Lines
- */
-
- pVbe->pInt10->num = 0x10;
- pVbe->pInt10->ax = 0x4f06;
- pVbe->pInt10->bx = command;
- if (command == SCANWID_SET || command == SCANWID_SET_BYTES)
- pVbe->pInt10->cx = width;
- xf86ExecX86int10(pVbe->pInt10);
-
- if (R16(pVbe->pInt10->ax) != 0x4f)
- return FALSE;
-
- if (command == SCANWID_GET || command == SCANWID_GET_MAX) {
- if (pixels)
- *pixels = R16(pVbe->pInt10->cx);
- if (bytes)
- *bytes = R16(pVbe->pInt10->bx);
- if (max)
- *max = R16(pVbe->pInt10->dx);
- }
-
- return TRUE;
-}
-
-Bool
-VBESetDisplayStart(vbeInfoPtr pVbe, int x, int y, Bool wait_retrace)
-{
- pVbe->pInt10->num = 0x10;
- pVbe->pInt10->ax = 0x4f07;
- pVbe->pInt10->bx = wait_retrace ? 0x80 : 0x00;
- pVbe->pInt10->cx = x;
- pVbe->pInt10->dx = y;
- xf86ExecX86int10(pVbe->pInt10);
-
- if (R16(pVbe->pInt10->ax) != 0x4f)
- return FALSE;
-
- return TRUE;
-}
-
-Bool
-VBEGetDisplayStart(vbeInfoPtr pVbe, int *x, int *y)
-{
- pVbe->pInt10->num = 0x10;
- pVbe->pInt10->ax = 0x4f07;
- pVbe->pInt10->bx = 0x01;
- xf86ExecX86int10(pVbe->pInt10);
-
- if (R16(pVbe->pInt10->ax) != 0x4f)
- return FALSE;
-
- *x = pVbe->pInt10->cx;
- *y = pVbe->pInt10->dx;
-
- return TRUE;
-}
-
-int
-VBESetGetDACPaletteFormat(vbeInfoPtr pVbe, int bits)
-{
- /*
- Input:
- AX := 4F08h VBE Set/Get Palette Format
- BL := 00h Set DAC Palette Format
- := 01h Get DAC Palette Format
- BH := Desired bits of color per primary
- (Set DAC Palette Format only)
-
- Output:
- AX := VBE Return Status
- BH := Current number of bits of color per primary
- */
-
- pVbe->pInt10->num = 0x10;
- pVbe->pInt10->ax = 0x4f08;
- if (!bits)
- pVbe->pInt10->bx = 0x01;
- else
- pVbe->pInt10->bx = (bits & 0x00ff) << 8;
- xf86ExecX86int10(pVbe->pInt10);
-
- if (R16(pVbe->pInt10->ax) != 0x4f)
- return 0;
-
- return (bits != 0 ? bits : (pVbe->pInt10->bx >> 8) & 0x00ff);
-}
-
-CARD32 *
-VBESetGetPaletteData(vbeInfoPtr pVbe, Bool set, int first, int num,
- CARD32 *data, Bool secondary, Bool wait_retrace)
-{
- /*
- Input:
- (16-bit)
- AX := 4F09h VBE Load/Unload Palette Data
- BL := 00h Set Palette Data
- := 01h Get Palette Data
- := 02h Set Secondary Palette Data
- := 03h Get Secondary Palette Data
- := 80h Set Palette Data during Vertical Retrace
- CX := Number of palette registers to update (to a maximum of 256)
- DX := First of the palette registers to update (start)
- ES:DI := Table of palette values (see below for format)
-
- Output:
- AX := VBE Return Status
-
-
- Input:
- (32-bit)
- BL := 00h Set Palette Data
- := 80h Set Palette Data during Vertical Retrace
- CX := Number of palette registers to update (to a maximum of 256)
- DX := First of the palette registers to update (start)
- ES:EDI := Table of palette values (see below for format)
- DS := Selector for memory mapped registers
- */
-
- pVbe->pInt10->num = 0x10;
- pVbe->pInt10->ax = 0x4f09;
- if (!secondary)
- pVbe->pInt10->bx = set && wait_retrace ? 0x80 : set ? 0 : 1;
- else
- pVbe->pInt10->bx = set ? 2 : 3;
- pVbe->pInt10->cx = num;
- pVbe->pInt10->dx = first;
- pVbe->pInt10->es = SEG_ADDR(pVbe->real_mode_base);
- pVbe->pInt10->di = SEG_OFF(pVbe->real_mode_base);
- if (set)
- memcpy(pVbe->memory, data, num * sizeof(CARD32));
- xf86ExecX86int10(pVbe->pInt10);
-
- if (R16(pVbe->pInt10->ax) != 0x4f)
- return NULL;
-
- if (set)
- return data;
-
- data = malloc(num * sizeof(CARD32));
- memcpy(data, pVbe->memory, num * sizeof(CARD32));
-
- return data;
-}
-
-VBEpmi *
-VBEGetVBEpmi(vbeInfoPtr pVbe)
-{
- VBEpmi *pmi;
-
- /*
- Input:
- AH := 4Fh Super VGA support
- AL := 0Ah Protected Mode Interface
- BL := 00h Return Protected Mode Table
-
- Output:
- AX := Status
- ES := Real Mode Segment of Table
- DI := Offset of Table
- CX := Lenght of Table including protected mode code in bytes (for copying purposes)
- (All other registers are preserved)
- */
-
- pVbe->pInt10->num = 0x10;
- pVbe->pInt10->ax = 0x4f0a;
- pVbe->pInt10->bx = 0;
- pVbe->pInt10->di = 0;
- xf86ExecX86int10(pVbe->pInt10);
-
- if (R16(pVbe->pInt10->ax) != 0x4f)
- return NULL;
-
- pmi = malloc(sizeof(VBEpmi));
- pmi->seg_tbl = R16(pVbe->pInt10->es);
- pmi->tbl_off = R16(pVbe->pInt10->di);
- pmi->tbl_len = R16(pVbe->pInt10->cx);
-
- return pmi;
-}
-
-#if 0
-vbeModeInfoPtr
-VBEBuildVbeModeList(vbeInfoPtr pVbe, VbeInfoBlock *vbe)
-{
- vbeModeInfoPtr ModeList = NULL;
-
- int i = 0;
- while (vbe->VideoModePtr[i] != 0xffff) {
- vbeModeInfoPtr m;
- VbeModeInfoBlock *mode;
- int id = vbe->VideoModePtr[i++];
- int bpp;
-
- if ((mode = VBEGetModeInfo(pVbe, id)) == NULL)
- continue;
-
- bpp = mode->BitsPerPixel;
-
- m = xnfcalloc(sizeof(vbeModeInfoRec),1);
- m->width = mode->XResolution;
- m->height = mode->YResolution;
- m->bpp = bpp;
- m->n = id;
- m->next = ModeList;
-
- xf86DrvMsgVerb(pVbe->pInt10->scrnIndex, X_PROBED, 3,
- "BIOS reported VESA mode 0x%x: x:%i y:%i bpp:%i\n",
- m->n, m->width, m->height, m->bpp);
-
- ModeList = m;
-
- VBEFreeModeInfo(mode);
- }
- return ModeList;
-}
-
-unsigned short
-VBECalcVbeModeIndex(vbeModeInfoPtr m, DisplayModePtr mode, int bpp)
-{
- while (m) {
- if (bpp == m->bpp
- && mode->HDisplay == m->width
- && mode->VDisplay == m->height)
- return m->n;
- m = m->next;
- }
- return 0;
-}
-#endif
-
-void
-VBEVesaSaveRestore(vbeInfoPtr pVbe, vbeSaveRestorePtr vbe_sr,
- vbeSaveRestoreFunction function)
-{
- Bool SaveSucc = FALSE;
-
- if (VBE_VERSION_MAJOR(pVbe->version) > 1
- && (function == MODE_SAVE || vbe_sr->pstate)) {
- if (function == MODE_RESTORE)
- memcpy(vbe_sr->state, vbe_sr->pstate, vbe_sr->stateSize);
- ErrorF("VBESaveRestore\n");
- if ((VBESaveRestore(pVbe,function,
- (pointer)&vbe_sr->state,
- &vbe_sr->stateSize,&vbe_sr->statePage))) {
- if (function == MODE_SAVE) {
- SaveSucc = TRUE;
- vbe_sr->stateMode = -1; /* invalidate */
- /* don't rely on the memory not being touched */
- if (vbe_sr->pstate == NULL)
- vbe_sr->pstate = malloc(vbe_sr->stateSize);
- memcpy(vbe_sr->pstate, vbe_sr->state, vbe_sr->stateSize);
- }
- ErrorF("VBESaveRestore done with success\n");
- return;
- }
- ErrorF("VBESaveRestore done\n");
- }
-
- if (function == MODE_SAVE && !SaveSucc)
- (void)VBEGetVBEMode(pVbe, &vbe_sr->stateMode);
-
- if (function == MODE_RESTORE && vbe_sr->stateMode != -1)
- VBESetVBEMode(pVbe, vbe_sr->stateMode, NULL);
-
-}
-
-int
-VBEGetPixelClock(vbeInfoPtr pVbe, int mode, int clock)
-{
- /*
- Input:
- AX := 4F0Bh VBE Get Pixel Clock
- BL := 00h Get Pixel Clock
- ECX := pixel clock in units of Hz
- DX := mode number
-
- Output:
- AX := VBE Return Status
- ECX := Closest pixel clock
- */
-
- pVbe->pInt10->num = 0x10;
- pVbe->pInt10->ax = 0x4f0b;
- pVbe->pInt10->bx = 0x00;
- pVbe->pInt10->cx = clock;
- pVbe->pInt10->dx = mode;
- xf86ExecX86int10(pVbe->pInt10);
-
- if (R16(pVbe->pInt10->ax) != 0x4f)
- return 0;
-
- return pVbe->pInt10->cx;
-}
-
-Bool
-VBEDPMSSet(vbeInfoPtr pVbe, int mode)
-{
- /*
- Input:
- AX := 4F10h DPMS
- BL := 01h Set Display Power State
- BH := requested power state
-
- Output:
- AX := VBE Return Status
- */
-
- pVbe->pInt10->num = 0x10;
- pVbe->pInt10->ax = 0x4f10;
- pVbe->pInt10->bx = 0x01;
- switch (mode) {
- case DPMSModeOn:
- break;
- case DPMSModeStandby:
- pVbe->pInt10->bx |= 0x100;
- break;
- case DPMSModeSuspend:
- pVbe->pInt10->bx |= 0x200;
- break;
- case DPMSModeOff:
- pVbe->pInt10->bx |= 0x400;
- break;
- }
- xf86ExecX86int10(pVbe->pInt10);
- return (R16(pVbe->pInt10->ax) == 0x4f);
-}
-
-void
-VBEInterpretPanelID(int scrnIndex, struct vbePanelID *data)
-{
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
- DisplayModePtr mode;
- const float PANEL_HZ = 60.0;
-
- if (!data)
- return;
-
- xf86DrvMsg(scrnIndex, X_INFO, "PanelID returned panel resolution %dx%d\n",
- data->hsize, data->vsize);
-
- if (pScrn->monitor->nHsync || pScrn->monitor->nVrefresh)
- return;
-
- if (data->hsize < 320 || data->vsize < 240) {
- xf86DrvMsg(scrnIndex, X_INFO, "...which I refuse to believe\n");
- return;
- }
-
- mode = xf86CVTMode(data->hsize, data->vsize, PANEL_HZ, 1, 0);
-
- pScrn->monitor->nHsync = 1;
- pScrn->monitor->hsync[0].lo = 31.5;
- pScrn->monitor->hsync[0].hi = (float)mode->Clock / (float)mode->HTotal;
- pScrn->monitor->nVrefresh = 1;
- pScrn->monitor->vrefresh[0].lo = 56.0;
- pScrn->monitor->vrefresh[0].hi =
- (float)mode->Clock*1000.0 / (float)mode->HTotal / (float)mode->VTotal;
-
- free(mode);
-}
-
-struct vbePanelID *
-VBEReadPanelID(vbeInfoPtr pVbe)
-{
- int RealOff = pVbe->real_mode_base;
- pointer page = pVbe->memory;
- void *tmp = NULL;
- int screen = pVbe->pInt10->scrnIndex;
-
- pVbe->pInt10->ax = 0x4F11;
- pVbe->pInt10->bx = 0x01;
- pVbe->pInt10->cx = 0;
- pVbe->pInt10->dx = 0;
- pVbe->pInt10->es = SEG_ADDR(RealOff);
- pVbe->pInt10->di = SEG_OFF(RealOff);
- pVbe->pInt10->num = 0x10;
-
- xf86ExecX86int10(pVbe->pInt10);
-
- if ((pVbe->pInt10->ax & 0xff) != 0x4f) {
- xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE PanelID invalid\n");
- goto error;
- }
-
- switch (pVbe->pInt10->ax & 0xff00) {
- case 0x0:
- xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE PanelID read successfully\n");
- tmp = xnfalloc(32);
- memcpy(tmp, page, 32);
- break;
- case 0x100:
- xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE PanelID read failed\n");
- break;
- default:
- xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE PanelID unknown failure %i\n",
- pVbe->pInt10->ax & 0xff00);
- break;
- }
-
-error:
- return tmp;
-}
+
+/*
+ * XFree86 vbe module
+ * Copyright 2000 Egbert Eich
+ *
+ * The mode query/save/set/restore functions from the vesa driver
+ * have been moved here.
+ * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com)
+ * Authors: Paulo César Pereira de Andrade <pcpa@conectiva.com.br>
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <string.h>
+
+#include "xf86.h"
+#include "vbe.h"
+#include <X11/extensions/dpmsconst.h>
+
+#define VERSION(x) VBE_VERSION_MAJOR(x),VBE_VERSION_MINOR(x)
+
+#if X_BYTE_ORDER == X_LITTLE_ENDIAN
+#define B_O16(x) (x)
+#define B_O32(x) (x)
+#else
+#define B_O16(x) ((((x) & 0xff) << 8) | (((x) & 0xff) >> 8))
+#define B_O32(x) ((((x) & 0xff) << 24) | (((x) & 0xff00) << 8) \
+ | (((x) & 0xff0000) >> 8) | (((x) & 0xff000000) >> 24))
+#endif
+#define L_ADD(x) (B_O32(x) & 0xffff) + ((B_O32(x) >> 12) & 0xffff00)
+
+#define FARP(p) (((unsigned)(p & 0xffff0000) >> 12) | (p & 0xffff))
+#define R16(v) ((v) & 0xffff)
+
+static unsigned char * vbeReadEDID(vbeInfoPtr pVbe);
+static Bool vbeProbeDDC(vbeInfoPtr pVbe);
+
+static const char vbeVersionString[] = "VBE2";
+
+vbeInfoPtr
+VBEInit(xf86Int10InfoPtr pInt, int entityIndex)
+{
+ return VBEExtendedInit(pInt, entityIndex, 0);
+}
+
+vbeInfoPtr
+VBEExtendedInit(xf86Int10InfoPtr pInt, int entityIndex, int Flags)
+{
+ int RealOff;
+ pointer page = NULL;
+ ScrnInfoPtr pScrn = xf86FindScreenForEntity(entityIndex);
+ vbeControllerInfoPtr vbe = NULL;
+ Bool init_int10 = FALSE;
+ vbeInfoPtr vip = NULL;
+ int screen;
+
+ if (!pScrn) return NULL;
+ screen = pScrn->scrnIndex;
+
+ if (!pInt) {
+ if (!xf86LoadSubModule(pScrn, "int10"))
+ goto error;
+
+ xf86DrvMsg(screen,X_INFO,"initializing int10\n");
+ pInt = xf86ExtendedInitInt10(entityIndex,Flags);
+ if (!pInt)
+ goto error;
+ init_int10 = TRUE;
+ }
+
+ page = xf86Int10AllocPages(pInt,1,&RealOff);
+ if (!page) goto error;
+ vbe = (vbeControllerInfoPtr) page;
+ memcpy(vbe->VbeSignature,vbeVersionString,4);
+
+ pInt->ax = 0x4F00;
+ pInt->es = SEG_ADDR(RealOff);
+ pInt->di = SEG_OFF(RealOff);
+ pInt->num = 0x10;
+
+ xf86ExecX86int10(pInt);
+
+ if ((pInt->ax & 0xff) != 0x4f) {
+ xf86DrvMsgVerb(screen,X_INFO,3,"VESA BIOS not detected\n");
+ goto error;
+ }
+
+ switch (pInt->ax & 0xff00) {
+ case 0:
+ xf86DrvMsg(screen,X_INFO,"VESA BIOS detected\n");
+ break;
+ case 0x100:
+ xf86DrvMsg(screen,X_INFO,"VESA BIOS function failed\n");
+ goto error;
+ case 0x200:
+ xf86DrvMsg(screen,X_INFO,"VESA BIOS not supported\n");
+ goto error;
+ case 0x300:
+ xf86DrvMsg(screen,X_INFO,"VESA BIOS not supported in current mode\n");
+ goto error;
+ default:
+ xf86DrvMsg(screen,X_INFO,"Invalid\n");
+ goto error;
+ }
+
+ xf86DrvMsgVerb(screen, X_INFO, 4,
+ "VbeVersion is %d, OemStringPtr is 0x%08lx,\n"
+ "\tOemVendorNamePtr is 0x%08lx, OemProductNamePtr is 0x%08lx,\n"
+ "\tOemProductRevPtr is 0x%08lx\n",
+ vbe->VbeVersion, (unsigned long)vbe->OemStringPtr,
+ (unsigned long)vbe->OemVendorNamePtr,
+ (unsigned long)vbe->OemProductNamePtr,
+ (unsigned long)vbe->OemProductRevPtr);
+
+ xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE Version %i.%i\n",
+ VERSION(vbe->VbeVersion));
+ xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE Total Mem: %i kB\n",
+ vbe->TotalMem * 64);
+ xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE OEM: %s\n",
+ (CARD8*)xf86int10Addr(pInt,L_ADD(vbe->OemStringPtr)));
+
+ if (B_O16(vbe->VbeVersion) >= 0x200) {
+ xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE OEM Software Rev: %i.%i\n",
+ VERSION(vbe->OemSoftwareRev));
+ if (vbe->OemVendorNamePtr)
+ xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE OEM Vendor: %s\n",
+ (CARD8*)xf86int10Addr(pInt,L_ADD(vbe->OemVendorNamePtr)));
+ if (vbe->OemProductNamePtr)
+ xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE OEM Product: %s\n",
+ (CARD8*)xf86int10Addr(pInt,L_ADD(vbe->OemProductNamePtr)));
+ if (vbe->OemProductRevPtr)
+ xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE OEM Product Rev: %s\n",
+ (CARD8*)xf86int10Addr(pInt,L_ADD(vbe->OemProductRevPtr)));
+ }
+ vip = (vbeInfoPtr)xnfalloc(sizeof(vbeInfoRec));
+ vip->version = B_O16(vbe->VbeVersion);
+ vip->pInt10 = pInt;
+ vip->ddc = DDC_UNCHECKED;
+ vip->memory = page;
+ vip->real_mode_base = RealOff;
+ vip->num_pages = 1;
+ vip->init_int10 = init_int10;
+
+ return vip;
+
+ error:
+ if (page)
+ xf86Int10FreePages(pInt, page, 1);
+ if (init_int10)
+ xf86FreeInt10(pInt);
+ return NULL;
+}
+
+void
+vbeFree(vbeInfoPtr pVbe)
+{
+ if (!pVbe)
+ return;
+
+ xf86Int10FreePages(pVbe->pInt10,pVbe->memory,pVbe->num_pages);
+ /* If we have initalized int10 we ought to free it, too */
+ if (pVbe->init_int10)
+ xf86FreeInt10(pVbe->pInt10);
+ free(pVbe);
+ return;
+}
+
+static Bool
+vbeProbeDDC(vbeInfoPtr pVbe)
+{
+ char *ddc_level;
+ int screen = pVbe->pInt10->scrnIndex;
+
+ if (pVbe->ddc == DDC_NONE)
+ return FALSE;
+ if (pVbe->ddc != DDC_UNCHECKED)
+ return TRUE;
+
+ pVbe->pInt10->ax = 0x4F15;
+ pVbe->pInt10->bx = 0;
+ pVbe->pInt10->cx = 0;
+ pVbe->pInt10->es = 0;
+ pVbe->pInt10->di = 0;
+ pVbe->pInt10->num = 0x10;
+
+ xf86ExecX86int10(pVbe->pInt10);
+
+ if ((pVbe->pInt10->ax & 0xff) != 0x4f) {
+ xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE DDC not supported\n");
+ pVbe->ddc = DDC_NONE;
+ return FALSE;
+ }
+
+ switch ((pVbe->pInt10->ax >> 8) & 0xff) {
+ case 0:
+ xf86DrvMsg(screen,X_INFO,"VESA VBE DDC supported\n");
+ switch (pVbe->pInt10->bx & 0x3) {
+ case 0:
+ ddc_level = " none";
+ pVbe->ddc = DDC_NONE;
+ break;
+ case 1:
+ ddc_level = " 1";
+ pVbe->ddc = DDC_1;
+ break;
+ case 2:
+ ddc_level = " 2";
+ pVbe->ddc = DDC_2;
+ break;
+ case 3:
+ ddc_level = " 1 + 2";
+ pVbe->ddc = DDC_1_2;
+ break;
+ default:
+ ddc_level = "";
+ pVbe->ddc = DDC_NONE;
+ break;
+ }
+ xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE DDC Level%s\n",ddc_level);
+ if (pVbe->pInt10->bx & 0x4) {
+ xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE DDC Screen blanked"
+ "for data transfer\n");
+ pVbe->ddc_blank = TRUE;
+ } else
+ pVbe->ddc_blank = FALSE;
+
+ xf86DrvMsgVerb(screen,X_INFO,3,
+ "VESA VBE DDC transfer in appr. %x sec.\n",
+ (pVbe->pInt10->bx >> 8) & 0xff);
+ }
+
+ return TRUE;
+}
+
+typedef enum {
+ VBEOPT_NOVBE,
+ VBEOPT_NODDC
+} VBEOpts;
+
+static const OptionInfoRec VBEOptions[] = {
+ { VBEOPT_NOVBE, "NoVBE", OPTV_BOOLEAN, {0}, FALSE },
+ { VBEOPT_NODDC, "NoDDC", OPTV_BOOLEAN, {0}, FALSE },
+ { -1, NULL, OPTV_NONE, {0}, FALSE },
+};
+
+static unsigned char *
+vbeReadEDID(vbeInfoPtr pVbe)
+{
+ int RealOff = pVbe->real_mode_base;
+ pointer page = pVbe->memory;
+ unsigned char *tmp = NULL;
+ Bool novbe = FALSE;
+ Bool noddc = FALSE;
+ int screen = pVbe->pInt10->scrnIndex;
+ OptionInfoPtr options;
+
+ if (!page) return NULL;
+
+ options = xnfalloc(sizeof(VBEOptions));
+ (void)memcpy(options, VBEOptions, sizeof(VBEOptions));
+ xf86ProcessOptions(screen, xf86Screens[screen]->options, options);
+ xf86GetOptValBool(options, VBEOPT_NOVBE, &novbe);
+ xf86GetOptValBool(options, VBEOPT_NODDC, &noddc);
+ free(options);
+ if (novbe || noddc) return NULL;
+
+ if (!vbeProbeDDC(pVbe)) goto error;
+
+ memset(page,0,sizeof(vbeInfoPtr));
+ strcpy(page,vbeVersionString);
+
+ pVbe->pInt10->ax = 0x4F15;
+ pVbe->pInt10->bx = 0x01;
+ pVbe->pInt10->cx = 0;
+ pVbe->pInt10->dx = 0;
+ pVbe->pInt10->es = SEG_ADDR(RealOff);
+ pVbe->pInt10->di = SEG_OFF(RealOff);
+ pVbe->pInt10->num = 0x10;
+
+ xf86ExecX86int10(pVbe->pInt10);
+
+ if ((pVbe->pInt10->ax & 0xff) != 0x4f) {
+ xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE DDC invalid\n");
+ goto error;
+ }
+ switch (pVbe->pInt10->ax & 0xff00) {
+ case 0x0:
+ xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE DDC read successfully\n");
+ tmp = (unsigned char *)xnfalloc(128);
+ memcpy(tmp,page,128);
+ break;
+ case 0x100:
+ xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE DDC read failed\n");
+ break;
+ default:
+ xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE DDC unkown failure %i\n",
+ pVbe->pInt10->ax & 0xff00);
+ break;
+ }
+
+ error:
+ return tmp;
+}
+
+xf86MonPtr
+vbeDoEDID(vbeInfoPtr pVbe, pointer pDDCModule)
+{
+ xf86MonPtr pMonitor;
+ pointer pModule;
+ unsigned char *DDC_data = NULL;
+
+ if (!pVbe) return NULL;
+ if (pVbe->version < 0x200)
+ return NULL;
+
+ if (!(pModule = pDDCModule)) {
+ pModule =
+ xf86LoadSubModule(xf86Screens[pVbe->pInt10->scrnIndex], "ddc");
+ if (!pModule)
+ return NULL;
+ }
+
+ DDC_data = vbeReadEDID(pVbe);
+
+ if (!DDC_data)
+ return NULL;
+
+ pMonitor = xf86InterpretEDID(pVbe->pInt10->scrnIndex, DDC_data);
+
+ if (!pDDCModule)
+ xf86UnloadSubModule(pModule);
+ return pMonitor;
+}
+
+#define GET_UNALIGNED2(x) \
+ ((*(CARD16*)(x)) | (*(((CARD16*)(x) + 1))) << 16)
+
+VbeInfoBlock *
+VBEGetVBEInfo(vbeInfoPtr pVbe)
+{
+ VbeInfoBlock *block = NULL;
+ int i, pStr, pModes;
+ char *str;
+ CARD16 major, *modes;
+
+ memset(pVbe->memory, 0, sizeof(VbeInfoBlock));
+
+ /*
+ Input:
+ AH := 4Fh Super VGA support
+ AL := 00h Return Super VGA information
+ ES:DI := Pointer to buffer
+
+ Output:
+ AX := status
+ (All other registers are preserved)
+ */
+
+ ((char*)pVbe->memory)[0] = 'V';
+ ((char*)pVbe->memory)[1] = 'B';
+ ((char*)pVbe->memory)[2] = 'E';
+ ((char*)pVbe->memory)[3] = '2';
+
+ pVbe->pInt10->num = 0x10;
+ pVbe->pInt10->ax = 0x4f00;
+ pVbe->pInt10->es = SEG_ADDR(pVbe->real_mode_base);
+ pVbe->pInt10->di = SEG_OFF(pVbe->real_mode_base);
+ xf86ExecX86int10(pVbe->pInt10);
+
+ if (R16(pVbe->pInt10->ax) != 0x4f)
+ return NULL;
+
+ block = calloc(sizeof(VbeInfoBlock), 1);
+ block->VESASignature[0] = ((char*)pVbe->memory)[0];
+ block->VESASignature[1] = ((char*)pVbe->memory)[1];
+ block->VESASignature[2] = ((char*)pVbe->memory)[2];
+ block->VESASignature[3] = ((char*)pVbe->memory)[3];
+
+ block->VESAVersion = *(CARD16*)(((char*)pVbe->memory) + 4);
+ major = (unsigned)block->VESAVersion >> 8;
+
+ pStr = GET_UNALIGNED2((((char*)pVbe->memory) + 6));
+ str = xf86int10Addr(pVbe->pInt10, FARP(pStr));
+ block->OEMStringPtr = strdup(str);
+
+ block->Capabilities[0] = ((char*)pVbe->memory)[10];
+ block->Capabilities[1] = ((char*)pVbe->memory)[11];
+ block->Capabilities[2] = ((char*)pVbe->memory)[12];
+ block->Capabilities[3] = ((char*)pVbe->memory)[13];
+
+ pModes = GET_UNALIGNED2((((char*)pVbe->memory) + 14));
+ modes = xf86int10Addr(pVbe->pInt10, FARP(pModes));
+ i = 0;
+ while (modes[i] != 0xffff)
+ i++;
+ block->VideoModePtr = malloc(sizeof(CARD16) * (i + 1));
+ memcpy(block->VideoModePtr, modes, sizeof(CARD16) * i);
+ block->VideoModePtr[i] = 0xffff;
+
+ block->TotalMemory = *(CARD16*)(((char*)pVbe->memory) + 18);
+
+ if (major < 2)
+ memcpy(&block->OemSoftwareRev, ((char*)pVbe->memory) + 20, 236);
+ else {
+ block->OemSoftwareRev = *(CARD16*)(((char*)pVbe->memory) + 20);
+ pStr = GET_UNALIGNED2((((char*)pVbe->memory) + 22));
+ str = xf86int10Addr(pVbe->pInt10, FARP(pStr));
+ block->OemVendorNamePtr = strdup(str);
+ pStr = GET_UNALIGNED2((((char*)pVbe->memory) + 26));
+ str = xf86int10Addr(pVbe->pInt10, FARP(pStr));
+ block->OemProductNamePtr = strdup(str);
+ pStr = GET_UNALIGNED2((((char*)pVbe->memory) + 30));
+ str = xf86int10Addr(pVbe->pInt10, FARP(pStr));
+ block->OemProductRevPtr = strdup(str);
+ memcpy(&block->Reserved, ((char*)pVbe->memory) + 34, 222);
+ memcpy(&block->OemData, ((char*)pVbe->memory) + 256, 256);
+ }
+
+ return block;
+}
+
+void
+VBEFreeVBEInfo(VbeInfoBlock *block)
+{
+ free(block->OEMStringPtr);
+ free(block->VideoModePtr);
+ if (((unsigned)block->VESAVersion >> 8) >= 2) {
+ free(block->OemVendorNamePtr);
+ free(block->OemProductNamePtr);
+ free(block->OemProductRevPtr);
+ }
+ free(block);
+}
+
+Bool
+VBESetVBEMode(vbeInfoPtr pVbe, int mode, VbeCRTCInfoBlock *block)
+{
+ /*
+ Input:
+ AH := 4Fh Super VGA support
+ AL := 02h Set Super VGA video mode
+ BX := Video mode
+ D0-D8 := Mode number
+ D9-D10 := Reserved (must be 0)
+ D11 := 0 Use current default refresh rate
+ := 1 Use user specified CRTC values for refresh rate
+ D12-13 Reserved for VBE/AF (must be 0)
+ D14 := 0 Use windowed frame buffer model
+ := 1 Use linear/flat frame buffer model
+ D15 := 0 Clear video memory
+ := 1 Don't clear video memory
+ ES:DI := Pointer to VbeCRTCInfoBlock structure
+
+ Output: AX = Status
+ (All other registers are preserved)
+ */
+ pVbe->pInt10->num = 0x10;
+ pVbe->pInt10->ax = 0x4f02;
+ pVbe->pInt10->bx = mode;
+ if (block) {
+ pVbe->pInt10->bx |= 1 << 11;
+ memcpy(pVbe->memory, block, sizeof(VbeCRTCInfoBlock));
+ pVbe->pInt10->es = SEG_ADDR(pVbe->real_mode_base);
+ pVbe->pInt10->di = SEG_OFF(pVbe->real_mode_base);
+ } else
+ pVbe->pInt10->bx &= ~(1 << 11);
+
+ xf86ExecX86int10(pVbe->pInt10);
+
+ return (R16(pVbe->pInt10->ax) == 0x4f);
+}
+
+Bool
+VBEGetVBEMode(vbeInfoPtr pVbe, int *mode)
+{
+ /*
+ Input:
+ AH := 4Fh Super VGA support
+ AL := 03h Return current video mode
+
+ Output:
+ AX := Status
+ BX := Current video mode
+ (All other registers are preserved)
+ */
+ pVbe->pInt10->num = 0x10;
+ pVbe->pInt10->ax = 0x4f03;
+
+ xf86ExecX86int10(pVbe->pInt10);
+
+ if (R16(pVbe->pInt10->ax) == 0x4f) {
+ *mode = R16(pVbe->pInt10->bx);
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+VbeModeInfoBlock *
+VBEGetModeInfo(vbeInfoPtr pVbe, int mode)
+{
+ VbeModeInfoBlock *block = NULL;
+
+ memset(pVbe->memory, 0, sizeof(VbeModeInfoBlock));
+
+ /*
+ Input:
+ AH := 4Fh Super VGA support
+ AL := 01h Return Super VGA mode information
+ CX := Super VGA video mode
+ (mode number must be one of those returned by Function 0)
+ ES:DI := Pointer to buffer
+
+ Output:
+ AX := status
+ (All other registers are preserved)
+ */
+ pVbe->pInt10->num = 0x10;
+ pVbe->pInt10->ax = 0x4f01;
+ pVbe->pInt10->cx = mode;
+ pVbe->pInt10->es = SEG_ADDR(pVbe->real_mode_base);
+ pVbe->pInt10->di = SEG_OFF(pVbe->real_mode_base);
+ xf86ExecX86int10(pVbe->pInt10);
+ if (R16(pVbe->pInt10->ax) != 0x4f)
+ return NULL;
+
+ block = malloc(sizeof(VbeModeInfoBlock));
+ if (block)
+ memcpy(block, pVbe->memory, sizeof(*block));
+
+ return block;
+}
+
+void
+VBEFreeModeInfo(VbeModeInfoBlock *block)
+{
+ free(block);
+}
+
+Bool
+VBESaveRestore(vbeInfoPtr pVbe, vbeSaveRestoreFunction function,
+ pointer *memory, int *size, int *real_mode_pages)
+{
+ /*
+ Input:
+ AH := 4Fh Super VGA support
+ AL := 04h Save/restore Super VGA video state
+ DL := 00h Return save/restore state buffer size
+ CX := Requested states
+ D0 = Save/restore video hardware state
+ D1 = Save/restore video BIOS data state
+ D2 = Save/restore video DAC state
+ D3 = Save/restore Super VGA state
+
+ Output:
+ AX = Status
+ BX = Number of 64-byte blocks to hold the state buffer
+ (All other registers are preserved)
+
+
+ Input:
+ AH := 4Fh Super VGA support
+ AL := 04h Save/restore Super VGA video state
+ DL := 01h Save Super VGA video state
+ CX := Requested states (see above)
+ ES:BX := Pointer to buffer
+
+ Output:
+ AX := Status
+ (All other registers are preserved)
+
+
+ Input:
+ AH := 4Fh Super VGA support
+ AL := 04h Save/restore Super VGA video state
+ DL := 02h Restore Super VGA video state
+ CX := Requested states (see above)
+ ES:BX := Pointer to buffer
+
+ Output:
+ AX := Status
+ (All other registers are preserved)
+ */
+
+ if ((pVbe->version & 0xff00) > 0x100) {
+ int screen = pVbe->pInt10->scrnIndex;
+ if (function == MODE_QUERY ||
+ (function == MODE_SAVE && !*memory)) {
+ /* Query amount of memory to save state */
+
+ pVbe->pInt10->num = 0x10;
+ pVbe->pInt10->ax = 0x4f04;
+ pVbe->pInt10->dx = 0;
+ pVbe->pInt10->cx = 0x000f;
+ xf86ExecX86int10(pVbe->pInt10);
+ if (R16(pVbe->pInt10->ax) != 0x4f)
+ return FALSE;
+
+ if (function == MODE_SAVE) {
+ int npages = (R16(pVbe->pInt10->bx) * 64) / 4096 + 1;
+ if ((*memory = xf86Int10AllocPages(pVbe->pInt10, npages,
+ real_mode_pages)) == NULL) {
+ xf86DrvMsg(screen, X_ERROR,
+ "Cannot allocate memory to save SVGA state.\n");
+ return FALSE;
+ }
+ }
+ *size = pVbe->pInt10->bx * 64;
+ }
+
+ /* Save/Restore Super VGA state */
+ if (function != MODE_QUERY) {
+
+ if (!*memory) return FALSE;
+ pVbe->pInt10->num = 0x10;
+ pVbe->pInt10->ax = 0x4f04;
+ switch (function) {
+ case MODE_SAVE:
+ pVbe->pInt10->dx = 1;
+ break;
+ case MODE_RESTORE:
+ pVbe->pInt10->dx = 2;
+ break;
+ case MODE_QUERY:
+ return FALSE;
+ }
+ pVbe->pInt10->cx = 0x000f;
+
+ pVbe->pInt10->es = SEG_ADDR(*real_mode_pages);
+ pVbe->pInt10->bx = SEG_OFF(*real_mode_pages);
+ xf86ExecX86int10(pVbe->pInt10);
+ return (R16(pVbe->pInt10->ax) == 0x4f);
+
+ }
+ }
+ return TRUE;
+}
+
+Bool
+VBEBankSwitch(vbeInfoPtr pVbe, unsigned int iBank, int window)
+{
+ /*
+ Input:
+ AH := 4Fh Super VGA support
+ AL := 05h
+
+ Output:
+ */
+ pVbe->pInt10->num = 0x10;
+ pVbe->pInt10->ax = 0x4f05;
+ pVbe->pInt10->bx = window;
+ pVbe->pInt10->dx = iBank;
+ xf86ExecX86int10(pVbe->pInt10);
+
+ if (R16(pVbe->pInt10->ax) != 0x4f)
+ return FALSE;
+
+ return TRUE;
+}
+
+Bool
+VBESetGetLogicalScanlineLength(vbeInfoPtr pVbe, vbeScanwidthCommand command,
+ int width, int *pixels, int *bytes, int *max)
+{
+ if (command < SCANWID_SET || command > SCANWID_GET_MAX)
+ return FALSE;
+
+ /*
+ Input:
+ AX := 4F06h VBE Set/Get Logical Scan Line Length
+ BL := 00h Set Scan Line Length in Pixels
+ := 01h Get Scan Line Length
+ := 02h Set Scan Line Length in Bytes
+ := 03h Get Maximum Scan Line Length
+ CX := If BL=00h Desired Width in Pixels
+ If BL=02h Desired Width in Bytes
+ (Ignored for Get Functions)
+
+ Output:
+ AX := VBE Return Status
+ BX := Bytes Per Scan Line
+ CX := Actual Pixels Per Scan Line
+ (truncated to nearest complete pixel)
+ DX := Maximum Number of Scan Lines
+ */
+
+ pVbe->pInt10->num = 0x10;
+ pVbe->pInt10->ax = 0x4f06;
+ pVbe->pInt10->bx = command;
+ if (command == SCANWID_SET || command == SCANWID_SET_BYTES)
+ pVbe->pInt10->cx = width;
+ xf86ExecX86int10(pVbe->pInt10);
+
+ if (R16(pVbe->pInt10->ax) != 0x4f)
+ return FALSE;
+
+ if (command == SCANWID_GET || command == SCANWID_GET_MAX) {
+ if (pixels)
+ *pixels = R16(pVbe->pInt10->cx);
+ if (bytes)
+ *bytes = R16(pVbe->pInt10->bx);
+ if (max)
+ *max = R16(pVbe->pInt10->dx);
+ }
+
+ return TRUE;
+}
+
+Bool
+VBESetDisplayStart(vbeInfoPtr pVbe, int x, int y, Bool wait_retrace)
+{
+ pVbe->pInt10->num = 0x10;
+ pVbe->pInt10->ax = 0x4f07;
+ pVbe->pInt10->bx = wait_retrace ? 0x80 : 0x00;
+ pVbe->pInt10->cx = x;
+ pVbe->pInt10->dx = y;
+ xf86ExecX86int10(pVbe->pInt10);
+
+ if (R16(pVbe->pInt10->ax) != 0x4f)
+ return FALSE;
+
+ return TRUE;
+}
+
+Bool
+VBEGetDisplayStart(vbeInfoPtr pVbe, int *x, int *y)
+{
+ pVbe->pInt10->num = 0x10;
+ pVbe->pInt10->ax = 0x4f07;
+ pVbe->pInt10->bx = 0x01;
+ xf86ExecX86int10(pVbe->pInt10);
+
+ if (R16(pVbe->pInt10->ax) != 0x4f)
+ return FALSE;
+
+ *x = pVbe->pInt10->cx;
+ *y = pVbe->pInt10->dx;
+
+ return TRUE;
+}
+
+int
+VBESetGetDACPaletteFormat(vbeInfoPtr pVbe, int bits)
+{
+ /*
+ Input:
+ AX := 4F08h VBE Set/Get Palette Format
+ BL := 00h Set DAC Palette Format
+ := 01h Get DAC Palette Format
+ BH := Desired bits of color per primary
+ (Set DAC Palette Format only)
+
+ Output:
+ AX := VBE Return Status
+ BH := Current number of bits of color per primary
+ */
+
+ pVbe->pInt10->num = 0x10;
+ pVbe->pInt10->ax = 0x4f08;
+ if (!bits)
+ pVbe->pInt10->bx = 0x01;
+ else
+ pVbe->pInt10->bx = (bits & 0x00ff) << 8;
+ xf86ExecX86int10(pVbe->pInt10);
+
+ if (R16(pVbe->pInt10->ax) != 0x4f)
+ return 0;
+
+ return (bits != 0 ? bits : (pVbe->pInt10->bx >> 8) & 0x00ff);
+}
+
+CARD32 *
+VBESetGetPaletteData(vbeInfoPtr pVbe, Bool set, int first, int num,
+ CARD32 *data, Bool secondary, Bool wait_retrace)
+{
+ /*
+ Input:
+ (16-bit)
+ AX := 4F09h VBE Load/Unload Palette Data
+ BL := 00h Set Palette Data
+ := 01h Get Palette Data
+ := 02h Set Secondary Palette Data
+ := 03h Get Secondary Palette Data
+ := 80h Set Palette Data during Vertical Retrace
+ CX := Number of palette registers to update (to a maximum of 256)
+ DX := First of the palette registers to update (start)
+ ES:DI := Table of palette values (see below for format)
+
+ Output:
+ AX := VBE Return Status
+
+
+ Input:
+ (32-bit)
+ BL := 00h Set Palette Data
+ := 80h Set Palette Data during Vertical Retrace
+ CX := Number of palette registers to update (to a maximum of 256)
+ DX := First of the palette registers to update (start)
+ ES:EDI := Table of palette values (see below for format)
+ DS := Selector for memory mapped registers
+ */
+
+ pVbe->pInt10->num = 0x10;
+ pVbe->pInt10->ax = 0x4f09;
+ if (!secondary)
+ pVbe->pInt10->bx = set && wait_retrace ? 0x80 : set ? 0 : 1;
+ else
+ pVbe->pInt10->bx = set ? 2 : 3;
+ pVbe->pInt10->cx = num;
+ pVbe->pInt10->dx = first;
+ pVbe->pInt10->es = SEG_ADDR(pVbe->real_mode_base);
+ pVbe->pInt10->di = SEG_OFF(pVbe->real_mode_base);
+ if (set)
+ memcpy(pVbe->memory, data, num * sizeof(CARD32));
+ xf86ExecX86int10(pVbe->pInt10);
+
+ if (R16(pVbe->pInt10->ax) != 0x4f)
+ return NULL;
+
+ if (set)
+ return data;
+
+ data = malloc(num * sizeof(CARD32));
+ memcpy(data, pVbe->memory, num * sizeof(CARD32));
+
+ return data;
+}
+
+VBEpmi *
+VBEGetVBEpmi(vbeInfoPtr pVbe)
+{
+ VBEpmi *pmi;
+
+ /*
+ Input:
+ AH := 4Fh Super VGA support
+ AL := 0Ah Protected Mode Interface
+ BL := 00h Return Protected Mode Table
+
+ Output:
+ AX := Status
+ ES := Real Mode Segment of Table
+ DI := Offset of Table
+ CX := Lenght of Table including protected mode code in bytes (for copying purposes)
+ (All other registers are preserved)
+ */
+
+ pVbe->pInt10->num = 0x10;
+ pVbe->pInt10->ax = 0x4f0a;
+ pVbe->pInt10->bx = 0;
+ pVbe->pInt10->di = 0;
+ xf86ExecX86int10(pVbe->pInt10);
+
+ if (R16(pVbe->pInt10->ax) != 0x4f)
+ return NULL;
+
+ pmi = malloc(sizeof(VBEpmi));
+ pmi->seg_tbl = R16(pVbe->pInt10->es);
+ pmi->tbl_off = R16(pVbe->pInt10->di);
+ pmi->tbl_len = R16(pVbe->pInt10->cx);
+
+ return pmi;
+}
+
+#if 0
+vbeModeInfoPtr
+VBEBuildVbeModeList(vbeInfoPtr pVbe, VbeInfoBlock *vbe)
+{
+ vbeModeInfoPtr ModeList = NULL;
+
+ int i = 0;
+ while (vbe->VideoModePtr[i] != 0xffff) {
+ vbeModeInfoPtr m;
+ VbeModeInfoBlock *mode;
+ int id = vbe->VideoModePtr[i++];
+ int bpp;
+
+ if ((mode = VBEGetModeInfo(pVbe, id)) == NULL)
+ continue;
+
+ bpp = mode->BitsPerPixel;
+
+ m = xnfcalloc(sizeof(vbeModeInfoRec),1);
+ m->width = mode->XResolution;
+ m->height = mode->YResolution;
+ m->bpp = bpp;
+ m->n = id;
+ m->next = ModeList;
+
+ xf86DrvMsgVerb(pVbe->pInt10->scrnIndex, X_PROBED, 3,
+ "BIOS reported VESA mode 0x%x: x:%i y:%i bpp:%i\n",
+ m->n, m->width, m->height, m->bpp);
+
+ ModeList = m;
+
+ VBEFreeModeInfo(mode);
+ }
+ return ModeList;
+}
+
+unsigned short
+VBECalcVbeModeIndex(vbeModeInfoPtr m, DisplayModePtr mode, int bpp)
+{
+ while (m) {
+ if (bpp == m->bpp
+ && mode->HDisplay == m->width
+ && mode->VDisplay == m->height)
+ return m->n;
+ m = m->next;
+ }
+ return 0;
+}
+#endif
+
+void
+VBEVesaSaveRestore(vbeInfoPtr pVbe, vbeSaveRestorePtr vbe_sr,
+ vbeSaveRestoreFunction function)
+{
+ Bool SaveSucc = FALSE;
+
+ if (VBE_VERSION_MAJOR(pVbe->version) > 1
+ && (function == MODE_SAVE || vbe_sr->pstate)) {
+ if (function == MODE_RESTORE)
+ memcpy(vbe_sr->state, vbe_sr->pstate, vbe_sr->stateSize);
+ ErrorF("VBESaveRestore\n");
+ if ((VBESaveRestore(pVbe,function,
+ (pointer)&vbe_sr->state,
+ &vbe_sr->stateSize,&vbe_sr->statePage))) {
+ if (function == MODE_SAVE) {
+ SaveSucc = TRUE;
+ vbe_sr->stateMode = -1; /* invalidate */
+ /* don't rely on the memory not being touched */
+ if (vbe_sr->pstate == NULL)
+ vbe_sr->pstate = malloc(vbe_sr->stateSize);
+ memcpy(vbe_sr->pstate, vbe_sr->state, vbe_sr->stateSize);
+ }
+ ErrorF("VBESaveRestore done with success\n");
+ return;
+ }
+ ErrorF("VBESaveRestore done\n");
+ }
+
+ if (function == MODE_SAVE && !SaveSucc)
+ (void)VBEGetVBEMode(pVbe, &vbe_sr->stateMode);
+
+ if (function == MODE_RESTORE && vbe_sr->stateMode != -1)
+ VBESetVBEMode(pVbe, vbe_sr->stateMode, NULL);
+
+}
+
+int
+VBEGetPixelClock(vbeInfoPtr pVbe, int mode, int clock)
+{
+ /*
+ Input:
+ AX := 4F0Bh VBE Get Pixel Clock
+ BL := 00h Get Pixel Clock
+ ECX := pixel clock in units of Hz
+ DX := mode number
+
+ Output:
+ AX := VBE Return Status
+ ECX := Closest pixel clock
+ */
+
+ pVbe->pInt10->num = 0x10;
+ pVbe->pInt10->ax = 0x4f0b;
+ pVbe->pInt10->bx = 0x00;
+ pVbe->pInt10->cx = clock;
+ pVbe->pInt10->dx = mode;
+ xf86ExecX86int10(pVbe->pInt10);
+
+ if (R16(pVbe->pInt10->ax) != 0x4f)
+ return 0;
+
+ return pVbe->pInt10->cx;
+}
+
+Bool
+VBEDPMSSet(vbeInfoPtr pVbe, int mode)
+{
+ /*
+ Input:
+ AX := 4F10h DPMS
+ BL := 01h Set Display Power State
+ BH := requested power state
+
+ Output:
+ AX := VBE Return Status
+ */
+
+ pVbe->pInt10->num = 0x10;
+ pVbe->pInt10->ax = 0x4f10;
+ pVbe->pInt10->bx = 0x01;
+ switch (mode) {
+ case DPMSModeOn:
+ break;
+ case DPMSModeStandby:
+ pVbe->pInt10->bx |= 0x100;
+ break;
+ case DPMSModeSuspend:
+ pVbe->pInt10->bx |= 0x200;
+ break;
+ case DPMSModeOff:
+ pVbe->pInt10->bx |= 0x400;
+ break;
+ }
+ xf86ExecX86int10(pVbe->pInt10);
+ return (R16(pVbe->pInt10->ax) == 0x4f);
+}
+
+void
+VBEInterpretPanelID(int scrnIndex, struct vbePanelID *data)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ DisplayModePtr mode;
+ const float PANEL_HZ = 60.0;
+
+ if (!data)
+ return;
+
+ xf86DrvMsg(scrnIndex, X_INFO, "PanelID returned panel resolution %dx%d\n",
+ data->hsize, data->vsize);
+
+ if (pScrn->monitor->nHsync || pScrn->monitor->nVrefresh)
+ return;
+
+ if (data->hsize < 320 || data->vsize < 240) {
+ xf86DrvMsg(scrnIndex, X_INFO, "...which I refuse to believe\n");
+ return;
+ }
+
+ mode = xf86CVTMode(data->hsize, data->vsize, PANEL_HZ, 1, 0);
+
+ pScrn->monitor->nHsync = 1;
+ pScrn->monitor->hsync[0].lo = 31.5;
+ pScrn->monitor->hsync[0].hi = (float)mode->Clock / (float)mode->HTotal;
+ pScrn->monitor->nVrefresh = 1;
+ pScrn->monitor->vrefresh[0].lo = 56.0;
+ pScrn->monitor->vrefresh[0].hi =
+ (float)mode->Clock*1000.0 / (float)mode->HTotal / (float)mode->VTotal;
+
+ free(mode);
+}
+
+struct vbePanelID *
+VBEReadPanelID(vbeInfoPtr pVbe)
+{
+ int RealOff = pVbe->real_mode_base;
+ pointer page = pVbe->memory;
+ void *tmp = NULL;
+ int screen = pVbe->pInt10->scrnIndex;
+
+ pVbe->pInt10->ax = 0x4F11;
+ pVbe->pInt10->bx = 0x01;
+ pVbe->pInt10->cx = 0;
+ pVbe->pInt10->dx = 0;
+ pVbe->pInt10->es = SEG_ADDR(RealOff);
+ pVbe->pInt10->di = SEG_OFF(RealOff);
+ pVbe->pInt10->num = 0x10;
+
+ xf86ExecX86int10(pVbe->pInt10);
+
+ if ((pVbe->pInt10->ax & 0xff) != 0x4f) {
+ xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE PanelID invalid\n");
+ goto error;
+ }
+
+ switch (pVbe->pInt10->ax & 0xff00) {
+ case 0x0:
+ xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE PanelID read successfully\n");
+ tmp = xnfalloc(32);
+ memcpy(tmp, page, 32);
+ break;
+ case 0x100:
+ xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE PanelID read failed\n");
+ break;
+ default:
+ xf86DrvMsgVerb(screen,X_INFO,3,"VESA VBE PanelID unknown failure %i\n",
+ pVbe->pInt10->ax & 0xff00);
+ break;
+ }
+
+error:
+ return tmp;
+}
diff --git a/xorg-server/hw/xnest/Events.c b/xorg-server/hw/xnest/Events.c
index 2abc6c73c..619427ded 100644
--- a/xorg-server/hw/xnest/Events.c
+++ b/xorg-server/hw/xnest/Events.c
@@ -1,217 +1,217 @@
-/*
-
-Copyright 1993 by Davor Matic
-
-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. Davor Matic makes no representations about
-the suitability of this software for any purpose. It is provided "as
-is" without express or implied warranty.
-
-*/
-
-#ifdef HAVE_XNEST_CONFIG_H
-#include <xnest-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include "screenint.h"
-#include "input.h"
-#include "misc.h"
-#include "scrnintstr.h"
-#include "windowstr.h"
-#include "servermd.h"
-#include "inputstr.h"
-#include "inpututils.h"
-
-#include "mi.h"
-
-#include "Xnest.h"
-
-#include "Args.h"
-#include "Color.h"
-#include "Display.h"
-#include "Screen.h"
-#include "XNWindow.h"
-#include "Events.h"
-#include "Keyboard.h"
-#include "Pointer.h"
-#include "mipointer.h"
-
-CARD32 lastEventTime = 0;
-
-void
-ProcessInputEvents(void)
-{
- mieqProcessInputEvents();
-}
-
-int
-TimeSinceLastInputEvent(void)
-{
- if (lastEventTime == 0)
- lastEventTime = GetTimeInMillis();
- return GetTimeInMillis() - lastEventTime;
-}
-
-void
-SetTimeSinceLastInputEvent(void)
-{
- lastEventTime = GetTimeInMillis();
-}
-
-static Bool
-xnestExposurePredicate(Display *display, XEvent *event, char *args)
-{
- return event->type == Expose || event->type == ProcessedExpose;
-}
-
-static Bool
-xnestNotExposurePredicate(Display *display, XEvent *event, char *args)
-{
- return !xnestExposurePredicate(display, event, args);
-}
-
-void
-xnestCollectExposures(void)
-{
- XEvent X;
- WindowPtr pWin;
- RegionRec Rgn;
- BoxRec Box;
-
- while (XCheckIfEvent(xnestDisplay, &X, xnestExposurePredicate, NULL)) {
- pWin = xnestWindowPtr(X.xexpose.window);
-
- if (pWin && X.xexpose.width && X.xexpose.height) {
- Box.x1 = pWin->drawable.x + wBorderWidth(pWin) + X.xexpose.x;
- Box.y1 = pWin->drawable.y + wBorderWidth(pWin) + X.xexpose.y;
- Box.x2 = Box.x1 + X.xexpose.width;
- Box.y2 = Box.y1 + X.xexpose.height;
-
- RegionInit(&Rgn, &Box, 1);
-
- miSendExposures(pWin, &Rgn, Box.x2, Box.y2);
- }
- }
-}
-
-void
-xnestQueueKeyEvent(int type, unsigned int keycode)
-{
- lastEventTime = GetTimeInMillis();
- QueueKeyboardEvents(xnestKeyboardDevice, type, keycode, NULL);
-}
-
-void
-xnestCollectEvents(void)
-{
- XEvent X;
- int valuators[2];
- ValuatorMask mask;
- ScreenPtr pScreen;
-
- while (XCheckIfEvent(xnestDisplay, &X, xnestNotExposurePredicate, NULL)) {
- switch (X.type) {
- case KeyPress:
- xnestUpdateModifierState(X.xkey.state);
- xnestQueueKeyEvent(KeyPress, X.xkey.keycode);
- break;
-
- case KeyRelease:
- xnestUpdateModifierState(X.xkey.state);
- xnestQueueKeyEvent(KeyRelease, X.xkey.keycode);
- break;
-
- case ButtonPress:
- valuator_mask_set_range(&mask, 0, 0, NULL);
- xnestUpdateModifierState(X.xkey.state);
- lastEventTime = GetTimeInMillis();
- QueuePointerEvents(xnestPointerDevice, ButtonPress,
- X.xbutton.button, POINTER_RELATIVE, &mask);
- break;
-
- case ButtonRelease:
- valuator_mask_set_range(&mask, 0, 0, NULL);
- xnestUpdateModifierState(X.xkey.state);
- lastEventTime = GetTimeInMillis();
- QueuePointerEvents(xnestPointerDevice, ButtonRelease,
- X.xbutton.button, POINTER_RELATIVE, &mask);
- break;
-
- case MotionNotify:
- valuators[0] = X.xmotion.x;
- valuators[1] = X.xmotion.y;
- valuator_mask_set_range(&mask, 0, 2, valuators);
- lastEventTime = GetTimeInMillis();
- QueuePointerEvents(xnestPointerDevice, MotionNotify,
- 0, POINTER_ABSOLUTE, &mask);
- break;
-
- case FocusIn:
- if (X.xfocus.detail != NotifyInferior) {
- pScreen = xnestScreen(X.xfocus.window);
- if (pScreen)
- xnestDirectInstallColormaps(pScreen);
- }
- break;
-
- case FocusOut:
- if (X.xfocus.detail != NotifyInferior) {
- pScreen = xnestScreen(X.xfocus.window);
- if (pScreen)
- xnestDirectUninstallColormaps(pScreen);
- }
- break;
-
- case KeymapNotify:
- break;
-
- case EnterNotify:
- if (X.xcrossing.detail != NotifyInferior) {
- pScreen = xnestScreen(X.xcrossing.window);
- if (pScreen) {
- NewCurrentScreen(inputInfo.pointer, pScreen, X.xcrossing.x, X.xcrossing.y);
- valuators[0] = X.xcrossing.x;
- valuators[1] = X.xcrossing.y;
- valuator_mask_set_range(&mask, 0, 2, valuators);
- lastEventTime = GetTimeInMillis();
- QueuePointerEvents(xnestPointerDevice, MotionNotify,
- 0, POINTER_ABSOLUTE, &mask);
- xnestDirectInstallColormaps(pScreen);
- }
- }
- break;
-
- case LeaveNotify:
- if (X.xcrossing.detail != NotifyInferior) {
- pScreen = xnestScreen(X.xcrossing.window);
- if (pScreen) {
- xnestDirectUninstallColormaps(pScreen);
- }
- }
- break;
-
- case DestroyNotify:
- if (xnestParentWindow != (Window) 0 &&
- X.xdestroywindow.window == xnestParentWindow)
- exit (0);
- break;
-
- case CirculateNotify:
- case ConfigureNotify:
- case GravityNotify:
- case MapNotify:
- case ReparentNotify:
- case UnmapNotify:
- break;
-
- default:
- ErrorF("xnest warning: unhandled event\n");
- break;
- }
- }
-}
+/*
+
+Copyright 1993 by Davor Matic
+
+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. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+
+#ifdef HAVE_XNEST_CONFIG_H
+#include <xnest-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "screenint.h"
+#include "input.h"
+#include "misc.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "servermd.h"
+#include "inputstr.h"
+#include "inpututils.h"
+
+#include "mi.h"
+
+#include "Xnest.h"
+
+#include "Args.h"
+#include "Color.h"
+#include "Display.h"
+#include "Screen.h"
+#include "XNWindow.h"
+#include "Events.h"
+#include "Keyboard.h"
+#include "Pointer.h"
+#include "mipointer.h"
+
+CARD32 lastEventTime = 0;
+
+void
+ProcessInputEvents(void)
+{
+ mieqProcessInputEvents();
+}
+
+int
+TimeSinceLastInputEvent(void)
+{
+ if (lastEventTime == 0)
+ lastEventTime = GetTimeInMillis();
+ return GetTimeInMillis() - lastEventTime;
+}
+
+void
+SetTimeSinceLastInputEvent(void)
+{
+ lastEventTime = GetTimeInMillis();
+}
+
+static Bool
+xnestExposurePredicate(Display *display, XEvent *event, char *args)
+{
+ return event->type == Expose || event->type == ProcessedExpose;
+}
+
+static Bool
+xnestNotExposurePredicate(Display *display, XEvent *event, char *args)
+{
+ return !xnestExposurePredicate(display, event, args);
+}
+
+void
+xnestCollectExposures(void)
+{
+ XEvent X;
+ WindowPtr pWin;
+ RegionRec Rgn;
+ BoxRec Box;
+
+ while (XCheckIfEvent(xnestDisplay, &X, xnestExposurePredicate, NULL)) {
+ pWin = xnestWindowPtr(X.xexpose.window);
+
+ if (pWin && X.xexpose.width && X.xexpose.height) {
+ Box.x1 = pWin->drawable.x + wBorderWidth(pWin) + X.xexpose.x;
+ Box.y1 = pWin->drawable.y + wBorderWidth(pWin) + X.xexpose.y;
+ Box.x2 = Box.x1 + X.xexpose.width;
+ Box.y2 = Box.y1 + X.xexpose.height;
+
+ RegionInit(&Rgn, &Box, 1);
+
+ miSendExposures(pWin, &Rgn, Box.x2, Box.y2);
+ }
+ }
+}
+
+void
+xnestQueueKeyEvent(int type, unsigned int keycode)
+{
+ lastEventTime = GetTimeInMillis();
+ QueueKeyboardEvents(xnestKeyboardDevice, type, keycode, NULL);
+}
+
+void
+xnestCollectEvents(void)
+{
+ XEvent X;
+ int valuators[2];
+ ValuatorMask mask;
+ ScreenPtr pScreen;
+
+ while (XCheckIfEvent(xnestDisplay, &X, xnestNotExposurePredicate, NULL)) {
+ switch (X.type) {
+ case KeyPress:
+ xnestUpdateModifierState(X.xkey.state);
+ xnestQueueKeyEvent(KeyPress, X.xkey.keycode);
+ break;
+
+ case KeyRelease:
+ xnestUpdateModifierState(X.xkey.state);
+ xnestQueueKeyEvent(KeyRelease, X.xkey.keycode);
+ break;
+
+ case ButtonPress:
+ valuator_mask_set_range(&mask, 0, 0, NULL);
+ xnestUpdateModifierState(X.xkey.state);
+ lastEventTime = GetTimeInMillis();
+ QueuePointerEvents(xnestPointerDevice, ButtonPress,
+ X.xbutton.button, POINTER_RELATIVE, &mask);
+ break;
+
+ case ButtonRelease:
+ valuator_mask_set_range(&mask, 0, 0, NULL);
+ xnestUpdateModifierState(X.xkey.state);
+ lastEventTime = GetTimeInMillis();
+ QueuePointerEvents(xnestPointerDevice, ButtonRelease,
+ X.xbutton.button, POINTER_RELATIVE, &mask);
+ break;
+
+ case MotionNotify:
+ valuators[0] = X.xmotion.x;
+ valuators[1] = X.xmotion.y;
+ valuator_mask_set_range(&mask, 0, 2, valuators);
+ lastEventTime = GetTimeInMillis();
+ QueuePointerEvents(xnestPointerDevice, MotionNotify,
+ 0, POINTER_ABSOLUTE, &mask);
+ break;
+
+ case FocusIn:
+ if (X.xfocus.detail != NotifyInferior) {
+ pScreen = xnestScreen(X.xfocus.window);
+ if (pScreen)
+ xnestDirectInstallColormaps(pScreen);
+ }
+ break;
+
+ case FocusOut:
+ if (X.xfocus.detail != NotifyInferior) {
+ pScreen = xnestScreen(X.xfocus.window);
+ if (pScreen)
+ xnestDirectUninstallColormaps(pScreen);
+ }
+ break;
+
+ case KeymapNotify:
+ break;
+
+ case EnterNotify:
+ if (X.xcrossing.detail != NotifyInferior) {
+ pScreen = xnestScreen(X.xcrossing.window);
+ if (pScreen) {
+ NewCurrentScreen(inputInfo.pointer, pScreen, X.xcrossing.x, X.xcrossing.y);
+ valuators[0] = X.xcrossing.x;
+ valuators[1] = X.xcrossing.y;
+ valuator_mask_set_range(&mask, 0, 2, valuators);
+ lastEventTime = GetTimeInMillis();
+ QueuePointerEvents(xnestPointerDevice, MotionNotify,
+ 0, POINTER_ABSOLUTE, &mask);
+ xnestDirectInstallColormaps(pScreen);
+ }
+ }
+ break;
+
+ case LeaveNotify:
+ if (X.xcrossing.detail != NotifyInferior) {
+ pScreen = xnestScreen(X.xcrossing.window);
+ if (pScreen) {
+ xnestDirectUninstallColormaps(pScreen);
+ }
+ }
+ break;
+
+ case DestroyNotify:
+ if (xnestParentWindow != (Window) 0 &&
+ X.xdestroywindow.window == xnestParentWindow)
+ exit (0);
+ break;
+
+ case CirculateNotify:
+ case ConfigureNotify:
+ case GravityNotify:
+ case MapNotify:
+ case ReparentNotify:
+ case UnmapNotify:
+ break;
+
+ default:
+ ErrorF("xnest warning: unhandled event\n");
+ break;
+ }
+ }
+}
diff --git a/xorg-server/hw/xnest/Init.c b/xorg-server/hw/xnest/Init.c
index 263565977..af57518ba 100644
--- a/xorg-server/hw/xnest/Init.c
+++ b/xorg-server/hw/xnest/Init.c
@@ -1,151 +1,151 @@
-/*
-
-Copyright 1993 by Davor Matic
-
-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. Davor Matic makes no representations about
-the suitability of this software for any purpose. It is provided "as
-is" without express or implied warranty.
-
-*/
-
-#ifdef HAVE_XNEST_CONFIG_H
-#include <xnest-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include "screenint.h"
-#include "input.h"
-#include "misc.h"
-#include "scrnintstr.h"
-#include "windowstr.h"
-#include "servermd.h"
-#include "mi.h"
-#include <X11/fonts/fontstruct.h>
-
-#include "Xnest.h"
-
-#include "Display.h"
-#include "Screen.h"
-#include "Pointer.h"
-#include "Keyboard.h"
-#include "Handlers.h"
-#include "Init.h"
-#include "Args.h"
-#include "Drawable.h"
-#include "XNGC.h"
-#include "XNFont.h"
-#ifdef DPMSExtension
-#include "dpmsproc.h"
-#endif
-
-Bool xnestDoFullGeneration = True;
-
-void
-InitOutput(ScreenInfo *screenInfo, int argc, char *argv[])
-{
- int i, j;
-
- xnestOpenDisplay(argc, argv);
-
- screenInfo->imageByteOrder = ImageByteOrder(xnestDisplay);
- screenInfo->bitmapScanlineUnit = BitmapUnit(xnestDisplay);
- screenInfo->bitmapScanlinePad = BitmapPad(xnestDisplay);
- screenInfo->bitmapBitOrder = BitmapBitOrder(xnestDisplay);
-
- screenInfo->numPixmapFormats = 0;
- for (i = 0; i < xnestNumPixmapFormats; i++)
- for (j = 0; j < xnestNumDepths; j++)
- if ((xnestPixmapFormats[i].depth == 1) ||
- (xnestPixmapFormats[i].depth == xnestDepths[j])) {
- screenInfo->formats[screenInfo->numPixmapFormats].depth =
- xnestPixmapFormats[i].depth;
- screenInfo->formats[screenInfo->numPixmapFormats].bitsPerPixel =
- xnestPixmapFormats[i].bits_per_pixel;
- screenInfo->formats[screenInfo->numPixmapFormats].scanlinePad =
- xnestPixmapFormats[i].scanline_pad;
- screenInfo->numPixmapFormats++;
- break;
- }
-
- xnestFontPrivateIndex = AllocateFontPrivateIndex();
-
- if (!xnestNumScreens) xnestNumScreens = 1;
-
- for (i = 0; i < xnestNumScreens; i++)
- AddScreen(xnestOpenScreen, argc, argv);
-
- xnestNumScreens = screenInfo->numScreens;
-
- xnestDoFullGeneration = xnestFullGeneration;
-}
-
-void
-InitInput(int argc, char *argv[])
-{
- int rc;
- rc = AllocDevicePair(serverClient, "Xnest",
- &xnestPointerDevice,
- &xnestKeyboardDevice,
- xnestPointerProc,
- xnestKeyboardProc,
- FALSE);
-
- if (rc != Success)
- FatalError("Failed to init Xnest default devices.\n");
-
- mieqInit();
-
- AddEnabledDevice(XConnectionNumber(xnestDisplay));
-
- RegisterBlockAndWakeupHandlers(xnestBlockHandler, xnestWakeupHandler, NULL);
-}
-
-void
-CloseInput(void)
-{
- mieqFini();
-}
-
-/*
- * DDX - specific abort routine. Called by AbortServer().
- */
-void AbortDDX(enum ExitCode error)
-{
- xnestDoFullGeneration = True;
- xnestCloseDisplay();
-}
-
-/* Called by GiveUp(). */
-void ddxGiveUp(enum ExitCode error)
-{
- AbortDDX(error);
-}
-
-#ifdef __APPLE__
-void
-DarwinHandleGUI(int argc, char *argv[])
-{
-}
-#endif
-
-void OsVendorInit(void)
-{
- return;
-}
-
-void OsVendorFatalError(void)
-{
- return;
-}
-
-#if defined(DDXBEFORERESET)
-void ddxBeforeReset(void)
-{
- return;
-}
-#endif
+/*
+
+Copyright 1993 by Davor Matic
+
+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. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+
+#ifdef HAVE_XNEST_CONFIG_H
+#include <xnest-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "screenint.h"
+#include "input.h"
+#include "misc.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "servermd.h"
+#include "mi.h"
+#include <X11/fonts/fontstruct.h>
+
+#include "Xnest.h"
+
+#include "Display.h"
+#include "Screen.h"
+#include "Pointer.h"
+#include "Keyboard.h"
+#include "Handlers.h"
+#include "Init.h"
+#include "Args.h"
+#include "Drawable.h"
+#include "XNGC.h"
+#include "XNFont.h"
+#ifdef DPMSExtension
+#include "dpmsproc.h"
+#endif
+
+Bool xnestDoFullGeneration = True;
+
+void
+InitOutput(ScreenInfo *screenInfo, int argc, char *argv[])
+{
+ int i, j;
+
+ xnestOpenDisplay(argc, argv);
+
+ screenInfo->imageByteOrder = ImageByteOrder(xnestDisplay);
+ screenInfo->bitmapScanlineUnit = BitmapUnit(xnestDisplay);
+ screenInfo->bitmapScanlinePad = BitmapPad(xnestDisplay);
+ screenInfo->bitmapBitOrder = BitmapBitOrder(xnestDisplay);
+
+ screenInfo->numPixmapFormats = 0;
+ for (i = 0; i < xnestNumPixmapFormats; i++)
+ for (j = 0; j < xnestNumDepths; j++)
+ if ((xnestPixmapFormats[i].depth == 1) ||
+ (xnestPixmapFormats[i].depth == xnestDepths[j])) {
+ screenInfo->formats[screenInfo->numPixmapFormats].depth =
+ xnestPixmapFormats[i].depth;
+ screenInfo->formats[screenInfo->numPixmapFormats].bitsPerPixel =
+ xnestPixmapFormats[i].bits_per_pixel;
+ screenInfo->formats[screenInfo->numPixmapFormats].scanlinePad =
+ xnestPixmapFormats[i].scanline_pad;
+ screenInfo->numPixmapFormats++;
+ break;
+ }
+
+ xnestFontPrivateIndex = AllocateFontPrivateIndex();
+
+ if (!xnestNumScreens) xnestNumScreens = 1;
+
+ for (i = 0; i < xnestNumScreens; i++)
+ AddScreen(xnestOpenScreen, argc, argv);
+
+ xnestNumScreens = screenInfo->numScreens;
+
+ xnestDoFullGeneration = xnestFullGeneration;
+}
+
+void
+InitInput(int argc, char *argv[])
+{
+ int rc;
+ rc = AllocDevicePair(serverClient, "Xnest",
+ &xnestPointerDevice,
+ &xnestKeyboardDevice,
+ xnestPointerProc,
+ xnestKeyboardProc,
+ FALSE);
+
+ if (rc != Success)
+ FatalError("Failed to init Xnest default devices.\n");
+
+ mieqInit();
+
+ AddEnabledDevice(XConnectionNumber(xnestDisplay));
+
+ RegisterBlockAndWakeupHandlers(xnestBlockHandler, xnestWakeupHandler, NULL);
+}
+
+void
+CloseInput(void)
+{
+ mieqFini();
+}
+
+/*
+ * DDX - specific abort routine. Called by AbortServer().
+ */
+void AbortDDX(enum ExitCode error)
+{
+ xnestDoFullGeneration = True;
+ xnestCloseDisplay();
+}
+
+/* Called by GiveUp(). */
+void ddxGiveUp(enum ExitCode error)
+{
+ AbortDDX(error);
+}
+
+#ifdef __APPLE__
+void
+DarwinHandleGUI(int argc, char *argv[])
+{
+}
+#endif
+
+void OsVendorInit(void)
+{
+ return;
+}
+
+void OsVendorFatalError(void)
+{
+ return;
+}
+
+#if defined(DDXBEFORERESET)
+void ddxBeforeReset(void)
+{
+ return;
+}
+#endif
diff --git a/xorg-server/hw/xnest/Pixmap.c b/xorg-server/hw/xnest/Pixmap.c
index acbe1a7cb..eccf56986 100644
--- a/xorg-server/hw/xnest/Pixmap.c
+++ b/xorg-server/hw/xnest/Pixmap.c
@@ -1,136 +1,136 @@
-/*
-
-Copyright 1993 by Davor Matic
-
-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. Davor Matic makes no representations about
-the suitability of this software for any purpose. It is provided "as
-is" without express or implied warranty.
-
-*/
-
-#ifdef HAVE_XNEST_CONFIG_H
-#include <xnest-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include "regionstr.h"
-#include "pixmapstr.h"
-#include "scrnintstr.h"
-#include "gc.h"
-#include "servermd.h"
-#include "privates.h"
-#include "mi.h"
-
-#include "Xnest.h"
-
-#include "Display.h"
-#include "Screen.h"
-#include "XNPixmap.h"
-
-DevPrivateKeyRec xnestPixmapPrivateKeyRec;
-
-PixmapPtr
-xnestCreatePixmap(ScreenPtr pScreen, int width, int height, int depth,
- unsigned usage_hint)
-{
- PixmapPtr pPixmap;
-
- pPixmap = AllocatePixmap(pScreen, 0);
- if (!pPixmap)
- return NullPixmap;
- pPixmap->drawable.type = DRAWABLE_PIXMAP;
- pPixmap->drawable.class = 0;
- pPixmap->drawable.depth = depth;
- pPixmap->drawable.bitsPerPixel = depth;
- pPixmap->drawable.id = 0;
- pPixmap->drawable.x = 0;
- pPixmap->drawable.y = 0;
- pPixmap->drawable.width = width;
- pPixmap->drawable.height = height;
- pPixmap->drawable.pScreen = pScreen;
- pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
- pPixmap->refcnt = 1;
- pPixmap->devKind = PixmapBytePad(width, depth);
- pPixmap->usage_hint = usage_hint;
- if (width && height)
- xnestPixmapPriv(pPixmap)->pixmap =
- XCreatePixmap(xnestDisplay,
- xnestDefaultWindows[pScreen->myNum],
- width, height, depth);
- else
- xnestPixmapPriv(pPixmap)->pixmap = 0;
-
- return pPixmap;
-}
-
-Bool
-xnestDestroyPixmap(PixmapPtr pPixmap)
-{
- if(--pPixmap->refcnt)
- return TRUE;
- XFreePixmap(xnestDisplay, xnestPixmap(pPixmap));
- FreePixmap(pPixmap);
- return TRUE;
-}
-
-RegionPtr
-xnestPixmapToRegion(PixmapPtr pPixmap)
-{
- XImage *ximage;
- register RegionPtr pReg, pTmpReg;
- register int x, y;
- unsigned long previousPixel, currentPixel;
- BoxRec Box = { 0, 0, 0, 0 };
- Bool overlap;
-
- ximage = XGetImage(xnestDisplay, xnestPixmap(pPixmap), 0, 0,
- pPixmap->drawable.width, pPixmap->drawable.height,
- 1, XYPixmap);
-
- pReg = RegionCreate(NULL, 1);
- pTmpReg = RegionCreate(NULL, 1);
- if(!pReg || !pTmpReg) {
- XDestroyImage(ximage);
- return NullRegion;
- }
-
- for (y = 0; y < pPixmap->drawable.height; y++) {
- Box.y1 = y;
- Box.y2 = y + 1;
- previousPixel = 0L;
- for (x = 0; x < pPixmap->drawable.width; x++) {
- currentPixel = XGetPixel(ximage, x, y);
- if (previousPixel != currentPixel) {
- if (previousPixel == 0L) {
- /* left edge */
- Box.x1 = x;
- }
- else if (currentPixel == 0L) {
- /* right edge */
- Box.x2 = x;
- RegionReset(pTmpReg, &Box);
- RegionAppend(pReg, pTmpReg);
- }
- previousPixel = currentPixel;
- }
- }
- if (previousPixel != 0L) {
- /* right edge because of the end of pixmap */
- Box.x2 = pPixmap->drawable.width;
- RegionReset(pTmpReg, &Box);
- RegionAppend(pReg, pTmpReg);
- }
- }
-
- RegionDestroy(pTmpReg);
- XDestroyImage(ximage);
-
- RegionValidate(pReg, &overlap);
-
- return pReg;
-}
+/*
+
+Copyright 1993 by Davor Matic
+
+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. Davor Matic makes no representations about
+the suitability of this software for any purpose. It is provided "as
+is" without express or implied warranty.
+
+*/
+
+#ifdef HAVE_XNEST_CONFIG_H
+#include <xnest-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "regionstr.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "gc.h"
+#include "servermd.h"
+#include "privates.h"
+#include "mi.h"
+
+#include "Xnest.h"
+
+#include "Display.h"
+#include "Screen.h"
+#include "XNPixmap.h"
+
+DevPrivateKeyRec xnestPixmapPrivateKeyRec;
+
+PixmapPtr
+xnestCreatePixmap(ScreenPtr pScreen, int width, int height, int depth,
+ unsigned usage_hint)
+{
+ PixmapPtr pPixmap;
+
+ pPixmap = AllocatePixmap(pScreen, 0);
+ if (!pPixmap)
+ return NullPixmap;
+ pPixmap->drawable.type = DRAWABLE_PIXMAP;
+ pPixmap->drawable.class = 0;
+ pPixmap->drawable.depth = depth;
+ pPixmap->drawable.bitsPerPixel = depth;
+ pPixmap->drawable.id = 0;
+ pPixmap->drawable.x = 0;
+ pPixmap->drawable.y = 0;
+ pPixmap->drawable.width = width;
+ pPixmap->drawable.height = height;
+ pPixmap->drawable.pScreen = pScreen;
+ pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ pPixmap->refcnt = 1;
+ pPixmap->devKind = PixmapBytePad(width, depth);
+ pPixmap->usage_hint = usage_hint;
+ if (width && height)
+ xnestPixmapPriv(pPixmap)->pixmap =
+ XCreatePixmap(xnestDisplay,
+ xnestDefaultWindows[pScreen->myNum],
+ width, height, depth);
+ else
+ xnestPixmapPriv(pPixmap)->pixmap = 0;
+
+ return pPixmap;
+}
+
+Bool
+xnestDestroyPixmap(PixmapPtr pPixmap)
+{
+ if(--pPixmap->refcnt)
+ return TRUE;
+ XFreePixmap(xnestDisplay, xnestPixmap(pPixmap));
+ FreePixmap(pPixmap);
+ return TRUE;
+}
+
+RegionPtr
+xnestPixmapToRegion(PixmapPtr pPixmap)
+{
+ XImage *ximage;
+ register RegionPtr pReg, pTmpReg;
+ register int x, y;
+ unsigned long previousPixel, currentPixel;
+ BoxRec Box = { 0, 0, 0, 0 };
+ Bool overlap;
+
+ ximage = XGetImage(xnestDisplay, xnestPixmap(pPixmap), 0, 0,
+ pPixmap->drawable.width, pPixmap->drawable.height,
+ 1, XYPixmap);
+
+ pReg = RegionCreate(NULL, 1);
+ pTmpReg = RegionCreate(NULL, 1);
+ if(!pReg || !pTmpReg) {
+ XDestroyImage(ximage);
+ return NullRegion;
+ }
+
+ for (y = 0; y < pPixmap->drawable.height; y++) {
+ Box.y1 = y;
+ Box.y2 = y + 1;
+ previousPixel = 0L;
+ for (x = 0; x < pPixmap->drawable.width; x++) {
+ currentPixel = XGetPixel(ximage, x, y);
+ if (previousPixel != currentPixel) {
+ if (previousPixel == 0L) {
+ /* left edge */
+ Box.x1 = x;
+ }
+ else if (currentPixel == 0L) {
+ /* right edge */
+ Box.x2 = x;
+ RegionReset(pTmpReg, &Box);
+ RegionAppend(pReg, pTmpReg);
+ }
+ previousPixel = currentPixel;
+ }
+ }
+ if (previousPixel != 0L) {
+ /* right edge because of the end of pixmap */
+ Box.x2 = pPixmap->drawable.width;
+ RegionReset(pTmpReg, &Box);
+ RegionAppend(pReg, pTmpReg);
+ }
+ }
+
+ RegionDestroy(pTmpReg);
+ XDestroyImage(ximage);
+
+ RegionValidate(pReg, &overlap);
+
+ return pReg;
+}
diff --git a/xorg-server/hw/xquartz/GL/capabilities.c b/xorg-server/hw/xquartz/GL/capabilities.c
index da52cc7c4..dd3f855f4 100644
--- a/xorg-server/hw/xquartz/GL/capabilities.c
+++ b/xorg-server/hw/xquartz/GL/capabilities.c
@@ -1,543 +1,543 @@
-/*
- * Copyright (c) 2008 Apple 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 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.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-#include <OpenGL/OpenGL.h>
-#include <OpenGL/gl.h>
-#include <OpenGL/glu.h>
-#include <OpenGL/glext.h>
-#include <ApplicationServices/ApplicationServices.h>
-
-#include "capabilities.h"
-
-#define Cursor X_Cursor
-#include "os.h"
-#undef Cursor
-
-static void handleBufferModes(struct glCapabilitiesConfig *c, GLint bufferModes) {
- if(bufferModes & kCGLStereoscopicBit) {
- c->stereo = true;
- }
-
- if(bufferModes & kCGLDoubleBufferBit) {
- c->buffers = 2;
- } else {
- c->buffers = 1;
- }
-}
-
-static void handleStencilModes(struct glCapabilitiesConfig *c, GLint smodes) {
- int offset = 0;
-
- if(kCGL0Bit & smodes)
- c->stencil_bit_depths[offset++] = 0;
-
- if(kCGL1Bit & smodes)
- c->stencil_bit_depths[offset++] = 1;
-
- if(kCGL2Bit & smodes)
- c->stencil_bit_depths[offset++] = 2;
-
- if(kCGL3Bit & smodes)
- c->stencil_bit_depths[offset++] = 3;
-
- if(kCGL4Bit & smodes)
- c->stencil_bit_depths[offset++] = 4;
-
- if(kCGL5Bit & smodes)
- c->stencil_bit_depths[offset++] = 5;
-
- if(kCGL6Bit & smodes)
- c->stencil_bit_depths[offset++] = 6;
-
- if(kCGL8Bit & smodes)
- c->stencil_bit_depths[offset++] = 8;
-
- if(kCGL10Bit & smodes)
- c->stencil_bit_depths[offset++] = 10;
-
- if(kCGL12Bit & smodes)
- c->stencil_bit_depths[offset++] = 12;
-
- if(kCGL16Bit & smodes)
- c->stencil_bit_depths[offset++] = 16;
-
- if(kCGL24Bit & smodes)
- c->stencil_bit_depths[offset++] = 24;
-
- if(kCGL32Bit & smodes)
- c->stencil_bit_depths[offset++] = 32;
-
- if(kCGL48Bit & smodes)
- c->stencil_bit_depths[offset++] = 48;
-
- if(kCGL64Bit & smodes)
- c->stencil_bit_depths[offset++] = 64;
-
- if(kCGL96Bit & smodes)
- c->stencil_bit_depths[offset++] = 96;
-
- if(kCGL128Bit & smodes)
- c->stencil_bit_depths[offset++] = 128;
-
- assert(offset < GLCAPS_STENCIL_BIT_DEPTH_BUFFERS);
-
- c->total_stencil_bit_depths = offset;
-}
-
-static int handleColorAndAccumulation(struct glColorBufCapabilities *c,
- GLint cmodes, int forAccum) {
- int offset = 0;
-
- /*1*/
- if(kCGLRGB444Bit & cmodes) {
- c[offset].r = 4;
- c[offset].g = 4;
- c[offset].b = 4;
- ++offset;
- }
-
- /*2*/
- if(kCGLARGB4444Bit & cmodes) {
- c[offset].a = 4;
- c[offset].r = 4;
- c[offset].g = 4;
- c[offset].b = 4;
- c[offset].is_argb = true;
- ++offset;
- }
-
- /*3*/
- if(kCGLRGB444A8Bit & cmodes) {
- c[offset].r = 4;
- c[offset].g = 4;
- c[offset].b = 4;
- c[offset].a = 8;
- ++offset;
- }
-
- /*4*/
- if(kCGLRGB555Bit & cmodes) {
- c[offset].r = 5;
- c[offset].g = 5;
- c[offset].b = 5;
- ++offset;
- }
-
- /*5*/
- if(kCGLARGB1555Bit & cmodes) {
- c[offset].a = 1;
- c[offset].r = 5;
- c[offset].g = 5;
- c[offset].b = 5;
- c[offset].is_argb = true;
- ++offset;
- }
-
- /*6*/
- if(kCGLRGB555A8Bit & cmodes) {
- c[offset].r = 5;
- c[offset].g = 5;
- c[offset].b = 5;
- c[offset].a = 8;
- ++offset;
- }
-
- /*7*/
- if(kCGLRGB565Bit & cmodes) {
- c[offset].r = 5;
- c[offset].g = 6;
- c[offset].b = 5;
- ++offset;
- }
-
- /*8*/
- if(kCGLRGB565A8Bit & cmodes) {
- c[offset].r = 5;
- c[offset].g = 6;
- c[offset].b = 5;
- c[offset].a = 8;
- ++offset;
- }
-
- /*9*/
- if(kCGLRGB888Bit & cmodes) {
- c[offset].r = 8;
- c[offset].g = 8;
- c[offset].b = 8;
- ++offset;
- }
-
- /*10*/
- if(kCGLARGB8888Bit & cmodes) {
- c[offset].a = 8;
- c[offset].r = 8;
- c[offset].g = 8;
- c[offset].b = 8;
- c[offset].is_argb = true;
- ++offset;
- }
-
- /*11*/
- if(kCGLRGB888A8Bit & cmodes) {
- c[offset].r = 8;
- c[offset].g = 8;
- c[offset].b = 8;
- c[offset].a = 8;
- ++offset;
- }
-
- if(forAccum) {
-//#if 0
- /* FIXME
- * Disable this path, because some part of libGL, X, or Xplugin
- * doesn't work with sizes greater than 8.
- * When this is enabled and visuals are chosen using depths
- * such as 16, the result is that the windows don't redraw
- * and are often white, until a resize.
- */
-
- /*12*/
- if(kCGLRGB101010Bit & cmodes) {
- c[offset].r = 10;
- c[offset].g = 10;
- c[offset].b = 10;
- ++offset;
- }
-
- /*13*/
- if(kCGLARGB2101010Bit & cmodes) {
- c[offset].a = 2;
- c[offset].r = 10;
- c[offset].g = 10;
- c[offset].b = 10;
- c[offset].is_argb = true;
- ++offset;
- }
-
- /*14*/
- if(kCGLRGB101010_A8Bit & cmodes) {
- c[offset].r = 10;
- c[offset].g = 10;
- c[offset].b = 10;
- c[offset].a = 8;
- ++offset;
- }
-
- /*15*/
- if(kCGLRGB121212Bit & cmodes) {
- c[offset].r = 12;
- c[offset].g = 12;
- c[offset].b = 12;
- ++offset;
- }
-
- /*16*/
- if(kCGLARGB12121212Bit & cmodes) {
- c[offset].a = 12;
- c[offset].r = 12;
- c[offset].g = 12;
- c[offset].b = 12;
- c[offset].is_argb = true;
- ++offset;
- }
-
- /*17*/
- if(kCGLRGB161616Bit & cmodes) {
- c[offset].r = 16;
- c[offset].g = 16;
- c[offset].b = 16;
- ++offset;
- }
-
- /*18*/
- if(kCGLRGBA16161616Bit & cmodes) {
- c[offset].r = 16;
- c[offset].g = 16;
- c[offset].b = 16;
- c[offset].a = 16;
- ++offset;
- }
- }
-//#endif
-
- /* FIXME should we handle the floating point color modes, and if so, how? */
-
- return offset;
-}
-
-
-static void handleColorModes(struct glCapabilitiesConfig *c, GLint cmodes) {
- c->total_color_buffers = handleColorAndAccumulation(c->color_buffers,
- cmodes, 0);
-
- assert(c->total_color_buffers < GLCAPS_COLOR_BUFFERS);
-}
-
-static void handleAccumulationModes(struct glCapabilitiesConfig *c, GLint cmodes) {
- c->total_accum_buffers = handleColorAndAccumulation(c->accum_buffers,
- cmodes, 1);
- assert(c->total_accum_buffers < GLCAPS_COLOR_BUFFERS);
-}
-
-static void handleDepthModes(struct glCapabilitiesConfig *c, GLint dmodes) {
- int offset = 0;
-#define DEPTH(flag,value) do { \
- if(dmodes & flag) { \
- c->depth_buffers[offset++] = value; \
- } \
- } while(0)
-
- /*1*/
- DEPTH(kCGL0Bit, 0);
- /*2*/
- DEPTH(kCGL1Bit, 1);
- /*3*/
- DEPTH(kCGL2Bit, 2);
- /*4*/
- DEPTH(kCGL3Bit, 3);
- /*5*/
- DEPTH(kCGL4Bit, 4);
- /*6*/
- DEPTH(kCGL5Bit, 5);
- /*7*/
- DEPTH(kCGL6Bit, 6);
- /*8*/
- DEPTH(kCGL8Bit, 8);
- /*9*/
- DEPTH(kCGL10Bit, 10);
- /*10*/
- DEPTH(kCGL12Bit, 12);
- /*11*/
- DEPTH(kCGL16Bit, 16);
- /*12*/
- DEPTH(kCGL24Bit, 24);
- /*13*/
- DEPTH(kCGL32Bit, 32);
- /*14*/
- DEPTH(kCGL48Bit, 48);
- /*15*/
- DEPTH(kCGL64Bit, 64);
- /*16*/
- DEPTH(kCGL96Bit, 96);
- /*17*/
- DEPTH(kCGL128Bit, 128);
-
-#undef DEPTH
-
- c->total_depth_buffer_depths = offset;
- assert(c->total_depth_buffer_depths < GLCAPS_DEPTH_BUFFERS);
-}
-
-/* Return non-zero if an error occured. */
-static CGLError handleRendererDescriptions(CGLRendererInfoObj info, GLint r,
- struct glCapabilitiesConfig *c) {
- CGLError err;
- GLint accelerated = 0, flags = 0, aux = 0, samplebufs = 0, samples = 0;
-
- err = CGLDescribeRenderer (info, r, kCGLRPAccelerated, &accelerated);
-
- if(err)
- return err;
-
- c->accelerated = accelerated;
-
- /* Buffering modes: single/double, stereo */
- err = CGLDescribeRenderer(info, r, kCGLRPBufferModes, &flags);
-
- if(err)
- return err;
-
- handleBufferModes(c, flags);
-
- /* AUX buffers */
- err = CGLDescribeRenderer(info, r, kCGLRPMaxAuxBuffers, &aux);
-
- if(err)
- return err;
-
- c->aux_buffers = aux;
-
-
- /* Depth buffer size */
- err = CGLDescribeRenderer(info, r, kCGLRPDepthModes, &flags);
-
- if(err)
- return err;
-
- handleDepthModes(c, flags);
-
-
- /* Multisample buffers */
- err = CGLDescribeRenderer(info, r, kCGLRPMaxSampleBuffers, &samplebufs);
-
- if(err)
- return err;
-
- c->multisample_buffers = samplebufs;
-
-
- /* Multisample samples per multisample buffer */
- err = CGLDescribeRenderer(info, r, kCGLRPMaxSamples, &samples);
-
- if(err)
- return err;
-
- c->multisample_samples = samples;
-
-
- /* Stencil bit depths */
- err = CGLDescribeRenderer(info, r, kCGLRPStencilModes, &flags);
-
- if(err)
- return err;
-
- handleStencilModes(c, flags);
-
-
- /* Color modes (RGB/RGBA depths supported */
- err = CGLDescribeRenderer(info, r, kCGLRPColorModes, &flags);
-
- if(err)
- return err;
-
- handleColorModes(c, flags);
-
- err = CGLDescribeRenderer(info, r, kCGLRPAccumModes, &flags);
-
- if(err)
- return err;
-
- handleAccumulationModes(c, flags);
-
- return kCGLNoError;
-}
-
-static void initCapabilities(struct glCapabilities *cap) {
- cap->configurations = NULL;
- cap->total_configurations = 0;
-}
-
-static void initConfig(struct glCapabilitiesConfig *c) {
- int i;
-
- c->accelerated = false;
- c->stereo = false;
- c->aux_buffers = 0;
- c->buffers = 0;
-
- c->total_depth_buffer_depths = 0;
-
- for(i = 0; i < GLCAPS_DEPTH_BUFFERS; ++i) {
- c->depth_buffers[i] = GLCAPS_INVALID_DEPTH_VALUE;
- }
-
- c->multisample_buffers = 0;
- c->multisample_samples = 0;
-
- c->total_stencil_bit_depths = 0;
-
- for(i = 0; i < GLCAPS_STENCIL_BIT_DEPTH_BUFFERS; ++i) {
- c->stencil_bit_depths[i] = GLCAPS_INVALID_STENCIL_DEPTH;
- }
-
- c->total_color_buffers = 0;
-
- for(i = 0; i < GLCAPS_COLOR_BUFFERS; ++i) {
- c->color_buffers[i].r = c->color_buffers[i].g =
- c->color_buffers[i].b = c->color_buffers[i].a =
- GLCAPS_COLOR_BUF_INVALID_VALUE;
- c->color_buffers[i].is_argb = false;
- }
-
- c->total_accum_buffers = 0;
-
- for(i = 0; i < GLCAPS_COLOR_BUFFERS; ++i) {
- c->accum_buffers[i].r = c->accum_buffers[i].g =
- c->accum_buffers[i].b = c->accum_buffers[i].a =
- GLCAPS_COLOR_BUF_INVALID_VALUE;
- c->accum_buffers[i].is_argb = false;
- }
-
- c->next = NULL;
-}
-
-void freeGlCapabilities(struct glCapabilities *cap) {
- struct glCapabilitiesConfig *conf, *next;
-
- conf = cap->configurations;
-
- while(conf) {
- next = conf->next;
- free(conf);
- conf = next;
- }
-
- cap->configurations = NULL;
-}
-
-/*Return true if an error occured. */
-bool getGlCapabilities(struct glCapabilities *cap) {
- CGLRendererInfoObj info;
- CGLError err;
- GLint numRenderers = 0, r;
-
- initCapabilities(cap);
-
- err = CGLQueryRendererInfo((GLuint)-1, &info, &numRenderers);
- if(err) {
- ErrorF("CGLQueryRendererInfo error: %s\n", CGLErrorString(err));
- return err;
- }
-
- for(r = 0; r < numRenderers; r++) {
- struct glCapabilitiesConfig tmpconf, *conf;
-
- initConfig(&tmpconf);
-
- err = handleRendererDescriptions(info, r, &tmpconf);
- if(err) {
- ErrorF("handleRendererDescriptions returned error: %s\n", CGLErrorString(err));
- ErrorF("trying to continue...\n");
- continue;
- }
-
- conf = malloc(sizeof(*conf));
- if(NULL == conf) {
- FatalError("Unable to allocate memory for OpenGL capabilities\n");
- }
-
- /* Copy the struct. */
- *conf = tmpconf;
-
- /* Now link the configuration into the list. */
- conf->next = cap->configurations;
- cap->configurations = conf;
- }
-
- CGLDestroyRendererInfo(info);
-
- /* No error occured. We are done. */
- return kCGLNoError;
-}
+/*
+ * Copyright (c) 2008 Apple 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 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.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <OpenGL/OpenGL.h>
+#include <OpenGL/gl.h>
+#include <OpenGL/glu.h>
+#include <OpenGL/glext.h>
+#include <ApplicationServices/ApplicationServices.h>
+
+#include "capabilities.h"
+
+#define Cursor X_Cursor
+#include "os.h"
+#undef Cursor
+
+static void handleBufferModes(struct glCapabilitiesConfig *c, GLint bufferModes) {
+ if(bufferModes & kCGLStereoscopicBit) {
+ c->stereo = true;
+ }
+
+ if(bufferModes & kCGLDoubleBufferBit) {
+ c->buffers = 2;
+ } else {
+ c->buffers = 1;
+ }
+}
+
+static void handleStencilModes(struct glCapabilitiesConfig *c, GLint smodes) {
+ int offset = 0;
+
+ if(kCGL0Bit & smodes)
+ c->stencil_bit_depths[offset++] = 0;
+
+ if(kCGL1Bit & smodes)
+ c->stencil_bit_depths[offset++] = 1;
+
+ if(kCGL2Bit & smodes)
+ c->stencil_bit_depths[offset++] = 2;
+
+ if(kCGL3Bit & smodes)
+ c->stencil_bit_depths[offset++] = 3;
+
+ if(kCGL4Bit & smodes)
+ c->stencil_bit_depths[offset++] = 4;
+
+ if(kCGL5Bit & smodes)
+ c->stencil_bit_depths[offset++] = 5;
+
+ if(kCGL6Bit & smodes)
+ c->stencil_bit_depths[offset++] = 6;
+
+ if(kCGL8Bit & smodes)
+ c->stencil_bit_depths[offset++] = 8;
+
+ if(kCGL10Bit & smodes)
+ c->stencil_bit_depths[offset++] = 10;
+
+ if(kCGL12Bit & smodes)
+ c->stencil_bit_depths[offset++] = 12;
+
+ if(kCGL16Bit & smodes)
+ c->stencil_bit_depths[offset++] = 16;
+
+ if(kCGL24Bit & smodes)
+ c->stencil_bit_depths[offset++] = 24;
+
+ if(kCGL32Bit & smodes)
+ c->stencil_bit_depths[offset++] = 32;
+
+ if(kCGL48Bit & smodes)
+ c->stencil_bit_depths[offset++] = 48;
+
+ if(kCGL64Bit & smodes)
+ c->stencil_bit_depths[offset++] = 64;
+
+ if(kCGL96Bit & smodes)
+ c->stencil_bit_depths[offset++] = 96;
+
+ if(kCGL128Bit & smodes)
+ c->stencil_bit_depths[offset++] = 128;
+
+ assert(offset < GLCAPS_STENCIL_BIT_DEPTH_BUFFERS);
+
+ c->total_stencil_bit_depths = offset;
+}
+
+static int handleColorAndAccumulation(struct glColorBufCapabilities *c,
+ GLint cmodes, int forAccum) {
+ int offset = 0;
+
+ /*1*/
+ if(kCGLRGB444Bit & cmodes) {
+ c[offset].r = 4;
+ c[offset].g = 4;
+ c[offset].b = 4;
+ ++offset;
+ }
+
+ /*2*/
+ if(kCGLARGB4444Bit & cmodes) {
+ c[offset].a = 4;
+ c[offset].r = 4;
+ c[offset].g = 4;
+ c[offset].b = 4;
+ c[offset].is_argb = true;
+ ++offset;
+ }
+
+ /*3*/
+ if(kCGLRGB444A8Bit & cmodes) {
+ c[offset].r = 4;
+ c[offset].g = 4;
+ c[offset].b = 4;
+ c[offset].a = 8;
+ ++offset;
+ }
+
+ /*4*/
+ if(kCGLRGB555Bit & cmodes) {
+ c[offset].r = 5;
+ c[offset].g = 5;
+ c[offset].b = 5;
+ ++offset;
+ }
+
+ /*5*/
+ if(kCGLARGB1555Bit & cmodes) {
+ c[offset].a = 1;
+ c[offset].r = 5;
+ c[offset].g = 5;
+ c[offset].b = 5;
+ c[offset].is_argb = true;
+ ++offset;
+ }
+
+ /*6*/
+ if(kCGLRGB555A8Bit & cmodes) {
+ c[offset].r = 5;
+ c[offset].g = 5;
+ c[offset].b = 5;
+ c[offset].a = 8;
+ ++offset;
+ }
+
+ /*7*/
+ if(kCGLRGB565Bit & cmodes) {
+ c[offset].r = 5;
+ c[offset].g = 6;
+ c[offset].b = 5;
+ ++offset;
+ }
+
+ /*8*/
+ if(kCGLRGB565A8Bit & cmodes) {
+ c[offset].r = 5;
+ c[offset].g = 6;
+ c[offset].b = 5;
+ c[offset].a = 8;
+ ++offset;
+ }
+
+ /*9*/
+ if(kCGLRGB888Bit & cmodes) {
+ c[offset].r = 8;
+ c[offset].g = 8;
+ c[offset].b = 8;
+ ++offset;
+ }
+
+ /*10*/
+ if(kCGLARGB8888Bit & cmodes) {
+ c[offset].a = 8;
+ c[offset].r = 8;
+ c[offset].g = 8;
+ c[offset].b = 8;
+ c[offset].is_argb = true;
+ ++offset;
+ }
+
+ /*11*/
+ if(kCGLRGB888A8Bit & cmodes) {
+ c[offset].r = 8;
+ c[offset].g = 8;
+ c[offset].b = 8;
+ c[offset].a = 8;
+ ++offset;
+ }
+
+ if(forAccum) {
+//#if 0
+ /* FIXME
+ * Disable this path, because some part of libGL, X, or Xplugin
+ * doesn't work with sizes greater than 8.
+ * When this is enabled and visuals are chosen using depths
+ * such as 16, the result is that the windows don't redraw
+ * and are often white, until a resize.
+ */
+
+ /*12*/
+ if(kCGLRGB101010Bit & cmodes) {
+ c[offset].r = 10;
+ c[offset].g = 10;
+ c[offset].b = 10;
+ ++offset;
+ }
+
+ /*13*/
+ if(kCGLARGB2101010Bit & cmodes) {
+ c[offset].a = 2;
+ c[offset].r = 10;
+ c[offset].g = 10;
+ c[offset].b = 10;
+ c[offset].is_argb = true;
+ ++offset;
+ }
+
+ /*14*/
+ if(kCGLRGB101010_A8Bit & cmodes) {
+ c[offset].r = 10;
+ c[offset].g = 10;
+ c[offset].b = 10;
+ c[offset].a = 8;
+ ++offset;
+ }
+
+ /*15*/
+ if(kCGLRGB121212Bit & cmodes) {
+ c[offset].r = 12;
+ c[offset].g = 12;
+ c[offset].b = 12;
+ ++offset;
+ }
+
+ /*16*/
+ if(kCGLARGB12121212Bit & cmodes) {
+ c[offset].a = 12;
+ c[offset].r = 12;
+ c[offset].g = 12;
+ c[offset].b = 12;
+ c[offset].is_argb = true;
+ ++offset;
+ }
+
+ /*17*/
+ if(kCGLRGB161616Bit & cmodes) {
+ c[offset].r = 16;
+ c[offset].g = 16;
+ c[offset].b = 16;
+ ++offset;
+ }
+
+ /*18*/
+ if(kCGLRGBA16161616Bit & cmodes) {
+ c[offset].r = 16;
+ c[offset].g = 16;
+ c[offset].b = 16;
+ c[offset].a = 16;
+ ++offset;
+ }
+ }
+//#endif
+
+ /* FIXME should we handle the floating point color modes, and if so, how? */
+
+ return offset;
+}
+
+
+static void handleColorModes(struct glCapabilitiesConfig *c, GLint cmodes) {
+ c->total_color_buffers = handleColorAndAccumulation(c->color_buffers,
+ cmodes, 0);
+
+ assert(c->total_color_buffers < GLCAPS_COLOR_BUFFERS);
+}
+
+static void handleAccumulationModes(struct glCapabilitiesConfig *c, GLint cmodes) {
+ c->total_accum_buffers = handleColorAndAccumulation(c->accum_buffers,
+ cmodes, 1);
+ assert(c->total_accum_buffers < GLCAPS_COLOR_BUFFERS);
+}
+
+static void handleDepthModes(struct glCapabilitiesConfig *c, GLint dmodes) {
+ int offset = 0;
+#define DEPTH(flag,value) do { \
+ if(dmodes & flag) { \
+ c->depth_buffers[offset++] = value; \
+ } \
+ } while(0)
+
+ /*1*/
+ DEPTH(kCGL0Bit, 0);
+ /*2*/
+ DEPTH(kCGL1Bit, 1);
+ /*3*/
+ DEPTH(kCGL2Bit, 2);
+ /*4*/
+ DEPTH(kCGL3Bit, 3);
+ /*5*/
+ DEPTH(kCGL4Bit, 4);
+ /*6*/
+ DEPTH(kCGL5Bit, 5);
+ /*7*/
+ DEPTH(kCGL6Bit, 6);
+ /*8*/
+ DEPTH(kCGL8Bit, 8);
+ /*9*/
+ DEPTH(kCGL10Bit, 10);
+ /*10*/
+ DEPTH(kCGL12Bit, 12);
+ /*11*/
+ DEPTH(kCGL16Bit, 16);
+ /*12*/
+ DEPTH(kCGL24Bit, 24);
+ /*13*/
+ DEPTH(kCGL32Bit, 32);
+ /*14*/
+ DEPTH(kCGL48Bit, 48);
+ /*15*/
+ DEPTH(kCGL64Bit, 64);
+ /*16*/
+ DEPTH(kCGL96Bit, 96);
+ /*17*/
+ DEPTH(kCGL128Bit, 128);
+
+#undef DEPTH
+
+ c->total_depth_buffer_depths = offset;
+ assert(c->total_depth_buffer_depths < GLCAPS_DEPTH_BUFFERS);
+}
+
+/* Return non-zero if an error occured. */
+static CGLError handleRendererDescriptions(CGLRendererInfoObj info, GLint r,
+ struct glCapabilitiesConfig *c) {
+ CGLError err;
+ GLint accelerated = 0, flags = 0, aux = 0, samplebufs = 0, samples = 0;
+
+ err = CGLDescribeRenderer (info, r, kCGLRPAccelerated, &accelerated);
+
+ if(err)
+ return err;
+
+ c->accelerated = accelerated;
+
+ /* Buffering modes: single/double, stereo */
+ err = CGLDescribeRenderer(info, r, kCGLRPBufferModes, &flags);
+
+ if(err)
+ return err;
+
+ handleBufferModes(c, flags);
+
+ /* AUX buffers */
+ err = CGLDescribeRenderer(info, r, kCGLRPMaxAuxBuffers, &aux);
+
+ if(err)
+ return err;
+
+ c->aux_buffers = aux;
+
+
+ /* Depth buffer size */
+ err = CGLDescribeRenderer(info, r, kCGLRPDepthModes, &flags);
+
+ if(err)
+ return err;
+
+ handleDepthModes(c, flags);
+
+
+ /* Multisample buffers */
+ err = CGLDescribeRenderer(info, r, kCGLRPMaxSampleBuffers, &samplebufs);
+
+ if(err)
+ return err;
+
+ c->multisample_buffers = samplebufs;
+
+
+ /* Multisample samples per multisample buffer */
+ err = CGLDescribeRenderer(info, r, kCGLRPMaxSamples, &samples);
+
+ if(err)
+ return err;
+
+ c->multisample_samples = samples;
+
+
+ /* Stencil bit depths */
+ err = CGLDescribeRenderer(info, r, kCGLRPStencilModes, &flags);
+
+ if(err)
+ return err;
+
+ handleStencilModes(c, flags);
+
+
+ /* Color modes (RGB/RGBA depths supported */
+ err = CGLDescribeRenderer(info, r, kCGLRPColorModes, &flags);
+
+ if(err)
+ return err;
+
+ handleColorModes(c, flags);
+
+ err = CGLDescribeRenderer(info, r, kCGLRPAccumModes, &flags);
+
+ if(err)
+ return err;
+
+ handleAccumulationModes(c, flags);
+
+ return kCGLNoError;
+}
+
+static void initCapabilities(struct glCapabilities *cap) {
+ cap->configurations = NULL;
+ cap->total_configurations = 0;
+}
+
+static void initConfig(struct glCapabilitiesConfig *c) {
+ int i;
+
+ c->accelerated = false;
+ c->stereo = false;
+ c->aux_buffers = 0;
+ c->buffers = 0;
+
+ c->total_depth_buffer_depths = 0;
+
+ for(i = 0; i < GLCAPS_DEPTH_BUFFERS; ++i) {
+ c->depth_buffers[i] = GLCAPS_INVALID_DEPTH_VALUE;
+ }
+
+ c->multisample_buffers = 0;
+ c->multisample_samples = 0;
+
+ c->total_stencil_bit_depths = 0;
+
+ for(i = 0; i < GLCAPS_STENCIL_BIT_DEPTH_BUFFERS; ++i) {
+ c->stencil_bit_depths[i] = GLCAPS_INVALID_STENCIL_DEPTH;
+ }
+
+ c->total_color_buffers = 0;
+
+ for(i = 0; i < GLCAPS_COLOR_BUFFERS; ++i) {
+ c->color_buffers[i].r = c->color_buffers[i].g =
+ c->color_buffers[i].b = c->color_buffers[i].a =
+ GLCAPS_COLOR_BUF_INVALID_VALUE;
+ c->color_buffers[i].is_argb = false;
+ }
+
+ c->total_accum_buffers = 0;
+
+ for(i = 0; i < GLCAPS_COLOR_BUFFERS; ++i) {
+ c->accum_buffers[i].r = c->accum_buffers[i].g =
+ c->accum_buffers[i].b = c->accum_buffers[i].a =
+ GLCAPS_COLOR_BUF_INVALID_VALUE;
+ c->accum_buffers[i].is_argb = false;
+ }
+
+ c->next = NULL;
+}
+
+void freeGlCapabilities(struct glCapabilities *cap) {
+ struct glCapabilitiesConfig *conf, *next;
+
+ conf = cap->configurations;
+
+ while(conf) {
+ next = conf->next;
+ free(conf);
+ conf = next;
+ }
+
+ cap->configurations = NULL;
+}
+
+/*Return true if an error occured. */
+bool getGlCapabilities(struct glCapabilities *cap) {
+ CGLRendererInfoObj info;
+ CGLError err;
+ GLint numRenderers = 0, r;
+
+ initCapabilities(cap);
+
+ err = CGLQueryRendererInfo((GLuint)-1, &info, &numRenderers);
+ if(err) {
+ ErrorF("CGLQueryRendererInfo error: %s\n", CGLErrorString(err));
+ return err;
+ }
+
+ for(r = 0; r < numRenderers; r++) {
+ struct glCapabilitiesConfig tmpconf, *conf;
+
+ initConfig(&tmpconf);
+
+ err = handleRendererDescriptions(info, r, &tmpconf);
+ if(err) {
+ ErrorF("handleRendererDescriptions returned error: %s\n", CGLErrorString(err));
+ ErrorF("trying to continue...\n");
+ continue;
+ }
+
+ conf = malloc(sizeof(*conf));
+ if(NULL == conf) {
+ FatalError("Unable to allocate memory for OpenGL capabilities\n");
+ }
+
+ /* Copy the struct. */
+ *conf = tmpconf;
+
+ /* Now link the configuration into the list. */
+ conf->next = cap->configurations;
+ cap->configurations = conf;
+ }
+
+ CGLDestroyRendererInfo(info);
+
+ /* No error occured. We are done. */
+ return kCGLNoError;
+}
diff --git a/xorg-server/hw/xquartz/GL/indirect.c b/xorg-server/hw/xquartz/GL/indirect.c
index 27fa7fc36..27d6daebd 100644
--- a/xorg-server/hw/xquartz/GL/indirect.c
+++ b/xorg-server/hw/xquartz/GL/indirect.c
@@ -1,615 +1,615 @@
-/*
- * GLX implementation that uses Apple's OpenGL.framework
- * (Indirect rendering path -- it's also used for some direct mode code too)
- *
- * Copyright (c) 2007-2011 Apple Inc.
- * Copyright (c) 2004 Torrey T. Lyons. All Rights Reserved.
- * Copyright (c) 2002 Greg Parker. All Rights Reserved.
- *
- * Portions of this file are copied from Mesa's xf86glx.c,
- * which contains the following copyright:
- *
- * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
- * 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 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.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <AvailabilityMacros.h>
-
-#include <dlfcn.h>
-
-#include <OpenGL/OpenGL.h>
-#include <OpenGL/gl.h> /* Just to prevent glxserver.h from loading mesa's and colliding with OpenGL.h */
-
-#include <X11/Xproto.h>
-#include <GL/glxproto.h>
-
-#include <glxserver.h>
-#include <glxutil.h>
-
-typedef unsigned long long GLuint64EXT;
-typedef long long GLint64EXT;
-#include <dispatch.h>
-#include <glapi.h>
-
-#include "x-hash.h"
-
-#include "visualConfigs.h"
-#include "dri.h"
-
-#include "darwin.h"
-#define GLAQUA_DEBUG_MSG(msg, args...) ASL_LOG(ASL_LEVEL_DEBUG, "GLXAqua", msg, ##args)
-
-__GLXprovider * GlxGetDRISWrastProvider (void);
-
-static void setup_dispatch_table(void);
-GLuint __glFloorLog2(GLuint val);
-void warn_func(void * p1, char *format, ...);
-
-// some prototypes
-static __GLXscreen * __glXAquaScreenProbe(ScreenPtr pScreen);
-static __GLXdrawable * __glXAquaScreenCreateDrawable(ClientPtr client, __GLXscreen *screen, DrawablePtr pDraw, XID drawId, int type, XID glxDrawId, __GLXconfig *conf);
-
-static void __glXAquaContextDestroy(__GLXcontext *baseContext);
-static int __glXAquaContextMakeCurrent(__GLXcontext *baseContext);
-static int __glXAquaContextLoseCurrent(__GLXcontext *baseContext);
-static int __glXAquaContextCopy(__GLXcontext *baseDst, __GLXcontext *baseSrc, unsigned long mask);
-
-static CGLPixelFormatObj makeFormat(__GLXconfig *conf);
-
-__GLXprovider __glXDRISWRastProvider = {
- __glXAquaScreenProbe,
- "Core OpenGL",
- NULL
-};
-
-typedef struct __GLXAquaScreen __GLXAquaScreen;
-typedef struct __GLXAquaContext __GLXAquaContext;
-typedef struct __GLXAquaDrawable __GLXAquaDrawable;
-
-/*
- * The following structs must keep the base as the first member.
- * It's used to treat the start of the struct as a different struct
- * in GLX.
- *
- * Note: these structs should be initialized with xcalloc or memset
- * prior to usage, and some of them require initializing
- * the base with function pointers.
- */
-struct __GLXAquaScreen {
- __GLXscreen base;
- int index;
- int num_vis;
-};
-
-struct __GLXAquaContext {
- __GLXcontext base;
- CGLContextObj ctx;
- CGLPixelFormatObj pixelFormat;
- xp_surface_id sid;
- unsigned isAttached :1;
-};
-
-struct __GLXAquaDrawable {
- __GLXdrawable base;
- DrawablePtr pDraw;
- xp_surface_id sid;
- __GLXAquaContext *context;
-};
-
-
-static __GLXcontext *
-__glXAquaScreenCreateContext(__GLXscreen *screen,
- __GLXconfig *conf,
- __GLXcontext *baseShareContext)
-{
- __GLXAquaContext *context;
- __GLXAquaContext *shareContext = (__GLXAquaContext *) baseShareContext;
- CGLError gl_err;
-
- GLAQUA_DEBUG_MSG("glXAquaScreenCreateContext\n");
-
- context = calloc(1, sizeof (__GLXAquaContext));
-
- if (context == NULL)
- return NULL;
-
- memset(context, 0, sizeof *context);
-
- context->base.pGlxScreen = screen;
-
- context->base.destroy = __glXAquaContextDestroy;
- context->base.makeCurrent = __glXAquaContextMakeCurrent;
- context->base.loseCurrent = __glXAquaContextLoseCurrent;
- context->base.copy = __glXAquaContextCopy;
- /*FIXME verify that the context->base is fully initialized. */
-
- context->pixelFormat = makeFormat(conf);
-
- if (!context->pixelFormat) {
- free(context);
- return NULL;
- }
-
- context->ctx = NULL;
- gl_err = CGLCreateContext(context->pixelFormat,
- shareContext ? shareContext->ctx : NULL,
- &context->ctx);
-
- if (gl_err != 0) {
- ErrorF("CGLCreateContext error: %s\n", CGLErrorString(gl_err));
- CGLDestroyPixelFormat(context->pixelFormat);
- free(context);
- return NULL;
- }
-
- setup_dispatch_table();
- GLAQUA_DEBUG_MSG("glAquaCreateContext done\n");
-
- return &context->base;
-}
-
-/* maps from surface id -> list of __GLcontext */
-static x_hash_table *surface_hash;
-
-static void __glXAquaContextDestroy(__GLXcontext *baseContext) {
- x_list *lst;
-
- __GLXAquaContext *context = (__GLXAquaContext *) baseContext;
-
- GLAQUA_DEBUG_MSG("glAquaContextDestroy (ctx %p)\n", baseContext);
- if (context != NULL) {
- if (context->sid != 0 && surface_hash != NULL) {
- lst = x_hash_table_lookup(surface_hash, x_cvt_uint_to_vptr(context->sid), NULL);
- lst = x_list_remove(lst, context);
- x_hash_table_insert(surface_hash, x_cvt_uint_to_vptr(context->sid), lst);
- }
-
- if (context->ctx != NULL)
- CGLDestroyContext(context->ctx);
-
- if (context->pixelFormat != NULL)
- CGLDestroyPixelFormat(context->pixelFormat);
-
- free(context);
- }
-}
-
-static int __glXAquaContextLoseCurrent(__GLXcontext *baseContext) {
- CGLError gl_err;
-
- GLAQUA_DEBUG_MSG("glAquaLoseCurrent (ctx 0x%p)\n", baseContext);
-
- gl_err = CGLSetCurrentContext(NULL);
- if (gl_err != 0)
- ErrorF("CGLSetCurrentContext error: %s\n", CGLErrorString(gl_err));
-
- /*
- * There should be no need to set __glXLastContext to NULL here, because
- * glxcmds.c does it as part of the context cache flush after calling
- * this.
- */
-
- return GL_TRUE;
-}
-
-/* Called when a surface is destroyed as a side effect of destroying
- the window it's attached to. */
-static void surface_notify(void *_arg, void *data) {
- DRISurfaceNotifyArg *arg = (DRISurfaceNotifyArg *)_arg;
- __GLXAquaDrawable *draw = (__GLXAquaDrawable *)data;
- __GLXAquaContext *context;
- x_list *lst;
- if(_arg == NULL || data == NULL) {
- ErrorF("surface_notify called with bad params");
- return;
- }
-
- GLAQUA_DEBUG_MSG("surface_notify(%p, %p)\n", _arg, data);
- switch (arg->kind) {
- case AppleDRISurfaceNotifyDestroyed:
- if (surface_hash != NULL)
- x_hash_table_remove(surface_hash, x_cvt_uint_to_vptr(arg->id));
- draw->pDraw = NULL;
- draw->sid = 0;
- break;
-
- case AppleDRISurfaceNotifyChanged:
- if (surface_hash != NULL) {
- lst = x_hash_table_lookup(surface_hash, x_cvt_uint_to_vptr(arg->id), NULL);
- for (; lst != NULL; lst = lst->next)
- {
- context = lst->data;
- xp_update_gl_context(context->ctx);
- }
- }
- break;
- default:
- ErrorF("surface_notify: unknown kind %d\n", arg->kind);
- break;
- }
-}
-
-static BOOL attach(__GLXAquaContext *context, __GLXAquaDrawable *draw) {
- DrawablePtr pDraw;
-
- GLAQUA_DEBUG_MSG("attach(%p, %p)\n", context, draw);
-
- if(NULL == context || NULL == draw)
- return TRUE;
-
- pDraw = draw->base.pDraw;
-
- if(NULL == pDraw) {
- ErrorF("%s:%s() pDraw is NULL!\n", __FILE__, __func__);
- return TRUE;
- }
-
- if (draw->sid == 0) {
- //if (!quartzProcs->CreateSurface(pDraw->pScreen, pDraw->id, pDraw,
- if (!DRICreateSurface(pDraw->pScreen, pDraw->id, pDraw,
- 0, &draw->sid, NULL,
- surface_notify, draw))
- return TRUE;
- draw->pDraw = pDraw;
- }
-
- if (!context->isAttached || context->sid != draw->sid) {
- x_list *lst;
-
- if (xp_attach_gl_context(context->ctx, draw->sid) != Success) {
- //quartzProcs->DestroySurface(pDraw->pScreen, pDraw->id, pDraw,
- DRIDestroySurface(pDraw->pScreen, pDraw->id, pDraw,
- surface_notify, draw);
- if (surface_hash != NULL)
- x_hash_table_remove(surface_hash, x_cvt_uint_to_vptr(draw->sid));
-
- draw->sid = 0;
- return TRUE;
- }
-
- context->isAttached = TRUE;
- context->sid = draw->sid;
-
- if (surface_hash == NULL)
- surface_hash = x_hash_table_new(NULL, NULL, NULL, NULL);
-
- lst = x_hash_table_lookup(surface_hash, x_cvt_uint_to_vptr(context->sid), NULL);
- if (x_list_find(lst, context) == NULL) {
- lst = x_list_prepend(lst, context);
- x_hash_table_insert(surface_hash, x_cvt_uint_to_vptr(context->sid), lst);
- }
-
-
-
- GLAQUA_DEBUG_MSG("attached 0x%x to 0x%x\n", (unsigned int) pDraw->id,
- (unsigned int) draw->sid);
- }
-
- draw->context = context;
-
- return FALSE;
-}
-
-#if 0 // unused
-static void unattach(__GLXAquaContext *context) {
- x_list *lst;
- GLAQUA_DEBUG_MSG("unattach\n");
- if (context == NULL) {
- ErrorF("Tried to unattach a null context\n");
- return;
- }
- if (context->isAttached) {
- GLAQUA_DEBUG_MSG("unattaching\n");
-
- if (surface_hash != NULL) {
- lst = x_hash_table_lookup(surface_hash, (void *) context->sid, NULL);
- lst = x_list_remove(lst, context);
- x_hash_table_insert(surface_hash, (void *) context->sid, lst);
- }
-
- CGLClearDrawable(context->ctx);
- context->isAttached = FALSE;
- context->sid = 0;
- }
-}
-#endif
-
-static int __glXAquaContextMakeCurrent(__GLXcontext *baseContext) {
- CGLError gl_err;
- __GLXAquaContext *context = (__GLXAquaContext *) baseContext;
- __GLXAquaDrawable *drawPriv = (__GLXAquaDrawable *) context->base.drawPriv;
-
- GLAQUA_DEBUG_MSG("glAquaMakeCurrent (ctx 0x%p)\n", baseContext);
-
- if(attach(context, drawPriv))
- return /*error*/ 0;
-
- gl_err = CGLSetCurrentContext(context->ctx);
- if (gl_err != 0)
- ErrorF("CGLSetCurrentContext error: %s\n", CGLErrorString(gl_err));
-
- return gl_err == 0;
-}
-
-static int __glXAquaContextCopy(__GLXcontext *baseDst, __GLXcontext *baseSrc, unsigned long mask)
-{
- CGLError gl_err;
-
- __GLXAquaContext *dst = (__GLXAquaContext *) baseDst;
- __GLXAquaContext *src = (__GLXAquaContext *) baseSrc;
-
- GLAQUA_DEBUG_MSG("GLXAquaContextCopy\n");
-
- gl_err = CGLCopyContext(src->ctx, dst->ctx, mask);
- if (gl_err != 0)
- ErrorF("CGLCopyContext error: %s\n", CGLErrorString(gl_err));
-
- return gl_err == 0;
-}
-
-/* Drawing surface notification callbacks */
-static GLboolean __glXAquaDrawableSwapBuffers(ClientPtr client, __GLXdrawable *base) {
- CGLError err;
- __GLXAquaDrawable *drawable;
-
- // GLAQUA_DEBUG_MSG("glAquaDrawableSwapBuffers(%p)\n",base);
-
- if(!base) {
- ErrorF("%s passed NULL\n", __func__);
- return GL_FALSE;
- }
-
- drawable = (__GLXAquaDrawable *)base;
-
- if(NULL == drawable->context) {
- ErrorF("%s called with a NULL->context for drawable %p!\n",
- __func__, (void *)drawable);
- return GL_FALSE;
- }
-
- err = CGLFlushDrawable(drawable->context->ctx);
-
- if(kCGLNoError != err) {
- ErrorF("CGLFlushDrawable error: %s in %s\n", CGLErrorString(err),
- __func__);
- return GL_FALSE;
- }
-
- return GL_TRUE;
-}
-
-
-static CGLPixelFormatObj makeFormat(__GLXconfig *conf) {
- CGLPixelFormatAttribute attr[64];
- CGLPixelFormatObj fobj;
- GLint formats;
- CGLError error;
- int i = 0;
-
- if(conf->doubleBufferMode)
- attr[i++] = kCGLPFADoubleBuffer;
-
- if(conf->stereoMode)
- attr[i++] = kCGLPFAStereo;
-
- attr[i++] = kCGLPFAColorSize;
- attr[i++] = conf->redBits + conf->greenBits + conf->blueBits;
- attr[i++] = kCGLPFAAlphaSize;
- attr[i++] = conf->alphaBits;
-
- if((conf->accumRedBits + conf->accumGreenBits + conf->accumBlueBits +
- conf->accumAlphaBits) > 0) {
-
- attr[i++] = kCGLPFAAccumSize;
- attr[i++] = conf->accumRedBits + conf->accumGreenBits
- + conf->accumBlueBits + conf->accumAlphaBits;
- }
-
- attr[i++] = kCGLPFADepthSize;
- attr[i++] = conf->depthBits;
-
- if(conf->stencilBits) {
- attr[i++] = kCGLPFAStencilSize;
- attr[i++] = conf->stencilBits;
- }
-
- if(conf->numAuxBuffers > 0) {
- attr[i++] = kCGLPFAAuxBuffers;
- attr[i++] = conf->numAuxBuffers;
- }
-
- if(conf->sampleBuffers > 0) {
- attr[i++] = kCGLPFASampleBuffers;
- attr[i++] = conf->sampleBuffers;
- attr[i++] = kCGLPFASamples;
- attr[i++] = conf->samples;
- }
-
- attr[i] = 0;
-
- error = CGLChoosePixelFormat(attr, &fobj, &formats);
- if(error) {
- ErrorF("error: creating pixel format %s\n", CGLErrorString(error));
- return NULL;
- }
-
- return fobj;
-}
-
-static void __glXAquaScreenDestroy(__GLXscreen *screen) {
-
- GLAQUA_DEBUG_MSG("glXAquaScreenDestroy(%p)\n", screen);
- __glXScreenDestroy(screen);
-
- free(screen);
-}
-
-/* This is called by __glXInitScreens(). */
-static __GLXscreen * __glXAquaScreenProbe(ScreenPtr pScreen) {
- __GLXAquaScreen *screen;
-
- GLAQUA_DEBUG_MSG("glXAquaScreenProbe\n");
-
- if (pScreen == NULL)
- return NULL;
-
- screen = calloc(1, sizeof *screen);
-
- if(NULL == screen)
- return NULL;
-
- screen->base.destroy = __glXAquaScreenDestroy;
- screen->base.createContext = __glXAquaScreenCreateContext;
- screen->base.createDrawable = __glXAquaScreenCreateDrawable;
- screen->base.swapInterval = /*FIXME*/ NULL;
- screen->base.pScreen = pScreen;
-
- screen->base.fbconfigs = __glXAquaCreateVisualConfigs(&screen->base.numFBConfigs, pScreen->myNum);
-
- __glXScreenInit(&screen->base, pScreen);
-
- screen->base.GLXmajor = 1;
- screen->base.GLXminor = 4;
- screen->base.GLXextensions = strdup("GLX_SGIX_fbconfig "
- "GLX_SGIS_multisample "
- "GLX_ARB_multisample "
- "GLX_EXT_visual_info "
- "GLX_EXT_import_context ");
-
- /*We may be able to add more GLXextensions at a later time. */
-
- return &screen->base;
-}
-
-#if 0 // unused
-static void __glXAquaDrawableCopySubBuffer (__GLXdrawable *drawable,
- int x, int y, int w, int h) {
- /*TODO finish me*/
-}
-#endif
-
-static void __glXAquaDrawableDestroy(__GLXdrawable *base) {
- /* gstaplin: base is the head of the structure, so it's at the same
- * offset in memory.
- * Is this safe with strict aliasing? I noticed that the other dri code
- * does this too...
- */
- __GLXAquaDrawable *glxPriv = (__GLXAquaDrawable *)base;
-
- GLAQUA_DEBUG_MSG("TRACE");
-
- /* It doesn't work to call DRIDestroySurface here, the drawable's
- already gone.. But dri.c notices the window destruction and
- frees the surface itself. */
-
- /*gstaplin: verify the statement above. The surface destroy
- *messages weren't making it through, and may still not be.
- *We need a good test case for surface creation and destruction.
- *We also need a good way to enable introspection on the server
- *to validate the test, beyond using gdb with print.
- */
-
- free(glxPriv);
-}
-
-static __GLXdrawable *
-__glXAquaScreenCreateDrawable(ClientPtr client,
- __GLXscreen *screen,
- DrawablePtr pDraw,
- XID drawId,
- int type,
- XID glxDrawId,
- __GLXconfig *conf) {
- __GLXAquaDrawable *glxPriv;
-
- glxPriv = malloc(sizeof *glxPriv);
-
- if(glxPriv == NULL)
- return NULL;
-
- memset(glxPriv, 0, sizeof *glxPriv);
-
- if(!__glXDrawableInit(&glxPriv->base, screen, pDraw, type, glxDrawId, conf)) {
- free(glxPriv);
- return NULL;
- }
-
- glxPriv->base.destroy = __glXAquaDrawableDestroy;
- glxPriv->base.swapBuffers = __glXAquaDrawableSwapBuffers;
- glxPriv->base.copySubBuffer = NULL; /* __glXAquaDrawableCopySubBuffer; */
-
- glxPriv->pDraw = pDraw;
- glxPriv->sid = 0;
- glxPriv->context = NULL;
-
- return &glxPriv->base;
-}
-
-// Extra goodies for glx
-
-GLuint __glFloorLog2(GLuint val)
-{
- int c = 0;
-
- while (val > 1) {
- c++;
- val >>= 1;
- }
- return c;
-}
-
-#ifndef OPENGL_FRAMEWORK_PATH
-#define OPENGL_FRAMEWORK_PATH "/System/Library/Frameworks/OpenGL.framework/OpenGL"
-#endif
-
-static void setup_dispatch_table(void) {
- static struct _glapi_table *disp = NULL;
- static void *handle;
- const char *opengl_framework_path;
-
- if(disp) {
- _glapi_set_dispatch(disp);
- return;
- }
-
- opengl_framework_path = getenv("OPENGL_FRAMEWORK_PATH");
- if (!opengl_framework_path) {
- opengl_framework_path = OPENGL_FRAMEWORK_PATH;
- }
-
- (void) dlerror(); /*drain dlerror */
- handle = dlopen(opengl_framework_path, RTLD_LOCAL);
-
- if (!handle) {
- ErrorF("unable to dlopen %s : %s, using RTLD_DEFAULT\n",
- opengl_framework_path, dlerror());
- handle = RTLD_DEFAULT;
- }
-
- disp = _glapi_create_table_from_handle(handle, "gl");
- assert(disp);
-
- _glapi_set_dispatch(disp);
-}
+/*
+ * GLX implementation that uses Apple's OpenGL.framework
+ * (Indirect rendering path -- it's also used for some direct mode code too)
+ *
+ * Copyright (c) 2007-2011 Apple Inc.
+ * Copyright (c) 2004 Torrey T. Lyons. All Rights Reserved.
+ * Copyright (c) 2002 Greg Parker. All Rights Reserved.
+ *
+ * Portions of this file are copied from Mesa's xf86glx.c,
+ * which contains the following copyright:
+ *
+ * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+ * 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 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.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <AvailabilityMacros.h>
+
+#include <dlfcn.h>
+
+#include <OpenGL/OpenGL.h>
+#include <OpenGL/gl.h> /* Just to prevent glxserver.h from loading mesa's and colliding with OpenGL.h */
+
+#include <X11/Xproto.h>
+#include <GL/glxproto.h>
+
+#include <glxserver.h>
+#include <glxutil.h>
+
+typedef unsigned long long GLuint64EXT;
+typedef long long GLint64EXT;
+#include <dispatch.h>
+#include <glapi.h>
+
+#include "x-hash.h"
+
+#include "visualConfigs.h"
+#include "dri.h"
+
+#include "darwin.h"
+#define GLAQUA_DEBUG_MSG(msg, args...) ASL_LOG(ASL_LEVEL_DEBUG, "GLXAqua", msg, ##args)
+
+__GLXprovider * GlxGetDRISWrastProvider (void);
+
+static void setup_dispatch_table(void);
+GLuint __glFloorLog2(GLuint val);
+void warn_func(void * p1, char *format, ...);
+
+// some prototypes
+static __GLXscreen * __glXAquaScreenProbe(ScreenPtr pScreen);
+static __GLXdrawable * __glXAquaScreenCreateDrawable(ClientPtr client, __GLXscreen *screen, DrawablePtr pDraw, XID drawId, int type, XID glxDrawId, __GLXconfig *conf);
+
+static void __glXAquaContextDestroy(__GLXcontext *baseContext);
+static int __glXAquaContextMakeCurrent(__GLXcontext *baseContext);
+static int __glXAquaContextLoseCurrent(__GLXcontext *baseContext);
+static int __glXAquaContextCopy(__GLXcontext *baseDst, __GLXcontext *baseSrc, unsigned long mask);
+
+static CGLPixelFormatObj makeFormat(__GLXconfig *conf);
+
+__GLXprovider __glXDRISWRastProvider = {
+ __glXAquaScreenProbe,
+ "Core OpenGL",
+ NULL
+};
+
+typedef struct __GLXAquaScreen __GLXAquaScreen;
+typedef struct __GLXAquaContext __GLXAquaContext;
+typedef struct __GLXAquaDrawable __GLXAquaDrawable;
+
+/*
+ * The following structs must keep the base as the first member.
+ * It's used to treat the start of the struct as a different struct
+ * in GLX.
+ *
+ * Note: these structs should be initialized with xcalloc or memset
+ * prior to usage, and some of them require initializing
+ * the base with function pointers.
+ */
+struct __GLXAquaScreen {
+ __GLXscreen base;
+ int index;
+ int num_vis;
+};
+
+struct __GLXAquaContext {
+ __GLXcontext base;
+ CGLContextObj ctx;
+ CGLPixelFormatObj pixelFormat;
+ xp_surface_id sid;
+ unsigned isAttached :1;
+};
+
+struct __GLXAquaDrawable {
+ __GLXdrawable base;
+ DrawablePtr pDraw;
+ xp_surface_id sid;
+ __GLXAquaContext *context;
+};
+
+
+static __GLXcontext *
+__glXAquaScreenCreateContext(__GLXscreen *screen,
+ __GLXconfig *conf,
+ __GLXcontext *baseShareContext)
+{
+ __GLXAquaContext *context;
+ __GLXAquaContext *shareContext = (__GLXAquaContext *) baseShareContext;
+ CGLError gl_err;
+
+ GLAQUA_DEBUG_MSG("glXAquaScreenCreateContext\n");
+
+ context = calloc(1, sizeof (__GLXAquaContext));
+
+ if (context == NULL)
+ return NULL;
+
+ memset(context, 0, sizeof *context);
+
+ context->base.pGlxScreen = screen;
+
+ context->base.destroy = __glXAquaContextDestroy;
+ context->base.makeCurrent = __glXAquaContextMakeCurrent;
+ context->base.loseCurrent = __glXAquaContextLoseCurrent;
+ context->base.copy = __glXAquaContextCopy;
+ /*FIXME verify that the context->base is fully initialized. */
+
+ context->pixelFormat = makeFormat(conf);
+
+ if (!context->pixelFormat) {
+ free(context);
+ return NULL;
+ }
+
+ context->ctx = NULL;
+ gl_err = CGLCreateContext(context->pixelFormat,
+ shareContext ? shareContext->ctx : NULL,
+ &context->ctx);
+
+ if (gl_err != 0) {
+ ErrorF("CGLCreateContext error: %s\n", CGLErrorString(gl_err));
+ CGLDestroyPixelFormat(context->pixelFormat);
+ free(context);
+ return NULL;
+ }
+
+ setup_dispatch_table();
+ GLAQUA_DEBUG_MSG("glAquaCreateContext done\n");
+
+ return &context->base;
+}
+
+/* maps from surface id -> list of __GLcontext */
+static x_hash_table *surface_hash;
+
+static void __glXAquaContextDestroy(__GLXcontext *baseContext) {
+ x_list *lst;
+
+ __GLXAquaContext *context = (__GLXAquaContext *) baseContext;
+
+ GLAQUA_DEBUG_MSG("glAquaContextDestroy (ctx %p)\n", baseContext);
+ if (context != NULL) {
+ if (context->sid != 0 && surface_hash != NULL) {
+ lst = x_hash_table_lookup(surface_hash, x_cvt_uint_to_vptr(context->sid), NULL);
+ lst = x_list_remove(lst, context);
+ x_hash_table_insert(surface_hash, x_cvt_uint_to_vptr(context->sid), lst);
+ }
+
+ if (context->ctx != NULL)
+ CGLDestroyContext(context->ctx);
+
+ if (context->pixelFormat != NULL)
+ CGLDestroyPixelFormat(context->pixelFormat);
+
+ free(context);
+ }
+}
+
+static int __glXAquaContextLoseCurrent(__GLXcontext *baseContext) {
+ CGLError gl_err;
+
+ GLAQUA_DEBUG_MSG("glAquaLoseCurrent (ctx 0x%p)\n", baseContext);
+
+ gl_err = CGLSetCurrentContext(NULL);
+ if (gl_err != 0)
+ ErrorF("CGLSetCurrentContext error: %s\n", CGLErrorString(gl_err));
+
+ /*
+ * There should be no need to set __glXLastContext to NULL here, because
+ * glxcmds.c does it as part of the context cache flush after calling
+ * this.
+ */
+
+ return GL_TRUE;
+}
+
+/* Called when a surface is destroyed as a side effect of destroying
+ the window it's attached to. */
+static void surface_notify(void *_arg, void *data) {
+ DRISurfaceNotifyArg *arg = (DRISurfaceNotifyArg *)_arg;
+ __GLXAquaDrawable *draw = (__GLXAquaDrawable *)data;
+ __GLXAquaContext *context;
+ x_list *lst;
+ if(_arg == NULL || data == NULL) {
+ ErrorF("surface_notify called with bad params");
+ return;
+ }
+
+ GLAQUA_DEBUG_MSG("surface_notify(%p, %p)\n", _arg, data);
+ switch (arg->kind) {
+ case AppleDRISurfaceNotifyDestroyed:
+ if (surface_hash != NULL)
+ x_hash_table_remove(surface_hash, x_cvt_uint_to_vptr(arg->id));
+ draw->pDraw = NULL;
+ draw->sid = 0;
+ break;
+
+ case AppleDRISurfaceNotifyChanged:
+ if (surface_hash != NULL) {
+ lst = x_hash_table_lookup(surface_hash, x_cvt_uint_to_vptr(arg->id), NULL);
+ for (; lst != NULL; lst = lst->next)
+ {
+ context = lst->data;
+ xp_update_gl_context(context->ctx);
+ }
+ }
+ break;
+ default:
+ ErrorF("surface_notify: unknown kind %d\n", arg->kind);
+ break;
+ }
+}
+
+static BOOL attach(__GLXAquaContext *context, __GLXAquaDrawable *draw) {
+ DrawablePtr pDraw;
+
+ GLAQUA_DEBUG_MSG("attach(%p, %p)\n", context, draw);
+
+ if(NULL == context || NULL == draw)
+ return TRUE;
+
+ pDraw = draw->base.pDraw;
+
+ if(NULL == pDraw) {
+ ErrorF("%s:%s() pDraw is NULL!\n", __FILE__, __func__);
+ return TRUE;
+ }
+
+ if (draw->sid == 0) {
+ //if (!quartzProcs->CreateSurface(pDraw->pScreen, pDraw->id, pDraw,
+ if (!DRICreateSurface(pDraw->pScreen, pDraw->id, pDraw,
+ 0, &draw->sid, NULL,
+ surface_notify, draw))
+ return TRUE;
+ draw->pDraw = pDraw;
+ }
+
+ if (!context->isAttached || context->sid != draw->sid) {
+ x_list *lst;
+
+ if (xp_attach_gl_context(context->ctx, draw->sid) != Success) {
+ //quartzProcs->DestroySurface(pDraw->pScreen, pDraw->id, pDraw,
+ DRIDestroySurface(pDraw->pScreen, pDraw->id, pDraw,
+ surface_notify, draw);
+ if (surface_hash != NULL)
+ x_hash_table_remove(surface_hash, x_cvt_uint_to_vptr(draw->sid));
+
+ draw->sid = 0;
+ return TRUE;
+ }
+
+ context->isAttached = TRUE;
+ context->sid = draw->sid;
+
+ if (surface_hash == NULL)
+ surface_hash = x_hash_table_new(NULL, NULL, NULL, NULL);
+
+ lst = x_hash_table_lookup(surface_hash, x_cvt_uint_to_vptr(context->sid), NULL);
+ if (x_list_find(lst, context) == NULL) {
+ lst = x_list_prepend(lst, context);
+ x_hash_table_insert(surface_hash, x_cvt_uint_to_vptr(context->sid), lst);
+ }
+
+
+
+ GLAQUA_DEBUG_MSG("attached 0x%x to 0x%x\n", (unsigned int) pDraw->id,
+ (unsigned int) draw->sid);
+ }
+
+ draw->context = context;
+
+ return FALSE;
+}
+
+#if 0 // unused
+static void unattach(__GLXAquaContext *context) {
+ x_list *lst;
+ GLAQUA_DEBUG_MSG("unattach\n");
+ if (context == NULL) {
+ ErrorF("Tried to unattach a null context\n");
+ return;
+ }
+ if (context->isAttached) {
+ GLAQUA_DEBUG_MSG("unattaching\n");
+
+ if (surface_hash != NULL) {
+ lst = x_hash_table_lookup(surface_hash, (void *) context->sid, NULL);
+ lst = x_list_remove(lst, context);
+ x_hash_table_insert(surface_hash, (void *) context->sid, lst);
+ }
+
+ CGLClearDrawable(context->ctx);
+ context->isAttached = FALSE;
+ context->sid = 0;
+ }
+}
+#endif
+
+static int __glXAquaContextMakeCurrent(__GLXcontext *baseContext) {
+ CGLError gl_err;
+ __GLXAquaContext *context = (__GLXAquaContext *) baseContext;
+ __GLXAquaDrawable *drawPriv = (__GLXAquaDrawable *) context->base.drawPriv;
+
+ GLAQUA_DEBUG_MSG("glAquaMakeCurrent (ctx 0x%p)\n", baseContext);
+
+ if(attach(context, drawPriv))
+ return /*error*/ 0;
+
+ gl_err = CGLSetCurrentContext(context->ctx);
+ if (gl_err != 0)
+ ErrorF("CGLSetCurrentContext error: %s\n", CGLErrorString(gl_err));
+
+ return gl_err == 0;
+}
+
+static int __glXAquaContextCopy(__GLXcontext *baseDst, __GLXcontext *baseSrc, unsigned long mask)
+{
+ CGLError gl_err;
+
+ __GLXAquaContext *dst = (__GLXAquaContext *) baseDst;
+ __GLXAquaContext *src = (__GLXAquaContext *) baseSrc;
+
+ GLAQUA_DEBUG_MSG("GLXAquaContextCopy\n");
+
+ gl_err = CGLCopyContext(src->ctx, dst->ctx, mask);
+ if (gl_err != 0)
+ ErrorF("CGLCopyContext error: %s\n", CGLErrorString(gl_err));
+
+ return gl_err == 0;
+}
+
+/* Drawing surface notification callbacks */
+static GLboolean __glXAquaDrawableSwapBuffers(ClientPtr client, __GLXdrawable *base) {
+ CGLError err;
+ __GLXAquaDrawable *drawable;
+
+ // GLAQUA_DEBUG_MSG("glAquaDrawableSwapBuffers(%p)\n",base);
+
+ if(!base) {
+ ErrorF("%s passed NULL\n", __func__);
+ return GL_FALSE;
+ }
+
+ drawable = (__GLXAquaDrawable *)base;
+
+ if(NULL == drawable->context) {
+ ErrorF("%s called with a NULL->context for drawable %p!\n",
+ __func__, (void *)drawable);
+ return GL_FALSE;
+ }
+
+ err = CGLFlushDrawable(drawable->context->ctx);
+
+ if(kCGLNoError != err) {
+ ErrorF("CGLFlushDrawable error: %s in %s\n", CGLErrorString(err),
+ __func__);
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+
+static CGLPixelFormatObj makeFormat(__GLXconfig *conf) {
+ CGLPixelFormatAttribute attr[64];
+ CGLPixelFormatObj fobj;
+ GLint formats;
+ CGLError error;
+ int i = 0;
+
+ if(conf->doubleBufferMode)
+ attr[i++] = kCGLPFADoubleBuffer;
+
+ if(conf->stereoMode)
+ attr[i++] = kCGLPFAStereo;
+
+ attr[i++] = kCGLPFAColorSize;
+ attr[i++] = conf->redBits + conf->greenBits + conf->blueBits;
+ attr[i++] = kCGLPFAAlphaSize;
+ attr[i++] = conf->alphaBits;
+
+ if((conf->accumRedBits + conf->accumGreenBits + conf->accumBlueBits +
+ conf->accumAlphaBits) > 0) {
+
+ attr[i++] = kCGLPFAAccumSize;
+ attr[i++] = conf->accumRedBits + conf->accumGreenBits
+ + conf->accumBlueBits + conf->accumAlphaBits;
+ }
+
+ attr[i++] = kCGLPFADepthSize;
+ attr[i++] = conf->depthBits;
+
+ if(conf->stencilBits) {
+ attr[i++] = kCGLPFAStencilSize;
+ attr[i++] = conf->stencilBits;
+ }
+
+ if(conf->numAuxBuffers > 0) {
+ attr[i++] = kCGLPFAAuxBuffers;
+ attr[i++] = conf->numAuxBuffers;
+ }
+
+ if(conf->sampleBuffers > 0) {
+ attr[i++] = kCGLPFASampleBuffers;
+ attr[i++] = conf->sampleBuffers;
+ attr[i++] = kCGLPFASamples;
+ attr[i++] = conf->samples;
+ }
+
+ attr[i] = 0;
+
+ error = CGLChoosePixelFormat(attr, &fobj, &formats);
+ if(error) {
+ ErrorF("error: creating pixel format %s\n", CGLErrorString(error));
+ return NULL;
+ }
+
+ return fobj;
+}
+
+static void __glXAquaScreenDestroy(__GLXscreen *screen) {
+
+ GLAQUA_DEBUG_MSG("glXAquaScreenDestroy(%p)\n", screen);
+ __glXScreenDestroy(screen);
+
+ free(screen);
+}
+
+/* This is called by __glXInitScreens(). */
+static __GLXscreen * __glXAquaScreenProbe(ScreenPtr pScreen) {
+ __GLXAquaScreen *screen;
+
+ GLAQUA_DEBUG_MSG("glXAquaScreenProbe\n");
+
+ if (pScreen == NULL)
+ return NULL;
+
+ screen = calloc(1, sizeof *screen);
+
+ if(NULL == screen)
+ return NULL;
+
+ screen->base.destroy = __glXAquaScreenDestroy;
+ screen->base.createContext = __glXAquaScreenCreateContext;
+ screen->base.createDrawable = __glXAquaScreenCreateDrawable;
+ screen->base.swapInterval = /*FIXME*/ NULL;
+ screen->base.pScreen = pScreen;
+
+ screen->base.fbconfigs = __glXAquaCreateVisualConfigs(&screen->base.numFBConfigs, pScreen->myNum);
+
+ __glXScreenInit(&screen->base, pScreen);
+
+ screen->base.GLXmajor = 1;
+ screen->base.GLXminor = 4;
+ screen->base.GLXextensions = strdup("GLX_SGIX_fbconfig "
+ "GLX_SGIS_multisample "
+ "GLX_ARB_multisample "
+ "GLX_EXT_visual_info "
+ "GLX_EXT_import_context ");
+
+ /*We may be able to add more GLXextensions at a later time. */
+
+ return &screen->base;
+}
+
+#if 0 // unused
+static void __glXAquaDrawableCopySubBuffer (__GLXdrawable *drawable,
+ int x, int y, int w, int h) {
+ /*TODO finish me*/
+}
+#endif
+
+static void __glXAquaDrawableDestroy(__GLXdrawable *base) {
+ /* gstaplin: base is the head of the structure, so it's at the same
+ * offset in memory.
+ * Is this safe with strict aliasing? I noticed that the other dri code
+ * does this too...
+ */
+ __GLXAquaDrawable *glxPriv = (__GLXAquaDrawable *)base;
+
+ GLAQUA_DEBUG_MSG("TRACE");
+
+ /* It doesn't work to call DRIDestroySurface here, the drawable's
+ already gone.. But dri.c notices the window destruction and
+ frees the surface itself. */
+
+ /*gstaplin: verify the statement above. The surface destroy
+ *messages weren't making it through, and may still not be.
+ *We need a good test case for surface creation and destruction.
+ *We also need a good way to enable introspection on the server
+ *to validate the test, beyond using gdb with print.
+ */
+
+ free(glxPriv);
+}
+
+static __GLXdrawable *
+__glXAquaScreenCreateDrawable(ClientPtr client,
+ __GLXscreen *screen,
+ DrawablePtr pDraw,
+ XID drawId,
+ int type,
+ XID glxDrawId,
+ __GLXconfig *conf) {
+ __GLXAquaDrawable *glxPriv;
+
+ glxPriv = malloc(sizeof *glxPriv);
+
+ if(glxPriv == NULL)
+ return NULL;
+
+ memset(glxPriv, 0, sizeof *glxPriv);
+
+ if(!__glXDrawableInit(&glxPriv->base, screen, pDraw, type, glxDrawId, conf)) {
+ free(glxPriv);
+ return NULL;
+ }
+
+ glxPriv->base.destroy = __glXAquaDrawableDestroy;
+ glxPriv->base.swapBuffers = __glXAquaDrawableSwapBuffers;
+ glxPriv->base.copySubBuffer = NULL; /* __glXAquaDrawableCopySubBuffer; */
+
+ glxPriv->pDraw = pDraw;
+ glxPriv->sid = 0;
+ glxPriv->context = NULL;
+
+ return &glxPriv->base;
+}
+
+// Extra goodies for glx
+
+GLuint __glFloorLog2(GLuint val)
+{
+ int c = 0;
+
+ while (val > 1) {
+ c++;
+ val >>= 1;
+ }
+ return c;
+}
+
+#ifndef OPENGL_FRAMEWORK_PATH
+#define OPENGL_FRAMEWORK_PATH "/System/Library/Frameworks/OpenGL.framework/OpenGL"
+#endif
+
+static void setup_dispatch_table(void) {
+ static struct _glapi_table *disp = NULL;
+ static void *handle;
+ const char *opengl_framework_path;
+
+ if(disp) {
+ _glapi_set_dispatch(disp);
+ return;
+ }
+
+ opengl_framework_path = getenv("OPENGL_FRAMEWORK_PATH");
+ if (!opengl_framework_path) {
+ opengl_framework_path = OPENGL_FRAMEWORK_PATH;
+ }
+
+ (void) dlerror(); /*drain dlerror */
+ handle = dlopen(opengl_framework_path, RTLD_LOCAL);
+
+ if (!handle) {
+ ErrorF("unable to dlopen %s : %s, using RTLD_DEFAULT\n",
+ opengl_framework_path, dlerror());
+ handle = RTLD_DEFAULT;
+ }
+
+ disp = _glapi_create_table_from_handle(handle, "gl");
+ assert(disp);
+
+ _glapi_set_dispatch(disp);
+}
diff --git a/xorg-server/hw/xquartz/GL/visualConfigs.c b/xorg-server/hw/xquartz/GL/visualConfigs.c
index f78b14a6e..2c2a9a29e 100644
--- a/xorg-server/hw/xquartz/GL/visualConfigs.c
+++ b/xorg-server/hw/xquartz/GL/visualConfigs.c
@@ -1,284 +1,284 @@
-/*
- * Copyright (c) 2007, 2008 Apple Inc.
- * Copyright (c) 2004 Torrey T. Lyons. All Rights Reserved.
- * Copyright (c) 2002 Greg Parker. All Rights Reserved.
- *
- * Portions of this file are copied from Mesa's xf86glx.c,
- * which contains the following copyright:
- *
- * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
- * 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 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.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "dri.h"
-
-#include <OpenGL/OpenGL.h>
-#include <OpenGL/gl.h>
-#include <OpenGL/glext.h>
-#include <OpenGL/CGLContext.h>
-
-#include <GL/glxproto.h>
-#include <windowstr.h>
-#include <resource.h>
-#include <GL/glxint.h>
-#include <GL/glxtokens.h>
-#include <scrnintstr.h>
-#include <glxserver.h>
-#include <glxscreens.h>
-#include <glxdrawable.h>
-#include <glxcontext.h>
-#include <glxext.h>
-#include <glxutil.h>
-#include <GL/internal/glcore.h>
-
-#include "capabilities.h"
-#include "visualConfigs.h"
-#include "darwinfb.h"
-
-/* Based originally on code from indirect.c which was based on code from i830_dri.c. */
-__GLXconfig *__glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber) {
- int numConfigs = 0;
- __GLXconfig *visualConfigs, *c;
- struct glCapabilities caps;
- struct glCapabilitiesConfig *conf;
- int stereo, depth, aux, buffers, stencil, accum, color, msample;
-
- if(getGlCapabilities(&caps)) {
- ErrorF("error from getGlCapabilities()!\n");
- return NULL;
- }
-
- /*
- conf->stereo is 0 or 1, but we need at least 1 iteration of the loop,
- so we treat a true conf->stereo as 2.
-
- The depth size is 0 or 24. Thus we do 2 iterations for that.
-
- conf->aux_buffers (when available/non-zero) result in 2 iterations instead of 1.
-
- conf->buffers indicates whether we have single or double buffering.
-
- conf->total_stencil_bit_depths
-
- conf->total_color_buffers indicates the RGB/RGBA color depths.
-
- conf->total_accum_buffers iterations for accum (with at least 1 if equal to 0)
-
- conf->total_depth_buffer_depths
-
- conf->multisample_buffers iterations (with at least 1 if equal to 0). We add 1
- for the 0 multisampling config.
-
- */
-
- assert(NULL != caps.configurations);
-
- numConfigs = 0;
-
- for(conf = caps.configurations; conf; conf = conf->next) {
- if(conf->total_color_buffers <= 0)
- continue;
-
- numConfigs += (conf->stereo ? 2 : 1)
- * (conf->aux_buffers ? 2 : 1)
- * conf->buffers
- * ((conf->total_stencil_bit_depths > 0) ? conf->total_stencil_bit_depths : 1)
- * conf->total_color_buffers
- * ((conf->total_accum_buffers > 0) ? conf->total_accum_buffers : 1)
- * conf->total_depth_buffer_depths
- * (conf->multisample_buffers + 1);
- }
-
- if(numConfigsPtr)
- *numConfigsPtr = numConfigs;
-
- visualConfigs = calloc(sizeof(*visualConfigs), numConfigs);
-
- if(NULL == visualConfigs) {
- ErrorF("xcalloc failure when allocating visualConfigs\n");
- freeGlCapabilities(&caps);
- return NULL;
- }
-
- c = visualConfigs; /* current buffer */
- for(conf = caps.configurations; conf; conf = conf->next) {
- for(stereo = 0; stereo < (conf->stereo ? 2 : 1); ++stereo) {
- for(aux = 0; aux < (conf->aux_buffers ? 2 : 1); ++aux) {
- for(buffers = 0; buffers < conf->buffers; ++buffers) {
- for(stencil = 0; stencil < ((conf->total_stencil_bit_depths > 0) ?
- conf->total_stencil_bit_depths : 1); ++stencil) {
- for(color = 0; color < conf->total_color_buffers; ++color) {
- for(accum = 0; accum < ((conf->total_accum_buffers > 0) ?
- conf->total_accum_buffers : 1); ++accum) {
- for(depth = 0; depth < conf->total_depth_buffer_depths; ++depth) {
- for(msample = 0; msample < (conf->multisample_buffers + 1); ++msample) {
-
- // Global
- c->visualID = -1;
- c->visualType = GLX_TRUE_COLOR;
- c->next = c + 1;
-
- c->screen = screenNumber;
-
- c->level = 0;
- c->indexBits = 0;
- c->pixmapMode = 0; // TODO: What should this be?
-
- if(conf->accelerated) {
- c->visualRating = GLX_NONE;
- } else {
- c->visualRating = GLX_SLOW_VISUAL_EXT;
- }
-
- c->transparentPixel = GLX_NONE;
- c->transparentRed = GLX_NONE;
- c->transparentGreen = GLX_NONE;
- c->transparentBlue = GLX_NONE;
- c->transparentAlpha = GLX_NONE;
- c->transparentIndex = GLX_NONE;
-
- c->visualSelectGroup = 0;
-
- c->swapMethod = GLX_SWAP_UNDEFINED_OML;
-
- // Stereo
- c->stereoMode = stereo ? TRUE : FALSE;
-
- // Aux buffers
- c->numAuxBuffers = aux ? conf->aux_buffers : 0;
-
- // Double Buffered
- c->doubleBufferMode = buffers ? TRUE : FALSE;
-
- // Stencil Buffer
- if(conf->total_stencil_bit_depths > 0) {
- c->stencilBits = conf->stencil_bit_depths[stencil];
- } else {
- c->stencilBits = 0;
- }
-
- // Color
- if(GLCAPS_COLOR_BUF_INVALID_VALUE != conf->color_buffers[color].a) {
- c->alphaBits = conf->color_buffers[color].a;
- } else {
- c->alphaBits = 0;
- }
- c->redBits = conf->color_buffers[color].r;
- c->greenBits = conf->color_buffers[color].g;
- c->blueBits = conf->color_buffers[color].b;
-
- c->rgbBits = c->alphaBits + c->redBits + c->greenBits + c->blueBits;
-
- c->alphaMask = AM_ARGB(c->alphaBits, c->redBits, c->greenBits, c->blueBits);
- c->redMask = RM_ARGB(c->alphaBits, c->redBits, c->greenBits, c->blueBits);
- c->greenMask = GM_ARGB(c->alphaBits, c->redBits, c->greenBits, c->blueBits);
- c->blueMask = BM_ARGB(c->alphaBits, c->redBits, c->greenBits, c->blueBits);
-
- // Accumulation Buffers
- if(conf->total_accum_buffers > 0) {
- c->accumRedBits = conf->accum_buffers[accum].r;
- c->accumGreenBits = conf->accum_buffers[accum].g;
- c->accumBlueBits = conf->accum_buffers[accum].b;
- if(GLCAPS_COLOR_BUF_INVALID_VALUE != conf->accum_buffers[accum].a) {
- c->accumAlphaBits = conf->accum_buffers[accum].a;
- } else {
- c->accumAlphaBits = 0;
- }
- } else {
- c->accumRedBits = 0;
- c->accumGreenBits = 0;
- c->accumBlueBits = 0;
- c->accumAlphaBits = 0;
- }
-
- // Depth
- c->depthBits = conf->depth_buffers[depth];
-
- // MultiSample
- if(msample > 0) {
- c->samples = conf->multisample_samples;
- c->sampleBuffers = conf->multisample_buffers;
- } else {
- c->samples = 0;
- c->sampleBuffers = 0;
- }
-
- /*
- * The Apple libGL supports GLXPixmaps and
- * GLXPbuffers in direct mode.
- */
- /* SGIX_fbconfig / GLX 1.3 */
- c->drawableType = GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT;
- c->renderType = GLX_RGBA_BIT;
- c->xRenderable = GL_TRUE;
- c->fbconfigID = -1;
-
- /* SGIX_pbuffer / GLX 1.3 */
-
- /*
- * The CGL layer provides a way of retrieving
- * the maximum pbuffer width/height, but only
- * if we create a context and call glGetIntegerv.
- *
- * The following values are from a test program
- * that does so.
- */
- c->maxPbufferWidth = 8192;
- c->maxPbufferHeight = 8192;
- c->maxPbufferPixels = /*Do we need this?*/ 0;
- /*
- * There is no introspection for this sort of thing
- * with CGL. What should we do realistically?
- */
- c->optimalPbufferWidth = 0;
- c->optimalPbufferHeight = 0;
-
- /* EXT_texture_from_pixmap */
- c->bindToTextureRgb = 0;
- c->bindToTextureRgba = 0;
- c->bindToMipmapTexture = 0;
- c->bindToTextureTargets = 0;
- c->yInverted = 0;
-
- c = c->next;
- }
- }
- }
- }
- }
- }
- }
- }
- }
-
- (c-1)->next = NULL;
-
- if (c - visualConfigs != numConfigs) {
- FatalError("numConfigs calculation error in setVisualConfigs! numConfigs is %d i is %d\n", numConfigs, (int)(c - visualConfigs));
- }
-
- freeGlCapabilities(&caps);
- return visualConfigs;
-}
+/*
+ * Copyright (c) 2007, 2008 Apple Inc.
+ * Copyright (c) 2004 Torrey T. Lyons. All Rights Reserved.
+ * Copyright (c) 2002 Greg Parker. All Rights Reserved.
+ *
+ * Portions of this file are copied from Mesa's xf86glx.c,
+ * which contains the following copyright:
+ *
+ * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+ * 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 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.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "dri.h"
+
+#include <OpenGL/OpenGL.h>
+#include <OpenGL/gl.h>
+#include <OpenGL/glext.h>
+#include <OpenGL/CGLContext.h>
+
+#include <GL/glxproto.h>
+#include <windowstr.h>
+#include <resource.h>
+#include <GL/glxint.h>
+#include <GL/glxtokens.h>
+#include <scrnintstr.h>
+#include <glxserver.h>
+#include <glxscreens.h>
+#include <glxdrawable.h>
+#include <glxcontext.h>
+#include <glxext.h>
+#include <glxutil.h>
+#include <GL/internal/glcore.h>
+
+#include "capabilities.h"
+#include "visualConfigs.h"
+#include "darwinfb.h"
+
+/* Based originally on code from indirect.c which was based on code from i830_dri.c. */
+__GLXconfig *__glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber) {
+ int numConfigs = 0;
+ __GLXconfig *visualConfigs, *c;
+ struct glCapabilities caps;
+ struct glCapabilitiesConfig *conf;
+ int stereo, depth, aux, buffers, stencil, accum, color, msample;
+
+ if(getGlCapabilities(&caps)) {
+ ErrorF("error from getGlCapabilities()!\n");
+ return NULL;
+ }
+
+ /*
+ conf->stereo is 0 or 1, but we need at least 1 iteration of the loop,
+ so we treat a true conf->stereo as 2.
+
+ The depth size is 0 or 24. Thus we do 2 iterations for that.
+
+ conf->aux_buffers (when available/non-zero) result in 2 iterations instead of 1.
+
+ conf->buffers indicates whether we have single or double buffering.
+
+ conf->total_stencil_bit_depths
+
+ conf->total_color_buffers indicates the RGB/RGBA color depths.
+
+ conf->total_accum_buffers iterations for accum (with at least 1 if equal to 0)
+
+ conf->total_depth_buffer_depths
+
+ conf->multisample_buffers iterations (with at least 1 if equal to 0). We add 1
+ for the 0 multisampling config.
+
+ */
+
+ assert(NULL != caps.configurations);
+
+ numConfigs = 0;
+
+ for(conf = caps.configurations; conf; conf = conf->next) {
+ if(conf->total_color_buffers <= 0)
+ continue;
+
+ numConfigs += (conf->stereo ? 2 : 1)
+ * (conf->aux_buffers ? 2 : 1)
+ * conf->buffers
+ * ((conf->total_stencil_bit_depths > 0) ? conf->total_stencil_bit_depths : 1)
+ * conf->total_color_buffers
+ * ((conf->total_accum_buffers > 0) ? conf->total_accum_buffers : 1)
+ * conf->total_depth_buffer_depths
+ * (conf->multisample_buffers + 1);
+ }
+
+ if(numConfigsPtr)
+ *numConfigsPtr = numConfigs;
+
+ visualConfigs = calloc(sizeof(*visualConfigs), numConfigs);
+
+ if(NULL == visualConfigs) {
+ ErrorF("xcalloc failure when allocating visualConfigs\n");
+ freeGlCapabilities(&caps);
+ return NULL;
+ }
+
+ c = visualConfigs; /* current buffer */
+ for(conf = caps.configurations; conf; conf = conf->next) {
+ for(stereo = 0; stereo < (conf->stereo ? 2 : 1); ++stereo) {
+ for(aux = 0; aux < (conf->aux_buffers ? 2 : 1); ++aux) {
+ for(buffers = 0; buffers < conf->buffers; ++buffers) {
+ for(stencil = 0; stencil < ((conf->total_stencil_bit_depths > 0) ?
+ conf->total_stencil_bit_depths : 1); ++stencil) {
+ for(color = 0; color < conf->total_color_buffers; ++color) {
+ for(accum = 0; accum < ((conf->total_accum_buffers > 0) ?
+ conf->total_accum_buffers : 1); ++accum) {
+ for(depth = 0; depth < conf->total_depth_buffer_depths; ++depth) {
+ for(msample = 0; msample < (conf->multisample_buffers + 1); ++msample) {
+
+ // Global
+ c->visualID = -1;
+ c->visualType = GLX_TRUE_COLOR;
+ c->next = c + 1;
+
+ c->screen = screenNumber;
+
+ c->level = 0;
+ c->indexBits = 0;
+ c->pixmapMode = 0; // TODO: What should this be?
+
+ if(conf->accelerated) {
+ c->visualRating = GLX_NONE;
+ } else {
+ c->visualRating = GLX_SLOW_VISUAL_EXT;
+ }
+
+ c->transparentPixel = GLX_NONE;
+ c->transparentRed = GLX_NONE;
+ c->transparentGreen = GLX_NONE;
+ c->transparentBlue = GLX_NONE;
+ c->transparentAlpha = GLX_NONE;
+ c->transparentIndex = GLX_NONE;
+
+ c->visualSelectGroup = 0;
+
+ c->swapMethod = GLX_SWAP_UNDEFINED_OML;
+
+ // Stereo
+ c->stereoMode = stereo ? TRUE : FALSE;
+
+ // Aux buffers
+ c->numAuxBuffers = aux ? conf->aux_buffers : 0;
+
+ // Double Buffered
+ c->doubleBufferMode = buffers ? TRUE : FALSE;
+
+ // Stencil Buffer
+ if(conf->total_stencil_bit_depths > 0) {
+ c->stencilBits = conf->stencil_bit_depths[stencil];
+ } else {
+ c->stencilBits = 0;
+ }
+
+ // Color
+ if(GLCAPS_COLOR_BUF_INVALID_VALUE != conf->color_buffers[color].a) {
+ c->alphaBits = conf->color_buffers[color].a;
+ } else {
+ c->alphaBits = 0;
+ }
+ c->redBits = conf->color_buffers[color].r;
+ c->greenBits = conf->color_buffers[color].g;
+ c->blueBits = conf->color_buffers[color].b;
+
+ c->rgbBits = c->alphaBits + c->redBits + c->greenBits + c->blueBits;
+
+ c->alphaMask = AM_ARGB(c->alphaBits, c->redBits, c->greenBits, c->blueBits);
+ c->redMask = RM_ARGB(c->alphaBits, c->redBits, c->greenBits, c->blueBits);
+ c->greenMask = GM_ARGB(c->alphaBits, c->redBits, c->greenBits, c->blueBits);
+ c->blueMask = BM_ARGB(c->alphaBits, c->redBits, c->greenBits, c->blueBits);
+
+ // Accumulation Buffers
+ if(conf->total_accum_buffers > 0) {
+ c->accumRedBits = conf->accum_buffers[accum].r;
+ c->accumGreenBits = conf->accum_buffers[accum].g;
+ c->accumBlueBits = conf->accum_buffers[accum].b;
+ if(GLCAPS_COLOR_BUF_INVALID_VALUE != conf->accum_buffers[accum].a) {
+ c->accumAlphaBits = conf->accum_buffers[accum].a;
+ } else {
+ c->accumAlphaBits = 0;
+ }
+ } else {
+ c->accumRedBits = 0;
+ c->accumGreenBits = 0;
+ c->accumBlueBits = 0;
+ c->accumAlphaBits = 0;
+ }
+
+ // Depth
+ c->depthBits = conf->depth_buffers[depth];
+
+ // MultiSample
+ if(msample > 0) {
+ c->samples = conf->multisample_samples;
+ c->sampleBuffers = conf->multisample_buffers;
+ } else {
+ c->samples = 0;
+ c->sampleBuffers = 0;
+ }
+
+ /*
+ * The Apple libGL supports GLXPixmaps and
+ * GLXPbuffers in direct mode.
+ */
+ /* SGIX_fbconfig / GLX 1.3 */
+ c->drawableType = GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT;
+ c->renderType = GLX_RGBA_BIT;
+ c->xRenderable = GL_TRUE;
+ c->fbconfigID = -1;
+
+ /* SGIX_pbuffer / GLX 1.3 */
+
+ /*
+ * The CGL layer provides a way of retrieving
+ * the maximum pbuffer width/height, but only
+ * if we create a context and call glGetIntegerv.
+ *
+ * The following values are from a test program
+ * that does so.
+ */
+ c->maxPbufferWidth = 8192;
+ c->maxPbufferHeight = 8192;
+ c->maxPbufferPixels = /*Do we need this?*/ 0;
+ /*
+ * There is no introspection for this sort of thing
+ * with CGL. What should we do realistically?
+ */
+ c->optimalPbufferWidth = 0;
+ c->optimalPbufferHeight = 0;
+
+ /* EXT_texture_from_pixmap */
+ c->bindToTextureRgb = 0;
+ c->bindToTextureRgba = 0;
+ c->bindToMipmapTexture = 0;
+ c->bindToTextureTargets = 0;
+ c->yInverted = 0;
+
+ c = c->next;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ (c-1)->next = NULL;
+
+ if (c - visualConfigs != numConfigs) {
+ FatalError("numConfigs calculation error in setVisualConfigs! numConfigs is %d i is %d\n", numConfigs, (int)(c - visualConfigs));
+ }
+
+ freeGlCapabilities(&caps);
+ return visualConfigs;
+}
diff --git a/xorg-server/hw/xquartz/Makefile.am b/xorg-server/hw/xquartz/Makefile.am
index d9dbccc71..a7cc012d9 100644
--- a/xorg-server/hw/xquartz/Makefile.am
+++ b/xorg-server/hw/xquartz/Makefile.am
@@ -1,54 +1,54 @@
-noinst_LTLIBRARIES = libXquartz.la
-AM_CFLAGS = $(DIX_CFLAGS)
-AM_OBJCFLAGS = $(DIX_CFLAGS)
-AM_CPPFLAGS = \
- -DBUILD_DATE=\"$(BUILD_DATE)\" \
- -DXSERVER_VERSION=\"$(VERSION)\" \
- -DINXQUARTZ \
- -DUSE_NEW_CLUT \
- -DXFree86Server \
- -I$(top_srcdir)/miext/rootless \
- -DX11LIBDIR=\"$(libdir)\"
-
-if GLX
-GL_DIR = GL
-endif
-
-SUBDIRS = bundle . $(GL_DIR) xpr pbproxy mach-startup man
-
-DIST_SUBDIRS = bundle . GL xpr pbproxy mach-startup man
-
-libXquartz_la_SOURCES = \
- $(top_srcdir)/fb/fbcmap_mi.c \
- $(top_srcdir)/mi/miinitext.c \
- X11Application.m \
- X11Controller.m \
- applewm.c \
- darwin.c \
- darwinEvents.c \
- darwinXinput.c \
- keysym2ucs.c \
- pseudoramiX.c \
- quartz.c \
- quartzCocoa.m \
- quartzKeyboard.c \
- quartzStartup.c \
- quartzRandR.c \
- console_redirect.c
-
-EXTRA_DIST = \
- X11Application.h \
- X11Controller.h \
- applewmExt.h \
- darwin.h \
- darwinfb.h \
- darwinEvents.h \
- keysym2ucs.h \
- pseudoramiX.h \
- quartz.h \
- quartzCommon.h \
- quartzKeyboard.h \
- quartzRandR.h \
- sanitizedCarbon.h \
- sanitizedCocoa.h \
- console_redirect.h
+noinst_LTLIBRARIES = libXquartz.la
+AM_CFLAGS = $(DIX_CFLAGS)
+AM_OBJCFLAGS = $(DIX_CFLAGS)
+AM_CPPFLAGS = \
+ -DBUILD_DATE=\"$(BUILD_DATE)\" \
+ -DXSERVER_VERSION=\"$(VERSION)\" \
+ -DINXQUARTZ \
+ -DUSE_NEW_CLUT \
+ -DXFree86Server \
+ -I$(top_srcdir)/miext/rootless \
+ -DX11LIBDIR=\"$(libdir)\"
+
+if GLX
+GL_DIR = GL
+endif
+
+SUBDIRS = bundle . $(GL_DIR) xpr pbproxy mach-startup man
+
+DIST_SUBDIRS = bundle . GL xpr pbproxy mach-startup man
+
+libXquartz_la_SOURCES = \
+ $(top_srcdir)/fb/fbcmap_mi.c \
+ $(top_srcdir)/mi/miinitext.c \
+ X11Application.m \
+ X11Controller.m \
+ applewm.c \
+ darwin.c \
+ darwinEvents.c \
+ darwinXinput.c \
+ keysym2ucs.c \
+ pseudoramiX.c \
+ quartz.c \
+ quartzCocoa.m \
+ quartzKeyboard.c \
+ quartzStartup.c \
+ quartzRandR.c \
+ console_redirect.c
+
+EXTRA_DIST = \
+ X11Application.h \
+ X11Controller.h \
+ applewmExt.h \
+ darwin.h \
+ darwinfb.h \
+ darwinEvents.h \
+ keysym2ucs.h \
+ pseudoramiX.h \
+ quartz.h \
+ quartzCommon.h \
+ quartzKeyboard.h \
+ quartzRandR.h \
+ sanitizedCarbon.h \
+ sanitizedCocoa.h \
+ console_redirect.h
diff --git a/xorg-server/hw/xquartz/X11Application.h b/xorg-server/hw/xquartz/X11Application.h
index 687551ec6..baee29d4c 100644
--- a/xorg-server/hw/xquartz/X11Application.h
+++ b/xorg-server/hw/xquartz/X11Application.h
@@ -1,116 +1,116 @@
-/* X11Application.h -- subclass of NSApplication to multiplex events
-
- Copyright (c) 2002-2007 Apple 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 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. */
-
-#ifndef X11APPLICATION_H
-#define X11APPLICATION_H 1
-
-#if __OBJC__
-
-#import "X11Controller.h"
-
-@interface X11Application : NSApplication {
- X11Controller *_controller;
-
- unsigned int _x_active :1;
-}
-
-- (void) set_controller:controller;
-- (void) set_window_menu:(NSArray *)list;
-
-- (CFPropertyListRef) prefs_get_copy:(NSString *)key CF_RETURNS_RETAINED;
-- (int) prefs_get_integer:(NSString *)key default:(int)def;
-- (const char *) prefs_get_string:(NSString *)key default:(const char *)def;
-- (float) prefs_get_float:(NSString *)key default:(float)def;
-- (int) prefs_get_boolean:(NSString *)key default:(int)def;
-- (NSURL *) prefs_copy_url:(NSString *)key default:(NSURL *)def NS_RETURNS_RETAINED;
-- (NSArray *) prefs_get_array:(NSString *)key;
-- (void) prefs_set_integer:(NSString *)key value:(int)value;
-- (void) prefs_set_float:(NSString *)key value:(float)value;
-- (void) prefs_set_boolean:(NSString *)key value:(int)value;
-- (void) prefs_set_array:(NSString *)key value:(NSArray *)value;
-- (void) prefs_set_string:(NSString *)key value:(NSString *)value;
-- (void) prefs_synchronize;
-
-- (X11Controller *) controller;
-- (OSX_BOOL) x_active;
-@end
-
-extern X11Application *X11App;
-
-#endif /* __OBJC__ */
-
-void X11ApplicationSetWindowMenu (int nitems, const char **items,
- const char *shortcuts);
-void X11ApplicationSetWindowMenuCheck (int idx);
-void X11ApplicationSetFrontProcess (void);
-void X11ApplicationSetCanQuit (int state);
-void X11ApplicationServerReady (void);
-void X11ApplicationShowHideMenubar (int state);
-void X11ApplicationLaunchClient (const char *cmd);
-
-Bool X11ApplicationCanEnterRandR (void);
-
-void X11ApplicationMain(int argc, char **argv, char **envp);
-
-#define PREFS_APPSMENU "apps_menu"
-#define PREFS_FAKEBUTTONS "enable_fake_buttons"
-#define PREFS_KEYEQUIVS "enable_key_equivalents"
-#define PREFS_FULLSCREEN_HOTKEYS "fullscreen_hotkeys"
-#define PREFS_FULLSCREEN_MENU "fullscreen_menu"
-#define PREFS_SYNC_KEYMAP "sync_keymap"
-#define PREFS_DEPTH "depth"
-#define PREFS_NO_AUTH "no_auth"
-#define PREFS_NO_TCP "nolisten_tcp"
-#define PREFS_DONE_XINIT_CHECK "done_xinit_check"
-#define PREFS_NO_QUIT_ALERT "no_quit_alert"
-#define PREFS_NO_RANDR_ALERT "no_randr_alert"
-#define PREFS_OPTION_SENDS_ALT "option_sends_alt"
-#define PREFS_FAKE_BUTTON2 "fake_button2"
-#define PREFS_FAKE_BUTTON3 "fake_button3"
-#define PREFS_APPKIT_MODIFIERS "appkit_modifiers"
-#define PREFS_WINDOW_ITEM_MODIFIERS "window_item_modifiers"
-#define PREFS_ROOTLESS "rootless"
-#define PREFS_TEST_EXTENSIONS "enable_test_extensions"
-#define PREFS_XP_OPTIONS "xp_options"
-#define PREFS_LOGIN_SHELL "login_shell"
-#define PREFS_UPDATE_FEED "update_feed"
-#define PREFS_CLICK_THROUGH "wm_click_through"
-#define PREFS_FFM "wm_ffm"
-#define PREFS_FOCUS_ON_NEW_WINDOW "wm_focus_on_new_window"
-
-#define PREFS_SCROLL_IN_DEV_DIRECTION "scroll_in_device_direction"
-extern Bool XQuartzScrollInDeviceDirection;
-
-#define PREFS_SYNC_PB "sync_pasteboard"
-#define PREFS_SYNC_PB_TO_CLIPBOARD "sync_pasteboard_to_clipboard"
-#define PREFS_SYNC_PB_TO_PRIMARY "sync_pasteboard_to_primary"
-#define PREFS_SYNC_CLIPBOARD_TO_PB "sync_clipboard_to_pasteboard"
-#define PREFS_SYNC_PRIMARY_ON_SELECT "sync_primary_on_select"
-
-#endif /* X11APPLICATION_H */
+/* X11Application.h -- subclass of NSApplication to multiplex events
+
+ Copyright (c) 2002-2007 Apple 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 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. */
+
+#ifndef X11APPLICATION_H
+#define X11APPLICATION_H 1
+
+#if __OBJC__
+
+#import "X11Controller.h"
+
+@interface X11Application : NSApplication {
+ X11Controller *_controller;
+
+ unsigned int _x_active :1;
+}
+
+- (void) set_controller:controller;
+- (void) set_window_menu:(NSArray *)list;
+
+- (CFPropertyListRef) prefs_get_copy:(NSString *)key CF_RETURNS_RETAINED;
+- (int) prefs_get_integer:(NSString *)key default:(int)def;
+- (const char *) prefs_get_string:(NSString *)key default:(const char *)def;
+- (float) prefs_get_float:(NSString *)key default:(float)def;
+- (int) prefs_get_boolean:(NSString *)key default:(int)def;
+- (NSURL *) prefs_copy_url:(NSString *)key default:(NSURL *)def NS_RETURNS_RETAINED;
+- (NSArray *) prefs_get_array:(NSString *)key;
+- (void) prefs_set_integer:(NSString *)key value:(int)value;
+- (void) prefs_set_float:(NSString *)key value:(float)value;
+- (void) prefs_set_boolean:(NSString *)key value:(int)value;
+- (void) prefs_set_array:(NSString *)key value:(NSArray *)value;
+- (void) prefs_set_string:(NSString *)key value:(NSString *)value;
+- (void) prefs_synchronize;
+
+- (X11Controller *) controller;
+- (OSX_BOOL) x_active;
+@end
+
+extern X11Application *X11App;
+
+#endif /* __OBJC__ */
+
+void X11ApplicationSetWindowMenu (int nitems, const char **items,
+ const char *shortcuts);
+void X11ApplicationSetWindowMenuCheck (int idx);
+void X11ApplicationSetFrontProcess (void);
+void X11ApplicationSetCanQuit (int state);
+void X11ApplicationServerReady (void);
+void X11ApplicationShowHideMenubar (int state);
+void X11ApplicationLaunchClient (const char *cmd);
+
+Bool X11ApplicationCanEnterRandR (void);
+
+void X11ApplicationMain(int argc, char **argv, char **envp);
+
+#define PREFS_APPSMENU "apps_menu"
+#define PREFS_FAKEBUTTONS "enable_fake_buttons"
+#define PREFS_KEYEQUIVS "enable_key_equivalents"
+#define PREFS_FULLSCREEN_HOTKEYS "fullscreen_hotkeys"
+#define PREFS_FULLSCREEN_MENU "fullscreen_menu"
+#define PREFS_SYNC_KEYMAP "sync_keymap"
+#define PREFS_DEPTH "depth"
+#define PREFS_NO_AUTH "no_auth"
+#define PREFS_NO_TCP "nolisten_tcp"
+#define PREFS_DONE_XINIT_CHECK "done_xinit_check"
+#define PREFS_NO_QUIT_ALERT "no_quit_alert"
+#define PREFS_NO_RANDR_ALERT "no_randr_alert"
+#define PREFS_OPTION_SENDS_ALT "option_sends_alt"
+#define PREFS_FAKE_BUTTON2 "fake_button2"
+#define PREFS_FAKE_BUTTON3 "fake_button3"
+#define PREFS_APPKIT_MODIFIERS "appkit_modifiers"
+#define PREFS_WINDOW_ITEM_MODIFIERS "window_item_modifiers"
+#define PREFS_ROOTLESS "rootless"
+#define PREFS_TEST_EXTENSIONS "enable_test_extensions"
+#define PREFS_XP_OPTIONS "xp_options"
+#define PREFS_LOGIN_SHELL "login_shell"
+#define PREFS_UPDATE_FEED "update_feed"
+#define PREFS_CLICK_THROUGH "wm_click_through"
+#define PREFS_FFM "wm_ffm"
+#define PREFS_FOCUS_ON_NEW_WINDOW "wm_focus_on_new_window"
+
+#define PREFS_SCROLL_IN_DEV_DIRECTION "scroll_in_device_direction"
+extern Bool XQuartzScrollInDeviceDirection;
+
+#define PREFS_SYNC_PB "sync_pasteboard"
+#define PREFS_SYNC_PB_TO_CLIPBOARD "sync_pasteboard_to_clipboard"
+#define PREFS_SYNC_PB_TO_PRIMARY "sync_pasteboard_to_primary"
+#define PREFS_SYNC_CLIPBOARD_TO_PB "sync_clipboard_to_pasteboard"
+#define PREFS_SYNC_PRIMARY_ON_SELECT "sync_primary_on_select"
+
+#endif /* X11APPLICATION_H */
diff --git a/xorg-server/hw/xquartz/X11Application.m b/xorg-server/hw/xquartz/X11Application.m
index 1dec6c03a..7fd7dab3c 100644
--- a/xorg-server/hw/xquartz/X11Application.m
+++ b/xorg-server/hw/xquartz/X11Application.m
@@ -1,1421 +1,1421 @@
-/* X11Application.m -- subclass of NSApplication to multiplex events
-
- Copyright (c) 2002-2008 Apple 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 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. */
-
-#include "sanitizedCarbon.h"
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "quartzCommon.h"
-
-#import "X11Application.h"
-
-#include "darwin.h"
-#include "quartz.h"
-#include "darwinEvents.h"
-#include "quartzKeyboard.h"
-#include <X11/extensions/applewmconst.h>
-#include "micmap.h"
-#include "exglobals.h"
-
-#include <mach/mach.h>
-#include <unistd.h>
-#include <AvailabilityMacros.h>
-
-#include <pthread.h>
-
-#include <Xplugin.h>
-
-// pbproxy/pbproxy.h
-extern int xpbproxy_run (void);
-
-#define DEFAULTS_FILE X11LIBDIR"/X11/xserver/Xquartz.plist"
-
-#ifndef XSERVER_VERSION
-#define XSERVER_VERSION "?"
-#endif
-
-#ifdef HAVE_LIBDISPATCH
-#include <dispatch/dispatch.h>
-
-static dispatch_queue_t eventTranslationQueue;
-#endif
-
-/* Stuck modifier / button state... force release when we context switch */
-static NSEventType keyState[NUM_KEYCODES];
-
-extern Bool noTestExtensions;
-
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
-static TISInputSourceRef last_key_layout;
-#else
-static KeyboardLayoutRef last_key_layout;
-#endif
-
-/* This preference is only tested on Lion or later as it's not relevant to
- * earlier OS versions.
- */
-Bool XQuartzScrollInDeviceDirection = FALSE;
-
-extern int darwinFakeButtons;
-
-/* Store the mouse location while in the background, and update X11's pointer
- * location when we become the foreground application
- */
-static NSPoint bgMouseLocation;
-static BOOL bgMouseLocationUpdated = FALSE;
-
-X11Application *X11App;
-
-CFStringRef app_prefs_domain_cfstr = NULL;
-
-#define ALL_KEY_MASKS (NSShiftKeyMask | NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask)
-
-@interface X11Application (Private)
-- (void) sendX11NSEvent:(NSEvent *)e;
-@end
-
-@implementation X11Application
-
-typedef struct message_struct message;
-struct message_struct {
- mach_msg_header_t hdr;
- SEL selector;
- NSObject *arg;
-};
-
-static mach_port_t _port;
-
-/* Quartz mode initialization routine. This is often dynamically loaded
- but is statically linked into this X server. */
-Bool QuartzModeBundleInit(void);
-
-static void init_ports (void) {
- kern_return_t r;
- NSPort *p;
-
- if (_port != MACH_PORT_NULL) return;
-
- r = mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE, &_port);
- if (r != KERN_SUCCESS) return;
-
- p = [NSMachPort portWithMachPort:_port];
- [p setDelegate:NSApp];
- [p scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
-}
-
-static void message_kit_thread (SEL selector, NSObject *arg) {
- message msg;
- kern_return_t r;
-
- msg.hdr.msgh_bits = MACH_MSGH_BITS (MACH_MSG_TYPE_MAKE_SEND, 0);
- msg.hdr.msgh_size = sizeof (msg);
- msg.hdr.msgh_remote_port = _port;
- msg.hdr.msgh_local_port = MACH_PORT_NULL;
- msg.hdr.msgh_reserved = 0;
- msg.hdr.msgh_id = 0;
-
- msg.selector = selector;
- msg.arg = [arg retain];
-
- r = mach_msg (&msg.hdr, MACH_SEND_MSG, msg.hdr.msgh_size,
- 0, MACH_PORT_NULL, 0, MACH_PORT_NULL);
- if (r != KERN_SUCCESS)
- ErrorF("%s: mach_msg failed: %x\n", __FUNCTION__, r);
-}
-
-- (void) handleMachMessage:(void *)_msg {
- message *msg = _msg;
-
- [self performSelector:msg->selector withObject:msg->arg];
- [msg->arg release];
-}
-
-- (void) set_controller:obj {
- if (_controller == nil) _controller = [obj retain];
-}
-
-- (void) dealloc {
- if (_controller != nil) [_controller release];
-
- if (_port != MACH_PORT_NULL)
- mach_port_deallocate (mach_task_self (), _port);
-
- [super dealloc];
-}
-
-- (void) orderFrontStandardAboutPanel: (id) sender {
- NSMutableDictionary *dict;
- NSDictionary *infoDict;
- NSString *tem;
-
- dict = [NSMutableDictionary dictionaryWithCapacity:3];
- infoDict = [[NSBundle mainBundle] infoDictionary];
-
- [dict setObject: NSLocalizedString (@"The X Window System", @"About panel")
- forKey:@"ApplicationName"];
-
- tem = [infoDict objectForKey:@"CFBundleShortVersionString"];
-
- [dict setObject:[NSString stringWithFormat:@"XQuartz %@", tem]
- forKey:@"ApplicationVersion"];
-
- [dict setObject:[NSString stringWithFormat:@"xorg-server %s", XSERVER_VERSION]
- forKey:@"Version"];
-
- [self orderFrontStandardAboutPanelWithOptions: dict];
-}
-
-- (void) activateX:(OSX_BOOL)state {
- size_t i;
- DEBUG_LOG("state=%d, _x_active=%d, \n", state, _x_active);
- if (state) {
- if(bgMouseLocationUpdated) {
- DarwinSendPointerEvents(darwinPointer, MotionNotify, 0, bgMouseLocation.x, bgMouseLocation.y, 0.0, 0.0, 0.0);
- bgMouseLocationUpdated = FALSE;
- }
- DarwinSendDDXEvent(kXquartzActivate, 0);
- } else {
-
- if(darwin_all_modifier_flags)
- DarwinUpdateModKeys(0);
- for(i=0; i < NUM_KEYCODES; i++) {
- if(keyState[i] == NSKeyDown) {
- DarwinSendKeyboardEvents(KeyRelease, i);
- keyState[i] = NSKeyUp;
- }
- }
-
- DarwinSendDDXEvent(kXquartzDeactivate, 0);
- }
-
- _x_active = state;
-}
-
-- (void) became_key:(NSWindow *)win {
- [self activateX:NO];
-}
-
-- (void) sendEvent:(NSEvent *)e {
- OSX_BOOL for_appkit, for_x;
-
- /* By default pass down the responder chain and to X. */
- for_appkit = YES;
- for_x = YES;
-
- switch ([e type]) {
- case NSLeftMouseDown: case NSRightMouseDown: case NSOtherMouseDown:
- case NSLeftMouseUp: case NSRightMouseUp: case NSOtherMouseUp:
- if ([e window] != nil) {
- /* Pointer event has an (AppKit) window. Probably something for the kit. */
- for_x = NO;
- if (_x_active) [self activateX:NO];
- } else if ([self modalWindow] == nil) {
- /* Must be an X window. Tell appkit it doesn't have focus. */
- for_appkit = NO;
-
- if ([self isActive]) {
- [self deactivate];
- if (!_x_active && quartzProcs->IsX11Window([e windowNumber]))
- [self activateX:YES];
- }
- }
-
- /* We want to force sending to appkit if we're over the menu bar */
- if(!for_appkit) {
- NSPoint NSlocation = [e locationInWindow];
- NSWindow *window = [e window];
- NSRect NSframe, NSvisibleFrame;
- CGRect CGframe, CGvisibleFrame;
- CGPoint CGlocation;
-
- if (window != nil) {
- NSRect frame = [window frame];
- NSlocation.x += frame.origin.x;
- NSlocation.y += frame.origin.y;
- }
-
- NSframe = [[NSScreen mainScreen] frame];
- NSvisibleFrame = [[NSScreen mainScreen] visibleFrame];
-
- CGframe = CGRectMake(NSframe.origin.x, NSframe.origin.y,
- NSframe.size.width, NSframe.size.height);
- CGvisibleFrame = CGRectMake(NSvisibleFrame.origin.x,
- NSvisibleFrame.origin.y,
- NSvisibleFrame.size.width,
- NSvisibleFrame.size.height);
- CGlocation = CGPointMake(NSlocation.x, NSlocation.y);
-
- if(CGRectContainsPoint(CGframe, CGlocation) &&
- !CGRectContainsPoint(CGvisibleFrame, CGlocation))
- for_appkit = YES;
- }
-
- break;
-
- case NSKeyDown: case NSKeyUp:
-
- if(_x_active) {
- static BOOL do_swallow = NO;
- static int swallow_keycode;
-
- if([e type] == NSKeyDown) {
- /* Before that though, see if there are any global
- * shortcuts bound to it. */
-
- if(darwinAppKitModMask & [e modifierFlags]) {
- /* Override to force sending to Appkit */
- swallow_keycode = [e keyCode];
- do_swallow = YES;
- for_x = NO;
-#if XPLUGIN_VERSION >= 1
- } else if(XQuartzEnableKeyEquivalents &&
- xp_is_symbolic_hotkey_event([e eventRef])) {
- swallow_keycode = [e keyCode];
- do_swallow = YES;
- for_x = NO;
-#endif
- } else if(XQuartzEnableKeyEquivalents &&
- [[self mainMenu] performKeyEquivalent:e]) {
- swallow_keycode = [e keyCode];
- do_swallow = YES;
- for_appkit = NO;
- for_x = NO;
- } else if(!XQuartzIsRootless
- && ([e modifierFlags] & ALL_KEY_MASKS) == (NSCommandKeyMask | NSAlternateKeyMask)
- && ([e keyCode] == 0 /*a*/ || [e keyCode] == 53 /*Esc*/)) {
- /* We have this here to force processing fullscreen
- * toggle even if XQuartzEnableKeyEquivalents is disabled */
- swallow_keycode = [e keyCode];
- do_swallow = YES;
- for_x = NO;
- for_appkit = NO;
- DarwinSendDDXEvent(kXquartzToggleFullscreen, 0);
- } else {
- /* No kit window is focused, so send it to X. */
- for_appkit = NO;
- }
- } else { /* KeyUp */
- /* If we saw a key equivalent on the down, don't pass
- * the up through to X. */
- if (do_swallow && [e keyCode] == swallow_keycode) {
- do_swallow = NO;
- for_x = NO;
- }
- }
- } else { /* !_x_active */
- for_x = NO;
- }
- break;
-
- case NSFlagsChanged:
- /* Don't tell X11 about modifiers changing while it's not active */
- if (!_x_active)
- for_x = NO;
- break;
-
- case NSAppKitDefined:
- switch ([e subtype]) {
- static BOOL x_was_active = NO;
-
- case NSApplicationActivatedEventType:
- for_x = NO;
- if ([e window] == nil && x_was_active) {
- BOOL order_all_windows = YES, workspaces, ok;
- for_appkit = NO;
-
- /* FIXME: This is a hack to avoid passing the event to AppKit which
- * would result in it raising one of its windows.
- */
- _appFlags._active = YES;
-
- X11ApplicationSetFrontProcess();
-
- /* Get the Spaces preference for SwitchOnActivate */
- (void)CFPreferencesAppSynchronize(CFSTR("com.apple.dock"));
- workspaces = CFPreferencesGetAppBooleanValue(CFSTR("workspaces"), CFSTR("com.apple.dock"), &ok);
- if (!ok)
- workspaces = NO;
-
- if (workspaces) {
- (void)CFPreferencesAppSynchronize(CFSTR(".GlobalPreferences"));
- order_all_windows = CFPreferencesGetAppBooleanValue(CFSTR("AppleSpacesSwitchOnActivate"), CFSTR(".GlobalPreferences"), &ok);
- if (!ok)
- order_all_windows = YES;
- }
-
- /* TODO: In the workspaces && !AppleSpacesSwitchOnActivate case, the windows are ordered
- * correctly, but we need to activate the top window on this space if there is
- * none active.
- *
- * If there are no active windows, and there are minimized windows, we should
- * be restoring one of them.
- */
- if ([e data2] & 0x10) { // 0x10 (bfCPSOrderAllWindowsForward) is set when we use cmd-tab or the dock icon
- DarwinSendDDXEvent(kXquartzBringAllToFront, 1, order_all_windows);
- }
- }
- break;
-
- case 18: /* ApplicationDidReactivate */
- if (XQuartzFullscreenVisible) for_appkit = NO;
- break;
-
- case NSApplicationDeactivatedEventType:
- for_x = NO;
-
- x_was_active = _x_active;
- if(_x_active)
- [self activateX:NO];
- break;
- }
- break;
-
- default: break; /* for gcc */
- }
-
- if (for_appkit) [super sendEvent:e];
-
- if (for_x) {
-#ifdef HAVE_LIBDISPATCH
- dispatch_async(eventTranslationQueue, ^{
-#endif
- [self sendX11NSEvent:e];
-#ifdef HAVE_LIBDISPATCH
- });
-#endif
- }
-}
-
-- (void) set_window_menu:(NSArray *)list {
- [_controller set_window_menu:list];
-}
-
-- (void) set_window_menu_check:(NSNumber *)n {
- [_controller set_window_menu_check:n];
-}
-
-- (void) set_apps_menu:(NSArray *)list {
- [_controller set_apps_menu:list];
-}
-
-- (void) set_front_process:unused {
- [NSApp activateIgnoringOtherApps:YES];
-
- if ([self modalWindow] == nil)
- [self activateX:YES];
-}
-
-- (void) set_can_quit:(NSNumber *)state {
- [_controller set_can_quit:[state boolValue]];
-}
-
-- (void) server_ready:unused {
- [_controller server_ready];
-}
-
-- (void) show_hide_menubar:(NSNumber *)state {
- /* Also shows/hides the dock */
- if ([state boolValue])
- SetSystemUIMode(kUIModeNormal, 0);
- else
- SetSystemUIMode(kUIModeAllHidden, XQuartzFullscreenMenu ? kUIOptionAutoShowMenuBar : 0); // kUIModeAllSuppressed or kUIOptionAutoShowMenuBar can be used to allow "mouse-activation"
-}
-
-- (void) launch_client:(NSString *)cmd {
- (void)[_controller application:self openFile:cmd];
-}
-
-/* user preferences */
-
-/* Note that these functions only work for arrays whose elements
- can be toll-free-bridged between NS and CF worlds. */
-
-static const void *cfretain (CFAllocatorRef a, const void *b) {
- return CFRetain (b);
-}
-
-static void cfrelease (CFAllocatorRef a, const void *b) {
- CFRelease (b);
-}
-
-static CFMutableArrayRef nsarray_to_cfarray (NSArray *in) {
- CFMutableArrayRef out;
- CFArrayCallBacks cb;
- NSObject *ns;
- const CFTypeRef *cf;
- int i, count;
-
- memset (&cb, 0, sizeof (cb));
- cb.version = 0;
- cb.retain = cfretain;
- cb.release = cfrelease;
-
- count = [in count];
- out = CFArrayCreateMutable (NULL, count, &cb);
-
- for (i = 0; i < count; i++) {
- ns = [in objectAtIndex:i];
-
- if ([ns isKindOfClass:[NSArray class]])
- cf = (CFTypeRef) nsarray_to_cfarray ((NSArray *) ns);
- else
- cf = CFRetain ((CFTypeRef) ns);
-
- CFArrayAppendValue (out, cf);
- CFRelease (cf);
- }
-
- return out;
-}
-
-static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
- NSMutableArray *out;
- const CFTypeRef *cf;
- NSObject *ns;
- int i, count;
-
- count = CFArrayGetCount (in);
- out = [[NSMutableArray alloc] initWithCapacity:count];
-
- for (i = 0; i < count; i++) {
- cf = CFArrayGetValueAtIndex (in, i);
-
- if (CFGetTypeID (cf) == CFArrayGetTypeID ())
- ns = cfarray_to_nsarray ((CFArrayRef) cf);
- else
- ns = [(id)cf retain];
-
- [out addObject:ns];
- [ns release];
- }
-
- return out;
-}
-
-- (CFPropertyListRef) prefs_get_copy:(NSString *)key {
- CFPropertyListRef value;
-
- value = CFPreferencesCopyAppValue ((CFStringRef) key, app_prefs_domain_cfstr);
-
- if (value == NULL) {
- static CFDictionaryRef defaults;
-
- if (defaults == NULL) {
- CFStringRef error = NULL;
- CFDataRef data;
- CFURLRef url;
- SInt32 error_code;
-
- url = (CFURLCreateFromFileSystemRepresentation
- (NULL, (unsigned char *)DEFAULTS_FILE, strlen (DEFAULTS_FILE), false));
- if (CFURLCreateDataAndPropertiesFromResource (NULL, url, &data,
- NULL, NULL, &error_code)) {
- defaults = (CFPropertyListCreateFromXMLData
- (NULL, data, kCFPropertyListMutableContainersAndLeaves, &error));
- if (error != NULL) CFRelease (error);
- CFRelease (data);
- }
- CFRelease (url);
-
- if (defaults != NULL) {
- NSMutableArray *apps, *elt;
- int count, i;
- NSString *name, *nname;
-
- /* Localize the names in the default apps menu. */
-
- apps = [(NSDictionary *)defaults objectForKey:@PREFS_APPSMENU];
- if (apps != nil) {
- count = [apps count];
- for (i = 0; i < count; i++) {
- elt = [apps objectAtIndex:i];
- if (elt != nil && [elt isKindOfClass:[NSArray class]]) {
- name = [elt objectAtIndex:0];
- if (name != nil) {
- nname = NSLocalizedString (name, nil);
- if (nname != nil && nname != name)
- [elt replaceObjectAtIndex:0 withObject:nname];
- }
- }
- }
- }
- }
- }
-
- if (defaults != NULL) value = CFDictionaryGetValue (defaults, key);
- if (value != NULL) CFRetain (value);
- }
-
- return value;
-}
-
-- (int) prefs_get_integer:(NSString *)key default:(int)def {
- CFPropertyListRef value;
- int ret;
-
- value = [self prefs_get_copy:key];
-
- if (value != NULL && CFGetTypeID (value) == CFNumberGetTypeID ())
- CFNumberGetValue (value, kCFNumberIntType, &ret);
- else if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ())
- ret = CFStringGetIntValue (value);
- else
- ret = def;
-
- if (value != NULL) CFRelease (value);
-
- return ret;
-}
-
-- (const char *) prefs_get_string:(NSString *)key default:(const char *)def {
- CFPropertyListRef value;
- const char *ret = NULL;
-
- value = [self prefs_get_copy:key];
-
- if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ()) {
- NSString *s = (NSString *) value;
-
- ret = [s UTF8String];
- }
-
- if (value != NULL) CFRelease (value);
-
- return ret != NULL ? ret : def;
-}
-
-- (NSURL *) prefs_copy_url:(NSString *)key default:(NSURL *)def {
- CFPropertyListRef value;
- NSURL *ret = NULL;
-
- value = [self prefs_get_copy:key];
-
- if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ()) {
- NSString *s = (NSString *) value;
-
- ret = [NSURL URLWithString:s];
- [ret retain];
- }
-
- if (value != NULL) CFRelease (value);
-
- return ret != NULL ? ret : def;
-}
-
-- (float) prefs_get_float:(NSString *)key default:(float)def {
- CFPropertyListRef value;
- float ret = def;
-
- value = [self prefs_get_copy:key];
-
- if (value != NULL
- && CFGetTypeID (value) == CFNumberGetTypeID ()
- && CFNumberIsFloatType (value))
- CFNumberGetValue (value, kCFNumberFloatType, &ret);
- else if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ())
- ret = CFStringGetDoubleValue (value);
-
- if (value != NULL) CFRelease (value);
-
- return ret;
-}
-
-- (int) prefs_get_boolean:(NSString *)key default:(int)def {
- CFPropertyListRef value;
- int ret = def;
-
- value = [self prefs_get_copy:key];
-
- if (value != NULL) {
- if (CFGetTypeID (value) == CFNumberGetTypeID ())
- CFNumberGetValue (value, kCFNumberIntType, &ret);
- else if (CFGetTypeID (value) == CFBooleanGetTypeID ())
- ret = CFBooleanGetValue (value);
- else if (CFGetTypeID (value) == CFStringGetTypeID ()) {
- const char *tem = [(NSString *) value UTF8String];
- if (strcasecmp (tem, "true") == 0 || strcasecmp (tem, "yes") == 0)
- ret = YES;
- else
- ret = NO;
- }
-
- CFRelease (value);
- }
- return ret;
-}
-
-- (NSArray *) prefs_get_array:(NSString *)key {
- NSArray *ret = nil;
- CFPropertyListRef value;
-
- value = [self prefs_get_copy:key];
-
- if (value != NULL) {
- if (CFGetTypeID (value) == CFArrayGetTypeID ())
- ret = [cfarray_to_nsarray (value) autorelease];
-
- CFRelease (value);
- }
-
- return ret;
-}
-
-- (void) prefs_set_integer:(NSString *)key value:(int)value {
- CFNumberRef x;
-
- x = CFNumberCreate (NULL, kCFNumberIntType, &value);
-
- CFPreferencesSetValue ((CFStringRef) key, (CFTypeRef) x, app_prefs_domain_cfstr,
- kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
-
- CFRelease (x);
-}
-
-- (void) prefs_set_float:(NSString *)key value:(float)value {
- CFNumberRef x;
-
- x = CFNumberCreate (NULL, kCFNumberFloatType, &value);
-
- CFPreferencesSetValue ((CFStringRef) key, (CFTypeRef) x, app_prefs_domain_cfstr,
- kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
-
- CFRelease (x);
-}
-
-- (void) prefs_set_boolean:(NSString *)key value:(int)value {
- CFPreferencesSetValue ((CFStringRef) key,
- (CFTypeRef) (value ? kCFBooleanTrue
- : kCFBooleanFalse), app_prefs_domain_cfstr,
- kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
-
-}
-
-- (void) prefs_set_array:(NSString *)key value:(NSArray *)value {
- CFArrayRef cfarray;
-
- cfarray = nsarray_to_cfarray (value);
- CFPreferencesSetValue ((CFStringRef) key,
- (CFTypeRef) cfarray,
- app_prefs_domain_cfstr,
- kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
- CFRelease (cfarray);
-}
-
-- (void) prefs_set_string:(NSString *)key value:(NSString *)value {
- CFPreferencesSetValue ((CFStringRef) key, (CFTypeRef) value,
- app_prefs_domain_cfstr, kCFPreferencesCurrentUser,
- kCFPreferencesAnyHost);
-}
-
-- (void) prefs_synchronize {
- CFPreferencesAppSynchronize (kCFPreferencesCurrentApplication);
-}
-
-- (void) read_defaults
-{
- NSString *nsstr;
- const char *tem;
-
- XQuartzRootlessDefault = [self prefs_get_boolean:@PREFS_ROOTLESS
- default:XQuartzRootlessDefault];
- XQuartzFullscreenMenu = [self prefs_get_boolean:@PREFS_FULLSCREEN_MENU
- default:XQuartzFullscreenMenu];
- XQuartzFullscreenDisableHotkeys = ![self prefs_get_boolean:@PREFS_FULLSCREEN_HOTKEYS
- default:!XQuartzFullscreenDisableHotkeys];
- darwinFakeButtons = [self prefs_get_boolean:@PREFS_FAKEBUTTONS
- default:darwinFakeButtons];
- XQuartzOptionSendsAlt = [self prefs_get_boolean:@PREFS_OPTION_SENDS_ALT
- default:XQuartzOptionSendsAlt];
-
- if (darwinFakeButtons) {
- const char *fake2, *fake3;
-
- fake2 = [self prefs_get_string:@PREFS_FAKE_BUTTON2 default:NULL];
- fake3 = [self prefs_get_string:@PREFS_FAKE_BUTTON3 default:NULL];
-
- if (fake2 != NULL) darwinFakeMouse2Mask = DarwinParseModifierList(fake2, TRUE);
- if (fake3 != NULL) darwinFakeMouse3Mask = DarwinParseModifierList(fake3, TRUE);
- }
-
- tem = [self prefs_get_string:@PREFS_APPKIT_MODIFIERS default:NULL];
- if (tem != NULL) darwinAppKitModMask = DarwinParseModifierList(tem, TRUE);
-
- tem = [self prefs_get_string:@PREFS_WINDOW_ITEM_MODIFIERS default:NULL];
- if (tem != NULL) {
- windowItemModMask = DarwinParseModifierList(tem, FALSE);
- } else {
- nsstr = NSLocalizedString (@"window item modifiers", @"window item modifiers");
- if(nsstr != NULL) {
- tem = [nsstr UTF8String];
- if((tem != NULL) && strcmp(tem, "window item modifiers")) {
- windowItemModMask = DarwinParseModifierList(tem, FALSE);
- }
- }
- }
-
- XQuartzEnableKeyEquivalents = [self prefs_get_boolean:@PREFS_KEYEQUIVS
- default:XQuartzEnableKeyEquivalents];
-
- darwinSyncKeymap = [self prefs_get_boolean:@PREFS_SYNC_KEYMAP
- default:darwinSyncKeymap];
-
- darwinDesiredDepth = [self prefs_get_integer:@PREFS_DEPTH
- default:darwinDesiredDepth];
-
- noTestExtensions = ![self prefs_get_boolean:@PREFS_TEST_EXTENSIONS
- default:FALSE];
-
- XQuartzScrollInDeviceDirection = [self prefs_get_boolean:@PREFS_SCROLL_IN_DEV_DIRECTION
- default:XQuartzScrollInDeviceDirection];
-
-#if XQUARTZ_SPARKLE
- NSURL *url = [self prefs_copy_url:@PREFS_UPDATE_FEED default:nil];
- if(url) {
- [[SUUpdater sharedUpdater] setFeedURL:url];
- [url release];
- }
-#endif
-}
-
-/* This will end up at the end of the responder chain. */
-- (void) copy:sender {
- DarwinSendDDXEvent(kXquartzPasteboardNotify, 1,
- AppleWMCopyToPasteboard);
-}
-
-- (X11Controller *) controller {
- return _controller;
-}
-
-- (OSX_BOOL) x_active {
- return _x_active;
-}
-
-@end
-
-static NSArray *
-array_with_strings_and_numbers (int nitems, const char **items,
- const char *numbers) {
- NSMutableArray *array, *subarray;
- NSString *string, *number;
- int i;
-
- /* (Can't autorelease on the X server thread) */
-
- array = [[NSMutableArray alloc] initWithCapacity:nitems];
-
- for (i = 0; i < nitems; i++) {
- subarray = [[NSMutableArray alloc] initWithCapacity:2];
-
- string = [[NSString alloc] initWithUTF8String:items[i]];
- [subarray addObject:string];
- [string release];
-
- if (numbers[i] != 0) {
- number = [[NSString alloc] initWithFormat:@"%d", numbers[i]];
- [subarray addObject:number];
- [number release];
- } else
- [subarray addObject:@""];
-
- [array addObject:subarray];
- [subarray release];
- }
-
- return array;
-}
-
-void X11ApplicationSetWindowMenu (int nitems, const char **items,
- const char *shortcuts) {
- NSArray *array;
- array = array_with_strings_and_numbers (nitems, items, shortcuts);
-
- /* Send the array of strings over to the appkit thread */
-
- message_kit_thread (@selector (set_window_menu:), array);
- [array release];
-}
-
-void X11ApplicationSetWindowMenuCheck (int idx) {
- NSNumber *n;
-
- n = [[NSNumber alloc] initWithInt:idx];
-
- message_kit_thread (@selector (set_window_menu_check:), n);
-
- [n release];
-}
-
-void X11ApplicationSetFrontProcess (void) {
- message_kit_thread (@selector (set_front_process:), nil);
-}
-
-void X11ApplicationSetCanQuit (int state) {
- NSNumber *n;
-
- n = [[NSNumber alloc] initWithBool:state];
-
- message_kit_thread (@selector (set_can_quit:), n);
-
- [n release];
-}
-
-void X11ApplicationServerReady (void) {
- message_kit_thread (@selector (server_ready:), nil);
-}
-
-void X11ApplicationShowHideMenubar (int state) {
- NSNumber *n;
-
- n = [[NSNumber alloc] initWithBool:state];
-
- message_kit_thread (@selector (show_hide_menubar:), n);
-
- [n release];
-}
-
-void X11ApplicationLaunchClient (const char *cmd) {
- NSString *string;
-
- string = [[NSString alloc] initWithUTF8String:cmd];
-
- message_kit_thread (@selector (launch_client:), string);
-
- [string release];
-}
-
-/* This is a special function in that it is run from the *SERVER* thread and
- * not the AppKit thread. We want to block entering a screen-capturing RandR
- * mode until we notify the user about how to get out if the X11 client crashes.
- */
-Bool X11ApplicationCanEnterRandR(void) {
- NSString *title, *msg;
-
- if([X11App prefs_get_boolean:@PREFS_NO_RANDR_ALERT default:NO] || XQuartzShieldingWindowLevel != 0)
- return TRUE;
-
- title = NSLocalizedString(@"Enter RandR mode?", @"Dialog title when switching to RandR");
- msg = NSLocalizedString(@"An application has requested X11 to change the resolution of your display. X11 will restore the display to its previous state when the requesting application requests to return to the previous state. Alternatively, you can use the ⌥⌘A key sequence to force X11 to return to the previous state.",
- @"Dialog when switching to RandR");
-
- if(!XQuartzIsRootless)
- QuartzShowFullscreen(FALSE);
-
- switch(NSRunAlertPanel(title, msg, NSLocalizedString(@"Allow", @""), NSLocalizedString (@"Cancel", @""), NSLocalizedString (@"Always Allow", @""))) {
- case NSAlertOtherReturn:
- [X11App prefs_set_boolean:@PREFS_NO_RANDR_ALERT value:YES];
- [X11App prefs_synchronize];
- case NSAlertDefaultReturn:
- return YES;
-
- default:
- return NO;
- }
-}
-
-static void check_xinitrc (void) {
- char *tem, buf[1024];
- NSString *msg;
-
- if ([X11App prefs_get_boolean:@PREFS_DONE_XINIT_CHECK default:NO])
- return;
-
- tem = getenv ("HOME");
- if (tem == NULL) goto done;
-
- snprintf (buf, sizeof (buf), "%s/.xinitrc", tem);
- if (access (buf, F_OK) != 0)
- goto done;
-
- msg = NSLocalizedString (@"You have an existing ~/.xinitrc file.\n\n\
-Windows displayed by X11 applications may not have titlebars, or may look \
-different to windows displayed by native applications.\n\n\
-Would you like to move aside the existing file and use the standard X11 \
-environment the next time you start X11?", @"Startup xinitrc dialog");
-
- if(NSAlertDefaultReturn == NSRunAlertPanel (nil, msg, NSLocalizedString (@"Yes", @""),
- NSLocalizedString (@"No", @""), nil)) {
- char buf2[1024];
- int i = -1;
-
- snprintf (buf2, sizeof (buf2), "%s.old", buf);
-
- for(i = 1; access (buf2, F_OK) == 0; i++)
- snprintf (buf2, sizeof (buf2), "%s.old.%d", buf, i);
-
- rename (buf, buf2);
- }
-
- done:
- [X11App prefs_set_boolean:@PREFS_DONE_XINIT_CHECK value:YES];
- [X11App prefs_synchronize];
-}
-
-static inline pthread_t create_thread(void *(*func)(void *), void *arg) {
- pthread_attr_t attr;
- pthread_t tid;
-
- pthread_attr_init(&attr);
- pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
- pthread_create(&tid, &attr, func, arg);
- pthread_attr_destroy(&attr);
-
- return tid;
-}
-
-static void *xpbproxy_x_thread(void *args) {
- xpbproxy_run();
-
- ErrorF("xpbproxy thread is terminating unexpectedly.\n");
- return NULL;
-}
-
-void X11ApplicationMain (int argc, char **argv, char **envp) {
- NSAutoreleasePool *pool;
-
-#ifdef DEBUG
- while (access ("/tmp/x11-block", F_OK) == 0) sleep (1);
-#endif
-
- pool = [[NSAutoreleasePool alloc] init];
- X11App = (X11Application *) [X11Application sharedApplication];
- init_ports ();
-
- app_prefs_domain_cfstr = (CFStringRef)[[NSBundle mainBundle] bundleIdentifier];
-
- if (app_prefs_domain_cfstr == NULL) {
- ErrorF("X11ApplicationMain: Unable to determine bundle identifier. Your installation of XQuartz may be broken.\n");
- app_prefs_domain_cfstr = CFSTR(BUNDLE_ID_PREFIX".X11");
- }
-
- [NSApp read_defaults];
- [NSBundle loadNibNamed:@"main" owner:NSApp];
- [[NSNotificationCenter defaultCenter] addObserver:NSApp
- selector:@selector (became_key:)
- name:NSWindowDidBecomeKeyNotification object:nil];
-
- /*
- * The xpr Quartz mode is statically linked into this server.
- * Initialize all the Quartz functions.
- */
- QuartzModeBundleInit();
-
- /* Calculate the height of the menubar so we can avoid it. */
- aquaMenuBarHeight = NSHeight([[NSScreen mainScreen] frame]) -
- NSMaxY([[NSScreen mainScreen] visibleFrame]);
-
-#ifdef HAVE_LIBDISPATCH
- eventTranslationQueue = dispatch_queue_create(BUNDLE_ID_PREFIX".X11.NSEventsToX11EventsQueue", NULL);
- assert(eventTranslationQueue != NULL);
-#endif
-
- /* Set the key layout seed before we start the server */
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
- last_key_layout = TISCopyCurrentKeyboardLayoutInputSource();
-
- if(!last_key_layout)
- ErrorF("X11ApplicationMain: Unable to determine TISCopyCurrentKeyboardLayoutInputSource() at startup.\n");
-#else
- KLGetCurrentKeyboardLayout(&last_key_layout);
- if(!last_key_layout)
- ErrorF("X11ApplicationMain: Unable to determine KLGetCurrentKeyboardLayout() at startup.\n");
-#endif
-
- if (!QuartsResyncKeymap(FALSE)) {
- ErrorF("X11ApplicationMain: Could not build a valid keymap.\n");
- }
-
- /* Tell the server thread that it can proceed */
- QuartzInitServer(argc, argv, envp);
-
- /* This must be done after QuartzInitServer because it can result in
- * an mieqEnqueue() - <rdar://problem/6300249>
- */
- check_xinitrc();
-
- create_thread(xpbproxy_x_thread, NULL);
-
-#if XQUARTZ_SPARKLE
- [[X11App controller] setup_sparkle];
- [[SUUpdater sharedUpdater] resetUpdateCycle];
-// [[SUUpdater sharedUpdater] checkForUpdates:X11App];
-#endif
-
- [pool release];
- [NSApp run];
- /* not reached */
-}
-
-@implementation X11Application (Private)
-
-#ifdef NX_DEVICELCMDKEYMASK
-/* This is to workaround a bug in the VNC server where we sometimes see the L
- * modifier and sometimes see no "side"
- */
-static inline int ensure_flag(int flags, int device_independent, int device_dependents, int device_dependent_default) {
- if( (flags & device_independent) &&
- !(flags & device_dependents))
- flags |= device_dependent_default;
- return flags;
-}
-#endif
-
-#ifdef DEBUG_UNTRUSTED_POINTER_DELTA
-static const char *untrusted_str(NSEvent *e) {
- switch([e type]) {
- case NSScrollWheel:
- return "NSScrollWheel";
- case NSTabletPoint:
- return "NSTabletPoint";
- case NSOtherMouseDown:
- return "NSOtherMouseDown";
- case NSOtherMouseUp:
- return "NSOtherMouseUp";
- case NSLeftMouseDown:
- return "NSLeftMouseDown";
- case NSLeftMouseUp:
- return "NSLeftMouseUp";
- default:
- switch([e subtype]) {
- case NSTabletPointEventSubtype:
- return "NSTabletPointEventSubtype";
- case NSTabletProximityEventSubtype:
- return "NSTabletProximityEventSubtype";
- default:
- return "Other";
- }
- }
-}
-#endif
-
-- (void) sendX11NSEvent:(NSEvent *)e {
- NSPoint location = NSZeroPoint;
- int ev_button, ev_type;
- static float pressure = 0.0; // static so ProximityOut will have the value from the previous tablet event
- static NSPoint tilt; // static so ProximityOut will have the value from the previous tablet event
- static DeviceIntPtr darwinTabletCurrent = NULL;
- static BOOL needsProximityIn = NO; // Do we do need to handle a pending ProximityIn once we have pressure/tilt?
- DeviceIntPtr pDev;
- int modifierFlags;
- BOOL isMouseOrTabletEvent, isTabletEvent;
-
-#ifdef HAVE_LIBDISPATCH
- static dispatch_once_t once_pred;
- dispatch_once(&once_pred, ^{
- tilt = NSZeroPoint;
- darwinTabletCurrent = darwinTabletStylus;
- });
-#else
- if(!darwinTabletCurrent) {
- tilt = NSZeroPoint;
- darwinTabletCurrent = darwinTabletStylus;
- }
-#endif
-
- isMouseOrTabletEvent = [e type] == NSLeftMouseDown || [e type] == NSOtherMouseDown || [e type] == NSRightMouseDown ||
- [e type] == NSLeftMouseUp || [e type] == NSOtherMouseUp || [e type] == NSRightMouseUp ||
- [e type] == NSLeftMouseDragged || [e type] == NSOtherMouseDragged || [e type] == NSRightMouseDragged ||
- [e type] == NSMouseMoved || [e type] == NSTabletPoint || [e type] == NSScrollWheel;
-
- isTabletEvent = ([e type] == NSTabletPoint) ||
- (isMouseOrTabletEvent && ([e subtype] == NSTabletPointEventSubtype || [e subtype] == NSTabletProximityEventSubtype));
-
- if(isMouseOrTabletEvent) {
- static NSPoint lastpt;
- NSWindow *window = [e window];
- NSRect screen = [[[NSScreen screens] objectAtIndex:0] frame];
- BOOL hasUntrustedPointerDelta;
-
- // NSEvents for tablets are not consistent wrt deltaXY between events, so we cannot rely on that
- // Thus tablets will be subject to the warp-pointer bug worked around by the delta, but tablets
- // are not normally used in cases where that bug would present itself, so this is a fair tradeoff
- // <rdar://problem/7111003> deltaX and deltaY are incorrect for NSMouseMoved, NSTabletPointEventSubtype
- // http://xquartz.macosforge.org/trac/ticket/288
- hasUntrustedPointerDelta = isTabletEvent;
-
- // The deltaXY for middle click events also appear erroneous after fast user switching
- // <rdar://problem/7979468> deltaX and deltaY are incorrect for NSOtherMouseDown and NSOtherMouseUp after FUS
- // http://xquartz.macosforge.org/trac/ticket/389
- hasUntrustedPointerDelta = hasUntrustedPointerDelta || [e type] == NSOtherMouseDown || [e type] == NSOtherMouseUp;
-
- // The deltaXY for scroll events correspond to the scroll delta, not the pointer delta
- // <rdar://problem/7989690> deltaXY for wheel events are being sent as mouse movement
- hasUntrustedPointerDelta = hasUntrustedPointerDelta || [e type] == NSScrollWheel;
-
-#ifdef DEBUG_UNTRUSTED_POINTER_DELTA
- hasUntrustedPointerDelta = hasUntrustedPointerDelta || [e type] == NSLeftMouseDown || [e type] == NSLeftMouseUp;
-#endif
-
- if (window != nil) {
- NSRect frame = [window frame];
- location = [e locationInWindow];
- location.x += frame.origin.x;
- location.y += frame.origin.y;
- lastpt = location;
- } else if(hasUntrustedPointerDelta) {
-#ifdef DEBUG_UNTRUSTED_POINTER_DELTA
- ErrorF("--- Begin Event Debug ---\n");
- ErrorF("Event type: %s\n", untrusted_str(e));
- ErrorF("old lastpt: (%0.2f, %0.2f)\n", lastpt.x, lastpt.y);
- ErrorF(" delta: (%0.2f, %0.2f)\n", [e deltaX], -[e deltaY]);
- ErrorF(" location: (%0.2f, %0.2f)\n", lastpt.x + [e deltaX], lastpt.y - [e deltaY]);
- ErrorF("workaround: (%0.2f, %0.2f)\n", [e locationInWindow].x, [e locationInWindow].y);
- ErrorF("--- End Event Debug ---\n");
-
- location.x = lastpt.x + [e deltaX];
- location.y = lastpt.y - [e deltaY];
- lastpt = [e locationInWindow];
-#else
- location = [e locationInWindow];
- lastpt = location;
-#endif
- } else {
- location.x = lastpt.x + [e deltaX];
- location.y = lastpt.y - [e deltaY];
- lastpt = [e locationInWindow];
- }
-
- /* Convert coordinate system */
- location.y = (screen.origin.y + screen.size.height) - location.y;
- }
-
- modifierFlags = [e modifierFlags];
-
-#ifdef NX_DEVICELCMDKEYMASK
- /* This is to workaround a bug in the VNC server where we sometimes see the L
- * modifier and sometimes see no "side"
- */
- modifierFlags = ensure_flag(modifierFlags, NX_CONTROLMASK, NX_DEVICELCTLKEYMASK | NX_DEVICERCTLKEYMASK, NX_DEVICELCTLKEYMASK);
- modifierFlags = ensure_flag(modifierFlags, NX_SHIFTMASK, NX_DEVICELSHIFTKEYMASK | NX_DEVICERSHIFTKEYMASK, NX_DEVICELSHIFTKEYMASK);
- modifierFlags = ensure_flag(modifierFlags, NX_COMMANDMASK, NX_DEVICELCMDKEYMASK | NX_DEVICERCMDKEYMASK, NX_DEVICELCMDKEYMASK);
- modifierFlags = ensure_flag(modifierFlags, NX_ALTERNATEMASK, NX_DEVICELALTKEYMASK | NX_DEVICERALTKEYMASK, NX_DEVICELALTKEYMASK);
-#endif
-
- modifierFlags &= darwin_all_modifier_mask;
-
- /* We don't receive modifier key events while out of focus, and 3button
- * emulation mucks this up, so we need to check our modifier flag state
- * on every event... ugg
- */
-
- if(darwin_all_modifier_flags != modifierFlags)
- DarwinUpdateModKeys(modifierFlags);
-
- switch ([e type]) {
- case NSLeftMouseDown: ev_button=1; ev_type=ButtonPress; goto handle_mouse;
- case NSOtherMouseDown: ev_button=2; ev_type=ButtonPress; goto handle_mouse;
- case NSRightMouseDown: ev_button=3; ev_type=ButtonPress; goto handle_mouse;
- case NSLeftMouseUp: ev_button=1; ev_type=ButtonRelease; goto handle_mouse;
- case NSOtherMouseUp: ev_button=2; ev_type=ButtonRelease; goto handle_mouse;
- case NSRightMouseUp: ev_button=3; ev_type=ButtonRelease; goto handle_mouse;
- case NSLeftMouseDragged: ev_button=1; ev_type=MotionNotify; goto handle_mouse;
- case NSOtherMouseDragged: ev_button=2; ev_type=MotionNotify; goto handle_mouse;
- case NSRightMouseDragged: ev_button=3; ev_type=MotionNotify; goto handle_mouse;
- case NSMouseMoved: ev_button=0; ev_type=MotionNotify; goto handle_mouse;
- case NSTabletPoint: ev_button=0; ev_type=MotionNotify; goto handle_mouse;
-
- handle_mouse:
- pDev = darwinPointer;
-
- /* NSTabletPoint can have no subtype */
- if([e type] != NSTabletPoint &&
- [e subtype] == NSTabletProximityEventSubtype) {
- switch([e pointingDeviceType]) {
- case NSEraserPointingDevice:
- darwinTabletCurrent=darwinTabletEraser;
- break;
- case NSPenPointingDevice:
- darwinTabletCurrent=darwinTabletStylus;
- break;
- case NSCursorPointingDevice:
- case NSUnknownPointingDevice:
- default:
- darwinTabletCurrent=darwinTabletCursor;
- break;
- }
-
- if([e isEnteringProximity])
- needsProximityIn = YES;
- else
- DarwinSendProximityEvents(darwinTabletCurrent, ProximityOut,
- location.x, location.y, pressure,
- tilt.x, tilt.y);
- return;
- }
-
- if ([e type] == NSTabletPoint || [e subtype] == NSTabletPointEventSubtype) {
- pressure = [e pressure];
- tilt = [e tilt];
-
- pDev = darwinTabletCurrent;
-
- if(needsProximityIn) {
- DarwinSendProximityEvents(darwinTabletCurrent, ProximityIn,
- location.x, location.y, pressure,
- tilt.x, tilt.y);
-
- needsProximityIn = NO;
- }
- }
-
- if(!XQuartzServerVisible && noTestExtensions) {
-#if defined(XPLUGIN_VERSION) && XPLUGIN_VERSION > 0
-/* Older libXplugin (Tiger/"Stock" Leopard) aren't thread safe, so we can't call xp_find_window from the Appkit thread */
- xp_window_id wid = 0;
- xp_error err;
-
- /* Sigh. Need to check that we're really over one of
- * our windows. (We need to receive pointer events while
- * not in the foreground, but we don't want to receive them
- * when another window is over us or we might show a tooltip)
- */
-
- err = xp_find_window(location.x, location.y, 0, &wid);
-
- if (err != XP_Success || (err == XP_Success && wid == 0))
-#endif
- {
- bgMouseLocation = location;
- bgMouseLocationUpdated = TRUE;
- return;
- }
- }
-
- if(bgMouseLocationUpdated) {
- if(!(ev_type == MotionNotify && ev_button == 0)) {
- DarwinSendPointerEvents(pDev, MotionNotify, 0, location.x,
- location.y, pressure, tilt.x, tilt.y);
- }
- bgMouseLocationUpdated = FALSE;
- }
-
- DarwinSendPointerEvents(pDev, ev_type, ev_button, location.x, location.y,
- pressure, tilt.x, tilt.y);
-
- break;
-
- case NSTabletProximity:
- switch([e pointingDeviceType]) {
- case NSEraserPointingDevice:
- darwinTabletCurrent=darwinTabletEraser;
- break;
- case NSPenPointingDevice:
- darwinTabletCurrent=darwinTabletStylus;
- break;
- case NSCursorPointingDevice:
- case NSUnknownPointingDevice:
- default:
- darwinTabletCurrent=darwinTabletCursor;
- break;
- }
-
- if([e isEnteringProximity])
- needsProximityIn = YES;
- else
- DarwinSendProximityEvents(darwinTabletCurrent, ProximityOut,
- location.x, location.y, pressure,
- tilt.x, tilt.y);
- break;
-
- case NSScrollWheel:
- {
- float deltaX = [e deltaX];
- float deltaY = [e deltaY];
-#if !defined(XPLUGIN_VERSION) || XPLUGIN_VERSION == 0
- /* If we're in the background, we need to send a MotionNotify event
- * first, since we aren't getting them on background mouse motion
- */
- if(!XQuartzServerVisible && noTestExtensions) {
- bgMouseLocationUpdated = FALSE;
- DarwinSendPointerEvents(darwinPointer, MotionNotify, 0, location.x,
- location.y, pressure, tilt.x, tilt.y);
- }
-#endif
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
- // TODO: Change 1117 to NSAppKitVersionNumber10_7 when it is defined
- if(NSAppKitVersionNumber >= 1117 && XQuartzScrollInDeviceDirection && [e isDirectionInvertedFromDevice]) {
- deltaX *= -1;
- deltaY *= -1;
- }
-#endif
- DarwinSendScrollEvents(deltaX, deltaY, location.x, location.y,
- pressure, tilt.x, tilt.y);
- break;
- }
- case NSKeyDown: case NSKeyUp:
- {
- /* XKB clobbers our keymap at startup, so we need to force it on the first keypress.
- * TODO: Make this less of a kludge.
- */
- static int force_resync_keymap = YES;
- if(force_resync_keymap) {
- DarwinSendDDXEvent(kXquartzReloadKeymap, 0);
- force_resync_keymap = NO;
- }
- }
-
- if(darwinSyncKeymap) {
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
- TISInputSourceRef key_layout = TISCopyCurrentKeyboardLayoutInputSource();
- TISInputSourceRef clear;
- if (CFEqual(key_layout, last_key_layout)) {
- CFRelease(key_layout);
- } else {
- /* Swap/free thread-safely */
- clear = last_key_layout;
- last_key_layout = key_layout;
- CFRelease(clear);
-#else
- KeyboardLayoutRef key_layout;
- KLGetCurrentKeyboardLayout(&key_layout);
- if(key_layout != last_key_layout) {
- last_key_layout = key_layout;
-#endif
- /* Update keyInfo */
- if (!QuartsResyncKeymap(TRUE)) {
- ErrorF("sendX11NSEvent: Could not build a valid keymap.\n");
- }
- }
- }
-
- /* Avoid stuck keys on context switch */
- if(keyState[[e keyCode]] == [e type])
- return;
- keyState[[e keyCode]] = [e type];
-
- DarwinSendKeyboardEvents(([e type] == NSKeyDown) ? KeyPress : KeyRelease, [e keyCode]);
- break;
-
- default: break; /* for gcc */
- }
-}
-@end
+/* X11Application.m -- subclass of NSApplication to multiplex events
+
+ Copyright (c) 2002-2008 Apple 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 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. */
+
+#include "sanitizedCarbon.h"
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "quartzCommon.h"
+
+#import "X11Application.h"
+
+#include "darwin.h"
+#include "quartz.h"
+#include "darwinEvents.h"
+#include "quartzKeyboard.h"
+#include <X11/extensions/applewmconst.h>
+#include "micmap.h"
+#include "exglobals.h"
+
+#include <mach/mach.h>
+#include <unistd.h>
+#include <AvailabilityMacros.h>
+
+#include <pthread.h>
+
+#include <Xplugin.h>
+
+// pbproxy/pbproxy.h
+extern int xpbproxy_run (void);
+
+#define DEFAULTS_FILE X11LIBDIR"/X11/xserver/Xquartz.plist"
+
+#ifndef XSERVER_VERSION
+#define XSERVER_VERSION "?"
+#endif
+
+#ifdef HAVE_LIBDISPATCH
+#include <dispatch/dispatch.h>
+
+static dispatch_queue_t eventTranslationQueue;
+#endif
+
+/* Stuck modifier / button state... force release when we context switch */
+static NSEventType keyState[NUM_KEYCODES];
+
+extern Bool noTestExtensions;
+
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
+static TISInputSourceRef last_key_layout;
+#else
+static KeyboardLayoutRef last_key_layout;
+#endif
+
+/* This preference is only tested on Lion or later as it's not relevant to
+ * earlier OS versions.
+ */
+Bool XQuartzScrollInDeviceDirection = FALSE;
+
+extern int darwinFakeButtons;
+
+/* Store the mouse location while in the background, and update X11's pointer
+ * location when we become the foreground application
+ */
+static NSPoint bgMouseLocation;
+static BOOL bgMouseLocationUpdated = FALSE;
+
+X11Application *X11App;
+
+CFStringRef app_prefs_domain_cfstr = NULL;
+
+#define ALL_KEY_MASKS (NSShiftKeyMask | NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask)
+
+@interface X11Application (Private)
+- (void) sendX11NSEvent:(NSEvent *)e;
+@end
+
+@implementation X11Application
+
+typedef struct message_struct message;
+struct message_struct {
+ mach_msg_header_t hdr;
+ SEL selector;
+ NSObject *arg;
+};
+
+static mach_port_t _port;
+
+/* Quartz mode initialization routine. This is often dynamically loaded
+ but is statically linked into this X server. */
+Bool QuartzModeBundleInit(void);
+
+static void init_ports (void) {
+ kern_return_t r;
+ NSPort *p;
+
+ if (_port != MACH_PORT_NULL) return;
+
+ r = mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE, &_port);
+ if (r != KERN_SUCCESS) return;
+
+ p = [NSMachPort portWithMachPort:_port];
+ [p setDelegate:NSApp];
+ [p scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
+}
+
+static void message_kit_thread (SEL selector, NSObject *arg) {
+ message msg;
+ kern_return_t r;
+
+ msg.hdr.msgh_bits = MACH_MSGH_BITS (MACH_MSG_TYPE_MAKE_SEND, 0);
+ msg.hdr.msgh_size = sizeof (msg);
+ msg.hdr.msgh_remote_port = _port;
+ msg.hdr.msgh_local_port = MACH_PORT_NULL;
+ msg.hdr.msgh_reserved = 0;
+ msg.hdr.msgh_id = 0;
+
+ msg.selector = selector;
+ msg.arg = [arg retain];
+
+ r = mach_msg (&msg.hdr, MACH_SEND_MSG, msg.hdr.msgh_size,
+ 0, MACH_PORT_NULL, 0, MACH_PORT_NULL);
+ if (r != KERN_SUCCESS)
+ ErrorF("%s: mach_msg failed: %x\n", __FUNCTION__, r);
+}
+
+- (void) handleMachMessage:(void *)_msg {
+ message *msg = _msg;
+
+ [self performSelector:msg->selector withObject:msg->arg];
+ [msg->arg release];
+}
+
+- (void) set_controller:obj {
+ if (_controller == nil) _controller = [obj retain];
+}
+
+- (void) dealloc {
+ if (_controller != nil) [_controller release];
+
+ if (_port != MACH_PORT_NULL)
+ mach_port_deallocate (mach_task_self (), _port);
+
+ [super dealloc];
+}
+
+- (void) orderFrontStandardAboutPanel: (id) sender {
+ NSMutableDictionary *dict;
+ NSDictionary *infoDict;
+ NSString *tem;
+
+ dict = [NSMutableDictionary dictionaryWithCapacity:3];
+ infoDict = [[NSBundle mainBundle] infoDictionary];
+
+ [dict setObject: NSLocalizedString (@"The X Window System", @"About panel")
+ forKey:@"ApplicationName"];
+
+ tem = [infoDict objectForKey:@"CFBundleShortVersionString"];
+
+ [dict setObject:[NSString stringWithFormat:@"XQuartz %@", tem]
+ forKey:@"ApplicationVersion"];
+
+ [dict setObject:[NSString stringWithFormat:@"xorg-server %s", XSERVER_VERSION]
+ forKey:@"Version"];
+
+ [self orderFrontStandardAboutPanelWithOptions: dict];
+}
+
+- (void) activateX:(OSX_BOOL)state {
+ size_t i;
+ DEBUG_LOG("state=%d, _x_active=%d, \n", state, _x_active);
+ if (state) {
+ if(bgMouseLocationUpdated) {
+ DarwinSendPointerEvents(darwinPointer, MotionNotify, 0, bgMouseLocation.x, bgMouseLocation.y, 0.0, 0.0, 0.0);
+ bgMouseLocationUpdated = FALSE;
+ }
+ DarwinSendDDXEvent(kXquartzActivate, 0);
+ } else {
+
+ if(darwin_all_modifier_flags)
+ DarwinUpdateModKeys(0);
+ for(i=0; i < NUM_KEYCODES; i++) {
+ if(keyState[i] == NSKeyDown) {
+ DarwinSendKeyboardEvents(KeyRelease, i);
+ keyState[i] = NSKeyUp;
+ }
+ }
+
+ DarwinSendDDXEvent(kXquartzDeactivate, 0);
+ }
+
+ _x_active = state;
+}
+
+- (void) became_key:(NSWindow *)win {
+ [self activateX:NO];
+}
+
+- (void) sendEvent:(NSEvent *)e {
+ OSX_BOOL for_appkit, for_x;
+
+ /* By default pass down the responder chain and to X. */
+ for_appkit = YES;
+ for_x = YES;
+
+ switch ([e type]) {
+ case NSLeftMouseDown: case NSRightMouseDown: case NSOtherMouseDown:
+ case NSLeftMouseUp: case NSRightMouseUp: case NSOtherMouseUp:
+ if ([e window] != nil) {
+ /* Pointer event has an (AppKit) window. Probably something for the kit. */
+ for_x = NO;
+ if (_x_active) [self activateX:NO];
+ } else if ([self modalWindow] == nil) {
+ /* Must be an X window. Tell appkit it doesn't have focus. */
+ for_appkit = NO;
+
+ if ([self isActive]) {
+ [self deactivate];
+ if (!_x_active && quartzProcs->IsX11Window([e windowNumber]))
+ [self activateX:YES];
+ }
+ }
+
+ /* We want to force sending to appkit if we're over the menu bar */
+ if(!for_appkit) {
+ NSPoint NSlocation = [e locationInWindow];
+ NSWindow *window = [e window];
+ NSRect NSframe, NSvisibleFrame;
+ CGRect CGframe, CGvisibleFrame;
+ CGPoint CGlocation;
+
+ if (window != nil) {
+ NSRect frame = [window frame];
+ NSlocation.x += frame.origin.x;
+ NSlocation.y += frame.origin.y;
+ }
+
+ NSframe = [[NSScreen mainScreen] frame];
+ NSvisibleFrame = [[NSScreen mainScreen] visibleFrame];
+
+ CGframe = CGRectMake(NSframe.origin.x, NSframe.origin.y,
+ NSframe.size.width, NSframe.size.height);
+ CGvisibleFrame = CGRectMake(NSvisibleFrame.origin.x,
+ NSvisibleFrame.origin.y,
+ NSvisibleFrame.size.width,
+ NSvisibleFrame.size.height);
+ CGlocation = CGPointMake(NSlocation.x, NSlocation.y);
+
+ if(CGRectContainsPoint(CGframe, CGlocation) &&
+ !CGRectContainsPoint(CGvisibleFrame, CGlocation))
+ for_appkit = YES;
+ }
+
+ break;
+
+ case NSKeyDown: case NSKeyUp:
+
+ if(_x_active) {
+ static BOOL do_swallow = NO;
+ static int swallow_keycode;
+
+ if([e type] == NSKeyDown) {
+ /* Before that though, see if there are any global
+ * shortcuts bound to it. */
+
+ if(darwinAppKitModMask & [e modifierFlags]) {
+ /* Override to force sending to Appkit */
+ swallow_keycode = [e keyCode];
+ do_swallow = YES;
+ for_x = NO;
+#if XPLUGIN_VERSION >= 1
+ } else if(XQuartzEnableKeyEquivalents &&
+ xp_is_symbolic_hotkey_event([e eventRef])) {
+ swallow_keycode = [e keyCode];
+ do_swallow = YES;
+ for_x = NO;
+#endif
+ } else if(XQuartzEnableKeyEquivalents &&
+ [[self mainMenu] performKeyEquivalent:e]) {
+ swallow_keycode = [e keyCode];
+ do_swallow = YES;
+ for_appkit = NO;
+ for_x = NO;
+ } else if(!XQuartzIsRootless
+ && ([e modifierFlags] & ALL_KEY_MASKS) == (NSCommandKeyMask | NSAlternateKeyMask)
+ && ([e keyCode] == 0 /*a*/ || [e keyCode] == 53 /*Esc*/)) {
+ /* We have this here to force processing fullscreen
+ * toggle even if XQuartzEnableKeyEquivalents is disabled */
+ swallow_keycode = [e keyCode];
+ do_swallow = YES;
+ for_x = NO;
+ for_appkit = NO;
+ DarwinSendDDXEvent(kXquartzToggleFullscreen, 0);
+ } else {
+ /* No kit window is focused, so send it to X. */
+ for_appkit = NO;
+ }
+ } else { /* KeyUp */
+ /* If we saw a key equivalent on the down, don't pass
+ * the up through to X. */
+ if (do_swallow && [e keyCode] == swallow_keycode) {
+ do_swallow = NO;
+ for_x = NO;
+ }
+ }
+ } else { /* !_x_active */
+ for_x = NO;
+ }
+ break;
+
+ case NSFlagsChanged:
+ /* Don't tell X11 about modifiers changing while it's not active */
+ if (!_x_active)
+ for_x = NO;
+ break;
+
+ case NSAppKitDefined:
+ switch ([e subtype]) {
+ static BOOL x_was_active = NO;
+
+ case NSApplicationActivatedEventType:
+ for_x = NO;
+ if ([e window] == nil && x_was_active) {
+ BOOL order_all_windows = YES, workspaces, ok;
+ for_appkit = NO;
+
+ /* FIXME: This is a hack to avoid passing the event to AppKit which
+ * would result in it raising one of its windows.
+ */
+ _appFlags._active = YES;
+
+ X11ApplicationSetFrontProcess();
+
+ /* Get the Spaces preference for SwitchOnActivate */
+ (void)CFPreferencesAppSynchronize(CFSTR("com.apple.dock"));
+ workspaces = CFPreferencesGetAppBooleanValue(CFSTR("workspaces"), CFSTR("com.apple.dock"), &ok);
+ if (!ok)
+ workspaces = NO;
+
+ if (workspaces) {
+ (void)CFPreferencesAppSynchronize(CFSTR(".GlobalPreferences"));
+ order_all_windows = CFPreferencesGetAppBooleanValue(CFSTR("AppleSpacesSwitchOnActivate"), CFSTR(".GlobalPreferences"), &ok);
+ if (!ok)
+ order_all_windows = YES;
+ }
+
+ /* TODO: In the workspaces && !AppleSpacesSwitchOnActivate case, the windows are ordered
+ * correctly, but we need to activate the top window on this space if there is
+ * none active.
+ *
+ * If there are no active windows, and there are minimized windows, we should
+ * be restoring one of them.
+ */
+ if ([e data2] & 0x10) { // 0x10 (bfCPSOrderAllWindowsForward) is set when we use cmd-tab or the dock icon
+ DarwinSendDDXEvent(kXquartzBringAllToFront, 1, order_all_windows);
+ }
+ }
+ break;
+
+ case 18: /* ApplicationDidReactivate */
+ if (XQuartzFullscreenVisible) for_appkit = NO;
+ break;
+
+ case NSApplicationDeactivatedEventType:
+ for_x = NO;
+
+ x_was_active = _x_active;
+ if(_x_active)
+ [self activateX:NO];
+ break;
+ }
+ break;
+
+ default: break; /* for gcc */
+ }
+
+ if (for_appkit) [super sendEvent:e];
+
+ if (for_x) {
+#ifdef HAVE_LIBDISPATCH
+ dispatch_async(eventTranslationQueue, ^{
+#endif
+ [self sendX11NSEvent:e];
+#ifdef HAVE_LIBDISPATCH
+ });
+#endif
+ }
+}
+
+- (void) set_window_menu:(NSArray *)list {
+ [_controller set_window_menu:list];
+}
+
+- (void) set_window_menu_check:(NSNumber *)n {
+ [_controller set_window_menu_check:n];
+}
+
+- (void) set_apps_menu:(NSArray *)list {
+ [_controller set_apps_menu:list];
+}
+
+- (void) set_front_process:unused {
+ [NSApp activateIgnoringOtherApps:YES];
+
+ if ([self modalWindow] == nil)
+ [self activateX:YES];
+}
+
+- (void) set_can_quit:(NSNumber *)state {
+ [_controller set_can_quit:[state boolValue]];
+}
+
+- (void) server_ready:unused {
+ [_controller server_ready];
+}
+
+- (void) show_hide_menubar:(NSNumber *)state {
+ /* Also shows/hides the dock */
+ if ([state boolValue])
+ SetSystemUIMode(kUIModeNormal, 0);
+ else
+ SetSystemUIMode(kUIModeAllHidden, XQuartzFullscreenMenu ? kUIOptionAutoShowMenuBar : 0); // kUIModeAllSuppressed or kUIOptionAutoShowMenuBar can be used to allow "mouse-activation"
+}
+
+- (void) launch_client:(NSString *)cmd {
+ (void)[_controller application:self openFile:cmd];
+}
+
+/* user preferences */
+
+/* Note that these functions only work for arrays whose elements
+ can be toll-free-bridged between NS and CF worlds. */
+
+static const void *cfretain (CFAllocatorRef a, const void *b) {
+ return CFRetain (b);
+}
+
+static void cfrelease (CFAllocatorRef a, const void *b) {
+ CFRelease (b);
+}
+
+static CFMutableArrayRef nsarray_to_cfarray (NSArray *in) {
+ CFMutableArrayRef out;
+ CFArrayCallBacks cb;
+ NSObject *ns;
+ const CFTypeRef *cf;
+ int i, count;
+
+ memset (&cb, 0, sizeof (cb));
+ cb.version = 0;
+ cb.retain = cfretain;
+ cb.release = cfrelease;
+
+ count = [in count];
+ out = CFArrayCreateMutable (NULL, count, &cb);
+
+ for (i = 0; i < count; i++) {
+ ns = [in objectAtIndex:i];
+
+ if ([ns isKindOfClass:[NSArray class]])
+ cf = (CFTypeRef) nsarray_to_cfarray ((NSArray *) ns);
+ else
+ cf = CFRetain ((CFTypeRef) ns);
+
+ CFArrayAppendValue (out, cf);
+ CFRelease (cf);
+ }
+
+ return out;
+}
+
+static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
+ NSMutableArray *out;
+ const CFTypeRef *cf;
+ NSObject *ns;
+ int i, count;
+
+ count = CFArrayGetCount (in);
+ out = [[NSMutableArray alloc] initWithCapacity:count];
+
+ for (i = 0; i < count; i++) {
+ cf = CFArrayGetValueAtIndex (in, i);
+
+ if (CFGetTypeID (cf) == CFArrayGetTypeID ())
+ ns = cfarray_to_nsarray ((CFArrayRef) cf);
+ else
+ ns = [(id)cf retain];
+
+ [out addObject:ns];
+ [ns release];
+ }
+
+ return out;
+}
+
+- (CFPropertyListRef) prefs_get_copy:(NSString *)key {
+ CFPropertyListRef value;
+
+ value = CFPreferencesCopyAppValue ((CFStringRef) key, app_prefs_domain_cfstr);
+
+ if (value == NULL) {
+ static CFDictionaryRef defaults;
+
+ if (defaults == NULL) {
+ CFStringRef error = NULL;
+ CFDataRef data;
+ CFURLRef url;
+ SInt32 error_code;
+
+ url = (CFURLCreateFromFileSystemRepresentation
+ (NULL, (unsigned char *)DEFAULTS_FILE, strlen (DEFAULTS_FILE), false));
+ if (CFURLCreateDataAndPropertiesFromResource (NULL, url, &data,
+ NULL, NULL, &error_code)) {
+ defaults = (CFPropertyListCreateFromXMLData
+ (NULL, data, kCFPropertyListMutableContainersAndLeaves, &error));
+ if (error != NULL) CFRelease (error);
+ CFRelease (data);
+ }
+ CFRelease (url);
+
+ if (defaults != NULL) {
+ NSMutableArray *apps, *elt;
+ int count, i;
+ NSString *name, *nname;
+
+ /* Localize the names in the default apps menu. */
+
+ apps = [(NSDictionary *)defaults objectForKey:@PREFS_APPSMENU];
+ if (apps != nil) {
+ count = [apps count];
+ for (i = 0; i < count; i++) {
+ elt = [apps objectAtIndex:i];
+ if (elt != nil && [elt isKindOfClass:[NSArray class]]) {
+ name = [elt objectAtIndex:0];
+ if (name != nil) {
+ nname = NSLocalizedString (name, nil);
+ if (nname != nil && nname != name)
+ [elt replaceObjectAtIndex:0 withObject:nname];
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (defaults != NULL) value = CFDictionaryGetValue (defaults, key);
+ if (value != NULL) CFRetain (value);
+ }
+
+ return value;
+}
+
+- (int) prefs_get_integer:(NSString *)key default:(int)def {
+ CFPropertyListRef value;
+ int ret;
+
+ value = [self prefs_get_copy:key];
+
+ if (value != NULL && CFGetTypeID (value) == CFNumberGetTypeID ())
+ CFNumberGetValue (value, kCFNumberIntType, &ret);
+ else if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ())
+ ret = CFStringGetIntValue (value);
+ else
+ ret = def;
+
+ if (value != NULL) CFRelease (value);
+
+ return ret;
+}
+
+- (const char *) prefs_get_string:(NSString *)key default:(const char *)def {
+ CFPropertyListRef value;
+ const char *ret = NULL;
+
+ value = [self prefs_get_copy:key];
+
+ if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ()) {
+ NSString *s = (NSString *) value;
+
+ ret = [s UTF8String];
+ }
+
+ if (value != NULL) CFRelease (value);
+
+ return ret != NULL ? ret : def;
+}
+
+- (NSURL *) prefs_copy_url:(NSString *)key default:(NSURL *)def {
+ CFPropertyListRef value;
+ NSURL *ret = NULL;
+
+ value = [self prefs_get_copy:key];
+
+ if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ()) {
+ NSString *s = (NSString *) value;
+
+ ret = [NSURL URLWithString:s];
+ [ret retain];
+ }
+
+ if (value != NULL) CFRelease (value);
+
+ return ret != NULL ? ret : def;
+}
+
+- (float) prefs_get_float:(NSString *)key default:(float)def {
+ CFPropertyListRef value;
+ float ret = def;
+
+ value = [self prefs_get_copy:key];
+
+ if (value != NULL
+ && CFGetTypeID (value) == CFNumberGetTypeID ()
+ && CFNumberIsFloatType (value))
+ CFNumberGetValue (value, kCFNumberFloatType, &ret);
+ else if (value != NULL && CFGetTypeID (value) == CFStringGetTypeID ())
+ ret = CFStringGetDoubleValue (value);
+
+ if (value != NULL) CFRelease (value);
+
+ return ret;
+}
+
+- (int) prefs_get_boolean:(NSString *)key default:(int)def {
+ CFPropertyListRef value;
+ int ret = def;
+
+ value = [self prefs_get_copy:key];
+
+ if (value != NULL) {
+ if (CFGetTypeID (value) == CFNumberGetTypeID ())
+ CFNumberGetValue (value, kCFNumberIntType, &ret);
+ else if (CFGetTypeID (value) == CFBooleanGetTypeID ())
+ ret = CFBooleanGetValue (value);
+ else if (CFGetTypeID (value) == CFStringGetTypeID ()) {
+ const char *tem = [(NSString *) value UTF8String];
+ if (strcasecmp (tem, "true") == 0 || strcasecmp (tem, "yes") == 0)
+ ret = YES;
+ else
+ ret = NO;
+ }
+
+ CFRelease (value);
+ }
+ return ret;
+}
+
+- (NSArray *) prefs_get_array:(NSString *)key {
+ NSArray *ret = nil;
+ CFPropertyListRef value;
+
+ value = [self prefs_get_copy:key];
+
+ if (value != NULL) {
+ if (CFGetTypeID (value) == CFArrayGetTypeID ())
+ ret = [cfarray_to_nsarray (value) autorelease];
+
+ CFRelease (value);
+ }
+
+ return ret;
+}
+
+- (void) prefs_set_integer:(NSString *)key value:(int)value {
+ CFNumberRef x;
+
+ x = CFNumberCreate (NULL, kCFNumberIntType, &value);
+
+ CFPreferencesSetValue ((CFStringRef) key, (CFTypeRef) x, app_prefs_domain_cfstr,
+ kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
+
+ CFRelease (x);
+}
+
+- (void) prefs_set_float:(NSString *)key value:(float)value {
+ CFNumberRef x;
+
+ x = CFNumberCreate (NULL, kCFNumberFloatType, &value);
+
+ CFPreferencesSetValue ((CFStringRef) key, (CFTypeRef) x, app_prefs_domain_cfstr,
+ kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
+
+ CFRelease (x);
+}
+
+- (void) prefs_set_boolean:(NSString *)key value:(int)value {
+ CFPreferencesSetValue ((CFStringRef) key,
+ (CFTypeRef) (value ? kCFBooleanTrue
+ : kCFBooleanFalse), app_prefs_domain_cfstr,
+ kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
+
+}
+
+- (void) prefs_set_array:(NSString *)key value:(NSArray *)value {
+ CFArrayRef cfarray;
+
+ cfarray = nsarray_to_cfarray (value);
+ CFPreferencesSetValue ((CFStringRef) key,
+ (CFTypeRef) cfarray,
+ app_prefs_domain_cfstr,
+ kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
+ CFRelease (cfarray);
+}
+
+- (void) prefs_set_string:(NSString *)key value:(NSString *)value {
+ CFPreferencesSetValue ((CFStringRef) key, (CFTypeRef) value,
+ app_prefs_domain_cfstr, kCFPreferencesCurrentUser,
+ kCFPreferencesAnyHost);
+}
+
+- (void) prefs_synchronize {
+ CFPreferencesAppSynchronize (kCFPreferencesCurrentApplication);
+}
+
+- (void) read_defaults
+{
+ NSString *nsstr;
+ const char *tem;
+
+ XQuartzRootlessDefault = [self prefs_get_boolean:@PREFS_ROOTLESS
+ default:XQuartzRootlessDefault];
+ XQuartzFullscreenMenu = [self prefs_get_boolean:@PREFS_FULLSCREEN_MENU
+ default:XQuartzFullscreenMenu];
+ XQuartzFullscreenDisableHotkeys = ![self prefs_get_boolean:@PREFS_FULLSCREEN_HOTKEYS
+ default:!XQuartzFullscreenDisableHotkeys];
+ darwinFakeButtons = [self prefs_get_boolean:@PREFS_FAKEBUTTONS
+ default:darwinFakeButtons];
+ XQuartzOptionSendsAlt = [self prefs_get_boolean:@PREFS_OPTION_SENDS_ALT
+ default:XQuartzOptionSendsAlt];
+
+ if (darwinFakeButtons) {
+ const char *fake2, *fake3;
+
+ fake2 = [self prefs_get_string:@PREFS_FAKE_BUTTON2 default:NULL];
+ fake3 = [self prefs_get_string:@PREFS_FAKE_BUTTON3 default:NULL];
+
+ if (fake2 != NULL) darwinFakeMouse2Mask = DarwinParseModifierList(fake2, TRUE);
+ if (fake3 != NULL) darwinFakeMouse3Mask = DarwinParseModifierList(fake3, TRUE);
+ }
+
+ tem = [self prefs_get_string:@PREFS_APPKIT_MODIFIERS default:NULL];
+ if (tem != NULL) darwinAppKitModMask = DarwinParseModifierList(tem, TRUE);
+
+ tem = [self prefs_get_string:@PREFS_WINDOW_ITEM_MODIFIERS default:NULL];
+ if (tem != NULL) {
+ windowItemModMask = DarwinParseModifierList(tem, FALSE);
+ } else {
+ nsstr = NSLocalizedString (@"window item modifiers", @"window item modifiers");
+ if(nsstr != NULL) {
+ tem = [nsstr UTF8String];
+ if((tem != NULL) && strcmp(tem, "window item modifiers")) {
+ windowItemModMask = DarwinParseModifierList(tem, FALSE);
+ }
+ }
+ }
+
+ XQuartzEnableKeyEquivalents = [self prefs_get_boolean:@PREFS_KEYEQUIVS
+ default:XQuartzEnableKeyEquivalents];
+
+ darwinSyncKeymap = [self prefs_get_boolean:@PREFS_SYNC_KEYMAP
+ default:darwinSyncKeymap];
+
+ darwinDesiredDepth = [self prefs_get_integer:@PREFS_DEPTH
+ default:darwinDesiredDepth];
+
+ noTestExtensions = ![self prefs_get_boolean:@PREFS_TEST_EXTENSIONS
+ default:FALSE];
+
+ XQuartzScrollInDeviceDirection = [self prefs_get_boolean:@PREFS_SCROLL_IN_DEV_DIRECTION
+ default:XQuartzScrollInDeviceDirection];
+
+#if XQUARTZ_SPARKLE
+ NSURL *url = [self prefs_copy_url:@PREFS_UPDATE_FEED default:nil];
+ if(url) {
+ [[SUUpdater sharedUpdater] setFeedURL:url];
+ [url release];
+ }
+#endif
+}
+
+/* This will end up at the end of the responder chain. */
+- (void) copy:sender {
+ DarwinSendDDXEvent(kXquartzPasteboardNotify, 1,
+ AppleWMCopyToPasteboard);
+}
+
+- (X11Controller *) controller {
+ return _controller;
+}
+
+- (OSX_BOOL) x_active {
+ return _x_active;
+}
+
+@end
+
+static NSArray *
+array_with_strings_and_numbers (int nitems, const char **items,
+ const char *numbers) {
+ NSMutableArray *array, *subarray;
+ NSString *string, *number;
+ int i;
+
+ /* (Can't autorelease on the X server thread) */
+
+ array = [[NSMutableArray alloc] initWithCapacity:nitems];
+
+ for (i = 0; i < nitems; i++) {
+ subarray = [[NSMutableArray alloc] initWithCapacity:2];
+
+ string = [[NSString alloc] initWithUTF8String:items[i]];
+ [subarray addObject:string];
+ [string release];
+
+ if (numbers[i] != 0) {
+ number = [[NSString alloc] initWithFormat:@"%d", numbers[i]];
+ [subarray addObject:number];
+ [number release];
+ } else
+ [subarray addObject:@""];
+
+ [array addObject:subarray];
+ [subarray release];
+ }
+
+ return array;
+}
+
+void X11ApplicationSetWindowMenu (int nitems, const char **items,
+ const char *shortcuts) {
+ NSArray *array;
+ array = array_with_strings_and_numbers (nitems, items, shortcuts);
+
+ /* Send the array of strings over to the appkit thread */
+
+ message_kit_thread (@selector (set_window_menu:), array);
+ [array release];
+}
+
+void X11ApplicationSetWindowMenuCheck (int idx) {
+ NSNumber *n;
+
+ n = [[NSNumber alloc] initWithInt:idx];
+
+ message_kit_thread (@selector (set_window_menu_check:), n);
+
+ [n release];
+}
+
+void X11ApplicationSetFrontProcess (void) {
+ message_kit_thread (@selector (set_front_process:), nil);
+}
+
+void X11ApplicationSetCanQuit (int state) {
+ NSNumber *n;
+
+ n = [[NSNumber alloc] initWithBool:state];
+
+ message_kit_thread (@selector (set_can_quit:), n);
+
+ [n release];
+}
+
+void X11ApplicationServerReady (void) {
+ message_kit_thread (@selector (server_ready:), nil);
+}
+
+void X11ApplicationShowHideMenubar (int state) {
+ NSNumber *n;
+
+ n = [[NSNumber alloc] initWithBool:state];
+
+ message_kit_thread (@selector (show_hide_menubar:), n);
+
+ [n release];
+}
+
+void X11ApplicationLaunchClient (const char *cmd) {
+ NSString *string;
+
+ string = [[NSString alloc] initWithUTF8String:cmd];
+
+ message_kit_thread (@selector (launch_client:), string);
+
+ [string release];
+}
+
+/* This is a special function in that it is run from the *SERVER* thread and
+ * not the AppKit thread. We want to block entering a screen-capturing RandR
+ * mode until we notify the user about how to get out if the X11 client crashes.
+ */
+Bool X11ApplicationCanEnterRandR(void) {
+ NSString *title, *msg;
+
+ if([X11App prefs_get_boolean:@PREFS_NO_RANDR_ALERT default:NO] || XQuartzShieldingWindowLevel != 0)
+ return TRUE;
+
+ title = NSLocalizedString(@"Enter RandR mode?", @"Dialog title when switching to RandR");
+ msg = NSLocalizedString(@"An application has requested X11 to change the resolution of your display. X11 will restore the display to its previous state when the requesting application requests to return to the previous state. Alternatively, you can use the ⌥⌘A key sequence to force X11 to return to the previous state.",
+ @"Dialog when switching to RandR");
+
+ if(!XQuartzIsRootless)
+ QuartzShowFullscreen(FALSE);
+
+ switch(NSRunAlertPanel(title, msg, NSLocalizedString(@"Allow", @""), NSLocalizedString (@"Cancel", @""), NSLocalizedString (@"Always Allow", @""))) {
+ case NSAlertOtherReturn:
+ [X11App prefs_set_boolean:@PREFS_NO_RANDR_ALERT value:YES];
+ [X11App prefs_synchronize];
+ case NSAlertDefaultReturn:
+ return YES;
+
+ default:
+ return NO;
+ }
+}
+
+static void check_xinitrc (void) {
+ char *tem, buf[1024];
+ NSString *msg;
+
+ if ([X11App prefs_get_boolean:@PREFS_DONE_XINIT_CHECK default:NO])
+ return;
+
+ tem = getenv ("HOME");
+ if (tem == NULL) goto done;
+
+ snprintf (buf, sizeof (buf), "%s/.xinitrc", tem);
+ if (access (buf, F_OK) != 0)
+ goto done;
+
+ msg = NSLocalizedString (@"You have an existing ~/.xinitrc file.\n\n\
+Windows displayed by X11 applications may not have titlebars, or may look \
+different to windows displayed by native applications.\n\n\
+Would you like to move aside the existing file and use the standard X11 \
+environment the next time you start X11?", @"Startup xinitrc dialog");
+
+ if(NSAlertDefaultReturn == NSRunAlertPanel (nil, msg, NSLocalizedString (@"Yes", @""),
+ NSLocalizedString (@"No", @""), nil)) {
+ char buf2[1024];
+ int i = -1;
+
+ snprintf (buf2, sizeof (buf2), "%s.old", buf);
+
+ for(i = 1; access (buf2, F_OK) == 0; i++)
+ snprintf (buf2, sizeof (buf2), "%s.old.%d", buf, i);
+
+ rename (buf, buf2);
+ }
+
+ done:
+ [X11App prefs_set_boolean:@PREFS_DONE_XINIT_CHECK value:YES];
+ [X11App prefs_synchronize];
+}
+
+static inline pthread_t create_thread(void *(*func)(void *), void *arg) {
+ pthread_attr_t attr;
+ pthread_t tid;
+
+ pthread_attr_init(&attr);
+ pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+ pthread_create(&tid, &attr, func, arg);
+ pthread_attr_destroy(&attr);
+
+ return tid;
+}
+
+static void *xpbproxy_x_thread(void *args) {
+ xpbproxy_run();
+
+ ErrorF("xpbproxy thread is terminating unexpectedly.\n");
+ return NULL;
+}
+
+void X11ApplicationMain (int argc, char **argv, char **envp) {
+ NSAutoreleasePool *pool;
+
+#ifdef DEBUG
+ while (access ("/tmp/x11-block", F_OK) == 0) sleep (1);
+#endif
+
+ pool = [[NSAutoreleasePool alloc] init];
+ X11App = (X11Application *) [X11Application sharedApplication];
+ init_ports ();
+
+ app_prefs_domain_cfstr = (CFStringRef)[[NSBundle mainBundle] bundleIdentifier];
+
+ if (app_prefs_domain_cfstr == NULL) {
+ ErrorF("X11ApplicationMain: Unable to determine bundle identifier. Your installation of XQuartz may be broken.\n");
+ app_prefs_domain_cfstr = CFSTR(BUNDLE_ID_PREFIX".X11");
+ }
+
+ [NSApp read_defaults];
+ [NSBundle loadNibNamed:@"main" owner:NSApp];
+ [[NSNotificationCenter defaultCenter] addObserver:NSApp
+ selector:@selector (became_key:)
+ name:NSWindowDidBecomeKeyNotification object:nil];
+
+ /*
+ * The xpr Quartz mode is statically linked into this server.
+ * Initialize all the Quartz functions.
+ */
+ QuartzModeBundleInit();
+
+ /* Calculate the height of the menubar so we can avoid it. */
+ aquaMenuBarHeight = NSHeight([[NSScreen mainScreen] frame]) -
+ NSMaxY([[NSScreen mainScreen] visibleFrame]);
+
+#ifdef HAVE_LIBDISPATCH
+ eventTranslationQueue = dispatch_queue_create(BUNDLE_ID_PREFIX".X11.NSEventsToX11EventsQueue", NULL);
+ assert(eventTranslationQueue != NULL);
+#endif
+
+ /* Set the key layout seed before we start the server */
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
+ last_key_layout = TISCopyCurrentKeyboardLayoutInputSource();
+
+ if(!last_key_layout)
+ ErrorF("X11ApplicationMain: Unable to determine TISCopyCurrentKeyboardLayoutInputSource() at startup.\n");
+#else
+ KLGetCurrentKeyboardLayout(&last_key_layout);
+ if(!last_key_layout)
+ ErrorF("X11ApplicationMain: Unable to determine KLGetCurrentKeyboardLayout() at startup.\n");
+#endif
+
+ if (!QuartsResyncKeymap(FALSE)) {
+ ErrorF("X11ApplicationMain: Could not build a valid keymap.\n");
+ }
+
+ /* Tell the server thread that it can proceed */
+ QuartzInitServer(argc, argv, envp);
+
+ /* This must be done after QuartzInitServer because it can result in
+ * an mieqEnqueue() - <rdar://problem/6300249>
+ */
+ check_xinitrc();
+
+ create_thread(xpbproxy_x_thread, NULL);
+
+#if XQUARTZ_SPARKLE
+ [[X11App controller] setup_sparkle];
+ [[SUUpdater sharedUpdater] resetUpdateCycle];
+// [[SUUpdater sharedUpdater] checkForUpdates:X11App];
+#endif
+
+ [pool release];
+ [NSApp run];
+ /* not reached */
+}
+
+@implementation X11Application (Private)
+
+#ifdef NX_DEVICELCMDKEYMASK
+/* This is to workaround a bug in the VNC server where we sometimes see the L
+ * modifier and sometimes see no "side"
+ */
+static inline int ensure_flag(int flags, int device_independent, int device_dependents, int device_dependent_default) {
+ if( (flags & device_independent) &&
+ !(flags & device_dependents))
+ flags |= device_dependent_default;
+ return flags;
+}
+#endif
+
+#ifdef DEBUG_UNTRUSTED_POINTER_DELTA
+static const char *untrusted_str(NSEvent *e) {
+ switch([e type]) {
+ case NSScrollWheel:
+ return "NSScrollWheel";
+ case NSTabletPoint:
+ return "NSTabletPoint";
+ case NSOtherMouseDown:
+ return "NSOtherMouseDown";
+ case NSOtherMouseUp:
+ return "NSOtherMouseUp";
+ case NSLeftMouseDown:
+ return "NSLeftMouseDown";
+ case NSLeftMouseUp:
+ return "NSLeftMouseUp";
+ default:
+ switch([e subtype]) {
+ case NSTabletPointEventSubtype:
+ return "NSTabletPointEventSubtype";
+ case NSTabletProximityEventSubtype:
+ return "NSTabletProximityEventSubtype";
+ default:
+ return "Other";
+ }
+ }
+}
+#endif
+
+- (void) sendX11NSEvent:(NSEvent *)e {
+ NSPoint location = NSZeroPoint;
+ int ev_button, ev_type;
+ static float pressure = 0.0; // static so ProximityOut will have the value from the previous tablet event
+ static NSPoint tilt; // static so ProximityOut will have the value from the previous tablet event
+ static DeviceIntPtr darwinTabletCurrent = NULL;
+ static BOOL needsProximityIn = NO; // Do we do need to handle a pending ProximityIn once we have pressure/tilt?
+ DeviceIntPtr pDev;
+ int modifierFlags;
+ BOOL isMouseOrTabletEvent, isTabletEvent;
+
+#ifdef HAVE_LIBDISPATCH
+ static dispatch_once_t once_pred;
+ dispatch_once(&once_pred, ^{
+ tilt = NSZeroPoint;
+ darwinTabletCurrent = darwinTabletStylus;
+ });
+#else
+ if(!darwinTabletCurrent) {
+ tilt = NSZeroPoint;
+ darwinTabletCurrent = darwinTabletStylus;
+ }
+#endif
+
+ isMouseOrTabletEvent = [e type] == NSLeftMouseDown || [e type] == NSOtherMouseDown || [e type] == NSRightMouseDown ||
+ [e type] == NSLeftMouseUp || [e type] == NSOtherMouseUp || [e type] == NSRightMouseUp ||
+ [e type] == NSLeftMouseDragged || [e type] == NSOtherMouseDragged || [e type] == NSRightMouseDragged ||
+ [e type] == NSMouseMoved || [e type] == NSTabletPoint || [e type] == NSScrollWheel;
+
+ isTabletEvent = ([e type] == NSTabletPoint) ||
+ (isMouseOrTabletEvent && ([e subtype] == NSTabletPointEventSubtype || [e subtype] == NSTabletProximityEventSubtype));
+
+ if(isMouseOrTabletEvent) {
+ static NSPoint lastpt;
+ NSWindow *window = [e window];
+ NSRect screen = [[[NSScreen screens] objectAtIndex:0] frame];
+ BOOL hasUntrustedPointerDelta;
+
+ // NSEvents for tablets are not consistent wrt deltaXY between events, so we cannot rely on that
+ // Thus tablets will be subject to the warp-pointer bug worked around by the delta, but tablets
+ // are not normally used in cases where that bug would present itself, so this is a fair tradeoff
+ // <rdar://problem/7111003> deltaX and deltaY are incorrect for NSMouseMoved, NSTabletPointEventSubtype
+ // http://xquartz.macosforge.org/trac/ticket/288
+ hasUntrustedPointerDelta = isTabletEvent;
+
+ // The deltaXY for middle click events also appear erroneous after fast user switching
+ // <rdar://problem/7979468> deltaX and deltaY are incorrect for NSOtherMouseDown and NSOtherMouseUp after FUS
+ // http://xquartz.macosforge.org/trac/ticket/389
+ hasUntrustedPointerDelta = hasUntrustedPointerDelta || [e type] == NSOtherMouseDown || [e type] == NSOtherMouseUp;
+
+ // The deltaXY for scroll events correspond to the scroll delta, not the pointer delta
+ // <rdar://problem/7989690> deltaXY for wheel events are being sent as mouse movement
+ hasUntrustedPointerDelta = hasUntrustedPointerDelta || [e type] == NSScrollWheel;
+
+#ifdef DEBUG_UNTRUSTED_POINTER_DELTA
+ hasUntrustedPointerDelta = hasUntrustedPointerDelta || [e type] == NSLeftMouseDown || [e type] == NSLeftMouseUp;
+#endif
+
+ if (window != nil) {
+ NSRect frame = [window frame];
+ location = [e locationInWindow];
+ location.x += frame.origin.x;
+ location.y += frame.origin.y;
+ lastpt = location;
+ } else if(hasUntrustedPointerDelta) {
+#ifdef DEBUG_UNTRUSTED_POINTER_DELTA
+ ErrorF("--- Begin Event Debug ---\n");
+ ErrorF("Event type: %s\n", untrusted_str(e));
+ ErrorF("old lastpt: (%0.2f, %0.2f)\n", lastpt.x, lastpt.y);
+ ErrorF(" delta: (%0.2f, %0.2f)\n", [e deltaX], -[e deltaY]);
+ ErrorF(" location: (%0.2f, %0.2f)\n", lastpt.x + [e deltaX], lastpt.y - [e deltaY]);
+ ErrorF("workaround: (%0.2f, %0.2f)\n", [e locationInWindow].x, [e locationInWindow].y);
+ ErrorF("--- End Event Debug ---\n");
+
+ location.x = lastpt.x + [e deltaX];
+ location.y = lastpt.y - [e deltaY];
+ lastpt = [e locationInWindow];
+#else
+ location = [e locationInWindow];
+ lastpt = location;
+#endif
+ } else {
+ location.x = lastpt.x + [e deltaX];
+ location.y = lastpt.y - [e deltaY];
+ lastpt = [e locationInWindow];
+ }
+
+ /* Convert coordinate system */
+ location.y = (screen.origin.y + screen.size.height) - location.y;
+ }
+
+ modifierFlags = [e modifierFlags];
+
+#ifdef NX_DEVICELCMDKEYMASK
+ /* This is to workaround a bug in the VNC server where we sometimes see the L
+ * modifier and sometimes see no "side"
+ */
+ modifierFlags = ensure_flag(modifierFlags, NX_CONTROLMASK, NX_DEVICELCTLKEYMASK | NX_DEVICERCTLKEYMASK, NX_DEVICELCTLKEYMASK);
+ modifierFlags = ensure_flag(modifierFlags, NX_SHIFTMASK, NX_DEVICELSHIFTKEYMASK | NX_DEVICERSHIFTKEYMASK, NX_DEVICELSHIFTKEYMASK);
+ modifierFlags = ensure_flag(modifierFlags, NX_COMMANDMASK, NX_DEVICELCMDKEYMASK | NX_DEVICERCMDKEYMASK, NX_DEVICELCMDKEYMASK);
+ modifierFlags = ensure_flag(modifierFlags, NX_ALTERNATEMASK, NX_DEVICELALTKEYMASK | NX_DEVICERALTKEYMASK, NX_DEVICELALTKEYMASK);
+#endif
+
+ modifierFlags &= darwin_all_modifier_mask;
+
+ /* We don't receive modifier key events while out of focus, and 3button
+ * emulation mucks this up, so we need to check our modifier flag state
+ * on every event... ugg
+ */
+
+ if(darwin_all_modifier_flags != modifierFlags)
+ DarwinUpdateModKeys(modifierFlags);
+
+ switch ([e type]) {
+ case NSLeftMouseDown: ev_button=1; ev_type=ButtonPress; goto handle_mouse;
+ case NSOtherMouseDown: ev_button=2; ev_type=ButtonPress; goto handle_mouse;
+ case NSRightMouseDown: ev_button=3; ev_type=ButtonPress; goto handle_mouse;
+ case NSLeftMouseUp: ev_button=1; ev_type=ButtonRelease; goto handle_mouse;
+ case NSOtherMouseUp: ev_button=2; ev_type=ButtonRelease; goto handle_mouse;
+ case NSRightMouseUp: ev_button=3; ev_type=ButtonRelease; goto handle_mouse;
+ case NSLeftMouseDragged: ev_button=1; ev_type=MotionNotify; goto handle_mouse;
+ case NSOtherMouseDragged: ev_button=2; ev_type=MotionNotify; goto handle_mouse;
+ case NSRightMouseDragged: ev_button=3; ev_type=MotionNotify; goto handle_mouse;
+ case NSMouseMoved: ev_button=0; ev_type=MotionNotify; goto handle_mouse;
+ case NSTabletPoint: ev_button=0; ev_type=MotionNotify; goto handle_mouse;
+
+ handle_mouse:
+ pDev = darwinPointer;
+
+ /* NSTabletPoint can have no subtype */
+ if([e type] != NSTabletPoint &&
+ [e subtype] == NSTabletProximityEventSubtype) {
+ switch([e pointingDeviceType]) {
+ case NSEraserPointingDevice:
+ darwinTabletCurrent=darwinTabletEraser;
+ break;
+ case NSPenPointingDevice:
+ darwinTabletCurrent=darwinTabletStylus;
+ break;
+ case NSCursorPointingDevice:
+ case NSUnknownPointingDevice:
+ default:
+ darwinTabletCurrent=darwinTabletCursor;
+ break;
+ }
+
+ if([e isEnteringProximity])
+ needsProximityIn = YES;
+ else
+ DarwinSendProximityEvents(darwinTabletCurrent, ProximityOut,
+ location.x, location.y, pressure,
+ tilt.x, tilt.y);
+ return;
+ }
+
+ if ([e type] == NSTabletPoint || [e subtype] == NSTabletPointEventSubtype) {
+ pressure = [e pressure];
+ tilt = [e tilt];
+
+ pDev = darwinTabletCurrent;
+
+ if(needsProximityIn) {
+ DarwinSendProximityEvents(darwinTabletCurrent, ProximityIn,
+ location.x, location.y, pressure,
+ tilt.x, tilt.y);
+
+ needsProximityIn = NO;
+ }
+ }
+
+ if(!XQuartzServerVisible && noTestExtensions) {
+#if defined(XPLUGIN_VERSION) && XPLUGIN_VERSION > 0
+/* Older libXplugin (Tiger/"Stock" Leopard) aren't thread safe, so we can't call xp_find_window from the Appkit thread */
+ xp_window_id wid = 0;
+ xp_error err;
+
+ /* Sigh. Need to check that we're really over one of
+ * our windows. (We need to receive pointer events while
+ * not in the foreground, but we don't want to receive them
+ * when another window is over us or we might show a tooltip)
+ */
+
+ err = xp_find_window(location.x, location.y, 0, &wid);
+
+ if (err != XP_Success || (err == XP_Success && wid == 0))
+#endif
+ {
+ bgMouseLocation = location;
+ bgMouseLocationUpdated = TRUE;
+ return;
+ }
+ }
+
+ if(bgMouseLocationUpdated) {
+ if(!(ev_type == MotionNotify && ev_button == 0)) {
+ DarwinSendPointerEvents(pDev, MotionNotify, 0, location.x,
+ location.y, pressure, tilt.x, tilt.y);
+ }
+ bgMouseLocationUpdated = FALSE;
+ }
+
+ DarwinSendPointerEvents(pDev, ev_type, ev_button, location.x, location.y,
+ pressure, tilt.x, tilt.y);
+
+ break;
+
+ case NSTabletProximity:
+ switch([e pointingDeviceType]) {
+ case NSEraserPointingDevice:
+ darwinTabletCurrent=darwinTabletEraser;
+ break;
+ case NSPenPointingDevice:
+ darwinTabletCurrent=darwinTabletStylus;
+ break;
+ case NSCursorPointingDevice:
+ case NSUnknownPointingDevice:
+ default:
+ darwinTabletCurrent=darwinTabletCursor;
+ break;
+ }
+
+ if([e isEnteringProximity])
+ needsProximityIn = YES;
+ else
+ DarwinSendProximityEvents(darwinTabletCurrent, ProximityOut,
+ location.x, location.y, pressure,
+ tilt.x, tilt.y);
+ break;
+
+ case NSScrollWheel:
+ {
+ float deltaX = [e deltaX];
+ float deltaY = [e deltaY];
+#if !defined(XPLUGIN_VERSION) || XPLUGIN_VERSION == 0
+ /* If we're in the background, we need to send a MotionNotify event
+ * first, since we aren't getting them on background mouse motion
+ */
+ if(!XQuartzServerVisible && noTestExtensions) {
+ bgMouseLocationUpdated = FALSE;
+ DarwinSendPointerEvents(darwinPointer, MotionNotify, 0, location.x,
+ location.y, pressure, tilt.x, tilt.y);
+ }
+#endif
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
+ // TODO: Change 1117 to NSAppKitVersionNumber10_7 when it is defined
+ if(NSAppKitVersionNumber >= 1117 && XQuartzScrollInDeviceDirection && [e isDirectionInvertedFromDevice]) {
+ deltaX *= -1;
+ deltaY *= -1;
+ }
+#endif
+ DarwinSendScrollEvents(deltaX, deltaY, location.x, location.y,
+ pressure, tilt.x, tilt.y);
+ break;
+ }
+ case NSKeyDown: case NSKeyUp:
+ {
+ /* XKB clobbers our keymap at startup, so we need to force it on the first keypress.
+ * TODO: Make this less of a kludge.
+ */
+ static int force_resync_keymap = YES;
+ if(force_resync_keymap) {
+ DarwinSendDDXEvent(kXquartzReloadKeymap, 0);
+ force_resync_keymap = NO;
+ }
+ }
+
+ if(darwinSyncKeymap) {
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
+ TISInputSourceRef key_layout = TISCopyCurrentKeyboardLayoutInputSource();
+ TISInputSourceRef clear;
+ if (CFEqual(key_layout, last_key_layout)) {
+ CFRelease(key_layout);
+ } else {
+ /* Swap/free thread-safely */
+ clear = last_key_layout;
+ last_key_layout = key_layout;
+ CFRelease(clear);
+#else
+ KeyboardLayoutRef key_layout;
+ KLGetCurrentKeyboardLayout(&key_layout);
+ if(key_layout != last_key_layout) {
+ last_key_layout = key_layout;
+#endif
+ /* Update keyInfo */
+ if (!QuartsResyncKeymap(TRUE)) {
+ ErrorF("sendX11NSEvent: Could not build a valid keymap.\n");
+ }
+ }
+ }
+
+ /* Avoid stuck keys on context switch */
+ if(keyState[[e keyCode]] == [e type])
+ return;
+ keyState[[e keyCode]] = [e type];
+
+ DarwinSendKeyboardEvents(([e type] == NSKeyDown) ? KeyPress : KeyRelease, [e keyCode]);
+ break;
+
+ default: break; /* for gcc */
+ }
+}
+@end
diff --git a/xorg-server/hw/xquartz/applewm.c b/xorg-server/hw/xquartz/applewm.c
index 3b8ca3094..2f26e61d9 100644
--- a/xorg-server/hw/xquartz/applewm.c
+++ b/xorg-server/hw/xquartz/applewm.c
@@ -1,736 +1,736 @@
-/**************************************************************************
-
-Copyright (c) 2002-2007 Apple 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.
-
-**************************************************************************/
-
-#include "sanitizedCarbon.h"
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "quartzCommon.h"
-
-#include "misc.h"
-#include "dixstruct.h"
-#include "globals.h"
-#include "extnsionst.h"
-#include "colormapst.h"
-#include "cursorstr.h"
-#include "scrnintstr.h"
-#include "windowstr.h"
-#include "servermd.h"
-#include "swaprep.h"
-#include "propertyst.h"
-#include <X11/Xatom.h>
-#include "darwin.h"
-#define _APPLEWM_SERVER_
-#include <X11/extensions/applewmproto.h>
-#include "applewmExt.h"
-#include "X11Application.h"
-#include "protocol-versions.h"
-
-#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; \
-}
-
-DEFINE_ATOM_HELPER(xa_native_screen_origin, "_NATIVE_SCREEN_ORIGIN")
-DEFINE_ATOM_HELPER (xa_apple_no_order_in, "_APPLE_NO_ORDER_IN")
-
-static AppleWMProcsPtr appleWMProcs;
-
-static int WMErrorBase;
-
-
-static unsigned char WMReqCode = 0;
-static int WMEventBase = 0;
-
-static RESTYPE ClientType, EventType; /* 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(xAppleWMNotifyEvent *from, xAppleWMNotifyEvent *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;
-}
-
-/* Updates the _NATIVE_SCREEN_ORIGIN property on the given root window. */
-void
-AppleWMSetScreenOrigin(
- WindowPtr pWin
-)
-{
- int32_t data[2];
-
- data[0] = pWin->drawable.pScreen->x + darwinMainScreenX;
- data[1] = pWin->drawable.pScreen->y + darwinMainScreenY;
-
- dixChangeWindowProperty(serverClient, pWin, xa_native_screen_origin(),
- XA_INTEGER, 32, PropModeReplace, 2, data, TRUE);
-}
-
-/* Window managers can set the _APPLE_NO_ORDER_IN property on windows
- that are being genie-restored from the Dock. We want them to
- be mapped but remain ordered-out until the animation
- completes (when the Dock will order them in). */
-Bool
-AppleWMDoReorderWindow(
- WindowPtr pWin
-)
-{
- Atom atom;
- PropertyPtr prop;
- int rc;
-
- atom = xa_apple_no_order_in();
- rc = dixLookupProperty(&prop, pWin, atom, serverClient, DixReadAccess);
-
- if(Success == rc && prop->type == atom)
- return 0;
-
- return 1;
-}
-
-
-static int
-ProcAppleWMQueryVersion(
- register ClientPtr client
-)
-{
- xAppleWMQueryVersionReply rep;
- register int n;
-
- REQUEST_SIZE_MATCH(xAppleWMQueryVersionReq);
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.majorVersion = SERVER_APPLEWM_MAJOR_VERSION;
- rep.minorVersion = SERVER_APPLEWM_MINOR_VERSION;
- rep.patchVersion = SERVER_APPLEWM_PATCH_VERSION;
- if (client->swapped) {
- swaps(&rep.sequenceNumber, n);
- swapl(&rep.length, n);
- }
- WriteToClient(client, sizeof(xAppleWMQueryVersionReply), (char *)&rep);
- return Success;
-}
-
-
-/* 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;
- int i;
-
- pEvent = (WMEventPtr) data;
- i = dixLookupResourceByType((pointer *)&pHead, eventResource, EventType, serverClient, DixReadAccess | DixWriteAccess | DixDestroyAccess);
- if (i == Success && 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);
- }
- free((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);
- free((pointer) pCur);
- }
- free((pointer) pHead);
- eventMask = 0;
- return 1;
-}
-
-static int
-ProcAppleWMSelectInput (register ClientPtr client)
-{
- REQUEST(xAppleWMSelectInputReq);
- WMEventPtr pEvent, pNewEvent, *pHead;
- XID clientResource;
- int i;
-
- REQUEST_SIZE_MATCH (xAppleWMSelectInputReq);
- i = dixLookupResourceByType((pointer *)&pHead, eventResource, EventType, client, DixWriteAccess);
- if (stuff->mask != 0) {
- if (i == Success && 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) malloc(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 (i != Success || !pHead)
- {
- pHead = (WMEventPtr *) malloc(sizeof (WMEventPtr));
- if (!pHead ||
- !AddResource (eventResource, EventType, (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 (i == Success && 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;
- free(pEvent);
- updateEventMask (pHead);
- }
- }
- } else {
- client->errorValue = stuff->mask;
- return BadValue;
- }
- return Success;
-}
-
-/*
- * deliver the event
- */
-
-void
-AppleWMSendEvent (int type, unsigned int mask, int which, int arg) {
- WMEventPtr *pHead, pEvent;
- xAppleWMNotifyEvent se;
- int i;
-
- i = dixLookupResourceByType((pointer *)&pHead, eventResource, EventType, serverClient, DixReadAccess);
- if (i != Success || !pHead)
- return;
- for (pEvent = *pHead; pEvent; pEvent = pEvent->next) {
- if ((pEvent->mask & mask) == 0)
- continue;
- se.type = type + WMEventBase;
- se.kind = which;
- se.arg = arg;
- se.time = currentTime.milliseconds;
- WriteEventsToClient (pEvent->client, 1, (xEvent *) &se);
- }
-}
-
-/* Safe to call from any thread. */
-unsigned int
-AppleWMSelectedEvents (void)
-{
- return eventMask;
-}
-
-
-/* general utility functions */
-
-static int
-ProcAppleWMDisableUpdate(
- register ClientPtr client
-)
-{
- REQUEST_SIZE_MATCH(xAppleWMDisableUpdateReq);
-
- appleWMProcs->DisableUpdate();
-
- return Success;
-}
-
-static int
-ProcAppleWMReenableUpdate(
- register ClientPtr client
-)
-{
- REQUEST_SIZE_MATCH(xAppleWMReenableUpdateReq);
-
- appleWMProcs->EnableUpdate();
-
- return Success;
-}
-
-
-/* window functions */
-
-static int
-ProcAppleWMSetWindowMenu(
- register ClientPtr client
-)
-{
- const char *bytes, **items;
- char *shortcuts;
- int max_len, nitems, i, j;
- REQUEST(xAppleWMSetWindowMenuReq);
-
- REQUEST_AT_LEAST_SIZE(xAppleWMSetWindowMenuReq);
-
- nitems = stuff->nitems;
- items = malloc(sizeof (char *) * nitems);
- shortcuts = malloc(sizeof (char) * nitems);
-
- max_len = (stuff->length << 2) - sizeof(xAppleWMSetWindowMenuReq);
- bytes = (char *) &stuff[1];
-
- for (i = j = 0; i < max_len && j < nitems;)
- {
- shortcuts[j] = bytes[i++];
- items[j++] = bytes + i;
-
- while (i < max_len)
- {
- if (bytes[i++] == 0)
- break;
- }
- }
- X11ApplicationSetWindowMenu (nitems, items, shortcuts);
- free(items);
- free(shortcuts);
-
- return Success;
-}
-
-static int
-ProcAppleWMSetWindowMenuCheck(
- register ClientPtr client
-)
-{
- REQUEST(xAppleWMSetWindowMenuCheckReq);
-
- REQUEST_SIZE_MATCH(xAppleWMSetWindowMenuCheckReq);
- X11ApplicationSetWindowMenuCheck(stuff->index);
- return Success;
-}
-
-static int
-ProcAppleWMSetFrontProcess(
- register ClientPtr client
-)
-{
- REQUEST_SIZE_MATCH(xAppleWMSetFrontProcessReq);
-
- X11ApplicationSetFrontProcess();
- return Success;
-}
-
-static int
-ProcAppleWMSetWindowLevel(register ClientPtr client)
-{
- REQUEST(xAppleWMSetWindowLevelReq);
- WindowPtr pWin;
- int err;
-
- REQUEST_SIZE_MATCH(xAppleWMSetWindowLevelReq);
-
- if (Success != dixLookupWindow(&pWin, stuff->window, client,
- DixReadAccess))
- return BadValue;
-
- if (stuff->level >= AppleWMNumWindowLevels) {
- return BadValue;
- }
-
- err = appleWMProcs->SetWindowLevel(pWin, stuff->level);
- if (err != Success) {
- return err;
- }
-
- return Success;
-}
-
-static int
-ProcAppleWMSendPSN(register ClientPtr client)
-{
- REQUEST(xAppleWMSendPSNReq);
- int err;
-
- REQUEST_SIZE_MATCH(xAppleWMSendPSNReq);
-
- if(!appleWMProcs->SendPSN)
- return BadRequest;
-
- err = appleWMProcs->SendPSN(stuff->psn_hi, stuff->psn_lo);
- if (err != Success) {
- return err;
- }
-
- return Success;
-}
-
-static int
-ProcAppleWMAttachTransient(register ClientPtr client)
-{
- WindowPtr pWinChild, pWinParent;
- REQUEST(xAppleWMAttachTransientReq);
- int err;
-
- REQUEST_SIZE_MATCH(xAppleWMAttachTransientReq);
-
- if(!appleWMProcs->AttachTransient)
- return BadRequest;
-
- if (Success != dixLookupWindow(&pWinChild, stuff->child, client, DixReadAccess))
- return BadValue;
-
- if(stuff->parent) {
- if(Success != dixLookupWindow(&pWinParent, stuff->parent, client, DixReadAccess))
- return BadValue;
- } else {
- pWinParent = NULL;
- }
-
- err = appleWMProcs->AttachTransient(pWinChild, pWinParent);
- if (err != Success) {
- return err;
- }
-
- return Success;
-}
-
-static int
-ProcAppleWMSetCanQuit(
- register ClientPtr client
-)
-{
- REQUEST(xAppleWMSetCanQuitReq);
-
- REQUEST_SIZE_MATCH(xAppleWMSetCanQuitReq);
-
- X11ApplicationSetCanQuit(stuff->state);
- return Success;
-}
-
-
-/* frame functions */
-
-static int
-ProcAppleWMFrameGetRect(
- register ClientPtr client
-)
-{
- xAppleWMFrameGetRectReply rep;
- BoxRec ir, or, rr;
- REQUEST(xAppleWMFrameGetRectReq);
-
- REQUEST_SIZE_MATCH(xAppleWMFrameGetRectReq);
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
-
- ir = make_box (stuff->ix, stuff->iy, stuff->iw, stuff->ih);
- or = make_box (stuff->ox, stuff->oy, stuff->ow, stuff->oh);
-
- if (appleWMProcs->FrameGetRect(stuff->frame_rect,
- stuff->frame_class,
- &or, &ir, &rr) != Success)
- {
- return BadValue;
- }
-
- rep.x = rr.x1;
- rep.y = rr.y1;
- rep.w = rr.x2 - rr.x1;
- rep.h = rr.y2 - rr.y1;
-
- WriteToClient(client, sizeof(xAppleWMFrameGetRectReply), (char *)&rep);
- return Success;
-}
-
-static int
-ProcAppleWMFrameHitTest(
- register ClientPtr client
-)
-{
- xAppleWMFrameHitTestReply rep;
- BoxRec ir, or;
- int ret;
- REQUEST(xAppleWMFrameHitTestReq);
-
- REQUEST_SIZE_MATCH(xAppleWMFrameHitTestReq);
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
-
- ir = make_box (stuff->ix, stuff->iy, stuff->iw, stuff->ih);
- or = make_box (stuff->ox, stuff->oy, stuff->ow, stuff->oh);
-
- if (appleWMProcs->FrameHitTest(stuff->frame_class, stuff->px,
- stuff->py, &or, &ir, &ret) != Success)
- {
- return BadValue;
- }
-
- rep.ret = ret;
-
- WriteToClient(client, sizeof(xAppleWMFrameHitTestReply), (char *)&rep);
- return Success;
-}
-
-static int
-ProcAppleWMFrameDraw(
- register ClientPtr client
-)
-{
- BoxRec ir, or;
- unsigned int title_length, title_max;
- unsigned char *title_bytes;
- REQUEST(xAppleWMFrameDrawReq);
- WindowPtr pWin;
-
- REQUEST_AT_LEAST_SIZE(xAppleWMFrameDrawReq);
-
- if (Success != dixLookupWindow(&pWin, stuff->window, client,
- DixReadAccess))
- return BadValue;
-
- ir = make_box (stuff->ix, stuff->iy, stuff->iw, stuff->ih);
- or = make_box (stuff->ox, stuff->oy, stuff->ow, stuff->oh);
-
- title_length = stuff->title_length;
- title_max = (stuff->length << 2) - sizeof(xAppleWMFrameDrawReq);
-
- if (title_max < title_length)
- return BadValue;
-
- title_bytes = (unsigned char *) &stuff[1];
-
- errno = appleWMProcs->FrameDraw(pWin, stuff->frame_class,
- stuff->frame_attr, &or, &ir,
- title_length, title_bytes);
- if (errno != Success) {
- return errno;
- }
-
- return Success;
-}
-
-
-/* dispatch */
-
-static int
-ProcAppleWMDispatch (
- register ClientPtr client
-)
-{
- REQUEST(xReq);
-
- switch (stuff->data)
- {
- case X_AppleWMQueryVersion:
- return ProcAppleWMQueryVersion(client);
- }
-
- if (!LocalClient(client))
- return WMErrorBase + AppleWMClientNotLocal;
-
- switch (stuff->data)
- {
- case X_AppleWMSelectInput:
- return ProcAppleWMSelectInput(client);
- case X_AppleWMDisableUpdate:
- return ProcAppleWMDisableUpdate(client);
- case X_AppleWMReenableUpdate:
- return ProcAppleWMReenableUpdate(client);
- case X_AppleWMSetWindowMenu:
- return ProcAppleWMSetWindowMenu(client);
- case X_AppleWMSetWindowMenuCheck:
- return ProcAppleWMSetWindowMenuCheck(client);
- case X_AppleWMSetFrontProcess:
- return ProcAppleWMSetFrontProcess(client);
- case X_AppleWMSetWindowLevel:
- return ProcAppleWMSetWindowLevel(client);
- case X_AppleWMSetCanQuit:
- return ProcAppleWMSetCanQuit(client);
- case X_AppleWMFrameGetRect:
- return ProcAppleWMFrameGetRect(client);
- case X_AppleWMFrameHitTest:
- return ProcAppleWMFrameHitTest(client);
- case X_AppleWMFrameDraw:
- return ProcAppleWMFrameDraw(client);
- case X_AppleWMSendPSN:
- return ProcAppleWMSendPSN(client);
- case X_AppleWMAttachTransient:
- return ProcAppleWMAttachTransient(client);
- default:
- return BadRequest;
- }
-}
-
-static void
-SNotifyEvent(xAppleWMNotifyEvent *from, xAppleWMNotifyEvent *to) {
- to->type = from->type;
- to->kind = from->kind;
- cpswaps (from->sequenceNumber, to->sequenceNumber);
- cpswapl (from->time, to->time);
- cpswapl (from->arg, to->arg);
-}
-
-static int
-SProcAppleWMQueryVersion(
- register ClientPtr client
-)
-{
- register int n;
- REQUEST(xAppleWMQueryVersionReq);
- swaps(&stuff->length, n);
- return ProcAppleWMQueryVersion(client);
-}
-
-static int
-SProcAppleWMDispatch (
- register ClientPtr client
-)
-{
- REQUEST(xReq);
-
- /* It is bound to be non-local when there is byte swapping */
- if (!LocalClient(client))
- return WMErrorBase + AppleWMClientNotLocal;
-
- /* only local clients are allowed WM access */
- switch (stuff->data)
- {
- case X_AppleWMQueryVersion:
- return SProcAppleWMQueryVersion(client);
- default:
- return BadRequest;
- }
-}
-
-void
-AppleWMExtensionInit(
- AppleWMProcsPtr procsPtr)
-{
- ExtensionEntry* extEntry;
-
- ClientType = CreateNewResourceType(WMFreeClient, "WMClient");
- EventType = CreateNewResourceType(WMFreeEvents, "WMEvent");
- eventResource = FakeClientID(0);
-
- if (ClientType && EventType &&
- (extEntry = AddExtension(APPLEWMNAME,
- AppleWMNumberEvents,
- AppleWMNumberErrors,
- ProcAppleWMDispatch,
- SProcAppleWMDispatch,
- NULL,
- StandardMinorOpcode)))
- {
- WMReqCode = (unsigned char)extEntry->base;
- WMErrorBase = extEntry->errorBase;
- WMEventBase = extEntry->eventBase;
- EventSwapVector[WMEventBase] = (EventSwapPtr) SNotifyEvent;
- appleWMProcs = procsPtr;
- }
-}
+/**************************************************************************
+
+Copyright (c) 2002-2007 Apple 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.
+
+**************************************************************************/
+
+#include "sanitizedCarbon.h"
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "quartzCommon.h"
+
+#include "misc.h"
+#include "dixstruct.h"
+#include "globals.h"
+#include "extnsionst.h"
+#include "colormapst.h"
+#include "cursorstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "servermd.h"
+#include "swaprep.h"
+#include "propertyst.h"
+#include <X11/Xatom.h>
+#include "darwin.h"
+#define _APPLEWM_SERVER_
+#include <X11/extensions/applewmproto.h>
+#include "applewmExt.h"
+#include "X11Application.h"
+#include "protocol-versions.h"
+
+#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; \
+}
+
+DEFINE_ATOM_HELPER(xa_native_screen_origin, "_NATIVE_SCREEN_ORIGIN")
+DEFINE_ATOM_HELPER (xa_apple_no_order_in, "_APPLE_NO_ORDER_IN")
+
+static AppleWMProcsPtr appleWMProcs;
+
+static int WMErrorBase;
+
+
+static unsigned char WMReqCode = 0;
+static int WMEventBase = 0;
+
+static RESTYPE ClientType, EventType; /* 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(xAppleWMNotifyEvent *from, xAppleWMNotifyEvent *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;
+}
+
+/* Updates the _NATIVE_SCREEN_ORIGIN property on the given root window. */
+void
+AppleWMSetScreenOrigin(
+ WindowPtr pWin
+)
+{
+ int32_t data[2];
+
+ data[0] = pWin->drawable.pScreen->x + darwinMainScreenX;
+ data[1] = pWin->drawable.pScreen->y + darwinMainScreenY;
+
+ dixChangeWindowProperty(serverClient, pWin, xa_native_screen_origin(),
+ XA_INTEGER, 32, PropModeReplace, 2, data, TRUE);
+}
+
+/* Window managers can set the _APPLE_NO_ORDER_IN property on windows
+ that are being genie-restored from the Dock. We want them to
+ be mapped but remain ordered-out until the animation
+ completes (when the Dock will order them in). */
+Bool
+AppleWMDoReorderWindow(
+ WindowPtr pWin
+)
+{
+ Atom atom;
+ PropertyPtr prop;
+ int rc;
+
+ atom = xa_apple_no_order_in();
+ rc = dixLookupProperty(&prop, pWin, atom, serverClient, DixReadAccess);
+
+ if(Success == rc && prop->type == atom)
+ return 0;
+
+ return 1;
+}
+
+
+static int
+ProcAppleWMQueryVersion(
+ register ClientPtr client
+)
+{
+ xAppleWMQueryVersionReply rep;
+ register int n;
+
+ REQUEST_SIZE_MATCH(xAppleWMQueryVersionReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.majorVersion = SERVER_APPLEWM_MAJOR_VERSION;
+ rep.minorVersion = SERVER_APPLEWM_MINOR_VERSION;
+ rep.patchVersion = SERVER_APPLEWM_PATCH_VERSION;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ }
+ WriteToClient(client, sizeof(xAppleWMQueryVersionReply), (char *)&rep);
+ return Success;
+}
+
+
+/* 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;
+ int i;
+
+ pEvent = (WMEventPtr) data;
+ i = dixLookupResourceByType((pointer *)&pHead, eventResource, EventType, serverClient, DixReadAccess | DixWriteAccess | DixDestroyAccess);
+ if (i == Success && 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);
+ }
+ free((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);
+ free((pointer) pCur);
+ }
+ free((pointer) pHead);
+ eventMask = 0;
+ return 1;
+}
+
+static int
+ProcAppleWMSelectInput (register ClientPtr client)
+{
+ REQUEST(xAppleWMSelectInputReq);
+ WMEventPtr pEvent, pNewEvent, *pHead;
+ XID clientResource;
+ int i;
+
+ REQUEST_SIZE_MATCH (xAppleWMSelectInputReq);
+ i = dixLookupResourceByType((pointer *)&pHead, eventResource, EventType, client, DixWriteAccess);
+ if (stuff->mask != 0) {
+ if (i == Success && 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) malloc(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 (i != Success || !pHead)
+ {
+ pHead = (WMEventPtr *) malloc(sizeof (WMEventPtr));
+ if (!pHead ||
+ !AddResource (eventResource, EventType, (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 (i == Success && 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;
+ free(pEvent);
+ updateEventMask (pHead);
+ }
+ }
+ } else {
+ client->errorValue = stuff->mask;
+ return BadValue;
+ }
+ return Success;
+}
+
+/*
+ * deliver the event
+ */
+
+void
+AppleWMSendEvent (int type, unsigned int mask, int which, int arg) {
+ WMEventPtr *pHead, pEvent;
+ xAppleWMNotifyEvent se;
+ int i;
+
+ i = dixLookupResourceByType((pointer *)&pHead, eventResource, EventType, serverClient, DixReadAccess);
+ if (i != Success || !pHead)
+ return;
+ for (pEvent = *pHead; pEvent; pEvent = pEvent->next) {
+ if ((pEvent->mask & mask) == 0)
+ continue;
+ se.type = type + WMEventBase;
+ se.kind = which;
+ se.arg = arg;
+ se.time = currentTime.milliseconds;
+ WriteEventsToClient (pEvent->client, 1, (xEvent *) &se);
+ }
+}
+
+/* Safe to call from any thread. */
+unsigned int
+AppleWMSelectedEvents (void)
+{
+ return eventMask;
+}
+
+
+/* general utility functions */
+
+static int
+ProcAppleWMDisableUpdate(
+ register ClientPtr client
+)
+{
+ REQUEST_SIZE_MATCH(xAppleWMDisableUpdateReq);
+
+ appleWMProcs->DisableUpdate();
+
+ return Success;
+}
+
+static int
+ProcAppleWMReenableUpdate(
+ register ClientPtr client
+)
+{
+ REQUEST_SIZE_MATCH(xAppleWMReenableUpdateReq);
+
+ appleWMProcs->EnableUpdate();
+
+ return Success;
+}
+
+
+/* window functions */
+
+static int
+ProcAppleWMSetWindowMenu(
+ register ClientPtr client
+)
+{
+ const char *bytes, **items;
+ char *shortcuts;
+ int max_len, nitems, i, j;
+ REQUEST(xAppleWMSetWindowMenuReq);
+
+ REQUEST_AT_LEAST_SIZE(xAppleWMSetWindowMenuReq);
+
+ nitems = stuff->nitems;
+ items = malloc(sizeof (char *) * nitems);
+ shortcuts = malloc(sizeof (char) * nitems);
+
+ max_len = (stuff->length << 2) - sizeof(xAppleWMSetWindowMenuReq);
+ bytes = (char *) &stuff[1];
+
+ for (i = j = 0; i < max_len && j < nitems;)
+ {
+ shortcuts[j] = bytes[i++];
+ items[j++] = bytes + i;
+
+ while (i < max_len)
+ {
+ if (bytes[i++] == 0)
+ break;
+ }
+ }
+ X11ApplicationSetWindowMenu (nitems, items, shortcuts);
+ free(items);
+ free(shortcuts);
+
+ return Success;
+}
+
+static int
+ProcAppleWMSetWindowMenuCheck(
+ register ClientPtr client
+)
+{
+ REQUEST(xAppleWMSetWindowMenuCheckReq);
+
+ REQUEST_SIZE_MATCH(xAppleWMSetWindowMenuCheckReq);
+ X11ApplicationSetWindowMenuCheck(stuff->index);
+ return Success;
+}
+
+static int
+ProcAppleWMSetFrontProcess(
+ register ClientPtr client
+)
+{
+ REQUEST_SIZE_MATCH(xAppleWMSetFrontProcessReq);
+
+ X11ApplicationSetFrontProcess();
+ return Success;
+}
+
+static int
+ProcAppleWMSetWindowLevel(register ClientPtr client)
+{
+ REQUEST(xAppleWMSetWindowLevelReq);
+ WindowPtr pWin;
+ int err;
+
+ REQUEST_SIZE_MATCH(xAppleWMSetWindowLevelReq);
+
+ if (Success != dixLookupWindow(&pWin, stuff->window, client,
+ DixReadAccess))
+ return BadValue;
+
+ if (stuff->level >= AppleWMNumWindowLevels) {
+ return BadValue;
+ }
+
+ err = appleWMProcs->SetWindowLevel(pWin, stuff->level);
+ if (err != Success) {
+ return err;
+ }
+
+ return Success;
+}
+
+static int
+ProcAppleWMSendPSN(register ClientPtr client)
+{
+ REQUEST(xAppleWMSendPSNReq);
+ int err;
+
+ REQUEST_SIZE_MATCH(xAppleWMSendPSNReq);
+
+ if(!appleWMProcs->SendPSN)
+ return BadRequest;
+
+ err = appleWMProcs->SendPSN(stuff->psn_hi, stuff->psn_lo);
+ if (err != Success) {
+ return err;
+ }
+
+ return Success;
+}
+
+static int
+ProcAppleWMAttachTransient(register ClientPtr client)
+{
+ WindowPtr pWinChild, pWinParent;
+ REQUEST(xAppleWMAttachTransientReq);
+ int err;
+
+ REQUEST_SIZE_MATCH(xAppleWMAttachTransientReq);
+
+ if(!appleWMProcs->AttachTransient)
+ return BadRequest;
+
+ if (Success != dixLookupWindow(&pWinChild, stuff->child, client, DixReadAccess))
+ return BadValue;
+
+ if(stuff->parent) {
+ if(Success != dixLookupWindow(&pWinParent, stuff->parent, client, DixReadAccess))
+ return BadValue;
+ } else {
+ pWinParent = NULL;
+ }
+
+ err = appleWMProcs->AttachTransient(pWinChild, pWinParent);
+ if (err != Success) {
+ return err;
+ }
+
+ return Success;
+}
+
+static int
+ProcAppleWMSetCanQuit(
+ register ClientPtr client
+)
+{
+ REQUEST(xAppleWMSetCanQuitReq);
+
+ REQUEST_SIZE_MATCH(xAppleWMSetCanQuitReq);
+
+ X11ApplicationSetCanQuit(stuff->state);
+ return Success;
+}
+
+
+/* frame functions */
+
+static int
+ProcAppleWMFrameGetRect(
+ register ClientPtr client
+)
+{
+ xAppleWMFrameGetRectReply rep;
+ BoxRec ir, or, rr;
+ REQUEST(xAppleWMFrameGetRectReq);
+
+ REQUEST_SIZE_MATCH(xAppleWMFrameGetRectReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ ir = make_box (stuff->ix, stuff->iy, stuff->iw, stuff->ih);
+ or = make_box (stuff->ox, stuff->oy, stuff->ow, stuff->oh);
+
+ if (appleWMProcs->FrameGetRect(stuff->frame_rect,
+ stuff->frame_class,
+ &or, &ir, &rr) != Success)
+ {
+ return BadValue;
+ }
+
+ rep.x = rr.x1;
+ rep.y = rr.y1;
+ rep.w = rr.x2 - rr.x1;
+ rep.h = rr.y2 - rr.y1;
+
+ WriteToClient(client, sizeof(xAppleWMFrameGetRectReply), (char *)&rep);
+ return Success;
+}
+
+static int
+ProcAppleWMFrameHitTest(
+ register ClientPtr client
+)
+{
+ xAppleWMFrameHitTestReply rep;
+ BoxRec ir, or;
+ int ret;
+ REQUEST(xAppleWMFrameHitTestReq);
+
+ REQUEST_SIZE_MATCH(xAppleWMFrameHitTestReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ ir = make_box (stuff->ix, stuff->iy, stuff->iw, stuff->ih);
+ or = make_box (stuff->ox, stuff->oy, stuff->ow, stuff->oh);
+
+ if (appleWMProcs->FrameHitTest(stuff->frame_class, stuff->px,
+ stuff->py, &or, &ir, &ret) != Success)
+ {
+ return BadValue;
+ }
+
+ rep.ret = ret;
+
+ WriteToClient(client, sizeof(xAppleWMFrameHitTestReply), (char *)&rep);
+ return Success;
+}
+
+static int
+ProcAppleWMFrameDraw(
+ register ClientPtr client
+)
+{
+ BoxRec ir, or;
+ unsigned int title_length, title_max;
+ unsigned char *title_bytes;
+ REQUEST(xAppleWMFrameDrawReq);
+ WindowPtr pWin;
+
+ REQUEST_AT_LEAST_SIZE(xAppleWMFrameDrawReq);
+
+ if (Success != dixLookupWindow(&pWin, stuff->window, client,
+ DixReadAccess))
+ return BadValue;
+
+ ir = make_box (stuff->ix, stuff->iy, stuff->iw, stuff->ih);
+ or = make_box (stuff->ox, stuff->oy, stuff->ow, stuff->oh);
+
+ title_length = stuff->title_length;
+ title_max = (stuff->length << 2) - sizeof(xAppleWMFrameDrawReq);
+
+ if (title_max < title_length)
+ return BadValue;
+
+ title_bytes = (unsigned char *) &stuff[1];
+
+ errno = appleWMProcs->FrameDraw(pWin, stuff->frame_class,
+ stuff->frame_attr, &or, &ir,
+ title_length, title_bytes);
+ if (errno != Success) {
+ return errno;
+ }
+
+ return Success;
+}
+
+
+/* dispatch */
+
+static int
+ProcAppleWMDispatch (
+ register ClientPtr client
+)
+{
+ REQUEST(xReq);
+
+ switch (stuff->data)
+ {
+ case X_AppleWMQueryVersion:
+ return ProcAppleWMQueryVersion(client);
+ }
+
+ if (!LocalClient(client))
+ return WMErrorBase + AppleWMClientNotLocal;
+
+ switch (stuff->data)
+ {
+ case X_AppleWMSelectInput:
+ return ProcAppleWMSelectInput(client);
+ case X_AppleWMDisableUpdate:
+ return ProcAppleWMDisableUpdate(client);
+ case X_AppleWMReenableUpdate:
+ return ProcAppleWMReenableUpdate(client);
+ case X_AppleWMSetWindowMenu:
+ return ProcAppleWMSetWindowMenu(client);
+ case X_AppleWMSetWindowMenuCheck:
+ return ProcAppleWMSetWindowMenuCheck(client);
+ case X_AppleWMSetFrontProcess:
+ return ProcAppleWMSetFrontProcess(client);
+ case X_AppleWMSetWindowLevel:
+ return ProcAppleWMSetWindowLevel(client);
+ case X_AppleWMSetCanQuit:
+ return ProcAppleWMSetCanQuit(client);
+ case X_AppleWMFrameGetRect:
+ return ProcAppleWMFrameGetRect(client);
+ case X_AppleWMFrameHitTest:
+ return ProcAppleWMFrameHitTest(client);
+ case X_AppleWMFrameDraw:
+ return ProcAppleWMFrameDraw(client);
+ case X_AppleWMSendPSN:
+ return ProcAppleWMSendPSN(client);
+ case X_AppleWMAttachTransient:
+ return ProcAppleWMAttachTransient(client);
+ default:
+ return BadRequest;
+ }
+}
+
+static void
+SNotifyEvent(xAppleWMNotifyEvent *from, xAppleWMNotifyEvent *to) {
+ to->type = from->type;
+ to->kind = from->kind;
+ cpswaps (from->sequenceNumber, to->sequenceNumber);
+ cpswapl (from->time, to->time);
+ cpswapl (from->arg, to->arg);
+}
+
+static int
+SProcAppleWMQueryVersion(
+ register ClientPtr client
+)
+{
+ register int n;
+ REQUEST(xAppleWMQueryVersionReq);
+ swaps(&stuff->length, n);
+ return ProcAppleWMQueryVersion(client);
+}
+
+static int
+SProcAppleWMDispatch (
+ register ClientPtr client
+)
+{
+ REQUEST(xReq);
+
+ /* It is bound to be non-local when there is byte swapping */
+ if (!LocalClient(client))
+ return WMErrorBase + AppleWMClientNotLocal;
+
+ /* only local clients are allowed WM access */
+ switch (stuff->data)
+ {
+ case X_AppleWMQueryVersion:
+ return SProcAppleWMQueryVersion(client);
+ default:
+ return BadRequest;
+ }
+}
+
+void
+AppleWMExtensionInit(
+ AppleWMProcsPtr procsPtr)
+{
+ ExtensionEntry* extEntry;
+
+ ClientType = CreateNewResourceType(WMFreeClient, "WMClient");
+ EventType = CreateNewResourceType(WMFreeEvents, "WMEvent");
+ eventResource = FakeClientID(0);
+
+ if (ClientType && EventType &&
+ (extEntry = AddExtension(APPLEWMNAME,
+ AppleWMNumberEvents,
+ AppleWMNumberErrors,
+ ProcAppleWMDispatch,
+ SProcAppleWMDispatch,
+ NULL,
+ StandardMinorOpcode)))
+ {
+ WMReqCode = (unsigned char)extEntry->base;
+ WMErrorBase = extEntry->errorBase;
+ WMEventBase = extEntry->eventBase;
+ EventSwapVector[WMEventBase] = (EventSwapPtr) SNotifyEvent;
+ appleWMProcs = procsPtr;
+ }
+}
diff --git a/xorg-server/hw/xquartz/applewmExt.h b/xorg-server/hw/xquartz/applewmExt.h
index 39a5a7a9a..c46a7bde4 100644
--- a/xorg-server/hw/xquartz/applewmExt.h
+++ b/xorg-server/hw/xquartz/applewmExt.h
@@ -1,95 +1,95 @@
-/*
- * External interface for the server's AppleWM support
- */
-/**************************************************************************
-
-Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved.
-Copyright (c) 2003-2004 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.
-
-**************************************************************************/
-
-#ifndef _APPLEWMEXT_H_
-#define _APPLEWMEXT_H_
-
-#include "window.h"
-#include <Xplugin.h>
-
-#if XPLUGIN_VERSION < 4
-typedef int xp_frame_attr;
-typedef int xp_frame_class;
-typedef int xp_frame_rect;
-#endif
-
-typedef int (*DisableUpdateProc)(void);
-typedef int (*EnableUpdateProc)(void);
-typedef int (*SetWindowLevelProc)(WindowPtr pWin, int level);
-typedef int (*FrameGetRectProc)(xp_frame_rect type, xp_frame_class class, const BoxRec *outer,
- const BoxRec *inner, BoxRec *ret);
-typedef int (*FrameHitTestProc)(xp_frame_class class, int x, int y,
- const BoxRec *outer,
- const BoxRec *inner, int *ret);
-typedef int (*FrameDrawProc)(WindowPtr pWin, xp_frame_class class, xp_frame_attr attr,
- const BoxRec *outer, const BoxRec *inner,
- unsigned int title_len,
- const unsigned char *title_bytes);
-typedef int (*SendPSNProc)(uint32_t hi, uint32_t lo);
-typedef int (*AttachTransientProc)(WindowPtr pWinChild, WindowPtr pWinParent);
-
-/*
- * AppleWM implementation function list
- */
-typedef struct _AppleWMProcs {
- DisableUpdateProc DisableUpdate;
- EnableUpdateProc EnableUpdate;
- SetWindowLevelProc SetWindowLevel;
- FrameGetRectProc FrameGetRect;
- FrameHitTestProc FrameHitTest;
- FrameDrawProc FrameDraw;
- SendPSNProc SendPSN;
- AttachTransientProc AttachTransient;
-} AppleWMProcsRec, *AppleWMProcsPtr;
-
-void AppleWMExtensionInit(
- AppleWMProcsPtr procsPtr
-);
-
-void AppleWMSetScreenOrigin(
- WindowPtr pWin
-);
-
-Bool AppleWMDoReorderWindow(
- WindowPtr pWin
-);
-
-void AppleWMSendEvent(
- int /* type */,
- unsigned int /* mask */,
- int /* which */,
- int /* arg */
-);
-
-unsigned int AppleWMSelectedEvents(
- void
-);
-
-#endif /* _APPLEWMEXT_H_ */
+/*
+ * External interface for the server's AppleWM support
+ */
+/**************************************************************************
+
+Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved.
+Copyright (c) 2003-2004 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.
+
+**************************************************************************/
+
+#ifndef _APPLEWMEXT_H_
+#define _APPLEWMEXT_H_
+
+#include "window.h"
+#include <Xplugin.h>
+
+#if XPLUGIN_VERSION < 4
+typedef int xp_frame_attr;
+typedef int xp_frame_class;
+typedef int xp_frame_rect;
+#endif
+
+typedef int (*DisableUpdateProc)(void);
+typedef int (*EnableUpdateProc)(void);
+typedef int (*SetWindowLevelProc)(WindowPtr pWin, int level);
+typedef int (*FrameGetRectProc)(xp_frame_rect type, xp_frame_class class, const BoxRec *outer,
+ const BoxRec *inner, BoxRec *ret);
+typedef int (*FrameHitTestProc)(xp_frame_class class, int x, int y,
+ const BoxRec *outer,
+ const BoxRec *inner, int *ret);
+typedef int (*FrameDrawProc)(WindowPtr pWin, xp_frame_class class, xp_frame_attr attr,
+ const BoxRec *outer, const BoxRec *inner,
+ unsigned int title_len,
+ const unsigned char *title_bytes);
+typedef int (*SendPSNProc)(uint32_t hi, uint32_t lo);
+typedef int (*AttachTransientProc)(WindowPtr pWinChild, WindowPtr pWinParent);
+
+/*
+ * AppleWM implementation function list
+ */
+typedef struct _AppleWMProcs {
+ DisableUpdateProc DisableUpdate;
+ EnableUpdateProc EnableUpdate;
+ SetWindowLevelProc SetWindowLevel;
+ FrameGetRectProc FrameGetRect;
+ FrameHitTestProc FrameHitTest;
+ FrameDrawProc FrameDraw;
+ SendPSNProc SendPSN;
+ AttachTransientProc AttachTransient;
+} AppleWMProcsRec, *AppleWMProcsPtr;
+
+void AppleWMExtensionInit(
+ AppleWMProcsPtr procsPtr
+);
+
+void AppleWMSetScreenOrigin(
+ WindowPtr pWin
+);
+
+Bool AppleWMDoReorderWindow(
+ WindowPtr pWin
+);
+
+void AppleWMSendEvent(
+ int /* type */,
+ unsigned int /* mask */,
+ int /* which */,
+ int /* arg */
+);
+
+unsigned int AppleWMSelectedEvents(
+ void
+);
+
+#endif /* _APPLEWMEXT_H_ */
diff --git a/xorg-server/hw/xquartz/bundle/Info.plist.cpp b/xorg-server/hw/xquartz/bundle/Info.plist.cpp
index 444400674..a4b8e1926 100644
--- a/xorg-server/hw/xquartz/bundle/Info.plist.cpp
+++ b/xorg-server/hw/xquartz/bundle/Info.plist.cpp
@@ -1,49 +1,49 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>CFBundleDevelopmentRegion</key>
- <string>English</string>
- <key>CFBundleExecutable</key>
- <string>X11</string>
- <key>CFBundleGetInfoString</key>
- <string>BUNDLE_ID_PREFIX.X11</string>
- <key>CFBundleIconFile</key>
- <string>X11.icns</string>
- <key>CFBundleIdentifier</key>
- <string>BUNDLE_ID_PREFIX.X11</string>
- <key>CFBundleInfoDictionaryVersion</key>
- <string>6.0</string>
- <key>CFBundleName</key>
- <string>APPLE_APPLICATION_NAME</string>
- <key>CFBundlePackageType</key>
- <string>APPL</string>
- <key>CFBundleShortVersionString</key>
- <string>2.7.0</string>
- <key>CFBundleVersion</key>
- <string>2.7.0</string>
- <key>CFBundleSignature</key>
- <string>x11a</string>
- <key>CSResourcesFileMapped</key>
- <true/>
-#ifdef XQUARTZ_SPARKLE
- <key>SUEnableAutomaticChecks</key>
- <true/>
- <key>SUPublicDSAKeyFile</key>
- <string>sparkle.pem</string>
- <key>SUFeedURL</key>
- <string>http://xquartz.macosforge.org/downloads/sparkle/release.xml</string>
-#endif
- <key>LSApplicationCategoryType</key>
- <string>public.app-category.utilities</string>
- <key>NSHumanReadableCopyright</key>
- <string>© 2003-2011 Apple Inc.
-© 2003 XFree86 Project, Inc.
-© 2003-2011 X.org Foundation, Inc.
-</string>
- <key>NSMainNibFile</key>
- <string>main</string>
- <key>NSPrincipalClass</key>
- <string>X11Application</string>
-</dict>
-</plist>
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleExecutable</key>
+ <string>X11</string>
+ <key>CFBundleGetInfoString</key>
+ <string>BUNDLE_ID_PREFIX.X11</string>
+ <key>CFBundleIconFile</key>
+ <string>X11.icns</string>
+ <key>CFBundleIdentifier</key>
+ <string>BUNDLE_ID_PREFIX.X11</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>APPLE_APPLICATION_NAME</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>2.7.0</string>
+ <key>CFBundleVersion</key>
+ <string>2.7.0</string>
+ <key>CFBundleSignature</key>
+ <string>x11a</string>
+ <key>CSResourcesFileMapped</key>
+ <true/>
+#ifdef XQUARTZ_SPARKLE
+ <key>SUEnableAutomaticChecks</key>
+ <true/>
+ <key>SUPublicDSAKeyFile</key>
+ <string>sparkle.pem</string>
+ <key>SUFeedURL</key>
+ <string>http://xquartz.macosforge.org/downloads/sparkle/release.xml</string>
+#endif
+ <key>LSApplicationCategoryType</key>
+ <string>public.app-category.utilities</string>
+ <key>NSHumanReadableCopyright</key>
+ <string>© 2003-2011 Apple Inc.
+© 2003 XFree86 Project, Inc.
+© 2003-2011 X.org Foundation, Inc.
+</string>
+ <key>NSMainNibFile</key>
+ <string>main</string>
+ <key>NSPrincipalClass</key>
+ <string>X11Application</string>
+</dict>
+</plist>
diff --git a/xorg-server/hw/xquartz/bundle/Makefile.am b/xorg-server/hw/xquartz/bundle/Makefile.am
index 2f86cdc95..6e83a42d6 100644
--- a/xorg-server/hw/xquartz/bundle/Makefile.am
+++ b/xorg-server/hw/xquartz/bundle/Makefile.am
@@ -1,101 +1,101 @@
-include cpprules.in
-
-CPP_FILES_FLAGS = \
- -DBUNDLE_ID_PREFIX="$(BUNDLE_ID_PREFIX)" \
- -DAPPLE_APPLICATION_NAME="$(APPLE_APPLICATION_NAME)"
-
-if XQUARTZ_SPARKLE
-CPP_FILES_FLAGS += -DXQUARTZ_SPARKLE
-endif
-
-install-data-hook:
- $(srcdir)/mk_bundke.sh $(srcdir) $(builddir) $(DESTDIR)$(APPLE_APPLICATIONS_DIR)/$(APPLE_APPLICATION_NAME).app install
-
-uninstall-hook:
- $(RM) -rf $(DESTDIR)$(APPLE_APPLICATIONS_DIR)/$(APPLE_APPLICATION_NAME).app/Contents/Resources
- $(RM) -rf $(DESTDIR)$(APPLE_APPLICATIONS_DIR)/$(APPLE_APPLICATION_NAME).app/Contents/Info.plist
- $(RM) -rf $(DESTDIR)$(APPLE_APPLICATIONS_DIR)/$(APPLE_APPLICATION_NAME).app/Contents/PkgInfo
-
-noinst_PRE = Info.plist.cpp
-noinst_DATA = $(noinst_PRE:plist.cpp=plist)
-
-CLEANFILES = $(noinst_DATA)
-
-resourcedir=$(libdir)/X11/xserver
-resource_DATA = Xquartz.plist
-
-EXTRA_DIST = \
- mk_bundke.sh \
- X11.sh \
- Info.plist.cpp \
- PkgInfo \
- $(resource_DATA) \
- Resources/ar.lproj/InfoPlist.strings \
- Resources/ar.lproj/Localizable.strings \
- Resources/ar.lproj/main.nib/designable.nib \
- Resources/ar.lproj/main.nib/keyedobjects.nib \
- Resources/da.lproj/InfoPlist.strings \
- Resources/da.lproj/Localizable.strings \
- Resources/da.lproj/main.nib/keyedobjects.nib \
- Resources/Dutch.lproj/InfoPlist.strings \
- Resources/Dutch.lproj/Localizable.strings \
- Resources/Dutch.lproj/main.nib/keyedobjects.nib \
- Resources/el.lproj/InfoPlist.strings \
- Resources/el.lproj/Localizable.strings \
- Resources/el.lproj/main.nib/keyedobjects.nib \
- Resources/English.lproj/InfoPlist.strings \
- Resources/English.lproj/Localizable.strings \
- Resources/English.lproj/main.nib/designable.nib \
- Resources/English.lproj/main.nib/keyedobjects.nib \
- Resources/fi.lproj/InfoPlist.strings \
- Resources/fi.lproj/Localizable.strings \
- Resources/fi.lproj/main.nib/keyedobjects.nib \
- Resources/French.lproj/InfoPlist.strings \
- Resources/French.lproj/Localizable.strings \
- Resources/French.lproj/main.nib/keyedobjects.nib \
- Resources/German.lproj/InfoPlist.strings \
- Resources/German.lproj/Localizable.strings \
- Resources/German.lproj/main.nib/keyedobjects.nib \
- Resources/he.lproj/InfoPlist.strings \
- Resources/he.lproj/Localizable.strings \
- Resources/he.lproj/main.nib/keyedobjects.nib \
- Resources/Italian.lproj/InfoPlist.strings \
- Resources/Italian.lproj/Localizable.strings \
- Resources/Italian.lproj/main.nib/keyedobjects.nib \
- Resources/Japanese.lproj/InfoPlist.strings \
- Resources/Japanese.lproj/Localizable.strings \
- Resources/Japanese.lproj/main.nib/keyedobjects.nib \
- Resources/ko.lproj/InfoPlist.strings \
- Resources/ko.lproj/Localizable.strings \
- Resources/ko.lproj/main.nib/keyedobjects.nib \
- Resources/no.lproj/InfoPlist.strings \
- Resources/no.lproj/Localizable.strings \
- Resources/no.lproj/main.nib/keyedobjects.nib \
- Resources/pl.lproj/InfoPlist.strings \
- Resources/pl.lproj/Localizable.strings \
- Resources/pl.lproj/main.nib/keyedobjects.nib \
- Resources/pt.lproj/InfoPlist.strings \
- Resources/pt.lproj/Localizable.strings \
- Resources/pt.lproj/main.nib/keyedobjects.nib \
- Resources/pt_PT.lproj/InfoPlist.strings \
- Resources/pt_PT.lproj/Localizable.strings \
- Resources/pt_PT.lproj/main.nib/keyedobjects.nib \
- Resources/ru.lproj/InfoPlist.strings \
- Resources/ru.lproj/Localizable.strings \
- Resources/ru.lproj/main.nib/keyedobjects.nib \
- Resources/sk.lproj/InfoPlist.strings \
- Resources/sk.lproj/Localizable.strings \
- Resources/sk.lproj/main.nib/keyedobjects.nib \
- Resources/Spanish.lproj/InfoPlist.strings \
- Resources/Spanish.lproj/Localizable.strings \
- Resources/Spanish.lproj/main.nib/keyedobjects.nib \
- Resources/sv.lproj/InfoPlist.strings \
- Resources/sv.lproj/Localizable.strings \
- Resources/sv.lproj/main.nib/keyedobjects.nib \
- Resources/X11.icns \
- Resources/zh_CN.lproj/InfoPlist.strings \
- Resources/zh_CN.lproj/Localizable.strings \
- Resources/zh_CN.lproj/main.nib/keyedobjects.nib \
- Resources/zh_TW.lproj/InfoPlist.strings \
- Resources/zh_TW.lproj/Localizable.strings \
- Resources/zh_TW.lproj/main.nib/keyedobjects.nib
+include cpprules.in
+
+CPP_FILES_FLAGS = \
+ -DBUNDLE_ID_PREFIX="$(BUNDLE_ID_PREFIX)" \
+ -DAPPLE_APPLICATION_NAME="$(APPLE_APPLICATION_NAME)"
+
+if XQUARTZ_SPARKLE
+CPP_FILES_FLAGS += -DXQUARTZ_SPARKLE
+endif
+
+install-data-hook:
+ $(srcdir)/mk_bundke.sh $(srcdir) $(builddir) $(DESTDIR)$(APPLE_APPLICATIONS_DIR)/$(APPLE_APPLICATION_NAME).app install
+
+uninstall-hook:
+ $(RM) -rf $(DESTDIR)$(APPLE_APPLICATIONS_DIR)/$(APPLE_APPLICATION_NAME).app/Contents/Resources
+ $(RM) -rf $(DESTDIR)$(APPLE_APPLICATIONS_DIR)/$(APPLE_APPLICATION_NAME).app/Contents/Info.plist
+ $(RM) -rf $(DESTDIR)$(APPLE_APPLICATIONS_DIR)/$(APPLE_APPLICATION_NAME).app/Contents/PkgInfo
+
+noinst_PRE = Info.plist.cpp
+noinst_DATA = $(noinst_PRE:plist.cpp=plist)
+
+CLEANFILES = $(noinst_DATA)
+
+resourcedir=$(libdir)/X11/xserver
+resource_DATA = Xquartz.plist
+
+EXTRA_DIST = \
+ mk_bundke.sh \
+ X11.sh \
+ Info.plist.cpp \
+ PkgInfo \
+ $(resource_DATA) \
+ Resources/ar.lproj/InfoPlist.strings \
+ Resources/ar.lproj/Localizable.strings \
+ Resources/ar.lproj/main.nib/designable.nib \
+ Resources/ar.lproj/main.nib/keyedobjects.nib \
+ Resources/da.lproj/InfoPlist.strings \
+ Resources/da.lproj/Localizable.strings \
+ Resources/da.lproj/main.nib/keyedobjects.nib \
+ Resources/Dutch.lproj/InfoPlist.strings \
+ Resources/Dutch.lproj/Localizable.strings \
+ Resources/Dutch.lproj/main.nib/keyedobjects.nib \
+ Resources/el.lproj/InfoPlist.strings \
+ Resources/el.lproj/Localizable.strings \
+ Resources/el.lproj/main.nib/keyedobjects.nib \
+ Resources/English.lproj/InfoPlist.strings \
+ Resources/English.lproj/Localizable.strings \
+ Resources/English.lproj/main.nib/designable.nib \
+ Resources/English.lproj/main.nib/keyedobjects.nib \
+ Resources/fi.lproj/InfoPlist.strings \
+ Resources/fi.lproj/Localizable.strings \
+ Resources/fi.lproj/main.nib/keyedobjects.nib \
+ Resources/French.lproj/InfoPlist.strings \
+ Resources/French.lproj/Localizable.strings \
+ Resources/French.lproj/main.nib/keyedobjects.nib \
+ Resources/German.lproj/InfoPlist.strings \
+ Resources/German.lproj/Localizable.strings \
+ Resources/German.lproj/main.nib/keyedobjects.nib \
+ Resources/he.lproj/InfoPlist.strings \
+ Resources/he.lproj/Localizable.strings \
+ Resources/he.lproj/main.nib/keyedobjects.nib \
+ Resources/Italian.lproj/InfoPlist.strings \
+ Resources/Italian.lproj/Localizable.strings \
+ Resources/Italian.lproj/main.nib/keyedobjects.nib \
+ Resources/Japanese.lproj/InfoPlist.strings \
+ Resources/Japanese.lproj/Localizable.strings \
+ Resources/Japanese.lproj/main.nib/keyedobjects.nib \
+ Resources/ko.lproj/InfoPlist.strings \
+ Resources/ko.lproj/Localizable.strings \
+ Resources/ko.lproj/main.nib/keyedobjects.nib \
+ Resources/no.lproj/InfoPlist.strings \
+ Resources/no.lproj/Localizable.strings \
+ Resources/no.lproj/main.nib/keyedobjects.nib \
+ Resources/pl.lproj/InfoPlist.strings \
+ Resources/pl.lproj/Localizable.strings \
+ Resources/pl.lproj/main.nib/keyedobjects.nib \
+ Resources/pt.lproj/InfoPlist.strings \
+ Resources/pt.lproj/Localizable.strings \
+ Resources/pt.lproj/main.nib/keyedobjects.nib \
+ Resources/pt_PT.lproj/InfoPlist.strings \
+ Resources/pt_PT.lproj/Localizable.strings \
+ Resources/pt_PT.lproj/main.nib/keyedobjects.nib \
+ Resources/ru.lproj/InfoPlist.strings \
+ Resources/ru.lproj/Localizable.strings \
+ Resources/ru.lproj/main.nib/keyedobjects.nib \
+ Resources/sk.lproj/InfoPlist.strings \
+ Resources/sk.lproj/Localizable.strings \
+ Resources/sk.lproj/main.nib/keyedobjects.nib \
+ Resources/Spanish.lproj/InfoPlist.strings \
+ Resources/Spanish.lproj/Localizable.strings \
+ Resources/Spanish.lproj/main.nib/keyedobjects.nib \
+ Resources/sv.lproj/InfoPlist.strings \
+ Resources/sv.lproj/Localizable.strings \
+ Resources/sv.lproj/main.nib/keyedobjects.nib \
+ Resources/X11.icns \
+ Resources/zh_CN.lproj/InfoPlist.strings \
+ Resources/zh_CN.lproj/Localizable.strings \
+ Resources/zh_CN.lproj/main.nib/keyedobjects.nib \
+ Resources/zh_TW.lproj/InfoPlist.strings \
+ Resources/zh_TW.lproj/Localizable.strings \
+ Resources/zh_TW.lproj/main.nib/keyedobjects.nib
diff --git a/xorg-server/hw/xquartz/bundle/Resources/French.lproj/locversion.plist b/xorg-server/hw/xquartz/bundle/Resources/French.lproj/locversion.plist
index ae019415c..04031c436 100644
--- a/xorg-server/hw/xquartz/bundle/Resources/French.lproj/locversion.plist
+++ b/xorg-server/hw/xquartz/bundle/Resources/French.lproj/locversion.plist
@@ -1,14 +1,14 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>LprojCompatibleVersion</key>
- <string>106</string>
- <key>LprojLocale</key>
- <string>fr</string>
- <key>LprojRevisionLevel</key>
- <string>1</string>
- <key>LprojVersion</key>
- <string>106</string>
-</dict>
-</plist>
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>LprojCompatibleVersion</key>
+ <string>106</string>
+ <key>LprojLocale</key>
+ <string>fr</string>
+ <key>LprojRevisionLevel</key>
+ <string>1</string>
+ <key>LprojVersion</key>
+ <string>106</string>
+</dict>
+</plist>
diff --git a/xorg-server/hw/xquartz/bundle/Resources/French.lproj/main.nib/designable.nib b/xorg-server/hw/xquartz/bundle/Resources/French.lproj/main.nib/designable.nib
index 285cae1c6..a56255966 100644
--- a/xorg-server/hw/xquartz/bundle/Resources/French.lproj/main.nib/designable.nib
+++ b/xorg-server/hw/xquartz/bundle/Resources/French.lproj/main.nib/designable.nib
@@ -1,3672 +1,3672 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00">
- <data>
- <int key="IBDocument.SystemTarget">1040</int>
- <string key="IBDocument.SystemVersion">11A289</string>
- <string key="IBDocument.InterfaceBuilderVersion">900</string>
- <string key="IBDocument.AppKitVersion">1094.2</string>
- <string key="IBDocument.HIToolboxVersion">521.00</string>
- <object class="NSMutableDictionary" key="IBDocument.PluginVersions">
- <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="NS.object.0">900</string>
- </object>
- <array class="NSMutableArray" key="IBDocument.EditedObjectIDs"/>
- <array key="IBDocument.PluginDependencies">
- <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- </array>
- <object class="NSMutableDictionary" key="IBDocument.Metadata">
- <string key="NS.key.0">PluginDependencyRecalculationVersion</string>
- <integer value="1" key="NS.object.0"/>
- </object>
- <array class="NSMutableArray" key="IBDocument.RootObjects" id="904585544">
- <object class="NSCustomObject" id="815810918">
- <object class="NSMutableString" key="NSClassName">
- <characters key="NS.bytes">NSApplication</characters>
- </object>
- </object>
- <object class="NSCustomObject" id="941939442">
- <string key="NSClassName">FirstResponder</string>
- </object>
- <object class="NSCustomObject" id="951368722">
- <string key="NSClassName">NSApplication</string>
- </object>
- <object class="NSMenu" id="524015605">
- <string key="NSTitle">MainMenu</string>
- <array class="NSMutableArray" key="NSMenuItems">
- <object class="NSMenuItem" id="365880285">
- <reference key="NSMenu" ref="524015605"/>
- <string key="NSTitle">X11</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <object class="NSCustomResource" key="NSOnImage" id="531645050">
- <string key="NSClassName">NSImage</string>
- <string key="NSResourceName">NSMenuCheckmark</string>
- </object>
- <object class="NSCustomResource" key="NSMixedImage" id="351811234">
- <string key="NSClassName">NSImage</string>
- <string key="NSResourceName">NSMenuMixedState</string>
- </object>
- <string key="NSAction">submenuAction:</string>
- <object class="NSMenu" key="NSSubmenu" id="576521955">
- <string key="NSTitle">X11</string>
- <array class="NSMutableArray" key="NSMenuItems">
- <object class="NSMenuItem" id="139290918">
- <reference key="NSMenu" ref="576521955"/>
- <string key="NSTitle">À propos d’X11</string>
- <string key="NSKeyEquiv"/>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="386173216">
- <reference key="NSMenu" ref="576521955"/>
- <string key="NSTitle">Préférences…</string>
- <string key="NSKeyEquiv">,</string>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="272876017">
- <reference key="NSMenu" ref="576521955"/>
- <bool key="NSIsDisabled">YES</bool>
- <bool key="NSIsSeparator">YES</bool>
- <string key="NSTitle"/>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="32285361">
- <reference key="NSMenu" ref="576521955"/>
- <string key="NSTitle">Services</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- <string key="NSAction">submenuAction:</string>
- <object class="NSMenu" key="NSSubmenu" id="821388474">
- <object class="NSMutableString" key="NSTitle">
- <characters key="NS.bytes">Services</characters>
- </object>
- <array class="NSMutableArray" key="NSMenuItems"/>
- <string key="NSName">_NSServicesMenu</string>
- </object>
- </object>
- <object class="NSMenuItem" id="431301145">
- <reference key="NSMenu" ref="576521955"/>
- <bool key="NSIsDisabled">YES</bool>
- <bool key="NSIsSeparator">YES</bool>
- <string key="NSTitle"/>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="6876565">
- <reference key="NSMenu" ref="576521955"/>
- <string key="NSTitle">Basculer en mode plein écran</string>
- <string key="NSKeyEquiv">a</string>
- <int key="NSKeyEquivModMask">1572864</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="479677589">
- <reference key="NSMenu" ref="576521955"/>
- <bool key="NSIsDisabled">YES</bool>
- <bool key="NSIsSeparator">YES</bool>
- <string key="NSTitle"/>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="301008465">
- <reference key="NSMenu" ref="576521955"/>
- <string key="NSTitle">Masquer X11</string>
- <string key="NSKeyEquiv">h</string>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- <int key="NSTag">42</int>
- </object>
- <object class="NSMenuItem" id="206802571">
- <reference key="NSMenu" ref="576521955"/>
- <string key="NSTitle">Masquer les autres</string>
- <string key="NSKeyEquiv">h</string>
- <int key="NSKeyEquivModMask">1572864</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="1023546148">
- <reference key="NSMenu" ref="576521955"/>
- <string key="NSTitle">Tout afficher</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- <int key="NSTag">42</int>
- </object>
- <object class="NSMenuItem" id="848095279">
- <reference key="NSMenu" ref="576521955"/>
- <bool key="NSIsDisabled">YES</bool>
- <bool key="NSIsSeparator">YES</bool>
- <string key="NSTitle"/>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="274138642">
- <reference key="NSMenu" ref="576521955"/>
- <string key="NSTitle">Quitter X11</string>
- <string key="NSKeyEquiv">q</string>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- </array>
- <string key="NSName">_NSAppleMenu</string>
- </object>
- </object>
- <object class="NSMenuItem" id="868031522">
- <reference key="NSMenu" ref="524015605"/>
- <string key="NSTitle">Applications</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- <string key="NSAction">submenuAction:</string>
- <object class="NSMenu" key="NSSubmenu" id="981161348">
- <string key="NSTitle">Applications</string>
- <array class="NSMutableArray" key="NSMenuItems">
- <object class="NSMenuItem" id="390088328">
- <reference key="NSMenu" ref="981161348"/>
- <bool key="NSIsDisabled">YES</bool>
- <bool key="NSIsSeparator">YES</bool>
- <string key="NSTitle"/>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="1065386165">
- <reference key="NSMenu" ref="981161348"/>
- <string key="NSTitle">Personnaliser…</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- </array>
- </object>
- </object>
- <object class="NSMenuItem" id="200491363">
- <reference key="NSMenu" ref="524015605"/>
- <string key="NSTitle">Édition</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- <string key="NSAction">submenuAction:</string>
- <object class="NSMenu" key="NSSubmenu" id="526778998">
- <string key="NSTitle">Édition</string>
- <array class="NSMutableArray" key="NSMenuItems">
- <object class="NSMenuItem" id="185296989">
- <reference key="NSMenu" ref="526778998"/>
- <string key="NSTitle">Copier</string>
- <string key="NSKeyEquiv">c</string>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- </array>
- </object>
- </object>
- <object class="NSMenuItem" id="931553638">
- <reference key="NSMenu" ref="524015605"/>
- <string key="NSTitle">Fenêtre</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- <string key="NSAction">submenuAction:</string>
- <object class="NSMenu" key="NSSubmenu" id="96874957">
- <string key="NSTitle">Fenêtre</string>
- <array class="NSMutableArray" key="NSMenuItems">
- <object class="NSMenuItem" id="984461797">
- <reference key="NSMenu" ref="96874957"/>
- <string key="NSTitle">Fermer</string>
- <string key="NSKeyEquiv">w</string>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="677652931">
- <reference key="NSMenu" ref="96874957"/>
- <string key="NSTitle">Placer dans le Dock</string>
- <string key="NSKeyEquiv">m</string>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="1066447520">
- <reference key="NSMenu" ref="96874957"/>
- <string key="NSTitle">Réduire/agrandir</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="280172320">
- <reference key="NSMenu" ref="96874957"/>
- <bool key="NSIsDisabled">YES</bool>
- <bool key="NSIsSeparator">YES</bool>
- <string key="NSTitle"/>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="1036389925">
- <reference key="NSMenu" ref="96874957"/>
- <string key="NSTitle">Faire défiler les fenêtres</string>
- <string key="NSKeyEquiv">`</string>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="369641893">
- <reference key="NSMenu" ref="96874957"/>
- <string key="NSTitle">Faire défiler les fenêtres en sens inverse</string>
- <string key="NSKeyEquiv">`</string>
- <int key="NSKeyEquivModMask">1179648</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="155085383">
- <reference key="NSMenu" ref="96874957"/>
- <bool key="NSIsDisabled">YES</bool>
- <bool key="NSIsSeparator">YES</bool>
- <string key="NSTitle"/>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="276216762">
- <reference key="NSMenu" ref="96874957"/>
- <string key="NSTitle">Tout ramener au premier plan</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- </array>
- <string key="NSName">_NSWindowsMenu</string>
- </object>
- </object>
- <object class="NSMenuItem" id="551174276">
- <reference key="NSMenu" ref="524015605"/>
- <string key="NSTitle">Aide</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- <string key="NSAction">submenuAction:</string>
- <object class="NSMenu" key="NSSubmenu" id="511848303">
- <string key="NSTitle">Aide</string>
- <array class="NSMutableArray" key="NSMenuItems">
- <object class="NSMenuItem" id="504984881">
- <reference key="NSMenu" ref="511848303"/>
- <string key="NSTitle">Aide X11</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- </array>
- </object>
- </object>
- </array>
- <string key="NSName">_NSMainMenu</string>
- </object>
- <object class="NSCustomObject" id="485884620">
- <string key="NSClassName">X11Controller</string>
- </object>
- <object class="NSWindowTemplate" id="124913468">
- <int key="NSWindowStyleMask">3</int>
- <int key="NSWindowBacking">2</int>
- <string key="NSWindowRect">{{414, 417.03906000000001}, {580, 341}}</string>
- <int key="NSWTFlags">1350041600</int>
- <string key="NSWindowTitle">Préférences d’X11</string>
- <string key="NSWindowClass">NSPanel</string>
- <object class="NSMutableString" key="NSViewClass">
- <characters key="NS.bytes">View</characters>
- </object>
- <nil key="NSUserInterfaceItemIdentifier"/>
- <string key="NSWindowContentMaxSize">{1.7976931348623157e+308, 1.7976931348623157e+308}</string>
- <string key="NSWindowContentMinSize">{320, 240}</string>
- <object class="NSView" key="NSWindowView" id="941366957">
- <nil key="NSNextResponder"/>
- <int key="NSvFlags">256</int>
- <array class="NSMutableArray" key="NSSubviews">
- <object class="NSTabView" id="448510093">
- <reference key="NSNextResponder" ref="941366957"/>
- <int key="NSvFlags">274</int>
- <string key="NSFrame">{{13, 10}, {554, 325}}</string>
- <reference key="NSSuperview" ref="941366957"/>
- <array class="NSMutableArray" key="NSTabViewItems">
- <object class="NSTabViewItem" id="287591690">
- <object class="NSMutableString" key="NSIdentifier">
- <characters key="NS.bytes">1</characters>
- </object>
- <object class="NSView" key="NSView" id="596750588">
- <reference key="NSNextResponder" ref="448510093"/>
- <int key="NSvFlags">256</int>
- <array class="NSMutableArray" key="NSSubviews">
- <object class="NSButton" id="119157981">
- <reference key="NSNextResponder" ref="596750588"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{18, 243}, {402, 18}}</string>
- <reference key="NSSuperview" ref="596750588"/>
- <reference key="NSNextKeyView" ref="179949713"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="990762273">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">Émuler une souris à trois boutons</string>
- <object class="NSFont" key="NSSupport" id="463863101">
- <string key="NSName">LucidaGrande</string>
- <double key="NSSize">13</double>
- <int key="NSfFlags">1044</int>
- </object>
- <reference key="NSControlView" ref="119157981"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <object class="NSCustomResource" key="NSNormalImage" id="967651788">
- <string key="NSClassName">NSImage</string>
- <string key="NSResourceName">NSSwitch</string>
- </object>
- <object class="NSButtonImageSource" key="NSAlternateImage" id="391434389">
- <string key="NSImageName">NSSwitch</string>
- </object>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSTextField" id="443008216">
- <reference key="NSNextResponder" ref="596750588"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{36, 82}, {484, 42}}</string>
- <reference key="NSSuperview" ref="596750588"/>
- <reference key="NSNextKeyView" ref="406291430"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="391919450">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">Quand cette option est activée, les touches équivalentes de la barre des menus peuvent perturber les applications X11 qui utilisent le modificateur d’instructions virtuelles.</string>
- <object class="NSFont" key="NSSupport" id="26">
- <string key="NSName">LucidaGrande</string>
- <double key="NSSize">11</double>
- <int key="NSfFlags">3100</int>
- </object>
- <string key="NSPlaceholderString"/>
- <reference key="NSControlView" ref="443008216"/>
- <object class="NSColor" key="NSBackgroundColor" id="57160303">
- <int key="NSColorSpace">6</int>
- <string key="NSCatalogName">System</string>
- <string key="NSColorName">controlColor</string>
- <object class="NSColor" key="NSColor" id="590688762">
- <int key="NSColorSpace">3</int>
- <bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes>
- </object>
- </object>
- <object class="NSColor" key="NSTextColor" id="930815747">
- <int key="NSColorSpace">6</int>
- <string key="NSCatalogName">System</string>
- <string key="NSColorName">controlTextColor</string>
- <object class="NSColor" key="NSColor" id="214098874">
- <int key="NSColorSpace">3</int>
- <bytes key="NSWhite">MAA</bytes>
- </object>
- </object>
- </object>
- </object>
- <object class="NSTextField" id="282885445">
- <reference key="NSNextResponder" ref="596750588"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{36, 203}, {484, 34}}</string>
- <reference key="NSSuperview" ref="596750588"/>
- <reference key="NSNextKeyView" ref="31160162"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="649334366">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string type="base64-UTF8" key="NSContents">TWFpbnRlbmV6IGxhIHRvdWNoZSBPcHRpb24gb3UgQ29tbWFuZGUgZW5mb25jw6llIHRvdXQgZW4gY2xp
-cXVhbnQgcG91ciBhY3RpdmVyIGxlIGJvdXRvbiBkcm9pdCBvdSBjZW50cmFsIGRlIGxhIHNvdXJpcy4K
-A</string>
- <reference key="NSSupport" ref="26"/>
- <string key="NSPlaceholderString"/>
- <reference key="NSControlView" ref="282885445"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- <object class="NSButton" id="842100515">
- <reference key="NSNextResponder" ref="596750588"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{18, 130}, {402, 18}}</string>
- <reference key="NSSuperview" ref="596750588"/>
- <reference key="NSNextKeyView" ref="443008216"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="940564599">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">Activer les touches équivalentes sous X11</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="842100515"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="967651788"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSTextField" id="31160162">
- <reference key="NSNextResponder" ref="596750588"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{36, 144}, {484, 29}}</string>
- <reference key="NSSuperview" ref="596750588"/>
- <reference key="NSNextKeyView" ref="842100515"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="666057093">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">Autorise les modifications du menu d’entrée pour remplacer la disposition des touches du clavier X11.</string>
- <reference key="NSSupport" ref="26"/>
- <string key="NSPlaceholderString"/>
- <reference key="NSControlView" ref="31160162"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- <object class="NSButton" id="179949713">
- <reference key="NSNextResponder" ref="596750588"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{18, 179}, {402, 18}}</string>
- <reference key="NSSuperview" ref="596750588"/>
- <reference key="NSNextKeyView" ref="282885445"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="967619578">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">Utiliser la disposition des touches du clavier du système</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="179949713"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="967651788"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSTextField" id="278155937">
- <reference key="NSNextResponder" ref="596750588"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{36, 35}, {484, 28}}</string>
- <reference key="NSSuperview" ref="596750588"/>
- <reference key="NSNextKeyView" ref="863505041"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="617441821">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">Une fois activées, les touches option envoient les symboles Alt_L et Alt_R au lieu de Mode_switch.</string>
- <reference key="NSSupport" ref="26"/>
- <reference key="NSControlView" ref="278155937"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- <object class="NSButton" id="406291430">
- <reference key="NSNextResponder" ref="596750588"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{18, 69}, {402, 18}}</string>
- <reference key="NSSuperview" ref="596750588"/>
- <reference key="NSNextKeyView" ref="278155937"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="67728988">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">Les touches option envoient Alt_L et Alt_R</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="406291430"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="967651788"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSButton" id="863505041">
- <reference key="NSNextResponder" ref="596750588"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{18, 8}, {418, 18}}</string>
- <reference key="NSSuperview" ref="596750588"/>
- <reference key="NSNextKeyView" ref="448510093"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="1016286396">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">Faire toujours défiler dans le sens du mouvement des doigts</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="863505041"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="967651788"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- </array>
- <string key="NSFrame">{{10, 33}, {534, 279}}</string>
- <reference key="NSSuperview" ref="448510093"/>
- <reference key="NSNextKeyView" ref="119157981"/>
- </object>
- <string key="NSLabel">Entrée</string>
- <reference key="NSColor" ref="57160303"/>
- <reference key="NSTabView" ref="448510093"/>
- </object>
- <object class="NSTabViewItem" id="960678392">
- <object class="NSMutableString" key="NSIdentifier">
- <characters key="NS.bytes">2</characters>
- </object>
- <object class="NSView" key="NSView" id="515308735">
- <nil key="NSNextResponder"/>
- <int key="NSvFlags">256</int>
- <array class="NSMutableArray" key="NSSubviews">
- <object class="NSPopUpButton" id="709074847">
- <reference key="NSNextResponder" ref="515308735"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{90, 234}, {128, 26}}</string>
- <reference key="NSSuperview" ref="515308735"/>
- <reference key="NSNextKeyView" ref="86150604"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSPopUpButtonCell" key="NSCell" id="633115429">
- <int key="NSCellFlags">-2076049856</int>
- <int key="NSCellFlags2">1024</int>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="709074847"/>
- <int key="NSButtonFlags">109199615</int>
- <int key="NSButtonFlags2">1</int>
- <object class="NSFont" key="NSAlternateImage">
- <string key="NSName">LucidaGrande</string>
- <double key="NSSize">13</double>
- <int key="NSfFlags">16</int>
- </object>
- <string key="NSAlternateContents"/>
- <object class="NSMutableString" key="NSKeyEquivalent">
- <characters key="NS.bytes"/>
- </object>
- <int key="NSPeriodicDelay">400</int>
- <int key="NSPeriodicInterval">75</int>
- <object class="NSMenuItem" key="NSMenuItem" id="616492372">
- <reference key="NSMenu" ref="341113515"/>
- <string key="NSTitle">du moniteur</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <int key="NSState">1</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- <string key="NSAction">_popUpItemAction:</string>
- <int key="NSTag">-1</int>
- <reference key="NSTarget" ref="633115429"/>
- </object>
- <bool key="NSMenuItemRespectAlignment">YES</bool>
- <object class="NSMenu" key="NSMenu" id="341113515">
- <object class="NSMutableString" key="NSTitle">
- <characters key="NS.bytes">OtherViews</characters>
- </object>
- <array class="NSMutableArray" key="NSMenuItems">
- <reference ref="616492372"/>
- <object class="NSMenuItem" id="759499526">
- <reference key="NSMenu" ref="341113515"/>
- <string key="NSTitle">256 couleurs</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- <string key="NSAction">_popUpItemAction:</string>
- <int key="NSTag">8</int>
- <reference key="NSTarget" ref="633115429"/>
- </object>
- <object class="NSMenuItem" id="543935434">
- <reference key="NSMenu" ref="341113515"/>
- <string key="NSTitle">milliers</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- <string key="NSAction">_popUpItemAction:</string>
- <int key="NSTag">15</int>
- <reference key="NSTarget" ref="633115429"/>
- </object>
- <object class="NSMenuItem" id="836673018">
- <reference key="NSMenu" ref="341113515"/>
- <string key="NSTitle">millions</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- <string key="NSAction">_popUpItemAction:</string>
- <int key="NSTag">24</int>
- <reference key="NSTarget" ref="633115429"/>
- </object>
- </array>
- </object>
- <int key="NSPreferredEdge">3</int>
- <bool key="NSUsesItemFromMenu">YES</bool>
- <bool key="NSAltersState">YES</bool>
- <int key="NSArrowPosition">1</int>
- </object>
- </object>
- <object class="NSTextField" id="201731424">
- <reference key="NSNextResponder" ref="515308735"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{17, 238}, {71, 20}}</string>
- <reference key="NSSuperview" ref="515308735"/>
- <reference key="NSNextKeyView" ref="709074847"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="930265681">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">Couleurs :</string>
- <reference key="NSSupport" ref="463863101"/>
- <string key="NSPlaceholderString"/>
- <reference key="NSControlView" ref="201731424"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- <object class="NSTextField" id="86150604">
- <reference key="NSNextResponder" ref="515308735"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{36, 216}, {392, 14}}</string>
- <reference key="NSSuperview" ref="515308735"/>
- <reference key="NSNextKeyView" ref="477203622"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="311969422">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">Cette option prend effet au prochain lancement d’X11.</string>
- <reference key="NSSupport" ref="26"/>
- <string key="NSPlaceholderString"/>
- <reference key="NSControlView" ref="86150604"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- <object class="NSButton" id="477203622">
- <reference key="NSNextResponder" ref="515308735"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{18, 182}, {409, 23}}</string>
- <reference key="NSSuperview" ref="515308735"/>
- <reference key="NSNextKeyView" ref="298603383"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="631531164">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">Mode plein écran</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="477203622"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="967651788"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSButton" id="57246850">
- <reference key="NSNextResponder" ref="515308735"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{37, 116}, {468, 18}}</string>
- <reference key="NSSuperview" ref="515308735"/>
- <reference key="NSNextKeyView" ref="331853183"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="917248662">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">Autoriser un accès à la barre des menus en mode plein écran</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="57246850"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="967651788"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSTextField" id="298603383">
- <reference key="NSNextResponder" ref="515308735"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{36, 145}, {484, 31}}</string>
- <reference key="NSSuperview" ref="515308735"/>
- <reference key="NSNextKeyView" ref="57246850"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="761107402">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">Active la fenêtre root X11. Utilisez le raccourci clavier Commande + Option + A pour ouvrir et fermer le mode plein écran.</string>
- <reference key="NSSupport" ref="26"/>
- <string key="NSPlaceholderString"/>
- <reference key="NSControlView" ref="298603383"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- <object class="NSTextField" id="331853183">
- <reference key="NSNextResponder" ref="515308735"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{54, 79}, {466, 31}}</string>
- <reference key="NSSuperview" ref="515308735"/>
- <reference key="NSNextKeyView" ref="448510093"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="1042813110">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">La barre des menus sera visible lorsque le curseur de souris est placé en haut de votre affichage principal.</string>
- <reference key="NSSupport" ref="26"/>
- <reference key="NSControlView" ref="331853183"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- </array>
- <string key="NSFrame">{{10, 33}, {534, 279}}</string>
- <reference key="NSNextKeyView" ref="201731424"/>
- </object>
- <string key="NSLabel">Sortie</string>
- <reference key="NSColor" ref="57160303"/>
- <reference key="NSTabView" ref="448510093"/>
- </object>
- <object class="NSTabViewItem" id="723450037">
- <object class="NSMutableString" key="NSIdentifier">
- <characters key="NS.bytes">2</characters>
- </object>
- <object class="NSView" key="NSView" id="408298283">
- <nil key="NSNextResponder"/>
- <int key="NSvFlags">256</int>
- <array class="NSMutableArray" key="NSSubviews">
- <object class="NSButton" id="878106058">
- <reference key="NSNextResponder" ref="408298283"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{18, 255}, {409, 23}}</string>
- <reference key="NSSuperview" ref="408298283"/>
- <reference key="NSNextKeyView" ref="386152084"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="718083688">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">Activer la synchronisation</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="878106058"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="967651788"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSTextField" id="386152084">
- <reference key="NSNextResponder" ref="408298283"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{36, 207}, {494, 42}}</string>
- <reference key="NSSuperview" ref="408298283"/>
- <reference key="NSNextKeyView" ref="487809555"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="572508492">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">Active la commande de menu « Copier » et permet la synchronisation entre le presse-papiers de OSX, celui de X11 (CLIPBOARD) et les mémoires tampons principales (PRIMARY).</string>
- <reference key="NSSupport" ref="26"/>
- <reference key="NSControlView" ref="386152084"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- <object class="NSButton" id="477050998">
- <reference key="NSNextResponder" ref="408298283"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{34, 129}, {458, 18}}</string>
- <reference key="NSSuperview" ref="408298283"/>
- <reference key="NSNextKeyView" ref="765780304"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="501304422">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">Mettre à jour CLIPBOARD lorsque le presse-papiers est modifié</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="477050998"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="967651788"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSButton" id="765780304">
- <reference key="NSNextResponder" ref="408298283"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{34, 104}, {495, 18}}</string>
- <reference key="NSSuperview" ref="408298283"/>
- <reference key="NSNextKeyView" ref="1002778833"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="510771323">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">Mettre à jour PRIMARY (clic central) lorsque le presse-papiers est modifié</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="765780304"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="967651788"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSButton" id="1002778833">
- <reference key="NSNextResponder" ref="408298283"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{34, 79}, {437, 18}}</string>
- <reference key="NSSuperview" ref="408298283"/>
- <reference key="NSNextKeyView" ref="522511724"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="897099877">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">Mettre à jour le presse-papiers dès la sélection de nouveau texte</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="1002778833"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="967651788"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSButton" id="487809555">
- <reference key="NSNextResponder" ref="408298283"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{34, 192}, {474, 18}}</string>
- <reference key="NSSuperview" ref="408298283"/>
- <reference key="NSNextKeyView" ref="620944856"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="619977658">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">Mettre à jour le presse-papiers lorsque CLIPBOARD est modifié</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="487809555"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="967651788"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSTextField" id="620944856">
- <reference key="NSNextResponder" ref="408298283"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{48, 158}, {482, 28}}</string>
- <reference key="NSSuperview" ref="408298283"/>
- <reference key="NSNextKeyView" ref="477050998"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="461823902">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">Désactivez cette option si vous voulez utiliser xclipboard, klipper, ou tout autre gestionnaire de presse-papiers X11.</string>
- <reference key="NSSupport" ref="26"/>
- <reference key="NSControlView" ref="620944856"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- <object class="NSTextField" id="522511724">
- <reference key="NSNextResponder" ref="408298283"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{48, 47}, {482, 28}}</string>
- <reference key="NSSuperview" ref="408298283"/>
- <reference key="NSNextKeyView" ref="448510093"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="994587858">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">En raison de limitations du protocole X11, cette option ne fonctionnera pas toujours dans certaines applications.</string>
- <reference key="NSSupport" ref="26"/>
- <reference key="NSControlView" ref="522511724"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- </array>
- <string key="NSFrame">{{10, 33}, {534, 279}}</string>
- <reference key="NSNextKeyView" ref="878106058"/>
- </object>
- <string key="NSLabel">Presse-papiers</string>
- <reference key="NSColor" ref="57160303"/>
- <reference key="NSTabView" ref="448510093"/>
- </object>
- <object class="NSTabViewItem" id="10973343">
- <object class="NSMutableString" key="NSIdentifier">
- <characters key="NS.bytes">2</characters>
- </object>
- <object class="NSView" key="NSView" id="184765684">
- <nil key="NSNextResponder"/>
- <int key="NSvFlags">256</int>
- <array class="NSMutableArray" key="NSSubviews">
- <object class="NSButton" id="657659108">
- <reference key="NSNextResponder" ref="184765684"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{15, 245}, {402, 18}}</string>
- <reference key="NSSuperview" ref="184765684"/>
- <reference key="NSNextKeyView" ref="290578835"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="259618205">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">Activation des fenêtres inactives en un clic</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="657659108"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="967651788"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSTextField" id="290578835">
- <reference key="NSNextResponder" ref="184765684"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{23, 208}, {505, 31}}</string>
- <reference key="NSSuperview" ref="184765684"/>
- <reference key="NSNextKeyView" ref="992839333"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="399127858">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">En cas d’activation de cette option, si vous cliquez sur une fenêtre inactive, celle-ci deviendra active et le clic sera effectif.</string>
- <reference key="NSSupport" ref="26"/>
- <string key="NSPlaceholderString"/>
- <reference key="NSControlView" ref="290578835"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- <object class="NSButton" id="992839333">
- <reference key="NSNextResponder" ref="184765684"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{15, 184}, {402, 18}}</string>
- <reference key="NSSuperview" ref="184765684"/>
- <reference key="NSNextKeyView" ref="138261120"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="959555182">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">Activation des fenêtres survolées par la souris</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="992839333"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="967651788"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSTextField" id="138261120">
- <reference key="NSNextResponder" ref="184765684"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{23, 150}, {505, 28}}</string>
- <reference key="NSSuperview" ref="184765684"/>
- <reference key="NSNextKeyView" ref="128352289"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="183409141">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">L’activation des fenêtres X11 suit le curseur. Ceci comporte des effets adverses.</string>
- <reference key="NSSupport" ref="26"/>
- <string key="NSPlaceholderString"/>
- <reference key="NSControlView" ref="138261120"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- <object class="NSButton" id="128352289">
- <reference key="NSNextResponder" ref="184765684"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{15, 140}, {402, 18}}</string>
- <reference key="NSSuperview" ref="184765684"/>
- <reference key="NSNextKeyView" ref="57161931"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="556463187">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">Activation des nouvelles fenêtres</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="128352289"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="967651788"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSTextField" id="57161931">
- <reference key="NSNextResponder" ref="184765684"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{23, 92}, {505, 42}}</string>
- <reference key="NSSuperview" ref="184765684"/>
- <reference key="NSNextKeyView" ref="448510093"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="989804990">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">Lorsque cette option est activée, la création d’une nouvelle fenêtre X11 fait passer X11.app au premier plan (au lieu de Finder.app, Terminal.app, etc.)</string>
- <reference key="NSSupport" ref="26"/>
- <string key="NSPlaceholderString"/>
- <reference key="NSControlView" ref="57161931"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- </array>
- <string key="NSFrame">{{10, 33}, {534, 279}}</string>
- <reference key="NSNextKeyView" ref="657659108"/>
- </object>
- <string key="NSLabel">Fenêtres</string>
- <reference key="NSColor" ref="57160303"/>
- <reference key="NSTabView" ref="448510093"/>
- </object>
- <object class="NSTabViewItem" id="348328898">
- <object class="NSView" key="NSView" id="300811574">
- <nil key="NSNextResponder"/>
- <int key="NSvFlags">256</int>
- <array class="NSMutableArray" key="NSSubviews">
- <object class="NSButton" id="989050925">
- <reference key="NSNextResponder" ref="300811574"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{18, 243}, {402, 18}}</string>
- <reference key="NSSuperview" ref="300811574"/>
- <reference key="NSNextKeyView" ref="168436707"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="189594322">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">Authentifier les connexions</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="989050925"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="967651788"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSButton" id="700826966">
- <reference key="NSNextResponder" ref="300811574"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{18, 166}, {402, 18}}</string>
- <reference key="NSSuperview" ref="300811574"/>
- <reference key="NSNextKeyView" ref="363817195"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="489340979">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">Autoriser les connexions de clients réseau</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="700826966"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="967651788"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSTextField" id="168436707">
- <reference key="NSNextResponder" ref="300811574"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{36, 195}, {484, 42}}</string>
- <reference key="NSSuperview" ref="300811574"/>
- <reference key="NSNextKeyView" ref="700826966"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="53243865">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">Le lancement d’X11 créera des touches de contrôle d’accès Xauthority. Si l’adresse IP du système change, ces touches ne seront plus valides, ce qui risquera d’empêcher le lancement des applications X11.</string>
- <reference key="NSSupport" ref="26"/>
- <string key="NSPlaceholderString"/>
- <reference key="NSControlView" ref="168436707"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- <object class="NSTextField" id="363817195">
- <reference key="NSNextResponder" ref="300811574"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{36, 104}, {484, 56}}</string>
- <reference key="NSSuperview" ref="300811574"/>
- <reference key="NSNextKeyView" ref="223835729"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="390084685">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">En cas d’activation de cette option, « Authentifier les connexions » doit aussi être activée pour garantir la sécurité du système. En cas de désactivation, les connexions à partir d’applications distantes sont interdites.</string>
- <reference key="NSSupport" ref="26"/>
- <string key="NSPlaceholderString"/>
- <reference key="NSControlView" ref="363817195"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- <object class="NSTextField" id="223835729">
- <reference key="NSNextResponder" ref="300811574"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{17, 17}, {404, 14}}</string>
- <reference key="NSSuperview" ref="300811574"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="283628678">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">Ces options prennent effet au prochain lancement d’X11.</string>
- <reference key="NSSupport" ref="26"/>
- <string key="NSPlaceholderString"/>
- <reference key="NSControlView" ref="223835729"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- </array>
- <string key="NSFrame">{{10, 33}, {534, 279}}</string>
- <reference key="NSNextKeyView" ref="989050925"/>
- </object>
- <string key="NSLabel">Sécurité</string>
- <reference key="NSColor" ref="57160303"/>
- <reference key="NSTabView" ref="448510093"/>
- </object>
- </array>
- <reference key="NSSelectedTabViewItem" ref="287591690"/>
- <reference key="NSFont" ref="463863101"/>
- <int key="NSTvFlags">0</int>
- <bool key="NSAllowTruncatedLabels">YES</bool>
- <bool key="NSDrawsBackground">YES</bool>
- <array class="NSMutableArray" key="NSSubviews">
- <reference ref="596750588"/>
- </array>
- </object>
- </array>
- <string key="NSFrameSize">{580, 341}</string>
- <reference key="NSNextKeyView" ref="448510093"/>
- </object>
- <string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
- <string key="NSMinSize">{320, 262}</string>
- <string key="NSMaxSize">{1.7976931348623157e+308, 1.7976931348623157e+308}</string>
- <string key="NSFrameAutosaveName">x11_prefs</string>
- </object>
- <object class="NSWindowTemplate" id="604417141">
- <int key="NSWindowStyleMask">11</int>
- <int key="NSWindowBacking">2</int>
- <string key="NSWindowRect">{{302, 440}, {548, 271}}</string>
- <int key="NSWTFlags">1350041600</int>
- <string key="NSWindowTitle">Menu de l’application X11</string>
- <string key="NSWindowClass">NSPanel</string>
- <object class="NSMutableString" key="NSViewClass">
- <characters key="NS.bytes">View</characters>
- </object>
- <nil key="NSUserInterfaceItemIdentifier"/>
- <string key="NSWindowContentMaxSize">{1.7976931348623157e+308, 1.7976931348623157e+308}</string>
- <string key="NSWindowContentMinSize">{320, 240}</string>
- <object class="NSView" key="NSWindowView" id="85544634">
- <nil key="NSNextResponder"/>
- <int key="NSvFlags">256</int>
- <array class="NSMutableArray" key="NSSubviews">
- <object class="NSButton" id="671954382">
- <reference key="NSNextResponder" ref="85544634"/>
- <int key="NSvFlags">265</int>
- <string key="NSFrame">{{372, 191}, {162, 32}}</string>
- <reference key="NSSuperview" ref="85544634"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="143554520">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">137887744</int>
- <string key="NSContents">Dupliquer</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="671954382"/>
- <int key="NSButtonFlags">-2038284033</int>
- <int key="NSButtonFlags2">1</int>
- <object class="NSFont" key="NSAlternateImage" id="549406736">
- <string key="NSName">Helvetica</string>
- <double key="NSSize">13</double>
- <int key="NSfFlags">16</int>
- </object>
- <string key="NSAlternateContents"/>
- <object class="NSMutableString" key="NSKeyEquivalent">
- <characters key="NS.bytes"/>
- </object>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSButton" id="492358940">
- <reference key="NSNextResponder" ref="85544634"/>
- <int key="NSvFlags">265</int>
- <string key="NSFrame">{{372, 159}, {162, 32}}</string>
- <reference key="NSSuperview" ref="85544634"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="8201128">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">137887744</int>
- <string key="NSContents">Supprimer</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="492358940"/>
- <int key="NSButtonFlags">-2038284033</int>
- <int key="NSButtonFlags2">1</int>
- <reference key="NSAlternateImage" ref="549406736"/>
- <string key="NSAlternateContents"/>
- <object class="NSMutableString" key="NSKeyEquivalent">
- <characters key="NS.bytes"/>
- </object>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSScrollView" id="1063387772">
- <reference key="NSNextResponder" ref="85544634"/>
- <int key="NSvFlags">274</int>
- <array class="NSMutableArray" key="NSSubviews">
- <object class="NSClipView" id="580565898">
- <reference key="NSNextResponder" ref="1063387772"/>
- <int key="NSvFlags">2304</int>
- <array class="NSMutableArray" key="NSSubviews">
- <object class="NSTableView" id="905092943">
- <reference key="NSNextResponder" ref="580565898"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrameSize">{333, 198}</string>
- <reference key="NSSuperview" ref="580565898"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTableHeaderView" key="NSHeaderView" id="792419186">
- <reference key="NSNextResponder" ref="672307654"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrameSize">{333, 17}</string>
- <reference key="NSSuperview" ref="672307654"/>
- <reference key="NSTableView" ref="905092943"/>
- </object>
- <object class="_NSCornerView" key="NSCornerView" id="898633680">
- <reference key="NSNextResponder" ref="1063387772"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{334, 0}, {16, 17}}</string>
- <reference key="NSSuperview" ref="1063387772"/>
- </object>
- <array class="NSMutableArray" key="NSTableColumns">
- <object class="NSTableColumn" id="938444323">
- <double key="NSWidth">155</double>
- <double key="NSMinWidth">62.730998992919922</double>
- <double key="NSMaxWidth">1000</double>
- <object class="NSTableHeaderCell" key="NSHeaderCell">
- <int key="NSCellFlags">75628096</int>
- <int key="NSCellFlags2">2048</int>
- <string key="NSContents">Nom</string>
- <reference key="NSSupport" ref="26"/>
- <object class="NSColor" key="NSBackgroundColor" id="113872566">
- <int key="NSColorSpace">3</int>
- <bytes key="NSWhite">MC4zMzMzMzI5ODU2AA</bytes>
- </object>
- <object class="NSColor" key="NSTextColor" id="249576247">
- <int key="NSColorSpace">6</int>
- <string key="NSCatalogName">System</string>
- <string key="NSColorName">headerTextColor</string>
- <reference key="NSColor" ref="214098874"/>
- </object>
- </object>
- <object class="NSTextFieldCell" key="NSDataCell" id="825378892">
- <int key="NSCellFlags">338820672</int>
- <int key="NSCellFlags2">1024</int>
- <string key="NSContents">Text Cell</string>
- <reference key="NSSupport" ref="463863101"/>
- <string key="NSPlaceholderString"/>
- <reference key="NSControlView" ref="905092943"/>
- <object class="NSColor" key="NSBackgroundColor" id="822946413">
- <int key="NSColorSpace">3</int>
- <bytes key="NSWhite">MQA</bytes>
- </object>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- <int key="NSResizingMask">3</int>
- <bool key="NSIsResizeable">YES</bool>
- <bool key="NSIsEditable">YES</bool>
- <reference key="NSTableView" ref="905092943"/>
- <string key="NSHeaderToolTip"/>
- </object>
- <object class="NSTableColumn" id="84282687">
- <double key="NSWidth">100</double>
- <double key="NSMinWidth">40</double>
- <double key="NSMaxWidth">1000</double>
- <object class="NSTableHeaderCell" key="NSHeaderCell">
- <int key="NSCellFlags">75628096</int>
- <int key="NSCellFlags2">2048</int>
- <string key="NSContents">Commande</string>
- <reference key="NSSupport" ref="26"/>
- <reference key="NSBackgroundColor" ref="113872566"/>
- <reference key="NSTextColor" ref="249576247"/>
- </object>
- <object class="NSTextFieldCell" key="NSDataCell" id="432610585">
- <int key="NSCellFlags">338820672</int>
- <int key="NSCellFlags2">1024</int>
- <string key="NSContents">Text Cell</string>
- <reference key="NSSupport" ref="463863101"/>
- <string key="NSPlaceholderString"/>
- <reference key="NSControlView" ref="905092943"/>
- <reference key="NSBackgroundColor" ref="822946413"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- <int key="NSResizingMask">3</int>
- <bool key="NSIsResizeable">YES</bool>
- <bool key="NSIsEditable">YES</bool>
- <reference key="NSTableView" ref="905092943"/>
- <string key="NSHeaderToolTip"/>
- </object>
- <object class="NSTableColumn" id="242608782">
- <double key="NSWidth">69</double>
- <double key="NSMinWidth">10</double>
- <double key="NSMaxWidth">1000</double>
- <object class="NSTableHeaderCell" key="NSHeaderCell">
- <int key="NSCellFlags">75628096</int>
- <int key="NSCellFlags2">2048</int>
- <string key="NSContents">Raccourci</string>
- <reference key="NSSupport" ref="26"/>
- <object class="NSColor" key="NSBackgroundColor">
- <int key="NSColorSpace">6</int>
- <string key="NSCatalogName">System</string>
- <string key="NSColorName">headerColor</string>
- <reference key="NSColor" ref="822946413"/>
- </object>
- <reference key="NSTextColor" ref="249576247"/>
- </object>
- <object class="NSTextFieldCell" key="NSDataCell" id="34714764">
- <int key="NSCellFlags">338820672</int>
- <int key="NSCellFlags2">1024</int>
- <string key="NSContents">Text Cell</string>
- <object class="NSFont" key="NSSupport">
- <string key="NSName">LucidaGrande</string>
- <double key="NSSize">12</double>
- <int key="NSfFlags">16</int>
- </object>
- <string key="NSPlaceholderString"/>
- <reference key="NSControlView" ref="905092943"/>
- <bool key="NSDrawsBackground">YES</bool>
- <object class="NSColor" key="NSBackgroundColor" id="812484075">
- <int key="NSColorSpace">6</int>
- <string key="NSCatalogName">System</string>
- <string key="NSColorName">controlBackgroundColor</string>
- <reference key="NSColor" ref="590688762"/>
- </object>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- <int key="NSResizingMask">3</int>
- <bool key="NSIsResizeable">YES</bool>
- <bool key="NSIsEditable">YES</bool>
- <reference key="NSTableView" ref="905092943"/>
- <string key="NSHeaderToolTip"/>
- </object>
- </array>
- <double key="NSIntercellSpacingWidth">3</double>
- <double key="NSIntercellSpacingHeight">2</double>
- <reference key="NSBackgroundColor" ref="822946413"/>
- <object class="NSColor" key="NSGridColor">
- <int key="NSColorSpace">6</int>
- <string key="NSCatalogName">System</string>
- <string key="NSColorName">gridColor</string>
- <object class="NSColor" key="NSColor">
- <int key="NSColorSpace">3</int>
- <bytes key="NSWhite">MC41AA</bytes>
- </object>
- </object>
- <double key="NSRowHeight">17</double>
- <int key="NSTvFlags">1379958784</int>
- <reference key="NSDelegate"/>
- <reference key="NSDataSource"/>
- <int key="NSColumnAutoresizingStyle">1</int>
- <int key="NSDraggingSourceMaskForLocal">-1</int>
- <int key="NSDraggingSourceMaskForNonLocal">0</int>
- <bool key="NSAllowsTypeSelect">YES</bool>
- <int key="NSTableViewDraggingDestinationStyle">0</int>
- <int key="NSTableViewGroupRowStyle">1</int>
- </object>
- </array>
- <string key="NSFrame">{{1, 17}, {333, 198}}</string>
- <reference key="NSSuperview" ref="1063387772"/>
- <reference key="NSNextKeyView" ref="905092943"/>
- <reference key="NSDocView" ref="905092943"/>
- <reference key="NSBGColor" ref="812484075"/>
- <int key="NScvFlags">4</int>
- </object>
- <object class="NSScroller" id="842897584">
- <reference key="NSNextResponder" ref="1063387772"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{334, 17}, {15, 198}}</string>
- <reference key="NSSuperview" ref="1063387772"/>
- <reference key="NSTarget" ref="1063387772"/>
- <string key="NSAction">_doScroller:</string>
- <double key="NSPercent">0.99492377042770386</double>
- </object>
- <object class="NSScroller" id="17278747">
- <reference key="NSNextResponder" ref="1063387772"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{1, 215}, {333, 15}}</string>
- <reference key="NSSuperview" ref="1063387772"/>
- <int key="NSsFlags">1</int>
- <reference key="NSTarget" ref="1063387772"/>
- <string key="NSAction">_doScroller:</string>
- <double key="NSPercent">0.68852460384368896</double>
- </object>
- <object class="NSClipView" id="672307654">
- <reference key="NSNextResponder" ref="1063387772"/>
- <int key="NSvFlags">2304</int>
- <array class="NSMutableArray" key="NSSubviews">
- <reference ref="792419186"/>
- </array>
- <string key="NSFrame">{{1, 0}, {333, 17}}</string>
- <reference key="NSSuperview" ref="1063387772"/>
- <reference key="NSNextKeyView" ref="792419186"/>
- <reference key="NSDocView" ref="792419186"/>
- <reference key="NSBGColor" ref="812484075"/>
- <int key="NScvFlags">4</int>
- </object>
- <reference ref="898633680"/>
- </array>
- <string key="NSFrame">{{20, 20}, {350, 231}}</string>
- <reference key="NSSuperview" ref="85544634"/>
- <reference key="NSNextKeyView" ref="580565898"/>
- <int key="NSsFlags">133170</int>
- <reference key="NSVScroller" ref="842897584"/>
- <reference key="NSHScroller" ref="17278747"/>
- <reference key="NSContentView" ref="580565898"/>
- <reference key="NSHeaderClipView" ref="672307654"/>
- <bytes key="NSScrollAmts">QSAAAEEgAABBmAAAQZgAAA</bytes>
- </object>
- <object class="NSButton" id="758204686">
- <reference key="NSNextResponder" ref="85544634"/>
- <int key="NSvFlags">265</int>
- <string key="NSFrame">{{372, 223}, {162, 32}}</string>
- <reference key="NSSuperview" ref="85544634"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="1025474039">
- <int key="NSCellFlags">-2080244224</int>
- <int key="NSCellFlags2">137887744</int>
- <string key="NSContents">Ajouter un élément</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="758204686"/>
- <int key="NSButtonFlags">-2038284033</int>
- <int key="NSButtonFlags2">1</int>
- <reference key="NSAlternateImage" ref="549406736"/>
- <string key="NSAlternateContents"/>
- <object class="NSMutableString" key="NSKeyEquivalent">
- <characters key="NS.bytes"/>
- </object>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- </array>
- <string key="NSFrameSize">{548, 271}</string>
- </object>
- <string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
- <string key="NSMinSize">{320, 262}</string>
- <string key="NSMaxSize">{1.7976931348623157e+308, 1.7976931348623157e+308}</string>
- <string key="NSFrameAutosaveName">x11_apps</string>
- </object>
- <object class="NSMenu" id="294137138">
- <string key="NSTitle">Menu</string>
- <array class="NSMutableArray" key="NSMenuItems">
- <object class="NSMenuItem" id="318286212">
- <reference key="NSMenu" ref="294137138"/>
- <bool key="NSIsDisabled">YES</bool>
- <bool key="NSIsSeparator">YES</bool>
- <string key="NSTitle"/>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="511651072">
- <reference key="NSMenu" ref="294137138"/>
- <string key="NSTitle">Applications</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- <string key="NSAction">submenuAction:</string>
- <object class="NSMenu" key="NSSubmenu" id="48278059">
- <string key="NSTitle">Applications</string>
- <array class="NSMutableArray" key="NSMenuItems">
- <object class="NSMenuItem" id="563798000">
- <reference key="NSMenu" ref="48278059"/>
- <bool key="NSIsDisabled">YES</bool>
- <bool key="NSIsSeparator">YES</bool>
- <string key="NSTitle"/>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="1032342329">
- <reference key="NSMenu" ref="48278059"/>
- <string key="NSTitle">Personnaliser…</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- </array>
- </object>
- </object>
- </array>
- <string key="NSName"/>
- </object>
- </array>
- <object class="IBObjectContainer" key="IBDocument.Objects">
- <array class="NSMutableArray" key="connectionRecords">
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">copy:</string>
- <reference key="source" ref="941939442"/>
- <reference key="destination" ref="185296989"/>
- </object>
- <int key="connectionID">181</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">minimize_window:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="677652931"/>
- </object>
- <int key="connectionID">202</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">close_window:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="984461797"/>
- </object>
- <int key="connectionID">205</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">zoom_window:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="1066447520"/>
- </object>
- <int key="connectionID">206</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">bring_to_front:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="276216762"/>
- </object>
- <int key="connectionID">207</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">hideOtherApplications:</string>
- <reference key="source" ref="815810918"/>
- <reference key="destination" ref="206802571"/>
- </object>
- <int key="connectionID">263</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">apps_separator</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="390088328"/>
- </object>
- <int key="connectionID">273</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">apps_table</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="905092943"/>
- </object>
- <int key="connectionID">301</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">apps_table_delete:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="492358940"/>
- </object>
- <int key="connectionID">303</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">apps_table_duplicate:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="671954382"/>
- </object>
- <int key="connectionID">304</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">apps_table_show:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="1065386165"/>
- </object>
- <int key="connectionID">308</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">apps_table_new:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="758204686"/>
- </object>
- <int key="connectionID">311</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_show:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="386173216"/>
- </object>
- <int key="connectionID">318</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">x11_about_item</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="139290918"/>
- </object>
- <int key="connectionID">321</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">enable_auth</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="989050925"/>
- </object>
- <int key="connectionID">387</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">enable_tcp</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="700826966"/>
- </object>
- <int key="connectionID">388</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">depth</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="709074847"/>
- </object>
- <int key="connectionID">389</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">fake_buttons</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="119157981"/>
- </object>
- <int key="connectionID">391</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">sync_keymap</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="179949713"/>
- </object>
- <int key="connectionID">392</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">enable_keyequivs</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="842100515"/>
- </object>
- <int key="connectionID">393</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="119157981"/>
- </object>
- <int key="connectionID">394</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="179949713"/>
- </object>
- <int key="connectionID">395</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="842100515"/>
- </object>
- <int key="connectionID">396</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="709074847"/>
- </object>
- <int key="connectionID">398</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="989050925"/>
- </object>
- <int key="connectionID">399</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="700826966"/>
- </object>
- <int key="connectionID">401</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">prefs_panel</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="124913468"/>
- </object>
- <int key="connectionID">402</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">x11_help:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="504984881"/>
- </object>
- <int key="connectionID">422</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">dockMenu</string>
- <reference key="source" ref="815810918"/>
- <reference key="destination" ref="294137138"/>
- </object>
- <int key="connectionID">426</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">dock_menu</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="294137138"/>
- </object>
- <int key="connectionID">428</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">delegate</string>
- <reference key="source" ref="815810918"/>
- <reference key="destination" ref="485884620"/>
- </object>
- <int key="connectionID">429</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">hide:</string>
- <reference key="source" ref="815810918"/>
- <reference key="destination" ref="301008465"/>
- </object>
- <int key="connectionID">430</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">unhideAllApplications:</string>
- <reference key="source" ref="815810918"/>
- <reference key="destination" ref="1023546148"/>
- </object>
- <int key="connectionID">431</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">orderFrontStandardAboutPanel:</string>
- <reference key="source" ref="815810918"/>
- <reference key="destination" ref="139290918"/>
- </object>
- <int key="connectionID">433</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">dock_apps_menu</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="48278059"/>
- </object>
- <int key="connectionID">530</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">dock_window_separator</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="318286212"/>
- </object>
- <int key="connectionID">531</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">apps_table_show:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="1032342329"/>
- </object>
- <int key="connectionID">534</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">next_window:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="1036389925"/>
- </object>
- <int key="connectionID">539</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">previous_window:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="369641893"/>
- </object>
- <int key="connectionID">540</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">enable_fullscreen</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="477203622"/>
- </object>
- <int key="connectionID">546</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">enable_fullscreen_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="477203622"/>
- </object>
- <int key="connectionID">547</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">toggle_fullscreen:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="6876565"/>
- </object>
- <int key="connectionID">548</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">toggle_fullscreen_item</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="6876565"/>
- </object>
- <int key="connectionID">549</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">menu</string>
- <reference key="source" ref="815810918"/>
- <reference key="destination" ref="524015605"/>
- </object>
- <int key="connectionID">300334</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">terminate:</string>
- <reference key="source" ref="815810918"/>
- <reference key="destination" ref="274138642"/>
- </object>
- <int key="connectionID">300336</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="657659108"/>
- </object>
- <int key="connectionID">300389</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="992839333"/>
- </object>
- <int key="connectionID">300390</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="128352289"/>
- </object>
- <int key="connectionID">300391</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">click_through</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="657659108"/>
- </object>
- <int key="connectionID">300392</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">focus_follows_mouse</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="992839333"/>
- </object>
- <int key="connectionID">300393</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">focus_on_new_window</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="128352289"/>
- </object>
- <int key="connectionID">300394</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">copy_menu_item</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="185296989"/>
- </object>
- <int key="connectionID">300443</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">sync_pasteboard</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="878106058"/>
- </object>
- <int key="connectionID">300444</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">sync_clipboard_to_pasteboard</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="487809555"/>
- </object>
- <int key="connectionID">300461</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">sync_pasteboard_to_clipboard</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="477050998"/>
- </object>
- <int key="connectionID">300462</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">sync_pasteboard_to_primary</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="765780304"/>
- </object>
- <int key="connectionID">300463</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">sync_primary_immediately</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="1002778833"/>
- </object>
- <int key="connectionID">300464</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="878106058"/>
- </object>
- <int key="connectionID">300465</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="487809555"/>
- </object>
- <int key="connectionID">300466</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="477050998"/>
- </object>
- <int key="connectionID">300467</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="765780304"/>
- </object>
- <int key="connectionID">300468</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="1002778833"/>
- </object>
- <int key="connectionID">300469</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">sync_text1</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="620944856"/>
- </object>
- <int key="connectionID">300470</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">sync_text2</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="522511724"/>
- </object>
- <int key="connectionID">300471</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">enable_fullscreen_menu</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="57246850"/>
- </object>
- <int key="connectionID">300474</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="57246850"/>
- </object>
- <int key="connectionID">300475</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="406291430"/>
- </object>
- <int key="connectionID">300480</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">option_sends_alt</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="406291430"/>
- </object>
- <int key="connectionID">300481</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="863505041"/>
- </object>
- <int key="connectionID">300484</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">enable_fullscreen_menu_text</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="331853183"/>
- </object>
- <int key="connectionID">300489</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">scroll_in_device_direction</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="863505041"/>
- </object>
- <int key="connectionID">300490</int>
- </object>
- </array>
- <object class="IBMutableOrderedSet" key="objectRecords">
- <array key="orderedObjects">
- <object class="IBObjectRecord">
- <int key="objectID">0</int>
- <array key="object" id="0"/>
- <reference key="children" ref="904585544"/>
- <nil key="parent"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">-2</int>
- <reference key="object" ref="815810918"/>
- <reference key="parent" ref="0"/>
- <string key="objectName">File's Owner</string>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">-1</int>
- <reference key="object" ref="941939442"/>
- <reference key="parent" ref="0"/>
- <string key="objectName">First Responder</string>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">-3</int>
- <reference key="object" ref="951368722"/>
- <reference key="parent" ref="0"/>
- <string key="objectName">Application</string>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">29</int>
- <reference key="object" ref="524015605"/>
- <array class="NSMutableArray" key="children">
- <reference ref="931553638"/>
- <reference ref="365880285"/>
- <reference ref="200491363"/>
- <reference ref="868031522"/>
- <reference ref="551174276"/>
- </array>
- <reference key="parent" ref="0"/>
- <string key="objectName">MainMenu</string>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">19</int>
- <reference key="object" ref="931553638"/>
- <array class="NSMutableArray" key="children">
- <reference ref="96874957"/>
- </array>
- <reference key="parent" ref="524015605"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">24</int>
- <reference key="object" ref="96874957"/>
- <array class="NSMutableArray" key="children">
- <reference ref="677652931"/>
- <reference ref="276216762"/>
- <reference ref="1066447520"/>
- <reference ref="1036389925"/>
- <reference ref="369641893"/>
- <reference ref="155085383"/>
- <reference ref="984461797"/>
- <reference ref="280172320"/>
- </array>
- <reference key="parent" ref="931553638"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">5</int>
- <reference key="object" ref="276216762"/>
- <reference key="parent" ref="96874957"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">23</int>
- <reference key="object" ref="677652931"/>
- <reference key="parent" ref="96874957"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">92</int>
- <reference key="object" ref="280172320"/>
- <reference key="parent" ref="96874957"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">203</int>
- <reference key="object" ref="984461797"/>
- <reference key="parent" ref="96874957"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">204</int>
- <reference key="object" ref="1066447520"/>
- <reference key="parent" ref="96874957"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">536</int>
- <reference key="object" ref="155085383"/>
- <reference key="parent" ref="96874957"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">537</int>
- <reference key="object" ref="1036389925"/>
- <reference key="parent" ref="96874957"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">538</int>
- <reference key="object" ref="369641893"/>
- <reference key="parent" ref="96874957"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">56</int>
- <reference key="object" ref="365880285"/>
- <array class="NSMutableArray" key="children">
- <reference ref="576521955"/>
- </array>
- <reference key="parent" ref="524015605"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">57</int>
- <reference key="object" ref="576521955"/>
- <array class="NSMutableArray" key="children">
- <reference ref="139290918"/>
- <reference ref="386173216"/>
- <reference ref="32285361"/>
- <reference ref="301008465"/>
- <reference ref="274138642"/>
- <reference ref="272876017"/>
- <reference ref="431301145"/>
- <reference ref="206802571"/>
- <reference ref="848095279"/>
- <reference ref="1023546148"/>
- <reference ref="6876565"/>
- <reference ref="479677589"/>
- </array>
- <reference key="parent" ref="365880285"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">58</int>
- <reference key="object" ref="139290918"/>
- <reference key="parent" ref="576521955"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">129</int>
- <reference key="object" ref="386173216"/>
- <reference key="parent" ref="576521955"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">131</int>
- <reference key="object" ref="32285361"/>
- <array class="NSMutableArray" key="children">
- <reference ref="821388474"/>
- </array>
- <reference key="parent" ref="576521955"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">130</int>
- <reference key="object" ref="821388474"/>
- <reference key="parent" ref="32285361"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">134</int>
- <reference key="object" ref="301008465"/>
- <reference key="parent" ref="576521955"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">136</int>
- <reference key="object" ref="274138642"/>
- <reference key="parent" ref="576521955"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">143</int>
- <reference key="object" ref="272876017"/>
- <reference key="parent" ref="576521955"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">144</int>
- <reference key="object" ref="431301145"/>
- <reference key="parent" ref="576521955"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">145</int>
- <reference key="object" ref="206802571"/>
- <reference key="parent" ref="576521955"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">149</int>
- <reference key="object" ref="848095279"/>
- <reference key="parent" ref="576521955"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">150</int>
- <reference key="object" ref="1023546148"/>
- <reference key="parent" ref="576521955"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">544</int>
- <reference key="object" ref="6876565"/>
- <reference key="parent" ref="576521955"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">545</int>
- <reference key="object" ref="479677589"/>
- <reference key="parent" ref="576521955"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">163</int>
- <reference key="object" ref="200491363"/>
- <array class="NSMutableArray" key="children">
- <reference ref="526778998"/>
- </array>
- <reference key="parent" ref="524015605"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">169</int>
- <reference key="object" ref="526778998"/>
- <array class="NSMutableArray" key="children">
- <reference ref="185296989"/>
- </array>
- <reference key="parent" ref="200491363"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">157</int>
- <reference key="object" ref="185296989"/>
- <reference key="parent" ref="526778998"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">269</int>
- <reference key="object" ref="868031522"/>
- <array class="NSMutableArray" key="children">
- <reference ref="981161348"/>
- </array>
- <reference key="parent" ref="524015605"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">270</int>
- <reference key="object" ref="981161348"/>
- <array class="NSMutableArray" key="children">
- <reference ref="390088328"/>
- <reference ref="1065386165"/>
- </array>
- <reference key="parent" ref="868031522"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">272</int>
- <reference key="object" ref="390088328"/>
- <reference key="parent" ref="981161348"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">305</int>
- <reference key="object" ref="1065386165"/>
- <reference key="parent" ref="981161348"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">419</int>
- <reference key="object" ref="551174276"/>
- <array class="NSMutableArray" key="children">
- <reference ref="511848303"/>
- </array>
- <reference key="parent" ref="524015605"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">420</int>
- <reference key="object" ref="511848303"/>
- <array class="NSMutableArray" key="children">
- <reference ref="504984881"/>
- </array>
- <reference key="parent" ref="551174276"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">421</int>
- <reference key="object" ref="504984881"/>
- <reference key="parent" ref="511848303"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">196</int>
- <reference key="object" ref="485884620"/>
- <reference key="parent" ref="0"/>
- <string key="objectName">X11Controller</string>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">244</int>
- <reference key="object" ref="124913468"/>
- <array class="NSMutableArray" key="children">
- <reference ref="941366957"/>
- </array>
- <reference key="parent" ref="0"/>
- <string key="objectName">PrefsPanel</string>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">245</int>
- <reference key="object" ref="941366957"/>
- <array class="NSMutableArray" key="children">
- <reference ref="448510093"/>
- </array>
- <reference key="parent" ref="124913468"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">348</int>
- <reference key="object" ref="448510093"/>
- <array class="NSMutableArray" key="children">
- <reference ref="287591690"/>
- <reference ref="960678392"/>
- <reference ref="348328898"/>
- <reference ref="10973343"/>
- <reference ref="723450037"/>
- </array>
- <reference key="parent" ref="941366957"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">349</int>
- <reference key="object" ref="287591690"/>
- <array class="NSMutableArray" key="children">
- <reference ref="596750588"/>
- </array>
- <reference key="parent" ref="448510093"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">351</int>
- <reference key="object" ref="596750588"/>
- <array class="NSMutableArray" key="children">
- <reference ref="119157981"/>
- <reference ref="443008216"/>
- <reference ref="282885445"/>
- <reference ref="842100515"/>
- <reference ref="31160162"/>
- <reference ref="179949713"/>
- <reference ref="278155937"/>
- <reference ref="406291430"/>
- <reference ref="863505041"/>
- </array>
- <reference key="parent" ref="287591690"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">363</int>
- <reference key="object" ref="119157981"/>
- <array class="NSMutableArray" key="children">
- <reference ref="990762273"/>
- </array>
- <reference key="parent" ref="596750588"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">364</int>
- <reference key="object" ref="443008216"/>
- <array class="NSMutableArray" key="children">
- <reference ref="391919450"/>
- </array>
- <reference key="parent" ref="596750588"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">365</int>
- <reference key="object" ref="282885445"/>
- <array class="NSMutableArray" key="children">
- <reference ref="649334366"/>
- </array>
- <reference key="parent" ref="596750588"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">368</int>
- <reference key="object" ref="842100515"/>
- <array class="NSMutableArray" key="children">
- <reference ref="940564599"/>
- </array>
- <reference key="parent" ref="596750588"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">369</int>
- <reference key="object" ref="31160162"/>
- <array class="NSMutableArray" key="children">
- <reference ref="666057093"/>
- </array>
- <reference key="parent" ref="596750588"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">370</int>
- <reference key="object" ref="179949713"/>
- <array class="NSMutableArray" key="children">
- <reference ref="967619578"/>
- </array>
- <reference key="parent" ref="596750588"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">352</int>
- <reference key="object" ref="960678392"/>
- <array class="NSMutableArray" key="children">
- <reference ref="515308735"/>
- </array>
- <reference key="parent" ref="448510093"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">350</int>
- <reference key="object" ref="515308735"/>
- <array class="NSMutableArray" key="children">
- <reference ref="709074847"/>
- <reference ref="201731424"/>
- <reference ref="86150604"/>
- <reference ref="477203622"/>
- <reference ref="57246850"/>
- <reference ref="298603383"/>
- <reference ref="331853183"/>
- </array>
- <reference key="parent" ref="960678392"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">382</int>
- <reference key="object" ref="709074847"/>
- <array class="NSMutableArray" key="children">
- <reference ref="633115429"/>
- </array>
- <reference key="parent" ref="515308735"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">385</int>
- <reference key="object" ref="201731424"/>
- <array class="NSMutableArray" key="children">
- <reference ref="930265681"/>
- </array>
- <reference key="parent" ref="515308735"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">386</int>
- <reference key="object" ref="86150604"/>
- <array class="NSMutableArray" key="children">
- <reference ref="311969422"/>
- </array>
- <reference key="parent" ref="515308735"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">541</int>
- <reference key="object" ref="477203622"/>
- <array class="NSMutableArray" key="children">
- <reference ref="631531164"/>
- </array>
- <reference key="parent" ref="515308735"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">543</int>
- <reference key="object" ref="298603383"/>
- <array class="NSMutableArray" key="children">
- <reference ref="761107402"/>
- </array>
- <reference key="parent" ref="515308735"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">353</int>
- <reference key="object" ref="348328898"/>
- <array class="NSMutableArray" key="children">
- <reference ref="300811574"/>
- </array>
- <reference key="parent" ref="448510093"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">354</int>
- <reference key="object" ref="300811574"/>
- <array class="NSMutableArray" key="children">
- <reference ref="989050925"/>
- <reference ref="700826966"/>
- <reference ref="168436707"/>
- <reference ref="363817195"/>
- <reference ref="223835729"/>
- </array>
- <reference key="parent" ref="348328898"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">374</int>
- <reference key="object" ref="989050925"/>
- <array class="NSMutableArray" key="children">
- <reference ref="189594322"/>
- </array>
- <reference key="parent" ref="300811574"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">375</int>
- <reference key="object" ref="700826966"/>
- <array class="NSMutableArray" key="children">
- <reference ref="489340979"/>
- </array>
- <reference key="parent" ref="300811574"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">376</int>
- <reference key="object" ref="168436707"/>
- <array class="NSMutableArray" key="children">
- <reference ref="53243865"/>
- </array>
- <reference key="parent" ref="300811574"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">377</int>
- <reference key="object" ref="363817195"/>
- <array class="NSMutableArray" key="children">
- <reference ref="390084685"/>
- </array>
- <reference key="parent" ref="300811574"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">379</int>
- <reference key="object" ref="223835729"/>
- <array class="NSMutableArray" key="children">
- <reference ref="283628678"/>
- </array>
- <reference key="parent" ref="300811574"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">285</int>
- <reference key="object" ref="604417141"/>
- <array class="NSMutableArray" key="children">
- <reference ref="85544634"/>
- </array>
- <reference key="parent" ref="0"/>
- <string key="objectName">EditPrograms</string>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">286</int>
- <reference key="object" ref="85544634"/>
- <array class="NSMutableArray" key="children">
- <reference ref="1063387772"/>
- <reference ref="758204686"/>
- <reference ref="671954382"/>
- <reference ref="492358940"/>
- </array>
- <reference key="parent" ref="604417141"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">423</int>
- <reference key="object" ref="294137138"/>
- <array class="NSMutableArray" key="children">
- <reference ref="318286212"/>
- <reference ref="511651072"/>
- </array>
- <reference key="parent" ref="0"/>
- <string key="objectName">DockMenu</string>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">524</int>
- <reference key="object" ref="318286212"/>
- <reference key="parent" ref="294137138"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">526</int>
- <reference key="object" ref="511651072"/>
- <array class="NSMutableArray" key="children">
- <reference ref="48278059"/>
- </array>
- <reference key="parent" ref="294137138"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">527</int>
- <reference key="object" ref="48278059"/>
- <array class="NSMutableArray" key="children">
- <reference ref="1032342329"/>
- <reference ref="563798000"/>
- </array>
- <reference key="parent" ref="511651072"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">532</int>
- <reference key="object" ref="1032342329"/>
- <reference key="parent" ref="48278059"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">533</int>
- <reference key="object" ref="563798000"/>
- <reference key="parent" ref="48278059"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100363</int>
- <reference key="object" ref="990762273"/>
- <reference key="parent" ref="119157981"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100364</int>
- <reference key="object" ref="391919450"/>
- <reference key="parent" ref="443008216"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100365</int>
- <reference key="object" ref="649334366"/>
- <reference key="parent" ref="282885445"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100368</int>
- <reference key="object" ref="940564599"/>
- <reference key="parent" ref="842100515"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100369</int>
- <reference key="object" ref="666057093"/>
- <reference key="parent" ref="31160162"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100370</int>
- <reference key="object" ref="967619578"/>
- <reference key="parent" ref="179949713"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100382</int>
- <reference key="object" ref="633115429"/>
- <array class="NSMutableArray" key="children">
- <reference ref="341113515"/>
- </array>
- <reference key="parent" ref="709074847"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100385</int>
- <reference key="object" ref="930265681"/>
- <reference key="parent" ref="201731424"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100386</int>
- <reference key="object" ref="311969422"/>
- <reference key="parent" ref="86150604"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100541</int>
- <reference key="object" ref="631531164"/>
- <reference key="parent" ref="477203622"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100543</int>
- <reference key="object" ref="761107402"/>
- <reference key="parent" ref="298603383"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100374</int>
- <reference key="object" ref="189594322"/>
- <reference key="parent" ref="989050925"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100375</int>
- <reference key="object" ref="489340979"/>
- <reference key="parent" ref="700826966"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100376</int>
- <reference key="object" ref="53243865"/>
- <reference key="parent" ref="168436707"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100377</int>
- <reference key="object" ref="390084685"/>
- <reference key="parent" ref="363817195"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100379</int>
- <reference key="object" ref="283628678"/>
- <reference key="parent" ref="223835729"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">380</int>
- <reference key="object" ref="341113515"/>
- <array class="NSMutableArray" key="children">
- <reference ref="759499526"/>
- <reference ref="616492372"/>
- <reference ref="543935434"/>
- <reference ref="836673018"/>
- </array>
- <reference key="parent" ref="633115429"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">435</int>
- <reference key="object" ref="759499526"/>
- <reference key="parent" ref="341113515"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">384</int>
- <reference key="object" ref="616492372"/>
- <reference key="parent" ref="341113515"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">383</int>
- <reference key="object" ref="543935434"/>
- <reference key="parent" ref="341113515"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">381</int>
- <reference key="object" ref="836673018"/>
- <reference key="parent" ref="341113515"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">295</int>
- <reference key="object" ref="1063387772"/>
- <array class="NSMutableArray" key="children">
- <reference ref="792419186"/>
- <reference ref="17278747"/>
- <reference ref="842897584"/>
- <reference ref="905092943"/>
- </array>
- <reference key="parent" ref="85544634"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300295</int>
- <reference key="object" ref="792419186"/>
- <reference key="parent" ref="1063387772"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">200295</int>
- <reference key="object" ref="17278747"/>
- <reference key="parent" ref="1063387772"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100295</int>
- <reference key="object" ref="842897584"/>
- <reference key="parent" ref="1063387772"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">296</int>
- <reference key="object" ref="905092943"/>
- <array class="NSMutableArray" key="children">
- <reference ref="242608782"/>
- <reference ref="938444323"/>
- <reference ref="84282687"/>
- </array>
- <reference key="parent" ref="1063387772"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">535</int>
- <reference key="object" ref="242608782"/>
- <array class="NSMutableArray" key="children">
- <reference ref="34714764"/>
- </array>
- <reference key="parent" ref="905092943"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">575</int>
- <reference key="object" ref="34714764"/>
- <reference key="parent" ref="242608782"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">298</int>
- <reference key="object" ref="938444323"/>
- <array class="NSMutableArray" key="children">
- <reference ref="825378892"/>
- </array>
- <reference key="parent" ref="905092943"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">573</int>
- <reference key="object" ref="825378892"/>
- <reference key="parent" ref="938444323"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">297</int>
- <reference key="object" ref="84282687"/>
- <array class="NSMutableArray" key="children">
- <reference ref="432610585"/>
- </array>
- <reference key="parent" ref="905092943"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">574</int>
- <reference key="object" ref="432610585"/>
- <reference key="parent" ref="84282687"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">310</int>
- <reference key="object" ref="758204686"/>
- <array class="NSMutableArray" key="children">
- <reference ref="1025474039"/>
- </array>
- <reference key="parent" ref="85544634"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100310</int>
- <reference key="object" ref="1025474039"/>
- <reference key="parent" ref="758204686"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">292</int>
- <reference key="object" ref="671954382"/>
- <array class="NSMutableArray" key="children">
- <reference ref="143554520"/>
- </array>
- <reference key="parent" ref="85544634"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100292</int>
- <reference key="object" ref="143554520"/>
- <reference key="parent" ref="671954382"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">293</int>
- <reference key="object" ref="492358940"/>
- <array class="NSMutableArray" key="children">
- <reference ref="8201128"/>
- </array>
- <reference key="parent" ref="85544634"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100293</int>
- <reference key="object" ref="8201128"/>
- <reference key="parent" ref="492358940"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300337</int>
- <reference key="object" ref="10973343"/>
- <array class="NSMutableArray" key="children">
- <reference ref="184765684"/>
- </array>
- <reference key="parent" ref="448510093"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300338</int>
- <reference key="object" ref="184765684"/>
- <array class="NSMutableArray" key="children">
- <reference ref="657659108"/>
- <reference ref="290578835"/>
- <reference ref="992839333"/>
- <reference ref="138261120"/>
- <reference ref="128352289"/>
- <reference ref="57161931"/>
- </array>
- <reference key="parent" ref="10973343"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300358</int>
- <reference key="object" ref="290578835"/>
- <array class="NSMutableArray" key="children">
- <reference ref="399127858"/>
- </array>
- <reference key="parent" ref="184765684"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300359</int>
- <reference key="object" ref="657659108"/>
- <array class="NSMutableArray" key="children">
- <reference ref="259618205"/>
- </array>
- <reference key="parent" ref="184765684"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300360</int>
- <reference key="object" ref="259618205"/>
- <reference key="parent" ref="657659108"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300361</int>
- <reference key="object" ref="399127858"/>
- <reference key="parent" ref="290578835"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300362</int>
- <reference key="object" ref="992839333"/>
- <array class="NSMutableArray" key="children">
- <reference ref="959555182"/>
- </array>
- <reference key="parent" ref="184765684"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300363</int>
- <reference key="object" ref="959555182"/>
- <reference key="parent" ref="992839333"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300364</int>
- <reference key="object" ref="138261120"/>
- <array class="NSMutableArray" key="children">
- <reference ref="183409141"/>
- </array>
- <reference key="parent" ref="184765684"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300365</int>
- <reference key="object" ref="183409141"/>
- <reference key="parent" ref="138261120"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300368</int>
- <reference key="object" ref="128352289"/>
- <array class="NSMutableArray" key="children">
- <reference ref="556463187"/>
- </array>
- <reference key="parent" ref="184765684"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300369</int>
- <reference key="object" ref="556463187"/>
- <reference key="parent" ref="128352289"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300370</int>
- <reference key="object" ref="57161931"/>
- <array class="NSMutableArray" key="children">
- <reference ref="989804990"/>
- </array>
- <reference key="parent" ref="184765684"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300371</int>
- <reference key="object" ref="989804990"/>
- <reference key="parent" ref="57161931"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300421</int>
- <reference key="object" ref="723450037"/>
- <array class="NSMutableArray" key="children">
- <reference ref="408298283"/>
- </array>
- <reference key="parent" ref="448510093"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300422</int>
- <reference key="object" ref="408298283"/>
- <array class="NSMutableArray" key="children">
- <reference ref="878106058"/>
- <reference ref="386152084"/>
- <reference ref="487809555"/>
- <reference ref="620944856"/>
- <reference ref="477050998"/>
- <reference ref="765780304"/>
- <reference ref="1002778833"/>
- <reference ref="522511724"/>
- </array>
- <reference key="parent" ref="723450037"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300423</int>
- <reference key="object" ref="386152084"/>
- <array class="NSMutableArray" key="children">
- <reference ref="572508492"/>
- </array>
- <reference key="parent" ref="408298283"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300424</int>
- <reference key="object" ref="878106058"/>
- <array class="NSMutableArray" key="children">
- <reference ref="718083688"/>
- </array>
- <reference key="parent" ref="408298283"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300440</int>
- <reference key="object" ref="718083688"/>
- <reference key="parent" ref="878106058"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300441</int>
- <reference key="object" ref="572508492"/>
- <reference key="parent" ref="386152084"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300447</int>
- <reference key="object" ref="477050998"/>
- <array class="NSMutableArray" key="children">
- <reference ref="501304422"/>
- </array>
- <reference key="parent" ref="408298283"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300450</int>
- <reference key="object" ref="501304422"/>
- <reference key="parent" ref="477050998"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300451</int>
- <reference key="object" ref="765780304"/>
- <array class="NSMutableArray" key="children">
- <reference ref="510771323"/>
- </array>
- <reference key="parent" ref="408298283"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300452</int>
- <reference key="object" ref="510771323"/>
- <reference key="parent" ref="765780304"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300453</int>
- <reference key="object" ref="487809555"/>
- <array class="NSMutableArray" key="children">
- <reference ref="619977658"/>
- </array>
- <reference key="parent" ref="408298283"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300454</int>
- <reference key="object" ref="619977658"/>
- <reference key="parent" ref="487809555"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300455</int>
- <reference key="object" ref="620944856"/>
- <array class="NSMutableArray" key="children">
- <reference ref="461823902"/>
- </array>
- <reference key="parent" ref="408298283"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300456</int>
- <reference key="object" ref="461823902"/>
- <reference key="parent" ref="620944856"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300457</int>
- <reference key="object" ref="1002778833"/>
- <array class="NSMutableArray" key="children">
- <reference ref="897099877"/>
- </array>
- <reference key="parent" ref="408298283"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300458</int>
- <reference key="object" ref="897099877"/>
- <reference key="parent" ref="1002778833"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300459</int>
- <reference key="object" ref="522511724"/>
- <array class="NSMutableArray" key="children">
- <reference ref="994587858"/>
- </array>
- <reference key="parent" ref="408298283"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300460</int>
- <reference key="object" ref="994587858"/>
- <reference key="parent" ref="522511724"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300472</int>
- <reference key="object" ref="57246850"/>
- <array class="NSMutableArray" key="children">
- <reference ref="917248662"/>
- </array>
- <reference key="parent" ref="515308735"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300473</int>
- <reference key="object" ref="917248662"/>
- <reference key="parent" ref="57246850"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300476</int>
- <reference key="object" ref="278155937"/>
- <array class="NSMutableArray" key="children">
- <reference ref="617441821"/>
- </array>
- <reference key="parent" ref="596750588"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300477</int>
- <reference key="object" ref="406291430"/>
- <array class="NSMutableArray" key="children">
- <reference ref="67728988"/>
- </array>
- <reference key="parent" ref="596750588"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300478</int>
- <reference key="object" ref="67728988"/>
- <reference key="parent" ref="406291430"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300479</int>
- <reference key="object" ref="617441821"/>
- <reference key="parent" ref="278155937"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300482</int>
- <reference key="object" ref="863505041"/>
- <array class="NSMutableArray" key="children">
- <reference ref="1016286396"/>
- </array>
- <reference key="parent" ref="596750588"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300483</int>
- <reference key="object" ref="1016286396"/>
- <reference key="parent" ref="863505041"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300487</int>
- <reference key="object" ref="331853183"/>
- <array class="NSMutableArray" key="children">
- <reference ref="1042813110"/>
- </array>
- <reference key="parent" ref="515308735"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300488</int>
- <reference key="object" ref="1042813110"/>
- <reference key="parent" ref="331853183"/>
- </object>
- </array>
- </object>
- <dictionary class="NSMutableDictionary" key="flattenedProperties">
- <string key="-3.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="-3.ImportedFromIB2"/>
- <string key="100292.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100293.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100295.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="100295.IBShouldRemoveOnLegacySave"/>
- <string key="100310.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100363.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100364.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100365.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100368.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100369.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100370.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100374.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100375.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100376.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100377.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100379.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100382.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100385.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100386.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100541.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100543.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="129.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="129.ImportedFromIB2"/>
- <string key="130.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="130.ImportedFromIB2"/>
- <string key="131.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="131.ImportedFromIB2"/>
- <string key="134.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="134.ImportedFromIB2"/>
- <string key="136.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="136.ImportedFromIB2"/>
- <string key="143.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="143.ImportedFromIB2"/>
- <string key="144.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="144.ImportedFromIB2"/>
- <string key="145.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="145.ImportedFromIB2"/>
- <string key="149.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="149.ImportedFromIB2"/>
- <string key="150.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="150.ImportedFromIB2"/>
- <string key="157.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="157.ImportedFromIB2"/>
- <string key="163.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="163.ImportedFromIB2"/>
- <string key="169.IBEditorWindowLastContentRect">{{168, 821}, {113, 23}}</string>
- <string key="169.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="169.ImportedFromIB2"/>
- <string key="169.editorWindowContentRectSynchronizationRect">{{202, 626}, {154, 153}}</string>
- <string key="19.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="19.ImportedFromIB2"/>
- <integer value="1" key="196.ImportedFromIB2"/>
- <string key="200295.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="200295.IBShouldRemoveOnLegacySave"/>
- <string key="203.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="203.ImportedFromIB2"/>
- <string key="204.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="204.ImportedFromIB2"/>
- <string key="23.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="23.ImportedFromIB2"/>
- <string key="24.IBEditorWindowLastContentRect">{{349, 868}, {315, 143}}</string>
- <string key="24.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="24.ImportedFromIB2"/>
- <string key="24.editorWindowContentRectSynchronizationRect">{{271, 666}, {301, 153}}</string>
- <string key="244.IBEditorWindowLastContentRect">{{127, 515}, {580, 341}}</string>
- <string key="244.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <boolean value="YES" key="244.IBViewEditorWindowController.showingLayoutRectangles"/>
- <string key="244.IBWindowTemplateEditedContentRect">{{127, 515}, {580, 341}}</string>
- <integer value="1" key="244.ImportedFromIB2"/>
- <string key="244.editorWindowContentRectSynchronizationRect">{{184, 290}, {481, 345}}</string>
- <string key="244.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <boolean value="YES" key="244.windowTemplate.hasMinSize"/>
- <string key="244.windowTemplate.maxSize">{1.7976931348623157e+308, 1.7976931348623157e+308}</string>
- <string key="244.windowTemplate.minSize">{320, 240}</string>
- <string key="245.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="245.ImportedFromIB2"/>
- <string key="245.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="269.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="269.ImportedFromIB2"/>
- <string key="270.IBEditorWindowLastContentRect">{{58, 803}, {155, 33}}</string>
- <string key="270.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="270.ImportedFromIB2"/>
- <string key="270.editorWindowContentRectSynchronizationRect">{{100, 746}, {155, 33}}</string>
- <string key="272.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="272.ImportedFromIB2"/>
- <string key="285.IBEditorWindowLastContentRect">{{68, 585}, {454, 271}}</string>
- <string key="285.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="285.IBViewEditorWindowController.showingBoundsRectangles"/>
- <integer value="1" key="285.IBViewEditorWindowController.showingLayoutRectangles"/>
- <string key="285.IBWindowTemplateEditedContentRect">{{68, 585}, {454, 271}}</string>
- <integer value="1" key="285.ImportedFromIB2"/>
- <string key="285.editorWindowContentRectSynchronizationRect">{{433, 406}, {486, 327}}</string>
- <string key="285.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <boolean value="YES" key="285.windowTemplate.hasMinSize"/>
- <string key="285.windowTemplate.maxSize">{1.7976931348623157e+308, 1.7976931348623157e+308}</string>
- <string key="285.windowTemplate.minSize">{320, 240}</string>
- <string key="286.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="286.ImportedFromIB2"/>
- <string key="29.IBEditorWindowLastContentRect">{{145, 1011}, {336, 20}}</string>
- <string key="29.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="29.ImportedFromIB2"/>
- <string key="29.editorWindowContentRectSynchronizationRect">{{67, 819}, {336, 20}}</string>
- <string key="292.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="292.ImportedFromIB2"/>
- <string key="293.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="293.ImportedFromIB2"/>
- <string key="295.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="295.ImportedFromIB2"/>
- <string key="296.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="296.ImportedFromIB2"/>
- <string key="297.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="297.ImportedFromIB2"/>
- <string key="298.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="298.ImportedFromIB2"/>
- <string key="300295.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300295.IBShouldRemoveOnLegacySave"/>
- <string key="300337.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300337.ImportedFromIB2"/>
- <string key="300338.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300338.ImportedFromIB2"/>
- <string key="300338.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="300358.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300358.ImportedFromIB2"/>
- <string key="300358.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="300359.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300359.ImportedFromIB2"/>
- <string key="300359.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="300360.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300361.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300362.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300362.ImportedFromIB2"/>
- <string key="300362.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="300363.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300364.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300364.ImportedFromIB2"/>
- <string key="300364.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="300365.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300368.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300368.ImportedFromIB2"/>
- <string key="300368.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="300369.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300370.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300370.ImportedFromIB2"/>
- <string key="300370.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="300371.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300421.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300421.ImportedFromIB2"/>
- <string key="300422.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300422.ImportedFromIB2"/>
- <string key="300422.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="300423.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300423.ImportedFromIB2"/>
- <string key="300423.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="300424.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300424.ImportedFromIB2"/>
- <string key="300424.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="300440.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300441.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300447.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300447.ImportedFromIB2"/>
- <string key="300447.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="300450.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300451.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300451.ImportedFromIB2"/>
- <string key="300451.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="300452.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300453.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300453.ImportedFromIB2"/>
- <string key="300453.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="300454.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300455.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300455.ImportedFromIB2"/>
- <string key="300455.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="300456.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300457.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300457.ImportedFromIB2"/>
- <string key="300457.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="300458.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300459.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300459.ImportedFromIB2"/>
- <string key="300459.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="300460.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300472.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300472.ImportedFromIB2"/>
- <string key="300472.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="300473.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300473.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="300476.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300476.ImportedFromIB2"/>
- <string key="300476.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="300477.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300477.ImportedFromIB2"/>
- <string key="300477.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="300478.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300479.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300482.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300482.ImportedFromIB2"/>
- <string key="300482.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="300483.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300483.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="300487.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300487.ImportedFromIB2"/>
- <string key="300487.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="300488.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300488.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="305.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="305.ImportedFromIB2"/>
- <string key="310.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="310.ImportedFromIB2"/>
- <string key="348.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <object class="NSAffineTransform" key="348.IBViewBoundsToFrameTransform">
- <bytes key="NSTransformStruct">P4AAAL+AAABBUAAAw6aAAA</bytes>
- </object>
- <integer value="1" key="348.ImportedFromIB2"/>
- <string key="348.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="349.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="349.ImportedFromIB2"/>
- <string key="350.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="350.ImportedFromIB2"/>
- <string key="350.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="351.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="351.ImportedFromIB2"/>
- <string key="351.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="352.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="352.ImportedFromIB2"/>
- <string key="353.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="353.ImportedFromIB2"/>
- <string key="354.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="354.ImportedFromIB2"/>
- <string key="354.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="363.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="363.ImportedFromIB2"/>
- <string key="363.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="364.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="364.ImportedFromIB2"/>
- <string key="364.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="365.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="365.ImportedFromIB2"/>
- <string key="365.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="368.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="368.ImportedFromIB2"/>
- <string key="368.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="369.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="369.ImportedFromIB2"/>
- <string key="369.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="370.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="370.ImportedFromIB2"/>
- <string key="370.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="374.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="374.ImportedFromIB2"/>
- <string key="374.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="375.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="375.ImportedFromIB2"/>
- <string key="375.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="376.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="376.ImportedFromIB2"/>
- <string key="376.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="377.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="377.ImportedFromIB2"/>
- <string key="377.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="379.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="379.ImportedFromIB2"/>
- <string key="379.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="380.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="380.ImportedFromIB2"/>
- <string key="381.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="381.ImportedFromIB2"/>
- <string key="382.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="382.ImportedFromIB2"/>
- <string key="382.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="383.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="383.ImportedFromIB2"/>
- <string key="384.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="384.ImportedFromIB2"/>
- <string key="385.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="385.ImportedFromIB2"/>
- <string key="385.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="386.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="386.ImportedFromIB2"/>
- <string key="386.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="419.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="419.ImportedFromIB2"/>
- <string key="420.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="420.ImportedFromIB2"/>
- <string key="421.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="421.ImportedFromIB2"/>
- <string key="423.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="423.ImportedFromIB2"/>
- <string key="435.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="435.ImportedFromIB2"/>
- <string key="5.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="5.ImportedFromIB2"/>
- <string key="524.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="524.ImportedFromIB2"/>
- <string key="526.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="526.ImportedFromIB2"/>
- <string key="527.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="527.ImportedFromIB2"/>
- <string key="532.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="532.ImportedFromIB2"/>
- <string key="533.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="533.ImportedFromIB2"/>
- <string key="535.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="535.ImportedFromIB2"/>
- <string key="536.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="536.ImportedFromIB2"/>
- <string key="537.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="537.ImportedFromIB2"/>
- <string key="537.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="538.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="538.ImportedFromIB2"/>
- <string key="541.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="541.ImportedFromIB2"/>
- <string key="541.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="543.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="543.ImportedFromIB2"/>
- <string key="543.object.labelIdentifier">IBBuiltInLabel-Red</string>
- <string key="544.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="544.ImportedFromIB2"/>
- <string key="545.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="545.ImportedFromIB2"/>
- <string key="56.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="56.ImportedFromIB2"/>
- <string key="57.IBEditorWindowLastContentRect">{{20, 641}, {218, 203}}</string>
- <string key="57.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="57.ImportedFromIB2"/>
- <string key="57.editorWindowContentRectSynchronizationRect">{{79, 616}, {218, 203}}</string>
- <string key="573.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="573.ImportedFromIB2"/>
- <string key="574.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="574.ImportedFromIB2"/>
- <string key="575.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="575.ImportedFromIB2"/>
- <string key="58.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="58.ImportedFromIB2"/>
- <string key="92.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="92.ImportedFromIB2"/>
- </dictionary>
- <dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
- <nil key="activeLocalization"/>
- <dictionary class="NSMutableDictionary" key="localizations"/>
- <nil key="sourceID"/>
- <int key="maxID">300490</int>
- </object>
- <object class="IBClassDescriber" key="IBDocument.Classes"/>
- <int key="IBDocument.localizationMode">0</int>
- <string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
- <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencies">
- <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string>
- <integer value="1040" key="NS.object.0"/>
- </object>
- <bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
- <nil key="IBDocument.LastKnownRelativeProjectPath"/>
- <int key="IBDocument.defaultPropertyAccessControl">3</int>
- <dictionary class="NSMutableDictionary" key="IBDocument.LastKnownImageSizes">
- <string key="NSMenuCheckmark">{9, 8}</string>
- <string key="NSMenuMixedState">{7, 2}</string>
- <string key="NSSwitch">{15, 15}</string>
- </dictionary>
- </data>
-</archive>
+<?xml version="1.0" encoding="UTF-8"?>
+<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00">
+ <data>
+ <int key="IBDocument.SystemTarget">1040</int>
+ <string key="IBDocument.SystemVersion">11A289</string>
+ <string key="IBDocument.InterfaceBuilderVersion">900</string>
+ <string key="IBDocument.AppKitVersion">1094.2</string>
+ <string key="IBDocument.HIToolboxVersion">521.00</string>
+ <object class="NSMutableDictionary" key="IBDocument.PluginVersions">
+ <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="NS.object.0">900</string>
+ </object>
+ <array class="NSMutableArray" key="IBDocument.EditedObjectIDs"/>
+ <array key="IBDocument.PluginDependencies">
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ </array>
+ <object class="NSMutableDictionary" key="IBDocument.Metadata">
+ <string key="NS.key.0">PluginDependencyRecalculationVersion</string>
+ <integer value="1" key="NS.object.0"/>
+ </object>
+ <array class="NSMutableArray" key="IBDocument.RootObjects" id="904585544">
+ <object class="NSCustomObject" id="815810918">
+ <object class="NSMutableString" key="NSClassName">
+ <characters key="NS.bytes">NSApplication</characters>
+ </object>
+ </object>
+ <object class="NSCustomObject" id="941939442">
+ <string key="NSClassName">FirstResponder</string>
+ </object>
+ <object class="NSCustomObject" id="951368722">
+ <string key="NSClassName">NSApplication</string>
+ </object>
+ <object class="NSMenu" id="524015605">
+ <string key="NSTitle">MainMenu</string>
+ <array class="NSMutableArray" key="NSMenuItems">
+ <object class="NSMenuItem" id="365880285">
+ <reference key="NSMenu" ref="524015605"/>
+ <string key="NSTitle">X11</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <object class="NSCustomResource" key="NSOnImage" id="531645050">
+ <string key="NSClassName">NSImage</string>
+ <string key="NSResourceName">NSMenuCheckmark</string>
+ </object>
+ <object class="NSCustomResource" key="NSMixedImage" id="351811234">
+ <string key="NSClassName">NSImage</string>
+ <string key="NSResourceName">NSMenuMixedState</string>
+ </object>
+ <string key="NSAction">submenuAction:</string>
+ <object class="NSMenu" key="NSSubmenu" id="576521955">
+ <string key="NSTitle">X11</string>
+ <array class="NSMutableArray" key="NSMenuItems">
+ <object class="NSMenuItem" id="139290918">
+ <reference key="NSMenu" ref="576521955"/>
+ <string key="NSTitle">À propos d’X11</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="386173216">
+ <reference key="NSMenu" ref="576521955"/>
+ <string key="NSTitle">Préférences…</string>
+ <string key="NSKeyEquiv">,</string>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="272876017">
+ <reference key="NSMenu" ref="576521955"/>
+ <bool key="NSIsDisabled">YES</bool>
+ <bool key="NSIsSeparator">YES</bool>
+ <string key="NSTitle"/>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="32285361">
+ <reference key="NSMenu" ref="576521955"/>
+ <string key="NSTitle">Services</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ <string key="NSAction">submenuAction:</string>
+ <object class="NSMenu" key="NSSubmenu" id="821388474">
+ <object class="NSMutableString" key="NSTitle">
+ <characters key="NS.bytes">Services</characters>
+ </object>
+ <array class="NSMutableArray" key="NSMenuItems"/>
+ <string key="NSName">_NSServicesMenu</string>
+ </object>
+ </object>
+ <object class="NSMenuItem" id="431301145">
+ <reference key="NSMenu" ref="576521955"/>
+ <bool key="NSIsDisabled">YES</bool>
+ <bool key="NSIsSeparator">YES</bool>
+ <string key="NSTitle"/>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="6876565">
+ <reference key="NSMenu" ref="576521955"/>
+ <string key="NSTitle">Basculer en mode plein écran</string>
+ <string key="NSKeyEquiv">a</string>
+ <int key="NSKeyEquivModMask">1572864</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="479677589">
+ <reference key="NSMenu" ref="576521955"/>
+ <bool key="NSIsDisabled">YES</bool>
+ <bool key="NSIsSeparator">YES</bool>
+ <string key="NSTitle"/>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="301008465">
+ <reference key="NSMenu" ref="576521955"/>
+ <string key="NSTitle">Masquer X11</string>
+ <string key="NSKeyEquiv">h</string>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ <int key="NSTag">42</int>
+ </object>
+ <object class="NSMenuItem" id="206802571">
+ <reference key="NSMenu" ref="576521955"/>
+ <string key="NSTitle">Masquer les autres</string>
+ <string key="NSKeyEquiv">h</string>
+ <int key="NSKeyEquivModMask">1572864</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="1023546148">
+ <reference key="NSMenu" ref="576521955"/>
+ <string key="NSTitle">Tout afficher</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ <int key="NSTag">42</int>
+ </object>
+ <object class="NSMenuItem" id="848095279">
+ <reference key="NSMenu" ref="576521955"/>
+ <bool key="NSIsDisabled">YES</bool>
+ <bool key="NSIsSeparator">YES</bool>
+ <string key="NSTitle"/>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="274138642">
+ <reference key="NSMenu" ref="576521955"/>
+ <string key="NSTitle">Quitter X11</string>
+ <string key="NSKeyEquiv">q</string>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ </array>
+ <string key="NSName">_NSAppleMenu</string>
+ </object>
+ </object>
+ <object class="NSMenuItem" id="868031522">
+ <reference key="NSMenu" ref="524015605"/>
+ <string key="NSTitle">Applications</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ <string key="NSAction">submenuAction:</string>
+ <object class="NSMenu" key="NSSubmenu" id="981161348">
+ <string key="NSTitle">Applications</string>
+ <array class="NSMutableArray" key="NSMenuItems">
+ <object class="NSMenuItem" id="390088328">
+ <reference key="NSMenu" ref="981161348"/>
+ <bool key="NSIsDisabled">YES</bool>
+ <bool key="NSIsSeparator">YES</bool>
+ <string key="NSTitle"/>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="1065386165">
+ <reference key="NSMenu" ref="981161348"/>
+ <string key="NSTitle">Personnaliser…</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ </array>
+ </object>
+ </object>
+ <object class="NSMenuItem" id="200491363">
+ <reference key="NSMenu" ref="524015605"/>
+ <string key="NSTitle">Édition</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ <string key="NSAction">submenuAction:</string>
+ <object class="NSMenu" key="NSSubmenu" id="526778998">
+ <string key="NSTitle">Édition</string>
+ <array class="NSMutableArray" key="NSMenuItems">
+ <object class="NSMenuItem" id="185296989">
+ <reference key="NSMenu" ref="526778998"/>
+ <string key="NSTitle">Copier</string>
+ <string key="NSKeyEquiv">c</string>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ </array>
+ </object>
+ </object>
+ <object class="NSMenuItem" id="931553638">
+ <reference key="NSMenu" ref="524015605"/>
+ <string key="NSTitle">Fenêtre</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ <string key="NSAction">submenuAction:</string>
+ <object class="NSMenu" key="NSSubmenu" id="96874957">
+ <string key="NSTitle">Fenêtre</string>
+ <array class="NSMutableArray" key="NSMenuItems">
+ <object class="NSMenuItem" id="984461797">
+ <reference key="NSMenu" ref="96874957"/>
+ <string key="NSTitle">Fermer</string>
+ <string key="NSKeyEquiv">w</string>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="677652931">
+ <reference key="NSMenu" ref="96874957"/>
+ <string key="NSTitle">Placer dans le Dock</string>
+ <string key="NSKeyEquiv">m</string>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="1066447520">
+ <reference key="NSMenu" ref="96874957"/>
+ <string key="NSTitle">Réduire/agrandir</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="280172320">
+ <reference key="NSMenu" ref="96874957"/>
+ <bool key="NSIsDisabled">YES</bool>
+ <bool key="NSIsSeparator">YES</bool>
+ <string key="NSTitle"/>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="1036389925">
+ <reference key="NSMenu" ref="96874957"/>
+ <string key="NSTitle">Faire défiler les fenêtres</string>
+ <string key="NSKeyEquiv">`</string>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="369641893">
+ <reference key="NSMenu" ref="96874957"/>
+ <string key="NSTitle">Faire défiler les fenêtres en sens inverse</string>
+ <string key="NSKeyEquiv">`</string>
+ <int key="NSKeyEquivModMask">1179648</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="155085383">
+ <reference key="NSMenu" ref="96874957"/>
+ <bool key="NSIsDisabled">YES</bool>
+ <bool key="NSIsSeparator">YES</bool>
+ <string key="NSTitle"/>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="276216762">
+ <reference key="NSMenu" ref="96874957"/>
+ <string key="NSTitle">Tout ramener au premier plan</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ </array>
+ <string key="NSName">_NSWindowsMenu</string>
+ </object>
+ </object>
+ <object class="NSMenuItem" id="551174276">
+ <reference key="NSMenu" ref="524015605"/>
+ <string key="NSTitle">Aide</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ <string key="NSAction">submenuAction:</string>
+ <object class="NSMenu" key="NSSubmenu" id="511848303">
+ <string key="NSTitle">Aide</string>
+ <array class="NSMutableArray" key="NSMenuItems">
+ <object class="NSMenuItem" id="504984881">
+ <reference key="NSMenu" ref="511848303"/>
+ <string key="NSTitle">Aide X11</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ </array>
+ </object>
+ </object>
+ </array>
+ <string key="NSName">_NSMainMenu</string>
+ </object>
+ <object class="NSCustomObject" id="485884620">
+ <string key="NSClassName">X11Controller</string>
+ </object>
+ <object class="NSWindowTemplate" id="124913468">
+ <int key="NSWindowStyleMask">3</int>
+ <int key="NSWindowBacking">2</int>
+ <string key="NSWindowRect">{{414, 417.03906000000001}, {580, 341}}</string>
+ <int key="NSWTFlags">1350041600</int>
+ <string key="NSWindowTitle">Préférences d’X11</string>
+ <string key="NSWindowClass">NSPanel</string>
+ <object class="NSMutableString" key="NSViewClass">
+ <characters key="NS.bytes">View</characters>
+ </object>
+ <nil key="NSUserInterfaceItemIdentifier"/>
+ <string key="NSWindowContentMaxSize">{1.7976931348623157e+308, 1.7976931348623157e+308}</string>
+ <string key="NSWindowContentMinSize">{320, 240}</string>
+ <object class="NSView" key="NSWindowView" id="941366957">
+ <nil key="NSNextResponder"/>
+ <int key="NSvFlags">256</int>
+ <array class="NSMutableArray" key="NSSubviews">
+ <object class="NSTabView" id="448510093">
+ <reference key="NSNextResponder" ref="941366957"/>
+ <int key="NSvFlags">274</int>
+ <string key="NSFrame">{{13, 10}, {554, 325}}</string>
+ <reference key="NSSuperview" ref="941366957"/>
+ <array class="NSMutableArray" key="NSTabViewItems">
+ <object class="NSTabViewItem" id="287591690">
+ <object class="NSMutableString" key="NSIdentifier">
+ <characters key="NS.bytes">1</characters>
+ </object>
+ <object class="NSView" key="NSView" id="596750588">
+ <reference key="NSNextResponder" ref="448510093"/>
+ <int key="NSvFlags">256</int>
+ <array class="NSMutableArray" key="NSSubviews">
+ <object class="NSButton" id="119157981">
+ <reference key="NSNextResponder" ref="596750588"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{18, 243}, {402, 18}}</string>
+ <reference key="NSSuperview" ref="596750588"/>
+ <reference key="NSNextKeyView" ref="179949713"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="990762273">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">Émuler une souris à trois boutons</string>
+ <object class="NSFont" key="NSSupport" id="463863101">
+ <string key="NSName">LucidaGrande</string>
+ <double key="NSSize">13</double>
+ <int key="NSfFlags">1044</int>
+ </object>
+ <reference key="NSControlView" ref="119157981"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <object class="NSCustomResource" key="NSNormalImage" id="967651788">
+ <string key="NSClassName">NSImage</string>
+ <string key="NSResourceName">NSSwitch</string>
+ </object>
+ <object class="NSButtonImageSource" key="NSAlternateImage" id="391434389">
+ <string key="NSImageName">NSSwitch</string>
+ </object>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSTextField" id="443008216">
+ <reference key="NSNextResponder" ref="596750588"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{36, 82}, {484, 42}}</string>
+ <reference key="NSSuperview" ref="596750588"/>
+ <reference key="NSNextKeyView" ref="406291430"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="391919450">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">Quand cette option est activée, les touches équivalentes de la barre des menus peuvent perturber les applications X11 qui utilisent le modificateur d’instructions virtuelles.</string>
+ <object class="NSFont" key="NSSupport" id="26">
+ <string key="NSName">LucidaGrande</string>
+ <double key="NSSize">11</double>
+ <int key="NSfFlags">3100</int>
+ </object>
+ <string key="NSPlaceholderString"/>
+ <reference key="NSControlView" ref="443008216"/>
+ <object class="NSColor" key="NSBackgroundColor" id="57160303">
+ <int key="NSColorSpace">6</int>
+ <string key="NSCatalogName">System</string>
+ <string key="NSColorName">controlColor</string>
+ <object class="NSColor" key="NSColor" id="590688762">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes>
+ </object>
+ </object>
+ <object class="NSColor" key="NSTextColor" id="930815747">
+ <int key="NSColorSpace">6</int>
+ <string key="NSCatalogName">System</string>
+ <string key="NSColorName">controlTextColor</string>
+ <object class="NSColor" key="NSColor" id="214098874">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MAA</bytes>
+ </object>
+ </object>
+ </object>
+ </object>
+ <object class="NSTextField" id="282885445">
+ <reference key="NSNextResponder" ref="596750588"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{36, 203}, {484, 34}}</string>
+ <reference key="NSSuperview" ref="596750588"/>
+ <reference key="NSNextKeyView" ref="31160162"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="649334366">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string type="base64-UTF8" key="NSContents">TWFpbnRlbmV6IGxhIHRvdWNoZSBPcHRpb24gb3UgQ29tbWFuZGUgZW5mb25jw6llIHRvdXQgZW4gY2xp
+cXVhbnQgcG91ciBhY3RpdmVyIGxlIGJvdXRvbiBkcm9pdCBvdSBjZW50cmFsIGRlIGxhIHNvdXJpcy4K
+A</string>
+ <reference key="NSSupport" ref="26"/>
+ <string key="NSPlaceholderString"/>
+ <reference key="NSControlView" ref="282885445"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ <object class="NSButton" id="842100515">
+ <reference key="NSNextResponder" ref="596750588"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{18, 130}, {402, 18}}</string>
+ <reference key="NSSuperview" ref="596750588"/>
+ <reference key="NSNextKeyView" ref="443008216"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="940564599">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">Activer les touches équivalentes sous X11</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="842100515"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="967651788"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSTextField" id="31160162">
+ <reference key="NSNextResponder" ref="596750588"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{36, 144}, {484, 29}}</string>
+ <reference key="NSSuperview" ref="596750588"/>
+ <reference key="NSNextKeyView" ref="842100515"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="666057093">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">Autorise les modifications du menu d’entrée pour remplacer la disposition des touches du clavier X11.</string>
+ <reference key="NSSupport" ref="26"/>
+ <string key="NSPlaceholderString"/>
+ <reference key="NSControlView" ref="31160162"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ <object class="NSButton" id="179949713">
+ <reference key="NSNextResponder" ref="596750588"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{18, 179}, {402, 18}}</string>
+ <reference key="NSSuperview" ref="596750588"/>
+ <reference key="NSNextKeyView" ref="282885445"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="967619578">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">Utiliser la disposition des touches du clavier du système</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="179949713"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="967651788"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSTextField" id="278155937">
+ <reference key="NSNextResponder" ref="596750588"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{36, 35}, {484, 28}}</string>
+ <reference key="NSSuperview" ref="596750588"/>
+ <reference key="NSNextKeyView" ref="863505041"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="617441821">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">Une fois activées, les touches option envoient les symboles Alt_L et Alt_R au lieu de Mode_switch.</string>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSControlView" ref="278155937"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ <object class="NSButton" id="406291430">
+ <reference key="NSNextResponder" ref="596750588"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{18, 69}, {402, 18}}</string>
+ <reference key="NSSuperview" ref="596750588"/>
+ <reference key="NSNextKeyView" ref="278155937"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="67728988">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">Les touches option envoient Alt_L et Alt_R</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="406291430"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="967651788"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSButton" id="863505041">
+ <reference key="NSNextResponder" ref="596750588"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{18, 8}, {418, 18}}</string>
+ <reference key="NSSuperview" ref="596750588"/>
+ <reference key="NSNextKeyView" ref="448510093"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="1016286396">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">Faire toujours défiler dans le sens du mouvement des doigts</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="863505041"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="967651788"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ </array>
+ <string key="NSFrame">{{10, 33}, {534, 279}}</string>
+ <reference key="NSSuperview" ref="448510093"/>
+ <reference key="NSNextKeyView" ref="119157981"/>
+ </object>
+ <string key="NSLabel">Entrée</string>
+ <reference key="NSColor" ref="57160303"/>
+ <reference key="NSTabView" ref="448510093"/>
+ </object>
+ <object class="NSTabViewItem" id="960678392">
+ <object class="NSMutableString" key="NSIdentifier">
+ <characters key="NS.bytes">2</characters>
+ </object>
+ <object class="NSView" key="NSView" id="515308735">
+ <nil key="NSNextResponder"/>
+ <int key="NSvFlags">256</int>
+ <array class="NSMutableArray" key="NSSubviews">
+ <object class="NSPopUpButton" id="709074847">
+ <reference key="NSNextResponder" ref="515308735"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{90, 234}, {128, 26}}</string>
+ <reference key="NSSuperview" ref="515308735"/>
+ <reference key="NSNextKeyView" ref="86150604"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSPopUpButtonCell" key="NSCell" id="633115429">
+ <int key="NSCellFlags">-2076049856</int>
+ <int key="NSCellFlags2">1024</int>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="709074847"/>
+ <int key="NSButtonFlags">109199615</int>
+ <int key="NSButtonFlags2">1</int>
+ <object class="NSFont" key="NSAlternateImage">
+ <string key="NSName">LucidaGrande</string>
+ <double key="NSSize">13</double>
+ <int key="NSfFlags">16</int>
+ </object>
+ <string key="NSAlternateContents"/>
+ <object class="NSMutableString" key="NSKeyEquivalent">
+ <characters key="NS.bytes"/>
+ </object>
+ <int key="NSPeriodicDelay">400</int>
+ <int key="NSPeriodicInterval">75</int>
+ <object class="NSMenuItem" key="NSMenuItem" id="616492372">
+ <reference key="NSMenu" ref="341113515"/>
+ <string key="NSTitle">du moniteur</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <int key="NSState">1</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ <string key="NSAction">_popUpItemAction:</string>
+ <int key="NSTag">-1</int>
+ <reference key="NSTarget" ref="633115429"/>
+ </object>
+ <bool key="NSMenuItemRespectAlignment">YES</bool>
+ <object class="NSMenu" key="NSMenu" id="341113515">
+ <object class="NSMutableString" key="NSTitle">
+ <characters key="NS.bytes">OtherViews</characters>
+ </object>
+ <array class="NSMutableArray" key="NSMenuItems">
+ <reference ref="616492372"/>
+ <object class="NSMenuItem" id="759499526">
+ <reference key="NSMenu" ref="341113515"/>
+ <string key="NSTitle">256 couleurs</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ <string key="NSAction">_popUpItemAction:</string>
+ <int key="NSTag">8</int>
+ <reference key="NSTarget" ref="633115429"/>
+ </object>
+ <object class="NSMenuItem" id="543935434">
+ <reference key="NSMenu" ref="341113515"/>
+ <string key="NSTitle">milliers</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ <string key="NSAction">_popUpItemAction:</string>
+ <int key="NSTag">15</int>
+ <reference key="NSTarget" ref="633115429"/>
+ </object>
+ <object class="NSMenuItem" id="836673018">
+ <reference key="NSMenu" ref="341113515"/>
+ <string key="NSTitle">millions</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ <string key="NSAction">_popUpItemAction:</string>
+ <int key="NSTag">24</int>
+ <reference key="NSTarget" ref="633115429"/>
+ </object>
+ </array>
+ </object>
+ <int key="NSPreferredEdge">3</int>
+ <bool key="NSUsesItemFromMenu">YES</bool>
+ <bool key="NSAltersState">YES</bool>
+ <int key="NSArrowPosition">1</int>
+ </object>
+ </object>
+ <object class="NSTextField" id="201731424">
+ <reference key="NSNextResponder" ref="515308735"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{17, 238}, {71, 20}}</string>
+ <reference key="NSSuperview" ref="515308735"/>
+ <reference key="NSNextKeyView" ref="709074847"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="930265681">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">Couleurs :</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <string key="NSPlaceholderString"/>
+ <reference key="NSControlView" ref="201731424"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ <object class="NSTextField" id="86150604">
+ <reference key="NSNextResponder" ref="515308735"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{36, 216}, {392, 14}}</string>
+ <reference key="NSSuperview" ref="515308735"/>
+ <reference key="NSNextKeyView" ref="477203622"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="311969422">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">Cette option prend effet au prochain lancement d’X11.</string>
+ <reference key="NSSupport" ref="26"/>
+ <string key="NSPlaceholderString"/>
+ <reference key="NSControlView" ref="86150604"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ <object class="NSButton" id="477203622">
+ <reference key="NSNextResponder" ref="515308735"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{18, 182}, {409, 23}}</string>
+ <reference key="NSSuperview" ref="515308735"/>
+ <reference key="NSNextKeyView" ref="298603383"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="631531164">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">Mode plein écran</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="477203622"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="967651788"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSButton" id="57246850">
+ <reference key="NSNextResponder" ref="515308735"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{37, 116}, {468, 18}}</string>
+ <reference key="NSSuperview" ref="515308735"/>
+ <reference key="NSNextKeyView" ref="331853183"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="917248662">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">Autoriser un accès à la barre des menus en mode plein écran</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="57246850"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="967651788"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSTextField" id="298603383">
+ <reference key="NSNextResponder" ref="515308735"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{36, 145}, {484, 31}}</string>
+ <reference key="NSSuperview" ref="515308735"/>
+ <reference key="NSNextKeyView" ref="57246850"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="761107402">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">Active la fenêtre root X11. Utilisez le raccourci clavier Commande + Option + A pour ouvrir et fermer le mode plein écran.</string>
+ <reference key="NSSupport" ref="26"/>
+ <string key="NSPlaceholderString"/>
+ <reference key="NSControlView" ref="298603383"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ <object class="NSTextField" id="331853183">
+ <reference key="NSNextResponder" ref="515308735"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{54, 79}, {466, 31}}</string>
+ <reference key="NSSuperview" ref="515308735"/>
+ <reference key="NSNextKeyView" ref="448510093"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="1042813110">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">La barre des menus sera visible lorsque le curseur de souris est placé en haut de votre affichage principal.</string>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSControlView" ref="331853183"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ </array>
+ <string key="NSFrame">{{10, 33}, {534, 279}}</string>
+ <reference key="NSNextKeyView" ref="201731424"/>
+ </object>
+ <string key="NSLabel">Sortie</string>
+ <reference key="NSColor" ref="57160303"/>
+ <reference key="NSTabView" ref="448510093"/>
+ </object>
+ <object class="NSTabViewItem" id="723450037">
+ <object class="NSMutableString" key="NSIdentifier">
+ <characters key="NS.bytes">2</characters>
+ </object>
+ <object class="NSView" key="NSView" id="408298283">
+ <nil key="NSNextResponder"/>
+ <int key="NSvFlags">256</int>
+ <array class="NSMutableArray" key="NSSubviews">
+ <object class="NSButton" id="878106058">
+ <reference key="NSNextResponder" ref="408298283"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{18, 255}, {409, 23}}</string>
+ <reference key="NSSuperview" ref="408298283"/>
+ <reference key="NSNextKeyView" ref="386152084"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="718083688">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">Activer la synchronisation</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="878106058"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="967651788"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSTextField" id="386152084">
+ <reference key="NSNextResponder" ref="408298283"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{36, 207}, {494, 42}}</string>
+ <reference key="NSSuperview" ref="408298283"/>
+ <reference key="NSNextKeyView" ref="487809555"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="572508492">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">Active la commande de menu « Copier » et permet la synchronisation entre le presse-papiers de OSX, celui de X11 (CLIPBOARD) et les mémoires tampons principales (PRIMARY).</string>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSControlView" ref="386152084"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ <object class="NSButton" id="477050998">
+ <reference key="NSNextResponder" ref="408298283"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{34, 129}, {458, 18}}</string>
+ <reference key="NSSuperview" ref="408298283"/>
+ <reference key="NSNextKeyView" ref="765780304"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="501304422">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">Mettre à jour CLIPBOARD lorsque le presse-papiers est modifié</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="477050998"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="967651788"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSButton" id="765780304">
+ <reference key="NSNextResponder" ref="408298283"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{34, 104}, {495, 18}}</string>
+ <reference key="NSSuperview" ref="408298283"/>
+ <reference key="NSNextKeyView" ref="1002778833"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="510771323">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">Mettre à jour PRIMARY (clic central) lorsque le presse-papiers est modifié</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="765780304"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="967651788"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSButton" id="1002778833">
+ <reference key="NSNextResponder" ref="408298283"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{34, 79}, {437, 18}}</string>
+ <reference key="NSSuperview" ref="408298283"/>
+ <reference key="NSNextKeyView" ref="522511724"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="897099877">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">Mettre à jour le presse-papiers dès la sélection de nouveau texte</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="1002778833"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="967651788"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSButton" id="487809555">
+ <reference key="NSNextResponder" ref="408298283"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{34, 192}, {474, 18}}</string>
+ <reference key="NSSuperview" ref="408298283"/>
+ <reference key="NSNextKeyView" ref="620944856"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="619977658">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">Mettre à jour le presse-papiers lorsque CLIPBOARD est modifié</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="487809555"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="967651788"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSTextField" id="620944856">
+ <reference key="NSNextResponder" ref="408298283"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{48, 158}, {482, 28}}</string>
+ <reference key="NSSuperview" ref="408298283"/>
+ <reference key="NSNextKeyView" ref="477050998"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="461823902">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">Désactivez cette option si vous voulez utiliser xclipboard, klipper, ou tout autre gestionnaire de presse-papiers X11.</string>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSControlView" ref="620944856"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ <object class="NSTextField" id="522511724">
+ <reference key="NSNextResponder" ref="408298283"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{48, 47}, {482, 28}}</string>
+ <reference key="NSSuperview" ref="408298283"/>
+ <reference key="NSNextKeyView" ref="448510093"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="994587858">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">En raison de limitations du protocole X11, cette option ne fonctionnera pas toujours dans certaines applications.</string>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSControlView" ref="522511724"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ </array>
+ <string key="NSFrame">{{10, 33}, {534, 279}}</string>
+ <reference key="NSNextKeyView" ref="878106058"/>
+ </object>
+ <string key="NSLabel">Presse-papiers</string>
+ <reference key="NSColor" ref="57160303"/>
+ <reference key="NSTabView" ref="448510093"/>
+ </object>
+ <object class="NSTabViewItem" id="10973343">
+ <object class="NSMutableString" key="NSIdentifier">
+ <characters key="NS.bytes">2</characters>
+ </object>
+ <object class="NSView" key="NSView" id="184765684">
+ <nil key="NSNextResponder"/>
+ <int key="NSvFlags">256</int>
+ <array class="NSMutableArray" key="NSSubviews">
+ <object class="NSButton" id="657659108">
+ <reference key="NSNextResponder" ref="184765684"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{15, 245}, {402, 18}}</string>
+ <reference key="NSSuperview" ref="184765684"/>
+ <reference key="NSNextKeyView" ref="290578835"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="259618205">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">Activation des fenêtres inactives en un clic</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="657659108"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="967651788"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSTextField" id="290578835">
+ <reference key="NSNextResponder" ref="184765684"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{23, 208}, {505, 31}}</string>
+ <reference key="NSSuperview" ref="184765684"/>
+ <reference key="NSNextKeyView" ref="992839333"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="399127858">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">En cas d’activation de cette option, si vous cliquez sur une fenêtre inactive, celle-ci deviendra active et le clic sera effectif.</string>
+ <reference key="NSSupport" ref="26"/>
+ <string key="NSPlaceholderString"/>
+ <reference key="NSControlView" ref="290578835"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ <object class="NSButton" id="992839333">
+ <reference key="NSNextResponder" ref="184765684"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{15, 184}, {402, 18}}</string>
+ <reference key="NSSuperview" ref="184765684"/>
+ <reference key="NSNextKeyView" ref="138261120"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="959555182">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">Activation des fenêtres survolées par la souris</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="992839333"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="967651788"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSTextField" id="138261120">
+ <reference key="NSNextResponder" ref="184765684"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{23, 150}, {505, 28}}</string>
+ <reference key="NSSuperview" ref="184765684"/>
+ <reference key="NSNextKeyView" ref="128352289"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="183409141">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">L’activation des fenêtres X11 suit le curseur. Ceci comporte des effets adverses.</string>
+ <reference key="NSSupport" ref="26"/>
+ <string key="NSPlaceholderString"/>
+ <reference key="NSControlView" ref="138261120"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ <object class="NSButton" id="128352289">
+ <reference key="NSNextResponder" ref="184765684"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{15, 140}, {402, 18}}</string>
+ <reference key="NSSuperview" ref="184765684"/>
+ <reference key="NSNextKeyView" ref="57161931"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="556463187">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">Activation des nouvelles fenêtres</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="128352289"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="967651788"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSTextField" id="57161931">
+ <reference key="NSNextResponder" ref="184765684"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{23, 92}, {505, 42}}</string>
+ <reference key="NSSuperview" ref="184765684"/>
+ <reference key="NSNextKeyView" ref="448510093"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="989804990">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">Lorsque cette option est activée, la création d’une nouvelle fenêtre X11 fait passer X11.app au premier plan (au lieu de Finder.app, Terminal.app, etc.)</string>
+ <reference key="NSSupport" ref="26"/>
+ <string key="NSPlaceholderString"/>
+ <reference key="NSControlView" ref="57161931"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ </array>
+ <string key="NSFrame">{{10, 33}, {534, 279}}</string>
+ <reference key="NSNextKeyView" ref="657659108"/>
+ </object>
+ <string key="NSLabel">Fenêtres</string>
+ <reference key="NSColor" ref="57160303"/>
+ <reference key="NSTabView" ref="448510093"/>
+ </object>
+ <object class="NSTabViewItem" id="348328898">
+ <object class="NSView" key="NSView" id="300811574">
+ <nil key="NSNextResponder"/>
+ <int key="NSvFlags">256</int>
+ <array class="NSMutableArray" key="NSSubviews">
+ <object class="NSButton" id="989050925">
+ <reference key="NSNextResponder" ref="300811574"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{18, 243}, {402, 18}}</string>
+ <reference key="NSSuperview" ref="300811574"/>
+ <reference key="NSNextKeyView" ref="168436707"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="189594322">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">Authentifier les connexions</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="989050925"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="967651788"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSButton" id="700826966">
+ <reference key="NSNextResponder" ref="300811574"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{18, 166}, {402, 18}}</string>
+ <reference key="NSSuperview" ref="300811574"/>
+ <reference key="NSNextKeyView" ref="363817195"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="489340979">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">Autoriser les connexions de clients réseau</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="700826966"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="967651788"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSTextField" id="168436707">
+ <reference key="NSNextResponder" ref="300811574"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{36, 195}, {484, 42}}</string>
+ <reference key="NSSuperview" ref="300811574"/>
+ <reference key="NSNextKeyView" ref="700826966"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="53243865">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">Le lancement d’X11 créera des touches de contrôle d’accès Xauthority. Si l’adresse IP du système change, ces touches ne seront plus valides, ce qui risquera d’empêcher le lancement des applications X11.</string>
+ <reference key="NSSupport" ref="26"/>
+ <string key="NSPlaceholderString"/>
+ <reference key="NSControlView" ref="168436707"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ <object class="NSTextField" id="363817195">
+ <reference key="NSNextResponder" ref="300811574"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{36, 104}, {484, 56}}</string>
+ <reference key="NSSuperview" ref="300811574"/>
+ <reference key="NSNextKeyView" ref="223835729"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="390084685">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">En cas d’activation de cette option, « Authentifier les connexions » doit aussi être activée pour garantir la sécurité du système. En cas de désactivation, les connexions à partir d’applications distantes sont interdites.</string>
+ <reference key="NSSupport" ref="26"/>
+ <string key="NSPlaceholderString"/>
+ <reference key="NSControlView" ref="363817195"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ <object class="NSTextField" id="223835729">
+ <reference key="NSNextResponder" ref="300811574"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{17, 17}, {404, 14}}</string>
+ <reference key="NSSuperview" ref="300811574"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="283628678">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">Ces options prennent effet au prochain lancement d’X11.</string>
+ <reference key="NSSupport" ref="26"/>
+ <string key="NSPlaceholderString"/>
+ <reference key="NSControlView" ref="223835729"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ </array>
+ <string key="NSFrame">{{10, 33}, {534, 279}}</string>
+ <reference key="NSNextKeyView" ref="989050925"/>
+ </object>
+ <string key="NSLabel">Sécurité</string>
+ <reference key="NSColor" ref="57160303"/>
+ <reference key="NSTabView" ref="448510093"/>
+ </object>
+ </array>
+ <reference key="NSSelectedTabViewItem" ref="287591690"/>
+ <reference key="NSFont" ref="463863101"/>
+ <int key="NSTvFlags">0</int>
+ <bool key="NSAllowTruncatedLabels">YES</bool>
+ <bool key="NSDrawsBackground">YES</bool>
+ <array class="NSMutableArray" key="NSSubviews">
+ <reference ref="596750588"/>
+ </array>
+ </object>
+ </array>
+ <string key="NSFrameSize">{580, 341}</string>
+ <reference key="NSNextKeyView" ref="448510093"/>
+ </object>
+ <string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
+ <string key="NSMinSize">{320, 262}</string>
+ <string key="NSMaxSize">{1.7976931348623157e+308, 1.7976931348623157e+308}</string>
+ <string key="NSFrameAutosaveName">x11_prefs</string>
+ </object>
+ <object class="NSWindowTemplate" id="604417141">
+ <int key="NSWindowStyleMask">11</int>
+ <int key="NSWindowBacking">2</int>
+ <string key="NSWindowRect">{{302, 440}, {548, 271}}</string>
+ <int key="NSWTFlags">1350041600</int>
+ <string key="NSWindowTitle">Menu de l’application X11</string>
+ <string key="NSWindowClass">NSPanel</string>
+ <object class="NSMutableString" key="NSViewClass">
+ <characters key="NS.bytes">View</characters>
+ </object>
+ <nil key="NSUserInterfaceItemIdentifier"/>
+ <string key="NSWindowContentMaxSize">{1.7976931348623157e+308, 1.7976931348623157e+308}</string>
+ <string key="NSWindowContentMinSize">{320, 240}</string>
+ <object class="NSView" key="NSWindowView" id="85544634">
+ <nil key="NSNextResponder"/>
+ <int key="NSvFlags">256</int>
+ <array class="NSMutableArray" key="NSSubviews">
+ <object class="NSButton" id="671954382">
+ <reference key="NSNextResponder" ref="85544634"/>
+ <int key="NSvFlags">265</int>
+ <string key="NSFrame">{{372, 191}, {162, 32}}</string>
+ <reference key="NSSuperview" ref="85544634"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="143554520">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">137887744</int>
+ <string key="NSContents">Dupliquer</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="671954382"/>
+ <int key="NSButtonFlags">-2038284033</int>
+ <int key="NSButtonFlags2">1</int>
+ <object class="NSFont" key="NSAlternateImage" id="549406736">
+ <string key="NSName">Helvetica</string>
+ <double key="NSSize">13</double>
+ <int key="NSfFlags">16</int>
+ </object>
+ <string key="NSAlternateContents"/>
+ <object class="NSMutableString" key="NSKeyEquivalent">
+ <characters key="NS.bytes"/>
+ </object>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSButton" id="492358940">
+ <reference key="NSNextResponder" ref="85544634"/>
+ <int key="NSvFlags">265</int>
+ <string key="NSFrame">{{372, 159}, {162, 32}}</string>
+ <reference key="NSSuperview" ref="85544634"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="8201128">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">137887744</int>
+ <string key="NSContents">Supprimer</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="492358940"/>
+ <int key="NSButtonFlags">-2038284033</int>
+ <int key="NSButtonFlags2">1</int>
+ <reference key="NSAlternateImage" ref="549406736"/>
+ <string key="NSAlternateContents"/>
+ <object class="NSMutableString" key="NSKeyEquivalent">
+ <characters key="NS.bytes"/>
+ </object>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSScrollView" id="1063387772">
+ <reference key="NSNextResponder" ref="85544634"/>
+ <int key="NSvFlags">274</int>
+ <array class="NSMutableArray" key="NSSubviews">
+ <object class="NSClipView" id="580565898">
+ <reference key="NSNextResponder" ref="1063387772"/>
+ <int key="NSvFlags">2304</int>
+ <array class="NSMutableArray" key="NSSubviews">
+ <object class="NSTableView" id="905092943">
+ <reference key="NSNextResponder" ref="580565898"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrameSize">{333, 198}</string>
+ <reference key="NSSuperview" ref="580565898"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTableHeaderView" key="NSHeaderView" id="792419186">
+ <reference key="NSNextResponder" ref="672307654"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrameSize">{333, 17}</string>
+ <reference key="NSSuperview" ref="672307654"/>
+ <reference key="NSTableView" ref="905092943"/>
+ </object>
+ <object class="_NSCornerView" key="NSCornerView" id="898633680">
+ <reference key="NSNextResponder" ref="1063387772"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{334, 0}, {16, 17}}</string>
+ <reference key="NSSuperview" ref="1063387772"/>
+ </object>
+ <array class="NSMutableArray" key="NSTableColumns">
+ <object class="NSTableColumn" id="938444323">
+ <double key="NSWidth">155</double>
+ <double key="NSMinWidth">62.730998992919922</double>
+ <double key="NSMaxWidth">1000</double>
+ <object class="NSTableHeaderCell" key="NSHeaderCell">
+ <int key="NSCellFlags">75628096</int>
+ <int key="NSCellFlags2">2048</int>
+ <string key="NSContents">Nom</string>
+ <reference key="NSSupport" ref="26"/>
+ <object class="NSColor" key="NSBackgroundColor" id="113872566">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MC4zMzMzMzI5ODU2AA</bytes>
+ </object>
+ <object class="NSColor" key="NSTextColor" id="249576247">
+ <int key="NSColorSpace">6</int>
+ <string key="NSCatalogName">System</string>
+ <string key="NSColorName">headerTextColor</string>
+ <reference key="NSColor" ref="214098874"/>
+ </object>
+ </object>
+ <object class="NSTextFieldCell" key="NSDataCell" id="825378892">
+ <int key="NSCellFlags">338820672</int>
+ <int key="NSCellFlags2">1024</int>
+ <string key="NSContents">Text Cell</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <string key="NSPlaceholderString"/>
+ <reference key="NSControlView" ref="905092943"/>
+ <object class="NSColor" key="NSBackgroundColor" id="822946413">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MQA</bytes>
+ </object>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ <int key="NSResizingMask">3</int>
+ <bool key="NSIsResizeable">YES</bool>
+ <bool key="NSIsEditable">YES</bool>
+ <reference key="NSTableView" ref="905092943"/>
+ <string key="NSHeaderToolTip"/>
+ </object>
+ <object class="NSTableColumn" id="84282687">
+ <double key="NSWidth">100</double>
+ <double key="NSMinWidth">40</double>
+ <double key="NSMaxWidth">1000</double>
+ <object class="NSTableHeaderCell" key="NSHeaderCell">
+ <int key="NSCellFlags">75628096</int>
+ <int key="NSCellFlags2">2048</int>
+ <string key="NSContents">Commande</string>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSBackgroundColor" ref="113872566"/>
+ <reference key="NSTextColor" ref="249576247"/>
+ </object>
+ <object class="NSTextFieldCell" key="NSDataCell" id="432610585">
+ <int key="NSCellFlags">338820672</int>
+ <int key="NSCellFlags2">1024</int>
+ <string key="NSContents">Text Cell</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <string key="NSPlaceholderString"/>
+ <reference key="NSControlView" ref="905092943"/>
+ <reference key="NSBackgroundColor" ref="822946413"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ <int key="NSResizingMask">3</int>
+ <bool key="NSIsResizeable">YES</bool>
+ <bool key="NSIsEditable">YES</bool>
+ <reference key="NSTableView" ref="905092943"/>
+ <string key="NSHeaderToolTip"/>
+ </object>
+ <object class="NSTableColumn" id="242608782">
+ <double key="NSWidth">69</double>
+ <double key="NSMinWidth">10</double>
+ <double key="NSMaxWidth">1000</double>
+ <object class="NSTableHeaderCell" key="NSHeaderCell">
+ <int key="NSCellFlags">75628096</int>
+ <int key="NSCellFlags2">2048</int>
+ <string key="NSContents">Raccourci</string>
+ <reference key="NSSupport" ref="26"/>
+ <object class="NSColor" key="NSBackgroundColor">
+ <int key="NSColorSpace">6</int>
+ <string key="NSCatalogName">System</string>
+ <string key="NSColorName">headerColor</string>
+ <reference key="NSColor" ref="822946413"/>
+ </object>
+ <reference key="NSTextColor" ref="249576247"/>
+ </object>
+ <object class="NSTextFieldCell" key="NSDataCell" id="34714764">
+ <int key="NSCellFlags">338820672</int>
+ <int key="NSCellFlags2">1024</int>
+ <string key="NSContents">Text Cell</string>
+ <object class="NSFont" key="NSSupport">
+ <string key="NSName">LucidaGrande</string>
+ <double key="NSSize">12</double>
+ <int key="NSfFlags">16</int>
+ </object>
+ <string key="NSPlaceholderString"/>
+ <reference key="NSControlView" ref="905092943"/>
+ <bool key="NSDrawsBackground">YES</bool>
+ <object class="NSColor" key="NSBackgroundColor" id="812484075">
+ <int key="NSColorSpace">6</int>
+ <string key="NSCatalogName">System</string>
+ <string key="NSColorName">controlBackgroundColor</string>
+ <reference key="NSColor" ref="590688762"/>
+ </object>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ <int key="NSResizingMask">3</int>
+ <bool key="NSIsResizeable">YES</bool>
+ <bool key="NSIsEditable">YES</bool>
+ <reference key="NSTableView" ref="905092943"/>
+ <string key="NSHeaderToolTip"/>
+ </object>
+ </array>
+ <double key="NSIntercellSpacingWidth">3</double>
+ <double key="NSIntercellSpacingHeight">2</double>
+ <reference key="NSBackgroundColor" ref="822946413"/>
+ <object class="NSColor" key="NSGridColor">
+ <int key="NSColorSpace">6</int>
+ <string key="NSCatalogName">System</string>
+ <string key="NSColorName">gridColor</string>
+ <object class="NSColor" key="NSColor">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MC41AA</bytes>
+ </object>
+ </object>
+ <double key="NSRowHeight">17</double>
+ <int key="NSTvFlags">1379958784</int>
+ <reference key="NSDelegate"/>
+ <reference key="NSDataSource"/>
+ <int key="NSColumnAutoresizingStyle">1</int>
+ <int key="NSDraggingSourceMaskForLocal">-1</int>
+ <int key="NSDraggingSourceMaskForNonLocal">0</int>
+ <bool key="NSAllowsTypeSelect">YES</bool>
+ <int key="NSTableViewDraggingDestinationStyle">0</int>
+ <int key="NSTableViewGroupRowStyle">1</int>
+ </object>
+ </array>
+ <string key="NSFrame">{{1, 17}, {333, 198}}</string>
+ <reference key="NSSuperview" ref="1063387772"/>
+ <reference key="NSNextKeyView" ref="905092943"/>
+ <reference key="NSDocView" ref="905092943"/>
+ <reference key="NSBGColor" ref="812484075"/>
+ <int key="NScvFlags">4</int>
+ </object>
+ <object class="NSScroller" id="842897584">
+ <reference key="NSNextResponder" ref="1063387772"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{334, 17}, {15, 198}}</string>
+ <reference key="NSSuperview" ref="1063387772"/>
+ <reference key="NSTarget" ref="1063387772"/>
+ <string key="NSAction">_doScroller:</string>
+ <double key="NSPercent">0.99492377042770386</double>
+ </object>
+ <object class="NSScroller" id="17278747">
+ <reference key="NSNextResponder" ref="1063387772"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{1, 215}, {333, 15}}</string>
+ <reference key="NSSuperview" ref="1063387772"/>
+ <int key="NSsFlags">1</int>
+ <reference key="NSTarget" ref="1063387772"/>
+ <string key="NSAction">_doScroller:</string>
+ <double key="NSPercent">0.68852460384368896</double>
+ </object>
+ <object class="NSClipView" id="672307654">
+ <reference key="NSNextResponder" ref="1063387772"/>
+ <int key="NSvFlags">2304</int>
+ <array class="NSMutableArray" key="NSSubviews">
+ <reference ref="792419186"/>
+ </array>
+ <string key="NSFrame">{{1, 0}, {333, 17}}</string>
+ <reference key="NSSuperview" ref="1063387772"/>
+ <reference key="NSNextKeyView" ref="792419186"/>
+ <reference key="NSDocView" ref="792419186"/>
+ <reference key="NSBGColor" ref="812484075"/>
+ <int key="NScvFlags">4</int>
+ </object>
+ <reference ref="898633680"/>
+ </array>
+ <string key="NSFrame">{{20, 20}, {350, 231}}</string>
+ <reference key="NSSuperview" ref="85544634"/>
+ <reference key="NSNextKeyView" ref="580565898"/>
+ <int key="NSsFlags">133170</int>
+ <reference key="NSVScroller" ref="842897584"/>
+ <reference key="NSHScroller" ref="17278747"/>
+ <reference key="NSContentView" ref="580565898"/>
+ <reference key="NSHeaderClipView" ref="672307654"/>
+ <bytes key="NSScrollAmts">QSAAAEEgAABBmAAAQZgAAA</bytes>
+ </object>
+ <object class="NSButton" id="758204686">
+ <reference key="NSNextResponder" ref="85544634"/>
+ <int key="NSvFlags">265</int>
+ <string key="NSFrame">{{372, 223}, {162, 32}}</string>
+ <reference key="NSSuperview" ref="85544634"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="1025474039">
+ <int key="NSCellFlags">-2080244224</int>
+ <int key="NSCellFlags2">137887744</int>
+ <string key="NSContents">Ajouter un élément</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="758204686"/>
+ <int key="NSButtonFlags">-2038284033</int>
+ <int key="NSButtonFlags2">1</int>
+ <reference key="NSAlternateImage" ref="549406736"/>
+ <string key="NSAlternateContents"/>
+ <object class="NSMutableString" key="NSKeyEquivalent">
+ <characters key="NS.bytes"/>
+ </object>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ </array>
+ <string key="NSFrameSize">{548, 271}</string>
+ </object>
+ <string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
+ <string key="NSMinSize">{320, 262}</string>
+ <string key="NSMaxSize">{1.7976931348623157e+308, 1.7976931348623157e+308}</string>
+ <string key="NSFrameAutosaveName">x11_apps</string>
+ </object>
+ <object class="NSMenu" id="294137138">
+ <string key="NSTitle">Menu</string>
+ <array class="NSMutableArray" key="NSMenuItems">
+ <object class="NSMenuItem" id="318286212">
+ <reference key="NSMenu" ref="294137138"/>
+ <bool key="NSIsDisabled">YES</bool>
+ <bool key="NSIsSeparator">YES</bool>
+ <string key="NSTitle"/>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="511651072">
+ <reference key="NSMenu" ref="294137138"/>
+ <string key="NSTitle">Applications</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ <string key="NSAction">submenuAction:</string>
+ <object class="NSMenu" key="NSSubmenu" id="48278059">
+ <string key="NSTitle">Applications</string>
+ <array class="NSMutableArray" key="NSMenuItems">
+ <object class="NSMenuItem" id="563798000">
+ <reference key="NSMenu" ref="48278059"/>
+ <bool key="NSIsDisabled">YES</bool>
+ <bool key="NSIsSeparator">YES</bool>
+ <string key="NSTitle"/>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="1032342329">
+ <reference key="NSMenu" ref="48278059"/>
+ <string key="NSTitle">Personnaliser…</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ </array>
+ </object>
+ </object>
+ </array>
+ <string key="NSName"/>
+ </object>
+ </array>
+ <object class="IBObjectContainer" key="IBDocument.Objects">
+ <array class="NSMutableArray" key="connectionRecords">
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">copy:</string>
+ <reference key="source" ref="941939442"/>
+ <reference key="destination" ref="185296989"/>
+ </object>
+ <int key="connectionID">181</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">minimize_window:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="677652931"/>
+ </object>
+ <int key="connectionID">202</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">close_window:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="984461797"/>
+ </object>
+ <int key="connectionID">205</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">zoom_window:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="1066447520"/>
+ </object>
+ <int key="connectionID">206</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">bring_to_front:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="276216762"/>
+ </object>
+ <int key="connectionID">207</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">hideOtherApplications:</string>
+ <reference key="source" ref="815810918"/>
+ <reference key="destination" ref="206802571"/>
+ </object>
+ <int key="connectionID">263</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">apps_separator</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="390088328"/>
+ </object>
+ <int key="connectionID">273</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">apps_table</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="905092943"/>
+ </object>
+ <int key="connectionID">301</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">apps_table_delete:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="492358940"/>
+ </object>
+ <int key="connectionID">303</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">apps_table_duplicate:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="671954382"/>
+ </object>
+ <int key="connectionID">304</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">apps_table_show:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="1065386165"/>
+ </object>
+ <int key="connectionID">308</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">apps_table_new:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="758204686"/>
+ </object>
+ <int key="connectionID">311</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_show:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="386173216"/>
+ </object>
+ <int key="connectionID">318</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">x11_about_item</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="139290918"/>
+ </object>
+ <int key="connectionID">321</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">enable_auth</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="989050925"/>
+ </object>
+ <int key="connectionID">387</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">enable_tcp</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="700826966"/>
+ </object>
+ <int key="connectionID">388</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">depth</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="709074847"/>
+ </object>
+ <int key="connectionID">389</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">fake_buttons</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="119157981"/>
+ </object>
+ <int key="connectionID">391</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">sync_keymap</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="179949713"/>
+ </object>
+ <int key="connectionID">392</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">enable_keyequivs</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="842100515"/>
+ </object>
+ <int key="connectionID">393</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="119157981"/>
+ </object>
+ <int key="connectionID">394</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="179949713"/>
+ </object>
+ <int key="connectionID">395</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="842100515"/>
+ </object>
+ <int key="connectionID">396</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="709074847"/>
+ </object>
+ <int key="connectionID">398</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="989050925"/>
+ </object>
+ <int key="connectionID">399</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="700826966"/>
+ </object>
+ <int key="connectionID">401</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">prefs_panel</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="124913468"/>
+ </object>
+ <int key="connectionID">402</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">x11_help:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="504984881"/>
+ </object>
+ <int key="connectionID">422</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">dockMenu</string>
+ <reference key="source" ref="815810918"/>
+ <reference key="destination" ref="294137138"/>
+ </object>
+ <int key="connectionID">426</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">dock_menu</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="294137138"/>
+ </object>
+ <int key="connectionID">428</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">delegate</string>
+ <reference key="source" ref="815810918"/>
+ <reference key="destination" ref="485884620"/>
+ </object>
+ <int key="connectionID">429</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">hide:</string>
+ <reference key="source" ref="815810918"/>
+ <reference key="destination" ref="301008465"/>
+ </object>
+ <int key="connectionID">430</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">unhideAllApplications:</string>
+ <reference key="source" ref="815810918"/>
+ <reference key="destination" ref="1023546148"/>
+ </object>
+ <int key="connectionID">431</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">orderFrontStandardAboutPanel:</string>
+ <reference key="source" ref="815810918"/>
+ <reference key="destination" ref="139290918"/>
+ </object>
+ <int key="connectionID">433</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">dock_apps_menu</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="48278059"/>
+ </object>
+ <int key="connectionID">530</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">dock_window_separator</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="318286212"/>
+ </object>
+ <int key="connectionID">531</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">apps_table_show:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="1032342329"/>
+ </object>
+ <int key="connectionID">534</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">next_window:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="1036389925"/>
+ </object>
+ <int key="connectionID">539</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">previous_window:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="369641893"/>
+ </object>
+ <int key="connectionID">540</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">enable_fullscreen</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="477203622"/>
+ </object>
+ <int key="connectionID">546</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">enable_fullscreen_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="477203622"/>
+ </object>
+ <int key="connectionID">547</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">toggle_fullscreen:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="6876565"/>
+ </object>
+ <int key="connectionID">548</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">toggle_fullscreen_item</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="6876565"/>
+ </object>
+ <int key="connectionID">549</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">menu</string>
+ <reference key="source" ref="815810918"/>
+ <reference key="destination" ref="524015605"/>
+ </object>
+ <int key="connectionID">300334</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">terminate:</string>
+ <reference key="source" ref="815810918"/>
+ <reference key="destination" ref="274138642"/>
+ </object>
+ <int key="connectionID">300336</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="657659108"/>
+ </object>
+ <int key="connectionID">300389</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="992839333"/>
+ </object>
+ <int key="connectionID">300390</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="128352289"/>
+ </object>
+ <int key="connectionID">300391</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">click_through</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="657659108"/>
+ </object>
+ <int key="connectionID">300392</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">focus_follows_mouse</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="992839333"/>
+ </object>
+ <int key="connectionID">300393</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">focus_on_new_window</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="128352289"/>
+ </object>
+ <int key="connectionID">300394</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">copy_menu_item</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="185296989"/>
+ </object>
+ <int key="connectionID">300443</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">sync_pasteboard</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="878106058"/>
+ </object>
+ <int key="connectionID">300444</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">sync_clipboard_to_pasteboard</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="487809555"/>
+ </object>
+ <int key="connectionID">300461</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">sync_pasteboard_to_clipboard</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="477050998"/>
+ </object>
+ <int key="connectionID">300462</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">sync_pasteboard_to_primary</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="765780304"/>
+ </object>
+ <int key="connectionID">300463</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">sync_primary_immediately</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="1002778833"/>
+ </object>
+ <int key="connectionID">300464</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="878106058"/>
+ </object>
+ <int key="connectionID">300465</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="487809555"/>
+ </object>
+ <int key="connectionID">300466</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="477050998"/>
+ </object>
+ <int key="connectionID">300467</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="765780304"/>
+ </object>
+ <int key="connectionID">300468</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="1002778833"/>
+ </object>
+ <int key="connectionID">300469</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">sync_text1</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="620944856"/>
+ </object>
+ <int key="connectionID">300470</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">sync_text2</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="522511724"/>
+ </object>
+ <int key="connectionID">300471</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">enable_fullscreen_menu</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="57246850"/>
+ </object>
+ <int key="connectionID">300474</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="57246850"/>
+ </object>
+ <int key="connectionID">300475</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="406291430"/>
+ </object>
+ <int key="connectionID">300480</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">option_sends_alt</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="406291430"/>
+ </object>
+ <int key="connectionID">300481</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="863505041"/>
+ </object>
+ <int key="connectionID">300484</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">enable_fullscreen_menu_text</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="331853183"/>
+ </object>
+ <int key="connectionID">300489</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">scroll_in_device_direction</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="863505041"/>
+ </object>
+ <int key="connectionID">300490</int>
+ </object>
+ </array>
+ <object class="IBMutableOrderedSet" key="objectRecords">
+ <array key="orderedObjects">
+ <object class="IBObjectRecord">
+ <int key="objectID">0</int>
+ <array key="object" id="0"/>
+ <reference key="children" ref="904585544"/>
+ <nil key="parent"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">-2</int>
+ <reference key="object" ref="815810918"/>
+ <reference key="parent" ref="0"/>
+ <string key="objectName">File's Owner</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">-1</int>
+ <reference key="object" ref="941939442"/>
+ <reference key="parent" ref="0"/>
+ <string key="objectName">First Responder</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">-3</int>
+ <reference key="object" ref="951368722"/>
+ <reference key="parent" ref="0"/>
+ <string key="objectName">Application</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">29</int>
+ <reference key="object" ref="524015605"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="931553638"/>
+ <reference ref="365880285"/>
+ <reference ref="200491363"/>
+ <reference ref="868031522"/>
+ <reference ref="551174276"/>
+ </array>
+ <reference key="parent" ref="0"/>
+ <string key="objectName">MainMenu</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">19</int>
+ <reference key="object" ref="931553638"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="96874957"/>
+ </array>
+ <reference key="parent" ref="524015605"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">24</int>
+ <reference key="object" ref="96874957"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="677652931"/>
+ <reference ref="276216762"/>
+ <reference ref="1066447520"/>
+ <reference ref="1036389925"/>
+ <reference ref="369641893"/>
+ <reference ref="155085383"/>
+ <reference ref="984461797"/>
+ <reference ref="280172320"/>
+ </array>
+ <reference key="parent" ref="931553638"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">5</int>
+ <reference key="object" ref="276216762"/>
+ <reference key="parent" ref="96874957"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">23</int>
+ <reference key="object" ref="677652931"/>
+ <reference key="parent" ref="96874957"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">92</int>
+ <reference key="object" ref="280172320"/>
+ <reference key="parent" ref="96874957"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">203</int>
+ <reference key="object" ref="984461797"/>
+ <reference key="parent" ref="96874957"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">204</int>
+ <reference key="object" ref="1066447520"/>
+ <reference key="parent" ref="96874957"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">536</int>
+ <reference key="object" ref="155085383"/>
+ <reference key="parent" ref="96874957"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">537</int>
+ <reference key="object" ref="1036389925"/>
+ <reference key="parent" ref="96874957"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">538</int>
+ <reference key="object" ref="369641893"/>
+ <reference key="parent" ref="96874957"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">56</int>
+ <reference key="object" ref="365880285"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="576521955"/>
+ </array>
+ <reference key="parent" ref="524015605"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">57</int>
+ <reference key="object" ref="576521955"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="139290918"/>
+ <reference ref="386173216"/>
+ <reference ref="32285361"/>
+ <reference ref="301008465"/>
+ <reference ref="274138642"/>
+ <reference ref="272876017"/>
+ <reference ref="431301145"/>
+ <reference ref="206802571"/>
+ <reference ref="848095279"/>
+ <reference ref="1023546148"/>
+ <reference ref="6876565"/>
+ <reference ref="479677589"/>
+ </array>
+ <reference key="parent" ref="365880285"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">58</int>
+ <reference key="object" ref="139290918"/>
+ <reference key="parent" ref="576521955"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">129</int>
+ <reference key="object" ref="386173216"/>
+ <reference key="parent" ref="576521955"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">131</int>
+ <reference key="object" ref="32285361"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="821388474"/>
+ </array>
+ <reference key="parent" ref="576521955"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">130</int>
+ <reference key="object" ref="821388474"/>
+ <reference key="parent" ref="32285361"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">134</int>
+ <reference key="object" ref="301008465"/>
+ <reference key="parent" ref="576521955"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">136</int>
+ <reference key="object" ref="274138642"/>
+ <reference key="parent" ref="576521955"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">143</int>
+ <reference key="object" ref="272876017"/>
+ <reference key="parent" ref="576521955"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">144</int>
+ <reference key="object" ref="431301145"/>
+ <reference key="parent" ref="576521955"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">145</int>
+ <reference key="object" ref="206802571"/>
+ <reference key="parent" ref="576521955"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">149</int>
+ <reference key="object" ref="848095279"/>
+ <reference key="parent" ref="576521955"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">150</int>
+ <reference key="object" ref="1023546148"/>
+ <reference key="parent" ref="576521955"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">544</int>
+ <reference key="object" ref="6876565"/>
+ <reference key="parent" ref="576521955"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">545</int>
+ <reference key="object" ref="479677589"/>
+ <reference key="parent" ref="576521955"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">163</int>
+ <reference key="object" ref="200491363"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="526778998"/>
+ </array>
+ <reference key="parent" ref="524015605"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">169</int>
+ <reference key="object" ref="526778998"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="185296989"/>
+ </array>
+ <reference key="parent" ref="200491363"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">157</int>
+ <reference key="object" ref="185296989"/>
+ <reference key="parent" ref="526778998"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">269</int>
+ <reference key="object" ref="868031522"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="981161348"/>
+ </array>
+ <reference key="parent" ref="524015605"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">270</int>
+ <reference key="object" ref="981161348"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="390088328"/>
+ <reference ref="1065386165"/>
+ </array>
+ <reference key="parent" ref="868031522"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">272</int>
+ <reference key="object" ref="390088328"/>
+ <reference key="parent" ref="981161348"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">305</int>
+ <reference key="object" ref="1065386165"/>
+ <reference key="parent" ref="981161348"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">419</int>
+ <reference key="object" ref="551174276"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="511848303"/>
+ </array>
+ <reference key="parent" ref="524015605"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">420</int>
+ <reference key="object" ref="511848303"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="504984881"/>
+ </array>
+ <reference key="parent" ref="551174276"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">421</int>
+ <reference key="object" ref="504984881"/>
+ <reference key="parent" ref="511848303"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">196</int>
+ <reference key="object" ref="485884620"/>
+ <reference key="parent" ref="0"/>
+ <string key="objectName">X11Controller</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">244</int>
+ <reference key="object" ref="124913468"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="941366957"/>
+ </array>
+ <reference key="parent" ref="0"/>
+ <string key="objectName">PrefsPanel</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">245</int>
+ <reference key="object" ref="941366957"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="448510093"/>
+ </array>
+ <reference key="parent" ref="124913468"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">348</int>
+ <reference key="object" ref="448510093"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="287591690"/>
+ <reference ref="960678392"/>
+ <reference ref="348328898"/>
+ <reference ref="10973343"/>
+ <reference ref="723450037"/>
+ </array>
+ <reference key="parent" ref="941366957"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">349</int>
+ <reference key="object" ref="287591690"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="596750588"/>
+ </array>
+ <reference key="parent" ref="448510093"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">351</int>
+ <reference key="object" ref="596750588"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="119157981"/>
+ <reference ref="443008216"/>
+ <reference ref="282885445"/>
+ <reference ref="842100515"/>
+ <reference ref="31160162"/>
+ <reference ref="179949713"/>
+ <reference ref="278155937"/>
+ <reference ref="406291430"/>
+ <reference ref="863505041"/>
+ </array>
+ <reference key="parent" ref="287591690"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">363</int>
+ <reference key="object" ref="119157981"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="990762273"/>
+ </array>
+ <reference key="parent" ref="596750588"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">364</int>
+ <reference key="object" ref="443008216"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="391919450"/>
+ </array>
+ <reference key="parent" ref="596750588"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">365</int>
+ <reference key="object" ref="282885445"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="649334366"/>
+ </array>
+ <reference key="parent" ref="596750588"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">368</int>
+ <reference key="object" ref="842100515"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="940564599"/>
+ </array>
+ <reference key="parent" ref="596750588"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">369</int>
+ <reference key="object" ref="31160162"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="666057093"/>
+ </array>
+ <reference key="parent" ref="596750588"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">370</int>
+ <reference key="object" ref="179949713"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="967619578"/>
+ </array>
+ <reference key="parent" ref="596750588"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">352</int>
+ <reference key="object" ref="960678392"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="515308735"/>
+ </array>
+ <reference key="parent" ref="448510093"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">350</int>
+ <reference key="object" ref="515308735"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="709074847"/>
+ <reference ref="201731424"/>
+ <reference ref="86150604"/>
+ <reference ref="477203622"/>
+ <reference ref="57246850"/>
+ <reference ref="298603383"/>
+ <reference ref="331853183"/>
+ </array>
+ <reference key="parent" ref="960678392"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">382</int>
+ <reference key="object" ref="709074847"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="633115429"/>
+ </array>
+ <reference key="parent" ref="515308735"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">385</int>
+ <reference key="object" ref="201731424"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="930265681"/>
+ </array>
+ <reference key="parent" ref="515308735"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">386</int>
+ <reference key="object" ref="86150604"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="311969422"/>
+ </array>
+ <reference key="parent" ref="515308735"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">541</int>
+ <reference key="object" ref="477203622"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="631531164"/>
+ </array>
+ <reference key="parent" ref="515308735"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">543</int>
+ <reference key="object" ref="298603383"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="761107402"/>
+ </array>
+ <reference key="parent" ref="515308735"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">353</int>
+ <reference key="object" ref="348328898"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="300811574"/>
+ </array>
+ <reference key="parent" ref="448510093"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">354</int>
+ <reference key="object" ref="300811574"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="989050925"/>
+ <reference ref="700826966"/>
+ <reference ref="168436707"/>
+ <reference ref="363817195"/>
+ <reference ref="223835729"/>
+ </array>
+ <reference key="parent" ref="348328898"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">374</int>
+ <reference key="object" ref="989050925"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="189594322"/>
+ </array>
+ <reference key="parent" ref="300811574"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">375</int>
+ <reference key="object" ref="700826966"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="489340979"/>
+ </array>
+ <reference key="parent" ref="300811574"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">376</int>
+ <reference key="object" ref="168436707"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="53243865"/>
+ </array>
+ <reference key="parent" ref="300811574"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">377</int>
+ <reference key="object" ref="363817195"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="390084685"/>
+ </array>
+ <reference key="parent" ref="300811574"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">379</int>
+ <reference key="object" ref="223835729"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="283628678"/>
+ </array>
+ <reference key="parent" ref="300811574"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">285</int>
+ <reference key="object" ref="604417141"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="85544634"/>
+ </array>
+ <reference key="parent" ref="0"/>
+ <string key="objectName">EditPrograms</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">286</int>
+ <reference key="object" ref="85544634"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="1063387772"/>
+ <reference ref="758204686"/>
+ <reference ref="671954382"/>
+ <reference ref="492358940"/>
+ </array>
+ <reference key="parent" ref="604417141"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">423</int>
+ <reference key="object" ref="294137138"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="318286212"/>
+ <reference ref="511651072"/>
+ </array>
+ <reference key="parent" ref="0"/>
+ <string key="objectName">DockMenu</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">524</int>
+ <reference key="object" ref="318286212"/>
+ <reference key="parent" ref="294137138"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">526</int>
+ <reference key="object" ref="511651072"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="48278059"/>
+ </array>
+ <reference key="parent" ref="294137138"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">527</int>
+ <reference key="object" ref="48278059"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="1032342329"/>
+ <reference ref="563798000"/>
+ </array>
+ <reference key="parent" ref="511651072"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">532</int>
+ <reference key="object" ref="1032342329"/>
+ <reference key="parent" ref="48278059"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">533</int>
+ <reference key="object" ref="563798000"/>
+ <reference key="parent" ref="48278059"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100363</int>
+ <reference key="object" ref="990762273"/>
+ <reference key="parent" ref="119157981"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100364</int>
+ <reference key="object" ref="391919450"/>
+ <reference key="parent" ref="443008216"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100365</int>
+ <reference key="object" ref="649334366"/>
+ <reference key="parent" ref="282885445"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100368</int>
+ <reference key="object" ref="940564599"/>
+ <reference key="parent" ref="842100515"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100369</int>
+ <reference key="object" ref="666057093"/>
+ <reference key="parent" ref="31160162"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100370</int>
+ <reference key="object" ref="967619578"/>
+ <reference key="parent" ref="179949713"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100382</int>
+ <reference key="object" ref="633115429"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="341113515"/>
+ </array>
+ <reference key="parent" ref="709074847"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100385</int>
+ <reference key="object" ref="930265681"/>
+ <reference key="parent" ref="201731424"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100386</int>
+ <reference key="object" ref="311969422"/>
+ <reference key="parent" ref="86150604"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100541</int>
+ <reference key="object" ref="631531164"/>
+ <reference key="parent" ref="477203622"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100543</int>
+ <reference key="object" ref="761107402"/>
+ <reference key="parent" ref="298603383"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100374</int>
+ <reference key="object" ref="189594322"/>
+ <reference key="parent" ref="989050925"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100375</int>
+ <reference key="object" ref="489340979"/>
+ <reference key="parent" ref="700826966"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100376</int>
+ <reference key="object" ref="53243865"/>
+ <reference key="parent" ref="168436707"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100377</int>
+ <reference key="object" ref="390084685"/>
+ <reference key="parent" ref="363817195"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100379</int>
+ <reference key="object" ref="283628678"/>
+ <reference key="parent" ref="223835729"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">380</int>
+ <reference key="object" ref="341113515"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="759499526"/>
+ <reference ref="616492372"/>
+ <reference ref="543935434"/>
+ <reference ref="836673018"/>
+ </array>
+ <reference key="parent" ref="633115429"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">435</int>
+ <reference key="object" ref="759499526"/>
+ <reference key="parent" ref="341113515"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">384</int>
+ <reference key="object" ref="616492372"/>
+ <reference key="parent" ref="341113515"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">383</int>
+ <reference key="object" ref="543935434"/>
+ <reference key="parent" ref="341113515"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">381</int>
+ <reference key="object" ref="836673018"/>
+ <reference key="parent" ref="341113515"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">295</int>
+ <reference key="object" ref="1063387772"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="792419186"/>
+ <reference ref="17278747"/>
+ <reference ref="842897584"/>
+ <reference ref="905092943"/>
+ </array>
+ <reference key="parent" ref="85544634"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300295</int>
+ <reference key="object" ref="792419186"/>
+ <reference key="parent" ref="1063387772"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">200295</int>
+ <reference key="object" ref="17278747"/>
+ <reference key="parent" ref="1063387772"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100295</int>
+ <reference key="object" ref="842897584"/>
+ <reference key="parent" ref="1063387772"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">296</int>
+ <reference key="object" ref="905092943"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="242608782"/>
+ <reference ref="938444323"/>
+ <reference ref="84282687"/>
+ </array>
+ <reference key="parent" ref="1063387772"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">535</int>
+ <reference key="object" ref="242608782"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="34714764"/>
+ </array>
+ <reference key="parent" ref="905092943"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">575</int>
+ <reference key="object" ref="34714764"/>
+ <reference key="parent" ref="242608782"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">298</int>
+ <reference key="object" ref="938444323"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="825378892"/>
+ </array>
+ <reference key="parent" ref="905092943"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">573</int>
+ <reference key="object" ref="825378892"/>
+ <reference key="parent" ref="938444323"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">297</int>
+ <reference key="object" ref="84282687"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="432610585"/>
+ </array>
+ <reference key="parent" ref="905092943"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">574</int>
+ <reference key="object" ref="432610585"/>
+ <reference key="parent" ref="84282687"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">310</int>
+ <reference key="object" ref="758204686"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="1025474039"/>
+ </array>
+ <reference key="parent" ref="85544634"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100310</int>
+ <reference key="object" ref="1025474039"/>
+ <reference key="parent" ref="758204686"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">292</int>
+ <reference key="object" ref="671954382"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="143554520"/>
+ </array>
+ <reference key="parent" ref="85544634"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100292</int>
+ <reference key="object" ref="143554520"/>
+ <reference key="parent" ref="671954382"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">293</int>
+ <reference key="object" ref="492358940"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="8201128"/>
+ </array>
+ <reference key="parent" ref="85544634"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100293</int>
+ <reference key="object" ref="8201128"/>
+ <reference key="parent" ref="492358940"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300337</int>
+ <reference key="object" ref="10973343"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="184765684"/>
+ </array>
+ <reference key="parent" ref="448510093"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300338</int>
+ <reference key="object" ref="184765684"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="657659108"/>
+ <reference ref="290578835"/>
+ <reference ref="992839333"/>
+ <reference ref="138261120"/>
+ <reference ref="128352289"/>
+ <reference ref="57161931"/>
+ </array>
+ <reference key="parent" ref="10973343"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300358</int>
+ <reference key="object" ref="290578835"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="399127858"/>
+ </array>
+ <reference key="parent" ref="184765684"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300359</int>
+ <reference key="object" ref="657659108"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="259618205"/>
+ </array>
+ <reference key="parent" ref="184765684"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300360</int>
+ <reference key="object" ref="259618205"/>
+ <reference key="parent" ref="657659108"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300361</int>
+ <reference key="object" ref="399127858"/>
+ <reference key="parent" ref="290578835"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300362</int>
+ <reference key="object" ref="992839333"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="959555182"/>
+ </array>
+ <reference key="parent" ref="184765684"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300363</int>
+ <reference key="object" ref="959555182"/>
+ <reference key="parent" ref="992839333"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300364</int>
+ <reference key="object" ref="138261120"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="183409141"/>
+ </array>
+ <reference key="parent" ref="184765684"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300365</int>
+ <reference key="object" ref="183409141"/>
+ <reference key="parent" ref="138261120"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300368</int>
+ <reference key="object" ref="128352289"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="556463187"/>
+ </array>
+ <reference key="parent" ref="184765684"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300369</int>
+ <reference key="object" ref="556463187"/>
+ <reference key="parent" ref="128352289"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300370</int>
+ <reference key="object" ref="57161931"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="989804990"/>
+ </array>
+ <reference key="parent" ref="184765684"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300371</int>
+ <reference key="object" ref="989804990"/>
+ <reference key="parent" ref="57161931"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300421</int>
+ <reference key="object" ref="723450037"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="408298283"/>
+ </array>
+ <reference key="parent" ref="448510093"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300422</int>
+ <reference key="object" ref="408298283"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="878106058"/>
+ <reference ref="386152084"/>
+ <reference ref="487809555"/>
+ <reference ref="620944856"/>
+ <reference ref="477050998"/>
+ <reference ref="765780304"/>
+ <reference ref="1002778833"/>
+ <reference ref="522511724"/>
+ </array>
+ <reference key="parent" ref="723450037"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300423</int>
+ <reference key="object" ref="386152084"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="572508492"/>
+ </array>
+ <reference key="parent" ref="408298283"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300424</int>
+ <reference key="object" ref="878106058"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="718083688"/>
+ </array>
+ <reference key="parent" ref="408298283"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300440</int>
+ <reference key="object" ref="718083688"/>
+ <reference key="parent" ref="878106058"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300441</int>
+ <reference key="object" ref="572508492"/>
+ <reference key="parent" ref="386152084"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300447</int>
+ <reference key="object" ref="477050998"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="501304422"/>
+ </array>
+ <reference key="parent" ref="408298283"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300450</int>
+ <reference key="object" ref="501304422"/>
+ <reference key="parent" ref="477050998"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300451</int>
+ <reference key="object" ref="765780304"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="510771323"/>
+ </array>
+ <reference key="parent" ref="408298283"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300452</int>
+ <reference key="object" ref="510771323"/>
+ <reference key="parent" ref="765780304"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300453</int>
+ <reference key="object" ref="487809555"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="619977658"/>
+ </array>
+ <reference key="parent" ref="408298283"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300454</int>
+ <reference key="object" ref="619977658"/>
+ <reference key="parent" ref="487809555"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300455</int>
+ <reference key="object" ref="620944856"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="461823902"/>
+ </array>
+ <reference key="parent" ref="408298283"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300456</int>
+ <reference key="object" ref="461823902"/>
+ <reference key="parent" ref="620944856"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300457</int>
+ <reference key="object" ref="1002778833"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="897099877"/>
+ </array>
+ <reference key="parent" ref="408298283"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300458</int>
+ <reference key="object" ref="897099877"/>
+ <reference key="parent" ref="1002778833"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300459</int>
+ <reference key="object" ref="522511724"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="994587858"/>
+ </array>
+ <reference key="parent" ref="408298283"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300460</int>
+ <reference key="object" ref="994587858"/>
+ <reference key="parent" ref="522511724"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300472</int>
+ <reference key="object" ref="57246850"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="917248662"/>
+ </array>
+ <reference key="parent" ref="515308735"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300473</int>
+ <reference key="object" ref="917248662"/>
+ <reference key="parent" ref="57246850"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300476</int>
+ <reference key="object" ref="278155937"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="617441821"/>
+ </array>
+ <reference key="parent" ref="596750588"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300477</int>
+ <reference key="object" ref="406291430"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="67728988"/>
+ </array>
+ <reference key="parent" ref="596750588"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300478</int>
+ <reference key="object" ref="67728988"/>
+ <reference key="parent" ref="406291430"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300479</int>
+ <reference key="object" ref="617441821"/>
+ <reference key="parent" ref="278155937"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300482</int>
+ <reference key="object" ref="863505041"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="1016286396"/>
+ </array>
+ <reference key="parent" ref="596750588"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300483</int>
+ <reference key="object" ref="1016286396"/>
+ <reference key="parent" ref="863505041"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300487</int>
+ <reference key="object" ref="331853183"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="1042813110"/>
+ </array>
+ <reference key="parent" ref="515308735"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300488</int>
+ <reference key="object" ref="1042813110"/>
+ <reference key="parent" ref="331853183"/>
+ </object>
+ </array>
+ </object>
+ <dictionary class="NSMutableDictionary" key="flattenedProperties">
+ <string key="-3.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="-3.ImportedFromIB2"/>
+ <string key="100292.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100293.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100295.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="100295.IBShouldRemoveOnLegacySave"/>
+ <string key="100310.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100363.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100364.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100365.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100368.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100369.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100370.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100374.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100375.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100376.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100377.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100379.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100382.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100385.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100386.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100541.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100543.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="129.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="129.ImportedFromIB2"/>
+ <string key="130.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="130.ImportedFromIB2"/>
+ <string key="131.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="131.ImportedFromIB2"/>
+ <string key="134.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="134.ImportedFromIB2"/>
+ <string key="136.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="136.ImportedFromIB2"/>
+ <string key="143.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="143.ImportedFromIB2"/>
+ <string key="144.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="144.ImportedFromIB2"/>
+ <string key="145.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="145.ImportedFromIB2"/>
+ <string key="149.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="149.ImportedFromIB2"/>
+ <string key="150.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="150.ImportedFromIB2"/>
+ <string key="157.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="157.ImportedFromIB2"/>
+ <string key="163.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="163.ImportedFromIB2"/>
+ <string key="169.IBEditorWindowLastContentRect">{{168, 821}, {113, 23}}</string>
+ <string key="169.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="169.ImportedFromIB2"/>
+ <string key="169.editorWindowContentRectSynchronizationRect">{{202, 626}, {154, 153}}</string>
+ <string key="19.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="19.ImportedFromIB2"/>
+ <integer value="1" key="196.ImportedFromIB2"/>
+ <string key="200295.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="200295.IBShouldRemoveOnLegacySave"/>
+ <string key="203.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="203.ImportedFromIB2"/>
+ <string key="204.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="204.ImportedFromIB2"/>
+ <string key="23.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="23.ImportedFromIB2"/>
+ <string key="24.IBEditorWindowLastContentRect">{{349, 868}, {315, 143}}</string>
+ <string key="24.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="24.ImportedFromIB2"/>
+ <string key="24.editorWindowContentRectSynchronizationRect">{{271, 666}, {301, 153}}</string>
+ <string key="244.IBEditorWindowLastContentRect">{{127, 515}, {580, 341}}</string>
+ <string key="244.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <boolean value="YES" key="244.IBViewEditorWindowController.showingLayoutRectangles"/>
+ <string key="244.IBWindowTemplateEditedContentRect">{{127, 515}, {580, 341}}</string>
+ <integer value="1" key="244.ImportedFromIB2"/>
+ <string key="244.editorWindowContentRectSynchronizationRect">{{184, 290}, {481, 345}}</string>
+ <string key="244.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <boolean value="YES" key="244.windowTemplate.hasMinSize"/>
+ <string key="244.windowTemplate.maxSize">{1.7976931348623157e+308, 1.7976931348623157e+308}</string>
+ <string key="244.windowTemplate.minSize">{320, 240}</string>
+ <string key="245.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="245.ImportedFromIB2"/>
+ <string key="245.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="269.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="269.ImportedFromIB2"/>
+ <string key="270.IBEditorWindowLastContentRect">{{58, 803}, {155, 33}}</string>
+ <string key="270.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="270.ImportedFromIB2"/>
+ <string key="270.editorWindowContentRectSynchronizationRect">{{100, 746}, {155, 33}}</string>
+ <string key="272.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="272.ImportedFromIB2"/>
+ <string key="285.IBEditorWindowLastContentRect">{{68, 585}, {454, 271}}</string>
+ <string key="285.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="285.IBViewEditorWindowController.showingBoundsRectangles"/>
+ <integer value="1" key="285.IBViewEditorWindowController.showingLayoutRectangles"/>
+ <string key="285.IBWindowTemplateEditedContentRect">{{68, 585}, {454, 271}}</string>
+ <integer value="1" key="285.ImportedFromIB2"/>
+ <string key="285.editorWindowContentRectSynchronizationRect">{{433, 406}, {486, 327}}</string>
+ <string key="285.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <boolean value="YES" key="285.windowTemplate.hasMinSize"/>
+ <string key="285.windowTemplate.maxSize">{1.7976931348623157e+308, 1.7976931348623157e+308}</string>
+ <string key="285.windowTemplate.minSize">{320, 240}</string>
+ <string key="286.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="286.ImportedFromIB2"/>
+ <string key="29.IBEditorWindowLastContentRect">{{145, 1011}, {336, 20}}</string>
+ <string key="29.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="29.ImportedFromIB2"/>
+ <string key="29.editorWindowContentRectSynchronizationRect">{{67, 819}, {336, 20}}</string>
+ <string key="292.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="292.ImportedFromIB2"/>
+ <string key="293.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="293.ImportedFromIB2"/>
+ <string key="295.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="295.ImportedFromIB2"/>
+ <string key="296.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="296.ImportedFromIB2"/>
+ <string key="297.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="297.ImportedFromIB2"/>
+ <string key="298.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="298.ImportedFromIB2"/>
+ <string key="300295.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300295.IBShouldRemoveOnLegacySave"/>
+ <string key="300337.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300337.ImportedFromIB2"/>
+ <string key="300338.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300338.ImportedFromIB2"/>
+ <string key="300338.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="300358.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300358.ImportedFromIB2"/>
+ <string key="300358.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="300359.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300359.ImportedFromIB2"/>
+ <string key="300359.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="300360.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300361.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300362.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300362.ImportedFromIB2"/>
+ <string key="300362.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="300363.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300364.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300364.ImportedFromIB2"/>
+ <string key="300364.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="300365.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300368.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300368.ImportedFromIB2"/>
+ <string key="300368.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="300369.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300370.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300370.ImportedFromIB2"/>
+ <string key="300370.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="300371.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300421.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300421.ImportedFromIB2"/>
+ <string key="300422.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300422.ImportedFromIB2"/>
+ <string key="300422.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="300423.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300423.ImportedFromIB2"/>
+ <string key="300423.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="300424.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300424.ImportedFromIB2"/>
+ <string key="300424.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="300440.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300441.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300447.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300447.ImportedFromIB2"/>
+ <string key="300447.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="300450.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300451.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300451.ImportedFromIB2"/>
+ <string key="300451.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="300452.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300453.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300453.ImportedFromIB2"/>
+ <string key="300453.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="300454.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300455.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300455.ImportedFromIB2"/>
+ <string key="300455.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="300456.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300457.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300457.ImportedFromIB2"/>
+ <string key="300457.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="300458.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300459.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300459.ImportedFromIB2"/>
+ <string key="300459.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="300460.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300472.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300472.ImportedFromIB2"/>
+ <string key="300472.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="300473.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300473.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="300476.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300476.ImportedFromIB2"/>
+ <string key="300476.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="300477.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300477.ImportedFromIB2"/>
+ <string key="300477.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="300478.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300479.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300482.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300482.ImportedFromIB2"/>
+ <string key="300482.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="300483.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300483.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="300487.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300487.ImportedFromIB2"/>
+ <string key="300487.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="300488.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300488.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="305.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="305.ImportedFromIB2"/>
+ <string key="310.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="310.ImportedFromIB2"/>
+ <string key="348.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <object class="NSAffineTransform" key="348.IBViewBoundsToFrameTransform">
+ <bytes key="NSTransformStruct">P4AAAL+AAABBUAAAw6aAAA</bytes>
+ </object>
+ <integer value="1" key="348.ImportedFromIB2"/>
+ <string key="348.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="349.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="349.ImportedFromIB2"/>
+ <string key="350.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="350.ImportedFromIB2"/>
+ <string key="350.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="351.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="351.ImportedFromIB2"/>
+ <string key="351.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="352.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="352.ImportedFromIB2"/>
+ <string key="353.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="353.ImportedFromIB2"/>
+ <string key="354.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="354.ImportedFromIB2"/>
+ <string key="354.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="363.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="363.ImportedFromIB2"/>
+ <string key="363.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="364.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="364.ImportedFromIB2"/>
+ <string key="364.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="365.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="365.ImportedFromIB2"/>
+ <string key="365.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="368.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="368.ImportedFromIB2"/>
+ <string key="368.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="369.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="369.ImportedFromIB2"/>
+ <string key="369.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="370.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="370.ImportedFromIB2"/>
+ <string key="370.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="374.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="374.ImportedFromIB2"/>
+ <string key="374.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="375.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="375.ImportedFromIB2"/>
+ <string key="375.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="376.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="376.ImportedFromIB2"/>
+ <string key="376.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="377.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="377.ImportedFromIB2"/>
+ <string key="377.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="379.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="379.ImportedFromIB2"/>
+ <string key="379.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="380.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="380.ImportedFromIB2"/>
+ <string key="381.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="381.ImportedFromIB2"/>
+ <string key="382.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="382.ImportedFromIB2"/>
+ <string key="382.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="383.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="383.ImportedFromIB2"/>
+ <string key="384.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="384.ImportedFromIB2"/>
+ <string key="385.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="385.ImportedFromIB2"/>
+ <string key="385.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="386.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="386.ImportedFromIB2"/>
+ <string key="386.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="419.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="419.ImportedFromIB2"/>
+ <string key="420.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="420.ImportedFromIB2"/>
+ <string key="421.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="421.ImportedFromIB2"/>
+ <string key="423.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="423.ImportedFromIB2"/>
+ <string key="435.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="435.ImportedFromIB2"/>
+ <string key="5.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="5.ImportedFromIB2"/>
+ <string key="524.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="524.ImportedFromIB2"/>
+ <string key="526.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="526.ImportedFromIB2"/>
+ <string key="527.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="527.ImportedFromIB2"/>
+ <string key="532.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="532.ImportedFromIB2"/>
+ <string key="533.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="533.ImportedFromIB2"/>
+ <string key="535.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="535.ImportedFromIB2"/>
+ <string key="536.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="536.ImportedFromIB2"/>
+ <string key="537.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="537.ImportedFromIB2"/>
+ <string key="537.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="538.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="538.ImportedFromIB2"/>
+ <string key="541.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="541.ImportedFromIB2"/>
+ <string key="541.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="543.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="543.ImportedFromIB2"/>
+ <string key="543.object.labelIdentifier">IBBuiltInLabel-Red</string>
+ <string key="544.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="544.ImportedFromIB2"/>
+ <string key="545.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="545.ImportedFromIB2"/>
+ <string key="56.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="56.ImportedFromIB2"/>
+ <string key="57.IBEditorWindowLastContentRect">{{20, 641}, {218, 203}}</string>
+ <string key="57.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="57.ImportedFromIB2"/>
+ <string key="57.editorWindowContentRectSynchronizationRect">{{79, 616}, {218, 203}}</string>
+ <string key="573.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="573.ImportedFromIB2"/>
+ <string key="574.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="574.ImportedFromIB2"/>
+ <string key="575.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="575.ImportedFromIB2"/>
+ <string key="58.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="58.ImportedFromIB2"/>
+ <string key="92.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="92.ImportedFromIB2"/>
+ </dictionary>
+ <dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
+ <nil key="activeLocalization"/>
+ <dictionary class="NSMutableDictionary" key="localizations"/>
+ <nil key="sourceID"/>
+ <int key="maxID">300490</int>
+ </object>
+ <object class="IBClassDescriber" key="IBDocument.Classes"/>
+ <int key="IBDocument.localizationMode">0</int>
+ <string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
+ <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencies">
+ <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string>
+ <integer value="1040" key="NS.object.0"/>
+ </object>
+ <bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
+ <nil key="IBDocument.LastKnownRelativeProjectPath"/>
+ <int key="IBDocument.defaultPropertyAccessControl">3</int>
+ <dictionary class="NSMutableDictionary" key="IBDocument.LastKnownImageSizes">
+ <string key="NSMenuCheckmark">{9, 8}</string>
+ <string key="NSMenuMixedState">{7, 2}</string>
+ <string key="NSSwitch">{15, 15}</string>
+ </dictionary>
+ </data>
+</archive>
diff --git a/xorg-server/hw/xquartz/bundle/Resources/German.lproj/locversion.plist b/xorg-server/hw/xquartz/bundle/Resources/German.lproj/locversion.plist
index 0052a22d7..62820e18b 100644
--- a/xorg-server/hw/xquartz/bundle/Resources/German.lproj/locversion.plist
+++ b/xorg-server/hw/xquartz/bundle/Resources/German.lproj/locversion.plist
@@ -1,14 +1,14 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>LprojCompatibleVersion</key>
- <string>106</string>
- <key>LprojLocale</key>
- <string>de</string>
- <key>LprojRevisionLevel</key>
- <string>1</string>
- <key>LprojVersion</key>
- <string>106</string>
-</dict>
-</plist>
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>LprojCompatibleVersion</key>
+ <string>106</string>
+ <key>LprojLocale</key>
+ <string>de</string>
+ <key>LprojRevisionLevel</key>
+ <string>1</string>
+ <key>LprojVersion</key>
+ <string>106</string>
+</dict>
+</plist>
diff --git a/xorg-server/hw/xquartz/bundle/Resources/German.lproj/main.nib/designable.nib b/xorg-server/hw/xquartz/bundle/Resources/German.lproj/main.nib/designable.nib
index 5e70cf291..d42b04645 100644
--- a/xorg-server/hw/xquartz/bundle/Resources/German.lproj/main.nib/designable.nib
+++ b/xorg-server/hw/xquartz/bundle/Resources/German.lproj/main.nib/designable.nib
@@ -1,3615 +1,3615 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00">
- <data>
- <int key="IBDocument.SystemTarget">1040</int>
- <string key="IBDocument.SystemVersion">11A289</string>
- <string key="IBDocument.InterfaceBuilderVersion">903</string>
- <string key="IBDocument.AppKitVersion">1094.2</string>
- <string key="IBDocument.HIToolboxVersion">521.00</string>
- <object class="NSMutableDictionary" key="IBDocument.PluginVersions">
- <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="NS.object.0">903</string>
- </object>
- <array class="NSMutableArray" key="IBDocument.EditedObjectIDs"/>
- <array key="IBDocument.PluginDependencies">
- <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- </array>
- <object class="NSMutableDictionary" key="IBDocument.Metadata">
- <string key="NS.key.0">PluginDependencyRecalculationVersion</string>
- <integer value="1" key="NS.object.0"/>
- </object>
- <array class="NSMutableArray" key="IBDocument.RootObjects" id="904585544">
- <object class="NSCustomObject" id="815810918">
- <object class="NSMutableString" key="NSClassName">
- <characters key="NS.bytes">NSApplication</characters>
- </object>
- </object>
- <object class="NSCustomObject" id="941939442">
- <string key="NSClassName">FirstResponder</string>
- </object>
- <object class="NSCustomObject" id="951368722">
- <string key="NSClassName">NSApplication</string>
- </object>
- <object class="NSMenu" id="524015605">
- <string key="NSTitle">MainMenu</string>
- <array class="NSMutableArray" key="NSMenuItems">
- <object class="NSMenuItem" id="365880285">
- <reference key="NSMenu" ref="524015605"/>
- <string key="NSTitle">X11</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <object class="NSCustomResource" key="NSOnImage" id="531645050">
- <string key="NSClassName">NSImage</string>
- <string key="NSResourceName">NSMenuCheckmark</string>
- </object>
- <object class="NSCustomResource" key="NSMixedImage" id="351811234">
- <string key="NSClassName">NSImage</string>
- <string key="NSResourceName">NSMenuMixedState</string>
- </object>
- <string key="NSAction">submenuAction:</string>
- <object class="NSMenu" key="NSSubmenu" id="576521955">
- <string key="NSTitle">X11</string>
- <array class="NSMutableArray" key="NSMenuItems">
- <object class="NSMenuItem" id="139290918">
- <reference key="NSMenu" ref="576521955"/>
- <string key="NSTitle">Über X11</string>
- <string key="NSKeyEquiv"/>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="386173216">
- <reference key="NSMenu" ref="576521955"/>
- <string key="NSTitle">Einstellungen …</string>
- <string key="NSKeyEquiv">,</string>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="272876017">
- <reference key="NSMenu" ref="576521955"/>
- <bool key="NSIsDisabled">YES</bool>
- <bool key="NSIsSeparator">YES</bool>
- <string key="NSTitle"/>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="32285361">
- <reference key="NSMenu" ref="576521955"/>
- <string key="NSTitle">Dienste</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- <string key="NSAction">submenuAction:</string>
- <object class="NSMenu" key="NSSubmenu" id="821388474">
- <string key="NSTitle">Dienste</string>
- <array class="NSMutableArray" key="NSMenuItems"/>
- <string key="NSName">_NSServicesMenu</string>
- </object>
- </object>
- <object class="NSMenuItem" id="431301145">
- <reference key="NSMenu" ref="576521955"/>
- <bool key="NSIsDisabled">YES</bool>
- <bool key="NSIsSeparator">YES</bool>
- <string key="NSTitle"/>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="6876565">
- <reference key="NSMenu" ref="576521955"/>
- <string key="NSTitle">Vollbildmodus ein-/ausschalten</string>
- <string key="NSKeyEquiv">a</string>
- <int key="NSKeyEquivModMask">1572864</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="479677589">
- <reference key="NSMenu" ref="576521955"/>
- <bool key="NSIsDisabled">YES</bool>
- <bool key="NSIsSeparator">YES</bool>
- <string key="NSTitle"/>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="301008465">
- <reference key="NSMenu" ref="576521955"/>
- <string key="NSTitle">X11 ausblenden</string>
- <string key="NSKeyEquiv">h</string>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- <int key="NSTag">42</int>
- </object>
- <object class="NSMenuItem" id="206802571">
- <reference key="NSMenu" ref="576521955"/>
- <string key="NSTitle">Andere ausblenden</string>
- <string key="NSKeyEquiv">h</string>
- <int key="NSKeyEquivModMask">1572864</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="1023546148">
- <reference key="NSMenu" ref="576521955"/>
- <string key="NSTitle">Alle einblenden</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- <int key="NSTag">42</int>
- </object>
- <object class="NSMenuItem" id="848095279">
- <reference key="NSMenu" ref="576521955"/>
- <bool key="NSIsDisabled">YES</bool>
- <bool key="NSIsSeparator">YES</bool>
- <string key="NSTitle"/>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="274138642">
- <reference key="NSMenu" ref="576521955"/>
- <string key="NSTitle">X11 beenden</string>
- <string key="NSKeyEquiv">q</string>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- </array>
- <string key="NSName">_NSAppleMenu</string>
- </object>
- </object>
- <object class="NSMenuItem" id="868031522">
- <reference key="NSMenu" ref="524015605"/>
- <string key="NSTitle">Programme</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- <string key="NSAction">submenuAction:</string>
- <object class="NSMenu" key="NSSubmenu" id="981161348">
- <string key="NSTitle">Programme</string>
- <array class="NSMutableArray" key="NSMenuItems">
- <object class="NSMenuItem" id="390088328">
- <reference key="NSMenu" ref="981161348"/>
- <bool key="NSIsDisabled">YES</bool>
- <bool key="NSIsSeparator">YES</bool>
- <string key="NSTitle"/>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="1065386165">
- <reference key="NSMenu" ref="981161348"/>
- <string key="NSTitle">Anpassen …</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- </array>
- </object>
- </object>
- <object class="NSMenuItem" id="200491363">
- <reference key="NSMenu" ref="524015605"/>
- <string key="NSTitle">Bearbeiten</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- <string key="NSAction">submenuAction:</string>
- <object class="NSMenu" key="NSSubmenu" id="526778998">
- <string key="NSTitle">Bearbeiten</string>
- <array class="NSMutableArray" key="NSMenuItems">
- <object class="NSMenuItem" id="185296989">
- <reference key="NSMenu" ref="526778998"/>
- <string key="NSTitle">Kopieren</string>
- <string key="NSKeyEquiv">c</string>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- </array>
- </object>
- </object>
- <object class="NSMenuItem" id="931553638">
- <reference key="NSMenu" ref="524015605"/>
- <string key="NSTitle">Fenster</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- <string key="NSAction">submenuAction:</string>
- <object class="NSMenu" key="NSSubmenu" id="96874957">
- <string key="NSTitle">Fenster</string>
- <array class="NSMutableArray" key="NSMenuItems">
- <object class="NSMenuItem" id="984461797">
- <reference key="NSMenu" ref="96874957"/>
- <string key="NSTitle">Schließen</string>
- <string key="NSKeyEquiv">w</string>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="677652931">
- <reference key="NSMenu" ref="96874957"/>
- <string key="NSTitle">Im Dock ablegen</string>
- <string key="NSKeyEquiv">m</string>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="1066447520">
- <reference key="NSMenu" ref="96874957"/>
- <string key="NSTitle">Zoomen</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="280172320">
- <reference key="NSMenu" ref="96874957"/>
- <bool key="NSIsDisabled">YES</bool>
- <bool key="NSIsSeparator">YES</bool>
- <string key="NSTitle"/>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="1036389925">
- <reference key="NSMenu" ref="96874957"/>
- <string key="NSTitle">Vorwärts blättern</string>
- <string key="NSKeyEquiv">&lt;</string>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="369641893">
- <reference key="NSMenu" ref="96874957"/>
- <string key="NSTitle">Rückwärts blättern</string>
- <string key="NSKeyEquiv">&gt;</string>
- <int key="NSKeyEquivModMask">1179648</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="155085383">
- <reference key="NSMenu" ref="96874957"/>
- <bool key="NSIsDisabled">YES</bool>
- <bool key="NSIsSeparator">YES</bool>
- <string key="NSTitle"/>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="276216762">
- <reference key="NSMenu" ref="96874957"/>
- <string key="NSTitle">Alle nach vorne bringen</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- </array>
- <string key="NSName">_NSWindowsMenu</string>
- </object>
- </object>
- <object class="NSMenuItem" id="551174276">
- <reference key="NSMenu" ref="524015605"/>
- <string key="NSTitle">Hilfe</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- <string key="NSAction">submenuAction:</string>
- <object class="NSMenu" key="NSSubmenu" id="511848303">
- <string key="NSTitle">Hilfe</string>
- <array class="NSMutableArray" key="NSMenuItems">
- <object class="NSMenuItem" id="504984881">
- <reference key="NSMenu" ref="511848303"/>
- <string key="NSTitle">X11 Hilfe</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- </array>
- </object>
- </object>
- </array>
- <string key="NSName">_NSMainMenu</string>
- </object>
- <object class="NSCustomObject" id="485884620">
- <string key="NSClassName">X11Controller</string>
- </object>
- <object class="NSWindowTemplate" id="124913468">
- <int key="NSWindowStyleMask">3</int>
- <int key="NSWindowBacking">2</int>
- <string key="NSWindowRect">{{2350, 1291.0391}, {550, 341}}</string>
- <int key="NSWTFlags">1350041600</int>
- <string key="NSWindowTitle">X11 Einstellungen</string>
- <string key="NSWindowClass">NSPanel</string>
- <object class="NSMutableString" key="NSViewClass">
- <characters key="NS.bytes">View</characters>
- </object>
- <nil key="NSUserInterfaceItemIdentifier"/>
- <string key="NSWindowContentMaxSize">{1.7976931348623157e+308, 1.7976931348623157e+308}</string>
- <string key="NSWindowContentMinSize">{320, 240}</string>
- <object class="NSView" key="NSWindowView" id="941366957">
- <nil key="NSNextResponder"/>
- <int key="NSvFlags">256</int>
- <array class="NSMutableArray" key="NSSubviews">
- <object class="NSTabView" id="448510093">
- <reference key="NSNextResponder" ref="941366957"/>
- <int key="NSvFlags">274</int>
- <string key="NSFrame">{{13, 10}, {524, 325}}</string>
- <reference key="NSSuperview" ref="941366957"/>
- <array class="NSMutableArray" key="NSTabViewItems">
- <object class="NSTabViewItem" id="287591690">
- <object class="NSMutableString" key="NSIdentifier">
- <characters key="NS.bytes">1</characters>
- </object>
- <object class="NSView" key="NSView" id="596750588">
- <nil key="NSNextResponder"/>
- <int key="NSvFlags">256</int>
- <array class="NSMutableArray" key="NSSubviews">
- <object class="NSButton" id="119157981">
- <reference key="NSNextResponder" ref="596750588"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{18, 243}, {402, 18}}</string>
- <reference key="NSSuperview" ref="596750588"/>
- <reference key="NSNextKeyView" ref="179949713"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="990762273">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">Drei Maustasten nachbilden</string>
- <object class="NSFont" key="NSSupport" id="463863101">
- <string key="NSName">LucidaGrande</string>
- <double key="NSSize">13</double>
- <int key="NSfFlags">1044</int>
- </object>
- <reference key="NSControlView" ref="119157981"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <object class="NSCustomResource" key="NSNormalImage" id="192701610">
- <string key="NSClassName">NSImage</string>
- <string key="NSResourceName">NSSwitch</string>
- </object>
- <object class="NSButtonImageSource" key="NSAlternateImage" id="391434389">
- <string key="NSImageName">NSSwitch</string>
- </object>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSTextField" id="443008216">
- <reference key="NSNextResponder" ref="596750588"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{36, 93}, {461, 28}}</string>
- <reference key="NSSuperview" ref="596750588"/>
- <reference key="NSNextKeyView" ref="406291430"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="391919450">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">Bei Aktivierung können die Tastenentsprechungen für die Menüleiste die X11-Programme stören, die Meta-Sondertasten verwenden.</string>
- <object class="NSFont" key="NSSupport" id="26">
- <string key="NSName">LucidaGrande</string>
- <double key="NSSize">11</double>
- <int key="NSfFlags">3100</int>
- </object>
- <string key="NSPlaceholderString"/>
- <reference key="NSControlView" ref="443008216"/>
- <object class="NSColor" key="NSBackgroundColor" id="57160303">
- <int key="NSColorSpace">6</int>
- <string key="NSCatalogName">System</string>
- <string key="NSColorName">controlColor</string>
- <object class="NSColor" key="NSColor" id="590688762">
- <int key="NSColorSpace">3</int>
- <bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes>
- </object>
- </object>
- <object class="NSColor" key="NSTextColor" id="930815747">
- <int key="NSColorSpace">6</int>
- <string key="NSCatalogName">System</string>
- <string key="NSColorName">controlTextColor</string>
- <object class="NSColor" key="NSColor" id="214098874">
- <int key="NSColorSpace">3</int>
- <bytes key="NSWhite">MAA</bytes>
- </object>
- </object>
- </object>
- </object>
- <object class="NSTextField" id="282885445">
- <reference key="NSNextResponder" ref="596750588"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{36, 203}, {461, 34}}</string>
- <reference key="NSSuperview" ref="596750588"/>
- <reference key="NSNextKeyView" ref="31160162"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="649334366">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string type="base64-UTF8" key="NSContents">SGFsdGVuIFNpZSBiZWltIEtsaWNrZW4gZGllIFdhaGx0YXN0ZSBvZGVyIGRpZSBCZWZlaGxzdGFzdGUg
-Z2VkcsO8Y2t0LCB1bSBkaWUgbWl0dGxlcmUgb2RlciBkaWUgcmVjaHRlIE1hdXN0YXN0ZSB6dSBha3Rp
-dmllcmVuLgo</string>
- <reference key="NSSupport" ref="26"/>
- <string key="NSPlaceholderString"/>
- <reference key="NSControlView" ref="282885445"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- <object class="NSButton" id="842100515">
- <reference key="NSNextResponder" ref="596750588"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{18, 127}, {402, 18}}</string>
- <reference key="NSSuperview" ref="596750588"/>
- <reference key="NSNextKeyView" ref="443008216"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="940564599">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">Tastenentsprechungen unter X11 aktivieren</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="842100515"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="192701610"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSTextField" id="31160162">
- <reference key="NSNextResponder" ref="596750588"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{36, 151}, {461, 28}}</string>
- <reference key="NSSuperview" ref="596750588"/>
- <reference key="NSNextKeyView" ref="842100515"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="666057093">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">Bei Aktivierung kann Ihre aktuelle X11-Keymap durch Änderungen des Tastaturmenüs überschrieben werden.</string>
- <reference key="NSSupport" ref="26"/>
- <string key="NSPlaceholderString"/>
- <reference key="NSControlView" ref="31160162"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- <object class="NSButton" id="179949713">
- <reference key="NSNextResponder" ref="596750588"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{18, 185}, {402, 18}}</string>
- <reference key="NSSuperview" ref="596750588"/>
- <reference key="NSNextKeyView" ref="282885445"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="967619578">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">Tastaturbelegung des Systems verwenden</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="179949713"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="192701610"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSTextField" id="278155937">
- <reference key="NSNextResponder" ref="596750588"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{36, 32}, {461, 31}}</string>
- <reference key="NSSuperview" ref="596750588"/>
- <reference key="NSNextKeyView" ref="863505041"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="617441821">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">Bei Aktivierung entsprechen die Wahltasten Alt_L und Alt_R X11-Tastensymbolen anstatt „Mode_switch“.</string>
- <reference key="NSSupport" ref="26"/>
- <reference key="NSControlView" ref="278155937"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- <object class="NSButton" id="406291430">
- <reference key="NSNextResponder" ref="596750588"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{18, 69}, {402, 18}}</string>
- <reference key="NSSuperview" ref="596750588"/>
- <reference key="NSNextKeyView" ref="278155937"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="67728988">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">Wahltasten entsprechen Alt_L und Alt_R</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="406291430"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="192701610"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSButton" id="863505041">
- <reference key="NSNextResponder" ref="596750588"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{18, 8}, {418, 18}}</string>
- <reference key="NSSuperview" ref="596750588"/>
- <reference key="NSNextKeyView" ref="448510093"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="1016286396">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">Immer in Bewegungsrichtung der Finger scrollen</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="863505041"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="192701610"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- </array>
- <string key="NSFrame">{{10, 33}, {504, 279}}</string>
- <reference key="NSNextKeyView" ref="119157981"/>
- </object>
- <string key="NSLabel">Eingabe</string>
- <reference key="NSColor" ref="57160303"/>
- <reference key="NSTabView" ref="448510093"/>
- </object>
- <object class="NSTabViewItem" id="960678392">
- <object class="NSMutableString" key="NSIdentifier">
- <characters key="NS.bytes">2</characters>
- </object>
- <object class="NSView" key="NSView" id="515308735">
- <nil key="NSNextResponder"/>
- <int key="NSvFlags">256</int>
- <array class="NSMutableArray" key="NSSubviews">
- <object class="NSPopUpButton" id="709074847">
- <reference key="NSNextResponder" ref="515308735"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{74, 235}, {197, 26}}</string>
- <reference key="NSSuperview" ref="515308735"/>
- <reference key="NSNextKeyView" ref="86150604"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSPopUpButtonCell" key="NSCell" id="633115429">
- <int key="NSCellFlags">-2076049856</int>
- <int key="NSCellFlags2">1024</int>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="709074847"/>
- <int key="NSButtonFlags">109199615</int>
- <int key="NSButtonFlags2">1</int>
- <object class="NSFont" key="NSAlternateImage">
- <string key="NSName">LucidaGrande</string>
- <double key="NSSize">13</double>
- <int key="NSfFlags">16</int>
- </object>
- <string key="NSAlternateContents"/>
- <object class="NSMutableString" key="NSKeyEquivalent">
- <characters key="NS.bytes"/>
- </object>
- <int key="NSPeriodicDelay">400</int>
- <int key="NSPeriodicInterval">75</int>
- <object class="NSMenuItem" key="NSMenuItem" id="616492372">
- <reference key="NSMenu" ref="341113515"/>
- <string key="NSTitle">Vom Monitor</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <int key="NSState">1</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- <string key="NSAction">_popUpItemAction:</string>
- <int key="NSTag">-1</int>
- <reference key="NSTarget" ref="633115429"/>
- </object>
- <bool key="NSMenuItemRespectAlignment">YES</bool>
- <object class="NSMenu" key="NSMenu" id="341113515">
- <object class="NSMutableString" key="NSTitle">
- <characters key="NS.bytes">OtherViews</characters>
- </object>
- <array class="NSMutableArray" key="NSMenuItems">
- <reference ref="616492372"/>
- <object class="NSMenuItem" id="759499526">
- <reference key="NSMenu" ref="341113515"/>
- <string key="NSTitle">256 Farben</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- <string key="NSAction">_popUpItemAction:</string>
- <int key="NSTag">8</int>
- <reference key="NSTarget" ref="633115429"/>
- </object>
- <object class="NSMenuItem" id="543935434">
- <reference key="NSMenu" ref="341113515"/>
- <string key="NSTitle">32768 Farben</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- <string key="NSAction">_popUpItemAction:</string>
- <int key="NSTag">15</int>
- <reference key="NSTarget" ref="633115429"/>
- </object>
- <object class="NSMenuItem" id="836673018">
- <reference key="NSMenu" ref="341113515"/>
- <string key="NSTitle">16,7 Millionen Farben</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- <string key="NSAction">_popUpItemAction:</string>
- <int key="NSTag">24</int>
- <reference key="NSTarget" ref="633115429"/>
- </object>
- </array>
- </object>
- <int key="NSPreferredEdge">3</int>
- <bool key="NSUsesItemFromMenu">YES</bool>
- <bool key="NSAltersState">YES</bool>
- <int key="NSArrowPosition">1</int>
- </object>
- </object>
- <object class="NSTextField" id="201731424">
- <reference key="NSNextResponder" ref="515308735"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{17, 238}, {55, 20}}</string>
- <reference key="NSSuperview" ref="515308735"/>
- <reference key="NSNextKeyView" ref="709074847"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="930265681">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">Farben:</string>
- <reference key="NSSupport" ref="463863101"/>
- <string key="NSPlaceholderString"/>
- <reference key="NSControlView" ref="201731424"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- <object class="NSTextField" id="86150604">
- <reference key="NSNextResponder" ref="515308735"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{36, 216}, {392, 14}}</string>
- <reference key="NSSuperview" ref="515308735"/>
- <reference key="NSNextKeyView" ref="477203622"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="311969422">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">Diese Option wird beim nächsten Start von X11 wirksam.</string>
- <reference key="NSSupport" ref="26"/>
- <string key="NSPlaceholderString"/>
- <reference key="NSControlView" ref="86150604"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- <object class="NSButton" id="477203622">
- <reference key="NSNextResponder" ref="515308735"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{18, 182}, {409, 23}}</string>
- <reference key="NSSuperview" ref="515308735"/>
- <reference key="NSNextKeyView" ref="298603383"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="631531164">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">Vollbildmodus</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="477203622"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="192701610"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSButton" id="57246850">
- <reference key="NSNextResponder" ref="515308735"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{37, 116}, {409, 23}}</string>
- <reference key="NSSuperview" ref="515308735"/>
- <reference key="NSNextKeyView" ref="331853183"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="917248662">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">Zugriff auf Menüleiste im Vollbildmodus erlauben</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="57246850"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="192701610"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSTextField" id="298603383">
- <reference key="NSNextResponder" ref="515308735"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{36, 145}, {461, 42}}</string>
- <reference key="NSSuperview" ref="515308735"/>
- <reference key="NSNextKeyView" ref="57246850"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="761107402">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">Hiermit wird das X11-Hauptfenster aktiviert. Verwenden Sie die Tastenkombination Befehl+Wahl+A, um den Vollbildmodus ein- oder auszuschalten.</string>
- <reference key="NSSupport" ref="26"/>
- <string key="NSPlaceholderString"/>
- <reference key="NSControlView" ref="298603383"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- <object class="NSTextField" id="331853183">
- <reference key="NSNextResponder" ref="515308735"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{54, 79}, {436, 31}}</string>
- <reference key="NSSuperview" ref="515308735"/>
- <reference key="NSNextKeyView" ref="448510093"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="1042813110">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">Die Menüleiste wird sichtbar, sobald Sie den Mauszeiger in den oberen Bereich Ihres primären Display bewegen.</string>
- <reference key="NSSupport" ref="26"/>
- <reference key="NSControlView" ref="331853183"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- </array>
- <string key="NSFrame">{{10, 33}, {504, 279}}</string>
- <reference key="NSNextKeyView" ref="201731424"/>
- </object>
- <string key="NSLabel">Ausgabe</string>
- <reference key="NSColor" ref="57160303"/>
- <reference key="NSTabView" ref="448510093"/>
- </object>
- <object class="NSTabViewItem" id="723450037">
- <object class="NSMutableString" key="NSIdentifier">
- <characters key="NS.bytes">2</characters>
- </object>
- <object class="NSView" key="NSView" id="408298283">
- <reference key="NSNextResponder" ref="448510093"/>
- <int key="NSvFlags">256</int>
- <array class="NSMutableArray" key="NSSubviews">
- <object class="NSButton" id="878106058">
- <reference key="NSNextResponder" ref="408298283"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{11, 255}, {409, 23}}</string>
- <reference key="NSSuperview" ref="408298283"/>
- <reference key="NSNextKeyView" ref="386152084"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="718083688">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">Synchronisierung aktivieren</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="878106058"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="192701610"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSTextField" id="386152084">
- <reference key="NSNextResponder" ref="408298283"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{29, 221}, {464, 28}}</string>
- <reference key="NSSuperview" ref="408298283"/>
- <reference key="NSNextKeyView" ref="487809555"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="572508492">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">Aktiviert das Menüobjekt „Kopieren“ und ermöglicht die Synchronisierung zwischen dem „OSX Pasteboard“ und den Pufferspeichern „CLIPBOARD“ und „PRIMARY“ von X11.</string>
- <reference key="NSSupport" ref="26"/>
- <reference key="NSControlView" ref="386152084"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- <object class="NSButton" id="477050998">
- <reference key="NSNextResponder" ref="408298283"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{27, 129}, {436, 18}}</string>
- <reference key="NSSuperview" ref="408298283"/>
- <reference key="NSNextKeyView" ref="765780304"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="501304422">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">CLIPBOARD aktualisieren, wenn Pasteboard geändert wird</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="477050998"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="192701610"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSButton" id="765780304">
- <reference key="NSNextResponder" ref="408298283"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{27, 104}, {463, 18}}</string>
- <reference key="NSSuperview" ref="408298283"/>
- <reference key="NSNextKeyView" ref="1002778833"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="510771323">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">PRIMARY (Mittel-Klick) aktualisieren, wenn Pasteboard geändert wird</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="765780304"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="192701610"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSButton" id="1002778833">
- <reference key="NSNextResponder" ref="408298283"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{27, 81}, {498, 18}}</string>
- <reference key="NSSuperview" ref="408298283"/>
- <reference key="NSNextKeyView" ref="522511724"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="897099877">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">Pasteboard sofort aktualisieren, wenn Text ausgewählt wird</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="1002778833"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="192701610"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSButton" id="487809555">
- <reference key="NSNextResponder" ref="408298283"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{27, 192}, {438, 18}}</string>
- <reference key="NSSuperview" ref="408298283"/>
- <reference key="NSNextKeyView" ref="620944856"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="619977658">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">Pasteboard aktualisieren, wenn CLIPBOARD geändert wird</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="487809555"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="192701610"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSTextField" id="620944856">
- <reference key="NSNextResponder" ref="408298283"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{41, 158}, {452, 28}}</string>
- <reference key="NSSuperview" ref="408298283"/>
- <reference key="NSNextKeyView" ref="477050998"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="461823902">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">Deaktivieren Sie diese Option, wenn Sie „xclipboard“, „klipper“ oder einen beliebigen anderen X11-Zwischenablage-Manager verwenden möchten.</string>
- <reference key="NSSupport" ref="26"/>
- <reference key="NSControlView" ref="620944856"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- <object class="NSTextField" id="522511724">
- <reference key="NSNextResponder" ref="408298283"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{41, 47}, {450, 28}}</string>
- <reference key="NSSuperview" ref="408298283"/>
- <reference key="NSNextKeyView" ref="448510093"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="994587858">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">Aufgrund von Einschränkungen im X11-Protokoll funktioniert diese Option in manchen Programmen u. U. nicht immer.</string>
- <reference key="NSSupport" ref="26"/>
- <reference key="NSControlView" ref="522511724"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- </array>
- <string key="NSFrame">{{10, 33}, {504, 279}}</string>
- <reference key="NSSuperview" ref="448510093"/>
- <reference key="NSNextKeyView" ref="878106058"/>
- </object>
- <string key="NSLabel">Zwischenablage</string>
- <reference key="NSColor" ref="57160303"/>
- <reference key="NSTabView" ref="448510093"/>
- </object>
- <object class="NSTabViewItem" id="10973343">
- <object class="NSMutableString" key="NSIdentifier">
- <characters key="NS.bytes">2</characters>
- </object>
- <object class="NSView" key="NSView" id="184765684">
- <nil key="NSNextResponder"/>
- <int key="NSvFlags">256</int>
- <array class="NSMutableArray" key="NSSubviews">
- <object class="NSButton" id="657659108">
- <reference key="NSNextResponder" ref="184765684"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{15, 245}, {213, 18}}</string>
- <reference key="NSSuperview" ref="184765684"/>
- <reference key="NSNextKeyView" ref="290578835"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="259618205">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">Durch inaktive Fenster klicken</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="657659108"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="192701610"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSTextField" id="290578835">
- <reference key="NSNextResponder" ref="184765684"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{23, 211}, {456, 28}}</string>
- <reference key="NSSuperview" ref="184765684"/>
- <reference key="NSNextKeyView" ref="992839333"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="399127858">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">Bei Aktivierung wird beim Klicken auf ein inaktives Fenster der Mausklick zusätzlich an dieses Fenster weitergegeben.</string>
- <reference key="NSSupport" ref="26"/>
- <reference key="NSControlView" ref="290578835"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- <object class="NSButton" id="992839333">
- <reference key="NSNextResponder" ref="184765684"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{15, 184}, {155, 18}}</string>
- <reference key="NSSuperview" ref="184765684"/>
- <reference key="NSNextKeyView" ref="138261120"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="959555182">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">Fokus folgt der Maus</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="992839333"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="192701610"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSTextField" id="138261120">
- <reference key="NSNextResponder" ref="184765684"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{23, 161}, {442, 17}}</string>
- <reference key="NSSuperview" ref="184765684"/>
- <reference key="NSNextKeyView" ref="128352289"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="183409141">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">Der Fokus des X11-Fensters folgt dem Cursor. Dies hat einige nachteilige Effekte.</string>
- <reference key="NSSupport" ref="26"/>
- <reference key="NSControlView" ref="138261120"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- <object class="NSButton" id="128352289">
- <reference key="NSNextResponder" ref="184765684"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{15, 140}, {402, 18}}</string>
- <reference key="NSSuperview" ref="184765684"/>
- <reference key="NSNextKeyView" ref="57161931"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="556463187">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">Fokus auf neuem Fenster</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="128352289"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="192701610"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSTextField" id="57161931">
- <reference key="NSNextResponder" ref="184765684"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{23, 92}, {456, 42}}</string>
- <reference key="NSSuperview" ref="184765684"/>
- <reference key="NSNextKeyView" ref="448510093"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="989804990">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">Bei Aktivierung wird beim Erzeugen eines neuen X11-Fensters das „X11.app“ in den Vordergrund gebracht (anstelle von „Finder.app“, „Terminal.app“ usw.).</string>
- <reference key="NSSupport" ref="26"/>
- <reference key="NSControlView" ref="57161931"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- </array>
- <string key="NSFrame">{{10, 33}, {504, 279}}</string>
- <reference key="NSNextKeyView" ref="657659108"/>
- </object>
- <string key="NSLabel">Fenster</string>
- <reference key="NSColor" ref="57160303"/>
- <reference key="NSTabView" ref="448510093"/>
- </object>
- <object class="NSTabViewItem" id="348328898">
- <object class="NSView" key="NSView" id="300811574">
- <nil key="NSNextResponder"/>
- <int key="NSvFlags">256</int>
- <array class="NSMutableArray" key="NSSubviews">
- <object class="NSButton" id="989050925">
- <reference key="NSNextResponder" ref="300811574"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{18, 243}, {215, 18}}</string>
- <reference key="NSSuperview" ref="300811574"/>
- <reference key="NSNextKeyView" ref="168436707"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="189594322">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">Verbindungen authentifizieren</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="989050925"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="192701610"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSButton" id="700826966">
- <reference key="NSNextResponder" ref="300811574"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{18, 166}, {312, 18}}</string>
- <reference key="NSSuperview" ref="300811574"/>
- <reference key="NSNextKeyView" ref="363817195"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="489340979">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">Verbindungen von Netzwerk-Clients erlauben</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="700826966"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="192701610"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSTextField" id="168436707">
- <reference key="NSNextResponder" ref="300811574"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{36, 189}, {463, 48}}</string>
- <reference key="NSSuperview" ref="300811574"/>
- <reference key="NSNextKeyView" ref="700826966"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="53243865">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">Beim Starten von X11 werden Xauthority-Schlüssel zur Zugriffskontrolle erstellt. Wenn sich die IP-Adresse des Systems ändert, sind diese Schlüssel nicht mehr gültig. Möglicherweise können die X11-Programme dann nicht mehr gestartet werden.</string>
- <reference key="NSSupport" ref="26"/>
- <string key="NSPlaceholderString"/>
- <reference key="NSControlView" ref="168436707"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- <object class="NSTextField" id="363817195">
- <reference key="NSNextResponder" ref="300811574"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{36, 104}, {463, 56}}</string>
- <reference key="NSSuperview" ref="300811574"/>
- <reference key="NSNextKeyView" ref="223835729"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="390084685">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">Bei Aktivierung muss „Verbindungen authentifizieren“ ebenfalls aktiviert sein, damit die Sicherheit des System gewährleistet ist. Bei Deaktivierung sind Verbindungen von entfernten Programmen nicht erlaubt.</string>
- <reference key="NSSupport" ref="26"/>
- <string key="NSPlaceholderString"/>
- <reference key="NSControlView" ref="363817195"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- <object class="NSTextField" id="223835729">
- <reference key="NSNextResponder" ref="300811574"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{17, 17}, {404, 14}}</string>
- <reference key="NSSuperview" ref="300811574"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="283628678">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">Diese Optionen werden beim nächsten Start von X11 wirksam.</string>
- <reference key="NSSupport" ref="26"/>
- <string key="NSPlaceholderString"/>
- <reference key="NSControlView" ref="223835729"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- </array>
- <string key="NSFrame">{{10, 33}, {504, 279}}</string>
- <reference key="NSNextKeyView" ref="989050925"/>
- </object>
- <string key="NSLabel">Sicherheit</string>
- <reference key="NSColor" ref="57160303"/>
- <reference key="NSTabView" ref="448510093"/>
- </object>
- </array>
- <reference key="NSSelectedTabViewItem" ref="723450037"/>
- <reference key="NSFont" ref="463863101"/>
- <int key="NSTvFlags">0</int>
- <bool key="NSAllowTruncatedLabels">YES</bool>
- <bool key="NSDrawsBackground">YES</bool>
- <array class="NSMutableArray" key="NSSubviews">
- <reference ref="408298283"/>
- </array>
- </object>
- </array>
- <string key="NSFrameSize">{550, 341}</string>
- <reference key="NSNextKeyView" ref="448510093"/>
- </object>
- <string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
- <string key="NSMinSize">{320, 262}</string>
- <string key="NSMaxSize">{1.7976931348623157e+308, 1.7976931348623157e+308}</string>
- <string key="NSFrameAutosaveName">x11_prefs</string>
- </object>
- <object class="NSWindowTemplate" id="604417141">
- <int key="NSWindowStyleMask">11</int>
- <int key="NSWindowBacking">2</int>
- <string key="NSWindowRect">{{360, 400}, {512, 271}}</string>
- <int key="NSWTFlags">1350041600</int>
- <string key="NSWindowTitle">X11-Programmmenü</string>
- <string key="NSWindowClass">NSPanel</string>
- <object class="NSMutableString" key="NSViewClass">
- <characters key="NS.bytes">View</characters>
- </object>
- <nil key="NSUserInterfaceItemIdentifier"/>
- <string key="NSWindowContentMaxSize">{1.7976931348623157e+308, 1.7976931348623157e+308}</string>
- <string key="NSWindowContentMinSize">{512, 240}</string>
- <object class="NSView" key="NSWindowView" id="85544634">
- <nil key="NSNextResponder"/>
- <int key="NSvFlags">256</int>
- <array class="NSMutableArray" key="NSSubviews">
- <object class="NSButton" id="671954382">
- <reference key="NSNextResponder" ref="85544634"/>
- <int key="NSvFlags">265</int>
- <string key="NSFrame">{{340, 191}, {158, 32}}</string>
- <reference key="NSSuperview" ref="85544634"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="143554520">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">137887744</int>
- <string key="NSContents">Duplizieren</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="671954382"/>
- <int key="NSButtonFlags">-2038284033</int>
- <int key="NSButtonFlags2">1</int>
- <object class="NSFont" key="NSAlternateImage" id="549406736">
- <string key="NSName">Helvetica</string>
- <double key="NSSize">13</double>
- <int key="NSfFlags">16</int>
- </object>
- <string key="NSAlternateContents"/>
- <object class="NSMutableString" key="NSKeyEquivalent">
- <characters key="NS.bytes"/>
- </object>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSButton" id="492358940">
- <reference key="NSNextResponder" ref="85544634"/>
- <int key="NSvFlags">265</int>
- <string key="NSFrame">{{340, 159}, {158, 32}}</string>
- <reference key="NSSuperview" ref="85544634"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="8201128">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">137887744</int>
- <string key="NSContents">Entfernen</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="492358940"/>
- <int key="NSButtonFlags">-2038284033</int>
- <int key="NSButtonFlags2">1</int>
- <reference key="NSAlternateImage" ref="549406736"/>
- <string key="NSAlternateContents"/>
- <object class="NSMutableString" key="NSKeyEquivalent">
- <characters key="NS.bytes"/>
- </object>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSScrollView" id="1063387772">
- <reference key="NSNextResponder" ref="85544634"/>
- <int key="NSvFlags">274</int>
- <array class="NSMutableArray" key="NSSubviews">
- <object class="NSClipView" id="580565898">
- <reference key="NSNextResponder" ref="1063387772"/>
- <int key="NSvFlags">2304</int>
- <array class="NSMutableArray" key="NSSubviews">
- <object class="NSTableView" id="905092943">
- <reference key="NSNextResponder" ref="580565898"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrameSize">{301, 198}</string>
- <reference key="NSSuperview" ref="580565898"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTableHeaderView" key="NSHeaderView" id="792419186">
- <reference key="NSNextResponder" ref="672307654"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrameSize">{301, 17}</string>
- <reference key="NSSuperview" ref="672307654"/>
- <reference key="NSTableView" ref="905092943"/>
- </object>
- <object class="_NSCornerView" key="NSCornerView" id="898633680">
- <reference key="NSNextResponder" ref="1063387772"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{302, 0}, {16, 17}}</string>
- <reference key="NSSuperview" ref="1063387772"/>
- </object>
- <array class="NSMutableArray" key="NSTableColumns">
- <object class="NSTableColumn" id="938444323">
- <double key="NSWidth">122.73100280761719</double>
- <double key="NSMinWidth">62.730998992919922</double>
- <double key="NSMaxWidth">1000</double>
- <object class="NSTableHeaderCell" key="NSHeaderCell">
- <int key="NSCellFlags">75628096</int>
- <int key="NSCellFlags2">2048</int>
- <string key="NSContents">Name</string>
- <reference key="NSSupport" ref="26"/>
- <object class="NSColor" key="NSBackgroundColor" id="113872566">
- <int key="NSColorSpace">3</int>
- <bytes key="NSWhite">MC4zMzMzMzI5ODU2AA</bytes>
- </object>
- <object class="NSColor" key="NSTextColor" id="249576247">
- <int key="NSColorSpace">6</int>
- <string key="NSCatalogName">System</string>
- <string key="NSColorName">headerTextColor</string>
- <reference key="NSColor" ref="214098874"/>
- </object>
- </object>
- <object class="NSTextFieldCell" key="NSDataCell" id="825378892">
- <int key="NSCellFlags">338820672</int>
- <int key="NSCellFlags2">1024</int>
- <string key="NSContents">Textzelle</string>
- <reference key="NSSupport" ref="463863101"/>
- <string key="NSPlaceholderString"/>
- <reference key="NSControlView" ref="905092943"/>
- <object class="NSColor" key="NSBackgroundColor" id="822946413">
- <int key="NSColorSpace">3</int>
- <bytes key="NSWhite">MQA</bytes>
- </object>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- <int key="NSResizingMask">3</int>
- <bool key="NSIsResizeable">YES</bool>
- <bool key="NSIsEditable">YES</bool>
- <reference key="NSTableView" ref="905092943"/>
- </object>
- <object class="NSTableColumn" id="84282687">
- <double key="NSWidth">100</double>
- <double key="NSMinWidth">40</double>
- <double key="NSMaxWidth">1000</double>
- <object class="NSTableHeaderCell" key="NSHeaderCell">
- <int key="NSCellFlags">75628096</int>
- <int key="NSCellFlags2">2048</int>
- <string key="NSContents">Befehl</string>
- <reference key="NSSupport" ref="26"/>
- <reference key="NSBackgroundColor" ref="113872566"/>
- <reference key="NSTextColor" ref="249576247"/>
- </object>
- <object class="NSTextFieldCell" key="NSDataCell" id="432610585">
- <int key="NSCellFlags">338820672</int>
- <int key="NSCellFlags2">1024</int>
- <string key="NSContents">Textzelle</string>
- <reference key="NSSupport" ref="463863101"/>
- <string key="NSPlaceholderString"/>
- <reference key="NSControlView" ref="905092943"/>
- <reference key="NSBackgroundColor" ref="822946413"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- <int key="NSResizingMask">3</int>
- <bool key="NSIsResizeable">YES</bool>
- <bool key="NSIsEditable">YES</bool>
- <reference key="NSTableView" ref="905092943"/>
- </object>
- <object class="NSTableColumn" id="242608782">
- <double key="NSWidth">69</double>
- <double key="NSMinWidth">10</double>
- <double key="NSMaxWidth">1000</double>
- <object class="NSTableHeaderCell" key="NSHeaderCell">
- <int key="NSCellFlags">75628096</int>
- <int key="NSCellFlags2">2048</int>
- <string key="NSContents">Kurzbefehl</string>
- <reference key="NSSupport" ref="26"/>
- <object class="NSColor" key="NSBackgroundColor">
- <int key="NSColorSpace">6</int>
- <string key="NSCatalogName">System</string>
- <string key="NSColorName">headerColor</string>
- <reference key="NSColor" ref="822946413"/>
- </object>
- <reference key="NSTextColor" ref="249576247"/>
- </object>
- <object class="NSTextFieldCell" key="NSDataCell" id="34714764">
- <int key="NSCellFlags">338820672</int>
- <int key="NSCellFlags2">1024</int>
- <string key="NSContents">Textzelle</string>
- <object class="NSFont" key="NSSupport">
- <string key="NSName">LucidaGrande</string>
- <double key="NSSize">12</double>
- <int key="NSfFlags">16</int>
- </object>
- <string key="NSPlaceholderString"/>
- <reference key="NSControlView" ref="905092943"/>
- <bool key="NSDrawsBackground">YES</bool>
- <object class="NSColor" key="NSBackgroundColor" id="812484075">
- <int key="NSColorSpace">6</int>
- <string key="NSCatalogName">System</string>
- <string key="NSColorName">controlBackgroundColor</string>
- <reference key="NSColor" ref="590688762"/>
- </object>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- <int key="NSResizingMask">3</int>
- <bool key="NSIsResizeable">YES</bool>
- <bool key="NSIsEditable">YES</bool>
- <reference key="NSTableView" ref="905092943"/>
- </object>
- </array>
- <double key="NSIntercellSpacingWidth">3</double>
- <double key="NSIntercellSpacingHeight">2</double>
- <reference key="NSBackgroundColor" ref="822946413"/>
- <object class="NSColor" key="NSGridColor">
- <int key="NSColorSpace">6</int>
- <string key="NSCatalogName">System</string>
- <string key="NSColorName">gridColor</string>
- <object class="NSColor" key="NSColor">
- <int key="NSColorSpace">3</int>
- <bytes key="NSWhite">MC41AA</bytes>
- </object>
- </object>
- <double key="NSRowHeight">17</double>
- <int key="NSTvFlags">1379958784</int>
- <reference key="NSDelegate"/>
- <reference key="NSDataSource"/>
- <int key="NSColumnAutoresizingStyle">1</int>
- <int key="NSDraggingSourceMaskForLocal">-1</int>
- <int key="NSDraggingSourceMaskForNonLocal">0</int>
- <bool key="NSAllowsTypeSelect">YES</bool>
- <int key="NSTableViewDraggingDestinationStyle">0</int>
- <int key="NSTableViewGroupRowStyle">1</int>
- </object>
- </array>
- <string key="NSFrame">{{1, 17}, {301, 198}}</string>
- <reference key="NSSuperview" ref="1063387772"/>
- <reference key="NSNextKeyView" ref="905092943"/>
- <reference key="NSDocView" ref="905092943"/>
- <reference key="NSBGColor" ref="812484075"/>
- <int key="NScvFlags">4</int>
- </object>
- <object class="NSScroller" id="842897584">
- <reference key="NSNextResponder" ref="1063387772"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{302, 17}, {15, 198}}</string>
- <reference key="NSSuperview" ref="1063387772"/>
- <reference key="NSTarget" ref="1063387772"/>
- <string key="NSAction">_doScroller:</string>
- <double key="NSPercent">0.99492377042770386</double>
- </object>
- <object class="NSScroller" id="17278747">
- <reference key="NSNextResponder" ref="1063387772"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{1, 215}, {301, 15}}</string>
- <reference key="NSSuperview" ref="1063387772"/>
- <int key="NSsFlags">1</int>
- <reference key="NSTarget" ref="1063387772"/>
- <string key="NSAction">_doScroller:</string>
- <double key="NSPercent">0.68852460384368896</double>
- </object>
- <object class="NSClipView" id="672307654">
- <reference key="NSNextResponder" ref="1063387772"/>
- <int key="NSvFlags">2304</int>
- <array class="NSMutableArray" key="NSSubviews">
- <reference ref="792419186"/>
- </array>
- <string key="NSFrame">{{1, 0}, {301, 17}}</string>
- <reference key="NSSuperview" ref="1063387772"/>
- <reference key="NSNextKeyView" ref="792419186"/>
- <reference key="NSDocView" ref="792419186"/>
- <reference key="NSBGColor" ref="812484075"/>
- <int key="NScvFlags">4</int>
- </object>
- <reference ref="898633680"/>
- </array>
- <string key="NSFrame">{{20, 20}, {318, 231}}</string>
- <reference key="NSSuperview" ref="85544634"/>
- <reference key="NSNextKeyView" ref="580565898"/>
- <int key="NSsFlags">133170</int>
- <reference key="NSVScroller" ref="842897584"/>
- <reference key="NSHScroller" ref="17278747"/>
- <reference key="NSContentView" ref="580565898"/>
- <reference key="NSHeaderClipView" ref="672307654"/>
- <bytes key="NSScrollAmts">QSAAAEEgAABBmAAAQZgAAA</bytes>
- </object>
- <object class="NSButton" id="758204686">
- <reference key="NSNextResponder" ref="85544634"/>
- <int key="NSvFlags">265</int>
- <string key="NSFrame">{{340, 223}, {158, 32}}</string>
- <reference key="NSSuperview" ref="85544634"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="1025474039">
- <int key="NSCellFlags">-2080244224</int>
- <int key="NSCellFlags2">137887744</int>
- <string key="NSContents">Objekt hinzufügen</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="758204686"/>
- <int key="NSButtonFlags">-2038284033</int>
- <int key="NSButtonFlags2">1</int>
- <reference key="NSAlternateImage" ref="549406736"/>
- <string key="NSAlternateContents"/>
- <object class="NSMutableString" key="NSKeyEquivalent">
- <characters key="NS.bytes"/>
- </object>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- </array>
- <string key="NSFrameSize">{512, 271}</string>
- </object>
- <string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
- <string key="NSMinSize">{512, 262}</string>
- <string key="NSMaxSize">{1.7976931348623157e+308, 1.7976931348623157e+308}</string>
- <string key="NSFrameAutosaveName">x11_apps</string>
- </object>
- <object class="NSMenu" id="294137138">
- <string key="NSTitle">Menü</string>
- <array class="NSMutableArray" key="NSMenuItems">
- <object class="NSMenuItem" id="318286212">
- <reference key="NSMenu" ref="294137138"/>
- <bool key="NSIsDisabled">YES</bool>
- <bool key="NSIsSeparator">YES</bool>
- <string key="NSTitle"/>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="511651072">
- <reference key="NSMenu" ref="294137138"/>
- <string key="NSTitle">Programme</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- <string key="NSAction">submenuAction:</string>
- <object class="NSMenu" key="NSSubmenu" id="48278059">
- <string key="NSTitle">Programme</string>
- <array class="NSMutableArray" key="NSMenuItems">
- <object class="NSMenuItem" id="563798000">
- <reference key="NSMenu" ref="48278059"/>
- <bool key="NSIsDisabled">YES</bool>
- <bool key="NSIsSeparator">YES</bool>
- <string key="NSTitle"/>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="1032342329">
- <reference key="NSMenu" ref="48278059"/>
- <string key="NSTitle">Anpassen …</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- </array>
- </object>
- </object>
- </array>
- <string key="NSName"/>
- </object>
- </array>
- <object class="IBObjectContainer" key="IBDocument.Objects">
- <array class="NSMutableArray" key="connectionRecords">
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">copy:</string>
- <reference key="source" ref="941939442"/>
- <reference key="destination" ref="185296989"/>
- </object>
- <int key="connectionID">181</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">minimize_window:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="677652931"/>
- </object>
- <int key="connectionID">202</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">close_window:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="984461797"/>
- </object>
- <int key="connectionID">205</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">zoom_window:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="1066447520"/>
- </object>
- <int key="connectionID">206</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">bring_to_front:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="276216762"/>
- </object>
- <int key="connectionID">207</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">hideOtherApplications:</string>
- <reference key="source" ref="815810918"/>
- <reference key="destination" ref="206802571"/>
- </object>
- <int key="connectionID">263</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">apps_separator</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="390088328"/>
- </object>
- <int key="connectionID">273</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">apps_table</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="905092943"/>
- </object>
- <int key="connectionID">301</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">apps_table_delete:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="492358940"/>
- </object>
- <int key="connectionID">303</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">apps_table_duplicate:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="671954382"/>
- </object>
- <int key="connectionID">304</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">apps_table_show:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="1065386165"/>
- </object>
- <int key="connectionID">308</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">apps_table_new:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="758204686"/>
- </object>
- <int key="connectionID">311</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_show:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="386173216"/>
- </object>
- <int key="connectionID">318</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">x11_about_item</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="139290918"/>
- </object>
- <int key="connectionID">321</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">enable_auth</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="989050925"/>
- </object>
- <int key="connectionID">387</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">enable_tcp</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="700826966"/>
- </object>
- <int key="connectionID">388</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">depth</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="709074847"/>
- </object>
- <int key="connectionID">389</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">fake_buttons</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="119157981"/>
- </object>
- <int key="connectionID">391</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">sync_keymap</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="179949713"/>
- </object>
- <int key="connectionID">392</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">enable_keyequivs</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="842100515"/>
- </object>
- <int key="connectionID">393</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="119157981"/>
- </object>
- <int key="connectionID">394</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="179949713"/>
- </object>
- <int key="connectionID">395</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="842100515"/>
- </object>
- <int key="connectionID">396</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="709074847"/>
- </object>
- <int key="connectionID">398</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="989050925"/>
- </object>
- <int key="connectionID">399</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="700826966"/>
- </object>
- <int key="connectionID">401</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">prefs_panel</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="124913468"/>
- </object>
- <int key="connectionID">402</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">x11_help:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="504984881"/>
- </object>
- <int key="connectionID">422</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">dockMenu</string>
- <reference key="source" ref="815810918"/>
- <reference key="destination" ref="294137138"/>
- </object>
- <int key="connectionID">426</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">dock_menu</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="294137138"/>
- </object>
- <int key="connectionID">428</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">delegate</string>
- <reference key="source" ref="815810918"/>
- <reference key="destination" ref="485884620"/>
- </object>
- <int key="connectionID">429</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">hide:</string>
- <reference key="source" ref="815810918"/>
- <reference key="destination" ref="301008465"/>
- </object>
- <int key="connectionID">430</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">unhideAllApplications:</string>
- <reference key="source" ref="815810918"/>
- <reference key="destination" ref="1023546148"/>
- </object>
- <int key="connectionID">431</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">orderFrontStandardAboutPanel:</string>
- <reference key="source" ref="815810918"/>
- <reference key="destination" ref="139290918"/>
- </object>
- <int key="connectionID">433</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">dock_apps_menu</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="48278059"/>
- </object>
- <int key="connectionID">530</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">dock_window_separator</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="318286212"/>
- </object>
- <int key="connectionID">531</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">apps_table_show:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="1032342329"/>
- </object>
- <int key="connectionID">534</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">next_window:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="1036389925"/>
- </object>
- <int key="connectionID">539</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">previous_window:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="369641893"/>
- </object>
- <int key="connectionID">540</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">enable_fullscreen</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="477203622"/>
- </object>
- <int key="connectionID">546</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">enable_fullscreen_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="477203622"/>
- </object>
- <int key="connectionID">547</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">toggle_fullscreen:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="6876565"/>
- </object>
- <int key="connectionID">548</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">toggle_fullscreen_item</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="6876565"/>
- </object>
- <int key="connectionID">549</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">menu</string>
- <reference key="source" ref="815810918"/>
- <reference key="destination" ref="524015605"/>
- </object>
- <int key="connectionID">300334</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">terminate:</string>
- <reference key="source" ref="815810918"/>
- <reference key="destination" ref="274138642"/>
- </object>
- <int key="connectionID">300336</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="657659108"/>
- </object>
- <int key="connectionID">300389</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="992839333"/>
- </object>
- <int key="connectionID">300390</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="128352289"/>
- </object>
- <int key="connectionID">300391</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">click_through</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="657659108"/>
- </object>
- <int key="connectionID">300392</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">focus_follows_mouse</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="992839333"/>
- </object>
- <int key="connectionID">300393</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">focus_on_new_window</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="128352289"/>
- </object>
- <int key="connectionID">300394</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">copy_menu_item</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="185296989"/>
- </object>
- <int key="connectionID">300443</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">sync_pasteboard</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="878106058"/>
- </object>
- <int key="connectionID">300444</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">sync_clipboard_to_pasteboard</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="487809555"/>
- </object>
- <int key="connectionID">300461</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">sync_pasteboard_to_clipboard</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="477050998"/>
- </object>
- <int key="connectionID">300462</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">sync_pasteboard_to_primary</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="765780304"/>
- </object>
- <int key="connectionID">300463</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">sync_primary_immediately</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="1002778833"/>
- </object>
- <int key="connectionID">300464</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="878106058"/>
- </object>
- <int key="connectionID">300465</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="487809555"/>
- </object>
- <int key="connectionID">300466</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="477050998"/>
- </object>
- <int key="connectionID">300467</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="765780304"/>
- </object>
- <int key="connectionID">300468</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="1002778833"/>
- </object>
- <int key="connectionID">300469</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">sync_text1</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="620944856"/>
- </object>
- <int key="connectionID">300470</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">sync_text2</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="522511724"/>
- </object>
- <int key="connectionID">300471</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">enable_fullscreen_menu</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="57246850"/>
- </object>
- <int key="connectionID">300474</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="57246850"/>
- </object>
- <int key="connectionID">300475</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="406291430"/>
- </object>
- <int key="connectionID">300480</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">option_sends_alt</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="406291430"/>
- </object>
- <int key="connectionID">300481</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="863505041"/>
- </object>
- <int key="connectionID">300484</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">enable_fullscreen_menu_text</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="331853183"/>
- </object>
- <int key="connectionID">300489</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">scroll_in_device_direction</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="863505041"/>
- </object>
- <int key="connectionID">300490</int>
- </object>
- </array>
- <object class="IBMutableOrderedSet" key="objectRecords">
- <array key="orderedObjects">
- <object class="IBObjectRecord">
- <int key="objectID">0</int>
- <array key="object" id="0"/>
- <reference key="children" ref="904585544"/>
- <nil key="parent"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">-2</int>
- <reference key="object" ref="815810918"/>
- <reference key="parent" ref="0"/>
- <string key="objectName">File's Owner</string>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">-1</int>
- <reference key="object" ref="941939442"/>
- <reference key="parent" ref="0"/>
- <string key="objectName">First Responder</string>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">-3</int>
- <reference key="object" ref="951368722"/>
- <reference key="parent" ref="0"/>
- <string key="objectName">Application</string>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">29</int>
- <reference key="object" ref="524015605"/>
- <array class="NSMutableArray" key="children">
- <reference ref="931553638"/>
- <reference ref="365880285"/>
- <reference ref="200491363"/>
- <reference ref="868031522"/>
- <reference ref="551174276"/>
- </array>
- <reference key="parent" ref="0"/>
- <string key="objectName">MainMenu</string>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">19</int>
- <reference key="object" ref="931553638"/>
- <array class="NSMutableArray" key="children">
- <reference ref="96874957"/>
- </array>
- <reference key="parent" ref="524015605"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">24</int>
- <reference key="object" ref="96874957"/>
- <array class="NSMutableArray" key="children">
- <reference ref="677652931"/>
- <reference ref="276216762"/>
- <reference ref="1066447520"/>
- <reference ref="1036389925"/>
- <reference ref="369641893"/>
- <reference ref="155085383"/>
- <reference ref="984461797"/>
- <reference ref="280172320"/>
- </array>
- <reference key="parent" ref="931553638"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">5</int>
- <reference key="object" ref="276216762"/>
- <reference key="parent" ref="96874957"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">23</int>
- <reference key="object" ref="677652931"/>
- <reference key="parent" ref="96874957"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">92</int>
- <reference key="object" ref="280172320"/>
- <reference key="parent" ref="96874957"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">203</int>
- <reference key="object" ref="984461797"/>
- <reference key="parent" ref="96874957"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">204</int>
- <reference key="object" ref="1066447520"/>
- <reference key="parent" ref="96874957"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">536</int>
- <reference key="object" ref="155085383"/>
- <reference key="parent" ref="96874957"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">537</int>
- <reference key="object" ref="1036389925"/>
- <reference key="parent" ref="96874957"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">538</int>
- <reference key="object" ref="369641893"/>
- <reference key="parent" ref="96874957"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">56</int>
- <reference key="object" ref="365880285"/>
- <array class="NSMutableArray" key="children">
- <reference ref="576521955"/>
- </array>
- <reference key="parent" ref="524015605"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">57</int>
- <reference key="object" ref="576521955"/>
- <array class="NSMutableArray" key="children">
- <reference ref="139290918"/>
- <reference ref="386173216"/>
- <reference ref="32285361"/>
- <reference ref="301008465"/>
- <reference ref="274138642"/>
- <reference ref="272876017"/>
- <reference ref="431301145"/>
- <reference ref="206802571"/>
- <reference ref="848095279"/>
- <reference ref="1023546148"/>
- <reference ref="6876565"/>
- <reference ref="479677589"/>
- </array>
- <reference key="parent" ref="365880285"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">58</int>
- <reference key="object" ref="139290918"/>
- <reference key="parent" ref="576521955"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">129</int>
- <reference key="object" ref="386173216"/>
- <reference key="parent" ref="576521955"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">131</int>
- <reference key="object" ref="32285361"/>
- <array class="NSMutableArray" key="children">
- <reference ref="821388474"/>
- </array>
- <reference key="parent" ref="576521955"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">130</int>
- <reference key="object" ref="821388474"/>
- <reference key="parent" ref="32285361"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">134</int>
- <reference key="object" ref="301008465"/>
- <reference key="parent" ref="576521955"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">136</int>
- <reference key="object" ref="274138642"/>
- <reference key="parent" ref="576521955"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">143</int>
- <reference key="object" ref="272876017"/>
- <reference key="parent" ref="576521955"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">144</int>
- <reference key="object" ref="431301145"/>
- <reference key="parent" ref="576521955"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">145</int>
- <reference key="object" ref="206802571"/>
- <reference key="parent" ref="576521955"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">149</int>
- <reference key="object" ref="848095279"/>
- <reference key="parent" ref="576521955"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">150</int>
- <reference key="object" ref="1023546148"/>
- <reference key="parent" ref="576521955"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">544</int>
- <reference key="object" ref="6876565"/>
- <reference key="parent" ref="576521955"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">545</int>
- <reference key="object" ref="479677589"/>
- <reference key="parent" ref="576521955"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">163</int>
- <reference key="object" ref="200491363"/>
- <array class="NSMutableArray" key="children">
- <reference ref="526778998"/>
- </array>
- <reference key="parent" ref="524015605"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">169</int>
- <reference key="object" ref="526778998"/>
- <array class="NSMutableArray" key="children">
- <reference ref="185296989"/>
- </array>
- <reference key="parent" ref="200491363"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">157</int>
- <reference key="object" ref="185296989"/>
- <reference key="parent" ref="526778998"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">269</int>
- <reference key="object" ref="868031522"/>
- <array class="NSMutableArray" key="children">
- <reference ref="981161348"/>
- </array>
- <reference key="parent" ref="524015605"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">270</int>
- <reference key="object" ref="981161348"/>
- <array class="NSMutableArray" key="children">
- <reference ref="390088328"/>
- <reference ref="1065386165"/>
- </array>
- <reference key="parent" ref="868031522"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">272</int>
- <reference key="object" ref="390088328"/>
- <reference key="parent" ref="981161348"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">305</int>
- <reference key="object" ref="1065386165"/>
- <reference key="parent" ref="981161348"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">419</int>
- <reference key="object" ref="551174276"/>
- <array class="NSMutableArray" key="children">
- <reference ref="511848303"/>
- </array>
- <reference key="parent" ref="524015605"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">420</int>
- <reference key="object" ref="511848303"/>
- <array class="NSMutableArray" key="children">
- <reference ref="504984881"/>
- </array>
- <reference key="parent" ref="551174276"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">421</int>
- <reference key="object" ref="504984881"/>
- <reference key="parent" ref="511848303"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">196</int>
- <reference key="object" ref="485884620"/>
- <reference key="parent" ref="0"/>
- <string key="objectName">X11Controller</string>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">244</int>
- <reference key="object" ref="124913468"/>
- <array class="NSMutableArray" key="children">
- <reference ref="941366957"/>
- </array>
- <reference key="parent" ref="0"/>
- <string key="objectName">PrefsPanel</string>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">245</int>
- <reference key="object" ref="941366957"/>
- <array class="NSMutableArray" key="children">
- <reference ref="448510093"/>
- </array>
- <reference key="parent" ref="124913468"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">348</int>
- <reference key="object" ref="448510093"/>
- <array class="NSMutableArray" key="children">
- <reference ref="287591690"/>
- <reference ref="960678392"/>
- <reference ref="348328898"/>
- <reference ref="10973343"/>
- <reference ref="723450037"/>
- </array>
- <reference key="parent" ref="941366957"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">349</int>
- <reference key="object" ref="287591690"/>
- <array class="NSMutableArray" key="children">
- <reference ref="596750588"/>
- </array>
- <reference key="parent" ref="448510093"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">351</int>
- <reference key="object" ref="596750588"/>
- <array class="NSMutableArray" key="children">
- <reference ref="119157981"/>
- <reference ref="443008216"/>
- <reference ref="282885445"/>
- <reference ref="842100515"/>
- <reference ref="31160162"/>
- <reference ref="179949713"/>
- <reference ref="278155937"/>
- <reference ref="406291430"/>
- <reference ref="863505041"/>
- </array>
- <reference key="parent" ref="287591690"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">363</int>
- <reference key="object" ref="119157981"/>
- <array class="NSMutableArray" key="children">
- <reference ref="990762273"/>
- </array>
- <reference key="parent" ref="596750588"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">364</int>
- <reference key="object" ref="443008216"/>
- <array class="NSMutableArray" key="children">
- <reference ref="391919450"/>
- </array>
- <reference key="parent" ref="596750588"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">365</int>
- <reference key="object" ref="282885445"/>
- <array class="NSMutableArray" key="children">
- <reference ref="649334366"/>
- </array>
- <reference key="parent" ref="596750588"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">368</int>
- <reference key="object" ref="842100515"/>
- <array class="NSMutableArray" key="children">
- <reference ref="940564599"/>
- </array>
- <reference key="parent" ref="596750588"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">369</int>
- <reference key="object" ref="31160162"/>
- <array class="NSMutableArray" key="children">
- <reference ref="666057093"/>
- </array>
- <reference key="parent" ref="596750588"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">370</int>
- <reference key="object" ref="179949713"/>
- <array class="NSMutableArray" key="children">
- <reference ref="967619578"/>
- </array>
- <reference key="parent" ref="596750588"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">352</int>
- <reference key="object" ref="960678392"/>
- <array class="NSMutableArray" key="children">
- <reference ref="515308735"/>
- </array>
- <reference key="parent" ref="448510093"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">350</int>
- <reference key="object" ref="515308735"/>
- <array class="NSMutableArray" key="children">
- <reference ref="709074847"/>
- <reference ref="201731424"/>
- <reference ref="86150604"/>
- <reference ref="477203622"/>
- <reference ref="57246850"/>
- <reference ref="298603383"/>
- <reference ref="331853183"/>
- </array>
- <reference key="parent" ref="960678392"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">382</int>
- <reference key="object" ref="709074847"/>
- <array class="NSMutableArray" key="children">
- <reference ref="633115429"/>
- </array>
- <reference key="parent" ref="515308735"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">385</int>
- <reference key="object" ref="201731424"/>
- <array class="NSMutableArray" key="children">
- <reference ref="930265681"/>
- </array>
- <reference key="parent" ref="515308735"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">386</int>
- <reference key="object" ref="86150604"/>
- <array class="NSMutableArray" key="children">
- <reference ref="311969422"/>
- </array>
- <reference key="parent" ref="515308735"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">541</int>
- <reference key="object" ref="477203622"/>
- <array class="NSMutableArray" key="children">
- <reference ref="631531164"/>
- </array>
- <reference key="parent" ref="515308735"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">543</int>
- <reference key="object" ref="298603383"/>
- <array class="NSMutableArray" key="children">
- <reference ref="761107402"/>
- </array>
- <reference key="parent" ref="515308735"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">353</int>
- <reference key="object" ref="348328898"/>
- <array class="NSMutableArray" key="children">
- <reference ref="300811574"/>
- </array>
- <reference key="parent" ref="448510093"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">354</int>
- <reference key="object" ref="300811574"/>
- <array class="NSMutableArray" key="children">
- <reference ref="989050925"/>
- <reference ref="700826966"/>
- <reference ref="168436707"/>
- <reference ref="363817195"/>
- <reference ref="223835729"/>
- </array>
- <reference key="parent" ref="348328898"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">374</int>
- <reference key="object" ref="989050925"/>
- <array class="NSMutableArray" key="children">
- <reference ref="189594322"/>
- </array>
- <reference key="parent" ref="300811574"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">375</int>
- <reference key="object" ref="700826966"/>
- <array class="NSMutableArray" key="children">
- <reference ref="489340979"/>
- </array>
- <reference key="parent" ref="300811574"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">376</int>
- <reference key="object" ref="168436707"/>
- <array class="NSMutableArray" key="children">
- <reference ref="53243865"/>
- </array>
- <reference key="parent" ref="300811574"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">377</int>
- <reference key="object" ref="363817195"/>
- <array class="NSMutableArray" key="children">
- <reference ref="390084685"/>
- </array>
- <reference key="parent" ref="300811574"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">379</int>
- <reference key="object" ref="223835729"/>
- <array class="NSMutableArray" key="children">
- <reference ref="283628678"/>
- </array>
- <reference key="parent" ref="300811574"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">285</int>
- <reference key="object" ref="604417141"/>
- <array class="NSMutableArray" key="children">
- <reference ref="85544634"/>
- </array>
- <reference key="parent" ref="0"/>
- <string key="objectName">EditPrograms</string>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">286</int>
- <reference key="object" ref="85544634"/>
- <array class="NSMutableArray" key="children">
- <reference ref="1063387772"/>
- <reference ref="758204686"/>
- <reference ref="671954382"/>
- <reference ref="492358940"/>
- </array>
- <reference key="parent" ref="604417141"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">423</int>
- <reference key="object" ref="294137138"/>
- <array class="NSMutableArray" key="children">
- <reference ref="318286212"/>
- <reference ref="511651072"/>
- </array>
- <reference key="parent" ref="0"/>
- <string key="objectName">DockMenu</string>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">524</int>
- <reference key="object" ref="318286212"/>
- <reference key="parent" ref="294137138"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">526</int>
- <reference key="object" ref="511651072"/>
- <array class="NSMutableArray" key="children">
- <reference ref="48278059"/>
- </array>
- <reference key="parent" ref="294137138"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">527</int>
- <reference key="object" ref="48278059"/>
- <array class="NSMutableArray" key="children">
- <reference ref="1032342329"/>
- <reference ref="563798000"/>
- </array>
- <reference key="parent" ref="511651072"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">532</int>
- <reference key="object" ref="1032342329"/>
- <reference key="parent" ref="48278059"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">533</int>
- <reference key="object" ref="563798000"/>
- <reference key="parent" ref="48278059"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100363</int>
- <reference key="object" ref="990762273"/>
- <reference key="parent" ref="119157981"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100364</int>
- <reference key="object" ref="391919450"/>
- <reference key="parent" ref="443008216"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100365</int>
- <reference key="object" ref="649334366"/>
- <reference key="parent" ref="282885445"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100368</int>
- <reference key="object" ref="940564599"/>
- <reference key="parent" ref="842100515"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100369</int>
- <reference key="object" ref="666057093"/>
- <reference key="parent" ref="31160162"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100370</int>
- <reference key="object" ref="967619578"/>
- <reference key="parent" ref="179949713"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100382</int>
- <reference key="object" ref="633115429"/>
- <array class="NSMutableArray" key="children">
- <reference ref="341113515"/>
- </array>
- <reference key="parent" ref="709074847"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100385</int>
- <reference key="object" ref="930265681"/>
- <reference key="parent" ref="201731424"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100386</int>
- <reference key="object" ref="311969422"/>
- <reference key="parent" ref="86150604"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100541</int>
- <reference key="object" ref="631531164"/>
- <reference key="parent" ref="477203622"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100543</int>
- <reference key="object" ref="761107402"/>
- <reference key="parent" ref="298603383"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100374</int>
- <reference key="object" ref="189594322"/>
- <reference key="parent" ref="989050925"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100375</int>
- <reference key="object" ref="489340979"/>
- <reference key="parent" ref="700826966"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100376</int>
- <reference key="object" ref="53243865"/>
- <reference key="parent" ref="168436707"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100377</int>
- <reference key="object" ref="390084685"/>
- <reference key="parent" ref="363817195"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100379</int>
- <reference key="object" ref="283628678"/>
- <reference key="parent" ref="223835729"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">380</int>
- <reference key="object" ref="341113515"/>
- <array class="NSMutableArray" key="children">
- <reference ref="759499526"/>
- <reference ref="616492372"/>
- <reference ref="543935434"/>
- <reference ref="836673018"/>
- </array>
- <reference key="parent" ref="633115429"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">435</int>
- <reference key="object" ref="759499526"/>
- <reference key="parent" ref="341113515"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">384</int>
- <reference key="object" ref="616492372"/>
- <reference key="parent" ref="341113515"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">383</int>
- <reference key="object" ref="543935434"/>
- <reference key="parent" ref="341113515"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">381</int>
- <reference key="object" ref="836673018"/>
- <reference key="parent" ref="341113515"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">295</int>
- <reference key="object" ref="1063387772"/>
- <array class="NSMutableArray" key="children">
- <reference ref="792419186"/>
- <reference ref="17278747"/>
- <reference ref="842897584"/>
- <reference ref="905092943"/>
- </array>
- <reference key="parent" ref="85544634"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300295</int>
- <reference key="object" ref="792419186"/>
- <reference key="parent" ref="1063387772"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">200295</int>
- <reference key="object" ref="17278747"/>
- <reference key="parent" ref="1063387772"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100295</int>
- <reference key="object" ref="842897584"/>
- <reference key="parent" ref="1063387772"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">296</int>
- <reference key="object" ref="905092943"/>
- <array class="NSMutableArray" key="children">
- <reference ref="242608782"/>
- <reference ref="938444323"/>
- <reference ref="84282687"/>
- </array>
- <reference key="parent" ref="1063387772"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">535</int>
- <reference key="object" ref="242608782"/>
- <array class="NSMutableArray" key="children">
- <reference ref="34714764"/>
- </array>
- <reference key="parent" ref="905092943"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">575</int>
- <reference key="object" ref="34714764"/>
- <reference key="parent" ref="242608782"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">298</int>
- <reference key="object" ref="938444323"/>
- <array class="NSMutableArray" key="children">
- <reference ref="825378892"/>
- </array>
- <reference key="parent" ref="905092943"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">573</int>
- <reference key="object" ref="825378892"/>
- <reference key="parent" ref="938444323"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">297</int>
- <reference key="object" ref="84282687"/>
- <array class="NSMutableArray" key="children">
- <reference ref="432610585"/>
- </array>
- <reference key="parent" ref="905092943"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">574</int>
- <reference key="object" ref="432610585"/>
- <reference key="parent" ref="84282687"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">310</int>
- <reference key="object" ref="758204686"/>
- <array class="NSMutableArray" key="children">
- <reference ref="1025474039"/>
- </array>
- <reference key="parent" ref="85544634"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100310</int>
- <reference key="object" ref="1025474039"/>
- <reference key="parent" ref="758204686"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">292</int>
- <reference key="object" ref="671954382"/>
- <array class="NSMutableArray" key="children">
- <reference ref="143554520"/>
- </array>
- <reference key="parent" ref="85544634"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100292</int>
- <reference key="object" ref="143554520"/>
- <reference key="parent" ref="671954382"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">293</int>
- <reference key="object" ref="492358940"/>
- <array class="NSMutableArray" key="children">
- <reference ref="8201128"/>
- </array>
- <reference key="parent" ref="85544634"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100293</int>
- <reference key="object" ref="8201128"/>
- <reference key="parent" ref="492358940"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300337</int>
- <reference key="object" ref="10973343"/>
- <array class="NSMutableArray" key="children">
- <reference ref="184765684"/>
- </array>
- <reference key="parent" ref="448510093"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300338</int>
- <reference key="object" ref="184765684"/>
- <array class="NSMutableArray" key="children">
- <reference ref="657659108"/>
- <reference ref="290578835"/>
- <reference ref="992839333"/>
- <reference ref="138261120"/>
- <reference ref="128352289"/>
- <reference ref="57161931"/>
- </array>
- <reference key="parent" ref="10973343"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300358</int>
- <reference key="object" ref="290578835"/>
- <array class="NSMutableArray" key="children">
- <reference ref="399127858"/>
- </array>
- <reference key="parent" ref="184765684"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300359</int>
- <reference key="object" ref="657659108"/>
- <array class="NSMutableArray" key="children">
- <reference ref="259618205"/>
- </array>
- <reference key="parent" ref="184765684"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300360</int>
- <reference key="object" ref="259618205"/>
- <reference key="parent" ref="657659108"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300361</int>
- <reference key="object" ref="399127858"/>
- <reference key="parent" ref="290578835"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300362</int>
- <reference key="object" ref="992839333"/>
- <array class="NSMutableArray" key="children">
- <reference ref="959555182"/>
- </array>
- <reference key="parent" ref="184765684"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300363</int>
- <reference key="object" ref="959555182"/>
- <reference key="parent" ref="992839333"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300364</int>
- <reference key="object" ref="138261120"/>
- <array class="NSMutableArray" key="children">
- <reference ref="183409141"/>
- </array>
- <reference key="parent" ref="184765684"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300365</int>
- <reference key="object" ref="183409141"/>
- <reference key="parent" ref="138261120"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300368</int>
- <reference key="object" ref="128352289"/>
- <array class="NSMutableArray" key="children">
- <reference ref="556463187"/>
- </array>
- <reference key="parent" ref="184765684"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300369</int>
- <reference key="object" ref="556463187"/>
- <reference key="parent" ref="128352289"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300370</int>
- <reference key="object" ref="57161931"/>
- <array class="NSMutableArray" key="children">
- <reference ref="989804990"/>
- </array>
- <reference key="parent" ref="184765684"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300371</int>
- <reference key="object" ref="989804990"/>
- <reference key="parent" ref="57161931"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300421</int>
- <reference key="object" ref="723450037"/>
- <array class="NSMutableArray" key="children">
- <reference ref="408298283"/>
- </array>
- <reference key="parent" ref="448510093"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300422</int>
- <reference key="object" ref="408298283"/>
- <array class="NSMutableArray" key="children">
- <reference ref="878106058"/>
- <reference ref="386152084"/>
- <reference ref="487809555"/>
- <reference ref="620944856"/>
- <reference ref="477050998"/>
- <reference ref="765780304"/>
- <reference ref="522511724"/>
- <reference ref="1002778833"/>
- </array>
- <reference key="parent" ref="723450037"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300423</int>
- <reference key="object" ref="386152084"/>
- <array class="NSMutableArray" key="children">
- <reference ref="572508492"/>
- </array>
- <reference key="parent" ref="408298283"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300424</int>
- <reference key="object" ref="878106058"/>
- <array class="NSMutableArray" key="children">
- <reference ref="718083688"/>
- </array>
- <reference key="parent" ref="408298283"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300440</int>
- <reference key="object" ref="718083688"/>
- <reference key="parent" ref="878106058"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300441</int>
- <reference key="object" ref="572508492"/>
- <reference key="parent" ref="386152084"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300447</int>
- <reference key="object" ref="477050998"/>
- <array class="NSMutableArray" key="children">
- <reference ref="501304422"/>
- </array>
- <reference key="parent" ref="408298283"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300450</int>
- <reference key="object" ref="501304422"/>
- <reference key="parent" ref="477050998"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300451</int>
- <reference key="object" ref="765780304"/>
- <array class="NSMutableArray" key="children">
- <reference ref="510771323"/>
- </array>
- <reference key="parent" ref="408298283"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300452</int>
- <reference key="object" ref="510771323"/>
- <reference key="parent" ref="765780304"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300453</int>
- <reference key="object" ref="487809555"/>
- <array class="NSMutableArray" key="children">
- <reference ref="619977658"/>
- </array>
- <reference key="parent" ref="408298283"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300454</int>
- <reference key="object" ref="619977658"/>
- <reference key="parent" ref="487809555"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300455</int>
- <reference key="object" ref="620944856"/>
- <array class="NSMutableArray" key="children">
- <reference ref="461823902"/>
- </array>
- <reference key="parent" ref="408298283"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300456</int>
- <reference key="object" ref="461823902"/>
- <reference key="parent" ref="620944856"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300457</int>
- <reference key="object" ref="1002778833"/>
- <array class="NSMutableArray" key="children">
- <reference ref="897099877"/>
- </array>
- <reference key="parent" ref="408298283"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300458</int>
- <reference key="object" ref="897099877"/>
- <reference key="parent" ref="1002778833"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300459</int>
- <reference key="object" ref="522511724"/>
- <array class="NSMutableArray" key="children">
- <reference ref="994587858"/>
- </array>
- <reference key="parent" ref="408298283"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300460</int>
- <reference key="object" ref="994587858"/>
- <reference key="parent" ref="522511724"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300472</int>
- <reference key="object" ref="57246850"/>
- <array class="NSMutableArray" key="children">
- <reference ref="917248662"/>
- </array>
- <reference key="parent" ref="515308735"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300473</int>
- <reference key="object" ref="917248662"/>
- <reference key="parent" ref="57246850"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300476</int>
- <reference key="object" ref="278155937"/>
- <array class="NSMutableArray" key="children">
- <reference ref="617441821"/>
- </array>
- <reference key="parent" ref="596750588"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300477</int>
- <reference key="object" ref="406291430"/>
- <array class="NSMutableArray" key="children">
- <reference ref="67728988"/>
- </array>
- <reference key="parent" ref="596750588"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300478</int>
- <reference key="object" ref="67728988"/>
- <reference key="parent" ref="406291430"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300479</int>
- <reference key="object" ref="617441821"/>
- <reference key="parent" ref="278155937"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300482</int>
- <reference key="object" ref="863505041"/>
- <array class="NSMutableArray" key="children">
- <reference ref="1016286396"/>
- </array>
- <reference key="parent" ref="596750588"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300483</int>
- <reference key="object" ref="1016286396"/>
- <reference key="parent" ref="863505041"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300487</int>
- <reference key="object" ref="331853183"/>
- <array class="NSMutableArray" key="children">
- <reference ref="1042813110"/>
- </array>
- <reference key="parent" ref="515308735"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300488</int>
- <reference key="object" ref="1042813110"/>
- <reference key="parent" ref="331853183"/>
- </object>
- </array>
- </object>
- <dictionary class="NSMutableDictionary" key="flattenedProperties">
- <string key="-3.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="-3.ImportedFromIB2"/>
- <string key="100292.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100293.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100295.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="100295.IBShouldRemoveOnLegacySave"/>
- <string key="100310.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100363.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100364.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100365.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100368.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100369.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100370.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100374.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100375.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100376.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100377.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100379.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100382.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100385.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100386.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100541.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100543.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="129.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="129.ImportedFromIB2"/>
- <string key="130.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="130.ImportedFromIB2"/>
- <string key="131.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="131.ImportedFromIB2"/>
- <string key="134.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="134.ImportedFromIB2"/>
- <string key="136.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="136.ImportedFromIB2"/>
- <string key="143.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="143.ImportedFromIB2"/>
- <string key="144.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="144.ImportedFromIB2"/>
- <string key="145.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="145.ImportedFromIB2"/>
- <string key="149.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="149.ImportedFromIB2"/>
- <string key="150.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="150.ImportedFromIB2"/>
- <string key="157.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="157.ImportedFromIB2"/>
- <string key="163.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="163.ImportedFromIB2"/>
- <string key="169.IBEditorWindowLastContentRect">{{168, 821}, {113, 23}}</string>
- <string key="169.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="169.ImportedFromIB2"/>
- <string key="169.editorWindowContentRectSynchronizationRect">{{202, 626}, {154, 153}}</string>
- <string key="19.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="19.ImportedFromIB2"/>
- <integer value="1" key="196.ImportedFromIB2"/>
- <string key="200295.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="200295.IBShouldRemoveOnLegacySave"/>
- <string key="203.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="203.ImportedFromIB2"/>
- <string key="204.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="204.ImportedFromIB2"/>
- <string key="23.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="23.ImportedFromIB2"/>
- <string key="24.IBEditorWindowLastContentRect">{{349, 868}, {315, 143}}</string>
- <string key="24.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="24.ImportedFromIB2"/>
- <string key="24.editorWindowContentRectSynchronizationRect">{{271, 666}, {301, 153}}</string>
- <string key="244.IBEditorWindowLastContentRect">{{329, 408}, {550, 341}}</string>
- <string key="244.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="244.IBWindowTemplateEditedContentRect">{{329, 408}, {550, 341}}</string>
- <integer value="1" key="244.ImportedFromIB2"/>
- <string key="244.editorWindowContentRectSynchronizationRect">{{184, 290}, {481, 345}}</string>
- <boolean value="YES" key="244.windowTemplate.hasMinSize"/>
- <string key="244.windowTemplate.maxSize">{1.7976931348623157e+308, 1.7976931348623157e+308}</string>
- <string key="244.windowTemplate.minSize">{320, 240}</string>
- <string key="245.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="245.ImportedFromIB2"/>
- <string key="269.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="269.ImportedFromIB2"/>
- <string key="270.IBEditorWindowLastContentRect">{{58, 803}, {155, 33}}</string>
- <string key="270.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="270.ImportedFromIB2"/>
- <string key="270.editorWindowContentRectSynchronizationRect">{{100, 746}, {155, 33}}</string>
- <string key="272.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="272.ImportedFromIB2"/>
- <string key="285.IBEditorWindowLastContentRect">{{68, 585}, {454, 271}}</string>
- <string key="285.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="285.IBViewEditorWindowController.showingBoundsRectangles"/>
- <integer value="1" key="285.IBViewEditorWindowController.showingLayoutRectangles"/>
- <string key="285.IBWindowTemplateEditedContentRect">{{68, 585}, {454, 271}}</string>
- <integer value="1" key="285.ImportedFromIB2"/>
- <string key="285.editorWindowContentRectSynchronizationRect">{{433, 406}, {486, 327}}</string>
- <boolean value="YES" key="285.windowTemplate.hasMinSize"/>
- <string key="285.windowTemplate.maxSize">{1.7976931348623157e+308, 1.7976931348623157e+308}</string>
- <string key="285.windowTemplate.minSize">{512, 240}</string>
- <string key="286.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="286.ImportedFromIB2"/>
- <string key="29.IBEditorWindowLastContentRect">{{145, 1011}, {336, 20}}</string>
- <string key="29.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="29.ImportedFromIB2"/>
- <string key="29.editorWindowContentRectSynchronizationRect">{{67, 819}, {336, 20}}</string>
- <string key="292.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="292.ImportedFromIB2"/>
- <string key="293.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="293.ImportedFromIB2"/>
- <string key="295.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="295.ImportedFromIB2"/>
- <string key="296.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="296.ImportedFromIB2"/>
- <string key="297.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="297.ImportedFromIB2"/>
- <string key="298.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="298.ImportedFromIB2"/>
- <string key="300295.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300295.IBShouldRemoveOnLegacySave"/>
- <string key="300337.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300337.ImportedFromIB2"/>
- <string key="300338.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300338.ImportedFromIB2"/>
- <string key="300358.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300358.ImportedFromIB2"/>
- <string key="300359.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300359.ImportedFromIB2"/>
- <string key="300360.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300361.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300362.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300362.ImportedFromIB2"/>
- <string key="300363.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300364.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300364.ImportedFromIB2"/>
- <string key="300365.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300368.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300368.ImportedFromIB2"/>
- <string key="300369.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300370.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300370.ImportedFromIB2"/>
- <string key="300371.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300421.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300421.ImportedFromIB2"/>
- <string key="300422.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300422.ImportedFromIB2"/>
- <string key="300423.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300423.ImportedFromIB2"/>
- <string key="300424.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300424.ImportedFromIB2"/>
- <string key="300440.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300441.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300447.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300447.ImportedFromIB2"/>
- <string key="300450.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300451.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300451.ImportedFromIB2"/>
- <string key="300452.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300453.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300453.ImportedFromIB2"/>
- <string key="300454.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300455.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300455.ImportedFromIB2"/>
- <string key="300456.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300457.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <object class="NSAffineTransform" key="300457.IBViewBoundsToFrameTransform">
- <bytes key="NSTransformStruct">P4AAAL+AAABCCAAAwr4AAA</bytes>
- </object>
- <integer value="1" key="300457.ImportedFromIB2"/>
- <string key="300458.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300459.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300459.ImportedFromIB2"/>
- <string key="300460.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300472.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300472.ImportedFromIB2"/>
- <string key="300473.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300476.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300476.ImportedFromIB2"/>
- <string key="300477.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300477.ImportedFromIB2"/>
- <string key="300478.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300479.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300482.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300482.ImportedFromIB2"/>
- <string key="300483.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300487.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300487.ImportedFromIB2"/>
- <string key="300488.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="305.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="305.ImportedFromIB2"/>
- <string key="310.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="310.ImportedFromIB2"/>
- <string key="348.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="348.ImportedFromIB2"/>
- <string key="349.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="349.ImportedFromIB2"/>
- <string key="350.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="350.ImportedFromIB2"/>
- <string key="351.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="351.ImportedFromIB2"/>
- <string key="352.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="352.ImportedFromIB2"/>
- <string key="353.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="353.ImportedFromIB2"/>
- <string key="354.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="354.ImportedFromIB2"/>
- <string key="363.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="363.ImportedFromIB2"/>
- <string key="364.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="364.ImportedFromIB2"/>
- <string key="365.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="365.ImportedFromIB2"/>
- <string key="368.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="368.ImportedFromIB2"/>
- <string key="369.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="369.ImportedFromIB2"/>
- <string key="370.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="370.ImportedFromIB2"/>
- <string key="374.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="374.ImportedFromIB2"/>
- <string key="375.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="375.ImportedFromIB2"/>
- <string key="376.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="376.ImportedFromIB2"/>
- <string key="377.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="377.ImportedFromIB2"/>
- <string key="379.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="379.ImportedFromIB2"/>
- <string key="380.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="380.ImportedFromIB2"/>
- <string key="381.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="381.ImportedFromIB2"/>
- <string key="382.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="382.ImportedFromIB2"/>
- <string key="383.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="383.ImportedFromIB2"/>
- <string key="384.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="384.ImportedFromIB2"/>
- <string key="385.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="385.ImportedFromIB2"/>
- <string key="386.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="386.ImportedFromIB2"/>
- <string key="419.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="419.ImportedFromIB2"/>
- <string key="420.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="420.ImportedFromIB2"/>
- <string key="421.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="421.ImportedFromIB2"/>
- <string key="423.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="423.ImportedFromIB2"/>
- <string key="435.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="435.ImportedFromIB2"/>
- <string key="5.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="5.ImportedFromIB2"/>
- <string key="524.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="524.ImportedFromIB2"/>
- <string key="526.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="526.ImportedFromIB2"/>
- <string key="527.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="527.ImportedFromIB2"/>
- <string key="532.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="532.ImportedFromIB2"/>
- <string key="533.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="533.ImportedFromIB2"/>
- <string key="535.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="535.ImportedFromIB2"/>
- <string key="536.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="536.ImportedFromIB2"/>
- <string key="537.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="537.ImportedFromIB2"/>
- <string key="538.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="538.ImportedFromIB2"/>
- <string key="541.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="541.ImportedFromIB2"/>
- <string key="543.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="543.ImportedFromIB2"/>
- <string key="544.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="544.ImportedFromIB2"/>
- <string key="545.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="545.ImportedFromIB2"/>
- <string key="56.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="56.ImportedFromIB2"/>
- <string key="57.IBEditorWindowLastContentRect">{{20, 641}, {218, 203}}</string>
- <string key="57.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="57.ImportedFromIB2"/>
- <string key="57.editorWindowContentRectSynchronizationRect">{{79, 616}, {218, 203}}</string>
- <string key="573.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="573.ImportedFromIB2"/>
- <string key="574.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="574.ImportedFromIB2"/>
- <string key="575.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="575.ImportedFromIB2"/>
- <string key="58.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="58.ImportedFromIB2"/>
- <string key="92.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="92.ImportedFromIB2"/>
- </dictionary>
- <dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
- <nil key="activeLocalization"/>
- <dictionary class="NSMutableDictionary" key="localizations"/>
- <nil key="sourceID"/>
- <int key="maxID">300490</int>
- </object>
- <object class="IBClassDescriber" key="IBDocument.Classes"/>
- <int key="IBDocument.localizationMode">0</int>
- <string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
- <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencies">
- <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string>
- <integer value="1040" key="NS.object.0"/>
- </object>
- <bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
- <nil key="IBDocument.LastKnownRelativeProjectPath"/>
- <int key="IBDocument.defaultPropertyAccessControl">3</int>
- <dictionary class="NSMutableDictionary" key="IBDocument.LastKnownImageSizes">
- <string key="NSMenuCheckmark">{9, 8}</string>
- <string key="NSMenuMixedState">{7, 2}</string>
- <string key="NSSwitch">{15, 15}</string>
- </dictionary>
- </data>
-</archive>
+<?xml version="1.0" encoding="UTF-8"?>
+<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00">
+ <data>
+ <int key="IBDocument.SystemTarget">1040</int>
+ <string key="IBDocument.SystemVersion">11A289</string>
+ <string key="IBDocument.InterfaceBuilderVersion">903</string>
+ <string key="IBDocument.AppKitVersion">1094.2</string>
+ <string key="IBDocument.HIToolboxVersion">521.00</string>
+ <object class="NSMutableDictionary" key="IBDocument.PluginVersions">
+ <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="NS.object.0">903</string>
+ </object>
+ <array class="NSMutableArray" key="IBDocument.EditedObjectIDs"/>
+ <array key="IBDocument.PluginDependencies">
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ </array>
+ <object class="NSMutableDictionary" key="IBDocument.Metadata">
+ <string key="NS.key.0">PluginDependencyRecalculationVersion</string>
+ <integer value="1" key="NS.object.0"/>
+ </object>
+ <array class="NSMutableArray" key="IBDocument.RootObjects" id="904585544">
+ <object class="NSCustomObject" id="815810918">
+ <object class="NSMutableString" key="NSClassName">
+ <characters key="NS.bytes">NSApplication</characters>
+ </object>
+ </object>
+ <object class="NSCustomObject" id="941939442">
+ <string key="NSClassName">FirstResponder</string>
+ </object>
+ <object class="NSCustomObject" id="951368722">
+ <string key="NSClassName">NSApplication</string>
+ </object>
+ <object class="NSMenu" id="524015605">
+ <string key="NSTitle">MainMenu</string>
+ <array class="NSMutableArray" key="NSMenuItems">
+ <object class="NSMenuItem" id="365880285">
+ <reference key="NSMenu" ref="524015605"/>
+ <string key="NSTitle">X11</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <object class="NSCustomResource" key="NSOnImage" id="531645050">
+ <string key="NSClassName">NSImage</string>
+ <string key="NSResourceName">NSMenuCheckmark</string>
+ </object>
+ <object class="NSCustomResource" key="NSMixedImage" id="351811234">
+ <string key="NSClassName">NSImage</string>
+ <string key="NSResourceName">NSMenuMixedState</string>
+ </object>
+ <string key="NSAction">submenuAction:</string>
+ <object class="NSMenu" key="NSSubmenu" id="576521955">
+ <string key="NSTitle">X11</string>
+ <array class="NSMutableArray" key="NSMenuItems">
+ <object class="NSMenuItem" id="139290918">
+ <reference key="NSMenu" ref="576521955"/>
+ <string key="NSTitle">Über X11</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="386173216">
+ <reference key="NSMenu" ref="576521955"/>
+ <string key="NSTitle">Einstellungen …</string>
+ <string key="NSKeyEquiv">,</string>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="272876017">
+ <reference key="NSMenu" ref="576521955"/>
+ <bool key="NSIsDisabled">YES</bool>
+ <bool key="NSIsSeparator">YES</bool>
+ <string key="NSTitle"/>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="32285361">
+ <reference key="NSMenu" ref="576521955"/>
+ <string key="NSTitle">Dienste</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ <string key="NSAction">submenuAction:</string>
+ <object class="NSMenu" key="NSSubmenu" id="821388474">
+ <string key="NSTitle">Dienste</string>
+ <array class="NSMutableArray" key="NSMenuItems"/>
+ <string key="NSName">_NSServicesMenu</string>
+ </object>
+ </object>
+ <object class="NSMenuItem" id="431301145">
+ <reference key="NSMenu" ref="576521955"/>
+ <bool key="NSIsDisabled">YES</bool>
+ <bool key="NSIsSeparator">YES</bool>
+ <string key="NSTitle"/>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="6876565">
+ <reference key="NSMenu" ref="576521955"/>
+ <string key="NSTitle">Vollbildmodus ein-/ausschalten</string>
+ <string key="NSKeyEquiv">a</string>
+ <int key="NSKeyEquivModMask">1572864</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="479677589">
+ <reference key="NSMenu" ref="576521955"/>
+ <bool key="NSIsDisabled">YES</bool>
+ <bool key="NSIsSeparator">YES</bool>
+ <string key="NSTitle"/>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="301008465">
+ <reference key="NSMenu" ref="576521955"/>
+ <string key="NSTitle">X11 ausblenden</string>
+ <string key="NSKeyEquiv">h</string>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ <int key="NSTag">42</int>
+ </object>
+ <object class="NSMenuItem" id="206802571">
+ <reference key="NSMenu" ref="576521955"/>
+ <string key="NSTitle">Andere ausblenden</string>
+ <string key="NSKeyEquiv">h</string>
+ <int key="NSKeyEquivModMask">1572864</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="1023546148">
+ <reference key="NSMenu" ref="576521955"/>
+ <string key="NSTitle">Alle einblenden</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ <int key="NSTag">42</int>
+ </object>
+ <object class="NSMenuItem" id="848095279">
+ <reference key="NSMenu" ref="576521955"/>
+ <bool key="NSIsDisabled">YES</bool>
+ <bool key="NSIsSeparator">YES</bool>
+ <string key="NSTitle"/>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="274138642">
+ <reference key="NSMenu" ref="576521955"/>
+ <string key="NSTitle">X11 beenden</string>
+ <string key="NSKeyEquiv">q</string>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ </array>
+ <string key="NSName">_NSAppleMenu</string>
+ </object>
+ </object>
+ <object class="NSMenuItem" id="868031522">
+ <reference key="NSMenu" ref="524015605"/>
+ <string key="NSTitle">Programme</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ <string key="NSAction">submenuAction:</string>
+ <object class="NSMenu" key="NSSubmenu" id="981161348">
+ <string key="NSTitle">Programme</string>
+ <array class="NSMutableArray" key="NSMenuItems">
+ <object class="NSMenuItem" id="390088328">
+ <reference key="NSMenu" ref="981161348"/>
+ <bool key="NSIsDisabled">YES</bool>
+ <bool key="NSIsSeparator">YES</bool>
+ <string key="NSTitle"/>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="1065386165">
+ <reference key="NSMenu" ref="981161348"/>
+ <string key="NSTitle">Anpassen …</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ </array>
+ </object>
+ </object>
+ <object class="NSMenuItem" id="200491363">
+ <reference key="NSMenu" ref="524015605"/>
+ <string key="NSTitle">Bearbeiten</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ <string key="NSAction">submenuAction:</string>
+ <object class="NSMenu" key="NSSubmenu" id="526778998">
+ <string key="NSTitle">Bearbeiten</string>
+ <array class="NSMutableArray" key="NSMenuItems">
+ <object class="NSMenuItem" id="185296989">
+ <reference key="NSMenu" ref="526778998"/>
+ <string key="NSTitle">Kopieren</string>
+ <string key="NSKeyEquiv">c</string>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ </array>
+ </object>
+ </object>
+ <object class="NSMenuItem" id="931553638">
+ <reference key="NSMenu" ref="524015605"/>
+ <string key="NSTitle">Fenster</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ <string key="NSAction">submenuAction:</string>
+ <object class="NSMenu" key="NSSubmenu" id="96874957">
+ <string key="NSTitle">Fenster</string>
+ <array class="NSMutableArray" key="NSMenuItems">
+ <object class="NSMenuItem" id="984461797">
+ <reference key="NSMenu" ref="96874957"/>
+ <string key="NSTitle">Schließen</string>
+ <string key="NSKeyEquiv">w</string>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="677652931">
+ <reference key="NSMenu" ref="96874957"/>
+ <string key="NSTitle">Im Dock ablegen</string>
+ <string key="NSKeyEquiv">m</string>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="1066447520">
+ <reference key="NSMenu" ref="96874957"/>
+ <string key="NSTitle">Zoomen</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="280172320">
+ <reference key="NSMenu" ref="96874957"/>
+ <bool key="NSIsDisabled">YES</bool>
+ <bool key="NSIsSeparator">YES</bool>
+ <string key="NSTitle"/>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="1036389925">
+ <reference key="NSMenu" ref="96874957"/>
+ <string key="NSTitle">Vorwärts blättern</string>
+ <string key="NSKeyEquiv">&lt;</string>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="369641893">
+ <reference key="NSMenu" ref="96874957"/>
+ <string key="NSTitle">Rückwärts blättern</string>
+ <string key="NSKeyEquiv">&gt;</string>
+ <int key="NSKeyEquivModMask">1179648</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="155085383">
+ <reference key="NSMenu" ref="96874957"/>
+ <bool key="NSIsDisabled">YES</bool>
+ <bool key="NSIsSeparator">YES</bool>
+ <string key="NSTitle"/>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="276216762">
+ <reference key="NSMenu" ref="96874957"/>
+ <string key="NSTitle">Alle nach vorne bringen</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ </array>
+ <string key="NSName">_NSWindowsMenu</string>
+ </object>
+ </object>
+ <object class="NSMenuItem" id="551174276">
+ <reference key="NSMenu" ref="524015605"/>
+ <string key="NSTitle">Hilfe</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ <string key="NSAction">submenuAction:</string>
+ <object class="NSMenu" key="NSSubmenu" id="511848303">
+ <string key="NSTitle">Hilfe</string>
+ <array class="NSMutableArray" key="NSMenuItems">
+ <object class="NSMenuItem" id="504984881">
+ <reference key="NSMenu" ref="511848303"/>
+ <string key="NSTitle">X11 Hilfe</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ </array>
+ </object>
+ </object>
+ </array>
+ <string key="NSName">_NSMainMenu</string>
+ </object>
+ <object class="NSCustomObject" id="485884620">
+ <string key="NSClassName">X11Controller</string>
+ </object>
+ <object class="NSWindowTemplate" id="124913468">
+ <int key="NSWindowStyleMask">3</int>
+ <int key="NSWindowBacking">2</int>
+ <string key="NSWindowRect">{{2350, 1291.0391}, {550, 341}}</string>
+ <int key="NSWTFlags">1350041600</int>
+ <string key="NSWindowTitle">X11 Einstellungen</string>
+ <string key="NSWindowClass">NSPanel</string>
+ <object class="NSMutableString" key="NSViewClass">
+ <characters key="NS.bytes">View</characters>
+ </object>
+ <nil key="NSUserInterfaceItemIdentifier"/>
+ <string key="NSWindowContentMaxSize">{1.7976931348623157e+308, 1.7976931348623157e+308}</string>
+ <string key="NSWindowContentMinSize">{320, 240}</string>
+ <object class="NSView" key="NSWindowView" id="941366957">
+ <nil key="NSNextResponder"/>
+ <int key="NSvFlags">256</int>
+ <array class="NSMutableArray" key="NSSubviews">
+ <object class="NSTabView" id="448510093">
+ <reference key="NSNextResponder" ref="941366957"/>
+ <int key="NSvFlags">274</int>
+ <string key="NSFrame">{{13, 10}, {524, 325}}</string>
+ <reference key="NSSuperview" ref="941366957"/>
+ <array class="NSMutableArray" key="NSTabViewItems">
+ <object class="NSTabViewItem" id="287591690">
+ <object class="NSMutableString" key="NSIdentifier">
+ <characters key="NS.bytes">1</characters>
+ </object>
+ <object class="NSView" key="NSView" id="596750588">
+ <nil key="NSNextResponder"/>
+ <int key="NSvFlags">256</int>
+ <array class="NSMutableArray" key="NSSubviews">
+ <object class="NSButton" id="119157981">
+ <reference key="NSNextResponder" ref="596750588"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{18, 243}, {402, 18}}</string>
+ <reference key="NSSuperview" ref="596750588"/>
+ <reference key="NSNextKeyView" ref="179949713"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="990762273">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">Drei Maustasten nachbilden</string>
+ <object class="NSFont" key="NSSupport" id="463863101">
+ <string key="NSName">LucidaGrande</string>
+ <double key="NSSize">13</double>
+ <int key="NSfFlags">1044</int>
+ </object>
+ <reference key="NSControlView" ref="119157981"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <object class="NSCustomResource" key="NSNormalImage" id="192701610">
+ <string key="NSClassName">NSImage</string>
+ <string key="NSResourceName">NSSwitch</string>
+ </object>
+ <object class="NSButtonImageSource" key="NSAlternateImage" id="391434389">
+ <string key="NSImageName">NSSwitch</string>
+ </object>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSTextField" id="443008216">
+ <reference key="NSNextResponder" ref="596750588"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{36, 93}, {461, 28}}</string>
+ <reference key="NSSuperview" ref="596750588"/>
+ <reference key="NSNextKeyView" ref="406291430"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="391919450">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">Bei Aktivierung können die Tastenentsprechungen für die Menüleiste die X11-Programme stören, die Meta-Sondertasten verwenden.</string>
+ <object class="NSFont" key="NSSupport" id="26">
+ <string key="NSName">LucidaGrande</string>
+ <double key="NSSize">11</double>
+ <int key="NSfFlags">3100</int>
+ </object>
+ <string key="NSPlaceholderString"/>
+ <reference key="NSControlView" ref="443008216"/>
+ <object class="NSColor" key="NSBackgroundColor" id="57160303">
+ <int key="NSColorSpace">6</int>
+ <string key="NSCatalogName">System</string>
+ <string key="NSColorName">controlColor</string>
+ <object class="NSColor" key="NSColor" id="590688762">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes>
+ </object>
+ </object>
+ <object class="NSColor" key="NSTextColor" id="930815747">
+ <int key="NSColorSpace">6</int>
+ <string key="NSCatalogName">System</string>
+ <string key="NSColorName">controlTextColor</string>
+ <object class="NSColor" key="NSColor" id="214098874">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MAA</bytes>
+ </object>
+ </object>
+ </object>
+ </object>
+ <object class="NSTextField" id="282885445">
+ <reference key="NSNextResponder" ref="596750588"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{36, 203}, {461, 34}}</string>
+ <reference key="NSSuperview" ref="596750588"/>
+ <reference key="NSNextKeyView" ref="31160162"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="649334366">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string type="base64-UTF8" key="NSContents">SGFsdGVuIFNpZSBiZWltIEtsaWNrZW4gZGllIFdhaGx0YXN0ZSBvZGVyIGRpZSBCZWZlaGxzdGFzdGUg
+Z2VkcsO8Y2t0LCB1bSBkaWUgbWl0dGxlcmUgb2RlciBkaWUgcmVjaHRlIE1hdXN0YXN0ZSB6dSBha3Rp
+dmllcmVuLgo</string>
+ <reference key="NSSupport" ref="26"/>
+ <string key="NSPlaceholderString"/>
+ <reference key="NSControlView" ref="282885445"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ <object class="NSButton" id="842100515">
+ <reference key="NSNextResponder" ref="596750588"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{18, 127}, {402, 18}}</string>
+ <reference key="NSSuperview" ref="596750588"/>
+ <reference key="NSNextKeyView" ref="443008216"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="940564599">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">Tastenentsprechungen unter X11 aktivieren</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="842100515"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="192701610"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSTextField" id="31160162">
+ <reference key="NSNextResponder" ref="596750588"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{36, 151}, {461, 28}}</string>
+ <reference key="NSSuperview" ref="596750588"/>
+ <reference key="NSNextKeyView" ref="842100515"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="666057093">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">Bei Aktivierung kann Ihre aktuelle X11-Keymap durch Änderungen des Tastaturmenüs überschrieben werden.</string>
+ <reference key="NSSupport" ref="26"/>
+ <string key="NSPlaceholderString"/>
+ <reference key="NSControlView" ref="31160162"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ <object class="NSButton" id="179949713">
+ <reference key="NSNextResponder" ref="596750588"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{18, 185}, {402, 18}}</string>
+ <reference key="NSSuperview" ref="596750588"/>
+ <reference key="NSNextKeyView" ref="282885445"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="967619578">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">Tastaturbelegung des Systems verwenden</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="179949713"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="192701610"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSTextField" id="278155937">
+ <reference key="NSNextResponder" ref="596750588"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{36, 32}, {461, 31}}</string>
+ <reference key="NSSuperview" ref="596750588"/>
+ <reference key="NSNextKeyView" ref="863505041"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="617441821">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">Bei Aktivierung entsprechen die Wahltasten Alt_L und Alt_R X11-Tastensymbolen anstatt „Mode_switch“.</string>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSControlView" ref="278155937"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ <object class="NSButton" id="406291430">
+ <reference key="NSNextResponder" ref="596750588"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{18, 69}, {402, 18}}</string>
+ <reference key="NSSuperview" ref="596750588"/>
+ <reference key="NSNextKeyView" ref="278155937"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="67728988">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">Wahltasten entsprechen Alt_L und Alt_R</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="406291430"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="192701610"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSButton" id="863505041">
+ <reference key="NSNextResponder" ref="596750588"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{18, 8}, {418, 18}}</string>
+ <reference key="NSSuperview" ref="596750588"/>
+ <reference key="NSNextKeyView" ref="448510093"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="1016286396">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">Immer in Bewegungsrichtung der Finger scrollen</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="863505041"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="192701610"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ </array>
+ <string key="NSFrame">{{10, 33}, {504, 279}}</string>
+ <reference key="NSNextKeyView" ref="119157981"/>
+ </object>
+ <string key="NSLabel">Eingabe</string>
+ <reference key="NSColor" ref="57160303"/>
+ <reference key="NSTabView" ref="448510093"/>
+ </object>
+ <object class="NSTabViewItem" id="960678392">
+ <object class="NSMutableString" key="NSIdentifier">
+ <characters key="NS.bytes">2</characters>
+ </object>
+ <object class="NSView" key="NSView" id="515308735">
+ <nil key="NSNextResponder"/>
+ <int key="NSvFlags">256</int>
+ <array class="NSMutableArray" key="NSSubviews">
+ <object class="NSPopUpButton" id="709074847">
+ <reference key="NSNextResponder" ref="515308735"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{74, 235}, {197, 26}}</string>
+ <reference key="NSSuperview" ref="515308735"/>
+ <reference key="NSNextKeyView" ref="86150604"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSPopUpButtonCell" key="NSCell" id="633115429">
+ <int key="NSCellFlags">-2076049856</int>
+ <int key="NSCellFlags2">1024</int>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="709074847"/>
+ <int key="NSButtonFlags">109199615</int>
+ <int key="NSButtonFlags2">1</int>
+ <object class="NSFont" key="NSAlternateImage">
+ <string key="NSName">LucidaGrande</string>
+ <double key="NSSize">13</double>
+ <int key="NSfFlags">16</int>
+ </object>
+ <string key="NSAlternateContents"/>
+ <object class="NSMutableString" key="NSKeyEquivalent">
+ <characters key="NS.bytes"/>
+ </object>
+ <int key="NSPeriodicDelay">400</int>
+ <int key="NSPeriodicInterval">75</int>
+ <object class="NSMenuItem" key="NSMenuItem" id="616492372">
+ <reference key="NSMenu" ref="341113515"/>
+ <string key="NSTitle">Vom Monitor</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <int key="NSState">1</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ <string key="NSAction">_popUpItemAction:</string>
+ <int key="NSTag">-1</int>
+ <reference key="NSTarget" ref="633115429"/>
+ </object>
+ <bool key="NSMenuItemRespectAlignment">YES</bool>
+ <object class="NSMenu" key="NSMenu" id="341113515">
+ <object class="NSMutableString" key="NSTitle">
+ <characters key="NS.bytes">OtherViews</characters>
+ </object>
+ <array class="NSMutableArray" key="NSMenuItems">
+ <reference ref="616492372"/>
+ <object class="NSMenuItem" id="759499526">
+ <reference key="NSMenu" ref="341113515"/>
+ <string key="NSTitle">256 Farben</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ <string key="NSAction">_popUpItemAction:</string>
+ <int key="NSTag">8</int>
+ <reference key="NSTarget" ref="633115429"/>
+ </object>
+ <object class="NSMenuItem" id="543935434">
+ <reference key="NSMenu" ref="341113515"/>
+ <string key="NSTitle">32768 Farben</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ <string key="NSAction">_popUpItemAction:</string>
+ <int key="NSTag">15</int>
+ <reference key="NSTarget" ref="633115429"/>
+ </object>
+ <object class="NSMenuItem" id="836673018">
+ <reference key="NSMenu" ref="341113515"/>
+ <string key="NSTitle">16,7 Millionen Farben</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ <string key="NSAction">_popUpItemAction:</string>
+ <int key="NSTag">24</int>
+ <reference key="NSTarget" ref="633115429"/>
+ </object>
+ </array>
+ </object>
+ <int key="NSPreferredEdge">3</int>
+ <bool key="NSUsesItemFromMenu">YES</bool>
+ <bool key="NSAltersState">YES</bool>
+ <int key="NSArrowPosition">1</int>
+ </object>
+ </object>
+ <object class="NSTextField" id="201731424">
+ <reference key="NSNextResponder" ref="515308735"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{17, 238}, {55, 20}}</string>
+ <reference key="NSSuperview" ref="515308735"/>
+ <reference key="NSNextKeyView" ref="709074847"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="930265681">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">Farben:</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <string key="NSPlaceholderString"/>
+ <reference key="NSControlView" ref="201731424"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ <object class="NSTextField" id="86150604">
+ <reference key="NSNextResponder" ref="515308735"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{36, 216}, {392, 14}}</string>
+ <reference key="NSSuperview" ref="515308735"/>
+ <reference key="NSNextKeyView" ref="477203622"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="311969422">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">Diese Option wird beim nächsten Start von X11 wirksam.</string>
+ <reference key="NSSupport" ref="26"/>
+ <string key="NSPlaceholderString"/>
+ <reference key="NSControlView" ref="86150604"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ <object class="NSButton" id="477203622">
+ <reference key="NSNextResponder" ref="515308735"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{18, 182}, {409, 23}}</string>
+ <reference key="NSSuperview" ref="515308735"/>
+ <reference key="NSNextKeyView" ref="298603383"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="631531164">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">Vollbildmodus</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="477203622"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="192701610"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSButton" id="57246850">
+ <reference key="NSNextResponder" ref="515308735"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{37, 116}, {409, 23}}</string>
+ <reference key="NSSuperview" ref="515308735"/>
+ <reference key="NSNextKeyView" ref="331853183"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="917248662">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">Zugriff auf Menüleiste im Vollbildmodus erlauben</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="57246850"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="192701610"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSTextField" id="298603383">
+ <reference key="NSNextResponder" ref="515308735"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{36, 145}, {461, 42}}</string>
+ <reference key="NSSuperview" ref="515308735"/>
+ <reference key="NSNextKeyView" ref="57246850"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="761107402">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">Hiermit wird das X11-Hauptfenster aktiviert. Verwenden Sie die Tastenkombination Befehl+Wahl+A, um den Vollbildmodus ein- oder auszuschalten.</string>
+ <reference key="NSSupport" ref="26"/>
+ <string key="NSPlaceholderString"/>
+ <reference key="NSControlView" ref="298603383"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ <object class="NSTextField" id="331853183">
+ <reference key="NSNextResponder" ref="515308735"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{54, 79}, {436, 31}}</string>
+ <reference key="NSSuperview" ref="515308735"/>
+ <reference key="NSNextKeyView" ref="448510093"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="1042813110">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">Die Menüleiste wird sichtbar, sobald Sie den Mauszeiger in den oberen Bereich Ihres primären Display bewegen.</string>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSControlView" ref="331853183"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ </array>
+ <string key="NSFrame">{{10, 33}, {504, 279}}</string>
+ <reference key="NSNextKeyView" ref="201731424"/>
+ </object>
+ <string key="NSLabel">Ausgabe</string>
+ <reference key="NSColor" ref="57160303"/>
+ <reference key="NSTabView" ref="448510093"/>
+ </object>
+ <object class="NSTabViewItem" id="723450037">
+ <object class="NSMutableString" key="NSIdentifier">
+ <characters key="NS.bytes">2</characters>
+ </object>
+ <object class="NSView" key="NSView" id="408298283">
+ <reference key="NSNextResponder" ref="448510093"/>
+ <int key="NSvFlags">256</int>
+ <array class="NSMutableArray" key="NSSubviews">
+ <object class="NSButton" id="878106058">
+ <reference key="NSNextResponder" ref="408298283"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{11, 255}, {409, 23}}</string>
+ <reference key="NSSuperview" ref="408298283"/>
+ <reference key="NSNextKeyView" ref="386152084"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="718083688">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">Synchronisierung aktivieren</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="878106058"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="192701610"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSTextField" id="386152084">
+ <reference key="NSNextResponder" ref="408298283"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{29, 221}, {464, 28}}</string>
+ <reference key="NSSuperview" ref="408298283"/>
+ <reference key="NSNextKeyView" ref="487809555"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="572508492">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">Aktiviert das Menüobjekt „Kopieren“ und ermöglicht die Synchronisierung zwischen dem „OSX Pasteboard“ und den Pufferspeichern „CLIPBOARD“ und „PRIMARY“ von X11.</string>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSControlView" ref="386152084"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ <object class="NSButton" id="477050998">
+ <reference key="NSNextResponder" ref="408298283"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{27, 129}, {436, 18}}</string>
+ <reference key="NSSuperview" ref="408298283"/>
+ <reference key="NSNextKeyView" ref="765780304"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="501304422">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">CLIPBOARD aktualisieren, wenn Pasteboard geändert wird</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="477050998"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="192701610"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSButton" id="765780304">
+ <reference key="NSNextResponder" ref="408298283"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{27, 104}, {463, 18}}</string>
+ <reference key="NSSuperview" ref="408298283"/>
+ <reference key="NSNextKeyView" ref="1002778833"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="510771323">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">PRIMARY (Mittel-Klick) aktualisieren, wenn Pasteboard geändert wird</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="765780304"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="192701610"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSButton" id="1002778833">
+ <reference key="NSNextResponder" ref="408298283"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{27, 81}, {498, 18}}</string>
+ <reference key="NSSuperview" ref="408298283"/>
+ <reference key="NSNextKeyView" ref="522511724"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="897099877">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">Pasteboard sofort aktualisieren, wenn Text ausgewählt wird</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="1002778833"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="192701610"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSButton" id="487809555">
+ <reference key="NSNextResponder" ref="408298283"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{27, 192}, {438, 18}}</string>
+ <reference key="NSSuperview" ref="408298283"/>
+ <reference key="NSNextKeyView" ref="620944856"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="619977658">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">Pasteboard aktualisieren, wenn CLIPBOARD geändert wird</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="487809555"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="192701610"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSTextField" id="620944856">
+ <reference key="NSNextResponder" ref="408298283"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{41, 158}, {452, 28}}</string>
+ <reference key="NSSuperview" ref="408298283"/>
+ <reference key="NSNextKeyView" ref="477050998"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="461823902">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">Deaktivieren Sie diese Option, wenn Sie „xclipboard“, „klipper“ oder einen beliebigen anderen X11-Zwischenablage-Manager verwenden möchten.</string>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSControlView" ref="620944856"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ <object class="NSTextField" id="522511724">
+ <reference key="NSNextResponder" ref="408298283"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{41, 47}, {450, 28}}</string>
+ <reference key="NSSuperview" ref="408298283"/>
+ <reference key="NSNextKeyView" ref="448510093"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="994587858">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">Aufgrund von Einschränkungen im X11-Protokoll funktioniert diese Option in manchen Programmen u. U. nicht immer.</string>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSControlView" ref="522511724"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ </array>
+ <string key="NSFrame">{{10, 33}, {504, 279}}</string>
+ <reference key="NSSuperview" ref="448510093"/>
+ <reference key="NSNextKeyView" ref="878106058"/>
+ </object>
+ <string key="NSLabel">Zwischenablage</string>
+ <reference key="NSColor" ref="57160303"/>
+ <reference key="NSTabView" ref="448510093"/>
+ </object>
+ <object class="NSTabViewItem" id="10973343">
+ <object class="NSMutableString" key="NSIdentifier">
+ <characters key="NS.bytes">2</characters>
+ </object>
+ <object class="NSView" key="NSView" id="184765684">
+ <nil key="NSNextResponder"/>
+ <int key="NSvFlags">256</int>
+ <array class="NSMutableArray" key="NSSubviews">
+ <object class="NSButton" id="657659108">
+ <reference key="NSNextResponder" ref="184765684"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{15, 245}, {213, 18}}</string>
+ <reference key="NSSuperview" ref="184765684"/>
+ <reference key="NSNextKeyView" ref="290578835"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="259618205">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">Durch inaktive Fenster klicken</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="657659108"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="192701610"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSTextField" id="290578835">
+ <reference key="NSNextResponder" ref="184765684"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{23, 211}, {456, 28}}</string>
+ <reference key="NSSuperview" ref="184765684"/>
+ <reference key="NSNextKeyView" ref="992839333"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="399127858">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">Bei Aktivierung wird beim Klicken auf ein inaktives Fenster der Mausklick zusätzlich an dieses Fenster weitergegeben.</string>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSControlView" ref="290578835"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ <object class="NSButton" id="992839333">
+ <reference key="NSNextResponder" ref="184765684"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{15, 184}, {155, 18}}</string>
+ <reference key="NSSuperview" ref="184765684"/>
+ <reference key="NSNextKeyView" ref="138261120"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="959555182">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">Fokus folgt der Maus</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="992839333"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="192701610"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSTextField" id="138261120">
+ <reference key="NSNextResponder" ref="184765684"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{23, 161}, {442, 17}}</string>
+ <reference key="NSSuperview" ref="184765684"/>
+ <reference key="NSNextKeyView" ref="128352289"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="183409141">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">Der Fokus des X11-Fensters folgt dem Cursor. Dies hat einige nachteilige Effekte.</string>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSControlView" ref="138261120"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ <object class="NSButton" id="128352289">
+ <reference key="NSNextResponder" ref="184765684"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{15, 140}, {402, 18}}</string>
+ <reference key="NSSuperview" ref="184765684"/>
+ <reference key="NSNextKeyView" ref="57161931"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="556463187">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">Fokus auf neuem Fenster</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="128352289"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="192701610"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSTextField" id="57161931">
+ <reference key="NSNextResponder" ref="184765684"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{23, 92}, {456, 42}}</string>
+ <reference key="NSSuperview" ref="184765684"/>
+ <reference key="NSNextKeyView" ref="448510093"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="989804990">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">Bei Aktivierung wird beim Erzeugen eines neuen X11-Fensters das „X11.app“ in den Vordergrund gebracht (anstelle von „Finder.app“, „Terminal.app“ usw.).</string>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSControlView" ref="57161931"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ </array>
+ <string key="NSFrame">{{10, 33}, {504, 279}}</string>
+ <reference key="NSNextKeyView" ref="657659108"/>
+ </object>
+ <string key="NSLabel">Fenster</string>
+ <reference key="NSColor" ref="57160303"/>
+ <reference key="NSTabView" ref="448510093"/>
+ </object>
+ <object class="NSTabViewItem" id="348328898">
+ <object class="NSView" key="NSView" id="300811574">
+ <nil key="NSNextResponder"/>
+ <int key="NSvFlags">256</int>
+ <array class="NSMutableArray" key="NSSubviews">
+ <object class="NSButton" id="989050925">
+ <reference key="NSNextResponder" ref="300811574"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{18, 243}, {215, 18}}</string>
+ <reference key="NSSuperview" ref="300811574"/>
+ <reference key="NSNextKeyView" ref="168436707"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="189594322">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">Verbindungen authentifizieren</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="989050925"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="192701610"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSButton" id="700826966">
+ <reference key="NSNextResponder" ref="300811574"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{18, 166}, {312, 18}}</string>
+ <reference key="NSSuperview" ref="300811574"/>
+ <reference key="NSNextKeyView" ref="363817195"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="489340979">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">Verbindungen von Netzwerk-Clients erlauben</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="700826966"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="192701610"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSTextField" id="168436707">
+ <reference key="NSNextResponder" ref="300811574"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{36, 189}, {463, 48}}</string>
+ <reference key="NSSuperview" ref="300811574"/>
+ <reference key="NSNextKeyView" ref="700826966"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="53243865">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">Beim Starten von X11 werden Xauthority-Schlüssel zur Zugriffskontrolle erstellt. Wenn sich die IP-Adresse des Systems ändert, sind diese Schlüssel nicht mehr gültig. Möglicherweise können die X11-Programme dann nicht mehr gestartet werden.</string>
+ <reference key="NSSupport" ref="26"/>
+ <string key="NSPlaceholderString"/>
+ <reference key="NSControlView" ref="168436707"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ <object class="NSTextField" id="363817195">
+ <reference key="NSNextResponder" ref="300811574"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{36, 104}, {463, 56}}</string>
+ <reference key="NSSuperview" ref="300811574"/>
+ <reference key="NSNextKeyView" ref="223835729"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="390084685">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">Bei Aktivierung muss „Verbindungen authentifizieren“ ebenfalls aktiviert sein, damit die Sicherheit des System gewährleistet ist. Bei Deaktivierung sind Verbindungen von entfernten Programmen nicht erlaubt.</string>
+ <reference key="NSSupport" ref="26"/>
+ <string key="NSPlaceholderString"/>
+ <reference key="NSControlView" ref="363817195"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ <object class="NSTextField" id="223835729">
+ <reference key="NSNextResponder" ref="300811574"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{17, 17}, {404, 14}}</string>
+ <reference key="NSSuperview" ref="300811574"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="283628678">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">Diese Optionen werden beim nächsten Start von X11 wirksam.</string>
+ <reference key="NSSupport" ref="26"/>
+ <string key="NSPlaceholderString"/>
+ <reference key="NSControlView" ref="223835729"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ </array>
+ <string key="NSFrame">{{10, 33}, {504, 279}}</string>
+ <reference key="NSNextKeyView" ref="989050925"/>
+ </object>
+ <string key="NSLabel">Sicherheit</string>
+ <reference key="NSColor" ref="57160303"/>
+ <reference key="NSTabView" ref="448510093"/>
+ </object>
+ </array>
+ <reference key="NSSelectedTabViewItem" ref="723450037"/>
+ <reference key="NSFont" ref="463863101"/>
+ <int key="NSTvFlags">0</int>
+ <bool key="NSAllowTruncatedLabels">YES</bool>
+ <bool key="NSDrawsBackground">YES</bool>
+ <array class="NSMutableArray" key="NSSubviews">
+ <reference ref="408298283"/>
+ </array>
+ </object>
+ </array>
+ <string key="NSFrameSize">{550, 341}</string>
+ <reference key="NSNextKeyView" ref="448510093"/>
+ </object>
+ <string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
+ <string key="NSMinSize">{320, 262}</string>
+ <string key="NSMaxSize">{1.7976931348623157e+308, 1.7976931348623157e+308}</string>
+ <string key="NSFrameAutosaveName">x11_prefs</string>
+ </object>
+ <object class="NSWindowTemplate" id="604417141">
+ <int key="NSWindowStyleMask">11</int>
+ <int key="NSWindowBacking">2</int>
+ <string key="NSWindowRect">{{360, 400}, {512, 271}}</string>
+ <int key="NSWTFlags">1350041600</int>
+ <string key="NSWindowTitle">X11-Programmmenü</string>
+ <string key="NSWindowClass">NSPanel</string>
+ <object class="NSMutableString" key="NSViewClass">
+ <characters key="NS.bytes">View</characters>
+ </object>
+ <nil key="NSUserInterfaceItemIdentifier"/>
+ <string key="NSWindowContentMaxSize">{1.7976931348623157e+308, 1.7976931348623157e+308}</string>
+ <string key="NSWindowContentMinSize">{512, 240}</string>
+ <object class="NSView" key="NSWindowView" id="85544634">
+ <nil key="NSNextResponder"/>
+ <int key="NSvFlags">256</int>
+ <array class="NSMutableArray" key="NSSubviews">
+ <object class="NSButton" id="671954382">
+ <reference key="NSNextResponder" ref="85544634"/>
+ <int key="NSvFlags">265</int>
+ <string key="NSFrame">{{340, 191}, {158, 32}}</string>
+ <reference key="NSSuperview" ref="85544634"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="143554520">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">137887744</int>
+ <string key="NSContents">Duplizieren</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="671954382"/>
+ <int key="NSButtonFlags">-2038284033</int>
+ <int key="NSButtonFlags2">1</int>
+ <object class="NSFont" key="NSAlternateImage" id="549406736">
+ <string key="NSName">Helvetica</string>
+ <double key="NSSize">13</double>
+ <int key="NSfFlags">16</int>
+ </object>
+ <string key="NSAlternateContents"/>
+ <object class="NSMutableString" key="NSKeyEquivalent">
+ <characters key="NS.bytes"/>
+ </object>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSButton" id="492358940">
+ <reference key="NSNextResponder" ref="85544634"/>
+ <int key="NSvFlags">265</int>
+ <string key="NSFrame">{{340, 159}, {158, 32}}</string>
+ <reference key="NSSuperview" ref="85544634"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="8201128">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">137887744</int>
+ <string key="NSContents">Entfernen</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="492358940"/>
+ <int key="NSButtonFlags">-2038284033</int>
+ <int key="NSButtonFlags2">1</int>
+ <reference key="NSAlternateImage" ref="549406736"/>
+ <string key="NSAlternateContents"/>
+ <object class="NSMutableString" key="NSKeyEquivalent">
+ <characters key="NS.bytes"/>
+ </object>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSScrollView" id="1063387772">
+ <reference key="NSNextResponder" ref="85544634"/>
+ <int key="NSvFlags">274</int>
+ <array class="NSMutableArray" key="NSSubviews">
+ <object class="NSClipView" id="580565898">
+ <reference key="NSNextResponder" ref="1063387772"/>
+ <int key="NSvFlags">2304</int>
+ <array class="NSMutableArray" key="NSSubviews">
+ <object class="NSTableView" id="905092943">
+ <reference key="NSNextResponder" ref="580565898"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrameSize">{301, 198}</string>
+ <reference key="NSSuperview" ref="580565898"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTableHeaderView" key="NSHeaderView" id="792419186">
+ <reference key="NSNextResponder" ref="672307654"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrameSize">{301, 17}</string>
+ <reference key="NSSuperview" ref="672307654"/>
+ <reference key="NSTableView" ref="905092943"/>
+ </object>
+ <object class="_NSCornerView" key="NSCornerView" id="898633680">
+ <reference key="NSNextResponder" ref="1063387772"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{302, 0}, {16, 17}}</string>
+ <reference key="NSSuperview" ref="1063387772"/>
+ </object>
+ <array class="NSMutableArray" key="NSTableColumns">
+ <object class="NSTableColumn" id="938444323">
+ <double key="NSWidth">122.73100280761719</double>
+ <double key="NSMinWidth">62.730998992919922</double>
+ <double key="NSMaxWidth">1000</double>
+ <object class="NSTableHeaderCell" key="NSHeaderCell">
+ <int key="NSCellFlags">75628096</int>
+ <int key="NSCellFlags2">2048</int>
+ <string key="NSContents">Name</string>
+ <reference key="NSSupport" ref="26"/>
+ <object class="NSColor" key="NSBackgroundColor" id="113872566">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MC4zMzMzMzI5ODU2AA</bytes>
+ </object>
+ <object class="NSColor" key="NSTextColor" id="249576247">
+ <int key="NSColorSpace">6</int>
+ <string key="NSCatalogName">System</string>
+ <string key="NSColorName">headerTextColor</string>
+ <reference key="NSColor" ref="214098874"/>
+ </object>
+ </object>
+ <object class="NSTextFieldCell" key="NSDataCell" id="825378892">
+ <int key="NSCellFlags">338820672</int>
+ <int key="NSCellFlags2">1024</int>
+ <string key="NSContents">Textzelle</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <string key="NSPlaceholderString"/>
+ <reference key="NSControlView" ref="905092943"/>
+ <object class="NSColor" key="NSBackgroundColor" id="822946413">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MQA</bytes>
+ </object>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ <int key="NSResizingMask">3</int>
+ <bool key="NSIsResizeable">YES</bool>
+ <bool key="NSIsEditable">YES</bool>
+ <reference key="NSTableView" ref="905092943"/>
+ </object>
+ <object class="NSTableColumn" id="84282687">
+ <double key="NSWidth">100</double>
+ <double key="NSMinWidth">40</double>
+ <double key="NSMaxWidth">1000</double>
+ <object class="NSTableHeaderCell" key="NSHeaderCell">
+ <int key="NSCellFlags">75628096</int>
+ <int key="NSCellFlags2">2048</int>
+ <string key="NSContents">Befehl</string>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSBackgroundColor" ref="113872566"/>
+ <reference key="NSTextColor" ref="249576247"/>
+ </object>
+ <object class="NSTextFieldCell" key="NSDataCell" id="432610585">
+ <int key="NSCellFlags">338820672</int>
+ <int key="NSCellFlags2">1024</int>
+ <string key="NSContents">Textzelle</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <string key="NSPlaceholderString"/>
+ <reference key="NSControlView" ref="905092943"/>
+ <reference key="NSBackgroundColor" ref="822946413"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ <int key="NSResizingMask">3</int>
+ <bool key="NSIsResizeable">YES</bool>
+ <bool key="NSIsEditable">YES</bool>
+ <reference key="NSTableView" ref="905092943"/>
+ </object>
+ <object class="NSTableColumn" id="242608782">
+ <double key="NSWidth">69</double>
+ <double key="NSMinWidth">10</double>
+ <double key="NSMaxWidth">1000</double>
+ <object class="NSTableHeaderCell" key="NSHeaderCell">
+ <int key="NSCellFlags">75628096</int>
+ <int key="NSCellFlags2">2048</int>
+ <string key="NSContents">Kurzbefehl</string>
+ <reference key="NSSupport" ref="26"/>
+ <object class="NSColor" key="NSBackgroundColor">
+ <int key="NSColorSpace">6</int>
+ <string key="NSCatalogName">System</string>
+ <string key="NSColorName">headerColor</string>
+ <reference key="NSColor" ref="822946413"/>
+ </object>
+ <reference key="NSTextColor" ref="249576247"/>
+ </object>
+ <object class="NSTextFieldCell" key="NSDataCell" id="34714764">
+ <int key="NSCellFlags">338820672</int>
+ <int key="NSCellFlags2">1024</int>
+ <string key="NSContents">Textzelle</string>
+ <object class="NSFont" key="NSSupport">
+ <string key="NSName">LucidaGrande</string>
+ <double key="NSSize">12</double>
+ <int key="NSfFlags">16</int>
+ </object>
+ <string key="NSPlaceholderString"/>
+ <reference key="NSControlView" ref="905092943"/>
+ <bool key="NSDrawsBackground">YES</bool>
+ <object class="NSColor" key="NSBackgroundColor" id="812484075">
+ <int key="NSColorSpace">6</int>
+ <string key="NSCatalogName">System</string>
+ <string key="NSColorName">controlBackgroundColor</string>
+ <reference key="NSColor" ref="590688762"/>
+ </object>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ <int key="NSResizingMask">3</int>
+ <bool key="NSIsResizeable">YES</bool>
+ <bool key="NSIsEditable">YES</bool>
+ <reference key="NSTableView" ref="905092943"/>
+ </object>
+ </array>
+ <double key="NSIntercellSpacingWidth">3</double>
+ <double key="NSIntercellSpacingHeight">2</double>
+ <reference key="NSBackgroundColor" ref="822946413"/>
+ <object class="NSColor" key="NSGridColor">
+ <int key="NSColorSpace">6</int>
+ <string key="NSCatalogName">System</string>
+ <string key="NSColorName">gridColor</string>
+ <object class="NSColor" key="NSColor">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MC41AA</bytes>
+ </object>
+ </object>
+ <double key="NSRowHeight">17</double>
+ <int key="NSTvFlags">1379958784</int>
+ <reference key="NSDelegate"/>
+ <reference key="NSDataSource"/>
+ <int key="NSColumnAutoresizingStyle">1</int>
+ <int key="NSDraggingSourceMaskForLocal">-1</int>
+ <int key="NSDraggingSourceMaskForNonLocal">0</int>
+ <bool key="NSAllowsTypeSelect">YES</bool>
+ <int key="NSTableViewDraggingDestinationStyle">0</int>
+ <int key="NSTableViewGroupRowStyle">1</int>
+ </object>
+ </array>
+ <string key="NSFrame">{{1, 17}, {301, 198}}</string>
+ <reference key="NSSuperview" ref="1063387772"/>
+ <reference key="NSNextKeyView" ref="905092943"/>
+ <reference key="NSDocView" ref="905092943"/>
+ <reference key="NSBGColor" ref="812484075"/>
+ <int key="NScvFlags">4</int>
+ </object>
+ <object class="NSScroller" id="842897584">
+ <reference key="NSNextResponder" ref="1063387772"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{302, 17}, {15, 198}}</string>
+ <reference key="NSSuperview" ref="1063387772"/>
+ <reference key="NSTarget" ref="1063387772"/>
+ <string key="NSAction">_doScroller:</string>
+ <double key="NSPercent">0.99492377042770386</double>
+ </object>
+ <object class="NSScroller" id="17278747">
+ <reference key="NSNextResponder" ref="1063387772"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{1, 215}, {301, 15}}</string>
+ <reference key="NSSuperview" ref="1063387772"/>
+ <int key="NSsFlags">1</int>
+ <reference key="NSTarget" ref="1063387772"/>
+ <string key="NSAction">_doScroller:</string>
+ <double key="NSPercent">0.68852460384368896</double>
+ </object>
+ <object class="NSClipView" id="672307654">
+ <reference key="NSNextResponder" ref="1063387772"/>
+ <int key="NSvFlags">2304</int>
+ <array class="NSMutableArray" key="NSSubviews">
+ <reference ref="792419186"/>
+ </array>
+ <string key="NSFrame">{{1, 0}, {301, 17}}</string>
+ <reference key="NSSuperview" ref="1063387772"/>
+ <reference key="NSNextKeyView" ref="792419186"/>
+ <reference key="NSDocView" ref="792419186"/>
+ <reference key="NSBGColor" ref="812484075"/>
+ <int key="NScvFlags">4</int>
+ </object>
+ <reference ref="898633680"/>
+ </array>
+ <string key="NSFrame">{{20, 20}, {318, 231}}</string>
+ <reference key="NSSuperview" ref="85544634"/>
+ <reference key="NSNextKeyView" ref="580565898"/>
+ <int key="NSsFlags">133170</int>
+ <reference key="NSVScroller" ref="842897584"/>
+ <reference key="NSHScroller" ref="17278747"/>
+ <reference key="NSContentView" ref="580565898"/>
+ <reference key="NSHeaderClipView" ref="672307654"/>
+ <bytes key="NSScrollAmts">QSAAAEEgAABBmAAAQZgAAA</bytes>
+ </object>
+ <object class="NSButton" id="758204686">
+ <reference key="NSNextResponder" ref="85544634"/>
+ <int key="NSvFlags">265</int>
+ <string key="NSFrame">{{340, 223}, {158, 32}}</string>
+ <reference key="NSSuperview" ref="85544634"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="1025474039">
+ <int key="NSCellFlags">-2080244224</int>
+ <int key="NSCellFlags2">137887744</int>
+ <string key="NSContents">Objekt hinzufügen</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="758204686"/>
+ <int key="NSButtonFlags">-2038284033</int>
+ <int key="NSButtonFlags2">1</int>
+ <reference key="NSAlternateImage" ref="549406736"/>
+ <string key="NSAlternateContents"/>
+ <object class="NSMutableString" key="NSKeyEquivalent">
+ <characters key="NS.bytes"/>
+ </object>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ </array>
+ <string key="NSFrameSize">{512, 271}</string>
+ </object>
+ <string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
+ <string key="NSMinSize">{512, 262}</string>
+ <string key="NSMaxSize">{1.7976931348623157e+308, 1.7976931348623157e+308}</string>
+ <string key="NSFrameAutosaveName">x11_apps</string>
+ </object>
+ <object class="NSMenu" id="294137138">
+ <string key="NSTitle">Menü</string>
+ <array class="NSMutableArray" key="NSMenuItems">
+ <object class="NSMenuItem" id="318286212">
+ <reference key="NSMenu" ref="294137138"/>
+ <bool key="NSIsDisabled">YES</bool>
+ <bool key="NSIsSeparator">YES</bool>
+ <string key="NSTitle"/>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="511651072">
+ <reference key="NSMenu" ref="294137138"/>
+ <string key="NSTitle">Programme</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ <string key="NSAction">submenuAction:</string>
+ <object class="NSMenu" key="NSSubmenu" id="48278059">
+ <string key="NSTitle">Programme</string>
+ <array class="NSMutableArray" key="NSMenuItems">
+ <object class="NSMenuItem" id="563798000">
+ <reference key="NSMenu" ref="48278059"/>
+ <bool key="NSIsDisabled">YES</bool>
+ <bool key="NSIsSeparator">YES</bool>
+ <string key="NSTitle"/>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="1032342329">
+ <reference key="NSMenu" ref="48278059"/>
+ <string key="NSTitle">Anpassen …</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ </array>
+ </object>
+ </object>
+ </array>
+ <string key="NSName"/>
+ </object>
+ </array>
+ <object class="IBObjectContainer" key="IBDocument.Objects">
+ <array class="NSMutableArray" key="connectionRecords">
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">copy:</string>
+ <reference key="source" ref="941939442"/>
+ <reference key="destination" ref="185296989"/>
+ </object>
+ <int key="connectionID">181</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">minimize_window:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="677652931"/>
+ </object>
+ <int key="connectionID">202</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">close_window:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="984461797"/>
+ </object>
+ <int key="connectionID">205</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">zoom_window:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="1066447520"/>
+ </object>
+ <int key="connectionID">206</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">bring_to_front:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="276216762"/>
+ </object>
+ <int key="connectionID">207</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">hideOtherApplications:</string>
+ <reference key="source" ref="815810918"/>
+ <reference key="destination" ref="206802571"/>
+ </object>
+ <int key="connectionID">263</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">apps_separator</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="390088328"/>
+ </object>
+ <int key="connectionID">273</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">apps_table</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="905092943"/>
+ </object>
+ <int key="connectionID">301</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">apps_table_delete:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="492358940"/>
+ </object>
+ <int key="connectionID">303</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">apps_table_duplicate:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="671954382"/>
+ </object>
+ <int key="connectionID">304</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">apps_table_show:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="1065386165"/>
+ </object>
+ <int key="connectionID">308</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">apps_table_new:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="758204686"/>
+ </object>
+ <int key="connectionID">311</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_show:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="386173216"/>
+ </object>
+ <int key="connectionID">318</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">x11_about_item</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="139290918"/>
+ </object>
+ <int key="connectionID">321</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">enable_auth</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="989050925"/>
+ </object>
+ <int key="connectionID">387</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">enable_tcp</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="700826966"/>
+ </object>
+ <int key="connectionID">388</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">depth</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="709074847"/>
+ </object>
+ <int key="connectionID">389</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">fake_buttons</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="119157981"/>
+ </object>
+ <int key="connectionID">391</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">sync_keymap</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="179949713"/>
+ </object>
+ <int key="connectionID">392</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">enable_keyequivs</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="842100515"/>
+ </object>
+ <int key="connectionID">393</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="119157981"/>
+ </object>
+ <int key="connectionID">394</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="179949713"/>
+ </object>
+ <int key="connectionID">395</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="842100515"/>
+ </object>
+ <int key="connectionID">396</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="709074847"/>
+ </object>
+ <int key="connectionID">398</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="989050925"/>
+ </object>
+ <int key="connectionID">399</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="700826966"/>
+ </object>
+ <int key="connectionID">401</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">prefs_panel</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="124913468"/>
+ </object>
+ <int key="connectionID">402</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">x11_help:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="504984881"/>
+ </object>
+ <int key="connectionID">422</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">dockMenu</string>
+ <reference key="source" ref="815810918"/>
+ <reference key="destination" ref="294137138"/>
+ </object>
+ <int key="connectionID">426</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">dock_menu</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="294137138"/>
+ </object>
+ <int key="connectionID">428</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">delegate</string>
+ <reference key="source" ref="815810918"/>
+ <reference key="destination" ref="485884620"/>
+ </object>
+ <int key="connectionID">429</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">hide:</string>
+ <reference key="source" ref="815810918"/>
+ <reference key="destination" ref="301008465"/>
+ </object>
+ <int key="connectionID">430</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">unhideAllApplications:</string>
+ <reference key="source" ref="815810918"/>
+ <reference key="destination" ref="1023546148"/>
+ </object>
+ <int key="connectionID">431</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">orderFrontStandardAboutPanel:</string>
+ <reference key="source" ref="815810918"/>
+ <reference key="destination" ref="139290918"/>
+ </object>
+ <int key="connectionID">433</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">dock_apps_menu</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="48278059"/>
+ </object>
+ <int key="connectionID">530</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">dock_window_separator</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="318286212"/>
+ </object>
+ <int key="connectionID">531</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">apps_table_show:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="1032342329"/>
+ </object>
+ <int key="connectionID">534</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">next_window:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="1036389925"/>
+ </object>
+ <int key="connectionID">539</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">previous_window:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="369641893"/>
+ </object>
+ <int key="connectionID">540</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">enable_fullscreen</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="477203622"/>
+ </object>
+ <int key="connectionID">546</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">enable_fullscreen_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="477203622"/>
+ </object>
+ <int key="connectionID">547</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">toggle_fullscreen:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="6876565"/>
+ </object>
+ <int key="connectionID">548</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">toggle_fullscreen_item</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="6876565"/>
+ </object>
+ <int key="connectionID">549</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">menu</string>
+ <reference key="source" ref="815810918"/>
+ <reference key="destination" ref="524015605"/>
+ </object>
+ <int key="connectionID">300334</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">terminate:</string>
+ <reference key="source" ref="815810918"/>
+ <reference key="destination" ref="274138642"/>
+ </object>
+ <int key="connectionID">300336</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="657659108"/>
+ </object>
+ <int key="connectionID">300389</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="992839333"/>
+ </object>
+ <int key="connectionID">300390</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="128352289"/>
+ </object>
+ <int key="connectionID">300391</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">click_through</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="657659108"/>
+ </object>
+ <int key="connectionID">300392</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">focus_follows_mouse</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="992839333"/>
+ </object>
+ <int key="connectionID">300393</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">focus_on_new_window</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="128352289"/>
+ </object>
+ <int key="connectionID">300394</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">copy_menu_item</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="185296989"/>
+ </object>
+ <int key="connectionID">300443</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">sync_pasteboard</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="878106058"/>
+ </object>
+ <int key="connectionID">300444</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">sync_clipboard_to_pasteboard</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="487809555"/>
+ </object>
+ <int key="connectionID">300461</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">sync_pasteboard_to_clipboard</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="477050998"/>
+ </object>
+ <int key="connectionID">300462</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">sync_pasteboard_to_primary</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="765780304"/>
+ </object>
+ <int key="connectionID">300463</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">sync_primary_immediately</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="1002778833"/>
+ </object>
+ <int key="connectionID">300464</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="878106058"/>
+ </object>
+ <int key="connectionID">300465</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="487809555"/>
+ </object>
+ <int key="connectionID">300466</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="477050998"/>
+ </object>
+ <int key="connectionID">300467</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="765780304"/>
+ </object>
+ <int key="connectionID">300468</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="1002778833"/>
+ </object>
+ <int key="connectionID">300469</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">sync_text1</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="620944856"/>
+ </object>
+ <int key="connectionID">300470</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">sync_text2</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="522511724"/>
+ </object>
+ <int key="connectionID">300471</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">enable_fullscreen_menu</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="57246850"/>
+ </object>
+ <int key="connectionID">300474</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="57246850"/>
+ </object>
+ <int key="connectionID">300475</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="406291430"/>
+ </object>
+ <int key="connectionID">300480</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">option_sends_alt</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="406291430"/>
+ </object>
+ <int key="connectionID">300481</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="863505041"/>
+ </object>
+ <int key="connectionID">300484</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">enable_fullscreen_menu_text</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="331853183"/>
+ </object>
+ <int key="connectionID">300489</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">scroll_in_device_direction</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="863505041"/>
+ </object>
+ <int key="connectionID">300490</int>
+ </object>
+ </array>
+ <object class="IBMutableOrderedSet" key="objectRecords">
+ <array key="orderedObjects">
+ <object class="IBObjectRecord">
+ <int key="objectID">0</int>
+ <array key="object" id="0"/>
+ <reference key="children" ref="904585544"/>
+ <nil key="parent"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">-2</int>
+ <reference key="object" ref="815810918"/>
+ <reference key="parent" ref="0"/>
+ <string key="objectName">File's Owner</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">-1</int>
+ <reference key="object" ref="941939442"/>
+ <reference key="parent" ref="0"/>
+ <string key="objectName">First Responder</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">-3</int>
+ <reference key="object" ref="951368722"/>
+ <reference key="parent" ref="0"/>
+ <string key="objectName">Application</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">29</int>
+ <reference key="object" ref="524015605"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="931553638"/>
+ <reference ref="365880285"/>
+ <reference ref="200491363"/>
+ <reference ref="868031522"/>
+ <reference ref="551174276"/>
+ </array>
+ <reference key="parent" ref="0"/>
+ <string key="objectName">MainMenu</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">19</int>
+ <reference key="object" ref="931553638"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="96874957"/>
+ </array>
+ <reference key="parent" ref="524015605"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">24</int>
+ <reference key="object" ref="96874957"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="677652931"/>
+ <reference ref="276216762"/>
+ <reference ref="1066447520"/>
+ <reference ref="1036389925"/>
+ <reference ref="369641893"/>
+ <reference ref="155085383"/>
+ <reference ref="984461797"/>
+ <reference ref="280172320"/>
+ </array>
+ <reference key="parent" ref="931553638"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">5</int>
+ <reference key="object" ref="276216762"/>
+ <reference key="parent" ref="96874957"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">23</int>
+ <reference key="object" ref="677652931"/>
+ <reference key="parent" ref="96874957"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">92</int>
+ <reference key="object" ref="280172320"/>
+ <reference key="parent" ref="96874957"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">203</int>
+ <reference key="object" ref="984461797"/>
+ <reference key="parent" ref="96874957"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">204</int>
+ <reference key="object" ref="1066447520"/>
+ <reference key="parent" ref="96874957"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">536</int>
+ <reference key="object" ref="155085383"/>
+ <reference key="parent" ref="96874957"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">537</int>
+ <reference key="object" ref="1036389925"/>
+ <reference key="parent" ref="96874957"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">538</int>
+ <reference key="object" ref="369641893"/>
+ <reference key="parent" ref="96874957"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">56</int>
+ <reference key="object" ref="365880285"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="576521955"/>
+ </array>
+ <reference key="parent" ref="524015605"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">57</int>
+ <reference key="object" ref="576521955"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="139290918"/>
+ <reference ref="386173216"/>
+ <reference ref="32285361"/>
+ <reference ref="301008465"/>
+ <reference ref="274138642"/>
+ <reference ref="272876017"/>
+ <reference ref="431301145"/>
+ <reference ref="206802571"/>
+ <reference ref="848095279"/>
+ <reference ref="1023546148"/>
+ <reference ref="6876565"/>
+ <reference ref="479677589"/>
+ </array>
+ <reference key="parent" ref="365880285"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">58</int>
+ <reference key="object" ref="139290918"/>
+ <reference key="parent" ref="576521955"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">129</int>
+ <reference key="object" ref="386173216"/>
+ <reference key="parent" ref="576521955"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">131</int>
+ <reference key="object" ref="32285361"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="821388474"/>
+ </array>
+ <reference key="parent" ref="576521955"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">130</int>
+ <reference key="object" ref="821388474"/>
+ <reference key="parent" ref="32285361"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">134</int>
+ <reference key="object" ref="301008465"/>
+ <reference key="parent" ref="576521955"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">136</int>
+ <reference key="object" ref="274138642"/>
+ <reference key="parent" ref="576521955"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">143</int>
+ <reference key="object" ref="272876017"/>
+ <reference key="parent" ref="576521955"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">144</int>
+ <reference key="object" ref="431301145"/>
+ <reference key="parent" ref="576521955"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">145</int>
+ <reference key="object" ref="206802571"/>
+ <reference key="parent" ref="576521955"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">149</int>
+ <reference key="object" ref="848095279"/>
+ <reference key="parent" ref="576521955"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">150</int>
+ <reference key="object" ref="1023546148"/>
+ <reference key="parent" ref="576521955"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">544</int>
+ <reference key="object" ref="6876565"/>
+ <reference key="parent" ref="576521955"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">545</int>
+ <reference key="object" ref="479677589"/>
+ <reference key="parent" ref="576521955"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">163</int>
+ <reference key="object" ref="200491363"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="526778998"/>
+ </array>
+ <reference key="parent" ref="524015605"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">169</int>
+ <reference key="object" ref="526778998"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="185296989"/>
+ </array>
+ <reference key="parent" ref="200491363"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">157</int>
+ <reference key="object" ref="185296989"/>
+ <reference key="parent" ref="526778998"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">269</int>
+ <reference key="object" ref="868031522"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="981161348"/>
+ </array>
+ <reference key="parent" ref="524015605"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">270</int>
+ <reference key="object" ref="981161348"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="390088328"/>
+ <reference ref="1065386165"/>
+ </array>
+ <reference key="parent" ref="868031522"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">272</int>
+ <reference key="object" ref="390088328"/>
+ <reference key="parent" ref="981161348"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">305</int>
+ <reference key="object" ref="1065386165"/>
+ <reference key="parent" ref="981161348"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">419</int>
+ <reference key="object" ref="551174276"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="511848303"/>
+ </array>
+ <reference key="parent" ref="524015605"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">420</int>
+ <reference key="object" ref="511848303"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="504984881"/>
+ </array>
+ <reference key="parent" ref="551174276"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">421</int>
+ <reference key="object" ref="504984881"/>
+ <reference key="parent" ref="511848303"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">196</int>
+ <reference key="object" ref="485884620"/>
+ <reference key="parent" ref="0"/>
+ <string key="objectName">X11Controller</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">244</int>
+ <reference key="object" ref="124913468"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="941366957"/>
+ </array>
+ <reference key="parent" ref="0"/>
+ <string key="objectName">PrefsPanel</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">245</int>
+ <reference key="object" ref="941366957"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="448510093"/>
+ </array>
+ <reference key="parent" ref="124913468"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">348</int>
+ <reference key="object" ref="448510093"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="287591690"/>
+ <reference ref="960678392"/>
+ <reference ref="348328898"/>
+ <reference ref="10973343"/>
+ <reference ref="723450037"/>
+ </array>
+ <reference key="parent" ref="941366957"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">349</int>
+ <reference key="object" ref="287591690"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="596750588"/>
+ </array>
+ <reference key="parent" ref="448510093"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">351</int>
+ <reference key="object" ref="596750588"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="119157981"/>
+ <reference ref="443008216"/>
+ <reference ref="282885445"/>
+ <reference ref="842100515"/>
+ <reference ref="31160162"/>
+ <reference ref="179949713"/>
+ <reference ref="278155937"/>
+ <reference ref="406291430"/>
+ <reference ref="863505041"/>
+ </array>
+ <reference key="parent" ref="287591690"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">363</int>
+ <reference key="object" ref="119157981"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="990762273"/>
+ </array>
+ <reference key="parent" ref="596750588"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">364</int>
+ <reference key="object" ref="443008216"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="391919450"/>
+ </array>
+ <reference key="parent" ref="596750588"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">365</int>
+ <reference key="object" ref="282885445"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="649334366"/>
+ </array>
+ <reference key="parent" ref="596750588"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">368</int>
+ <reference key="object" ref="842100515"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="940564599"/>
+ </array>
+ <reference key="parent" ref="596750588"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">369</int>
+ <reference key="object" ref="31160162"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="666057093"/>
+ </array>
+ <reference key="parent" ref="596750588"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">370</int>
+ <reference key="object" ref="179949713"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="967619578"/>
+ </array>
+ <reference key="parent" ref="596750588"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">352</int>
+ <reference key="object" ref="960678392"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="515308735"/>
+ </array>
+ <reference key="parent" ref="448510093"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">350</int>
+ <reference key="object" ref="515308735"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="709074847"/>
+ <reference ref="201731424"/>
+ <reference ref="86150604"/>
+ <reference ref="477203622"/>
+ <reference ref="57246850"/>
+ <reference ref="298603383"/>
+ <reference ref="331853183"/>
+ </array>
+ <reference key="parent" ref="960678392"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">382</int>
+ <reference key="object" ref="709074847"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="633115429"/>
+ </array>
+ <reference key="parent" ref="515308735"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">385</int>
+ <reference key="object" ref="201731424"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="930265681"/>
+ </array>
+ <reference key="parent" ref="515308735"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">386</int>
+ <reference key="object" ref="86150604"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="311969422"/>
+ </array>
+ <reference key="parent" ref="515308735"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">541</int>
+ <reference key="object" ref="477203622"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="631531164"/>
+ </array>
+ <reference key="parent" ref="515308735"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">543</int>
+ <reference key="object" ref="298603383"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="761107402"/>
+ </array>
+ <reference key="parent" ref="515308735"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">353</int>
+ <reference key="object" ref="348328898"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="300811574"/>
+ </array>
+ <reference key="parent" ref="448510093"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">354</int>
+ <reference key="object" ref="300811574"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="989050925"/>
+ <reference ref="700826966"/>
+ <reference ref="168436707"/>
+ <reference ref="363817195"/>
+ <reference ref="223835729"/>
+ </array>
+ <reference key="parent" ref="348328898"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">374</int>
+ <reference key="object" ref="989050925"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="189594322"/>
+ </array>
+ <reference key="parent" ref="300811574"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">375</int>
+ <reference key="object" ref="700826966"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="489340979"/>
+ </array>
+ <reference key="parent" ref="300811574"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">376</int>
+ <reference key="object" ref="168436707"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="53243865"/>
+ </array>
+ <reference key="parent" ref="300811574"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">377</int>
+ <reference key="object" ref="363817195"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="390084685"/>
+ </array>
+ <reference key="parent" ref="300811574"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">379</int>
+ <reference key="object" ref="223835729"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="283628678"/>
+ </array>
+ <reference key="parent" ref="300811574"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">285</int>
+ <reference key="object" ref="604417141"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="85544634"/>
+ </array>
+ <reference key="parent" ref="0"/>
+ <string key="objectName">EditPrograms</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">286</int>
+ <reference key="object" ref="85544634"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="1063387772"/>
+ <reference ref="758204686"/>
+ <reference ref="671954382"/>
+ <reference ref="492358940"/>
+ </array>
+ <reference key="parent" ref="604417141"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">423</int>
+ <reference key="object" ref="294137138"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="318286212"/>
+ <reference ref="511651072"/>
+ </array>
+ <reference key="parent" ref="0"/>
+ <string key="objectName">DockMenu</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">524</int>
+ <reference key="object" ref="318286212"/>
+ <reference key="parent" ref="294137138"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">526</int>
+ <reference key="object" ref="511651072"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="48278059"/>
+ </array>
+ <reference key="parent" ref="294137138"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">527</int>
+ <reference key="object" ref="48278059"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="1032342329"/>
+ <reference ref="563798000"/>
+ </array>
+ <reference key="parent" ref="511651072"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">532</int>
+ <reference key="object" ref="1032342329"/>
+ <reference key="parent" ref="48278059"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">533</int>
+ <reference key="object" ref="563798000"/>
+ <reference key="parent" ref="48278059"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100363</int>
+ <reference key="object" ref="990762273"/>
+ <reference key="parent" ref="119157981"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100364</int>
+ <reference key="object" ref="391919450"/>
+ <reference key="parent" ref="443008216"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100365</int>
+ <reference key="object" ref="649334366"/>
+ <reference key="parent" ref="282885445"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100368</int>
+ <reference key="object" ref="940564599"/>
+ <reference key="parent" ref="842100515"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100369</int>
+ <reference key="object" ref="666057093"/>
+ <reference key="parent" ref="31160162"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100370</int>
+ <reference key="object" ref="967619578"/>
+ <reference key="parent" ref="179949713"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100382</int>
+ <reference key="object" ref="633115429"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="341113515"/>
+ </array>
+ <reference key="parent" ref="709074847"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100385</int>
+ <reference key="object" ref="930265681"/>
+ <reference key="parent" ref="201731424"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100386</int>
+ <reference key="object" ref="311969422"/>
+ <reference key="parent" ref="86150604"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100541</int>
+ <reference key="object" ref="631531164"/>
+ <reference key="parent" ref="477203622"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100543</int>
+ <reference key="object" ref="761107402"/>
+ <reference key="parent" ref="298603383"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100374</int>
+ <reference key="object" ref="189594322"/>
+ <reference key="parent" ref="989050925"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100375</int>
+ <reference key="object" ref="489340979"/>
+ <reference key="parent" ref="700826966"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100376</int>
+ <reference key="object" ref="53243865"/>
+ <reference key="parent" ref="168436707"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100377</int>
+ <reference key="object" ref="390084685"/>
+ <reference key="parent" ref="363817195"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100379</int>
+ <reference key="object" ref="283628678"/>
+ <reference key="parent" ref="223835729"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">380</int>
+ <reference key="object" ref="341113515"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="759499526"/>
+ <reference ref="616492372"/>
+ <reference ref="543935434"/>
+ <reference ref="836673018"/>
+ </array>
+ <reference key="parent" ref="633115429"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">435</int>
+ <reference key="object" ref="759499526"/>
+ <reference key="parent" ref="341113515"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">384</int>
+ <reference key="object" ref="616492372"/>
+ <reference key="parent" ref="341113515"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">383</int>
+ <reference key="object" ref="543935434"/>
+ <reference key="parent" ref="341113515"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">381</int>
+ <reference key="object" ref="836673018"/>
+ <reference key="parent" ref="341113515"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">295</int>
+ <reference key="object" ref="1063387772"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="792419186"/>
+ <reference ref="17278747"/>
+ <reference ref="842897584"/>
+ <reference ref="905092943"/>
+ </array>
+ <reference key="parent" ref="85544634"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300295</int>
+ <reference key="object" ref="792419186"/>
+ <reference key="parent" ref="1063387772"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">200295</int>
+ <reference key="object" ref="17278747"/>
+ <reference key="parent" ref="1063387772"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100295</int>
+ <reference key="object" ref="842897584"/>
+ <reference key="parent" ref="1063387772"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">296</int>
+ <reference key="object" ref="905092943"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="242608782"/>
+ <reference ref="938444323"/>
+ <reference ref="84282687"/>
+ </array>
+ <reference key="parent" ref="1063387772"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">535</int>
+ <reference key="object" ref="242608782"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="34714764"/>
+ </array>
+ <reference key="parent" ref="905092943"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">575</int>
+ <reference key="object" ref="34714764"/>
+ <reference key="parent" ref="242608782"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">298</int>
+ <reference key="object" ref="938444323"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="825378892"/>
+ </array>
+ <reference key="parent" ref="905092943"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">573</int>
+ <reference key="object" ref="825378892"/>
+ <reference key="parent" ref="938444323"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">297</int>
+ <reference key="object" ref="84282687"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="432610585"/>
+ </array>
+ <reference key="parent" ref="905092943"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">574</int>
+ <reference key="object" ref="432610585"/>
+ <reference key="parent" ref="84282687"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">310</int>
+ <reference key="object" ref="758204686"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="1025474039"/>
+ </array>
+ <reference key="parent" ref="85544634"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100310</int>
+ <reference key="object" ref="1025474039"/>
+ <reference key="parent" ref="758204686"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">292</int>
+ <reference key="object" ref="671954382"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="143554520"/>
+ </array>
+ <reference key="parent" ref="85544634"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100292</int>
+ <reference key="object" ref="143554520"/>
+ <reference key="parent" ref="671954382"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">293</int>
+ <reference key="object" ref="492358940"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="8201128"/>
+ </array>
+ <reference key="parent" ref="85544634"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100293</int>
+ <reference key="object" ref="8201128"/>
+ <reference key="parent" ref="492358940"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300337</int>
+ <reference key="object" ref="10973343"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="184765684"/>
+ </array>
+ <reference key="parent" ref="448510093"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300338</int>
+ <reference key="object" ref="184765684"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="657659108"/>
+ <reference ref="290578835"/>
+ <reference ref="992839333"/>
+ <reference ref="138261120"/>
+ <reference ref="128352289"/>
+ <reference ref="57161931"/>
+ </array>
+ <reference key="parent" ref="10973343"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300358</int>
+ <reference key="object" ref="290578835"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="399127858"/>
+ </array>
+ <reference key="parent" ref="184765684"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300359</int>
+ <reference key="object" ref="657659108"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="259618205"/>
+ </array>
+ <reference key="parent" ref="184765684"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300360</int>
+ <reference key="object" ref="259618205"/>
+ <reference key="parent" ref="657659108"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300361</int>
+ <reference key="object" ref="399127858"/>
+ <reference key="parent" ref="290578835"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300362</int>
+ <reference key="object" ref="992839333"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="959555182"/>
+ </array>
+ <reference key="parent" ref="184765684"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300363</int>
+ <reference key="object" ref="959555182"/>
+ <reference key="parent" ref="992839333"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300364</int>
+ <reference key="object" ref="138261120"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="183409141"/>
+ </array>
+ <reference key="parent" ref="184765684"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300365</int>
+ <reference key="object" ref="183409141"/>
+ <reference key="parent" ref="138261120"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300368</int>
+ <reference key="object" ref="128352289"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="556463187"/>
+ </array>
+ <reference key="parent" ref="184765684"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300369</int>
+ <reference key="object" ref="556463187"/>
+ <reference key="parent" ref="128352289"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300370</int>
+ <reference key="object" ref="57161931"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="989804990"/>
+ </array>
+ <reference key="parent" ref="184765684"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300371</int>
+ <reference key="object" ref="989804990"/>
+ <reference key="parent" ref="57161931"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300421</int>
+ <reference key="object" ref="723450037"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="408298283"/>
+ </array>
+ <reference key="parent" ref="448510093"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300422</int>
+ <reference key="object" ref="408298283"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="878106058"/>
+ <reference ref="386152084"/>
+ <reference ref="487809555"/>
+ <reference ref="620944856"/>
+ <reference ref="477050998"/>
+ <reference ref="765780304"/>
+ <reference ref="522511724"/>
+ <reference ref="1002778833"/>
+ </array>
+ <reference key="parent" ref="723450037"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300423</int>
+ <reference key="object" ref="386152084"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="572508492"/>
+ </array>
+ <reference key="parent" ref="408298283"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300424</int>
+ <reference key="object" ref="878106058"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="718083688"/>
+ </array>
+ <reference key="parent" ref="408298283"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300440</int>
+ <reference key="object" ref="718083688"/>
+ <reference key="parent" ref="878106058"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300441</int>
+ <reference key="object" ref="572508492"/>
+ <reference key="parent" ref="386152084"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300447</int>
+ <reference key="object" ref="477050998"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="501304422"/>
+ </array>
+ <reference key="parent" ref="408298283"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300450</int>
+ <reference key="object" ref="501304422"/>
+ <reference key="parent" ref="477050998"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300451</int>
+ <reference key="object" ref="765780304"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="510771323"/>
+ </array>
+ <reference key="parent" ref="408298283"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300452</int>
+ <reference key="object" ref="510771323"/>
+ <reference key="parent" ref="765780304"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300453</int>
+ <reference key="object" ref="487809555"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="619977658"/>
+ </array>
+ <reference key="parent" ref="408298283"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300454</int>
+ <reference key="object" ref="619977658"/>
+ <reference key="parent" ref="487809555"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300455</int>
+ <reference key="object" ref="620944856"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="461823902"/>
+ </array>
+ <reference key="parent" ref="408298283"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300456</int>
+ <reference key="object" ref="461823902"/>
+ <reference key="parent" ref="620944856"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300457</int>
+ <reference key="object" ref="1002778833"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="897099877"/>
+ </array>
+ <reference key="parent" ref="408298283"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300458</int>
+ <reference key="object" ref="897099877"/>
+ <reference key="parent" ref="1002778833"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300459</int>
+ <reference key="object" ref="522511724"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="994587858"/>
+ </array>
+ <reference key="parent" ref="408298283"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300460</int>
+ <reference key="object" ref="994587858"/>
+ <reference key="parent" ref="522511724"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300472</int>
+ <reference key="object" ref="57246850"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="917248662"/>
+ </array>
+ <reference key="parent" ref="515308735"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300473</int>
+ <reference key="object" ref="917248662"/>
+ <reference key="parent" ref="57246850"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300476</int>
+ <reference key="object" ref="278155937"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="617441821"/>
+ </array>
+ <reference key="parent" ref="596750588"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300477</int>
+ <reference key="object" ref="406291430"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="67728988"/>
+ </array>
+ <reference key="parent" ref="596750588"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300478</int>
+ <reference key="object" ref="67728988"/>
+ <reference key="parent" ref="406291430"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300479</int>
+ <reference key="object" ref="617441821"/>
+ <reference key="parent" ref="278155937"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300482</int>
+ <reference key="object" ref="863505041"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="1016286396"/>
+ </array>
+ <reference key="parent" ref="596750588"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300483</int>
+ <reference key="object" ref="1016286396"/>
+ <reference key="parent" ref="863505041"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300487</int>
+ <reference key="object" ref="331853183"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="1042813110"/>
+ </array>
+ <reference key="parent" ref="515308735"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300488</int>
+ <reference key="object" ref="1042813110"/>
+ <reference key="parent" ref="331853183"/>
+ </object>
+ </array>
+ </object>
+ <dictionary class="NSMutableDictionary" key="flattenedProperties">
+ <string key="-3.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="-3.ImportedFromIB2"/>
+ <string key="100292.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100293.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100295.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="100295.IBShouldRemoveOnLegacySave"/>
+ <string key="100310.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100363.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100364.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100365.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100368.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100369.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100370.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100374.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100375.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100376.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100377.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100379.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100382.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100385.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100386.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100541.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100543.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="129.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="129.ImportedFromIB2"/>
+ <string key="130.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="130.ImportedFromIB2"/>
+ <string key="131.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="131.ImportedFromIB2"/>
+ <string key="134.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="134.ImportedFromIB2"/>
+ <string key="136.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="136.ImportedFromIB2"/>
+ <string key="143.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="143.ImportedFromIB2"/>
+ <string key="144.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="144.ImportedFromIB2"/>
+ <string key="145.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="145.ImportedFromIB2"/>
+ <string key="149.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="149.ImportedFromIB2"/>
+ <string key="150.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="150.ImportedFromIB2"/>
+ <string key="157.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="157.ImportedFromIB2"/>
+ <string key="163.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="163.ImportedFromIB2"/>
+ <string key="169.IBEditorWindowLastContentRect">{{168, 821}, {113, 23}}</string>
+ <string key="169.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="169.ImportedFromIB2"/>
+ <string key="169.editorWindowContentRectSynchronizationRect">{{202, 626}, {154, 153}}</string>
+ <string key="19.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="19.ImportedFromIB2"/>
+ <integer value="1" key="196.ImportedFromIB2"/>
+ <string key="200295.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="200295.IBShouldRemoveOnLegacySave"/>
+ <string key="203.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="203.ImportedFromIB2"/>
+ <string key="204.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="204.ImportedFromIB2"/>
+ <string key="23.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="23.ImportedFromIB2"/>
+ <string key="24.IBEditorWindowLastContentRect">{{349, 868}, {315, 143}}</string>
+ <string key="24.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="24.ImportedFromIB2"/>
+ <string key="24.editorWindowContentRectSynchronizationRect">{{271, 666}, {301, 153}}</string>
+ <string key="244.IBEditorWindowLastContentRect">{{329, 408}, {550, 341}}</string>
+ <string key="244.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="244.IBWindowTemplateEditedContentRect">{{329, 408}, {550, 341}}</string>
+ <integer value="1" key="244.ImportedFromIB2"/>
+ <string key="244.editorWindowContentRectSynchronizationRect">{{184, 290}, {481, 345}}</string>
+ <boolean value="YES" key="244.windowTemplate.hasMinSize"/>
+ <string key="244.windowTemplate.maxSize">{1.7976931348623157e+308, 1.7976931348623157e+308}</string>
+ <string key="244.windowTemplate.minSize">{320, 240}</string>
+ <string key="245.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="245.ImportedFromIB2"/>
+ <string key="269.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="269.ImportedFromIB2"/>
+ <string key="270.IBEditorWindowLastContentRect">{{58, 803}, {155, 33}}</string>
+ <string key="270.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="270.ImportedFromIB2"/>
+ <string key="270.editorWindowContentRectSynchronizationRect">{{100, 746}, {155, 33}}</string>
+ <string key="272.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="272.ImportedFromIB2"/>
+ <string key="285.IBEditorWindowLastContentRect">{{68, 585}, {454, 271}}</string>
+ <string key="285.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="285.IBViewEditorWindowController.showingBoundsRectangles"/>
+ <integer value="1" key="285.IBViewEditorWindowController.showingLayoutRectangles"/>
+ <string key="285.IBWindowTemplateEditedContentRect">{{68, 585}, {454, 271}}</string>
+ <integer value="1" key="285.ImportedFromIB2"/>
+ <string key="285.editorWindowContentRectSynchronizationRect">{{433, 406}, {486, 327}}</string>
+ <boolean value="YES" key="285.windowTemplate.hasMinSize"/>
+ <string key="285.windowTemplate.maxSize">{1.7976931348623157e+308, 1.7976931348623157e+308}</string>
+ <string key="285.windowTemplate.minSize">{512, 240}</string>
+ <string key="286.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="286.ImportedFromIB2"/>
+ <string key="29.IBEditorWindowLastContentRect">{{145, 1011}, {336, 20}}</string>
+ <string key="29.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="29.ImportedFromIB2"/>
+ <string key="29.editorWindowContentRectSynchronizationRect">{{67, 819}, {336, 20}}</string>
+ <string key="292.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="292.ImportedFromIB2"/>
+ <string key="293.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="293.ImportedFromIB2"/>
+ <string key="295.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="295.ImportedFromIB2"/>
+ <string key="296.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="296.ImportedFromIB2"/>
+ <string key="297.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="297.ImportedFromIB2"/>
+ <string key="298.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="298.ImportedFromIB2"/>
+ <string key="300295.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300295.IBShouldRemoveOnLegacySave"/>
+ <string key="300337.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300337.ImportedFromIB2"/>
+ <string key="300338.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300338.ImportedFromIB2"/>
+ <string key="300358.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300358.ImportedFromIB2"/>
+ <string key="300359.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300359.ImportedFromIB2"/>
+ <string key="300360.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300361.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300362.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300362.ImportedFromIB2"/>
+ <string key="300363.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300364.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300364.ImportedFromIB2"/>
+ <string key="300365.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300368.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300368.ImportedFromIB2"/>
+ <string key="300369.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300370.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300370.ImportedFromIB2"/>
+ <string key="300371.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300421.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300421.ImportedFromIB2"/>
+ <string key="300422.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300422.ImportedFromIB2"/>
+ <string key="300423.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300423.ImportedFromIB2"/>
+ <string key="300424.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300424.ImportedFromIB2"/>
+ <string key="300440.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300441.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300447.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300447.ImportedFromIB2"/>
+ <string key="300450.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300451.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300451.ImportedFromIB2"/>
+ <string key="300452.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300453.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300453.ImportedFromIB2"/>
+ <string key="300454.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300455.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300455.ImportedFromIB2"/>
+ <string key="300456.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300457.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <object class="NSAffineTransform" key="300457.IBViewBoundsToFrameTransform">
+ <bytes key="NSTransformStruct">P4AAAL+AAABCCAAAwr4AAA</bytes>
+ </object>
+ <integer value="1" key="300457.ImportedFromIB2"/>
+ <string key="300458.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300459.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300459.ImportedFromIB2"/>
+ <string key="300460.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300472.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300472.ImportedFromIB2"/>
+ <string key="300473.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300476.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300476.ImportedFromIB2"/>
+ <string key="300477.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300477.ImportedFromIB2"/>
+ <string key="300478.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300479.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300482.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300482.ImportedFromIB2"/>
+ <string key="300483.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300487.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300487.ImportedFromIB2"/>
+ <string key="300488.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="305.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="305.ImportedFromIB2"/>
+ <string key="310.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="310.ImportedFromIB2"/>
+ <string key="348.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="348.ImportedFromIB2"/>
+ <string key="349.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="349.ImportedFromIB2"/>
+ <string key="350.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="350.ImportedFromIB2"/>
+ <string key="351.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="351.ImportedFromIB2"/>
+ <string key="352.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="352.ImportedFromIB2"/>
+ <string key="353.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="353.ImportedFromIB2"/>
+ <string key="354.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="354.ImportedFromIB2"/>
+ <string key="363.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="363.ImportedFromIB2"/>
+ <string key="364.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="364.ImportedFromIB2"/>
+ <string key="365.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="365.ImportedFromIB2"/>
+ <string key="368.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="368.ImportedFromIB2"/>
+ <string key="369.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="369.ImportedFromIB2"/>
+ <string key="370.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="370.ImportedFromIB2"/>
+ <string key="374.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="374.ImportedFromIB2"/>
+ <string key="375.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="375.ImportedFromIB2"/>
+ <string key="376.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="376.ImportedFromIB2"/>
+ <string key="377.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="377.ImportedFromIB2"/>
+ <string key="379.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="379.ImportedFromIB2"/>
+ <string key="380.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="380.ImportedFromIB2"/>
+ <string key="381.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="381.ImportedFromIB2"/>
+ <string key="382.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="382.ImportedFromIB2"/>
+ <string key="383.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="383.ImportedFromIB2"/>
+ <string key="384.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="384.ImportedFromIB2"/>
+ <string key="385.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="385.ImportedFromIB2"/>
+ <string key="386.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="386.ImportedFromIB2"/>
+ <string key="419.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="419.ImportedFromIB2"/>
+ <string key="420.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="420.ImportedFromIB2"/>
+ <string key="421.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="421.ImportedFromIB2"/>
+ <string key="423.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="423.ImportedFromIB2"/>
+ <string key="435.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="435.ImportedFromIB2"/>
+ <string key="5.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="5.ImportedFromIB2"/>
+ <string key="524.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="524.ImportedFromIB2"/>
+ <string key="526.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="526.ImportedFromIB2"/>
+ <string key="527.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="527.ImportedFromIB2"/>
+ <string key="532.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="532.ImportedFromIB2"/>
+ <string key="533.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="533.ImportedFromIB2"/>
+ <string key="535.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="535.ImportedFromIB2"/>
+ <string key="536.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="536.ImportedFromIB2"/>
+ <string key="537.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="537.ImportedFromIB2"/>
+ <string key="538.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="538.ImportedFromIB2"/>
+ <string key="541.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="541.ImportedFromIB2"/>
+ <string key="543.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="543.ImportedFromIB2"/>
+ <string key="544.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="544.ImportedFromIB2"/>
+ <string key="545.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="545.ImportedFromIB2"/>
+ <string key="56.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="56.ImportedFromIB2"/>
+ <string key="57.IBEditorWindowLastContentRect">{{20, 641}, {218, 203}}</string>
+ <string key="57.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="57.ImportedFromIB2"/>
+ <string key="57.editorWindowContentRectSynchronizationRect">{{79, 616}, {218, 203}}</string>
+ <string key="573.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="573.ImportedFromIB2"/>
+ <string key="574.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="574.ImportedFromIB2"/>
+ <string key="575.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="575.ImportedFromIB2"/>
+ <string key="58.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="58.ImportedFromIB2"/>
+ <string key="92.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="92.ImportedFromIB2"/>
+ </dictionary>
+ <dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
+ <nil key="activeLocalization"/>
+ <dictionary class="NSMutableDictionary" key="localizations"/>
+ <nil key="sourceID"/>
+ <int key="maxID">300490</int>
+ </object>
+ <object class="IBClassDescriber" key="IBDocument.Classes"/>
+ <int key="IBDocument.localizationMode">0</int>
+ <string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
+ <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencies">
+ <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string>
+ <integer value="1040" key="NS.object.0"/>
+ </object>
+ <bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
+ <nil key="IBDocument.LastKnownRelativeProjectPath"/>
+ <int key="IBDocument.defaultPropertyAccessControl">3</int>
+ <dictionary class="NSMutableDictionary" key="IBDocument.LastKnownImageSizes">
+ <string key="NSMenuCheckmark">{9, 8}</string>
+ <string key="NSMenuMixedState">{7, 2}</string>
+ <string key="NSSwitch">{15, 15}</string>
+ </dictionary>
+ </data>
+</archive>
diff --git a/xorg-server/hw/xquartz/bundle/Resources/Japanese.lproj/locversion.plist b/xorg-server/hw/xquartz/bundle/Resources/Japanese.lproj/locversion.plist
index afdc96f72..4dce0add7 100644
--- a/xorg-server/hw/xquartz/bundle/Resources/Japanese.lproj/locversion.plist
+++ b/xorg-server/hw/xquartz/bundle/Resources/Japanese.lproj/locversion.plist
@@ -1,14 +1,14 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>LprojCompatibleVersion</key>
- <string>106.3</string>
- <key>LprojLocale</key>
- <string>ja</string>
- <key>LprojRevisionLevel</key>
- <string>1</string>
- <key>LprojVersion</key>
- <string>106.3</string>
-</dict>
-</plist>
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>LprojCompatibleVersion</key>
+ <string>106.3</string>
+ <key>LprojLocale</key>
+ <string>ja</string>
+ <key>LprojRevisionLevel</key>
+ <string>1</string>
+ <key>LprojVersion</key>
+ <string>106.3</string>
+</dict>
+</plist>
diff --git a/xorg-server/hw/xquartz/bundle/Resources/Japanese.lproj/main.nib/designable.nib b/xorg-server/hw/xquartz/bundle/Resources/Japanese.lproj/main.nib/designable.nib
index a707b0095..743edb60a 100644
--- a/xorg-server/hw/xquartz/bundle/Resources/Japanese.lproj/main.nib/designable.nib
+++ b/xorg-server/hw/xquartz/bundle/Resources/Japanese.lproj/main.nib/designable.nib
@@ -1,3620 +1,3620 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00">
- <data>
- <int key="IBDocument.SystemTarget">1040</int>
- <string key="IBDocument.SystemVersion">11A289</string>
- <string key="IBDocument.InterfaceBuilderVersion">903</string>
- <string key="IBDocument.AppKitVersion">1094.2</string>
- <string key="IBDocument.HIToolboxVersion">521.00</string>
- <object class="NSMutableDictionary" key="IBDocument.PluginVersions">
- <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="NS.object.0">903</string>
- </object>
- <array class="NSMutableArray" key="IBDocument.EditedObjectIDs"/>
- <array key="IBDocument.PluginDependencies">
- <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- </array>
- <object class="NSMutableDictionary" key="IBDocument.Metadata">
- <string key="NS.key.0">PluginDependencyRecalculationVersion</string>
- <integer value="1" key="NS.object.0"/>
- </object>
- <array class="NSMutableArray" key="IBDocument.RootObjects" id="904585544">
- <object class="NSCustomObject" id="815810918">
- <object class="NSMutableString" key="NSClassName">
- <characters key="NS.bytes">NSApplication</characters>
- </object>
- </object>
- <object class="NSCustomObject" id="941939442">
- <string key="NSClassName">FirstResponder</string>
- </object>
- <object class="NSCustomObject" id="951368722">
- <string key="NSClassName">NSApplication</string>
- </object>
- <object class="NSMenu" id="524015605">
- <string key="NSTitle">MainMenu</string>
- <array class="NSMutableArray" key="NSMenuItems">
- <object class="NSMenuItem" id="365880285">
- <reference key="NSMenu" ref="524015605"/>
- <string key="NSTitle">X11</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <object class="NSCustomResource" key="NSOnImage" id="531645050">
- <string key="NSClassName">NSImage</string>
- <string key="NSResourceName">NSMenuCheckmark</string>
- </object>
- <object class="NSCustomResource" key="NSMixedImage" id="351811234">
- <string key="NSClassName">NSImage</string>
- <string key="NSResourceName">NSMenuMixedState</string>
- </object>
- <string key="NSAction">submenuAction:</string>
- <object class="NSMenu" key="NSSubmenu" id="576521955">
- <string key="NSTitle">X11</string>
- <array class="NSMutableArray" key="NSMenuItems">
- <object class="NSMenuItem" id="139290918">
- <reference key="NSMenu" ref="576521955"/>
- <string key="NSTitle">X11 について</string>
- <string key="NSKeyEquiv"/>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="386173216">
- <reference key="NSMenu" ref="576521955"/>
- <string key="NSTitle">環境設定...</string>
- <string key="NSKeyEquiv">,</string>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="272876017">
- <reference key="NSMenu" ref="576521955"/>
- <bool key="NSIsDisabled">YES</bool>
- <bool key="NSIsSeparator">YES</bool>
- <string key="NSTitle"/>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="32285361">
- <reference key="NSMenu" ref="576521955"/>
- <string key="NSTitle">サービス</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- <string key="NSAction">submenuAction:</string>
- <object class="NSMenu" key="NSSubmenu" id="821388474">
- <string key="NSTitle">サービス</string>
- <array class="NSMutableArray" key="NSMenuItems"/>
- <string key="NSName">_NSServicesMenu</string>
- </object>
- </object>
- <object class="NSMenuItem" id="431301145">
- <reference key="NSMenu" ref="576521955"/>
- <bool key="NSIsDisabled">YES</bool>
- <bool key="NSIsSeparator">YES</bool>
- <string key="NSTitle"/>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="6876565">
- <reference key="NSMenu" ref="576521955"/>
- <string key="NSTitle">フルスクリーンを切り替える</string>
- <string key="NSKeyEquiv">a</string>
- <int key="NSKeyEquivModMask">1572864</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="479677589">
- <reference key="NSMenu" ref="576521955"/>
- <bool key="NSIsDisabled">YES</bool>
- <bool key="NSIsSeparator">YES</bool>
- <string key="NSTitle"/>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="301008465">
- <reference key="NSMenu" ref="576521955"/>
- <string key="NSTitle">X11 を隠す</string>
- <string key="NSKeyEquiv">h</string>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- <int key="NSTag">42</int>
- </object>
- <object class="NSMenuItem" id="206802571">
- <reference key="NSMenu" ref="576521955"/>
- <string key="NSTitle">ほかを隠す</string>
- <string key="NSKeyEquiv">h</string>
- <int key="NSKeyEquivModMask">1572864</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="1023546148">
- <reference key="NSMenu" ref="576521955"/>
- <string key="NSTitle">すべてを表示</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- <int key="NSTag">42</int>
- </object>
- <object class="NSMenuItem" id="848095279">
- <reference key="NSMenu" ref="576521955"/>
- <bool key="NSIsDisabled">YES</bool>
- <bool key="NSIsSeparator">YES</bool>
- <string key="NSTitle"/>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="274138642">
- <reference key="NSMenu" ref="576521955"/>
- <string key="NSTitle">X11 を終了</string>
- <string key="NSKeyEquiv">q</string>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- </array>
- <string key="NSName">_NSAppleMenu</string>
- </object>
- </object>
- <object class="NSMenuItem" id="868031522">
- <reference key="NSMenu" ref="524015605"/>
- <string key="NSTitle">アプリケーション</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- <string key="NSAction">submenuAction:</string>
- <object class="NSMenu" key="NSSubmenu" id="981161348">
- <string key="NSTitle">アプリケーション</string>
- <array class="NSMutableArray" key="NSMenuItems">
- <object class="NSMenuItem" id="390088328">
- <reference key="NSMenu" ref="981161348"/>
- <bool key="NSIsDisabled">YES</bool>
- <bool key="NSIsSeparator">YES</bool>
- <string key="NSTitle"/>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="1065386165">
- <reference key="NSMenu" ref="981161348"/>
- <string key="NSTitle">カスタマイズ...</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- </array>
- </object>
- </object>
- <object class="NSMenuItem" id="200491363">
- <reference key="NSMenu" ref="524015605"/>
- <string key="NSTitle">編集</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- <string key="NSAction">submenuAction:</string>
- <object class="NSMenu" key="NSSubmenu" id="526778998">
- <string key="NSTitle">編集</string>
- <array class="NSMutableArray" key="NSMenuItems">
- <object class="NSMenuItem" id="185296989">
- <reference key="NSMenu" ref="526778998"/>
- <string key="NSTitle">コピー</string>
- <string key="NSKeyEquiv">c</string>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- </array>
- </object>
- </object>
- <object class="NSMenuItem" id="931553638">
- <reference key="NSMenu" ref="524015605"/>
- <string key="NSTitle">ウインドウ</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- <string key="NSAction">submenuAction:</string>
- <object class="NSMenu" key="NSSubmenu" id="96874957">
- <string key="NSTitle">ウインドウ</string>
- <array class="NSMutableArray" key="NSMenuItems">
- <object class="NSMenuItem" id="984461797">
- <reference key="NSMenu" ref="96874957"/>
- <string key="NSTitle">閉じる</string>
- <string key="NSKeyEquiv">w</string>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="677652931">
- <reference key="NSMenu" ref="96874957"/>
- <string key="NSTitle">しまう</string>
- <string key="NSKeyEquiv">m</string>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="1066447520">
- <reference key="NSMenu" ref="96874957"/>
- <string key="NSTitle">拡大/縮小</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="280172320">
- <reference key="NSMenu" ref="96874957"/>
- <bool key="NSIsDisabled">YES</bool>
- <bool key="NSIsSeparator">YES</bool>
- <string key="NSTitle"/>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="1036389925">
- <reference key="NSMenu" ref="96874957"/>
- <string key="NSTitle">ウインドウを巡回</string>
- <string key="NSKeyEquiv"></string>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="369641893">
- <reference key="NSMenu" ref="96874957"/>
- <string key="NSTitle">ウインドウを逆方向に巡回</string>
- <string key="NSKeyEquiv"></string>
- <int key="NSKeyEquivModMask">1179648</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="155085383">
- <reference key="NSMenu" ref="96874957"/>
- <bool key="NSIsDisabled">YES</bool>
- <bool key="NSIsSeparator">YES</bool>
- <string key="NSTitle"/>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="276216762">
- <reference key="NSMenu" ref="96874957"/>
- <string key="NSTitle">すべてを手前に移動</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- </array>
- <string key="NSName">_NSWindowsMenu</string>
- </object>
- </object>
- <object class="NSMenuItem" id="551174276">
- <reference key="NSMenu" ref="524015605"/>
- <string key="NSTitle">ヘルプ</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- <string key="NSAction">submenuAction:</string>
- <object class="NSMenu" key="NSSubmenu" id="511848303">
- <string key="NSTitle">ヘルプ</string>
- <array class="NSMutableArray" key="NSMenuItems">
- <object class="NSMenuItem" id="504984881">
- <reference key="NSMenu" ref="511848303"/>
- <string key="NSTitle">X11 ヘルプ</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- </array>
- </object>
- </object>
- </array>
- <string key="NSName">_NSMainMenu</string>
- </object>
- <object class="NSCustomObject" id="485884620">
- <string key="NSClassName">X11Controller</string>
- </object>
- <object class="NSWindowTemplate" id="124913468">
- <int key="NSWindowStyleMask">3</int>
- <int key="NSWindowBacking">2</int>
- <string key="NSWindowRect">{{319, 328.03906000000001}, {584, 341}}</string>
- <int key="NSWTFlags">1350041600</int>
- <string key="NSWindowTitle">X11 の環境設定</string>
- <string key="NSWindowClass">NSPanel</string>
- <object class="NSMutableString" key="NSViewClass">
- <characters key="NS.bytes">View</characters>
- </object>
- <nil key="NSUserInterfaceItemIdentifier"/>
- <string key="NSWindowContentMaxSize">{1.7976931348623157e+308, 1.7976931348623157e+308}</string>
- <string key="NSWindowContentMinSize">{320, 240}</string>
- <object class="NSView" key="NSWindowView" id="941366957">
- <nil key="NSNextResponder"/>
- <int key="NSvFlags">256</int>
- <array class="NSMutableArray" key="NSSubviews">
- <object class="NSTabView" id="448510093">
- <reference key="NSNextResponder" ref="941366957"/>
- <int key="NSvFlags">274</int>
- <string key="NSFrame">{{13, 10}, {558, 325}}</string>
- <reference key="NSSuperview" ref="941366957"/>
- <array class="NSMutableArray" key="NSTabViewItems">
- <object class="NSTabViewItem" id="287591690">
- <object class="NSMutableString" key="NSIdentifier">
- <characters key="NS.bytes">1</characters>
- </object>
- <object class="NSView" key="NSView" id="596750588">
- <reference key="NSNextResponder" ref="448510093"/>
- <int key="NSvFlags">256</int>
- <array class="NSMutableArray" key="NSSubviews">
- <object class="NSButton" id="119157981">
- <reference key="NSNextResponder" ref="596750588"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{18, 243}, {505, 18}}</string>
- <reference key="NSSuperview" ref="596750588"/>
- <reference key="NSNextKeyView" ref="179949713"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="990762273">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">3 ボタンマウスをエミュレート</string>
- <object class="NSFont" key="NSSupport" id="463863101">
- <string key="NSName">LucidaGrande</string>
- <double key="NSSize">13</double>
- <int key="NSfFlags">1044</int>
- </object>
- <reference key="NSControlView" ref="119157981"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <object class="NSCustomResource" key="NSNormalImage" id="815090595">
- <string key="NSClassName">NSImage</string>
- <string key="NSResourceName">NSSwitch</string>
- </object>
- <object class="NSButtonImageSource" key="NSAlternateImage" id="391434389">
- <string key="NSImageName">NSSwitch</string>
- </object>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSTextField" id="443008216">
- <reference key="NSNextResponder" ref="596750588"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{36, 96}, {488, 28}}</string>
- <reference key="NSSuperview" ref="596750588"/>
- <reference key="NSNextKeyView" ref="406291430"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="391919450">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">有効にすると、メニューバーの代替キーによって X11 アプリケーションのメタ修飾キーを使用できなくなる場合があります。</string>
- <object class="NSFont" key="NSSupport" id="26">
- <string key="NSName">LucidaGrande</string>
- <double key="NSSize">11</double>
- <int key="NSfFlags">3100</int>
- </object>
- <string key="NSPlaceholderString"/>
- <reference key="NSControlView" ref="443008216"/>
- <object class="NSColor" key="NSBackgroundColor" id="57160303">
- <int key="NSColorSpace">6</int>
- <string key="NSCatalogName">System</string>
- <string key="NSColorName">controlColor</string>
- <object class="NSColor" key="NSColor" id="590688762">
- <int key="NSColorSpace">3</int>
- <bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes>
- </object>
- </object>
- <object class="NSColor" key="NSTextColor" id="930815747">
- <int key="NSColorSpace">6</int>
- <string key="NSCatalogName">System</string>
- <string key="NSColorName">controlTextColor</string>
- <object class="NSColor" key="NSColor" id="214098874">
- <int key="NSColorSpace">3</int>
- <bytes key="NSWhite">MAA</bytes>
- </object>
- </object>
- </object>
- </object>
- <object class="NSTextField" id="282885445">
- <reference key="NSNextResponder" ref="596750588"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{36, 209}, {488, 28}}</string>
- <reference key="NSSuperview" ref="596750588"/>
- <reference key="NSNextKeyView" ref="31160162"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="649334366">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string type="base64-UTF8" key="NSContents">T3B0aW9uIOOCreODvOOCkuaKvOOBl+OBn+OBvuOBvuOCr+ODquODg+OCr+OBmeOCi+OBqOODnuOCpuOC
-ueOBruS4reODnOOCv+ODs+aTjeS9nOOBq+OBquOCiuOAgUNvbW1hbmQg44Kt44O844KS5oq844GX44Gf
-44G+44G+44Kv44Oq44OD44Kv44GZ44KL44Go44Oe44Km44K544Gu5Y+z44Oc44K/44Oz5pON5L2c44Gr
-44Gq44KK44G+44GZ44CCCg</string>
- <reference key="NSSupport" ref="26"/>
- <string key="NSPlaceholderString"/>
- <reference key="NSControlView" ref="282885445"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- <object class="NSButton" id="842100515">
- <reference key="NSNextResponder" ref="596750588"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{18, 130}, {505, 18}}</string>
- <reference key="NSSuperview" ref="596750588"/>
- <reference key="NSNextKeyView" ref="443008216"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="940564599">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">X11 の代替キーを有効にする</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="842100515"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="815090595"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSTextField" id="31160162">
- <reference key="NSNextResponder" ref="596750588"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{36, 156}, {488, 17}}</string>
- <reference key="NSSuperview" ref="596750588"/>
- <reference key="NSNextKeyView" ref="842100515"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="666057093">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">入力メニューを変更して現在の X11 キーマップを上書きすることを許可します。</string>
- <reference key="NSSupport" ref="26"/>
- <string key="NSPlaceholderString"/>
- <reference key="NSControlView" ref="31160162"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- <object class="NSButton" id="179949713">
- <reference key="NSNextResponder" ref="596750588"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{18, 179}, {505, 18}}</string>
- <reference key="NSSuperview" ref="596750588"/>
- <reference key="NSNextKeyView" ref="282885445"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="967619578">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">システムのキーボードレイアウトに従う</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="179949713"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="815090595"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSTextField" id="278155937">
- <reference key="NSNextResponder" ref="596750588"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{36, 32}, {488, 31}}</string>
- <reference key="NSSuperview" ref="596750588"/>
- <reference key="NSNextKeyView" ref="863505041"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="617441821">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">有効にすると、option キー で Mode_switch の代わりに X11 キーシンボルの Alt_L と Alt_R が送信されます。 </string>
- <reference key="NSSupport" ref="26"/>
- <reference key="NSControlView" ref="278155937"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- <object class="NSButton" id="406291430">
- <reference key="NSNextResponder" ref="596750588"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{18, 69}, {505, 18}}</string>
- <reference key="NSSuperview" ref="596750588"/>
- <reference key="NSNextKeyView" ref="278155937"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="67728988">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">Option キーで Alt_L と Alt_R を送信</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="406291430"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="815090595"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSButton" id="863505041">
- <reference key="NSNextResponder" ref="596750588"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{18, 8}, {505, 18}}</string>
- <reference key="NSSuperview" ref="596750588"/>
- <reference key="NSNextKeyView" ref="448510093"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="1016286396">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">常に指を動かした方向にスクロール</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="863505041"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="815090595"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- </array>
- <string key="NSFrame">{{10, 33}, {538, 279}}</string>
- <reference key="NSSuperview" ref="448510093"/>
- <reference key="NSNextKeyView" ref="119157981"/>
- </object>
- <string key="NSLabel">入力</string>
- <reference key="NSColor" ref="57160303"/>
- <reference key="NSTabView" ref="448510093"/>
- </object>
- <object class="NSTabViewItem" id="960678392">
- <object class="NSMutableString" key="NSIdentifier">
- <characters key="NS.bytes">2</characters>
- </object>
- <object class="NSView" key="NSView" id="515308735">
- <nil key="NSNextResponder"/>
- <int key="NSvFlags">256</int>
- <array class="NSMutableArray" key="NSSubviews">
- <object class="NSPopUpButton" id="709074847">
- <reference key="NSNextResponder" ref="515308735"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{75, 234}, {163, 26}}</string>
- <reference key="NSSuperview" ref="515308735"/>
- <reference key="NSNextKeyView" ref="86150604"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSPopUpButtonCell" key="NSCell" id="633115429">
- <int key="NSCellFlags">-2076049856</int>
- <int key="NSCellFlags2">1024</int>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="709074847"/>
- <int key="NSButtonFlags">109199615</int>
- <int key="NSButtonFlags2">1</int>
- <object class="NSFont" key="NSAlternateImage">
- <string key="NSName">LucidaGrande</string>
- <double key="NSSize">13</double>
- <int key="NSfFlags">16</int>
- </object>
- <string key="NSAlternateContents"/>
- <object class="NSMutableString" key="NSKeyEquivalent">
- <characters key="NS.bytes"/>
- </object>
- <int key="NSPeriodicDelay">400</int>
- <int key="NSPeriodicInterval">75</int>
- <object class="NSMenuItem" key="NSMenuItem" id="616492372">
- <reference key="NSMenu" ref="341113515"/>
- <string key="NSTitle">ディスプレイから</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <int key="NSState">1</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- <string key="NSAction">_popUpItemAction:</string>
- <int key="NSTag">-1</int>
- <reference key="NSTarget" ref="633115429"/>
- </object>
- <bool key="NSMenuItemRespectAlignment">YES</bool>
- <object class="NSMenu" key="NSMenu" id="341113515">
- <object class="NSMutableString" key="NSTitle">
- <characters key="NS.bytes">OtherViews</characters>
- </object>
- <array class="NSMutableArray" key="NSMenuItems">
- <reference ref="616492372"/>
- <object class="NSMenuItem" id="759499526">
- <reference key="NSMenu" ref="341113515"/>
- <string key="NSTitle">256 色</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- <string key="NSAction">_popUpItemAction:</string>
- <int key="NSTag">8</int>
- <reference key="NSTarget" ref="633115429"/>
- </object>
- <object class="NSMenuItem" id="543935434">
- <reference key="NSMenu" ref="341113515"/>
- <string key="NSTitle">約 32000 色</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- <string key="NSAction">_popUpItemAction:</string>
- <int key="NSTag">15</int>
- <reference key="NSTarget" ref="633115429"/>
- </object>
- <object class="NSMenuItem" id="836673018">
- <reference key="NSMenu" ref="341113515"/>
- <string key="NSTitle">約 1670 万色</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- <string key="NSAction">_popUpItemAction:</string>
- <int key="NSTag">24</int>
- <reference key="NSTarget" ref="633115429"/>
- </object>
- </array>
- </object>
- <int key="NSPreferredEdge">3</int>
- <bool key="NSUsesItemFromMenu">YES</bool>
- <bool key="NSAltersState">YES</bool>
- <int key="NSArrowPosition">1</int>
- </object>
- </object>
- <object class="NSTextField" id="201731424">
- <reference key="NSNextResponder" ref="515308735"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{17, 238}, {56, 19}}</string>
- <reference key="NSSuperview" ref="515308735"/>
- <reference key="NSNextKeyView" ref="709074847"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="930265681">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">カラー:</string>
- <reference key="NSSupport" ref="463863101"/>
- <string key="NSPlaceholderString"/>
- <reference key="NSControlView" ref="201731424"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- <object class="NSTextField" id="86150604">
- <reference key="NSNextResponder" ref="515308735"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{36, 216}, {488, 14}}</string>
- <reference key="NSSuperview" ref="515308735"/>
- <reference key="NSNextKeyView" ref="477203622"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="311969422">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">このオプションは、次回 X11 を起動したときに有効になります。</string>
- <reference key="NSSupport" ref="26"/>
- <string key="NSPlaceholderString"/>
- <reference key="NSControlView" ref="86150604"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- <object class="NSButton" id="477203622">
- <reference key="NSNextResponder" ref="515308735"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{18, 182}, {505, 23}}</string>
- <reference key="NSSuperview" ref="515308735"/>
- <reference key="NSNextKeyView" ref="298603383"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="631531164">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">フルスクリーンモード</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="477203622"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="815090595"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSButton" id="57246850">
- <reference key="NSNextResponder" ref="515308735"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{37, 118}, {492, 23}}</string>
- <reference key="NSSuperview" ref="515308735"/>
- <reference key="NSNextKeyView" ref="331853183"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="917248662">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">フルスクリーンモード時のメニューバーへのアクセスを許可</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="57246850"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="815090595"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSTextField" id="298603383">
- <reference key="NSNextResponder" ref="515308735"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{36, 147}, {494, 28}}</string>
- <reference key="NSSuperview" ref="515308735"/>
- <reference key="NSNextKeyView" ref="57246850"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="761107402">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">X11 のルートウインドウを有効にします。フルスクリーンモードに切り替えたり、フルスクリーンモードを終了するときは、コマンド + Option + A キーを押します。</string>
- <reference key="NSSupport" ref="26"/>
- <string key="NSPlaceholderString"/>
- <reference key="NSControlView" ref="298603383"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- <object class="NSTextField" id="331853183">
- <reference key="NSNextResponder" ref="515308735"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{54, 70}, {476, 42}}</string>
- <reference key="NSSuperview" ref="515308735"/>
- <reference key="NSNextKeyView" ref="448510093"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="1042813110">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">マウスカーソルが主ディスプレイの一番上に置かれたときにメニューバーが表示されます。</string>
- <reference key="NSSupport" ref="26"/>
- <reference key="NSControlView" ref="331853183"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- </array>
- <string key="NSFrame">{{10, 33}, {538, 279}}</string>
- <reference key="NSNextKeyView" ref="201731424"/>
- </object>
- <string key="NSLabel">出力</string>
- <reference key="NSColor" ref="57160303"/>
- <reference key="NSTabView" ref="448510093"/>
- </object>
- <object class="NSTabViewItem" id="723450037">
- <object class="NSMutableString" key="NSIdentifier">
- <characters key="NS.bytes">2</characters>
- </object>
- <object class="NSView" key="NSView" id="408298283">
- <nil key="NSNextResponder"/>
- <int key="NSvFlags">256</int>
- <array class="NSMutableArray" key="NSSubviews">
- <object class="NSButton" id="878106058">
- <reference key="NSNextResponder" ref="408298283"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{18, 255}, {505, 23}}</string>
- <reference key="NSSuperview" ref="408298283"/>
- <reference key="NSNextKeyView" ref="386152084"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="718083688">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">同期を有効にする</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="878106058"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="815090595"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSTextField" id="386152084">
- <reference key="NSNextResponder" ref="408298283"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{36, 221}, {488, 28}}</string>
- <reference key="NSSuperview" ref="408298283"/>
- <reference key="NSNextKeyView" ref="487809555"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="572508492">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">“コピー”メニュー項目を有効にして、OSX のペーストボードと X11 の CLIPBOARD バッファおよび PRIMARY バッファを同期できるようにします。</string>
- <reference key="NSSupport" ref="26"/>
- <reference key="NSControlView" ref="386152084"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- <object class="NSButton" id="477050998">
- <reference key="NSNextResponder" ref="408298283"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{34, 129}, {489, 18}}</string>
- <reference key="NSSuperview" ref="408298283"/>
- <reference key="NSNextKeyView" ref="765780304"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="501304422">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">ペーストボードが変更されたときに CLIPBOARD をアップデート</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="477050998"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="815090595"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSButton" id="765780304">
- <reference key="NSNextResponder" ref="408298283"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{34, 104}, {489, 18}}</string>
- <reference key="NSSuperview" ref="408298283"/>
- <reference key="NSNextKeyView" ref="1002778833"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="510771323">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">ペーストボードが変更されたときに PRIMARY (中クリック)をアップデート</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="765780304"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="815090595"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSButton" id="1002778833">
- <reference key="NSNextResponder" ref="408298283"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{34, 79}, {489, 18}}</string>
- <reference key="NSSuperview" ref="408298283"/>
- <reference key="NSNextKeyView" ref="522511724"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="897099877">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">新しいテキストが選択されたら、すぐにペーストボードをアップデート</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="1002778833"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="815090595"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSButton" id="487809555">
- <reference key="NSNextResponder" ref="408298283"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{34, 192}, {489, 18}}</string>
- <reference key="NSSuperview" ref="408298283"/>
- <reference key="NSNextKeyView" ref="620944856"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="619977658">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">CLIPBOARD が変更されたときにペーストボードをアップデート</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="487809555"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="815090595"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSTextField" id="620944856">
- <reference key="NSNextResponder" ref="408298283"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{48, 158}, {476, 28}}</string>
- <reference key="NSSuperview" ref="408298283"/>
- <reference key="NSNextKeyView" ref="477050998"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="461823902">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">xclipboard、klipper、その他の X11 クリップボードマネージャを使用したい場合は、このオプションを無効にしてください。</string>
- <reference key="NSSupport" ref="26"/>
- <reference key="NSControlView" ref="620944856"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- <object class="NSTextField" id="522511724">
- <reference key="NSNextResponder" ref="408298283"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{48, 47}, {476, 28}}</string>
- <reference key="NSSuperview" ref="408298283"/>
- <reference key="NSNextKeyView" ref="448510093"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="994587858">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">X11 プロトコルの制限により、このオプションは、一部のアプリケーションで機能しない場合があります。</string>
- <reference key="NSSupport" ref="26"/>
- <reference key="NSControlView" ref="522511724"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- </array>
- <string key="NSFrame">{{10, 33}, {538, 279}}</string>
- <reference key="NSNextKeyView" ref="878106058"/>
- </object>
- <string key="NSLabel">ペーストボード</string>
- <reference key="NSColor" ref="57160303"/>
- <reference key="NSTabView" ref="448510093"/>
- </object>
- <object class="NSTabViewItem" id="10973343">
- <object class="NSMutableString" key="NSIdentifier">
- <characters key="NS.bytes">2</characters>
- </object>
- <object class="NSView" key="NSView" id="184765684">
- <nil key="NSNextResponder"/>
- <int key="NSvFlags">256</int>
- <array class="NSMutableArray" key="NSSubviews">
- <object class="NSButton" id="657659108">
- <reference key="NSNextResponder" ref="184765684"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{15, 245}, {508, 18}}</string>
- <reference key="NSSuperview" ref="184765684"/>
- <reference key="NSNextKeyView" ref="290578835"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="259618205">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">選択されていないウインドウを直接クリック</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="657659108"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="815090595"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSTextField" id="290578835">
- <reference key="NSNextResponder" ref="184765684"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{23, 211}, {501, 28}}</string>
- <reference key="NSSuperview" ref="184765684"/>
- <reference key="NSNextKeyView" ref="992839333"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="399127858">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">有効にした場合、選択されていないウインドウをクリックしたときに、そのウインドウを一番手前に表示するだけでなく、ウインドウ内の項目を直接クリックします。</string>
- <reference key="NSSupport" ref="26"/>
- <string key="NSPlaceholderString"/>
- <reference key="NSControlView" ref="290578835"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- <object class="NSButton" id="992839333">
- <reference key="NSNextResponder" ref="184765684"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{15, 184}, {508, 18}}</string>
- <reference key="NSSuperview" ref="184765684"/>
- <reference key="NSNextKeyView" ref="138261120"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="959555182">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">フォーカスをマウスと一緒に移動</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="992839333"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="815090595"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSTextField" id="138261120">
- <reference key="NSNextResponder" ref="184765684"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{23, 164}, {501, 14}}</string>
- <reference key="NSSuperview" ref="184765684"/>
- <reference key="NSNextKeyView" ref="128352289"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="183409141">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">X11 ウインドウのフォーカスがカーソルと一緒に移動します。逆効果になる場合もあります。</string>
- <reference key="NSSupport" ref="26"/>
- <string key="NSPlaceholderString"/>
- <reference key="NSControlView" ref="138261120"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- <object class="NSButton" id="128352289">
- <reference key="NSNextResponder" ref="184765684"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{15, 140}, {508, 18}}</string>
- <reference key="NSSuperview" ref="184765684"/>
- <reference key="NSNextKeyView" ref="57161931"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="556463187">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">新規ウインドウにフォーカス</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="128352289"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="815090595"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSTextField" id="57161931">
- <reference key="NSNextResponder" ref="184765684"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{23, 106}, {501, 28}}</string>
- <reference key="NSSuperview" ref="184765684"/>
- <reference key="NSNextKeyView" ref="448510093"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="989804990">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">有効にした場合、新しい X11 ウインドウを作成すると、Finder.app や ターミナル.app などの代わりに、X11.app が前面に移動します。</string>
- <reference key="NSSupport" ref="26"/>
- <string key="NSPlaceholderString"/>
- <reference key="NSControlView" ref="57161931"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- </array>
- <string key="NSFrame">{{10, 33}, {538, 279}}</string>
- <reference key="NSNextKeyView" ref="657659108"/>
- </object>
- <string key="NSLabel">ウインドウ</string>
- <reference key="NSColor" ref="57160303"/>
- <reference key="NSTabView" ref="448510093"/>
- </object>
- <object class="NSTabViewItem" id="348328898">
- <object class="NSView" key="NSView" id="300811574">
- <nil key="NSNextResponder"/>
- <int key="NSvFlags">256</int>
- <array class="NSMutableArray" key="NSSubviews">
- <object class="NSButton" id="989050925">
- <reference key="NSNextResponder" ref="300811574"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{18, 243}, {482, 18}}</string>
- <reference key="NSSuperview" ref="300811574"/>
- <reference key="NSNextKeyView" ref="168436707"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="189594322">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">接続を認証</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="989050925"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="815090595"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSButton" id="700826966">
- <reference key="NSNextResponder" ref="300811574"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{18, 180}, {402, 18}}</string>
- <reference key="NSSuperview" ref="300811574"/>
- <reference key="NSNextKeyView" ref="363817195"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="489340979">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">0</int>
- <string key="NSContents">ネットワーク・クライアントからの接続を許可</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="700826966"/>
- <int key="NSButtonFlags">1211912703</int>
- <int key="NSButtonFlags2">2</int>
- <reference key="NSNormalImage" ref="815090595"/>
- <reference key="NSAlternateImage" ref="391434389"/>
- <string key="NSAlternateContents"/>
- <string key="NSKeyEquivalent"/>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSTextField" id="168436707">
- <reference key="NSNextResponder" ref="300811574"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{36, 209}, {488, 28}}</string>
- <reference key="NSSuperview" ref="300811574"/>
- <reference key="NSNextKeyView" ref="700826966"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="53243865">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">X11 の起動時に、Xauthority アクセス制御キーを作成します。システムの IP アドレスが変更されると、これらのキーが無効になり、X11 アプリケーションが起動しなくなることがあります。</string>
- <reference key="NSSupport" ref="26"/>
- <string key="NSPlaceholderString"/>
- <reference key="NSControlView" ref="168436707"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- <object class="NSTextField" id="363817195">
- <reference key="NSNextResponder" ref="300811574"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{36, 132}, {488, 42}}</string>
- <reference key="NSSuperview" ref="300811574"/>
- <reference key="NSNextKeyView" ref="223835729"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="390084685">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">有効にする場合は、システムのセキュリティを維持するために、“接続を認証”も有効にしてください。無効にすると、リモートアプリケーションからの接続は拒否されます。</string>
- <reference key="NSSupport" ref="26"/>
- <string key="NSPlaceholderString"/>
- <reference key="NSControlView" ref="363817195"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- <object class="NSTextField" id="223835729">
- <reference key="NSNextResponder" ref="300811574"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{17, 17}, {404, 14}}</string>
- <reference key="NSSuperview" ref="300811574"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTextFieldCell" key="NSCell" id="283628678">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">4194304</int>
- <string key="NSContents">これらのオプションは、次回 X11 を起動したときに有効になります。</string>
- <reference key="NSSupport" ref="26"/>
- <string key="NSPlaceholderString"/>
- <reference key="NSControlView" ref="223835729"/>
- <reference key="NSBackgroundColor" ref="57160303"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- </object>
- </array>
- <string key="NSFrame">{{10, 33}, {538, 279}}</string>
- <reference key="NSNextKeyView" ref="989050925"/>
- </object>
- <string key="NSLabel">セキュリティ</string>
- <reference key="NSColor" ref="57160303"/>
- <reference key="NSTabView" ref="448510093"/>
- </object>
- </array>
- <reference key="NSSelectedTabViewItem" ref="287591690"/>
- <reference key="NSFont" ref="463863101"/>
- <int key="NSTvFlags">0</int>
- <bool key="NSAllowTruncatedLabels">YES</bool>
- <bool key="NSDrawsBackground">YES</bool>
- <array class="NSMutableArray" key="NSSubviews">
- <reference ref="596750588"/>
- </array>
- </object>
- </array>
- <string key="NSFrameSize">{584, 341}</string>
- <reference key="NSNextKeyView" ref="448510093"/>
- </object>
- <string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
- <string key="NSMinSize">{320, 262}</string>
- <string key="NSMaxSize">{1.7976931348623157e+308, 1.7976931348623157e+308}</string>
- <string key="NSFrameAutosaveName">x11_prefs</string>
- </object>
- <object class="NSWindowTemplate" id="604417141">
- <int key="NSWindowStyleMask">11</int>
- <int key="NSWindowBacking">2</int>
- <string key="NSWindowRect">{{360, 402}, {454, 271}}</string>
- <int key="NSWTFlags">1350041600</int>
- <string key="NSWindowTitle">X11 アプリケーションメニュー</string>
- <string key="NSWindowClass">NSPanel</string>
- <object class="NSMutableString" key="NSViewClass">
- <characters key="NS.bytes">View</characters>
- </object>
- <nil key="NSUserInterfaceItemIdentifier"/>
- <string key="NSWindowContentMaxSize">{1.7976931348623157e+308, 1.7976931348623157e+308}</string>
- <string key="NSWindowContentMinSize">{454, 271}</string>
- <object class="NSView" key="NSWindowView" id="85544634">
- <nil key="NSNextResponder"/>
- <int key="NSvFlags">256</int>
- <array class="NSMutableArray" key="NSSubviews">
- <object class="NSButton" id="671954382">
- <reference key="NSNextResponder" ref="85544634"/>
- <int key="NSvFlags">265</int>
- <string key="NSFrame">{{340, 191}, {105, 32}}</string>
- <reference key="NSSuperview" ref="85544634"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="143554520">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">137887744</int>
- <string key="NSContents">複製</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="671954382"/>
- <int key="NSButtonFlags">-2038284033</int>
- <int key="NSButtonFlags2">1</int>
- <object class="NSFont" key="NSAlternateImage" id="549406736">
- <string key="NSName">Helvetica</string>
- <double key="NSSize">13</double>
- <int key="NSfFlags">16</int>
- </object>
- <string key="NSAlternateContents"/>
- <object class="NSMutableString" key="NSKeyEquivalent">
- <characters key="NS.bytes"/>
- </object>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSButton" id="492358940">
- <reference key="NSNextResponder" ref="85544634"/>
- <int key="NSvFlags">265</int>
- <string key="NSFrame">{{340, 159}, {105, 32}}</string>
- <reference key="NSSuperview" ref="85544634"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="8201128">
- <int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">137887744</int>
- <string key="NSContents">削除</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="492358940"/>
- <int key="NSButtonFlags">-2038284033</int>
- <int key="NSButtonFlags2">1</int>
- <reference key="NSAlternateImage" ref="549406736"/>
- <string key="NSAlternateContents"/>
- <object class="NSMutableString" key="NSKeyEquivalent">
- <characters key="NS.bytes"/>
- </object>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- <object class="NSScrollView" id="1063387772">
- <reference key="NSNextResponder" ref="85544634"/>
- <int key="NSvFlags">274</int>
- <array class="NSMutableArray" key="NSSubviews">
- <object class="NSClipView" id="580565898">
- <reference key="NSNextResponder" ref="1063387772"/>
- <int key="NSvFlags">2304</int>
- <array class="NSMutableArray" key="NSSubviews">
- <object class="NSTableView" id="905092943">
- <reference key="NSNextResponder" ref="580565898"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrameSize">{301, 198}</string>
- <reference key="NSSuperview" ref="580565898"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSTableHeaderView" key="NSHeaderView" id="792419186">
- <reference key="NSNextResponder" ref="672307654"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrameSize">{301, 17}</string>
- <reference key="NSSuperview" ref="672307654"/>
- <reference key="NSTableView" ref="905092943"/>
- </object>
- <object class="_NSCornerView" key="NSCornerView" id="898633680">
- <reference key="NSNextResponder" ref="1063387772"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{302, 0}, {16, 17}}</string>
- <reference key="NSSuperview" ref="1063387772"/>
- </object>
- <array class="NSMutableArray" key="NSTableColumns">
- <object class="NSTableColumn" id="938444323">
- <double key="NSWidth">103</double>
- <double key="NSMinWidth">43</double>
- <double key="NSMaxWidth">1000</double>
- <object class="NSTableHeaderCell" key="NSHeaderCell">
- <int key="NSCellFlags">75628096</int>
- <int key="NSCellFlags2">2048</int>
- <string key="NSContents">名前</string>
- <reference key="NSSupport" ref="26"/>
- <object class="NSColor" key="NSBackgroundColor" id="113872566">
- <int key="NSColorSpace">3</int>
- <bytes key="NSWhite">MC4zMzMzMzI5ODU2AA</bytes>
- </object>
- <object class="NSColor" key="NSTextColor" id="249576247">
- <int key="NSColorSpace">6</int>
- <string key="NSCatalogName">System</string>
- <string key="NSColorName">headerTextColor</string>
- <reference key="NSColor" ref="214098874"/>
- </object>
- </object>
- <object class="NSTextFieldCell" key="NSDataCell" id="825378892">
- <int key="NSCellFlags">338820672</int>
- <int key="NSCellFlags2">1024</int>
- <string key="NSContents">テキストセル</string>
- <reference key="NSSupport" ref="463863101"/>
- <string key="NSPlaceholderString"/>
- <reference key="NSControlView" ref="905092943"/>
- <object class="NSColor" key="NSBackgroundColor" id="822946413">
- <int key="NSColorSpace">3</int>
- <bytes key="NSWhite">MQA</bytes>
- </object>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- <int key="NSResizingMask">3</int>
- <bool key="NSIsResizeable">YES</bool>
- <bool key="NSIsEditable">YES</bool>
- <reference key="NSTableView" ref="905092943"/>
- <string key="NSHeaderToolTip"/>
- </object>
- <object class="NSTableColumn" id="84282687">
- <double key="NSWidth">100</double>
- <double key="NSMinWidth">40</double>
- <double key="NSMaxWidth">1000</double>
- <object class="NSTableHeaderCell" key="NSHeaderCell">
- <int key="NSCellFlags">75628096</int>
- <int key="NSCellFlags2">2048</int>
- <string key="NSContents">コマンド</string>
- <reference key="NSSupport" ref="26"/>
- <reference key="NSBackgroundColor" ref="113872566"/>
- <reference key="NSTextColor" ref="249576247"/>
- </object>
- <object class="NSTextFieldCell" key="NSDataCell" id="432610585">
- <int key="NSCellFlags">338820672</int>
- <int key="NSCellFlags2">1024</int>
- <string key="NSContents">テキストセル</string>
- <reference key="NSSupport" ref="463863101"/>
- <string key="NSPlaceholderString"/>
- <reference key="NSControlView" ref="905092943"/>
- <reference key="NSBackgroundColor" ref="822946413"/>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- <int key="NSResizingMask">3</int>
- <bool key="NSIsResizeable">YES</bool>
- <bool key="NSIsEditable">YES</bool>
- <reference key="NSTableView" ref="905092943"/>
- <string key="NSHeaderToolTip"/>
- </object>
- <object class="NSTableColumn" id="242608782">
- <double key="NSWidth">89</double>
- <double key="NSMinWidth">30</double>
- <double key="NSMaxWidth">1000</double>
- <object class="NSTableHeaderCell" key="NSHeaderCell">
- <int key="NSCellFlags">75628096</int>
- <int key="NSCellFlags2">2048</int>
- <string key="NSContents">ショートカット</string>
- <reference key="NSSupport" ref="26"/>
- <object class="NSColor" key="NSBackgroundColor">
- <int key="NSColorSpace">6</int>
- <string key="NSCatalogName">System</string>
- <string key="NSColorName">headerColor</string>
- <reference key="NSColor" ref="822946413"/>
- </object>
- <reference key="NSTextColor" ref="249576247"/>
- </object>
- <object class="NSTextFieldCell" key="NSDataCell" id="34714764">
- <int key="NSCellFlags">338820672</int>
- <int key="NSCellFlags2">1024</int>
- <string key="NSContents">テキストセル</string>
- <object class="NSFont" key="NSSupport">
- <string key="NSName">LucidaGrande</string>
- <double key="NSSize">12</double>
- <int key="NSfFlags">16</int>
- </object>
- <string key="NSPlaceholderString"/>
- <reference key="NSControlView" ref="905092943"/>
- <bool key="NSDrawsBackground">YES</bool>
- <object class="NSColor" key="NSBackgroundColor" id="812484075">
- <int key="NSColorSpace">6</int>
- <string key="NSCatalogName">System</string>
- <string key="NSColorName">controlBackgroundColor</string>
- <reference key="NSColor" ref="590688762"/>
- </object>
- <reference key="NSTextColor" ref="930815747"/>
- </object>
- <int key="NSResizingMask">3</int>
- <bool key="NSIsResizeable">YES</bool>
- <bool key="NSIsEditable">YES</bool>
- <reference key="NSTableView" ref="905092943"/>
- <string key="NSHeaderToolTip"/>
- </object>
- </array>
- <double key="NSIntercellSpacingWidth">3</double>
- <double key="NSIntercellSpacingHeight">2</double>
- <reference key="NSBackgroundColor" ref="822946413"/>
- <object class="NSColor" key="NSGridColor">
- <int key="NSColorSpace">6</int>
- <string key="NSCatalogName">System</string>
- <string key="NSColorName">gridColor</string>
- <object class="NSColor" key="NSColor">
- <int key="NSColorSpace">3</int>
- <bytes key="NSWhite">MC41AA</bytes>
- </object>
- </object>
- <double key="NSRowHeight">17</double>
- <int key="NSTvFlags">1379958784</int>
- <reference key="NSDelegate"/>
- <reference key="NSDataSource"/>
- <int key="NSColumnAutoresizingStyle">1</int>
- <int key="NSDraggingSourceMaskForLocal">-1</int>
- <int key="NSDraggingSourceMaskForNonLocal">0</int>
- <bool key="NSAllowsTypeSelect">YES</bool>
- <int key="NSTableViewDraggingDestinationStyle">0</int>
- <int key="NSTableViewGroupRowStyle">1</int>
- </object>
- </array>
- <string key="NSFrame">{{1, 17}, {301, 198}}</string>
- <reference key="NSSuperview" ref="1063387772"/>
- <reference key="NSNextKeyView" ref="905092943"/>
- <reference key="NSDocView" ref="905092943"/>
- <reference key="NSBGColor" ref="812484075"/>
- <int key="NScvFlags">4</int>
- </object>
- <object class="NSScroller" id="842897584">
- <reference key="NSNextResponder" ref="1063387772"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{302, 17}, {15, 198}}</string>
- <reference key="NSSuperview" ref="1063387772"/>
- <reference key="NSTarget" ref="1063387772"/>
- <string key="NSAction">_doScroller:</string>
- <double key="NSPercent">0.99492377042770386</double>
- </object>
- <object class="NSScroller" id="17278747">
- <reference key="NSNextResponder" ref="1063387772"/>
- <int key="NSvFlags">256</int>
- <string key="NSFrame">{{1, 215}, {301, 15}}</string>
- <reference key="NSSuperview" ref="1063387772"/>
- <int key="NSsFlags">1</int>
- <reference key="NSTarget" ref="1063387772"/>
- <string key="NSAction">_doScroller:</string>
- <double key="NSPercent">0.68852460384368896</double>
- </object>
- <object class="NSClipView" id="672307654">
- <reference key="NSNextResponder" ref="1063387772"/>
- <int key="NSvFlags">2304</int>
- <array class="NSMutableArray" key="NSSubviews">
- <reference ref="792419186"/>
- </array>
- <string key="NSFrame">{{1, 0}, {301, 17}}</string>
- <reference key="NSSuperview" ref="1063387772"/>
- <reference key="NSNextKeyView" ref="792419186"/>
- <reference key="NSDocView" ref="792419186"/>
- <reference key="NSBGColor" ref="812484075"/>
- <int key="NScvFlags">4</int>
- </object>
- <reference ref="898633680"/>
- </array>
- <string key="NSFrame">{{20, 20}, {318, 231}}</string>
- <reference key="NSSuperview" ref="85544634"/>
- <reference key="NSNextKeyView" ref="580565898"/>
- <int key="NSsFlags">133170</int>
- <reference key="NSVScroller" ref="842897584"/>
- <reference key="NSHScroller" ref="17278747"/>
- <reference key="NSContentView" ref="580565898"/>
- <reference key="NSHeaderClipView" ref="672307654"/>
- <bytes key="NSScrollAmts">QSAAAEEgAABBmAAAQZgAAA</bytes>
- </object>
- <object class="NSButton" id="758204686">
- <reference key="NSNextResponder" ref="85544634"/>
- <int key="NSvFlags">265</int>
- <string key="NSFrame">{{340, 223}, {105, 32}}</string>
- <reference key="NSSuperview" ref="85544634"/>
- <bool key="NSEnabled">YES</bool>
- <object class="NSButtonCell" key="NSCell" id="1025474039">
- <int key="NSCellFlags">-2080244224</int>
- <int key="NSCellFlags2">137887744</int>
- <string key="NSContents">項目を追加</string>
- <reference key="NSSupport" ref="463863101"/>
- <reference key="NSControlView" ref="758204686"/>
- <int key="NSButtonFlags">-2038284033</int>
- <int key="NSButtonFlags2">1</int>
- <reference key="NSAlternateImage" ref="549406736"/>
- <string key="NSAlternateContents"/>
- <object class="NSMutableString" key="NSKeyEquivalent">
- <characters key="NS.bytes"/>
- </object>
- <int key="NSPeriodicDelay">200</int>
- <int key="NSPeriodicInterval">25</int>
- </object>
- </object>
- </array>
- <string key="NSFrameSize">{454, 271}</string>
- </object>
- <string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
- <string key="NSMinSize">{454, 293}</string>
- <string key="NSMaxSize">{1.7976931348623157e+308, 1.7976931348623157e+308}</string>
- <string key="NSFrameAutosaveName">x11_apps</string>
- </object>
- <object class="NSMenu" id="294137138">
- <string key="NSTitle">メニュー</string>
- <array class="NSMutableArray" key="NSMenuItems">
- <object class="NSMenuItem" id="318286212">
- <reference key="NSMenu" ref="294137138"/>
- <bool key="NSIsDisabled">YES</bool>
- <bool key="NSIsSeparator">YES</bool>
- <string key="NSTitle"/>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="511651072">
- <reference key="NSMenu" ref="294137138"/>
- <string key="NSTitle">アプリケーション</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- <string key="NSAction">submenuAction:</string>
- <object class="NSMenu" key="NSSubmenu" id="48278059">
- <string key="NSTitle">アプリケーション</string>
- <array class="NSMutableArray" key="NSMenuItems">
- <object class="NSMenuItem" id="563798000">
- <reference key="NSMenu" ref="48278059"/>
- <bool key="NSIsDisabled">YES</bool>
- <bool key="NSIsSeparator">YES</bool>
- <string key="NSTitle"/>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- <object class="NSMenuItem" id="1032342329">
- <reference key="NSMenu" ref="48278059"/>
- <string key="NSTitle">カスタマイズ...</string>
- <string key="NSKeyEquiv"/>
- <int key="NSKeyEquivModMask">1048576</int>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="531645050"/>
- <reference key="NSMixedImage" ref="351811234"/>
- </object>
- </array>
- </object>
- </object>
- </array>
- <string key="NSName"/>
- </object>
- </array>
- <object class="IBObjectContainer" key="IBDocument.Objects">
- <array class="NSMutableArray" key="connectionRecords">
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">copy:</string>
- <reference key="source" ref="941939442"/>
- <reference key="destination" ref="185296989"/>
- </object>
- <int key="connectionID">181</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">minimize_window:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="677652931"/>
- </object>
- <int key="connectionID">202</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">close_window:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="984461797"/>
- </object>
- <int key="connectionID">205</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">zoom_window:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="1066447520"/>
- </object>
- <int key="connectionID">206</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">bring_to_front:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="276216762"/>
- </object>
- <int key="connectionID">207</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">hideOtherApplications:</string>
- <reference key="source" ref="815810918"/>
- <reference key="destination" ref="206802571"/>
- </object>
- <int key="connectionID">263</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">apps_separator</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="390088328"/>
- </object>
- <int key="connectionID">273</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">apps_table</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="905092943"/>
- </object>
- <int key="connectionID">301</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">apps_table_delete:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="492358940"/>
- </object>
- <int key="connectionID">303</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">apps_table_duplicate:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="671954382"/>
- </object>
- <int key="connectionID">304</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">apps_table_show:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="1065386165"/>
- </object>
- <int key="connectionID">308</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">apps_table_new:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="758204686"/>
- </object>
- <int key="connectionID">311</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_show:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="386173216"/>
- </object>
- <int key="connectionID">318</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">x11_about_item</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="139290918"/>
- </object>
- <int key="connectionID">321</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">enable_auth</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="989050925"/>
- </object>
- <int key="connectionID">387</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">enable_tcp</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="700826966"/>
- </object>
- <int key="connectionID">388</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">depth</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="709074847"/>
- </object>
- <int key="connectionID">389</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">fake_buttons</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="119157981"/>
- </object>
- <int key="connectionID">391</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">sync_keymap</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="179949713"/>
- </object>
- <int key="connectionID">392</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">enable_keyequivs</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="842100515"/>
- </object>
- <int key="connectionID">393</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="119157981"/>
- </object>
- <int key="connectionID">394</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="179949713"/>
- </object>
- <int key="connectionID">395</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="842100515"/>
- </object>
- <int key="connectionID">396</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="709074847"/>
- </object>
- <int key="connectionID">398</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="989050925"/>
- </object>
- <int key="connectionID">399</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="700826966"/>
- </object>
- <int key="connectionID">401</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">prefs_panel</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="124913468"/>
- </object>
- <int key="connectionID">402</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">x11_help:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="504984881"/>
- </object>
- <int key="connectionID">422</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">dockMenu</string>
- <reference key="source" ref="815810918"/>
- <reference key="destination" ref="294137138"/>
- </object>
- <int key="connectionID">426</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">dock_menu</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="294137138"/>
- </object>
- <int key="connectionID">428</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">delegate</string>
- <reference key="source" ref="815810918"/>
- <reference key="destination" ref="485884620"/>
- </object>
- <int key="connectionID">429</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">hide:</string>
- <reference key="source" ref="815810918"/>
- <reference key="destination" ref="301008465"/>
- </object>
- <int key="connectionID">430</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">unhideAllApplications:</string>
- <reference key="source" ref="815810918"/>
- <reference key="destination" ref="1023546148"/>
- </object>
- <int key="connectionID">431</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">orderFrontStandardAboutPanel:</string>
- <reference key="source" ref="815810918"/>
- <reference key="destination" ref="139290918"/>
- </object>
- <int key="connectionID">433</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">dock_apps_menu</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="48278059"/>
- </object>
- <int key="connectionID">530</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">dock_window_separator</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="318286212"/>
- </object>
- <int key="connectionID">531</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">apps_table_show:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="1032342329"/>
- </object>
- <int key="connectionID">534</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">next_window:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="1036389925"/>
- </object>
- <int key="connectionID">539</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">previous_window:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="369641893"/>
- </object>
- <int key="connectionID">540</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">enable_fullscreen</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="477203622"/>
- </object>
- <int key="connectionID">546</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">enable_fullscreen_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="477203622"/>
- </object>
- <int key="connectionID">547</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">toggle_fullscreen:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="6876565"/>
- </object>
- <int key="connectionID">548</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">toggle_fullscreen_item</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="6876565"/>
- </object>
- <int key="connectionID">549</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">menu</string>
- <reference key="source" ref="815810918"/>
- <reference key="destination" ref="524015605"/>
- </object>
- <int key="connectionID">300334</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">terminate:</string>
- <reference key="source" ref="815810918"/>
- <reference key="destination" ref="274138642"/>
- </object>
- <int key="connectionID">300336</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="657659108"/>
- </object>
- <int key="connectionID">300389</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="992839333"/>
- </object>
- <int key="connectionID">300390</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="128352289"/>
- </object>
- <int key="connectionID">300391</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">click_through</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="657659108"/>
- </object>
- <int key="connectionID">300392</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">focus_follows_mouse</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="992839333"/>
- </object>
- <int key="connectionID">300393</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">focus_on_new_window</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="128352289"/>
- </object>
- <int key="connectionID">300394</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">copy_menu_item</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="185296989"/>
- </object>
- <int key="connectionID">300443</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">sync_pasteboard</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="878106058"/>
- </object>
- <int key="connectionID">300444</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">sync_clipboard_to_pasteboard</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="487809555"/>
- </object>
- <int key="connectionID">300461</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">sync_pasteboard_to_clipboard</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="477050998"/>
- </object>
- <int key="connectionID">300462</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">sync_pasteboard_to_primary</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="765780304"/>
- </object>
- <int key="connectionID">300463</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">sync_primary_immediately</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="1002778833"/>
- </object>
- <int key="connectionID">300464</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="878106058"/>
- </object>
- <int key="connectionID">300465</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="487809555"/>
- </object>
- <int key="connectionID">300466</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="477050998"/>
- </object>
- <int key="connectionID">300467</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="765780304"/>
- </object>
- <int key="connectionID">300468</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="1002778833"/>
- </object>
- <int key="connectionID">300469</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">sync_text1</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="620944856"/>
- </object>
- <int key="connectionID">300470</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">sync_text2</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="522511724"/>
- </object>
- <int key="connectionID">300471</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">enable_fullscreen_menu</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="57246850"/>
- </object>
- <int key="connectionID">300474</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="57246850"/>
- </object>
- <int key="connectionID">300475</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="406291430"/>
- </object>
- <int key="connectionID">300480</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">option_sends_alt</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="406291430"/>
- </object>
- <int key="connectionID">300481</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">prefs_changed:</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="863505041"/>
- </object>
- <int key="connectionID">300484</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">enable_fullscreen_menu_text</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="331853183"/>
- </object>
- <int key="connectionID">300489</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">scroll_in_device_direction</string>
- <reference key="source" ref="485884620"/>
- <reference key="destination" ref="863505041"/>
- </object>
- <int key="connectionID">300490</int>
- </object>
- </array>
- <object class="IBMutableOrderedSet" key="objectRecords">
- <array key="orderedObjects">
- <object class="IBObjectRecord">
- <int key="objectID">0</int>
- <array key="object" id="0"/>
- <reference key="children" ref="904585544"/>
- <nil key="parent"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">-2</int>
- <reference key="object" ref="815810918"/>
- <reference key="parent" ref="0"/>
- <string key="objectName">File's Owner</string>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">-1</int>
- <reference key="object" ref="941939442"/>
- <reference key="parent" ref="0"/>
- <string key="objectName">First Responder</string>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">-3</int>
- <reference key="object" ref="951368722"/>
- <reference key="parent" ref="0"/>
- <string key="objectName">Application</string>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">29</int>
- <reference key="object" ref="524015605"/>
- <array class="NSMutableArray" key="children">
- <reference ref="931553638"/>
- <reference ref="365880285"/>
- <reference ref="200491363"/>
- <reference ref="868031522"/>
- <reference ref="551174276"/>
- </array>
- <reference key="parent" ref="0"/>
- <string key="objectName">MainMenu</string>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">19</int>
- <reference key="object" ref="931553638"/>
- <array class="NSMutableArray" key="children">
- <reference ref="96874957"/>
- </array>
- <reference key="parent" ref="524015605"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">24</int>
- <reference key="object" ref="96874957"/>
- <array class="NSMutableArray" key="children">
- <reference ref="677652931"/>
- <reference ref="276216762"/>
- <reference ref="1066447520"/>
- <reference ref="1036389925"/>
- <reference ref="369641893"/>
- <reference ref="155085383"/>
- <reference ref="984461797"/>
- <reference ref="280172320"/>
- </array>
- <reference key="parent" ref="931553638"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">5</int>
- <reference key="object" ref="276216762"/>
- <reference key="parent" ref="96874957"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">23</int>
- <reference key="object" ref="677652931"/>
- <reference key="parent" ref="96874957"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">92</int>
- <reference key="object" ref="280172320"/>
- <reference key="parent" ref="96874957"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">203</int>
- <reference key="object" ref="984461797"/>
- <reference key="parent" ref="96874957"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">204</int>
- <reference key="object" ref="1066447520"/>
- <reference key="parent" ref="96874957"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">536</int>
- <reference key="object" ref="155085383"/>
- <reference key="parent" ref="96874957"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">537</int>
- <reference key="object" ref="1036389925"/>
- <reference key="parent" ref="96874957"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">538</int>
- <reference key="object" ref="369641893"/>
- <reference key="parent" ref="96874957"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">56</int>
- <reference key="object" ref="365880285"/>
- <array class="NSMutableArray" key="children">
- <reference ref="576521955"/>
- </array>
- <reference key="parent" ref="524015605"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">57</int>
- <reference key="object" ref="576521955"/>
- <array class="NSMutableArray" key="children">
- <reference ref="139290918"/>
- <reference ref="386173216"/>
- <reference ref="32285361"/>
- <reference ref="301008465"/>
- <reference ref="274138642"/>
- <reference ref="272876017"/>
- <reference ref="431301145"/>
- <reference ref="206802571"/>
- <reference ref="848095279"/>
- <reference ref="1023546148"/>
- <reference ref="6876565"/>
- <reference ref="479677589"/>
- </array>
- <reference key="parent" ref="365880285"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">58</int>
- <reference key="object" ref="139290918"/>
- <reference key="parent" ref="576521955"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">129</int>
- <reference key="object" ref="386173216"/>
- <reference key="parent" ref="576521955"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">131</int>
- <reference key="object" ref="32285361"/>
- <array class="NSMutableArray" key="children">
- <reference ref="821388474"/>
- </array>
- <reference key="parent" ref="576521955"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">130</int>
- <reference key="object" ref="821388474"/>
- <reference key="parent" ref="32285361"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">134</int>
- <reference key="object" ref="301008465"/>
- <reference key="parent" ref="576521955"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">136</int>
- <reference key="object" ref="274138642"/>
- <reference key="parent" ref="576521955"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">143</int>
- <reference key="object" ref="272876017"/>
- <reference key="parent" ref="576521955"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">144</int>
- <reference key="object" ref="431301145"/>
- <reference key="parent" ref="576521955"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">145</int>
- <reference key="object" ref="206802571"/>
- <reference key="parent" ref="576521955"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">149</int>
- <reference key="object" ref="848095279"/>
- <reference key="parent" ref="576521955"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">150</int>
- <reference key="object" ref="1023546148"/>
- <reference key="parent" ref="576521955"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">544</int>
- <reference key="object" ref="6876565"/>
- <reference key="parent" ref="576521955"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">545</int>
- <reference key="object" ref="479677589"/>
- <reference key="parent" ref="576521955"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">163</int>
- <reference key="object" ref="200491363"/>
- <array class="NSMutableArray" key="children">
- <reference ref="526778998"/>
- </array>
- <reference key="parent" ref="524015605"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">169</int>
- <reference key="object" ref="526778998"/>
- <array class="NSMutableArray" key="children">
- <reference ref="185296989"/>
- </array>
- <reference key="parent" ref="200491363"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">157</int>
- <reference key="object" ref="185296989"/>
- <reference key="parent" ref="526778998"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">269</int>
- <reference key="object" ref="868031522"/>
- <array class="NSMutableArray" key="children">
- <reference ref="981161348"/>
- </array>
- <reference key="parent" ref="524015605"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">270</int>
- <reference key="object" ref="981161348"/>
- <array class="NSMutableArray" key="children">
- <reference ref="390088328"/>
- <reference ref="1065386165"/>
- </array>
- <reference key="parent" ref="868031522"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">272</int>
- <reference key="object" ref="390088328"/>
- <reference key="parent" ref="981161348"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">305</int>
- <reference key="object" ref="1065386165"/>
- <reference key="parent" ref="981161348"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">419</int>
- <reference key="object" ref="551174276"/>
- <array class="NSMutableArray" key="children">
- <reference ref="511848303"/>
- </array>
- <reference key="parent" ref="524015605"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">420</int>
- <reference key="object" ref="511848303"/>
- <array class="NSMutableArray" key="children">
- <reference ref="504984881"/>
- </array>
- <reference key="parent" ref="551174276"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">421</int>
- <reference key="object" ref="504984881"/>
- <reference key="parent" ref="511848303"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">196</int>
- <reference key="object" ref="485884620"/>
- <reference key="parent" ref="0"/>
- <string key="objectName">X11Controller</string>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">244</int>
- <reference key="object" ref="124913468"/>
- <array class="NSMutableArray" key="children">
- <reference ref="941366957"/>
- </array>
- <reference key="parent" ref="0"/>
- <string key="objectName">PrefsPanel</string>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">245</int>
- <reference key="object" ref="941366957"/>
- <array class="NSMutableArray" key="children">
- <reference ref="448510093"/>
- </array>
- <reference key="parent" ref="124913468"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">348</int>
- <reference key="object" ref="448510093"/>
- <array class="NSMutableArray" key="children">
- <reference ref="287591690"/>
- <reference ref="960678392"/>
- <reference ref="348328898"/>
- <reference ref="10973343"/>
- <reference ref="723450037"/>
- </array>
- <reference key="parent" ref="941366957"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">349</int>
- <reference key="object" ref="287591690"/>
- <array class="NSMutableArray" key="children">
- <reference ref="596750588"/>
- </array>
- <reference key="parent" ref="448510093"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">351</int>
- <reference key="object" ref="596750588"/>
- <array class="NSMutableArray" key="children">
- <reference ref="119157981"/>
- <reference ref="443008216"/>
- <reference ref="282885445"/>
- <reference ref="842100515"/>
- <reference ref="31160162"/>
- <reference ref="179949713"/>
- <reference ref="278155937"/>
- <reference ref="406291430"/>
- <reference ref="863505041"/>
- </array>
- <reference key="parent" ref="287591690"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">363</int>
- <reference key="object" ref="119157981"/>
- <array class="NSMutableArray" key="children">
- <reference ref="990762273"/>
- </array>
- <reference key="parent" ref="596750588"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">364</int>
- <reference key="object" ref="443008216"/>
- <array class="NSMutableArray" key="children">
- <reference ref="391919450"/>
- </array>
- <reference key="parent" ref="596750588"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">365</int>
- <reference key="object" ref="282885445"/>
- <array class="NSMutableArray" key="children">
- <reference ref="649334366"/>
- </array>
- <reference key="parent" ref="596750588"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">368</int>
- <reference key="object" ref="842100515"/>
- <array class="NSMutableArray" key="children">
- <reference ref="940564599"/>
- </array>
- <reference key="parent" ref="596750588"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">369</int>
- <reference key="object" ref="31160162"/>
- <array class="NSMutableArray" key="children">
- <reference ref="666057093"/>
- </array>
- <reference key="parent" ref="596750588"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">370</int>
- <reference key="object" ref="179949713"/>
- <array class="NSMutableArray" key="children">
- <reference ref="967619578"/>
- </array>
- <reference key="parent" ref="596750588"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">352</int>
- <reference key="object" ref="960678392"/>
- <array class="NSMutableArray" key="children">
- <reference ref="515308735"/>
- </array>
- <reference key="parent" ref="448510093"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">350</int>
- <reference key="object" ref="515308735"/>
- <array class="NSMutableArray" key="children">
- <reference ref="709074847"/>
- <reference ref="201731424"/>
- <reference ref="86150604"/>
- <reference ref="477203622"/>
- <reference ref="57246850"/>
- <reference ref="298603383"/>
- <reference ref="331853183"/>
- </array>
- <reference key="parent" ref="960678392"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">382</int>
- <reference key="object" ref="709074847"/>
- <array class="NSMutableArray" key="children">
- <reference ref="633115429"/>
- </array>
- <reference key="parent" ref="515308735"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">385</int>
- <reference key="object" ref="201731424"/>
- <array class="NSMutableArray" key="children">
- <reference ref="930265681"/>
- </array>
- <reference key="parent" ref="515308735"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">386</int>
- <reference key="object" ref="86150604"/>
- <array class="NSMutableArray" key="children">
- <reference ref="311969422"/>
- </array>
- <reference key="parent" ref="515308735"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">541</int>
- <reference key="object" ref="477203622"/>
- <array class="NSMutableArray" key="children">
- <reference ref="631531164"/>
- </array>
- <reference key="parent" ref="515308735"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">543</int>
- <reference key="object" ref="298603383"/>
- <array class="NSMutableArray" key="children">
- <reference ref="761107402"/>
- </array>
- <reference key="parent" ref="515308735"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">353</int>
- <reference key="object" ref="348328898"/>
- <array class="NSMutableArray" key="children">
- <reference ref="300811574"/>
- </array>
- <reference key="parent" ref="448510093"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">354</int>
- <reference key="object" ref="300811574"/>
- <array class="NSMutableArray" key="children">
- <reference ref="989050925"/>
- <reference ref="700826966"/>
- <reference ref="168436707"/>
- <reference ref="363817195"/>
- <reference ref="223835729"/>
- </array>
- <reference key="parent" ref="348328898"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">374</int>
- <reference key="object" ref="989050925"/>
- <array class="NSMutableArray" key="children">
- <reference ref="189594322"/>
- </array>
- <reference key="parent" ref="300811574"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">375</int>
- <reference key="object" ref="700826966"/>
- <array class="NSMutableArray" key="children">
- <reference ref="489340979"/>
- </array>
- <reference key="parent" ref="300811574"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">376</int>
- <reference key="object" ref="168436707"/>
- <array class="NSMutableArray" key="children">
- <reference ref="53243865"/>
- </array>
- <reference key="parent" ref="300811574"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">377</int>
- <reference key="object" ref="363817195"/>
- <array class="NSMutableArray" key="children">
- <reference ref="390084685"/>
- </array>
- <reference key="parent" ref="300811574"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">379</int>
- <reference key="object" ref="223835729"/>
- <array class="NSMutableArray" key="children">
- <reference ref="283628678"/>
- </array>
- <reference key="parent" ref="300811574"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">285</int>
- <reference key="object" ref="604417141"/>
- <array class="NSMutableArray" key="children">
- <reference ref="85544634"/>
- </array>
- <reference key="parent" ref="0"/>
- <string key="objectName">EditPrograms</string>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">286</int>
- <reference key="object" ref="85544634"/>
- <array class="NSMutableArray" key="children">
- <reference ref="1063387772"/>
- <reference ref="758204686"/>
- <reference ref="671954382"/>
- <reference ref="492358940"/>
- </array>
- <reference key="parent" ref="604417141"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">423</int>
- <reference key="object" ref="294137138"/>
- <array class="NSMutableArray" key="children">
- <reference ref="318286212"/>
- <reference ref="511651072"/>
- </array>
- <reference key="parent" ref="0"/>
- <string key="objectName">DockMenu</string>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">524</int>
- <reference key="object" ref="318286212"/>
- <reference key="parent" ref="294137138"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">526</int>
- <reference key="object" ref="511651072"/>
- <array class="NSMutableArray" key="children">
- <reference ref="48278059"/>
- </array>
- <reference key="parent" ref="294137138"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">527</int>
- <reference key="object" ref="48278059"/>
- <array class="NSMutableArray" key="children">
- <reference ref="1032342329"/>
- <reference ref="563798000"/>
- </array>
- <reference key="parent" ref="511651072"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">532</int>
- <reference key="object" ref="1032342329"/>
- <reference key="parent" ref="48278059"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">533</int>
- <reference key="object" ref="563798000"/>
- <reference key="parent" ref="48278059"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100363</int>
- <reference key="object" ref="990762273"/>
- <reference key="parent" ref="119157981"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100364</int>
- <reference key="object" ref="391919450"/>
- <reference key="parent" ref="443008216"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100365</int>
- <reference key="object" ref="649334366"/>
- <reference key="parent" ref="282885445"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100368</int>
- <reference key="object" ref="940564599"/>
- <reference key="parent" ref="842100515"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100369</int>
- <reference key="object" ref="666057093"/>
- <reference key="parent" ref="31160162"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100370</int>
- <reference key="object" ref="967619578"/>
- <reference key="parent" ref="179949713"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100382</int>
- <reference key="object" ref="633115429"/>
- <array class="NSMutableArray" key="children">
- <reference ref="341113515"/>
- </array>
- <reference key="parent" ref="709074847"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100385</int>
- <reference key="object" ref="930265681"/>
- <reference key="parent" ref="201731424"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100386</int>
- <reference key="object" ref="311969422"/>
- <reference key="parent" ref="86150604"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100541</int>
- <reference key="object" ref="631531164"/>
- <reference key="parent" ref="477203622"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100543</int>
- <reference key="object" ref="761107402"/>
- <reference key="parent" ref="298603383"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100374</int>
- <reference key="object" ref="189594322"/>
- <reference key="parent" ref="989050925"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100375</int>
- <reference key="object" ref="489340979"/>
- <reference key="parent" ref="700826966"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100376</int>
- <reference key="object" ref="53243865"/>
- <reference key="parent" ref="168436707"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100377</int>
- <reference key="object" ref="390084685"/>
- <reference key="parent" ref="363817195"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100379</int>
- <reference key="object" ref="283628678"/>
- <reference key="parent" ref="223835729"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">380</int>
- <reference key="object" ref="341113515"/>
- <array class="NSMutableArray" key="children">
- <reference ref="759499526"/>
- <reference ref="616492372"/>
- <reference ref="543935434"/>
- <reference ref="836673018"/>
- </array>
- <reference key="parent" ref="633115429"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">435</int>
- <reference key="object" ref="759499526"/>
- <reference key="parent" ref="341113515"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">384</int>
- <reference key="object" ref="616492372"/>
- <reference key="parent" ref="341113515"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">383</int>
- <reference key="object" ref="543935434"/>
- <reference key="parent" ref="341113515"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">381</int>
- <reference key="object" ref="836673018"/>
- <reference key="parent" ref="341113515"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">295</int>
- <reference key="object" ref="1063387772"/>
- <array class="NSMutableArray" key="children">
- <reference ref="792419186"/>
- <reference ref="17278747"/>
- <reference ref="842897584"/>
- <reference ref="905092943"/>
- </array>
- <reference key="parent" ref="85544634"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300295</int>
- <reference key="object" ref="792419186"/>
- <reference key="parent" ref="1063387772"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">200295</int>
- <reference key="object" ref="17278747"/>
- <reference key="parent" ref="1063387772"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100295</int>
- <reference key="object" ref="842897584"/>
- <reference key="parent" ref="1063387772"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">296</int>
- <reference key="object" ref="905092943"/>
- <array class="NSMutableArray" key="children">
- <reference ref="242608782"/>
- <reference ref="938444323"/>
- <reference ref="84282687"/>
- </array>
- <reference key="parent" ref="1063387772"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">535</int>
- <reference key="object" ref="242608782"/>
- <array class="NSMutableArray" key="children">
- <reference ref="34714764"/>
- </array>
- <reference key="parent" ref="905092943"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">575</int>
- <reference key="object" ref="34714764"/>
- <reference key="parent" ref="242608782"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">298</int>
- <reference key="object" ref="938444323"/>
- <array class="NSMutableArray" key="children">
- <reference ref="825378892"/>
- </array>
- <reference key="parent" ref="905092943"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">573</int>
- <reference key="object" ref="825378892"/>
- <reference key="parent" ref="938444323"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">297</int>
- <reference key="object" ref="84282687"/>
- <array class="NSMutableArray" key="children">
- <reference ref="432610585"/>
- </array>
- <reference key="parent" ref="905092943"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">574</int>
- <reference key="object" ref="432610585"/>
- <reference key="parent" ref="84282687"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">310</int>
- <reference key="object" ref="758204686"/>
- <array class="NSMutableArray" key="children">
- <reference ref="1025474039"/>
- </array>
- <reference key="parent" ref="85544634"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100310</int>
- <reference key="object" ref="1025474039"/>
- <reference key="parent" ref="758204686"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">292</int>
- <reference key="object" ref="671954382"/>
- <array class="NSMutableArray" key="children">
- <reference ref="143554520"/>
- </array>
- <reference key="parent" ref="85544634"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100292</int>
- <reference key="object" ref="143554520"/>
- <reference key="parent" ref="671954382"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">293</int>
- <reference key="object" ref="492358940"/>
- <array class="NSMutableArray" key="children">
- <reference ref="8201128"/>
- </array>
- <reference key="parent" ref="85544634"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">100293</int>
- <reference key="object" ref="8201128"/>
- <reference key="parent" ref="492358940"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300337</int>
- <reference key="object" ref="10973343"/>
- <array class="NSMutableArray" key="children">
- <reference ref="184765684"/>
- </array>
- <reference key="parent" ref="448510093"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300338</int>
- <reference key="object" ref="184765684"/>
- <array class="NSMutableArray" key="children">
- <reference ref="657659108"/>
- <reference ref="290578835"/>
- <reference ref="992839333"/>
- <reference ref="138261120"/>
- <reference ref="128352289"/>
- <reference ref="57161931"/>
- </array>
- <reference key="parent" ref="10973343"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300358</int>
- <reference key="object" ref="290578835"/>
- <array class="NSMutableArray" key="children">
- <reference ref="399127858"/>
- </array>
- <reference key="parent" ref="184765684"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300359</int>
- <reference key="object" ref="657659108"/>
- <array class="NSMutableArray" key="children">
- <reference ref="259618205"/>
- </array>
- <reference key="parent" ref="184765684"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300360</int>
- <reference key="object" ref="259618205"/>
- <reference key="parent" ref="657659108"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300361</int>
- <reference key="object" ref="399127858"/>
- <reference key="parent" ref="290578835"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300362</int>
- <reference key="object" ref="992839333"/>
- <array class="NSMutableArray" key="children">
- <reference ref="959555182"/>
- </array>
- <reference key="parent" ref="184765684"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300363</int>
- <reference key="object" ref="959555182"/>
- <reference key="parent" ref="992839333"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300364</int>
- <reference key="object" ref="138261120"/>
- <array class="NSMutableArray" key="children">
- <reference ref="183409141"/>
- </array>
- <reference key="parent" ref="184765684"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300365</int>
- <reference key="object" ref="183409141"/>
- <reference key="parent" ref="138261120"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300368</int>
- <reference key="object" ref="128352289"/>
- <array class="NSMutableArray" key="children">
- <reference ref="556463187"/>
- </array>
- <reference key="parent" ref="184765684"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300369</int>
- <reference key="object" ref="556463187"/>
- <reference key="parent" ref="128352289"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300370</int>
- <reference key="object" ref="57161931"/>
- <array class="NSMutableArray" key="children">
- <reference ref="989804990"/>
- </array>
- <reference key="parent" ref="184765684"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300371</int>
- <reference key="object" ref="989804990"/>
- <reference key="parent" ref="57161931"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300421</int>
- <reference key="object" ref="723450037"/>
- <array class="NSMutableArray" key="children">
- <reference ref="408298283"/>
- </array>
- <reference key="parent" ref="448510093"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300422</int>
- <reference key="object" ref="408298283"/>
- <array class="NSMutableArray" key="children">
- <reference ref="878106058"/>
- <reference ref="386152084"/>
- <reference ref="487809555"/>
- <reference ref="620944856"/>
- <reference ref="477050998"/>
- <reference ref="765780304"/>
- <reference ref="1002778833"/>
- <reference ref="522511724"/>
- </array>
- <reference key="parent" ref="723450037"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300423</int>
- <reference key="object" ref="386152084"/>
- <array class="NSMutableArray" key="children">
- <reference ref="572508492"/>
- </array>
- <reference key="parent" ref="408298283"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300424</int>
- <reference key="object" ref="878106058"/>
- <array class="NSMutableArray" key="children">
- <reference ref="718083688"/>
- </array>
- <reference key="parent" ref="408298283"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300440</int>
- <reference key="object" ref="718083688"/>
- <reference key="parent" ref="878106058"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300441</int>
- <reference key="object" ref="572508492"/>
- <reference key="parent" ref="386152084"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300447</int>
- <reference key="object" ref="477050998"/>
- <array class="NSMutableArray" key="children">
- <reference ref="501304422"/>
- </array>
- <reference key="parent" ref="408298283"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300450</int>
- <reference key="object" ref="501304422"/>
- <reference key="parent" ref="477050998"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300451</int>
- <reference key="object" ref="765780304"/>
- <array class="NSMutableArray" key="children">
- <reference ref="510771323"/>
- </array>
- <reference key="parent" ref="408298283"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300452</int>
- <reference key="object" ref="510771323"/>
- <reference key="parent" ref="765780304"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300453</int>
- <reference key="object" ref="487809555"/>
- <array class="NSMutableArray" key="children">
- <reference ref="619977658"/>
- </array>
- <reference key="parent" ref="408298283"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300454</int>
- <reference key="object" ref="619977658"/>
- <reference key="parent" ref="487809555"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300455</int>
- <reference key="object" ref="620944856"/>
- <array class="NSMutableArray" key="children">
- <reference ref="461823902"/>
- </array>
- <reference key="parent" ref="408298283"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300456</int>
- <reference key="object" ref="461823902"/>
- <reference key="parent" ref="620944856"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300457</int>
- <reference key="object" ref="1002778833"/>
- <array class="NSMutableArray" key="children">
- <reference ref="897099877"/>
- </array>
- <reference key="parent" ref="408298283"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300458</int>
- <reference key="object" ref="897099877"/>
- <reference key="parent" ref="1002778833"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300459</int>
- <reference key="object" ref="522511724"/>
- <array class="NSMutableArray" key="children">
- <reference ref="994587858"/>
- </array>
- <reference key="parent" ref="408298283"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300460</int>
- <reference key="object" ref="994587858"/>
- <reference key="parent" ref="522511724"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300472</int>
- <reference key="object" ref="57246850"/>
- <array class="NSMutableArray" key="children">
- <reference ref="917248662"/>
- </array>
- <reference key="parent" ref="515308735"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300473</int>
- <reference key="object" ref="917248662"/>
- <reference key="parent" ref="57246850"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300476</int>
- <reference key="object" ref="278155937"/>
- <array class="NSMutableArray" key="children">
- <reference ref="617441821"/>
- </array>
- <reference key="parent" ref="596750588"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300477</int>
- <reference key="object" ref="406291430"/>
- <array class="NSMutableArray" key="children">
- <reference ref="67728988"/>
- </array>
- <reference key="parent" ref="596750588"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300478</int>
- <reference key="object" ref="67728988"/>
- <reference key="parent" ref="406291430"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300479</int>
- <reference key="object" ref="617441821"/>
- <reference key="parent" ref="278155937"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300482</int>
- <reference key="object" ref="863505041"/>
- <array class="NSMutableArray" key="children">
- <reference ref="1016286396"/>
- </array>
- <reference key="parent" ref="596750588"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300483</int>
- <reference key="object" ref="1016286396"/>
- <reference key="parent" ref="863505041"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300487</int>
- <reference key="object" ref="331853183"/>
- <array class="NSMutableArray" key="children">
- <reference ref="1042813110"/>
- </array>
- <reference key="parent" ref="515308735"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">300488</int>
- <reference key="object" ref="1042813110"/>
- <reference key="parent" ref="331853183"/>
- </object>
- </array>
- </object>
- <dictionary class="NSMutableDictionary" key="flattenedProperties">
- <string key="-3.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="-3.ImportedFromIB2"/>
- <string key="100292.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100293.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100295.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="100295.IBShouldRemoveOnLegacySave"/>
- <string key="100310.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100363.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100364.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100365.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100368.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100369.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100370.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100374.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100375.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100376.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100377.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100379.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100382.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100385.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100386.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100541.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="100543.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="129.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="129.ImportedFromIB2"/>
- <string key="130.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="130.ImportedFromIB2"/>
- <string key="131.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="131.ImportedFromIB2"/>
- <string key="134.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="134.ImportedFromIB2"/>
- <string key="136.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="136.ImportedFromIB2"/>
- <string key="143.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="143.ImportedFromIB2"/>
- <string key="144.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="144.ImportedFromIB2"/>
- <string key="145.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="145.ImportedFromIB2"/>
- <string key="149.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="149.ImportedFromIB2"/>
- <string key="150.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="150.ImportedFromIB2"/>
- <string key="157.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="157.ImportedFromIB2"/>
- <string key="163.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="163.ImportedFromIB2"/>
- <string key="169.IBEditorWindowLastContentRect">{{168, 821}, {113, 23}}</string>
- <string key="169.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="169.ImportedFromIB2"/>
- <string key="169.editorWindowContentRectSynchronizationRect">{{202, 626}, {154, 153}}</string>
- <string key="19.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="19.ImportedFromIB2"/>
- <integer value="1" key="196.ImportedFromIB2"/>
- <string key="200295.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="200295.IBShouldRemoveOnLegacySave"/>
- <string key="203.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="203.ImportedFromIB2"/>
- <string key="204.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="204.ImportedFromIB2"/>
- <string key="23.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="23.ImportedFromIB2"/>
- <string key="24.IBEditorWindowLastContentRect">{{349, 868}, {315, 143}}</string>
- <string key="24.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="24.ImportedFromIB2"/>
- <string key="24.editorWindowContentRectSynchronizationRect">{{271, 666}, {301, 153}}</string>
- <string key="244.IBEditorWindowLastContentRect">{{507, 515}, {584, 341}}</string>
- <string key="244.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <boolean value="YES" key="244.IBViewEditorWindowController.showingLayoutRectangles"/>
- <string key="244.IBWindowTemplateEditedContentRect">{{507, 515}, {584, 341}}</string>
- <integer value="1" key="244.ImportedFromIB2"/>
- <string key="244.editorWindowContentRectSynchronizationRect">{{184, 290}, {481, 345}}</string>
- <boolean value="YES" key="244.windowTemplate.hasMinSize"/>
- <string key="244.windowTemplate.maxSize">{1.7976931348623157e+308, 1.7976931348623157e+308}</string>
- <string key="244.windowTemplate.minSize">{320, 240}</string>
- <string key="245.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="245.ImportedFromIB2"/>
- <string key="269.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="269.ImportedFromIB2"/>
- <string key="270.IBEditorWindowLastContentRect">{{58, 803}, {155, 33}}</string>
- <string key="270.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="270.ImportedFromIB2"/>
- <string key="270.editorWindowContentRectSynchronizationRect">{{100, 746}, {155, 33}}</string>
- <string key="272.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="272.ImportedFromIB2"/>
- <string key="285.IBEditorWindowLastContentRect">{{68, 585}, {454, 271}}</string>
- <string key="285.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="285.IBViewEditorWindowController.showingBoundsRectangles"/>
- <integer value="1" key="285.IBViewEditorWindowController.showingLayoutRectangles"/>
- <string key="285.IBWindowTemplateEditedContentRect">{{68, 585}, {454, 271}}</string>
- <integer value="1" key="285.ImportedFromIB2"/>
- <string key="285.editorWindowContentRectSynchronizationRect">{{433, 406}, {486, 327}}</string>
- <boolean value="YES" key="285.windowTemplate.hasMinSize"/>
- <string key="285.windowTemplate.maxSize">{1.7976931348623157e+308, 1.7976931348623157e+308}</string>
- <string key="285.windowTemplate.minSize">{454, 271}</string>
- <string key="286.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="286.ImportedFromIB2"/>
- <string key="29.IBEditorWindowLastContentRect">{{145, 1011}, {336, 20}}</string>
- <string key="29.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="29.ImportedFromIB2"/>
- <string key="29.editorWindowContentRectSynchronizationRect">{{67, 819}, {336, 20}}</string>
- <string key="292.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="292.ImportedFromIB2"/>
- <string key="293.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="293.ImportedFromIB2"/>
- <string key="295.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="295.ImportedFromIB2"/>
- <string key="296.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="296.ImportedFromIB2"/>
- <string key="297.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="297.ImportedFromIB2"/>
- <string key="298.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="298.ImportedFromIB2"/>
- <string key="300295.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300295.IBShouldRemoveOnLegacySave"/>
- <string key="300337.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300337.ImportedFromIB2"/>
- <string key="300338.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300338.ImportedFromIB2"/>
- <string key="300358.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300358.ImportedFromIB2"/>
- <string key="300359.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300359.ImportedFromIB2"/>
- <string key="300360.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300361.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300362.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300362.ImportedFromIB2"/>
- <string key="300363.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300364.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300364.ImportedFromIB2"/>
- <string key="300365.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300368.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300368.ImportedFromIB2"/>
- <string key="300369.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300370.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300370.ImportedFromIB2"/>
- <string key="300371.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300421.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300421.ImportedFromIB2"/>
- <string key="300422.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300422.ImportedFromIB2"/>
- <string key="300423.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300423.ImportedFromIB2"/>
- <string key="300424.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300424.ImportedFromIB2"/>
- <string key="300440.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300441.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300447.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300447.ImportedFromIB2"/>
- <string key="300450.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300451.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300451.ImportedFromIB2"/>
- <string key="300452.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300453.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300453.ImportedFromIB2"/>
- <string key="300454.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300455.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300455.ImportedFromIB2"/>
- <string key="300456.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300457.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300457.ImportedFromIB2"/>
- <string key="300458.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300459.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300459.ImportedFromIB2"/>
- <string key="300460.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300472.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300472.ImportedFromIB2"/>
- <string key="300473.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300476.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300476.ImportedFromIB2"/>
- <string key="300477.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300477.ImportedFromIB2"/>
- <string key="300478.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300479.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300482.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300482.ImportedFromIB2"/>
- <string key="300483.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="300487.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="300487.ImportedFromIB2"/>
- <string key="300488.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="305.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="305.ImportedFromIB2"/>
- <string key="310.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="310.ImportedFromIB2"/>
- <string key="348.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="348.ImportedFromIB2"/>
- <string key="349.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="349.ImportedFromIB2"/>
- <string key="350.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="350.ImportedFromIB2"/>
- <string key="351.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="351.ImportedFromIB2"/>
- <string key="352.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="352.ImportedFromIB2"/>
- <string key="353.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="353.ImportedFromIB2"/>
- <string key="354.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="354.ImportedFromIB2"/>
- <string key="363.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="363.ImportedFromIB2"/>
- <string key="364.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="364.ImportedFromIB2"/>
- <string key="365.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="365.ImportedFromIB2"/>
- <string key="368.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="368.ImportedFromIB2"/>
- <string key="369.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="369.ImportedFromIB2"/>
- <string key="370.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="370.ImportedFromIB2"/>
- <string key="374.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="374.ImportedFromIB2"/>
- <string key="375.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="375.ImportedFromIB2"/>
- <string key="376.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="376.ImportedFromIB2"/>
- <string key="377.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="377.ImportedFromIB2"/>
- <string key="379.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="379.ImportedFromIB2"/>
- <string key="380.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="380.ImportedFromIB2"/>
- <string key="381.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="381.ImportedFromIB2"/>
- <string key="382.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="382.ImportedFromIB2"/>
- <string key="383.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="383.ImportedFromIB2"/>
- <string key="384.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="384.ImportedFromIB2"/>
- <string key="385.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="385.ImportedFromIB2"/>
- <string key="386.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="386.ImportedFromIB2"/>
- <string key="419.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="419.ImportedFromIB2"/>
- <string key="420.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="420.ImportedFromIB2"/>
- <string key="421.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="421.ImportedFromIB2"/>
- <string key="423.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="423.ImportedFromIB2"/>
- <string key="435.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="435.ImportedFromIB2"/>
- <string key="5.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="5.ImportedFromIB2"/>
- <string key="524.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="524.ImportedFromIB2"/>
- <string key="526.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="526.ImportedFromIB2"/>
- <string key="527.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="527.ImportedFromIB2"/>
- <string key="532.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="532.ImportedFromIB2"/>
- <string key="533.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="533.ImportedFromIB2"/>
- <string key="535.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="535.ImportedFromIB2"/>
- <string key="536.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="536.ImportedFromIB2"/>
- <string key="537.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="537.ImportedFromIB2"/>
- <string key="538.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="538.ImportedFromIB2"/>
- <string key="541.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="541.ImportedFromIB2"/>
- <string key="543.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="543.ImportedFromIB2"/>
- <string key="544.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="544.ImportedFromIB2"/>
- <string key="545.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="545.ImportedFromIB2"/>
- <string key="56.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="56.ImportedFromIB2"/>
- <string key="57.IBEditorWindowLastContentRect">{{20, 641}, {218, 203}}</string>
- <string key="57.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="57.ImportedFromIB2"/>
- <string key="57.editorWindowContentRectSynchronizationRect">{{79, 616}, {218, 203}}</string>
- <string key="573.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="573.ImportedFromIB2"/>
- <string key="574.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="574.ImportedFromIB2"/>
- <string key="575.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="575.ImportedFromIB2"/>
- <string key="58.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="58.ImportedFromIB2"/>
- <string key="92.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <integer value="1" key="92.ImportedFromIB2"/>
- </dictionary>
- <dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
- <nil key="activeLocalization"/>
- <dictionary class="NSMutableDictionary" key="localizations"/>
- <nil key="sourceID"/>
- <int key="maxID">300490</int>
- </object>
- <object class="IBClassDescriber" key="IBDocument.Classes"/>
- <int key="IBDocument.localizationMode">0</int>
- <string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
- <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencies">
- <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string>
- <integer value="1040" key="NS.object.0"/>
- </object>
- <bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
- <nil key="IBDocument.LastKnownRelativeProjectPath"/>
- <int key="IBDocument.defaultPropertyAccessControl">3</int>
- <dictionary class="NSMutableDictionary" key="IBDocument.LastKnownImageSizes">
- <string key="NSMenuCheckmark">{9, 8}</string>
- <string key="NSMenuMixedState">{7, 2}</string>
- <string key="NSSwitch">{15, 15}</string>
- </dictionary>
- </data>
-</archive>
+<?xml version="1.0" encoding="UTF-8"?>
+<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00">
+ <data>
+ <int key="IBDocument.SystemTarget">1040</int>
+ <string key="IBDocument.SystemVersion">11A289</string>
+ <string key="IBDocument.InterfaceBuilderVersion">903</string>
+ <string key="IBDocument.AppKitVersion">1094.2</string>
+ <string key="IBDocument.HIToolboxVersion">521.00</string>
+ <object class="NSMutableDictionary" key="IBDocument.PluginVersions">
+ <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="NS.object.0">903</string>
+ </object>
+ <array class="NSMutableArray" key="IBDocument.EditedObjectIDs"/>
+ <array key="IBDocument.PluginDependencies">
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ </array>
+ <object class="NSMutableDictionary" key="IBDocument.Metadata">
+ <string key="NS.key.0">PluginDependencyRecalculationVersion</string>
+ <integer value="1" key="NS.object.0"/>
+ </object>
+ <array class="NSMutableArray" key="IBDocument.RootObjects" id="904585544">
+ <object class="NSCustomObject" id="815810918">
+ <object class="NSMutableString" key="NSClassName">
+ <characters key="NS.bytes">NSApplication</characters>
+ </object>
+ </object>
+ <object class="NSCustomObject" id="941939442">
+ <string key="NSClassName">FirstResponder</string>
+ </object>
+ <object class="NSCustomObject" id="951368722">
+ <string key="NSClassName">NSApplication</string>
+ </object>
+ <object class="NSMenu" id="524015605">
+ <string key="NSTitle">MainMenu</string>
+ <array class="NSMutableArray" key="NSMenuItems">
+ <object class="NSMenuItem" id="365880285">
+ <reference key="NSMenu" ref="524015605"/>
+ <string key="NSTitle">X11</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <object class="NSCustomResource" key="NSOnImage" id="531645050">
+ <string key="NSClassName">NSImage</string>
+ <string key="NSResourceName">NSMenuCheckmark</string>
+ </object>
+ <object class="NSCustomResource" key="NSMixedImage" id="351811234">
+ <string key="NSClassName">NSImage</string>
+ <string key="NSResourceName">NSMenuMixedState</string>
+ </object>
+ <string key="NSAction">submenuAction:</string>
+ <object class="NSMenu" key="NSSubmenu" id="576521955">
+ <string key="NSTitle">X11</string>
+ <array class="NSMutableArray" key="NSMenuItems">
+ <object class="NSMenuItem" id="139290918">
+ <reference key="NSMenu" ref="576521955"/>
+ <string key="NSTitle">X11 について</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="386173216">
+ <reference key="NSMenu" ref="576521955"/>
+ <string key="NSTitle">環境設定...</string>
+ <string key="NSKeyEquiv">,</string>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="272876017">
+ <reference key="NSMenu" ref="576521955"/>
+ <bool key="NSIsDisabled">YES</bool>
+ <bool key="NSIsSeparator">YES</bool>
+ <string key="NSTitle"/>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="32285361">
+ <reference key="NSMenu" ref="576521955"/>
+ <string key="NSTitle">サービス</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ <string key="NSAction">submenuAction:</string>
+ <object class="NSMenu" key="NSSubmenu" id="821388474">
+ <string key="NSTitle">サービス</string>
+ <array class="NSMutableArray" key="NSMenuItems"/>
+ <string key="NSName">_NSServicesMenu</string>
+ </object>
+ </object>
+ <object class="NSMenuItem" id="431301145">
+ <reference key="NSMenu" ref="576521955"/>
+ <bool key="NSIsDisabled">YES</bool>
+ <bool key="NSIsSeparator">YES</bool>
+ <string key="NSTitle"/>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="6876565">
+ <reference key="NSMenu" ref="576521955"/>
+ <string key="NSTitle">フルスクリーンを切り替える</string>
+ <string key="NSKeyEquiv">a</string>
+ <int key="NSKeyEquivModMask">1572864</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="479677589">
+ <reference key="NSMenu" ref="576521955"/>
+ <bool key="NSIsDisabled">YES</bool>
+ <bool key="NSIsSeparator">YES</bool>
+ <string key="NSTitle"/>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="301008465">
+ <reference key="NSMenu" ref="576521955"/>
+ <string key="NSTitle">X11 を隠す</string>
+ <string key="NSKeyEquiv">h</string>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ <int key="NSTag">42</int>
+ </object>
+ <object class="NSMenuItem" id="206802571">
+ <reference key="NSMenu" ref="576521955"/>
+ <string key="NSTitle">ほかを隠す</string>
+ <string key="NSKeyEquiv">h</string>
+ <int key="NSKeyEquivModMask">1572864</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="1023546148">
+ <reference key="NSMenu" ref="576521955"/>
+ <string key="NSTitle">すべてを表示</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ <int key="NSTag">42</int>
+ </object>
+ <object class="NSMenuItem" id="848095279">
+ <reference key="NSMenu" ref="576521955"/>
+ <bool key="NSIsDisabled">YES</bool>
+ <bool key="NSIsSeparator">YES</bool>
+ <string key="NSTitle"/>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="274138642">
+ <reference key="NSMenu" ref="576521955"/>
+ <string key="NSTitle">X11 を終了</string>
+ <string key="NSKeyEquiv">q</string>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ </array>
+ <string key="NSName">_NSAppleMenu</string>
+ </object>
+ </object>
+ <object class="NSMenuItem" id="868031522">
+ <reference key="NSMenu" ref="524015605"/>
+ <string key="NSTitle">アプリケーション</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ <string key="NSAction">submenuAction:</string>
+ <object class="NSMenu" key="NSSubmenu" id="981161348">
+ <string key="NSTitle">アプリケーション</string>
+ <array class="NSMutableArray" key="NSMenuItems">
+ <object class="NSMenuItem" id="390088328">
+ <reference key="NSMenu" ref="981161348"/>
+ <bool key="NSIsDisabled">YES</bool>
+ <bool key="NSIsSeparator">YES</bool>
+ <string key="NSTitle"/>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="1065386165">
+ <reference key="NSMenu" ref="981161348"/>
+ <string key="NSTitle">カスタマイズ...</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ </array>
+ </object>
+ </object>
+ <object class="NSMenuItem" id="200491363">
+ <reference key="NSMenu" ref="524015605"/>
+ <string key="NSTitle">編集</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ <string key="NSAction">submenuAction:</string>
+ <object class="NSMenu" key="NSSubmenu" id="526778998">
+ <string key="NSTitle">編集</string>
+ <array class="NSMutableArray" key="NSMenuItems">
+ <object class="NSMenuItem" id="185296989">
+ <reference key="NSMenu" ref="526778998"/>
+ <string key="NSTitle">コピー</string>
+ <string key="NSKeyEquiv">c</string>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ </array>
+ </object>
+ </object>
+ <object class="NSMenuItem" id="931553638">
+ <reference key="NSMenu" ref="524015605"/>
+ <string key="NSTitle">ウインドウ</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ <string key="NSAction">submenuAction:</string>
+ <object class="NSMenu" key="NSSubmenu" id="96874957">
+ <string key="NSTitle">ウインドウ</string>
+ <array class="NSMutableArray" key="NSMenuItems">
+ <object class="NSMenuItem" id="984461797">
+ <reference key="NSMenu" ref="96874957"/>
+ <string key="NSTitle">閉じる</string>
+ <string key="NSKeyEquiv">w</string>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="677652931">
+ <reference key="NSMenu" ref="96874957"/>
+ <string key="NSTitle">しまう</string>
+ <string key="NSKeyEquiv">m</string>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="1066447520">
+ <reference key="NSMenu" ref="96874957"/>
+ <string key="NSTitle">拡大/縮小</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="280172320">
+ <reference key="NSMenu" ref="96874957"/>
+ <bool key="NSIsDisabled">YES</bool>
+ <bool key="NSIsSeparator">YES</bool>
+ <string key="NSTitle"/>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="1036389925">
+ <reference key="NSMenu" ref="96874957"/>
+ <string key="NSTitle">ウインドウを巡回</string>
+ <string key="NSKeyEquiv"></string>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="369641893">
+ <reference key="NSMenu" ref="96874957"/>
+ <string key="NSTitle">ウインドウを逆方向に巡回</string>
+ <string key="NSKeyEquiv"></string>
+ <int key="NSKeyEquivModMask">1179648</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="155085383">
+ <reference key="NSMenu" ref="96874957"/>
+ <bool key="NSIsDisabled">YES</bool>
+ <bool key="NSIsSeparator">YES</bool>
+ <string key="NSTitle"/>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="276216762">
+ <reference key="NSMenu" ref="96874957"/>
+ <string key="NSTitle">すべてを手前に移動</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ </array>
+ <string key="NSName">_NSWindowsMenu</string>
+ </object>
+ </object>
+ <object class="NSMenuItem" id="551174276">
+ <reference key="NSMenu" ref="524015605"/>
+ <string key="NSTitle">ヘルプ</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ <string key="NSAction">submenuAction:</string>
+ <object class="NSMenu" key="NSSubmenu" id="511848303">
+ <string key="NSTitle">ヘルプ</string>
+ <array class="NSMutableArray" key="NSMenuItems">
+ <object class="NSMenuItem" id="504984881">
+ <reference key="NSMenu" ref="511848303"/>
+ <string key="NSTitle">X11 ヘルプ</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ </array>
+ </object>
+ </object>
+ </array>
+ <string key="NSName">_NSMainMenu</string>
+ </object>
+ <object class="NSCustomObject" id="485884620">
+ <string key="NSClassName">X11Controller</string>
+ </object>
+ <object class="NSWindowTemplate" id="124913468">
+ <int key="NSWindowStyleMask">3</int>
+ <int key="NSWindowBacking">2</int>
+ <string key="NSWindowRect">{{319, 328.03906000000001}, {584, 341}}</string>
+ <int key="NSWTFlags">1350041600</int>
+ <string key="NSWindowTitle">X11 の環境設定</string>
+ <string key="NSWindowClass">NSPanel</string>
+ <object class="NSMutableString" key="NSViewClass">
+ <characters key="NS.bytes">View</characters>
+ </object>
+ <nil key="NSUserInterfaceItemIdentifier"/>
+ <string key="NSWindowContentMaxSize">{1.7976931348623157e+308, 1.7976931348623157e+308}</string>
+ <string key="NSWindowContentMinSize">{320, 240}</string>
+ <object class="NSView" key="NSWindowView" id="941366957">
+ <nil key="NSNextResponder"/>
+ <int key="NSvFlags">256</int>
+ <array class="NSMutableArray" key="NSSubviews">
+ <object class="NSTabView" id="448510093">
+ <reference key="NSNextResponder" ref="941366957"/>
+ <int key="NSvFlags">274</int>
+ <string key="NSFrame">{{13, 10}, {558, 325}}</string>
+ <reference key="NSSuperview" ref="941366957"/>
+ <array class="NSMutableArray" key="NSTabViewItems">
+ <object class="NSTabViewItem" id="287591690">
+ <object class="NSMutableString" key="NSIdentifier">
+ <characters key="NS.bytes">1</characters>
+ </object>
+ <object class="NSView" key="NSView" id="596750588">
+ <reference key="NSNextResponder" ref="448510093"/>
+ <int key="NSvFlags">256</int>
+ <array class="NSMutableArray" key="NSSubviews">
+ <object class="NSButton" id="119157981">
+ <reference key="NSNextResponder" ref="596750588"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{18, 243}, {505, 18}}</string>
+ <reference key="NSSuperview" ref="596750588"/>
+ <reference key="NSNextKeyView" ref="179949713"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="990762273">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">3 ボタンマウスをエミュレート</string>
+ <object class="NSFont" key="NSSupport" id="463863101">
+ <string key="NSName">LucidaGrande</string>
+ <double key="NSSize">13</double>
+ <int key="NSfFlags">1044</int>
+ </object>
+ <reference key="NSControlView" ref="119157981"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <object class="NSCustomResource" key="NSNormalImage" id="815090595">
+ <string key="NSClassName">NSImage</string>
+ <string key="NSResourceName">NSSwitch</string>
+ </object>
+ <object class="NSButtonImageSource" key="NSAlternateImage" id="391434389">
+ <string key="NSImageName">NSSwitch</string>
+ </object>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSTextField" id="443008216">
+ <reference key="NSNextResponder" ref="596750588"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{36, 96}, {488, 28}}</string>
+ <reference key="NSSuperview" ref="596750588"/>
+ <reference key="NSNextKeyView" ref="406291430"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="391919450">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">有効にすると、メニューバーの代替キーによって X11 アプリケーションのメタ修飾キーを使用できなくなる場合があります。</string>
+ <object class="NSFont" key="NSSupport" id="26">
+ <string key="NSName">LucidaGrande</string>
+ <double key="NSSize">11</double>
+ <int key="NSfFlags">3100</int>
+ </object>
+ <string key="NSPlaceholderString"/>
+ <reference key="NSControlView" ref="443008216"/>
+ <object class="NSColor" key="NSBackgroundColor" id="57160303">
+ <int key="NSColorSpace">6</int>
+ <string key="NSCatalogName">System</string>
+ <string key="NSColorName">controlColor</string>
+ <object class="NSColor" key="NSColor" id="590688762">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes>
+ </object>
+ </object>
+ <object class="NSColor" key="NSTextColor" id="930815747">
+ <int key="NSColorSpace">6</int>
+ <string key="NSCatalogName">System</string>
+ <string key="NSColorName">controlTextColor</string>
+ <object class="NSColor" key="NSColor" id="214098874">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MAA</bytes>
+ </object>
+ </object>
+ </object>
+ </object>
+ <object class="NSTextField" id="282885445">
+ <reference key="NSNextResponder" ref="596750588"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{36, 209}, {488, 28}}</string>
+ <reference key="NSSuperview" ref="596750588"/>
+ <reference key="NSNextKeyView" ref="31160162"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="649334366">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string type="base64-UTF8" key="NSContents">T3B0aW9uIOOCreODvOOCkuaKvOOBl+OBn+OBvuOBvuOCr+ODquODg+OCr+OBmeOCi+OBqOODnuOCpuOC
+ueOBruS4reODnOOCv+ODs+aTjeS9nOOBq+OBquOCiuOAgUNvbW1hbmQg44Kt44O844KS5oq844GX44Gf
+44G+44G+44Kv44Oq44OD44Kv44GZ44KL44Go44Oe44Km44K544Gu5Y+z44Oc44K/44Oz5pON5L2c44Gr
+44Gq44KK44G+44GZ44CCCg</string>
+ <reference key="NSSupport" ref="26"/>
+ <string key="NSPlaceholderString"/>
+ <reference key="NSControlView" ref="282885445"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ <object class="NSButton" id="842100515">
+ <reference key="NSNextResponder" ref="596750588"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{18, 130}, {505, 18}}</string>
+ <reference key="NSSuperview" ref="596750588"/>
+ <reference key="NSNextKeyView" ref="443008216"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="940564599">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">X11 の代替キーを有効にする</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="842100515"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="815090595"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSTextField" id="31160162">
+ <reference key="NSNextResponder" ref="596750588"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{36, 156}, {488, 17}}</string>
+ <reference key="NSSuperview" ref="596750588"/>
+ <reference key="NSNextKeyView" ref="842100515"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="666057093">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">入力メニューを変更して現在の X11 キーマップを上書きすることを許可します。</string>
+ <reference key="NSSupport" ref="26"/>
+ <string key="NSPlaceholderString"/>
+ <reference key="NSControlView" ref="31160162"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ <object class="NSButton" id="179949713">
+ <reference key="NSNextResponder" ref="596750588"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{18, 179}, {505, 18}}</string>
+ <reference key="NSSuperview" ref="596750588"/>
+ <reference key="NSNextKeyView" ref="282885445"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="967619578">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">システムのキーボードレイアウトに従う</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="179949713"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="815090595"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSTextField" id="278155937">
+ <reference key="NSNextResponder" ref="596750588"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{36, 32}, {488, 31}}</string>
+ <reference key="NSSuperview" ref="596750588"/>
+ <reference key="NSNextKeyView" ref="863505041"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="617441821">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">有効にすると、option キー で Mode_switch の代わりに X11 キーシンボルの Alt_L と Alt_R が送信されます。 </string>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSControlView" ref="278155937"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ <object class="NSButton" id="406291430">
+ <reference key="NSNextResponder" ref="596750588"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{18, 69}, {505, 18}}</string>
+ <reference key="NSSuperview" ref="596750588"/>
+ <reference key="NSNextKeyView" ref="278155937"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="67728988">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">Option キーで Alt_L と Alt_R を送信</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="406291430"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="815090595"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSButton" id="863505041">
+ <reference key="NSNextResponder" ref="596750588"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{18, 8}, {505, 18}}</string>
+ <reference key="NSSuperview" ref="596750588"/>
+ <reference key="NSNextKeyView" ref="448510093"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="1016286396">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">常に指を動かした方向にスクロール</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="863505041"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="815090595"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ </array>
+ <string key="NSFrame">{{10, 33}, {538, 279}}</string>
+ <reference key="NSSuperview" ref="448510093"/>
+ <reference key="NSNextKeyView" ref="119157981"/>
+ </object>
+ <string key="NSLabel">入力</string>
+ <reference key="NSColor" ref="57160303"/>
+ <reference key="NSTabView" ref="448510093"/>
+ </object>
+ <object class="NSTabViewItem" id="960678392">
+ <object class="NSMutableString" key="NSIdentifier">
+ <characters key="NS.bytes">2</characters>
+ </object>
+ <object class="NSView" key="NSView" id="515308735">
+ <nil key="NSNextResponder"/>
+ <int key="NSvFlags">256</int>
+ <array class="NSMutableArray" key="NSSubviews">
+ <object class="NSPopUpButton" id="709074847">
+ <reference key="NSNextResponder" ref="515308735"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{75, 234}, {163, 26}}</string>
+ <reference key="NSSuperview" ref="515308735"/>
+ <reference key="NSNextKeyView" ref="86150604"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSPopUpButtonCell" key="NSCell" id="633115429">
+ <int key="NSCellFlags">-2076049856</int>
+ <int key="NSCellFlags2">1024</int>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="709074847"/>
+ <int key="NSButtonFlags">109199615</int>
+ <int key="NSButtonFlags2">1</int>
+ <object class="NSFont" key="NSAlternateImage">
+ <string key="NSName">LucidaGrande</string>
+ <double key="NSSize">13</double>
+ <int key="NSfFlags">16</int>
+ </object>
+ <string key="NSAlternateContents"/>
+ <object class="NSMutableString" key="NSKeyEquivalent">
+ <characters key="NS.bytes"/>
+ </object>
+ <int key="NSPeriodicDelay">400</int>
+ <int key="NSPeriodicInterval">75</int>
+ <object class="NSMenuItem" key="NSMenuItem" id="616492372">
+ <reference key="NSMenu" ref="341113515"/>
+ <string key="NSTitle">ディスプレイから</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <int key="NSState">1</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ <string key="NSAction">_popUpItemAction:</string>
+ <int key="NSTag">-1</int>
+ <reference key="NSTarget" ref="633115429"/>
+ </object>
+ <bool key="NSMenuItemRespectAlignment">YES</bool>
+ <object class="NSMenu" key="NSMenu" id="341113515">
+ <object class="NSMutableString" key="NSTitle">
+ <characters key="NS.bytes">OtherViews</characters>
+ </object>
+ <array class="NSMutableArray" key="NSMenuItems">
+ <reference ref="616492372"/>
+ <object class="NSMenuItem" id="759499526">
+ <reference key="NSMenu" ref="341113515"/>
+ <string key="NSTitle">256 色</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ <string key="NSAction">_popUpItemAction:</string>
+ <int key="NSTag">8</int>
+ <reference key="NSTarget" ref="633115429"/>
+ </object>
+ <object class="NSMenuItem" id="543935434">
+ <reference key="NSMenu" ref="341113515"/>
+ <string key="NSTitle">約 32000 色</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ <string key="NSAction">_popUpItemAction:</string>
+ <int key="NSTag">15</int>
+ <reference key="NSTarget" ref="633115429"/>
+ </object>
+ <object class="NSMenuItem" id="836673018">
+ <reference key="NSMenu" ref="341113515"/>
+ <string key="NSTitle">約 1670 万色</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ <string key="NSAction">_popUpItemAction:</string>
+ <int key="NSTag">24</int>
+ <reference key="NSTarget" ref="633115429"/>
+ </object>
+ </array>
+ </object>
+ <int key="NSPreferredEdge">3</int>
+ <bool key="NSUsesItemFromMenu">YES</bool>
+ <bool key="NSAltersState">YES</bool>
+ <int key="NSArrowPosition">1</int>
+ </object>
+ </object>
+ <object class="NSTextField" id="201731424">
+ <reference key="NSNextResponder" ref="515308735"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{17, 238}, {56, 19}}</string>
+ <reference key="NSSuperview" ref="515308735"/>
+ <reference key="NSNextKeyView" ref="709074847"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="930265681">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">カラー:</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <string key="NSPlaceholderString"/>
+ <reference key="NSControlView" ref="201731424"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ <object class="NSTextField" id="86150604">
+ <reference key="NSNextResponder" ref="515308735"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{36, 216}, {488, 14}}</string>
+ <reference key="NSSuperview" ref="515308735"/>
+ <reference key="NSNextKeyView" ref="477203622"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="311969422">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">このオプションは、次回 X11 を起動したときに有効になります。</string>
+ <reference key="NSSupport" ref="26"/>
+ <string key="NSPlaceholderString"/>
+ <reference key="NSControlView" ref="86150604"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ <object class="NSButton" id="477203622">
+ <reference key="NSNextResponder" ref="515308735"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{18, 182}, {505, 23}}</string>
+ <reference key="NSSuperview" ref="515308735"/>
+ <reference key="NSNextKeyView" ref="298603383"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="631531164">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">フルスクリーンモード</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="477203622"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="815090595"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSButton" id="57246850">
+ <reference key="NSNextResponder" ref="515308735"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{37, 118}, {492, 23}}</string>
+ <reference key="NSSuperview" ref="515308735"/>
+ <reference key="NSNextKeyView" ref="331853183"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="917248662">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">フルスクリーンモード時のメニューバーへのアクセスを許可</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="57246850"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="815090595"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSTextField" id="298603383">
+ <reference key="NSNextResponder" ref="515308735"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{36, 147}, {494, 28}}</string>
+ <reference key="NSSuperview" ref="515308735"/>
+ <reference key="NSNextKeyView" ref="57246850"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="761107402">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">X11 のルートウインドウを有効にします。フルスクリーンモードに切り替えたり、フルスクリーンモードを終了するときは、コマンド + Option + A キーを押します。</string>
+ <reference key="NSSupport" ref="26"/>
+ <string key="NSPlaceholderString"/>
+ <reference key="NSControlView" ref="298603383"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ <object class="NSTextField" id="331853183">
+ <reference key="NSNextResponder" ref="515308735"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{54, 70}, {476, 42}}</string>
+ <reference key="NSSuperview" ref="515308735"/>
+ <reference key="NSNextKeyView" ref="448510093"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="1042813110">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">マウスカーソルが主ディスプレイの一番上に置かれたときにメニューバーが表示されます。</string>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSControlView" ref="331853183"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ </array>
+ <string key="NSFrame">{{10, 33}, {538, 279}}</string>
+ <reference key="NSNextKeyView" ref="201731424"/>
+ </object>
+ <string key="NSLabel">出力</string>
+ <reference key="NSColor" ref="57160303"/>
+ <reference key="NSTabView" ref="448510093"/>
+ </object>
+ <object class="NSTabViewItem" id="723450037">
+ <object class="NSMutableString" key="NSIdentifier">
+ <characters key="NS.bytes">2</characters>
+ </object>
+ <object class="NSView" key="NSView" id="408298283">
+ <nil key="NSNextResponder"/>
+ <int key="NSvFlags">256</int>
+ <array class="NSMutableArray" key="NSSubviews">
+ <object class="NSButton" id="878106058">
+ <reference key="NSNextResponder" ref="408298283"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{18, 255}, {505, 23}}</string>
+ <reference key="NSSuperview" ref="408298283"/>
+ <reference key="NSNextKeyView" ref="386152084"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="718083688">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">同期を有効にする</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="878106058"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="815090595"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSTextField" id="386152084">
+ <reference key="NSNextResponder" ref="408298283"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{36, 221}, {488, 28}}</string>
+ <reference key="NSSuperview" ref="408298283"/>
+ <reference key="NSNextKeyView" ref="487809555"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="572508492">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">“コピー”メニュー項目を有効にして、OSX のペーストボードと X11 の CLIPBOARD バッファおよび PRIMARY バッファを同期できるようにします。</string>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSControlView" ref="386152084"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ <object class="NSButton" id="477050998">
+ <reference key="NSNextResponder" ref="408298283"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{34, 129}, {489, 18}}</string>
+ <reference key="NSSuperview" ref="408298283"/>
+ <reference key="NSNextKeyView" ref="765780304"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="501304422">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">ペーストボードが変更されたときに CLIPBOARD をアップデート</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="477050998"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="815090595"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSButton" id="765780304">
+ <reference key="NSNextResponder" ref="408298283"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{34, 104}, {489, 18}}</string>
+ <reference key="NSSuperview" ref="408298283"/>
+ <reference key="NSNextKeyView" ref="1002778833"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="510771323">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">ペーストボードが変更されたときに PRIMARY (中クリック)をアップデート</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="765780304"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="815090595"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSButton" id="1002778833">
+ <reference key="NSNextResponder" ref="408298283"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{34, 79}, {489, 18}}</string>
+ <reference key="NSSuperview" ref="408298283"/>
+ <reference key="NSNextKeyView" ref="522511724"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="897099877">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">新しいテキストが選択されたら、すぐにペーストボードをアップデート</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="1002778833"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="815090595"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSButton" id="487809555">
+ <reference key="NSNextResponder" ref="408298283"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{34, 192}, {489, 18}}</string>
+ <reference key="NSSuperview" ref="408298283"/>
+ <reference key="NSNextKeyView" ref="620944856"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="619977658">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">CLIPBOARD が変更されたときにペーストボードをアップデート</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="487809555"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="815090595"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSTextField" id="620944856">
+ <reference key="NSNextResponder" ref="408298283"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{48, 158}, {476, 28}}</string>
+ <reference key="NSSuperview" ref="408298283"/>
+ <reference key="NSNextKeyView" ref="477050998"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="461823902">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">xclipboard、klipper、その他の X11 クリップボードマネージャを使用したい場合は、このオプションを無効にしてください。</string>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSControlView" ref="620944856"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ <object class="NSTextField" id="522511724">
+ <reference key="NSNextResponder" ref="408298283"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{48, 47}, {476, 28}}</string>
+ <reference key="NSSuperview" ref="408298283"/>
+ <reference key="NSNextKeyView" ref="448510093"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="994587858">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">X11 プロトコルの制限により、このオプションは、一部のアプリケーションで機能しない場合があります。</string>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSControlView" ref="522511724"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ </array>
+ <string key="NSFrame">{{10, 33}, {538, 279}}</string>
+ <reference key="NSNextKeyView" ref="878106058"/>
+ </object>
+ <string key="NSLabel">ペーストボード</string>
+ <reference key="NSColor" ref="57160303"/>
+ <reference key="NSTabView" ref="448510093"/>
+ </object>
+ <object class="NSTabViewItem" id="10973343">
+ <object class="NSMutableString" key="NSIdentifier">
+ <characters key="NS.bytes">2</characters>
+ </object>
+ <object class="NSView" key="NSView" id="184765684">
+ <nil key="NSNextResponder"/>
+ <int key="NSvFlags">256</int>
+ <array class="NSMutableArray" key="NSSubviews">
+ <object class="NSButton" id="657659108">
+ <reference key="NSNextResponder" ref="184765684"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{15, 245}, {508, 18}}</string>
+ <reference key="NSSuperview" ref="184765684"/>
+ <reference key="NSNextKeyView" ref="290578835"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="259618205">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">選択されていないウインドウを直接クリック</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="657659108"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="815090595"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSTextField" id="290578835">
+ <reference key="NSNextResponder" ref="184765684"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{23, 211}, {501, 28}}</string>
+ <reference key="NSSuperview" ref="184765684"/>
+ <reference key="NSNextKeyView" ref="992839333"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="399127858">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">有効にした場合、選択されていないウインドウをクリックしたときに、そのウインドウを一番手前に表示するだけでなく、ウインドウ内の項目を直接クリックします。</string>
+ <reference key="NSSupport" ref="26"/>
+ <string key="NSPlaceholderString"/>
+ <reference key="NSControlView" ref="290578835"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ <object class="NSButton" id="992839333">
+ <reference key="NSNextResponder" ref="184765684"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{15, 184}, {508, 18}}</string>
+ <reference key="NSSuperview" ref="184765684"/>
+ <reference key="NSNextKeyView" ref="138261120"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="959555182">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">フォーカスをマウスと一緒に移動</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="992839333"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="815090595"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSTextField" id="138261120">
+ <reference key="NSNextResponder" ref="184765684"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{23, 164}, {501, 14}}</string>
+ <reference key="NSSuperview" ref="184765684"/>
+ <reference key="NSNextKeyView" ref="128352289"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="183409141">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">X11 ウインドウのフォーカスがカーソルと一緒に移動します。逆効果になる場合もあります。</string>
+ <reference key="NSSupport" ref="26"/>
+ <string key="NSPlaceholderString"/>
+ <reference key="NSControlView" ref="138261120"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ <object class="NSButton" id="128352289">
+ <reference key="NSNextResponder" ref="184765684"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{15, 140}, {508, 18}}</string>
+ <reference key="NSSuperview" ref="184765684"/>
+ <reference key="NSNextKeyView" ref="57161931"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="556463187">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">新規ウインドウにフォーカス</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="128352289"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="815090595"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSTextField" id="57161931">
+ <reference key="NSNextResponder" ref="184765684"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{23, 106}, {501, 28}}</string>
+ <reference key="NSSuperview" ref="184765684"/>
+ <reference key="NSNextKeyView" ref="448510093"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="989804990">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">有効にした場合、新しい X11 ウインドウを作成すると、Finder.app や ターミナル.app などの代わりに、X11.app が前面に移動します。</string>
+ <reference key="NSSupport" ref="26"/>
+ <string key="NSPlaceholderString"/>
+ <reference key="NSControlView" ref="57161931"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ </array>
+ <string key="NSFrame">{{10, 33}, {538, 279}}</string>
+ <reference key="NSNextKeyView" ref="657659108"/>
+ </object>
+ <string key="NSLabel">ウインドウ</string>
+ <reference key="NSColor" ref="57160303"/>
+ <reference key="NSTabView" ref="448510093"/>
+ </object>
+ <object class="NSTabViewItem" id="348328898">
+ <object class="NSView" key="NSView" id="300811574">
+ <nil key="NSNextResponder"/>
+ <int key="NSvFlags">256</int>
+ <array class="NSMutableArray" key="NSSubviews">
+ <object class="NSButton" id="989050925">
+ <reference key="NSNextResponder" ref="300811574"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{18, 243}, {482, 18}}</string>
+ <reference key="NSSuperview" ref="300811574"/>
+ <reference key="NSNextKeyView" ref="168436707"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="189594322">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">接続を認証</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="989050925"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="815090595"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSButton" id="700826966">
+ <reference key="NSNextResponder" ref="300811574"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{18, 180}, {402, 18}}</string>
+ <reference key="NSSuperview" ref="300811574"/>
+ <reference key="NSNextKeyView" ref="363817195"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="489340979">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">ネットワーク・クライアントからの接続を許可</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="700826966"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">2</int>
+ <reference key="NSNormalImage" ref="815090595"/>
+ <reference key="NSAlternateImage" ref="391434389"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSTextField" id="168436707">
+ <reference key="NSNextResponder" ref="300811574"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{36, 209}, {488, 28}}</string>
+ <reference key="NSSuperview" ref="300811574"/>
+ <reference key="NSNextKeyView" ref="700826966"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="53243865">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">X11 の起動時に、Xauthority アクセス制御キーを作成します。システムの IP アドレスが変更されると、これらのキーが無効になり、X11 アプリケーションが起動しなくなることがあります。</string>
+ <reference key="NSSupport" ref="26"/>
+ <string key="NSPlaceholderString"/>
+ <reference key="NSControlView" ref="168436707"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ <object class="NSTextField" id="363817195">
+ <reference key="NSNextResponder" ref="300811574"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{36, 132}, {488, 42}}</string>
+ <reference key="NSSuperview" ref="300811574"/>
+ <reference key="NSNextKeyView" ref="223835729"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="390084685">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">有効にする場合は、システムのセキュリティを維持するために、“接続を認証”も有効にしてください。無効にすると、リモートアプリケーションからの接続は拒否されます。</string>
+ <reference key="NSSupport" ref="26"/>
+ <string key="NSPlaceholderString"/>
+ <reference key="NSControlView" ref="363817195"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ <object class="NSTextField" id="223835729">
+ <reference key="NSNextResponder" ref="300811574"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{17, 17}, {404, 14}}</string>
+ <reference key="NSSuperview" ref="300811574"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="283628678">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">4194304</int>
+ <string key="NSContents">これらのオプションは、次回 X11 を起動したときに有効になります。</string>
+ <reference key="NSSupport" ref="26"/>
+ <string key="NSPlaceholderString"/>
+ <reference key="NSControlView" ref="223835729"/>
+ <reference key="NSBackgroundColor" ref="57160303"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ </object>
+ </array>
+ <string key="NSFrame">{{10, 33}, {538, 279}}</string>
+ <reference key="NSNextKeyView" ref="989050925"/>
+ </object>
+ <string key="NSLabel">セキュリティ</string>
+ <reference key="NSColor" ref="57160303"/>
+ <reference key="NSTabView" ref="448510093"/>
+ </object>
+ </array>
+ <reference key="NSSelectedTabViewItem" ref="287591690"/>
+ <reference key="NSFont" ref="463863101"/>
+ <int key="NSTvFlags">0</int>
+ <bool key="NSAllowTruncatedLabels">YES</bool>
+ <bool key="NSDrawsBackground">YES</bool>
+ <array class="NSMutableArray" key="NSSubviews">
+ <reference ref="596750588"/>
+ </array>
+ </object>
+ </array>
+ <string key="NSFrameSize">{584, 341}</string>
+ <reference key="NSNextKeyView" ref="448510093"/>
+ </object>
+ <string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
+ <string key="NSMinSize">{320, 262}</string>
+ <string key="NSMaxSize">{1.7976931348623157e+308, 1.7976931348623157e+308}</string>
+ <string key="NSFrameAutosaveName">x11_prefs</string>
+ </object>
+ <object class="NSWindowTemplate" id="604417141">
+ <int key="NSWindowStyleMask">11</int>
+ <int key="NSWindowBacking">2</int>
+ <string key="NSWindowRect">{{360, 402}, {454, 271}}</string>
+ <int key="NSWTFlags">1350041600</int>
+ <string key="NSWindowTitle">X11 アプリケーションメニュー</string>
+ <string key="NSWindowClass">NSPanel</string>
+ <object class="NSMutableString" key="NSViewClass">
+ <characters key="NS.bytes">View</characters>
+ </object>
+ <nil key="NSUserInterfaceItemIdentifier"/>
+ <string key="NSWindowContentMaxSize">{1.7976931348623157e+308, 1.7976931348623157e+308}</string>
+ <string key="NSWindowContentMinSize">{454, 271}</string>
+ <object class="NSView" key="NSWindowView" id="85544634">
+ <nil key="NSNextResponder"/>
+ <int key="NSvFlags">256</int>
+ <array class="NSMutableArray" key="NSSubviews">
+ <object class="NSButton" id="671954382">
+ <reference key="NSNextResponder" ref="85544634"/>
+ <int key="NSvFlags">265</int>
+ <string key="NSFrame">{{340, 191}, {105, 32}}</string>
+ <reference key="NSSuperview" ref="85544634"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="143554520">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">137887744</int>
+ <string key="NSContents">複製</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="671954382"/>
+ <int key="NSButtonFlags">-2038284033</int>
+ <int key="NSButtonFlags2">1</int>
+ <object class="NSFont" key="NSAlternateImage" id="549406736">
+ <string key="NSName">Helvetica</string>
+ <double key="NSSize">13</double>
+ <int key="NSfFlags">16</int>
+ </object>
+ <string key="NSAlternateContents"/>
+ <object class="NSMutableString" key="NSKeyEquivalent">
+ <characters key="NS.bytes"/>
+ </object>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSButton" id="492358940">
+ <reference key="NSNextResponder" ref="85544634"/>
+ <int key="NSvFlags">265</int>
+ <string key="NSFrame">{{340, 159}, {105, 32}}</string>
+ <reference key="NSSuperview" ref="85544634"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="8201128">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">137887744</int>
+ <string key="NSContents">削除</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="492358940"/>
+ <int key="NSButtonFlags">-2038284033</int>
+ <int key="NSButtonFlags2">1</int>
+ <reference key="NSAlternateImage" ref="549406736"/>
+ <string key="NSAlternateContents"/>
+ <object class="NSMutableString" key="NSKeyEquivalent">
+ <characters key="NS.bytes"/>
+ </object>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSScrollView" id="1063387772">
+ <reference key="NSNextResponder" ref="85544634"/>
+ <int key="NSvFlags">274</int>
+ <array class="NSMutableArray" key="NSSubviews">
+ <object class="NSClipView" id="580565898">
+ <reference key="NSNextResponder" ref="1063387772"/>
+ <int key="NSvFlags">2304</int>
+ <array class="NSMutableArray" key="NSSubviews">
+ <object class="NSTableView" id="905092943">
+ <reference key="NSNextResponder" ref="580565898"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrameSize">{301, 198}</string>
+ <reference key="NSSuperview" ref="580565898"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTableHeaderView" key="NSHeaderView" id="792419186">
+ <reference key="NSNextResponder" ref="672307654"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrameSize">{301, 17}</string>
+ <reference key="NSSuperview" ref="672307654"/>
+ <reference key="NSTableView" ref="905092943"/>
+ </object>
+ <object class="_NSCornerView" key="NSCornerView" id="898633680">
+ <reference key="NSNextResponder" ref="1063387772"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{302, 0}, {16, 17}}</string>
+ <reference key="NSSuperview" ref="1063387772"/>
+ </object>
+ <array class="NSMutableArray" key="NSTableColumns">
+ <object class="NSTableColumn" id="938444323">
+ <double key="NSWidth">103</double>
+ <double key="NSMinWidth">43</double>
+ <double key="NSMaxWidth">1000</double>
+ <object class="NSTableHeaderCell" key="NSHeaderCell">
+ <int key="NSCellFlags">75628096</int>
+ <int key="NSCellFlags2">2048</int>
+ <string key="NSContents">名前</string>
+ <reference key="NSSupport" ref="26"/>
+ <object class="NSColor" key="NSBackgroundColor" id="113872566">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MC4zMzMzMzI5ODU2AA</bytes>
+ </object>
+ <object class="NSColor" key="NSTextColor" id="249576247">
+ <int key="NSColorSpace">6</int>
+ <string key="NSCatalogName">System</string>
+ <string key="NSColorName">headerTextColor</string>
+ <reference key="NSColor" ref="214098874"/>
+ </object>
+ </object>
+ <object class="NSTextFieldCell" key="NSDataCell" id="825378892">
+ <int key="NSCellFlags">338820672</int>
+ <int key="NSCellFlags2">1024</int>
+ <string key="NSContents">テキストセル</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <string key="NSPlaceholderString"/>
+ <reference key="NSControlView" ref="905092943"/>
+ <object class="NSColor" key="NSBackgroundColor" id="822946413">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MQA</bytes>
+ </object>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ <int key="NSResizingMask">3</int>
+ <bool key="NSIsResizeable">YES</bool>
+ <bool key="NSIsEditable">YES</bool>
+ <reference key="NSTableView" ref="905092943"/>
+ <string key="NSHeaderToolTip"/>
+ </object>
+ <object class="NSTableColumn" id="84282687">
+ <double key="NSWidth">100</double>
+ <double key="NSMinWidth">40</double>
+ <double key="NSMaxWidth">1000</double>
+ <object class="NSTableHeaderCell" key="NSHeaderCell">
+ <int key="NSCellFlags">75628096</int>
+ <int key="NSCellFlags2">2048</int>
+ <string key="NSContents">コマンド</string>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSBackgroundColor" ref="113872566"/>
+ <reference key="NSTextColor" ref="249576247"/>
+ </object>
+ <object class="NSTextFieldCell" key="NSDataCell" id="432610585">
+ <int key="NSCellFlags">338820672</int>
+ <int key="NSCellFlags2">1024</int>
+ <string key="NSContents">テキストセル</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <string key="NSPlaceholderString"/>
+ <reference key="NSControlView" ref="905092943"/>
+ <reference key="NSBackgroundColor" ref="822946413"/>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ <int key="NSResizingMask">3</int>
+ <bool key="NSIsResizeable">YES</bool>
+ <bool key="NSIsEditable">YES</bool>
+ <reference key="NSTableView" ref="905092943"/>
+ <string key="NSHeaderToolTip"/>
+ </object>
+ <object class="NSTableColumn" id="242608782">
+ <double key="NSWidth">89</double>
+ <double key="NSMinWidth">30</double>
+ <double key="NSMaxWidth">1000</double>
+ <object class="NSTableHeaderCell" key="NSHeaderCell">
+ <int key="NSCellFlags">75628096</int>
+ <int key="NSCellFlags2">2048</int>
+ <string key="NSContents">ショートカット</string>
+ <reference key="NSSupport" ref="26"/>
+ <object class="NSColor" key="NSBackgroundColor">
+ <int key="NSColorSpace">6</int>
+ <string key="NSCatalogName">System</string>
+ <string key="NSColorName">headerColor</string>
+ <reference key="NSColor" ref="822946413"/>
+ </object>
+ <reference key="NSTextColor" ref="249576247"/>
+ </object>
+ <object class="NSTextFieldCell" key="NSDataCell" id="34714764">
+ <int key="NSCellFlags">338820672</int>
+ <int key="NSCellFlags2">1024</int>
+ <string key="NSContents">テキストセル</string>
+ <object class="NSFont" key="NSSupport">
+ <string key="NSName">LucidaGrande</string>
+ <double key="NSSize">12</double>
+ <int key="NSfFlags">16</int>
+ </object>
+ <string key="NSPlaceholderString"/>
+ <reference key="NSControlView" ref="905092943"/>
+ <bool key="NSDrawsBackground">YES</bool>
+ <object class="NSColor" key="NSBackgroundColor" id="812484075">
+ <int key="NSColorSpace">6</int>
+ <string key="NSCatalogName">System</string>
+ <string key="NSColorName">controlBackgroundColor</string>
+ <reference key="NSColor" ref="590688762"/>
+ </object>
+ <reference key="NSTextColor" ref="930815747"/>
+ </object>
+ <int key="NSResizingMask">3</int>
+ <bool key="NSIsResizeable">YES</bool>
+ <bool key="NSIsEditable">YES</bool>
+ <reference key="NSTableView" ref="905092943"/>
+ <string key="NSHeaderToolTip"/>
+ </object>
+ </array>
+ <double key="NSIntercellSpacingWidth">3</double>
+ <double key="NSIntercellSpacingHeight">2</double>
+ <reference key="NSBackgroundColor" ref="822946413"/>
+ <object class="NSColor" key="NSGridColor">
+ <int key="NSColorSpace">6</int>
+ <string key="NSCatalogName">System</string>
+ <string key="NSColorName">gridColor</string>
+ <object class="NSColor" key="NSColor">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MC41AA</bytes>
+ </object>
+ </object>
+ <double key="NSRowHeight">17</double>
+ <int key="NSTvFlags">1379958784</int>
+ <reference key="NSDelegate"/>
+ <reference key="NSDataSource"/>
+ <int key="NSColumnAutoresizingStyle">1</int>
+ <int key="NSDraggingSourceMaskForLocal">-1</int>
+ <int key="NSDraggingSourceMaskForNonLocal">0</int>
+ <bool key="NSAllowsTypeSelect">YES</bool>
+ <int key="NSTableViewDraggingDestinationStyle">0</int>
+ <int key="NSTableViewGroupRowStyle">1</int>
+ </object>
+ </array>
+ <string key="NSFrame">{{1, 17}, {301, 198}}</string>
+ <reference key="NSSuperview" ref="1063387772"/>
+ <reference key="NSNextKeyView" ref="905092943"/>
+ <reference key="NSDocView" ref="905092943"/>
+ <reference key="NSBGColor" ref="812484075"/>
+ <int key="NScvFlags">4</int>
+ </object>
+ <object class="NSScroller" id="842897584">
+ <reference key="NSNextResponder" ref="1063387772"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{302, 17}, {15, 198}}</string>
+ <reference key="NSSuperview" ref="1063387772"/>
+ <reference key="NSTarget" ref="1063387772"/>
+ <string key="NSAction">_doScroller:</string>
+ <double key="NSPercent">0.99492377042770386</double>
+ </object>
+ <object class="NSScroller" id="17278747">
+ <reference key="NSNextResponder" ref="1063387772"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{1, 215}, {301, 15}}</string>
+ <reference key="NSSuperview" ref="1063387772"/>
+ <int key="NSsFlags">1</int>
+ <reference key="NSTarget" ref="1063387772"/>
+ <string key="NSAction">_doScroller:</string>
+ <double key="NSPercent">0.68852460384368896</double>
+ </object>
+ <object class="NSClipView" id="672307654">
+ <reference key="NSNextResponder" ref="1063387772"/>
+ <int key="NSvFlags">2304</int>
+ <array class="NSMutableArray" key="NSSubviews">
+ <reference ref="792419186"/>
+ </array>
+ <string key="NSFrame">{{1, 0}, {301, 17}}</string>
+ <reference key="NSSuperview" ref="1063387772"/>
+ <reference key="NSNextKeyView" ref="792419186"/>
+ <reference key="NSDocView" ref="792419186"/>
+ <reference key="NSBGColor" ref="812484075"/>
+ <int key="NScvFlags">4</int>
+ </object>
+ <reference ref="898633680"/>
+ </array>
+ <string key="NSFrame">{{20, 20}, {318, 231}}</string>
+ <reference key="NSSuperview" ref="85544634"/>
+ <reference key="NSNextKeyView" ref="580565898"/>
+ <int key="NSsFlags">133170</int>
+ <reference key="NSVScroller" ref="842897584"/>
+ <reference key="NSHScroller" ref="17278747"/>
+ <reference key="NSContentView" ref="580565898"/>
+ <reference key="NSHeaderClipView" ref="672307654"/>
+ <bytes key="NSScrollAmts">QSAAAEEgAABBmAAAQZgAAA</bytes>
+ </object>
+ <object class="NSButton" id="758204686">
+ <reference key="NSNextResponder" ref="85544634"/>
+ <int key="NSvFlags">265</int>
+ <string key="NSFrame">{{340, 223}, {105, 32}}</string>
+ <reference key="NSSuperview" ref="85544634"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="1025474039">
+ <int key="NSCellFlags">-2080244224</int>
+ <int key="NSCellFlags2">137887744</int>
+ <string key="NSContents">項目を追加</string>
+ <reference key="NSSupport" ref="463863101"/>
+ <reference key="NSControlView" ref="758204686"/>
+ <int key="NSButtonFlags">-2038284033</int>
+ <int key="NSButtonFlags2">1</int>
+ <reference key="NSAlternateImage" ref="549406736"/>
+ <string key="NSAlternateContents"/>
+ <object class="NSMutableString" key="NSKeyEquivalent">
+ <characters key="NS.bytes"/>
+ </object>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ </array>
+ <string key="NSFrameSize">{454, 271}</string>
+ </object>
+ <string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
+ <string key="NSMinSize">{454, 293}</string>
+ <string key="NSMaxSize">{1.7976931348623157e+308, 1.7976931348623157e+308}</string>
+ <string key="NSFrameAutosaveName">x11_apps</string>
+ </object>
+ <object class="NSMenu" id="294137138">
+ <string key="NSTitle">メニュー</string>
+ <array class="NSMutableArray" key="NSMenuItems">
+ <object class="NSMenuItem" id="318286212">
+ <reference key="NSMenu" ref="294137138"/>
+ <bool key="NSIsDisabled">YES</bool>
+ <bool key="NSIsSeparator">YES</bool>
+ <string key="NSTitle"/>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="511651072">
+ <reference key="NSMenu" ref="294137138"/>
+ <string key="NSTitle">アプリケーション</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ <string key="NSAction">submenuAction:</string>
+ <object class="NSMenu" key="NSSubmenu" id="48278059">
+ <string key="NSTitle">アプリケーション</string>
+ <array class="NSMutableArray" key="NSMenuItems">
+ <object class="NSMenuItem" id="563798000">
+ <reference key="NSMenu" ref="48278059"/>
+ <bool key="NSIsDisabled">YES</bool>
+ <bool key="NSIsSeparator">YES</bool>
+ <string key="NSTitle"/>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ <object class="NSMenuItem" id="1032342329">
+ <reference key="NSMenu" ref="48278059"/>
+ <string key="NSTitle">カスタマイズ...</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="531645050"/>
+ <reference key="NSMixedImage" ref="351811234"/>
+ </object>
+ </array>
+ </object>
+ </object>
+ </array>
+ <string key="NSName"/>
+ </object>
+ </array>
+ <object class="IBObjectContainer" key="IBDocument.Objects">
+ <array class="NSMutableArray" key="connectionRecords">
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">copy:</string>
+ <reference key="source" ref="941939442"/>
+ <reference key="destination" ref="185296989"/>
+ </object>
+ <int key="connectionID">181</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">minimize_window:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="677652931"/>
+ </object>
+ <int key="connectionID">202</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">close_window:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="984461797"/>
+ </object>
+ <int key="connectionID">205</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">zoom_window:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="1066447520"/>
+ </object>
+ <int key="connectionID">206</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">bring_to_front:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="276216762"/>
+ </object>
+ <int key="connectionID">207</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">hideOtherApplications:</string>
+ <reference key="source" ref="815810918"/>
+ <reference key="destination" ref="206802571"/>
+ </object>
+ <int key="connectionID">263</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">apps_separator</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="390088328"/>
+ </object>
+ <int key="connectionID">273</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">apps_table</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="905092943"/>
+ </object>
+ <int key="connectionID">301</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">apps_table_delete:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="492358940"/>
+ </object>
+ <int key="connectionID">303</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">apps_table_duplicate:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="671954382"/>
+ </object>
+ <int key="connectionID">304</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">apps_table_show:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="1065386165"/>
+ </object>
+ <int key="connectionID">308</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">apps_table_new:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="758204686"/>
+ </object>
+ <int key="connectionID">311</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_show:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="386173216"/>
+ </object>
+ <int key="connectionID">318</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">x11_about_item</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="139290918"/>
+ </object>
+ <int key="connectionID">321</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">enable_auth</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="989050925"/>
+ </object>
+ <int key="connectionID">387</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">enable_tcp</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="700826966"/>
+ </object>
+ <int key="connectionID">388</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">depth</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="709074847"/>
+ </object>
+ <int key="connectionID">389</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">fake_buttons</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="119157981"/>
+ </object>
+ <int key="connectionID">391</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">sync_keymap</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="179949713"/>
+ </object>
+ <int key="connectionID">392</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">enable_keyequivs</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="842100515"/>
+ </object>
+ <int key="connectionID">393</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="119157981"/>
+ </object>
+ <int key="connectionID">394</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="179949713"/>
+ </object>
+ <int key="connectionID">395</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="842100515"/>
+ </object>
+ <int key="connectionID">396</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="709074847"/>
+ </object>
+ <int key="connectionID">398</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="989050925"/>
+ </object>
+ <int key="connectionID">399</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="700826966"/>
+ </object>
+ <int key="connectionID">401</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">prefs_panel</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="124913468"/>
+ </object>
+ <int key="connectionID">402</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">x11_help:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="504984881"/>
+ </object>
+ <int key="connectionID">422</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">dockMenu</string>
+ <reference key="source" ref="815810918"/>
+ <reference key="destination" ref="294137138"/>
+ </object>
+ <int key="connectionID">426</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">dock_menu</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="294137138"/>
+ </object>
+ <int key="connectionID">428</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">delegate</string>
+ <reference key="source" ref="815810918"/>
+ <reference key="destination" ref="485884620"/>
+ </object>
+ <int key="connectionID">429</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">hide:</string>
+ <reference key="source" ref="815810918"/>
+ <reference key="destination" ref="301008465"/>
+ </object>
+ <int key="connectionID">430</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">unhideAllApplications:</string>
+ <reference key="source" ref="815810918"/>
+ <reference key="destination" ref="1023546148"/>
+ </object>
+ <int key="connectionID">431</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">orderFrontStandardAboutPanel:</string>
+ <reference key="source" ref="815810918"/>
+ <reference key="destination" ref="139290918"/>
+ </object>
+ <int key="connectionID">433</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">dock_apps_menu</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="48278059"/>
+ </object>
+ <int key="connectionID">530</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">dock_window_separator</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="318286212"/>
+ </object>
+ <int key="connectionID">531</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">apps_table_show:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="1032342329"/>
+ </object>
+ <int key="connectionID">534</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">next_window:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="1036389925"/>
+ </object>
+ <int key="connectionID">539</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">previous_window:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="369641893"/>
+ </object>
+ <int key="connectionID">540</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">enable_fullscreen</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="477203622"/>
+ </object>
+ <int key="connectionID">546</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">enable_fullscreen_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="477203622"/>
+ </object>
+ <int key="connectionID">547</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">toggle_fullscreen:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="6876565"/>
+ </object>
+ <int key="connectionID">548</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">toggle_fullscreen_item</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="6876565"/>
+ </object>
+ <int key="connectionID">549</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">menu</string>
+ <reference key="source" ref="815810918"/>
+ <reference key="destination" ref="524015605"/>
+ </object>
+ <int key="connectionID">300334</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">terminate:</string>
+ <reference key="source" ref="815810918"/>
+ <reference key="destination" ref="274138642"/>
+ </object>
+ <int key="connectionID">300336</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="657659108"/>
+ </object>
+ <int key="connectionID">300389</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="992839333"/>
+ </object>
+ <int key="connectionID">300390</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="128352289"/>
+ </object>
+ <int key="connectionID">300391</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">click_through</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="657659108"/>
+ </object>
+ <int key="connectionID">300392</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">focus_follows_mouse</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="992839333"/>
+ </object>
+ <int key="connectionID">300393</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">focus_on_new_window</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="128352289"/>
+ </object>
+ <int key="connectionID">300394</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">copy_menu_item</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="185296989"/>
+ </object>
+ <int key="connectionID">300443</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">sync_pasteboard</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="878106058"/>
+ </object>
+ <int key="connectionID">300444</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">sync_clipboard_to_pasteboard</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="487809555"/>
+ </object>
+ <int key="connectionID">300461</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">sync_pasteboard_to_clipboard</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="477050998"/>
+ </object>
+ <int key="connectionID">300462</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">sync_pasteboard_to_primary</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="765780304"/>
+ </object>
+ <int key="connectionID">300463</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">sync_primary_immediately</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="1002778833"/>
+ </object>
+ <int key="connectionID">300464</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="878106058"/>
+ </object>
+ <int key="connectionID">300465</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="487809555"/>
+ </object>
+ <int key="connectionID">300466</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="477050998"/>
+ </object>
+ <int key="connectionID">300467</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="765780304"/>
+ </object>
+ <int key="connectionID">300468</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="1002778833"/>
+ </object>
+ <int key="connectionID">300469</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">sync_text1</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="620944856"/>
+ </object>
+ <int key="connectionID">300470</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">sync_text2</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="522511724"/>
+ </object>
+ <int key="connectionID">300471</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">enable_fullscreen_menu</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="57246850"/>
+ </object>
+ <int key="connectionID">300474</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="57246850"/>
+ </object>
+ <int key="connectionID">300475</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="406291430"/>
+ </object>
+ <int key="connectionID">300480</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">option_sends_alt</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="406291430"/>
+ </object>
+ <int key="connectionID">300481</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">prefs_changed:</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="863505041"/>
+ </object>
+ <int key="connectionID">300484</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">enable_fullscreen_menu_text</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="331853183"/>
+ </object>
+ <int key="connectionID">300489</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">scroll_in_device_direction</string>
+ <reference key="source" ref="485884620"/>
+ <reference key="destination" ref="863505041"/>
+ </object>
+ <int key="connectionID">300490</int>
+ </object>
+ </array>
+ <object class="IBMutableOrderedSet" key="objectRecords">
+ <array key="orderedObjects">
+ <object class="IBObjectRecord">
+ <int key="objectID">0</int>
+ <array key="object" id="0"/>
+ <reference key="children" ref="904585544"/>
+ <nil key="parent"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">-2</int>
+ <reference key="object" ref="815810918"/>
+ <reference key="parent" ref="0"/>
+ <string key="objectName">File's Owner</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">-1</int>
+ <reference key="object" ref="941939442"/>
+ <reference key="parent" ref="0"/>
+ <string key="objectName">First Responder</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">-3</int>
+ <reference key="object" ref="951368722"/>
+ <reference key="parent" ref="0"/>
+ <string key="objectName">Application</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">29</int>
+ <reference key="object" ref="524015605"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="931553638"/>
+ <reference ref="365880285"/>
+ <reference ref="200491363"/>
+ <reference ref="868031522"/>
+ <reference ref="551174276"/>
+ </array>
+ <reference key="parent" ref="0"/>
+ <string key="objectName">MainMenu</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">19</int>
+ <reference key="object" ref="931553638"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="96874957"/>
+ </array>
+ <reference key="parent" ref="524015605"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">24</int>
+ <reference key="object" ref="96874957"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="677652931"/>
+ <reference ref="276216762"/>
+ <reference ref="1066447520"/>
+ <reference ref="1036389925"/>
+ <reference ref="369641893"/>
+ <reference ref="155085383"/>
+ <reference ref="984461797"/>
+ <reference ref="280172320"/>
+ </array>
+ <reference key="parent" ref="931553638"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">5</int>
+ <reference key="object" ref="276216762"/>
+ <reference key="parent" ref="96874957"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">23</int>
+ <reference key="object" ref="677652931"/>
+ <reference key="parent" ref="96874957"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">92</int>
+ <reference key="object" ref="280172320"/>
+ <reference key="parent" ref="96874957"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">203</int>
+ <reference key="object" ref="984461797"/>
+ <reference key="parent" ref="96874957"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">204</int>
+ <reference key="object" ref="1066447520"/>
+ <reference key="parent" ref="96874957"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">536</int>
+ <reference key="object" ref="155085383"/>
+ <reference key="parent" ref="96874957"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">537</int>
+ <reference key="object" ref="1036389925"/>
+ <reference key="parent" ref="96874957"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">538</int>
+ <reference key="object" ref="369641893"/>
+ <reference key="parent" ref="96874957"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">56</int>
+ <reference key="object" ref="365880285"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="576521955"/>
+ </array>
+ <reference key="parent" ref="524015605"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">57</int>
+ <reference key="object" ref="576521955"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="139290918"/>
+ <reference ref="386173216"/>
+ <reference ref="32285361"/>
+ <reference ref="301008465"/>
+ <reference ref="274138642"/>
+ <reference ref="272876017"/>
+ <reference ref="431301145"/>
+ <reference ref="206802571"/>
+ <reference ref="848095279"/>
+ <reference ref="1023546148"/>
+ <reference ref="6876565"/>
+ <reference ref="479677589"/>
+ </array>
+ <reference key="parent" ref="365880285"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">58</int>
+ <reference key="object" ref="139290918"/>
+ <reference key="parent" ref="576521955"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">129</int>
+ <reference key="object" ref="386173216"/>
+ <reference key="parent" ref="576521955"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">131</int>
+ <reference key="object" ref="32285361"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="821388474"/>
+ </array>
+ <reference key="parent" ref="576521955"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">130</int>
+ <reference key="object" ref="821388474"/>
+ <reference key="parent" ref="32285361"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">134</int>
+ <reference key="object" ref="301008465"/>
+ <reference key="parent" ref="576521955"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">136</int>
+ <reference key="object" ref="274138642"/>
+ <reference key="parent" ref="576521955"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">143</int>
+ <reference key="object" ref="272876017"/>
+ <reference key="parent" ref="576521955"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">144</int>
+ <reference key="object" ref="431301145"/>
+ <reference key="parent" ref="576521955"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">145</int>
+ <reference key="object" ref="206802571"/>
+ <reference key="parent" ref="576521955"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">149</int>
+ <reference key="object" ref="848095279"/>
+ <reference key="parent" ref="576521955"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">150</int>
+ <reference key="object" ref="1023546148"/>
+ <reference key="parent" ref="576521955"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">544</int>
+ <reference key="object" ref="6876565"/>
+ <reference key="parent" ref="576521955"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">545</int>
+ <reference key="object" ref="479677589"/>
+ <reference key="parent" ref="576521955"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">163</int>
+ <reference key="object" ref="200491363"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="526778998"/>
+ </array>
+ <reference key="parent" ref="524015605"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">169</int>
+ <reference key="object" ref="526778998"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="185296989"/>
+ </array>
+ <reference key="parent" ref="200491363"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">157</int>
+ <reference key="object" ref="185296989"/>
+ <reference key="parent" ref="526778998"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">269</int>
+ <reference key="object" ref="868031522"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="981161348"/>
+ </array>
+ <reference key="parent" ref="524015605"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">270</int>
+ <reference key="object" ref="981161348"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="390088328"/>
+ <reference ref="1065386165"/>
+ </array>
+ <reference key="parent" ref="868031522"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">272</int>
+ <reference key="object" ref="390088328"/>
+ <reference key="parent" ref="981161348"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">305</int>
+ <reference key="object" ref="1065386165"/>
+ <reference key="parent" ref="981161348"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">419</int>
+ <reference key="object" ref="551174276"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="511848303"/>
+ </array>
+ <reference key="parent" ref="524015605"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">420</int>
+ <reference key="object" ref="511848303"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="504984881"/>
+ </array>
+ <reference key="parent" ref="551174276"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">421</int>
+ <reference key="object" ref="504984881"/>
+ <reference key="parent" ref="511848303"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">196</int>
+ <reference key="object" ref="485884620"/>
+ <reference key="parent" ref="0"/>
+ <string key="objectName">X11Controller</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">244</int>
+ <reference key="object" ref="124913468"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="941366957"/>
+ </array>
+ <reference key="parent" ref="0"/>
+ <string key="objectName">PrefsPanel</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">245</int>
+ <reference key="object" ref="941366957"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="448510093"/>
+ </array>
+ <reference key="parent" ref="124913468"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">348</int>
+ <reference key="object" ref="448510093"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="287591690"/>
+ <reference ref="960678392"/>
+ <reference ref="348328898"/>
+ <reference ref="10973343"/>
+ <reference ref="723450037"/>
+ </array>
+ <reference key="parent" ref="941366957"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">349</int>
+ <reference key="object" ref="287591690"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="596750588"/>
+ </array>
+ <reference key="parent" ref="448510093"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">351</int>
+ <reference key="object" ref="596750588"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="119157981"/>
+ <reference ref="443008216"/>
+ <reference ref="282885445"/>
+ <reference ref="842100515"/>
+ <reference ref="31160162"/>
+ <reference ref="179949713"/>
+ <reference ref="278155937"/>
+ <reference ref="406291430"/>
+ <reference ref="863505041"/>
+ </array>
+ <reference key="parent" ref="287591690"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">363</int>
+ <reference key="object" ref="119157981"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="990762273"/>
+ </array>
+ <reference key="parent" ref="596750588"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">364</int>
+ <reference key="object" ref="443008216"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="391919450"/>
+ </array>
+ <reference key="parent" ref="596750588"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">365</int>
+ <reference key="object" ref="282885445"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="649334366"/>
+ </array>
+ <reference key="parent" ref="596750588"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">368</int>
+ <reference key="object" ref="842100515"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="940564599"/>
+ </array>
+ <reference key="parent" ref="596750588"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">369</int>
+ <reference key="object" ref="31160162"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="666057093"/>
+ </array>
+ <reference key="parent" ref="596750588"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">370</int>
+ <reference key="object" ref="179949713"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="967619578"/>
+ </array>
+ <reference key="parent" ref="596750588"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">352</int>
+ <reference key="object" ref="960678392"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="515308735"/>
+ </array>
+ <reference key="parent" ref="448510093"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">350</int>
+ <reference key="object" ref="515308735"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="709074847"/>
+ <reference ref="201731424"/>
+ <reference ref="86150604"/>
+ <reference ref="477203622"/>
+ <reference ref="57246850"/>
+ <reference ref="298603383"/>
+ <reference ref="331853183"/>
+ </array>
+ <reference key="parent" ref="960678392"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">382</int>
+ <reference key="object" ref="709074847"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="633115429"/>
+ </array>
+ <reference key="parent" ref="515308735"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">385</int>
+ <reference key="object" ref="201731424"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="930265681"/>
+ </array>
+ <reference key="parent" ref="515308735"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">386</int>
+ <reference key="object" ref="86150604"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="311969422"/>
+ </array>
+ <reference key="parent" ref="515308735"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">541</int>
+ <reference key="object" ref="477203622"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="631531164"/>
+ </array>
+ <reference key="parent" ref="515308735"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">543</int>
+ <reference key="object" ref="298603383"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="761107402"/>
+ </array>
+ <reference key="parent" ref="515308735"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">353</int>
+ <reference key="object" ref="348328898"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="300811574"/>
+ </array>
+ <reference key="parent" ref="448510093"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">354</int>
+ <reference key="object" ref="300811574"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="989050925"/>
+ <reference ref="700826966"/>
+ <reference ref="168436707"/>
+ <reference ref="363817195"/>
+ <reference ref="223835729"/>
+ </array>
+ <reference key="parent" ref="348328898"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">374</int>
+ <reference key="object" ref="989050925"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="189594322"/>
+ </array>
+ <reference key="parent" ref="300811574"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">375</int>
+ <reference key="object" ref="700826966"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="489340979"/>
+ </array>
+ <reference key="parent" ref="300811574"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">376</int>
+ <reference key="object" ref="168436707"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="53243865"/>
+ </array>
+ <reference key="parent" ref="300811574"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">377</int>
+ <reference key="object" ref="363817195"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="390084685"/>
+ </array>
+ <reference key="parent" ref="300811574"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">379</int>
+ <reference key="object" ref="223835729"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="283628678"/>
+ </array>
+ <reference key="parent" ref="300811574"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">285</int>
+ <reference key="object" ref="604417141"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="85544634"/>
+ </array>
+ <reference key="parent" ref="0"/>
+ <string key="objectName">EditPrograms</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">286</int>
+ <reference key="object" ref="85544634"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="1063387772"/>
+ <reference ref="758204686"/>
+ <reference ref="671954382"/>
+ <reference ref="492358940"/>
+ </array>
+ <reference key="parent" ref="604417141"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">423</int>
+ <reference key="object" ref="294137138"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="318286212"/>
+ <reference ref="511651072"/>
+ </array>
+ <reference key="parent" ref="0"/>
+ <string key="objectName">DockMenu</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">524</int>
+ <reference key="object" ref="318286212"/>
+ <reference key="parent" ref="294137138"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">526</int>
+ <reference key="object" ref="511651072"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="48278059"/>
+ </array>
+ <reference key="parent" ref="294137138"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">527</int>
+ <reference key="object" ref="48278059"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="1032342329"/>
+ <reference ref="563798000"/>
+ </array>
+ <reference key="parent" ref="511651072"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">532</int>
+ <reference key="object" ref="1032342329"/>
+ <reference key="parent" ref="48278059"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">533</int>
+ <reference key="object" ref="563798000"/>
+ <reference key="parent" ref="48278059"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100363</int>
+ <reference key="object" ref="990762273"/>
+ <reference key="parent" ref="119157981"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100364</int>
+ <reference key="object" ref="391919450"/>
+ <reference key="parent" ref="443008216"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100365</int>
+ <reference key="object" ref="649334366"/>
+ <reference key="parent" ref="282885445"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100368</int>
+ <reference key="object" ref="940564599"/>
+ <reference key="parent" ref="842100515"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100369</int>
+ <reference key="object" ref="666057093"/>
+ <reference key="parent" ref="31160162"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100370</int>
+ <reference key="object" ref="967619578"/>
+ <reference key="parent" ref="179949713"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100382</int>
+ <reference key="object" ref="633115429"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="341113515"/>
+ </array>
+ <reference key="parent" ref="709074847"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100385</int>
+ <reference key="object" ref="930265681"/>
+ <reference key="parent" ref="201731424"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100386</int>
+ <reference key="object" ref="311969422"/>
+ <reference key="parent" ref="86150604"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100541</int>
+ <reference key="object" ref="631531164"/>
+ <reference key="parent" ref="477203622"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100543</int>
+ <reference key="object" ref="761107402"/>
+ <reference key="parent" ref="298603383"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100374</int>
+ <reference key="object" ref="189594322"/>
+ <reference key="parent" ref="989050925"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100375</int>
+ <reference key="object" ref="489340979"/>
+ <reference key="parent" ref="700826966"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100376</int>
+ <reference key="object" ref="53243865"/>
+ <reference key="parent" ref="168436707"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100377</int>
+ <reference key="object" ref="390084685"/>
+ <reference key="parent" ref="363817195"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100379</int>
+ <reference key="object" ref="283628678"/>
+ <reference key="parent" ref="223835729"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">380</int>
+ <reference key="object" ref="341113515"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="759499526"/>
+ <reference ref="616492372"/>
+ <reference ref="543935434"/>
+ <reference ref="836673018"/>
+ </array>
+ <reference key="parent" ref="633115429"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">435</int>
+ <reference key="object" ref="759499526"/>
+ <reference key="parent" ref="341113515"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">384</int>
+ <reference key="object" ref="616492372"/>
+ <reference key="parent" ref="341113515"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">383</int>
+ <reference key="object" ref="543935434"/>
+ <reference key="parent" ref="341113515"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">381</int>
+ <reference key="object" ref="836673018"/>
+ <reference key="parent" ref="341113515"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">295</int>
+ <reference key="object" ref="1063387772"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="792419186"/>
+ <reference ref="17278747"/>
+ <reference ref="842897584"/>
+ <reference ref="905092943"/>
+ </array>
+ <reference key="parent" ref="85544634"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300295</int>
+ <reference key="object" ref="792419186"/>
+ <reference key="parent" ref="1063387772"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">200295</int>
+ <reference key="object" ref="17278747"/>
+ <reference key="parent" ref="1063387772"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100295</int>
+ <reference key="object" ref="842897584"/>
+ <reference key="parent" ref="1063387772"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">296</int>
+ <reference key="object" ref="905092943"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="242608782"/>
+ <reference ref="938444323"/>
+ <reference ref="84282687"/>
+ </array>
+ <reference key="parent" ref="1063387772"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">535</int>
+ <reference key="object" ref="242608782"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="34714764"/>
+ </array>
+ <reference key="parent" ref="905092943"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">575</int>
+ <reference key="object" ref="34714764"/>
+ <reference key="parent" ref="242608782"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">298</int>
+ <reference key="object" ref="938444323"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="825378892"/>
+ </array>
+ <reference key="parent" ref="905092943"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">573</int>
+ <reference key="object" ref="825378892"/>
+ <reference key="parent" ref="938444323"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">297</int>
+ <reference key="object" ref="84282687"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="432610585"/>
+ </array>
+ <reference key="parent" ref="905092943"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">574</int>
+ <reference key="object" ref="432610585"/>
+ <reference key="parent" ref="84282687"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">310</int>
+ <reference key="object" ref="758204686"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="1025474039"/>
+ </array>
+ <reference key="parent" ref="85544634"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100310</int>
+ <reference key="object" ref="1025474039"/>
+ <reference key="parent" ref="758204686"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">292</int>
+ <reference key="object" ref="671954382"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="143554520"/>
+ </array>
+ <reference key="parent" ref="85544634"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100292</int>
+ <reference key="object" ref="143554520"/>
+ <reference key="parent" ref="671954382"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">293</int>
+ <reference key="object" ref="492358940"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="8201128"/>
+ </array>
+ <reference key="parent" ref="85544634"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100293</int>
+ <reference key="object" ref="8201128"/>
+ <reference key="parent" ref="492358940"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300337</int>
+ <reference key="object" ref="10973343"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="184765684"/>
+ </array>
+ <reference key="parent" ref="448510093"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300338</int>
+ <reference key="object" ref="184765684"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="657659108"/>
+ <reference ref="290578835"/>
+ <reference ref="992839333"/>
+ <reference ref="138261120"/>
+ <reference ref="128352289"/>
+ <reference ref="57161931"/>
+ </array>
+ <reference key="parent" ref="10973343"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300358</int>
+ <reference key="object" ref="290578835"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="399127858"/>
+ </array>
+ <reference key="parent" ref="184765684"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300359</int>
+ <reference key="object" ref="657659108"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="259618205"/>
+ </array>
+ <reference key="parent" ref="184765684"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300360</int>
+ <reference key="object" ref="259618205"/>
+ <reference key="parent" ref="657659108"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300361</int>
+ <reference key="object" ref="399127858"/>
+ <reference key="parent" ref="290578835"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300362</int>
+ <reference key="object" ref="992839333"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="959555182"/>
+ </array>
+ <reference key="parent" ref="184765684"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300363</int>
+ <reference key="object" ref="959555182"/>
+ <reference key="parent" ref="992839333"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300364</int>
+ <reference key="object" ref="138261120"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="183409141"/>
+ </array>
+ <reference key="parent" ref="184765684"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300365</int>
+ <reference key="object" ref="183409141"/>
+ <reference key="parent" ref="138261120"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300368</int>
+ <reference key="object" ref="128352289"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="556463187"/>
+ </array>
+ <reference key="parent" ref="184765684"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300369</int>
+ <reference key="object" ref="556463187"/>
+ <reference key="parent" ref="128352289"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300370</int>
+ <reference key="object" ref="57161931"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="989804990"/>
+ </array>
+ <reference key="parent" ref="184765684"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300371</int>
+ <reference key="object" ref="989804990"/>
+ <reference key="parent" ref="57161931"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300421</int>
+ <reference key="object" ref="723450037"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="408298283"/>
+ </array>
+ <reference key="parent" ref="448510093"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300422</int>
+ <reference key="object" ref="408298283"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="878106058"/>
+ <reference ref="386152084"/>
+ <reference ref="487809555"/>
+ <reference ref="620944856"/>
+ <reference ref="477050998"/>
+ <reference ref="765780304"/>
+ <reference ref="1002778833"/>
+ <reference ref="522511724"/>
+ </array>
+ <reference key="parent" ref="723450037"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300423</int>
+ <reference key="object" ref="386152084"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="572508492"/>
+ </array>
+ <reference key="parent" ref="408298283"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300424</int>
+ <reference key="object" ref="878106058"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="718083688"/>
+ </array>
+ <reference key="parent" ref="408298283"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300440</int>
+ <reference key="object" ref="718083688"/>
+ <reference key="parent" ref="878106058"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300441</int>
+ <reference key="object" ref="572508492"/>
+ <reference key="parent" ref="386152084"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300447</int>
+ <reference key="object" ref="477050998"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="501304422"/>
+ </array>
+ <reference key="parent" ref="408298283"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300450</int>
+ <reference key="object" ref="501304422"/>
+ <reference key="parent" ref="477050998"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300451</int>
+ <reference key="object" ref="765780304"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="510771323"/>
+ </array>
+ <reference key="parent" ref="408298283"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300452</int>
+ <reference key="object" ref="510771323"/>
+ <reference key="parent" ref="765780304"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300453</int>
+ <reference key="object" ref="487809555"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="619977658"/>
+ </array>
+ <reference key="parent" ref="408298283"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300454</int>
+ <reference key="object" ref="619977658"/>
+ <reference key="parent" ref="487809555"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300455</int>
+ <reference key="object" ref="620944856"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="461823902"/>
+ </array>
+ <reference key="parent" ref="408298283"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300456</int>
+ <reference key="object" ref="461823902"/>
+ <reference key="parent" ref="620944856"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300457</int>
+ <reference key="object" ref="1002778833"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="897099877"/>
+ </array>
+ <reference key="parent" ref="408298283"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300458</int>
+ <reference key="object" ref="897099877"/>
+ <reference key="parent" ref="1002778833"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300459</int>
+ <reference key="object" ref="522511724"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="994587858"/>
+ </array>
+ <reference key="parent" ref="408298283"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300460</int>
+ <reference key="object" ref="994587858"/>
+ <reference key="parent" ref="522511724"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300472</int>
+ <reference key="object" ref="57246850"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="917248662"/>
+ </array>
+ <reference key="parent" ref="515308735"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300473</int>
+ <reference key="object" ref="917248662"/>
+ <reference key="parent" ref="57246850"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300476</int>
+ <reference key="object" ref="278155937"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="617441821"/>
+ </array>
+ <reference key="parent" ref="596750588"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300477</int>
+ <reference key="object" ref="406291430"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="67728988"/>
+ </array>
+ <reference key="parent" ref="596750588"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300478</int>
+ <reference key="object" ref="67728988"/>
+ <reference key="parent" ref="406291430"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300479</int>
+ <reference key="object" ref="617441821"/>
+ <reference key="parent" ref="278155937"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300482</int>
+ <reference key="object" ref="863505041"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="1016286396"/>
+ </array>
+ <reference key="parent" ref="596750588"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300483</int>
+ <reference key="object" ref="1016286396"/>
+ <reference key="parent" ref="863505041"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300487</int>
+ <reference key="object" ref="331853183"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="1042813110"/>
+ </array>
+ <reference key="parent" ref="515308735"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">300488</int>
+ <reference key="object" ref="1042813110"/>
+ <reference key="parent" ref="331853183"/>
+ </object>
+ </array>
+ </object>
+ <dictionary class="NSMutableDictionary" key="flattenedProperties">
+ <string key="-3.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="-3.ImportedFromIB2"/>
+ <string key="100292.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100293.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100295.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="100295.IBShouldRemoveOnLegacySave"/>
+ <string key="100310.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100363.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100364.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100365.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100368.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100369.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100370.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100374.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100375.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100376.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100377.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100379.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100382.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100385.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100386.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100541.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="100543.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="129.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="129.ImportedFromIB2"/>
+ <string key="130.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="130.ImportedFromIB2"/>
+ <string key="131.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="131.ImportedFromIB2"/>
+ <string key="134.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="134.ImportedFromIB2"/>
+ <string key="136.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="136.ImportedFromIB2"/>
+ <string key="143.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="143.ImportedFromIB2"/>
+ <string key="144.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="144.ImportedFromIB2"/>
+ <string key="145.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="145.ImportedFromIB2"/>
+ <string key="149.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="149.ImportedFromIB2"/>
+ <string key="150.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="150.ImportedFromIB2"/>
+ <string key="157.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="157.ImportedFromIB2"/>
+ <string key="163.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="163.ImportedFromIB2"/>
+ <string key="169.IBEditorWindowLastContentRect">{{168, 821}, {113, 23}}</string>
+ <string key="169.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="169.ImportedFromIB2"/>
+ <string key="169.editorWindowContentRectSynchronizationRect">{{202, 626}, {154, 153}}</string>
+ <string key="19.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="19.ImportedFromIB2"/>
+ <integer value="1" key="196.ImportedFromIB2"/>
+ <string key="200295.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="200295.IBShouldRemoveOnLegacySave"/>
+ <string key="203.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="203.ImportedFromIB2"/>
+ <string key="204.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="204.ImportedFromIB2"/>
+ <string key="23.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="23.ImportedFromIB2"/>
+ <string key="24.IBEditorWindowLastContentRect">{{349, 868}, {315, 143}}</string>
+ <string key="24.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="24.ImportedFromIB2"/>
+ <string key="24.editorWindowContentRectSynchronizationRect">{{271, 666}, {301, 153}}</string>
+ <string key="244.IBEditorWindowLastContentRect">{{507, 515}, {584, 341}}</string>
+ <string key="244.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <boolean value="YES" key="244.IBViewEditorWindowController.showingLayoutRectangles"/>
+ <string key="244.IBWindowTemplateEditedContentRect">{{507, 515}, {584, 341}}</string>
+ <integer value="1" key="244.ImportedFromIB2"/>
+ <string key="244.editorWindowContentRectSynchronizationRect">{{184, 290}, {481, 345}}</string>
+ <boolean value="YES" key="244.windowTemplate.hasMinSize"/>
+ <string key="244.windowTemplate.maxSize">{1.7976931348623157e+308, 1.7976931348623157e+308}</string>
+ <string key="244.windowTemplate.minSize">{320, 240}</string>
+ <string key="245.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="245.ImportedFromIB2"/>
+ <string key="269.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="269.ImportedFromIB2"/>
+ <string key="270.IBEditorWindowLastContentRect">{{58, 803}, {155, 33}}</string>
+ <string key="270.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="270.ImportedFromIB2"/>
+ <string key="270.editorWindowContentRectSynchronizationRect">{{100, 746}, {155, 33}}</string>
+ <string key="272.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="272.ImportedFromIB2"/>
+ <string key="285.IBEditorWindowLastContentRect">{{68, 585}, {454, 271}}</string>
+ <string key="285.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="285.IBViewEditorWindowController.showingBoundsRectangles"/>
+ <integer value="1" key="285.IBViewEditorWindowController.showingLayoutRectangles"/>
+ <string key="285.IBWindowTemplateEditedContentRect">{{68, 585}, {454, 271}}</string>
+ <integer value="1" key="285.ImportedFromIB2"/>
+ <string key="285.editorWindowContentRectSynchronizationRect">{{433, 406}, {486, 327}}</string>
+ <boolean value="YES" key="285.windowTemplate.hasMinSize"/>
+ <string key="285.windowTemplate.maxSize">{1.7976931348623157e+308, 1.7976931348623157e+308}</string>
+ <string key="285.windowTemplate.minSize">{454, 271}</string>
+ <string key="286.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="286.ImportedFromIB2"/>
+ <string key="29.IBEditorWindowLastContentRect">{{145, 1011}, {336, 20}}</string>
+ <string key="29.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="29.ImportedFromIB2"/>
+ <string key="29.editorWindowContentRectSynchronizationRect">{{67, 819}, {336, 20}}</string>
+ <string key="292.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="292.ImportedFromIB2"/>
+ <string key="293.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="293.ImportedFromIB2"/>
+ <string key="295.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="295.ImportedFromIB2"/>
+ <string key="296.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="296.ImportedFromIB2"/>
+ <string key="297.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="297.ImportedFromIB2"/>
+ <string key="298.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="298.ImportedFromIB2"/>
+ <string key="300295.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300295.IBShouldRemoveOnLegacySave"/>
+ <string key="300337.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300337.ImportedFromIB2"/>
+ <string key="300338.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300338.ImportedFromIB2"/>
+ <string key="300358.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300358.ImportedFromIB2"/>
+ <string key="300359.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300359.ImportedFromIB2"/>
+ <string key="300360.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300361.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300362.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300362.ImportedFromIB2"/>
+ <string key="300363.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300364.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300364.ImportedFromIB2"/>
+ <string key="300365.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300368.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300368.ImportedFromIB2"/>
+ <string key="300369.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300370.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300370.ImportedFromIB2"/>
+ <string key="300371.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300421.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300421.ImportedFromIB2"/>
+ <string key="300422.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300422.ImportedFromIB2"/>
+ <string key="300423.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300423.ImportedFromIB2"/>
+ <string key="300424.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300424.ImportedFromIB2"/>
+ <string key="300440.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300441.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300447.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300447.ImportedFromIB2"/>
+ <string key="300450.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300451.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300451.ImportedFromIB2"/>
+ <string key="300452.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300453.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300453.ImportedFromIB2"/>
+ <string key="300454.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300455.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300455.ImportedFromIB2"/>
+ <string key="300456.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300457.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300457.ImportedFromIB2"/>
+ <string key="300458.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300459.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300459.ImportedFromIB2"/>
+ <string key="300460.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300472.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300472.ImportedFromIB2"/>
+ <string key="300473.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300476.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300476.ImportedFromIB2"/>
+ <string key="300477.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300477.ImportedFromIB2"/>
+ <string key="300478.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300479.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300482.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300482.ImportedFromIB2"/>
+ <string key="300483.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="300487.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="300487.ImportedFromIB2"/>
+ <string key="300488.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="305.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="305.ImportedFromIB2"/>
+ <string key="310.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="310.ImportedFromIB2"/>
+ <string key="348.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="348.ImportedFromIB2"/>
+ <string key="349.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="349.ImportedFromIB2"/>
+ <string key="350.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="350.ImportedFromIB2"/>
+ <string key="351.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="351.ImportedFromIB2"/>
+ <string key="352.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="352.ImportedFromIB2"/>
+ <string key="353.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="353.ImportedFromIB2"/>
+ <string key="354.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="354.ImportedFromIB2"/>
+ <string key="363.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="363.ImportedFromIB2"/>
+ <string key="364.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="364.ImportedFromIB2"/>
+ <string key="365.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="365.ImportedFromIB2"/>
+ <string key="368.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="368.ImportedFromIB2"/>
+ <string key="369.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="369.ImportedFromIB2"/>
+ <string key="370.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="370.ImportedFromIB2"/>
+ <string key="374.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="374.ImportedFromIB2"/>
+ <string key="375.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="375.ImportedFromIB2"/>
+ <string key="376.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="376.ImportedFromIB2"/>
+ <string key="377.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="377.ImportedFromIB2"/>
+ <string key="379.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="379.ImportedFromIB2"/>
+ <string key="380.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="380.ImportedFromIB2"/>
+ <string key="381.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="381.ImportedFromIB2"/>
+ <string key="382.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="382.ImportedFromIB2"/>
+ <string key="383.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="383.ImportedFromIB2"/>
+ <string key="384.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="384.ImportedFromIB2"/>
+ <string key="385.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="385.ImportedFromIB2"/>
+ <string key="386.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="386.ImportedFromIB2"/>
+ <string key="419.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="419.ImportedFromIB2"/>
+ <string key="420.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="420.ImportedFromIB2"/>
+ <string key="421.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="421.ImportedFromIB2"/>
+ <string key="423.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="423.ImportedFromIB2"/>
+ <string key="435.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="435.ImportedFromIB2"/>
+ <string key="5.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="5.ImportedFromIB2"/>
+ <string key="524.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="524.ImportedFromIB2"/>
+ <string key="526.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="526.ImportedFromIB2"/>
+ <string key="527.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="527.ImportedFromIB2"/>
+ <string key="532.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="532.ImportedFromIB2"/>
+ <string key="533.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="533.ImportedFromIB2"/>
+ <string key="535.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="535.ImportedFromIB2"/>
+ <string key="536.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="536.ImportedFromIB2"/>
+ <string key="537.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="537.ImportedFromIB2"/>
+ <string key="538.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="538.ImportedFromIB2"/>
+ <string key="541.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="541.ImportedFromIB2"/>
+ <string key="543.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="543.ImportedFromIB2"/>
+ <string key="544.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="544.ImportedFromIB2"/>
+ <string key="545.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="545.ImportedFromIB2"/>
+ <string key="56.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="56.ImportedFromIB2"/>
+ <string key="57.IBEditorWindowLastContentRect">{{20, 641}, {218, 203}}</string>
+ <string key="57.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="57.ImportedFromIB2"/>
+ <string key="57.editorWindowContentRectSynchronizationRect">{{79, 616}, {218, 203}}</string>
+ <string key="573.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="573.ImportedFromIB2"/>
+ <string key="574.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="574.ImportedFromIB2"/>
+ <string key="575.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="575.ImportedFromIB2"/>
+ <string key="58.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="58.ImportedFromIB2"/>
+ <string key="92.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" key="92.ImportedFromIB2"/>
+ </dictionary>
+ <dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
+ <nil key="activeLocalization"/>
+ <dictionary class="NSMutableDictionary" key="localizations"/>
+ <nil key="sourceID"/>
+ <int key="maxID">300490</int>
+ </object>
+ <object class="IBClassDescriber" key="IBDocument.Classes"/>
+ <int key="IBDocument.localizationMode">0</int>
+ <string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
+ <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencies">
+ <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string>
+ <integer value="1040" key="NS.object.0"/>
+ </object>
+ <bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
+ <nil key="IBDocument.LastKnownRelativeProjectPath"/>
+ <int key="IBDocument.defaultPropertyAccessControl">3</int>
+ <dictionary class="NSMutableDictionary" key="IBDocument.LastKnownImageSizes">
+ <string key="NSMenuCheckmark">{9, 8}</string>
+ <string key="NSMenuMixedState">{7, 2}</string>
+ <string key="NSSwitch">{15, 15}</string>
+ </dictionary>
+ </data>
+</archive>
diff --git a/xorg-server/hw/xquartz/console_redirect.c b/xorg-server/hw/xquartz/console_redirect.c
index f7b95df2b..70a819e42 100644
--- a/xorg-server/hw/xquartz/console_redirect.c
+++ b/xorg-server/hw/xquartz/console_redirect.c
@@ -1,418 +1,418 @@
-/* Copyright (c) 2011 Apple 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 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.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#else
-#define DEBUG_CONSOLE_REDIRECT 1
-#define HAVE_LIBDISPATCH 1
-#endif
-
-#include <assert.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/event.h>
-#include <asl.h>
-#include <errno.h>
-#include <fcntl.h>
-
-#include "console_redirect.h"
-
-#define BUF_SIZE 512
-
-#ifdef HAVE_LIBDISPATCH
-#include <dispatch/dispatch.h>
-
-static dispatch_queue_t redirect_serial_q;
-static dispatch_group_t read_source_group;
-#else
-#include <pthread.h>
-
-static pthread_t redirect_pthread;
-static pthread_mutex_t redirect_fds_lock = PTHREAD_MUTEX_INITIALIZER;
-
-static int kq;
-
-/* Notifications to our reader thread */
-#define ASL_REDIRECT_TERMINATE ((void *)(uintptr_t)1)
-#endif
-
-typedef struct {
- int level;
- aslclient asl;
- aslmsg msg;
-
- /* Buffered reading */
- char *buf;
- char *w;
-
-#ifdef HAVE_LIBDISPATCH
- dispatch_source_t read_source;
-#endif
-} asl_redirect;
-
-static asl_redirect *redirect_fds = NULL;
-static int n_redirect_fds = 0;
-
-/* Read from the FD until there is no more to read and redirect to ASL.
- * Preconditions:
- * 1: pthread_mutex_lock lock is held (pthreads) or called
- * from the appropriate serial queue for operating on
- * redirect_fds
- * 2: fd corresponds to a valid entry in redirect_fds
- *
- * Return values:
- * If the pipe is closed, EOF is returned regardless of how many bytes
- * were processed. If the pipe is still open, the number of read bytes
- * is returned.
- */
-static inline int _read_redirect(int fd, int flush) {
- int total_read = 0;
- int nbytes;
- asl_redirect *aslr = &redirect_fds[fd];
-
- while((nbytes = read(fd, aslr->w, BUF_SIZE - (aslr->w - aslr->buf) - 1)) > 0) {
- char *s, *p;
-
- /* Increment our returned number read */
- total_read += nbytes;
-
- nbytes += (aslr->w - aslr->buf);
- aslr->buf[nbytes] = '\0';
-
- /* One line at a time */
- for(p=aslr->buf; *p && (p - aslr->buf) < nbytes; p = s + 1) {
- // Find null or \n
- for(s=p; *s && *s != '\n'; s++);
- if(*s == '\n') {
- *s='\0';
- asl_log(aslr->asl, aslr->msg, aslr->level, "%s", p);
- } else if(aslr->buf != p) {
- memmove(aslr->buf, p, BUF_SIZE - (p - aslr->buf));
- aslr->w = aslr->buf + (s - p);
- break;
- } else if(nbytes == BUF_SIZE - 1) {
- asl_log(aslr->asl, aslr->msg, aslr->level, "%s", p);
- aslr->w = aslr->buf;
- break;
- }
- }
- }
-
- /* Flush if requested or we're at EOF */
- if(flush || nbytes == 0) {
- if(aslr->w > aslr->buf) {
- *aslr->w = '\0';
- asl_log(aslr->asl, aslr->msg, aslr->level, "%s", aslr->buf);
- }
- }
-
- if(nbytes == 0)
- return EOF;
- return total_read;
-}
-
-#ifdef HAVE_LIBDISPATCH
-static void read_from_source(void *_source) {
- dispatch_source_t source = (dispatch_source_t)_source;
- int fd = dispatch_source_get_handle(source);
- if(_read_redirect(fd, 0) == EOF) {
- dispatch_source_cancel(source);
- }
-}
-
-static void cancel_source(void *_source) {
- dispatch_source_t source = (dispatch_source_t)_source;
- int fd = dispatch_source_get_handle(source);
- asl_redirect *aslr = &redirect_fds[fd];
-
- /* Flush the buffer */
- _read_redirect(fd, 1);
-
- close(fd);
- free(aslr->buf);
- memset(aslr, 0, sizeof(*aslr));
- dispatch_release(source);
- dispatch_group_leave(read_source_group);
-}
-
-#else /* !HAVE_LIBDISPATCH */
-static void *redirect_thread(void *ctx __unused) {
- struct kevent ev;
- int n;
-
- while(1) {
- n = kevent(kq, NULL, 0, &ev, 1, NULL);
-
- /* Bail on errors */
- if(n < 0) {
- asl_log(NULL, NULL, ASL_LEVEL_ERR, "kevent failure: %s", strerror(errno));
- break;
- }
-
- /* This should not happen */
- if(n == 0)
- continue;
-
- switch(ev.filter) {
- case EVFILT_READ:
- pthread_mutex_lock(&redirect_fds_lock);
- {
- int fd = ev.ident;
- int close_fd = 0;
- asl_redirect *aslr = &redirect_fds[fd];
-
- if(fd < 0 || fd >= n_redirect_fds || aslr->buf == NULL) {
- asl_log(NULL, NULL, ASL_LEVEL_ERR, "Unexpected file descriptor: %d", fd);
- goto next;
- }
-
- if(ev.flags & EV_EOF) {
- close_fd = 1;
- if(EOF != _read_redirect(fd, 1)) {
- asl_log(NULL, NULL, ASL_LEVEL_ERR, "kevent reported EOF on %d, but read doesn't concur.", fd);
- }
- } else {
- close_fd = (EOF == _read_redirect(fd, 0));
- }
-
- if(close_fd) {
- EV_SET(&ev, fd, EVFILT_READ, EV_DELETE, 0, 0, 0);
- kevent(kq, &ev, 1, NULL, 0, NULL);
- close(fd);
- free(aslr->buf);
- memset(aslr, 0, sizeof(*aslr));
- }
- }
- next:
- pthread_mutex_unlock(&redirect_fds_lock);
-
- case EVFILT_TIMER:
- if(ev.udata == ASL_REDIRECT_TERMINATE)
- return NULL;
-
- default:
- ;;
- }
- }
-
- return NULL;
-}
-#endif
-
-static void redirect_atexit(void) {
- /* stdout is linebuffered, so flush the buffer */
- if(redirect_fds[STDOUT_FILENO].buf)
- fflush(stdout);
-
-#ifdef HAVE_LIBDISPATCH
- {
- int i;
-
- /* Cancel all of our dispatch sources, so they flush to ASL */
- for(i=0; i < n_redirect_fds; i++)
- if(redirect_fds[i].read_source)
- dispatch_source_cancel(redirect_fds[i].read_source);
-
- /* Wait at least three seconds for our sources to flush to ASL */
- dispatch_group_wait(read_source_group, dispatch_time(DISPATCH_TIME_NOW, 3LL * NSEC_PER_SEC));
- }
-#else
- {
- struct kevent ev;
-
- /* Tell our reader thread it is time to pack up and go home */
- EV_SET(&ev, 0, EVFILT_TIMER, EV_ADD | EV_ONESHOT, 0, 0, ASL_REDIRECT_TERMINATE);
- kevent(kq, &ev, 1, NULL, 0, NULL);
-
- pthread_join(redirect_pthread, NULL);
- }
-#endif
-}
-
-#ifdef HAVE_LIBDISPATCH
-static void xq_asl_init(void *ctx __unused)
-#else
-static void xq_asl_init(void)
-#endif
-{
- assert((redirect_fds = calloc(16, sizeof(*redirect_fds))) != NULL);
- n_redirect_fds = 16;
-
-#ifdef HAVE_LIBDISPATCH
- redirect_serial_q = dispatch_queue_create("com.apple.asl-redirect", NULL);
- assert(redirect_serial_q != NULL);
-
- read_source_group = dispatch_group_create();
- assert(read_source_group != NULL);
-#else
- assert((kq = kqueue()) != -1);
- assert(pthread_create(&redirect_pthread, NULL, redirect_thread, NULL) == 0);
-#endif
-
- atexit(redirect_atexit);
-}
-
-int xq_asl_log_fd(aslclient asl, aslmsg msg, int level, int fd) {
-#ifdef HAVE_LIBDISPATCH
- int err __block = 0;
- static dispatch_once_t once_control;
- dispatch_once_f(&once_control, NULL, xq_asl_init);
-#else
- int err = 0;
- static pthread_once_t once_control = PTHREAD_ONCE_INIT;
- assert(pthread_once(&once_control, xq_asl_init) == 0);
-#endif
-
- if(fd < 0)
- return EBADF;
-
-#ifdef HAVE_LIBDISPATCH
-#define BLOCK_DONE return
- dispatch_sync(redirect_serial_q, ^
-#else
-#define BLOCK_DONE goto done
- assert(pthread_mutex_lock(&redirect_fds_lock) == 0);
-#endif
- {
- /* Reallocate if we need more space */
- if(fd >= n_redirect_fds) {
- size_t new_n = 1 << (ffs(fd) + 1);
- asl_redirect *new_array = realloc(redirect_fds, new_n * sizeof(*redirect_fds));
- if(!new_array) {
- err = errno;
- BLOCK_DONE;
- }
- redirect_fds = new_array;
- memset(redirect_fds + n_redirect_fds, 0, new_n - n_redirect_fds);
- n_redirect_fds = new_n;
- }
-
- /* If we're already listening on it, return error. */
- if(redirect_fds[fd].buf != NULL) {
- err = EBADF;
- BLOCK_DONE;
- }
-
- /* Initialize our buffer */
- redirect_fds[fd].buf = (char *)malloc(BUF_SIZE);
- if(redirect_fds[fd].buf == NULL) {
- err = errno;
- BLOCK_DONE;
- }
- redirect_fds[fd].w = redirect_fds[fd].buf;
-
- /* Store our ASL settings */
- redirect_fds[fd].level = level;
- redirect_fds[fd].asl = asl;
- redirect_fds[fd].msg = msg;
-
- /* Don't block on reads from this fd */
- fcntl(fd, F_SETFL, O_NONBLOCK);
-
- /* Start listening */
-#ifdef HAVE_LIBDISPATCH
- {
- dispatch_source_t read_source = dispatch_source_create(DISPATCH_SOURCE_TYPE_READ, fd, 0, redirect_serial_q);
- redirect_fds[fd].read_source = read_source;
- dispatch_set_context(read_source, read_source);
- dispatch_source_set_event_handler_f(read_source, read_from_source);
- dispatch_source_set_cancel_handler_f(read_source, cancel_source);
- dispatch_group_enter(read_source_group);
- dispatch_resume(read_source);
- }
-#else
- {
- struct kevent ev;
- EV_SET(&ev, fd, EVFILT_READ, EV_ADD, 0, 0, 0);
- kevent(kq, &ev, 1, NULL, 0, NULL);
- }
-#endif
- }
-#ifdef HAVE_LIBDISPATCH
- );
-#else
-done:
- assert(pthread_mutex_unlock(&redirect_fds_lock) == 0);
-#endif
-#undef BLOCK_DONE
-
- return err;
-}
-
-int xq_asl_capture_fd(aslclient asl, aslmsg msg, int level, int fd) {
- int pipepair[2];
-
- /* Create pipe */
- if(pipe(pipepair) == -1)
- return errno;
-
- /* Close the read fd but not the write fd on exec */
- if(fcntl(pipepair[0], F_SETFD, FD_CLOEXEC) == -1)
- return errno;
-
- /* Replace the existing fd */
- if(dup2(pipepair[1], fd) == -1) {
- close(pipepair[0]);
- close(pipepair[1]);
- return errno;
- }
-
- /* If we capture STDOUT_FILENO, make sure we linebuffer stdout */
- if(fd == STDOUT_FILENO)
- setlinebuf(stdout);
-
- /* Close the duplicate fds since they've been reassigned */
- close(pipepair[1]);
-
- /* Hand off the read end of our pipe to xq_asl_log_fd */
- return xq_asl_log_fd(asl, msg, level, pipepair[0]);
-}
-
-#ifdef DEBUG_CONSOLE_REDIRECT
-int main(int argc __unused, char **argv __unused) {
- xq_asl_capture_fd(NULL, NULL, ASL_LEVEL_NOTICE, STDOUT_FILENO);
- xq_asl_capture_fd(NULL, NULL, ASL_LEVEL_ERR, STDERR_FILENO);
-
- fprintf(stderr, "TEST ERR1\n");
- fprintf(stdout, "TEST OUT1\n");
- fprintf(stderr, "TEST ERR2\n");
- fprintf(stdout, "TEST OUT2\n");
- system("/bin/echo SYST OUT");
- system("/bin/echo SYST ERR >&2");
- fprintf(stdout, "TEST OUT3\n");
- fprintf(stdout, "TEST OUT4\n");
- fprintf(stderr, "TEST ERR3\n");
- fprintf(stderr, "TEST ERR4\n");
-
- exit(0);
-}
-#endif
+/* Copyright (c) 2011 Apple 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 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.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#else
+#define DEBUG_CONSOLE_REDIRECT 1
+#define HAVE_LIBDISPATCH 1
+#endif
+
+#include <assert.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/event.h>
+#include <asl.h>
+#include <errno.h>
+#include <fcntl.h>
+
+#include "console_redirect.h"
+
+#define BUF_SIZE 512
+
+#ifdef HAVE_LIBDISPATCH
+#include <dispatch/dispatch.h>
+
+static dispatch_queue_t redirect_serial_q;
+static dispatch_group_t read_source_group;
+#else
+#include <pthread.h>
+
+static pthread_t redirect_pthread;
+static pthread_mutex_t redirect_fds_lock = PTHREAD_MUTEX_INITIALIZER;
+
+static int kq;
+
+/* Notifications to our reader thread */
+#define ASL_REDIRECT_TERMINATE ((void *)(uintptr_t)1)
+#endif
+
+typedef struct {
+ int level;
+ aslclient asl;
+ aslmsg msg;
+
+ /* Buffered reading */
+ char *buf;
+ char *w;
+
+#ifdef HAVE_LIBDISPATCH
+ dispatch_source_t read_source;
+#endif
+} asl_redirect;
+
+static asl_redirect *redirect_fds = NULL;
+static int n_redirect_fds = 0;
+
+/* Read from the FD until there is no more to read and redirect to ASL.
+ * Preconditions:
+ * 1: pthread_mutex_lock lock is held (pthreads) or called
+ * from the appropriate serial queue for operating on
+ * redirect_fds
+ * 2: fd corresponds to a valid entry in redirect_fds
+ *
+ * Return values:
+ * If the pipe is closed, EOF is returned regardless of how many bytes
+ * were processed. If the pipe is still open, the number of read bytes
+ * is returned.
+ */
+static inline int _read_redirect(int fd, int flush) {
+ int total_read = 0;
+ int nbytes;
+ asl_redirect *aslr = &redirect_fds[fd];
+
+ while((nbytes = read(fd, aslr->w, BUF_SIZE - (aslr->w - aslr->buf) - 1)) > 0) {
+ char *s, *p;
+
+ /* Increment our returned number read */
+ total_read += nbytes;
+
+ nbytes += (aslr->w - aslr->buf);
+ aslr->buf[nbytes] = '\0';
+
+ /* One line at a time */
+ for(p=aslr->buf; *p && (p - aslr->buf) < nbytes; p = s + 1) {
+ // Find null or \n
+ for(s=p; *s && *s != '\n'; s++);
+ if(*s == '\n') {
+ *s='\0';
+ asl_log(aslr->asl, aslr->msg, aslr->level, "%s", p);
+ } else if(aslr->buf != p) {
+ memmove(aslr->buf, p, BUF_SIZE - (p - aslr->buf));
+ aslr->w = aslr->buf + (s - p);
+ break;
+ } else if(nbytes == BUF_SIZE - 1) {
+ asl_log(aslr->asl, aslr->msg, aslr->level, "%s", p);
+ aslr->w = aslr->buf;
+ break;
+ }
+ }
+ }
+
+ /* Flush if requested or we're at EOF */
+ if(flush || nbytes == 0) {
+ if(aslr->w > aslr->buf) {
+ *aslr->w = '\0';
+ asl_log(aslr->asl, aslr->msg, aslr->level, "%s", aslr->buf);
+ }
+ }
+
+ if(nbytes == 0)
+ return EOF;
+ return total_read;
+}
+
+#ifdef HAVE_LIBDISPATCH
+static void read_from_source(void *_source) {
+ dispatch_source_t source = (dispatch_source_t)_source;
+ int fd = dispatch_source_get_handle(source);
+ if(_read_redirect(fd, 0) == EOF) {
+ dispatch_source_cancel(source);
+ }
+}
+
+static void cancel_source(void *_source) {
+ dispatch_source_t source = (dispatch_source_t)_source;
+ int fd = dispatch_source_get_handle(source);
+ asl_redirect *aslr = &redirect_fds[fd];
+
+ /* Flush the buffer */
+ _read_redirect(fd, 1);
+
+ close(fd);
+ free(aslr->buf);
+ memset(aslr, 0, sizeof(*aslr));
+ dispatch_release(source);
+ dispatch_group_leave(read_source_group);
+}
+
+#else /* !HAVE_LIBDISPATCH */
+static void *redirect_thread(void *ctx __unused) {
+ struct kevent ev;
+ int n;
+
+ while(1) {
+ n = kevent(kq, NULL, 0, &ev, 1, NULL);
+
+ /* Bail on errors */
+ if(n < 0) {
+ asl_log(NULL, NULL, ASL_LEVEL_ERR, "kevent failure: %s", strerror(errno));
+ break;
+ }
+
+ /* This should not happen */
+ if(n == 0)
+ continue;
+
+ switch(ev.filter) {
+ case EVFILT_READ:
+ pthread_mutex_lock(&redirect_fds_lock);
+ {
+ int fd = ev.ident;
+ int close_fd = 0;
+ asl_redirect *aslr = &redirect_fds[fd];
+
+ if(fd < 0 || fd >= n_redirect_fds || aslr->buf == NULL) {
+ asl_log(NULL, NULL, ASL_LEVEL_ERR, "Unexpected file descriptor: %d", fd);
+ goto next;
+ }
+
+ if(ev.flags & EV_EOF) {
+ close_fd = 1;
+ if(EOF != _read_redirect(fd, 1)) {
+ asl_log(NULL, NULL, ASL_LEVEL_ERR, "kevent reported EOF on %d, but read doesn't concur.", fd);
+ }
+ } else {
+ close_fd = (EOF == _read_redirect(fd, 0));
+ }
+
+ if(close_fd) {
+ EV_SET(&ev, fd, EVFILT_READ, EV_DELETE, 0, 0, 0);
+ kevent(kq, &ev, 1, NULL, 0, NULL);
+ close(fd);
+ free(aslr->buf);
+ memset(aslr, 0, sizeof(*aslr));
+ }
+ }
+ next:
+ pthread_mutex_unlock(&redirect_fds_lock);
+
+ case EVFILT_TIMER:
+ if(ev.udata == ASL_REDIRECT_TERMINATE)
+ return NULL;
+
+ default:
+ ;;
+ }
+ }
+
+ return NULL;
+}
+#endif
+
+static void redirect_atexit(void) {
+ /* stdout is linebuffered, so flush the buffer */
+ if(redirect_fds[STDOUT_FILENO].buf)
+ fflush(stdout);
+
+#ifdef HAVE_LIBDISPATCH
+ {
+ int i;
+
+ /* Cancel all of our dispatch sources, so they flush to ASL */
+ for(i=0; i < n_redirect_fds; i++)
+ if(redirect_fds[i].read_source)
+ dispatch_source_cancel(redirect_fds[i].read_source);
+
+ /* Wait at least three seconds for our sources to flush to ASL */
+ dispatch_group_wait(read_source_group, dispatch_time(DISPATCH_TIME_NOW, 3LL * NSEC_PER_SEC));
+ }
+#else
+ {
+ struct kevent ev;
+
+ /* Tell our reader thread it is time to pack up and go home */
+ EV_SET(&ev, 0, EVFILT_TIMER, EV_ADD | EV_ONESHOT, 0, 0, ASL_REDIRECT_TERMINATE);
+ kevent(kq, &ev, 1, NULL, 0, NULL);
+
+ pthread_join(redirect_pthread, NULL);
+ }
+#endif
+}
+
+#ifdef HAVE_LIBDISPATCH
+static void xq_asl_init(void *ctx __unused)
+#else
+static void xq_asl_init(void)
+#endif
+{
+ assert((redirect_fds = calloc(16, sizeof(*redirect_fds))) != NULL);
+ n_redirect_fds = 16;
+
+#ifdef HAVE_LIBDISPATCH
+ redirect_serial_q = dispatch_queue_create("com.apple.asl-redirect", NULL);
+ assert(redirect_serial_q != NULL);
+
+ read_source_group = dispatch_group_create();
+ assert(read_source_group != NULL);
+#else
+ assert((kq = kqueue()) != -1);
+ assert(pthread_create(&redirect_pthread, NULL, redirect_thread, NULL) == 0);
+#endif
+
+ atexit(redirect_atexit);
+}
+
+int xq_asl_log_fd(aslclient asl, aslmsg msg, int level, int fd) {
+#ifdef HAVE_LIBDISPATCH
+ int err __block = 0;
+ static dispatch_once_t once_control;
+ dispatch_once_f(&once_control, NULL, xq_asl_init);
+#else
+ int err = 0;
+ static pthread_once_t once_control = PTHREAD_ONCE_INIT;
+ assert(pthread_once(&once_control, xq_asl_init) == 0);
+#endif
+
+ if(fd < 0)
+ return EBADF;
+
+#ifdef HAVE_LIBDISPATCH
+#define BLOCK_DONE return
+ dispatch_sync(redirect_serial_q, ^
+#else
+#define BLOCK_DONE goto done
+ assert(pthread_mutex_lock(&redirect_fds_lock) == 0);
+#endif
+ {
+ /* Reallocate if we need more space */
+ if(fd >= n_redirect_fds) {
+ size_t new_n = 1 << (ffs(fd) + 1);
+ asl_redirect *new_array = realloc(redirect_fds, new_n * sizeof(*redirect_fds));
+ if(!new_array) {
+ err = errno;
+ BLOCK_DONE;
+ }
+ redirect_fds = new_array;
+ memset(redirect_fds + n_redirect_fds, 0, new_n - n_redirect_fds);
+ n_redirect_fds = new_n;
+ }
+
+ /* If we're already listening on it, return error. */
+ if(redirect_fds[fd].buf != NULL) {
+ err = EBADF;
+ BLOCK_DONE;
+ }
+
+ /* Initialize our buffer */
+ redirect_fds[fd].buf = (char *)malloc(BUF_SIZE);
+ if(redirect_fds[fd].buf == NULL) {
+ err = errno;
+ BLOCK_DONE;
+ }
+ redirect_fds[fd].w = redirect_fds[fd].buf;
+
+ /* Store our ASL settings */
+ redirect_fds[fd].level = level;
+ redirect_fds[fd].asl = asl;
+ redirect_fds[fd].msg = msg;
+
+ /* Don't block on reads from this fd */
+ fcntl(fd, F_SETFL, O_NONBLOCK);
+
+ /* Start listening */
+#ifdef HAVE_LIBDISPATCH
+ {
+ dispatch_source_t read_source = dispatch_source_create(DISPATCH_SOURCE_TYPE_READ, fd, 0, redirect_serial_q);
+ redirect_fds[fd].read_source = read_source;
+ dispatch_set_context(read_source, read_source);
+ dispatch_source_set_event_handler_f(read_source, read_from_source);
+ dispatch_source_set_cancel_handler_f(read_source, cancel_source);
+ dispatch_group_enter(read_source_group);
+ dispatch_resume(read_source);
+ }
+#else
+ {
+ struct kevent ev;
+ EV_SET(&ev, fd, EVFILT_READ, EV_ADD, 0, 0, 0);
+ kevent(kq, &ev, 1, NULL, 0, NULL);
+ }
+#endif
+ }
+#ifdef HAVE_LIBDISPATCH
+ );
+#else
+done:
+ assert(pthread_mutex_unlock(&redirect_fds_lock) == 0);
+#endif
+#undef BLOCK_DONE
+
+ return err;
+}
+
+int xq_asl_capture_fd(aslclient asl, aslmsg msg, int level, int fd) {
+ int pipepair[2];
+
+ /* Create pipe */
+ if(pipe(pipepair) == -1)
+ return errno;
+
+ /* Close the read fd but not the write fd on exec */
+ if(fcntl(pipepair[0], F_SETFD, FD_CLOEXEC) == -1)
+ return errno;
+
+ /* Replace the existing fd */
+ if(dup2(pipepair[1], fd) == -1) {
+ close(pipepair[0]);
+ close(pipepair[1]);
+ return errno;
+ }
+
+ /* If we capture STDOUT_FILENO, make sure we linebuffer stdout */
+ if(fd == STDOUT_FILENO)
+ setlinebuf(stdout);
+
+ /* Close the duplicate fds since they've been reassigned */
+ close(pipepair[1]);
+
+ /* Hand off the read end of our pipe to xq_asl_log_fd */
+ return xq_asl_log_fd(asl, msg, level, pipepair[0]);
+}
+
+#ifdef DEBUG_CONSOLE_REDIRECT
+int main(int argc __unused, char **argv __unused) {
+ xq_asl_capture_fd(NULL, NULL, ASL_LEVEL_NOTICE, STDOUT_FILENO);
+ xq_asl_capture_fd(NULL, NULL, ASL_LEVEL_ERR, STDERR_FILENO);
+
+ fprintf(stderr, "TEST ERR1\n");
+ fprintf(stdout, "TEST OUT1\n");
+ fprintf(stderr, "TEST ERR2\n");
+ fprintf(stdout, "TEST OUT2\n");
+ system("/bin/echo SYST OUT");
+ system("/bin/echo SYST ERR >&2");
+ fprintf(stdout, "TEST OUT3\n");
+ fprintf(stdout, "TEST OUT4\n");
+ fprintf(stderr, "TEST ERR3\n");
+ fprintf(stderr, "TEST ERR4\n");
+
+ exit(0);
+}
+#endif
diff --git a/xorg-server/hw/xquartz/darwin.c b/xorg-server/hw/xquartz/darwin.c
index 06099398d..b483000f8 100644
--- a/xorg-server/hw/xquartz/darwin.c
+++ b/xorg-server/hw/xquartz/darwin.c
@@ -1,786 +1,786 @@
-/**************************************************************
- *
- * Xquartz initialization code
- *
- * Copyright (c) 2007-2008 Apple Inc.
- * Copyright (c) 2001-2004 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, 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.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include "os.h"
-#include "servermd.h"
-#include "inputstr.h"
-#include "scrnintstr.h"
-#include "mibstore.h" // mi backing store implementation
-#include "mipointer.h" // mi software cursor
-#include "micmap.h" // mi colormap code
-#include "fb.h" // fb framebuffer code
-#include "site.h"
-#include "globals.h"
-#include "dix.h"
-#include "xkbsrv.h"
-
-#include <X11/extensions/XI.h>
-#include <X11/extensions/XIproto.h>
-#include "exevents.h"
-#include "extinit.h"
-
-#include "xserver-properties.h"
-
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/syslimits.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <stdarg.h>
-
-#define HAS_UTSNAME 1
-#include <sys/utsname.h>
-
-#define NO_CFPLUGIN
-#include <IOKit/hidsystem/IOHIDLib.h>
-
-#ifdef MITSHM
-#include "shmint.h"
-#endif
-
-#include "darwin.h"
-#include "darwinEvents.h"
-#include "quartzKeyboard.h"
-#include "quartz.h"
-
-aslclient aslc;
-
-void xq_asl_log (int level, const char *subsystem, const char *file, const char *function, int line, const char *fmt, ...) {
- va_list args;
- aslmsg msg = asl_new(ASL_TYPE_MSG);
-
- if(msg) {
- char *_line;
-
- asl_set(msg, "File", file);
- asl_set(msg, "Function", function);
- asprintf(&_line, "%d", line);
- if(_line) {
- asl_set(msg, "Line", _line);
- free(_line);
- }
- if(subsystem)
- asl_set(msg, "Subsystem", subsystem);
- }
-
- va_start(args, fmt);
- asl_vlog(aslc, msg, level, fmt, args);
- va_end(args);
-
- if(msg)
- asl_free(msg);
-}
-
-/*
- * X server shared global variables
- */
-int darwinScreensFound = 0;
-DevPrivateKeyRec darwinScreenKeyRec;
-io_connect_t darwinParamConnect = 0;
-int darwinEventReadFD = -1;
-int darwinEventWriteFD = -1;
-// int darwinMouseAccelChange = 1;
-int darwinFakeButtons = 0;
-
-// location of X11's (0,0) point in global screen coordinates
-int darwinMainScreenX = 0;
-int darwinMainScreenY = 0;
-
-// parameters read from the command line or user preferences
-int darwinDesiredDepth = -1;
-int darwinSyncKeymap = FALSE;
-
-// modifier masks for faking mouse buttons - ANY of these bits trigger it (not all)
-#ifdef NX_DEVICELCMDKEYMASK
-int darwinFakeMouse2Mask = NX_DEVICELALTKEYMASK | NX_DEVICERALTKEYMASK;
-int darwinFakeMouse3Mask = NX_DEVICELCMDKEYMASK | NX_DEVICERCMDKEYMASK;
-#else
-int darwinFakeMouse2Mask = NX_ALTERNATEMASK;
-int darwinFakeMouse3Mask = NX_COMMANDMASK;
-#endif
-
-// Modifier mask for overriding event delivery to appkit (might be useful to set this to rcommand for input menu
-unsigned int darwinAppKitModMask = 0; // Any of these bits
-
-// Modifier mask for items in the Window menu (0 and -1 cause shortcuts to be disabled)
-unsigned int windowItemModMask = NX_COMMANDMASK;
-
-// devices
-DeviceIntPtr darwinKeyboard = NULL;
-DeviceIntPtr darwinPointer = NULL;
-DeviceIntPtr darwinTabletStylus = NULL;
-DeviceIntPtr darwinTabletCursor = NULL;
-DeviceIntPtr darwinTabletEraser = NULL;
-
-// Common pixmap formats
-static PixmapFormatRec formats[] = {
- { 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 },
- { 32, 32, BITMAP_SCANLINE_PAD }
-};
-const int NUMFORMATS = sizeof(formats)/sizeof(formats[0]);
-
-void
-DarwinPrintBanner(void)
-{
- ErrorF("Xquartz starting:\n");
- ErrorF("X.Org X Server %s\n", XSERVER_VERSION);
- ErrorF("Build Date: %s\n", BUILD_DATE );
-}
-
-
-/*
- * DarwinSaveScreen
- * X screensaver support. Not implemented.
- */
-static Bool DarwinSaveScreen(ScreenPtr pScreen, int on)
-{
- // FIXME
- if (on == SCREEN_SAVER_FORCER) {
- } else if (on == SCREEN_SAVER_ON) {
- } else {
- }
- return TRUE;
-}
-
-/*
- * DarwinScreenInit
- * This is a callback from dix during AddScreen() from InitOutput().
- * Initialize the screen and communicate information about it back to dix.
- */
-static Bool DarwinScreenInit(int index, ScreenPtr pScreen, int argc, char **argv) {
- int dpi;
- static int foundIndex = 0;
- Bool ret;
- DarwinFramebufferPtr dfb;
-
- if (!dixRegisterPrivateKey(&darwinScreenKeyRec, PRIVATE_SCREEN, 0))
- return FALSE;
-
- // reset index of found screens for each server generation
- if (index == 0) {
- foundIndex = 0;
-
- // reset the visual list
- miClearVisualTypes();
- }
-
- // allocate space for private per screen storage
- dfb = malloc(sizeof(DarwinFramebufferRec));
-
- // SCREEN_PRIV(pScreen) = dfb;
- dixSetPrivate(&pScreen->devPrivates, darwinScreenKey, dfb);
-
- // setup hardware/mode specific details
- ret = QuartzAddScreen(foundIndex, pScreen);
- foundIndex++;
- if (! ret)
- return FALSE;
-
- // setup a single visual appropriate for our pixel type
- if(!miSetVisualTypesAndMasks(dfb->depth, dfb->visuals, dfb->bitsPerRGB,
- dfb->preferredCVC, dfb->redMask,
- dfb->greenMask, dfb->blueMask)) {
- return FALSE;
- }
-
-// TODO: Make PseudoColor visuals not suck in TrueColor mode
-// if(dfb->depth > 8)
-// miSetVisualTypesAndMasks(8, PseudoColorMask, 8, PseudoColor, 0, 0, 0);
- if(dfb->depth > 15)
- miSetVisualTypesAndMasks(15, TrueColorMask, 5, TrueColor, RM_ARGB(0,5,5,5), GM_ARGB(0,5,5,5), BM_ARGB(0,5,5,5));
- if(dfb->depth > 24)
- miSetVisualTypesAndMasks(24, TrueColorMask, 8, TrueColor, RM_ARGB(0,8,8,8), GM_ARGB(0,8,8,8), BM_ARGB(0,8,8,8));
-
- miSetPixmapDepths();
-
- // machine independent screen init
- // setup _Screen structure in pScreen
- if (monitorResolution)
- dpi = monitorResolution;
- else
- dpi = 96;
-
- // initialize fb
- if (! fbScreenInit(pScreen,
- dfb->framebuffer, // pointer to screen bitmap
- dfb->width, dfb->height, // screen size in pixels
- dpi, dpi, // dots per inch
- dfb->pitch/(dfb->bitsPerPixel/8), // pixel width of framebuffer
- dfb->bitsPerPixel)) // bits per pixel for screen
- {
- return FALSE;
- }
-
- if (! fbPictureInit(pScreen, 0, 0)) {
- return FALSE;
- }
-
-#ifdef MITSHM
- ShmRegisterFbFuncs(pScreen);
-#endif
-
- // this must be initialized (why doesn't X have a default?)
- pScreen->SaveScreen = DarwinSaveScreen;
-
- // finish mode dependent screen setup including cursor support
- if (!QuartzSetupScreen(index, pScreen)) {
- return FALSE;
- }
-
- // create and install the default colormap and
- // set pScreen->blackPixel / pScreen->white
- if (!miCreateDefColormap( pScreen )) {
- return FALSE;
- }
-
- pScreen->x = dfb->x;
- pScreen->y = dfb->y;
-
- /* ErrorF("Screen %d added: %dx%d @ (%d,%d)\n",
- index, dfb->width, dfb->height, dfb->x, dfb->y); */
-
- return TRUE;
-}
-
-/*
- =============================================================================
-
- mouse and keyboard callbacks
-
- =============================================================================
-*/
-
-/*
- * DarwinMouseProc: Handle the initialization, etc. of a mouse
- */
-static int DarwinMouseProc(DeviceIntPtr pPointer, int what) {
-#define NBUTTONS 7
-#define NAXES 2
- // 7 buttons: left, right, middle, then four scroll wheel "buttons"
- CARD8 map[NBUTTONS + 1] = {0, 1, 2, 3, 4, 5, 6, 7};
- Atom btn_labels[NBUTTONS] = {0};
- Atom axes_labels[NAXES] = {0};
-
- switch (what) {
- case DEVICE_INIT:
- pPointer->public.on = FALSE;
-
- 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);
- btn_labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT);
- btn_labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT);
-
- axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
- axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
-
-
- // Set button map.
- InitPointerDeviceStruct((DevicePtr)pPointer, map, NBUTTONS,
- btn_labels,
- (PtrCtrlProcPtr)NoopDDA,
- GetMotionHistorySize(), NAXES,
- axes_labels);
- InitValuatorAxisStruct(pPointer, 0, axes_labels[0], NO_AXIS_LIMITS, NO_AXIS_LIMITS, 0, 0, 0, Absolute);
- InitValuatorAxisStruct(pPointer, 1, axes_labels[1], NO_AXIS_LIMITS, NO_AXIS_LIMITS, 0, 0, 0, Absolute);
- break;
- case DEVICE_ON:
- pPointer->public.on = TRUE;
- AddEnabledDevice( darwinEventReadFD );
- return Success;
- case DEVICE_CLOSE:
- case DEVICE_OFF:
- pPointer->public.on = FALSE;
- RemoveEnabledDevice(darwinEventReadFD);
- return Success;
- }
-
- return Success;
-#undef NBUTTONS
-#undef NAXES
-}
-
-static int DarwinTabletProc(DeviceIntPtr pPointer, int what) {
-#define NBUTTONS 3
-#define NAXES 5
- CARD8 map[NBUTTONS + 1] = {0, 1, 2, 3};
- Atom btn_labels[NBUTTONS] = {0};
- Atom axes_labels[NAXES] = {0};
-
- switch (what) {
- case DEVICE_INIT:
- pPointer->public.on = FALSE;
-
- 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);
-
- axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_X);
- axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_Y);
- axes_labels[2] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_PRESSURE);
- axes_labels[3] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_TILT_X);
- axes_labels[4] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_TILT_Y);
-
- // Set button map.
- InitPointerDeviceStruct((DevicePtr)pPointer, map, NBUTTONS,
- btn_labels,
- (PtrCtrlProcPtr)NoopDDA,
- GetMotionHistorySize(), NAXES,
- axes_labels);
- InitProximityClassDeviceStruct(pPointer);
-
- InitValuatorAxisStruct(pPointer, 0, axes_labels[0], 0, XQUARTZ_VALUATOR_LIMIT, 1, 0, 1, Absolute);
- InitValuatorAxisStruct(pPointer, 1, axes_labels[1], 0, XQUARTZ_VALUATOR_LIMIT, 1, 0, 1, Absolute);
- InitValuatorAxisStruct(pPointer, 2, axes_labels[2], 0, XQUARTZ_VALUATOR_LIMIT, 1, 0, 1, Absolute);
- InitValuatorAxisStruct(pPointer, 3, axes_labels[3], -XQUARTZ_VALUATOR_LIMIT, XQUARTZ_VALUATOR_LIMIT, 1, 0, 1, Absolute);
- InitValuatorAxisStruct(pPointer, 4, axes_labels[4], -XQUARTZ_VALUATOR_LIMIT, XQUARTZ_VALUATOR_LIMIT, 1, 0, 1, Absolute);
-// pPointer->use = IsXExtensionDevice;
- break;
- case DEVICE_ON:
- pPointer->public.on = TRUE;
- AddEnabledDevice( darwinEventReadFD );
- return Success;
- case DEVICE_CLOSE:
- case DEVICE_OFF:
- pPointer->public.on = FALSE;
- RemoveEnabledDevice(darwinEventReadFD);
- return Success;
- }
- return Success;
-#undef NBUTTONS
-#undef NAXES
-}
-
-/*
- * DarwinKeybdProc
- * Callback from X
- */
-static int DarwinKeybdProc( DeviceIntPtr pDev, int onoff )
-{
- switch ( onoff ) {
- case DEVICE_INIT:
- DarwinKeyboardInit( pDev );
- break;
- case DEVICE_ON:
- pDev->public.on = TRUE;
- AddEnabledDevice( darwinEventReadFD );
- break;
- case DEVICE_OFF:
- pDev->public.on = FALSE;
- RemoveEnabledDevice( darwinEventReadFD );
- break;
- case DEVICE_CLOSE:
- break;
- }
-
- return Success;
-}
-
-/*
-===========================================================================
-
- Utility routines
-
-===========================================================================
-*/
-
-/*
- * DarwinParseModifierList
- * Parse a list of modifier names and return a corresponding modifier mask
- */
-int DarwinParseModifierList(const char *constmodifiers, int separatelr)
-{
- int result = 0;
-
- if (constmodifiers) {
- char *modifiers = strdup(constmodifiers);
- char *modifier;
- int nxkey;
- char *p = modifiers;
-
- while (p) {
- modifier = strsep(&p, " ,+&|/"); // allow lots of separators
- nxkey = DarwinModifierStringToNXMask(modifier, separatelr);
- if(nxkey)
- result |= nxkey;
- else
- ErrorF("fakebuttons: Unknown modifier \"%s\"\n", modifier);
- }
- free(modifiers);
- }
- return result;
-}
-
-/*
-===========================================================================
-
- Functions needed to link against device independent X
-
-===========================================================================
-*/
-
-/*
- * InitInput
- * Register the keyboard and mouse devices
- */
-void InitInput( int argc, char **argv )
-{
- XkbRMLVOSet rmlvo = { .rules = "base", .model = "empty", .layout = "empty",
- .variant = NULL, .options = NULL };
- /* We need to really have rules... or something... */
- XkbSetRulesDflts(&rmlvo);
-
- darwinKeyboard = AddInputDevice(serverClient, DarwinKeybdProc, TRUE);
- darwinKeyboard->name = strdup("keyboard");
-
- /* here's the snippet from the current gdk sources:
- if (!strcmp (tmp_name, "pointer"))
- gdkdev->info.source = GDK_SOURCE_MOUSE;
- else if (!strcmp (tmp_name, "wacom") ||
- !strcmp (tmp_name, "pen"))
- gdkdev->info.source = GDK_SOURCE_PEN;
- else if (!strcmp (tmp_name, "eraser"))
- gdkdev->info.source = GDK_SOURCE_ERASER;
- else if (!strcmp (tmp_name, "cursor"))
- gdkdev->info.source = GDK_SOURCE_CURSOR;
- else
- gdkdev->info.source = GDK_SOURCE_PEN;
- */
-
- darwinPointer = AddInputDevice(serverClient, DarwinMouseProc, TRUE);
- darwinPointer->name = strdup("pointer");
-
- darwinTabletStylus = AddInputDevice(serverClient, DarwinTabletProc, TRUE);
- darwinTabletStylus->name = strdup("pen");
-
- darwinTabletCursor = AddInputDevice(serverClient, DarwinTabletProc, TRUE);
- darwinTabletCursor->name = strdup("cursor");
-
- darwinTabletEraser = AddInputDevice(serverClient, DarwinTabletProc, TRUE);
- darwinTabletEraser->name = strdup("eraser");
-
- DarwinEQInit();
-
- QuartzInitInput(argc, argv);
-}
-
-void CloseInput(void)
-{
- DarwinEQFini();
-}
-
-/*
- * DarwinAdjustScreenOrigins
- * Shift all screens so the X11 (0, 0) coordinate is at the top
- * left of the global screen coordinates.
- *
- * Screens can be arranged so the top left isn't on any screen, so
- * instead use the top left of the leftmost screen as (0,0). This
- * may mean some screen space is in -y, but it's better that (0,0)
- * be onscreen, or else default xterms disappear. It's better that
- * -y be used than -x, because when popup menus are forced
- * "onscreen" by dumb window managers like twm, they'll shift the
- * menus down instead of left, which still looks funny but is an
- * easier target to hit.
- */
-void
-DarwinAdjustScreenOrigins(ScreenInfo *pScreenInfo)
-{
- int i, left, top;
-
- left = pScreenInfo->screens[0]->x;
- top = pScreenInfo->screens[0]->y;
-
- /* Find leftmost screen. If there's a tie, take the topmost of the two. */
- for (i = 1; i < pScreenInfo->numScreens; i++) {
- if (pScreenInfo->screens[i]->x < left ||
- (pScreenInfo->screens[i]->x == left && pScreenInfo->screens[i]->y < top))
- {
- left = pScreenInfo->screens[i]->x;
- top = pScreenInfo->screens[i]->y;
- }
- }
-
- darwinMainScreenX = left;
- darwinMainScreenY = top;
-
- DEBUG_LOG("top = %d, left=%d\n", top, left);
-
- /* Shift all screens so that there is a screen whose top left
- * is at X11 (0,0) and at global screen coordinate
- * (darwinMainScreenX, darwinMainScreenY).
- */
-
- if (darwinMainScreenX != 0 || darwinMainScreenY != 0) {
- for (i = 0; i < pScreenInfo->numScreens; i++) {
- pScreenInfo->screens[i]->x -= darwinMainScreenX;
- pScreenInfo->screens[i]->y -= darwinMainScreenY;
- DEBUG_LOG("Screen %d placed at X11 coordinate (%d,%d).\n",
- i, pScreenInfo->screens[i]->x, pScreenInfo->screens[i]->y);
- }
- }
-}
-
-
-/*
- * InitOutput
- * Initialize screenInfo for all actually accessible framebuffers.
- *
- * The display mode dependent code gets called three times. The mode
- * specific InitOutput routines are expected to discover the number
- * of potentially useful screens and cache routes to them internally.
- * Inside DarwinScreenInit are two other mode specific calls.
- * A mode specific AddScreen routine is called for each screen to
- * actually initialize the screen with the ScreenPtr structure.
- * After other screen setup has been done, a mode specific
- * SetupScreen function can be called to finalize screen setup.
- */
-void InitOutput( ScreenInfo *pScreenInfo, int argc, char **argv )
-{
- int i;
-
- pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
- pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
- pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
- pScreenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
-
- // List how we want common pixmap formats to be padded
- pScreenInfo->numPixmapFormats = NUMFORMATS;
- for (i = 0; i < NUMFORMATS; i++)
- pScreenInfo->formats[i] = formats[i];
-
- // Discover screens and do mode specific initialization
- QuartzInitOutput(argc, argv);
-
- // Add screens
- for (i = 0; i < darwinScreensFound; i++) {
- AddScreen(DarwinScreenInit, argc, argv);
- }
-
- DarwinAdjustScreenOrigins(pScreenInfo);
-}
-
-
-/*
- * OsVendorFatalError
- */
-void OsVendorFatalError( void )
-{
- ErrorF( " OsVendorFatalError\n" );
-}
-
-
-/*
- * OsVendorInit
- * Initialization of Darwin OS support.
- */
-void OsVendorInit(void)
-{
- if (serverGeneration == 1) {
- char *lf;
- char *home = getenv("HOME");
- assert(home);
- assert(0 < asprintf(&lf, "%s/Library/Logs/X11.%s.log", home, bundle_id_prefix));
- LogInit(lf, ".old");
- free(lf);
-
- DarwinPrintBanner();
-#ifdef ENABLE_DEBUG_LOG
- {
- char *home_dir=NULL, *log_file_path=NULL;
- home_dir = getenv("HOME");
- if (home_dir) asprintf(&log_file_path, "%s/%s", home_dir, DEBUG_LOG_NAME);
- if (log_file_path) {
- if (!access(log_file_path, F_OK)) {
- debug_log_fp = fopen(log_file_path, "a");
- if (debug_log_fp) ErrorF("Debug logging enabled to %s\n", log_file_path);
- }
- free(log_file_path);
- }
- }
-#endif
- }
-}
-
-
-/*
- * ddxProcessArgument
- * Process device-dependent command line args. Returns 0 if argument is
- * not device dependent, otherwise Count of number of elements of argv
- * that are part of a device dependent commandline option.
- */
-int ddxProcessArgument( int argc, char *argv[], int i )
-{
-// if ( !strcmp( argv[i], "-fullscreen" ) ) {
-// ErrorF( "Running full screen in parallel with Mac OS X Quartz window server.\n" );
-// return 1;
-// }
-
-// if ( !strcmp( argv[i], "-rootless" ) ) {
-// ErrorF( "Running rootless inside Mac OS X window server.\n" );
-// return 1;
-// }
-
- // This command line arg is passed when launched from the Aqua GUI.
- if ( !strncmp( argv[i], "-psn_", 5 ) ) {
- return 1;
- }
-
- if ( !strcmp( argv[i], "-fakebuttons" ) ) {
- darwinFakeButtons = TRUE;
- ErrorF( "Faking a three button mouse\n" );
- return 1;
- }
-
- if ( !strcmp( argv[i], "-nofakebuttons" ) ) {
- darwinFakeButtons = FALSE;
- ErrorF( "Not faking a three button mouse\n" );
- return 1;
- }
-
- if (!strcmp( argv[i], "-fakemouse2" ) ) {
- if ( i == argc-1 ) {
- FatalError( "-fakemouse2 must be followed by a modifer list\n" );
- }
- if (!strcasecmp(argv[i+1], "none") || !strcmp(argv[i+1], ""))
- darwinFakeMouse2Mask = 0;
- else
- darwinFakeMouse2Mask = DarwinParseModifierList(argv[i+1], 1);
- ErrorF("Modifier mask to fake mouse button 2 = 0x%x\n",
- darwinFakeMouse2Mask);
- return 2;
- }
-
- if (!strcmp( argv[i], "-fakemouse3" ) ) {
- if ( i == argc-1 ) {
- FatalError( "-fakemouse3 must be followed by a modifer list\n" );
- }
- if (!strcasecmp(argv[i+1], "none") || !strcmp(argv[i+1], ""))
- darwinFakeMouse3Mask = 0;
- else
- darwinFakeMouse3Mask = DarwinParseModifierList(argv[i+1], 1);
- ErrorF("Modifier mask to fake mouse button 3 = 0x%x\n",
- darwinFakeMouse3Mask);
- return 2;
- }
-
- if ( !strcmp( argv[i], "+synckeymap" ) ) {
- darwinSyncKeymap = TRUE;
- return 1;
- }
-
- if ( !strcmp( argv[i], "-synckeymap" ) ) {
- darwinSyncKeymap = FALSE;
- return 1;
- }
-
- if ( !strcmp( argv[i], "-depth" ) ) {
- if ( i == argc-1 ) {
- FatalError( "-depth must be followed by a number\n" );
- }
- darwinDesiredDepth = atoi( argv[i+1] );
- if(darwinDesiredDepth != -1 &&
- darwinDesiredDepth != 8 &&
- darwinDesiredDepth != 15 &&
- darwinDesiredDepth != 24) {
- FatalError( "Unsupported pixel depth. Use 8, 15, or 24 bits\n" );
- }
-
- ErrorF( "Attempting to use pixel depth of %i\n", darwinDesiredDepth );
- return 2;
- }
-
- if (!strcmp( argv[i], "-showconfig" ) || !strcmp( argv[i], "-version" )) {
- DarwinPrintBanner();
- exit(0);
- }
-
- return 0;
-}
-
-
-/*
- * ddxUseMsg --
- * Print out correct use of device dependent commandline options.
- * Maybe the user now knows what really to do ...
- */
-void ddxUseMsg( void )
-{
- ErrorF("\n");
- ErrorF("\n");
- ErrorF("Device Dependent Usage:\n");
- ErrorF("\n");
- ErrorF("-depth <8,15,24> : use this bit depth.\n");
- ErrorF("-fakebuttons : fake a three button mouse with Command and Option keys.\n");
- ErrorF("-nofakebuttons : don't fake a three button mouse.\n");
- ErrorF("-fakemouse2 <modifiers> : fake middle mouse button with modifier keys.\n");
- ErrorF("-fakemouse3 <modifiers> : fake right mouse button with modifier keys.\n");
- ErrorF(" ex: -fakemouse2 \"option,shift\" = option-shift-click is middle button.\n");
- ErrorF("-version : show the server version.\n");
- ErrorF("\n");
-}
-
-
-/*
- * ddxGiveUp --
- * Device dependent cleanup. Called by dix before normal server death.
- */
-void ddxGiveUp( enum ExitCode error )
-{
- LogClose(error);
-}
-
-
-/*
- * AbortDDX --
- * DDX - specific abort routine. Called by AbortServer(). The attempt is
- * made to restore all original setting of the displays. Also all devices
- * are closed.
- */
-_X_NORETURN
-void AbortDDX( enum ExitCode error ) {
- ErrorF( " AbortDDX\n" );
- OsAbort();
-}
-
+/**************************************************************
+ *
+ * Xquartz initialization code
+ *
+ * Copyright (c) 2007-2008 Apple Inc.
+ * Copyright (c) 2001-2004 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, 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.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "os.h"
+#include "servermd.h"
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "mibstore.h" // mi backing store implementation
+#include "mipointer.h" // mi software cursor
+#include "micmap.h" // mi colormap code
+#include "fb.h" // fb framebuffer code
+#include "site.h"
+#include "globals.h"
+#include "dix.h"
+#include "xkbsrv.h"
+
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "exevents.h"
+#include "extinit.h"
+
+#include "xserver-properties.h"
+
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/syslimits.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdarg.h>
+
+#define HAS_UTSNAME 1
+#include <sys/utsname.h>
+
+#define NO_CFPLUGIN
+#include <IOKit/hidsystem/IOHIDLib.h>
+
+#ifdef MITSHM
+#include "shmint.h"
+#endif
+
+#include "darwin.h"
+#include "darwinEvents.h"
+#include "quartzKeyboard.h"
+#include "quartz.h"
+
+aslclient aslc;
+
+void xq_asl_log (int level, const char *subsystem, const char *file, const char *function, int line, const char *fmt, ...) {
+ va_list args;
+ aslmsg msg = asl_new(ASL_TYPE_MSG);
+
+ if(msg) {
+ char *_line;
+
+ asl_set(msg, "File", file);
+ asl_set(msg, "Function", function);
+ asprintf(&_line, "%d", line);
+ if(_line) {
+ asl_set(msg, "Line", _line);
+ free(_line);
+ }
+ if(subsystem)
+ asl_set(msg, "Subsystem", subsystem);
+ }
+
+ va_start(args, fmt);
+ asl_vlog(aslc, msg, level, fmt, args);
+ va_end(args);
+
+ if(msg)
+ asl_free(msg);
+}
+
+/*
+ * X server shared global variables
+ */
+int darwinScreensFound = 0;
+DevPrivateKeyRec darwinScreenKeyRec;
+io_connect_t darwinParamConnect = 0;
+int darwinEventReadFD = -1;
+int darwinEventWriteFD = -1;
+// int darwinMouseAccelChange = 1;
+int darwinFakeButtons = 0;
+
+// location of X11's (0,0) point in global screen coordinates
+int darwinMainScreenX = 0;
+int darwinMainScreenY = 0;
+
+// parameters read from the command line or user preferences
+int darwinDesiredDepth = -1;
+int darwinSyncKeymap = FALSE;
+
+// modifier masks for faking mouse buttons - ANY of these bits trigger it (not all)
+#ifdef NX_DEVICELCMDKEYMASK
+int darwinFakeMouse2Mask = NX_DEVICELALTKEYMASK | NX_DEVICERALTKEYMASK;
+int darwinFakeMouse3Mask = NX_DEVICELCMDKEYMASK | NX_DEVICERCMDKEYMASK;
+#else
+int darwinFakeMouse2Mask = NX_ALTERNATEMASK;
+int darwinFakeMouse3Mask = NX_COMMANDMASK;
+#endif
+
+// Modifier mask for overriding event delivery to appkit (might be useful to set this to rcommand for input menu
+unsigned int darwinAppKitModMask = 0; // Any of these bits
+
+// Modifier mask for items in the Window menu (0 and -1 cause shortcuts to be disabled)
+unsigned int windowItemModMask = NX_COMMANDMASK;
+
+// devices
+DeviceIntPtr darwinKeyboard = NULL;
+DeviceIntPtr darwinPointer = NULL;
+DeviceIntPtr darwinTabletStylus = NULL;
+DeviceIntPtr darwinTabletCursor = NULL;
+DeviceIntPtr darwinTabletEraser = NULL;
+
+// Common pixmap formats
+static PixmapFormatRec formats[] = {
+ { 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 },
+ { 32, 32, BITMAP_SCANLINE_PAD }
+};
+const int NUMFORMATS = sizeof(formats)/sizeof(formats[0]);
+
+void
+DarwinPrintBanner(void)
+{
+ ErrorF("Xquartz starting:\n");
+ ErrorF("X.Org X Server %s\n", XSERVER_VERSION);
+ ErrorF("Build Date: %s\n", BUILD_DATE );
+}
+
+
+/*
+ * DarwinSaveScreen
+ * X screensaver support. Not implemented.
+ */
+static Bool DarwinSaveScreen(ScreenPtr pScreen, int on)
+{
+ // FIXME
+ if (on == SCREEN_SAVER_FORCER) {
+ } else if (on == SCREEN_SAVER_ON) {
+ } else {
+ }
+ return TRUE;
+}
+
+/*
+ * DarwinScreenInit
+ * This is a callback from dix during AddScreen() from InitOutput().
+ * Initialize the screen and communicate information about it back to dix.
+ */
+static Bool DarwinScreenInit(int index, ScreenPtr pScreen, int argc, char **argv) {
+ int dpi;
+ static int foundIndex = 0;
+ Bool ret;
+ DarwinFramebufferPtr dfb;
+
+ if (!dixRegisterPrivateKey(&darwinScreenKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
+ // reset index of found screens for each server generation
+ if (index == 0) {
+ foundIndex = 0;
+
+ // reset the visual list
+ miClearVisualTypes();
+ }
+
+ // allocate space for private per screen storage
+ dfb = malloc(sizeof(DarwinFramebufferRec));
+
+ // SCREEN_PRIV(pScreen) = dfb;
+ dixSetPrivate(&pScreen->devPrivates, darwinScreenKey, dfb);
+
+ // setup hardware/mode specific details
+ ret = QuartzAddScreen(foundIndex, pScreen);
+ foundIndex++;
+ if (! ret)
+ return FALSE;
+
+ // setup a single visual appropriate for our pixel type
+ if(!miSetVisualTypesAndMasks(dfb->depth, dfb->visuals, dfb->bitsPerRGB,
+ dfb->preferredCVC, dfb->redMask,
+ dfb->greenMask, dfb->blueMask)) {
+ return FALSE;
+ }
+
+// TODO: Make PseudoColor visuals not suck in TrueColor mode
+// if(dfb->depth > 8)
+// miSetVisualTypesAndMasks(8, PseudoColorMask, 8, PseudoColor, 0, 0, 0);
+ if(dfb->depth > 15)
+ miSetVisualTypesAndMasks(15, TrueColorMask, 5, TrueColor, RM_ARGB(0,5,5,5), GM_ARGB(0,5,5,5), BM_ARGB(0,5,5,5));
+ if(dfb->depth > 24)
+ miSetVisualTypesAndMasks(24, TrueColorMask, 8, TrueColor, RM_ARGB(0,8,8,8), GM_ARGB(0,8,8,8), BM_ARGB(0,8,8,8));
+
+ miSetPixmapDepths();
+
+ // machine independent screen init
+ // setup _Screen structure in pScreen
+ if (monitorResolution)
+ dpi = monitorResolution;
+ else
+ dpi = 96;
+
+ // initialize fb
+ if (! fbScreenInit(pScreen,
+ dfb->framebuffer, // pointer to screen bitmap
+ dfb->width, dfb->height, // screen size in pixels
+ dpi, dpi, // dots per inch
+ dfb->pitch/(dfb->bitsPerPixel/8), // pixel width of framebuffer
+ dfb->bitsPerPixel)) // bits per pixel for screen
+ {
+ return FALSE;
+ }
+
+ if (! fbPictureInit(pScreen, 0, 0)) {
+ return FALSE;
+ }
+
+#ifdef MITSHM
+ ShmRegisterFbFuncs(pScreen);
+#endif
+
+ // this must be initialized (why doesn't X have a default?)
+ pScreen->SaveScreen = DarwinSaveScreen;
+
+ // finish mode dependent screen setup including cursor support
+ if (!QuartzSetupScreen(index, pScreen)) {
+ return FALSE;
+ }
+
+ // create and install the default colormap and
+ // set pScreen->blackPixel / pScreen->white
+ if (!miCreateDefColormap( pScreen )) {
+ return FALSE;
+ }
+
+ pScreen->x = dfb->x;
+ pScreen->y = dfb->y;
+
+ /* ErrorF("Screen %d added: %dx%d @ (%d,%d)\n",
+ index, dfb->width, dfb->height, dfb->x, dfb->y); */
+
+ return TRUE;
+}
+
+/*
+ =============================================================================
+
+ mouse and keyboard callbacks
+
+ =============================================================================
+*/
+
+/*
+ * DarwinMouseProc: Handle the initialization, etc. of a mouse
+ */
+static int DarwinMouseProc(DeviceIntPtr pPointer, int what) {
+#define NBUTTONS 7
+#define NAXES 2
+ // 7 buttons: left, right, middle, then four scroll wheel "buttons"
+ CARD8 map[NBUTTONS + 1] = {0, 1, 2, 3, 4, 5, 6, 7};
+ Atom btn_labels[NBUTTONS] = {0};
+ Atom axes_labels[NAXES] = {0};
+
+ switch (what) {
+ case DEVICE_INIT:
+ pPointer->public.on = FALSE;
+
+ 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);
+ btn_labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT);
+ btn_labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT);
+
+ axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
+ axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
+
+
+ // Set button map.
+ InitPointerDeviceStruct((DevicePtr)pPointer, map, NBUTTONS,
+ btn_labels,
+ (PtrCtrlProcPtr)NoopDDA,
+ GetMotionHistorySize(), NAXES,
+ axes_labels);
+ InitValuatorAxisStruct(pPointer, 0, axes_labels[0], NO_AXIS_LIMITS, NO_AXIS_LIMITS, 0, 0, 0, Absolute);
+ InitValuatorAxisStruct(pPointer, 1, axes_labels[1], NO_AXIS_LIMITS, NO_AXIS_LIMITS, 0, 0, 0, Absolute);
+ break;
+ case DEVICE_ON:
+ pPointer->public.on = TRUE;
+ AddEnabledDevice( darwinEventReadFD );
+ return Success;
+ case DEVICE_CLOSE:
+ case DEVICE_OFF:
+ pPointer->public.on = FALSE;
+ RemoveEnabledDevice(darwinEventReadFD);
+ return Success;
+ }
+
+ return Success;
+#undef NBUTTONS
+#undef NAXES
+}
+
+static int DarwinTabletProc(DeviceIntPtr pPointer, int what) {
+#define NBUTTONS 3
+#define NAXES 5
+ CARD8 map[NBUTTONS + 1] = {0, 1, 2, 3};
+ Atom btn_labels[NBUTTONS] = {0};
+ Atom axes_labels[NAXES] = {0};
+
+ switch (what) {
+ case DEVICE_INIT:
+ pPointer->public.on = FALSE;
+
+ 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);
+
+ axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_X);
+ axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_Y);
+ axes_labels[2] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_PRESSURE);
+ axes_labels[3] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_TILT_X);
+ axes_labels[4] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_TILT_Y);
+
+ // Set button map.
+ InitPointerDeviceStruct((DevicePtr)pPointer, map, NBUTTONS,
+ btn_labels,
+ (PtrCtrlProcPtr)NoopDDA,
+ GetMotionHistorySize(), NAXES,
+ axes_labels);
+ InitProximityClassDeviceStruct(pPointer);
+
+ InitValuatorAxisStruct(pPointer, 0, axes_labels[0], 0, XQUARTZ_VALUATOR_LIMIT, 1, 0, 1, Absolute);
+ InitValuatorAxisStruct(pPointer, 1, axes_labels[1], 0, XQUARTZ_VALUATOR_LIMIT, 1, 0, 1, Absolute);
+ InitValuatorAxisStruct(pPointer, 2, axes_labels[2], 0, XQUARTZ_VALUATOR_LIMIT, 1, 0, 1, Absolute);
+ InitValuatorAxisStruct(pPointer, 3, axes_labels[3], -XQUARTZ_VALUATOR_LIMIT, XQUARTZ_VALUATOR_LIMIT, 1, 0, 1, Absolute);
+ InitValuatorAxisStruct(pPointer, 4, axes_labels[4], -XQUARTZ_VALUATOR_LIMIT, XQUARTZ_VALUATOR_LIMIT, 1, 0, 1, Absolute);
+// pPointer->use = IsXExtensionDevice;
+ break;
+ case DEVICE_ON:
+ pPointer->public.on = TRUE;
+ AddEnabledDevice( darwinEventReadFD );
+ return Success;
+ case DEVICE_CLOSE:
+ case DEVICE_OFF:
+ pPointer->public.on = FALSE;
+ RemoveEnabledDevice(darwinEventReadFD);
+ return Success;
+ }
+ return Success;
+#undef NBUTTONS
+#undef NAXES
+}
+
+/*
+ * DarwinKeybdProc
+ * Callback from X
+ */
+static int DarwinKeybdProc( DeviceIntPtr pDev, int onoff )
+{
+ switch ( onoff ) {
+ case DEVICE_INIT:
+ DarwinKeyboardInit( pDev );
+ break;
+ case DEVICE_ON:
+ pDev->public.on = TRUE;
+ AddEnabledDevice( darwinEventReadFD );
+ break;
+ case DEVICE_OFF:
+ pDev->public.on = FALSE;
+ RemoveEnabledDevice( darwinEventReadFD );
+ break;
+ case DEVICE_CLOSE:
+ break;
+ }
+
+ return Success;
+}
+
+/*
+===========================================================================
+
+ Utility routines
+
+===========================================================================
+*/
+
+/*
+ * DarwinParseModifierList
+ * Parse a list of modifier names and return a corresponding modifier mask
+ */
+int DarwinParseModifierList(const char *constmodifiers, int separatelr)
+{
+ int result = 0;
+
+ if (constmodifiers) {
+ char *modifiers = strdup(constmodifiers);
+ char *modifier;
+ int nxkey;
+ char *p = modifiers;
+
+ while (p) {
+ modifier = strsep(&p, " ,+&|/"); // allow lots of separators
+ nxkey = DarwinModifierStringToNXMask(modifier, separatelr);
+ if(nxkey)
+ result |= nxkey;
+ else
+ ErrorF("fakebuttons: Unknown modifier \"%s\"\n", modifier);
+ }
+ free(modifiers);
+ }
+ return result;
+}
+
+/*
+===========================================================================
+
+ Functions needed to link against device independent X
+
+===========================================================================
+*/
+
+/*
+ * InitInput
+ * Register the keyboard and mouse devices
+ */
+void InitInput( int argc, char **argv )
+{
+ XkbRMLVOSet rmlvo = { .rules = "base", .model = "empty", .layout = "empty",
+ .variant = NULL, .options = NULL };
+ /* We need to really have rules... or something... */
+ XkbSetRulesDflts(&rmlvo);
+
+ darwinKeyboard = AddInputDevice(serverClient, DarwinKeybdProc, TRUE);
+ darwinKeyboard->name = strdup("keyboard");
+
+ /* here's the snippet from the current gdk sources:
+ if (!strcmp (tmp_name, "pointer"))
+ gdkdev->info.source = GDK_SOURCE_MOUSE;
+ else if (!strcmp (tmp_name, "wacom") ||
+ !strcmp (tmp_name, "pen"))
+ gdkdev->info.source = GDK_SOURCE_PEN;
+ else if (!strcmp (tmp_name, "eraser"))
+ gdkdev->info.source = GDK_SOURCE_ERASER;
+ else if (!strcmp (tmp_name, "cursor"))
+ gdkdev->info.source = GDK_SOURCE_CURSOR;
+ else
+ gdkdev->info.source = GDK_SOURCE_PEN;
+ */
+
+ darwinPointer = AddInputDevice(serverClient, DarwinMouseProc, TRUE);
+ darwinPointer->name = strdup("pointer");
+
+ darwinTabletStylus = AddInputDevice(serverClient, DarwinTabletProc, TRUE);
+ darwinTabletStylus->name = strdup("pen");
+
+ darwinTabletCursor = AddInputDevice(serverClient, DarwinTabletProc, TRUE);
+ darwinTabletCursor->name = strdup("cursor");
+
+ darwinTabletEraser = AddInputDevice(serverClient, DarwinTabletProc, TRUE);
+ darwinTabletEraser->name = strdup("eraser");
+
+ DarwinEQInit();
+
+ QuartzInitInput(argc, argv);
+}
+
+void CloseInput(void)
+{
+ DarwinEQFini();
+}
+
+/*
+ * DarwinAdjustScreenOrigins
+ * Shift all screens so the X11 (0, 0) coordinate is at the top
+ * left of the global screen coordinates.
+ *
+ * Screens can be arranged so the top left isn't on any screen, so
+ * instead use the top left of the leftmost screen as (0,0). This
+ * may mean some screen space is in -y, but it's better that (0,0)
+ * be onscreen, or else default xterms disappear. It's better that
+ * -y be used than -x, because when popup menus are forced
+ * "onscreen" by dumb window managers like twm, they'll shift the
+ * menus down instead of left, which still looks funny but is an
+ * easier target to hit.
+ */
+void
+DarwinAdjustScreenOrigins(ScreenInfo *pScreenInfo)
+{
+ int i, left, top;
+
+ left = pScreenInfo->screens[0]->x;
+ top = pScreenInfo->screens[0]->y;
+
+ /* Find leftmost screen. If there's a tie, take the topmost of the two. */
+ for (i = 1; i < pScreenInfo->numScreens; i++) {
+ if (pScreenInfo->screens[i]->x < left ||
+ (pScreenInfo->screens[i]->x == left && pScreenInfo->screens[i]->y < top))
+ {
+ left = pScreenInfo->screens[i]->x;
+ top = pScreenInfo->screens[i]->y;
+ }
+ }
+
+ darwinMainScreenX = left;
+ darwinMainScreenY = top;
+
+ DEBUG_LOG("top = %d, left=%d\n", top, left);
+
+ /* Shift all screens so that there is a screen whose top left
+ * is at X11 (0,0) and at global screen coordinate
+ * (darwinMainScreenX, darwinMainScreenY).
+ */
+
+ if (darwinMainScreenX != 0 || darwinMainScreenY != 0) {
+ for (i = 0; i < pScreenInfo->numScreens; i++) {
+ pScreenInfo->screens[i]->x -= darwinMainScreenX;
+ pScreenInfo->screens[i]->y -= darwinMainScreenY;
+ DEBUG_LOG("Screen %d placed at X11 coordinate (%d,%d).\n",
+ i, pScreenInfo->screens[i]->x, pScreenInfo->screens[i]->y);
+ }
+ }
+}
+
+
+/*
+ * InitOutput
+ * Initialize screenInfo for all actually accessible framebuffers.
+ *
+ * The display mode dependent code gets called three times. The mode
+ * specific InitOutput routines are expected to discover the number
+ * of potentially useful screens and cache routes to them internally.
+ * Inside DarwinScreenInit are two other mode specific calls.
+ * A mode specific AddScreen routine is called for each screen to
+ * actually initialize the screen with the ScreenPtr structure.
+ * After other screen setup has been done, a mode specific
+ * SetupScreen function can be called to finalize screen setup.
+ */
+void InitOutput( ScreenInfo *pScreenInfo, int argc, char **argv )
+{
+ int i;
+
+ pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
+ pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
+ pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
+ pScreenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
+
+ // List how we want common pixmap formats to be padded
+ pScreenInfo->numPixmapFormats = NUMFORMATS;
+ for (i = 0; i < NUMFORMATS; i++)
+ pScreenInfo->formats[i] = formats[i];
+
+ // Discover screens and do mode specific initialization
+ QuartzInitOutput(argc, argv);
+
+ // Add screens
+ for (i = 0; i < darwinScreensFound; i++) {
+ AddScreen(DarwinScreenInit, argc, argv);
+ }
+
+ DarwinAdjustScreenOrigins(pScreenInfo);
+}
+
+
+/*
+ * OsVendorFatalError
+ */
+void OsVendorFatalError( void )
+{
+ ErrorF( " OsVendorFatalError\n" );
+}
+
+
+/*
+ * OsVendorInit
+ * Initialization of Darwin OS support.
+ */
+void OsVendorInit(void)
+{
+ if (serverGeneration == 1) {
+ char *lf;
+ char *home = getenv("HOME");
+ assert(home);
+ assert(0 < asprintf(&lf, "%s/Library/Logs/X11.%s.log", home, bundle_id_prefix));
+ LogInit(lf, ".old");
+ free(lf);
+
+ DarwinPrintBanner();
+#ifdef ENABLE_DEBUG_LOG
+ {
+ char *home_dir=NULL, *log_file_path=NULL;
+ home_dir = getenv("HOME");
+ if (home_dir) asprintf(&log_file_path, "%s/%s", home_dir, DEBUG_LOG_NAME);
+ if (log_file_path) {
+ if (!access(log_file_path, F_OK)) {
+ debug_log_fp = fopen(log_file_path, "a");
+ if (debug_log_fp) ErrorF("Debug logging enabled to %s\n", log_file_path);
+ }
+ free(log_file_path);
+ }
+ }
+#endif
+ }
+}
+
+
+/*
+ * ddxProcessArgument
+ * Process device-dependent command line args. Returns 0 if argument is
+ * not device dependent, otherwise Count of number of elements of argv
+ * that are part of a device dependent commandline option.
+ */
+int ddxProcessArgument( int argc, char *argv[], int i )
+{
+// if ( !strcmp( argv[i], "-fullscreen" ) ) {
+// ErrorF( "Running full screen in parallel with Mac OS X Quartz window server.\n" );
+// return 1;
+// }
+
+// if ( !strcmp( argv[i], "-rootless" ) ) {
+// ErrorF( "Running rootless inside Mac OS X window server.\n" );
+// return 1;
+// }
+
+ // This command line arg is passed when launched from the Aqua GUI.
+ if ( !strncmp( argv[i], "-psn_", 5 ) ) {
+ return 1;
+ }
+
+ if ( !strcmp( argv[i], "-fakebuttons" ) ) {
+ darwinFakeButtons = TRUE;
+ ErrorF( "Faking a three button mouse\n" );
+ return 1;
+ }
+
+ if ( !strcmp( argv[i], "-nofakebuttons" ) ) {
+ darwinFakeButtons = FALSE;
+ ErrorF( "Not faking a three button mouse\n" );
+ return 1;
+ }
+
+ if (!strcmp( argv[i], "-fakemouse2" ) ) {
+ if ( i == argc-1 ) {
+ FatalError( "-fakemouse2 must be followed by a modifer list\n" );
+ }
+ if (!strcasecmp(argv[i+1], "none") || !strcmp(argv[i+1], ""))
+ darwinFakeMouse2Mask = 0;
+ else
+ darwinFakeMouse2Mask = DarwinParseModifierList(argv[i+1], 1);
+ ErrorF("Modifier mask to fake mouse button 2 = 0x%x\n",
+ darwinFakeMouse2Mask);
+ return 2;
+ }
+
+ if (!strcmp( argv[i], "-fakemouse3" ) ) {
+ if ( i == argc-1 ) {
+ FatalError( "-fakemouse3 must be followed by a modifer list\n" );
+ }
+ if (!strcasecmp(argv[i+1], "none") || !strcmp(argv[i+1], ""))
+ darwinFakeMouse3Mask = 0;
+ else
+ darwinFakeMouse3Mask = DarwinParseModifierList(argv[i+1], 1);
+ ErrorF("Modifier mask to fake mouse button 3 = 0x%x\n",
+ darwinFakeMouse3Mask);
+ return 2;
+ }
+
+ if ( !strcmp( argv[i], "+synckeymap" ) ) {
+ darwinSyncKeymap = TRUE;
+ return 1;
+ }
+
+ if ( !strcmp( argv[i], "-synckeymap" ) ) {
+ darwinSyncKeymap = FALSE;
+ return 1;
+ }
+
+ if ( !strcmp( argv[i], "-depth" ) ) {
+ if ( i == argc-1 ) {
+ FatalError( "-depth must be followed by a number\n" );
+ }
+ darwinDesiredDepth = atoi( argv[i+1] );
+ if(darwinDesiredDepth != -1 &&
+ darwinDesiredDepth != 8 &&
+ darwinDesiredDepth != 15 &&
+ darwinDesiredDepth != 24) {
+ FatalError( "Unsupported pixel depth. Use 8, 15, or 24 bits\n" );
+ }
+
+ ErrorF( "Attempting to use pixel depth of %i\n", darwinDesiredDepth );
+ return 2;
+ }
+
+ if (!strcmp( argv[i], "-showconfig" ) || !strcmp( argv[i], "-version" )) {
+ DarwinPrintBanner();
+ exit(0);
+ }
+
+ return 0;
+}
+
+
+/*
+ * ddxUseMsg --
+ * Print out correct use of device dependent commandline options.
+ * Maybe the user now knows what really to do ...
+ */
+void ddxUseMsg( void )
+{
+ ErrorF("\n");
+ ErrorF("\n");
+ ErrorF("Device Dependent Usage:\n");
+ ErrorF("\n");
+ ErrorF("-depth <8,15,24> : use this bit depth.\n");
+ ErrorF("-fakebuttons : fake a three button mouse with Command and Option keys.\n");
+ ErrorF("-nofakebuttons : don't fake a three button mouse.\n");
+ ErrorF("-fakemouse2 <modifiers> : fake middle mouse button with modifier keys.\n");
+ ErrorF("-fakemouse3 <modifiers> : fake right mouse button with modifier keys.\n");
+ ErrorF(" ex: -fakemouse2 \"option,shift\" = option-shift-click is middle button.\n");
+ ErrorF("-version : show the server version.\n");
+ ErrorF("\n");
+}
+
+
+/*
+ * ddxGiveUp --
+ * Device dependent cleanup. Called by dix before normal server death.
+ */
+void ddxGiveUp( enum ExitCode error )
+{
+ LogClose(error);
+}
+
+
+/*
+ * AbortDDX --
+ * DDX - specific abort routine. Called by AbortServer(). The attempt is
+ * made to restore all original setting of the displays. Also all devices
+ * are closed.
+ */
+_X_NORETURN
+void AbortDDX( enum ExitCode error ) {
+ ErrorF( " AbortDDX\n" );
+ OsAbort();
+}
+
diff --git a/xorg-server/hw/xquartz/darwin.h b/xorg-server/hw/xquartz/darwin.h
index c209147ef..aafc12fbf 100644
--- a/xorg-server/hw/xquartz/darwin.h
+++ b/xorg-server/hw/xquartz/darwin.h
@@ -1,86 +1,86 @@
-/*
- * Copyright (C) 2008 Apple, Inc.
- * Copyright (c) 2001-2004 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, 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.
- */
-
-#ifndef _DARWIN_H
-#define _DARWIN_H
-
-#include <IOKit/IOTypes.h>
-#include "inputstr.h"
-#include "scrnintstr.h"
-#include <X11/extensions/XKB.h>
-#include <asl.h>
-
-#include "darwinfb.h"
-
-// From darwin.c
-void DarwinPrintBanner(void);
-int DarwinParseModifierList(const char *constmodifiers, int separatelr);
-void DarwinAdjustScreenOrigins(ScreenInfo *pScreenInfo);
-
-#define SCREEN_PRIV(pScreen) ((DarwinFramebufferPtr) \
- dixLookupPrivate(&pScreen->devPrivates, darwinScreenKey))
-
-/*
- * Global variables from darwin.c
- */
-extern DevPrivateKeyRec darwinScreenKeyRec;
-#define darwinScreenKey (&darwinScreenKeyRec)
-extern int darwinScreensFound;
-extern io_connect_t darwinParamConnect;
-extern int darwinEventReadFD;
-extern int darwinEventWriteFD;
-extern DeviceIntPtr darwinPointer;
-extern DeviceIntPtr darwinTabletCursor;
-extern DeviceIntPtr darwinTabletStylus;
-extern DeviceIntPtr darwinTabletEraser;
-extern DeviceIntPtr darwinKeyboard;
-
-// User preferences
-extern int darwinMouseAccelChange;
-extern int darwinFakeButtons;
-extern int darwinFakeMouse2Mask;
-extern int darwinFakeMouse3Mask;
-extern unsigned int darwinAppKitModMask;
-extern unsigned int windowItemModMask;
-extern int darwinSyncKeymap;
-extern int darwinDesiredDepth;
-
-// location of X11's (0,0) point in global screen coordinates
-extern int darwinMainScreenX;
-extern int darwinMainScreenY;
-
-// bundle-main.c
-extern char *bundle_id_prefix;
-
-_X_ATTRIBUTE_PRINTF(6,7)
-extern void xq_asl_log (int level, const char *subsystem, const char *file, const char *function, int line, const char *fmt, ...);
-
-#define ASL_LOG(level, subsystem, msg, args...) xq_asl_log(level, subsystem, __FILE__, __FUNCTION__, __LINE__, msg, ##args)
-#define DEBUG_LOG(msg, args...) ASL_LOG(ASL_LEVEL_DEBUG, "XQuartz", msg, ##args)
-#define TRACE() DEBUG_LOG("TRACE")
-
-#endif /* _DARWIN_H */
+/*
+ * Copyright (C) 2008 Apple, Inc.
+ * Copyright (c) 2001-2004 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, 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.
+ */
+
+#ifndef _DARWIN_H
+#define _DARWIN_H
+
+#include <IOKit/IOTypes.h>
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include <X11/extensions/XKB.h>
+#include <asl.h>
+
+#include "darwinfb.h"
+
+// From darwin.c
+void DarwinPrintBanner(void);
+int DarwinParseModifierList(const char *constmodifiers, int separatelr);
+void DarwinAdjustScreenOrigins(ScreenInfo *pScreenInfo);
+
+#define SCREEN_PRIV(pScreen) ((DarwinFramebufferPtr) \
+ dixLookupPrivate(&pScreen->devPrivates, darwinScreenKey))
+
+/*
+ * Global variables from darwin.c
+ */
+extern DevPrivateKeyRec darwinScreenKeyRec;
+#define darwinScreenKey (&darwinScreenKeyRec)
+extern int darwinScreensFound;
+extern io_connect_t darwinParamConnect;
+extern int darwinEventReadFD;
+extern int darwinEventWriteFD;
+extern DeviceIntPtr darwinPointer;
+extern DeviceIntPtr darwinTabletCursor;
+extern DeviceIntPtr darwinTabletStylus;
+extern DeviceIntPtr darwinTabletEraser;
+extern DeviceIntPtr darwinKeyboard;
+
+// User preferences
+extern int darwinMouseAccelChange;
+extern int darwinFakeButtons;
+extern int darwinFakeMouse2Mask;
+extern int darwinFakeMouse3Mask;
+extern unsigned int darwinAppKitModMask;
+extern unsigned int windowItemModMask;
+extern int darwinSyncKeymap;
+extern int darwinDesiredDepth;
+
+// location of X11's (0,0) point in global screen coordinates
+extern int darwinMainScreenX;
+extern int darwinMainScreenY;
+
+// bundle-main.c
+extern char *bundle_id_prefix;
+
+_X_ATTRIBUTE_PRINTF(6,7)
+extern void xq_asl_log (int level, const char *subsystem, const char *file, const char *function, int line, const char *fmt, ...);
+
+#define ASL_LOG(level, subsystem, msg, args...) xq_asl_log(level, subsystem, __FILE__, __FUNCTION__, __LINE__, msg, ##args)
+#define DEBUG_LOG(msg, args...) ASL_LOG(ASL_LEVEL_DEBUG, "XQuartz", msg, ##args)
+#define TRACE() DEBUG_LOG("TRACE")
+
+#endif /* _DARWIN_H */
diff --git a/xorg-server/hw/xquartz/darwinEvents.c b/xorg-server/hw/xquartz/darwinEvents.c
index 8f39a39a7..c367e3c1c 100644
--- a/xorg-server/hw/xquartz/darwinEvents.c
+++ b/xorg-server/hw/xquartz/darwinEvents.c
@@ -1,602 +1,602 @@
-/*
-Darwin event queue and event handling
-
-Copyright 2007-2008 Apple Inc.
-Copyright 2004 Kaleb S. KEITHLEY. All Rights Reserved.
-Copyright (c) 2002-2004 Torrey T. Lyons. All Rights Reserved.
-
-This file is based on mieq.c by Keith Packard,
-which contains the following copyright:
-Copyright 1990, 1998 The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
- */
-
-#include "sanitizedCarbon.h"
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xmd.h>
-#include <X11/Xproto.h>
-#include "misc.h"
-#include "windowstr.h"
-#include "pixmapstr.h"
-#include "inputstr.h"
-#include "inpututils.h"
-#include "eventstr.h"
-#include "mi.h"
-#include "scrnintstr.h"
-#include "mipointer.h"
-#include "os.h"
-
-#include "darwin.h"
-#include "quartz.h"
-#include "quartzKeyboard.h"
-#include "quartzRandR.h"
-#include "darwinEvents.h"
-
-#include <sys/types.h>
-#include <sys/uio.h>
-#include <unistd.h>
-#include <pthread.h>
-#include <errno.h>
-#include <time.h>
-
-#include <IOKit/hidsystem/IOLLEvent.h>
-
-/* Fake button press/release for scroll wheel move. */
-#define SCROLLWHEELUPFAKE 4
-#define SCROLLWHEELDOWNFAKE 5
-#define SCROLLWHEELLEFTFAKE 6
-#define SCROLLWHEELRIGHTFAKE 7
-
-#include <X11/extensions/applewmconst.h>
-#include "applewmExt.h"
-
-/* FIXME: Abstract this better */
-extern Bool QuartzModeEventHandler(int screenNum, XQuartzEvent *e, DeviceIntPtr dev);
-
-int darwin_all_modifier_flags = 0; // last known modifier state
-int darwin_all_modifier_mask = 0;
-int darwin_x11_modifier_mask = 0;
-
-#define FD_ADD_MAX 128
-static int fd_add[FD_ADD_MAX];
-int fd_add_count = 0;
-static pthread_mutex_t fd_add_lock = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t fd_add_ready_cond = PTHREAD_COND_INITIALIZER;
-static pthread_t fd_add_tid = NULL;
-
-static InternalEvent* darwinEvents = NULL;
-
-static pthread_mutex_t mieq_lock = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t mieq_ready_cond = PTHREAD_COND_INITIALIZER;
-
-/*** Pthread Magics ***/
-static pthread_t create_thread(void *(*func)(void *), void *arg) {
- pthread_attr_t attr;
- pthread_t tid;
-
- pthread_attr_init (&attr);
- pthread_attr_setscope (&attr, PTHREAD_SCOPE_SYSTEM);
- pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
- pthread_create (&tid, &attr, func, arg);
- pthread_attr_destroy (&attr);
-
- return tid;
-}
-
-void darwinEvents_lock(void);
-void darwinEvents_lock(void) {
- int err;
- if((err = pthread_mutex_lock(&mieq_lock))) {
- ErrorF("%s:%s:%d: Failed to lock mieq_lock: %d\n",
- __FILE__, __FUNCTION__, __LINE__, err);
- xorg_backtrace();
- }
- if(darwinEvents == NULL) {
- pthread_cond_wait(&mieq_ready_cond, &mieq_lock);
- }
-}
-
-void darwinEvents_unlock(void);
-void darwinEvents_unlock(void) {
- int err;
- if((err = pthread_mutex_unlock(&mieq_lock))) {
- ErrorF("%s:%s:%d: Failed to unlock mieq_lock: %d\n",
- __FILE__, __FUNCTION__, __LINE__, err);
- xorg_backtrace();
- }
-}
-
-/*
- * DarwinPressModifierKey
- * Press or release the given modifier key (one of NX_MODIFIERKEY_* constants)
- */
-static void DarwinPressModifierKey(int pressed, int key) {
- int keycode = DarwinModifierNXKeyToNXKeycode(key, 0);
-
- if (keycode == 0) {
- ErrorF("DarwinPressModifierKey bad keycode: key=%d\n", key);
- return;
- }
-
- DarwinSendKeyboardEvents(pressed, keycode);
-}
-
-/*
- * DarwinUpdateModifiers
- * Send events to update the modifier state.
- */
-
-static int darwin_x11_modifier_mask_list[] = {
-#ifdef NX_DEVICELCMDKEYMASK
- NX_DEVICELCTLKEYMASK, NX_DEVICERCTLKEYMASK,
- NX_DEVICELSHIFTKEYMASK, NX_DEVICERSHIFTKEYMASK,
- NX_DEVICELCMDKEYMASK, NX_DEVICERCMDKEYMASK,
- NX_DEVICELALTKEYMASK, NX_DEVICERALTKEYMASK,
-#else
- NX_CONTROLMASK, NX_SHIFTMASK, NX_COMMANDMASK, NX_ALTERNATEMASK,
-#endif
- NX_ALPHASHIFTMASK,
- 0
-};
-
-static int darwin_all_modifier_mask_additions[] = { NX_SECONDARYFNMASK, };
-
-static void DarwinUpdateModifiers(
- int pressed, // KeyPress or KeyRelease
- int flags ) // modifier flags that have changed
-{
- int *f;
- int key;
-
- /* Capslock is special. This mask is the state of capslock (on/off),
- * not the state of the button. Hopefully we can find a better solution.
- */
- if(NX_ALPHASHIFTMASK & flags) {
- DarwinPressModifierKey(KeyPress, NX_MODIFIERKEY_ALPHALOCK);
- DarwinPressModifierKey(KeyRelease, NX_MODIFIERKEY_ALPHALOCK);
- }
-
- for(f=darwin_x11_modifier_mask_list; *f; f++)
- if(*f & flags && *f != NX_ALPHASHIFTMASK) {
- key = DarwinModifierNXMaskToNXKey(*f);
- if(key == -1)
- ErrorF("DarwinUpdateModifiers: Unsupported NXMask: 0x%x\n", *f);
- else
- DarwinPressModifierKey(pressed, key);
- }
-}
-
-/* Generic handler for Xquartz-specifc events. When possible, these should
- be moved into their own individual functions and set as handlers using
- mieqSetHandler. */
-
-static void DarwinEventHandler(int screenNum, InternalEvent *ie, DeviceIntPtr dev) {
- XQuartzEvent *e = &(ie->xquartz_event);
-
- switch(e->subtype) {
- case kXquartzControllerNotify:
- DEBUG_LOG("kXquartzControllerNotify\n");
- AppleWMSendEvent(AppleWMControllerNotify,
- AppleWMControllerNotifyMask,
- e->data[0],
- e->data[1]);
- break;
-
- case kXquartzPasteboardNotify:
- DEBUG_LOG("kXquartzPasteboardNotify\n");
- AppleWMSendEvent(AppleWMPasteboardNotify,
- AppleWMPasteboardNotifyMask,
- e->data[0],
- e->data[1]);
- break;
-
- case kXquartzActivate:
- DEBUG_LOG("kXquartzActivate\n");
- QuartzShow();
- AppleWMSendEvent(AppleWMActivationNotify,
- AppleWMActivationNotifyMask,
- AppleWMIsActive, 0);
- break;
-
- case kXquartzDeactivate:
- DEBUG_LOG("kXquartzDeactivate\n");
- AppleWMSendEvent(AppleWMActivationNotify,
- AppleWMActivationNotifyMask,
- AppleWMIsInactive, 0);
- QuartzHide();
- break;
-
- case kXquartzReloadPreferences:
- DEBUG_LOG("kXquartzReloadPreferences\n");
- AppleWMSendEvent(AppleWMActivationNotify,
- AppleWMActivationNotifyMask,
- AppleWMReloadPreferences, 0);
- break;
-
- case kXquartzToggleFullscreen:
- DEBUG_LOG("kXquartzToggleFullscreen\n");
- if(XQuartzIsRootless)
- ErrorF("Ignoring kXquartzToggleFullscreen because of rootless mode.");
- else
- QuartzRandRToggleFullscreen();
- break;
-
- case kXquartzSetRootless:
- DEBUG_LOG("kXquartzSetRootless\n");
- if(e->data[0]) {
- QuartzRandRSetFakeRootless();
- } else {
- QuartzRandRSetFakeFullscreen(FALSE);
- }
- break;
-
- case kXquartzSetRootClip:
- QuartzSetRootClip((Bool)e->data[0]);
- break;
-
- case kXquartzQuit:
- GiveUp(0);
- break;
-
- case kXquartzSpaceChanged:
- DEBUG_LOG("kXquartzSpaceChanged\n");
- QuartzSpaceChanged(e->data[0]);
- break;
-
- case kXquartzListenOnOpenFD:
- ErrorF("Calling ListenOnOpenFD() for new fd: %d\n", (int)e->data[0]);
- ListenOnOpenFD((int)e->data[0], 1);
- break;
-
- case kXquartzReloadKeymap:
- DarwinKeyboardReloadHandler();
- break;
-
- case kXquartzDisplayChanged:
- DEBUG_LOG("kXquartzDisplayChanged\n");
- QuartzUpdateScreens();
-
- /* Update our RandR info */
- QuartzRandRUpdateFakeModes(TRUE);
- break;
-
- default:
- if(!QuartzModeEventHandler(screenNum, e, dev))
- ErrorF("Unknown application defined event type %d.\n", e->subtype);
- }
-}
-
-void DarwinListenOnOpenFD(int fd) {
- ErrorF("DarwinListenOnOpenFD: %d\n", fd);
-
- pthread_mutex_lock(&fd_add_lock);
- if(fd_add_count < FD_ADD_MAX)
- fd_add[fd_add_count++] = fd;
- else
- ErrorF("FD Addition buffer at max. Dropping fd addition request.\n");
-
- pthread_cond_broadcast(&fd_add_ready_cond);
- pthread_mutex_unlock(&fd_add_lock);
-}
-
-static void *DarwinProcessFDAdditionQueue_thread(void *args) {
- /* TODO: Possibly adjust this to no longer be a race... maybe trigger this
- * once a client connects and claims to be the WM.
- *
- * From ajax:
- * There's already an internal callback chain for setting selection [in 1.5]
- * ownership. See the CallSelectionCallback at the bottom of
- * ProcSetSelectionOwner, and xfixes/select.c for an example of how to hook
- * into it.
- */
-
- struct timespec sleep_for;
- struct timespec sleep_remaining;
-
- sleep_for.tv_sec = 3;
- sleep_for.tv_nsec = 0;
-
- ErrorF("X11.app: DarwinProcessFDAdditionQueue_thread: Sleeping to allow xinitrc to catchup.\n");
- while(nanosleep(&sleep_for, &sleep_remaining) != 0) {
- sleep_for = sleep_remaining;
- }
-
- pthread_mutex_lock(&fd_add_lock);
- while(true) {
- while(fd_add_count) {
- DarwinSendDDXEvent(kXquartzListenOnOpenFD, 1, fd_add[--fd_add_count]);
- }
- pthread_cond_wait(&fd_add_ready_cond, &fd_add_lock);
- }
-
- return NULL;
-}
-
-Bool DarwinEQInit(void) {
- int *p;
-
- for(p=darwin_x11_modifier_mask_list, darwin_all_modifier_mask=0; *p; p++) {
- darwin_x11_modifier_mask |= *p;
- }
-
- for(p=darwin_all_modifier_mask_additions, darwin_all_modifier_mask= darwin_x11_modifier_mask; *p; p++) {
- darwin_all_modifier_mask |= *p;
- }
-
- mieqInit();
- mieqSetHandler(ET_XQuartz, DarwinEventHandler);
-
- /* Note that this *could* cause a potential async issue, since we're checking
- * darwinEvents without holding the lock, but darwinEvents is only ever set
- * here, so I don't bother.
- */
- if (!darwinEvents) {
- darwinEvents = InitEventList(GetMaximumEventsNum());;
-
- if (!darwinEvents)
- FatalError("Couldn't allocate event buffer\n");
-
- darwinEvents_lock();
- pthread_cond_broadcast(&mieq_ready_cond);
- darwinEvents_unlock();
- }
-
- if(!fd_add_tid)
- fd_add_tid = create_thread(DarwinProcessFDAdditionQueue_thread, NULL);
-
- return TRUE;
-}
-
-void DarwinEQFini(void) {
- mieqFini();
-}
-
-/*
- * ProcessInputEvents
- * Read and process events from the event queue until it is empty.
- */
-void ProcessInputEvents(void) {
- char nullbyte;
- int x = sizeof(nullbyte);
-
- mieqProcessInputEvents();
-
- // Empty the signaling pipe
- while (x == sizeof(nullbyte)) {
- x = read(darwinEventReadFD, &nullbyte, sizeof(nullbyte));
- }
-}
-
-/* Sends a null byte down darwinEventWriteFD, which will cause the
- Dispatch() event loop to check out event queue */
-static void DarwinPokeEQ(void) {
- char nullbyte=0;
- // <daniels> oh, i ... er ... christ.
- write(darwinEventWriteFD, &nullbyte, sizeof(nullbyte));
-}
-
-/* Convert from Appkit pointer input values to X input values:
- * Note: pointer_x and pointer_y are relative to the upper-left of primary
- * display.
- */
-static void DarwinPrepareValuators(DeviceIntPtr pDev, int *valuators, ScreenPtr screen,
- float pointer_x, float pointer_y,
- float pressure, float tilt_x, float tilt_y) {
- /* Fix offset between darwin and X screens */
- pointer_x -= darwinMainScreenX + screen->x;
- pointer_y -= darwinMainScreenY + screen->y;
-
- if(pointer_x < 0.0)
- pointer_x = 0.0;
-
- if(pointer_y < 0.0)
- pointer_y = 0.0;
-
- if(pDev == darwinPointer) {
- valuators[0] = pointer_x;
- valuators[1] = pointer_y;
- valuators[2] = 0;
- valuators[3] = 0;
- valuators[4] = 0;
- } else {
- /* Setup our array of values */
- valuators[0] = XQUARTZ_VALUATOR_LIMIT * (pointer_x / (float)screenInfo.screens[0]->width);
- valuators[1] = XQUARTZ_VALUATOR_LIMIT * (pointer_y / (float)screenInfo.screens[0]->height);
- valuators[2] = XQUARTZ_VALUATOR_LIMIT * pressure;
- valuators[3] = XQUARTZ_VALUATOR_LIMIT * tilt_x;
- valuators[4] = XQUARTZ_VALUATOR_LIMIT * tilt_y;
- }
- //DEBUG_LOG("Pointer (%f, %f), Valuators: {%d,%d,%d,%d,%d}\n", pointer_x, pointer_y,
- // valuators[0], valuators[1], valuators[2], valuators[3], valuators[4]);
-}
-
-void DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button, float pointer_x, float pointer_y,
- float pressure, float tilt_x, float tilt_y) {
- static int darwinFakeMouseButtonDown = 0;
- ScreenPtr screen;
- int valuators[5];
-
- //DEBUG_LOG("x=%f, y=%f, p=%f, tx=%f, ty=%f\n", pointer_x, pointer_y, pressure, tilt_x, tilt_y);
-
- if(!darwinEvents) {
- DEBUG_LOG("DarwinSendPointerEvents called before darwinEvents was initialized\n");
- return;
- }
-
- screen = miPointerGetScreen(pDev);
- if(!screen) {
- DEBUG_LOG("DarwinSendPointerEvents called before screen was initialized\n");
- return;
- }
-
- /* Handle fake click */
- if (ev_type == ButtonPress && darwinFakeButtons && ev_button == 1) {
- if(darwinFakeMouseButtonDown != 0) {
- /* We're currently "down" with another button, so release it first */
- DarwinSendPointerEvents(pDev, ButtonRelease, darwinFakeMouseButtonDown, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
- darwinFakeMouseButtonDown=0;
- }
- if (darwin_all_modifier_flags & darwinFakeMouse2Mask) {
- ev_button = 2;
- darwinFakeMouseButtonDown = 2;
- DarwinUpdateModKeys(darwin_all_modifier_flags & ~darwinFakeMouse2Mask);
- } else if (darwin_all_modifier_flags & darwinFakeMouse3Mask) {
- ev_button = 3;
- darwinFakeMouseButtonDown = 3;
- DarwinUpdateModKeys(darwin_all_modifier_flags & ~darwinFakeMouse3Mask);
- }
- }
-
- if (ev_type == ButtonRelease && ev_button == 1) {
- if(darwinFakeMouseButtonDown) {
- ev_button = darwinFakeMouseButtonDown;
- }
-
- if(darwinFakeMouseButtonDown == 2) {
- DarwinUpdateModKeys(darwin_all_modifier_flags & ~darwinFakeMouse2Mask);
- } else if(darwinFakeMouseButtonDown == 3) {
- DarwinUpdateModKeys(darwin_all_modifier_flags & ~darwinFakeMouse3Mask);
- }
-
- darwinFakeMouseButtonDown = 0;
- }
-
- DarwinPrepareValuators(pDev, valuators, screen, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
- darwinEvents_lock(); {
- ValuatorMask mask;
- valuator_mask_set_range(&mask, 0, (pDev == darwinPointer) ? 2 : 5, valuators);
- QueuePointerEvents(pDev, ev_type, ev_button, POINTER_ABSOLUTE, &mask);
- DarwinPokeEQ();
- } darwinEvents_unlock();
-}
-
-void DarwinSendKeyboardEvents(int ev_type, int keycode) {
-
- if(!darwinEvents) {
- DEBUG_LOG("DarwinSendKeyboardEvents called before darwinEvents was initialized\n");
- return;
- }
-
- darwinEvents_lock(); {
- QueueKeyboardEvents(darwinKeyboard, ev_type, keycode + MIN_KEYCODE, NULL);
- DarwinPokeEQ();
- } darwinEvents_unlock();
-}
-
-void DarwinSendProximityEvents(DeviceIntPtr pDev, int ev_type, float pointer_x, float pointer_y,
- float pressure, float tilt_x, float tilt_y) {
- ScreenPtr screen;
- int valuators[5];
-
- DEBUG_LOG("DarwinSendProximityEvents: %d l:%f,%f p:%f t:%f,%f\n", ev_type, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
-
- if(!darwinEvents) {
- DEBUG_LOG("DarwinSendProximityEvents called before darwinEvents was initialized\n");
- return;
- }
-
- screen = miPointerGetScreen(pDev);
- if(!screen) {
- DEBUG_LOG("DarwinSendPointerEvents called before screen was initialized\n");
- return;
- }
-
- DarwinPrepareValuators(pDev, valuators, screen, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
- darwinEvents_lock(); {
- ValuatorMask mask;
- valuator_mask_set_range(&mask, 0, 5, valuators);
- QueueProximityEvents(pDev, ev_type, &mask);
- DarwinPokeEQ();
- } darwinEvents_unlock();
-}
-
-
-/* Send the appropriate number of button clicks to emulate scroll wheel */
-void DarwinSendScrollEvents(float count_x, float count_y,
- float pointer_x, float pointer_y,
- float pressure, float tilt_x, float tilt_y) {
- int sign_x, sign_y;
- if(!darwinEvents) {
- DEBUG_LOG("DarwinSendScrollEvents called before darwinEvents was initialized\n");
- return;
- }
-
- sign_x = count_x > 0.0f ? SCROLLWHEELLEFTFAKE : SCROLLWHEELRIGHTFAKE;
- sign_y = count_y > 0.0f ? SCROLLWHEELUPFAKE : SCROLLWHEELDOWNFAKE;
- count_x = fabs(count_x);
- count_y = fabs(count_y);
-
- while ((count_x > 0.0f) || (count_y > 0.0f)) {
- if (count_x > 0.0f) {
- DarwinSendPointerEvents(darwinPointer, ButtonPress, sign_x, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
- DarwinSendPointerEvents(darwinPointer, ButtonRelease, sign_x, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
- count_x = count_x - 1.0f;
- }
- if (count_y > 0.0f) {
- DarwinSendPointerEvents(darwinPointer, ButtonPress, sign_y, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
- DarwinSendPointerEvents(darwinPointer, ButtonRelease, sign_y, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
- count_y = count_y - 1.0f;
- }
- }
-}
-
-/* Send the appropriate KeyPress/KeyRelease events to GetKeyboardEvents to
- reflect changing modifier flags (alt, control, meta, etc) */
-void DarwinUpdateModKeys(int flags) {
- DarwinUpdateModifiers(KeyRelease, darwin_all_modifier_flags & ~flags & darwin_x11_modifier_mask);
- DarwinUpdateModifiers(KeyPress, ~darwin_all_modifier_flags & flags & darwin_x11_modifier_mask);
- darwin_all_modifier_flags = flags;
-}
-
-/*
- * DarwinSendDDXEvent
- * Send the X server thread a message by placing it on the event queue.
- */
-void DarwinSendDDXEvent(int type, int argc, ...) {
- XQuartzEvent e;
- int i;
- va_list args;
-
- memset(&e, 0, sizeof(e));
- e.header = ET_Internal;
- e.type = ET_XQuartz;
- e.length = sizeof(e);
- e.time = GetTimeInMillis();
- e.subtype = type;
-
- if (argc > 0 && argc < XQUARTZ_EVENT_MAXARGS) {
- va_start (args, argc);
- for (i = 0; i < argc; i++)
- e.data[i] = (uint32_t) va_arg (args, uint32_t);
- va_end (args);
- }
-
- darwinEvents_lock(); {
- mieqEnqueue(NULL, (InternalEvent*)&e);
- DarwinPokeEQ();
- } darwinEvents_unlock();
-}
+/*
+Darwin event queue and event handling
+
+Copyright 2007-2008 Apple Inc.
+Copyright 2004 Kaleb S. KEITHLEY. All Rights Reserved.
+Copyright (c) 2002-2004 Torrey T. Lyons. All Rights Reserved.
+
+This file is based on mieq.c by Keith Packard,
+which contains the following copyright:
+Copyright 1990, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ */
+
+#include "sanitizedCarbon.h"
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "inputstr.h"
+#include "inpututils.h"
+#include "eventstr.h"
+#include "mi.h"
+#include "scrnintstr.h"
+#include "mipointer.h"
+#include "os.h"
+
+#include "darwin.h"
+#include "quartz.h"
+#include "quartzKeyboard.h"
+#include "quartzRandR.h"
+#include "darwinEvents.h"
+
+#include <sys/types.h>
+#include <sys/uio.h>
+#include <unistd.h>
+#include <pthread.h>
+#include <errno.h>
+#include <time.h>
+
+#include <IOKit/hidsystem/IOLLEvent.h>
+
+/* Fake button press/release for scroll wheel move. */
+#define SCROLLWHEELUPFAKE 4
+#define SCROLLWHEELDOWNFAKE 5
+#define SCROLLWHEELLEFTFAKE 6
+#define SCROLLWHEELRIGHTFAKE 7
+
+#include <X11/extensions/applewmconst.h>
+#include "applewmExt.h"
+
+/* FIXME: Abstract this better */
+extern Bool QuartzModeEventHandler(int screenNum, XQuartzEvent *e, DeviceIntPtr dev);
+
+int darwin_all_modifier_flags = 0; // last known modifier state
+int darwin_all_modifier_mask = 0;
+int darwin_x11_modifier_mask = 0;
+
+#define FD_ADD_MAX 128
+static int fd_add[FD_ADD_MAX];
+int fd_add_count = 0;
+static pthread_mutex_t fd_add_lock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_cond_t fd_add_ready_cond = PTHREAD_COND_INITIALIZER;
+static pthread_t fd_add_tid = NULL;
+
+static InternalEvent* darwinEvents = NULL;
+
+static pthread_mutex_t mieq_lock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_cond_t mieq_ready_cond = PTHREAD_COND_INITIALIZER;
+
+/*** Pthread Magics ***/
+static pthread_t create_thread(void *(*func)(void *), void *arg) {
+ pthread_attr_t attr;
+ pthread_t tid;
+
+ pthread_attr_init (&attr);
+ pthread_attr_setscope (&attr, PTHREAD_SCOPE_SYSTEM);
+ pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
+ pthread_create (&tid, &attr, func, arg);
+ pthread_attr_destroy (&attr);
+
+ return tid;
+}
+
+void darwinEvents_lock(void);
+void darwinEvents_lock(void) {
+ int err;
+ if((err = pthread_mutex_lock(&mieq_lock))) {
+ ErrorF("%s:%s:%d: Failed to lock mieq_lock: %d\n",
+ __FILE__, __FUNCTION__, __LINE__, err);
+ xorg_backtrace();
+ }
+ if(darwinEvents == NULL) {
+ pthread_cond_wait(&mieq_ready_cond, &mieq_lock);
+ }
+}
+
+void darwinEvents_unlock(void);
+void darwinEvents_unlock(void) {
+ int err;
+ if((err = pthread_mutex_unlock(&mieq_lock))) {
+ ErrorF("%s:%s:%d: Failed to unlock mieq_lock: %d\n",
+ __FILE__, __FUNCTION__, __LINE__, err);
+ xorg_backtrace();
+ }
+}
+
+/*
+ * DarwinPressModifierKey
+ * Press or release the given modifier key (one of NX_MODIFIERKEY_* constants)
+ */
+static void DarwinPressModifierKey(int pressed, int key) {
+ int keycode = DarwinModifierNXKeyToNXKeycode(key, 0);
+
+ if (keycode == 0) {
+ ErrorF("DarwinPressModifierKey bad keycode: key=%d\n", key);
+ return;
+ }
+
+ DarwinSendKeyboardEvents(pressed, keycode);
+}
+
+/*
+ * DarwinUpdateModifiers
+ * Send events to update the modifier state.
+ */
+
+static int darwin_x11_modifier_mask_list[] = {
+#ifdef NX_DEVICELCMDKEYMASK
+ NX_DEVICELCTLKEYMASK, NX_DEVICERCTLKEYMASK,
+ NX_DEVICELSHIFTKEYMASK, NX_DEVICERSHIFTKEYMASK,
+ NX_DEVICELCMDKEYMASK, NX_DEVICERCMDKEYMASK,
+ NX_DEVICELALTKEYMASK, NX_DEVICERALTKEYMASK,
+#else
+ NX_CONTROLMASK, NX_SHIFTMASK, NX_COMMANDMASK, NX_ALTERNATEMASK,
+#endif
+ NX_ALPHASHIFTMASK,
+ 0
+};
+
+static int darwin_all_modifier_mask_additions[] = { NX_SECONDARYFNMASK, };
+
+static void DarwinUpdateModifiers(
+ int pressed, // KeyPress or KeyRelease
+ int flags ) // modifier flags that have changed
+{
+ int *f;
+ int key;
+
+ /* Capslock is special. This mask is the state of capslock (on/off),
+ * not the state of the button. Hopefully we can find a better solution.
+ */
+ if(NX_ALPHASHIFTMASK & flags) {
+ DarwinPressModifierKey(KeyPress, NX_MODIFIERKEY_ALPHALOCK);
+ DarwinPressModifierKey(KeyRelease, NX_MODIFIERKEY_ALPHALOCK);
+ }
+
+ for(f=darwin_x11_modifier_mask_list; *f; f++)
+ if(*f & flags && *f != NX_ALPHASHIFTMASK) {
+ key = DarwinModifierNXMaskToNXKey(*f);
+ if(key == -1)
+ ErrorF("DarwinUpdateModifiers: Unsupported NXMask: 0x%x\n", *f);
+ else
+ DarwinPressModifierKey(pressed, key);
+ }
+}
+
+/* Generic handler for Xquartz-specifc events. When possible, these should
+ be moved into their own individual functions and set as handlers using
+ mieqSetHandler. */
+
+static void DarwinEventHandler(int screenNum, InternalEvent *ie, DeviceIntPtr dev) {
+ XQuartzEvent *e = &(ie->xquartz_event);
+
+ switch(e->subtype) {
+ case kXquartzControllerNotify:
+ DEBUG_LOG("kXquartzControllerNotify\n");
+ AppleWMSendEvent(AppleWMControllerNotify,
+ AppleWMControllerNotifyMask,
+ e->data[0],
+ e->data[1]);
+ break;
+
+ case kXquartzPasteboardNotify:
+ DEBUG_LOG("kXquartzPasteboardNotify\n");
+ AppleWMSendEvent(AppleWMPasteboardNotify,
+ AppleWMPasteboardNotifyMask,
+ e->data[0],
+ e->data[1]);
+ break;
+
+ case kXquartzActivate:
+ DEBUG_LOG("kXquartzActivate\n");
+ QuartzShow();
+ AppleWMSendEvent(AppleWMActivationNotify,
+ AppleWMActivationNotifyMask,
+ AppleWMIsActive, 0);
+ break;
+
+ case kXquartzDeactivate:
+ DEBUG_LOG("kXquartzDeactivate\n");
+ AppleWMSendEvent(AppleWMActivationNotify,
+ AppleWMActivationNotifyMask,
+ AppleWMIsInactive, 0);
+ QuartzHide();
+ break;
+
+ case kXquartzReloadPreferences:
+ DEBUG_LOG("kXquartzReloadPreferences\n");
+ AppleWMSendEvent(AppleWMActivationNotify,
+ AppleWMActivationNotifyMask,
+ AppleWMReloadPreferences, 0);
+ break;
+
+ case kXquartzToggleFullscreen:
+ DEBUG_LOG("kXquartzToggleFullscreen\n");
+ if(XQuartzIsRootless)
+ ErrorF("Ignoring kXquartzToggleFullscreen because of rootless mode.");
+ else
+ QuartzRandRToggleFullscreen();
+ break;
+
+ case kXquartzSetRootless:
+ DEBUG_LOG("kXquartzSetRootless\n");
+ if(e->data[0]) {
+ QuartzRandRSetFakeRootless();
+ } else {
+ QuartzRandRSetFakeFullscreen(FALSE);
+ }
+ break;
+
+ case kXquartzSetRootClip:
+ QuartzSetRootClip((Bool)e->data[0]);
+ break;
+
+ case kXquartzQuit:
+ GiveUp(0);
+ break;
+
+ case kXquartzSpaceChanged:
+ DEBUG_LOG("kXquartzSpaceChanged\n");
+ QuartzSpaceChanged(e->data[0]);
+ break;
+
+ case kXquartzListenOnOpenFD:
+ ErrorF("Calling ListenOnOpenFD() for new fd: %d\n", (int)e->data[0]);
+ ListenOnOpenFD((int)e->data[0], 1);
+ break;
+
+ case kXquartzReloadKeymap:
+ DarwinKeyboardReloadHandler();
+ break;
+
+ case kXquartzDisplayChanged:
+ DEBUG_LOG("kXquartzDisplayChanged\n");
+ QuartzUpdateScreens();
+
+ /* Update our RandR info */
+ QuartzRandRUpdateFakeModes(TRUE);
+ break;
+
+ default:
+ if(!QuartzModeEventHandler(screenNum, e, dev))
+ ErrorF("Unknown application defined event type %d.\n", e->subtype);
+ }
+}
+
+void DarwinListenOnOpenFD(int fd) {
+ ErrorF("DarwinListenOnOpenFD: %d\n", fd);
+
+ pthread_mutex_lock(&fd_add_lock);
+ if(fd_add_count < FD_ADD_MAX)
+ fd_add[fd_add_count++] = fd;
+ else
+ ErrorF("FD Addition buffer at max. Dropping fd addition request.\n");
+
+ pthread_cond_broadcast(&fd_add_ready_cond);
+ pthread_mutex_unlock(&fd_add_lock);
+}
+
+static void *DarwinProcessFDAdditionQueue_thread(void *args) {
+ /* TODO: Possibly adjust this to no longer be a race... maybe trigger this
+ * once a client connects and claims to be the WM.
+ *
+ * From ajax:
+ * There's already an internal callback chain for setting selection [in 1.5]
+ * ownership. See the CallSelectionCallback at the bottom of
+ * ProcSetSelectionOwner, and xfixes/select.c for an example of how to hook
+ * into it.
+ */
+
+ struct timespec sleep_for;
+ struct timespec sleep_remaining;
+
+ sleep_for.tv_sec = 3;
+ sleep_for.tv_nsec = 0;
+
+ ErrorF("X11.app: DarwinProcessFDAdditionQueue_thread: Sleeping to allow xinitrc to catchup.\n");
+ while(nanosleep(&sleep_for, &sleep_remaining) != 0) {
+ sleep_for = sleep_remaining;
+ }
+
+ pthread_mutex_lock(&fd_add_lock);
+ while(true) {
+ while(fd_add_count) {
+ DarwinSendDDXEvent(kXquartzListenOnOpenFD, 1, fd_add[--fd_add_count]);
+ }
+ pthread_cond_wait(&fd_add_ready_cond, &fd_add_lock);
+ }
+
+ return NULL;
+}
+
+Bool DarwinEQInit(void) {
+ int *p;
+
+ for(p=darwin_x11_modifier_mask_list, darwin_all_modifier_mask=0; *p; p++) {
+ darwin_x11_modifier_mask |= *p;
+ }
+
+ for(p=darwin_all_modifier_mask_additions, darwin_all_modifier_mask= darwin_x11_modifier_mask; *p; p++) {
+ darwin_all_modifier_mask |= *p;
+ }
+
+ mieqInit();
+ mieqSetHandler(ET_XQuartz, DarwinEventHandler);
+
+ /* Note that this *could* cause a potential async issue, since we're checking
+ * darwinEvents without holding the lock, but darwinEvents is only ever set
+ * here, so I don't bother.
+ */
+ if (!darwinEvents) {
+ darwinEvents = InitEventList(GetMaximumEventsNum());;
+
+ if (!darwinEvents)
+ FatalError("Couldn't allocate event buffer\n");
+
+ darwinEvents_lock();
+ pthread_cond_broadcast(&mieq_ready_cond);
+ darwinEvents_unlock();
+ }
+
+ if(!fd_add_tid)
+ fd_add_tid = create_thread(DarwinProcessFDAdditionQueue_thread, NULL);
+
+ return TRUE;
+}
+
+void DarwinEQFini(void) {
+ mieqFini();
+}
+
+/*
+ * ProcessInputEvents
+ * Read and process events from the event queue until it is empty.
+ */
+void ProcessInputEvents(void) {
+ char nullbyte;
+ int x = sizeof(nullbyte);
+
+ mieqProcessInputEvents();
+
+ // Empty the signaling pipe
+ while (x == sizeof(nullbyte)) {
+ x = read(darwinEventReadFD, &nullbyte, sizeof(nullbyte));
+ }
+}
+
+/* Sends a null byte down darwinEventWriteFD, which will cause the
+ Dispatch() event loop to check out event queue */
+static void DarwinPokeEQ(void) {
+ char nullbyte=0;
+ // <daniels> oh, i ... er ... christ.
+ write(darwinEventWriteFD, &nullbyte, sizeof(nullbyte));
+}
+
+/* Convert from Appkit pointer input values to X input values:
+ * Note: pointer_x and pointer_y are relative to the upper-left of primary
+ * display.
+ */
+static void DarwinPrepareValuators(DeviceIntPtr pDev, int *valuators, ScreenPtr screen,
+ float pointer_x, float pointer_y,
+ float pressure, float tilt_x, float tilt_y) {
+ /* Fix offset between darwin and X screens */
+ pointer_x -= darwinMainScreenX + screen->x;
+ pointer_y -= darwinMainScreenY + screen->y;
+
+ if(pointer_x < 0.0)
+ pointer_x = 0.0;
+
+ if(pointer_y < 0.0)
+ pointer_y = 0.0;
+
+ if(pDev == darwinPointer) {
+ valuators[0] = pointer_x;
+ valuators[1] = pointer_y;
+ valuators[2] = 0;
+ valuators[3] = 0;
+ valuators[4] = 0;
+ } else {
+ /* Setup our array of values */
+ valuators[0] = XQUARTZ_VALUATOR_LIMIT * (pointer_x / (float)screenInfo.screens[0]->width);
+ valuators[1] = XQUARTZ_VALUATOR_LIMIT * (pointer_y / (float)screenInfo.screens[0]->height);
+ valuators[2] = XQUARTZ_VALUATOR_LIMIT * pressure;
+ valuators[3] = XQUARTZ_VALUATOR_LIMIT * tilt_x;
+ valuators[4] = XQUARTZ_VALUATOR_LIMIT * tilt_y;
+ }
+ //DEBUG_LOG("Pointer (%f, %f), Valuators: {%d,%d,%d,%d,%d}\n", pointer_x, pointer_y,
+ // valuators[0], valuators[1], valuators[2], valuators[3], valuators[4]);
+}
+
+void DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button, float pointer_x, float pointer_y,
+ float pressure, float tilt_x, float tilt_y) {
+ static int darwinFakeMouseButtonDown = 0;
+ ScreenPtr screen;
+ int valuators[5];
+
+ //DEBUG_LOG("x=%f, y=%f, p=%f, tx=%f, ty=%f\n", pointer_x, pointer_y, pressure, tilt_x, tilt_y);
+
+ if(!darwinEvents) {
+ DEBUG_LOG("DarwinSendPointerEvents called before darwinEvents was initialized\n");
+ return;
+ }
+
+ screen = miPointerGetScreen(pDev);
+ if(!screen) {
+ DEBUG_LOG("DarwinSendPointerEvents called before screen was initialized\n");
+ return;
+ }
+
+ /* Handle fake click */
+ if (ev_type == ButtonPress && darwinFakeButtons && ev_button == 1) {
+ if(darwinFakeMouseButtonDown != 0) {
+ /* We're currently "down" with another button, so release it first */
+ DarwinSendPointerEvents(pDev, ButtonRelease, darwinFakeMouseButtonDown, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
+ darwinFakeMouseButtonDown=0;
+ }
+ if (darwin_all_modifier_flags & darwinFakeMouse2Mask) {
+ ev_button = 2;
+ darwinFakeMouseButtonDown = 2;
+ DarwinUpdateModKeys(darwin_all_modifier_flags & ~darwinFakeMouse2Mask);
+ } else if (darwin_all_modifier_flags & darwinFakeMouse3Mask) {
+ ev_button = 3;
+ darwinFakeMouseButtonDown = 3;
+ DarwinUpdateModKeys(darwin_all_modifier_flags & ~darwinFakeMouse3Mask);
+ }
+ }
+
+ if (ev_type == ButtonRelease && ev_button == 1) {
+ if(darwinFakeMouseButtonDown) {
+ ev_button = darwinFakeMouseButtonDown;
+ }
+
+ if(darwinFakeMouseButtonDown == 2) {
+ DarwinUpdateModKeys(darwin_all_modifier_flags & ~darwinFakeMouse2Mask);
+ } else if(darwinFakeMouseButtonDown == 3) {
+ DarwinUpdateModKeys(darwin_all_modifier_flags & ~darwinFakeMouse3Mask);
+ }
+
+ darwinFakeMouseButtonDown = 0;
+ }
+
+ DarwinPrepareValuators(pDev, valuators, screen, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
+ darwinEvents_lock(); {
+ ValuatorMask mask;
+ valuator_mask_set_range(&mask, 0, (pDev == darwinPointer) ? 2 : 5, valuators);
+ QueuePointerEvents(pDev, ev_type, ev_button, POINTER_ABSOLUTE, &mask);
+ DarwinPokeEQ();
+ } darwinEvents_unlock();
+}
+
+void DarwinSendKeyboardEvents(int ev_type, int keycode) {
+
+ if(!darwinEvents) {
+ DEBUG_LOG("DarwinSendKeyboardEvents called before darwinEvents was initialized\n");
+ return;
+ }
+
+ darwinEvents_lock(); {
+ QueueKeyboardEvents(darwinKeyboard, ev_type, keycode + MIN_KEYCODE, NULL);
+ DarwinPokeEQ();
+ } darwinEvents_unlock();
+}
+
+void DarwinSendProximityEvents(DeviceIntPtr pDev, int ev_type, float pointer_x, float pointer_y,
+ float pressure, float tilt_x, float tilt_y) {
+ ScreenPtr screen;
+ int valuators[5];
+
+ DEBUG_LOG("DarwinSendProximityEvents: %d l:%f,%f p:%f t:%f,%f\n", ev_type, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
+
+ if(!darwinEvents) {
+ DEBUG_LOG("DarwinSendProximityEvents called before darwinEvents was initialized\n");
+ return;
+ }
+
+ screen = miPointerGetScreen(pDev);
+ if(!screen) {
+ DEBUG_LOG("DarwinSendPointerEvents called before screen was initialized\n");
+ return;
+ }
+
+ DarwinPrepareValuators(pDev, valuators, screen, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
+ darwinEvents_lock(); {
+ ValuatorMask mask;
+ valuator_mask_set_range(&mask, 0, 5, valuators);
+ QueueProximityEvents(pDev, ev_type, &mask);
+ DarwinPokeEQ();
+ } darwinEvents_unlock();
+}
+
+
+/* Send the appropriate number of button clicks to emulate scroll wheel */
+void DarwinSendScrollEvents(float count_x, float count_y,
+ float pointer_x, float pointer_y,
+ float pressure, float tilt_x, float tilt_y) {
+ int sign_x, sign_y;
+ if(!darwinEvents) {
+ DEBUG_LOG("DarwinSendScrollEvents called before darwinEvents was initialized\n");
+ return;
+ }
+
+ sign_x = count_x > 0.0f ? SCROLLWHEELLEFTFAKE : SCROLLWHEELRIGHTFAKE;
+ sign_y = count_y > 0.0f ? SCROLLWHEELUPFAKE : SCROLLWHEELDOWNFAKE;
+ count_x = fabs(count_x);
+ count_y = fabs(count_y);
+
+ while ((count_x > 0.0f) || (count_y > 0.0f)) {
+ if (count_x > 0.0f) {
+ DarwinSendPointerEvents(darwinPointer, ButtonPress, sign_x, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
+ DarwinSendPointerEvents(darwinPointer, ButtonRelease, sign_x, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
+ count_x = count_x - 1.0f;
+ }
+ if (count_y > 0.0f) {
+ DarwinSendPointerEvents(darwinPointer, ButtonPress, sign_y, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
+ DarwinSendPointerEvents(darwinPointer, ButtonRelease, sign_y, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
+ count_y = count_y - 1.0f;
+ }
+ }
+}
+
+/* Send the appropriate KeyPress/KeyRelease events to GetKeyboardEvents to
+ reflect changing modifier flags (alt, control, meta, etc) */
+void DarwinUpdateModKeys(int flags) {
+ DarwinUpdateModifiers(KeyRelease, darwin_all_modifier_flags & ~flags & darwin_x11_modifier_mask);
+ DarwinUpdateModifiers(KeyPress, ~darwin_all_modifier_flags & flags & darwin_x11_modifier_mask);
+ darwin_all_modifier_flags = flags;
+}
+
+/*
+ * DarwinSendDDXEvent
+ * Send the X server thread a message by placing it on the event queue.
+ */
+void DarwinSendDDXEvent(int type, int argc, ...) {
+ XQuartzEvent e;
+ int i;
+ va_list args;
+
+ memset(&e, 0, sizeof(e));
+ e.header = ET_Internal;
+ e.type = ET_XQuartz;
+ e.length = sizeof(e);
+ e.time = GetTimeInMillis();
+ e.subtype = type;
+
+ if (argc > 0 && argc < XQUARTZ_EVENT_MAXARGS) {
+ va_start (args, argc);
+ for (i = 0; i < argc; i++)
+ e.data[i] = (uint32_t) va_arg (args, uint32_t);
+ va_end (args);
+ }
+
+ darwinEvents_lock(); {
+ mieqEnqueue(NULL, (InternalEvent*)&e);
+ DarwinPokeEQ();
+ } darwinEvents_unlock();
+}
diff --git a/xorg-server/hw/xquartz/darwinEvents.h b/xorg-server/hw/xquartz/darwinEvents.h
index 22fc88a01..aefb5c7bb 100644
--- a/xorg-server/hw/xquartz/darwinEvents.h
+++ b/xorg-server/hw/xquartz/darwinEvents.h
@@ -1,91 +1,91 @@
-/*
- * Copyright (c) 2008 Apple, Inc.
- * Copyright (c) 2001-2004 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, 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.
- */
-
-#ifndef _DARWIN_EVENTS_H
-#define _DARWIN_EVENTS_H
-
-/* For extra precision of our cursor and other valuators */
-#define XQUARTZ_VALUATOR_LIMIT (1 << 16)
-
-Bool DarwinEQInit(void);
-void DarwinEQFini(void);
-void DarwinEQEnqueue(const xEventPtr e);
-void DarwinEQPointerPost(DeviceIntPtr pDev, xEventPtr e);
-void DarwinEQSwitchScreen(ScreenPtr pScreen, Bool fromDIX);
-void DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button, float pointer_x, float pointer_y,
- float pressure, float tilt_x, float tilt_y);
-void DarwinSendProximityEvents(DeviceIntPtr pDev, int ev_type, float pointer_x, float pointer_y,
- float pressure, float tilt_x, float tilt_y);
-void DarwinSendKeyboardEvents(int ev_type, int keycode);
-void DarwinSendScrollEvents(float count_x, float count_y, float pointer_x, float pointer_y,
- float pressure, float tilt_x, float tilt_y);
-void DarwinUpdateModKeys(int flags);
-void DarwinListenOnOpenFD(int fd);
-
-/*
- * Subtypes for the ET_XQuartz event type
- */
-enum {
- kXquartzReloadKeymap, // Reload system keymap
- kXquartzActivate, // restore X drawing and cursor
- kXquartzDeactivate, // clip X drawing and switch to Aqua cursor
- kXquartzSetRootClip, // enable or disable drawing to the X screen
- kXquartzQuit, // kill the X server and release the display
- kXquartzBringAllToFront, // bring all X windows to front
- kXquartzToggleFullscreen, // Enable/Disable fullscreen mode
- kXquartzSetRootless, // Set rootless mode
- kXquartzSpaceChanged, // Spaces changed
- kXquartzListenOnOpenFD, // Listen to the launchd fd (passed as arg)
- /*
- * AppleWM events
- */
- kXquartzControllerNotify, // send an AppleWMControllerNotify event
- kXquartzPasteboardNotify, // notify the WM to copy or paste
- kXquartzReloadPreferences, // send AppleWMReloadPreferences
- /*
- * Xplugin notification events
- */
- kXquartzDisplayChanged, // display configuration has changed
- kXquartzWindowState, // window visibility state has changed
- kXquartzWindowMoved, // window has moved on screen
-};
-
-/* Send one of the above events to the server thread. */
-void DarwinSendDDXEvent(int type, int argc, ...);
-
-/* A mask of the modifiers that are in our X11 keyboard layout:
- * (Fn for example is just useful for 3button mouse emulation) */
-extern int darwin_all_modifier_mask;
-
-/* A mask of the modifiers that are in our X11 keyboard layout:
- * (Fn for example is just useful for 3button mouse emulation) */
-extern int darwin_x11_modifier_mask;
-
-/* The current state of the above listed modifiers */
-extern int darwin_all_modifier_flags;
-
-#endif /* _DARWIN_EVENTS_H */
+/*
+ * Copyright (c) 2008 Apple, Inc.
+ * Copyright (c) 2001-2004 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, 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.
+ */
+
+#ifndef _DARWIN_EVENTS_H
+#define _DARWIN_EVENTS_H
+
+/* For extra precision of our cursor and other valuators */
+#define XQUARTZ_VALUATOR_LIMIT (1 << 16)
+
+Bool DarwinEQInit(void);
+void DarwinEQFini(void);
+void DarwinEQEnqueue(const xEventPtr e);
+void DarwinEQPointerPost(DeviceIntPtr pDev, xEventPtr e);
+void DarwinEQSwitchScreen(ScreenPtr pScreen, Bool fromDIX);
+void DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button, float pointer_x, float pointer_y,
+ float pressure, float tilt_x, float tilt_y);
+void DarwinSendProximityEvents(DeviceIntPtr pDev, int ev_type, float pointer_x, float pointer_y,
+ float pressure, float tilt_x, float tilt_y);
+void DarwinSendKeyboardEvents(int ev_type, int keycode);
+void DarwinSendScrollEvents(float count_x, float count_y, float pointer_x, float pointer_y,
+ float pressure, float tilt_x, float tilt_y);
+void DarwinUpdateModKeys(int flags);
+void DarwinListenOnOpenFD(int fd);
+
+/*
+ * Subtypes for the ET_XQuartz event type
+ */
+enum {
+ kXquartzReloadKeymap, // Reload system keymap
+ kXquartzActivate, // restore X drawing and cursor
+ kXquartzDeactivate, // clip X drawing and switch to Aqua cursor
+ kXquartzSetRootClip, // enable or disable drawing to the X screen
+ kXquartzQuit, // kill the X server and release the display
+ kXquartzBringAllToFront, // bring all X windows to front
+ kXquartzToggleFullscreen, // Enable/Disable fullscreen mode
+ kXquartzSetRootless, // Set rootless mode
+ kXquartzSpaceChanged, // Spaces changed
+ kXquartzListenOnOpenFD, // Listen to the launchd fd (passed as arg)
+ /*
+ * AppleWM events
+ */
+ kXquartzControllerNotify, // send an AppleWMControllerNotify event
+ kXquartzPasteboardNotify, // notify the WM to copy or paste
+ kXquartzReloadPreferences, // send AppleWMReloadPreferences
+ /*
+ * Xplugin notification events
+ */
+ kXquartzDisplayChanged, // display configuration has changed
+ kXquartzWindowState, // window visibility state has changed
+ kXquartzWindowMoved, // window has moved on screen
+};
+
+/* Send one of the above events to the server thread. */
+void DarwinSendDDXEvent(int type, int argc, ...);
+
+/* A mask of the modifiers that are in our X11 keyboard layout:
+ * (Fn for example is just useful for 3button mouse emulation) */
+extern int darwin_all_modifier_mask;
+
+/* A mask of the modifiers that are in our X11 keyboard layout:
+ * (Fn for example is just useful for 3button mouse emulation) */
+extern int darwin_x11_modifier_mask;
+
+/* The current state of the above listed modifiers */
+extern int darwin_all_modifier_flags;
+
+#endif /* _DARWIN_EVENTS_H */
diff --git a/xorg-server/hw/xquartz/darwinXinput.c b/xorg-server/hw/xquartz/darwinXinput.c
index 52d41d646..94c31bb23 100644
--- a/xorg-server/hw/xquartz/darwinXinput.c
+++ b/xorg-server/hw/xquartz/darwinXinput.c
@@ -1,151 +1,151 @@
-/*
- * X server support of the XINPUT extension for xquartz
- *
- * This is currently a copy of Xi/stubs.c, but eventually this
- * should include more complete XINPUT support.
- */
-
-/************************************************************
-
-Copyright 1989, 1998 The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
-
- All Rights Reserved
-
-Permission to use, copy, modify, and distribute this software and its
-documentation for any purpose and without fee is hereby granted,
-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 Hewlett-Packard not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.
-
-HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-HEWLETT-PACKARD 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_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include "inputstr.h"
-#include <X11/extensions/XI.h>
-#include <X11/extensions/XIproto.h>
-#include "XIstubs.h"
-#include "darwin.h"
-
-/****************************************************************************
- *
- * Caller: ProcXSetDeviceMode
- *
- * Change the mode of an extension device.
- * This function is used to change the mode of a device from reporting
- * relative motion to reporting absolute positional information, and
- * vice versa.
- * The default implementation below is that no such devices are supported.
- *
- */
-
-int
-SetDeviceMode(ClientPtr client, DeviceIntPtr dev, int mode)
-{
- DEBUG_LOG("SetDeviceMode(%p, %p, %d)\n", client, dev, mode);
- return BadMatch;
-}
-
-/****************************************************************************
- *
- * Caller: ProcXSetDeviceValuators
- *
- * Set the value of valuators on an extension input device.
- * This function is used to set the initial value of valuators on
- * those input devices that are capable of reporting either relative
- * motion or an absolute position, and allow an initial position to be set.
- * The default implementation below is that no such devices are supported.
- *
- */
-
-int
-SetDeviceValuators(ClientPtr client, DeviceIntPtr dev,
- int *valuators, int first_valuator, int num_valuators)
-{
- DEBUG_LOG("SetDeviceValuators(%p, %p, %p, %d, %d)\n", client,
- dev, valuators, first_valuator, num_valuators);
- return BadMatch;
-}
-
-/****************************************************************************
- *
- * Caller: ProcXChangeDeviceControl
- *
- * Change the specified device controls on an extension input device.
- *
- */
-
-int
-ChangeDeviceControl(ClientPtr client, DeviceIntPtr dev,
- xDeviceCtl * control)
-{
-
- DEBUG_LOG("ChangeDeviceControl(%p, %p, %p)\n", client, dev, control);
- return BadMatch;
-}
-
-
-/****************************************************************************
- *
- * Caller: configAddDevice (and others)
- *
- * Add a new device with the specified options.
- *
- */
-int
-NewInputDeviceRequest(InputOption *options, InputAttributes *attrs,
- DeviceIntPtr *pdev)
-{
- DEBUG_LOG("NewInputDeviceRequest(%p, %p)\n", options, pdev);
- return BadValue;
-}
-
-/****************************************************************************
- *
- * Caller: configRemoveDevice (and others)
- *
- * Remove the specified device previously added.
- *
- */
-void
-DeleteInputDeviceRequest(DeviceIntPtr dev)
-{
- DEBUG_LOG("DeleteInputDeviceRequest(%p)\n", dev);
-}
-
+/*
+ * X server support of the XINPUT extension for xquartz
+ *
+ * This is currently a copy of Xi/stubs.c, but eventually this
+ * should include more complete XINPUT support.
+ */
+
+/************************************************************
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+Copyright 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+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 Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD 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_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "inputstr.h"
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "XIstubs.h"
+#include "darwin.h"
+
+/****************************************************************************
+ *
+ * Caller: ProcXSetDeviceMode
+ *
+ * Change the mode of an extension device.
+ * This function is used to change the mode of a device from reporting
+ * relative motion to reporting absolute positional information, and
+ * vice versa.
+ * The default implementation below is that no such devices are supported.
+ *
+ */
+
+int
+SetDeviceMode(ClientPtr client, DeviceIntPtr dev, int mode)
+{
+ DEBUG_LOG("SetDeviceMode(%p, %p, %d)\n", client, dev, mode);
+ return BadMatch;
+}
+
+/****************************************************************************
+ *
+ * Caller: ProcXSetDeviceValuators
+ *
+ * Set the value of valuators on an extension input device.
+ * This function is used to set the initial value of valuators on
+ * those input devices that are capable of reporting either relative
+ * motion or an absolute position, and allow an initial position to be set.
+ * The default implementation below is that no such devices are supported.
+ *
+ */
+
+int
+SetDeviceValuators(ClientPtr client, DeviceIntPtr dev,
+ int *valuators, int first_valuator, int num_valuators)
+{
+ DEBUG_LOG("SetDeviceValuators(%p, %p, %p, %d, %d)\n", client,
+ dev, valuators, first_valuator, num_valuators);
+ return BadMatch;
+}
+
+/****************************************************************************
+ *
+ * Caller: ProcXChangeDeviceControl
+ *
+ * Change the specified device controls on an extension input device.
+ *
+ */
+
+int
+ChangeDeviceControl(ClientPtr client, DeviceIntPtr dev,
+ xDeviceCtl * control)
+{
+
+ DEBUG_LOG("ChangeDeviceControl(%p, %p, %p)\n", client, dev, control);
+ return BadMatch;
+}
+
+
+/****************************************************************************
+ *
+ * Caller: configAddDevice (and others)
+ *
+ * Add a new device with the specified options.
+ *
+ */
+int
+NewInputDeviceRequest(InputOption *options, InputAttributes *attrs,
+ DeviceIntPtr *pdev)
+{
+ DEBUG_LOG("NewInputDeviceRequest(%p, %p)\n", options, pdev);
+ return BadValue;
+}
+
+/****************************************************************************
+ *
+ * Caller: configRemoveDevice (and others)
+ *
+ * Remove the specified device previously added.
+ *
+ */
+void
+DeleteInputDeviceRequest(DeviceIntPtr dev)
+{
+ DEBUG_LOG("DeleteInputDeviceRequest(%p)\n", dev);
+}
+
diff --git a/xorg-server/hw/xquartz/mach-startup/Makefile.am b/xorg-server/hw/xquartz/mach-startup/Makefile.am
index 388ecfa2a..0b1f8977e 100644
--- a/xorg-server/hw/xquartz/mach-startup/Makefile.am
+++ b/xorg-server/hw/xquartz/mach-startup/Makefile.am
@@ -1,84 +1,84 @@
-AM_CPPFLAGS = \
- -I$(srcdir)/.. \
- -DBUILD_DATE=\"$(BUILD_DATE)\" \
- -DXSERVER_VERSION=\"$(VERSION)\" \
- -DX11BINDIR=\"$(bindir)\"
-
-AM_CFLAGS = $(DIX_CFLAGS)
-
-x11appdir = $(APPLE_APPLICATIONS_DIR)/$(APPLE_APPLICATION_NAME).app/Contents/MacOS
-x11app_PROGRAMS = X11.bin
-
-dist_X11_bin_SOURCES = \
- bundle-main.c
-
-nodist_X11_bin_SOURCES = \
- mach_startupServer.c \
- mach_startupUser.c
-
-X11_bin_LDADD = \
- $(top_builddir)/hw/xquartz/libXquartz.la \
- $(top_builddir)/hw/xquartz/xpr/libXquartzXpr.la \
- $(top_builddir)/dix/dixfonts.lo \
- $(top_builddir)/miext/rootless/librootless.la \
- $(top_builddir)/hw/xquartz/pbproxy/libxpbproxy.la \
- $(XQUARTZ_LIBS) $(XSERVER_LIBS)
-
-X11_bin_LDFLAGS = \
- $(XSERVER_SYS_LIBS) -lXplugin \
- -XCClinker -Objc \
- -Wl,-u,_miDCInitialize \
- -Wl,-framework,Carbon \
- -Wl,-framework,Cocoa \
- -Wl,-framework,CoreAudio \
- -Wl,-framework,IOKit
-
-if GLX
-X11_bin_LDADD += \
- $(top_builddir)/hw/xquartz/GL/libCGLCore.la \
- $(top_builddir)/glx/libglx.la
-
-X11_bin_LDFLAGS += \
- -Wl,-framework,OpenGL
-endif
-
-if XQUARTZ_SPARKLE
-X11_bin_LDFLAGS += \
- -Wl,-framework,Sparkle
-endif
-
-if RECORD
-X11_bin_LDADD += \
- $(top_builddir)/record/librecord.la
-endif
-
-X11_bin_DEPENDENCIES = $(X11_bin_LDADD)
-
-bin_PROGRAMS = Xquartz
-
-dist_Xquartz_SOURCES = \
- stub.c \
- launchd_fd.c
-
-nodist_Xquartz_SOURCES = \
- mach_startupUser.c
-
-Xquartz_LDFLAGS = \
- -Wl,-framework,CoreServices
-
-BUILT_SOURCES = \
- mach_startupServer.c \
- mach_startupUser.c \
- mach_startupServer.h \
- mach_startup.h
-
-CLEANFILES = \
- $(BUILT_SOURCES)
-
-$(BUILT_SOURCES): $(srcdir)/mach_startup.defs
- mig -sheader mach_startupServer.h $(srcdir)/mach_startup.defs
-
-EXTRA_DIST = \
- launchd_fd.h \
- mach_startup.defs \
- mach_startup_types.h
+AM_CPPFLAGS = \
+ -I$(srcdir)/.. \
+ -DBUILD_DATE=\"$(BUILD_DATE)\" \
+ -DXSERVER_VERSION=\"$(VERSION)\" \
+ -DX11BINDIR=\"$(bindir)\"
+
+AM_CFLAGS = $(DIX_CFLAGS)
+
+x11appdir = $(APPLE_APPLICATIONS_DIR)/$(APPLE_APPLICATION_NAME).app/Contents/MacOS
+x11app_PROGRAMS = X11.bin
+
+dist_X11_bin_SOURCES = \
+ bundle-main.c
+
+nodist_X11_bin_SOURCES = \
+ mach_startupServer.c \
+ mach_startupUser.c
+
+X11_bin_LDADD = \
+ $(top_builddir)/hw/xquartz/libXquartz.la \
+ $(top_builddir)/hw/xquartz/xpr/libXquartzXpr.la \
+ $(top_builddir)/dix/dixfonts.lo \
+ $(top_builddir)/miext/rootless/librootless.la \
+ $(top_builddir)/hw/xquartz/pbproxy/libxpbproxy.la \
+ $(XQUARTZ_LIBS) $(XSERVER_LIBS)
+
+X11_bin_LDFLAGS = \
+ $(XSERVER_SYS_LIBS) -lXplugin \
+ -XCClinker -Objc \
+ -Wl,-u,_miDCInitialize \
+ -Wl,-framework,Carbon \
+ -Wl,-framework,Cocoa \
+ -Wl,-framework,CoreAudio \
+ -Wl,-framework,IOKit
+
+if GLX
+X11_bin_LDADD += \
+ $(top_builddir)/hw/xquartz/GL/libCGLCore.la \
+ $(top_builddir)/glx/libglx.la
+
+X11_bin_LDFLAGS += \
+ -Wl,-framework,OpenGL
+endif
+
+if XQUARTZ_SPARKLE
+X11_bin_LDFLAGS += \
+ -Wl,-framework,Sparkle
+endif
+
+if RECORD
+X11_bin_LDADD += \
+ $(top_builddir)/record/librecord.la
+endif
+
+X11_bin_DEPENDENCIES = $(X11_bin_LDADD)
+
+bin_PROGRAMS = Xquartz
+
+dist_Xquartz_SOURCES = \
+ stub.c \
+ launchd_fd.c
+
+nodist_Xquartz_SOURCES = \
+ mach_startupUser.c
+
+Xquartz_LDFLAGS = \
+ -Wl,-framework,CoreServices
+
+BUILT_SOURCES = \
+ mach_startupServer.c \
+ mach_startupUser.c \
+ mach_startupServer.h \
+ mach_startup.h
+
+CLEANFILES = \
+ $(BUILT_SOURCES)
+
+$(BUILT_SOURCES): $(srcdir)/mach_startup.defs
+ mig -sheader mach_startupServer.h $(srcdir)/mach_startup.defs
+
+EXTRA_DIST = \
+ launchd_fd.h \
+ mach_startup.defs \
+ mach_startup_types.h
diff --git a/xorg-server/hw/xquartz/mach-startup/bundle-main.c b/xorg-server/hw/xquartz/mach-startup/bundle-main.c
index 323ad0907..94c606823 100644
--- a/xorg-server/hw/xquartz/mach-startup/bundle-main.c
+++ b/xorg-server/hw/xquartz/mach-startup/bundle-main.c
@@ -1,754 +1,754 @@
-/* main.c -- X application launcher
-
- Copyright (c) 2007 Jeremy Huddleston
- Copyright (c) 2007 Apple 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 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. */
-
-#include <CoreFoundation/CoreFoundation.h>
-#include <AvailabilityMacros.h>
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <X11/Xlib.h>
-#include <assert.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <signal.h>
-
-#ifdef HAVE_LIBDISPATCH
-#include <dispatch/dispatch.h>
-#else
-#include <pthread.h>
-#endif
-
-#include <sys/socket.h>
-#include <sys/un.h>
-
-#include <fcntl.h>
-
-#include <mach/mach.h>
-#include <mach/mach_error.h>
-#include <servers/bootstrap.h>
-#include "mach_startup.h"
-#include "mach_startupServer.h"
-
-#include "console_redirect.h"
-
-/* From darwinEvents.c ... but don't want to pull in all the server cruft */
-void DarwinListenOnOpenFD(int fd);
-
-extern aslclient aslc;
-
-/* Ditto, from os/log.c */
-extern void ErrorF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2);
-extern void FatalError(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2) _X_NORETURN;
-
-extern int noPanoramiXExtension;
-
-#define DEFAULT_CLIENT X11BINDIR "/xterm"
-#define DEFAULT_STARTX X11BINDIR "/startx"
-#define DEFAULT_SHELL "/bin/sh"
-
-#ifndef BUILD_DATE
-#define BUILD_DATE ""
-#endif
-#ifndef XSERVER_VERSION
-#define XSERVER_VERSION "?"
-#endif
-
-static char __crashreporter_info_buff__[4096] = {0};
-static const char *__crashreporter_info__ __attribute__((__used__)) = &__crashreporter_info_buff__[0];
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
-// This is actually a toolchain requirement, but I'm not sure the correct check,
-// but it should be fine to just only include it for Leopard and later. This line
-// just tells the linker to never strip this symbol (such as for space optimization)
-asm (".desc ___crashreporter_info__, 0x10");
-#endif
-
-static const char *__crashreporter_info__base = "X.Org X Server " XSERVER_VERSION " Build Date: " BUILD_DATE;
-
-char *bundle_id_prefix = NULL;
-static char *server_bootstrap_name = NULL;
-
-#define DEBUG 1
-
-/* This is in quartzStartup.c */
-int server_main(int argc, char **argv, char **envp);
-
-static int execute(const char *command);
-static char *command_from_prefs(const char *key, const char *default_value);
-
-static char *pref_app_to_run;
-static char *pref_login_shell;
-static char *pref_startx_script;
-
-#ifndef HAVE_LIBDISPATCH
-/*** Pthread Magics ***/
-static pthread_t create_thread(void *(*func)(void *), void *arg) {
- pthread_attr_t attr;
- pthread_t tid;
-
- pthread_attr_init (&attr);
- pthread_attr_setscope (&attr, PTHREAD_SCOPE_SYSTEM);
- pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
- pthread_create (&tid, &attr, func, arg);
- pthread_attr_destroy (&attr);
-
- return tid;
-}
-#endif
-
-/*** Mach-O IPC Stuffs ***/
-
-union MaxMsgSize {
- union __RequestUnion__mach_startup_subsystem req;
- union __ReplyUnion__mach_startup_subsystem rep;
-};
-
-static mach_port_t checkin_or_register(char *bname) {
- kern_return_t kr;
- mach_port_t mp;
-
- /* If we're started by launchd or the old mach_init */
- kr = bootstrap_check_in(bootstrap_port, bname, &mp);
- if (kr == KERN_SUCCESS)
- return mp;
-
- /* We probably were not started by launchd or the old mach_init */
- kr = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &mp);
- if (kr != KERN_SUCCESS) {
- ErrorF("mach_port_allocate(): %s\n", mach_error_string(kr));
- exit(EXIT_FAILURE);
- }
-
- kr = mach_port_insert_right(mach_task_self(), mp, mp, MACH_MSG_TYPE_MAKE_SEND);
- if (kr != KERN_SUCCESS) {
- ErrorF("mach_port_insert_right(): %s\n", mach_error_string(kr));
- exit(EXIT_FAILURE);
- }
-
-#ifdef __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations" // bootstrap_register
-#endif
- kr = bootstrap_register(bootstrap_port, bname, mp);
-#ifdef __clang__
-#pragma clang diagnostic pop
-#endif
-
- if (kr != KERN_SUCCESS) {
- ErrorF("bootstrap_register(): %s\n", mach_error_string(kr));
- exit(EXIT_FAILURE);
- }
-
- return mp;
-}
-
-/*** $DISPLAY handoff ***/
-static int accept_fd_handoff(int connected_fd) {
- int launchd_fd;
-
- char databuf[] = "display";
- struct iovec iov[1];
-
- union {
- struct cmsghdr hdr;
- char bytes[CMSG_SPACE(sizeof(int))];
- } buf;
-
- struct msghdr msg;
- struct cmsghdr *cmsg;
-
- iov[0].iov_base = databuf;
- iov[0].iov_len = sizeof(databuf);
-
- msg.msg_iov = iov;
- msg.msg_iovlen = 1;
- msg.msg_control = buf.bytes;
- msg.msg_controllen = sizeof(buf);
- msg.msg_name = 0;
- msg.msg_namelen = 0;
- msg.msg_flags = 0;
-
- cmsg = CMSG_FIRSTHDR (&msg);
- cmsg->cmsg_level = SOL_SOCKET;
- cmsg->cmsg_type = SCM_RIGHTS;
- cmsg->cmsg_len = CMSG_LEN(sizeof(int));
-
- msg.msg_controllen = cmsg->cmsg_len;
-
- *((int*)CMSG_DATA(cmsg)) = -1;
-
- if(recvmsg(connected_fd, &msg, 0) < 0) {
- ErrorF("X11.app: Error receiving $DISPLAY file descriptor. recvmsg() error: %s\n", strerror(errno));
- return -1;
- }
-
- launchd_fd = *((int*)CMSG_DATA(cmsg));
-
- return launchd_fd;
-}
-
-typedef struct {
- int fd;
- string_t filename;
-} socket_handoff_t;
-
-/* This thread accepts an incoming connection and hands off the file
- * descriptor for the new connection to accept_fd_handoff()
- */
-#ifdef HAVE_LIBDISPATCH
-static void socket_handoff(socket_handoff_t *handoff_data) {
-#else
-static void *socket_handoff_thread(void *arg) {
- socket_handoff_t *handoff_data = (socket_handoff_t *)arg;
-#endif
-
- int launchd_fd = -1;
- int connected_fd;
-
- /* Now actually get the passed file descriptor from this connection
- * If we encounter an error, keep listening.
- */
- while(launchd_fd == -1) {
- connected_fd = accept(handoff_data->fd, NULL, NULL);
- if(connected_fd == -1) {
- ErrorF("X11.app: Failed to accept incoming connection on socket (fd=%d): %s\n", handoff_data->fd, strerror(errno));
- sleep(2);
- continue;
- }
-
- launchd_fd = accept_fd_handoff(connected_fd);
- if(launchd_fd == -1)
- ErrorF("X11.app: Error receiving $DISPLAY file descriptor, no descriptor received? Waiting for another connection.\n");
-
- close(connected_fd);
- }
-
- close(handoff_data->fd);
- unlink(handoff_data->filename);
- free(handoff_data);
-
- ErrorF("X11.app Handing off fd to server thread via DarwinListenOnOpenFD(%d)\n", launchd_fd);
- DarwinListenOnOpenFD(launchd_fd);
-
-#ifndef HAVE_LIBDISPATCH
- return NULL;
-#endif
-}
-
-static int create_socket(char *filename_out) {
- struct sockaddr_un servaddr_un;
- struct sockaddr *servaddr;
- socklen_t servaddr_len;
- int ret_fd;
- size_t try, try_max;
-
- for(try=0, try_max=5; try < try_max; try++) {
- tmpnam(filename_out);
-
- /* Setup servaddr_un */
- memset (&servaddr_un, 0, sizeof (struct sockaddr_un));
- servaddr_un.sun_family = AF_UNIX;
- strlcpy(servaddr_un.sun_path, filename_out, sizeof(servaddr_un.sun_path));
-
- servaddr = (struct sockaddr *) &servaddr_un;
- servaddr_len = sizeof(struct sockaddr_un) - sizeof(servaddr_un.sun_path) + strlen(filename_out);
-
- ret_fd = socket(PF_UNIX, SOCK_STREAM, 0);
- if(ret_fd == -1) {
- ErrorF("X11.app: Failed to create socket (try %d / %d): %s - %s\n", (int)try+1, (int)try_max, filename_out, strerror(errno));
- continue;
- }
-
- if(bind(ret_fd, servaddr, servaddr_len) != 0) {
- ErrorF("X11.app: Failed to bind socket: %d - %s\n", errno, strerror(errno));
- close(ret_fd);
- return 0;
- }
-
- if(listen(ret_fd, 10) != 0) {
- ErrorF("X11.app: Failed to listen to socket: %s - %d - %s\n", filename_out, errno, strerror(errno));
- close(ret_fd);
- return 0;
- }
-
-#ifdef DEBUG
- ErrorF("X11.app: Listening on socket for fd handoff: (%d) %s\n", ret_fd, filename_out);
-#endif
-
- return ret_fd;
- }
-
- return 0;
-}
-
-static int launchd_socket_handed_off = 0;
-
-kern_return_t do_request_fd_handoff_socket(mach_port_t port, string_t filename) {
- socket_handoff_t *handoff_data;
-
- launchd_socket_handed_off = 1;
-
- handoff_data = (socket_handoff_t *)calloc(1,sizeof(socket_handoff_t));
- if(!handoff_data) {
- ErrorF("X11.app: Error allocating memory for handoff_data\n");
- return KERN_FAILURE;
- }
-
- handoff_data->fd = create_socket(handoff_data->filename);
- if(!handoff_data->fd) {
- free(handoff_data);
- return KERN_FAILURE;
- }
-
- strlcpy(filename, handoff_data->filename, STRING_T_SIZE);
-
-#ifdef HAVE_LIBDISPATCH
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0), ^{
- socket_handoff(handoff_data);
- });
-#else
- create_thread(socket_handoff_thread, handoff_data);
-#endif
-
-#ifdef DEBUG
- ErrorF("X11.app: Thread created for handoff. Returning success to tell caller to connect and push the fd.\n");
-#endif
-
- return KERN_SUCCESS;
-}
-
-kern_return_t do_request_pid(mach_port_t port, int *my_pid) {
- *my_pid = getpid();
- return KERN_SUCCESS;
-}
-
-/*** Server Startup ***/
-kern_return_t do_start_x11_server(mach_port_t port, string_array_t argv,
- mach_msg_type_number_t argvCnt,
- string_array_t envp,
- mach_msg_type_number_t envpCnt) {
- /* And now back to char ** */
- char **_argv = alloca((argvCnt + 1) * sizeof(char *));
- char **_envp = alloca((envpCnt + 1) * sizeof(char *));
- size_t i;
-
- /* If we didn't get handed a launchd DISPLAY socket, we should
- * unset DISPLAY or we can run into problems with pbproxy
- */
- if(!launchd_socket_handed_off) {
- ErrorF("X11.app: No launchd socket handed off, unsetting DISPLAY\n");
- unsetenv("DISPLAY");
- }
-
- if(!_argv || !_envp) {
- return KERN_FAILURE;
- }
-
- ErrorF("X11.app: do_start_x11_server(): argc=%d\n", argvCnt);
- for(i=0; i < argvCnt; i++) {
- _argv[i] = argv[i];
- ErrorF("\targv[%u] = %s\n", (unsigned)i, argv[i]);
- }
- _argv[argvCnt] = NULL;
-
- for(i=0; i < envpCnt; i++) {
- _envp[i] = envp[i];
- }
- _envp[envpCnt] = NULL;
-
- if(server_main(argvCnt, _argv, _envp) == 0)
- return KERN_SUCCESS;
- else
- return KERN_FAILURE;
-}
-
-static int startup_trigger(int argc, char **argv, char **envp) {
- Display *display;
- const char *s;
-
- /* Take care of the case where we're called like a normal DDX */
- if(argc > 1 && argv[1][0] == ':') {
- size_t i;
- kern_return_t kr;
- mach_port_t mp;
- string_array_t newenvp;
- string_array_t newargv;
-
- /* We need to count envp */
- int envpc;
- for(envpc=0; envp[envpc]; envpc++);
-
- /* We have fixed-size string lengths due to limitations in IPC,
- * so we need to copy our argv and envp.
- */
- newargv = (string_array_t)alloca(argc * sizeof(string_t));
- newenvp = (string_array_t)alloca(envpc * sizeof(string_t));
-
- if(!newargv || !newenvp) {
- ErrorF("Memory allocation failure\n");
- exit(EXIT_FAILURE);
- }
-
- for(i=0; i < argc; i++) {
- strlcpy(newargv[i], argv[i], STRING_T_SIZE);
- }
- for(i=0; i < envpc; i++) {
- strlcpy(newenvp[i], envp[i], STRING_T_SIZE);
- }
-
- kr = bootstrap_look_up(bootstrap_port, server_bootstrap_name, &mp);
- if (kr != KERN_SUCCESS) {
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
- ErrorF("bootstrap_look_up(%s): %s\n", server_bootstrap_name, bootstrap_strerror(kr));
-#else
- ErrorF("bootstrap_look_up(%s): %ul\n", server_bootstrap_name, (unsigned long)kr);
-#endif
- exit(EXIT_FAILURE);
- }
-
- kr = start_x11_server(mp, newargv, argc, newenvp, envpc);
- if (kr != KERN_SUCCESS) {
- ErrorF("start_x11_server: %s\n", mach_error_string(kr));
- exit(EXIT_FAILURE);
- }
- exit(EXIT_SUCCESS);
- }
-
- /* If we have a process serial number and it's our only arg, act as if
- * the user double clicked the app bundle: launch app_to_run if possible
- */
- if(argc == 1 || (argc == 2 && !strncmp(argv[1], "-psn_", 5))) {
- /* Now, try to open a display, if so, run the launcher */
- display = XOpenDisplay(NULL);
- if(display) {
- /* Could open the display, start the launcher */
- XCloseDisplay(display);
-
- return execute(pref_app_to_run);
- }
- }
-
- /* Start the server */
- if((s = getenv("DISPLAY"))) {
- ErrorF("X11.app: Could not connect to server (DISPLAY=\"%s\", unsetting). Starting X server.\n", s);
- unsetenv("DISPLAY");
- } else {
- ErrorF("X11.app: Could not connect to server (DISPLAY is not set). Starting X server.\n");
- }
- return execute(pref_startx_script);
-}
-
-/** Setup the environment we want our child processes to inherit */
-static void ensure_path(const char *dir) {
- char buf[1024], *temp;
-
- /* Make sure /usr/X11/bin is in the $PATH */
- temp = getenv("PATH");
- if(temp == NULL || temp[0] == 0) {
- snprintf(buf, sizeof(buf), "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:%s", dir);
- setenv("PATH", buf, TRUE);
- } else if(strnstr(temp, X11BINDIR, sizeof(temp)) == NULL) {
- snprintf(buf, sizeof(buf), "%s:%s", temp, dir);
- setenv("PATH", buf, TRUE);
- }
-}
-
-static void setup_console_redirect(const char *bundle_id) {
- char *asl_sender;
- char *asl_facility;
-
- asprintf(&asl_sender, "%s.server", bundle_id);
- assert(asl_sender);
-
- asl_facility = strdup(bundle_id);
- assert(asl_facility);
- if(strcmp(asl_facility + strlen(asl_facility) - 4, ".X11") == 0)
- asl_facility[strlen(asl_facility) - 4] = '\0';
-
- assert(aslc = asl_open(asl_sender, asl_facility, ASL_OPT_NO_DELAY));
- free(asl_sender);
- free(asl_facility);
-
- asl_set_filter(aslc, ASL_FILTER_MASK_UPTO(ASL_LEVEL_WARNING));
- xq_asl_capture_fd(aslc, NULL, ASL_LEVEL_INFO, STDOUT_FILENO);
- xq_asl_capture_fd(aslc, NULL, ASL_LEVEL_NOTICE, STDERR_FILENO);
-}
-
-static void setup_env(void) {
- char *temp;
- const char *pds = NULL;
- const char *disp = getenv("DISPLAY");
- size_t len;
-
- /* Pass on our prefs domain to startx and its inheritors (mainly for
- * quartz-wm and the Xquartz stub's MachIPC)
- */
- CFBundleRef bundle = CFBundleGetMainBundle();
- if(bundle) {
- CFStringRef pd = CFBundleGetIdentifier(bundle);
- if(pd) {
- pds = CFStringGetCStringPtr(pd, 0);
- }
- }
-
- /* fallback to hardcoded value if we can't discover it */
- if(!pds) {
- pds = BUNDLE_ID_PREFIX".X11";
- }
-
- setup_console_redirect(pds);
-
- server_bootstrap_name = strdup(pds);
- if(!server_bootstrap_name) {
- ErrorF("X11.app: Memory allocation error.\n");
- exit(1);
- }
- setenv("X11_PREFS_DOMAIN", server_bootstrap_name, 1);
-
- len = strlen(server_bootstrap_name);
- bundle_id_prefix = malloc(sizeof(char) * (len - 3));
- if(!bundle_id_prefix) {
- ErrorF("X11.app: Memory allocation error.\n");
- exit(1);
- }
- strlcpy(bundle_id_prefix, server_bootstrap_name, len - 3);
-
- /* We need to unset DISPLAY if it is not our socket */
- if(disp) {
- /* s = basename(disp) */
- const char *d, *s;
- for(s = NULL, d = disp; *d; d++) {
- if(*d == '/')
- s = d + 1;
- }
-
- if(s && *s) {
- if(strcmp(bundle_id_prefix, "org.x") == 0 && strcmp(s, ":0") == 0) {
- ErrorF("X11.app: Detected old style launchd DISPLAY, please update xinit.\n");
- } else {
- temp = (char *)malloc(sizeof(char) * len);
- if(!temp) {
- ErrorF("X11.app: Memory allocation error creating space for socket name test.\n");
- exit(1);
- }
- strlcpy(temp, bundle_id_prefix, len);
- strlcat(temp, ":0", len);
-
- if(strcmp(temp, s) != 0) {
- /* If we don't have a match, unset it. */
- ErrorF("X11.app: DISPLAY (\"%s\") does not match our id (\"%s\"), unsetting.\n", disp, bundle_id_prefix);
- unsetenv("DISPLAY");
- }
- free(temp);
- }
- } else {
- /* The DISPLAY environment variable is not formatted like a launchd socket, so reset. */
- ErrorF("X11.app: DISPLAY does not look like a launchd set variable, unsetting.\n");
- unsetenv("DISPLAY");
- }
- }
-
- /* Make sure PATH is right */
- ensure_path(X11BINDIR);
-
- /* cd $HOME */
- temp = getenv("HOME");
- if(temp != NULL && temp[0] != '\0')
- chdir(temp);
-}
-
-/*** Main ***/
-int main(int argc, char **argv, char **envp) {
- Bool listenOnly = FALSE;
- int i;
- mach_msg_size_t mxmsgsz = sizeof(union MaxMsgSize) + MAX_TRAILER_SIZE;
- mach_port_t mp;
- kern_return_t kr;
-
- /* Setup our environment for our children */
- setup_env();
-
- /* The server must not run the PanoramiX operations. */
- noPanoramiXExtension = TRUE;
-
- /* Setup the initial crasherporter info */
- strlcpy(__crashreporter_info_buff__, __crashreporter_info__base, sizeof(__crashreporter_info_buff__));
-
- ErrorF("X11.app: main(): argc=%d\n", argc);
- for(i=0; i < argc; i++) {
- ErrorF("\targv[%u] = %s\n", (unsigned)i, argv[i]);
- if(!strcmp(argv[i], "--listenonly")) {
- listenOnly = TRUE;
- }
- }
-
- mp = checkin_or_register(server_bootstrap_name);
- if(mp == MACH_PORT_NULL) {
- ErrorF("NULL mach service: %s", server_bootstrap_name);
- return EXIT_FAILURE;
- }
-
- /* Check if we need to do something other than listen, and make another
- * thread handle it.
- */
- if(!listenOnly) {
- pid_t child1, child2;
- int status;
-
- pref_app_to_run = command_from_prefs("app_to_run", DEFAULT_CLIENT);
- assert(pref_app_to_run);
-
- pref_login_shell = command_from_prefs("login_shell", DEFAULT_SHELL);
- assert(pref_login_shell);
-
- pref_startx_script = command_from_prefs("startx_script", DEFAULT_STARTX);
- assert(pref_startx_script);
-
- /* Do the fork-twice trick to avoid having to reap zombies */
- child1 = fork();
- switch (child1) {
- case -1: /* error */
- FatalError("fork() failed: %s\n", strerror(errno));
-
- case 0: /* child1 */
- child2 = fork();
-
- switch (child2) {
- int max_files;
-
- case -1: /* error */
- FatalError("fork() failed: %s\n", strerror(errno));
-
- case 0: /* child2 */
- /* close all open files except for standard streams */
- max_files = sysconf(_SC_OPEN_MAX);
- for(i = 3; i < max_files; i++)
- close(i);
-
- /* ensure stdin is on /dev/null */
- close(0);
- open("/dev/null", O_RDONLY);
-
- return startup_trigger(argc, argv, envp);
-
- default: /* parent (child1) */
- _exit(0);
- }
- break;
-
- default: /* parent */
- waitpid(child1, &status, 0);
- }
-
- free(pref_app_to_run);
- free(pref_login_shell);
- free(pref_startx_script);
- }
-
- /* Main event loop */
- ErrorF("Waiting for startup parameters via Mach IPC.\n");
- kr = mach_msg_server(mach_startup_server, mxmsgsz, mp, 0);
- if (kr != KERN_SUCCESS) {
- ErrorF("%s.X11(mp): %s\n", BUNDLE_ID_PREFIX, mach_error_string(kr));
- return EXIT_FAILURE;
- }
-
- return EXIT_SUCCESS;
-}
-
-static int execute(const char *command) {
- const char *newargv[4];
- const char **p;
-
- newargv[0] = pref_login_shell;
- newargv[1] = "-c";
- newargv[2] = command;
- newargv[3] = NULL;
-
- ErrorF("X11.app: Launching %s:\n", command);
- for(p=newargv; *p; p++) {
- ErrorF("\targv[%ld] = %s\n", (long int)(p - newargv), *p);
- }
-
- execvp (newargv[0], (char * const *) newargv);
- perror ("X11.app: Couldn't exec.");
- return 1;
-}
-
-static char *command_from_prefs(const char *key, const char *default_value) {
- char *command = NULL;
-
- CFStringRef cfKey;
- CFPropertyListRef PlistRef;
-
- if(!key)
- return NULL;
-
- cfKey = CFStringCreateWithCString(NULL, key, kCFStringEncodingASCII);
-
- if(!cfKey)
- return NULL;
-
- PlistRef = CFPreferencesCopyAppValue(cfKey, kCFPreferencesCurrentApplication);
-
- if ((PlistRef == NULL) || (CFGetTypeID(PlistRef) != CFStringGetTypeID())) {
- CFStringRef cfDefaultValue = CFStringCreateWithCString(NULL, default_value, kCFStringEncodingASCII);
- int len = strlen(default_value) + 1;
-
- if(!cfDefaultValue)
- goto command_from_prefs_out;
-
- CFPreferencesSetAppValue(cfKey, cfDefaultValue, kCFPreferencesCurrentApplication);
- CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
- CFRelease(cfDefaultValue);
-
- command = (char *)malloc(len * sizeof(char));
- if(!command)
- goto command_from_prefs_out;
- strcpy(command, default_value);
- } else {
- int len = CFStringGetLength((CFStringRef)PlistRef) + 1;
- command = (char *)malloc(len * sizeof(char));
- if(!command)
- goto command_from_prefs_out;
- CFStringGetCString((CFStringRef)PlistRef, command, len, kCFStringEncodingASCII);
- }
-
-command_from_prefs_out:
- if (PlistRef)
- CFRelease(PlistRef);
- if(cfKey)
- CFRelease(cfKey);
- return command;
-}
+/* main.c -- X application launcher
+
+ Copyright (c) 2007 Jeremy Huddleston
+ Copyright (c) 2007 Apple 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 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. */
+
+#include <CoreFoundation/CoreFoundation.h>
+#include <AvailabilityMacros.h>
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/Xlib.h>
+#include <assert.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <signal.h>
+
+#ifdef HAVE_LIBDISPATCH
+#include <dispatch/dispatch.h>
+#else
+#include <pthread.h>
+#endif
+
+#include <sys/socket.h>
+#include <sys/un.h>
+
+#include <fcntl.h>
+
+#include <mach/mach.h>
+#include <mach/mach_error.h>
+#include <servers/bootstrap.h>
+#include "mach_startup.h"
+#include "mach_startupServer.h"
+
+#include "console_redirect.h"
+
+/* From darwinEvents.c ... but don't want to pull in all the server cruft */
+void DarwinListenOnOpenFD(int fd);
+
+extern aslclient aslc;
+
+/* Ditto, from os/log.c */
+extern void ErrorF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2);
+extern void FatalError(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2) _X_NORETURN;
+
+extern int noPanoramiXExtension;
+
+#define DEFAULT_CLIENT X11BINDIR "/xterm"
+#define DEFAULT_STARTX X11BINDIR "/startx"
+#define DEFAULT_SHELL "/bin/sh"
+
+#ifndef BUILD_DATE
+#define BUILD_DATE ""
+#endif
+#ifndef XSERVER_VERSION
+#define XSERVER_VERSION "?"
+#endif
+
+static char __crashreporter_info_buff__[4096] = {0};
+static const char *__crashreporter_info__ __attribute__((__used__)) = &__crashreporter_info_buff__[0];
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
+// This is actually a toolchain requirement, but I'm not sure the correct check,
+// but it should be fine to just only include it for Leopard and later. This line
+// just tells the linker to never strip this symbol (such as for space optimization)
+asm (".desc ___crashreporter_info__, 0x10");
+#endif
+
+static const char *__crashreporter_info__base = "X.Org X Server " XSERVER_VERSION " Build Date: " BUILD_DATE;
+
+char *bundle_id_prefix = NULL;
+static char *server_bootstrap_name = NULL;
+
+#define DEBUG 1
+
+/* This is in quartzStartup.c */
+int server_main(int argc, char **argv, char **envp);
+
+static int execute(const char *command);
+static char *command_from_prefs(const char *key, const char *default_value);
+
+static char *pref_app_to_run;
+static char *pref_login_shell;
+static char *pref_startx_script;
+
+#ifndef HAVE_LIBDISPATCH
+/*** Pthread Magics ***/
+static pthread_t create_thread(void *(*func)(void *), void *arg) {
+ pthread_attr_t attr;
+ pthread_t tid;
+
+ pthread_attr_init (&attr);
+ pthread_attr_setscope (&attr, PTHREAD_SCOPE_SYSTEM);
+ pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
+ pthread_create (&tid, &attr, func, arg);
+ pthread_attr_destroy (&attr);
+
+ return tid;
+}
+#endif
+
+/*** Mach-O IPC Stuffs ***/
+
+union MaxMsgSize {
+ union __RequestUnion__mach_startup_subsystem req;
+ union __ReplyUnion__mach_startup_subsystem rep;
+};
+
+static mach_port_t checkin_or_register(char *bname) {
+ kern_return_t kr;
+ mach_port_t mp;
+
+ /* If we're started by launchd or the old mach_init */
+ kr = bootstrap_check_in(bootstrap_port, bname, &mp);
+ if (kr == KERN_SUCCESS)
+ return mp;
+
+ /* We probably were not started by launchd or the old mach_init */
+ kr = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &mp);
+ if (kr != KERN_SUCCESS) {
+ ErrorF("mach_port_allocate(): %s\n", mach_error_string(kr));
+ exit(EXIT_FAILURE);
+ }
+
+ kr = mach_port_insert_right(mach_task_self(), mp, mp, MACH_MSG_TYPE_MAKE_SEND);
+ if (kr != KERN_SUCCESS) {
+ ErrorF("mach_port_insert_right(): %s\n", mach_error_string(kr));
+ exit(EXIT_FAILURE);
+ }
+
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations" // bootstrap_register
+#endif
+ kr = bootstrap_register(bootstrap_port, bname, mp);
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+
+ if (kr != KERN_SUCCESS) {
+ ErrorF("bootstrap_register(): %s\n", mach_error_string(kr));
+ exit(EXIT_FAILURE);
+ }
+
+ return mp;
+}
+
+/*** $DISPLAY handoff ***/
+static int accept_fd_handoff(int connected_fd) {
+ int launchd_fd;
+
+ char databuf[] = "display";
+ struct iovec iov[1];
+
+ union {
+ struct cmsghdr hdr;
+ char bytes[CMSG_SPACE(sizeof(int))];
+ } buf;
+
+ struct msghdr msg;
+ struct cmsghdr *cmsg;
+
+ iov[0].iov_base = databuf;
+ iov[0].iov_len = sizeof(databuf);
+
+ msg.msg_iov = iov;
+ msg.msg_iovlen = 1;
+ msg.msg_control = buf.bytes;
+ msg.msg_controllen = sizeof(buf);
+ msg.msg_name = 0;
+ msg.msg_namelen = 0;
+ msg.msg_flags = 0;
+
+ cmsg = CMSG_FIRSTHDR (&msg);
+ cmsg->cmsg_level = SOL_SOCKET;
+ cmsg->cmsg_type = SCM_RIGHTS;
+ cmsg->cmsg_len = CMSG_LEN(sizeof(int));
+
+ msg.msg_controllen = cmsg->cmsg_len;
+
+ *((int*)CMSG_DATA(cmsg)) = -1;
+
+ if(recvmsg(connected_fd, &msg, 0) < 0) {
+ ErrorF("X11.app: Error receiving $DISPLAY file descriptor. recvmsg() error: %s\n", strerror(errno));
+ return -1;
+ }
+
+ launchd_fd = *((int*)CMSG_DATA(cmsg));
+
+ return launchd_fd;
+}
+
+typedef struct {
+ int fd;
+ string_t filename;
+} socket_handoff_t;
+
+/* This thread accepts an incoming connection and hands off the file
+ * descriptor for the new connection to accept_fd_handoff()
+ */
+#ifdef HAVE_LIBDISPATCH
+static void socket_handoff(socket_handoff_t *handoff_data) {
+#else
+static void *socket_handoff_thread(void *arg) {
+ socket_handoff_t *handoff_data = (socket_handoff_t *)arg;
+#endif
+
+ int launchd_fd = -1;
+ int connected_fd;
+
+ /* Now actually get the passed file descriptor from this connection
+ * If we encounter an error, keep listening.
+ */
+ while(launchd_fd == -1) {
+ connected_fd = accept(handoff_data->fd, NULL, NULL);
+ if(connected_fd == -1) {
+ ErrorF("X11.app: Failed to accept incoming connection on socket (fd=%d): %s\n", handoff_data->fd, strerror(errno));
+ sleep(2);
+ continue;
+ }
+
+ launchd_fd = accept_fd_handoff(connected_fd);
+ if(launchd_fd == -1)
+ ErrorF("X11.app: Error receiving $DISPLAY file descriptor, no descriptor received? Waiting for another connection.\n");
+
+ close(connected_fd);
+ }
+
+ close(handoff_data->fd);
+ unlink(handoff_data->filename);
+ free(handoff_data);
+
+ ErrorF("X11.app Handing off fd to server thread via DarwinListenOnOpenFD(%d)\n", launchd_fd);
+ DarwinListenOnOpenFD(launchd_fd);
+
+#ifndef HAVE_LIBDISPATCH
+ return NULL;
+#endif
+}
+
+static int create_socket(char *filename_out) {
+ struct sockaddr_un servaddr_un;
+ struct sockaddr *servaddr;
+ socklen_t servaddr_len;
+ int ret_fd;
+ size_t try, try_max;
+
+ for(try=0, try_max=5; try < try_max; try++) {
+ tmpnam(filename_out);
+
+ /* Setup servaddr_un */
+ memset (&servaddr_un, 0, sizeof (struct sockaddr_un));
+ servaddr_un.sun_family = AF_UNIX;
+ strlcpy(servaddr_un.sun_path, filename_out, sizeof(servaddr_un.sun_path));
+
+ servaddr = (struct sockaddr *) &servaddr_un;
+ servaddr_len = sizeof(struct sockaddr_un) - sizeof(servaddr_un.sun_path) + strlen(filename_out);
+
+ ret_fd = socket(PF_UNIX, SOCK_STREAM, 0);
+ if(ret_fd == -1) {
+ ErrorF("X11.app: Failed to create socket (try %d / %d): %s - %s\n", (int)try+1, (int)try_max, filename_out, strerror(errno));
+ continue;
+ }
+
+ if(bind(ret_fd, servaddr, servaddr_len) != 0) {
+ ErrorF("X11.app: Failed to bind socket: %d - %s\n", errno, strerror(errno));
+ close(ret_fd);
+ return 0;
+ }
+
+ if(listen(ret_fd, 10) != 0) {
+ ErrorF("X11.app: Failed to listen to socket: %s - %d - %s\n", filename_out, errno, strerror(errno));
+ close(ret_fd);
+ return 0;
+ }
+
+#ifdef DEBUG
+ ErrorF("X11.app: Listening on socket for fd handoff: (%d) %s\n", ret_fd, filename_out);
+#endif
+
+ return ret_fd;
+ }
+
+ return 0;
+}
+
+static int launchd_socket_handed_off = 0;
+
+kern_return_t do_request_fd_handoff_socket(mach_port_t port, string_t filename) {
+ socket_handoff_t *handoff_data;
+
+ launchd_socket_handed_off = 1;
+
+ handoff_data = (socket_handoff_t *)calloc(1,sizeof(socket_handoff_t));
+ if(!handoff_data) {
+ ErrorF("X11.app: Error allocating memory for handoff_data\n");
+ return KERN_FAILURE;
+ }
+
+ handoff_data->fd = create_socket(handoff_data->filename);
+ if(!handoff_data->fd) {
+ free(handoff_data);
+ return KERN_FAILURE;
+ }
+
+ strlcpy(filename, handoff_data->filename, STRING_T_SIZE);
+
+#ifdef HAVE_LIBDISPATCH
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0), ^{
+ socket_handoff(handoff_data);
+ });
+#else
+ create_thread(socket_handoff_thread, handoff_data);
+#endif
+
+#ifdef DEBUG
+ ErrorF("X11.app: Thread created for handoff. Returning success to tell caller to connect and push the fd.\n");
+#endif
+
+ return KERN_SUCCESS;
+}
+
+kern_return_t do_request_pid(mach_port_t port, int *my_pid) {
+ *my_pid = getpid();
+ return KERN_SUCCESS;
+}
+
+/*** Server Startup ***/
+kern_return_t do_start_x11_server(mach_port_t port, string_array_t argv,
+ mach_msg_type_number_t argvCnt,
+ string_array_t envp,
+ mach_msg_type_number_t envpCnt) {
+ /* And now back to char ** */
+ char **_argv = alloca((argvCnt + 1) * sizeof(char *));
+ char **_envp = alloca((envpCnt + 1) * sizeof(char *));
+ size_t i;
+
+ /* If we didn't get handed a launchd DISPLAY socket, we should
+ * unset DISPLAY or we can run into problems with pbproxy
+ */
+ if(!launchd_socket_handed_off) {
+ ErrorF("X11.app: No launchd socket handed off, unsetting DISPLAY\n");
+ unsetenv("DISPLAY");
+ }
+
+ if(!_argv || !_envp) {
+ return KERN_FAILURE;
+ }
+
+ ErrorF("X11.app: do_start_x11_server(): argc=%d\n", argvCnt);
+ for(i=0; i < argvCnt; i++) {
+ _argv[i] = argv[i];
+ ErrorF("\targv[%u] = %s\n", (unsigned)i, argv[i]);
+ }
+ _argv[argvCnt] = NULL;
+
+ for(i=0; i < envpCnt; i++) {
+ _envp[i] = envp[i];
+ }
+ _envp[envpCnt] = NULL;
+
+ if(server_main(argvCnt, _argv, _envp) == 0)
+ return KERN_SUCCESS;
+ else
+ return KERN_FAILURE;
+}
+
+static int startup_trigger(int argc, char **argv, char **envp) {
+ Display *display;
+ const char *s;
+
+ /* Take care of the case where we're called like a normal DDX */
+ if(argc > 1 && argv[1][0] == ':') {
+ size_t i;
+ kern_return_t kr;
+ mach_port_t mp;
+ string_array_t newenvp;
+ string_array_t newargv;
+
+ /* We need to count envp */
+ int envpc;
+ for(envpc=0; envp[envpc]; envpc++);
+
+ /* We have fixed-size string lengths due to limitations in IPC,
+ * so we need to copy our argv and envp.
+ */
+ newargv = (string_array_t)alloca(argc * sizeof(string_t));
+ newenvp = (string_array_t)alloca(envpc * sizeof(string_t));
+
+ if(!newargv || !newenvp) {
+ ErrorF("Memory allocation failure\n");
+ exit(EXIT_FAILURE);
+ }
+
+ for(i=0; i < argc; i++) {
+ strlcpy(newargv[i], argv[i], STRING_T_SIZE);
+ }
+ for(i=0; i < envpc; i++) {
+ strlcpy(newenvp[i], envp[i], STRING_T_SIZE);
+ }
+
+ kr = bootstrap_look_up(bootstrap_port, server_bootstrap_name, &mp);
+ if (kr != KERN_SUCCESS) {
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
+ ErrorF("bootstrap_look_up(%s): %s\n", server_bootstrap_name, bootstrap_strerror(kr));
+#else
+ ErrorF("bootstrap_look_up(%s): %ul\n", server_bootstrap_name, (unsigned long)kr);
+#endif
+ exit(EXIT_FAILURE);
+ }
+
+ kr = start_x11_server(mp, newargv, argc, newenvp, envpc);
+ if (kr != KERN_SUCCESS) {
+ ErrorF("start_x11_server: %s\n", mach_error_string(kr));
+ exit(EXIT_FAILURE);
+ }
+ exit(EXIT_SUCCESS);
+ }
+
+ /* If we have a process serial number and it's our only arg, act as if
+ * the user double clicked the app bundle: launch app_to_run if possible
+ */
+ if(argc == 1 || (argc == 2 && !strncmp(argv[1], "-psn_", 5))) {
+ /* Now, try to open a display, if so, run the launcher */
+ display = XOpenDisplay(NULL);
+ if(display) {
+ /* Could open the display, start the launcher */
+ XCloseDisplay(display);
+
+ return execute(pref_app_to_run);
+ }
+ }
+
+ /* Start the server */
+ if((s = getenv("DISPLAY"))) {
+ ErrorF("X11.app: Could not connect to server (DISPLAY=\"%s\", unsetting). Starting X server.\n", s);
+ unsetenv("DISPLAY");
+ } else {
+ ErrorF("X11.app: Could not connect to server (DISPLAY is not set). Starting X server.\n");
+ }
+ return execute(pref_startx_script);
+}
+
+/** Setup the environment we want our child processes to inherit */
+static void ensure_path(const char *dir) {
+ char buf[1024], *temp;
+
+ /* Make sure /usr/X11/bin is in the $PATH */
+ temp = getenv("PATH");
+ if(temp == NULL || temp[0] == 0) {
+ snprintf(buf, sizeof(buf), "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:%s", dir);
+ setenv("PATH", buf, TRUE);
+ } else if(strnstr(temp, X11BINDIR, sizeof(temp)) == NULL) {
+ snprintf(buf, sizeof(buf), "%s:%s", temp, dir);
+ setenv("PATH", buf, TRUE);
+ }
+}
+
+static void setup_console_redirect(const char *bundle_id) {
+ char *asl_sender;
+ char *asl_facility;
+
+ asprintf(&asl_sender, "%s.server", bundle_id);
+ assert(asl_sender);
+
+ asl_facility = strdup(bundle_id);
+ assert(asl_facility);
+ if(strcmp(asl_facility + strlen(asl_facility) - 4, ".X11") == 0)
+ asl_facility[strlen(asl_facility) - 4] = '\0';
+
+ assert(aslc = asl_open(asl_sender, asl_facility, ASL_OPT_NO_DELAY));
+ free(asl_sender);
+ free(asl_facility);
+
+ asl_set_filter(aslc, ASL_FILTER_MASK_UPTO(ASL_LEVEL_WARNING));
+ xq_asl_capture_fd(aslc, NULL, ASL_LEVEL_INFO, STDOUT_FILENO);
+ xq_asl_capture_fd(aslc, NULL, ASL_LEVEL_NOTICE, STDERR_FILENO);
+}
+
+static void setup_env(void) {
+ char *temp;
+ const char *pds = NULL;
+ const char *disp = getenv("DISPLAY");
+ size_t len;
+
+ /* Pass on our prefs domain to startx and its inheritors (mainly for
+ * quartz-wm and the Xquartz stub's MachIPC)
+ */
+ CFBundleRef bundle = CFBundleGetMainBundle();
+ if(bundle) {
+ CFStringRef pd = CFBundleGetIdentifier(bundle);
+ if(pd) {
+ pds = CFStringGetCStringPtr(pd, 0);
+ }
+ }
+
+ /* fallback to hardcoded value if we can't discover it */
+ if(!pds) {
+ pds = BUNDLE_ID_PREFIX".X11";
+ }
+
+ setup_console_redirect(pds);
+
+ server_bootstrap_name = strdup(pds);
+ if(!server_bootstrap_name) {
+ ErrorF("X11.app: Memory allocation error.\n");
+ exit(1);
+ }
+ setenv("X11_PREFS_DOMAIN", server_bootstrap_name, 1);
+
+ len = strlen(server_bootstrap_name);
+ bundle_id_prefix = malloc(sizeof(char) * (len - 3));
+ if(!bundle_id_prefix) {
+ ErrorF("X11.app: Memory allocation error.\n");
+ exit(1);
+ }
+ strlcpy(bundle_id_prefix, server_bootstrap_name, len - 3);
+
+ /* We need to unset DISPLAY if it is not our socket */
+ if(disp) {
+ /* s = basename(disp) */
+ const char *d, *s;
+ for(s = NULL, d = disp; *d; d++) {
+ if(*d == '/')
+ s = d + 1;
+ }
+
+ if(s && *s) {
+ if(strcmp(bundle_id_prefix, "org.x") == 0 && strcmp(s, ":0") == 0) {
+ ErrorF("X11.app: Detected old style launchd DISPLAY, please update xinit.\n");
+ } else {
+ temp = (char *)malloc(sizeof(char) * len);
+ if(!temp) {
+ ErrorF("X11.app: Memory allocation error creating space for socket name test.\n");
+ exit(1);
+ }
+ strlcpy(temp, bundle_id_prefix, len);
+ strlcat(temp, ":0", len);
+
+ if(strcmp(temp, s) != 0) {
+ /* If we don't have a match, unset it. */
+ ErrorF("X11.app: DISPLAY (\"%s\") does not match our id (\"%s\"), unsetting.\n", disp, bundle_id_prefix);
+ unsetenv("DISPLAY");
+ }
+ free(temp);
+ }
+ } else {
+ /* The DISPLAY environment variable is not formatted like a launchd socket, so reset. */
+ ErrorF("X11.app: DISPLAY does not look like a launchd set variable, unsetting.\n");
+ unsetenv("DISPLAY");
+ }
+ }
+
+ /* Make sure PATH is right */
+ ensure_path(X11BINDIR);
+
+ /* cd $HOME */
+ temp = getenv("HOME");
+ if(temp != NULL && temp[0] != '\0')
+ chdir(temp);
+}
+
+/*** Main ***/
+int main(int argc, char **argv, char **envp) {
+ Bool listenOnly = FALSE;
+ int i;
+ mach_msg_size_t mxmsgsz = sizeof(union MaxMsgSize) + MAX_TRAILER_SIZE;
+ mach_port_t mp;
+ kern_return_t kr;
+
+ /* Setup our environment for our children */
+ setup_env();
+
+ /* The server must not run the PanoramiX operations. */
+ noPanoramiXExtension = TRUE;
+
+ /* Setup the initial crasherporter info */
+ strlcpy(__crashreporter_info_buff__, __crashreporter_info__base, sizeof(__crashreporter_info_buff__));
+
+ ErrorF("X11.app: main(): argc=%d\n", argc);
+ for(i=0; i < argc; i++) {
+ ErrorF("\targv[%u] = %s\n", (unsigned)i, argv[i]);
+ if(!strcmp(argv[i], "--listenonly")) {
+ listenOnly = TRUE;
+ }
+ }
+
+ mp = checkin_or_register(server_bootstrap_name);
+ if(mp == MACH_PORT_NULL) {
+ ErrorF("NULL mach service: %s", server_bootstrap_name);
+ return EXIT_FAILURE;
+ }
+
+ /* Check if we need to do something other than listen, and make another
+ * thread handle it.
+ */
+ if(!listenOnly) {
+ pid_t child1, child2;
+ int status;
+
+ pref_app_to_run = command_from_prefs("app_to_run", DEFAULT_CLIENT);
+ assert(pref_app_to_run);
+
+ pref_login_shell = command_from_prefs("login_shell", DEFAULT_SHELL);
+ assert(pref_login_shell);
+
+ pref_startx_script = command_from_prefs("startx_script", DEFAULT_STARTX);
+ assert(pref_startx_script);
+
+ /* Do the fork-twice trick to avoid having to reap zombies */
+ child1 = fork();
+ switch (child1) {
+ case -1: /* error */
+ FatalError("fork() failed: %s\n", strerror(errno));
+
+ case 0: /* child1 */
+ child2 = fork();
+
+ switch (child2) {
+ int max_files;
+
+ case -1: /* error */
+ FatalError("fork() failed: %s\n", strerror(errno));
+
+ case 0: /* child2 */
+ /* close all open files except for standard streams */
+ max_files = sysconf(_SC_OPEN_MAX);
+ for(i = 3; i < max_files; i++)
+ close(i);
+
+ /* ensure stdin is on /dev/null */
+ close(0);
+ open("/dev/null", O_RDONLY);
+
+ return startup_trigger(argc, argv, envp);
+
+ default: /* parent (child1) */
+ _exit(0);
+ }
+ break;
+
+ default: /* parent */
+ waitpid(child1, &status, 0);
+ }
+
+ free(pref_app_to_run);
+ free(pref_login_shell);
+ free(pref_startx_script);
+ }
+
+ /* Main event loop */
+ ErrorF("Waiting for startup parameters via Mach IPC.\n");
+ kr = mach_msg_server(mach_startup_server, mxmsgsz, mp, 0);
+ if (kr != KERN_SUCCESS) {
+ ErrorF("%s.X11(mp): %s\n", BUNDLE_ID_PREFIX, mach_error_string(kr));
+ return EXIT_FAILURE;
+ }
+
+ return EXIT_SUCCESS;
+}
+
+static int execute(const char *command) {
+ const char *newargv[4];
+ const char **p;
+
+ newargv[0] = pref_login_shell;
+ newargv[1] = "-c";
+ newargv[2] = command;
+ newargv[3] = NULL;
+
+ ErrorF("X11.app: Launching %s:\n", command);
+ for(p=newargv; *p; p++) {
+ ErrorF("\targv[%ld] = %s\n", (long int)(p - newargv), *p);
+ }
+
+ execvp (newargv[0], (char * const *) newargv);
+ perror ("X11.app: Couldn't exec.");
+ return 1;
+}
+
+static char *command_from_prefs(const char *key, const char *default_value) {
+ char *command = NULL;
+
+ CFStringRef cfKey;
+ CFPropertyListRef PlistRef;
+
+ if(!key)
+ return NULL;
+
+ cfKey = CFStringCreateWithCString(NULL, key, kCFStringEncodingASCII);
+
+ if(!cfKey)
+ return NULL;
+
+ PlistRef = CFPreferencesCopyAppValue(cfKey, kCFPreferencesCurrentApplication);
+
+ if ((PlistRef == NULL) || (CFGetTypeID(PlistRef) != CFStringGetTypeID())) {
+ CFStringRef cfDefaultValue = CFStringCreateWithCString(NULL, default_value, kCFStringEncodingASCII);
+ int len = strlen(default_value) + 1;
+
+ if(!cfDefaultValue)
+ goto command_from_prefs_out;
+
+ CFPreferencesSetAppValue(cfKey, cfDefaultValue, kCFPreferencesCurrentApplication);
+ CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
+ CFRelease(cfDefaultValue);
+
+ command = (char *)malloc(len * sizeof(char));
+ if(!command)
+ goto command_from_prefs_out;
+ strcpy(command, default_value);
+ } else {
+ int len = CFStringGetLength((CFStringRef)PlistRef) + 1;
+ command = (char *)malloc(len * sizeof(char));
+ if(!command)
+ goto command_from_prefs_out;
+ CFStringGetCString((CFStringRef)PlistRef, command, len, kCFStringEncodingASCII);
+ }
+
+command_from_prefs_out:
+ if (PlistRef)
+ CFRelease(PlistRef);
+ if(cfKey)
+ CFRelease(cfKey);
+ return command;
+}
diff --git a/xorg-server/hw/xquartz/mach-startup/launchd_fd.c b/xorg-server/hw/xquartz/mach-startup/launchd_fd.c
index 67a4dadd7..8003dd177 100644
--- a/xorg-server/hw/xquartz/mach-startup/launchd_fd.c
+++ b/xorg-server/hw/xquartz/mach-startup/launchd_fd.c
@@ -1,91 +1,91 @@
-/* Copyright (c) 2008 Apple 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 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.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <launch.h>
-#include <asl.h>
-#include <errno.h>
-
-#include "launchd_fd.h"
-
-extern aslclient aslc;
-
-int launchd_display_fd(void) {
- launch_data_t sockets_dict, checkin_request, checkin_response;
- launch_data_t listening_fd_array, listening_fd;
-
- /* Get launchd fd */
- if ((checkin_request = launch_data_new_string(LAUNCH_KEY_CHECKIN)) == NULL) {
- asl_log(aslc, NULL, ASL_LEVEL_ERR, "launch_data_new_string(\"" LAUNCH_KEY_CHECKIN "\") Unable to create string.\n");
- return ERROR_FD;
- }
-
- if ((checkin_response = launch_msg(checkin_request)) == NULL) {
- asl_log(aslc, NULL, ASL_LEVEL_WARNING, "launch_msg(\"" LAUNCH_KEY_CHECKIN "\") IPC failure: %s\n",strerror(errno));
- return ERROR_FD;
- }
-
- if (LAUNCH_DATA_ERRNO == launch_data_get_type(checkin_response)) {
- // ignore EACCES, which is common if we weren't started by launchd
- if (launch_data_get_errno(checkin_response) != EACCES)
- asl_log(aslc, NULL, ASL_LEVEL_ERR, "launchd check-in failed: %s\n", strerror(launch_data_get_errno(checkin_response)));
- return ERROR_FD;
- }
-
- sockets_dict = launch_data_dict_lookup(checkin_response, LAUNCH_JOBKEY_SOCKETS);
- if (NULL == sockets_dict) {
- asl_log(aslc, NULL, ASL_LEVEL_ERR, "launchd check-in: no sockets found to answer requests on!\n");
- return ERROR_FD;
- }
-
- if (launch_data_dict_get_count(sockets_dict) > 1) {
- asl_log(aslc, NULL, ASL_LEVEL_ERR, "launchd check-in: some sockets will be ignored!\n");
- return ERROR_FD;
- }
-
- listening_fd_array = launch_data_dict_lookup(sockets_dict, BUNDLE_ID_PREFIX":0");
- if (NULL == listening_fd_array) {
- listening_fd_array = launch_data_dict_lookup(sockets_dict, ":0");
- if (NULL == listening_fd_array) {
- asl_log(aslc, NULL, ASL_LEVEL_ERR, "launchd check-in: No known sockets found to answer requests on! \"%s:0\" and \":0\" failed.\n", BUNDLE_ID_PREFIX);
- return ERROR_FD;
- }
- }
-
- if (launch_data_array_get_count(listening_fd_array)!=1) {
- asl_log(aslc, NULL, ASL_LEVEL_ERR, "launchd check-in: Expected 1 socket from launchd, got %u)\n",
- (unsigned)launch_data_array_get_count(listening_fd_array));
- return ERROR_FD;
- }
-
- listening_fd=launch_data_array_get_index(listening_fd_array, 0);
- return launch_data_get_fd(listening_fd);
-}
+/* Copyright (c) 2008 Apple 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 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.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <launch.h>
+#include <asl.h>
+#include <errno.h>
+
+#include "launchd_fd.h"
+
+extern aslclient aslc;
+
+int launchd_display_fd(void) {
+ launch_data_t sockets_dict, checkin_request, checkin_response;
+ launch_data_t listening_fd_array, listening_fd;
+
+ /* Get launchd fd */
+ if ((checkin_request = launch_data_new_string(LAUNCH_KEY_CHECKIN)) == NULL) {
+ asl_log(aslc, NULL, ASL_LEVEL_ERR, "launch_data_new_string(\"" LAUNCH_KEY_CHECKIN "\") Unable to create string.\n");
+ return ERROR_FD;
+ }
+
+ if ((checkin_response = launch_msg(checkin_request)) == NULL) {
+ asl_log(aslc, NULL, ASL_LEVEL_WARNING, "launch_msg(\"" LAUNCH_KEY_CHECKIN "\") IPC failure: %s\n",strerror(errno));
+ return ERROR_FD;
+ }
+
+ if (LAUNCH_DATA_ERRNO == launch_data_get_type(checkin_response)) {
+ // ignore EACCES, which is common if we weren't started by launchd
+ if (launch_data_get_errno(checkin_response) != EACCES)
+ asl_log(aslc, NULL, ASL_LEVEL_ERR, "launchd check-in failed: %s\n", strerror(launch_data_get_errno(checkin_response)));
+ return ERROR_FD;
+ }
+
+ sockets_dict = launch_data_dict_lookup(checkin_response, LAUNCH_JOBKEY_SOCKETS);
+ if (NULL == sockets_dict) {
+ asl_log(aslc, NULL, ASL_LEVEL_ERR, "launchd check-in: no sockets found to answer requests on!\n");
+ return ERROR_FD;
+ }
+
+ if (launch_data_dict_get_count(sockets_dict) > 1) {
+ asl_log(aslc, NULL, ASL_LEVEL_ERR, "launchd check-in: some sockets will be ignored!\n");
+ return ERROR_FD;
+ }
+
+ listening_fd_array = launch_data_dict_lookup(sockets_dict, BUNDLE_ID_PREFIX":0");
+ if (NULL == listening_fd_array) {
+ listening_fd_array = launch_data_dict_lookup(sockets_dict, ":0");
+ if (NULL == listening_fd_array) {
+ asl_log(aslc, NULL, ASL_LEVEL_ERR, "launchd check-in: No known sockets found to answer requests on! \"%s:0\" and \":0\" failed.\n", BUNDLE_ID_PREFIX);
+ return ERROR_FD;
+ }
+ }
+
+ if (launch_data_array_get_count(listening_fd_array)!=1) {
+ asl_log(aslc, NULL, ASL_LEVEL_ERR, "launchd check-in: Expected 1 socket from launchd, got %u)\n",
+ (unsigned)launch_data_array_get_count(listening_fd_array));
+ return ERROR_FD;
+ }
+
+ listening_fd=launch_data_array_get_index(listening_fd_array, 0);
+ return launch_data_get_fd(listening_fd);
+}
diff --git a/xorg-server/hw/xquartz/mach-startup/stub.c b/xorg-server/hw/xquartz/mach-startup/stub.c
index f6dda98e9..d8e4abdd1 100644
--- a/xorg-server/hw/xquartz/mach-startup/stub.c
+++ b/xorg-server/hw/xquartz/mach-startup/stub.c
@@ -1,318 +1,318 @@
-/* Copyright (c) 2008 Apple 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 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.
- */
-
-#include <CoreServices/CoreServices.h>
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <string.h>
-#include <unistd.h>
-#include <errno.h>
-#include <asl.h>
-
-#include <sys/socket.h>
-#include <sys/un.h>
-
-#define kX11AppBundleId BUNDLE_ID_PREFIX".X11"
-#define kX11AppBundlePath "/Contents/MacOS/X11"
-
-#include <mach/mach.h>
-#include <mach/mach_error.h>
-#include <servers/bootstrap.h>
-#include "mach_startup.h"
-
-#include <signal.h>
-
-#include <AvailabilityMacros.h>
-
-#include "launchd_fd.h"
-
-static char x11_path[PATH_MAX + 1];
-static pid_t x11app_pid = 0;
-aslclient aslc;
-
-static void set_x11_path(void) {
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
-
- CFURLRef appURL = NULL;
- OSStatus osstatus = LSFindApplicationForInfo(kLSUnknownCreator, CFSTR(kX11AppBundleId), nil, nil, &appURL);
-
- switch (osstatus) {
- case noErr:
- if (appURL == NULL) {
- asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: Invalid response from LSFindApplicationForInfo(%s)",
- kX11AppBundleId);
- exit(1);
- }
-
- if (!CFURLGetFileSystemRepresentation(appURL, true, (unsigned char *)x11_path, sizeof(x11_path))) {
- asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: Error resolving URL for %s", kX11AppBundleId);
- exit(3);
- }
-
- strlcat(x11_path, kX11AppBundlePath, sizeof(x11_path));
- asl_log(aslc, NULL, ASL_LEVEL_INFO, "Xquartz: X11.app = %s", x11_path);
- break;
- case kLSApplicationNotFoundErr:
- asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: Unable to find application for %s", kX11AppBundleId);
- exit(10);
- default:
- asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: Unable to find application for %s, error code = %d",
- kX11AppBundleId, (int)osstatus);
- exit(11);
- }
-#else
- /* TODO: Make Tiger smarter... but TBH, this should never get called on Tiger... */
- strlcpy(x11_path, "/Applications/Utilities/X11.app/Contents/MacOS/X11", sizeof(x11_path));
-#endif
-}
-
-static int connect_to_socket(const char *filename) {
- struct sockaddr_un servaddr_un;
- struct sockaddr *servaddr;
- socklen_t servaddr_len;
- int ret_fd;
-
- /* Setup servaddr_un */
- memset (&servaddr_un, 0, sizeof (struct sockaddr_un));
- servaddr_un.sun_family = AF_UNIX;
- strlcpy(servaddr_un.sun_path, filename, sizeof(servaddr_un.sun_path));
-
- servaddr = (struct sockaddr *) &servaddr_un;
- servaddr_len = sizeof(struct sockaddr_un) - sizeof(servaddr_un.sun_path) + strlen(filename);
-
- ret_fd = socket(PF_UNIX, SOCK_STREAM, 0);
- if(ret_fd == -1) {
- asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: Failed to create socket: %s - %s", filename, strerror(errno));
- return -1;
- }
-
- if(connect(ret_fd, servaddr, servaddr_len) < 0) {
- asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: Failed to connect to socket: %s - %d - %s", filename, errno, strerror(errno));
- close(ret_fd);
- return -1;
- }
-
- return ret_fd;
-}
-
-static void send_fd_handoff(int connected_fd, int launchd_fd) {
- char databuf[] = "display";
- struct iovec iov[1];
-
- union {
- struct cmsghdr hdr;
- char bytes[CMSG_SPACE(sizeof(int))];
- } buf;
-
- struct msghdr msg;
- struct cmsghdr *cmsg;
-
- iov[0].iov_base = databuf;
- iov[0].iov_len = sizeof(databuf);
-
- msg.msg_iov = iov;
- msg.msg_iovlen = 1;
- msg.msg_control = buf.bytes;
- msg.msg_controllen = sizeof(buf);
- msg.msg_name = 0;
- msg.msg_namelen = 0;
- msg.msg_flags = 0;
-
- cmsg = CMSG_FIRSTHDR (&msg);
- cmsg->cmsg_level = SOL_SOCKET;
- cmsg->cmsg_type = SCM_RIGHTS;
- cmsg->cmsg_len = CMSG_LEN(sizeof(int));
-
- msg.msg_controllen = cmsg->cmsg_len;
-
- *((int*)CMSG_DATA(cmsg)) = launchd_fd;
-
- if(sendmsg(connected_fd, &msg, 0) < 0) {
- asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: Error sending $DISPLAY file descriptor over fd %d: %d -- %s", connected_fd, errno, strerror(errno));
- return;
- }
-
- asl_log(aslc, NULL, ASL_LEVEL_DEBUG, "Xquartz: Message sent. Closing handoff fd.");
- close(connected_fd);
-}
-
-__attribute__((__noreturn__))
-static void signal_handler(int sig) {
- if(x11app_pid)
- kill(x11app_pid, sig);
- _exit(0);
-}
-
-int main(int argc, char **argv, char **envp) {
- int envpc;
- kern_return_t kr;
- mach_port_t mp;
- string_array_t newenvp;
- string_array_t newargv;
- size_t i;
- int launchd_fd;
- string_t handoff_socket_filename;
- sig_t handler;
- char *asl_sender;
- char *asl_facility;
- char *server_bootstrap_name = kX11AppBundleId;
-
- if(getenv("X11_PREFS_DOMAIN"))
- server_bootstrap_name = getenv("X11_PREFS_DOMAIN");
-
- asprintf(&asl_sender, "%s.stub", server_bootstrap_name);
- assert(asl_sender);
-
- asl_facility = strdup(server_bootstrap_name);
- assert(asl_facility);
- if(strcmp(asl_facility + strlen(asl_facility) - 4, ".X11") == 0)
- asl_facility[strlen(asl_facility) - 4] = '\0';
-
- assert(aslc = asl_open(asl_sender, asl_facility, ASL_OPT_NO_DELAY));
- free(asl_sender);
- free(asl_facility);
-
- /* We don't have a mechanism in place to handle this interrupt driven
- * server-start notification, so just send the signal now, so xinit doesn't
- * time out waiting for it and will just poll for the server.
- */
- handler = signal(SIGUSR1, SIG_IGN);
- if(handler == SIG_IGN)
- kill(getppid(), SIGUSR1);
- signal(SIGUSR1, handler);
-
- /* Pass on SIGs to X11.app */
- signal(SIGINT, signal_handler);
- signal(SIGTERM, signal_handler);
-
- /* Get the $DISPLAY FD */
- launchd_fd = launchd_display_fd();
-
- kr = bootstrap_look_up(bootstrap_port, server_bootstrap_name, &mp);
- if(kr != KERN_SUCCESS) {
- pid_t child;
-
- asl_log(aslc, NULL, ASL_LEVEL_WARNING, "Xquartz: Unable to locate waiting server: %s", server_bootstrap_name);
- set_x11_path();
-
- /* This forking is ugly and will be cleaned up later */
- child = fork();
- if(child == -1) {
- asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: Could not fork: %s", strerror(errno));
- return EXIT_FAILURE;
- }
-
- if(child == 0) {
- char *_argv[3];
- _argv[0] = x11_path;
- _argv[1] = "--listenonly";
- _argv[2] = NULL;
- asl_log(aslc, NULL, ASL_LEVEL_NOTICE, "Xquartz: Starting X server: %s --listenonly", x11_path);
- return execvp(x11_path, _argv);
- }
-
- /* Try connecting for 10 seconds */
- for(i=0; i < 80; i++) {
- usleep(250000);
- kr = bootstrap_look_up(bootstrap_port, server_bootstrap_name, &mp);
- if(kr == KERN_SUCCESS)
- break;
- }
-
- if(kr != KERN_SUCCESS) {
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
- asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: bootstrap_look_up(): %s", bootstrap_strerror(kr));
-#else
- asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: bootstrap_look_up(): %ul", (unsigned long)kr);
-#endif
- return EXIT_FAILURE;
- }
- }
-
- /* Get X11.app's pid */
- request_pid(mp, &x11app_pid);
-
- /* Handoff the $DISPLAY FD */
- if(launchd_fd != -1) {
- size_t try, try_max;
- int handoff_fd = -1;
-
- for(try=0, try_max=5; try < try_max; try++) {
- if(request_fd_handoff_socket(mp, handoff_socket_filename) != KERN_SUCCESS) {
- asl_log(aslc, NULL, ASL_LEVEL_INFO, "Xquartz: Failed to request a socket from the server to send the $DISPLAY fd over (try %d of %d)", (int)try+1, (int)try_max);
- continue;
- }
-
- handoff_fd = connect_to_socket(handoff_socket_filename);
- if(handoff_fd == -1) {
- asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: Failed to connect to socket (try %d of %d)", (int)try+1, (int)try_max);
- continue;
- }
-
- asl_log(aslc, NULL, ASL_LEVEL_INFO, "Xquartz: Handoff connection established (try %d of %d) on fd %d, \"%s\". Sending message.", (int)try+1, (int)try_max, handoff_fd, handoff_socket_filename);
- send_fd_handoff(handoff_fd, launchd_fd);
- close(handoff_fd);
- break;
- }
- }
-
- /* Count envp */
- for(envpc=0; envp[envpc]; envpc++);
-
- /* We have fixed-size string lengths due to limitations in IPC,
- * so we need to copy our argv and envp.
- */
- newargv = (string_array_t)calloc((1 + argc), sizeof(string_t));
- newenvp = (string_array_t)calloc((1 + envpc), sizeof(string_t));
-
- if(!newargv || !newenvp) {
- asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: Memory allocation failure");
- return EXIT_FAILURE;
- }
-
- for(i=0; i < argc; i++) {
- strlcpy(newargv[i], argv[i], STRING_T_SIZE);
- }
- for(i=0; i < envpc; i++) {
- strlcpy(newenvp[i], envp[i], STRING_T_SIZE);
- }
-
- kr = start_x11_server(mp, newargv, argc, newenvp, envpc);
-
- free(newargv);
- free(newenvp);
-
- if (kr != KERN_SUCCESS) {
- asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: start_x11_server: %s", mach_error_string(kr));
- return EXIT_FAILURE;
- }
- return EXIT_SUCCESS;
-}
+/* Copyright (c) 2008 Apple 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 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.
+ */
+
+#include <CoreServices/CoreServices.h>
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+#include <asl.h>
+
+#include <sys/socket.h>
+#include <sys/un.h>
+
+#define kX11AppBundleId BUNDLE_ID_PREFIX".X11"
+#define kX11AppBundlePath "/Contents/MacOS/X11"
+
+#include <mach/mach.h>
+#include <mach/mach_error.h>
+#include <servers/bootstrap.h>
+#include "mach_startup.h"
+
+#include <signal.h>
+
+#include <AvailabilityMacros.h>
+
+#include "launchd_fd.h"
+
+static char x11_path[PATH_MAX + 1];
+static pid_t x11app_pid = 0;
+aslclient aslc;
+
+static void set_x11_path(void) {
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
+
+ CFURLRef appURL = NULL;
+ OSStatus osstatus = LSFindApplicationForInfo(kLSUnknownCreator, CFSTR(kX11AppBundleId), nil, nil, &appURL);
+
+ switch (osstatus) {
+ case noErr:
+ if (appURL == NULL) {
+ asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: Invalid response from LSFindApplicationForInfo(%s)",
+ kX11AppBundleId);
+ exit(1);
+ }
+
+ if (!CFURLGetFileSystemRepresentation(appURL, true, (unsigned char *)x11_path, sizeof(x11_path))) {
+ asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: Error resolving URL for %s", kX11AppBundleId);
+ exit(3);
+ }
+
+ strlcat(x11_path, kX11AppBundlePath, sizeof(x11_path));
+ asl_log(aslc, NULL, ASL_LEVEL_INFO, "Xquartz: X11.app = %s", x11_path);
+ break;
+ case kLSApplicationNotFoundErr:
+ asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: Unable to find application for %s", kX11AppBundleId);
+ exit(10);
+ default:
+ asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: Unable to find application for %s, error code = %d",
+ kX11AppBundleId, (int)osstatus);
+ exit(11);
+ }
+#else
+ /* TODO: Make Tiger smarter... but TBH, this should never get called on Tiger... */
+ strlcpy(x11_path, "/Applications/Utilities/X11.app/Contents/MacOS/X11", sizeof(x11_path));
+#endif
+}
+
+static int connect_to_socket(const char *filename) {
+ struct sockaddr_un servaddr_un;
+ struct sockaddr *servaddr;
+ socklen_t servaddr_len;
+ int ret_fd;
+
+ /* Setup servaddr_un */
+ memset (&servaddr_un, 0, sizeof (struct sockaddr_un));
+ servaddr_un.sun_family = AF_UNIX;
+ strlcpy(servaddr_un.sun_path, filename, sizeof(servaddr_un.sun_path));
+
+ servaddr = (struct sockaddr *) &servaddr_un;
+ servaddr_len = sizeof(struct sockaddr_un) - sizeof(servaddr_un.sun_path) + strlen(filename);
+
+ ret_fd = socket(PF_UNIX, SOCK_STREAM, 0);
+ if(ret_fd == -1) {
+ asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: Failed to create socket: %s - %s", filename, strerror(errno));
+ return -1;
+ }
+
+ if(connect(ret_fd, servaddr, servaddr_len) < 0) {
+ asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: Failed to connect to socket: %s - %d - %s", filename, errno, strerror(errno));
+ close(ret_fd);
+ return -1;
+ }
+
+ return ret_fd;
+}
+
+static void send_fd_handoff(int connected_fd, int launchd_fd) {
+ char databuf[] = "display";
+ struct iovec iov[1];
+
+ union {
+ struct cmsghdr hdr;
+ char bytes[CMSG_SPACE(sizeof(int))];
+ } buf;
+
+ struct msghdr msg;
+ struct cmsghdr *cmsg;
+
+ iov[0].iov_base = databuf;
+ iov[0].iov_len = sizeof(databuf);
+
+ msg.msg_iov = iov;
+ msg.msg_iovlen = 1;
+ msg.msg_control = buf.bytes;
+ msg.msg_controllen = sizeof(buf);
+ msg.msg_name = 0;
+ msg.msg_namelen = 0;
+ msg.msg_flags = 0;
+
+ cmsg = CMSG_FIRSTHDR (&msg);
+ cmsg->cmsg_level = SOL_SOCKET;
+ cmsg->cmsg_type = SCM_RIGHTS;
+ cmsg->cmsg_len = CMSG_LEN(sizeof(int));
+
+ msg.msg_controllen = cmsg->cmsg_len;
+
+ *((int*)CMSG_DATA(cmsg)) = launchd_fd;
+
+ if(sendmsg(connected_fd, &msg, 0) < 0) {
+ asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: Error sending $DISPLAY file descriptor over fd %d: %d -- %s", connected_fd, errno, strerror(errno));
+ return;
+ }
+
+ asl_log(aslc, NULL, ASL_LEVEL_DEBUG, "Xquartz: Message sent. Closing handoff fd.");
+ close(connected_fd);
+}
+
+__attribute__((__noreturn__))
+static void signal_handler(int sig) {
+ if(x11app_pid)
+ kill(x11app_pid, sig);
+ _exit(0);
+}
+
+int main(int argc, char **argv, char **envp) {
+ int envpc;
+ kern_return_t kr;
+ mach_port_t mp;
+ string_array_t newenvp;
+ string_array_t newargv;
+ size_t i;
+ int launchd_fd;
+ string_t handoff_socket_filename;
+ sig_t handler;
+ char *asl_sender;
+ char *asl_facility;
+ char *server_bootstrap_name = kX11AppBundleId;
+
+ if(getenv("X11_PREFS_DOMAIN"))
+ server_bootstrap_name = getenv("X11_PREFS_DOMAIN");
+
+ asprintf(&asl_sender, "%s.stub", server_bootstrap_name);
+ assert(asl_sender);
+
+ asl_facility = strdup(server_bootstrap_name);
+ assert(asl_facility);
+ if(strcmp(asl_facility + strlen(asl_facility) - 4, ".X11") == 0)
+ asl_facility[strlen(asl_facility) - 4] = '\0';
+
+ assert(aslc = asl_open(asl_sender, asl_facility, ASL_OPT_NO_DELAY));
+ free(asl_sender);
+ free(asl_facility);
+
+ /* We don't have a mechanism in place to handle this interrupt driven
+ * server-start notification, so just send the signal now, so xinit doesn't
+ * time out waiting for it and will just poll for the server.
+ */
+ handler = signal(SIGUSR1, SIG_IGN);
+ if(handler == SIG_IGN)
+ kill(getppid(), SIGUSR1);
+ signal(SIGUSR1, handler);
+
+ /* Pass on SIGs to X11.app */
+ signal(SIGINT, signal_handler);
+ signal(SIGTERM, signal_handler);
+
+ /* Get the $DISPLAY FD */
+ launchd_fd = launchd_display_fd();
+
+ kr = bootstrap_look_up(bootstrap_port, server_bootstrap_name, &mp);
+ if(kr != KERN_SUCCESS) {
+ pid_t child;
+
+ asl_log(aslc, NULL, ASL_LEVEL_WARNING, "Xquartz: Unable to locate waiting server: %s", server_bootstrap_name);
+ set_x11_path();
+
+ /* This forking is ugly and will be cleaned up later */
+ child = fork();
+ if(child == -1) {
+ asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: Could not fork: %s", strerror(errno));
+ return EXIT_FAILURE;
+ }
+
+ if(child == 0) {
+ char *_argv[3];
+ _argv[0] = x11_path;
+ _argv[1] = "--listenonly";
+ _argv[2] = NULL;
+ asl_log(aslc, NULL, ASL_LEVEL_NOTICE, "Xquartz: Starting X server: %s --listenonly", x11_path);
+ return execvp(x11_path, _argv);
+ }
+
+ /* Try connecting for 10 seconds */
+ for(i=0; i < 80; i++) {
+ usleep(250000);
+ kr = bootstrap_look_up(bootstrap_port, server_bootstrap_name, &mp);
+ if(kr == KERN_SUCCESS)
+ break;
+ }
+
+ if(kr != KERN_SUCCESS) {
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
+ asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: bootstrap_look_up(): %s", bootstrap_strerror(kr));
+#else
+ asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: bootstrap_look_up(): %ul", (unsigned long)kr);
+#endif
+ return EXIT_FAILURE;
+ }
+ }
+
+ /* Get X11.app's pid */
+ request_pid(mp, &x11app_pid);
+
+ /* Handoff the $DISPLAY FD */
+ if(launchd_fd != -1) {
+ size_t try, try_max;
+ int handoff_fd = -1;
+
+ for(try=0, try_max=5; try < try_max; try++) {
+ if(request_fd_handoff_socket(mp, handoff_socket_filename) != KERN_SUCCESS) {
+ asl_log(aslc, NULL, ASL_LEVEL_INFO, "Xquartz: Failed to request a socket from the server to send the $DISPLAY fd over (try %d of %d)", (int)try+1, (int)try_max);
+ continue;
+ }
+
+ handoff_fd = connect_to_socket(handoff_socket_filename);
+ if(handoff_fd == -1) {
+ asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: Failed to connect to socket (try %d of %d)", (int)try+1, (int)try_max);
+ continue;
+ }
+
+ asl_log(aslc, NULL, ASL_LEVEL_INFO, "Xquartz: Handoff connection established (try %d of %d) on fd %d, \"%s\". Sending message.", (int)try+1, (int)try_max, handoff_fd, handoff_socket_filename);
+ send_fd_handoff(handoff_fd, launchd_fd);
+ close(handoff_fd);
+ break;
+ }
+ }
+
+ /* Count envp */
+ for(envpc=0; envp[envpc]; envpc++);
+
+ /* We have fixed-size string lengths due to limitations in IPC,
+ * so we need to copy our argv and envp.
+ */
+ newargv = (string_array_t)calloc((1 + argc), sizeof(string_t));
+ newenvp = (string_array_t)calloc((1 + envpc), sizeof(string_t));
+
+ if(!newargv || !newenvp) {
+ asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: Memory allocation failure");
+ return EXIT_FAILURE;
+ }
+
+ for(i=0; i < argc; i++) {
+ strlcpy(newargv[i], argv[i], STRING_T_SIZE);
+ }
+ for(i=0; i < envpc; i++) {
+ strlcpy(newenvp[i], envp[i], STRING_T_SIZE);
+ }
+
+ kr = start_x11_server(mp, newargv, argc, newenvp, envpc);
+
+ free(newargv);
+ free(newenvp);
+
+ if (kr != KERN_SUCCESS) {
+ asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: start_x11_server: %s", mach_error_string(kr));
+ return EXIT_FAILURE;
+ }
+ return EXIT_SUCCESS;
+}
diff --git a/xorg-server/hw/xquartz/man/Xquartz.man b/xorg-server/hw/xquartz/man/Xquartz.man
index cf4edcd20..0ea6e6eb8 100644
--- a/xorg-server/hw/xquartz/man/Xquartz.man
+++ b/xorg-server/hw/xquartz/man/Xquartz.man
@@ -1,192 +1,192 @@
-.TH XQUARTZ 1 __vendorversion__
-.SH NAME
-Xquartz \- X window system server for Mac OSX
-.SH SYNOPSIS
-.B Xquartz
-[ options ] ...
-.SH DESCRIPTION
-.I Xquartz
-is the X window server for Mac OS X provided by Apple.
-.I Xquartz
-runs in parallel with Aqua in rootless mode. In rootless mode, the X
-window system and Mac OS X share your display. The root window of the
-X11 display is the size of the screen and contains all the other
-windows. The X11 root window is not displayed in rootless mode as Mac
-OS X handles the desktop background.
-.SH CUSTOMIZATION
-\fIXquartz\fP can be customized using the defaults(1) command. The available options are:
-.TP 8
-.B defaults write __bundle_id_prefix__.X11 enable_fake_buttons -boolean true
-Emulates a 3 button mouse using modifier keys. By default, the Command modifier
-is used to emulate button 2 and Option is used for button 3. Thus, clicking the
-first mouse button while holding down Command will act like clicking
-button 2. Holding down Option will simulate button 3.
-.TP 8
-.B defaults write __bundle_id_prefix__.X11 fake_button2 \fImodifiers\fP
-Change the modifier keys used to emulate the second mouse button. By default,
-Command is used to emulate the second button. Any combination of the following
-modifier names may be used: {l,r,}shift, {l,r,}option, {l,r,}control, {l,r,}command, fn
-.TP 8
-.B defaults write __bundle_id_prefix__.X11 fake_button3 \fImodifiers\fP
-Change the modifier keys used to emulate the second mouse button. By default,
-Command is used to emulate the second button. Any combination of the following
-modifier names may be used: {l,r,}shift, {l,r,}option, {l,r,}control, {l,r,}command, fn
-.TP 8
-.B defaults write __bundle_id_prefix__.X11 fullscreen_hotkeys -boolean true
-Enable OSX hotkeys while in fullscreen
-.TP 8
-.B defaults write __bundle_id_prefix__.X11 fullscreen_menu -boolean true
-Show the OSX menu while in fullscreen
-.TP 8
-.B defaults write __bundle_id_prefix__.X11 no_quit_alert -boolean true
-Disables the alert dialog displayed when attempting to quit X11.
-.TP 8
-.B defaults write __bundle_id_prefix__.X11 no_auth -boolean true
-Stops the X server requiring that clients authenticate themselves when
-connecting. See Xsecurity(__miscmansuffix__).
-.TP 8
-.B defaults write __bundle_id_prefix__.X11 nolisten_tcp -boolean false
-This will tell the server to listen and accept TCP connections. Doing this without enabling
-xauth is a possible security concern. See Xsecurity(__miscmansuffix__).
-.TP 8
-.B defaults write __bundle_id_prefix__.X11 enable_system_beep -boolean false
-Don't use the standard system beep effect for X11 alerts.
-.TP 8
-.B defaults write __bundle_id_prefix__.X11 enable_key_equivalents -boolean false
-Disable menu keyboard equivalents while X11 windows are focused.
-.TP 8
-.B defaults write __bundle_id_prefix__.X11 depth \fIdepth\fP
-Specifies the color bit depth to use. Currently only 15, and 24 color
-bits per pixel are supported. If not specified, or a value of -1 is specified,
-defaults to the depth of the main display.
-.TP 8
-.B defaults write __bundle_id_prefix__.X11 sync_keymap -boolean true
-Keep the X11 keymap up to date with the OSX system keymap.
-.TP 8
-.B defaults write __bundle_id_prefix__.X11 option_sends_alt -boolean true
-The Option key will send Alt_L and Alt_R instead of Mode_switch.
-.TP 8
-.B defaults write __bundle_id_prefix__.X11 sync_pasteboard -boolean true
-Enable syncing between the OSX pasteboard and clipboard/primary selection buffers in X11. This option needs to be true for any of the other pasteboard sync options to have an effect.
-.TP 8
-.B defaults write __bundle_id_prefix__.X11 sync_pasteboard_to_clipboard -boolean true
-Update the X11 CLIPBOARD when the OSX NSPasteboard is updated.
-.TP 8
-.B defaults write __bundle_id_prefix__.X11 sync_pasteboard_to_primary -boolean true
-Update the the X11 PRIMARY buffer when the OSX NSPasteboard is updated.
-.TP 8
-.B defaults write __bundle_id_prefix__.X11 sync_clipboard_to_pasteboard -boolean true
-Update the the OSX NSPasteboard when the X11 CLIPBOARD is updated. Note that enabling this option causes the clipboard synchronization to act as a clipboard manager in X11. This makes it impossible to use xclipboard, klipper, or any other such clipboard managers. If you want to use any of these programs, you must disable this option.
-.TP 8
-.B defaults write __bundle_id_prefix__.X11 sync_primary_on_select -boolean true
-This option defaults to false and is provided only "for experts." It updates the NSPasteboard whenever a new X11 selection is made (rather than requiring you to hit cmd-c to copy the selection to the NSPasteboard). Since the X11 protocol does not require applications to send notification when they change selection, this might not work in all cases (if you run into this problem, try selecting text in another application first, then selecting the text you want).
-.TP 8
-.B defaults write __bundle_id_prefix__.X11 enable_test_extensions -boolean true
-This option defaults to false and is only accessible through the command line. Enable this option to turn on the DEC-XTRAP, RECORD, and XTEST extensions in the server.
-.TP 8
-.B defaults write __laucnd_id_prefix__.X11 scroll_in_device_direction -boolean true
-This option defaults to false. Enable this option to ensure that X11 scroll events are always in the direction of the device. This overrides the related option in the Mouse/Trackpad section of System Preferences.
-.SH OPTIONS
-.PP
-In addition to the normal server options described in the \fIXserver(1)\fP
-manual page, \fIXquartz\fP accepts the following command line switches:
-.TP 8
-.B \-fakebuttons
-Same as enable_fake_buttons above with value true.
-.TP 8
-.B \-nofakebuttons
-Same as enable_fake_buttons above with value false.
-.TP 8
-.B "\-fakemouse2 \fImodifiers\fP"
-Same as fake_button2 above.
-.TP 8
-.B "\-fakemouse3 \fImodifiers\fP"
-Same as fake_button3 above.
-.TP 8
-.B "\-depth \fIdepth\fP"
-Same as depth above.
-.SH LOGGING
-XQuartz stores a server log at ~/Library/Logs/X11.__bundle_id_prefix__.log which
-is analogous to /var/log/Xorg.#.log on systems that use the XFree86 DDX such as
-Linux, BSD, and Solaris.
-.PP
-In addition to this server log, XQuartz sends messages to syslogd(8) using
-asl(3). These logs are sent to the __bundle_id_prefix__ facility, and you can
-watch these logs using the following syslog(1) command:
-.TP 8
-.B $ syslog -w -k Facility eq __bundle_id_prefix__
-.PP
-or you can include extra information such as the file, line, and function where the message originated:
-.TP 8
-.B $ syslog -w -F '$(Time) $(Sender) <$(Level)> $(File):$(Line) $(Function) :: $(Message)' -k Facility eq __bundle_id_prefix__
-.PP
-By default, XQaurtz sets an ASL mask which prevents it from logging messages
-below the ASL_LEVEL_WARNING level (meaning almost all logging is done strictly
-to the file referenced above). To force XQuartz to send all log messages to
-syslogd(8), you can adjust this mask using the following syslog(1) command:
-.TP 8
-.B $ syslog -c X11.bin -d
-.PP
-The stdout and stderr messages printed by any process launched by XQuartz will
-be redirected to this syslog facility with a priority level of ASL_LEVEL_INFO
-and ASL_LEVEL_NOTICE respectively. In order to see these messages in syslog,
-you will need to adjust XQuartz's asl mask as above but using -i or -n
-instead of -d.
-.SH "SEE ALSO"
-.PP
-X(__miscmansuffix__), Xserver(1), xdm(1), xinit(1), syslog(1), syslogd(8)
-.PP
-http://xquartz.macosforge.org
-.PP
-.SH AUTHORS / HISTORY
-X11 was originally ported to Mac OS X Server by John Carmack. Dave
-Zarzycki used this as the basis of his port of XFree86 4.0 to Darwin 1.0.
-Torrey T. Lyons improved and integrated this code into the XFree86
-Project's mainline for the 4.0.2 release.
-.PP
-The following members of the XonX Team contributed to the following
-releases (in alphabetical order):
-.TP 4
-XFree86 4.1.0:
-.br
-Rob Braun - Darwin x86 support
-.br
-Torrey T. Lyons - Project Lead
-.br
-Andreas Monitzer - Cocoa version of XDarwin front end
-.br
-Gregory Robert Parker - Original Quartz implementation
-.br
-Christoph Pfisterer - Dynamic shared X libraries
-.br
-Toshimitsu Tanaka - Japanese localization
-.TP 4
-XFree86 4.2.0:
-.br
-Rob Braun - Darwin x86 support
-.br
-Pablo Di Noto - Spanish localization
-.br
-Paul Edens - Dutch localization
-.br
-Kyunghwan Kim - Korean localization
-.br
-Mario Klebsch - Non-US keyboard support
-.br
-Torrey T. Lyons - Project Lead
-.br
-Andreas Monitzer - German localization
-.br
-Patrik Montgomery - Swedish localization
-.br
-Greg Parker - Rootless support
-.br
-Toshimitsu Tanaka - Japanese localization
-.br
-Olivier Verdier - French localization
-.PP
-Code from Apple's X11.app (which was based on XFree86 4.1) was integrated into X.org's XDarwin DDX by Ben Byer for xorg-server-1.2.
-The XDarwin DDX was renamed Xquartz to more accurately reflect its state (the pure-darwin backend was removed).
-Jeremy Huddleston took over as project lead and brought the project up to the X.org 1.4 server branch.
-.PP
-Jeremy Huddleston <jeremyhu@apple.com> is the current maintainer.
+.TH XQUARTZ 1 __vendorversion__
+.SH NAME
+Xquartz \- X window system server for Mac OSX
+.SH SYNOPSIS
+.B Xquartz
+[ options ] ...
+.SH DESCRIPTION
+.I Xquartz
+is the X window server for Mac OS X provided by Apple.
+.I Xquartz
+runs in parallel with Aqua in rootless mode. In rootless mode, the X
+window system and Mac OS X share your display. The root window of the
+X11 display is the size of the screen and contains all the other
+windows. The X11 root window is not displayed in rootless mode as Mac
+OS X handles the desktop background.
+.SH CUSTOMIZATION
+\fIXquartz\fP can be customized using the defaults(1) command. The available options are:
+.TP 8
+.B defaults write __bundle_id_prefix__.X11 enable_fake_buttons -boolean true
+Emulates a 3 button mouse using modifier keys. By default, the Command modifier
+is used to emulate button 2 and Option is used for button 3. Thus, clicking the
+first mouse button while holding down Command will act like clicking
+button 2. Holding down Option will simulate button 3.
+.TP 8
+.B defaults write __bundle_id_prefix__.X11 fake_button2 \fImodifiers\fP
+Change the modifier keys used to emulate the second mouse button. By default,
+Command is used to emulate the second button. Any combination of the following
+modifier names may be used: {l,r,}shift, {l,r,}option, {l,r,}control, {l,r,}command, fn
+.TP 8
+.B defaults write __bundle_id_prefix__.X11 fake_button3 \fImodifiers\fP
+Change the modifier keys used to emulate the second mouse button. By default,
+Command is used to emulate the second button. Any combination of the following
+modifier names may be used: {l,r,}shift, {l,r,}option, {l,r,}control, {l,r,}command, fn
+.TP 8
+.B defaults write __bundle_id_prefix__.X11 fullscreen_hotkeys -boolean true
+Enable OSX hotkeys while in fullscreen
+.TP 8
+.B defaults write __bundle_id_prefix__.X11 fullscreen_menu -boolean true
+Show the OSX menu while in fullscreen
+.TP 8
+.B defaults write __bundle_id_prefix__.X11 no_quit_alert -boolean true
+Disables the alert dialog displayed when attempting to quit X11.
+.TP 8
+.B defaults write __bundle_id_prefix__.X11 no_auth -boolean true
+Stops the X server requiring that clients authenticate themselves when
+connecting. See Xsecurity(__miscmansuffix__).
+.TP 8
+.B defaults write __bundle_id_prefix__.X11 nolisten_tcp -boolean false
+This will tell the server to listen and accept TCP connections. Doing this without enabling
+xauth is a possible security concern. See Xsecurity(__miscmansuffix__).
+.TP 8
+.B defaults write __bundle_id_prefix__.X11 enable_system_beep -boolean false
+Don't use the standard system beep effect for X11 alerts.
+.TP 8
+.B defaults write __bundle_id_prefix__.X11 enable_key_equivalents -boolean false
+Disable menu keyboard equivalents while X11 windows are focused.
+.TP 8
+.B defaults write __bundle_id_prefix__.X11 depth \fIdepth\fP
+Specifies the color bit depth to use. Currently only 15, and 24 color
+bits per pixel are supported. If not specified, or a value of -1 is specified,
+defaults to the depth of the main display.
+.TP 8
+.B defaults write __bundle_id_prefix__.X11 sync_keymap -boolean true
+Keep the X11 keymap up to date with the OSX system keymap.
+.TP 8
+.B defaults write __bundle_id_prefix__.X11 option_sends_alt -boolean true
+The Option key will send Alt_L and Alt_R instead of Mode_switch.
+.TP 8
+.B defaults write __bundle_id_prefix__.X11 sync_pasteboard -boolean true
+Enable syncing between the OSX pasteboard and clipboard/primary selection buffers in X11. This option needs to be true for any of the other pasteboard sync options to have an effect.
+.TP 8
+.B defaults write __bundle_id_prefix__.X11 sync_pasteboard_to_clipboard -boolean true
+Update the X11 CLIPBOARD when the OSX NSPasteboard is updated.
+.TP 8
+.B defaults write __bundle_id_prefix__.X11 sync_pasteboard_to_primary -boolean true
+Update the the X11 PRIMARY buffer when the OSX NSPasteboard is updated.
+.TP 8
+.B defaults write __bundle_id_prefix__.X11 sync_clipboard_to_pasteboard -boolean true
+Update the the OSX NSPasteboard when the X11 CLIPBOARD is updated. Note that enabling this option causes the clipboard synchronization to act as a clipboard manager in X11. This makes it impossible to use xclipboard, klipper, or any other such clipboard managers. If you want to use any of these programs, you must disable this option.
+.TP 8
+.B defaults write __bundle_id_prefix__.X11 sync_primary_on_select -boolean true
+This option defaults to false and is provided only "for experts." It updates the NSPasteboard whenever a new X11 selection is made (rather than requiring you to hit cmd-c to copy the selection to the NSPasteboard). Since the X11 protocol does not require applications to send notification when they change selection, this might not work in all cases (if you run into this problem, try selecting text in another application first, then selecting the text you want).
+.TP 8
+.B defaults write __bundle_id_prefix__.X11 enable_test_extensions -boolean true
+This option defaults to false and is only accessible through the command line. Enable this option to turn on the DEC-XTRAP, RECORD, and XTEST extensions in the server.
+.TP 8
+.B defaults write __laucnd_id_prefix__.X11 scroll_in_device_direction -boolean true
+This option defaults to false. Enable this option to ensure that X11 scroll events are always in the direction of the device. This overrides the related option in the Mouse/Trackpad section of System Preferences.
+.SH OPTIONS
+.PP
+In addition to the normal server options described in the \fIXserver(1)\fP
+manual page, \fIXquartz\fP accepts the following command line switches:
+.TP 8
+.B \-fakebuttons
+Same as enable_fake_buttons above with value true.
+.TP 8
+.B \-nofakebuttons
+Same as enable_fake_buttons above with value false.
+.TP 8
+.B "\-fakemouse2 \fImodifiers\fP"
+Same as fake_button2 above.
+.TP 8
+.B "\-fakemouse3 \fImodifiers\fP"
+Same as fake_button3 above.
+.TP 8
+.B "\-depth \fIdepth\fP"
+Same as depth above.
+.SH LOGGING
+XQuartz stores a server log at ~/Library/Logs/X11.__bundle_id_prefix__.log which
+is analogous to /var/log/Xorg.#.log on systems that use the XFree86 DDX such as
+Linux, BSD, and Solaris.
+.PP
+In addition to this server log, XQuartz sends messages to syslogd(8) using
+asl(3). These logs are sent to the __bundle_id_prefix__ facility, and you can
+watch these logs using the following syslog(1) command:
+.TP 8
+.B $ syslog -w -k Facility eq __bundle_id_prefix__
+.PP
+or you can include extra information such as the file, line, and function where the message originated:
+.TP 8
+.B $ syslog -w -F '$(Time) $(Sender) <$(Level)> $(File):$(Line) $(Function) :: $(Message)' -k Facility eq __bundle_id_prefix__
+.PP
+By default, XQaurtz sets an ASL mask which prevents it from logging messages
+below the ASL_LEVEL_WARNING level (meaning almost all logging is done strictly
+to the file referenced above). To force XQuartz to send all log messages to
+syslogd(8), you can adjust this mask using the following syslog(1) command:
+.TP 8
+.B $ syslog -c X11.bin -d
+.PP
+The stdout and stderr messages printed by any process launched by XQuartz will
+be redirected to this syslog facility with a priority level of ASL_LEVEL_INFO
+and ASL_LEVEL_NOTICE respectively. In order to see these messages in syslog,
+you will need to adjust XQuartz's asl mask as above but using -i or -n
+instead of -d.
+.SH "SEE ALSO"
+.PP
+X(__miscmansuffix__), Xserver(1), xdm(1), xinit(1), syslog(1), syslogd(8)
+.PP
+http://xquartz.macosforge.org
+.PP
+.SH AUTHORS / HISTORY
+X11 was originally ported to Mac OS X Server by John Carmack. Dave
+Zarzycki used this as the basis of his port of XFree86 4.0 to Darwin 1.0.
+Torrey T. Lyons improved and integrated this code into the XFree86
+Project's mainline for the 4.0.2 release.
+.PP
+The following members of the XonX Team contributed to the following
+releases (in alphabetical order):
+.TP 4
+XFree86 4.1.0:
+.br
+Rob Braun - Darwin x86 support
+.br
+Torrey T. Lyons - Project Lead
+.br
+Andreas Monitzer - Cocoa version of XDarwin front end
+.br
+Gregory Robert Parker - Original Quartz implementation
+.br
+Christoph Pfisterer - Dynamic shared X libraries
+.br
+Toshimitsu Tanaka - Japanese localization
+.TP 4
+XFree86 4.2.0:
+.br
+Rob Braun - Darwin x86 support
+.br
+Pablo Di Noto - Spanish localization
+.br
+Paul Edens - Dutch localization
+.br
+Kyunghwan Kim - Korean localization
+.br
+Mario Klebsch - Non-US keyboard support
+.br
+Torrey T. Lyons - Project Lead
+.br
+Andreas Monitzer - German localization
+.br
+Patrik Montgomery - Swedish localization
+.br
+Greg Parker - Rootless support
+.br
+Toshimitsu Tanaka - Japanese localization
+.br
+Olivier Verdier - French localization
+.PP
+Code from Apple's X11.app (which was based on XFree86 4.1) was integrated into X.org's XDarwin DDX by Ben Byer for xorg-server-1.2.
+The XDarwin DDX was renamed Xquartz to more accurately reflect its state (the pure-darwin backend was removed).
+Jeremy Huddleston took over as project lead and brought the project up to the X.org 1.4 server branch.
+.PP
+Jeremy Huddleston <jeremyhu@apple.com> is the current maintainer.
diff --git a/xorg-server/hw/xquartz/pbproxy/Makefile.am b/xorg-server/hw/xquartz/pbproxy/Makefile.am
index e3782ac61..b8b95d232 100644
--- a/xorg-server/hw/xquartz/pbproxy/Makefile.am
+++ b/xorg-server/hw/xquartz/pbproxy/Makefile.am
@@ -1,28 +1,28 @@
-AM_CPPFLAGS=-F/System/Library/Frameworks/ApplicationServices.framework/Frameworks \
- -DBUNDLE_ID_PREFIX=\"$(BUNDLE_ID_PREFIX)\"
-
-AM_CFLAGS=$(XPBPROXY_CFLAGS)
-
-noinst_LTLIBRARIES = libxpbproxy.la
-libxpbproxy_la_SOURCES = \
- trick_autotools.c \
- main.m \
- x-input.m \
- x-selection.m
-
-libxpbproxy_la_LDFLAGS=$(XPBPROXY_LIBS)
-
-if STANDALONE_XPBPROXY
-
-bin_PROGRAMS = xpbproxy
-xpbproxy_SOURCES = app-main.m
-xpbproxy_LDADD = libxpbproxy.la
-xpbproxy_LDFLAGS = -Wl,-framework,Cocoa
-
-AM_CPPFLAGS += -DSTANDALONE_XPBPROXY
-
-endif
-
-EXTRA_DIST = \
- pbproxy.h \
- x-selection.h
+AM_CPPFLAGS=-F/System/Library/Frameworks/ApplicationServices.framework/Frameworks \
+ -DBUNDLE_ID_PREFIX=\"$(BUNDLE_ID_PREFIX)\"
+
+AM_CFLAGS=$(XPBPROXY_CFLAGS)
+
+noinst_LTLIBRARIES = libxpbproxy.la
+libxpbproxy_la_SOURCES = \
+ trick_autotools.c \
+ main.m \
+ x-input.m \
+ x-selection.m
+
+libxpbproxy_la_LDFLAGS=$(XPBPROXY_LIBS)
+
+if STANDALONE_XPBPROXY
+
+bin_PROGRAMS = xpbproxy
+xpbproxy_SOURCES = app-main.m
+xpbproxy_LDADD = libxpbproxy.la
+xpbproxy_LDFLAGS = -Wl,-framework,Cocoa
+
+AM_CPPFLAGS += -DSTANDALONE_XPBPROXY
+
+endif
+
+EXTRA_DIST = \
+ pbproxy.h \
+ x-selection.h
diff --git a/xorg-server/hw/xquartz/pbproxy/app-main.m b/xorg-server/hw/xquartz/pbproxy/app-main.m
index 5758a33a7..772c458a1 100644
--- a/xorg-server/hw/xquartz/pbproxy/app-main.m
+++ b/xorg-server/hw/xquartz/pbproxy/app-main.m
@@ -1,114 +1,114 @@
-/* app-main.m
- Copyright (c) 2002, 2008 Apple Computer, 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 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.
- */
-
-#include "pbproxy.h"
-#import "x-selection.h"
-
-#include <pthread.h>
-#include <unistd.h> /*for getpid*/
-#include <Cocoa/Cocoa.h>
-
-static const char *app_prefs_domain = BUNDLE_ID_PREFIX".xpbproxy";
-CFStringRef app_prefs_domain_cfstr;
-
-/* Stubs */
-char *display = NULL;
-BOOL serverRunning = YES;
-pthread_mutex_t serverRunningMutex = PTHREAD_MUTEX_INITIALIZER;
-pthread_cond_t serverRunningCond = PTHREAD_COND_INITIALIZER;
-
-static void signal_handler (int sig) {
- switch(sig) {
- case SIGHUP:
- xpbproxy_prefs_reload = YES;
- break;
- default:
- _exit(EXIT_SUCCESS);
- }
-}
-
-void
-ErrorF(const char * f, ...)
-{
- va_list args;
-
- va_start(args, f);
- vfprintf(stderr, f, args);
- va_end(args);
-}
-
-/* TODO: Have this actually log to ASL */
-void xq_asl_log (int level, const char *subsystem, const char *file, const char *function, int line, const char *fmt, ...) {
-#ifdef DEBUG
- va_list args;
-
- va_start(args, fmt);
- vfprintf(stderr, fmt, args);
- va_end(args);
-#endif
-}
-
-int main (int argc, const char *argv[]) {
- const char *s;
- int i;
-
-#ifdef DEBUG
- ErrorF("pid: %u\n", getpid());
-#endif
-
- xpbproxy_is_standalone = YES;
-
- if((s = getenv("X11_PREFS_DOMAIN")))
- app_prefs_domain = s;
-
- for (i = 1; i < argc; i++) {
- if(strcmp (argv[i], "--prefs-domain") == 0 && i+1 < argc) {
- app_prefs_domain = argv[++i];
- } else if (strcmp (argv[i], "--help") == 0) {
- ErrorF("usage: xpbproxy OPTIONS\n"
- "Pasteboard proxying for X11.\n\n"
- "--prefs-domain <domain> Change the domain used for reading preferences\n"
- " (default: %s)\n", app_prefs_domain);
- return 0;
- } else {
- ErrorF("usage: xpbproxy OPTIONS...\n"
- "Try 'xpbproxy --help' for more information.\n");
- return 1;
- }
- }
-
- app_prefs_domain_cfstr = CFStringCreateWithCString(NULL, app_prefs_domain, kCFStringEncodingUTF8);
-
- signal (SIGINT, signal_handler);
- signal (SIGTERM, signal_handler);
- signal (SIGHUP, signal_handler);
- signal (SIGPIPE, SIG_IGN);
-
- return xpbproxy_run();
-}
+/* app-main.m
+ Copyright (c) 2002, 2008 Apple Computer, 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 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.
+ */
+
+#include "pbproxy.h"
+#import "x-selection.h"
+
+#include <pthread.h>
+#include <unistd.h> /*for getpid*/
+#include <Cocoa/Cocoa.h>
+
+static const char *app_prefs_domain = BUNDLE_ID_PREFIX".xpbproxy";
+CFStringRef app_prefs_domain_cfstr;
+
+/* Stubs */
+char *display = NULL;
+BOOL serverRunning = YES;
+pthread_mutex_t serverRunningMutex = PTHREAD_MUTEX_INITIALIZER;
+pthread_cond_t serverRunningCond = PTHREAD_COND_INITIALIZER;
+
+static void signal_handler (int sig) {
+ switch(sig) {
+ case SIGHUP:
+ xpbproxy_prefs_reload = YES;
+ break;
+ default:
+ _exit(EXIT_SUCCESS);
+ }
+}
+
+void
+ErrorF(const char * f, ...)
+{
+ va_list args;
+
+ va_start(args, f);
+ vfprintf(stderr, f, args);
+ va_end(args);
+}
+
+/* TODO: Have this actually log to ASL */
+void xq_asl_log (int level, const char *subsystem, const char *file, const char *function, int line, const char *fmt, ...) {
+#ifdef DEBUG
+ va_list args;
+
+ va_start(args, fmt);
+ vfprintf(stderr, fmt, args);
+ va_end(args);
+#endif
+}
+
+int main (int argc, const char *argv[]) {
+ const char *s;
+ int i;
+
+#ifdef DEBUG
+ ErrorF("pid: %u\n", getpid());
+#endif
+
+ xpbproxy_is_standalone = YES;
+
+ if((s = getenv("X11_PREFS_DOMAIN")))
+ app_prefs_domain = s;
+
+ for (i = 1; i < argc; i++) {
+ if(strcmp (argv[i], "--prefs-domain") == 0 && i+1 < argc) {
+ app_prefs_domain = argv[++i];
+ } else if (strcmp (argv[i], "--help") == 0) {
+ ErrorF("usage: xpbproxy OPTIONS\n"
+ "Pasteboard proxying for X11.\n\n"
+ "--prefs-domain <domain> Change the domain used for reading preferences\n"
+ " (default: %s)\n", app_prefs_domain);
+ return 0;
+ } else {
+ ErrorF("usage: xpbproxy OPTIONS...\n"
+ "Try 'xpbproxy --help' for more information.\n");
+ return 1;
+ }
+ }
+
+ app_prefs_domain_cfstr = CFStringCreateWithCString(NULL, app_prefs_domain, kCFStringEncodingUTF8);
+
+ signal (SIGINT, signal_handler);
+ signal (SIGTERM, signal_handler);
+ signal (SIGHUP, signal_handler);
+ signal (SIGPIPE, SIG_IGN);
+
+ return xpbproxy_run();
+}
diff --git a/xorg-server/hw/xquartz/pbproxy/main.m b/xorg-server/hw/xquartz/pbproxy/main.m
index f8450587e..29ce83b35 100644
--- a/xorg-server/hw/xquartz/pbproxy/main.m
+++ b/xorg-server/hw/xquartz/pbproxy/main.m
@@ -1,149 +1,149 @@
-/* main.m
- Copyright (c) 2002, 2008 Apple Computer, 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 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.
- */
-
-#include "pbproxy.h"
-#import "x-selection.h"
-
-#include <pthread.h>
-#include <unistd.h>
-#include <X11/extensions/applewm.h>
-
-Display *xpbproxy_dpy;
-int xpbproxy_apple_wm_event_base, xpbproxy_apple_wm_error_base;
-int xpbproxy_xfixes_event_base, xpbproxy_xfixes_error_base;
-BOOL xpbproxy_have_xfixes;
-
-extern char *display;
-
-#ifdef STANDALONE_XPBPROXY
-BOOL xpbproxy_is_standalone = NO;
-#endif
-
-x_selection *_selection_object;
-
-extern BOOL serverRunning;
-extern pthread_mutex_t serverRunningMutex;
-extern pthread_cond_t serverRunningCond;
-
-static inline void wait_for_server_init(void) {
- /* If the server hasn't finished initializing, wait for it... */
- if(!serverRunning) {
- pthread_mutex_lock(&serverRunningMutex);
- while(!serverRunning)
- pthread_cond_wait(&serverRunningCond, &serverRunningMutex);
- pthread_mutex_unlock(&serverRunningMutex);
- }
-}
-
-static int x_io_error_handler (Display *dpy) {
- /* We lost our connection to the server. */
-
- TRACE ();
-
- /* trigger the thread to restart?
- * NO - this would be to a "deeper" problem, and restarts would just
- * make things worse...
- */
-#ifdef STANDALONE_XPBPROXY
- if(xpbproxy_is_standalone)
- exit(EXIT_FAILURE);
-#endif
-
- /* Prevent _XIOError from calling exit() */
- pthread_exit(NULL);
- return 0;
-}
-
-static int x_error_handler (Display *dpy, XErrorEvent *errevent) {
- return 0;
-}
-
-int xpbproxy_run (void) {
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- size_t i;
-
- wait_for_server_init();
-
- for(i=0, xpbproxy_dpy=NULL; !xpbproxy_dpy && i<5; i++) {
- xpbproxy_dpy = XOpenDisplay(NULL);
-
- if(!xpbproxy_dpy && display) {
- char _display[32];
- snprintf(_display, sizeof(_display), ":%s", display);
- setenv("DISPLAY", _display, TRUE);
-
- xpbproxy_dpy=XOpenDisplay(_display);
- }
- if(!xpbproxy_dpy)
- sleep(1);
- }
-
- if (xpbproxy_dpy == NULL) {
- ErrorF("xpbproxy: can't open default display\n");
- [pool release];
- return EXIT_FAILURE;
- }
-
- XSetIOErrorHandler (x_io_error_handler);
- XSetErrorHandler (x_error_handler);
-
- if (!XAppleWMQueryExtension (xpbproxy_dpy, &xpbproxy_apple_wm_event_base,
- &xpbproxy_apple_wm_error_base)) {
- ErrorF("xpbproxy: can't open AppleWM server extension\n");
- [pool release];
- return EXIT_FAILURE;
- }
-
- xpbproxy_have_xfixes = XFixesQueryExtension(xpbproxy_dpy, &xpbproxy_xfixes_event_base, &xpbproxy_xfixes_error_base);
-
- XAppleWMSelectInput (xpbproxy_dpy, AppleWMActivationNotifyMask |
- AppleWMPasteboardNotifyMask);
-
- _selection_object = [[x_selection alloc] init];
-
- if(!xpbproxy_input_register()) {
- [pool release];
- return EXIT_FAILURE;
- }
-
- [pool release];
-
- CFRunLoopRun();
-
- return EXIT_SUCCESS;
-}
-
-id xpbproxy_selection_object (void) {
- return _selection_object;
-}
-
-Time xpbproxy_current_timestamp (void) {
- /* FIXME: may want to fetch a timestamp from the server.. */
- return CurrentTime;
-}
+/* main.m
+ Copyright (c) 2002, 2008 Apple Computer, 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 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.
+ */
+
+#include "pbproxy.h"
+#import "x-selection.h"
+
+#include <pthread.h>
+#include <unistd.h>
+#include <X11/extensions/applewm.h>
+
+Display *xpbproxy_dpy;
+int xpbproxy_apple_wm_event_base, xpbproxy_apple_wm_error_base;
+int xpbproxy_xfixes_event_base, xpbproxy_xfixes_error_base;
+BOOL xpbproxy_have_xfixes;
+
+extern char *display;
+
+#ifdef STANDALONE_XPBPROXY
+BOOL xpbproxy_is_standalone = NO;
+#endif
+
+x_selection *_selection_object;
+
+extern BOOL serverRunning;
+extern pthread_mutex_t serverRunningMutex;
+extern pthread_cond_t serverRunningCond;
+
+static inline void wait_for_server_init(void) {
+ /* If the server hasn't finished initializing, wait for it... */
+ if(!serverRunning) {
+ pthread_mutex_lock(&serverRunningMutex);
+ while(!serverRunning)
+ pthread_cond_wait(&serverRunningCond, &serverRunningMutex);
+ pthread_mutex_unlock(&serverRunningMutex);
+ }
+}
+
+static int x_io_error_handler (Display *dpy) {
+ /* We lost our connection to the server. */
+
+ TRACE ();
+
+ /* trigger the thread to restart?
+ * NO - this would be to a "deeper" problem, and restarts would just
+ * make things worse...
+ */
+#ifdef STANDALONE_XPBPROXY
+ if(xpbproxy_is_standalone)
+ exit(EXIT_FAILURE);
+#endif
+
+ /* Prevent _XIOError from calling exit() */
+ pthread_exit(NULL);
+ return 0;
+}
+
+static int x_error_handler (Display *dpy, XErrorEvent *errevent) {
+ return 0;
+}
+
+int xpbproxy_run (void) {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ size_t i;
+
+ wait_for_server_init();
+
+ for(i=0, xpbproxy_dpy=NULL; !xpbproxy_dpy && i<5; i++) {
+ xpbproxy_dpy = XOpenDisplay(NULL);
+
+ if(!xpbproxy_dpy && display) {
+ char _display[32];
+ snprintf(_display, sizeof(_display), ":%s", display);
+ setenv("DISPLAY", _display, TRUE);
+
+ xpbproxy_dpy=XOpenDisplay(_display);
+ }
+ if(!xpbproxy_dpy)
+ sleep(1);
+ }
+
+ if (xpbproxy_dpy == NULL) {
+ ErrorF("xpbproxy: can't open default display\n");
+ [pool release];
+ return EXIT_FAILURE;
+ }
+
+ XSetIOErrorHandler (x_io_error_handler);
+ XSetErrorHandler (x_error_handler);
+
+ if (!XAppleWMQueryExtension (xpbproxy_dpy, &xpbproxy_apple_wm_event_base,
+ &xpbproxy_apple_wm_error_base)) {
+ ErrorF("xpbproxy: can't open AppleWM server extension\n");
+ [pool release];
+ return EXIT_FAILURE;
+ }
+
+ xpbproxy_have_xfixes = XFixesQueryExtension(xpbproxy_dpy, &xpbproxy_xfixes_event_base, &xpbproxy_xfixes_error_base);
+
+ XAppleWMSelectInput (xpbproxy_dpy, AppleWMActivationNotifyMask |
+ AppleWMPasteboardNotifyMask);
+
+ _selection_object = [[x_selection alloc] init];
+
+ if(!xpbproxy_input_register()) {
+ [pool release];
+ return EXIT_FAILURE;
+ }
+
+ [pool release];
+
+ CFRunLoopRun();
+
+ return EXIT_SUCCESS;
+}
+
+id xpbproxy_selection_object (void) {
+ return _selection_object;
+}
+
+Time xpbproxy_current_timestamp (void) {
+ /* FIXME: may want to fetch a timestamp from the server.. */
+ return CurrentTime;
+}
diff --git a/xorg-server/hw/xquartz/pbproxy/pbproxy.h b/xorg-server/hw/xquartz/pbproxy/pbproxy.h
index 9d729531f..c80a660cc 100644
--- a/xorg-server/hw/xquartz/pbproxy/pbproxy.h
+++ b/xorg-server/hw/xquartz/pbproxy/pbproxy.h
@@ -1,93 +1,93 @@
-/* pbproxy.h
- Copyright (c) 2002, 2008 Apple Computer, 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 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.
-*/
-
-#ifndef PBPROXY_H
-#define PBPROXY_H 1
-
-#import <Foundation/Foundation.h>
-
-#include <asl.h>
-
-#include <AvailabilityMacros.h>
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1050
-#if __LP64__ || NS_BUILD_32_LIKE_64
-typedef long NSInteger;
-typedef unsigned long NSUInteger;
-#else
-typedef int NSInteger;
-typedef unsigned int NSUInteger;
-#endif
-#endif
-
-#define Cursor X_Cursor
-#undef _SHAPE_H_
-#include <X11/Xlib.h>
-#include <X11/extensions/shape.h>
-#undef Cursor
-
-#ifdef STANDALONE_XPBPROXY
-/* Just used for the standalone to respond to SIGHUP to reload prefs */
-extern BOOL xpbproxy_prefs_reload;
-
-/* Setting this to YES (for the standalone app) causes us to ignore the
- * 'sync_pasteboard' defaults preference since we assume it to be on... this is
- * mainly useful for debugging/developing xpbproxy with XQuartz still running.
- * Just disable the one in the server with X11's preference pane, then run
- * the standalone app.
- */
-extern BOOL xpbproxy_is_standalone;
-#endif
-
-/* from main.m */
-extern void xpbproxy_set_is_active (BOOL state);
-extern BOOL xpbproxy_get_is_active (void);
-extern id xpbproxy_selection_object (void);
-extern Time xpbproxy_current_timestamp (void);
-extern int xpbproxy_run (void);
-
-extern Display *xpbproxy_dpy;
-extern int xpbproxy_apple_wm_event_base, xpbproxy_apple_wm_error_base;
-extern int xpbproxy_xfixes_event_base, xpbproxy_xfixes_error_base;
-extern BOOL xpbproxy_have_xfixes;
-
-/* from x-input.m */
-extern BOOL xpbproxy_input_register (void);
-
-/* os/log.c or app-main.m */
-extern void ErrorF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2);
-
-/* from darwin.h */
-_X_ATTRIBUTE_PRINTF(6,7)
-extern void xq_asl_log (int level, const char *subsystem, const char *file, const char *function, int line, const char *fmt, ...);
-
-#define ASL_LOG(level, subsystem, msg, args...) xq_asl_log(level, subsystem, __FILE__, __FUNCTION__, __LINE__, msg, ##args)
-#define DebugF(msg, args...) ASL_LOG(ASL_LEVEL_DEBUG, "xpbproxy", msg, ##args)
-#define TRACE() DebugF("TRACE")
-
-#endif /* PBPROXY_H */
+/* pbproxy.h
+ Copyright (c) 2002, 2008 Apple Computer, 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 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.
+*/
+
+#ifndef PBPROXY_H
+#define PBPROXY_H 1
+
+#import <Foundation/Foundation.h>
+
+#include <asl.h>
+
+#include <AvailabilityMacros.h>
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1050
+#if __LP64__ || NS_BUILD_32_LIKE_64
+typedef long NSInteger;
+typedef unsigned long NSUInteger;
+#else
+typedef int NSInteger;
+typedef unsigned int NSUInteger;
+#endif
+#endif
+
+#define Cursor X_Cursor
+#undef _SHAPE_H_
+#include <X11/Xlib.h>
+#include <X11/extensions/shape.h>
+#undef Cursor
+
+#ifdef STANDALONE_XPBPROXY
+/* Just used for the standalone to respond to SIGHUP to reload prefs */
+extern BOOL xpbproxy_prefs_reload;
+
+/* Setting this to YES (for the standalone app) causes us to ignore the
+ * 'sync_pasteboard' defaults preference since we assume it to be on... this is
+ * mainly useful for debugging/developing xpbproxy with XQuartz still running.
+ * Just disable the one in the server with X11's preference pane, then run
+ * the standalone app.
+ */
+extern BOOL xpbproxy_is_standalone;
+#endif
+
+/* from main.m */
+extern void xpbproxy_set_is_active (BOOL state);
+extern BOOL xpbproxy_get_is_active (void);
+extern id xpbproxy_selection_object (void);
+extern Time xpbproxy_current_timestamp (void);
+extern int xpbproxy_run (void);
+
+extern Display *xpbproxy_dpy;
+extern int xpbproxy_apple_wm_event_base, xpbproxy_apple_wm_error_base;
+extern int xpbproxy_xfixes_event_base, xpbproxy_xfixes_error_base;
+extern BOOL xpbproxy_have_xfixes;
+
+/* from x-input.m */
+extern BOOL xpbproxy_input_register (void);
+
+/* os/log.c or app-main.m */
+extern void ErrorF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2);
+
+/* from darwin.h */
+_X_ATTRIBUTE_PRINTF(6,7)
+extern void xq_asl_log (int level, const char *subsystem, const char *file, const char *function, int line, const char *fmt, ...);
+
+#define ASL_LOG(level, subsystem, msg, args...) xq_asl_log(level, subsystem, __FILE__, __FUNCTION__, __LINE__, msg, ##args)
+#define DebugF(msg, args...) ASL_LOG(ASL_LEVEL_DEBUG, "xpbproxy", msg, ##args)
+#define TRACE() DebugF("TRACE")
+
+#endif /* PBPROXY_H */
diff --git a/xorg-server/hw/xquartz/pbproxy/x-input.m b/xorg-server/hw/xquartz/pbproxy/x-input.m
index 7ecc90896..ebb89980f 100644
--- a/xorg-server/hw/xquartz/pbproxy/x-input.m
+++ b/xorg-server/hw/xquartz/pbproxy/x-input.m
@@ -1,173 +1,173 @@
-/* x-input.m -- event handling
- Copyright (c) 2002, 2008 Apple Computer, 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 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.
- */
-
-#include "pbproxy.h"
-#import "x-selection.h"
-
-#include <CoreFoundation/CFSocket.h>
-#include <CoreFoundation/CFRunLoop.h>
-
-#include <X11/Xatom.h>
-#include <X11/keysym.h>
-#include <X11/extensions/applewm.h>
-
-#include <unistd.h>
-
-static CFRunLoopSourceRef xpbproxy_dpy_source;
-
-#ifdef STANDALONE_XPBPROXY
-BOOL xpbproxy_prefs_reload = NO;
-#endif
-
-/* Timestamp when the X server last told us it's active */
-static Time last_activation_time;
-
-static void x_event_apple_wm_notify(XAppleWMNotifyEvent *e) {
- int type = e->type - xpbproxy_apple_wm_event_base;
- int kind = e->kind;
-
- /* We want to reload prefs even if we're not active */
- if(type == AppleWMActivationNotify &&
- kind == AppleWMReloadPreferences)
- [xpbproxy_selection_object() reload_preferences];
-
- if(![xpbproxy_selection_object() is_active])
- return;
-
- switch (type) {
- case AppleWMActivationNotify:
- switch (kind) {
- case AppleWMIsActive:
- last_activation_time = e->time;
- [xpbproxy_selection_object() x_active:e->time];
- break;
-
- case AppleWMIsInactive:
- [xpbproxy_selection_object() x_inactive:e->time];
- break;
- }
- break;
-
- case AppleWMPasteboardNotify:
- switch (kind) {
- case AppleWMCopyToPasteboard:
- [xpbproxy_selection_object() x_copy:e->time];
- }
- break;
- }
-}
-
-static void xpbproxy_process_xevents(void) {
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
- if(pool == nil) {
- ErrorF("unable to allocate/init auto release pool!\n");
- return;
- }
-
- while (XPending(xpbproxy_dpy) != 0) {
- XEvent e;
-
- XNextEvent (xpbproxy_dpy, &e);
-
- switch (e.type) {
- case SelectionClear:
- if([xpbproxy_selection_object() is_active])
- [xpbproxy_selection_object () clear_event:&e.xselectionclear];
- break;
-
- case SelectionRequest:
- [xpbproxy_selection_object () request_event:&e.xselectionrequest];
- break;
-
- case SelectionNotify:
- [xpbproxy_selection_object () notify_event:&e.xselection];
- break;
-
- case PropertyNotify:
- [xpbproxy_selection_object () property_event:&e.xproperty];
- break;
-
- default:
- if(e.type >= xpbproxy_apple_wm_event_base &&
- e.type < xpbproxy_apple_wm_event_base + AppleWMNumberEvents) {
- x_event_apple_wm_notify((XAppleWMNotifyEvent *) &e);
- } else if(e.type == xpbproxy_xfixes_event_base + XFixesSelectionNotify) {
- [xpbproxy_selection_object() xfixes_selection_notify:(XFixesSelectionNotifyEvent *)&e];
- }
- break;
- }
-
- XFlush(xpbproxy_dpy);
- }
-
- [pool release];
-}
-
-static BOOL add_input_socket (int sock, CFOptionFlags callback_types,
- CFSocketCallBack callback, const CFSocketContext *ctx,
- CFRunLoopSourceRef *cf_source) {
- CFSocketRef cf_sock;
-
- cf_sock = CFSocketCreateWithNative (kCFAllocatorDefault, sock,
- callback_types, callback, ctx);
- if (cf_sock == NULL) {
- close (sock);
- return FALSE;
- }
-
- *cf_source = CFSocketCreateRunLoopSource (kCFAllocatorDefault,
- cf_sock, 0);
- CFRelease (cf_sock);
-
- if (*cf_source == NULL)
- return FALSE;
-
- CFRunLoopAddSource (CFRunLoopGetCurrent (),
- *cf_source, kCFRunLoopDefaultMode);
- return TRUE;
-}
-
-static void x_input_callback (CFSocketRef sock, CFSocketCallBackType type,
- CFDataRef address, const void *data, void *info) {
-
-#ifdef STANDALONE_XPBPROXY
- if(xpbproxy_prefs_reload) {
- [xpbproxy_selection_object() reload_preferences];
- xpbproxy_prefs_reload = NO;
- }
-#endif
-
- xpbproxy_process_xevents();
-}
-
-BOOL xpbproxy_input_register(void) {
- return add_input_socket(ConnectionNumber(xpbproxy_dpy), kCFSocketReadCallBack,
- x_input_callback, NULL, &xpbproxy_dpy_source);
-}
+/* x-input.m -- event handling
+ Copyright (c) 2002, 2008 Apple Computer, 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 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.
+ */
+
+#include "pbproxy.h"
+#import "x-selection.h"
+
+#include <CoreFoundation/CFSocket.h>
+#include <CoreFoundation/CFRunLoop.h>
+
+#include <X11/Xatom.h>
+#include <X11/keysym.h>
+#include <X11/extensions/applewm.h>
+
+#include <unistd.h>
+
+static CFRunLoopSourceRef xpbproxy_dpy_source;
+
+#ifdef STANDALONE_XPBPROXY
+BOOL xpbproxy_prefs_reload = NO;
+#endif
+
+/* Timestamp when the X server last told us it's active */
+static Time last_activation_time;
+
+static void x_event_apple_wm_notify(XAppleWMNotifyEvent *e) {
+ int type = e->type - xpbproxy_apple_wm_event_base;
+ int kind = e->kind;
+
+ /* We want to reload prefs even if we're not active */
+ if(type == AppleWMActivationNotify &&
+ kind == AppleWMReloadPreferences)
+ [xpbproxy_selection_object() reload_preferences];
+
+ if(![xpbproxy_selection_object() is_active])
+ return;
+
+ switch (type) {
+ case AppleWMActivationNotify:
+ switch (kind) {
+ case AppleWMIsActive:
+ last_activation_time = e->time;
+ [xpbproxy_selection_object() x_active:e->time];
+ break;
+
+ case AppleWMIsInactive:
+ [xpbproxy_selection_object() x_inactive:e->time];
+ break;
+ }
+ break;
+
+ case AppleWMPasteboardNotify:
+ switch (kind) {
+ case AppleWMCopyToPasteboard:
+ [xpbproxy_selection_object() x_copy:e->time];
+ }
+ break;
+ }
+}
+
+static void xpbproxy_process_xevents(void) {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+ if(pool == nil) {
+ ErrorF("unable to allocate/init auto release pool!\n");
+ return;
+ }
+
+ while (XPending(xpbproxy_dpy) != 0) {
+ XEvent e;
+
+ XNextEvent (xpbproxy_dpy, &e);
+
+ switch (e.type) {
+ case SelectionClear:
+ if([xpbproxy_selection_object() is_active])
+ [xpbproxy_selection_object () clear_event:&e.xselectionclear];
+ break;
+
+ case SelectionRequest:
+ [xpbproxy_selection_object () request_event:&e.xselectionrequest];
+ break;
+
+ case SelectionNotify:
+ [xpbproxy_selection_object () notify_event:&e.xselection];
+ break;
+
+ case PropertyNotify:
+ [xpbproxy_selection_object () property_event:&e.xproperty];
+ break;
+
+ default:
+ if(e.type >= xpbproxy_apple_wm_event_base &&
+ e.type < xpbproxy_apple_wm_event_base + AppleWMNumberEvents) {
+ x_event_apple_wm_notify((XAppleWMNotifyEvent *) &e);
+ } else if(e.type == xpbproxy_xfixes_event_base + XFixesSelectionNotify) {
+ [xpbproxy_selection_object() xfixes_selection_notify:(XFixesSelectionNotifyEvent *)&e];
+ }
+ break;
+ }
+
+ XFlush(xpbproxy_dpy);
+ }
+
+ [pool release];
+}
+
+static BOOL add_input_socket (int sock, CFOptionFlags callback_types,
+ CFSocketCallBack callback, const CFSocketContext *ctx,
+ CFRunLoopSourceRef *cf_source) {
+ CFSocketRef cf_sock;
+
+ cf_sock = CFSocketCreateWithNative (kCFAllocatorDefault, sock,
+ callback_types, callback, ctx);
+ if (cf_sock == NULL) {
+ close (sock);
+ return FALSE;
+ }
+
+ *cf_source = CFSocketCreateRunLoopSource (kCFAllocatorDefault,
+ cf_sock, 0);
+ CFRelease (cf_sock);
+
+ if (*cf_source == NULL)
+ return FALSE;
+
+ CFRunLoopAddSource (CFRunLoopGetCurrent (),
+ *cf_source, kCFRunLoopDefaultMode);
+ return TRUE;
+}
+
+static void x_input_callback (CFSocketRef sock, CFSocketCallBackType type,
+ CFDataRef address, const void *data, void *info) {
+
+#ifdef STANDALONE_XPBPROXY
+ if(xpbproxy_prefs_reload) {
+ [xpbproxy_selection_object() reload_preferences];
+ xpbproxy_prefs_reload = NO;
+ }
+#endif
+
+ xpbproxy_process_xevents();
+}
+
+BOOL xpbproxy_input_register(void) {
+ return add_input_socket(ConnectionNumber(xpbproxy_dpy), kCFSocketReadCallBack,
+ x_input_callback, NULL, &xpbproxy_dpy_source);
+}
diff --git a/xorg-server/hw/xquartz/pbproxy/x-selection.h b/xorg-server/hw/xquartz/pbproxy/x-selection.h
index b31d7515e..d4a39e58f 100644
--- a/xorg-server/hw/xquartz/pbproxy/x-selection.h
+++ b/xorg-server/hw/xquartz/pbproxy/x-selection.h
@@ -1,110 +1,110 @@
-/* x-selection.h -- proxies between NSPasteboard and X11 selections
-
- Copyright (c) 2002, 2008 Apple Computer, 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 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.
-*/
-
-#ifndef X_SELECTION_H
-#define X_SELECTION_H 1
-
-#include "pbproxy.h"
-
-#define Cursor X_Cursor
-#include <X11/extensions/Xfixes.h>
-#undef Cursor
-
-#include <AppKit/NSPasteboard.h>
-
-/* This stores image data or text. */
-struct propdata {
- unsigned char *data;
- size_t length;
- int format;
-};
-
-struct atom_list {
- Atom primary, clipboard, text, utf8_string, string, targets, multiple,
- cstring, image_png, image_jpeg, incr, atom, clipboard_manager,
- compound_text, atom_pair;
-};
-
-
-@interface x_selection : NSObject
-{
-@private
-
- /* The unmapped window we use for fetching selections. */
- Window _selection_window;
-
- Atom request_atom;
-
- struct {
- struct propdata propdata;
- Window requestor;
- Atom selection;
- } pending;
-
- /*
- * This is the number of times the user has requested a copy.
- * Once the copy is completed, we --pending_copy, and if the
- * pending_copy is > 0 we do it again.
- */
- int pending_copy;
- /*
- * This is used for the same purpose as pending_copy, but for the
- * CLIPBOARD. It also prevents a race with INCR transfers.
- */
- int pending_clipboard;
-
- struct atom_list atoms[1];
-}
-
-- (void) x_active:(Time)timestamp;
-- (void) x_inactive:(Time)timestamp;
-
-- (void) x_copy:(Time)timestamp;
-
-- (void) clear_event:(XSelectionClearEvent *)e;
-- (void) request_event:(XSelectionRequestEvent *)e;
-- (void) notify_event:(XSelectionEvent *)e;
-- (void) property_event:(XPropertyEvent *)e;
-- (void) xfixes_selection_notify:(XFixesSelectionNotifyEvent *)e;
-- (void) handle_selection:(Atom)selection type:(Atom)type propdata:(struct propdata *)pdata;
-- (void) claim_clipboard;
-- (BOOL) set_clipboard_manager_status:(BOOL)value;
-- (void) own_clipboard;
-- (void) copy_completed:(Atom)selection;
-
-- (void) reload_preferences;
-- (BOOL) is_active;
-- (void) send_none:(XSelectionRequestEvent *)e;
-@end
-
-/* main.m */
-extern x_selection *_selection_object;
-
-#endif /* X_SELECTION_H */
+/* x-selection.h -- proxies between NSPasteboard and X11 selections
+
+ Copyright (c) 2002, 2008 Apple Computer, 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 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.
+*/
+
+#ifndef X_SELECTION_H
+#define X_SELECTION_H 1
+
+#include "pbproxy.h"
+
+#define Cursor X_Cursor
+#include <X11/extensions/Xfixes.h>
+#undef Cursor
+
+#include <AppKit/NSPasteboard.h>
+
+/* This stores image data or text. */
+struct propdata {
+ unsigned char *data;
+ size_t length;
+ int format;
+};
+
+struct atom_list {
+ Atom primary, clipboard, text, utf8_string, string, targets, multiple,
+ cstring, image_png, image_jpeg, incr, atom, clipboard_manager,
+ compound_text, atom_pair;
+};
+
+
+@interface x_selection : NSObject
+{
+@private
+
+ /* The unmapped window we use for fetching selections. */
+ Window _selection_window;
+
+ Atom request_atom;
+
+ struct {
+ struct propdata propdata;
+ Window requestor;
+ Atom selection;
+ } pending;
+
+ /*
+ * This is the number of times the user has requested a copy.
+ * Once the copy is completed, we --pending_copy, and if the
+ * pending_copy is > 0 we do it again.
+ */
+ int pending_copy;
+ /*
+ * This is used for the same purpose as pending_copy, but for the
+ * CLIPBOARD. It also prevents a race with INCR transfers.
+ */
+ int pending_clipboard;
+
+ struct atom_list atoms[1];
+}
+
+- (void) x_active:(Time)timestamp;
+- (void) x_inactive:(Time)timestamp;
+
+- (void) x_copy:(Time)timestamp;
+
+- (void) clear_event:(XSelectionClearEvent *)e;
+- (void) request_event:(XSelectionRequestEvent *)e;
+- (void) notify_event:(XSelectionEvent *)e;
+- (void) property_event:(XPropertyEvent *)e;
+- (void) xfixes_selection_notify:(XFixesSelectionNotifyEvent *)e;
+- (void) handle_selection:(Atom)selection type:(Atom)type propdata:(struct propdata *)pdata;
+- (void) claim_clipboard;
+- (BOOL) set_clipboard_manager_status:(BOOL)value;
+- (void) own_clipboard;
+- (void) copy_completed:(Atom)selection;
+
+- (void) reload_preferences;
+- (BOOL) is_active;
+- (void) send_none:(XSelectionRequestEvent *)e;
+@end
+
+/* main.m */
+extern x_selection *_selection_object;
+
+#endif /* X_SELECTION_H */
diff --git a/xorg-server/hw/xquartz/pbproxy/x-selection.m b/xorg-server/hw/xquartz/pbproxy/x-selection.m
index 0f48371d0..b5f4dde5c 100644
--- a/xorg-server/hw/xquartz/pbproxy/x-selection.m
+++ b/xorg-server/hw/xquartz/pbproxy/x-selection.m
@@ -1,1587 +1,1587 @@
-/* x-selection.m -- proxies between NSPasteboard and X11 selections
-
- Copyright (c) 2002, 2008 Apple Computer, 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 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.
-*/
-
-#import "x-selection.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <X11/Xatom.h>
-#include <X11/Xutil.h>
-#import <AppKit/NSGraphics.h>
-#import <AppKit/NSImage.h>
-#import <AppKit/NSBitmapImageRep.h>
-
-/*
- * The basic design of the pbproxy code is as follows.
- *
- * When a client selects text, say from an xterm - we only copy it when the
- * X11 Edit->Copy menu item is pressed or the shortcut activated. In this
- * case we take the PRIMARY selection, and set it as the NSPasteboard data.
- *
- * When an X11 client copies something to the CLIPBOARD, pbproxy greedily grabs
- * the data, sets it as the NSPasteboard data, and finally sets itself as
- * owner of the CLIPBOARD.
- *
- * When an X11 window is activated we check to see if the NSPasteboard has
- * changed. If the NSPasteboard has changed, then we set pbproxy as owner
- * of the PRIMARY and CLIPBOARD and respond to requests for text and images.
- *
- * The behavior is now dynamic since the information above was written.
- * The behavior is now dependent on the pbproxy_prefs below.
- */
-
-/*
- * TODO:
- * 1. handle MULTIPLE - I need to study the ICCCM further, and find a test app.
- * 2. Handle NSPasteboard updates immediately, not on active/inactive
- * - Open xterm, run 'cat readme.txt | pbcopy'
- */
-
-static struct {
- BOOL active ;
- BOOL primary_on_grab; /* This is provided as an option for people who
- * want it and has issues that won't ever be
- * addressed to make it *always* work.
- */
- BOOL clipboard_to_pasteboard;
- BOOL pasteboard_to_primary;
- BOOL pasteboard_to_clipboard;
-} pbproxy_prefs = { YES, NO, YES, YES, YES };
-
-@implementation x_selection
-
-static struct propdata null_propdata = {NULL, 0, 0};
-
-#ifdef DEBUG
-static void
-dump_prefs() {
- ErrorF(fp,
- "pbproxy preferences:\n"
- "\tactive %u\n"
- "\tprimary_on_grab %u\n"
- "\tclipboard_to_pasteboard %u\n"
- "\tpasteboard_to_primary %u\n"
- "\tpasteboard_to_clipboard %u\n",
- pbproxy_prefs.active,
- pbproxy_prefs.primary_on_grab,
- pbproxy_prefs.clipboard_to_pasteboard,
- pbproxy_prefs.pasteboard_to_primary,
- pbproxy_prefs.pasteboard_to_clipboard);
-}
-#endif
-
-extern CFStringRef app_prefs_domain_cfstr;
-
-static BOOL
-prefs_get_bool (CFStringRef key, BOOL defaultValue) {
- Boolean value, ok;
-
- value = CFPreferencesGetAppBooleanValue (key, app_prefs_domain_cfstr, &ok);
-
- return ok ? (BOOL) value : defaultValue;
-}
-
-static void
-init_propdata (struct propdata *pdata)
-{
- *pdata = null_propdata;
-}
-
-static void
-free_propdata (struct propdata *pdata)
-{
- free (pdata->data);
- *pdata = null_propdata;
-}
-
-/*
- * Return True if an error occurs. Return False if pdata has data
- * and we finished.
- * The property is only deleted when bytesleft is 0 if delete is True.
- */
-static Bool
-get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Atom *type)
-{
- long offset = 0;
- unsigned long numitems, bytesleft = 0;
-#ifdef TEST
- /* This is used to test the growth handling. */
- unsigned long length = 4UL;
-#else
- unsigned long length = (100000UL + 3) / 4;
-#endif
- unsigned char *buf = NULL, *chunk = NULL;
- size_t buflen = 0, chunkbytesize = 0;
- int format;
-
- TRACE ();
-
- if(None == property)
- return True;
-
- do
- {
- unsigned long newbuflen = 0;
- unsigned char *newbuf = NULL;
-
-#ifdef TEST
- ErrorF("bytesleft %lu\n", bytesleft);
-#endif
-
- if (Success != XGetWindowProperty (xpbproxy_dpy, win, property,
- offset, length, delete,
- AnyPropertyType,
- type, &format, &numitems,
- &bytesleft, &chunk))
- {
- DebugF ("Error while getting window property.\n");
- *pdata = null_propdata;
- free (buf);
- return True;
- }
-
-#ifdef TEST
- ErrorF("format %d numitems %lu bytesleft %lu\n",
- format, numitems, bytesleft);
-
- ErrorF("type %s\n", XGetAtomName (xpbproxy_dpy, *type));
-#endif
-
- /* Format is the number of bits. */
- if (format == 8)
- chunkbytesize = numitems;
- else if (format == 16)
- chunkbytesize = numitems * sizeof(short);
- else if (format == 32)
- chunkbytesize = numitems * sizeof(long);
-
-#ifdef TEST
- ErrorF("chunkbytesize %zu\n", chunkbytesize);
-#endif
- newbuflen = buflen + chunkbytesize;
- if (newbuflen > 0)
- {
- newbuf = realloc (buf, newbuflen);
-
- if (NULL == newbuf)
- {
- XFree (chunk);
- free (buf);
- return True;
- }
-
- memcpy (newbuf + buflen, chunk, chunkbytesize);
- XFree (chunk);
- buf = newbuf;
- buflen = newbuflen;
- /* offset is a multiple of 32 bits*/
- offset += chunkbytesize / 4;
- }
- else
- {
- if (chunk)
- XFree (chunk);
- }
-
-#ifdef TEST
- ErrorF("bytesleft %lu\n", bytesleft);
-#endif
- } while (bytesleft > 0);
-
- pdata->data = buf;
- pdata->length = buflen;
- pdata->format = format;
-
- return /*success*/ False;
-}
-
-
-/* Implementation methods */
-
-/* This finds the preferred type from a TARGETS list.*/
-- (Atom) find_preferred:(struct propdata *)pdata
-{
- Atom a = None;
- size_t i, step;
- Bool png = False, jpeg = False, utf8 = False, string = False;
-
- TRACE ();
-
- if (pdata->format != 32)
- {
- ErrorF("Atom list is expected to be formatted as an array of 32bit values.\n");
- return None;
- }
-
- for (i = 0, step = sizeof(long); i < pdata->length; i += step)
- {
- a = (Atom)*(long *)(pdata->data + i);
-
- if (a == atoms->image_png)
- {
- png = True;
- }
- else if (a == atoms->image_jpeg)
- {
- jpeg = True;
- }
- else if (a == atoms->utf8_string)
- {
- utf8 = True;
- }
- else if (a == atoms->string)
- {
- string = True;
- }
- else
- {
- char *type = XGetAtomName(xpbproxy_dpy, a);
- if (type)
- {
- DebugF("Unhandled X11 mime type: %s", type);
- XFree(type);
- }
- }
- }
-
- /*We prefer PNG over strings, and UTF8 over a Latin-1 string.*/
- if (png)
- return atoms->image_png;
-
- if (jpeg)
- return atoms->image_jpeg;
-
- if (utf8)
- return atoms->utf8_string;
-
- if (string)
- return atoms->string;
-
- /* This is evidently something we don't know how to handle.*/
- return None;
-}
-
-/* Return True if this is an INCR-style transfer. */
-- (Bool) is_incr_type:(XSelectionEvent *)e
-{
- Atom seltype;
- int format;
- unsigned long numitems = 0UL, bytesleft = 0UL;
- unsigned char *chunk;
-
- TRACE ();
-
- if (Success != XGetWindowProperty (xpbproxy_dpy, e->requestor, e->property,
- /*offset*/ 0L, /*length*/ 4UL,
- /*Delete*/ False,
- AnyPropertyType, &seltype, &format,
- &numitems, &bytesleft, &chunk))
- {
- return False;
- }
-
- if(chunk)
- XFree(chunk);
-
- return (seltype == atoms->incr) ? True : False;
-}
-
-/*
- * This should be called after a selection has been copied,
- * or when the selection is unfinished before a transfer completes.
- */
-- (void) release_pending
-{
- TRACE ();
-
- free_propdata (&pending.propdata);
- pending.requestor = None;
- pending.selection = None;
-}
-
-/* Return True if an error occurs during an append.*/
-/* Return False if the append succeeds. */
-- (Bool) append_to_pending:(struct propdata *)pdata requestor:(Window)requestor
-{
- unsigned char *newdata;
- size_t newlength;
-
- TRACE ();
-
- if (requestor != pending.requestor)
- {
- [self release_pending];
- pending.requestor = requestor;
- }
-
- newlength = pending.propdata.length + pdata->length;
- newdata = realloc(pending.propdata.data, newlength);
-
- if(NULL == newdata)
- {
- perror("realloc propdata");
- [self release_pending];
- return True;
- }
-
- memcpy(newdata + pending.propdata.length, pdata->data, pdata->length);
- pending.propdata.data = newdata;
- pending.propdata.length = newlength;
-
- return False;
-}
-
-
-
-/* Called when X11 becomes active (i.e. has key focus) */
-- (void) x_active:(Time)timestamp
-{
- static NSInteger changeCount;
- NSInteger countNow;
- NSPasteboard *pb;
-
- TRACE ();
-
- pb = [NSPasteboard generalPasteboard];
-
- if (nil == pb)
- return;
-
- countNow = [pb changeCount];
-
- if (countNow != changeCount)
- {
- DebugF ("changed pasteboard!\n");
- changeCount = countNow;
-
- if (pbproxy_prefs.pasteboard_to_primary)
- {
- XSetSelectionOwner (xpbproxy_dpy, atoms->primary, _selection_window, CurrentTime);
- }
-
- if (pbproxy_prefs.pasteboard_to_clipboard) {
- [self own_clipboard];
- }
- }
-
-#if 0
- /*gstaplin: we should perhaps investigate something like this branch above...*/
- if ([_pasteboard availableTypeFromArray: _known_types] != nil)
- {
- /* Pasteboard has data we should proxy; I think it makes
- sense to put it on both CLIPBOARD and PRIMARY */
-
- XSetSelectionOwner (xpbproxy_dpy, atoms->clipboard,
- _selection_window, timestamp);
- XSetSelectionOwner (xpbproxy_dpy, atoms->primary,
- _selection_window, timestamp);
- }
-#endif
-}
-
-/* Called when X11 loses key focus */
-- (void) x_inactive:(Time)timestamp
-{
- TRACE ();
-}
-
-/* This requests the TARGETS list from the PRIMARY selection owner. */
-- (void) x_copy_request_targets
-{
- TRACE ();
-
- request_atom = atoms->targets;
- XConvertSelection (xpbproxy_dpy, atoms->primary, atoms->targets,
- atoms->primary, _selection_window, CurrentTime);
-}
-
-/* Called when the Edit/Copy item on the main X11 menubar is selected
- * and no appkit window claims it. */
-- (void) x_copy:(Time)timestamp
-{
- Window w;
-
- TRACE ();
-
- w = XGetSelectionOwner (xpbproxy_dpy, atoms->primary);
-
- if (None != w)
- {
- ++pending_copy;
-
- if (1 == pending_copy) {
- /*
- * There are no other copy operations in progress, so we
- * can proceed safely. Otherwise the copy_completed method
- * will see that the pending_copy is > 1, and do another copy.
- */
- [self x_copy_request_targets];
- }
- }
-}
-
-/* Set pbproxy as owner of the SELECTION_MANAGER selection.
- * This prevents tools like xclipboard from causing havoc.
- * Returns TRUE on success
- */
-- (BOOL) set_clipboard_manager_status:(BOOL)value
-{
- TRACE ();
-
- Window owner = XGetSelectionOwner (xpbproxy_dpy, atoms->clipboard_manager);
-
- if(value) {
- if(owner == _selection_window)
- return TRUE;
-
- if(owner != None) {
- ErrorF("A clipboard manager using window 0x%lx already owns the clipboard selection. "
- "pbproxy will not sync clipboard to pasteboard.\n", owner);
- return FALSE;
- }
-
- XSetSelectionOwner(xpbproxy_dpy, atoms->clipboard_manager, _selection_window, CurrentTime);
- return (_selection_window == XGetSelectionOwner(xpbproxy_dpy, atoms->clipboard_manager));
- } else {
- if(owner != _selection_window)
- return TRUE;
-
- XSetSelectionOwner(xpbproxy_dpy, atoms->clipboard_manager, None, CurrentTime);
- return(None == XGetSelectionOwner(xpbproxy_dpy, atoms->clipboard_manager));
- }
-
- return FALSE;
-}
-
-/*
- * This occurs when we previously owned a selection,
- * and then lost it from another client.
- */
-- (void) clear_event:(XSelectionClearEvent *)e
-{
-
-
- TRACE ();
-
- DebugF ("e->selection %s\n", XGetAtomName (xpbproxy_dpy, e->selection));
-
- if(e->selection == atoms->clipboard) {
- /*
- * We lost ownership of the CLIPBOARD.
- */
- ++pending_clipboard;
-
- if (1 == pending_clipboard) {
- /* Claim the clipboard contents from the new owner. */
- [self claim_clipboard];
- }
- } else if(e->selection == atoms->clipboard_manager) {
- if(pbproxy_prefs.clipboard_to_pasteboard) {
- /* Another CLIPBOARD_MANAGER has set itself as owner. Disable syncing
- * to avoid a race.
- */
- ErrorF("Another clipboard manager was started! "
- "xpbproxy is disabling syncing with clipboard.\n");
- pbproxy_prefs.clipboard_to_pasteboard = NO;
- }
- }
-}
-
-/*
- * We greedily acquire the clipboard after it changes, and on startup.
- */
-- (void) claim_clipboard
-{
- Window owner;
-
- TRACE ();
-
- if (!pbproxy_prefs.clipboard_to_pasteboard)
- return;
-
- owner = XGetSelectionOwner (xpbproxy_dpy, atoms->clipboard);
- if (None == owner) {
- /*
- * The owner probably died or we are just starting up pbproxy.
- * Set pbproxy's _selection_window as the owner, and continue.
- */
- DebugF ("No clipboard owner.\n");
- [self copy_completed:atoms->clipboard];
- return;
- } else if (owner == _selection_window) {
- [self copy_completed:atoms->clipboard];
- return;
- }
-
- DebugF ("requesting targets\n");
-
- request_atom = atoms->targets;
- XConvertSelection (xpbproxy_dpy, atoms->clipboard, atoms->targets,
- atoms->clipboard, _selection_window, CurrentTime);
- XFlush (xpbproxy_dpy);
- /* Now we will get a SelectionNotify event in the future. */
-}
-
-/* Greedily acquire the clipboard. */
-- (void) own_clipboard
-{
-
- TRACE ();
-
- /* We should perhaps have a boundary limit on the number of iterations... */
- do
- {
- XSetSelectionOwner (xpbproxy_dpy, atoms->clipboard, _selection_window,
- CurrentTime);
- } while (_selection_window != XGetSelectionOwner (xpbproxy_dpy,
- atoms->clipboard));
-}
-
-- (void) init_reply:(XEvent *)reply request:(XSelectionRequestEvent *)e
-{
- reply->xselection.type = SelectionNotify;
- reply->xselection.selection = e->selection;
- reply->xselection.target = e->target;
- reply->xselection.requestor = e->requestor;
- reply->xselection.time = e->time;
- reply->xselection.property = None;
-}
-
-- (void) send_reply:(XEvent *)reply
-{
- /*
- * We are supposed to use an empty event mask, and not propagate
- * the event, according to the ICCCM.
- */
- DebugF ("reply->xselection.requestor 0x%lx\n", reply->xselection.requestor);
-
- XSendEvent (xpbproxy_dpy, reply->xselection.requestor, False, 0, reply);
- XFlush (xpbproxy_dpy);
-}
-
-/*
- * This responds to a TARGETS request.
- * The result is a list of a ATOMs that correspond to the types available
- * for a selection.
- * For instance an application might provide a UTF8_STRING and a STRING
- * (in Latin-1 encoding). The requestor can then make the choice based on
- * the list.
- */
-- (void) send_targets:(XSelectionRequestEvent *)e pasteboard:(NSPasteboard *)pb
-{
- XEvent reply;
- NSArray *pbtypes;
-
- [self init_reply:&reply request:e];
-
- pbtypes = [pb types];
- if (pbtypes)
- {
- long list[7]; /* Don't forget to increase this if we handle more types! */
- long count = 0;
-
- /*
- * I'm not sure if this is needed, but some toolkits/clients list
- * TARGETS in response to targets.
- */
- list[count] = atoms->targets;
- ++count;
-
- if ([pbtypes containsObject:NSStringPboardType])
- {
- /* We have a string type that we can convert to UTF8, or Latin-1... */
- DebugF ("NSStringPboardType\n");
- list[count] = atoms->utf8_string;
- ++count;
- list[count] = atoms->string;
- ++count;
- list[count] = atoms->compound_text;
- ++count;
- }
-
- /* TODO add the NSPICTPboardType back again, once we have conversion
- * functionality in send_image.
- */
-#ifdef __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations" // NSPICTPboardType
-#endif
-
- if ([pbtypes containsObject:NSPICTPboardType]
- || [pbtypes containsObject:NSTIFFPboardType])
- {
- /* We can convert a TIFF to a PNG or JPEG. */
- DebugF ("NSTIFFPboardType\n");
- list[count] = atoms->image_png;
- ++count;
- list[count] = atoms->image_jpeg;
- ++count;
- }
-
-#ifdef __clang__
-#pragma clang diagnostic pop
-#endif
-
- if (count)
- {
- /* We have a list of ATOMs to send. */
- XChangeProperty (xpbproxy_dpy, e->requestor, e->property, atoms->atom, 32,
- PropModeReplace, (unsigned char *) list, count);
-
- reply.xselection.property = e->property;
- }
- }
-
- [self send_reply:&reply];
-}
-
-
-- (void) send_string:(XSelectionRequestEvent *)e utf8:(BOOL)utf8 pasteboard:(NSPasteboard *)pb
-{
- XEvent reply;
- NSArray *pbtypes;
- NSString *data;
- const char *bytes;
- NSUInteger length;
-
- TRACE ();
-
- [self init_reply:&reply request:e];
-
- pbtypes = [pb types];
-
- if (![pbtypes containsObject:NSStringPboardType])
- {
- [self send_reply:&reply];
- return;
- }
-
-#ifdef __LP64__
- DebugF ("pbtypes retainCount after containsObject: %lu\n", [pbtypes retainCount]);
-#else
- DebugF ("pbtypes retainCount after containsObject: %u\n", [pbtypes retainCount]);
-#endif
-
- data = [pb stringForType:NSStringPboardType];
-
- if (nil == data)
- {
- [self send_reply:&reply];
- return;
- }
-
- if (utf8)
- {
- bytes = [data UTF8String];
- /*
- * We don't want the UTF-8 string length here.
- * We want the length in bytes.
- */
- length = strlen (bytes);
-
- if (length < 50) {
- DebugF ("UTF-8: %s\n", bytes);
-#ifdef __LP64__
- DebugF ("UTF-8 length: %lu\n", length);
-#else
- DebugF ("UTF-8 length: %u\n", length);
-#endif
- }
- }
- else
- {
- DebugF ("Latin-1\n");
- bytes = [data cStringUsingEncoding:NSISOLatin1StringEncoding];
- /*WARNING: bytes is not NUL-terminated. */
- length = [data lengthOfBytesUsingEncoding:NSISOLatin1StringEncoding];
- }
-
- DebugF ("e->target %s\n", XGetAtomName (xpbproxy_dpy, e->target));
-
- XChangeProperty (xpbproxy_dpy, e->requestor, e->property, e->target,
- 8, PropModeReplace, (unsigned char *) bytes, length);
-
- reply.xselection.property = e->property;
-
- [self send_reply:&reply];
-}
-
-- (void) send_compound_text:(XSelectionRequestEvent *)e pasteboard:(NSPasteboard *)pb
-{
- XEvent reply;
- NSArray *pbtypes;
-
- TRACE ();
-
- [self init_reply:&reply request:e];
-
- pbtypes = [pb types];
-
- if ([pbtypes containsObject: NSStringPboardType])
- {
- NSString *data = [pb stringForType:NSStringPboardType];
- if (nil != data)
- {
- /*
- * Cast to (void *) to avoid a const warning.
- * AFAIK Xutf8TextListToTextProperty does not modify the input memory.
- */
- void *utf8 = (void *)[data UTF8String];
- char *list[] = { utf8, NULL };
- XTextProperty textprop;
-
- textprop.value = NULL;
-
- if (Success == Xutf8TextListToTextProperty (xpbproxy_dpy, list, 1,
- XCompoundTextStyle,
- &textprop))
- {
-
- if (8 != textprop.format)
- DebugF ("textprop.format is unexpectedly not 8 - it's %d instead\n",
- textprop.format);
-
- XChangeProperty (xpbproxy_dpy, e->requestor, e->property,
- atoms->compound_text, textprop.format,
- PropModeReplace, textprop.value,
- textprop.nitems);
-
- reply.xselection.property = e->property;
- }
-
- if (textprop.value)
- XFree (textprop.value);
-
- }
- }
-
- [self send_reply:&reply];
-}
-
-/* Finding a test application that uses MULTIPLE has proven to be difficult. */
-- (void) send_multiple:(XSelectionRequestEvent *)e
-{
- XEvent reply;
-
- TRACE ();
-
- [self init_reply:&reply request:e];
-
- if (None != e->property)
- {
-
- }
-
- [self send_reply:&reply];
-}
-
-/* Return nil if an error occured. */
-/* DO NOT retain the encdata for longer than the length of an event response.
- * The autorelease pool will reuse/free it.
- */
-- (NSData *) encode_image_data:(NSData *)data type:(NSBitmapImageFileType)enctype
-{
- NSBitmapImageRep *bmimage = nil;
- NSData *encdata = nil;
- NSDictionary *dict = nil;
-
- bmimage = [[NSBitmapImageRep alloc] initWithData:data];
-
- if (nil == bmimage)
- return nil;
-
- dict = [[NSDictionary alloc] init];
- encdata = [bmimage representationUsingType:enctype properties:dict];
-
- if (nil == encdata)
- {
- [dict autorelease];
- [bmimage autorelease];
- return nil;
- }
-
- [dict autorelease];
- [bmimage autorelease];
-
- return encdata;
-}
-
-/* Return YES when an error has occured when trying to send the PICT. */
-/* The caller should send a default reponse with a property of None when an error occurs. */
-- (BOOL) send_image_pict_reply:(XSelectionRequestEvent *)e
- pasteboard:(NSPasteboard *)pb
- type:(NSBitmapImageFileType)imagetype
-{
- XEvent reply;
- NSImage *img = nil;
- NSData *data = nil, *encdata = nil;
- NSUInteger length;
- const void *bytes = NULL;
-
- img = [[NSImage alloc] initWithPasteboard:pb];
-
- if (nil == img)
- {
- return YES;
- }
-
- data = [img TIFFRepresentation];
-
- if (nil == data)
- {
- [img autorelease];
- ErrorF("unable to convert PICT to TIFF!\n");
- return YES;
- }
-
- encdata = [self encode_image_data:data type:imagetype];
- if(nil == encdata)
- {
- [img autorelease];
- return YES;
- }
-
- [self init_reply:&reply request:e];
-
- length = [encdata length];
- bytes = [encdata bytes];
-
- XChangeProperty (xpbproxy_dpy, e->requestor, e->property, e->target,
- 8, PropModeReplace, bytes, length);
- reply.xselection.property = e->property;
-
- [self send_reply:&reply];
-
- [img autorelease];
-
- return NO; /*no error*/
-}
-
-/* Return YES if an error occured. */
-/* The caller should send a reply with a property of None when an error occurs. */
-- (BOOL) send_image_tiff_reply:(XSelectionRequestEvent *)e
- pasteboard:(NSPasteboard *)pb
- type:(NSBitmapImageFileType)imagetype
-{
- XEvent reply;
- NSData *data = nil;
- NSData *encdata = nil;
- NSUInteger length;
- const void *bytes = NULL;
-
- data = [pb dataForType:NSTIFFPboardType];
-
- if (nil == data)
- return YES;
-
- encdata = [self encode_image_data:data type:imagetype];
-
- if(nil == encdata)
- return YES;
-
- [self init_reply:&reply request:e];
-
- length = [encdata length];
- bytes = [encdata bytes];
-
- XChangeProperty (xpbproxy_dpy, e->requestor, e->property, e->target,
- 8, PropModeReplace, bytes, length);
- reply.xselection.property = e->property;
-
- [self send_reply:&reply];
-
- return NO; /*no error*/
-}
-
-- (void) send_image:(XSelectionRequestEvent *)e pasteboard:(NSPasteboard *)pb
-{
- NSArray *pbtypes = nil;
- NSBitmapImageFileType imagetype = NSPNGFileType;
-
- TRACE ();
-
- if (e->target == atoms->image_png)
- imagetype = NSPNGFileType;
- else if (e->target == atoms->image_jpeg)
- imagetype = NSJPEGFileType;
- else
- {
- ErrorF("internal failure in xpbproxy! imagetype being sent isn't PNG or JPEG.\n");
- }
-
- pbtypes = [pb types];
-
- if (pbtypes)
- {
- if ([pbtypes containsObject:NSTIFFPboardType])
- {
- if (NO == [self send_image_tiff_reply:e pasteboard:pb type:imagetype])
- return;
- }
-#ifdef __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations" // NSPICTPboardType
-#endif
- else if ([pbtypes containsObject:NSPICTPboardType])
-#ifdef __clang__
-#pragma clang diagnostic pop
-#endif
- {
- if (NO == [self send_image_pict_reply:e pasteboard:pb type:imagetype])
- return;
-
- /* Fall through intentionally to the send_none: */
- }
- }
-
- [self send_none:e];
-}
-
-- (void)send_none:(XSelectionRequestEvent *)e
-{
- XEvent reply;
-
- TRACE ();
-
- [self init_reply:&reply request:e];
- [self send_reply:&reply];
-}
-
-
-/* Another client requested the data or targets of data available from the clipboard. */
-- (void)request_event:(XSelectionRequestEvent *)e
-{
- NSPasteboard *pb;
-
- TRACE ();
-
- /* TODO We should also keep track of the time of the selection, and
- * according to the ICCCM "refuse the request" if the event timestamp
- * is before we owned it.
- * What should we base the time on? How can we get the current time just
- * before an XSetSelectionOwner? Is it the server's time, or the clients?
- * According to the XSelectionRequestEvent manual page, the Time value
- * may be set to CurrentTime or a time, so that makes it a bit different.
- * Perhaps we should just punt and ignore races.
- */
-
- /*TODO we need a COMPOUND_TEXT test app*/
- /*TODO we need a MULTIPLE test app*/
-
- pb = [NSPasteboard generalPasteboard];
- if (nil == pb)
- {
- [self send_none:e];
- return;
- }
-
-
- if (None != e->target)
- DebugF ("e->target %s\n", XGetAtomName (xpbproxy_dpy, e->target));
-
- if (e->target == atoms->targets)
- {
- /* The paste requestor wants to know what TARGETS we support. */
- [self send_targets:e pasteboard:pb];
- }
- else if (e->target == atoms->multiple)
- {
- /*
- * This isn't finished, and may never be, unless I can find
- * a good test app.
- */
- [self send_multiple:e];
- }
- else if (e->target == atoms->utf8_string)
- {
- [self send_string:e utf8:YES pasteboard:pb];
- }
- else if (e->target == atoms->string)
- {
- [self send_string:e utf8:NO pasteboard:pb];
- }
- else if (e->target == atoms->compound_text)
- {
- [self send_compound_text:e pasteboard:pb];
- }
- else if (e->target == atoms->multiple)
- {
- [self send_multiple:e];
- }
- else if (e->target == atoms->image_png || e->target == atoms->image_jpeg)
- {
- [self send_image:e pasteboard:pb];
- }
- else
- {
- [self send_none:e];
- }
-}
-
-/* This handles the events resulting from an XConvertSelection request. */
-- (void) notify_event:(XSelectionEvent *)e
-{
- Atom type;
- struct propdata pdata;
-
- TRACE ();
-
- [self release_pending];
-
- if (None == e->property) {
- DebugF ("e->property is None.\n");
- [self copy_completed:e->selection];
- /* Nothing is selected. */
- return;
- }
-
-#if 0
- ErrorF("e->selection %s\n", XGetAtomName (xpbproxy_dpy, e->selection));
- ErrorF("e->property %s\n", XGetAtomName (xpbproxy_dpy, e->property));
-#endif
-
- if ([self is_incr_type:e])
- {
- /*
- * This is an INCR-style transfer, which means that we
- * will get the data after a series of PropertyNotify events.
- */
- DebugF ("is INCR\n");
-
- if (get_property (e->requestor, e->property, &pdata, /*Delete*/ True, &type))
- {
- /*
- * An error occured, so we should invoke the copy_completed:, but
- * not handle_selection:type:propdata:
- */
- [self copy_completed:e->selection];
- return;
- }
-
- free_propdata (&pdata);
-
- pending.requestor = e->requestor;
- pending.selection = e->selection;
-
- DebugF ("set pending.requestor to 0x%lx\n", pending.requestor);
- }
- else
- {
- if (get_property (e->requestor, e->property, &pdata, /*Delete*/ True, &type))
- {
- [self copy_completed:e->selection];
- return;
- }
-
- /* We have the complete selection data.*/
- [self handle_selection:e->selection type:type propdata:&pdata];
-
- DebugF ("handled selection with the first notify_event\n");
- }
-}
-
-/* This is used for INCR transfers. See the ICCCM for the details. */
-/* This is used to retrieve PRIMARY and CLIPBOARD selections. */
-- (void) property_event:(XPropertyEvent *)e
-{
- struct propdata pdata;
- Atom type;
-
- TRACE ();
-
- if (None != e->atom)
- {
-#ifdef DEBUG
- char *name = XGetAtomName (xpbproxy_dpy, e->atom);
-
- if (name)
- {
- DebugF ("e->atom %s\n", name);
- XFree(name);
- }
-#endif
- }
-
- if (None != pending.requestor && PropertyNewValue == e->state)
- {
- DebugF ("pending.requestor 0x%lx\n", pending.requestor);
-
- if (get_property (e->window, e->atom, &pdata, /*Delete*/ True, &type))
- {
- [self copy_completed:pending.selection];
- [self release_pending];
- return;
- }
-
- if (0 == pdata.length)
- {
- /*
- * We completed the transfer.
- * handle_selection will call copy_completed: for us.
- */
- [self handle_selection:pending.selection type:type propdata:&pending.propdata];
- free_propdata(&pdata);
- pending.propdata = null_propdata;
- pending.requestor = None;
- pending.selection = None;
- }
- else
- {
- [self append_to_pending:&pdata requestor:e->window];
- free_propdata (&pdata);
- }
- }
-}
-
-- (void) xfixes_selection_notify:(XFixesSelectionNotifyEvent *)e {
- if(!pbproxy_prefs.active)
- return;
-
- switch(e->subtype) {
- case XFixesSetSelectionOwnerNotify:
- if(e->selection == atoms->primary && pbproxy_prefs.primary_on_grab)
- [self x_copy:e->timestamp];
- break;
-
- case XFixesSelectionWindowDestroyNotify:
- case XFixesSelectionClientCloseNotify:
- default:
- ErrorF("Unhandled XFixesSelectionNotifyEvent: subtype=%d\n", e->subtype);
- break;
- }
-}
-
-- (void) handle_targets: (Atom)selection propdata:(struct propdata *)pdata
-{
- /* Find a type we can handle and prefer from the list of ATOMs. */
- Atom preferred;
- char *name;
-
- TRACE ();
-
- preferred = [self find_preferred:pdata];
-
- if (None == preferred)
- {
- /*
- * This isn't required by the ICCCM, but some apps apparently
- * don't respond to TARGETS properly.
- */
- preferred = atoms->string;
- }
-
- (void)name; /* Avoid a warning with non-debug compiles. */
-#ifdef DEBUG
- name = XGetAtomName (xpbproxy_dpy, preferred);
-
- if (name)
- {
- DebugF ("requesting %s\n", name);
- }
-#endif
- request_atom = preferred;
- XConvertSelection (xpbproxy_dpy, selection, preferred, selection,
- _selection_window, CurrentTime);
-}
-
-/* This handles the image type of selection (typically in CLIPBOARD). */
-/* We convert to a TIFF, so that other applications can paste more easily. */
-- (void) handle_image: (struct propdata *)pdata pasteboard:(NSPasteboard *)pb
-{
- NSArray *pbtypes;
- NSUInteger length;
- NSData *data, *tiff;
- NSBitmapImageRep *bmimage;
-
- TRACE ();
-
- length = pdata->length;
- data = [[NSData alloc] initWithBytes:pdata->data length:length];
-
- if (nil == data)
- {
- DebugF ("unable to create NSData object!\n");
- return;
- }
-
-#ifdef __LP64__
- DebugF ("data retainCount before NSBitmapImageRep initWithData: %lu\n",
- [data retainCount]);
-#else
- DebugF ("data retainCount before NSBitmapImageRep initWithData: %u\n",
- [data retainCount]);
-#endif
-
- bmimage = [[NSBitmapImageRep alloc] initWithData:data];
-
- if (nil == bmimage)
- {
- [data autorelease];
- DebugF ("unable to create NSBitmapImageRep!\n");
- return;
- }
-
-#ifdef __LP64__
- DebugF ("data retainCount after NSBitmapImageRep initWithData: %lu\n",
- [data retainCount]);
-#else
- DebugF ("data retainCount after NSBitmapImageRep initWithData: %u\n",
- [data retainCount]);
-#endif
-
- @try
- {
- tiff = [bmimage TIFFRepresentation];
- }
-
- @catch (NSException *e)
- {
- DebugF ("NSTIFFException!\n");
- [data autorelease];
- [bmimage autorelease];
- return;
- }
-
-#ifdef __LP64__
- DebugF ("bmimage retainCount after TIFFRepresentation %lu\n", [bmimage retainCount]);
-#else
- DebugF ("bmimage retainCount after TIFFRepresentation %u\n", [bmimage retainCount]);
-#endif
-
- pbtypes = [NSArray arrayWithObjects:NSTIFFPboardType, nil];
-
- if (nil == pbtypes)
- {
- [data autorelease];
- [bmimage autorelease];
- return;
- }
-
- [pb declareTypes:pbtypes owner:nil];
- if (YES != [pb setData:tiff forType:NSTIFFPboardType])
- {
- DebugF ("writing pasteboard data failed!\n");
- }
-
- [data autorelease];
-
-#ifdef __LP64__
- DebugF ("bmimage retainCount before release %lu\n", [bmimage retainCount]);
-#else
- DebugF ("bmimage retainCount before release %u\n", [bmimage retainCount]);
-#endif
-
- [bmimage autorelease];
-}
-
-/* This handles the UTF8_STRING type of selection. */
-- (void) handle_utf8_string:(struct propdata *)pdata pasteboard:(NSPasteboard *)pb
-{
- NSString *string;
- NSArray *pbtypes;
-
- TRACE ();
-
- string = [[NSString alloc] initWithBytes:pdata->data length:pdata->length encoding:NSUTF8StringEncoding];
-
- if (nil == string)
- return;
-
- pbtypes = [NSArray arrayWithObjects:NSStringPboardType, nil];
-
- if (nil == pbtypes)
- {
- [string autorelease];
- return;
- }
-
- [pb declareTypes:pbtypes owner:nil];
-
- if (YES != [pb setString:string forType:NSStringPboardType]) {
- ErrorF("pasteboard setString:forType: failed!\n");
- }
- [string autorelease];
- DebugF ("done handling utf8 string\n");
-}
-
-/* This handles the STRING type, which should be in Latin-1. */
-- (void) handle_string: (struct propdata *)pdata pasteboard:(NSPasteboard *)pb
-{
- NSString *string;
- NSArray *pbtypes;
-
- TRACE ();
-
- string = [[NSString alloc] initWithBytes:pdata->data length:pdata->length encoding:NSISOLatin1StringEncoding];
-
- if (nil == string)
- return;
-
- pbtypes = [NSArray arrayWithObjects:NSStringPboardType, nil];
-
- if (nil == pbtypes)
- {
- [string autorelease];
- return;
- }
-
- [pb declareTypes:pbtypes owner:nil];
- if (YES != [pb setString:string forType:NSStringPboardType]) {
- ErrorF("pasteboard setString:forType failed in handle_string!\n");
- }
- [string autorelease];
-}
-
-/* This is called when the selection is completely retrieved from another client. */
-/* Warning: this frees the propdata. */
-- (void) handle_selection:(Atom)selection type:(Atom)type propdata:(struct propdata *)pdata
-{
- NSPasteboard *pb;
-
- TRACE ();
-
- pb = [NSPasteboard generalPasteboard];
-
- if (nil == pb)
- {
- [self copy_completed:selection];
- free_propdata (pdata);
- return;
- }
-
- /*
- * Some apps it seems set the type to TARGETS instead of ATOM, such as Eterm.
- * These aren't ICCCM compliant apps, but we need these to work...
- */
- if (request_atom == atoms->targets
- && (type == atoms->atom || type == atoms->targets))
- {
- [self handle_targets:selection propdata:pdata];
- free_propdata(pdata);
- return;
- }
- else if (type == atoms->image_png)
- {
- [self handle_image:pdata pasteboard:pb];
- }
- else if (type == atoms->image_jpeg)
- {
- [self handle_image:pdata pasteboard:pb];
- }
- else if (type == atoms->utf8_string)
- {
- [self handle_utf8_string:pdata pasteboard:pb];
- }
- else if (type == atoms->string)
- {
- [self handle_string:pdata pasteboard:pb];
- }
-
- free_propdata(pdata);
-
- [self copy_completed:selection];
-}
-
-
-- (void) copy_completed:(Atom)selection
-{
- TRACE ();
- char *name;
-
- (void)name; /* Avoid warning with non-debug compiles. */
-#ifdef DEBUG
- name = XGetAtomName (xpbproxy_dpy, selection);
- if (name)
- {
- DebugF ("copy_completed: %s\n", name);
- XFree (name);
- }
-#endif
-
- if (selection == atoms->primary && pending_copy > 0)
- {
- --pending_copy;
- if (pending_copy > 0)
- {
- /* Copy PRIMARY again. */
- [self x_copy_request_targets];
- return;
- }
- }
- else if (selection == atoms->clipboard && pending_clipboard > 0)
- {
- --pending_clipboard;
- if (pending_clipboard > 0)
- {
- /* Copy CLIPBOARD. */
- [self claim_clipboard];
- return;
- }
- else
- {
- /* We got the final data. Now set pbproxy as the owner. */
- [self own_clipboard];
- return;
- }
- }
-
- /*
- * We had 1 or more primary in progress, and the clipboard arrived
- * while we were busy.
- */
- if (pending_clipboard > 0)
- {
- [self claim_clipboard];
- }
-}
-
-- (void) reload_preferences
-{
- /*
- * It's uncertain how we could handle the synchronization failing, so cast to void.
- * The prefs_get_bool should fall back to defaults if the org.x.X11 plist doesn't exist or is invalid.
- */
- (void)CFPreferencesAppSynchronize(app_prefs_domain_cfstr);
-#ifdef STANDALONE_XPBPROXY
- if(xpbproxy_is_standalone)
- pbproxy_prefs.active = YES;
- else
-#endif
- pbproxy_prefs.active = prefs_get_bool(CFSTR("sync_pasteboard"), pbproxy_prefs.active);
- pbproxy_prefs.primary_on_grab = prefs_get_bool(CFSTR("sync_primary_on_select"), pbproxy_prefs.primary_on_grab);
- pbproxy_prefs.clipboard_to_pasteboard = prefs_get_bool(CFSTR("sync_clipboard_to_pasteboard"), pbproxy_prefs.clipboard_to_pasteboard);
- pbproxy_prefs.pasteboard_to_primary = prefs_get_bool(CFSTR("sync_pasteboard_to_primary"), pbproxy_prefs.pasteboard_to_primary);
- pbproxy_prefs.pasteboard_to_clipboard = prefs_get_bool(CFSTR("sync_pasteboard_to_clipboard"), pbproxy_prefs.pasteboard_to_clipboard);
-
- /* This is used for debugging. */
- //dump_prefs();
-
- if(pbproxy_prefs.active && pbproxy_prefs.primary_on_grab && !xpbproxy_have_xfixes) {
- ErrorF("Disabling sync_primary_on_select functionality due to missing XFixes extension.\n");
- pbproxy_prefs.primary_on_grab = NO;
- }
-
- /* Claim or release the CLIPBOARD_MANAGER atom */
- if(![self set_clipboard_manager_status:(pbproxy_prefs.active && pbproxy_prefs.clipboard_to_pasteboard)])
- pbproxy_prefs.clipboard_to_pasteboard = NO;
-
- if(pbproxy_prefs.active && pbproxy_prefs.clipboard_to_pasteboard)
- [self claim_clipboard];
-}
-
-- (BOOL) is_active
-{
- return pbproxy_prefs.active;
-}
-
-/* NSPasteboard-required methods */
-
-- (void) paste:(id)sender
-{
- TRACE ();
-}
-
-- (void) pasteboard:(NSPasteboard *)pb provideDataForType:(NSString *)type
-{
- TRACE ();
-}
-
-- (void) pasteboardChangedOwner:(NSPasteboard *)pb
-{
- TRACE ();
-
- /* Right now we don't care with this. */
-}
-
-/* Allocation */
-
-- init
-{
- unsigned long pixel;
-
- self = [super init];
- if (self == nil)
- return nil;
-
- atoms->primary = XInternAtom (xpbproxy_dpy, "PRIMARY", False);
- atoms->clipboard = XInternAtom (xpbproxy_dpy, "CLIPBOARD", False);
- atoms->text = XInternAtom (xpbproxy_dpy, "TEXT", False);
- atoms->utf8_string = XInternAtom (xpbproxy_dpy, "UTF8_STRING", False);
- atoms->string = XInternAtom (xpbproxy_dpy, "STRING", False);
- atoms->targets = XInternAtom (xpbproxy_dpy, "TARGETS", False);
- atoms->multiple = XInternAtom (xpbproxy_dpy, "MULTIPLE", False);
- atoms->cstring = XInternAtom (xpbproxy_dpy, "CSTRING", False);
- atoms->image_png = XInternAtom (xpbproxy_dpy, "image/png", False);
- atoms->image_jpeg = XInternAtom (xpbproxy_dpy, "image/jpeg", False);
- atoms->incr = XInternAtom (xpbproxy_dpy, "INCR", False);
- atoms->atom = XInternAtom (xpbproxy_dpy, "ATOM", False);
- atoms->clipboard_manager = XInternAtom (xpbproxy_dpy, "CLIPBOARD_MANAGER", False);
- atoms->compound_text = XInternAtom (xpbproxy_dpy, "COMPOUND_TEXT", False);
- atoms->atom_pair = XInternAtom (xpbproxy_dpy, "ATOM_PAIR", False);
-
- pixel = BlackPixel (xpbproxy_dpy, DefaultScreen (xpbproxy_dpy));
- _selection_window = XCreateSimpleWindow (xpbproxy_dpy, DefaultRootWindow (xpbproxy_dpy),
- 0, 0, 1, 1, 0, pixel, pixel);
-
- /* This is used to get PropertyNotify events when doing INCR transfers. */
- XSelectInput (xpbproxy_dpy, _selection_window, PropertyChangeMask);
-
- request_atom = None;
-
- init_propdata (&pending.propdata);
- pending.requestor = None;
- pending.selection = None;
-
- pending_copy = 0;
- pending_clipboard = 0;
-
- if(xpbproxy_have_xfixes)
- XFixesSelectSelectionInput(xpbproxy_dpy, _selection_window, atoms->primary,
- XFixesSetSelectionOwnerNotifyMask);
-
- [self reload_preferences];
-
- return self;
-}
-
-- (void) dealloc
-{
- if (None != _selection_window)
- {
- XDestroyWindow (xpbproxy_dpy, _selection_window);
- _selection_window = None;
- }
-
- free_propdata (&pending.propdata);
-
- [super dealloc];
-}
-
-@end
+/* x-selection.m -- proxies between NSPasteboard and X11 selections
+
+ Copyright (c) 2002, 2008 Apple Computer, 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 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.
+*/
+
+#import "x-selection.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+#import <AppKit/NSGraphics.h>
+#import <AppKit/NSImage.h>
+#import <AppKit/NSBitmapImageRep.h>
+
+/*
+ * The basic design of the pbproxy code is as follows.
+ *
+ * When a client selects text, say from an xterm - we only copy it when the
+ * X11 Edit->Copy menu item is pressed or the shortcut activated. In this
+ * case we take the PRIMARY selection, and set it as the NSPasteboard data.
+ *
+ * When an X11 client copies something to the CLIPBOARD, pbproxy greedily grabs
+ * the data, sets it as the NSPasteboard data, and finally sets itself as
+ * owner of the CLIPBOARD.
+ *
+ * When an X11 window is activated we check to see if the NSPasteboard has
+ * changed. If the NSPasteboard has changed, then we set pbproxy as owner
+ * of the PRIMARY and CLIPBOARD and respond to requests for text and images.
+ *
+ * The behavior is now dynamic since the information above was written.
+ * The behavior is now dependent on the pbproxy_prefs below.
+ */
+
+/*
+ * TODO:
+ * 1. handle MULTIPLE - I need to study the ICCCM further, and find a test app.
+ * 2. Handle NSPasteboard updates immediately, not on active/inactive
+ * - Open xterm, run 'cat readme.txt | pbcopy'
+ */
+
+static struct {
+ BOOL active ;
+ BOOL primary_on_grab; /* This is provided as an option for people who
+ * want it and has issues that won't ever be
+ * addressed to make it *always* work.
+ */
+ BOOL clipboard_to_pasteboard;
+ BOOL pasteboard_to_primary;
+ BOOL pasteboard_to_clipboard;
+} pbproxy_prefs = { YES, NO, YES, YES, YES };
+
+@implementation x_selection
+
+static struct propdata null_propdata = {NULL, 0, 0};
+
+#ifdef DEBUG
+static void
+dump_prefs() {
+ ErrorF(fp,
+ "pbproxy preferences:\n"
+ "\tactive %u\n"
+ "\tprimary_on_grab %u\n"
+ "\tclipboard_to_pasteboard %u\n"
+ "\tpasteboard_to_primary %u\n"
+ "\tpasteboard_to_clipboard %u\n",
+ pbproxy_prefs.active,
+ pbproxy_prefs.primary_on_grab,
+ pbproxy_prefs.clipboard_to_pasteboard,
+ pbproxy_prefs.pasteboard_to_primary,
+ pbproxy_prefs.pasteboard_to_clipboard);
+}
+#endif
+
+extern CFStringRef app_prefs_domain_cfstr;
+
+static BOOL
+prefs_get_bool (CFStringRef key, BOOL defaultValue) {
+ Boolean value, ok;
+
+ value = CFPreferencesGetAppBooleanValue (key, app_prefs_domain_cfstr, &ok);
+
+ return ok ? (BOOL) value : defaultValue;
+}
+
+static void
+init_propdata (struct propdata *pdata)
+{
+ *pdata = null_propdata;
+}
+
+static void
+free_propdata (struct propdata *pdata)
+{
+ free (pdata->data);
+ *pdata = null_propdata;
+}
+
+/*
+ * Return True if an error occurs. Return False if pdata has data
+ * and we finished.
+ * The property is only deleted when bytesleft is 0 if delete is True.
+ */
+static Bool
+get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Atom *type)
+{
+ long offset = 0;
+ unsigned long numitems, bytesleft = 0;
+#ifdef TEST
+ /* This is used to test the growth handling. */
+ unsigned long length = 4UL;
+#else
+ unsigned long length = (100000UL + 3) / 4;
+#endif
+ unsigned char *buf = NULL, *chunk = NULL;
+ size_t buflen = 0, chunkbytesize = 0;
+ int format;
+
+ TRACE ();
+
+ if(None == property)
+ return True;
+
+ do
+ {
+ unsigned long newbuflen = 0;
+ unsigned char *newbuf = NULL;
+
+#ifdef TEST
+ ErrorF("bytesleft %lu\n", bytesleft);
+#endif
+
+ if (Success != XGetWindowProperty (xpbproxy_dpy, win, property,
+ offset, length, delete,
+ AnyPropertyType,
+ type, &format, &numitems,
+ &bytesleft, &chunk))
+ {
+ DebugF ("Error while getting window property.\n");
+ *pdata = null_propdata;
+ free (buf);
+ return True;
+ }
+
+#ifdef TEST
+ ErrorF("format %d numitems %lu bytesleft %lu\n",
+ format, numitems, bytesleft);
+
+ ErrorF("type %s\n", XGetAtomName (xpbproxy_dpy, *type));
+#endif
+
+ /* Format is the number of bits. */
+ if (format == 8)
+ chunkbytesize = numitems;
+ else if (format == 16)
+ chunkbytesize = numitems * sizeof(short);
+ else if (format == 32)
+ chunkbytesize = numitems * sizeof(long);
+
+#ifdef TEST
+ ErrorF("chunkbytesize %zu\n", chunkbytesize);
+#endif
+ newbuflen = buflen + chunkbytesize;
+ if (newbuflen > 0)
+ {
+ newbuf = realloc (buf, newbuflen);
+
+ if (NULL == newbuf)
+ {
+ XFree (chunk);
+ free (buf);
+ return True;
+ }
+
+ memcpy (newbuf + buflen, chunk, chunkbytesize);
+ XFree (chunk);
+ buf = newbuf;
+ buflen = newbuflen;
+ /* offset is a multiple of 32 bits*/
+ offset += chunkbytesize / 4;
+ }
+ else
+ {
+ if (chunk)
+ XFree (chunk);
+ }
+
+#ifdef TEST
+ ErrorF("bytesleft %lu\n", bytesleft);
+#endif
+ } while (bytesleft > 0);
+
+ pdata->data = buf;
+ pdata->length = buflen;
+ pdata->format = format;
+
+ return /*success*/ False;
+}
+
+
+/* Implementation methods */
+
+/* This finds the preferred type from a TARGETS list.*/
+- (Atom) find_preferred:(struct propdata *)pdata
+{
+ Atom a = None;
+ size_t i, step;
+ Bool png = False, jpeg = False, utf8 = False, string = False;
+
+ TRACE ();
+
+ if (pdata->format != 32)
+ {
+ ErrorF("Atom list is expected to be formatted as an array of 32bit values.\n");
+ return None;
+ }
+
+ for (i = 0, step = sizeof(long); i < pdata->length; i += step)
+ {
+ a = (Atom)*(long *)(pdata->data + i);
+
+ if (a == atoms->image_png)
+ {
+ png = True;
+ }
+ else if (a == atoms->image_jpeg)
+ {
+ jpeg = True;
+ }
+ else if (a == atoms->utf8_string)
+ {
+ utf8 = True;
+ }
+ else if (a == atoms->string)
+ {
+ string = True;
+ }
+ else
+ {
+ char *type = XGetAtomName(xpbproxy_dpy, a);
+ if (type)
+ {
+ DebugF("Unhandled X11 mime type: %s", type);
+ XFree(type);
+ }
+ }
+ }
+
+ /*We prefer PNG over strings, and UTF8 over a Latin-1 string.*/
+ if (png)
+ return atoms->image_png;
+
+ if (jpeg)
+ return atoms->image_jpeg;
+
+ if (utf8)
+ return atoms->utf8_string;
+
+ if (string)
+ return atoms->string;
+
+ /* This is evidently something we don't know how to handle.*/
+ return None;
+}
+
+/* Return True if this is an INCR-style transfer. */
+- (Bool) is_incr_type:(XSelectionEvent *)e
+{
+ Atom seltype;
+ int format;
+ unsigned long numitems = 0UL, bytesleft = 0UL;
+ unsigned char *chunk;
+
+ TRACE ();
+
+ if (Success != XGetWindowProperty (xpbproxy_dpy, e->requestor, e->property,
+ /*offset*/ 0L, /*length*/ 4UL,
+ /*Delete*/ False,
+ AnyPropertyType, &seltype, &format,
+ &numitems, &bytesleft, &chunk))
+ {
+ return False;
+ }
+
+ if(chunk)
+ XFree(chunk);
+
+ return (seltype == atoms->incr) ? True : False;
+}
+
+/*
+ * This should be called after a selection has been copied,
+ * or when the selection is unfinished before a transfer completes.
+ */
+- (void) release_pending
+{
+ TRACE ();
+
+ free_propdata (&pending.propdata);
+ pending.requestor = None;
+ pending.selection = None;
+}
+
+/* Return True if an error occurs during an append.*/
+/* Return False if the append succeeds. */
+- (Bool) append_to_pending:(struct propdata *)pdata requestor:(Window)requestor
+{
+ unsigned char *newdata;
+ size_t newlength;
+
+ TRACE ();
+
+ if (requestor != pending.requestor)
+ {
+ [self release_pending];
+ pending.requestor = requestor;
+ }
+
+ newlength = pending.propdata.length + pdata->length;
+ newdata = realloc(pending.propdata.data, newlength);
+
+ if(NULL == newdata)
+ {
+ perror("realloc propdata");
+ [self release_pending];
+ return True;
+ }
+
+ memcpy(newdata + pending.propdata.length, pdata->data, pdata->length);
+ pending.propdata.data = newdata;
+ pending.propdata.length = newlength;
+
+ return False;
+}
+
+
+
+/* Called when X11 becomes active (i.e. has key focus) */
+- (void) x_active:(Time)timestamp
+{
+ static NSInteger changeCount;
+ NSInteger countNow;
+ NSPasteboard *pb;
+
+ TRACE ();
+
+ pb = [NSPasteboard generalPasteboard];
+
+ if (nil == pb)
+ return;
+
+ countNow = [pb changeCount];
+
+ if (countNow != changeCount)
+ {
+ DebugF ("changed pasteboard!\n");
+ changeCount = countNow;
+
+ if (pbproxy_prefs.pasteboard_to_primary)
+ {
+ XSetSelectionOwner (xpbproxy_dpy, atoms->primary, _selection_window, CurrentTime);
+ }
+
+ if (pbproxy_prefs.pasteboard_to_clipboard) {
+ [self own_clipboard];
+ }
+ }
+
+#if 0
+ /*gstaplin: we should perhaps investigate something like this branch above...*/
+ if ([_pasteboard availableTypeFromArray: _known_types] != nil)
+ {
+ /* Pasteboard has data we should proxy; I think it makes
+ sense to put it on both CLIPBOARD and PRIMARY */
+
+ XSetSelectionOwner (xpbproxy_dpy, atoms->clipboard,
+ _selection_window, timestamp);
+ XSetSelectionOwner (xpbproxy_dpy, atoms->primary,
+ _selection_window, timestamp);
+ }
+#endif
+}
+
+/* Called when X11 loses key focus */
+- (void) x_inactive:(Time)timestamp
+{
+ TRACE ();
+}
+
+/* This requests the TARGETS list from the PRIMARY selection owner. */
+- (void) x_copy_request_targets
+{
+ TRACE ();
+
+ request_atom = atoms->targets;
+ XConvertSelection (xpbproxy_dpy, atoms->primary, atoms->targets,
+ atoms->primary, _selection_window, CurrentTime);
+}
+
+/* Called when the Edit/Copy item on the main X11 menubar is selected
+ * and no appkit window claims it. */
+- (void) x_copy:(Time)timestamp
+{
+ Window w;
+
+ TRACE ();
+
+ w = XGetSelectionOwner (xpbproxy_dpy, atoms->primary);
+
+ if (None != w)
+ {
+ ++pending_copy;
+
+ if (1 == pending_copy) {
+ /*
+ * There are no other copy operations in progress, so we
+ * can proceed safely. Otherwise the copy_completed method
+ * will see that the pending_copy is > 1, and do another copy.
+ */
+ [self x_copy_request_targets];
+ }
+ }
+}
+
+/* Set pbproxy as owner of the SELECTION_MANAGER selection.
+ * This prevents tools like xclipboard from causing havoc.
+ * Returns TRUE on success
+ */
+- (BOOL) set_clipboard_manager_status:(BOOL)value
+{
+ TRACE ();
+
+ Window owner = XGetSelectionOwner (xpbproxy_dpy, atoms->clipboard_manager);
+
+ if(value) {
+ if(owner == _selection_window)
+ return TRUE;
+
+ if(owner != None) {
+ ErrorF("A clipboard manager using window 0x%lx already owns the clipboard selection. "
+ "pbproxy will not sync clipboard to pasteboard.\n", owner);
+ return FALSE;
+ }
+
+ XSetSelectionOwner(xpbproxy_dpy, atoms->clipboard_manager, _selection_window, CurrentTime);
+ return (_selection_window == XGetSelectionOwner(xpbproxy_dpy, atoms->clipboard_manager));
+ } else {
+ if(owner != _selection_window)
+ return TRUE;
+
+ XSetSelectionOwner(xpbproxy_dpy, atoms->clipboard_manager, None, CurrentTime);
+ return(None == XGetSelectionOwner(xpbproxy_dpy, atoms->clipboard_manager));
+ }
+
+ return FALSE;
+}
+
+/*
+ * This occurs when we previously owned a selection,
+ * and then lost it from another client.
+ */
+- (void) clear_event:(XSelectionClearEvent *)e
+{
+
+
+ TRACE ();
+
+ DebugF ("e->selection %s\n", XGetAtomName (xpbproxy_dpy, e->selection));
+
+ if(e->selection == atoms->clipboard) {
+ /*
+ * We lost ownership of the CLIPBOARD.
+ */
+ ++pending_clipboard;
+
+ if (1 == pending_clipboard) {
+ /* Claim the clipboard contents from the new owner. */
+ [self claim_clipboard];
+ }
+ } else if(e->selection == atoms->clipboard_manager) {
+ if(pbproxy_prefs.clipboard_to_pasteboard) {
+ /* Another CLIPBOARD_MANAGER has set itself as owner. Disable syncing
+ * to avoid a race.
+ */
+ ErrorF("Another clipboard manager was started! "
+ "xpbproxy is disabling syncing with clipboard.\n");
+ pbproxy_prefs.clipboard_to_pasteboard = NO;
+ }
+ }
+}
+
+/*
+ * We greedily acquire the clipboard after it changes, and on startup.
+ */
+- (void) claim_clipboard
+{
+ Window owner;
+
+ TRACE ();
+
+ if (!pbproxy_prefs.clipboard_to_pasteboard)
+ return;
+
+ owner = XGetSelectionOwner (xpbproxy_dpy, atoms->clipboard);
+ if (None == owner) {
+ /*
+ * The owner probably died or we are just starting up pbproxy.
+ * Set pbproxy's _selection_window as the owner, and continue.
+ */
+ DebugF ("No clipboard owner.\n");
+ [self copy_completed:atoms->clipboard];
+ return;
+ } else if (owner == _selection_window) {
+ [self copy_completed:atoms->clipboard];
+ return;
+ }
+
+ DebugF ("requesting targets\n");
+
+ request_atom = atoms->targets;
+ XConvertSelection (xpbproxy_dpy, atoms->clipboard, atoms->targets,
+ atoms->clipboard, _selection_window, CurrentTime);
+ XFlush (xpbproxy_dpy);
+ /* Now we will get a SelectionNotify event in the future. */
+}
+
+/* Greedily acquire the clipboard. */
+- (void) own_clipboard
+{
+
+ TRACE ();
+
+ /* We should perhaps have a boundary limit on the number of iterations... */
+ do
+ {
+ XSetSelectionOwner (xpbproxy_dpy, atoms->clipboard, _selection_window,
+ CurrentTime);
+ } while (_selection_window != XGetSelectionOwner (xpbproxy_dpy,
+ atoms->clipboard));
+}
+
+- (void) init_reply:(XEvent *)reply request:(XSelectionRequestEvent *)e
+{
+ reply->xselection.type = SelectionNotify;
+ reply->xselection.selection = e->selection;
+ reply->xselection.target = e->target;
+ reply->xselection.requestor = e->requestor;
+ reply->xselection.time = e->time;
+ reply->xselection.property = None;
+}
+
+- (void) send_reply:(XEvent *)reply
+{
+ /*
+ * We are supposed to use an empty event mask, and not propagate
+ * the event, according to the ICCCM.
+ */
+ DebugF ("reply->xselection.requestor 0x%lx\n", reply->xselection.requestor);
+
+ XSendEvent (xpbproxy_dpy, reply->xselection.requestor, False, 0, reply);
+ XFlush (xpbproxy_dpy);
+}
+
+/*
+ * This responds to a TARGETS request.
+ * The result is a list of a ATOMs that correspond to the types available
+ * for a selection.
+ * For instance an application might provide a UTF8_STRING and a STRING
+ * (in Latin-1 encoding). The requestor can then make the choice based on
+ * the list.
+ */
+- (void) send_targets:(XSelectionRequestEvent *)e pasteboard:(NSPasteboard *)pb
+{
+ XEvent reply;
+ NSArray *pbtypes;
+
+ [self init_reply:&reply request:e];
+
+ pbtypes = [pb types];
+ if (pbtypes)
+ {
+ long list[7]; /* Don't forget to increase this if we handle more types! */
+ long count = 0;
+
+ /*
+ * I'm not sure if this is needed, but some toolkits/clients list
+ * TARGETS in response to targets.
+ */
+ list[count] = atoms->targets;
+ ++count;
+
+ if ([pbtypes containsObject:NSStringPboardType])
+ {
+ /* We have a string type that we can convert to UTF8, or Latin-1... */
+ DebugF ("NSStringPboardType\n");
+ list[count] = atoms->utf8_string;
+ ++count;
+ list[count] = atoms->string;
+ ++count;
+ list[count] = atoms->compound_text;
+ ++count;
+ }
+
+ /* TODO add the NSPICTPboardType back again, once we have conversion
+ * functionality in send_image.
+ */
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations" // NSPICTPboardType
+#endif
+
+ if ([pbtypes containsObject:NSPICTPboardType]
+ || [pbtypes containsObject:NSTIFFPboardType])
+ {
+ /* We can convert a TIFF to a PNG or JPEG. */
+ DebugF ("NSTIFFPboardType\n");
+ list[count] = atoms->image_png;
+ ++count;
+ list[count] = atoms->image_jpeg;
+ ++count;
+ }
+
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+
+ if (count)
+ {
+ /* We have a list of ATOMs to send. */
+ XChangeProperty (xpbproxy_dpy, e->requestor, e->property, atoms->atom, 32,
+ PropModeReplace, (unsigned char *) list, count);
+
+ reply.xselection.property = e->property;
+ }
+ }
+
+ [self send_reply:&reply];
+}
+
+
+- (void) send_string:(XSelectionRequestEvent *)e utf8:(BOOL)utf8 pasteboard:(NSPasteboard *)pb
+{
+ XEvent reply;
+ NSArray *pbtypes;
+ NSString *data;
+ const char *bytes;
+ NSUInteger length;
+
+ TRACE ();
+
+ [self init_reply:&reply request:e];
+
+ pbtypes = [pb types];
+
+ if (![pbtypes containsObject:NSStringPboardType])
+ {
+ [self send_reply:&reply];
+ return;
+ }
+
+#ifdef __LP64__
+ DebugF ("pbtypes retainCount after containsObject: %lu\n", [pbtypes retainCount]);
+#else
+ DebugF ("pbtypes retainCount after containsObject: %u\n", [pbtypes retainCount]);
+#endif
+
+ data = [pb stringForType:NSStringPboardType];
+
+ if (nil == data)
+ {
+ [self send_reply:&reply];
+ return;
+ }
+
+ if (utf8)
+ {
+ bytes = [data UTF8String];
+ /*
+ * We don't want the UTF-8 string length here.
+ * We want the length in bytes.
+ */
+ length = strlen (bytes);
+
+ if (length < 50) {
+ DebugF ("UTF-8: %s\n", bytes);
+#ifdef __LP64__
+ DebugF ("UTF-8 length: %lu\n", length);
+#else
+ DebugF ("UTF-8 length: %u\n", length);
+#endif
+ }
+ }
+ else
+ {
+ DebugF ("Latin-1\n");
+ bytes = [data cStringUsingEncoding:NSISOLatin1StringEncoding];
+ /*WARNING: bytes is not NUL-terminated. */
+ length = [data lengthOfBytesUsingEncoding:NSISOLatin1StringEncoding];
+ }
+
+ DebugF ("e->target %s\n", XGetAtomName (xpbproxy_dpy, e->target));
+
+ XChangeProperty (xpbproxy_dpy, e->requestor, e->property, e->target,
+ 8, PropModeReplace, (unsigned char *) bytes, length);
+
+ reply.xselection.property = e->property;
+
+ [self send_reply:&reply];
+}
+
+- (void) send_compound_text:(XSelectionRequestEvent *)e pasteboard:(NSPasteboard *)pb
+{
+ XEvent reply;
+ NSArray *pbtypes;
+
+ TRACE ();
+
+ [self init_reply:&reply request:e];
+
+ pbtypes = [pb types];
+
+ if ([pbtypes containsObject: NSStringPboardType])
+ {
+ NSString *data = [pb stringForType:NSStringPboardType];
+ if (nil != data)
+ {
+ /*
+ * Cast to (void *) to avoid a const warning.
+ * AFAIK Xutf8TextListToTextProperty does not modify the input memory.
+ */
+ void *utf8 = (void *)[data UTF8String];
+ char *list[] = { utf8, NULL };
+ XTextProperty textprop;
+
+ textprop.value = NULL;
+
+ if (Success == Xutf8TextListToTextProperty (xpbproxy_dpy, list, 1,
+ XCompoundTextStyle,
+ &textprop))
+ {
+
+ if (8 != textprop.format)
+ DebugF ("textprop.format is unexpectedly not 8 - it's %d instead\n",
+ textprop.format);
+
+ XChangeProperty (xpbproxy_dpy, e->requestor, e->property,
+ atoms->compound_text, textprop.format,
+ PropModeReplace, textprop.value,
+ textprop.nitems);
+
+ reply.xselection.property = e->property;
+ }
+
+ if (textprop.value)
+ XFree (textprop.value);
+
+ }
+ }
+
+ [self send_reply:&reply];
+}
+
+/* Finding a test application that uses MULTIPLE has proven to be difficult. */
+- (void) send_multiple:(XSelectionRequestEvent *)e
+{
+ XEvent reply;
+
+ TRACE ();
+
+ [self init_reply:&reply request:e];
+
+ if (None != e->property)
+ {
+
+ }
+
+ [self send_reply:&reply];
+}
+
+/* Return nil if an error occured. */
+/* DO NOT retain the encdata for longer than the length of an event response.
+ * The autorelease pool will reuse/free it.
+ */
+- (NSData *) encode_image_data:(NSData *)data type:(NSBitmapImageFileType)enctype
+{
+ NSBitmapImageRep *bmimage = nil;
+ NSData *encdata = nil;
+ NSDictionary *dict = nil;
+
+ bmimage = [[NSBitmapImageRep alloc] initWithData:data];
+
+ if (nil == bmimage)
+ return nil;
+
+ dict = [[NSDictionary alloc] init];
+ encdata = [bmimage representationUsingType:enctype properties:dict];
+
+ if (nil == encdata)
+ {
+ [dict autorelease];
+ [bmimage autorelease];
+ return nil;
+ }
+
+ [dict autorelease];
+ [bmimage autorelease];
+
+ return encdata;
+}
+
+/* Return YES when an error has occured when trying to send the PICT. */
+/* The caller should send a default reponse with a property of None when an error occurs. */
+- (BOOL) send_image_pict_reply:(XSelectionRequestEvent *)e
+ pasteboard:(NSPasteboard *)pb
+ type:(NSBitmapImageFileType)imagetype
+{
+ XEvent reply;
+ NSImage *img = nil;
+ NSData *data = nil, *encdata = nil;
+ NSUInteger length;
+ const void *bytes = NULL;
+
+ img = [[NSImage alloc] initWithPasteboard:pb];
+
+ if (nil == img)
+ {
+ return YES;
+ }
+
+ data = [img TIFFRepresentation];
+
+ if (nil == data)
+ {
+ [img autorelease];
+ ErrorF("unable to convert PICT to TIFF!\n");
+ return YES;
+ }
+
+ encdata = [self encode_image_data:data type:imagetype];
+ if(nil == encdata)
+ {
+ [img autorelease];
+ return YES;
+ }
+
+ [self init_reply:&reply request:e];
+
+ length = [encdata length];
+ bytes = [encdata bytes];
+
+ XChangeProperty (xpbproxy_dpy, e->requestor, e->property, e->target,
+ 8, PropModeReplace, bytes, length);
+ reply.xselection.property = e->property;
+
+ [self send_reply:&reply];
+
+ [img autorelease];
+
+ return NO; /*no error*/
+}
+
+/* Return YES if an error occured. */
+/* The caller should send a reply with a property of None when an error occurs. */
+- (BOOL) send_image_tiff_reply:(XSelectionRequestEvent *)e
+ pasteboard:(NSPasteboard *)pb
+ type:(NSBitmapImageFileType)imagetype
+{
+ XEvent reply;
+ NSData *data = nil;
+ NSData *encdata = nil;
+ NSUInteger length;
+ const void *bytes = NULL;
+
+ data = [pb dataForType:NSTIFFPboardType];
+
+ if (nil == data)
+ return YES;
+
+ encdata = [self encode_image_data:data type:imagetype];
+
+ if(nil == encdata)
+ return YES;
+
+ [self init_reply:&reply request:e];
+
+ length = [encdata length];
+ bytes = [encdata bytes];
+
+ XChangeProperty (xpbproxy_dpy, e->requestor, e->property, e->target,
+ 8, PropModeReplace, bytes, length);
+ reply.xselection.property = e->property;
+
+ [self send_reply:&reply];
+
+ return NO; /*no error*/
+}
+
+- (void) send_image:(XSelectionRequestEvent *)e pasteboard:(NSPasteboard *)pb
+{
+ NSArray *pbtypes = nil;
+ NSBitmapImageFileType imagetype = NSPNGFileType;
+
+ TRACE ();
+
+ if (e->target == atoms->image_png)
+ imagetype = NSPNGFileType;
+ else if (e->target == atoms->image_jpeg)
+ imagetype = NSJPEGFileType;
+ else
+ {
+ ErrorF("internal failure in xpbproxy! imagetype being sent isn't PNG or JPEG.\n");
+ }
+
+ pbtypes = [pb types];
+
+ if (pbtypes)
+ {
+ if ([pbtypes containsObject:NSTIFFPboardType])
+ {
+ if (NO == [self send_image_tiff_reply:e pasteboard:pb type:imagetype])
+ return;
+ }
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations" // NSPICTPboardType
+#endif
+ else if ([pbtypes containsObject:NSPICTPboardType])
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+ {
+ if (NO == [self send_image_pict_reply:e pasteboard:pb type:imagetype])
+ return;
+
+ /* Fall through intentionally to the send_none: */
+ }
+ }
+
+ [self send_none:e];
+}
+
+- (void)send_none:(XSelectionRequestEvent *)e
+{
+ XEvent reply;
+
+ TRACE ();
+
+ [self init_reply:&reply request:e];
+ [self send_reply:&reply];
+}
+
+
+/* Another client requested the data or targets of data available from the clipboard. */
+- (void)request_event:(XSelectionRequestEvent *)e
+{
+ NSPasteboard *pb;
+
+ TRACE ();
+
+ /* TODO We should also keep track of the time of the selection, and
+ * according to the ICCCM "refuse the request" if the event timestamp
+ * is before we owned it.
+ * What should we base the time on? How can we get the current time just
+ * before an XSetSelectionOwner? Is it the server's time, or the clients?
+ * According to the XSelectionRequestEvent manual page, the Time value
+ * may be set to CurrentTime or a time, so that makes it a bit different.
+ * Perhaps we should just punt and ignore races.
+ */
+
+ /*TODO we need a COMPOUND_TEXT test app*/
+ /*TODO we need a MULTIPLE test app*/
+
+ pb = [NSPasteboard generalPasteboard];
+ if (nil == pb)
+ {
+ [self send_none:e];
+ return;
+ }
+
+
+ if (None != e->target)
+ DebugF ("e->target %s\n", XGetAtomName (xpbproxy_dpy, e->target));
+
+ if (e->target == atoms->targets)
+ {
+ /* The paste requestor wants to know what TARGETS we support. */
+ [self send_targets:e pasteboard:pb];
+ }
+ else if (e->target == atoms->multiple)
+ {
+ /*
+ * This isn't finished, and may never be, unless I can find
+ * a good test app.
+ */
+ [self send_multiple:e];
+ }
+ else if (e->target == atoms->utf8_string)
+ {
+ [self send_string:e utf8:YES pasteboard:pb];
+ }
+ else if (e->target == atoms->string)
+ {
+ [self send_string:e utf8:NO pasteboard:pb];
+ }
+ else if (e->target == atoms->compound_text)
+ {
+ [self send_compound_text:e pasteboard:pb];
+ }
+ else if (e->target == atoms->multiple)
+ {
+ [self send_multiple:e];
+ }
+ else if (e->target == atoms->image_png || e->target == atoms->image_jpeg)
+ {
+ [self send_image:e pasteboard:pb];
+ }
+ else
+ {
+ [self send_none:e];
+ }
+}
+
+/* This handles the events resulting from an XConvertSelection request. */
+- (void) notify_event:(XSelectionEvent *)e
+{
+ Atom type;
+ struct propdata pdata;
+
+ TRACE ();
+
+ [self release_pending];
+
+ if (None == e->property) {
+ DebugF ("e->property is None.\n");
+ [self copy_completed:e->selection];
+ /* Nothing is selected. */
+ return;
+ }
+
+#if 0
+ ErrorF("e->selection %s\n", XGetAtomName (xpbproxy_dpy, e->selection));
+ ErrorF("e->property %s\n", XGetAtomName (xpbproxy_dpy, e->property));
+#endif
+
+ if ([self is_incr_type:e])
+ {
+ /*
+ * This is an INCR-style transfer, which means that we
+ * will get the data after a series of PropertyNotify events.
+ */
+ DebugF ("is INCR\n");
+
+ if (get_property (e->requestor, e->property, &pdata, /*Delete*/ True, &type))
+ {
+ /*
+ * An error occured, so we should invoke the copy_completed:, but
+ * not handle_selection:type:propdata:
+ */
+ [self copy_completed:e->selection];
+ return;
+ }
+
+ free_propdata (&pdata);
+
+ pending.requestor = e->requestor;
+ pending.selection = e->selection;
+
+ DebugF ("set pending.requestor to 0x%lx\n", pending.requestor);
+ }
+ else
+ {
+ if (get_property (e->requestor, e->property, &pdata, /*Delete*/ True, &type))
+ {
+ [self copy_completed:e->selection];
+ return;
+ }
+
+ /* We have the complete selection data.*/
+ [self handle_selection:e->selection type:type propdata:&pdata];
+
+ DebugF ("handled selection with the first notify_event\n");
+ }
+}
+
+/* This is used for INCR transfers. See the ICCCM for the details. */
+/* This is used to retrieve PRIMARY and CLIPBOARD selections. */
+- (void) property_event:(XPropertyEvent *)e
+{
+ struct propdata pdata;
+ Atom type;
+
+ TRACE ();
+
+ if (None != e->atom)
+ {
+#ifdef DEBUG
+ char *name = XGetAtomName (xpbproxy_dpy, e->atom);
+
+ if (name)
+ {
+ DebugF ("e->atom %s\n", name);
+ XFree(name);
+ }
+#endif
+ }
+
+ if (None != pending.requestor && PropertyNewValue == e->state)
+ {
+ DebugF ("pending.requestor 0x%lx\n", pending.requestor);
+
+ if (get_property (e->window, e->atom, &pdata, /*Delete*/ True, &type))
+ {
+ [self copy_completed:pending.selection];
+ [self release_pending];
+ return;
+ }
+
+ if (0 == pdata.length)
+ {
+ /*
+ * We completed the transfer.
+ * handle_selection will call copy_completed: for us.
+ */
+ [self handle_selection:pending.selection type:type propdata:&pending.propdata];
+ free_propdata(&pdata);
+ pending.propdata = null_propdata;
+ pending.requestor = None;
+ pending.selection = None;
+ }
+ else
+ {
+ [self append_to_pending:&pdata requestor:e->window];
+ free_propdata (&pdata);
+ }
+ }
+}
+
+- (void) xfixes_selection_notify:(XFixesSelectionNotifyEvent *)e {
+ if(!pbproxy_prefs.active)
+ return;
+
+ switch(e->subtype) {
+ case XFixesSetSelectionOwnerNotify:
+ if(e->selection == atoms->primary && pbproxy_prefs.primary_on_grab)
+ [self x_copy:e->timestamp];
+ break;
+
+ case XFixesSelectionWindowDestroyNotify:
+ case XFixesSelectionClientCloseNotify:
+ default:
+ ErrorF("Unhandled XFixesSelectionNotifyEvent: subtype=%d\n", e->subtype);
+ break;
+ }
+}
+
+- (void) handle_targets: (Atom)selection propdata:(struct propdata *)pdata
+{
+ /* Find a type we can handle and prefer from the list of ATOMs. */
+ Atom preferred;
+ char *name;
+
+ TRACE ();
+
+ preferred = [self find_preferred:pdata];
+
+ if (None == preferred)
+ {
+ /*
+ * This isn't required by the ICCCM, but some apps apparently
+ * don't respond to TARGETS properly.
+ */
+ preferred = atoms->string;
+ }
+
+ (void)name; /* Avoid a warning with non-debug compiles. */
+#ifdef DEBUG
+ name = XGetAtomName (xpbproxy_dpy, preferred);
+
+ if (name)
+ {
+ DebugF ("requesting %s\n", name);
+ }
+#endif
+ request_atom = preferred;
+ XConvertSelection (xpbproxy_dpy, selection, preferred, selection,
+ _selection_window, CurrentTime);
+}
+
+/* This handles the image type of selection (typically in CLIPBOARD). */
+/* We convert to a TIFF, so that other applications can paste more easily. */
+- (void) handle_image: (struct propdata *)pdata pasteboard:(NSPasteboard *)pb
+{
+ NSArray *pbtypes;
+ NSUInteger length;
+ NSData *data, *tiff;
+ NSBitmapImageRep *bmimage;
+
+ TRACE ();
+
+ length = pdata->length;
+ data = [[NSData alloc] initWithBytes:pdata->data length:length];
+
+ if (nil == data)
+ {
+ DebugF ("unable to create NSData object!\n");
+ return;
+ }
+
+#ifdef __LP64__
+ DebugF ("data retainCount before NSBitmapImageRep initWithData: %lu\n",
+ [data retainCount]);
+#else
+ DebugF ("data retainCount before NSBitmapImageRep initWithData: %u\n",
+ [data retainCount]);
+#endif
+
+ bmimage = [[NSBitmapImageRep alloc] initWithData:data];
+
+ if (nil == bmimage)
+ {
+ [data autorelease];
+ DebugF ("unable to create NSBitmapImageRep!\n");
+ return;
+ }
+
+#ifdef __LP64__
+ DebugF ("data retainCount after NSBitmapImageRep initWithData: %lu\n",
+ [data retainCount]);
+#else
+ DebugF ("data retainCount after NSBitmapImageRep initWithData: %u\n",
+ [data retainCount]);
+#endif
+
+ @try
+ {
+ tiff = [bmimage TIFFRepresentation];
+ }
+
+ @catch (NSException *e)
+ {
+ DebugF ("NSTIFFException!\n");
+ [data autorelease];
+ [bmimage autorelease];
+ return;
+ }
+
+#ifdef __LP64__
+ DebugF ("bmimage retainCount after TIFFRepresentation %lu\n", [bmimage retainCount]);
+#else
+ DebugF ("bmimage retainCount after TIFFRepresentation %u\n", [bmimage retainCount]);
+#endif
+
+ pbtypes = [NSArray arrayWithObjects:NSTIFFPboardType, nil];
+
+ if (nil == pbtypes)
+ {
+ [data autorelease];
+ [bmimage autorelease];
+ return;
+ }
+
+ [pb declareTypes:pbtypes owner:nil];
+ if (YES != [pb setData:tiff forType:NSTIFFPboardType])
+ {
+ DebugF ("writing pasteboard data failed!\n");
+ }
+
+ [data autorelease];
+
+#ifdef __LP64__
+ DebugF ("bmimage retainCount before release %lu\n", [bmimage retainCount]);
+#else
+ DebugF ("bmimage retainCount before release %u\n", [bmimage retainCount]);
+#endif
+
+ [bmimage autorelease];
+}
+
+/* This handles the UTF8_STRING type of selection. */
+- (void) handle_utf8_string:(struct propdata *)pdata pasteboard:(NSPasteboard *)pb
+{
+ NSString *string;
+ NSArray *pbtypes;
+
+ TRACE ();
+
+ string = [[NSString alloc] initWithBytes:pdata->data length:pdata->length encoding:NSUTF8StringEncoding];
+
+ if (nil == string)
+ return;
+
+ pbtypes = [NSArray arrayWithObjects:NSStringPboardType, nil];
+
+ if (nil == pbtypes)
+ {
+ [string autorelease];
+ return;
+ }
+
+ [pb declareTypes:pbtypes owner:nil];
+
+ if (YES != [pb setString:string forType:NSStringPboardType]) {
+ ErrorF("pasteboard setString:forType: failed!\n");
+ }
+ [string autorelease];
+ DebugF ("done handling utf8 string\n");
+}
+
+/* This handles the STRING type, which should be in Latin-1. */
+- (void) handle_string: (struct propdata *)pdata pasteboard:(NSPasteboard *)pb
+{
+ NSString *string;
+ NSArray *pbtypes;
+
+ TRACE ();
+
+ string = [[NSString alloc] initWithBytes:pdata->data length:pdata->length encoding:NSISOLatin1StringEncoding];
+
+ if (nil == string)
+ return;
+
+ pbtypes = [NSArray arrayWithObjects:NSStringPboardType, nil];
+
+ if (nil == pbtypes)
+ {
+ [string autorelease];
+ return;
+ }
+
+ [pb declareTypes:pbtypes owner:nil];
+ if (YES != [pb setString:string forType:NSStringPboardType]) {
+ ErrorF("pasteboard setString:forType failed in handle_string!\n");
+ }
+ [string autorelease];
+}
+
+/* This is called when the selection is completely retrieved from another client. */
+/* Warning: this frees the propdata. */
+- (void) handle_selection:(Atom)selection type:(Atom)type propdata:(struct propdata *)pdata
+{
+ NSPasteboard *pb;
+
+ TRACE ();
+
+ pb = [NSPasteboard generalPasteboard];
+
+ if (nil == pb)
+ {
+ [self copy_completed:selection];
+ free_propdata (pdata);
+ return;
+ }
+
+ /*
+ * Some apps it seems set the type to TARGETS instead of ATOM, such as Eterm.
+ * These aren't ICCCM compliant apps, but we need these to work...
+ */
+ if (request_atom == atoms->targets
+ && (type == atoms->atom || type == atoms->targets))
+ {
+ [self handle_targets:selection propdata:pdata];
+ free_propdata(pdata);
+ return;
+ }
+ else if (type == atoms->image_png)
+ {
+ [self handle_image:pdata pasteboard:pb];
+ }
+ else if (type == atoms->image_jpeg)
+ {
+ [self handle_image:pdata pasteboard:pb];
+ }
+ else if (type == atoms->utf8_string)
+ {
+ [self handle_utf8_string:pdata pasteboard:pb];
+ }
+ else if (type == atoms->string)
+ {
+ [self handle_string:pdata pasteboard:pb];
+ }
+
+ free_propdata(pdata);
+
+ [self copy_completed:selection];
+}
+
+
+- (void) copy_completed:(Atom)selection
+{
+ TRACE ();
+ char *name;
+
+ (void)name; /* Avoid warning with non-debug compiles. */
+#ifdef DEBUG
+ name = XGetAtomName (xpbproxy_dpy, selection);
+ if (name)
+ {
+ DebugF ("copy_completed: %s\n", name);
+ XFree (name);
+ }
+#endif
+
+ if (selection == atoms->primary && pending_copy > 0)
+ {
+ --pending_copy;
+ if (pending_copy > 0)
+ {
+ /* Copy PRIMARY again. */
+ [self x_copy_request_targets];
+ return;
+ }
+ }
+ else if (selection == atoms->clipboard && pending_clipboard > 0)
+ {
+ --pending_clipboard;
+ if (pending_clipboard > 0)
+ {
+ /* Copy CLIPBOARD. */
+ [self claim_clipboard];
+ return;
+ }
+ else
+ {
+ /* We got the final data. Now set pbproxy as the owner. */
+ [self own_clipboard];
+ return;
+ }
+ }
+
+ /*
+ * We had 1 or more primary in progress, and the clipboard arrived
+ * while we were busy.
+ */
+ if (pending_clipboard > 0)
+ {
+ [self claim_clipboard];
+ }
+}
+
+- (void) reload_preferences
+{
+ /*
+ * It's uncertain how we could handle the synchronization failing, so cast to void.
+ * The prefs_get_bool should fall back to defaults if the org.x.X11 plist doesn't exist or is invalid.
+ */
+ (void)CFPreferencesAppSynchronize(app_prefs_domain_cfstr);
+#ifdef STANDALONE_XPBPROXY
+ if(xpbproxy_is_standalone)
+ pbproxy_prefs.active = YES;
+ else
+#endif
+ pbproxy_prefs.active = prefs_get_bool(CFSTR("sync_pasteboard"), pbproxy_prefs.active);
+ pbproxy_prefs.primary_on_grab = prefs_get_bool(CFSTR("sync_primary_on_select"), pbproxy_prefs.primary_on_grab);
+ pbproxy_prefs.clipboard_to_pasteboard = prefs_get_bool(CFSTR("sync_clipboard_to_pasteboard"), pbproxy_prefs.clipboard_to_pasteboard);
+ pbproxy_prefs.pasteboard_to_primary = prefs_get_bool(CFSTR("sync_pasteboard_to_primary"), pbproxy_prefs.pasteboard_to_primary);
+ pbproxy_prefs.pasteboard_to_clipboard = prefs_get_bool(CFSTR("sync_pasteboard_to_clipboard"), pbproxy_prefs.pasteboard_to_clipboard);
+
+ /* This is used for debugging. */
+ //dump_prefs();
+
+ if(pbproxy_prefs.active && pbproxy_prefs.primary_on_grab && !xpbproxy_have_xfixes) {
+ ErrorF("Disabling sync_primary_on_select functionality due to missing XFixes extension.\n");
+ pbproxy_prefs.primary_on_grab = NO;
+ }
+
+ /* Claim or release the CLIPBOARD_MANAGER atom */
+ if(![self set_clipboard_manager_status:(pbproxy_prefs.active && pbproxy_prefs.clipboard_to_pasteboard)])
+ pbproxy_prefs.clipboard_to_pasteboard = NO;
+
+ if(pbproxy_prefs.active && pbproxy_prefs.clipboard_to_pasteboard)
+ [self claim_clipboard];
+}
+
+- (BOOL) is_active
+{
+ return pbproxy_prefs.active;
+}
+
+/* NSPasteboard-required methods */
+
+- (void) paste:(id)sender
+{
+ TRACE ();
+}
+
+- (void) pasteboard:(NSPasteboard *)pb provideDataForType:(NSString *)type
+{
+ TRACE ();
+}
+
+- (void) pasteboardChangedOwner:(NSPasteboard *)pb
+{
+ TRACE ();
+
+ /* Right now we don't care with this. */
+}
+
+/* Allocation */
+
+- init
+{
+ unsigned long pixel;
+
+ self = [super init];
+ if (self == nil)
+ return nil;
+
+ atoms->primary = XInternAtom (xpbproxy_dpy, "PRIMARY", False);
+ atoms->clipboard = XInternAtom (xpbproxy_dpy, "CLIPBOARD", False);
+ atoms->text = XInternAtom (xpbproxy_dpy, "TEXT", False);
+ atoms->utf8_string = XInternAtom (xpbproxy_dpy, "UTF8_STRING", False);
+ atoms->string = XInternAtom (xpbproxy_dpy, "STRING", False);
+ atoms->targets = XInternAtom (xpbproxy_dpy, "TARGETS", False);
+ atoms->multiple = XInternAtom (xpbproxy_dpy, "MULTIPLE", False);
+ atoms->cstring = XInternAtom (xpbproxy_dpy, "CSTRING", False);
+ atoms->image_png = XInternAtom (xpbproxy_dpy, "image/png", False);
+ atoms->image_jpeg = XInternAtom (xpbproxy_dpy, "image/jpeg", False);
+ atoms->incr = XInternAtom (xpbproxy_dpy, "INCR", False);
+ atoms->atom = XInternAtom (xpbproxy_dpy, "ATOM", False);
+ atoms->clipboard_manager = XInternAtom (xpbproxy_dpy, "CLIPBOARD_MANAGER", False);
+ atoms->compound_text = XInternAtom (xpbproxy_dpy, "COMPOUND_TEXT", False);
+ atoms->atom_pair = XInternAtom (xpbproxy_dpy, "ATOM_PAIR", False);
+
+ pixel = BlackPixel (xpbproxy_dpy, DefaultScreen (xpbproxy_dpy));
+ _selection_window = XCreateSimpleWindow (xpbproxy_dpy, DefaultRootWindow (xpbproxy_dpy),
+ 0, 0, 1, 1, 0, pixel, pixel);
+
+ /* This is used to get PropertyNotify events when doing INCR transfers. */
+ XSelectInput (xpbproxy_dpy, _selection_window, PropertyChangeMask);
+
+ request_atom = None;
+
+ init_propdata (&pending.propdata);
+ pending.requestor = None;
+ pending.selection = None;
+
+ pending_copy = 0;
+ pending_clipboard = 0;
+
+ if(xpbproxy_have_xfixes)
+ XFixesSelectSelectionInput(xpbproxy_dpy, _selection_window, atoms->primary,
+ XFixesSetSelectionOwnerNotifyMask);
+
+ [self reload_preferences];
+
+ return self;
+}
+
+- (void) dealloc
+{
+ if (None != _selection_window)
+ {
+ XDestroyWindow (xpbproxy_dpy, _selection_window);
+ _selection_window = None;
+ }
+
+ free_propdata (&pending.propdata);
+
+ [super dealloc];
+}
+
+@end
diff --git a/xorg-server/hw/xquartz/quartz.c b/xorg-server/hw/xquartz/quartz.c
index 45ea725b4..c395b42e6 100644
--- a/xorg-server/hw/xquartz/quartz.c
+++ b/xorg-server/hw/xquartz/quartz.c
@@ -1,488 +1,488 @@
-/*
- *
- * Quartz-specific support for the Darwin X Server
- *
- * Copyright (c) 2001-2004 Greg Parker and 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, 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.
- */
-
-#include "sanitizedCarbon.h"
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "quartzCommon.h"
-#include "quartzRandR.h"
-#include "inputstr.h"
-#include "quartz.h"
-#include "darwin.h"
-#include "darwinEvents.h"
-#include "pseudoramiX.h"
-#define _APPLEWM_SERVER_
-#include "applewmExt.h"
-
-#include "X11Application.h"
-
-#include <X11/extensions/applewmconst.h>
-
-// X headers
-#include "scrnintstr.h"
-#include "windowstr.h"
-#include "colormapst.h"
-#include "globals.h"
-#include "mi.h"
-
-// System headers
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <IOKit/pwr_mgt/IOPMLib.h>
-#include <libkern/OSAtomic.h>
-#include <signal.h>
-
-#include <rootlessCommon.h>
-#include <Xplugin.h>
-
-DevPrivateKeyRec quartzScreenKeyRec;
-int aquaMenuBarHeight = 0;
-QuartzModeProcsPtr quartzProcs = NULL;
-const char *quartzOpenGLBundle = NULL;
-
-Bool XQuartzFullscreenDisableHotkeys = TRUE;
-Bool XQuartzOptionSendsAlt = FALSE;
-Bool XQuartzEnableKeyEquivalents = TRUE;
-Bool XQuartzFullscreenVisible = FALSE;
-Bool XQuartzRootlessDefault = TRUE;
-Bool XQuartzIsRootless = TRUE;
-Bool XQuartzServerVisible = FALSE;
-Bool XQuartzFullscreenMenu = FALSE;
-
-int32_t XQuartzShieldingWindowLevel = 0;
-
-/*
-===========================================================================
-
- Screen functions
-
-===========================================================================
-*/
-
-/*
- * QuartzAddScreen
- * Do mode dependent initialization of each screen for Quartz.
- */
-Bool QuartzAddScreen(
- int index,
- ScreenPtr pScreen)
-{
- // allocate space for private per screen Quartz specific storage
- QuartzScreenPtr displayInfo = calloc(sizeof(QuartzScreenRec), 1);
-
- // QUARTZ_PRIV(pScreen) = displayInfo;
- dixSetPrivate(&pScreen->devPrivates, quartzScreenKey, displayInfo);
-
- // do Quartz mode specific initialization
- return quartzProcs->AddScreen(index, pScreen);
-}
-
-
-/*
- * QuartzSetupScreen
- * Finalize mode specific setup of each screen.
- */
-Bool QuartzSetupScreen(
- int index,
- ScreenPtr pScreen)
-{
- // do Quartz mode specific setup
- if (! quartzProcs->SetupScreen(index, pScreen))
- return FALSE;
-
- // setup cursor support
- if (! quartzProcs->InitCursor(pScreen))
- return FALSE;
-
-#if defined(RANDR)
- if(!QuartzRandRInit(pScreen)) {
- DEBUG_LOG("Failed to init RandR extension.\n");
- return FALSE;
- }
-#endif
-
- return TRUE;
-}
-
-
-/*
- * QuartzInitOutput
- * Quartz display initialization.
- */
-void QuartzInitOutput(
- int argc,
- char **argv )
-{
- /* For XQuartz, we want to just use the default signal handler to work better with CrashTracer */
- signal(SIGSEGV, SIG_DFL);
- signal(SIGILL, SIG_DFL);
-#ifdef SIGEMT
- signal(SIGEMT, SIG_DFL);
-#endif
- signal(SIGFPE, SIG_DFL);
-#ifdef SIGBUS
- signal(SIGBUS, SIG_DFL);
-#endif
-#ifdef SIGSYS
- signal(SIGSYS, SIG_DFL);
-#endif
-#ifdef SIGXCPU
- signal(SIGXCPU, SIG_DFL);
-#endif
-#ifdef SIGXFSZ
- signal(SIGXFSZ, SIG_DFL);
-#endif
-
- if (!RegisterBlockAndWakeupHandlers(QuartzBlockHandler,
- QuartzWakeupHandler,
- NULL))
- {
- FatalError("Could not register block and wakeup handlers.");
- }
-
- if (!dixRegisterPrivateKey(&quartzScreenKeyRec, PRIVATE_SCREEN, 0))
- FatalError("Failed to alloc quartz screen private.\n");
-
- // Do display mode specific initialization
- quartzProcs->DisplayInit();
-}
-
-
-/*
- * QuartzInitInput
- * Inform the main thread the X server is ready to handle events.
- */
-void QuartzInitInput(
- int argc,
- char **argv )
-{
- X11ApplicationSetCanQuit(0);
- X11ApplicationServerReady();
- // Do final display mode specific initialization before handling events
- if (quartzProcs->InitInput)
- quartzProcs->InitInput(argc, argv);
-}
-
-
-void QuartzUpdateScreens(void) {
- ScreenPtr pScreen;
- WindowPtr pRoot;
- int x, y, width, height, sx, sy;
- xEvent e;
- BoxRec bounds;
-
- if (noPseudoramiXExtension || screenInfo.numScreens != 1)
- {
- /* FIXME: if not using Xinerama, we have multiple screens, and
- to do this properly may need to add or remove screens. Which
- isn't possible. So don't do anything. Another reason why
- we default to running with Xinerama. */
-
- return;
- }
-
- pScreen = screenInfo.screens[0];
-
- PseudoramiXResetScreens();
- quartzProcs->AddPseudoramiXScreens(&x, &y, &width, &height, pScreen);
-
- pScreen->x = x;
- pScreen->y = y;
- pScreen->mmWidth = pScreen->mmWidth * ((double) width / pScreen->width);
- pScreen->mmHeight = pScreen->mmHeight * ((double) height / pScreen->height);
- pScreen->width = width;
- pScreen->height = height;
-
- DarwinAdjustScreenOrigins(&screenInfo);
-
- /* DarwinAdjustScreenOrigins or UpdateScreen may change pScreen->x/y,
- * so use it rather than x/y
- */
- sx = pScreen->x + darwinMainScreenX;
- sy = pScreen->y + darwinMainScreenY;
-
- /* Adjust the root window. */
- pRoot = pScreen->root;
- AppleWMSetScreenOrigin(pRoot);
- pScreen->ResizeWindow(pRoot, x - sx, y - sy, width, height, NULL);
-
- /* <rdar://problem/7770779> pointer events are clipped to old display region after display reconfiguration
- * http://xquartz.macosforge.org/trac/ticket/346
- */
- bounds.x1 = 0;
- bounds.x2 = width;
- bounds.y1 = 0;
- bounds.y2 = height;
- pScreen->ConstrainCursor(inputInfo.pointer, pScreen, &bounds);
- inputInfo.pointer->spriteInfo->sprite->physLimits = bounds;
- inputInfo.pointer->spriteInfo->sprite->hotLimits = bounds;
-
- DEBUG_LOG("Root Window: %dx%d @ (%d, %d) darwinMainScreen (%d, %d) xy (%d, %d) dixScreenOrigins (%d, %d)\n", width, height, x - sx, y - sy, darwinMainScreenX, darwinMainScreenY, x, y, pScreen->x, pScreen->y);
-
- /* Send an event for the root reconfigure */
- e.u.u.type = ConfigureNotify;
- e.u.configureNotify.window = pRoot->drawable.id;
- e.u.configureNotify.aboveSibling = None;
- e.u.configureNotify.x = x - sx;
- e.u.configureNotify.y = y - sy;
- e.u.configureNotify.width = width;
- e.u.configureNotify.height = height;
- e.u.configureNotify.borderWidth = wBorderWidth(pRoot);
- e.u.configureNotify.override = pRoot->overrideRedirect;
- DeliverEvents(pRoot, &e, 1, NullWindow);
-
- quartzProcs->UpdateScreen(pScreen);
-
- /* miPaintWindow needs to be called after RootlessUpdateScreenPixmap (from xprUpdateScreen) */
- miPaintWindow(pRoot, &pRoot->borderClip, PW_BACKGROUND);
-
- /* Tell RandR about the new size, so new connections get the correct info */
- RRScreenSizeNotify(pScreen);
-}
-
-static void pokeActivityCallback(CFRunLoopTimerRef timer, void *info) {
- UpdateSystemActivity(OverallAct);
-}
-
-static void QuartzScreenSaver(int state) {
- static CFRunLoopTimerRef pokeActivityTimer = NULL;
- static CFRunLoopTimerContext pokeActivityContext = { 0, NULL, NULL, NULL, NULL };
- static OSSpinLock pokeActivitySpinLock = OS_SPINLOCK_INIT;
-
- OSSpinLockLock(&pokeActivitySpinLock);
-
- if(state) {
- if(pokeActivityTimer == NULL)
- goto QuartzScreenSaverEnd;
-
- CFRunLoopTimerInvalidate(pokeActivityTimer);
- CFRelease(pokeActivityTimer);
- pokeActivityTimer = NULL;
- } else {
- if(pokeActivityTimer != NULL)
- goto QuartzScreenSaverEnd;
-
- pokeActivityTimer = CFRunLoopTimerCreate(NULL, CFAbsoluteTimeGetCurrent(), 30, 0, 0, pokeActivityCallback, &pokeActivityContext);
- if(pokeActivityTimer == NULL) {
- ErrorF("Unable to create pokeActivityTimer.\n");
- goto QuartzScreenSaverEnd;
- }
-
- CFRunLoopAddTimer(CFRunLoopGetMain(), pokeActivityTimer, kCFRunLoopCommonModes);
- }
-QuartzScreenSaverEnd:
- OSSpinLockUnlock(&pokeActivitySpinLock);
-}
-
-void QuartzShowFullscreen(int state) {
- int i;
-
- DEBUG_LOG("QuartzShowFullscreen: state=%d\n", state);
-
- if(XQuartzIsRootless) {
- ErrorF("QuartzShowFullscreen called while in rootless mode.\n");
- return;
- }
-
- QuartzScreenSaver(!state);
-
- if(XQuartzFullscreenVisible == state)
- return;
-
- XQuartzFullscreenVisible = state;
-
- xp_disable_update ();
-
- if (!XQuartzFullscreenVisible)
- RootlessHideAllWindows();
-
- RootlessUpdateRooted(XQuartzFullscreenVisible);
-
- if (XQuartzFullscreenVisible) {
- RootlessShowAllWindows ();
- for (i=0; i < screenInfo.numScreens; i++) {
- ScreenPtr pScreen = screenInfo.screens[i];
- RootlessRepositionWindows(pScreen);
- // JH: I don't think this is necessary, but keeping it here as a reminder
- //RootlessUpdateScreenPixmap(pScreen);
- }
- }
-
- /* Somehow the menubar manages to interfere with our event stream
- * in fullscreen mode, even though it's not visible.
- */
- X11ApplicationShowHideMenubar(!XQuartzFullscreenVisible);
-
- xp_reenable_update ();
-
- if (XQuartzFullscreenDisableHotkeys)
- xp_disable_hot_keys(XQuartzFullscreenVisible);
-}
-
-void QuartzSetRootless(Bool state) {
- DEBUG_LOG("QuartzSetRootless state=%d\n", state);
-
- if(XQuartzIsRootless == state)
- return;
-
- if(state)
- QuartzShowFullscreen(FALSE);
-
- XQuartzIsRootless = state;
-
- xp_disable_update();
-
- /* When in rootless, the menubar is not part of the screen, so we need to update our screens on toggle */
- QuartzUpdateScreens();
-
- if(XQuartzIsRootless) {
- RootlessShowAllWindows();
- } else {
- RootlessHideAllWindows();
- }
-
- X11ApplicationShowHideMenubar(TRUE);
-
- xp_reenable_update();
-
- xp_disable_hot_keys(FALSE);
-}
-
-/*
- * QuartzShow
- * Show the X server on screen. Does nothing if already shown.
- * Calls mode specific screen resume to restore the X clip regions
- * (if needed) and the X server cursor state.
- */
-void QuartzShow(void) {
- int i;
-
- if (XQuartzServerVisible)
- return;
-
- XQuartzServerVisible = TRUE;
- for (i = 0; i < screenInfo.numScreens; i++) {
- if (screenInfo.screens[i]) {
- quartzProcs->ResumeScreen(screenInfo.screens[i]);
- }
- }
-
- if (!XQuartzIsRootless)
- QuartzShowFullscreen(TRUE);
-}
-
-
-/*
- * QuartzHide
- * Remove the X server display from the screen. Does nothing if already
- * hidden. Calls mode specific screen suspend to set X clip regions to
- * prevent drawing (if needed) and restore the Aqua cursor.
- */
-void QuartzHide(void)
-{
- int i;
-
- if (XQuartzServerVisible) {
- for (i = 0; i < screenInfo.numScreens; i++) {
- if (screenInfo.screens[i]) {
- quartzProcs->SuspendScreen(screenInfo.screens[i]);
- }
- }
- }
-
- if(!XQuartzIsRootless)
- QuartzShowFullscreen(FALSE);
- XQuartzServerVisible = FALSE;
-}
-
-
-/*
- * QuartzSetRootClip
- * Enable or disable rendering to the X screen.
- */
-void QuartzSetRootClip(
- BOOL enable)
-{
- int i;
-
- if (!XQuartzServerVisible)
- return;
-
- for (i = 0; i < screenInfo.numScreens; i++) {
- if (screenInfo.screens[i]) {
- SetRootClip(screenInfo.screens[i], enable);
- }
- }
-}
-
-/*
- * QuartzSpaceChanged
- * Unmap offscreen windows, map onscreen windows
- */
-void QuartzSpaceChanged(uint32_t space_id) {
- /* Do something special here, so we don't depend on quartz-wm for spaces to work... */
- DEBUG_LOG("Space Changed (%u) ... do something interesting...\n", space_id);
-}
-
-/*
- * QuartzCopyDisplayIDs
- * Associate an X11 screen with one or more CoreGraphics display IDs by copying
- * the list into a private array. Free the previously copied array, if present.
- */
-void QuartzCopyDisplayIDs(ScreenPtr pScreen,
- int displayCount, CGDirectDisplayID *displayIDs) {
- QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
-
- free(pQuartzScreen->displayIDs);
- if(displayCount) {
- size_t size = displayCount * sizeof(CGDirectDisplayID);
- pQuartzScreen->displayIDs = malloc(size);
- memcpy(pQuartzScreen->displayIDs, displayIDs, size);
- } else {
- pQuartzScreen->displayIDs = NULL;
- }
- pQuartzScreen->displayCount = displayCount;
-}
-
-void NSBeep(void);
-void DDXRingBell(
- int volume, // volume is % of max
- int pitch, // pitch is Hz
- int duration) // duration is milliseconds
-{
- if (volume)
- NSBeep();
-}
+/*
+ *
+ * Quartz-specific support for the Darwin X Server
+ *
+ * Copyright (c) 2001-2004 Greg Parker and 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, 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.
+ */
+
+#include "sanitizedCarbon.h"
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "quartzCommon.h"
+#include "quartzRandR.h"
+#include "inputstr.h"
+#include "quartz.h"
+#include "darwin.h"
+#include "darwinEvents.h"
+#include "pseudoramiX.h"
+#define _APPLEWM_SERVER_
+#include "applewmExt.h"
+
+#include "X11Application.h"
+
+#include <X11/extensions/applewmconst.h>
+
+// X headers
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "colormapst.h"
+#include "globals.h"
+#include "mi.h"
+
+// System headers
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <IOKit/pwr_mgt/IOPMLib.h>
+#include <libkern/OSAtomic.h>
+#include <signal.h>
+
+#include <rootlessCommon.h>
+#include <Xplugin.h>
+
+DevPrivateKeyRec quartzScreenKeyRec;
+int aquaMenuBarHeight = 0;
+QuartzModeProcsPtr quartzProcs = NULL;
+const char *quartzOpenGLBundle = NULL;
+
+Bool XQuartzFullscreenDisableHotkeys = TRUE;
+Bool XQuartzOptionSendsAlt = FALSE;
+Bool XQuartzEnableKeyEquivalents = TRUE;
+Bool XQuartzFullscreenVisible = FALSE;
+Bool XQuartzRootlessDefault = TRUE;
+Bool XQuartzIsRootless = TRUE;
+Bool XQuartzServerVisible = FALSE;
+Bool XQuartzFullscreenMenu = FALSE;
+
+int32_t XQuartzShieldingWindowLevel = 0;
+
+/*
+===========================================================================
+
+ Screen functions
+
+===========================================================================
+*/
+
+/*
+ * QuartzAddScreen
+ * Do mode dependent initialization of each screen for Quartz.
+ */
+Bool QuartzAddScreen(
+ int index,
+ ScreenPtr pScreen)
+{
+ // allocate space for private per screen Quartz specific storage
+ QuartzScreenPtr displayInfo = calloc(sizeof(QuartzScreenRec), 1);
+
+ // QUARTZ_PRIV(pScreen) = displayInfo;
+ dixSetPrivate(&pScreen->devPrivates, quartzScreenKey, displayInfo);
+
+ // do Quartz mode specific initialization
+ return quartzProcs->AddScreen(index, pScreen);
+}
+
+
+/*
+ * QuartzSetupScreen
+ * Finalize mode specific setup of each screen.
+ */
+Bool QuartzSetupScreen(
+ int index,
+ ScreenPtr pScreen)
+{
+ // do Quartz mode specific setup
+ if (! quartzProcs->SetupScreen(index, pScreen))
+ return FALSE;
+
+ // setup cursor support
+ if (! quartzProcs->InitCursor(pScreen))
+ return FALSE;
+
+#if defined(RANDR)
+ if(!QuartzRandRInit(pScreen)) {
+ DEBUG_LOG("Failed to init RandR extension.\n");
+ return FALSE;
+ }
+#endif
+
+ return TRUE;
+}
+
+
+/*
+ * QuartzInitOutput
+ * Quartz display initialization.
+ */
+void QuartzInitOutput(
+ int argc,
+ char **argv )
+{
+ /* For XQuartz, we want to just use the default signal handler to work better with CrashTracer */
+ signal(SIGSEGV, SIG_DFL);
+ signal(SIGILL, SIG_DFL);
+#ifdef SIGEMT
+ signal(SIGEMT, SIG_DFL);
+#endif
+ signal(SIGFPE, SIG_DFL);
+#ifdef SIGBUS
+ signal(SIGBUS, SIG_DFL);
+#endif
+#ifdef SIGSYS
+ signal(SIGSYS, SIG_DFL);
+#endif
+#ifdef SIGXCPU
+ signal(SIGXCPU, SIG_DFL);
+#endif
+#ifdef SIGXFSZ
+ signal(SIGXFSZ, SIG_DFL);
+#endif
+
+ if (!RegisterBlockAndWakeupHandlers(QuartzBlockHandler,
+ QuartzWakeupHandler,
+ NULL))
+ {
+ FatalError("Could not register block and wakeup handlers.");
+ }
+
+ if (!dixRegisterPrivateKey(&quartzScreenKeyRec, PRIVATE_SCREEN, 0))
+ FatalError("Failed to alloc quartz screen private.\n");
+
+ // Do display mode specific initialization
+ quartzProcs->DisplayInit();
+}
+
+
+/*
+ * QuartzInitInput
+ * Inform the main thread the X server is ready to handle events.
+ */
+void QuartzInitInput(
+ int argc,
+ char **argv )
+{
+ X11ApplicationSetCanQuit(0);
+ X11ApplicationServerReady();
+ // Do final display mode specific initialization before handling events
+ if (quartzProcs->InitInput)
+ quartzProcs->InitInput(argc, argv);
+}
+
+
+void QuartzUpdateScreens(void) {
+ ScreenPtr pScreen;
+ WindowPtr pRoot;
+ int x, y, width, height, sx, sy;
+ xEvent e;
+ BoxRec bounds;
+
+ if (noPseudoramiXExtension || screenInfo.numScreens != 1)
+ {
+ /* FIXME: if not using Xinerama, we have multiple screens, and
+ to do this properly may need to add or remove screens. Which
+ isn't possible. So don't do anything. Another reason why
+ we default to running with Xinerama. */
+
+ return;
+ }
+
+ pScreen = screenInfo.screens[0];
+
+ PseudoramiXResetScreens();
+ quartzProcs->AddPseudoramiXScreens(&x, &y, &width, &height, pScreen);
+
+ pScreen->x = x;
+ pScreen->y = y;
+ pScreen->mmWidth = pScreen->mmWidth * ((double) width / pScreen->width);
+ pScreen->mmHeight = pScreen->mmHeight * ((double) height / pScreen->height);
+ pScreen->width = width;
+ pScreen->height = height;
+
+ DarwinAdjustScreenOrigins(&screenInfo);
+
+ /* DarwinAdjustScreenOrigins or UpdateScreen may change pScreen->x/y,
+ * so use it rather than x/y
+ */
+ sx = pScreen->x + darwinMainScreenX;
+ sy = pScreen->y + darwinMainScreenY;
+
+ /* Adjust the root window. */
+ pRoot = pScreen->root;
+ AppleWMSetScreenOrigin(pRoot);
+ pScreen->ResizeWindow(pRoot, x - sx, y - sy, width, height, NULL);
+
+ /* <rdar://problem/7770779> pointer events are clipped to old display region after display reconfiguration
+ * http://xquartz.macosforge.org/trac/ticket/346
+ */
+ bounds.x1 = 0;
+ bounds.x2 = width;
+ bounds.y1 = 0;
+ bounds.y2 = height;
+ pScreen->ConstrainCursor(inputInfo.pointer, pScreen, &bounds);
+ inputInfo.pointer->spriteInfo->sprite->physLimits = bounds;
+ inputInfo.pointer->spriteInfo->sprite->hotLimits = bounds;
+
+ DEBUG_LOG("Root Window: %dx%d @ (%d, %d) darwinMainScreen (%d, %d) xy (%d, %d) dixScreenOrigins (%d, %d)\n", width, height, x - sx, y - sy, darwinMainScreenX, darwinMainScreenY, x, y, pScreen->x, pScreen->y);
+
+ /* Send an event for the root reconfigure */
+ e.u.u.type = ConfigureNotify;
+ e.u.configureNotify.window = pRoot->drawable.id;
+ e.u.configureNotify.aboveSibling = None;
+ e.u.configureNotify.x = x - sx;
+ e.u.configureNotify.y = y - sy;
+ e.u.configureNotify.width = width;
+ e.u.configureNotify.height = height;
+ e.u.configureNotify.borderWidth = wBorderWidth(pRoot);
+ e.u.configureNotify.override = pRoot->overrideRedirect;
+ DeliverEvents(pRoot, &e, 1, NullWindow);
+
+ quartzProcs->UpdateScreen(pScreen);
+
+ /* miPaintWindow needs to be called after RootlessUpdateScreenPixmap (from xprUpdateScreen) */
+ miPaintWindow(pRoot, &pRoot->borderClip, PW_BACKGROUND);
+
+ /* Tell RandR about the new size, so new connections get the correct info */
+ RRScreenSizeNotify(pScreen);
+}
+
+static void pokeActivityCallback(CFRunLoopTimerRef timer, void *info) {
+ UpdateSystemActivity(OverallAct);
+}
+
+static void QuartzScreenSaver(int state) {
+ static CFRunLoopTimerRef pokeActivityTimer = NULL;
+ static CFRunLoopTimerContext pokeActivityContext = { 0, NULL, NULL, NULL, NULL };
+ static OSSpinLock pokeActivitySpinLock = OS_SPINLOCK_INIT;
+
+ OSSpinLockLock(&pokeActivitySpinLock);
+
+ if(state) {
+ if(pokeActivityTimer == NULL)
+ goto QuartzScreenSaverEnd;
+
+ CFRunLoopTimerInvalidate(pokeActivityTimer);
+ CFRelease(pokeActivityTimer);
+ pokeActivityTimer = NULL;
+ } else {
+ if(pokeActivityTimer != NULL)
+ goto QuartzScreenSaverEnd;
+
+ pokeActivityTimer = CFRunLoopTimerCreate(NULL, CFAbsoluteTimeGetCurrent(), 30, 0, 0, pokeActivityCallback, &pokeActivityContext);
+ if(pokeActivityTimer == NULL) {
+ ErrorF("Unable to create pokeActivityTimer.\n");
+ goto QuartzScreenSaverEnd;
+ }
+
+ CFRunLoopAddTimer(CFRunLoopGetMain(), pokeActivityTimer, kCFRunLoopCommonModes);
+ }
+QuartzScreenSaverEnd:
+ OSSpinLockUnlock(&pokeActivitySpinLock);
+}
+
+void QuartzShowFullscreen(int state) {
+ int i;
+
+ DEBUG_LOG("QuartzShowFullscreen: state=%d\n", state);
+
+ if(XQuartzIsRootless) {
+ ErrorF("QuartzShowFullscreen called while in rootless mode.\n");
+ return;
+ }
+
+ QuartzScreenSaver(!state);
+
+ if(XQuartzFullscreenVisible == state)
+ return;
+
+ XQuartzFullscreenVisible = state;
+
+ xp_disable_update ();
+
+ if (!XQuartzFullscreenVisible)
+ RootlessHideAllWindows();
+
+ RootlessUpdateRooted(XQuartzFullscreenVisible);
+
+ if (XQuartzFullscreenVisible) {
+ RootlessShowAllWindows ();
+ for (i=0; i < screenInfo.numScreens; i++) {
+ ScreenPtr pScreen = screenInfo.screens[i];
+ RootlessRepositionWindows(pScreen);
+ // JH: I don't think this is necessary, but keeping it here as a reminder
+ //RootlessUpdateScreenPixmap(pScreen);
+ }
+ }
+
+ /* Somehow the menubar manages to interfere with our event stream
+ * in fullscreen mode, even though it's not visible.
+ */
+ X11ApplicationShowHideMenubar(!XQuartzFullscreenVisible);
+
+ xp_reenable_update ();
+
+ if (XQuartzFullscreenDisableHotkeys)
+ xp_disable_hot_keys(XQuartzFullscreenVisible);
+}
+
+void QuartzSetRootless(Bool state) {
+ DEBUG_LOG("QuartzSetRootless state=%d\n", state);
+
+ if(XQuartzIsRootless == state)
+ return;
+
+ if(state)
+ QuartzShowFullscreen(FALSE);
+
+ XQuartzIsRootless = state;
+
+ xp_disable_update();
+
+ /* When in rootless, the menubar is not part of the screen, so we need to update our screens on toggle */
+ QuartzUpdateScreens();
+
+ if(XQuartzIsRootless) {
+ RootlessShowAllWindows();
+ } else {
+ RootlessHideAllWindows();
+ }
+
+ X11ApplicationShowHideMenubar(TRUE);
+
+ xp_reenable_update();
+
+ xp_disable_hot_keys(FALSE);
+}
+
+/*
+ * QuartzShow
+ * Show the X server on screen. Does nothing if already shown.
+ * Calls mode specific screen resume to restore the X clip regions
+ * (if needed) and the X server cursor state.
+ */
+void QuartzShow(void) {
+ int i;
+
+ if (XQuartzServerVisible)
+ return;
+
+ XQuartzServerVisible = TRUE;
+ for (i = 0; i < screenInfo.numScreens; i++) {
+ if (screenInfo.screens[i]) {
+ quartzProcs->ResumeScreen(screenInfo.screens[i]);
+ }
+ }
+
+ if (!XQuartzIsRootless)
+ QuartzShowFullscreen(TRUE);
+}
+
+
+/*
+ * QuartzHide
+ * Remove the X server display from the screen. Does nothing if already
+ * hidden. Calls mode specific screen suspend to set X clip regions to
+ * prevent drawing (if needed) and restore the Aqua cursor.
+ */
+void QuartzHide(void)
+{
+ int i;
+
+ if (XQuartzServerVisible) {
+ for (i = 0; i < screenInfo.numScreens; i++) {
+ if (screenInfo.screens[i]) {
+ quartzProcs->SuspendScreen(screenInfo.screens[i]);
+ }
+ }
+ }
+
+ if(!XQuartzIsRootless)
+ QuartzShowFullscreen(FALSE);
+ XQuartzServerVisible = FALSE;
+}
+
+
+/*
+ * QuartzSetRootClip
+ * Enable or disable rendering to the X screen.
+ */
+void QuartzSetRootClip(
+ BOOL enable)
+{
+ int i;
+
+ if (!XQuartzServerVisible)
+ return;
+
+ for (i = 0; i < screenInfo.numScreens; i++) {
+ if (screenInfo.screens[i]) {
+ SetRootClip(screenInfo.screens[i], enable);
+ }
+ }
+}
+
+/*
+ * QuartzSpaceChanged
+ * Unmap offscreen windows, map onscreen windows
+ */
+void QuartzSpaceChanged(uint32_t space_id) {
+ /* Do something special here, so we don't depend on quartz-wm for spaces to work... */
+ DEBUG_LOG("Space Changed (%u) ... do something interesting...\n", space_id);
+}
+
+/*
+ * QuartzCopyDisplayIDs
+ * Associate an X11 screen with one or more CoreGraphics display IDs by copying
+ * the list into a private array. Free the previously copied array, if present.
+ */
+void QuartzCopyDisplayIDs(ScreenPtr pScreen,
+ int displayCount, CGDirectDisplayID *displayIDs) {
+ QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
+
+ free(pQuartzScreen->displayIDs);
+ if(displayCount) {
+ size_t size = displayCount * sizeof(CGDirectDisplayID);
+ pQuartzScreen->displayIDs = malloc(size);
+ memcpy(pQuartzScreen->displayIDs, displayIDs, size);
+ } else {
+ pQuartzScreen->displayIDs = NULL;
+ }
+ pQuartzScreen->displayCount = displayCount;
+}
+
+void NSBeep(void);
+void DDXRingBell(
+ int volume, // volume is % of max
+ int pitch, // pitch is Hz
+ int duration) // duration is milliseconds
+{
+ if (volume)
+ NSBeep();
+}
diff --git a/xorg-server/hw/xquartz/quartz.h b/xorg-server/hw/xquartz/quartz.h
index 7fa6d431c..0a9c47a6b 100644
--- a/xorg-server/hw/xquartz/quartz.h
+++ b/xorg-server/hw/xquartz/quartz.h
@@ -1,147 +1,147 @@
-/*
- * quartz.h
- *
- * External interface of the Quartz display modes seen by the generic, mode
- * independent parts of the Darwin X server.
- *
- * Copyright (c) 2001-2003 Greg Parker and 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, 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.
- */
-
-#ifndef _QUARTZ_H
-#define _QUARTZ_H
-
-#include "screenint.h"
-#include "window.h"
-#include "pixmap.h"
-
-/*------------------------------------------
- Quartz display mode function types
- ------------------------------------------*/
-
-/*
- * Display mode initialization
- */
-typedef void (*DisplayInitProc)(void);
-typedef Bool (*AddScreenProc)(int index, ScreenPtr pScreen);
-typedef Bool (*SetupScreenProc)(int index, ScreenPtr pScreen);
-typedef void (*InitInputProc)(int argc, char **argv);
-
-/*
- * Cursor functions
- */
-typedef Bool (*InitCursorProc)(ScreenPtr pScreen);
-
-/*
- * Suspend and resume X11 activity
- */
-typedef void (*SuspendScreenProc)(ScreenPtr pScreen);
-typedef void (*ResumeScreenProc)(ScreenPtr pScreen);
-
-/*
- * Screen state change support
- */
-typedef void (*AddPseudoramiXScreensProc)
- (int *x, int *y, int *width, int *height, ScreenPtr pScreen);
-typedef void (*UpdateScreenProc)(ScreenPtr pScreen);
-
-/*
- * Rootless helper functions
- */
-typedef Bool (*IsX11WindowProc)(int windowNumber);
-typedef void (*HideWindowsProc)(Bool hide);
-
-/*
- * Rootless functions for optional export to GLX layer
- */
-typedef void * (*FrameForWindowProc)(WindowPtr pWin, Bool create);
-typedef WindowPtr (*TopLevelParentProc)(WindowPtr pWindow);
-typedef Bool (*CreateSurfaceProc)
- (ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable,
- unsigned int client_id, unsigned int *surface_id,
- unsigned int key[2], void (*notify) (void *arg, void *data),
- void *notify_data);
-typedef Bool (*DestroySurfaceProc)
- (ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable,
- void (*notify) (void *arg, void *data), void *notify_data);
-
-/*
- * Quartz display mode function list
- */
-typedef struct _QuartzModeProcs {
- DisplayInitProc DisplayInit;
- AddScreenProc AddScreen;
- SetupScreenProc SetupScreen;
- InitInputProc InitInput;
-
- InitCursorProc InitCursor;
-
- SuspendScreenProc SuspendScreen;
- ResumeScreenProc ResumeScreen;
-
- AddPseudoramiXScreensProc AddPseudoramiXScreens;
- UpdateScreenProc UpdateScreen;
-
- IsX11WindowProc IsX11Window;
- HideWindowsProc HideWindows;
-
- FrameForWindowProc FrameForWindow;
- TopLevelParentProc TopLevelParent;
- CreateSurfaceProc CreateSurface;
- DestroySurfaceProc DestroySurface;
-} QuartzModeProcsRec, *QuartzModeProcsPtr;
-
-extern QuartzModeProcsPtr quartzProcs;
-
-extern Bool XQuartzFullscreenVisible; /* Are the windows visible (predicated on !rootless) */
-extern Bool XQuartzServerVisible; /* Is the server visible ... TODO: Refactor to "active" */
-extern Bool XQuartzEnableKeyEquivalents;
-extern Bool XQuartzRootlessDefault; /* Is our default mode rootless? */
-extern Bool XQuartzIsRootless; /* Is our current mode rootless (or FS)? */
-extern Bool XQuartzFullscreenMenu; /* Show the menu bar (autohide) while in FS */
-extern Bool XQuartzFullscreenDisableHotkeys;
-extern Bool XQuartzOptionSendsAlt; /* Alt or Mode_switch? */
-
-extern int32_t XQuartzShieldingWindowLevel; /* CGShieldingWindowLevel() or 0 */
-
-Bool QuartzAddScreen(int index, ScreenPtr pScreen);
-Bool QuartzSetupScreen(int index, ScreenPtr pScreen);
-void QuartzInitOutput(int argc,char **argv);
-void QuartzInitInput(int argc, char **argv);
-void QuartzInitServer(int argc, char **argv, char **envp);
-void QuartzGiveUp(void);
-void QuartzProcessEvent(xEvent *xe);
-void QuartzUpdateScreens(void);
-
-void QuartzShow(void);
-void QuartzHide(void);
-void QuartzSetRootClip(BOOL enable);
-void QuartzSpaceChanged(uint32_t space_id);
-
-void QuartzSetRootless(Bool state);
-void QuartzShowFullscreen(Bool state);
-
-int server_main(int argc, char **argv, char **envp);
-#endif
+/*
+ * quartz.h
+ *
+ * External interface of the Quartz display modes seen by the generic, mode
+ * independent parts of the Darwin X server.
+ *
+ * Copyright (c) 2001-2003 Greg Parker and 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, 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.
+ */
+
+#ifndef _QUARTZ_H
+#define _QUARTZ_H
+
+#include "screenint.h"
+#include "window.h"
+#include "pixmap.h"
+
+/*------------------------------------------
+ Quartz display mode function types
+ ------------------------------------------*/
+
+/*
+ * Display mode initialization
+ */
+typedef void (*DisplayInitProc)(void);
+typedef Bool (*AddScreenProc)(int index, ScreenPtr pScreen);
+typedef Bool (*SetupScreenProc)(int index, ScreenPtr pScreen);
+typedef void (*InitInputProc)(int argc, char **argv);
+
+/*
+ * Cursor functions
+ */
+typedef Bool (*InitCursorProc)(ScreenPtr pScreen);
+
+/*
+ * Suspend and resume X11 activity
+ */
+typedef void (*SuspendScreenProc)(ScreenPtr pScreen);
+typedef void (*ResumeScreenProc)(ScreenPtr pScreen);
+
+/*
+ * Screen state change support
+ */
+typedef void (*AddPseudoramiXScreensProc)
+ (int *x, int *y, int *width, int *height, ScreenPtr pScreen);
+typedef void (*UpdateScreenProc)(ScreenPtr pScreen);
+
+/*
+ * Rootless helper functions
+ */
+typedef Bool (*IsX11WindowProc)(int windowNumber);
+typedef void (*HideWindowsProc)(Bool hide);
+
+/*
+ * Rootless functions for optional export to GLX layer
+ */
+typedef void * (*FrameForWindowProc)(WindowPtr pWin, Bool create);
+typedef WindowPtr (*TopLevelParentProc)(WindowPtr pWindow);
+typedef Bool (*CreateSurfaceProc)
+ (ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable,
+ unsigned int client_id, unsigned int *surface_id,
+ unsigned int key[2], void (*notify) (void *arg, void *data),
+ void *notify_data);
+typedef Bool (*DestroySurfaceProc)
+ (ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable,
+ void (*notify) (void *arg, void *data), void *notify_data);
+
+/*
+ * Quartz display mode function list
+ */
+typedef struct _QuartzModeProcs {
+ DisplayInitProc DisplayInit;
+ AddScreenProc AddScreen;
+ SetupScreenProc SetupScreen;
+ InitInputProc InitInput;
+
+ InitCursorProc InitCursor;
+
+ SuspendScreenProc SuspendScreen;
+ ResumeScreenProc ResumeScreen;
+
+ AddPseudoramiXScreensProc AddPseudoramiXScreens;
+ UpdateScreenProc UpdateScreen;
+
+ IsX11WindowProc IsX11Window;
+ HideWindowsProc HideWindows;
+
+ FrameForWindowProc FrameForWindow;
+ TopLevelParentProc TopLevelParent;
+ CreateSurfaceProc CreateSurface;
+ DestroySurfaceProc DestroySurface;
+} QuartzModeProcsRec, *QuartzModeProcsPtr;
+
+extern QuartzModeProcsPtr quartzProcs;
+
+extern Bool XQuartzFullscreenVisible; /* Are the windows visible (predicated on !rootless) */
+extern Bool XQuartzServerVisible; /* Is the server visible ... TODO: Refactor to "active" */
+extern Bool XQuartzEnableKeyEquivalents;
+extern Bool XQuartzRootlessDefault; /* Is our default mode rootless? */
+extern Bool XQuartzIsRootless; /* Is our current mode rootless (or FS)? */
+extern Bool XQuartzFullscreenMenu; /* Show the menu bar (autohide) while in FS */
+extern Bool XQuartzFullscreenDisableHotkeys;
+extern Bool XQuartzOptionSendsAlt; /* Alt or Mode_switch? */
+
+extern int32_t XQuartzShieldingWindowLevel; /* CGShieldingWindowLevel() or 0 */
+
+Bool QuartzAddScreen(int index, ScreenPtr pScreen);
+Bool QuartzSetupScreen(int index, ScreenPtr pScreen);
+void QuartzInitOutput(int argc,char **argv);
+void QuartzInitInput(int argc, char **argv);
+void QuartzInitServer(int argc, char **argv, char **envp);
+void QuartzGiveUp(void);
+void QuartzProcessEvent(xEvent *xe);
+void QuartzUpdateScreens(void);
+
+void QuartzShow(void);
+void QuartzHide(void);
+void QuartzSetRootClip(BOOL enable);
+void QuartzSpaceChanged(uint32_t space_id);
+
+void QuartzSetRootless(Bool state);
+void QuartzShowFullscreen(Bool state);
+
+int server_main(int argc, char **argv, char **envp);
+#endif
diff --git a/xorg-server/hw/xquartz/quartzKeyboard.c b/xorg-server/hw/xquartz/quartzKeyboard.c
index 4db03a8de..e682f08b6 100644
--- a/xorg-server/hw/xquartz/quartzKeyboard.c
+++ b/xorg-server/hw/xquartz/quartzKeyboard.c
@@ -1,868 +1,868 @@
-/*
- quartzKeyboard.c: Keyboard support for Xquartz
-
- Copyright (c) 2003-2008 Apple Inc.
- Copyright (c) 2001-2004 Torrey T. Lyons. All Rights Reserved.
- Copyright 2004 Kaleb S. KEITHLEY. All Rights Reserved.
-
- Copyright (C) 1999,2000 by Eric Sunshine <sunshine@sunshineco.com>
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
- NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#include "sanitizedCarbon.h"
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#define HACK_MISSING 1
-#define HACK_KEYPAD 1
-#define HACK_BLACKLIST 1
-
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <AvailabilityMacros.h>
-
-#include "quartz.h"
-#include "darwin.h"
-#include "darwinEvents.h"
-
-#include "quartzKeyboard.h"
-
-#include "X11Application.h"
-
-#include <assert.h>
-#include <pthread.h>
-
-#include "xkbsrv.h"
-#include "exevents.h"
-#include "X11/keysym.h"
-#include "keysym2ucs.h"
-
-extern void
-CopyKeyClass(DeviceIntPtr device, DeviceIntPtr master);
-
-enum {
- MOD_COMMAND = 256,
- MOD_SHIFT = 512,
- MOD_OPTION = 2048,
- MOD_CONTROL = 4096,
-};
-
-#define UKEYSYM(u) ((u) | 0x01000000)
-
-#if HACK_MISSING
-/* Table of keycode->keysym mappings we use to fallback on for important
- keys that are often not in the Unicode mapping. */
-
-const static struct {
- unsigned short keycode;
- KeySym keysym;
-} known_keys[] = {
- {55, XK_Meta_L},
- {56, XK_Shift_L},
- {57, XK_Caps_Lock},
- {58, XK_Alt_L},
- {59, XK_Control_L},
-
- {60, XK_Shift_R},
- {61, XK_Alt_R},
- {62, XK_Control_R},
- {63, XK_Meta_R},
-
- {122, XK_F1},
- {120, XK_F2},
- {99, XK_F3},
- {118, XK_F4},
- {96, XK_F5},
- {97, XK_F6},
- {98, XK_F7},
- {100, XK_F8},
- {101, XK_F9},
- {109, XK_F10},
- {103, XK_F11},
- {111, XK_F12},
- {105, XK_F13},
- {107, XK_F14},
- {113, XK_F15},
-};
-#endif
-
-#if HACK_KEYPAD
-/* Table of keycode->old,new-keysym mappings we use to fixup the numeric
- keypad entries. */
-
-const static struct {
- unsigned short keycode;
- KeySym normal, keypad;
-} known_numeric_keys[] = {
- {65, XK_period, XK_KP_Decimal},
- {67, XK_asterisk, XK_KP_Multiply},
- {69, XK_plus, XK_KP_Add},
- {75, XK_slash, XK_KP_Divide},
- {76, 0x01000003, XK_KP_Enter},
- {78, XK_minus, XK_KP_Subtract},
- {81, XK_equal, XK_KP_Equal},
- {82, XK_0, XK_KP_0},
- {83, XK_1, XK_KP_1},
- {84, XK_2, XK_KP_2},
- {85, XK_3, XK_KP_3},
- {86, XK_4, XK_KP_4},
- {87, XK_5, XK_KP_5},
- {88, XK_6, XK_KP_6},
- {89, XK_7, XK_KP_7},
- {91, XK_8, XK_KP_8},
- {92, XK_9, XK_KP_9},
-};
-#endif
-
-#if HACK_BLACKLIST
-/* <rdar://problem/7824370> wine notepad produces wrong characters on shift+arrow
- * http://xquartz.macosforge.org/trac/ticket/295
- * http://developer.apple.com/legacy/mac/library/documentation/mac/Text/Text-579.html
- *
- * legacy Mac keycodes for arrow keys that shift-modify to math symbols
- */
-const static unsigned short keycode_blacklist[] = {66, 70, 72, 77};
-#endif
-
-/* Table mapping normal keysyms to their dead equivalents.
- FIXME: all the unicode keysyms (apart from circumflex) were guessed. */
-
-const static struct {
- KeySym normal, dead;
-} dead_keys[] = {
- {XK_grave, XK_dead_grave},
- {XK_apostrophe, XK_dead_acute}, /* US:"=" on a Czech keyboard */
- {XK_acute, XK_dead_acute},
- {UKEYSYM (0x384), XK_dead_acute}, /* US:";" on a Greek keyboard */
-// {XK_Greek_accentdieresis, XK_dead_diaeresis}, /* US:"opt+;" on a Greek keyboard ... replace with dead_accentdieresis if there is one */
- {XK_asciicircum, XK_dead_circumflex},
- {UKEYSYM (0x2c6), XK_dead_circumflex}, /* MODIFIER LETTER CIRCUMFLEX ACCENT */
- {XK_asciitilde, XK_dead_tilde},
- {UKEYSYM (0x2dc), XK_dead_tilde}, /* SMALL TILDE */
- {XK_macron, XK_dead_macron},
- {XK_breve, XK_dead_breve},
- {XK_abovedot, XK_dead_abovedot},
- {XK_diaeresis, XK_dead_diaeresis},
- {UKEYSYM (0x2da), XK_dead_abovering}, /* DOT ABOVE */
- {XK_doubleacute, XK_dead_doubleacute},
- {XK_caron, XK_dead_caron},
- {XK_cedilla, XK_dead_cedilla},
- {XK_ogonek, XK_dead_ogonek},
- {UKEYSYM (0x269), XK_dead_iota}, /* LATIN SMALL LETTER IOTA */
- {UKEYSYM (0x2ec), XK_dead_voiced_sound}, /* MODIFIER LETTER VOICING */
-/* {XK_semivoiced_sound, XK_dead_semivoiced_sound}, */
- {UKEYSYM (0x323), XK_dead_belowdot}, /* COMBINING DOT BELOW */
- {UKEYSYM (0x309), XK_dead_hook}, /* COMBINING HOOK ABOVE */
- {UKEYSYM (0x31b), XK_dead_horn}, /* COMBINING HORN */
-};
-
-typedef struct darwinKeyboardInfo_struct {
- CARD8 modMap[MAP_LENGTH];
- KeySym keyMap[MAP_LENGTH * GLYPHS_PER_KEY];
- unsigned char modifierKeycodes[32][2];
-} darwinKeyboardInfo;
-
-darwinKeyboardInfo keyInfo;
-pthread_mutex_t keyInfo_mutex = PTHREAD_MUTEX_INITIALIZER;
-
-static void DarwinChangeKeyboardControl(DeviceIntPtr device, KeybdCtrl *ctrl) {
- // FIXME: to be implemented
- // keyclick, bell volume / pitch, autorepead, LED's
-}
-
-//-----------------------------------------------------------------------------
-// Utility functions to help parse Darwin keymap
-//-----------------------------------------------------------------------------
-
-/*
- * DarwinBuildModifierMaps
- * Use the keyMap field of keyboard info structure to populate
- * the modMap and modifierKeycodes fields.
- */
-static void DarwinBuildModifierMaps(darwinKeyboardInfo *info) {
- int i;
- KeySym *k;
-
- memset(info->modMap, NoSymbol, sizeof(info->modMap));
- memset(info->modifierKeycodes, 0, sizeof(info->modifierKeycodes));
-
- for (i = 0; i < NUM_KEYCODES; i++) {
- k = info->keyMap + i * GLYPHS_PER_KEY;
-
- switch (*k) {
- case XK_Shift_L:
- info->modifierKeycodes[NX_MODIFIERKEY_SHIFT][0] = i;
- info->modMap[MIN_KEYCODE + i] = ShiftMask;
- break;
-
- case XK_Shift_R:
-#ifdef NX_MODIFIERKEY_RSHIFT
- info->modifierKeycodes[NX_MODIFIERKEY_RSHIFT][0] = i;
-#else
- info->modifierKeycodes[NX_MODIFIERKEY_SHIFT][0] = i;
-#endif
- info->modMap[MIN_KEYCODE + i] = ShiftMask;
- break;
-
- case XK_Control_L:
- info->modifierKeycodes[NX_MODIFIERKEY_CONTROL][0] = i;
- info->modMap[MIN_KEYCODE + i] = ControlMask;
- break;
-
- case XK_Control_R:
-#ifdef NX_MODIFIERKEY_RCONTROL
- info->modifierKeycodes[NX_MODIFIERKEY_RCONTROL][0] = i;
-#else
- info->modifierKeycodes[NX_MODIFIERKEY_CONTROL][0] = i;
-#endif
- info->modMap[MIN_KEYCODE + i] = ControlMask;
- break;
-
- case XK_Caps_Lock:
- info->modifierKeycodes[NX_MODIFIERKEY_ALPHALOCK][0] = i;
- info->modMap[MIN_KEYCODE + i] = LockMask;
- break;
-
- case XK_Alt_L:
- info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i;
- info->modMap[MIN_KEYCODE + i] = Mod1Mask;
- if(!XQuartzOptionSendsAlt)
- *k = XK_Mode_switch; // Yes, this is ugly. This needs to be cleaned up when we integrate quartzKeyboard with this code and refactor.
- break;
-
- case XK_Alt_R:
-#ifdef NX_MODIFIERKEY_RALTERNATE
- info->modifierKeycodes[NX_MODIFIERKEY_RALTERNATE][0] = i;
-#else
- info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i;
-#endif
- if(!XQuartzOptionSendsAlt)
- *k = XK_Mode_switch; // Yes, this is ugly. This needs to be cleaned up when we integrate quartzKeyboard with this code and refactor.
- info->modMap[MIN_KEYCODE + i] = Mod1Mask;
- break;
-
- case XK_Mode_switch:
- ErrorF("DarwinBuildModifierMaps: XK_Mode_switch encountered, unable to determine side.\n");
- info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i;
-#ifdef NX_MODIFIERKEY_RALTERNATE
- info->modifierKeycodes[NX_MODIFIERKEY_RALTERNATE][0] = i;
-#endif
- info->modMap[MIN_KEYCODE + i] = Mod1Mask;
- break;
-
- case XK_Meta_L:
- info->modifierKeycodes[NX_MODIFIERKEY_COMMAND][0] = i;
- info->modMap[MIN_KEYCODE + i] = Mod2Mask;
- break;
-
- case XK_Meta_R:
-#ifdef NX_MODIFIERKEY_RCOMMAND
- info->modifierKeycodes[NX_MODIFIERKEY_RCOMMAND][0] = i;
-#else
- info->modifierKeycodes[NX_MODIFIERKEY_COMMAND][0] = i;
-#endif
- info->modMap[MIN_KEYCODE + i] = Mod2Mask;
- break;
-
- case XK_Num_Lock:
- info->modMap[MIN_KEYCODE + i] = Mod3Mask;
- break;
- }
- }
-}
-
-/*
- * DarwinKeyboardInit
- * Get the Darwin keyboard map and compute an equivalent
- * X keyboard map and modifier map. Set the new keyboard
- * device structure.
- */
-void DarwinKeyboardInit(DeviceIntPtr pDev) {
- // Open a shared connection to the HID System.
- // Note that the Event Status Driver is really just a wrapper
- // for a kIOHIDParamConnectType connection.
- assert(darwinParamConnect = NXOpenEventStatus());
-
- InitKeyboardDeviceStruct(pDev, NULL, NULL, DarwinChangeKeyboardControl);
-
- DarwinKeyboardReloadHandler();
-
- CopyKeyClass(pDev, inputInfo.keyboard);
-}
-
-/* Set the repeat rates based on global preferences and keycodes for modifiers.
- * Precondition: Has the keyInfo_mutex lock.
- */
-static void DarwinKeyboardSetRepeat(DeviceIntPtr pDev, int initialKeyRepeatValue, int keyRepeatValue) {
- if(initialKeyRepeatValue == 300000) { // off
- /* Turn off repeats globally */
- XkbSetRepeatKeys(pDev, -1, AutoRepeatModeOff);
- } else {
- int i;
- XkbControlsPtr ctrl;
- XkbControlsRec old;
-
- /* Turn on repeats globally */
- XkbSetRepeatKeys(pDev, -1, AutoRepeatModeOn);
-
- /* Setup the bit mask for individual key repeats */
- ctrl = pDev->key->xkbInfo->desc->ctrls;
- old= *ctrl;
-
- ctrl->repeat_delay = initialKeyRepeatValue * 15;
- ctrl->repeat_interval = keyRepeatValue * 15;
-
- /* Turn off key-repeat for modifier keys, on for others */
- /* First set them all on */
- for(i=0; i < XkbPerKeyBitArraySize; i++)
- ctrl->per_key_repeat[i] = -1;
-
- /* Now turn off the modifiers */
- for(i=0; i < 32; i++) {
- unsigned char keycode;
-
- keycode = keyInfo.modifierKeycodes[i][0];
- if(keycode)
- ClearBit(ctrl->per_key_repeat, keycode + MIN_KEYCODE);
-
- keycode = keyInfo.modifierKeycodes[i][1];
- if(keycode)
- ClearBit(ctrl->per_key_repeat, keycode + MIN_KEYCODE);
- }
-
- /* Hurray for data duplication */
- if (pDev->kbdfeed)
- memcpy(pDev->kbdfeed->ctrl.autoRepeats, ctrl->per_key_repeat, XkbPerKeyBitArraySize);
-
- //ErrorF("per_key_repeat =\n");
- //for(i=0; i < XkbPerKeyBitArraySize; i++)
- // ErrorF("%02x%s", ctrl->per_key_repeat[i], (i + 1) & 7 ? "" : "\n");
-
- /* And now we notify the puppies about the changes */
- XkbDDXChangeControls(pDev, &old, ctrl);
- }
-}
-
-void DarwinKeyboardReloadHandler(void) {
- KeySymsRec keySyms;
- CFIndex initialKeyRepeatValue, keyRepeatValue;
- BOOL ok;
- DeviceIntPtr pDev;
- const char *xmodmap = PROJECTROOT "/bin/xmodmap";
- const char *sysmodmap = PROJECTROOT "/lib/X11/xinit/.Xmodmap";
- const char *homedir = getenv("HOME");
- char usermodmap[PATH_MAX], cmd[PATH_MAX];
-
- DEBUG_LOG("DarwinKeyboardReloadHandler\n");
-
- /* Get our key repeat settings from GlobalPreferences */
- (void)CFPreferencesAppSynchronize(CFSTR(".GlobalPreferences"));
-
- initialKeyRepeatValue = CFPreferencesGetAppIntegerValue(CFSTR("InitialKeyRepeat"), CFSTR(".GlobalPreferences"), &ok);
- if(!ok)
- initialKeyRepeatValue = 35;
-
- keyRepeatValue = CFPreferencesGetAppIntegerValue(CFSTR("KeyRepeat"), CFSTR(".GlobalPreferences"), &ok);
- if(!ok)
- keyRepeatValue = 6;
-
- pthread_mutex_lock(&keyInfo_mutex); {
- /* Initialize our keySyms */
- keySyms.map = keyInfo.keyMap;
- keySyms.mapWidth = GLYPHS_PER_KEY;
- keySyms.minKeyCode = MIN_KEYCODE;
- keySyms.maxKeyCode = MAX_KEYCODE;
-
- // TODO: We should build the entire XkbDescRec and use XkbCopyKeymap
- /* Apply the mappings to darwinKeyboard */
- XkbApplyMappingChange(darwinKeyboard, &keySyms, keySyms.minKeyCode,
- keySyms.maxKeyCode - keySyms.minKeyCode + 1,
- keyInfo.modMap, serverClient);
- DarwinKeyboardSetRepeat(darwinKeyboard, initialKeyRepeatValue, keyRepeatValue);
-
- /* Apply the mappings to the core keyboard */
- for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
- if ((pDev->coreEvents || pDev == inputInfo.keyboard) && pDev->key) {
- XkbApplyMappingChange(pDev, &keySyms, keySyms.minKeyCode,
- keySyms.maxKeyCode - keySyms.minKeyCode + 1,
- keyInfo.modMap, serverClient);
- DarwinKeyboardSetRepeat(pDev, initialKeyRepeatValue, keyRepeatValue);
- }
- }
- } pthread_mutex_unlock(&keyInfo_mutex);
-
- /* Modify with xmodmap */
- if (access(xmodmap, F_OK) == 0) {
- /* Check for system .Xmodmap */
- if (access(sysmodmap, F_OK) == 0) {
- if(snprintf (cmd, sizeof(cmd), "%s %s", xmodmap, sysmodmap) < sizeof(cmd)) {
- X11ApplicationLaunchClient(cmd);
- } else {
- ErrorF("X11.app: Unable to create / execute xmodmap command line");
- }
- }
-
- /* Check for user's local .Xmodmap */
- if ((homedir != NULL) && (snprintf (usermodmap, sizeof(usermodmap), "%s/.Xmodmap", homedir) < sizeof(usermodmap))) {
- if (access(usermodmap, F_OK) == 0) {
- if(snprintf (cmd, sizeof(cmd), "%s %s", xmodmap, usermodmap) < sizeof(cmd)) {
- X11ApplicationLaunchClient(cmd);
- } else {
- ErrorF("X11.app: Unable to create / execute xmodmap command line");
- }
- }
- } else {
- ErrorF("X11.app: Unable to determine path to user's .Xmodmap");
- }
- }
-}
-
-//-----------------------------------------------------------------------------
-// Modifier translation functions
-//
-// There are three different ways to specify a Mac modifier key:
-// keycode - specifies hardware key, read from keymapping
-// key - NX_MODIFIERKEY_*, really an index
-// mask - NX_*MASK, mask for modifier flags in event record
-// Left and right side have different keycodes but the same key and mask.
-//-----------------------------------------------------------------------------
-
-/*
- * DarwinModifierNXKeyToNXKeycode
- * Return the keycode for an NX_MODIFIERKEY_* modifier.
- * side = 0 for left or 1 for right.
- * Returns 0 if key+side is not a known modifier.
- */
-int DarwinModifierNXKeyToNXKeycode(int key, int side) {
- int retval;
- pthread_mutex_lock(&keyInfo_mutex);
- retval = keyInfo.modifierKeycodes[key][side];
- pthread_mutex_unlock(&keyInfo_mutex);
-
- return retval;
-}
-
-/*
- * DarwinModifierNXKeycodeToNXKey
- * Returns -1 if keycode+side is not a modifier key
- * outSide may be NULL, else it gets 0 for left and 1 for right.
- */
-int DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide) {
- int key, side;
-
- keycode += MIN_KEYCODE;
-
- // search modifierKeycodes for this keycode+side
- pthread_mutex_lock(&keyInfo_mutex);
- for (key = 0; key < NX_NUMMODIFIERS; key++) {
- for (side = 0; side <= 1; side++) {
- if (keyInfo.modifierKeycodes[key][side] == keycode) break;
- }
- }
- pthread_mutex_unlock(&keyInfo_mutex);
-
- if (key == NX_NUMMODIFIERS) {
- return -1;
- }
- if (outSide) *outSide = side;
-
- return key;
-}
-
-/*
- * DarwinModifierNXMaskToNXKey
- * Returns -1 if mask is not a known modifier mask.
- */
-int DarwinModifierNXMaskToNXKey(int mask) {
- switch (mask) {
- case NX_ALPHASHIFTMASK: return NX_MODIFIERKEY_ALPHALOCK;
- case NX_SHIFTMASK: return NX_MODIFIERKEY_SHIFT;
-#ifdef NX_DEVICELSHIFTKEYMASK
- case NX_DEVICELSHIFTKEYMASK: return NX_MODIFIERKEY_SHIFT;
- case NX_DEVICERSHIFTKEYMASK: return NX_MODIFIERKEY_RSHIFT;
-#endif
- case NX_CONTROLMASK: return NX_MODIFIERKEY_CONTROL;
-#ifdef NX_DEVICELCTLKEYMASK
- case NX_DEVICELCTLKEYMASK: return NX_MODIFIERKEY_CONTROL;
- case NX_DEVICERCTLKEYMASK: return NX_MODIFIERKEY_RCONTROL;
-#endif
- case NX_ALTERNATEMASK: return NX_MODIFIERKEY_ALTERNATE;
-#ifdef NX_DEVICELALTKEYMASK
- case NX_DEVICELALTKEYMASK: return NX_MODIFIERKEY_ALTERNATE;
- case NX_DEVICERALTKEYMASK: return NX_MODIFIERKEY_RALTERNATE;
-#endif
- case NX_COMMANDMASK: return NX_MODIFIERKEY_COMMAND;
-#ifdef NX_DEVICELCMDKEYMASK
- case NX_DEVICELCMDKEYMASK: return NX_MODIFIERKEY_COMMAND;
- case NX_DEVICERCMDKEYMASK: return NX_MODIFIERKEY_RCOMMAND;
-#endif
- case NX_NUMERICPADMASK: return NX_MODIFIERKEY_NUMERICPAD;
- case NX_HELPMASK: return NX_MODIFIERKEY_HELP;
- case NX_SECONDARYFNMASK: return NX_MODIFIERKEY_SECONDARYFN;
- }
- return -1;
-}
-
-/*
- * DarwinModifierNXKeyToNXMask
- * Returns 0 if key is not a known modifier key.
- */
-int DarwinModifierNXKeyToNXMask(int key) {
- switch (key) {
- case NX_MODIFIERKEY_ALPHALOCK: return NX_ALPHASHIFTMASK;
-#ifdef NX_DEVICELSHIFTKEYMASK
- case NX_MODIFIERKEY_SHIFT: return NX_DEVICELSHIFTKEYMASK;
- case NX_MODIFIERKEY_RSHIFT: return NX_DEVICERSHIFTKEYMASK;
- case NX_MODIFIERKEY_CONTROL: return NX_DEVICELCTLKEYMASK;
- case NX_MODIFIERKEY_RCONTROL: return NX_DEVICERCTLKEYMASK;
- case NX_MODIFIERKEY_ALTERNATE: return NX_DEVICELALTKEYMASK;
- case NX_MODIFIERKEY_RALTERNATE: return NX_DEVICERALTKEYMASK;
- case NX_MODIFIERKEY_COMMAND: return NX_DEVICELCMDKEYMASK;
- case NX_MODIFIERKEY_RCOMMAND: return NX_DEVICERCMDKEYMASK;
-#else
- case NX_MODIFIERKEY_SHIFT: return NX_SHIFTMASK;
- case NX_MODIFIERKEY_CONTROL: return NX_CONTROLMASK;
- case NX_MODIFIERKEY_ALTERNATE: return NX_ALTERNATEMASK;
- case NX_MODIFIERKEY_COMMAND: return NX_COMMANDMASK;
-#endif
- case NX_MODIFIERKEY_NUMERICPAD: return NX_NUMERICPADMASK;
- case NX_MODIFIERKEY_HELP: return NX_HELPMASK;
- case NX_MODIFIERKEY_SECONDARYFN: return NX_SECONDARYFNMASK;
- }
- return 0;
-}
-
-/*
- * DarwinModifierStringToNXMask
- * Returns 0 if string is not a known modifier.
- */
-int DarwinModifierStringToNXMask(const char *str, int separatelr) {
-#ifdef NX_DEVICELSHIFTKEYMASK
- if(separatelr) {
- if (!strcasecmp(str, "shift")) return NX_DEVICELSHIFTKEYMASK | NX_DEVICERSHIFTKEYMASK;
- if (!strcasecmp(str, "control")) return NX_DEVICELCTLKEYMASK | NX_DEVICERCTLKEYMASK;
- if (!strcasecmp(str, "option")) return NX_DEVICELALTKEYMASK | NX_DEVICERALTKEYMASK;
- if (!strcasecmp(str, "alt")) return NX_DEVICELALTKEYMASK | NX_DEVICERALTKEYMASK;
- if (!strcasecmp(str, "command")) return NX_DEVICELCMDKEYMASK | NX_DEVICERCMDKEYMASK;
- if (!strcasecmp(str, "lshift")) return NX_DEVICELSHIFTKEYMASK;
- if (!strcasecmp(str, "rshift")) return NX_DEVICERSHIFTKEYMASK;
- if (!strcasecmp(str, "lcontrol")) return NX_DEVICELCTLKEYMASK;
- if (!strcasecmp(str, "rcontrol")) return NX_DEVICERCTLKEYMASK;
- if (!strcasecmp(str, "loption")) return NX_DEVICELALTKEYMASK;
- if (!strcasecmp(str, "roption")) return NX_DEVICERALTKEYMASK;
- if (!strcasecmp(str, "lalt")) return NX_DEVICELALTKEYMASK;
- if (!strcasecmp(str, "ralt")) return NX_DEVICERALTKEYMASK;
- if (!strcasecmp(str, "lcommand")) return NX_DEVICELCMDKEYMASK;
- if (!strcasecmp(str, "rcommand")) return NX_DEVICERCMDKEYMASK;
- } else {
-#endif
- if (!strcasecmp(str, "shift")) return NX_SHIFTMASK;
- if (!strcasecmp(str, "control")) return NX_CONTROLMASK;
- if (!strcasecmp(str, "option")) return NX_ALTERNATEMASK;
- if (!strcasecmp(str, "alt")) return NX_ALTERNATEMASK;
- if (!strcasecmp(str, "command")) return NX_COMMANDMASK;
- if (!strcasecmp(str, "lshift")) return NX_SHIFTMASK;
- if (!strcasecmp(str, "rshift")) return NX_SHIFTMASK;
- if (!strcasecmp(str, "lcontrol")) return NX_CONTROLMASK;
- if (!strcasecmp(str, "rcontrol")) return NX_CONTROLMASK;
- if (!strcasecmp(str, "loption")) return NX_ALTERNATEMASK;
- if (!strcasecmp(str, "roption")) return NX_ALTERNATEMASK;
- if (!strcasecmp(str, "lalt")) return NX_ALTERNATEMASK;
- if (!strcasecmp(str, "ralt")) return NX_ALTERNATEMASK;
- if (!strcasecmp(str, "lcommand")) return NX_COMMANDMASK;
- if (!strcasecmp(str, "rcommand")) return NX_COMMANDMASK;
-#ifdef NX_DEVICELSHIFTKEYMASK
- }
-#endif
- if (!strcasecmp(str, "lock")) return NX_ALPHASHIFTMASK;
- if (!strcasecmp(str, "fn")) return NX_SECONDARYFNMASK;
- if (!strcasecmp(str, "help")) return NX_HELPMASK;
- if (!strcasecmp(str, "numlock")) return NX_NUMERICPADMASK;
- return 0;
-}
-
-/*
- * LegalModifier
- * This allows the ddx layer to prevent some keys from being remapped
- * as modifier keys.
- */
-Bool LegalModifier(unsigned int key, DeviceIntPtr pDev)
-{
- return 1;
-}
-
-static inline UniChar macroman2ucs(unsigned char c) {
- /* Precalculated table mapping MacRoman-128 to Unicode. Generated
- by creating single element CFStringRefs then extracting the
- first character. */
-
- static const unsigned short table[128] = {
- 0xc4, 0xc5, 0xc7, 0xc9, 0xd1, 0xd6, 0xdc, 0xe1,
- 0xe0, 0xe2, 0xe4, 0xe3, 0xe5, 0xe7, 0xe9, 0xe8,
- 0xea, 0xeb, 0xed, 0xec, 0xee, 0xef, 0xf1, 0xf3,
- 0xf2, 0xf4, 0xf6, 0xf5, 0xfa, 0xf9, 0xfb, 0xfc,
- 0x2020, 0xb0, 0xa2, 0xa3, 0xa7, 0x2022, 0xb6, 0xdf,
- 0xae, 0xa9, 0x2122, 0xb4, 0xa8, 0x2260, 0xc6, 0xd8,
- 0x221e, 0xb1, 0x2264, 0x2265, 0xa5, 0xb5, 0x2202, 0x2211,
- 0x220f, 0x3c0, 0x222b, 0xaa, 0xba, 0x3a9, 0xe6, 0xf8,
- 0xbf, 0xa1, 0xac, 0x221a, 0x192, 0x2248, 0x2206, 0xab,
- 0xbb, 0x2026, 0xa0, 0xc0, 0xc3, 0xd5, 0x152, 0x153,
- 0x2013, 0x2014, 0x201c, 0x201d, 0x2018, 0x2019, 0xf7, 0x25ca,
- 0xff, 0x178, 0x2044, 0x20ac, 0x2039, 0x203a, 0xfb01, 0xfb02,
- 0x2021, 0xb7, 0x201a, 0x201e, 0x2030, 0xc2, 0xca, 0xc1,
- 0xcb, 0xc8, 0xcd, 0xce, 0xcf, 0xcc, 0xd3, 0xd4,
- 0xf8ff, 0xd2, 0xda, 0xdb, 0xd9, 0x131, 0x2c6, 0x2dc,
- 0xaf, 0x2d8, 0x2d9, 0x2da, 0xb8, 0x2dd, 0x2db, 0x2c7,
- };
-
- if (c < 128) return c;
- else return table[c - 128];
-}
-
-static KeySym make_dead_key(KeySym in) {
- int i;
-
- for (i = 0; i < sizeof (dead_keys) / sizeof (dead_keys[0]); i++)
- if (dead_keys[i].normal == in) return dead_keys[i].dead;
-
- return in;
-}
-
-static Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info) {
-#if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050
- KeyboardLayoutRef key_layout;
- int is_uchr = 1;
-#endif
- const void *chr_data = NULL;
- int num_keycodes = NUM_KEYCODES;
- UInt32 keyboard_type = LMGetKbdType();
- int i, j;
- OSStatus err;
- KeySym *k;
- CFDataRef currentKeyLayoutDataRef = NULL;
-
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
- TISInputSourceRef currentKeyLayoutRef = TISCopyCurrentKeyboardLayoutInputSource();
-
- if (currentKeyLayoutRef) {
- currentKeyLayoutDataRef = (CFDataRef )TISGetInputSourceProperty(currentKeyLayoutRef, kTISPropertyUnicodeKeyLayoutData);
- if (currentKeyLayoutDataRef)
- chr_data = CFDataGetBytePtr(currentKeyLayoutDataRef);
- }
-#endif
-
-#ifdef __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations" // KLGetCurrentKeyboardLayout, KLGetKeyboardLayoutProperty
-#endif
-
-#if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050
- if (chr_data == NULL) {
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
- ErrorF("X11.app: Error detected in determining keyboard layout. If you are using an Apple-provided keyboard layout, please report this error at http://xquartz.macosforge.org and http://bugreport.apple.com\n");
- ErrorF("X11.app: Debug Info: keyboard_type=%u, currentKeyLayoutRef=%p, currentKeyLayoutDataRef=%p, chr_data=%p\n",
- (unsigned)keyboard_type, currentKeyLayoutRef, currentKeyLayoutDataRef, chr_data);
-#endif
-
- KLGetCurrentKeyboardLayout (&key_layout);
- KLGetKeyboardLayoutProperty (key_layout, kKLuchrData, &chr_data);
-
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
- if(chr_data != NULL) {
- ErrorF("X11.app: Fallback succeeded, but this is still a bug. Please report the above information.\n");
- }
-#endif
- }
-
- if (chr_data == NULL) {
- ErrorF("X11.app: Debug Info: kKLuchrData failed, trying kKLKCHRData.\n");
- ErrorF("If you are using a 3rd party keyboard layout, please see http://xquartz.macosforge.org/trac/ticket/154\n");
- KLGetKeyboardLayoutProperty (key_layout, kKLKCHRData, &chr_data);
- is_uchr = 0;
- num_keycodes = 128;
-
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
- if(chr_data != NULL) {
- ErrorF("X11.app: Fallback succeeded, but this is still a bug. Please report the above information.\n");
- }
-#endif
- }
-#endif
-
-#ifdef __clang__
-#pragma clang diagnostic pop
-#endif
-
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
- if(currentKeyLayoutRef)
- CFRelease(currentKeyLayoutRef);
-#endif
-
- if (chr_data == NULL) {
- ErrorF ( "Couldn't get uchr or kchr resource\n");
- return FALSE;
- }
-
- /* Scan the keycode range for the Unicode character that each
- key produces in the four shift states. Then convert that to
- an X11 keysym (which may just the bit that says "this is
- Unicode" if it can't find the real symbol.) */
-
- /* KeyTranslate is not available on 64-bit platforms; UCKeyTranslate
- must be used instead. */
-
- for (i = 0; i < num_keycodes; i++) {
- static const int mods[4] = {0, MOD_SHIFT, MOD_OPTION,
- MOD_OPTION | MOD_SHIFT};
-
- k = info->keyMap + i * GLYPHS_PER_KEY;
-
- for (j = 0; j < 4; j++) {
-#if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050
- if (is_uchr) {
-#endif
- UniChar s[8];
- UniCharCount len;
- UInt32 dead_key_state = 0, extra_dead = 0;
-
- err = UCKeyTranslate (chr_data, i, kUCKeyActionDown,
- mods[j] >> 8, keyboard_type, 0,
- &dead_key_state, 8, &len, s);
- if (err != noErr) continue;
-
- if (len == 0 && dead_key_state != 0) {
- /* Found a dead key. Work out which one it is, but
- remembering that it's dead. */
- err = UCKeyTranslate (chr_data, i, kUCKeyActionDown,
- mods[j] >> 8, keyboard_type,
- kUCKeyTranslateNoDeadKeysMask,
- &extra_dead, 8, &len, s);
- if (err != noErr) continue;
- }
-
- /* Not sure why 0x0010 is there.
- * 0x0000 - <rdar://problem/7793566> 'Unicode Hex Input' ...
- */
- if (len > 0 && s[0] != 0x0010 && s[0] != 0x0000) {
- k[j] = ucs2keysym (s[0]);
- if (dead_key_state != 0) k[j] = make_dead_key (k[j]);
- }
-#if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050
- } else { // kchr
- UInt32 c, state = 0, state2 = 0;
- UInt16 code;
-
- code = i | mods[j];
-
-#ifdef __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations" // KeyTranslate
-#endif
-
- c = KeyTranslate (chr_data, code, &state);
-
- /* Dead keys are only processed on key-down, so ask
- to translate those events. When we find a dead key,
- translating the matching key up event will give
- us the actual dead character. */
-
- if (state != 0)
- c = KeyTranslate (chr_data, code | 128, &state2);
-
-#ifdef __clang__
-#pragma clang diagnostic pop
-#endif
-
- /* Characters seem to be in MacRoman encoding. */
-
- if (c != 0 && c != 0x0010) {
- k[j] = ucs2keysym (macroman2ucs (c & 255));
-
- if (state != 0) k[j] = make_dead_key (k[j]);
- }
- }
-#endif
- }
-
- if (k[3] == k[2]) k[3] = NoSymbol;
- if (k[1] == k[0]) k[1] = NoSymbol;
- if (k[0] == k[2] && k[1] == k[3]) k[2] = k[3] = NoSymbol;
- if (k[3] == k[0] && k[2] == k[1] && k[2] == NoSymbol) k[3] = NoSymbol;
- }
-
-#if HACK_MISSING
- /* Fix up some things that are normally missing.. */
-
- for (i = 0; i < sizeof (known_keys) / sizeof (known_keys[0]); i++) {
- k = info->keyMap + known_keys[i].keycode * GLYPHS_PER_KEY;
-
- if ( k[0] == NoSymbol && k[1] == NoSymbol
- && k[2] == NoSymbol && k[3] == NoSymbol)
- k[0] = known_keys[i].keysym;
- }
-#endif
-
-#if HACK_KEYPAD
- /* And some more things. We find the right symbols for the numeric
- keypad, but not the KP_ keysyms. So try to convert known keycodes. */
- for (i = 0; i < sizeof (known_numeric_keys) / sizeof (known_numeric_keys[0]); i++) {
- k = info->keyMap + known_numeric_keys[i].keycode * GLYPHS_PER_KEY;
-
- if (k[0] == known_numeric_keys[i].normal)
- k[0] = known_numeric_keys[i].keypad;
- }
-#endif
-
-#if HACK_BLACKLIST
- for (i = 0; i < sizeof (keycode_blacklist) / sizeof (keycode_blacklist[0]); i++) {
- k = info->keyMap + keycode_blacklist[i] * GLYPHS_PER_KEY;
- k[0] = k[1] = k[2] = k[3] = NoSymbol;
- }
-#endif
-
- DarwinBuildModifierMaps(info);
-
- return TRUE;
-}
-
-Bool QuartsResyncKeymap(Bool sendDDXEvent) {
- Bool retval;
- /* Update keyInfo */
- pthread_mutex_lock(&keyInfo_mutex);
- memset(keyInfo.keyMap, 0, sizeof(keyInfo.keyMap));
- retval = QuartzReadSystemKeymap(&keyInfo);
- pthread_mutex_unlock(&keyInfo_mutex);
-
- /* Tell server thread to deal with new keyInfo */
- if(sendDDXEvent)
- DarwinSendDDXEvent(kXquartzReloadKeymap, 0);
-
- return retval;
-}
+/*
+ quartzKeyboard.c: Keyboard support for Xquartz
+
+ Copyright (c) 2003-2008 Apple Inc.
+ Copyright (c) 2001-2004 Torrey T. Lyons. All Rights Reserved.
+ Copyright 2004 Kaleb S. KEITHLEY. All Rights Reserved.
+
+ Copyright (C) 1999,2000 by Eric Sunshine <sunshine@sunshineco.com>
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ 3. The name of the author may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
+ NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include "sanitizedCarbon.h"
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#define HACK_MISSING 1
+#define HACK_KEYPAD 1
+#define HACK_BLACKLIST 1
+
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <AvailabilityMacros.h>
+
+#include "quartz.h"
+#include "darwin.h"
+#include "darwinEvents.h"
+
+#include "quartzKeyboard.h"
+
+#include "X11Application.h"
+
+#include <assert.h>
+#include <pthread.h>
+
+#include "xkbsrv.h"
+#include "exevents.h"
+#include "X11/keysym.h"
+#include "keysym2ucs.h"
+
+extern void
+CopyKeyClass(DeviceIntPtr device, DeviceIntPtr master);
+
+enum {
+ MOD_COMMAND = 256,
+ MOD_SHIFT = 512,
+ MOD_OPTION = 2048,
+ MOD_CONTROL = 4096,
+};
+
+#define UKEYSYM(u) ((u) | 0x01000000)
+
+#if HACK_MISSING
+/* Table of keycode->keysym mappings we use to fallback on for important
+ keys that are often not in the Unicode mapping. */
+
+const static struct {
+ unsigned short keycode;
+ KeySym keysym;
+} known_keys[] = {
+ {55, XK_Meta_L},
+ {56, XK_Shift_L},
+ {57, XK_Caps_Lock},
+ {58, XK_Alt_L},
+ {59, XK_Control_L},
+
+ {60, XK_Shift_R},
+ {61, XK_Alt_R},
+ {62, XK_Control_R},
+ {63, XK_Meta_R},
+
+ {122, XK_F1},
+ {120, XK_F2},
+ {99, XK_F3},
+ {118, XK_F4},
+ {96, XK_F5},
+ {97, XK_F6},
+ {98, XK_F7},
+ {100, XK_F8},
+ {101, XK_F9},
+ {109, XK_F10},
+ {103, XK_F11},
+ {111, XK_F12},
+ {105, XK_F13},
+ {107, XK_F14},
+ {113, XK_F15},
+};
+#endif
+
+#if HACK_KEYPAD
+/* Table of keycode->old,new-keysym mappings we use to fixup the numeric
+ keypad entries. */
+
+const static struct {
+ unsigned short keycode;
+ KeySym normal, keypad;
+} known_numeric_keys[] = {
+ {65, XK_period, XK_KP_Decimal},
+ {67, XK_asterisk, XK_KP_Multiply},
+ {69, XK_plus, XK_KP_Add},
+ {75, XK_slash, XK_KP_Divide},
+ {76, 0x01000003, XK_KP_Enter},
+ {78, XK_minus, XK_KP_Subtract},
+ {81, XK_equal, XK_KP_Equal},
+ {82, XK_0, XK_KP_0},
+ {83, XK_1, XK_KP_1},
+ {84, XK_2, XK_KP_2},
+ {85, XK_3, XK_KP_3},
+ {86, XK_4, XK_KP_4},
+ {87, XK_5, XK_KP_5},
+ {88, XK_6, XK_KP_6},
+ {89, XK_7, XK_KP_7},
+ {91, XK_8, XK_KP_8},
+ {92, XK_9, XK_KP_9},
+};
+#endif
+
+#if HACK_BLACKLIST
+/* <rdar://problem/7824370> wine notepad produces wrong characters on shift+arrow
+ * http://xquartz.macosforge.org/trac/ticket/295
+ * http://developer.apple.com/legacy/mac/library/documentation/mac/Text/Text-579.html
+ *
+ * legacy Mac keycodes for arrow keys that shift-modify to math symbols
+ */
+const static unsigned short keycode_blacklist[] = {66, 70, 72, 77};
+#endif
+
+/* Table mapping normal keysyms to their dead equivalents.
+ FIXME: all the unicode keysyms (apart from circumflex) were guessed. */
+
+const static struct {
+ KeySym normal, dead;
+} dead_keys[] = {
+ {XK_grave, XK_dead_grave},
+ {XK_apostrophe, XK_dead_acute}, /* US:"=" on a Czech keyboard */
+ {XK_acute, XK_dead_acute},
+ {UKEYSYM (0x384), XK_dead_acute}, /* US:";" on a Greek keyboard */
+// {XK_Greek_accentdieresis, XK_dead_diaeresis}, /* US:"opt+;" on a Greek keyboard ... replace with dead_accentdieresis if there is one */
+ {XK_asciicircum, XK_dead_circumflex},
+ {UKEYSYM (0x2c6), XK_dead_circumflex}, /* MODIFIER LETTER CIRCUMFLEX ACCENT */
+ {XK_asciitilde, XK_dead_tilde},
+ {UKEYSYM (0x2dc), XK_dead_tilde}, /* SMALL TILDE */
+ {XK_macron, XK_dead_macron},
+ {XK_breve, XK_dead_breve},
+ {XK_abovedot, XK_dead_abovedot},
+ {XK_diaeresis, XK_dead_diaeresis},
+ {UKEYSYM (0x2da), XK_dead_abovering}, /* DOT ABOVE */
+ {XK_doubleacute, XK_dead_doubleacute},
+ {XK_caron, XK_dead_caron},
+ {XK_cedilla, XK_dead_cedilla},
+ {XK_ogonek, XK_dead_ogonek},
+ {UKEYSYM (0x269), XK_dead_iota}, /* LATIN SMALL LETTER IOTA */
+ {UKEYSYM (0x2ec), XK_dead_voiced_sound}, /* MODIFIER LETTER VOICING */
+/* {XK_semivoiced_sound, XK_dead_semivoiced_sound}, */
+ {UKEYSYM (0x323), XK_dead_belowdot}, /* COMBINING DOT BELOW */
+ {UKEYSYM (0x309), XK_dead_hook}, /* COMBINING HOOK ABOVE */
+ {UKEYSYM (0x31b), XK_dead_horn}, /* COMBINING HORN */
+};
+
+typedef struct darwinKeyboardInfo_struct {
+ CARD8 modMap[MAP_LENGTH];
+ KeySym keyMap[MAP_LENGTH * GLYPHS_PER_KEY];
+ unsigned char modifierKeycodes[32][2];
+} darwinKeyboardInfo;
+
+darwinKeyboardInfo keyInfo;
+pthread_mutex_t keyInfo_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+static void DarwinChangeKeyboardControl(DeviceIntPtr device, KeybdCtrl *ctrl) {
+ // FIXME: to be implemented
+ // keyclick, bell volume / pitch, autorepead, LED's
+}
+
+//-----------------------------------------------------------------------------
+// Utility functions to help parse Darwin keymap
+//-----------------------------------------------------------------------------
+
+/*
+ * DarwinBuildModifierMaps
+ * Use the keyMap field of keyboard info structure to populate
+ * the modMap and modifierKeycodes fields.
+ */
+static void DarwinBuildModifierMaps(darwinKeyboardInfo *info) {
+ int i;
+ KeySym *k;
+
+ memset(info->modMap, NoSymbol, sizeof(info->modMap));
+ memset(info->modifierKeycodes, 0, sizeof(info->modifierKeycodes));
+
+ for (i = 0; i < NUM_KEYCODES; i++) {
+ k = info->keyMap + i * GLYPHS_PER_KEY;
+
+ switch (*k) {
+ case XK_Shift_L:
+ info->modifierKeycodes[NX_MODIFIERKEY_SHIFT][0] = i;
+ info->modMap[MIN_KEYCODE + i] = ShiftMask;
+ break;
+
+ case XK_Shift_R:
+#ifdef NX_MODIFIERKEY_RSHIFT
+ info->modifierKeycodes[NX_MODIFIERKEY_RSHIFT][0] = i;
+#else
+ info->modifierKeycodes[NX_MODIFIERKEY_SHIFT][0] = i;
+#endif
+ info->modMap[MIN_KEYCODE + i] = ShiftMask;
+ break;
+
+ case XK_Control_L:
+ info->modifierKeycodes[NX_MODIFIERKEY_CONTROL][0] = i;
+ info->modMap[MIN_KEYCODE + i] = ControlMask;
+ break;
+
+ case XK_Control_R:
+#ifdef NX_MODIFIERKEY_RCONTROL
+ info->modifierKeycodes[NX_MODIFIERKEY_RCONTROL][0] = i;
+#else
+ info->modifierKeycodes[NX_MODIFIERKEY_CONTROL][0] = i;
+#endif
+ info->modMap[MIN_KEYCODE + i] = ControlMask;
+ break;
+
+ case XK_Caps_Lock:
+ info->modifierKeycodes[NX_MODIFIERKEY_ALPHALOCK][0] = i;
+ info->modMap[MIN_KEYCODE + i] = LockMask;
+ break;
+
+ case XK_Alt_L:
+ info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i;
+ info->modMap[MIN_KEYCODE + i] = Mod1Mask;
+ if(!XQuartzOptionSendsAlt)
+ *k = XK_Mode_switch; // Yes, this is ugly. This needs to be cleaned up when we integrate quartzKeyboard with this code and refactor.
+ break;
+
+ case XK_Alt_R:
+#ifdef NX_MODIFIERKEY_RALTERNATE
+ info->modifierKeycodes[NX_MODIFIERKEY_RALTERNATE][0] = i;
+#else
+ info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i;
+#endif
+ if(!XQuartzOptionSendsAlt)
+ *k = XK_Mode_switch; // Yes, this is ugly. This needs to be cleaned up when we integrate quartzKeyboard with this code and refactor.
+ info->modMap[MIN_KEYCODE + i] = Mod1Mask;
+ break;
+
+ case XK_Mode_switch:
+ ErrorF("DarwinBuildModifierMaps: XK_Mode_switch encountered, unable to determine side.\n");
+ info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i;
+#ifdef NX_MODIFIERKEY_RALTERNATE
+ info->modifierKeycodes[NX_MODIFIERKEY_RALTERNATE][0] = i;
+#endif
+ info->modMap[MIN_KEYCODE + i] = Mod1Mask;
+ break;
+
+ case XK_Meta_L:
+ info->modifierKeycodes[NX_MODIFIERKEY_COMMAND][0] = i;
+ info->modMap[MIN_KEYCODE + i] = Mod2Mask;
+ break;
+
+ case XK_Meta_R:
+#ifdef NX_MODIFIERKEY_RCOMMAND
+ info->modifierKeycodes[NX_MODIFIERKEY_RCOMMAND][0] = i;
+#else
+ info->modifierKeycodes[NX_MODIFIERKEY_COMMAND][0] = i;
+#endif
+ info->modMap[MIN_KEYCODE + i] = Mod2Mask;
+ break;
+
+ case XK_Num_Lock:
+ info->modMap[MIN_KEYCODE + i] = Mod3Mask;
+ break;
+ }
+ }
+}
+
+/*
+ * DarwinKeyboardInit
+ * Get the Darwin keyboard map and compute an equivalent
+ * X keyboard map and modifier map. Set the new keyboard
+ * device structure.
+ */
+void DarwinKeyboardInit(DeviceIntPtr pDev) {
+ // Open a shared connection to the HID System.
+ // Note that the Event Status Driver is really just a wrapper
+ // for a kIOHIDParamConnectType connection.
+ assert(darwinParamConnect = NXOpenEventStatus());
+
+ InitKeyboardDeviceStruct(pDev, NULL, NULL, DarwinChangeKeyboardControl);
+
+ DarwinKeyboardReloadHandler();
+
+ CopyKeyClass(pDev, inputInfo.keyboard);
+}
+
+/* Set the repeat rates based on global preferences and keycodes for modifiers.
+ * Precondition: Has the keyInfo_mutex lock.
+ */
+static void DarwinKeyboardSetRepeat(DeviceIntPtr pDev, int initialKeyRepeatValue, int keyRepeatValue) {
+ if(initialKeyRepeatValue == 300000) { // off
+ /* Turn off repeats globally */
+ XkbSetRepeatKeys(pDev, -1, AutoRepeatModeOff);
+ } else {
+ int i;
+ XkbControlsPtr ctrl;
+ XkbControlsRec old;
+
+ /* Turn on repeats globally */
+ XkbSetRepeatKeys(pDev, -1, AutoRepeatModeOn);
+
+ /* Setup the bit mask for individual key repeats */
+ ctrl = pDev->key->xkbInfo->desc->ctrls;
+ old= *ctrl;
+
+ ctrl->repeat_delay = initialKeyRepeatValue * 15;
+ ctrl->repeat_interval = keyRepeatValue * 15;
+
+ /* Turn off key-repeat for modifier keys, on for others */
+ /* First set them all on */
+ for(i=0; i < XkbPerKeyBitArraySize; i++)
+ ctrl->per_key_repeat[i] = -1;
+
+ /* Now turn off the modifiers */
+ for(i=0; i < 32; i++) {
+ unsigned char keycode;
+
+ keycode = keyInfo.modifierKeycodes[i][0];
+ if(keycode)
+ ClearBit(ctrl->per_key_repeat, keycode + MIN_KEYCODE);
+
+ keycode = keyInfo.modifierKeycodes[i][1];
+ if(keycode)
+ ClearBit(ctrl->per_key_repeat, keycode + MIN_KEYCODE);
+ }
+
+ /* Hurray for data duplication */
+ if (pDev->kbdfeed)
+ memcpy(pDev->kbdfeed->ctrl.autoRepeats, ctrl->per_key_repeat, XkbPerKeyBitArraySize);
+
+ //ErrorF("per_key_repeat =\n");
+ //for(i=0; i < XkbPerKeyBitArraySize; i++)
+ // ErrorF("%02x%s", ctrl->per_key_repeat[i], (i + 1) & 7 ? "" : "\n");
+
+ /* And now we notify the puppies about the changes */
+ XkbDDXChangeControls(pDev, &old, ctrl);
+ }
+}
+
+void DarwinKeyboardReloadHandler(void) {
+ KeySymsRec keySyms;
+ CFIndex initialKeyRepeatValue, keyRepeatValue;
+ BOOL ok;
+ DeviceIntPtr pDev;
+ const char *xmodmap = PROJECTROOT "/bin/xmodmap";
+ const char *sysmodmap = PROJECTROOT "/lib/X11/xinit/.Xmodmap";
+ const char *homedir = getenv("HOME");
+ char usermodmap[PATH_MAX], cmd[PATH_MAX];
+
+ DEBUG_LOG("DarwinKeyboardReloadHandler\n");
+
+ /* Get our key repeat settings from GlobalPreferences */
+ (void)CFPreferencesAppSynchronize(CFSTR(".GlobalPreferences"));
+
+ initialKeyRepeatValue = CFPreferencesGetAppIntegerValue(CFSTR("InitialKeyRepeat"), CFSTR(".GlobalPreferences"), &ok);
+ if(!ok)
+ initialKeyRepeatValue = 35;
+
+ keyRepeatValue = CFPreferencesGetAppIntegerValue(CFSTR("KeyRepeat"), CFSTR(".GlobalPreferences"), &ok);
+ if(!ok)
+ keyRepeatValue = 6;
+
+ pthread_mutex_lock(&keyInfo_mutex); {
+ /* Initialize our keySyms */
+ keySyms.map = keyInfo.keyMap;
+ keySyms.mapWidth = GLYPHS_PER_KEY;
+ keySyms.minKeyCode = MIN_KEYCODE;
+ keySyms.maxKeyCode = MAX_KEYCODE;
+
+ // TODO: We should build the entire XkbDescRec and use XkbCopyKeymap
+ /* Apply the mappings to darwinKeyboard */
+ XkbApplyMappingChange(darwinKeyboard, &keySyms, keySyms.minKeyCode,
+ keySyms.maxKeyCode - keySyms.minKeyCode + 1,
+ keyInfo.modMap, serverClient);
+ DarwinKeyboardSetRepeat(darwinKeyboard, initialKeyRepeatValue, keyRepeatValue);
+
+ /* Apply the mappings to the core keyboard */
+ for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
+ if ((pDev->coreEvents || pDev == inputInfo.keyboard) && pDev->key) {
+ XkbApplyMappingChange(pDev, &keySyms, keySyms.minKeyCode,
+ keySyms.maxKeyCode - keySyms.minKeyCode + 1,
+ keyInfo.modMap, serverClient);
+ DarwinKeyboardSetRepeat(pDev, initialKeyRepeatValue, keyRepeatValue);
+ }
+ }
+ } pthread_mutex_unlock(&keyInfo_mutex);
+
+ /* Modify with xmodmap */
+ if (access(xmodmap, F_OK) == 0) {
+ /* Check for system .Xmodmap */
+ if (access(sysmodmap, F_OK) == 0) {
+ if(snprintf (cmd, sizeof(cmd), "%s %s", xmodmap, sysmodmap) < sizeof(cmd)) {
+ X11ApplicationLaunchClient(cmd);
+ } else {
+ ErrorF("X11.app: Unable to create / execute xmodmap command line");
+ }
+ }
+
+ /* Check for user's local .Xmodmap */
+ if ((homedir != NULL) && (snprintf (usermodmap, sizeof(usermodmap), "%s/.Xmodmap", homedir) < sizeof(usermodmap))) {
+ if (access(usermodmap, F_OK) == 0) {
+ if(snprintf (cmd, sizeof(cmd), "%s %s", xmodmap, usermodmap) < sizeof(cmd)) {
+ X11ApplicationLaunchClient(cmd);
+ } else {
+ ErrorF("X11.app: Unable to create / execute xmodmap command line");
+ }
+ }
+ } else {
+ ErrorF("X11.app: Unable to determine path to user's .Xmodmap");
+ }
+ }
+}
+
+//-----------------------------------------------------------------------------
+// Modifier translation functions
+//
+// There are three different ways to specify a Mac modifier key:
+// keycode - specifies hardware key, read from keymapping
+// key - NX_MODIFIERKEY_*, really an index
+// mask - NX_*MASK, mask for modifier flags in event record
+// Left and right side have different keycodes but the same key and mask.
+//-----------------------------------------------------------------------------
+
+/*
+ * DarwinModifierNXKeyToNXKeycode
+ * Return the keycode for an NX_MODIFIERKEY_* modifier.
+ * side = 0 for left or 1 for right.
+ * Returns 0 if key+side is not a known modifier.
+ */
+int DarwinModifierNXKeyToNXKeycode(int key, int side) {
+ int retval;
+ pthread_mutex_lock(&keyInfo_mutex);
+ retval = keyInfo.modifierKeycodes[key][side];
+ pthread_mutex_unlock(&keyInfo_mutex);
+
+ return retval;
+}
+
+/*
+ * DarwinModifierNXKeycodeToNXKey
+ * Returns -1 if keycode+side is not a modifier key
+ * outSide may be NULL, else it gets 0 for left and 1 for right.
+ */
+int DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide) {
+ int key, side;
+
+ keycode += MIN_KEYCODE;
+
+ // search modifierKeycodes for this keycode+side
+ pthread_mutex_lock(&keyInfo_mutex);
+ for (key = 0; key < NX_NUMMODIFIERS; key++) {
+ for (side = 0; side <= 1; side++) {
+ if (keyInfo.modifierKeycodes[key][side] == keycode) break;
+ }
+ }
+ pthread_mutex_unlock(&keyInfo_mutex);
+
+ if (key == NX_NUMMODIFIERS) {
+ return -1;
+ }
+ if (outSide) *outSide = side;
+
+ return key;
+}
+
+/*
+ * DarwinModifierNXMaskToNXKey
+ * Returns -1 if mask is not a known modifier mask.
+ */
+int DarwinModifierNXMaskToNXKey(int mask) {
+ switch (mask) {
+ case NX_ALPHASHIFTMASK: return NX_MODIFIERKEY_ALPHALOCK;
+ case NX_SHIFTMASK: return NX_MODIFIERKEY_SHIFT;
+#ifdef NX_DEVICELSHIFTKEYMASK
+ case NX_DEVICELSHIFTKEYMASK: return NX_MODIFIERKEY_SHIFT;
+ case NX_DEVICERSHIFTKEYMASK: return NX_MODIFIERKEY_RSHIFT;
+#endif
+ case NX_CONTROLMASK: return NX_MODIFIERKEY_CONTROL;
+#ifdef NX_DEVICELCTLKEYMASK
+ case NX_DEVICELCTLKEYMASK: return NX_MODIFIERKEY_CONTROL;
+ case NX_DEVICERCTLKEYMASK: return NX_MODIFIERKEY_RCONTROL;
+#endif
+ case NX_ALTERNATEMASK: return NX_MODIFIERKEY_ALTERNATE;
+#ifdef NX_DEVICELALTKEYMASK
+ case NX_DEVICELALTKEYMASK: return NX_MODIFIERKEY_ALTERNATE;
+ case NX_DEVICERALTKEYMASK: return NX_MODIFIERKEY_RALTERNATE;
+#endif
+ case NX_COMMANDMASK: return NX_MODIFIERKEY_COMMAND;
+#ifdef NX_DEVICELCMDKEYMASK
+ case NX_DEVICELCMDKEYMASK: return NX_MODIFIERKEY_COMMAND;
+ case NX_DEVICERCMDKEYMASK: return NX_MODIFIERKEY_RCOMMAND;
+#endif
+ case NX_NUMERICPADMASK: return NX_MODIFIERKEY_NUMERICPAD;
+ case NX_HELPMASK: return NX_MODIFIERKEY_HELP;
+ case NX_SECONDARYFNMASK: return NX_MODIFIERKEY_SECONDARYFN;
+ }
+ return -1;
+}
+
+/*
+ * DarwinModifierNXKeyToNXMask
+ * Returns 0 if key is not a known modifier key.
+ */
+int DarwinModifierNXKeyToNXMask(int key) {
+ switch (key) {
+ case NX_MODIFIERKEY_ALPHALOCK: return NX_ALPHASHIFTMASK;
+#ifdef NX_DEVICELSHIFTKEYMASK
+ case NX_MODIFIERKEY_SHIFT: return NX_DEVICELSHIFTKEYMASK;
+ case NX_MODIFIERKEY_RSHIFT: return NX_DEVICERSHIFTKEYMASK;
+ case NX_MODIFIERKEY_CONTROL: return NX_DEVICELCTLKEYMASK;
+ case NX_MODIFIERKEY_RCONTROL: return NX_DEVICERCTLKEYMASK;
+ case NX_MODIFIERKEY_ALTERNATE: return NX_DEVICELALTKEYMASK;
+ case NX_MODIFIERKEY_RALTERNATE: return NX_DEVICERALTKEYMASK;
+ case NX_MODIFIERKEY_COMMAND: return NX_DEVICELCMDKEYMASK;
+ case NX_MODIFIERKEY_RCOMMAND: return NX_DEVICERCMDKEYMASK;
+#else
+ case NX_MODIFIERKEY_SHIFT: return NX_SHIFTMASK;
+ case NX_MODIFIERKEY_CONTROL: return NX_CONTROLMASK;
+ case NX_MODIFIERKEY_ALTERNATE: return NX_ALTERNATEMASK;
+ case NX_MODIFIERKEY_COMMAND: return NX_COMMANDMASK;
+#endif
+ case NX_MODIFIERKEY_NUMERICPAD: return NX_NUMERICPADMASK;
+ case NX_MODIFIERKEY_HELP: return NX_HELPMASK;
+ case NX_MODIFIERKEY_SECONDARYFN: return NX_SECONDARYFNMASK;
+ }
+ return 0;
+}
+
+/*
+ * DarwinModifierStringToNXMask
+ * Returns 0 if string is not a known modifier.
+ */
+int DarwinModifierStringToNXMask(const char *str, int separatelr) {
+#ifdef NX_DEVICELSHIFTKEYMASK
+ if(separatelr) {
+ if (!strcasecmp(str, "shift")) return NX_DEVICELSHIFTKEYMASK | NX_DEVICERSHIFTKEYMASK;
+ if (!strcasecmp(str, "control")) return NX_DEVICELCTLKEYMASK | NX_DEVICERCTLKEYMASK;
+ if (!strcasecmp(str, "option")) return NX_DEVICELALTKEYMASK | NX_DEVICERALTKEYMASK;
+ if (!strcasecmp(str, "alt")) return NX_DEVICELALTKEYMASK | NX_DEVICERALTKEYMASK;
+ if (!strcasecmp(str, "command")) return NX_DEVICELCMDKEYMASK | NX_DEVICERCMDKEYMASK;
+ if (!strcasecmp(str, "lshift")) return NX_DEVICELSHIFTKEYMASK;
+ if (!strcasecmp(str, "rshift")) return NX_DEVICERSHIFTKEYMASK;
+ if (!strcasecmp(str, "lcontrol")) return NX_DEVICELCTLKEYMASK;
+ if (!strcasecmp(str, "rcontrol")) return NX_DEVICERCTLKEYMASK;
+ if (!strcasecmp(str, "loption")) return NX_DEVICELALTKEYMASK;
+ if (!strcasecmp(str, "roption")) return NX_DEVICERALTKEYMASK;
+ if (!strcasecmp(str, "lalt")) return NX_DEVICELALTKEYMASK;
+ if (!strcasecmp(str, "ralt")) return NX_DEVICERALTKEYMASK;
+ if (!strcasecmp(str, "lcommand")) return NX_DEVICELCMDKEYMASK;
+ if (!strcasecmp(str, "rcommand")) return NX_DEVICERCMDKEYMASK;
+ } else {
+#endif
+ if (!strcasecmp(str, "shift")) return NX_SHIFTMASK;
+ if (!strcasecmp(str, "control")) return NX_CONTROLMASK;
+ if (!strcasecmp(str, "option")) return NX_ALTERNATEMASK;
+ if (!strcasecmp(str, "alt")) return NX_ALTERNATEMASK;
+ if (!strcasecmp(str, "command")) return NX_COMMANDMASK;
+ if (!strcasecmp(str, "lshift")) return NX_SHIFTMASK;
+ if (!strcasecmp(str, "rshift")) return NX_SHIFTMASK;
+ if (!strcasecmp(str, "lcontrol")) return NX_CONTROLMASK;
+ if (!strcasecmp(str, "rcontrol")) return NX_CONTROLMASK;
+ if (!strcasecmp(str, "loption")) return NX_ALTERNATEMASK;
+ if (!strcasecmp(str, "roption")) return NX_ALTERNATEMASK;
+ if (!strcasecmp(str, "lalt")) return NX_ALTERNATEMASK;
+ if (!strcasecmp(str, "ralt")) return NX_ALTERNATEMASK;
+ if (!strcasecmp(str, "lcommand")) return NX_COMMANDMASK;
+ if (!strcasecmp(str, "rcommand")) return NX_COMMANDMASK;
+#ifdef NX_DEVICELSHIFTKEYMASK
+ }
+#endif
+ if (!strcasecmp(str, "lock")) return NX_ALPHASHIFTMASK;
+ if (!strcasecmp(str, "fn")) return NX_SECONDARYFNMASK;
+ if (!strcasecmp(str, "help")) return NX_HELPMASK;
+ if (!strcasecmp(str, "numlock")) return NX_NUMERICPADMASK;
+ return 0;
+}
+
+/*
+ * LegalModifier
+ * This allows the ddx layer to prevent some keys from being remapped
+ * as modifier keys.
+ */
+Bool LegalModifier(unsigned int key, DeviceIntPtr pDev)
+{
+ return 1;
+}
+
+static inline UniChar macroman2ucs(unsigned char c) {
+ /* Precalculated table mapping MacRoman-128 to Unicode. Generated
+ by creating single element CFStringRefs then extracting the
+ first character. */
+
+ static const unsigned short table[128] = {
+ 0xc4, 0xc5, 0xc7, 0xc9, 0xd1, 0xd6, 0xdc, 0xe1,
+ 0xe0, 0xe2, 0xe4, 0xe3, 0xe5, 0xe7, 0xe9, 0xe8,
+ 0xea, 0xeb, 0xed, 0xec, 0xee, 0xef, 0xf1, 0xf3,
+ 0xf2, 0xf4, 0xf6, 0xf5, 0xfa, 0xf9, 0xfb, 0xfc,
+ 0x2020, 0xb0, 0xa2, 0xa3, 0xa7, 0x2022, 0xb6, 0xdf,
+ 0xae, 0xa9, 0x2122, 0xb4, 0xa8, 0x2260, 0xc6, 0xd8,
+ 0x221e, 0xb1, 0x2264, 0x2265, 0xa5, 0xb5, 0x2202, 0x2211,
+ 0x220f, 0x3c0, 0x222b, 0xaa, 0xba, 0x3a9, 0xe6, 0xf8,
+ 0xbf, 0xa1, 0xac, 0x221a, 0x192, 0x2248, 0x2206, 0xab,
+ 0xbb, 0x2026, 0xa0, 0xc0, 0xc3, 0xd5, 0x152, 0x153,
+ 0x2013, 0x2014, 0x201c, 0x201d, 0x2018, 0x2019, 0xf7, 0x25ca,
+ 0xff, 0x178, 0x2044, 0x20ac, 0x2039, 0x203a, 0xfb01, 0xfb02,
+ 0x2021, 0xb7, 0x201a, 0x201e, 0x2030, 0xc2, 0xca, 0xc1,
+ 0xcb, 0xc8, 0xcd, 0xce, 0xcf, 0xcc, 0xd3, 0xd4,
+ 0xf8ff, 0xd2, 0xda, 0xdb, 0xd9, 0x131, 0x2c6, 0x2dc,
+ 0xaf, 0x2d8, 0x2d9, 0x2da, 0xb8, 0x2dd, 0x2db, 0x2c7,
+ };
+
+ if (c < 128) return c;
+ else return table[c - 128];
+}
+
+static KeySym make_dead_key(KeySym in) {
+ int i;
+
+ for (i = 0; i < sizeof (dead_keys) / sizeof (dead_keys[0]); i++)
+ if (dead_keys[i].normal == in) return dead_keys[i].dead;
+
+ return in;
+}
+
+static Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info) {
+#if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050
+ KeyboardLayoutRef key_layout;
+ int is_uchr = 1;
+#endif
+ const void *chr_data = NULL;
+ int num_keycodes = NUM_KEYCODES;
+ UInt32 keyboard_type = LMGetKbdType();
+ int i, j;
+ OSStatus err;
+ KeySym *k;
+ CFDataRef currentKeyLayoutDataRef = NULL;
+
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
+ TISInputSourceRef currentKeyLayoutRef = TISCopyCurrentKeyboardLayoutInputSource();
+
+ if (currentKeyLayoutRef) {
+ currentKeyLayoutDataRef = (CFDataRef )TISGetInputSourceProperty(currentKeyLayoutRef, kTISPropertyUnicodeKeyLayoutData);
+ if (currentKeyLayoutDataRef)
+ chr_data = CFDataGetBytePtr(currentKeyLayoutDataRef);
+ }
+#endif
+
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations" // KLGetCurrentKeyboardLayout, KLGetKeyboardLayoutProperty
+#endif
+
+#if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050
+ if (chr_data == NULL) {
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
+ ErrorF("X11.app: Error detected in determining keyboard layout. If you are using an Apple-provided keyboard layout, please report this error at http://xquartz.macosforge.org and http://bugreport.apple.com\n");
+ ErrorF("X11.app: Debug Info: keyboard_type=%u, currentKeyLayoutRef=%p, currentKeyLayoutDataRef=%p, chr_data=%p\n",
+ (unsigned)keyboard_type, currentKeyLayoutRef, currentKeyLayoutDataRef, chr_data);
+#endif
+
+ KLGetCurrentKeyboardLayout (&key_layout);
+ KLGetKeyboardLayoutProperty (key_layout, kKLuchrData, &chr_data);
+
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
+ if(chr_data != NULL) {
+ ErrorF("X11.app: Fallback succeeded, but this is still a bug. Please report the above information.\n");
+ }
+#endif
+ }
+
+ if (chr_data == NULL) {
+ ErrorF("X11.app: Debug Info: kKLuchrData failed, trying kKLKCHRData.\n");
+ ErrorF("If you are using a 3rd party keyboard layout, please see http://xquartz.macosforge.org/trac/ticket/154\n");
+ KLGetKeyboardLayoutProperty (key_layout, kKLKCHRData, &chr_data);
+ is_uchr = 0;
+ num_keycodes = 128;
+
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
+ if(chr_data != NULL) {
+ ErrorF("X11.app: Fallback succeeded, but this is still a bug. Please report the above information.\n");
+ }
+#endif
+ }
+#endif
+
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
+ if(currentKeyLayoutRef)
+ CFRelease(currentKeyLayoutRef);
+#endif
+
+ if (chr_data == NULL) {
+ ErrorF ( "Couldn't get uchr or kchr resource\n");
+ return FALSE;
+ }
+
+ /* Scan the keycode range for the Unicode character that each
+ key produces in the four shift states. Then convert that to
+ an X11 keysym (which may just the bit that says "this is
+ Unicode" if it can't find the real symbol.) */
+
+ /* KeyTranslate is not available on 64-bit platforms; UCKeyTranslate
+ must be used instead. */
+
+ for (i = 0; i < num_keycodes; i++) {
+ static const int mods[4] = {0, MOD_SHIFT, MOD_OPTION,
+ MOD_OPTION | MOD_SHIFT};
+
+ k = info->keyMap + i * GLYPHS_PER_KEY;
+
+ for (j = 0; j < 4; j++) {
+#if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050
+ if (is_uchr) {
+#endif
+ UniChar s[8];
+ UniCharCount len;
+ UInt32 dead_key_state = 0, extra_dead = 0;
+
+ err = UCKeyTranslate (chr_data, i, kUCKeyActionDown,
+ mods[j] >> 8, keyboard_type, 0,
+ &dead_key_state, 8, &len, s);
+ if (err != noErr) continue;
+
+ if (len == 0 && dead_key_state != 0) {
+ /* Found a dead key. Work out which one it is, but
+ remembering that it's dead. */
+ err = UCKeyTranslate (chr_data, i, kUCKeyActionDown,
+ mods[j] >> 8, keyboard_type,
+ kUCKeyTranslateNoDeadKeysMask,
+ &extra_dead, 8, &len, s);
+ if (err != noErr) continue;
+ }
+
+ /* Not sure why 0x0010 is there.
+ * 0x0000 - <rdar://problem/7793566> 'Unicode Hex Input' ...
+ */
+ if (len > 0 && s[0] != 0x0010 && s[0] != 0x0000) {
+ k[j] = ucs2keysym (s[0]);
+ if (dead_key_state != 0) k[j] = make_dead_key (k[j]);
+ }
+#if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050
+ } else { // kchr
+ UInt32 c, state = 0, state2 = 0;
+ UInt16 code;
+
+ code = i | mods[j];
+
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations" // KeyTranslate
+#endif
+
+ c = KeyTranslate (chr_data, code, &state);
+
+ /* Dead keys are only processed on key-down, so ask
+ to translate those events. When we find a dead key,
+ translating the matching key up event will give
+ us the actual dead character. */
+
+ if (state != 0)
+ c = KeyTranslate (chr_data, code | 128, &state2);
+
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+
+ /* Characters seem to be in MacRoman encoding. */
+
+ if (c != 0 && c != 0x0010) {
+ k[j] = ucs2keysym (macroman2ucs (c & 255));
+
+ if (state != 0) k[j] = make_dead_key (k[j]);
+ }
+ }
+#endif
+ }
+
+ if (k[3] == k[2]) k[3] = NoSymbol;
+ if (k[1] == k[0]) k[1] = NoSymbol;
+ if (k[0] == k[2] && k[1] == k[3]) k[2] = k[3] = NoSymbol;
+ if (k[3] == k[0] && k[2] == k[1] && k[2] == NoSymbol) k[3] = NoSymbol;
+ }
+
+#if HACK_MISSING
+ /* Fix up some things that are normally missing.. */
+
+ for (i = 0; i < sizeof (known_keys) / sizeof (known_keys[0]); i++) {
+ k = info->keyMap + known_keys[i].keycode * GLYPHS_PER_KEY;
+
+ if ( k[0] == NoSymbol && k[1] == NoSymbol
+ && k[2] == NoSymbol && k[3] == NoSymbol)
+ k[0] = known_keys[i].keysym;
+ }
+#endif
+
+#if HACK_KEYPAD
+ /* And some more things. We find the right symbols for the numeric
+ keypad, but not the KP_ keysyms. So try to convert known keycodes. */
+ for (i = 0; i < sizeof (known_numeric_keys) / sizeof (known_numeric_keys[0]); i++) {
+ k = info->keyMap + known_numeric_keys[i].keycode * GLYPHS_PER_KEY;
+
+ if (k[0] == known_numeric_keys[i].normal)
+ k[0] = known_numeric_keys[i].keypad;
+ }
+#endif
+
+#if HACK_BLACKLIST
+ for (i = 0; i < sizeof (keycode_blacklist) / sizeof (keycode_blacklist[0]); i++) {
+ k = info->keyMap + keycode_blacklist[i] * GLYPHS_PER_KEY;
+ k[0] = k[1] = k[2] = k[3] = NoSymbol;
+ }
+#endif
+
+ DarwinBuildModifierMaps(info);
+
+ return TRUE;
+}
+
+Bool QuartsResyncKeymap(Bool sendDDXEvent) {
+ Bool retval;
+ /* Update keyInfo */
+ pthread_mutex_lock(&keyInfo_mutex);
+ memset(keyInfo.keyMap, 0, sizeof(keyInfo.keyMap));
+ retval = QuartzReadSystemKeymap(&keyInfo);
+ pthread_mutex_unlock(&keyInfo_mutex);
+
+ /* Tell server thread to deal with new keyInfo */
+ if(sendDDXEvent)
+ DarwinSendDDXEvent(kXquartzReloadKeymap, 0);
+
+ return retval;
+}
diff --git a/xorg-server/hw/xquartz/quartzKeyboard.h b/xorg-server/hw/xquartz/quartzKeyboard.h
index bb5e84597..de4aed868 100644
--- a/xorg-server/hw/xquartz/quartzKeyboard.h
+++ b/xorg-server/hw/xquartz/quartzKeyboard.h
@@ -1,56 +1,56 @@
-/*
- * Copyright (c) 2003-2004 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, 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.
- */
-
-#ifndef QUARTZ_KEYBOARD_H
-#define QUARTZ_KEYBOARD_H 1
-
-#define XK_TECHNICAL // needed to get XK_Escape
-#define XK_PUBLISHING
-#include "X11/keysym.h"
-#include "inputstr.h"
-
-// Each key can generate 4 glyphs. They are, in order:
-// unshifted, shifted, modeswitch unshifted, modeswitch shifted
-#define GLYPHS_PER_KEY 4
-#define NUM_KEYCODES 248 // NX_NUMKEYCODES might be better
-#define MIN_KEYCODE XkbMinLegalKeyCode // unfortunately, this isn't 0...
-#define MAX_KEYCODE NUM_KEYCODES + MIN_KEYCODE - 1
-
-/* These functions need to be implemented by Xquartz, XDarwin, etc. */
-Bool QuartsResyncKeymap(Bool sendDDXEvent);
-
-/* Provided for darwinEvents.c */
-void DarwinKeyboardReloadHandler(void);
-int DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide);
-int DarwinModifierNXKeyToNXKeycode(int key, int side);
-int DarwinModifierNXKeyToNXMask(int key);
-int DarwinModifierNXMaskToNXKey(int mask);
-int DarwinModifierStringToNXMask(const char *string, int separatelr);
-
-/* Provided for darwin.c */
-void DarwinKeyboardInit(DeviceIntPtr pDev);
-
-#endif /* QUARTZ_KEYBOARD_H */
+/*
+ * Copyright (c) 2003-2004 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, 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.
+ */
+
+#ifndef QUARTZ_KEYBOARD_H
+#define QUARTZ_KEYBOARD_H 1
+
+#define XK_TECHNICAL // needed to get XK_Escape
+#define XK_PUBLISHING
+#include "X11/keysym.h"
+#include "inputstr.h"
+
+// Each key can generate 4 glyphs. They are, in order:
+// unshifted, shifted, modeswitch unshifted, modeswitch shifted
+#define GLYPHS_PER_KEY 4
+#define NUM_KEYCODES 248 // NX_NUMKEYCODES might be better
+#define MIN_KEYCODE XkbMinLegalKeyCode // unfortunately, this isn't 0...
+#define MAX_KEYCODE NUM_KEYCODES + MIN_KEYCODE - 1
+
+/* These functions need to be implemented by Xquartz, XDarwin, etc. */
+Bool QuartsResyncKeymap(Bool sendDDXEvent);
+
+/* Provided for darwinEvents.c */
+void DarwinKeyboardReloadHandler(void);
+int DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide);
+int DarwinModifierNXKeyToNXKeycode(int key, int side);
+int DarwinModifierNXKeyToNXMask(int key);
+int DarwinModifierNXMaskToNXKey(int mask);
+int DarwinModifierStringToNXMask(const char *string, int separatelr);
+
+/* Provided for darwin.c */
+void DarwinKeyboardInit(DeviceIntPtr pDev);
+
+#endif /* QUARTZ_KEYBOARD_H */
diff --git a/xorg-server/hw/xquartz/quartzRandR.c b/xorg-server/hw/xquartz/quartzRandR.c
index 651352b79..98b382d65 100644
--- a/xorg-server/hw/xquartz/quartzRandR.c
+++ b/xorg-server/hw/xquartz/quartzRandR.c
@@ -1,585 +1,585 @@
-/*
- * Quartz-specific support for the XRandR extension
- *
- * Copyright (c) 2001-2004 Greg Parker and Torrey T. Lyons,
- * 2010 Jan Hauffa.
- * 2010-2011 Apple 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 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.
- */
-
-#include "sanitizedCarbon.h"
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "quartzCommon.h"
-#include "quartzRandR.h"
-#include "quartz.h"
-#include "darwin.h"
-
-#include "X11Application.h"
-
-#include <AvailabilityMacros.h>
-
-#include <X11/extensions/randr.h>
-#include <randrstr.h>
-#include <IOKit/graphics/IOGraphicsTypes.h>
-
-/* TODO: UGLY, find a better way!
- * We want to ignore kXquartzDisplayChanged which are generated by us
- */
-static Bool ignore_next_fake_mode_update = FALSE;
-
-#define FAKE_REFRESH_ROOTLESS 1
-#define FAKE_REFRESH_FULLSCREEN 2
-
-#define DEFAULT_REFRESH 60
-#define kDisplayModeUsableFlags (kDisplayModeValidFlag | kDisplayModeSafeFlag)
-
-#define CALLBACK_SUCCESS 0
-#define CALLBACK_CONTINUE 1
-#define CALLBACK_ERROR -1
-
-typedef int (*QuartzModeCallback)
- (ScreenPtr, QuartzModeInfoPtr, void *);
-
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
-
-static long getDictLong (CFDictionaryRef dictRef, CFStringRef key) {
- long value;
-
- CFNumberRef numRef = (CFNumberRef) CFDictionaryGetValue(dictRef, key);
- if (!numRef)
- return 0;
-
- if (!CFNumberGetValue(numRef, kCFNumberLongType, &value))
- return 0;
- return value;
-}
-
-static double getDictDouble (CFDictionaryRef dictRef, CFStringRef key) {
- double value;
-
- CFNumberRef numRef = (CFNumberRef) CFDictionaryGetValue(dictRef, key);
- if (!numRef)
- return 0.0;
-
- if (!CFNumberGetValue(numRef, kCFNumberDoubleType, &value))
- return 0.0;
- return value;
-}
-
-static void QuartzRandRGetModeInfo (CFDictionaryRef modeRef,
- QuartzModeInfoPtr pMode) {
- pMode->width = (size_t) getDictLong(modeRef, kCGDisplayWidth);
- pMode->height = (size_t) getDictLong(modeRef, kCGDisplayHeight);
- pMode->refresh = (int)(getDictDouble(modeRef, kCGDisplayRefreshRate) + 0.5);
- if (pMode->refresh == 0)
- pMode->refresh = DEFAULT_REFRESH;
- pMode->ref = NULL;
- pMode->pSize = NULL;
-}
-
-static Bool QuartzRandRCopyCurrentModeInfo (CGDirectDisplayID screenId,
- QuartzModeInfoPtr pMode) {
- CFDictionaryRef curModeRef = CGDisplayCurrentMode(screenId);
- if (!curModeRef)
- return FALSE;
-
- QuartzRandRGetModeInfo(curModeRef, pMode);
- pMode->ref = (void *)curModeRef;
- CFRetain(pMode->ref);
- return TRUE;
-}
-
-static Bool QuartzRandRSetCGMode (CGDirectDisplayID screenId,
- QuartzModeInfoPtr pMode) {
- CFDictionaryRef modeRef = (CFDictionaryRef) pMode->ref;
- return (CGDisplaySwitchToMode(screenId, modeRef) == kCGErrorSuccess);
-}
-
-static Bool QuartzRandREnumerateModes (ScreenPtr pScreen,
- QuartzModeCallback callback,
- void *data) {
- Bool retval = FALSE;
- QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
-
- /* Just an 800x600 fallback if we have no attached heads */
- if(pQuartzScreen->displayIDs) {
- CFDictionaryRef curModeRef, modeRef;
- long curBpp;
- CFArrayRef modes;
- QuartzModeInfo modeInfo;
- int i;
- CGDirectDisplayID screenId = pQuartzScreen->displayIDs[0];
-
- curModeRef = CGDisplayCurrentMode(screenId);
- if (!curModeRef)
- return FALSE;
- curBpp = getDictLong(curModeRef, kCGDisplayBitsPerPixel);
-
- modes = CGDisplayAvailableModes(screenId);
- if (!modes)
- return FALSE;
- for (i = 0; i < CFArrayGetCount(modes); i++) {
- int cb;
- modeRef = (CFDictionaryRef) CFArrayGetValueAtIndex(modes, i);
-
- /* Skip modes that are not usable on the current display or have a
- different pixel encoding than the current mode. */
- if (((unsigned long) getDictLong(modeRef, kCGDisplayIOFlags) &
- kDisplayModeUsableFlags) != kDisplayModeUsableFlags)
- continue;
- if (getDictLong(modeRef, kCGDisplayBitsPerPixel) != curBpp)
- continue;
-
- QuartzRandRGetModeInfo(modeRef, &modeInfo);
- modeInfo.ref = (void *)modeRef;
- cb = callback(pScreen, &modeInfo, data);
- if (cb == CALLBACK_CONTINUE)
- retval = TRUE;
- else if (cb == CALLBACK_SUCCESS)
- return TRUE;
- else if (cb == CALLBACK_ERROR)
- return FALSE;
- }
- }
-
- switch(callback(pScreen, &pQuartzScreen->rootlessMode, data)) {
- case CALLBACK_SUCCESS:
- return TRUE;
- case CALLBACK_ERROR:
- return FALSE;
- case CALLBACK_CONTINUE:
- retval = TRUE;
- default:
- break;
- }
-
- switch(callback(pScreen, &pQuartzScreen->fullscreenMode, data)) {
- case CALLBACK_SUCCESS:
- return TRUE;
- case CALLBACK_ERROR:
- return FALSE;
- case CALLBACK_CONTINUE:
- retval = TRUE;
- default:
- break;
- }
-
- return retval;
-}
-
-#else /* we have the new CG APIs from Snow Leopard */
-
-static void QuartzRandRGetModeInfo (CGDisplayModeRef modeRef,
- QuartzModeInfoPtr pMode) {
- pMode->width = CGDisplayModeGetWidth(modeRef);
- pMode->height = CGDisplayModeGetHeight(modeRef);
- pMode->refresh = (int) (CGDisplayModeGetRefreshRate(modeRef) + 0.5);
- if (pMode->refresh == 0)
- pMode->refresh = DEFAULT_REFRESH;
- pMode->ref = NULL;
- pMode->pSize = NULL;
-}
-
-static Bool QuartzRandRCopyCurrentModeInfo (CGDirectDisplayID screenId,
- QuartzModeInfoPtr pMode) {
- CGDisplayModeRef curModeRef = CGDisplayCopyDisplayMode(screenId);
- if (!curModeRef)
- return FALSE;
-
- QuartzRandRGetModeInfo(curModeRef, pMode);
- pMode->ref = curModeRef;
- return TRUE;
-}
-
-static Bool QuartzRandRSetCGMode (CGDirectDisplayID screenId,
- QuartzModeInfoPtr pMode) {
- CGDisplayModeRef modeRef = (CGDisplayModeRef) pMode->ref;
- if (!modeRef)
- return FALSE;
-
- return (CGDisplaySetDisplayMode(screenId, modeRef, NULL) == kCGErrorSuccess);
-}
-
-static Bool QuartzRandREnumerateModes (ScreenPtr pScreen,
- QuartzModeCallback callback,
- void *data) {
- Bool retval = FALSE;
- QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
-
- /* Just an 800x600 fallback if we have no attached heads */
- if(pQuartzScreen->displayIDs) {
- CGDisplayModeRef curModeRef, modeRef;
- CFStringRef curPixelEnc, pixelEnc;
- CFComparisonResult pixelEncEqual;
- CFArrayRef modes;
- QuartzModeInfo modeInfo;
- int i;
- CGDirectDisplayID screenId = pQuartzScreen->displayIDs[0];
-
- curModeRef = CGDisplayCopyDisplayMode(screenId);
- if (!curModeRef)
- return FALSE;
- curPixelEnc = CGDisplayModeCopyPixelEncoding(curModeRef);
- CGDisplayModeRelease(curModeRef);
-
- modes = CGDisplayCopyAllDisplayModes(screenId, NULL);
- if (!modes) {
- CFRelease(curPixelEnc);
- return FALSE;
- }
- for (i = 0; i < CFArrayGetCount(modes); i++) {
- int cb;
- modeRef = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
-
- /* Skip modes that are not usable on the current display or have a
- different pixel encoding than the current mode. */
- if ((CGDisplayModeGetIOFlags(modeRef) & kDisplayModeUsableFlags) !=
- kDisplayModeUsableFlags)
- continue;
- pixelEnc = CGDisplayModeCopyPixelEncoding(modeRef);
- pixelEncEqual = CFStringCompare(pixelEnc, curPixelEnc, 0);
- CFRelease(pixelEnc);
- if (pixelEncEqual != kCFCompareEqualTo)
- continue;
-
- QuartzRandRGetModeInfo(modeRef, &modeInfo);
- modeInfo.ref = modeRef;
- cb = callback(pScreen, &modeInfo, data);
- if (cb == CALLBACK_CONTINUE) {
- retval = TRUE;
- } else if (cb == CALLBACK_SUCCESS) {
- CFRelease(modes);
- CFRelease(curPixelEnc);
- return TRUE;
- } else if (cb == CALLBACK_ERROR) {
- CFRelease(modes);
- CFRelease(curPixelEnc);
- return FALSE;
- }
- }
-
- CFRelease(modes);
- CFRelease(curPixelEnc);
- }
-
- switch(callback(pScreen, &pQuartzScreen->rootlessMode, data)) {
- case CALLBACK_SUCCESS:
- return TRUE;
- case CALLBACK_ERROR:
- return FALSE;
- case CALLBACK_CONTINUE:
- retval = TRUE;
- default:
- break;
- }
-
- switch(callback(pScreen, &pQuartzScreen->fullscreenMode, data)) {
- case CALLBACK_SUCCESS:
- return TRUE;
- case CALLBACK_ERROR:
- return FALSE;
- case CALLBACK_CONTINUE:
- retval = TRUE;
- default:
- break;
- }
-
- return retval;
-}
-
-#endif /* Snow Leopard CoreGraphics APIs */
-
-
-static Bool QuartzRandRModesEqual (QuartzModeInfoPtr pMode1,
- QuartzModeInfoPtr pMode2) {
- return (pMode1->width == pMode2->width) &&
- (pMode1->height == pMode2->height) &&
- (pMode1->refresh == pMode2->refresh);
-}
-
-static Bool QuartzRandRRegisterMode (ScreenPtr pScreen,
- QuartzModeInfoPtr pMode) {
- QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
- Bool isCurrentMode = QuartzRandRModesEqual(&pQuartzScreen->currentMode, pMode);
-
- /* TODO: DPI */
- pMode->pSize = RRRegisterSize(pScreen, pMode->width, pMode->height, pScreen->mmWidth, pScreen->mmHeight);
- if (pMode->pSize) {
- //DEBUG_LOG("registering: %d x %d @ %d %s\n", (int)pMode->width, (int)pMode->height, (int)pMode->refresh, isCurrentMode ? "*" : "");
- RRRegisterRate(pScreen, pMode->pSize, pMode->refresh);
-
- if (isCurrentMode)
- RRSetCurrentConfig(pScreen, RR_Rotate_0, pMode->refresh, pMode->pSize);
-
- return TRUE;
- }
- return FALSE;
-}
-
-static int QuartzRandRRegisterModeCallback (ScreenPtr pScreen,
- QuartzModeInfoPtr pMode,
- void *data __unused) {
- if(QuartzRandRRegisterMode(pScreen, pMode)) {
- return CALLBACK_CONTINUE;
- } else {
- return CALLBACK_ERROR;
- }
-}
-
-static Bool QuartzRandRSetMode(ScreenPtr pScreen, QuartzModeInfoPtr pMode, BOOL doRegister) {
- QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
- Bool captureDisplay = (pMode->refresh != FAKE_REFRESH_FULLSCREEN && pMode->refresh != FAKE_REFRESH_ROOTLESS);
- CGDirectDisplayID screenId;
-
- if(pQuartzScreen->displayIDs == NULL)
- return FALSE;
-
- screenId = pQuartzScreen->displayIDs[0];
- if(XQuartzShieldingWindowLevel == 0 && captureDisplay) {
- if(!X11ApplicationCanEnterRandR())
- return FALSE;
- CGCaptureAllDisplays();
- XQuartzShieldingWindowLevel = CGShieldingWindowLevel(); // 2147483630
- DEBUG_LOG("Display captured. ShieldWindowID: %u, Shield level: %d\n",
- CGShieldingWindowID(screenId), XQuartzShieldingWindowLevel);
- }
-
- if (pQuartzScreen->currentMode.ref && CFEqual(pMode->ref, pQuartzScreen->currentMode.ref)) {
- DEBUG_LOG("Requested RandR resolution matches current CG mode\n");
- } if (QuartzRandRSetCGMode(screenId, pMode)) {
- ignore_next_fake_mode_update = TRUE;
- } else {
- DEBUG_LOG("Error while requesting CG resolution change.\n");
- return FALSE;
- }
-
- /* If the client requested the fake rootless mode, switch to rootless.
- * Otherwise, force fullscreen mode.
- */
- QuartzSetRootless(pMode->refresh == FAKE_REFRESH_ROOTLESS);
- if (pMode->refresh != FAKE_REFRESH_ROOTLESS) {
- QuartzShowFullscreen(TRUE);
- }
-
- if(pQuartzScreen->currentMode.ref)
- CFRelease(pQuartzScreen->currentMode.ref);
- pQuartzScreen->currentMode = *pMode;
- if(pQuartzScreen->currentMode.ref)
- CFRetain(pQuartzScreen->currentMode.ref);
-
- if(XQuartzShieldingWindowLevel != 0 && !captureDisplay) {
- CGReleaseAllDisplays();
- XQuartzShieldingWindowLevel = 0;
- }
-
- return TRUE;
-}
-
-static int QuartzRandRSetModeCallback (ScreenPtr pScreen,
- QuartzModeInfoPtr pMode,
- void *data) {
- QuartzModeInfoPtr pReqMode = (QuartzModeInfoPtr) data;
-
- if (!QuartzRandRModesEqual(pMode, pReqMode))
- return CALLBACK_CONTINUE; /* continue enumeration */
-
- DEBUG_LOG("Found a match for requested RandR resolution (%dx%d@%d).\n", (int)pMode->width, (int)pMode->height, (int)pMode->refresh);
-
- if(QuartzRandRSetMode(pScreen, pMode, FALSE))
- return CALLBACK_SUCCESS;
- else
- return CALLBACK_ERROR;
-}
-
-static Bool QuartzRandRGetInfo (ScreenPtr pScreen, Rotation *rotations) {
- *rotations = RR_Rotate_0; /* TODO: support rotation */
-
- return QuartzRandREnumerateModes(pScreen, QuartzRandRRegisterModeCallback, NULL);
-}
-
-static Bool QuartzRandRSetConfig (ScreenPtr pScreen,
- Rotation randr,
- int rate,
- RRScreenSizePtr pSize) {
- QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
- QuartzModeInfo reqMode;
-
- reqMode.width = pSize->width;
- reqMode.height = pSize->height;
- reqMode.refresh = rate;
-
- /* Do not switch modes if requested mode is equal to current mode. */
- if (QuartzRandRModesEqual(&reqMode, &pQuartzScreen->currentMode))
- return TRUE;
-
- if (QuartzRandREnumerateModes(pScreen, QuartzRandRSetModeCallback, &reqMode)) {
- return TRUE;
- }
-
- DEBUG_LOG("Unable to find a matching config: %d x %d @ %d\n", (int)reqMode.width, (int)reqMode.height, (int)reqMode.refresh);
- return FALSE;
-}
-
-static Bool _QuartzRandRUpdateFakeModes (ScreenPtr pScreen) {
- QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
- QuartzModeInfo activeMode;
-
- if(pQuartzScreen->displayCount > 0) {
- if(!QuartzRandRCopyCurrentModeInfo(pQuartzScreen->displayIDs[0], &activeMode)) {
- ErrorF("Unable to determine current display mode.\n");
- return FALSE;
- }
- } else {
- memset(&activeMode, 0, sizeof(activeMode));
- activeMode.width = 800;
- activeMode.height = 600;
- activeMode.refresh = 60;
- }
-
- if(pQuartzScreen->fullscreenMode.ref)
- CFRelease(pQuartzScreen->fullscreenMode.ref);
- if(pQuartzScreen->currentMode.ref)
- CFRelease(pQuartzScreen->currentMode.ref);
-
- if(pQuartzScreen->displayCount > 1) {
- activeMode.width = pScreen->width;
- activeMode.height = pScreen->height;
- if(XQuartzIsRootless)
- activeMode.height += aquaMenuBarHeight;
- }
-
- pQuartzScreen->fullscreenMode = activeMode;
- pQuartzScreen->fullscreenMode.refresh = FAKE_REFRESH_FULLSCREEN;
-
- pQuartzScreen->rootlessMode = activeMode;
- pQuartzScreen->rootlessMode.refresh = FAKE_REFRESH_ROOTLESS;
- pQuartzScreen->rootlessMode.height -= aquaMenuBarHeight;
-
- if(XQuartzIsRootless) {
- pQuartzScreen->currentMode = pQuartzScreen->rootlessMode;
- } else {
- pQuartzScreen->currentMode = pQuartzScreen->fullscreenMode;
- }
-
- /* This extra retain is for currentMode's copy.
- * fullscreen and rootless share a retain.
- */
- if(pQuartzScreen->currentMode.ref)
- CFRetain(pQuartzScreen->currentMode.ref);
-
- DEBUG_LOG("rootlessMode: %d x %d\n", (int)pQuartzScreen->rootlessMode.width, (int)pQuartzScreen->rootlessMode.height);
- DEBUG_LOG("fullscreenMode: %d x %d\n", (int)pQuartzScreen->fullscreenMode.width, (int)pQuartzScreen->fullscreenMode.height);
- DEBUG_LOG("currentMode: %d x %d\n", (int)pQuartzScreen->currentMode.width, (int)pQuartzScreen->currentMode.height);
-
- return TRUE;
-}
-
-Bool QuartzRandRUpdateFakeModes (BOOL force_update) {
- ScreenPtr pScreen = screenInfo.screens[0];
-
- if(ignore_next_fake_mode_update) {
- DEBUG_LOG("Ignoring update request caused by RandR resolution change.\n");
- ignore_next_fake_mode_update = FALSE;
- return TRUE;
- }
-
- if(!_QuartzRandRUpdateFakeModes(pScreen))
- return FALSE;
-
- if(force_update)
- RRGetInfo(pScreen, TRUE);
-
- return TRUE;
-}
-
-Bool QuartzRandRInit (ScreenPtr pScreen) {
- rrScrPrivPtr pScrPriv;
-
- if (!RRScreenInit (pScreen)) return FALSE;
- if (!_QuartzRandRUpdateFakeModes (pScreen)) return FALSE;
-
- pScrPriv = rrGetScrPriv(pScreen);
- pScrPriv->rrGetInfo = QuartzRandRGetInfo;
- pScrPriv->rrSetConfig = QuartzRandRSetConfig;
- return TRUE;
-}
-
-void QuartzRandRSetFakeRootless (void) {
- int i;
-
- DEBUG_LOG("QuartzRandRSetFakeRootless called.\n");
-
- for (i=0; i < screenInfo.numScreens; i++) {
- ScreenPtr pScreen = screenInfo.screens[i];
- QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
-
- QuartzRandRSetMode(pScreen, &pQuartzScreen->rootlessMode, TRUE);
- }
-}
-
-void QuartzRandRSetFakeFullscreen (BOOL state) {
- int i;
-
- DEBUG_LOG("QuartzRandRSetFakeFullscreen called.\n");
-
- for (i=0; i < screenInfo.numScreens; i++) {
- ScreenPtr pScreen = screenInfo.screens[i];
- QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
-
- QuartzRandRSetMode(pScreen, &pQuartzScreen->fullscreenMode, TRUE);
- }
-
- QuartzShowFullscreen(state);
-}
-
-/* Toggle fullscreen mode. If "fake" fullscreen is the current mode,
- * this will just show/hide the X11 windows. If we are in a RandR fullscreen
- * mode, this will toggles us to the default fake mode and hide windows if
- * it is fullscreen
- */
-void QuartzRandRToggleFullscreen (void) {
- ScreenPtr pScreen = screenInfo.screens[0];
- QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
-
- if (pQuartzScreen->currentMode.ref == NULL) {
- ErrorF("Ignoring QuartzRandRToggleFullscreen because don't have a current mode set.\n");
- } else if (pQuartzScreen->currentMode.refresh == FAKE_REFRESH_ROOTLESS) {
- ErrorF("Ignoring QuartzRandRToggleFullscreen because we are in rootless mode.\n");
- } else if (pQuartzScreen->currentMode.refresh == FAKE_REFRESH_FULLSCREEN) {
- /* Legacy fullscreen mode. Hide/Show */
- QuartzShowFullscreen(!XQuartzFullscreenVisible);
- } else {
- /* RandR fullscreen mode. Return to default mode and hide if it is fullscreen. */
- if(XQuartzRootlessDefault) {
- QuartzRandRSetFakeRootless();
- } else {
- QuartzRandRSetFakeFullscreen(FALSE);
- }
- }
-}
+/*
+ * Quartz-specific support for the XRandR extension
+ *
+ * Copyright (c) 2001-2004 Greg Parker and Torrey T. Lyons,
+ * 2010 Jan Hauffa.
+ * 2010-2011 Apple 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 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.
+ */
+
+#include "sanitizedCarbon.h"
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "quartzCommon.h"
+#include "quartzRandR.h"
+#include "quartz.h"
+#include "darwin.h"
+
+#include "X11Application.h"
+
+#include <AvailabilityMacros.h>
+
+#include <X11/extensions/randr.h>
+#include <randrstr.h>
+#include <IOKit/graphics/IOGraphicsTypes.h>
+
+/* TODO: UGLY, find a better way!
+ * We want to ignore kXquartzDisplayChanged which are generated by us
+ */
+static Bool ignore_next_fake_mode_update = FALSE;
+
+#define FAKE_REFRESH_ROOTLESS 1
+#define FAKE_REFRESH_FULLSCREEN 2
+
+#define DEFAULT_REFRESH 60
+#define kDisplayModeUsableFlags (kDisplayModeValidFlag | kDisplayModeSafeFlag)
+
+#define CALLBACK_SUCCESS 0
+#define CALLBACK_CONTINUE 1
+#define CALLBACK_ERROR -1
+
+typedef int (*QuartzModeCallback)
+ (ScreenPtr, QuartzModeInfoPtr, void *);
+
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
+
+static long getDictLong (CFDictionaryRef dictRef, CFStringRef key) {
+ long value;
+
+ CFNumberRef numRef = (CFNumberRef) CFDictionaryGetValue(dictRef, key);
+ if (!numRef)
+ return 0;
+
+ if (!CFNumberGetValue(numRef, kCFNumberLongType, &value))
+ return 0;
+ return value;
+}
+
+static double getDictDouble (CFDictionaryRef dictRef, CFStringRef key) {
+ double value;
+
+ CFNumberRef numRef = (CFNumberRef) CFDictionaryGetValue(dictRef, key);
+ if (!numRef)
+ return 0.0;
+
+ if (!CFNumberGetValue(numRef, kCFNumberDoubleType, &value))
+ return 0.0;
+ return value;
+}
+
+static void QuartzRandRGetModeInfo (CFDictionaryRef modeRef,
+ QuartzModeInfoPtr pMode) {
+ pMode->width = (size_t) getDictLong(modeRef, kCGDisplayWidth);
+ pMode->height = (size_t) getDictLong(modeRef, kCGDisplayHeight);
+ pMode->refresh = (int)(getDictDouble(modeRef, kCGDisplayRefreshRate) + 0.5);
+ if (pMode->refresh == 0)
+ pMode->refresh = DEFAULT_REFRESH;
+ pMode->ref = NULL;
+ pMode->pSize = NULL;
+}
+
+static Bool QuartzRandRCopyCurrentModeInfo (CGDirectDisplayID screenId,
+ QuartzModeInfoPtr pMode) {
+ CFDictionaryRef curModeRef = CGDisplayCurrentMode(screenId);
+ if (!curModeRef)
+ return FALSE;
+
+ QuartzRandRGetModeInfo(curModeRef, pMode);
+ pMode->ref = (void *)curModeRef;
+ CFRetain(pMode->ref);
+ return TRUE;
+}
+
+static Bool QuartzRandRSetCGMode (CGDirectDisplayID screenId,
+ QuartzModeInfoPtr pMode) {
+ CFDictionaryRef modeRef = (CFDictionaryRef) pMode->ref;
+ return (CGDisplaySwitchToMode(screenId, modeRef) == kCGErrorSuccess);
+}
+
+static Bool QuartzRandREnumerateModes (ScreenPtr pScreen,
+ QuartzModeCallback callback,
+ void *data) {
+ Bool retval = FALSE;
+ QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
+
+ /* Just an 800x600 fallback if we have no attached heads */
+ if(pQuartzScreen->displayIDs) {
+ CFDictionaryRef curModeRef, modeRef;
+ long curBpp;
+ CFArrayRef modes;
+ QuartzModeInfo modeInfo;
+ int i;
+ CGDirectDisplayID screenId = pQuartzScreen->displayIDs[0];
+
+ curModeRef = CGDisplayCurrentMode(screenId);
+ if (!curModeRef)
+ return FALSE;
+ curBpp = getDictLong(curModeRef, kCGDisplayBitsPerPixel);
+
+ modes = CGDisplayAvailableModes(screenId);
+ if (!modes)
+ return FALSE;
+ for (i = 0; i < CFArrayGetCount(modes); i++) {
+ int cb;
+ modeRef = (CFDictionaryRef) CFArrayGetValueAtIndex(modes, i);
+
+ /* Skip modes that are not usable on the current display or have a
+ different pixel encoding than the current mode. */
+ if (((unsigned long) getDictLong(modeRef, kCGDisplayIOFlags) &
+ kDisplayModeUsableFlags) != kDisplayModeUsableFlags)
+ continue;
+ if (getDictLong(modeRef, kCGDisplayBitsPerPixel) != curBpp)
+ continue;
+
+ QuartzRandRGetModeInfo(modeRef, &modeInfo);
+ modeInfo.ref = (void *)modeRef;
+ cb = callback(pScreen, &modeInfo, data);
+ if (cb == CALLBACK_CONTINUE)
+ retval = TRUE;
+ else if (cb == CALLBACK_SUCCESS)
+ return TRUE;
+ else if (cb == CALLBACK_ERROR)
+ return FALSE;
+ }
+ }
+
+ switch(callback(pScreen, &pQuartzScreen->rootlessMode, data)) {
+ case CALLBACK_SUCCESS:
+ return TRUE;
+ case CALLBACK_ERROR:
+ return FALSE;
+ case CALLBACK_CONTINUE:
+ retval = TRUE;
+ default:
+ break;
+ }
+
+ switch(callback(pScreen, &pQuartzScreen->fullscreenMode, data)) {
+ case CALLBACK_SUCCESS:
+ return TRUE;
+ case CALLBACK_ERROR:
+ return FALSE;
+ case CALLBACK_CONTINUE:
+ retval = TRUE;
+ default:
+ break;
+ }
+
+ return retval;
+}
+
+#else /* we have the new CG APIs from Snow Leopard */
+
+static void QuartzRandRGetModeInfo (CGDisplayModeRef modeRef,
+ QuartzModeInfoPtr pMode) {
+ pMode->width = CGDisplayModeGetWidth(modeRef);
+ pMode->height = CGDisplayModeGetHeight(modeRef);
+ pMode->refresh = (int) (CGDisplayModeGetRefreshRate(modeRef) + 0.5);
+ if (pMode->refresh == 0)
+ pMode->refresh = DEFAULT_REFRESH;
+ pMode->ref = NULL;
+ pMode->pSize = NULL;
+}
+
+static Bool QuartzRandRCopyCurrentModeInfo (CGDirectDisplayID screenId,
+ QuartzModeInfoPtr pMode) {
+ CGDisplayModeRef curModeRef = CGDisplayCopyDisplayMode(screenId);
+ if (!curModeRef)
+ return FALSE;
+
+ QuartzRandRGetModeInfo(curModeRef, pMode);
+ pMode->ref = curModeRef;
+ return TRUE;
+}
+
+static Bool QuartzRandRSetCGMode (CGDirectDisplayID screenId,
+ QuartzModeInfoPtr pMode) {
+ CGDisplayModeRef modeRef = (CGDisplayModeRef) pMode->ref;
+ if (!modeRef)
+ return FALSE;
+
+ return (CGDisplaySetDisplayMode(screenId, modeRef, NULL) == kCGErrorSuccess);
+}
+
+static Bool QuartzRandREnumerateModes (ScreenPtr pScreen,
+ QuartzModeCallback callback,
+ void *data) {
+ Bool retval = FALSE;
+ QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
+
+ /* Just an 800x600 fallback if we have no attached heads */
+ if(pQuartzScreen->displayIDs) {
+ CGDisplayModeRef curModeRef, modeRef;
+ CFStringRef curPixelEnc, pixelEnc;
+ CFComparisonResult pixelEncEqual;
+ CFArrayRef modes;
+ QuartzModeInfo modeInfo;
+ int i;
+ CGDirectDisplayID screenId = pQuartzScreen->displayIDs[0];
+
+ curModeRef = CGDisplayCopyDisplayMode(screenId);
+ if (!curModeRef)
+ return FALSE;
+ curPixelEnc = CGDisplayModeCopyPixelEncoding(curModeRef);
+ CGDisplayModeRelease(curModeRef);
+
+ modes = CGDisplayCopyAllDisplayModes(screenId, NULL);
+ if (!modes) {
+ CFRelease(curPixelEnc);
+ return FALSE;
+ }
+ for (i = 0; i < CFArrayGetCount(modes); i++) {
+ int cb;
+ modeRef = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
+
+ /* Skip modes that are not usable on the current display or have a
+ different pixel encoding than the current mode. */
+ if ((CGDisplayModeGetIOFlags(modeRef) & kDisplayModeUsableFlags) !=
+ kDisplayModeUsableFlags)
+ continue;
+ pixelEnc = CGDisplayModeCopyPixelEncoding(modeRef);
+ pixelEncEqual = CFStringCompare(pixelEnc, curPixelEnc, 0);
+ CFRelease(pixelEnc);
+ if (pixelEncEqual != kCFCompareEqualTo)
+ continue;
+
+ QuartzRandRGetModeInfo(modeRef, &modeInfo);
+ modeInfo.ref = modeRef;
+ cb = callback(pScreen, &modeInfo, data);
+ if (cb == CALLBACK_CONTINUE) {
+ retval = TRUE;
+ } else if (cb == CALLBACK_SUCCESS) {
+ CFRelease(modes);
+ CFRelease(curPixelEnc);
+ return TRUE;
+ } else if (cb == CALLBACK_ERROR) {
+ CFRelease(modes);
+ CFRelease(curPixelEnc);
+ return FALSE;
+ }
+ }
+
+ CFRelease(modes);
+ CFRelease(curPixelEnc);
+ }
+
+ switch(callback(pScreen, &pQuartzScreen->rootlessMode, data)) {
+ case CALLBACK_SUCCESS:
+ return TRUE;
+ case CALLBACK_ERROR:
+ return FALSE;
+ case CALLBACK_CONTINUE:
+ retval = TRUE;
+ default:
+ break;
+ }
+
+ switch(callback(pScreen, &pQuartzScreen->fullscreenMode, data)) {
+ case CALLBACK_SUCCESS:
+ return TRUE;
+ case CALLBACK_ERROR:
+ return FALSE;
+ case CALLBACK_CONTINUE:
+ retval = TRUE;
+ default:
+ break;
+ }
+
+ return retval;
+}
+
+#endif /* Snow Leopard CoreGraphics APIs */
+
+
+static Bool QuartzRandRModesEqual (QuartzModeInfoPtr pMode1,
+ QuartzModeInfoPtr pMode2) {
+ return (pMode1->width == pMode2->width) &&
+ (pMode1->height == pMode2->height) &&
+ (pMode1->refresh == pMode2->refresh);
+}
+
+static Bool QuartzRandRRegisterMode (ScreenPtr pScreen,
+ QuartzModeInfoPtr pMode) {
+ QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
+ Bool isCurrentMode = QuartzRandRModesEqual(&pQuartzScreen->currentMode, pMode);
+
+ /* TODO: DPI */
+ pMode->pSize = RRRegisterSize(pScreen, pMode->width, pMode->height, pScreen->mmWidth, pScreen->mmHeight);
+ if (pMode->pSize) {
+ //DEBUG_LOG("registering: %d x %d @ %d %s\n", (int)pMode->width, (int)pMode->height, (int)pMode->refresh, isCurrentMode ? "*" : "");
+ RRRegisterRate(pScreen, pMode->pSize, pMode->refresh);
+
+ if (isCurrentMode)
+ RRSetCurrentConfig(pScreen, RR_Rotate_0, pMode->refresh, pMode->pSize);
+
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static int QuartzRandRRegisterModeCallback (ScreenPtr pScreen,
+ QuartzModeInfoPtr pMode,
+ void *data __unused) {
+ if(QuartzRandRRegisterMode(pScreen, pMode)) {
+ return CALLBACK_CONTINUE;
+ } else {
+ return CALLBACK_ERROR;
+ }
+}
+
+static Bool QuartzRandRSetMode(ScreenPtr pScreen, QuartzModeInfoPtr pMode, BOOL doRegister) {
+ QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
+ Bool captureDisplay = (pMode->refresh != FAKE_REFRESH_FULLSCREEN && pMode->refresh != FAKE_REFRESH_ROOTLESS);
+ CGDirectDisplayID screenId;
+
+ if(pQuartzScreen->displayIDs == NULL)
+ return FALSE;
+
+ screenId = pQuartzScreen->displayIDs[0];
+ if(XQuartzShieldingWindowLevel == 0 && captureDisplay) {
+ if(!X11ApplicationCanEnterRandR())
+ return FALSE;
+ CGCaptureAllDisplays();
+ XQuartzShieldingWindowLevel = CGShieldingWindowLevel(); // 2147483630
+ DEBUG_LOG("Display captured. ShieldWindowID: %u, Shield level: %d\n",
+ CGShieldingWindowID(screenId), XQuartzShieldingWindowLevel);
+ }
+
+ if (pQuartzScreen->currentMode.ref && CFEqual(pMode->ref, pQuartzScreen->currentMode.ref)) {
+ DEBUG_LOG("Requested RandR resolution matches current CG mode\n");
+ } if (QuartzRandRSetCGMode(screenId, pMode)) {
+ ignore_next_fake_mode_update = TRUE;
+ } else {
+ DEBUG_LOG("Error while requesting CG resolution change.\n");
+ return FALSE;
+ }
+
+ /* If the client requested the fake rootless mode, switch to rootless.
+ * Otherwise, force fullscreen mode.
+ */
+ QuartzSetRootless(pMode->refresh == FAKE_REFRESH_ROOTLESS);
+ if (pMode->refresh != FAKE_REFRESH_ROOTLESS) {
+ QuartzShowFullscreen(TRUE);
+ }
+
+ if(pQuartzScreen->currentMode.ref)
+ CFRelease(pQuartzScreen->currentMode.ref);
+ pQuartzScreen->currentMode = *pMode;
+ if(pQuartzScreen->currentMode.ref)
+ CFRetain(pQuartzScreen->currentMode.ref);
+
+ if(XQuartzShieldingWindowLevel != 0 && !captureDisplay) {
+ CGReleaseAllDisplays();
+ XQuartzShieldingWindowLevel = 0;
+ }
+
+ return TRUE;
+}
+
+static int QuartzRandRSetModeCallback (ScreenPtr pScreen,
+ QuartzModeInfoPtr pMode,
+ void *data) {
+ QuartzModeInfoPtr pReqMode = (QuartzModeInfoPtr) data;
+
+ if (!QuartzRandRModesEqual(pMode, pReqMode))
+ return CALLBACK_CONTINUE; /* continue enumeration */
+
+ DEBUG_LOG("Found a match for requested RandR resolution (%dx%d@%d).\n", (int)pMode->width, (int)pMode->height, (int)pMode->refresh);
+
+ if(QuartzRandRSetMode(pScreen, pMode, FALSE))
+ return CALLBACK_SUCCESS;
+ else
+ return CALLBACK_ERROR;
+}
+
+static Bool QuartzRandRGetInfo (ScreenPtr pScreen, Rotation *rotations) {
+ *rotations = RR_Rotate_0; /* TODO: support rotation */
+
+ return QuartzRandREnumerateModes(pScreen, QuartzRandRRegisterModeCallback, NULL);
+}
+
+static Bool QuartzRandRSetConfig (ScreenPtr pScreen,
+ Rotation randr,
+ int rate,
+ RRScreenSizePtr pSize) {
+ QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
+ QuartzModeInfo reqMode;
+
+ reqMode.width = pSize->width;
+ reqMode.height = pSize->height;
+ reqMode.refresh = rate;
+
+ /* Do not switch modes if requested mode is equal to current mode. */
+ if (QuartzRandRModesEqual(&reqMode, &pQuartzScreen->currentMode))
+ return TRUE;
+
+ if (QuartzRandREnumerateModes(pScreen, QuartzRandRSetModeCallback, &reqMode)) {
+ return TRUE;
+ }
+
+ DEBUG_LOG("Unable to find a matching config: %d x %d @ %d\n", (int)reqMode.width, (int)reqMode.height, (int)reqMode.refresh);
+ return FALSE;
+}
+
+static Bool _QuartzRandRUpdateFakeModes (ScreenPtr pScreen) {
+ QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
+ QuartzModeInfo activeMode;
+
+ if(pQuartzScreen->displayCount > 0) {
+ if(!QuartzRandRCopyCurrentModeInfo(pQuartzScreen->displayIDs[0], &activeMode)) {
+ ErrorF("Unable to determine current display mode.\n");
+ return FALSE;
+ }
+ } else {
+ memset(&activeMode, 0, sizeof(activeMode));
+ activeMode.width = 800;
+ activeMode.height = 600;
+ activeMode.refresh = 60;
+ }
+
+ if(pQuartzScreen->fullscreenMode.ref)
+ CFRelease(pQuartzScreen->fullscreenMode.ref);
+ if(pQuartzScreen->currentMode.ref)
+ CFRelease(pQuartzScreen->currentMode.ref);
+
+ if(pQuartzScreen->displayCount > 1) {
+ activeMode.width = pScreen->width;
+ activeMode.height = pScreen->height;
+ if(XQuartzIsRootless)
+ activeMode.height += aquaMenuBarHeight;
+ }
+
+ pQuartzScreen->fullscreenMode = activeMode;
+ pQuartzScreen->fullscreenMode.refresh = FAKE_REFRESH_FULLSCREEN;
+
+ pQuartzScreen->rootlessMode = activeMode;
+ pQuartzScreen->rootlessMode.refresh = FAKE_REFRESH_ROOTLESS;
+ pQuartzScreen->rootlessMode.height -= aquaMenuBarHeight;
+
+ if(XQuartzIsRootless) {
+ pQuartzScreen->currentMode = pQuartzScreen->rootlessMode;
+ } else {
+ pQuartzScreen->currentMode = pQuartzScreen->fullscreenMode;
+ }
+
+ /* This extra retain is for currentMode's copy.
+ * fullscreen and rootless share a retain.
+ */
+ if(pQuartzScreen->currentMode.ref)
+ CFRetain(pQuartzScreen->currentMode.ref);
+
+ DEBUG_LOG("rootlessMode: %d x %d\n", (int)pQuartzScreen->rootlessMode.width, (int)pQuartzScreen->rootlessMode.height);
+ DEBUG_LOG("fullscreenMode: %d x %d\n", (int)pQuartzScreen->fullscreenMode.width, (int)pQuartzScreen->fullscreenMode.height);
+ DEBUG_LOG("currentMode: %d x %d\n", (int)pQuartzScreen->currentMode.width, (int)pQuartzScreen->currentMode.height);
+
+ return TRUE;
+}
+
+Bool QuartzRandRUpdateFakeModes (BOOL force_update) {
+ ScreenPtr pScreen = screenInfo.screens[0];
+
+ if(ignore_next_fake_mode_update) {
+ DEBUG_LOG("Ignoring update request caused by RandR resolution change.\n");
+ ignore_next_fake_mode_update = FALSE;
+ return TRUE;
+ }
+
+ if(!_QuartzRandRUpdateFakeModes(pScreen))
+ return FALSE;
+
+ if(force_update)
+ RRGetInfo(pScreen, TRUE);
+
+ return TRUE;
+}
+
+Bool QuartzRandRInit (ScreenPtr pScreen) {
+ rrScrPrivPtr pScrPriv;
+
+ if (!RRScreenInit (pScreen)) return FALSE;
+ if (!_QuartzRandRUpdateFakeModes (pScreen)) return FALSE;
+
+ pScrPriv = rrGetScrPriv(pScreen);
+ pScrPriv->rrGetInfo = QuartzRandRGetInfo;
+ pScrPriv->rrSetConfig = QuartzRandRSetConfig;
+ return TRUE;
+}
+
+void QuartzRandRSetFakeRootless (void) {
+ int i;
+
+ DEBUG_LOG("QuartzRandRSetFakeRootless called.\n");
+
+ for (i=0; i < screenInfo.numScreens; i++) {
+ ScreenPtr pScreen = screenInfo.screens[i];
+ QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
+
+ QuartzRandRSetMode(pScreen, &pQuartzScreen->rootlessMode, TRUE);
+ }
+}
+
+void QuartzRandRSetFakeFullscreen (BOOL state) {
+ int i;
+
+ DEBUG_LOG("QuartzRandRSetFakeFullscreen called.\n");
+
+ for (i=0; i < screenInfo.numScreens; i++) {
+ ScreenPtr pScreen = screenInfo.screens[i];
+ QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
+
+ QuartzRandRSetMode(pScreen, &pQuartzScreen->fullscreenMode, TRUE);
+ }
+
+ QuartzShowFullscreen(state);
+}
+
+/* Toggle fullscreen mode. If "fake" fullscreen is the current mode,
+ * this will just show/hide the X11 windows. If we are in a RandR fullscreen
+ * mode, this will toggles us to the default fake mode and hide windows if
+ * it is fullscreen
+ */
+void QuartzRandRToggleFullscreen (void) {
+ ScreenPtr pScreen = screenInfo.screens[0];
+ QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
+
+ if (pQuartzScreen->currentMode.ref == NULL) {
+ ErrorF("Ignoring QuartzRandRToggleFullscreen because don't have a current mode set.\n");
+ } else if (pQuartzScreen->currentMode.refresh == FAKE_REFRESH_ROOTLESS) {
+ ErrorF("Ignoring QuartzRandRToggleFullscreen because we are in rootless mode.\n");
+ } else if (pQuartzScreen->currentMode.refresh == FAKE_REFRESH_FULLSCREEN) {
+ /* Legacy fullscreen mode. Hide/Show */
+ QuartzShowFullscreen(!XQuartzFullscreenVisible);
+ } else {
+ /* RandR fullscreen mode. Return to default mode and hide if it is fullscreen. */
+ if(XQuartzRootlessDefault) {
+ QuartzRandRSetFakeRootless();
+ } else {
+ QuartzRandRSetFakeFullscreen(FALSE);
+ }
+ }
+}
diff --git a/xorg-server/hw/xquartz/quartzStartup.c b/xorg-server/hw/xquartz/quartzStartup.c
index e70194948..25ef76efa 100644
--- a/xorg-server/hw/xquartz/quartzStartup.c
+++ b/xorg-server/hw/xquartz/quartzStartup.c
@@ -1,119 +1,119 @@
-/**************************************************************
- *
- * Startup code for the Quartz Darwin X Server
- *
- * Copyright (c) 2001-2004 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, 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.
- */
-
-#include "sanitizedCarbon.h"
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <fcntl.h>
-#include <unistd.h>
-#include <CoreFoundation/CoreFoundation.h>
-#include "quartzCommon.h"
-#include "X11Controller.h"
-#include "darwin.h"
-#include "darwinEvents.h"
-#include "quartz.h"
-#include "opaque.h"
-#include "micmap.h"
-
-#include <assert.h>
-
-#include <pthread.h>
-
-int dix_main(int argc, char **argv, char **envp);
-
-struct arg {
- int argc;
- char **argv;
- char **envp;
-};
-
-_X_NORETURN
-static void server_thread (void *arg) {
- struct arg args = *((struct arg *)arg);
- free(arg);
- exit (dix_main(args.argc, args.argv, args.envp));
-}
-
-static pthread_t create_thread (void *func, void *arg) {
- pthread_attr_t attr;
- pthread_t tid;
-
- pthread_attr_init (&attr);
- pthread_attr_setscope (&attr, PTHREAD_SCOPE_SYSTEM);
- pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
- pthread_create (&tid, &attr, func, arg);
- pthread_attr_destroy (&attr);
-
- return tid;
-}
-
-void QuartzInitServer(int argc, char **argv, char **envp) {
- struct arg *args = (struct arg*)malloc(sizeof(struct arg));
- if(!args)
- FatalError("Could not allocate memory.\n");
-
- args->argc = argc;
- args->argv = argv;
- args->envp = envp;
-
- if (!create_thread(server_thread, args)) {
- FatalError("can't create secondary thread\n");
- }
-}
-
-int server_main(int argc, char **argv, char **envp) {
- int i;
- int fd[2];
-
- /* Unset CFProcessPath, so our children don't inherit this kludge we need
- * to load our nib. If an xterm gets this set, then it fails to
- * 'open hi.txt' properly.
- */
- unsetenv("CFProcessPath");
-
- // Make a pipe to pass events
- assert( pipe(fd) == 0 );
- darwinEventReadFD = fd[0];
- darwinEventWriteFD = fd[1];
- fcntl(darwinEventReadFD, F_SETFL, O_NONBLOCK);
-
- for (i = 1; i < argc; i++) {
- // Display version info without starting Mac OS X UI if requested
- if (!strcmp( argv[i], "-showconfig" ) || !strcmp( argv[i], "-version" )) {
- DarwinPrintBanner();
- exit(0);
- }
- }
-
- X11ControllerMain(argc, argv, envp);
- exit(0);
-}
+/**************************************************************
+ *
+ * Startup code for the Quartz Darwin X Server
+ *
+ * Copyright (c) 2001-2004 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, 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.
+ */
+
+#include "sanitizedCarbon.h"
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <fcntl.h>
+#include <unistd.h>
+#include <CoreFoundation/CoreFoundation.h>
+#include "quartzCommon.h"
+#include "X11Controller.h"
+#include "darwin.h"
+#include "darwinEvents.h"
+#include "quartz.h"
+#include "opaque.h"
+#include "micmap.h"
+
+#include <assert.h>
+
+#include <pthread.h>
+
+int dix_main(int argc, char **argv, char **envp);
+
+struct arg {
+ int argc;
+ char **argv;
+ char **envp;
+};
+
+_X_NORETURN
+static void server_thread (void *arg) {
+ struct arg args = *((struct arg *)arg);
+ free(arg);
+ exit (dix_main(args.argc, args.argv, args.envp));
+}
+
+static pthread_t create_thread (void *func, void *arg) {
+ pthread_attr_t attr;
+ pthread_t tid;
+
+ pthread_attr_init (&attr);
+ pthread_attr_setscope (&attr, PTHREAD_SCOPE_SYSTEM);
+ pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
+ pthread_create (&tid, &attr, func, arg);
+ pthread_attr_destroy (&attr);
+
+ return tid;
+}
+
+void QuartzInitServer(int argc, char **argv, char **envp) {
+ struct arg *args = (struct arg*)malloc(sizeof(struct arg));
+ if(!args)
+ FatalError("Could not allocate memory.\n");
+
+ args->argc = argc;
+ args->argv = argv;
+ args->envp = envp;
+
+ if (!create_thread(server_thread, args)) {
+ FatalError("can't create secondary thread\n");
+ }
+}
+
+int server_main(int argc, char **argv, char **envp) {
+ int i;
+ int fd[2];
+
+ /* Unset CFProcessPath, so our children don't inherit this kludge we need
+ * to load our nib. If an xterm gets this set, then it fails to
+ * 'open hi.txt' properly.
+ */
+ unsetenv("CFProcessPath");
+
+ // Make a pipe to pass events
+ assert( pipe(fd) == 0 );
+ darwinEventReadFD = fd[0];
+ darwinEventWriteFD = fd[1];
+ fcntl(darwinEventReadFD, F_SETFL, O_NONBLOCK);
+
+ for (i = 1; i < argc; i++) {
+ // Display version info without starting Mac OS X UI if requested
+ if (!strcmp( argv[i], "-showconfig" ) || !strcmp( argv[i], "-version" )) {
+ DarwinPrintBanner();
+ exit(0);
+ }
+ }
+
+ X11ControllerMain(argc, argv, envp);
+ exit(0);
+}
diff --git a/xorg-server/hw/xquartz/sanitizedCocoa.h b/xorg-server/hw/xquartz/sanitizedCocoa.h
index 5112ddf5a..5a2a282d1 100644
--- a/xorg-server/hw/xquartz/sanitizedCocoa.h
+++ b/xorg-server/hw/xquartz/sanitizedCocoa.h
@@ -1,64 +1,64 @@
-/*
- * Don't #include any of the AppKit, etc stuff directly since it will
- * pollute the X11 namespace.
- */
-
-#ifndef _XQ_SANITIZED_COCOA_H_
-#define _XQ_SANITIZED_COCOA_H_
-
-// QuickDraw in ApplicationServices has the following conflicts with
-// the basic X server headers. Use QD_<name> to use the QuickDraw
-// definition of any of these symbols, or the normal name for the
-// X11 definition.
-#define Cursor QD_Cursor
-#define WindowPtr QD_WindowPtr
-#define Picture QD_Picture
-#define BOOL OSX_BOOL
-#define EventType HIT_EventType
-
-#import <Cocoa/Cocoa.h>
-#import <Foundation/Foundation.h>
-
-#undef Cursor
-#undef WindowPtr
-#undef Picture
-#undef BOOL
-#undef EventType
-
-#ifndef __has_feature
-#define __has_feature(x) 0 // Compatibility with non-clang compilers.
-#endif
-
-#ifndef NS_RETURNS_RETAINED
-#if __has_feature(attribute_ns_returns_retained)
-#define NS_RETURNS_RETAINED __attribute__((ns_returns_retained))
-#else
-#define NS_RETURNS_RETAINED
-#endif
-#endif
-
-#ifndef NS_RETURNS_NOT_RETAINED
-#if __has_feature(attribute_ns_returns_not_retained)
-#define NS_RETURNS_NOT_RETAINED __attribute__((ns_returns_not_retained))
-#else
-#define NS_RETURNS_NOT_RETAINED
-#endif
-#endif
-
-#ifndef CF_RETURNS_RETAINED
-#if __has_feature(attribute_cf_returns_retained)
-#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained))
-#else
-#define CF_RETURNS_RETAINED
-#endif
-#endif
-
-#ifndef CF_RETURNS_NOT_RETAINED
-#if __has_feature(attribute_cf_returns_not_retained)
-#define CF_RETURNS_NOT_RETAINED __attribute__((cf_returns_not_retained))
-#else
-#define CF_RETURNS_NOT_RETAINED
-#endif
-#endif
-
-#endif /* _XQ_SANITIZED_COCOA_H_ */
+/*
+ * Don't #include any of the AppKit, etc stuff directly since it will
+ * pollute the X11 namespace.
+ */
+
+#ifndef _XQ_SANITIZED_COCOA_H_
+#define _XQ_SANITIZED_COCOA_H_
+
+// QuickDraw in ApplicationServices has the following conflicts with
+// the basic X server headers. Use QD_<name> to use the QuickDraw
+// definition of any of these symbols, or the normal name for the
+// X11 definition.
+#define Cursor QD_Cursor
+#define WindowPtr QD_WindowPtr
+#define Picture QD_Picture
+#define BOOL OSX_BOOL
+#define EventType HIT_EventType
+
+#import <Cocoa/Cocoa.h>
+#import <Foundation/Foundation.h>
+
+#undef Cursor
+#undef WindowPtr
+#undef Picture
+#undef BOOL
+#undef EventType
+
+#ifndef __has_feature
+#define __has_feature(x) 0 // Compatibility with non-clang compilers.
+#endif
+
+#ifndef NS_RETURNS_RETAINED
+#if __has_feature(attribute_ns_returns_retained)
+#define NS_RETURNS_RETAINED __attribute__((ns_returns_retained))
+#else
+#define NS_RETURNS_RETAINED
+#endif
+#endif
+
+#ifndef NS_RETURNS_NOT_RETAINED
+#if __has_feature(attribute_ns_returns_not_retained)
+#define NS_RETURNS_NOT_RETAINED __attribute__((ns_returns_not_retained))
+#else
+#define NS_RETURNS_NOT_RETAINED
+#endif
+#endif
+
+#ifndef CF_RETURNS_RETAINED
+#if __has_feature(attribute_cf_returns_retained)
+#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained))
+#else
+#define CF_RETURNS_RETAINED
+#endif
+#endif
+
+#ifndef CF_RETURNS_NOT_RETAINED
+#if __has_feature(attribute_cf_returns_not_retained)
+#define CF_RETURNS_NOT_RETAINED __attribute__((cf_returns_not_retained))
+#else
+#define CF_RETURNS_NOT_RETAINED
+#endif
+#endif
+
+#endif /* _XQ_SANITIZED_COCOA_H_ */
diff --git a/xorg-server/hw/xquartz/xpr/dri.c b/xorg-server/hw/xquartz/xpr/dri.c
index 63fcabe38..8bae6b009 100644
--- a/xorg-server/hw/xquartz/xpr/dri.c
+++ b/xorg-server/hw/xquartz/xpr/dri.c
@@ -1,884 +1,884 @@
-/**************************************************************************
-
-Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
-Copyright 2000 VA Linux Systems, Inc.
-Copyright (c) 2002, 2009 Apple Computer, 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, 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.
-
-**************************************************************************/
-
-/*
- * Authors:
- * Jens Owen <jens@valinux.com>
- * Rickard E. (Rik) Faith <faith@valinux.com>
- *
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#ifdef XFree86LOADER
-#include "xf86.h"
-#include "xf86_ansic.h"
-#else
-#include <sys/time.h>
-#include <unistd.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include <fcntl.h>
-#include <sys/mman.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include "misc.h"
-#include "dixstruct.h"
-#include "extnsionst.h"
-#include "colormapst.h"
-#include "cursorstr.h"
-#include "scrnintstr.h"
-#include "windowstr.h"
-#include "servermd.h"
-#define _APPLEDRI_SERVER_
-#include "appledristr.h"
-#include "swaprep.h"
-#include "dri.h"
-#include "dristruct.h"
-#include "mi.h"
-#include "mipointer.h"
-#include "rootless.h"
-#include "x-hash.h"
-#include "x-hook.h"
-#include "driWrap.h"
-
-#include <AvailabilityMacros.h>
-
-static DevPrivateKeyRec DRIScreenPrivKeyRec;
-#define DRIScreenPrivKey (&DRIScreenPrivKeyRec)
-static DevPrivateKeyRec DRIWindowPrivKeyRec;
-#define DRIWindowPrivKey (&DRIWindowPrivKeyRec)
-static DevPrivateKeyRec DRIPixmapPrivKeyRec;
-#define DRIPixmapPrivKey (&DRIPixmapPrivKeyRec)
-static DevPrivateKeyRec DRIPixmapBufferPrivKeyRec;
-#define DRIPixmapBufferPrivKey (&DRIPixmapBufferPrivKeyRec)
-
-static RESTYPE DRIDrawablePrivResType;
-
-static x_hash_table *surface_hash; /* maps surface ids -> drawablePrivs */
-
-static Bool DRIFreePixmapImp(DrawablePtr pDrawable);
-
-typedef struct {
- DrawablePtr pDrawable;
- int refCount;
- int bytesPerPixel;
- int width;
- int height;
- char shmPath[PATH_MAX];
- int fd; /* From shm_open (for now) */
- size_t length; /* length of buffer */
- void *buffer;
-} DRIPixmapBuffer, *DRIPixmapBufferPtr;
-
-Bool
-DRIScreenInit(ScreenPtr pScreen)
-{
- DRIScreenPrivPtr pDRIPriv;
- int i;
-
- if (!dixRegisterPrivateKey(&DRIScreenPrivKeyRec, PRIVATE_SCREEN, 0))
- return FALSE;
- if (!dixRegisterPrivateKey(&DRIWindowPrivKeyRec, PRIVATE_WINDOW, 0))
- return FALSE;
- if (!dixRegisterPrivateKey(&DRIPixmapPrivKeyRec, PRIVATE_PIXMAP, 0))
- return FALSE;
- if (!dixRegisterPrivateKey(&DRIPixmapBufferPrivKeyRec, PRIVATE_PIXMAP, 0))
- return FALSE;
-
- pDRIPriv = (DRIScreenPrivPtr) calloc(1, sizeof(DRIScreenPrivRec));
- if (!pDRIPriv) {
- dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
- return FALSE;
- }
-
- dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, pDRIPriv);
- pDRIPriv->directRenderingSupport = TRUE;
- pDRIPriv->nrWindows = 0;
-
- /* Initialize drawable tables */
- for (i = 0; i < DRI_MAX_DRAWABLES; i++) {
- pDRIPriv->DRIDrawables[i] = NULL;
- }
-
- return TRUE;
-}
-
-Bool
-DRIFinishScreenInit(ScreenPtr pScreen)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- /* Wrap DRI support */
- pDRIPriv->wrap.ValidateTree = pScreen->ValidateTree;
- pScreen->ValidateTree = DRIValidateTree;
-
- pDRIPriv->wrap.PostValidateTree = pScreen->PostValidateTree;
- pScreen->PostValidateTree = DRIPostValidateTree;
-
- pDRIPriv->wrap.WindowExposures = pScreen->WindowExposures;
- pScreen->WindowExposures = DRIWindowExposures;
-
- pDRIPriv->wrap.CopyWindow = pScreen->CopyWindow;
- pScreen->CopyWindow = DRICopyWindow;
-
- pDRIPriv->wrap.ClipNotify = pScreen->ClipNotify;
- pScreen->ClipNotify = DRIClipNotify;
-
- // ErrorF("[DRI] screen %d installation complete\n", pScreen->myNum);
-
- return DRIWrapInit(pScreen);
-}
-
-void
-DRICloseScreen(ScreenPtr pScreen)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- if (pDRIPriv && pDRIPriv->directRenderingSupport) {
- free(pDRIPriv);
- dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
- }
-}
-
-Bool
-DRIExtensionInit(void)
-{
- DRIDrawablePrivResType = CreateNewResourceType(DRIDrawablePrivDelete,
- "DRIDrawable");
-
- return DRIDrawablePrivResType != 0;
-}
-
-void
-DRIReset(void)
-{
- /*
- * This stub routine is called when the X Server recycles, resources
- * allocated by DRIExtensionInit need to be managed here.
- *
- * Currently this routine is a stub because all the interesting resources
- * are managed via the screen init process.
- */
-}
-
-Bool
-DRIQueryDirectRenderingCapable(ScreenPtr pScreen, Bool* isCapable)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- if (pDRIPriv)
- *isCapable = pDRIPriv->directRenderingSupport;
- else
- *isCapable = FALSE;
-
- return TRUE;
-}
-
-Bool
-DRIAuthConnection(ScreenPtr pScreen, unsigned int magic)
-{
-#if 0
- /* FIXME: something? */
-
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- if (drmAuthMagic(pDRIPriv->drmFD, magic)) return FALSE;
-#endif
- return TRUE;
-}
-
-static void
-DRIUpdateSurface(DRIDrawablePrivPtr pDRIDrawablePriv, DrawablePtr pDraw)
-{
- xp_window_changes wc;
- unsigned int flags = 0;
-
- if (pDRIDrawablePriv->sid == 0)
- return;
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
- wc.depth = (pDraw->bitsPerPixel == 32 ? XP_DEPTH_ARGB8888
- : pDraw->bitsPerPixel == 16 ? XP_DEPTH_RGB555 : XP_DEPTH_NIL);
- if (wc.depth != XP_DEPTH_NIL)
- flags |= XP_DEPTH;
-#endif
-
- if (pDraw->type == DRAWABLE_WINDOW) {
- WindowPtr pWin = (WindowPtr) pDraw;
- WindowPtr pTopWin = TopLevelParent(pWin);
-
- wc.x = pWin->drawable.x - (pTopWin->drawable.x - pTopWin->borderWidth);
- wc.y = pWin->drawable.y - (pTopWin->drawable.y - pTopWin->borderWidth);
- wc.width = pWin->drawable.width + 2 * pWin->borderWidth;
- wc.height = pWin->drawable.height + 2 * pWin->borderWidth;
- wc.bit_gravity = XP_GRAVITY_NONE;
-
- wc.shape_nrects = RegionNumRects(&pWin->clipList);
- wc.shape_rects = RegionRects(&pWin->clipList);
- wc.shape_tx = - (pTopWin->drawable.x - pTopWin->borderWidth);
- wc.shape_ty = - (pTopWin->drawable.y - pTopWin->borderWidth);
-
- flags |= XP_BOUNDS | XP_SHAPE;
-
- } else if (pDraw->type == DRAWABLE_PIXMAP) {
- wc.x = 0;
- wc.y = 0;
- wc.width = pDraw->width;
- wc.height = pDraw->height;
- wc.bit_gravity = XP_GRAVITY_NONE;
- flags |= XP_BOUNDS;
- }
-
- xp_configure_surface(pDRIDrawablePriv->sid, flags, &wc);
-}
-
-/* Return NULL if an error occurs. */
-static DRIDrawablePrivPtr
-CreateSurfaceForWindow(ScreenPtr pScreen, WindowPtr pWin, xp_window_id *widPtr) {
- DRIDrawablePrivPtr pDRIDrawablePriv;
- xp_window_id wid = 0;
-
- *widPtr = 0;
-
- pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
-
- if (pDRIDrawablePriv == NULL) {
- xp_error err;
- xp_window_changes wc;
-
- /* allocate a DRI Window Private record */
- if (!(pDRIDrawablePriv = malloc(sizeof(*pDRIDrawablePriv)))) {
- return NULL;
- }
-
- pDRIDrawablePriv->pDraw = (DrawablePtr)pWin;
- pDRIDrawablePriv->pScreen = pScreen;
- pDRIDrawablePriv->refCount = 0;
- pDRIDrawablePriv->drawableIndex = -1;
- pDRIDrawablePriv->notifiers = NULL;
-
- /* find the physical window */
- wid = x_cvt_vptr_to_uint(RootlessFrameForWindow(pWin, TRUE));
-
- if (wid == 0) {
- free(pDRIDrawablePriv);
- return NULL;
- }
-
- /* allocate the physical surface */
- err = xp_create_surface(wid, &pDRIDrawablePriv->sid);
-
- if (err != Success) {
- free(pDRIDrawablePriv);
- return NULL;
- }
-
- /* Make it visible */
- wc.stack_mode = XP_MAPPED_ABOVE;
- wc.sibling = 0;
- err = xp_configure_surface(pDRIDrawablePriv->sid, XP_STACKING, &wc);
-
- if (err != Success) {
- xp_destroy_surface(pDRIDrawablePriv->sid);
- free(pDRIDrawablePriv);
- return NULL;
- }
-
- /* save private off of preallocated index */
- dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey,
- pDRIDrawablePriv);
- }
-
- *widPtr = wid;
-
- return pDRIDrawablePriv;
-}
-
-/* Return NULL if an error occurs. */
-static DRIDrawablePrivPtr
-CreateSurfaceForPixmap(ScreenPtr pScreen, PixmapPtr pPix) {
- DRIDrawablePrivPtr pDRIDrawablePriv;
-
- pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix);
-
- if (pDRIDrawablePriv == NULL) {
- xp_error err;
-
- /* allocate a DRI Window Private record */
- if (!(pDRIDrawablePriv = calloc(1, sizeof(*pDRIDrawablePriv)))) {
- return NULL;
- }
-
- pDRIDrawablePriv->pDraw = (DrawablePtr)pPix;
- pDRIDrawablePriv->pScreen = pScreen;
- pDRIDrawablePriv->refCount = 0;
- pDRIDrawablePriv->drawableIndex = -1;
- pDRIDrawablePriv->notifiers = NULL;
-
- /* Passing a null window id to Xplugin in 10.3+ asks for
- an accelerated offscreen surface. */
-
- err = xp_create_surface(0, &pDRIDrawablePriv->sid);
- if (err != Success) {
- free(pDRIDrawablePriv);
- return NULL;
- }
-
- /*
- * The DRIUpdateSurface will be called to resize the surface
- * after this function, if the export is successful.
- */
-
- /* save private off of preallocated index */
- dixSetPrivate(&pPix->devPrivates, DRIPixmapPrivKey,
- pDRIDrawablePriv);
- }
-
- return pDRIDrawablePriv;
-}
-
-
-Bool
-DRICreateSurface(ScreenPtr pScreen, Drawable id,
- DrawablePtr pDrawable, xp_client_id client_id,
- xp_surface_id *surface_id, unsigned int ret_key[2],
- void (*notify) (void *arg, void *data), void *notify_data)
-{
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- xp_window_id wid = 0;
- DRIDrawablePrivPtr pDRIDrawablePriv;
-
- if (pDrawable->type == DRAWABLE_WINDOW) {
- pDRIDrawablePriv = CreateSurfaceForWindow(pScreen,
- (WindowPtr)pDrawable, &wid);
-
- if(NULL == pDRIDrawablePriv)
- return FALSE; /*error*/
- }
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
- else if (pDrawable->type == DRAWABLE_PIXMAP) {
- pDRIDrawablePriv = CreateSurfaceForPixmap(pScreen,
- (PixmapPtr)pDrawable);
-
- if(NULL == pDRIDrawablePriv)
- return FALSE; /*error*/
- }
-#endif
- else {
- /* We handle GLXPbuffers in a different way (via CGL). */
- return FALSE;
- }
-
-
- /* Finish initialization of new surfaces */
- if (pDRIDrawablePriv->refCount == 0) {
- unsigned int key[2] = {0};
- xp_error err;
-
- /* try to give the client access to the surface */
- if (client_id != 0) {
- /*
- * Xplugin accepts a 0 wid if the surface id is offscreen, such
- * as for a pixmap.
- */
- err = xp_export_surface(wid, pDRIDrawablePriv->sid,
- client_id, key);
- if (err != Success) {
- xp_destroy_surface(pDRIDrawablePriv->sid);
- free(pDRIDrawablePriv);
-
- /*
- * Now set the dix privates to NULL that were previously set.
- * This prevents reusing an invalid pointer.
- */
- if(pDrawable->type == DRAWABLE_WINDOW) {
- WindowPtr pWin = (WindowPtr)pDrawable;
-
- dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey, NULL);
- } else if(pDrawable->type == DRAWABLE_PIXMAP) {
- PixmapPtr pPix = (PixmapPtr)pDrawable;
-
- dixSetPrivate(&pPix->devPrivates, DRIPixmapPrivKey, NULL);
- }
-
- return FALSE;
- }
- }
-
- pDRIDrawablePriv->key[0] = key[0];
- pDRIDrawablePriv->key[1] = key[1];
-
- ++pDRIPriv->nrWindows;
-
- /* and stash it by surface id */
- if (surface_hash == NULL)
- surface_hash = x_hash_table_new(NULL, NULL, NULL, NULL);
- x_hash_table_insert(surface_hash,
- x_cvt_uint_to_vptr(pDRIDrawablePriv->sid), pDRIDrawablePriv);
-
- /* track this in case this window is destroyed */
- AddResource(id, DRIDrawablePrivResType, (pointer)pDrawable);
-
- /* Initialize shape */
- DRIUpdateSurface(pDRIDrawablePriv, pDrawable);
- }
-
- pDRIDrawablePriv->refCount++;
-
- *surface_id = pDRIDrawablePriv->sid;
-
- if (ret_key != NULL) {
- ret_key[0] = pDRIDrawablePriv->key[0];
- ret_key[1] = pDRIDrawablePriv->key[1];
- }
-
- if (notify != NULL) {
- pDRIDrawablePriv->notifiers = x_hook_add(pDRIDrawablePriv->notifiers,
- notify, notify_data);
- }
-
- return TRUE;
-}
-
-Bool
-DRIDestroySurface(ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable,
- void (*notify) (void *, void *), void *notify_data)
-{
- DRIDrawablePrivPtr pDRIDrawablePriv;
-
- if (pDrawable->type == DRAWABLE_WINDOW) {
- pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW((WindowPtr)pDrawable);
- } else if (pDrawable->type == DRAWABLE_PIXMAP) {
- pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_PIXMAP((PixmapPtr)pDrawable);
- } else {
- return FALSE;
- }
-
- if (pDRIDrawablePriv != NULL) {
- /*
- * This doesn't seem to be used, because notify is NULL in all callers.
- */
-
- if (notify != NULL) {
- pDRIDrawablePriv->notifiers = x_hook_remove(pDRIDrawablePriv->notifiers,
- notify, notify_data);
- }
-
- --pDRIDrawablePriv->refCount;
-
- /*
- * Check if the drawable privates still have a reference to the
- * surface.
- */
-
- if (pDRIDrawablePriv->refCount <= 0) {
- /*
- * This calls back to DRIDrawablePrivDelete which
- * frees the private area and dispatches events, if needed.
- */
- FreeResourceByType(id, DRIDrawablePrivResType, FALSE);
- }
- }
-
- return TRUE;
-}
-
-/*
- * The assumption is that this is called when the refCount of a surface
- * drops to <= 0, or the window/pixmap is destroyed.
- */
-Bool
-DRIDrawablePrivDelete(pointer pResource, XID id)
-{
- DrawablePtr pDrawable = (DrawablePtr)pResource;
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pDrawable->pScreen);
- DRIDrawablePrivPtr pDRIDrawablePriv = NULL;
- WindowPtr pWin = NULL;
- PixmapPtr pPix = NULL;
-
- if (pDrawable->type == DRAWABLE_WINDOW) {
- pWin = (WindowPtr)pDrawable;
- pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
- } else if (pDrawable->type == DRAWABLE_PIXMAP) {
- pPix = (PixmapPtr)pDrawable;
- pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix);
- }
-
- if (pDRIDrawablePriv == NULL) {
- /*
- * We reuse __func__ and the resource type for the GLXPixmap code.
- * Attempt to free a pixmap buffer associated with the resource
- * if possible.
- */
- return DRIFreePixmapImp(pDrawable);
- }
-
- if (pDRIDrawablePriv->drawableIndex != -1) {
- /* release drawable table entry */
- pDRIPriv->DRIDrawables[pDRIDrawablePriv->drawableIndex] = NULL;
- }
-
- if (pDRIDrawablePriv->sid != 0) {
- DRISurfaceNotify(pDRIDrawablePriv->sid, AppleDRISurfaceNotifyDestroyed);
- }
-
-
- if (pDRIDrawablePriv->notifiers != NULL)
- x_hook_free(pDRIDrawablePriv->notifiers);
-
- free(pDRIDrawablePriv);
-
- if (pDrawable->type == DRAWABLE_WINDOW) {
- dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey, NULL);
- } else if (pDrawable->type == DRAWABLE_PIXMAP) {
- dixSetPrivate(&pPix->devPrivates, DRIPixmapPrivKey, NULL);
- }
-
- --pDRIPriv->nrWindows;
-
- return TRUE;
-}
-
-void
-DRIWindowExposures(WindowPtr pWin, RegionPtr prgn, RegionPtr bsreg)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- DRIDrawablePrivPtr pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
-
- if (pDRIDrawablePriv) {
- /* FIXME: something? */
- }
-
- pScreen->WindowExposures = pDRIPriv->wrap.WindowExposures;
-
- (*pScreen->WindowExposures)(pWin, prgn, bsreg);
-
- pScreen->WindowExposures = DRIWindowExposures;
-}
-
-void
-DRICopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- DRIDrawablePrivPtr pDRIDrawablePriv;
-
- if (pDRIPriv->nrWindows > 0) {
- pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
- if (pDRIDrawablePriv != NULL) {
- DRIUpdateSurface(pDRIDrawablePriv, &pWin->drawable);
- }
- }
-
- /* unwrap */
- pScreen->CopyWindow = pDRIPriv->wrap.CopyWindow;
-
- /* call lower layers */
- (*pScreen->CopyWindow)(pWin, ptOldOrg, prgnSrc);
-
- /* rewrap */
- pScreen->CopyWindow = DRICopyWindow;
-}
-
-int
-DRIValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind)
-{
- ScreenPtr pScreen = pParent->drawable.pScreen;
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- int returnValue;
-
- /* unwrap */
- pScreen->ValidateTree = pDRIPriv->wrap.ValidateTree;
-
- /* call lower layers */
- returnValue = (*pScreen->ValidateTree)(pParent, pChild, kind);
-
- /* rewrap */
- pScreen->ValidateTree = DRIValidateTree;
-
- return returnValue;
-}
-
-void
-DRIPostValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind)
-{
- ScreenPtr pScreen;
- DRIScreenPrivPtr pDRIPriv;
-
- if (pParent) {
- pScreen = pParent->drawable.pScreen;
- } else {
- pScreen = pChild->drawable.pScreen;
- }
- pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-
- if (pDRIPriv->wrap.PostValidateTree) {
- /* unwrap */
- pScreen->PostValidateTree = pDRIPriv->wrap.PostValidateTree;
-
- /* call lower layers */
- (*pScreen->PostValidateTree)(pParent, pChild, kind);
-
- /* rewrap */
- pScreen->PostValidateTree = DRIPostValidateTree;
- }
-}
-
-void
-DRIClipNotify(WindowPtr pWin, int dx, int dy)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- DRIDrawablePrivPtr pDRIDrawablePriv;
-
- if ((pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin))) {
- DRIUpdateSurface(pDRIDrawablePriv, &pWin->drawable);
- }
-
- if (pDRIPriv->wrap.ClipNotify) {
- pScreen->ClipNotify = pDRIPriv->wrap.ClipNotify;
-
- (*pScreen->ClipNotify)(pWin, dx, dy);
-
- pScreen->ClipNotify = DRIClipNotify;
- }
-}
-
-/* This lets us get at the unwrapped functions so that they can correctly
- * call the lower level functions, and choose whether they will be
- * called at every level of recursion (eg in validatetree).
- */
-DRIWrappedFuncsRec *
-DRIGetWrappedFuncs(ScreenPtr pScreen)
-{
- return &(DRI_SCREEN_PRIV(pScreen)->wrap);
-}
-
-void
-DRIQueryVersion(int *majorVersion,
- int *minorVersion,
- int *patchVersion)
-{
- *majorVersion = APPLE_DRI_MAJOR_VERSION;
- *minorVersion = APPLE_DRI_MINOR_VERSION;
- *patchVersion = APPLE_DRI_PATCH_VERSION;
-}
-
-/*
- * Note: this also cleans up the hash table in addition to notifying clients.
- * The sid/surface-id should not be used after this, because it will be
- * invalid.
- */
-void
-DRISurfaceNotify(xp_surface_id id, int kind)
-{
- DRIDrawablePrivPtr pDRIDrawablePriv = NULL;
- DRISurfaceNotifyArg arg;
-
- arg.id = id;
- arg.kind = kind;
-
- if (surface_hash != NULL)
- {
- pDRIDrawablePriv = x_hash_table_lookup(surface_hash,
- x_cvt_uint_to_vptr(id), NULL);
- }
-
- if (pDRIDrawablePriv == NULL)
- return;
-
- if (kind == AppleDRISurfaceNotifyDestroyed)
- {
- x_hash_table_remove(surface_hash, x_cvt_uint_to_vptr(id));
- }
-
- x_hook_run(pDRIDrawablePriv->notifiers, &arg);
-
- if (kind == AppleDRISurfaceNotifyDestroyed)
- {
- xp_error error;
-
- error = xp_destroy_surface(pDRIDrawablePriv->sid);
-
- if(error)
- ErrorF("%s: xp_destroy_surface failed: %d\n", __func__, error);
-
- /* Guard against reuse, even though we are freeing after this. */
- pDRIDrawablePriv->sid = 0;
-
- FreeResourceByType(pDRIDrawablePriv->pDraw->id,
- DRIDrawablePrivResType, FALSE);
- }
-}
-
-/*
- * This creates a shared memory buffer for use with GLXPixmaps
- * and AppleSGLX.
- */
-Bool DRICreatePixmap(ScreenPtr pScreen, Drawable id,
- DrawablePtr pDrawable, char *path,
- size_t pathmax)
-{
- DRIPixmapBufferPtr shared;
- PixmapPtr pPix;
-
- if(pDrawable->type != DRAWABLE_PIXMAP)
- return FALSE;
-
- pPix = (PixmapPtr)pDrawable;
-
- shared = malloc(sizeof(*shared));
- if(NULL == shared) {
- FatalError("failed to allocate DRIPixmapBuffer in %s\n", __func__);
- }
-
- shared->pDrawable = pDrawable;
- shared->refCount = 1;
-
- if(pDrawable->bitsPerPixel >= 24) {
- shared->bytesPerPixel = 4;
- } else if(pDrawable->bitsPerPixel <= 16) {
- shared->bytesPerPixel = 2;
- }
-
- shared->width = pDrawable->width;
- shared->height = pDrawable->height;
-
- if(-1 == snprintf(shared->shmPath, sizeof(shared->shmPath),
- "%d_0x%lx", getpid(),
- (unsigned long)id)) {
- FatalError("buffer overflow in %s\n", __func__);
- }
-
- shared->fd = shm_open(shared->shmPath,
- O_RDWR | O_EXCL | O_CREAT,
- S_IRUSR | S_IWUSR | S_IROTH | S_IWOTH);
-
- if(-1 == shared->fd) {
- free(shared);
- return FALSE;
- }
-
- shared->length = shared->width * shared->height * shared->bytesPerPixel;
-
- if(-1 == ftruncate(shared->fd, shared->length)) {
- ErrorF("failed to ftruncate (extend) file.");
- shm_unlink(shared->shmPath);
- close(shared->fd);
- free(shared);
- return FALSE;
- }
-
- shared->buffer = mmap(NULL, shared->length,
- PROT_READ | PROT_WRITE,
- MAP_FILE | MAP_SHARED, shared->fd, 0);
-
- if(MAP_FAILED == shared->buffer) {
- ErrorF("failed to mmap shared memory.");
- shm_unlink(shared->shmPath);
- close(shared->fd);
- free(shared);
- return FALSE;
- }
-
- strncpy(path, shared->shmPath, pathmax);
- path[pathmax - 1] = '\0';
-
- dixSetPrivate(&pPix->devPrivates, DRIPixmapBufferPrivKey, shared);
-
- AddResource(id, DRIDrawablePrivResType, (pointer)pDrawable);
-
- return TRUE;
-}
-
-
-Bool DRIGetPixmapData(DrawablePtr pDrawable, int *width, int *height,
- int *pitch, int *bpp, void **ptr) {
- PixmapPtr pPix;
- DRIPixmapBufferPtr shared;
-
- if(pDrawable->type != DRAWABLE_PIXMAP)
- return FALSE;
-
- pPix = (PixmapPtr)pDrawable;
-
- shared = dixLookupPrivate(&pPix->devPrivates, DRIPixmapBufferPrivKey);
-
- if(NULL == shared)
- return FALSE;
-
- assert(pDrawable->width == shared->width);
- assert(pDrawable->height == shared->height);
-
- *width = shared->width;
- *height = shared->height;
- *bpp = shared->bytesPerPixel;
- *pitch = shared->width * shared->bytesPerPixel;
- *ptr = shared->buffer;
-
- return TRUE;
-}
-
-static Bool
-DRIFreePixmapImp(DrawablePtr pDrawable) {
- DRIPixmapBufferPtr shared;
- PixmapPtr pPix;
-
- if(pDrawable->type != DRAWABLE_PIXMAP)
- return FALSE;
-
- pPix = (PixmapPtr)pDrawable;
-
- shared = dixLookupPrivate(&pPix->devPrivates, DRIPixmapBufferPrivKey);
-
- if(NULL == shared)
- return FALSE;
-
- close(shared->fd);
- munmap(shared->buffer, shared->length);
- shm_unlink(shared->shmPath);
- free(shared);
-
- dixSetPrivate(&pPix->devPrivates, DRIPixmapBufferPrivKey, (pointer)NULL);
-
- return TRUE;
-}
-
-void
-DRIDestroyPixmap(DrawablePtr pDrawable) {
- if(DRIFreePixmapImp(pDrawable))
- FreeResourceByType(pDrawable->id, DRIDrawablePrivResType, FALSE);
-
-}
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright 2000 VA Linux Systems, Inc.
+Copyright (c) 2002, 2009 Apple Computer, 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, 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.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Jens Owen <jens@valinux.com>
+ * Rickard E. (Rik) Faith <faith@valinux.com>
+ *
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef XFree86LOADER
+#include "xf86.h"
+#include "xf86_ansic.h"
+#else
+#include <sys/time.h>
+#include <unistd.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include "misc.h"
+#include "dixstruct.h"
+#include "extnsionst.h"
+#include "colormapst.h"
+#include "cursorstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "servermd.h"
+#define _APPLEDRI_SERVER_
+#include "appledristr.h"
+#include "swaprep.h"
+#include "dri.h"
+#include "dristruct.h"
+#include "mi.h"
+#include "mipointer.h"
+#include "rootless.h"
+#include "x-hash.h"
+#include "x-hook.h"
+#include "driWrap.h"
+
+#include <AvailabilityMacros.h>
+
+static DevPrivateKeyRec DRIScreenPrivKeyRec;
+#define DRIScreenPrivKey (&DRIScreenPrivKeyRec)
+static DevPrivateKeyRec DRIWindowPrivKeyRec;
+#define DRIWindowPrivKey (&DRIWindowPrivKeyRec)
+static DevPrivateKeyRec DRIPixmapPrivKeyRec;
+#define DRIPixmapPrivKey (&DRIPixmapPrivKeyRec)
+static DevPrivateKeyRec DRIPixmapBufferPrivKeyRec;
+#define DRIPixmapBufferPrivKey (&DRIPixmapBufferPrivKeyRec)
+
+static RESTYPE DRIDrawablePrivResType;
+
+static x_hash_table *surface_hash; /* maps surface ids -> drawablePrivs */
+
+static Bool DRIFreePixmapImp(DrawablePtr pDrawable);
+
+typedef struct {
+ DrawablePtr pDrawable;
+ int refCount;
+ int bytesPerPixel;
+ int width;
+ int height;
+ char shmPath[PATH_MAX];
+ int fd; /* From shm_open (for now) */
+ size_t length; /* length of buffer */
+ void *buffer;
+} DRIPixmapBuffer, *DRIPixmapBufferPtr;
+
+Bool
+DRIScreenInit(ScreenPtr pScreen)
+{
+ DRIScreenPrivPtr pDRIPriv;
+ int i;
+
+ if (!dixRegisterPrivateKey(&DRIScreenPrivKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+ if (!dixRegisterPrivateKey(&DRIWindowPrivKeyRec, PRIVATE_WINDOW, 0))
+ return FALSE;
+ if (!dixRegisterPrivateKey(&DRIPixmapPrivKeyRec, PRIVATE_PIXMAP, 0))
+ return FALSE;
+ if (!dixRegisterPrivateKey(&DRIPixmapBufferPrivKeyRec, PRIVATE_PIXMAP, 0))
+ return FALSE;
+
+ pDRIPriv = (DRIScreenPrivPtr) calloc(1, sizeof(DRIScreenPrivRec));
+ if (!pDRIPriv) {
+ dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
+ return FALSE;
+ }
+
+ dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, pDRIPriv);
+ pDRIPriv->directRenderingSupport = TRUE;
+ pDRIPriv->nrWindows = 0;
+
+ /* Initialize drawable tables */
+ for (i = 0; i < DRI_MAX_DRAWABLES; i++) {
+ pDRIPriv->DRIDrawables[i] = NULL;
+ }
+
+ return TRUE;
+}
+
+Bool
+DRIFinishScreenInit(ScreenPtr pScreen)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ /* Wrap DRI support */
+ pDRIPriv->wrap.ValidateTree = pScreen->ValidateTree;
+ pScreen->ValidateTree = DRIValidateTree;
+
+ pDRIPriv->wrap.PostValidateTree = pScreen->PostValidateTree;
+ pScreen->PostValidateTree = DRIPostValidateTree;
+
+ pDRIPriv->wrap.WindowExposures = pScreen->WindowExposures;
+ pScreen->WindowExposures = DRIWindowExposures;
+
+ pDRIPriv->wrap.CopyWindow = pScreen->CopyWindow;
+ pScreen->CopyWindow = DRICopyWindow;
+
+ pDRIPriv->wrap.ClipNotify = pScreen->ClipNotify;
+ pScreen->ClipNotify = DRIClipNotify;
+
+ // ErrorF("[DRI] screen %d installation complete\n", pScreen->myNum);
+
+ return DRIWrapInit(pScreen);
+}
+
+void
+DRICloseScreen(ScreenPtr pScreen)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ if (pDRIPriv && pDRIPriv->directRenderingSupport) {
+ free(pDRIPriv);
+ dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
+ }
+}
+
+Bool
+DRIExtensionInit(void)
+{
+ DRIDrawablePrivResType = CreateNewResourceType(DRIDrawablePrivDelete,
+ "DRIDrawable");
+
+ return DRIDrawablePrivResType != 0;
+}
+
+void
+DRIReset(void)
+{
+ /*
+ * This stub routine is called when the X Server recycles, resources
+ * allocated by DRIExtensionInit need to be managed here.
+ *
+ * Currently this routine is a stub because all the interesting resources
+ * are managed via the screen init process.
+ */
+}
+
+Bool
+DRIQueryDirectRenderingCapable(ScreenPtr pScreen, Bool* isCapable)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ if (pDRIPriv)
+ *isCapable = pDRIPriv->directRenderingSupport;
+ else
+ *isCapable = FALSE;
+
+ return TRUE;
+}
+
+Bool
+DRIAuthConnection(ScreenPtr pScreen, unsigned int magic)
+{
+#if 0
+ /* FIXME: something? */
+
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ if (drmAuthMagic(pDRIPriv->drmFD, magic)) return FALSE;
+#endif
+ return TRUE;
+}
+
+static void
+DRIUpdateSurface(DRIDrawablePrivPtr pDRIDrawablePriv, DrawablePtr pDraw)
+{
+ xp_window_changes wc;
+ unsigned int flags = 0;
+
+ if (pDRIDrawablePriv->sid == 0)
+ return;
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
+ wc.depth = (pDraw->bitsPerPixel == 32 ? XP_DEPTH_ARGB8888
+ : pDraw->bitsPerPixel == 16 ? XP_DEPTH_RGB555 : XP_DEPTH_NIL);
+ if (wc.depth != XP_DEPTH_NIL)
+ flags |= XP_DEPTH;
+#endif
+
+ if (pDraw->type == DRAWABLE_WINDOW) {
+ WindowPtr pWin = (WindowPtr) pDraw;
+ WindowPtr pTopWin = TopLevelParent(pWin);
+
+ wc.x = pWin->drawable.x - (pTopWin->drawable.x - pTopWin->borderWidth);
+ wc.y = pWin->drawable.y - (pTopWin->drawable.y - pTopWin->borderWidth);
+ wc.width = pWin->drawable.width + 2 * pWin->borderWidth;
+ wc.height = pWin->drawable.height + 2 * pWin->borderWidth;
+ wc.bit_gravity = XP_GRAVITY_NONE;
+
+ wc.shape_nrects = RegionNumRects(&pWin->clipList);
+ wc.shape_rects = RegionRects(&pWin->clipList);
+ wc.shape_tx = - (pTopWin->drawable.x - pTopWin->borderWidth);
+ wc.shape_ty = - (pTopWin->drawable.y - pTopWin->borderWidth);
+
+ flags |= XP_BOUNDS | XP_SHAPE;
+
+ } else if (pDraw->type == DRAWABLE_PIXMAP) {
+ wc.x = 0;
+ wc.y = 0;
+ wc.width = pDraw->width;
+ wc.height = pDraw->height;
+ wc.bit_gravity = XP_GRAVITY_NONE;
+ flags |= XP_BOUNDS;
+ }
+
+ xp_configure_surface(pDRIDrawablePriv->sid, flags, &wc);
+}
+
+/* Return NULL if an error occurs. */
+static DRIDrawablePrivPtr
+CreateSurfaceForWindow(ScreenPtr pScreen, WindowPtr pWin, xp_window_id *widPtr) {
+ DRIDrawablePrivPtr pDRIDrawablePriv;
+ xp_window_id wid = 0;
+
+ *widPtr = 0;
+
+ pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
+
+ if (pDRIDrawablePriv == NULL) {
+ xp_error err;
+ xp_window_changes wc;
+
+ /* allocate a DRI Window Private record */
+ if (!(pDRIDrawablePriv = malloc(sizeof(*pDRIDrawablePriv)))) {
+ return NULL;
+ }
+
+ pDRIDrawablePriv->pDraw = (DrawablePtr)pWin;
+ pDRIDrawablePriv->pScreen = pScreen;
+ pDRIDrawablePriv->refCount = 0;
+ pDRIDrawablePriv->drawableIndex = -1;
+ pDRIDrawablePriv->notifiers = NULL;
+
+ /* find the physical window */
+ wid = x_cvt_vptr_to_uint(RootlessFrameForWindow(pWin, TRUE));
+
+ if (wid == 0) {
+ free(pDRIDrawablePriv);
+ return NULL;
+ }
+
+ /* allocate the physical surface */
+ err = xp_create_surface(wid, &pDRIDrawablePriv->sid);
+
+ if (err != Success) {
+ free(pDRIDrawablePriv);
+ return NULL;
+ }
+
+ /* Make it visible */
+ wc.stack_mode = XP_MAPPED_ABOVE;
+ wc.sibling = 0;
+ err = xp_configure_surface(pDRIDrawablePriv->sid, XP_STACKING, &wc);
+
+ if (err != Success) {
+ xp_destroy_surface(pDRIDrawablePriv->sid);
+ free(pDRIDrawablePriv);
+ return NULL;
+ }
+
+ /* save private off of preallocated index */
+ dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey,
+ pDRIDrawablePriv);
+ }
+
+ *widPtr = wid;
+
+ return pDRIDrawablePriv;
+}
+
+/* Return NULL if an error occurs. */
+static DRIDrawablePrivPtr
+CreateSurfaceForPixmap(ScreenPtr pScreen, PixmapPtr pPix) {
+ DRIDrawablePrivPtr pDRIDrawablePriv;
+
+ pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix);
+
+ if (pDRIDrawablePriv == NULL) {
+ xp_error err;
+
+ /* allocate a DRI Window Private record */
+ if (!(pDRIDrawablePriv = calloc(1, sizeof(*pDRIDrawablePriv)))) {
+ return NULL;
+ }
+
+ pDRIDrawablePriv->pDraw = (DrawablePtr)pPix;
+ pDRIDrawablePriv->pScreen = pScreen;
+ pDRIDrawablePriv->refCount = 0;
+ pDRIDrawablePriv->drawableIndex = -1;
+ pDRIDrawablePriv->notifiers = NULL;
+
+ /* Passing a null window id to Xplugin in 10.3+ asks for
+ an accelerated offscreen surface. */
+
+ err = xp_create_surface(0, &pDRIDrawablePriv->sid);
+ if (err != Success) {
+ free(pDRIDrawablePriv);
+ return NULL;
+ }
+
+ /*
+ * The DRIUpdateSurface will be called to resize the surface
+ * after this function, if the export is successful.
+ */
+
+ /* save private off of preallocated index */
+ dixSetPrivate(&pPix->devPrivates, DRIPixmapPrivKey,
+ pDRIDrawablePriv);
+ }
+
+ return pDRIDrawablePriv;
+}
+
+
+Bool
+DRICreateSurface(ScreenPtr pScreen, Drawable id,
+ DrawablePtr pDrawable, xp_client_id client_id,
+ xp_surface_id *surface_id, unsigned int ret_key[2],
+ void (*notify) (void *arg, void *data), void *notify_data)
+{
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ xp_window_id wid = 0;
+ DRIDrawablePrivPtr pDRIDrawablePriv;
+
+ if (pDrawable->type == DRAWABLE_WINDOW) {
+ pDRIDrawablePriv = CreateSurfaceForWindow(pScreen,
+ (WindowPtr)pDrawable, &wid);
+
+ if(NULL == pDRIDrawablePriv)
+ return FALSE; /*error*/
+ }
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
+ else if (pDrawable->type == DRAWABLE_PIXMAP) {
+ pDRIDrawablePriv = CreateSurfaceForPixmap(pScreen,
+ (PixmapPtr)pDrawable);
+
+ if(NULL == pDRIDrawablePriv)
+ return FALSE; /*error*/
+ }
+#endif
+ else {
+ /* We handle GLXPbuffers in a different way (via CGL). */
+ return FALSE;
+ }
+
+
+ /* Finish initialization of new surfaces */
+ if (pDRIDrawablePriv->refCount == 0) {
+ unsigned int key[2] = {0};
+ xp_error err;
+
+ /* try to give the client access to the surface */
+ if (client_id != 0) {
+ /*
+ * Xplugin accepts a 0 wid if the surface id is offscreen, such
+ * as for a pixmap.
+ */
+ err = xp_export_surface(wid, pDRIDrawablePriv->sid,
+ client_id, key);
+ if (err != Success) {
+ xp_destroy_surface(pDRIDrawablePriv->sid);
+ free(pDRIDrawablePriv);
+
+ /*
+ * Now set the dix privates to NULL that were previously set.
+ * This prevents reusing an invalid pointer.
+ */
+ if(pDrawable->type == DRAWABLE_WINDOW) {
+ WindowPtr pWin = (WindowPtr)pDrawable;
+
+ dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey, NULL);
+ } else if(pDrawable->type == DRAWABLE_PIXMAP) {
+ PixmapPtr pPix = (PixmapPtr)pDrawable;
+
+ dixSetPrivate(&pPix->devPrivates, DRIPixmapPrivKey, NULL);
+ }
+
+ return FALSE;
+ }
+ }
+
+ pDRIDrawablePriv->key[0] = key[0];
+ pDRIDrawablePriv->key[1] = key[1];
+
+ ++pDRIPriv->nrWindows;
+
+ /* and stash it by surface id */
+ if (surface_hash == NULL)
+ surface_hash = x_hash_table_new(NULL, NULL, NULL, NULL);
+ x_hash_table_insert(surface_hash,
+ x_cvt_uint_to_vptr(pDRIDrawablePriv->sid), pDRIDrawablePriv);
+
+ /* track this in case this window is destroyed */
+ AddResource(id, DRIDrawablePrivResType, (pointer)pDrawable);
+
+ /* Initialize shape */
+ DRIUpdateSurface(pDRIDrawablePriv, pDrawable);
+ }
+
+ pDRIDrawablePriv->refCount++;
+
+ *surface_id = pDRIDrawablePriv->sid;
+
+ if (ret_key != NULL) {
+ ret_key[0] = pDRIDrawablePriv->key[0];
+ ret_key[1] = pDRIDrawablePriv->key[1];
+ }
+
+ if (notify != NULL) {
+ pDRIDrawablePriv->notifiers = x_hook_add(pDRIDrawablePriv->notifiers,
+ notify, notify_data);
+ }
+
+ return TRUE;
+}
+
+Bool
+DRIDestroySurface(ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable,
+ void (*notify) (void *, void *), void *notify_data)
+{
+ DRIDrawablePrivPtr pDRIDrawablePriv;
+
+ if (pDrawable->type == DRAWABLE_WINDOW) {
+ pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW((WindowPtr)pDrawable);
+ } else if (pDrawable->type == DRAWABLE_PIXMAP) {
+ pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_PIXMAP((PixmapPtr)pDrawable);
+ } else {
+ return FALSE;
+ }
+
+ if (pDRIDrawablePriv != NULL) {
+ /*
+ * This doesn't seem to be used, because notify is NULL in all callers.
+ */
+
+ if (notify != NULL) {
+ pDRIDrawablePriv->notifiers = x_hook_remove(pDRIDrawablePriv->notifiers,
+ notify, notify_data);
+ }
+
+ --pDRIDrawablePriv->refCount;
+
+ /*
+ * Check if the drawable privates still have a reference to the
+ * surface.
+ */
+
+ if (pDRIDrawablePriv->refCount <= 0) {
+ /*
+ * This calls back to DRIDrawablePrivDelete which
+ * frees the private area and dispatches events, if needed.
+ */
+ FreeResourceByType(id, DRIDrawablePrivResType, FALSE);
+ }
+ }
+
+ return TRUE;
+}
+
+/*
+ * The assumption is that this is called when the refCount of a surface
+ * drops to <= 0, or the window/pixmap is destroyed.
+ */
+Bool
+DRIDrawablePrivDelete(pointer pResource, XID id)
+{
+ DrawablePtr pDrawable = (DrawablePtr)pResource;
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pDrawable->pScreen);
+ DRIDrawablePrivPtr pDRIDrawablePriv = NULL;
+ WindowPtr pWin = NULL;
+ PixmapPtr pPix = NULL;
+
+ if (pDrawable->type == DRAWABLE_WINDOW) {
+ pWin = (WindowPtr)pDrawable;
+ pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
+ } else if (pDrawable->type == DRAWABLE_PIXMAP) {
+ pPix = (PixmapPtr)pDrawable;
+ pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix);
+ }
+
+ if (pDRIDrawablePriv == NULL) {
+ /*
+ * We reuse __func__ and the resource type for the GLXPixmap code.
+ * Attempt to free a pixmap buffer associated with the resource
+ * if possible.
+ */
+ return DRIFreePixmapImp(pDrawable);
+ }
+
+ if (pDRIDrawablePriv->drawableIndex != -1) {
+ /* release drawable table entry */
+ pDRIPriv->DRIDrawables[pDRIDrawablePriv->drawableIndex] = NULL;
+ }
+
+ if (pDRIDrawablePriv->sid != 0) {
+ DRISurfaceNotify(pDRIDrawablePriv->sid, AppleDRISurfaceNotifyDestroyed);
+ }
+
+
+ if (pDRIDrawablePriv->notifiers != NULL)
+ x_hook_free(pDRIDrawablePriv->notifiers);
+
+ free(pDRIDrawablePriv);
+
+ if (pDrawable->type == DRAWABLE_WINDOW) {
+ dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey, NULL);
+ } else if (pDrawable->type == DRAWABLE_PIXMAP) {
+ dixSetPrivate(&pPix->devPrivates, DRIPixmapPrivKey, NULL);
+ }
+
+ --pDRIPriv->nrWindows;
+
+ return TRUE;
+}
+
+void
+DRIWindowExposures(WindowPtr pWin, RegionPtr prgn, RegionPtr bsreg)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ DRIDrawablePrivPtr pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
+
+ if (pDRIDrawablePriv) {
+ /* FIXME: something? */
+ }
+
+ pScreen->WindowExposures = pDRIPriv->wrap.WindowExposures;
+
+ (*pScreen->WindowExposures)(pWin, prgn, bsreg);
+
+ pScreen->WindowExposures = DRIWindowExposures;
+}
+
+void
+DRICopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ DRIDrawablePrivPtr pDRIDrawablePriv;
+
+ if (pDRIPriv->nrWindows > 0) {
+ pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
+ if (pDRIDrawablePriv != NULL) {
+ DRIUpdateSurface(pDRIDrawablePriv, &pWin->drawable);
+ }
+ }
+
+ /* unwrap */
+ pScreen->CopyWindow = pDRIPriv->wrap.CopyWindow;
+
+ /* call lower layers */
+ (*pScreen->CopyWindow)(pWin, ptOldOrg, prgnSrc);
+
+ /* rewrap */
+ pScreen->CopyWindow = DRICopyWindow;
+}
+
+int
+DRIValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind)
+{
+ ScreenPtr pScreen = pParent->drawable.pScreen;
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ int returnValue;
+
+ /* unwrap */
+ pScreen->ValidateTree = pDRIPriv->wrap.ValidateTree;
+
+ /* call lower layers */
+ returnValue = (*pScreen->ValidateTree)(pParent, pChild, kind);
+
+ /* rewrap */
+ pScreen->ValidateTree = DRIValidateTree;
+
+ return returnValue;
+}
+
+void
+DRIPostValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind)
+{
+ ScreenPtr pScreen;
+ DRIScreenPrivPtr pDRIPriv;
+
+ if (pParent) {
+ pScreen = pParent->drawable.pScreen;
+ } else {
+ pScreen = pChild->drawable.pScreen;
+ }
+ pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+
+ if (pDRIPriv->wrap.PostValidateTree) {
+ /* unwrap */
+ pScreen->PostValidateTree = pDRIPriv->wrap.PostValidateTree;
+
+ /* call lower layers */
+ (*pScreen->PostValidateTree)(pParent, pChild, kind);
+
+ /* rewrap */
+ pScreen->PostValidateTree = DRIPostValidateTree;
+ }
+}
+
+void
+DRIClipNotify(WindowPtr pWin, int dx, int dy)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
+ DRIDrawablePrivPtr pDRIDrawablePriv;
+
+ if ((pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin))) {
+ DRIUpdateSurface(pDRIDrawablePriv, &pWin->drawable);
+ }
+
+ if (pDRIPriv->wrap.ClipNotify) {
+ pScreen->ClipNotify = pDRIPriv->wrap.ClipNotify;
+
+ (*pScreen->ClipNotify)(pWin, dx, dy);
+
+ pScreen->ClipNotify = DRIClipNotify;
+ }
+}
+
+/* This lets us get at the unwrapped functions so that they can correctly
+ * call the lower level functions, and choose whether they will be
+ * called at every level of recursion (eg in validatetree).
+ */
+DRIWrappedFuncsRec *
+DRIGetWrappedFuncs(ScreenPtr pScreen)
+{
+ return &(DRI_SCREEN_PRIV(pScreen)->wrap);
+}
+
+void
+DRIQueryVersion(int *majorVersion,
+ int *minorVersion,
+ int *patchVersion)
+{
+ *majorVersion = APPLE_DRI_MAJOR_VERSION;
+ *minorVersion = APPLE_DRI_MINOR_VERSION;
+ *patchVersion = APPLE_DRI_PATCH_VERSION;
+}
+
+/*
+ * Note: this also cleans up the hash table in addition to notifying clients.
+ * The sid/surface-id should not be used after this, because it will be
+ * invalid.
+ */
+void
+DRISurfaceNotify(xp_surface_id id, int kind)
+{
+ DRIDrawablePrivPtr pDRIDrawablePriv = NULL;
+ DRISurfaceNotifyArg arg;
+
+ arg.id = id;
+ arg.kind = kind;
+
+ if (surface_hash != NULL)
+ {
+ pDRIDrawablePriv = x_hash_table_lookup(surface_hash,
+ x_cvt_uint_to_vptr(id), NULL);
+ }
+
+ if (pDRIDrawablePriv == NULL)
+ return;
+
+ if (kind == AppleDRISurfaceNotifyDestroyed)
+ {
+ x_hash_table_remove(surface_hash, x_cvt_uint_to_vptr(id));
+ }
+
+ x_hook_run(pDRIDrawablePriv->notifiers, &arg);
+
+ if (kind == AppleDRISurfaceNotifyDestroyed)
+ {
+ xp_error error;
+
+ error = xp_destroy_surface(pDRIDrawablePriv->sid);
+
+ if(error)
+ ErrorF("%s: xp_destroy_surface failed: %d\n", __func__, error);
+
+ /* Guard against reuse, even though we are freeing after this. */
+ pDRIDrawablePriv->sid = 0;
+
+ FreeResourceByType(pDRIDrawablePriv->pDraw->id,
+ DRIDrawablePrivResType, FALSE);
+ }
+}
+
+/*
+ * This creates a shared memory buffer for use with GLXPixmaps
+ * and AppleSGLX.
+ */
+Bool DRICreatePixmap(ScreenPtr pScreen, Drawable id,
+ DrawablePtr pDrawable, char *path,
+ size_t pathmax)
+{
+ DRIPixmapBufferPtr shared;
+ PixmapPtr pPix;
+
+ if(pDrawable->type != DRAWABLE_PIXMAP)
+ return FALSE;
+
+ pPix = (PixmapPtr)pDrawable;
+
+ shared = malloc(sizeof(*shared));
+ if(NULL == shared) {
+ FatalError("failed to allocate DRIPixmapBuffer in %s\n", __func__);
+ }
+
+ shared->pDrawable = pDrawable;
+ shared->refCount = 1;
+
+ if(pDrawable->bitsPerPixel >= 24) {
+ shared->bytesPerPixel = 4;
+ } else if(pDrawable->bitsPerPixel <= 16) {
+ shared->bytesPerPixel = 2;
+ }
+
+ shared->width = pDrawable->width;
+ shared->height = pDrawable->height;
+
+ if(-1 == snprintf(shared->shmPath, sizeof(shared->shmPath),
+ "%d_0x%lx", getpid(),
+ (unsigned long)id)) {
+ FatalError("buffer overflow in %s\n", __func__);
+ }
+
+ shared->fd = shm_open(shared->shmPath,
+ O_RDWR | O_EXCL | O_CREAT,
+ S_IRUSR | S_IWUSR | S_IROTH | S_IWOTH);
+
+ if(-1 == shared->fd) {
+ free(shared);
+ return FALSE;
+ }
+
+ shared->length = shared->width * shared->height * shared->bytesPerPixel;
+
+ if(-1 == ftruncate(shared->fd, shared->length)) {
+ ErrorF("failed to ftruncate (extend) file.");
+ shm_unlink(shared->shmPath);
+ close(shared->fd);
+ free(shared);
+ return FALSE;
+ }
+
+ shared->buffer = mmap(NULL, shared->length,
+ PROT_READ | PROT_WRITE,
+ MAP_FILE | MAP_SHARED, shared->fd, 0);
+
+ if(MAP_FAILED == shared->buffer) {
+ ErrorF("failed to mmap shared memory.");
+ shm_unlink(shared->shmPath);
+ close(shared->fd);
+ free(shared);
+ return FALSE;
+ }
+
+ strncpy(path, shared->shmPath, pathmax);
+ path[pathmax - 1] = '\0';
+
+ dixSetPrivate(&pPix->devPrivates, DRIPixmapBufferPrivKey, shared);
+
+ AddResource(id, DRIDrawablePrivResType, (pointer)pDrawable);
+
+ return TRUE;
+}
+
+
+Bool DRIGetPixmapData(DrawablePtr pDrawable, int *width, int *height,
+ int *pitch, int *bpp, void **ptr) {
+ PixmapPtr pPix;
+ DRIPixmapBufferPtr shared;
+
+ if(pDrawable->type != DRAWABLE_PIXMAP)
+ return FALSE;
+
+ pPix = (PixmapPtr)pDrawable;
+
+ shared = dixLookupPrivate(&pPix->devPrivates, DRIPixmapBufferPrivKey);
+
+ if(NULL == shared)
+ return FALSE;
+
+ assert(pDrawable->width == shared->width);
+ assert(pDrawable->height == shared->height);
+
+ *width = shared->width;
+ *height = shared->height;
+ *bpp = shared->bytesPerPixel;
+ *pitch = shared->width * shared->bytesPerPixel;
+ *ptr = shared->buffer;
+
+ return TRUE;
+}
+
+static Bool
+DRIFreePixmapImp(DrawablePtr pDrawable) {
+ DRIPixmapBufferPtr shared;
+ PixmapPtr pPix;
+
+ if(pDrawable->type != DRAWABLE_PIXMAP)
+ return FALSE;
+
+ pPix = (PixmapPtr)pDrawable;
+
+ shared = dixLookupPrivate(&pPix->devPrivates, DRIPixmapBufferPrivKey);
+
+ if(NULL == shared)
+ return FALSE;
+
+ close(shared->fd);
+ munmap(shared->buffer, shared->length);
+ shm_unlink(shared->shmPath);
+ free(shared);
+
+ dixSetPrivate(&pPix->devPrivates, DRIPixmapBufferPrivKey, (pointer)NULL);
+
+ return TRUE;
+}
+
+void
+DRIDestroyPixmap(DrawablePtr pDrawable) {
+ if(DRIFreePixmapImp(pDrawable))
+ FreeResourceByType(pDrawable->id, DRIDrawablePrivResType, FALSE);
+
+}
diff --git a/xorg-server/hw/xquartz/xpr/xpr.h b/xorg-server/hw/xquartz/xpr/xpr.h
index d25f2acc8..0b138ddd7 100644
--- a/xorg-server/hw/xquartz/xpr/xpr.h
+++ b/xorg-server/hw/xquartz/xpr/xpr.h
@@ -1,69 +1,69 @@
-/*
- * Xplugin rootless implementation
- *
- * 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, 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.
- */
-
-#ifndef XPR_H
-#define XPR_H
-
-#include "windowstr.h"
-#include "screenint.h"
-#include <Xplugin.h>
-
-#include "darwin.h"
-
-#undef DEBUG_LOG
-#define DEBUG_LOG(msg, args...) ASL_LOG(ASL_LEVEL_DEBUG, "xpr", msg, ##args)
-
-Bool QuartzModeBundleInit(void);
-
-void AppleDRIExtensionInit(void);
-void xprAppleWMInit(void);
-Bool xprInit(ScreenPtr pScreen);
-Bool xprIsX11Window(int windowNumber);
-WindowPtr xprGetXWindow(xp_window_id wid);
-
-void xprHideWindows(Bool hide);
-
-Bool QuartzInitCursor(ScreenPtr pScreen);
-void QuartzSuspendXCursor(ScreenPtr pScreen);
-void QuartzResumeXCursor(ScreenPtr pScreen);
-
-/* If we are rooted, we need the root window and desktop levels to be below
- * the menubar (24) but above native windows. Normal window level is 0.
- * Floating window level is 3. The rest are filled in as appropriate.
- * See CGWindowLevel.h
- */
-
-#include <X11/extensions/applewmconst.h>
-static const int normal_window_levels[AppleWMNumWindowLevels+1] = {
-0, 3, 4, 5, INT_MIN + 30, INT_MIN + 29,
-};
-static const int rooted_window_levels[AppleWMNumWindowLevels+1] = {
-20, 21, 22, 23, 19, 18,
-};
-
-#endif /* XPR_H */
+/*
+ * Xplugin rootless implementation
+ *
+ * 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, 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.
+ */
+
+#ifndef XPR_H
+#define XPR_H
+
+#include "windowstr.h"
+#include "screenint.h"
+#include <Xplugin.h>
+
+#include "darwin.h"
+
+#undef DEBUG_LOG
+#define DEBUG_LOG(msg, args...) ASL_LOG(ASL_LEVEL_DEBUG, "xpr", msg, ##args)
+
+Bool QuartzModeBundleInit(void);
+
+void AppleDRIExtensionInit(void);
+void xprAppleWMInit(void);
+Bool xprInit(ScreenPtr pScreen);
+Bool xprIsX11Window(int windowNumber);
+WindowPtr xprGetXWindow(xp_window_id wid);
+
+void xprHideWindows(Bool hide);
+
+Bool QuartzInitCursor(ScreenPtr pScreen);
+void QuartzSuspendXCursor(ScreenPtr pScreen);
+void QuartzResumeXCursor(ScreenPtr pScreen);
+
+/* If we are rooted, we need the root window and desktop levels to be below
+ * the menubar (24) but above native windows. Normal window level is 0.
+ * Floating window level is 3. The rest are filled in as appropriate.
+ * See CGWindowLevel.h
+ */
+
+#include <X11/extensions/applewmconst.h>
+static const int normal_window_levels[AppleWMNumWindowLevels+1] = {
+0, 3, 4, 5, INT_MIN + 30, INT_MIN + 29,
+};
+static const int rooted_window_levels[AppleWMNumWindowLevels+1] = {
+20, 21, 22, 23, 19, 18,
+};
+
+#endif /* XPR_H */
diff --git a/xorg-server/hw/xquartz/xpr/xprAppleWM.c b/xorg-server/hw/xquartz/xpr/xprAppleWM.c
index 6f501e201..b6b9a5fc8 100644
--- a/xorg-server/hw/xquartz/xpr/xprAppleWM.c
+++ b/xorg-server/hw/xquartz/xpr/xprAppleWM.c
@@ -1,162 +1,162 @@
-/*
- * Xplugin rootless implementation functions for 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, 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.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "xpr.h"
-
-#include <X11/extensions/applewmproto.h>
-
-#include "applewmExt.h"
-#include "rootless.h"
-#include "rootlessCommon.h"
-#include <Xplugin.h>
-#include <X11/X.h>
-#include "quartz.h"
-#include "x-hash.h"
-
-static int xprSetWindowLevel(
- WindowPtr pWin,
- int level)
-{
- xp_window_id wid;
- xp_window_changes wc;
- RootlessWindowRec *winRec;
-
- // AppleWMNumWindowLevels is allowed, but is only set by the server
- // for the root window.
- if (level < 0 || level >= AppleWMNumWindowLevels) {
- return BadValue;
- }
-
- wid = x_cvt_vptr_to_uint(RootlessFrameForWindow (pWin, TRUE));
- if (wid == 0)
- return BadWindow;
-
- RootlessStopDrawing (pWin, FALSE);
- winRec = WINREC(pWin);
-
- if(!winRec)
- return BadWindow;
-
- if(XQuartzIsRootless)
- wc.window_level = normal_window_levels[level];
- else if(XQuartzShieldingWindowLevel)
- wc.window_level = XQuartzShieldingWindowLevel + 1;
- else
- wc.window_level = rooted_window_levels[level];
-
- if (xp_configure_window (wid, XP_WINDOW_LEVEL, &wc) != Success) {
- return BadValue;
- }
-
- winRec->level = level;
-
- return Success;
-}
-
-#if defined(XPLUGIN_VERSION) && XPLUGIN_VERSION >= 3
-static int xprAttachTransient(WindowPtr pWinChild, WindowPtr pWinParent) {
- xp_window_id child_wid, parent_wid;
- xp_window_changes wc;
-
- child_wid = x_cvt_vptr_to_uint(RootlessFrameForWindow(pWinChild, TRUE));
- if (child_wid == 0)
- return BadWindow;
-
- if(pWinParent) {
- parent_wid = x_cvt_vptr_to_uint(RootlessFrameForWindow(pWinParent, TRUE));
- if (parent_wid == 0)
- return BadWindow;
- } else {
- parent_wid = 0;
- }
-
- wc.transient_for = parent_wid;
-
- RootlessStopDrawing (pWinChild, FALSE);
-
- if (xp_configure_window(child_wid, XP_ATTACH_TRANSIENT, &wc) != Success) {
- return BadValue;
- }
-
- return Success;
-}
-#endif
-
-static int xprFrameDraw(
- WindowPtr pWin,
- xp_frame_class class,
- xp_frame_attr attr,
- const BoxRec *outer,
- const BoxRec *inner,
- unsigned int title_len,
- const unsigned char *title_bytes)
-{
- xp_window_id wid;
-
- wid = x_cvt_vptr_to_uint(RootlessFrameForWindow (pWin, FALSE));
- if (wid == 0)
- return BadWindow;
-
- if (xp_frame_draw (wid, class, attr, outer, inner,
- title_len, title_bytes) != Success)
- {
- return BadValue;
- }
-
- return Success;
-}
-
-static AppleWMProcsRec xprAppleWMProcs = {
- xp_disable_update,
- xp_reenable_update,
- xprSetWindowLevel,
- xp_frame_get_rect,
- xp_frame_hit_test,
- xprFrameDraw,
-#if defined(XPLUGIN_VERSION) && XPLUGIN_VERSION >= 3
- xp_set_dock_proxy,
- xprAttachTransient
-#elif defined(XPLUGIN_VERSION) && XPLUGIN_VERSION >= 2
- xp_set_dock_proxy,
- NULL
-#else
- NULL,
- NULL
-#endif
-};
-
-
-void xprAppleWMInit(void)
-{
- AppleWMExtensionInit(&xprAppleWMProcs);
-}
+/*
+ * Xplugin rootless implementation functions for 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, 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.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "xpr.h"
+
+#include <X11/extensions/applewmproto.h>
+
+#include "applewmExt.h"
+#include "rootless.h"
+#include "rootlessCommon.h"
+#include <Xplugin.h>
+#include <X11/X.h>
+#include "quartz.h"
+#include "x-hash.h"
+
+static int xprSetWindowLevel(
+ WindowPtr pWin,
+ int level)
+{
+ xp_window_id wid;
+ xp_window_changes wc;
+ RootlessWindowRec *winRec;
+
+ // AppleWMNumWindowLevels is allowed, but is only set by the server
+ // for the root window.
+ if (level < 0 || level >= AppleWMNumWindowLevels) {
+ return BadValue;
+ }
+
+ wid = x_cvt_vptr_to_uint(RootlessFrameForWindow (pWin, TRUE));
+ if (wid == 0)
+ return BadWindow;
+
+ RootlessStopDrawing (pWin, FALSE);
+ winRec = WINREC(pWin);
+
+ if(!winRec)
+ return BadWindow;
+
+ if(XQuartzIsRootless)
+ wc.window_level = normal_window_levels[level];
+ else if(XQuartzShieldingWindowLevel)
+ wc.window_level = XQuartzShieldingWindowLevel + 1;
+ else
+ wc.window_level = rooted_window_levels[level];
+
+ if (xp_configure_window (wid, XP_WINDOW_LEVEL, &wc) != Success) {
+ return BadValue;
+ }
+
+ winRec->level = level;
+
+ return Success;
+}
+
+#if defined(XPLUGIN_VERSION) && XPLUGIN_VERSION >= 3
+static int xprAttachTransient(WindowPtr pWinChild, WindowPtr pWinParent) {
+ xp_window_id child_wid, parent_wid;
+ xp_window_changes wc;
+
+ child_wid = x_cvt_vptr_to_uint(RootlessFrameForWindow(pWinChild, TRUE));
+ if (child_wid == 0)
+ return BadWindow;
+
+ if(pWinParent) {
+ parent_wid = x_cvt_vptr_to_uint(RootlessFrameForWindow(pWinParent, TRUE));
+ if (parent_wid == 0)
+ return BadWindow;
+ } else {
+ parent_wid = 0;
+ }
+
+ wc.transient_for = parent_wid;
+
+ RootlessStopDrawing (pWinChild, FALSE);
+
+ if (xp_configure_window(child_wid, XP_ATTACH_TRANSIENT, &wc) != Success) {
+ return BadValue;
+ }
+
+ return Success;
+}
+#endif
+
+static int xprFrameDraw(
+ WindowPtr pWin,
+ xp_frame_class class,
+ xp_frame_attr attr,
+ const BoxRec *outer,
+ const BoxRec *inner,
+ unsigned int title_len,
+ const unsigned char *title_bytes)
+{
+ xp_window_id wid;
+
+ wid = x_cvt_vptr_to_uint(RootlessFrameForWindow (pWin, FALSE));
+ if (wid == 0)
+ return BadWindow;
+
+ if (xp_frame_draw (wid, class, attr, outer, inner,
+ title_len, title_bytes) != Success)
+ {
+ return BadValue;
+ }
+
+ return Success;
+}
+
+static AppleWMProcsRec xprAppleWMProcs = {
+ xp_disable_update,
+ xp_reenable_update,
+ xprSetWindowLevel,
+ xp_frame_get_rect,
+ xp_frame_hit_test,
+ xprFrameDraw,
+#if defined(XPLUGIN_VERSION) && XPLUGIN_VERSION >= 3
+ xp_set_dock_proxy,
+ xprAttachTransient
+#elif defined(XPLUGIN_VERSION) && XPLUGIN_VERSION >= 2
+ xp_set_dock_proxy,
+ NULL
+#else
+ NULL,
+ NULL
+#endif
+};
+
+
+void xprAppleWMInit(void)
+{
+ AppleWMExtensionInit(&xprAppleWMProcs);
+}
diff --git a/xorg-server/hw/xquartz/xpr/xprEvent.c b/xorg-server/hw/xquartz/xpr/xprEvent.c
index 9d476d1f4..4e7ece64f 100644
--- a/xorg-server/hw/xquartz/xpr/xprEvent.c
+++ b/xorg-server/hw/xquartz/xpr/xprEvent.c
@@ -1,78 +1,78 @@
-/* Copyright (c) 2008 Apple 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 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.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "xpr.h"
-
-#include <X11/X.h>
-#include <X11/Xmd.h>
-#include <X11/Xproto.h>
-#include "misc.h"
-#include "windowstr.h"
-#include "pixmapstr.h"
-#include "inputstr.h"
-#include "eventstr.h"
-#include "mi.h"
-#include "scrnintstr.h"
-#include "mipointer.h"
-
-#include "quartz.h"
-#include "quartzKeyboard.h"
-#include "darwinEvents.h"
-
-#include <sys/types.h>
-#include <sys/uio.h>
-#include <unistd.h>
-
-#include "rootlessWindow.h"
-#include "xprEvent.h"
-
-Bool QuartzModeEventHandler(int screenNum, XQuartzEvent *e, DeviceIntPtr dev) {
- switch(e->subtype) {
- case kXquartzWindowState:
- DEBUG_LOG("kXquartzWindowState\n");
- RootlessNativeWindowStateChanged(xprGetXWindow(e->data[0]),
- e->data[1]);
- return TRUE;
-
- case kXquartzWindowMoved:
- DEBUG_LOG("kXquartzWindowMoved\n");
- RootlessNativeWindowMoved(xprGetXWindow(e->data[0]));
- return TRUE;
-
- case kXquartzBringAllToFront:
- DEBUG_LOG("kXquartzBringAllToFront\n");
- RootlessOrderAllWindows(e->data[0]);
- return TRUE;
- default:
- return FALSE;
- }
-}
+/* Copyright (c) 2008 Apple 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 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.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "xpr.h"
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "inputstr.h"
+#include "eventstr.h"
+#include "mi.h"
+#include "scrnintstr.h"
+#include "mipointer.h"
+
+#include "quartz.h"
+#include "quartzKeyboard.h"
+#include "darwinEvents.h"
+
+#include <sys/types.h>
+#include <sys/uio.h>
+#include <unistd.h>
+
+#include "rootlessWindow.h"
+#include "xprEvent.h"
+
+Bool QuartzModeEventHandler(int screenNum, XQuartzEvent *e, DeviceIntPtr dev) {
+ switch(e->subtype) {
+ case kXquartzWindowState:
+ DEBUG_LOG("kXquartzWindowState\n");
+ RootlessNativeWindowStateChanged(xprGetXWindow(e->data[0]),
+ e->data[1]);
+ return TRUE;
+
+ case kXquartzWindowMoved:
+ DEBUG_LOG("kXquartzWindowMoved\n");
+ RootlessNativeWindowMoved(xprGetXWindow(e->data[0]));
+ return TRUE;
+
+ case kXquartzBringAllToFront:
+ DEBUG_LOG("kXquartzBringAllToFront\n");
+ RootlessOrderAllWindows(e->data[0]);
+ return TRUE;
+ default:
+ return FALSE;
+ }
+}
diff --git a/xorg-server/hw/xquartz/xpr/xprFrame.c b/xorg-server/hw/xquartz/xpr/xprFrame.c
index 4214eff33..98f1cc3ed 100644
--- a/xorg-server/hw/xquartz/xpr/xprFrame.c
+++ b/xorg-server/hw/xquartz/xpr/xprFrame.c
@@ -1,608 +1,608 @@
-/*
- * Xplugin rootless implementation frame functions
- *
- * Copyright (c) 2002-2011 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, 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.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "xpr.h"
-#include "rootlessCommon.h"
-#include <Xplugin.h>
-#include "x-hash.h"
-#include "applewmExt.h"
-
-#include "propertyst.h"
-#include "dix.h"
-#include <X11/Xatom.h>
-#include "windowstr.h"
-#include "quartz.h"
-
-#ifdef HAVE_LIBDISPATCH
-#include <dispatch/dispatch.h>
-#else
-#include <pthread.h>
-#endif
-
-#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; \
-}
-
-DEFINE_ATOM_HELPER(xa_native_window_id, "_NATIVE_WINDOW_ID")
-
-/* Maps xp_window_id -> RootlessWindowRec */
-static x_hash_table *window_hash;
-
-/* Need to guard window_hash since xprIsX11Window can be called from any thread. */
-#ifdef HAVE_LIBDISPATCH
-static dispatch_queue_t window_hash_serial_q;
-#else
-static pthread_rwlock_t window_hash_rwlock;
-#endif
-
-/* Prototypes for static functions */
-static Bool xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen,
- int newX, int newY, RegionPtr pShape);
-static void xprDestroyFrame(RootlessFrameID wid);
-static void xprMoveFrame(RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY);
-static void xprResizeFrame(RootlessFrameID wid, ScreenPtr pScreen,
- int newX, int newY, unsigned int newW, unsigned int newH,
- unsigned int gravity);
-static void xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid);
-static void xprReshapeFrame(RootlessFrameID wid, RegionPtr pShape);
-static void xprUnmapFrame(RootlessFrameID wid);
-static void xprStartDrawing(RootlessFrameID wid, char **pixelData, int *bytesPerRow);
-static void xprStopDrawing(RootlessFrameID wid, Bool flush);
-static void xprUpdateRegion(RootlessFrameID wid, RegionPtr pDamage);
-static void xprDamageRects(RootlessFrameID wid, int nrects, const BoxRec *rects,
- int shift_x, int shift_y);
-static void xprSwitchWindow(RootlessWindowPtr pFrame, WindowPtr oldWin);
-static Bool xprDoReorderWindow(RootlessWindowPtr pFrame);
-static void xprHideWindow(RootlessFrameID wid);
-static void xprUpdateColormap(RootlessFrameID wid, ScreenPtr pScreen);
-static void xprCopyWindow(RootlessFrameID wid, int dstNrects, const BoxRec *dstRects,
- int dx, int dy);
-
-
-static inline xp_error
-xprConfigureWindow(xp_window_id id, unsigned int mask,
- const xp_window_changes *values)
-{
- return xp_configure_window(id, mask, values);
-}
-
-
-static void
-xprSetNativeProperty(RootlessWindowPtr pFrame)
-{
- xp_error err;
- unsigned int native_id;
- long data;
-
- err = xp_get_native_window(x_cvt_vptr_to_uint(pFrame->wid), &native_id);
- if (err == Success)
- {
- /* FIXME: move this to AppleWM extension */
-
- data = native_id;
- dixChangeWindowProperty(serverClient, pFrame->win, xa_native_window_id(),
- XA_INTEGER, 32, PropModeReplace, 1, &data, TRUE);
- }
-}
-
-static xp_error
-xprColormapCallback(void *data, int first_color, int n_colors, uint32_t *colors)
-{
- return (RootlessResolveColormap (data, first_color, n_colors, colors) ? XP_Success : XP_BadMatch);
-}
-
-/*
- * Create and display a new frame.
- */
-static Bool
-xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen,
- int newX, int newY, RegionPtr pShape)
-{
- WindowPtr pWin = pFrame->win;
- xp_window_changes wc;
- unsigned int mask = 0;
- xp_error err;
-
- wc.x = newX;
- wc.y = newY;
- wc.width = pFrame->width;
- wc.height = pFrame->height;
- wc.bit_gravity = XP_GRAVITY_NONE;
- mask |= XP_BOUNDS;
-
- if (pWin->drawable.depth == 8)
- {
- wc.depth = XP_DEPTH_INDEX8;
- wc.colormap = xprColormapCallback;
- wc.colormap_data = pScreen;
- mask |= XP_COLORMAP;
- }
- else if (pWin->drawable.depth == 15)
- wc.depth = XP_DEPTH_RGB555;
- else if (pWin->drawable.depth == 24)
- wc.depth = XP_DEPTH_ARGB8888;
- else
- wc.depth = XP_DEPTH_NIL;
- mask |= XP_DEPTH;
-
- if (pShape != NULL)
- {
- wc.shape_nrects = RegionNumRects(pShape);
- wc.shape_rects = RegionRects(pShape);
- wc.shape_tx = wc.shape_ty = 0;
- mask |= XP_SHAPE;
- }
-
- pFrame->level = !IsRoot (pWin) ? AppleWMWindowLevelNormal : AppleWMNumWindowLevels;
-
- if(XQuartzIsRootless)
- wc.window_level = normal_window_levels[pFrame->level];
- else if(XQuartzShieldingWindowLevel)
- wc.window_level = XQuartzShieldingWindowLevel + 1;
- else
- wc.window_level = rooted_window_levels[pFrame->level];
- mask |= XP_WINDOW_LEVEL;
-
- err = xp_create_window(mask, &wc, (xp_window_id *) &pFrame->wid);
-
- if (err != Success)
- {
- return FALSE;
- }
-
-#ifdef HAVE_LIBDISPATCH
- dispatch_async(window_hash_serial_q, ^{
- x_hash_table_insert(window_hash, pFrame->wid, pFrame);
- });
-#else
- pthread_rwlock_wrlock(&window_hash_rwlock);
- x_hash_table_insert(window_hash, pFrame->wid, pFrame);
- pthread_rwlock_wrlock(&window_hash_rwlock);
-#endif
-
- xprSetNativeProperty(pFrame);
-
- return TRUE;
-}
-
-
-/*
- * Destroy a frame.
- */
-static void
-xprDestroyFrame(RootlessFrameID wid)
-{
- xp_error err;
-
-#ifdef HAVE_LIBDISPATCH
- dispatch_async(window_hash_serial_q, ^{
- x_hash_table_remove(window_hash, wid);
- });
-#else
- pthread_rwlock_wrlock(&window_hash_rwlock);
- x_hash_table_remove(window_hash, wid);
- pthread_rwlock_unlock(&window_hash_rwlock);
-#endif
-
- err = xp_destroy_window(x_cvt_vptr_to_uint(wid));
- if (err != Success)
- FatalError("Could not destroy window %d (%d).", (int)x_cvt_vptr_to_uint(wid), (int)err);
-}
-
-
-/*
- * Move a frame on screen.
- */
-static void
-xprMoveFrame(RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY)
-{
- xp_window_changes wc;
-
- wc.x = newX;
- wc.y = newY;
- // ErrorF("xprMoveFrame(%d, %p, %d, %d)\n", wid, pScreen, newX, newY);
- xprConfigureWindow(x_cvt_vptr_to_uint(wid), XP_ORIGIN, &wc);
-}
-
-
-/*
- * Resize and move a frame.
- */
-static void
-xprResizeFrame(RootlessFrameID wid, ScreenPtr pScreen,
- int newX, int newY, unsigned int newW, unsigned int newH,
- unsigned int gravity)
-{
- xp_window_changes wc;
-
- wc.x = newX;
- wc.y = newY;
- wc.width = newW;
- wc.height = newH;
- wc.bit_gravity = gravity;
-
- /* It's unlikely that being async will save us anything here.
- But it can't hurt. */
-
- xprConfigureWindow(x_cvt_vptr_to_uint(wid), XP_BOUNDS, &wc);
-}
-
-
-/*
- * Change frame stacking.
- */
-static void xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid) {
- xp_window_changes wc;
- unsigned int mask = XP_STACKING;
-#ifdef HAVE_LIBDISPATCH
- __block
-#endif
- RootlessWindowRec *winRec;
-
- /* Stack frame below nextWid it if it exists, or raise
- frame above everything otherwise. */
-
- if(nextWid == NULL) {
- wc.stack_mode = XP_MAPPED_ABOVE;
- wc.sibling = 0;
- } else {
- wc.stack_mode = XP_MAPPED_BELOW;
- wc.sibling = x_cvt_vptr_to_uint(nextWid);
- }
-
-#ifdef HAVE_LIBDISPATCH
- dispatch_sync(window_hash_serial_q, ^{
- winRec = x_hash_table_lookup(window_hash, wid, NULL);
- });
-#else
- pthread_rwlock_rdlock(&window_hash_rwlock);
- winRec = x_hash_table_lookup(window_hash, wid, NULL);
- pthread_rwlock_unlock(&window_hash_rwlock);
-#endif
-
- if(winRec) {
- if(XQuartzIsRootless)
- wc.window_level = normal_window_levels[winRec->level];
- else if(XQuartzShieldingWindowLevel)
- wc.window_level = XQuartzShieldingWindowLevel + 1;
- else
- wc.window_level = rooted_window_levels[winRec->level];
- mask |= XP_WINDOW_LEVEL;
- }
-
- xprConfigureWindow(x_cvt_vptr_to_uint(wid), mask, &wc);
-}
-
-
-/*
- * Change the frame's shape.
- */
-static void
-xprReshapeFrame(RootlessFrameID wid, RegionPtr pShape)
-{
- xp_window_changes wc;
-
- if (pShape != NULL)
- {
- wc.shape_nrects = RegionNumRects(pShape);
- wc.shape_rects = RegionRects(pShape);
- }
- else
- {
- wc.shape_nrects = -1;
- wc.shape_rects = NULL;
- }
-
- wc.shape_tx = wc.shape_ty = 0;
-
- xprConfigureWindow(x_cvt_vptr_to_uint(wid), XP_SHAPE, &wc);
-}
-
-
-/*
- * Unmap a frame.
- */
-static void
-xprUnmapFrame(RootlessFrameID wid)
-{
- xp_window_changes wc;
-
- wc.stack_mode = XP_UNMAPPED;
- wc.sibling = 0;
-
- xprConfigureWindow(x_cvt_vptr_to_uint(wid), XP_STACKING, &wc);
-}
-
-
-/*
- * Start drawing to a frame.
- * Prepare for direct access to its backing buffer.
- */
-static void
-xprStartDrawing(RootlessFrameID wid, char **pixelData, int *bytesPerRow)
-{
- void *data[2];
- unsigned int rowbytes[2];
- xp_error err;
-
- err = xp_lock_window(x_cvt_vptr_to_uint(wid), NULL, NULL, data, rowbytes, NULL);
- if (err != Success)
- FatalError("Could not lock window %d for drawing (%d).", (int)x_cvt_vptr_to_uint(wid), (int)err);
-
- *pixelData = data[0];
- *bytesPerRow = rowbytes[0];
-}
-
-
-/*
- * Stop drawing to a frame.
- */
-static void
-xprStopDrawing(RootlessFrameID wid, Bool flush)
-{
- xp_error err;
-
- err = xp_unlock_window(x_cvt_vptr_to_uint(wid), flush);
- /* This should be a FatalError, but we started tripping over it. Make it a
- * FatalError after http://xquartz.macosforge.org/trac/ticket/482 is fixed.
- */
- if(err != Success)
- ErrorF("Could not unlock window %d after drawing (%d).", (int)x_cvt_vptr_to_uint(wid), (int)err);
-}
-
-
-/*
- * Flush drawing updates to the screen.
- */
-static void
-xprUpdateRegion(RootlessFrameID wid, RegionPtr pDamage)
-{
- xp_flush_window(x_cvt_vptr_to_uint(wid));
-}
-
-
-/*
- * Mark damaged rectangles as requiring redisplay to screen.
- */
-static void
-xprDamageRects(RootlessFrameID wid, int nrects, const BoxRec *rects,
- int shift_x, int shift_y)
-{
- xp_mark_window(x_cvt_vptr_to_uint(wid), nrects, rects, shift_x, shift_y);
-}
-
-
-/*
- * Called after the window associated with a frame has been switched
- * to a new top-level parent.
- */
-static void
-xprSwitchWindow(RootlessWindowPtr pFrame, WindowPtr oldWin)
-{
- DeleteProperty(serverClient, oldWin, xa_native_window_id());
-
- xprSetNativeProperty(pFrame);
-}
-
-
-/*
- * Called to check if the frame should be reordered when it is restacked.
- */
-static Bool xprDoReorderWindow(RootlessWindowPtr pFrame)
-{
- WindowPtr pWin = pFrame->win;
-
- return AppleWMDoReorderWindow(pWin);
-}
-
-
-/*
- * Copy area in frame to another part of frame.
- * Used to accelerate scrolling.
- */
-static void
-xprCopyWindow(RootlessFrameID wid, int dstNrects, const BoxRec *dstRects,
- int dx, int dy)
-{
- xp_copy_window(x_cvt_vptr_to_uint(wid), x_cvt_vptr_to_uint(wid),
- dstNrects, dstRects, dx, dy);
-}
-
-
-static RootlessFrameProcsRec xprRootlessProcs = {
- xprCreateFrame,
- xprDestroyFrame,
- xprMoveFrame,
- xprResizeFrame,
- xprRestackFrame,
- xprReshapeFrame,
- xprUnmapFrame,
- xprStartDrawing,
- xprStopDrawing,
- xprUpdateRegion,
- xprDamageRects,
- xprSwitchWindow,
- xprDoReorderWindow,
- xprHideWindow,
- xprUpdateColormap,
- xp_copy_bytes,
- xprCopyWindow
-};
-
-
-/*
- * Initialize XPR implementation
- */
-Bool
-xprInit(ScreenPtr pScreen)
-{
- RootlessInit(pScreen, &xprRootlessProcs);
-
- rootless_CopyBytes_threshold = xp_copy_bytes_threshold;
- rootless_CopyWindow_threshold = xp_scroll_area_threshold;
-
- assert((window_hash = x_hash_table_new(NULL, NULL, NULL, NULL)));
-#ifdef HAVE_LIBDISPATCH
- assert((window_hash_serial_q = dispatch_queue_create(BUNDLE_ID_PREFIX".X11.xpr_window_hash", NULL)));
-#else
- assert(0 == pthread_rwlock_init(&window_hash_rwlock, NULL));
-#endif
-
- return TRUE;
-}
-
-
-/*
- * Given the id of a physical window, try to find the top-level (or root)
- * X window that it represents.
- */
-WindowPtr
-xprGetXWindow(xp_window_id wid)
-{
-#ifdef HAVE_LIBDISPATCH
- RootlessWindowRec *winRec __block;
- dispatch_sync(window_hash_serial_q, ^{
- winRec = x_hash_table_lookup(window_hash, x_cvt_uint_to_vptr(wid), NULL);
- });
-#else
- RootlessWindowRec *winRec;
- pthread_rwlock_rdlock(&window_hash_rwlock);
- winRec = x_hash_table_lookup(window_hash, x_cvt_uint_to_vptr(wid), NULL);
- pthread_rwlock_unlock(&window_hash_rwlock);
-#endif
-
- return winRec != NULL ? winRec->win : NULL;
-}
-
-/*
- * The windowNumber is an AppKit window number. Returns TRUE if xpr is
- * displaying a window with that number.
- */
-Bool
-xprIsX11Window(int windowNumber)
-{
- Bool ret;
- xp_window_id wid;
-
- if (xp_lookup_native_window(windowNumber, &wid))
- ret = xprGetXWindow(wid) != NULL;
- else
- ret = FALSE;
-
- return ret;
-}
-
-
-/*
- * xprHideWindows
- * Hide or unhide all top level windows. This is called for application hide/
- * unhide events if the window manager is not Apple-WM aware. Xplugin windows
- * do not hide or unhide themselves.
- */
-void
-xprHideWindows(Bool hide)
-{
- int screen;
- WindowPtr pRoot, pWin;
-
- for (screen = 0; screen < screenInfo.numScreens; screen++) {
- RootlessFrameID prevWid = NULL;
- pRoot = screenInfo.screens[screen]->root;
-
- for (pWin = pRoot->firstChild; pWin; pWin = pWin->nextSib) {
- RootlessWindowRec *winRec = WINREC(pWin);
-
- if (winRec != NULL) {
- if (hide) {
- xprUnmapFrame(winRec->wid);
- } else {
- BoxRec box;
-
- xprRestackFrame(winRec->wid, prevWid);
- prevWid = winRec->wid;
-
- box.x1 = 0;
- box.y1 = 0;
- box.x2 = winRec->width;
- box.y2 = winRec->height;
-
- xprDamageRects(winRec->wid, 1, &box, 0, 0);
- RootlessQueueRedisplay(screenInfo.screens[screen]);
- }
- }
- }
- }
-}
-
-// XXX: identical to x_cvt_vptr_to_uint ?
-#define MAKE_WINDOW_ID(x) ((xp_window_id)((size_t)(x)))
-
-Bool no_configure_window;
-
-static inline int
-configure_window (xp_window_id id, unsigned int mask,
- const xp_window_changes *values)
-{
- if (!no_configure_window)
- return xp_configure_window (id, mask, values);
- else
- return XP_Success;
-}
-
-
-static
-void xprUpdateColormap(RootlessFrameID wid, ScreenPtr pScreen)
-{
- /* This is how we tell xp that the colormap may have changed. */
- xp_window_changes wc;
- wc.colormap = xprColormapCallback;
- wc.colormap_data = pScreen;
-
- configure_window(MAKE_WINDOW_ID(wid), XP_COLORMAP, &wc);
-}
-
-static
-void xprHideWindow(RootlessFrameID wid)
-{
- xp_window_changes wc;
- wc.stack_mode = XP_UNMAPPED;
- wc.sibling = 0;
- configure_window(MAKE_WINDOW_ID(wid), XP_STACKING, &wc);
-}
+/*
+ * Xplugin rootless implementation frame functions
+ *
+ * Copyright (c) 2002-2011 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, 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.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "xpr.h"
+#include "rootlessCommon.h"
+#include <Xplugin.h>
+#include "x-hash.h"
+#include "applewmExt.h"
+
+#include "propertyst.h"
+#include "dix.h"
+#include <X11/Xatom.h>
+#include "windowstr.h"
+#include "quartz.h"
+
+#ifdef HAVE_LIBDISPATCH
+#include <dispatch/dispatch.h>
+#else
+#include <pthread.h>
+#endif
+
+#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; \
+}
+
+DEFINE_ATOM_HELPER(xa_native_window_id, "_NATIVE_WINDOW_ID")
+
+/* Maps xp_window_id -> RootlessWindowRec */
+static x_hash_table *window_hash;
+
+/* Need to guard window_hash since xprIsX11Window can be called from any thread. */
+#ifdef HAVE_LIBDISPATCH
+static dispatch_queue_t window_hash_serial_q;
+#else
+static pthread_rwlock_t window_hash_rwlock;
+#endif
+
+/* Prototypes for static functions */
+static Bool xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen,
+ int newX, int newY, RegionPtr pShape);
+static void xprDestroyFrame(RootlessFrameID wid);
+static void xprMoveFrame(RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY);
+static void xprResizeFrame(RootlessFrameID wid, ScreenPtr pScreen,
+ int newX, int newY, unsigned int newW, unsigned int newH,
+ unsigned int gravity);
+static void xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid);
+static void xprReshapeFrame(RootlessFrameID wid, RegionPtr pShape);
+static void xprUnmapFrame(RootlessFrameID wid);
+static void xprStartDrawing(RootlessFrameID wid, char **pixelData, int *bytesPerRow);
+static void xprStopDrawing(RootlessFrameID wid, Bool flush);
+static void xprUpdateRegion(RootlessFrameID wid, RegionPtr pDamage);
+static void xprDamageRects(RootlessFrameID wid, int nrects, const BoxRec *rects,
+ int shift_x, int shift_y);
+static void xprSwitchWindow(RootlessWindowPtr pFrame, WindowPtr oldWin);
+static Bool xprDoReorderWindow(RootlessWindowPtr pFrame);
+static void xprHideWindow(RootlessFrameID wid);
+static void xprUpdateColormap(RootlessFrameID wid, ScreenPtr pScreen);
+static void xprCopyWindow(RootlessFrameID wid, int dstNrects, const BoxRec *dstRects,
+ int dx, int dy);
+
+
+static inline xp_error
+xprConfigureWindow(xp_window_id id, unsigned int mask,
+ const xp_window_changes *values)
+{
+ return xp_configure_window(id, mask, values);
+}
+
+
+static void
+xprSetNativeProperty(RootlessWindowPtr pFrame)
+{
+ xp_error err;
+ unsigned int native_id;
+ long data;
+
+ err = xp_get_native_window(x_cvt_vptr_to_uint(pFrame->wid), &native_id);
+ if (err == Success)
+ {
+ /* FIXME: move this to AppleWM extension */
+
+ data = native_id;
+ dixChangeWindowProperty(serverClient, pFrame->win, xa_native_window_id(),
+ XA_INTEGER, 32, PropModeReplace, 1, &data, TRUE);
+ }
+}
+
+static xp_error
+xprColormapCallback(void *data, int first_color, int n_colors, uint32_t *colors)
+{
+ return (RootlessResolveColormap (data, first_color, n_colors, colors) ? XP_Success : XP_BadMatch);
+}
+
+/*
+ * Create and display a new frame.
+ */
+static Bool
+xprCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen,
+ int newX, int newY, RegionPtr pShape)
+{
+ WindowPtr pWin = pFrame->win;
+ xp_window_changes wc;
+ unsigned int mask = 0;
+ xp_error err;
+
+ wc.x = newX;
+ wc.y = newY;
+ wc.width = pFrame->width;
+ wc.height = pFrame->height;
+ wc.bit_gravity = XP_GRAVITY_NONE;
+ mask |= XP_BOUNDS;
+
+ if (pWin->drawable.depth == 8)
+ {
+ wc.depth = XP_DEPTH_INDEX8;
+ wc.colormap = xprColormapCallback;
+ wc.colormap_data = pScreen;
+ mask |= XP_COLORMAP;
+ }
+ else if (pWin->drawable.depth == 15)
+ wc.depth = XP_DEPTH_RGB555;
+ else if (pWin->drawable.depth == 24)
+ wc.depth = XP_DEPTH_ARGB8888;
+ else
+ wc.depth = XP_DEPTH_NIL;
+ mask |= XP_DEPTH;
+
+ if (pShape != NULL)
+ {
+ wc.shape_nrects = RegionNumRects(pShape);
+ wc.shape_rects = RegionRects(pShape);
+ wc.shape_tx = wc.shape_ty = 0;
+ mask |= XP_SHAPE;
+ }
+
+ pFrame->level = !IsRoot (pWin) ? AppleWMWindowLevelNormal : AppleWMNumWindowLevels;
+
+ if(XQuartzIsRootless)
+ wc.window_level = normal_window_levels[pFrame->level];
+ else if(XQuartzShieldingWindowLevel)
+ wc.window_level = XQuartzShieldingWindowLevel + 1;
+ else
+ wc.window_level = rooted_window_levels[pFrame->level];
+ mask |= XP_WINDOW_LEVEL;
+
+ err = xp_create_window(mask, &wc, (xp_window_id *) &pFrame->wid);
+
+ if (err != Success)
+ {
+ return FALSE;
+ }
+
+#ifdef HAVE_LIBDISPATCH
+ dispatch_async(window_hash_serial_q, ^{
+ x_hash_table_insert(window_hash, pFrame->wid, pFrame);
+ });
+#else
+ pthread_rwlock_wrlock(&window_hash_rwlock);
+ x_hash_table_insert(window_hash, pFrame->wid, pFrame);
+ pthread_rwlock_wrlock(&window_hash_rwlock);
+#endif
+
+ xprSetNativeProperty(pFrame);
+
+ return TRUE;
+}
+
+
+/*
+ * Destroy a frame.
+ */
+static void
+xprDestroyFrame(RootlessFrameID wid)
+{
+ xp_error err;
+
+#ifdef HAVE_LIBDISPATCH
+ dispatch_async(window_hash_serial_q, ^{
+ x_hash_table_remove(window_hash, wid);
+ });
+#else
+ pthread_rwlock_wrlock(&window_hash_rwlock);
+ x_hash_table_remove(window_hash, wid);
+ pthread_rwlock_unlock(&window_hash_rwlock);
+#endif
+
+ err = xp_destroy_window(x_cvt_vptr_to_uint(wid));
+ if (err != Success)
+ FatalError("Could not destroy window %d (%d).", (int)x_cvt_vptr_to_uint(wid), (int)err);
+}
+
+
+/*
+ * Move a frame on screen.
+ */
+static void
+xprMoveFrame(RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY)
+{
+ xp_window_changes wc;
+
+ wc.x = newX;
+ wc.y = newY;
+ // ErrorF("xprMoveFrame(%d, %p, %d, %d)\n", wid, pScreen, newX, newY);
+ xprConfigureWindow(x_cvt_vptr_to_uint(wid), XP_ORIGIN, &wc);
+}
+
+
+/*
+ * Resize and move a frame.
+ */
+static void
+xprResizeFrame(RootlessFrameID wid, ScreenPtr pScreen,
+ int newX, int newY, unsigned int newW, unsigned int newH,
+ unsigned int gravity)
+{
+ xp_window_changes wc;
+
+ wc.x = newX;
+ wc.y = newY;
+ wc.width = newW;
+ wc.height = newH;
+ wc.bit_gravity = gravity;
+
+ /* It's unlikely that being async will save us anything here.
+ But it can't hurt. */
+
+ xprConfigureWindow(x_cvt_vptr_to_uint(wid), XP_BOUNDS, &wc);
+}
+
+
+/*
+ * Change frame stacking.
+ */
+static void xprRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid) {
+ xp_window_changes wc;
+ unsigned int mask = XP_STACKING;
+#ifdef HAVE_LIBDISPATCH
+ __block
+#endif
+ RootlessWindowRec *winRec;
+
+ /* Stack frame below nextWid it if it exists, or raise
+ frame above everything otherwise. */
+
+ if(nextWid == NULL) {
+ wc.stack_mode = XP_MAPPED_ABOVE;
+ wc.sibling = 0;
+ } else {
+ wc.stack_mode = XP_MAPPED_BELOW;
+ wc.sibling = x_cvt_vptr_to_uint(nextWid);
+ }
+
+#ifdef HAVE_LIBDISPATCH
+ dispatch_sync(window_hash_serial_q, ^{
+ winRec = x_hash_table_lookup(window_hash, wid, NULL);
+ });
+#else
+ pthread_rwlock_rdlock(&window_hash_rwlock);
+ winRec = x_hash_table_lookup(window_hash, wid, NULL);
+ pthread_rwlock_unlock(&window_hash_rwlock);
+#endif
+
+ if(winRec) {
+ if(XQuartzIsRootless)
+ wc.window_level = normal_window_levels[winRec->level];
+ else if(XQuartzShieldingWindowLevel)
+ wc.window_level = XQuartzShieldingWindowLevel + 1;
+ else
+ wc.window_level = rooted_window_levels[winRec->level];
+ mask |= XP_WINDOW_LEVEL;
+ }
+
+ xprConfigureWindow(x_cvt_vptr_to_uint(wid), mask, &wc);
+}
+
+
+/*
+ * Change the frame's shape.
+ */
+static void
+xprReshapeFrame(RootlessFrameID wid, RegionPtr pShape)
+{
+ xp_window_changes wc;
+
+ if (pShape != NULL)
+ {
+ wc.shape_nrects = RegionNumRects(pShape);
+ wc.shape_rects = RegionRects(pShape);
+ }
+ else
+ {
+ wc.shape_nrects = -1;
+ wc.shape_rects = NULL;
+ }
+
+ wc.shape_tx = wc.shape_ty = 0;
+
+ xprConfigureWindow(x_cvt_vptr_to_uint(wid), XP_SHAPE, &wc);
+}
+
+
+/*
+ * Unmap a frame.
+ */
+static void
+xprUnmapFrame(RootlessFrameID wid)
+{
+ xp_window_changes wc;
+
+ wc.stack_mode = XP_UNMAPPED;
+ wc.sibling = 0;
+
+ xprConfigureWindow(x_cvt_vptr_to_uint(wid), XP_STACKING, &wc);
+}
+
+
+/*
+ * Start drawing to a frame.
+ * Prepare for direct access to its backing buffer.
+ */
+static void
+xprStartDrawing(RootlessFrameID wid, char **pixelData, int *bytesPerRow)
+{
+ void *data[2];
+ unsigned int rowbytes[2];
+ xp_error err;
+
+ err = xp_lock_window(x_cvt_vptr_to_uint(wid), NULL, NULL, data, rowbytes, NULL);
+ if (err != Success)
+ FatalError("Could not lock window %d for drawing (%d).", (int)x_cvt_vptr_to_uint(wid), (int)err);
+
+ *pixelData = data[0];
+ *bytesPerRow = rowbytes[0];
+}
+
+
+/*
+ * Stop drawing to a frame.
+ */
+static void
+xprStopDrawing(RootlessFrameID wid, Bool flush)
+{
+ xp_error err;
+
+ err = xp_unlock_window(x_cvt_vptr_to_uint(wid), flush);
+ /* This should be a FatalError, but we started tripping over it. Make it a
+ * FatalError after http://xquartz.macosforge.org/trac/ticket/482 is fixed.
+ */
+ if(err != Success)
+ ErrorF("Could not unlock window %d after drawing (%d).", (int)x_cvt_vptr_to_uint(wid), (int)err);
+}
+
+
+/*
+ * Flush drawing updates to the screen.
+ */
+static void
+xprUpdateRegion(RootlessFrameID wid, RegionPtr pDamage)
+{
+ xp_flush_window(x_cvt_vptr_to_uint(wid));
+}
+
+
+/*
+ * Mark damaged rectangles as requiring redisplay to screen.
+ */
+static void
+xprDamageRects(RootlessFrameID wid, int nrects, const BoxRec *rects,
+ int shift_x, int shift_y)
+{
+ xp_mark_window(x_cvt_vptr_to_uint(wid), nrects, rects, shift_x, shift_y);
+}
+
+
+/*
+ * Called after the window associated with a frame has been switched
+ * to a new top-level parent.
+ */
+static void
+xprSwitchWindow(RootlessWindowPtr pFrame, WindowPtr oldWin)
+{
+ DeleteProperty(serverClient, oldWin, xa_native_window_id());
+
+ xprSetNativeProperty(pFrame);
+}
+
+
+/*
+ * Called to check if the frame should be reordered when it is restacked.
+ */
+static Bool xprDoReorderWindow(RootlessWindowPtr pFrame)
+{
+ WindowPtr pWin = pFrame->win;
+
+ return AppleWMDoReorderWindow(pWin);
+}
+
+
+/*
+ * Copy area in frame to another part of frame.
+ * Used to accelerate scrolling.
+ */
+static void
+xprCopyWindow(RootlessFrameID wid, int dstNrects, const BoxRec *dstRects,
+ int dx, int dy)
+{
+ xp_copy_window(x_cvt_vptr_to_uint(wid), x_cvt_vptr_to_uint(wid),
+ dstNrects, dstRects, dx, dy);
+}
+
+
+static RootlessFrameProcsRec xprRootlessProcs = {
+ xprCreateFrame,
+ xprDestroyFrame,
+ xprMoveFrame,
+ xprResizeFrame,
+ xprRestackFrame,
+ xprReshapeFrame,
+ xprUnmapFrame,
+ xprStartDrawing,
+ xprStopDrawing,
+ xprUpdateRegion,
+ xprDamageRects,
+ xprSwitchWindow,
+ xprDoReorderWindow,
+ xprHideWindow,
+ xprUpdateColormap,
+ xp_copy_bytes,
+ xprCopyWindow
+};
+
+
+/*
+ * Initialize XPR implementation
+ */
+Bool
+xprInit(ScreenPtr pScreen)
+{
+ RootlessInit(pScreen, &xprRootlessProcs);
+
+ rootless_CopyBytes_threshold = xp_copy_bytes_threshold;
+ rootless_CopyWindow_threshold = xp_scroll_area_threshold;
+
+ assert((window_hash = x_hash_table_new(NULL, NULL, NULL, NULL)));
+#ifdef HAVE_LIBDISPATCH
+ assert((window_hash_serial_q = dispatch_queue_create(BUNDLE_ID_PREFIX".X11.xpr_window_hash", NULL)));
+#else
+ assert(0 == pthread_rwlock_init(&window_hash_rwlock, NULL));
+#endif
+
+ return TRUE;
+}
+
+
+/*
+ * Given the id of a physical window, try to find the top-level (or root)
+ * X window that it represents.
+ */
+WindowPtr
+xprGetXWindow(xp_window_id wid)
+{
+#ifdef HAVE_LIBDISPATCH
+ RootlessWindowRec *winRec __block;
+ dispatch_sync(window_hash_serial_q, ^{
+ winRec = x_hash_table_lookup(window_hash, x_cvt_uint_to_vptr(wid), NULL);
+ });
+#else
+ RootlessWindowRec *winRec;
+ pthread_rwlock_rdlock(&window_hash_rwlock);
+ winRec = x_hash_table_lookup(window_hash, x_cvt_uint_to_vptr(wid), NULL);
+ pthread_rwlock_unlock(&window_hash_rwlock);
+#endif
+
+ return winRec != NULL ? winRec->win : NULL;
+}
+
+/*
+ * The windowNumber is an AppKit window number. Returns TRUE if xpr is
+ * displaying a window with that number.
+ */
+Bool
+xprIsX11Window(int windowNumber)
+{
+ Bool ret;
+ xp_window_id wid;
+
+ if (xp_lookup_native_window(windowNumber, &wid))
+ ret = xprGetXWindow(wid) != NULL;
+ else
+ ret = FALSE;
+
+ return ret;
+}
+
+
+/*
+ * xprHideWindows
+ * Hide or unhide all top level windows. This is called for application hide/
+ * unhide events if the window manager is not Apple-WM aware. Xplugin windows
+ * do not hide or unhide themselves.
+ */
+void
+xprHideWindows(Bool hide)
+{
+ int screen;
+ WindowPtr pRoot, pWin;
+
+ for (screen = 0; screen < screenInfo.numScreens; screen++) {
+ RootlessFrameID prevWid = NULL;
+ pRoot = screenInfo.screens[screen]->root;
+
+ for (pWin = pRoot->firstChild; pWin; pWin = pWin->nextSib) {
+ RootlessWindowRec *winRec = WINREC(pWin);
+
+ if (winRec != NULL) {
+ if (hide) {
+ xprUnmapFrame(winRec->wid);
+ } else {
+ BoxRec box;
+
+ xprRestackFrame(winRec->wid, prevWid);
+ prevWid = winRec->wid;
+
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = winRec->width;
+ box.y2 = winRec->height;
+
+ xprDamageRects(winRec->wid, 1, &box, 0, 0);
+ RootlessQueueRedisplay(screenInfo.screens[screen]);
+ }
+ }
+ }
+ }
+}
+
+// XXX: identical to x_cvt_vptr_to_uint ?
+#define MAKE_WINDOW_ID(x) ((xp_window_id)((size_t)(x)))
+
+Bool no_configure_window;
+
+static inline int
+configure_window (xp_window_id id, unsigned int mask,
+ const xp_window_changes *values)
+{
+ if (!no_configure_window)
+ return xp_configure_window (id, mask, values);
+ else
+ return XP_Success;
+}
+
+
+static
+void xprUpdateColormap(RootlessFrameID wid, ScreenPtr pScreen)
+{
+ /* This is how we tell xp that the colormap may have changed. */
+ xp_window_changes wc;
+ wc.colormap = xprColormapCallback;
+ wc.colormap_data = pScreen;
+
+ configure_window(MAKE_WINDOW_ID(wid), XP_COLORMAP, &wc);
+}
+
+static
+void xprHideWindow(RootlessFrameID wid)
+{
+ xp_window_changes wc;
+ wc.stack_mode = XP_UNMAPPED;
+ wc.sibling = 0;
+ configure_window(MAKE_WINDOW_ID(wid), XP_STACKING, &wc);
+}
diff --git a/xorg-server/hw/xquartz/xpr/xprScreen.c b/xorg-server/hw/xquartz/xpr/xprScreen.c
index 4df3b2b20..002355eca 100644
--- a/xorg-server/hw/xquartz/xpr/xprScreen.c
+++ b/xorg-server/hw/xquartz/xpr/xprScreen.c
@@ -1,485 +1,485 @@
-/*
- * Xplugin rootless implementation screen functions
- *
- * Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved.
- * Copyright (c) 2004 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, 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.
- */
-
-#include "sanitizedCarbon.h"
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "quartzCommon.h"
-#include "inputstr.h"
-#include "quartz.h"
-#include "quartzRandR.h"
-#include "xpr.h"
-#include "xprEvent.h"
-#include "pseudoramiX.h"
-#include "darwinEvents.h"
-#include "rootless.h"
-#include "dri.h"
-#include "globals.h"
-#include <Xplugin.h>
-#include "applewmExt.h"
-#include "micmap.h"
-
-#include "rootlessCommon.h"
-
-#ifdef DAMAGE
-# include "damage.h"
-#endif
-
-/* 10.4's deferred update makes X slower.. have to live with the tearing
- for now.. */
-#define XP_NO_DEFERRED_UPDATES 8
-
-// Name of GLX bundle for native OpenGL
-static const char *xprOpenGLBundle = "glxCGL.bundle";
-
-/*
- * eventHandler
- * Callback handler for Xplugin events.
- */
-static void eventHandler(unsigned int type, const void *arg,
- unsigned int arg_size, void *data) {
-
- switch (type) {
- case XP_EVENT_DISPLAY_CHANGED:
- DEBUG_LOG("XP_EVENT_DISPLAY_CHANGED\n");
- DarwinSendDDXEvent(kXquartzDisplayChanged, 0);
- break;
-
- case XP_EVENT_WINDOW_STATE_CHANGED:
- if (arg_size >= sizeof(xp_window_state_event)) {
- const xp_window_state_event *ws_arg = arg;
-
- DEBUG_LOG("XP_EVENT_WINDOW_STATE_CHANGED: id=%d, state=%d\n", ws_arg->id, ws_arg->state);
- DarwinSendDDXEvent(kXquartzWindowState, 2,
- ws_arg->id, ws_arg->state);
- } else {
- DEBUG_LOG("XP_EVENT_WINDOW_STATE_CHANGED: ignored\n");
- }
- break;
-
- case XP_EVENT_WINDOW_MOVED:
- DEBUG_LOG("XP_EVENT_WINDOW_MOVED\n");
- if (arg_size == sizeof(xp_window_id)) {
- xp_window_id id = * (xp_window_id *) arg;
- DarwinSendDDXEvent(kXquartzWindowMoved, 1, id);
- }
- break;
-
- case XP_EVENT_SURFACE_DESTROYED:
- DEBUG_LOG("XP_EVENT_SURFACE_DESTROYED\n");
- case XP_EVENT_SURFACE_CHANGED:
- DEBUG_LOG("XP_EVENT_SURFACE_CHANGED\n");
- if (arg_size == sizeof(xp_surface_id)) {
- int kind;
-
- if (type == XP_EVENT_SURFACE_DESTROYED)
- kind = AppleDRISurfaceNotifyDestroyed;
- else
- kind = AppleDRISurfaceNotifyChanged;
-
- DRISurfaceNotify(*(xp_surface_id *) arg, kind);
- }
- break;
-#ifdef XP_EVENT_SPACE_CHANGED
- case XP_EVENT_SPACE_CHANGED:
- DEBUG_LOG("XP_EVENT_SPACE_CHANGED\n");
- if(arg_size == sizeof(uint32_t)) {
- uint32_t space_id = *(uint32_t *)arg;
- DarwinSendDDXEvent(kXquartzSpaceChanged, 1, space_id);
- }
- break;
-#endif
- default:
- ErrorF("Unknown XP_EVENT type (%d) in xprScreen:eventHandler\n", type);
- }
-}
-
-/*
- * displayAtIndex
- * Return the display ID for a particular display index.
- */
-static CGDirectDisplayID
-displayAtIndex(int index)
-{
- CGError err;
- CGDisplayCount cnt;
- CGDirectDisplayID dpy[index+1];
-
- err = CGGetActiveDisplayList(index + 1, dpy, &cnt);
- if (err == kCGErrorSuccess && cnt == index + 1)
- return dpy[index];
- else
- return kCGNullDirectDisplay;
-}
-
-/*
- * displayScreenBounds
- * Return the bounds of a particular display.
- */
-static CGRect
-displayScreenBounds(CGDirectDisplayID id)
-{
- CGRect frame;
-
- frame = CGDisplayBounds(id);
-
- DEBUG_LOG(" %dx%d @ (%d,%d).\n",
- (int)frame.size.width, (int)frame.size.height,
- (int)frame.origin.x, (int)frame.origin.y);
-
- /* Remove menubar to help standard X11 window managers. */
- if (XQuartzIsRootless &&
- frame.origin.x == 0 && frame.origin.y == 0) {
- frame.origin.y += aquaMenuBarHeight;
- frame.size.height -= aquaMenuBarHeight;
- }
-
- DEBUG_LOG(" %dx%d @ (%d,%d).\n",
- (int)frame.size.width, (int)frame.size.height,
- (int)frame.origin.x, (int)frame.origin.y);
-
- return frame;
-}
-
-/*
- * xprAddPseudoramiXScreens
- * Add a single virtual screen encompassing all the physical screens
- * with PseudoramiX.
- */
-static void
-xprAddPseudoramiXScreens(int *x, int *y, int *width, int *height, ScreenPtr pScreen)
-{
- CGDisplayCount i, displayCount;
- CGDirectDisplayID *displayList = NULL;
- CGRect unionRect = CGRectNull, frame;
-
- // Find all the CoreGraphics displays
- CGGetActiveDisplayList(0, NULL, &displayCount);
- DEBUG_LOG("displayCount: %d\n", (int)displayCount);
-
- if(!displayCount) {
- ErrorF("CoreGraphics has reported no connected displays. Creating a stub 800x600 display.\n");
- *x = *y = 0;
- *width = 800;
- *height = 600;
- PseudoramiXAddScreen(*x, *y, *width, *height);
- QuartzCopyDisplayIDs(pScreen, 0, NULL);
- return;
- }
-
- /* If the displays are captured, we are in a RandR game mode
- * on the primary display, so we only want to include the first
- * display. The others are covered by the shield window.
- */
- if (CGDisplayIsCaptured(kCGDirectMainDisplay))
- displayCount = 1;
-
- displayList = malloc(displayCount * sizeof(CGDirectDisplayID));
- if(!displayList)
- FatalError("Unable to allocate memory for list of displays.\n");
- CGGetActiveDisplayList(displayCount, displayList, &displayCount);
- QuartzCopyDisplayIDs(pScreen, displayCount, displayList);
-
- /* Get the union of all screens */
- for (i = 0; i < displayCount; i++) {
- CGDirectDisplayID dpy = displayList[i];
- frame = displayScreenBounds(dpy);
- unionRect = CGRectUnion(unionRect, frame);
- }
-
- /* Use unionRect as the screen size for the X server. */
- *x = unionRect.origin.x;
- *y = unionRect.origin.y;
- *width = unionRect.size.width;
- *height = unionRect.size.height;
-
- DEBUG_LOG(" screen union origin: (%d,%d) size: (%d,%d).\n",
- *x, *y, *width, *height);
-
- /* Tell PseudoramiX about the real screens. */
- for (i = 0; i < displayCount; i++)
- {
- CGDirectDisplayID dpy = displayList[i];
-
- frame = displayScreenBounds(dpy);
- frame.origin.x -= unionRect.origin.x;
- frame.origin.y -= unionRect.origin.y;
-
- DEBUG_LOG(" placed at X11 coordinate (%d,%d).\n",
- (int)frame.origin.x, (int)frame.origin.y);
-
- PseudoramiXAddScreen(frame.origin.x, frame.origin.y,
- frame.size.width, frame.size.height);
- }
-
- free(displayList);
-}
-
-/*
- * xprDisplayInit
- * Find number of CoreGraphics displays and initialize Xplugin.
- */
-static void
-xprDisplayInit(void)
-{
- CGDisplayCount displayCount;
-
- TRACE();
-
- CGGetActiveDisplayList(0, NULL, &displayCount);
-
- /* With PseudoramiX, the X server only sees one screen; only PseudoramiX
- itself knows about all of the screens. */
-
- if (noPseudoramiXExtension)
- darwinScreensFound = displayCount;
- else
- darwinScreensFound = 1;
-
- if (xp_init(XP_BACKGROUND_EVENTS | XP_NO_DEFERRED_UPDATES) != Success)
- FatalError("Could not initialize the Xplugin library.");
-
- xp_select_events(XP_EVENT_DISPLAY_CHANGED
- | XP_EVENT_WINDOW_STATE_CHANGED
- | XP_EVENT_WINDOW_MOVED
-#ifdef XP_EVENT_SPACE_CHANGED
- | XP_EVENT_SPACE_CHANGED
-#endif
- | XP_EVENT_SURFACE_CHANGED
- | XP_EVENT_SURFACE_DESTROYED,
- eventHandler, NULL);
-
- AppleDRIExtensionInit();
- xprAppleWMInit();
-
- XQuartzIsRootless = XQuartzRootlessDefault;
- if (!XQuartzIsRootless)
- RootlessHideAllWindows();
-}
-
-/*
- * xprAddScreen
- * Init the framebuffer and record pixmap parameters for the screen.
- */
-static Bool
-xprAddScreen(int index, ScreenPtr pScreen)
-{
- DarwinFramebufferPtr dfb = SCREEN_PRIV(pScreen);
- int depth = darwinDesiredDepth;
-
- DEBUG_LOG("index=%d depth=%d\n", index, depth);
-
- if(depth == -1) {
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
- depth = CGDisplaySamplesPerPixel(kCGDirectMainDisplay) * CGDisplayBitsPerSample(kCGDirectMainDisplay);
-#else
- CGDisplayModeRef modeRef;
- CFStringRef encStrRef;
-
- modeRef = CGDisplayCopyDisplayMode(kCGDirectMainDisplay);
- if(!modeRef)
- goto have_depth;
-
- encStrRef = CGDisplayModeCopyPixelEncoding(modeRef);
- CFRelease(modeRef);
- if(!encStrRef)
- goto have_depth;
-
- if(CFStringCompare(encStrRef, CFSTR(IO32BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
- depth = 24;
- } else if(CFStringCompare(encStrRef, CFSTR(IO16BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
- depth = 15;
- } else if(CFStringCompare(encStrRef, CFSTR(IO8BitIndexedPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
- depth = 8;
- }
-
- CFRelease(encStrRef);
-#endif
- }
-
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
-have_depth:
-#endif
- switch(depth) {
- case 8: // pseudo-working
- dfb->visuals = PseudoColorMask;
- dfb->preferredCVC = PseudoColor;
- dfb->depth = 8;
- dfb->bitsPerRGB = 8;
- dfb->bitsPerPixel = 8;
- dfb->redMask = 0;
- dfb->greenMask = 0;
- dfb->blueMask = 0;
- break;
- case 15:
- dfb->visuals = TrueColorMask; //LARGE_VISUALS;
- dfb->preferredCVC = TrueColor;
- dfb->depth = 15;
- dfb->bitsPerRGB = 5;
- dfb->bitsPerPixel = 16;
- dfb->redMask = RM_ARGB(0,5,5,5);
- dfb->greenMask = GM_ARGB(0,5,5,5);
- dfb->blueMask = BM_ARGB(0,5,5,5);
- break;
-// case 24:
- default:
- if(depth != 24)
- ErrorF("Unsupported color depth requested. Defaulting to 24bit. (depth=%d darwinDesiredDepth=%d)\n", depth, darwinDesiredDepth);
- dfb->visuals = TrueColorMask; //LARGE_VISUALS;
- dfb->preferredCVC = TrueColor;
- dfb->depth = 24;
- dfb->bitsPerRGB = 8;
- dfb->bitsPerPixel = 32;
- dfb->redMask = RM_ARGB(0,8,8,8);
- dfb->greenMask = GM_ARGB(0,8,8,8);
- dfb->blueMask = BM_ARGB(0,8,8,8);
- break;
- }
-
- if (noPseudoramiXExtension)
- {
- CGDirectDisplayID dpy;
- CGRect frame;
-
- ErrorF("Warning: noPseudoramiXExtension!\n");
-
- dpy = displayAtIndex(index);
- QuartzCopyDisplayIDs(pScreen, 1, &dpy);
-
- frame = displayScreenBounds(dpy);
-
- dfb->x = frame.origin.x;
- dfb->y = frame.origin.y;
- dfb->width = frame.size.width;
- dfb->height = frame.size.height;
- }
- else
- {
- xprAddPseudoramiXScreens(&dfb->x, &dfb->y, &dfb->width, &dfb->height, pScreen);
- }
-
- /* Passing zero width (pitch) makes miCreateScreenResources set the
- screen pixmap to the framebuffer pointer, i.e. NULL. The generic
- rootless code takes care of making this work. */
- dfb->pitch = 0;
- dfb->framebuffer = NULL;
-
- DRIScreenInit(pScreen);
-
- return TRUE;
-}
-
-/*
- * xprSetupScreen
- * Setup the screen for rootless access.
- */
-static Bool
-xprSetupScreen(int index, ScreenPtr pScreen)
-{
-#ifdef DAMAGE
- // The Damage extension needs to wrap underneath the
- // generic rootless layer, so do it now.
- if (!DamageSetup(pScreen))
- return FALSE;
-#endif
-
- // Initialize generic rootless code
- if (!xprInit(pScreen))
- return FALSE;
-
- return DRIFinishScreenInit(pScreen);
-}
-
-/*
- * xprUpdateScreen
- * Update screen after configuation change.
- */
-static void
-xprUpdateScreen(ScreenPtr pScreen)
-{
- rootlessGlobalOffsetX = darwinMainScreenX;
- rootlessGlobalOffsetY = darwinMainScreenY;
-
- AppleWMSetScreenOrigin(pScreen->root);
-
- RootlessRepositionWindows(pScreen);
- RootlessUpdateScreenPixmap(pScreen);
-}
-
-/*
- * xprInitInput
- * Finalize xpr specific setup.
- */
-static void
-xprInitInput(int argc, char **argv)
-{
- int i;
-
- rootlessGlobalOffsetX = darwinMainScreenX;
- rootlessGlobalOffsetY = darwinMainScreenY;
-
- for (i = 0; i < screenInfo.numScreens; i++)
- AppleWMSetScreenOrigin(screenInfo.screens[i]->root);
-}
-
-/*
- * Quartz display mode function list.
- */
-static QuartzModeProcsRec xprModeProcs = {
- xprDisplayInit,
- xprAddScreen,
- xprSetupScreen,
- xprInitInput,
- QuartzInitCursor,
- QuartzSuspendXCursor,
- QuartzResumeXCursor,
- xprAddPseudoramiXScreens,
- xprUpdateScreen,
- xprIsX11Window,
- xprHideWindows,
- RootlessFrameForWindow,
- TopLevelParent,
- DRICreateSurface,
- DRIDestroySurface
-};
-
-/*
- * QuartzModeBundleInit
- * Initialize the display mode bundle after loading.
- */
-Bool
-QuartzModeBundleInit(void)
-{
- quartzProcs = &xprModeProcs;
- quartzOpenGLBundle = xprOpenGLBundle;
- return TRUE;
-}
+/*
+ * Xplugin rootless implementation screen functions
+ *
+ * Copyright (c) 2002 Apple Computer, Inc. All Rights Reserved.
+ * Copyright (c) 2004 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, 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.
+ */
+
+#include "sanitizedCarbon.h"
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "quartzCommon.h"
+#include "inputstr.h"
+#include "quartz.h"
+#include "quartzRandR.h"
+#include "xpr.h"
+#include "xprEvent.h"
+#include "pseudoramiX.h"
+#include "darwinEvents.h"
+#include "rootless.h"
+#include "dri.h"
+#include "globals.h"
+#include <Xplugin.h>
+#include "applewmExt.h"
+#include "micmap.h"
+
+#include "rootlessCommon.h"
+
+#ifdef DAMAGE
+# include "damage.h"
+#endif
+
+/* 10.4's deferred update makes X slower.. have to live with the tearing
+ for now.. */
+#define XP_NO_DEFERRED_UPDATES 8
+
+// Name of GLX bundle for native OpenGL
+static const char *xprOpenGLBundle = "glxCGL.bundle";
+
+/*
+ * eventHandler
+ * Callback handler for Xplugin events.
+ */
+static void eventHandler(unsigned int type, const void *arg,
+ unsigned int arg_size, void *data) {
+
+ switch (type) {
+ case XP_EVENT_DISPLAY_CHANGED:
+ DEBUG_LOG("XP_EVENT_DISPLAY_CHANGED\n");
+ DarwinSendDDXEvent(kXquartzDisplayChanged, 0);
+ break;
+
+ case XP_EVENT_WINDOW_STATE_CHANGED:
+ if (arg_size >= sizeof(xp_window_state_event)) {
+ const xp_window_state_event *ws_arg = arg;
+
+ DEBUG_LOG("XP_EVENT_WINDOW_STATE_CHANGED: id=%d, state=%d\n", ws_arg->id, ws_arg->state);
+ DarwinSendDDXEvent(kXquartzWindowState, 2,
+ ws_arg->id, ws_arg->state);
+ } else {
+ DEBUG_LOG("XP_EVENT_WINDOW_STATE_CHANGED: ignored\n");
+ }
+ break;
+
+ case XP_EVENT_WINDOW_MOVED:
+ DEBUG_LOG("XP_EVENT_WINDOW_MOVED\n");
+ if (arg_size == sizeof(xp_window_id)) {
+ xp_window_id id = * (xp_window_id *) arg;
+ DarwinSendDDXEvent(kXquartzWindowMoved, 1, id);
+ }
+ break;
+
+ case XP_EVENT_SURFACE_DESTROYED:
+ DEBUG_LOG("XP_EVENT_SURFACE_DESTROYED\n");
+ case XP_EVENT_SURFACE_CHANGED:
+ DEBUG_LOG("XP_EVENT_SURFACE_CHANGED\n");
+ if (arg_size == sizeof(xp_surface_id)) {
+ int kind;
+
+ if (type == XP_EVENT_SURFACE_DESTROYED)
+ kind = AppleDRISurfaceNotifyDestroyed;
+ else
+ kind = AppleDRISurfaceNotifyChanged;
+
+ DRISurfaceNotify(*(xp_surface_id *) arg, kind);
+ }
+ break;
+#ifdef XP_EVENT_SPACE_CHANGED
+ case XP_EVENT_SPACE_CHANGED:
+ DEBUG_LOG("XP_EVENT_SPACE_CHANGED\n");
+ if(arg_size == sizeof(uint32_t)) {
+ uint32_t space_id = *(uint32_t *)arg;
+ DarwinSendDDXEvent(kXquartzSpaceChanged, 1, space_id);
+ }
+ break;
+#endif
+ default:
+ ErrorF("Unknown XP_EVENT type (%d) in xprScreen:eventHandler\n", type);
+ }
+}
+
+/*
+ * displayAtIndex
+ * Return the display ID for a particular display index.
+ */
+static CGDirectDisplayID
+displayAtIndex(int index)
+{
+ CGError err;
+ CGDisplayCount cnt;
+ CGDirectDisplayID dpy[index+1];
+
+ err = CGGetActiveDisplayList(index + 1, dpy, &cnt);
+ if (err == kCGErrorSuccess && cnt == index + 1)
+ return dpy[index];
+ else
+ return kCGNullDirectDisplay;
+}
+
+/*
+ * displayScreenBounds
+ * Return the bounds of a particular display.
+ */
+static CGRect
+displayScreenBounds(CGDirectDisplayID id)
+{
+ CGRect frame;
+
+ frame = CGDisplayBounds(id);
+
+ DEBUG_LOG(" %dx%d @ (%d,%d).\n",
+ (int)frame.size.width, (int)frame.size.height,
+ (int)frame.origin.x, (int)frame.origin.y);
+
+ /* Remove menubar to help standard X11 window managers. */
+ if (XQuartzIsRootless &&
+ frame.origin.x == 0 && frame.origin.y == 0) {
+ frame.origin.y += aquaMenuBarHeight;
+ frame.size.height -= aquaMenuBarHeight;
+ }
+
+ DEBUG_LOG(" %dx%d @ (%d,%d).\n",
+ (int)frame.size.width, (int)frame.size.height,
+ (int)frame.origin.x, (int)frame.origin.y);
+
+ return frame;
+}
+
+/*
+ * xprAddPseudoramiXScreens
+ * Add a single virtual screen encompassing all the physical screens
+ * with PseudoramiX.
+ */
+static void
+xprAddPseudoramiXScreens(int *x, int *y, int *width, int *height, ScreenPtr pScreen)
+{
+ CGDisplayCount i, displayCount;
+ CGDirectDisplayID *displayList = NULL;
+ CGRect unionRect = CGRectNull, frame;
+
+ // Find all the CoreGraphics displays
+ CGGetActiveDisplayList(0, NULL, &displayCount);
+ DEBUG_LOG("displayCount: %d\n", (int)displayCount);
+
+ if(!displayCount) {
+ ErrorF("CoreGraphics has reported no connected displays. Creating a stub 800x600 display.\n");
+ *x = *y = 0;
+ *width = 800;
+ *height = 600;
+ PseudoramiXAddScreen(*x, *y, *width, *height);
+ QuartzCopyDisplayIDs(pScreen, 0, NULL);
+ return;
+ }
+
+ /* If the displays are captured, we are in a RandR game mode
+ * on the primary display, so we only want to include the first
+ * display. The others are covered by the shield window.
+ */
+ if (CGDisplayIsCaptured(kCGDirectMainDisplay))
+ displayCount = 1;
+
+ displayList = malloc(displayCount * sizeof(CGDirectDisplayID));
+ if(!displayList)
+ FatalError("Unable to allocate memory for list of displays.\n");
+ CGGetActiveDisplayList(displayCount, displayList, &displayCount);
+ QuartzCopyDisplayIDs(pScreen, displayCount, displayList);
+
+ /* Get the union of all screens */
+ for (i = 0; i < displayCount; i++) {
+ CGDirectDisplayID dpy = displayList[i];
+ frame = displayScreenBounds(dpy);
+ unionRect = CGRectUnion(unionRect, frame);
+ }
+
+ /* Use unionRect as the screen size for the X server. */
+ *x = unionRect.origin.x;
+ *y = unionRect.origin.y;
+ *width = unionRect.size.width;
+ *height = unionRect.size.height;
+
+ DEBUG_LOG(" screen union origin: (%d,%d) size: (%d,%d).\n",
+ *x, *y, *width, *height);
+
+ /* Tell PseudoramiX about the real screens. */
+ for (i = 0; i < displayCount; i++)
+ {
+ CGDirectDisplayID dpy = displayList[i];
+
+ frame = displayScreenBounds(dpy);
+ frame.origin.x -= unionRect.origin.x;
+ frame.origin.y -= unionRect.origin.y;
+
+ DEBUG_LOG(" placed at X11 coordinate (%d,%d).\n",
+ (int)frame.origin.x, (int)frame.origin.y);
+
+ PseudoramiXAddScreen(frame.origin.x, frame.origin.y,
+ frame.size.width, frame.size.height);
+ }
+
+ free(displayList);
+}
+
+/*
+ * xprDisplayInit
+ * Find number of CoreGraphics displays and initialize Xplugin.
+ */
+static void
+xprDisplayInit(void)
+{
+ CGDisplayCount displayCount;
+
+ TRACE();
+
+ CGGetActiveDisplayList(0, NULL, &displayCount);
+
+ /* With PseudoramiX, the X server only sees one screen; only PseudoramiX
+ itself knows about all of the screens. */
+
+ if (noPseudoramiXExtension)
+ darwinScreensFound = displayCount;
+ else
+ darwinScreensFound = 1;
+
+ if (xp_init(XP_BACKGROUND_EVENTS | XP_NO_DEFERRED_UPDATES) != Success)
+ FatalError("Could not initialize the Xplugin library.");
+
+ xp_select_events(XP_EVENT_DISPLAY_CHANGED
+ | XP_EVENT_WINDOW_STATE_CHANGED
+ | XP_EVENT_WINDOW_MOVED
+#ifdef XP_EVENT_SPACE_CHANGED
+ | XP_EVENT_SPACE_CHANGED
+#endif
+ | XP_EVENT_SURFACE_CHANGED
+ | XP_EVENT_SURFACE_DESTROYED,
+ eventHandler, NULL);
+
+ AppleDRIExtensionInit();
+ xprAppleWMInit();
+
+ XQuartzIsRootless = XQuartzRootlessDefault;
+ if (!XQuartzIsRootless)
+ RootlessHideAllWindows();
+}
+
+/*
+ * xprAddScreen
+ * Init the framebuffer and record pixmap parameters for the screen.
+ */
+static Bool
+xprAddScreen(int index, ScreenPtr pScreen)
+{
+ DarwinFramebufferPtr dfb = SCREEN_PRIV(pScreen);
+ int depth = darwinDesiredDepth;
+
+ DEBUG_LOG("index=%d depth=%d\n", index, depth);
+
+ if(depth == -1) {
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
+ depth = CGDisplaySamplesPerPixel(kCGDirectMainDisplay) * CGDisplayBitsPerSample(kCGDirectMainDisplay);
+#else
+ CGDisplayModeRef modeRef;
+ CFStringRef encStrRef;
+
+ modeRef = CGDisplayCopyDisplayMode(kCGDirectMainDisplay);
+ if(!modeRef)
+ goto have_depth;
+
+ encStrRef = CGDisplayModeCopyPixelEncoding(modeRef);
+ CFRelease(modeRef);
+ if(!encStrRef)
+ goto have_depth;
+
+ if(CFStringCompare(encStrRef, CFSTR(IO32BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
+ depth = 24;
+ } else if(CFStringCompare(encStrRef, CFSTR(IO16BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
+ depth = 15;
+ } else if(CFStringCompare(encStrRef, CFSTR(IO8BitIndexedPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
+ depth = 8;
+ }
+
+ CFRelease(encStrRef);
+#endif
+ }
+
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
+have_depth:
+#endif
+ switch(depth) {
+ case 8: // pseudo-working
+ dfb->visuals = PseudoColorMask;
+ dfb->preferredCVC = PseudoColor;
+ dfb->depth = 8;
+ dfb->bitsPerRGB = 8;
+ dfb->bitsPerPixel = 8;
+ dfb->redMask = 0;
+ dfb->greenMask = 0;
+ dfb->blueMask = 0;
+ break;
+ case 15:
+ dfb->visuals = TrueColorMask; //LARGE_VISUALS;
+ dfb->preferredCVC = TrueColor;
+ dfb->depth = 15;
+ dfb->bitsPerRGB = 5;
+ dfb->bitsPerPixel = 16;
+ dfb->redMask = RM_ARGB(0,5,5,5);
+ dfb->greenMask = GM_ARGB(0,5,5,5);
+ dfb->blueMask = BM_ARGB(0,5,5,5);
+ break;
+// case 24:
+ default:
+ if(depth != 24)
+ ErrorF("Unsupported color depth requested. Defaulting to 24bit. (depth=%d darwinDesiredDepth=%d)\n", depth, darwinDesiredDepth);
+ dfb->visuals = TrueColorMask; //LARGE_VISUALS;
+ dfb->preferredCVC = TrueColor;
+ dfb->depth = 24;
+ dfb->bitsPerRGB = 8;
+ dfb->bitsPerPixel = 32;
+ dfb->redMask = RM_ARGB(0,8,8,8);
+ dfb->greenMask = GM_ARGB(0,8,8,8);
+ dfb->blueMask = BM_ARGB(0,8,8,8);
+ break;
+ }
+
+ if (noPseudoramiXExtension)
+ {
+ CGDirectDisplayID dpy;
+ CGRect frame;
+
+ ErrorF("Warning: noPseudoramiXExtension!\n");
+
+ dpy = displayAtIndex(index);
+ QuartzCopyDisplayIDs(pScreen, 1, &dpy);
+
+ frame = displayScreenBounds(dpy);
+
+ dfb->x = frame.origin.x;
+ dfb->y = frame.origin.y;
+ dfb->width = frame.size.width;
+ dfb->height = frame.size.height;
+ }
+ else
+ {
+ xprAddPseudoramiXScreens(&dfb->x, &dfb->y, &dfb->width, &dfb->height, pScreen);
+ }
+
+ /* Passing zero width (pitch) makes miCreateScreenResources set the
+ screen pixmap to the framebuffer pointer, i.e. NULL. The generic
+ rootless code takes care of making this work. */
+ dfb->pitch = 0;
+ dfb->framebuffer = NULL;
+
+ DRIScreenInit(pScreen);
+
+ return TRUE;
+}
+
+/*
+ * xprSetupScreen
+ * Setup the screen for rootless access.
+ */
+static Bool
+xprSetupScreen(int index, ScreenPtr pScreen)
+{
+#ifdef DAMAGE
+ // The Damage extension needs to wrap underneath the
+ // generic rootless layer, so do it now.
+ if (!DamageSetup(pScreen))
+ return FALSE;
+#endif
+
+ // Initialize generic rootless code
+ if (!xprInit(pScreen))
+ return FALSE;
+
+ return DRIFinishScreenInit(pScreen);
+}
+
+/*
+ * xprUpdateScreen
+ * Update screen after configuation change.
+ */
+static void
+xprUpdateScreen(ScreenPtr pScreen)
+{
+ rootlessGlobalOffsetX = darwinMainScreenX;
+ rootlessGlobalOffsetY = darwinMainScreenY;
+
+ AppleWMSetScreenOrigin(pScreen->root);
+
+ RootlessRepositionWindows(pScreen);
+ RootlessUpdateScreenPixmap(pScreen);
+}
+
+/*
+ * xprInitInput
+ * Finalize xpr specific setup.
+ */
+static void
+xprInitInput(int argc, char **argv)
+{
+ int i;
+
+ rootlessGlobalOffsetX = darwinMainScreenX;
+ rootlessGlobalOffsetY = darwinMainScreenY;
+
+ for (i = 0; i < screenInfo.numScreens; i++)
+ AppleWMSetScreenOrigin(screenInfo.screens[i]->root);
+}
+
+/*
+ * Quartz display mode function list.
+ */
+static QuartzModeProcsRec xprModeProcs = {
+ xprDisplayInit,
+ xprAddScreen,
+ xprSetupScreen,
+ xprInitInput,
+ QuartzInitCursor,
+ QuartzSuspendXCursor,
+ QuartzResumeXCursor,
+ xprAddPseudoramiXScreens,
+ xprUpdateScreen,
+ xprIsX11Window,
+ xprHideWindows,
+ RootlessFrameForWindow,
+ TopLevelParent,
+ DRICreateSurface,
+ DRIDestroySurface
+};
+
+/*
+ * QuartzModeBundleInit
+ * Initialize the display mode bundle after loading.
+ */
+Bool
+QuartzModeBundleInit(void)
+{
+ quartzProcs = &xprModeProcs;
+ quartzOpenGLBundle = xprOpenGLBundle;
+ return TRUE;
+}
diff --git a/xorg-server/hw/xwin/InitOutput.c b/xorg-server/hw/xwin/InitOutput.c
index f79132c42..3c2f22d73 100644
--- a/xorg-server/hw/xwin/InitOutput.c
+++ b/xorg-server/hw/xwin/InitOutput.c
@@ -1,1120 +1,1120 @@
-
-/*
-
-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 DPMSExtension
-#include "dpmsproc.h"
-#endif
-#include <locale.h>
-#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
- */
-#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
-
-
-/*
- module handle for dynamically loaded comctl32 library
-*/
-static HMODULE g_hmodCommonControls = NULL;
-
-/*
- * Function prototypes
- */
-
-#ifdef XWIN_CLIPBOARD
-static void
-winClipboardShutdown (void);
-#endif
-
-#if defined(DDXOSVERRORF)
-void
-OsVendorVErrorF (const char *pszFormat, va_list va_args);
-#endif
-
-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 },
- { 32, 32, BITMAP_SCANLINE_PAD }
-};
-
-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)
- {
- g_fClipboardStarted=FALSE; /* This is to avoid dead-locls caused by the clipboard thread still doing some stuff */
- 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 (enum ExitCode error)
-{
- 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 (error);
-
- /*
- * At this point we aren't creating any new screens, so
- * we are guaranteed to not need the DirectDraw functions.
- */
- winReleaseDDProcAddresses();
-
- /* Unload our TrackMouseEvent function pointer */
- if (g_hmodCommonControls != NULL)
- {
- FreeLibrary (g_hmodCommonControls);
- g_hmodCommonControls = NULL;
- g_fpTrackMouseEvent = (FARPROC) (void (*)(void))NoopDDA;
- }
-
- /* Free concatenated command line */
- 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 (enum ExitCode error)
-{
- winDebug ("AbortDDX\n");
- ddxGiveUp (error);
-}
-
-#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 = FALSE;
- else
- binary = TRUE;
- }
-
- 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 default fontpath */
- char *fontpath = strdup(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 = strdup(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 = strdup(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 default screen 0\n");
-
- /*
- * We need to initialize the default screen 0 if no -screen
- * arguments were processed.
- *
- * Add a screen 0 using the defaults set by winInitializeDefaultScreens()
- * and any additional default screen parameters given
- */
- winInitializeScreens(1);
-
- /* We have to flag this as an explicit screen, even though it isn't */
- g_ScreenInfo[0].fExplicitScreen = TRUE;
- }
-}
-
-
-static void
-winUseMsg (void)
-{
- ErrorF("\n");
- ErrorF("\n");
- ErrorF(EXECUTABLE_NAME " Device Dependent Usage:\n");
- ErrorF("\n");
-
-#ifdef XWIN_CLIPBOARD
- ErrorF ("-[no]clipboard\n"
- "\tEnable [disable] the clipboard integration. Default is enabled.\n");
- ErrorF ("-[no]clipboardprimary\n"
- "\t[Do not] map the PRIMARY selection to the windows clipboard.\n"
- "\tThe CLIPBOARD selection is always mapped if -clipboard is enabled.\n"
- "\tDefault is mapped.\n");
-#endif
-
- 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.\n");
-
-#ifdef XWIN_XF86CONFIG
- ErrorF ("-config\n"
- "\tSpecify a configuration file.\n");
-
- ErrorF ("-configdir\n"
- "\tSpecify a configuration directory.\n");
-#endif
-
- 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");
-
-#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 ("-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_PRIMARYFB
- "\t\t8 - Primary DirectDraw - obsolete\n"
-#endif
-#ifdef XWIN_NATIVEGDI
- "\t\t16 - Native GDI - experimental\n"
-#endif
- );
-
- ErrorF ("-fullscreen\n"
- "\tRun the server in fullscreen mode.\n");
-
- ErrorF ("-ignoreinput\n"
- "\tIgnore keyboard and mouse input.\n");
-
-#ifdef XWIN_MULTIWINDOWINTWM
- ErrorF ("-internalwm\n"
- "\tRun the internal window manager.\n");
-#endif
-
-#ifdef XWIN_XF86CONFIG
- ErrorF ("-keyboard\n"
- "\tSpecify a keyboard device from the configuration file.\n");
-#endif
-
- ErrorF ("-[no]keyhook\n"
- "\tGrab special Windows keypresses like Alt-Tab or the Menu "
- "key.\n");
-
- ErrorF ("-lesspointer\n"
- "\tHide the windows mouse pointer when it is over any\n"
- "\t" EXECUTABLE_NAME " window. This prevents ghost cursors appearing when\n"
- "\tthe Windows cursor is drawn on top of the X cursor\n");
-
- ErrorF ("-logfile filename\n"
- "\tWrite log messages to <filename>.\n");
-
- ErrorF ("-logverbose verbosity\n"
- "\tSet the verbosity of log messages. [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]multimonitors or -[no]multiplemonitors\n"
- "\tUse the entire virtual screen if multiple\n"
- "\tmonitors are present.\n");
-
-#ifdef XWIN_MULTIWINDOW
- ErrorF ("-multiwindow\n"
- "\tRun the server in multi-window mode.\n");
-#endif
-
-#ifdef XWIN_MULTIWINDOWEXTWM
- ErrorF ("-mwextwm\n"
- "\tRun the server in multi-window external window manager mode.\n");
-#endif
-
- ErrorF ("-nodecoration\n"
- "\tDo not draw a window border, title bar, etc. Windowed\n"
- "\tmode only.\n");
-
-#ifdef XWIN_CLIPBOARD
- ErrorF ("-nounicodeclipboard\n"
- "\tDo not use Unicode clipboard even if on a NT-based platform.\n");
-#endif
-
- ErrorF ("-refresh rate_in_Hz\n"
- "\tSpecify an optional refresh rate to use in fullscreen mode\n"
- "\twith a DirectDraw engine.\n");
-
- ErrorF ("-resize=none|scrollbars|randr"
- "\tIn windowed mode, [don't] allow resizing of the window. 'scrollbars'\n"
- "\tmode gives the window scrollbars as needed, 'randr' mode uses the RANR\n"
- "\textension to resize the X screen.\n");
-
- ErrorF ("-rootless\n"
- "\tRun the server in rootless mode.\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 ("-silent-dup-error\n"
- "\tIf another instance of " EXECUTABLE_NAME " with the same display number is running\n"
- "\texit silently and don't display any error message.\n");
-
- ErrorF ("-swcursor\n"
- "\tDisable the usage of the Windows cursor and use the X11 software\n"
- "\tcursor instead.\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 ("-[no]unixkill\n"
- "\tCtrl+Alt+Backspace exits the X Server.\n");
-
- ErrorF ("-[no]wgl\n"
- "\tEnable the GLX extension to use the native Windows WGL interface for accelerated OpenGL\n");
-
- ErrorF ("-[no]winkill\n"
- "\tAlt+F4 exits the X Server.\n");
-
- ErrorF ("-xkblayout XKBLayout\n"
- "\tEquivalent to XKBLayout in XF86Config files.\n"
- "\tFor example: -xkblayout de\n");
-
- ErrorF ("-xkbmodel XKBModel\n"
- "\tEquivalent to XKBModel in XF86Config files.\n");
-
- ErrorF ("-xkboptions XKBOptions\n"
- "\tEquivalent to XKBOptions in XF86Config files.\n");
-
- ErrorF ("-xkbrules XKBRules\n"
- "\tEquivalent to XKBRules in XF86Config files.\n");
-
- ErrorF ("-xkbvariant XKBVariant\n"
- "\tEquivalent to XKBVariant in XF86Config files.\n"
- "\tFor example: -xkbvariant nodeadkeys\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 (EXIT_NO_ERROR);
-
- /* 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.
- */
- if (!setlocale (LC_ALL, ""))
- {
- ErrorF ("setlocale failed.\n");
- }
-
- /* See if X supports the current locale */
- if (XSupportsLocale () == FALSE)
- {
- ErrorF ("Warning: Locale not supported by X, falling back to 'C' locale.\n");
- setlocale(LC_ALL, "C");
- }
-
- }
-#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;
-}
+
+/*
+
+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 DPMSExtension
+#include "dpmsproc.h"
+#endif
+#include <locale.h>
+#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
+ */
+#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
+
+
+/*
+ module handle for dynamically loaded comctl32 library
+*/
+static HMODULE g_hmodCommonControls = NULL;
+
+/*
+ * Function prototypes
+ */
+
+#ifdef XWIN_CLIPBOARD
+static void
+winClipboardShutdown (void);
+#endif
+
+#if defined(DDXOSVERRORF)
+void
+OsVendorVErrorF (const char *pszFormat, va_list va_args);
+#endif
+
+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 },
+ { 32, 32, BITMAP_SCANLINE_PAD }
+};
+
+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)
+ {
+ g_fClipboardStarted=FALSE; /* This is to avoid dead-locls caused by the clipboard thread still doing some stuff */
+ 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 (enum ExitCode error)
+{
+ 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 (error);
+
+ /*
+ * At this point we aren't creating any new screens, so
+ * we are guaranteed to not need the DirectDraw functions.
+ */
+ winReleaseDDProcAddresses();
+
+ /* Unload our TrackMouseEvent function pointer */
+ if (g_hmodCommonControls != NULL)
+ {
+ FreeLibrary (g_hmodCommonControls);
+ g_hmodCommonControls = NULL;
+ g_fpTrackMouseEvent = (FARPROC) (void (*)(void))NoopDDA;
+ }
+
+ /* Free concatenated command line */
+ 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 (enum ExitCode error)
+{
+ winDebug ("AbortDDX\n");
+ ddxGiveUp (error);
+}
+
+#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 = FALSE;
+ else
+ binary = TRUE;
+ }
+
+ 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 default fontpath */
+ char *fontpath = strdup(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 = strdup(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 = strdup(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 default screen 0\n");
+
+ /*
+ * We need to initialize the default screen 0 if no -screen
+ * arguments were processed.
+ *
+ * Add a screen 0 using the defaults set by winInitializeDefaultScreens()
+ * and any additional default screen parameters given
+ */
+ winInitializeScreens(1);
+
+ /* We have to flag this as an explicit screen, even though it isn't */
+ g_ScreenInfo[0].fExplicitScreen = TRUE;
+ }
+}
+
+
+static void
+winUseMsg (void)
+{
+ ErrorF("\n");
+ ErrorF("\n");
+ ErrorF(EXECUTABLE_NAME " Device Dependent Usage:\n");
+ ErrorF("\n");
+
+#ifdef XWIN_CLIPBOARD
+ ErrorF ("-[no]clipboard\n"
+ "\tEnable [disable] the clipboard integration. Default is enabled.\n");
+ ErrorF ("-[no]clipboardprimary\n"
+ "\t[Do not] map the PRIMARY selection to the windows clipboard.\n"
+ "\tThe CLIPBOARD selection is always mapped if -clipboard is enabled.\n"
+ "\tDefault is mapped.\n");
+#endif
+
+ 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.\n");
+
+#ifdef XWIN_XF86CONFIG
+ ErrorF ("-config\n"
+ "\tSpecify a configuration file.\n");
+
+ ErrorF ("-configdir\n"
+ "\tSpecify a configuration directory.\n");
+#endif
+
+ 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");
+
+#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 ("-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_PRIMARYFB
+ "\t\t8 - Primary DirectDraw - obsolete\n"
+#endif
+#ifdef XWIN_NATIVEGDI
+ "\t\t16 - Native GDI - experimental\n"
+#endif
+ );
+
+ ErrorF ("-fullscreen\n"
+ "\tRun the server in fullscreen mode.\n");
+
+ ErrorF ("-ignoreinput\n"
+ "\tIgnore keyboard and mouse input.\n");
+
+#ifdef XWIN_MULTIWINDOWINTWM
+ ErrorF ("-internalwm\n"
+ "\tRun the internal window manager.\n");
+#endif
+
+#ifdef XWIN_XF86CONFIG
+ ErrorF ("-keyboard\n"
+ "\tSpecify a keyboard device from the configuration file.\n");
+#endif
+
+ ErrorF ("-[no]keyhook\n"
+ "\tGrab special Windows keypresses like Alt-Tab or the Menu "
+ "key.\n");
+
+ ErrorF ("-lesspointer\n"
+ "\tHide the windows mouse pointer when it is over any\n"
+ "\t" EXECUTABLE_NAME " window. This prevents ghost cursors appearing when\n"
+ "\tthe Windows cursor is drawn on top of the X cursor\n");
+
+ ErrorF ("-logfile filename\n"
+ "\tWrite log messages to <filename>.\n");
+
+ ErrorF ("-logverbose verbosity\n"
+ "\tSet the verbosity of log messages. [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]multimonitors or -[no]multiplemonitors\n"
+ "\tUse the entire virtual screen if multiple\n"
+ "\tmonitors are present.\n");
+
+#ifdef XWIN_MULTIWINDOW
+ ErrorF ("-multiwindow\n"
+ "\tRun the server in multi-window mode.\n");
+#endif
+
+#ifdef XWIN_MULTIWINDOWEXTWM
+ ErrorF ("-mwextwm\n"
+ "\tRun the server in multi-window external window manager mode.\n");
+#endif
+
+ ErrorF ("-nodecoration\n"
+ "\tDo not draw a window border, title bar, etc. Windowed\n"
+ "\tmode only.\n");
+
+#ifdef XWIN_CLIPBOARD
+ ErrorF ("-nounicodeclipboard\n"
+ "\tDo not use Unicode clipboard even if on a NT-based platform.\n");
+#endif
+
+ ErrorF ("-refresh rate_in_Hz\n"
+ "\tSpecify an optional refresh rate to use in fullscreen mode\n"
+ "\twith a DirectDraw engine.\n");
+
+ ErrorF ("-resize=none|scrollbars|randr"
+ "\tIn windowed mode, [don't] allow resizing of the window. 'scrollbars'\n"
+ "\tmode gives the window scrollbars as needed, 'randr' mode uses the RANR\n"
+ "\textension to resize the X screen.\n");
+
+ ErrorF ("-rootless\n"
+ "\tRun the server in rootless mode.\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 ("-silent-dup-error\n"
+ "\tIf another instance of " EXECUTABLE_NAME " with the same display number is running\n"
+ "\texit silently and don't display any error message.\n");
+
+ ErrorF ("-swcursor\n"
+ "\tDisable the usage of the Windows cursor and use the X11 software\n"
+ "\tcursor instead.\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 ("-[no]unixkill\n"
+ "\tCtrl+Alt+Backspace exits the X Server.\n");
+
+ ErrorF ("-[no]wgl\n"
+ "\tEnable the GLX extension to use the native Windows WGL interface for accelerated OpenGL\n");
+
+ ErrorF ("-[no]winkill\n"
+ "\tAlt+F4 exits the X Server.\n");
+
+ ErrorF ("-xkblayout XKBLayout\n"
+ "\tEquivalent to XKBLayout in XF86Config files.\n"
+ "\tFor example: -xkblayout de\n");
+
+ ErrorF ("-xkbmodel XKBModel\n"
+ "\tEquivalent to XKBModel in XF86Config files.\n");
+
+ ErrorF ("-xkboptions XKBOptions\n"
+ "\tEquivalent to XKBOptions in XF86Config files.\n");
+
+ ErrorF ("-xkbrules XKBRules\n"
+ "\tEquivalent to XKBRules in XF86Config files.\n");
+
+ ErrorF ("-xkbvariant XKBVariant\n"
+ "\tEquivalent to XKBVariant in XF86Config files.\n"
+ "\tFor example: -xkbvariant nodeadkeys\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 (EXIT_NO_ERROR);
+
+ /* 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.
+ */
+ if (!setlocale (LC_ALL, ""))
+ {
+ ErrorF ("setlocale failed.\n");
+ }
+
+ /* See if X supports the current locale */
+ if (XSupportsLocale () == FALSE)
+ {
+ ErrorF ("Warning: Locale not supported by X, falling back to 'C' locale.\n");
+ setlocale(LC_ALL, "C");
+ }
+
+ }
+#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;
+}
diff --git a/xorg-server/hw/xwin/XWin.rc b/xorg-server/hw/xwin/XWin.rc
index 061c91738..b9012bfcf 100644
--- a/xorg-server/hw/xwin/XWin.rc
+++ b/xorg-server/hw/xwin/XWin.rc
@@ -1,116 +1,116 @@
-/*
- *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 "XVENDORNAMESHORT
-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 "http://vcxsrv.sourceforge.net", IDC_STATIC, 36, 18, 220, 8
- LTEXT "marha@users.sourceforge.net", IDC_STATIC, 36, 28, 220, 8
- LTEXT "Version 1.11.0.0 (5 Sep 2011)", IDC_STATIC, 36, 38, 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 XVENDORNAMESHORT
-BEGIN
- DEFPUSHBUTTON "Dismiss", IDOK, 66, 80, 50, 14
- CTEXT XVENDORNAMESHORT, IDC_STATIC, 40, 12, 100, 8
- CTEXT "Disruptive screen configuration change.", IDC_STATIC, 7, 40, 166, 8
- CTEXT "Restore previous resolution to use "XVENDORNAMESHORT".", 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 "XVENDORNAMESHORT"?"
-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
-
-/* Xdmcp host selection dialog */
-XDMCP_HOSTS DIALOGEX 32, 32, 260, 156
-STYLE DS_SETFONT | DS_CENTERMOUSE | WS_POPUP | WS_VISIBLE | WS_CAPTION
-EXSTYLE WS_EX_NOPARENTNOTIFY
-CAPTION "Select host to connect to"
-FONT 8, "MS Shell Dlg 2", 0, 0, 0x1
-BEGIN
- DEFPUSHBUTTON "Connect",IDOK,61,132,50,15
- LISTBOX IDC_HOSTLIST,7,7,245,113,LBS_SORT | LBS_NOINTEGRALHEIGHT | LBS_NOTIFY | WS_VSCROLL | WS_TABSTOP
- PUSHBUTTON "Cancel",IDCANCEL,147,134,50,14
-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"
-/* CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "XWin.exe.manifest"*/
+/*
+ *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 "XVENDORNAMESHORT
+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 "http://vcxsrv.sourceforge.net", IDC_STATIC, 36, 18, 220, 8
+ LTEXT "marha@users.sourceforge.net", IDC_STATIC, 36, 28, 220, 8
+ LTEXT "Version 1.11.0.0 (5 Sep 2011)", IDC_STATIC, 36, 38, 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 XVENDORNAMESHORT
+BEGIN
+ DEFPUSHBUTTON "Dismiss", IDOK, 66, 80, 50, 14
+ CTEXT XVENDORNAMESHORT, IDC_STATIC, 40, 12, 100, 8
+ CTEXT "Disruptive screen configuration change.", IDC_STATIC, 7, 40, 166, 8
+ CTEXT "Restore previous resolution to use "XVENDORNAMESHORT".", 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 "XVENDORNAMESHORT"?"
+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
+
+/* Xdmcp host selection dialog */
+XDMCP_HOSTS DIALOGEX 32, 32, 260, 156
+STYLE DS_SETFONT | DS_CENTERMOUSE | WS_POPUP | WS_VISIBLE | WS_CAPTION
+EXSTYLE WS_EX_NOPARENTNOTIFY
+CAPTION "Select host to connect to"
+FONT 8, "MS Shell Dlg 2", 0, 0, 0x1
+BEGIN
+ DEFPUSHBUTTON "Connect",IDOK,61,132,50,15
+ LISTBOX IDC_HOSTLIST,7,7,245,113,LBS_SORT | LBS_NOINTEGRALHEIGHT | LBS_NOTIFY | WS_VSCROLL | WS_TABSTOP
+ PUSHBUTTON "Cancel",IDCANCEL,147,134,50,14
+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"
+/* CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "XWin.exe.manifest"*/
diff --git a/xorg-server/hw/xwin/man/XWin.man b/xorg-server/hw/xwin/man/XWin.man
index 0330c4caa..6e69a185d 100644
--- a/xorg-server/hw/xwin/man/XWin.man
+++ b/xorg-server/hw/xwin/man/XWin.man
@@ -1,403 +1,403 @@
-.TH XWIN 1 __vendorversion__
-.SH NAME
-XWin \- X Server for the Cygwin environment on Microsoft Windows
-
-
-.SH SYNOPSIS
-.B XWin
-[ options ] ...
-
-
-.SH DESCRIPTION
-\fIXWin\fP is an X Server for the X Window System on the Cygwin environment
-running on Microsoft Windows.
-
-
-.SH MODES
-\fIXWin\fP can operate in 3 different modes:
-.br
-* \fISingle Window\fP: This is the default mode. Each X screen
-appears as a single \fIWindows\fP window and all X windows are contained
-within this window.
-(In X terminology, the \fIWindows\fP window contains the root window for
-the screen)
-.br
-* \fIMulti-Window\fP: In this mode \fIXWin\fP uses its own integrated
-window manager in order to handle the top-level X windows, in such a
-way that they appear as normal \fIWindows\fP windows.
-.br
-* \fIRootless\fP: In this mode the X server works in a window
-containing the whole screen but this root window (traditionally covered with an X hatch
-pattern) is hidden from view, so only top-level X windows are seen.
-
-.SH OPTIONS
-In addition to the normal server options described in the \fIXserver(1)\fP
-manual page, \fIXWin\fP accepts the following command line switches,
-\fIall\fP of which are optional:
-
-.SH OPTIONS CONTROLLING WINDOWING MODE
-Only one of these options may be specified.
-.TP 8
-.B (default)
-Windowed or rooted mode.
-Each X screen appears as a single \fIWindows\fP window and all X windows are
-contained within those windows.
-.TP 8
-.B \-multiwindow
-Each top-level X window appears in its own \fIWindows\fP window.
-Also start the integrated \fIWindows\fP-based window manager.
-.TP 8
-.B \-rootless
-Run the server in rootless mode.
-The X server works on a window covering the whole screen but the root window
-is hidden from view.
-.TP 8
-.B \-mwextwm
-Experimental.
-The mode combines \fB\-rootless\fP mode drawing with native \fIWindows\fP
-window frames managed by the experimental external window manager \fIxwinwm\fP.
-.PP
-\fBNOTE:\fP \fI-multiwindow\fP mode uses its own internal window manager.
-All other modes require an external window manager in order to move, resize, and perform other
-operations on the individual X windows.
-
-.SH OPTIONS FOR SPECIFYING X SCREENS
-An X display may be composed of multiple screens.
-The default behaviour is to create a single screen 0 that is roughly the
-size of useful area of the primary monitor (allowing for any window
-decorations and the task-bar).
-
-Screen specific parameters can be applied as a
-default to all screens by placing those screen specific parameters
-before any \fB\-screen\fP parameter. Screen specific parameters placed after
-the first \fB\-screen\fP parameter will apply only to the immediately
-preceeding \fB\-screen\fP parameter.
-.TP 8
-.B \-[no]multimonitors or \-[no]multiplemonitors
-Create a screen 0 that covers all monitors [the primary monitor] on a system with
-multiple monitors.
-This option is currently enabled by default in \fB\-multiwindow\fP mode.
-.TP 8
-.B "\-screen \fIscreen_number\fP [\fIW\fP \fIH\fP [\fIX\fP \fIY\fP] | [[\fIW\fPx\fIH\fP[+\fIX\fP+\fIY\fP]][@\fIM\fP]] ] "
-Create screen number
-.I screen_number
-and optionally specify it's
-.I height,
-.I width
-and
-.I initial position.
-Additionally a
-.I
-monitor number
-(which count from 1) can be specified to place the screen on,
-at which point, all coordinates become relative to that monitor.
-Screen numbers must be contiguous starting from zero and cannot be duplicated.
-
-Examples:
-
-.I " -screen 0 @1 ; on 1st monitor using its full resolution (the default)"
-
-.I " -screen 0 800x600+100+100@2 ; on 2nd monitor offset 100,100 size 800x600"
-
-.I " -screen 0 1024x768@3 ; on 3rd monitor size 1024x768"
-
-.SH OPTIONS CONTROLLING THE APPEARANCE OF THE X SCREEN WINDOWS
-These parameters only apply to windowed mode screens i.e. not
-in \fB-multiwindow\fP or \fB-rootless\fP mode.
-.TP 8
-.B "\-fullscreen"
-The X server window takes the full screen, covering completely the
-\fIWindows\fP desktop.
-Currently \fB\-fullscreen\fP may only be applied to one X screen.
-.TP 8
-.B \-nodecoration
-Do not give the Cygwin/X window a \fIWindows\fP window border, title bar,
-etc.
-This parameter is ignored when the \fB\-fullscreen\fP parameter is specified.
-.TP 8
-.B \-scrollbars
-Alternative name for \fB\-resize=scrollbars\fP.
-
-.SH OPTIONS CONTROLLING RESIZE BEHAVIOUR
-.TP 8
-.B \-resize[=none|scrollbars|randr]
-Select the resize mode of an X screen.
-
-.RS
-.IP \fB\-resize=none\fP 8
-(default). The screen is not resizable.
-
-In windowed mode, if the window has decorations, a fixed frame is used.
-
-.IP \fB\-resize=scrollbars\fP 8
-The screen window is resizeable, but the screen is not resizable.
-
-In windowed mode, if the window has decorations, a resizing frame is used.
-Scrollbars are drawn when needed to allow the entire X screen
-to viewed by adjusting them.
-
-This also permits screens bigger than the \fIWindows\fP virtual desktop to be used.
-
-This parameter is ignored in \fB-multiwindow\fP or \fB-rootless\fP mode.
-Alternative name is \fB\-scrollbars\fP.
-
-.IP \fB\-resize=randr\fP 8
-The screen is resizable and the screen window is resizeable.
-
-In windowed mode, if the window has decorations, a resizing frame is used.
-
-Resizing the \fIWindows\fP window will use the RANDR extension to change
-the size of the X screen. Likewise, changing the size of
-the X screen using the RANDR extension will cause the size
-of the \fIWindows\fP window containing the X screen to be changed.
-
-In \fB-multiwindow\fP or \fB-rootless\fP mode, if the X screen is
-of the same dimensions as a Windows monitor or the virtual desktop,
-the X server will respond to the WM_DISPLAYCHANGED sent when those
-dimensions change by resizing the X screen. Changing the size
-of the X screen using the RANDR extension is not permitted.
-
-The maximum dimensions of the screen are the dimensions of the \fIWindows\fP virtual desktop.
-
-.IP \fB\--resize\fP 8
-on its own is equivalent to \fB\--resize=randr\fP
-.RE
-
-.SH OPTIONS CONTROLLING WINDOWS INTEGRATION
-.TP 8
-.B \-[no]clipboard
-Enables [disables] the integration between the Cygwin/X clipboard and
-\fIWindows\fP clipboard. The default is enabled.
-.TP 8
-.B "\-emulate3buttons [\fItimeout\fP]"
-Emulate a three button mouse; pressing both buttons within
-.I timeout
-milliseconds causes an emulated middle button press. The default
-.I timeout
-is 50 milliseconds. Note that most mice with scroll wheel have middle
-button functionality, usually you will need this option only if you have
-a two button mouse without scroll wheel.
-.TP 8
-.B \-[no]keyhook
-Enable [disable] a low-level keyboard hook for catching
-special keypresses like Menu and Alt+Tab and passing them to the X
-Server instead of letting \fIWindows\fP handle them.
-.TP 8
-.B \-lesspointer
-Normally the \fIWindows\fP mouse cursor is hidden when the mouse is
-over an active Cygwin/X window. This option causes the mouse cursor
-also to be hidden when it is over an inactive Cygwin/X window. This
-prevents the \fIWindows\fP mouse cursor from being drawn on top of the X
-cursor.
-This parameter has no effect unless \fB-swcursor\fP is also specified.
-.TP 8
-.B \-swcursor
-Disable the usage of the \fIWindows\fP cursor and use the X11 software cursor instead.
-.TP 8
-.B \-[no]trayicon
-Do not create a tray icon. Default is to create one
-icon per screen. You can globally disable tray icons with
-\fB\-notrayicon\fP, then enable it for specific screens with
-\fB\-trayicon\fP for those screens.
-.TP 8
-.B \-nounicodeclipboard
-Do not use Unicode clipboard even if on a NT-based platform.
-.TP 8
-.B \-[no]unixkill
-Enable or disable the \fICtrl-Alt-Backspace\fP key combination as a
-signal to exit the X Server. The \fICtrl-Alt-Backspace\fP key combination
-is disabled by default.
-.TP 8
-.B \-[no]wgl
-Enable [disable] the GLX extension to use the native Windows WGL interface
-for hardware accelerated OpenGL (AIGLX). (Experimental)
-.TP 8
-.B \-[no]winkill
-Enable or disable the \fIAlt-F4\fP key combination as a signal to exit the
-X Server.
-The \fIAlt-F4\fP key combination is enabled by default.
-
-.SH DRAWING ENGINE OPTIONS
-.TP 8
-.B "\-clipupdates \fInum_boxes\fP"
-Specify an optional threshold, above which the regions in a shadow
-update operation will be collected into a GDI clipping region. The
-clipping region is then used to do a single bit block transfer that is
-constrained to the updated area by the clipping region. There is some
-overhead involved in creating, installing, destroying, and removing
-the clipping region, thus there may not be much benefit for a small
-number of boxes (less than 10). It is even possible that this
-functionality does not provide a benefit at any number of boxes; we
-can only determine the usefulness of this feature through testing.
-This option probably has limited effect on current \fIWindows\fP versions
-as they already perform GDI batching.
-This parameter works in conjunction with engines 1, 2, and 4 (Shadow
-GDI, Shadow DirectDraw, and Shadow DirectDraw Non-Locking,
-respectively).
-.TP 8
-.B "\-engine \fIengine_type_id\fP"
-This option, which is intended for Cygwin/X developers,
-overrides the server's automatically selected drawing engine type. This
-parameter will be ignored if the specified drawing engine type is not
-supported on the current system.
-
-Default behavior is to select the drawing engine with optimum performance that
-supports the specified depth and window configuration.
-
-The engine type ids are:
-.RS
-.IP 1 4
-Shadow GDI
-.IP 2 4
-Shadow DirectDraw
-.IP 4 4
-Shadow DirectDraw Non-Locking
-.IP 8 4
-Primary DirectDraw (unsupported, obsolete)
-.IP 16 4
-Native GDI (unsupported, experimental and barely functional)
-.RE
-
-.SH FULLSCREEN OPTIONS
-.TP 8
-.B "\-depth \fIdepth\fP"
-Specify the color depth, in bits per pixel, to use when running in
-fullscreen with a DirectDraw engine. This parameter is ignored if
-\fB\-fullscreen\fP is not specified.
-.TP 8
-.B "\-refresh \fIrate_in_Hz\fP"
-Specify an optional refresh rate to use when running in
-fullscreen with a DirectDraw engine. This parameter is ignored if
-\fB\-fullscreen\fP is not specified.
-
-.SH MISCELLANEOUS OPTIONS
-See also the normal server options described in the \fIXserver(1)\fP
-manual page
-
-.TP 8
-.B \-help
-Write a help text listing supported command line options and their description to the console.
-.TP 8
-.B \-ignoreinput
-Ignore keyboard and mouse input. This is usually only used for testing
-and debugging purposes.
-.TP 8
-.B "\-logfile \fIfilename\fP"
-Change the server log file from the default of \fI
-__logdir__/XWin.n.log\fP,
-where \fIn\fP is the display number of the XWin server, to \fIfilename\fP.
-.TP 8
-.B "\-logverbose \fIlevel\fP"
-Control the degree of verbosity of the log messages with the integer
-parameter \fIlevel\fP. For \fIlevel\fP=0 only fatal errors are
-reported, for \fIlevel\fP=1 simple information about
-configuration is also given, for \fIlevel\fP=2 (default)
-additional runtime information is recorded
-and for \fIlevel\fP=3 detailed log
-information (including trace and debug output) is produced. Bigger
-values will yield a still more detailed debug output.
-.TP 8
-.B \-silent-dup-error
-If another instance of \fIXWin\fP with the same display number is found running,
-exit silently and don't display any error message.
-.TP 8
-.B "\-xkblayout \fIlayout\fP"
-.TP 8
-.B "\-xkbmodel \fImodel\fP"
-.TP 8
-.B "\-xkboptions \fIoption\fP"
-.TP 8
-.B "\-xkbrules \fIrule\fP"
-.TP 8
-.B "\-xkbvariant \fIvariant\fp"
-These options configure the xkeyboard extension to load
-a particular keyboard map as the X server starts. The behavior is similar
-to the \fIsetxkbmap\fP program. The layout data is located at \fI
-__datadir__/X11/xkb/\fP. Additional information is found in the
-README files therein and in the man page of \fIsetxkbmap\fP. For example
-in order to load a German layout for a pc105 keyboard one uses
-the options:
-.br
-.I " \-xkblayout de \-xkbmodel pc105"
-
-Alternatively one may use the \fIsetxkbmap\fP program after \fIXWin\fP is
-running.
-
-The default is to select a configuration matching your current layout as
-reported by \fIWindows\fP, if known, or the default X server configuration
-if no matching keyboard configuration was found.
-
-.SH UNDOCUMENTED OPTIONS
-These options are undocumented. Do not use them.
-
-.TP 8
-.B \-emulatepseudo
-Create a depth 8 PseudoColor visual when running in depths 15, 16, 24,
-or 32, collectively known as TrueColor depths.
-Color map manipulation is not supported, so the PseudoColor visual will
-not have the correct colors.
-This option is intended to allow applications which only work with a depth 8
-visual to operate in TrueColor modes.
-.TP 8
-.B \-internalwm
-Run the internal window manager.
-
-.SH LOG FILE
-As it runs \fIXWin\fP writes messages indicating the most relevant events
-to the console
-from which it was called and to a log file that by default is located at \fI
-__logdir__/XWin.0.log\fP. This file is mainly for debugging purposes.
-
-
-.SH PREFERENCES FILE
-On startup \fIXWin\fP looks for the file \fI$HOME/.XWinrc\fP or, if
-the previous file does not exist, \fI
-__sysconfdir__/X11/system.XWinrc\fP. \fI.XWinrc\fP allows setting
-preferences for the following:
-.br
-* To include items into the menu associated with the \fIXWin\fP icon
-which is in the \fIWindows\fP system tray. This functions in all
-modes that have a tray icon.
-.br
-* To include items in the system menu which is associated with the \fIWindows\fP
-window that \fIXWin -multiwindow\fP produces for each top-level X
-window, in both the generic case and for particular programs.
-.br
-* To change the icon that is associated to the \fIWindows\fP window that
-\fIXWin -multiwindow\fP produces for each top-level X-window.
-.br
-* To change the style that is associated to the \fIWindows\fP window that
-\fXWin I-multiwindow\fP produces for each top-level X window.
-.PP
-The format of the \fI.XWinrc\fP file is given in the man page XWinrc(5).
-
-.SH EXAMPLES
-Need some examples
-
-
-.SH "SEE ALSO"
-X(__miscmansuffix__), Xserver(1), xdm(1), xinit(1), XWinrc(__filemansuffix__),
-setxkbmap(1), xkeyboard-config (__miscmansuffix__).
-
-
-.SH BUGS
-.I XWin
-and this man page still have many limitations.
-
-The \fIXWin\fP software is continuously developing; it is therefore possible that
-this man page is not up to date. It is always prudent to
-look also at the output of \fIXWin -help\fP in order to
-check the options that are operative.
-
-
-.SH AUTHORS
-This list is by no means complete, but direct contributors to the
-Cygwin/X project include (in alphabetical order by last name): Stuart
-Adamson, Michael Bax, Jehan Bing, Lev Bishop, Dr. Peter Busch, Biju G
-C, Robert Collins, Nick Crabtree, Early Ehlinger, Christopher Faylor,
-John Fortin, Brian Genisio, Fabrizio Gennari, Alexander Gottwald, Ralf
-Habacker, Colin Harrison, Matthieu Herrb, Alan Hourihane, Pierre A
-Humblet, Harold L Hunt II, Dakshinamurthy Karra, Joe Krahn,
-Paul Loewenstein, Kensuke Matsuzaki,
-Takuma Murakami, Earle F. Philhower III, Benjamin Riefenstahl, Yaakov Selkowitz,
-Suhaib Siddiqi, Jack Tanner, Jon Turney and Nicholas Wourms.
+.TH XWIN 1 __vendorversion__
+.SH NAME
+XWin \- X Server for the Cygwin environment on Microsoft Windows
+
+
+.SH SYNOPSIS
+.B XWin
+[ options ] ...
+
+
+.SH DESCRIPTION
+\fIXWin\fP is an X Server for the X Window System on the Cygwin environment
+running on Microsoft Windows.
+
+
+.SH MODES
+\fIXWin\fP can operate in 3 different modes:
+.br
+* \fISingle Window\fP: This is the default mode. Each X screen
+appears as a single \fIWindows\fP window and all X windows are contained
+within this window.
+(In X terminology, the \fIWindows\fP window contains the root window for
+the screen)
+.br
+* \fIMulti-Window\fP: In this mode \fIXWin\fP uses its own integrated
+window manager in order to handle the top-level X windows, in such a
+way that they appear as normal \fIWindows\fP windows.
+.br
+* \fIRootless\fP: In this mode the X server works in a window
+containing the whole screen but this root window (traditionally covered with an X hatch
+pattern) is hidden from view, so only top-level X windows are seen.
+
+.SH OPTIONS
+In addition to the normal server options described in the \fIXserver(1)\fP
+manual page, \fIXWin\fP accepts the following command line switches,
+\fIall\fP of which are optional:
+
+.SH OPTIONS CONTROLLING WINDOWING MODE
+Only one of these options may be specified.
+.TP 8
+.B (default)
+Windowed or rooted mode.
+Each X screen appears as a single \fIWindows\fP window and all X windows are
+contained within those windows.
+.TP 8
+.B \-multiwindow
+Each top-level X window appears in its own \fIWindows\fP window.
+Also start the integrated \fIWindows\fP-based window manager.
+.TP 8
+.B \-rootless
+Run the server in rootless mode.
+The X server works on a window covering the whole screen but the root window
+is hidden from view.
+.TP 8
+.B \-mwextwm
+Experimental.
+The mode combines \fB\-rootless\fP mode drawing with native \fIWindows\fP
+window frames managed by the experimental external window manager \fIxwinwm\fP.
+.PP
+\fBNOTE:\fP \fI-multiwindow\fP mode uses its own internal window manager.
+All other modes require an external window manager in order to move, resize, and perform other
+operations on the individual X windows.
+
+.SH OPTIONS FOR SPECIFYING X SCREENS
+An X display may be composed of multiple screens.
+The default behaviour is to create a single screen 0 that is roughly the
+size of useful area of the primary monitor (allowing for any window
+decorations and the task-bar).
+
+Screen specific parameters can be applied as a
+default to all screens by placing those screen specific parameters
+before any \fB\-screen\fP parameter. Screen specific parameters placed after
+the first \fB\-screen\fP parameter will apply only to the immediately
+preceeding \fB\-screen\fP parameter.
+.TP 8
+.B \-[no]multimonitors or \-[no]multiplemonitors
+Create a screen 0 that covers all monitors [the primary monitor] on a system with
+multiple monitors.
+This option is currently enabled by default in \fB\-multiwindow\fP mode.
+.TP 8
+.B "\-screen \fIscreen_number\fP [\fIW\fP \fIH\fP [\fIX\fP \fIY\fP] | [[\fIW\fPx\fIH\fP[+\fIX\fP+\fIY\fP]][@\fIM\fP]] ] "
+Create screen number
+.I screen_number
+and optionally specify it's
+.I height,
+.I width
+and
+.I initial position.
+Additionally a
+.I
+monitor number
+(which count from 1) can be specified to place the screen on,
+at which point, all coordinates become relative to that monitor.
+Screen numbers must be contiguous starting from zero and cannot be duplicated.
+
+Examples:
+
+.I " -screen 0 @1 ; on 1st monitor using its full resolution (the default)"
+
+.I " -screen 0 800x600+100+100@2 ; on 2nd monitor offset 100,100 size 800x600"
+
+.I " -screen 0 1024x768@3 ; on 3rd monitor size 1024x768"
+
+.SH OPTIONS CONTROLLING THE APPEARANCE OF THE X SCREEN WINDOWS
+These parameters only apply to windowed mode screens i.e. not
+in \fB-multiwindow\fP or \fB-rootless\fP mode.
+.TP 8
+.B "\-fullscreen"
+The X server window takes the full screen, covering completely the
+\fIWindows\fP desktop.
+Currently \fB\-fullscreen\fP may only be applied to one X screen.
+.TP 8
+.B \-nodecoration
+Do not give the Cygwin/X window a \fIWindows\fP window border, title bar,
+etc.
+This parameter is ignored when the \fB\-fullscreen\fP parameter is specified.
+.TP 8
+.B \-scrollbars
+Alternative name for \fB\-resize=scrollbars\fP.
+
+.SH OPTIONS CONTROLLING RESIZE BEHAVIOUR
+.TP 8
+.B \-resize[=none|scrollbars|randr]
+Select the resize mode of an X screen.
+
+.RS
+.IP \fB\-resize=none\fP 8
+(default). The screen is not resizable.
+
+In windowed mode, if the window has decorations, a fixed frame is used.
+
+.IP \fB\-resize=scrollbars\fP 8
+The screen window is resizeable, but the screen is not resizable.
+
+In windowed mode, if the window has decorations, a resizing frame is used.
+Scrollbars are drawn when needed to allow the entire X screen
+to viewed by adjusting them.
+
+This also permits screens bigger than the \fIWindows\fP virtual desktop to be used.
+
+This parameter is ignored in \fB-multiwindow\fP or \fB-rootless\fP mode.
+Alternative name is \fB\-scrollbars\fP.
+
+.IP \fB\-resize=randr\fP 8
+The screen is resizable and the screen window is resizeable.
+
+In windowed mode, if the window has decorations, a resizing frame is used.
+
+Resizing the \fIWindows\fP window will use the RANDR extension to change
+the size of the X screen. Likewise, changing the size of
+the X screen using the RANDR extension will cause the size
+of the \fIWindows\fP window containing the X screen to be changed.
+
+In \fB-multiwindow\fP or \fB-rootless\fP mode, if the X screen is
+of the same dimensions as a Windows monitor or the virtual desktop,
+the X server will respond to the WM_DISPLAYCHANGED sent when those
+dimensions change by resizing the X screen. Changing the size
+of the X screen using the RANDR extension is not permitted.
+
+The maximum dimensions of the screen are the dimensions of the \fIWindows\fP virtual desktop.
+
+.IP \fB\--resize\fP 8
+on its own is equivalent to \fB\--resize=randr\fP
+.RE
+
+.SH OPTIONS CONTROLLING WINDOWS INTEGRATION
+.TP 8
+.B \-[no]clipboard
+Enables [disables] the integration between the Cygwin/X clipboard and
+\fIWindows\fP clipboard. The default is enabled.
+.TP 8
+.B "\-emulate3buttons [\fItimeout\fP]"
+Emulate a three button mouse; pressing both buttons within
+.I timeout
+milliseconds causes an emulated middle button press. The default
+.I timeout
+is 50 milliseconds. Note that most mice with scroll wheel have middle
+button functionality, usually you will need this option only if you have
+a two button mouse without scroll wheel.
+.TP 8
+.B \-[no]keyhook
+Enable [disable] a low-level keyboard hook for catching
+special keypresses like Menu and Alt+Tab and passing them to the X
+Server instead of letting \fIWindows\fP handle them.
+.TP 8
+.B \-lesspointer
+Normally the \fIWindows\fP mouse cursor is hidden when the mouse is
+over an active Cygwin/X window. This option causes the mouse cursor
+also to be hidden when it is over an inactive Cygwin/X window. This
+prevents the \fIWindows\fP mouse cursor from being drawn on top of the X
+cursor.
+This parameter has no effect unless \fB-swcursor\fP is also specified.
+.TP 8
+.B \-swcursor
+Disable the usage of the \fIWindows\fP cursor and use the X11 software cursor instead.
+.TP 8
+.B \-[no]trayicon
+Do not create a tray icon. Default is to create one
+icon per screen. You can globally disable tray icons with
+\fB\-notrayicon\fP, then enable it for specific screens with
+\fB\-trayicon\fP for those screens.
+.TP 8
+.B \-nounicodeclipboard
+Do not use Unicode clipboard even if on a NT-based platform.
+.TP 8
+.B \-[no]unixkill
+Enable or disable the \fICtrl-Alt-Backspace\fP key combination as a
+signal to exit the X Server. The \fICtrl-Alt-Backspace\fP key combination
+is disabled by default.
+.TP 8
+.B \-[no]wgl
+Enable [disable] the GLX extension to use the native Windows WGL interface
+for hardware accelerated OpenGL (AIGLX). (Experimental)
+.TP 8
+.B \-[no]winkill
+Enable or disable the \fIAlt-F4\fP key combination as a signal to exit the
+X Server.
+The \fIAlt-F4\fP key combination is enabled by default.
+
+.SH DRAWING ENGINE OPTIONS
+.TP 8
+.B "\-clipupdates \fInum_boxes\fP"
+Specify an optional threshold, above which the regions in a shadow
+update operation will be collected into a GDI clipping region. The
+clipping region is then used to do a single bit block transfer that is
+constrained to the updated area by the clipping region. There is some
+overhead involved in creating, installing, destroying, and removing
+the clipping region, thus there may not be much benefit for a small
+number of boxes (less than 10). It is even possible that this
+functionality does not provide a benefit at any number of boxes; we
+can only determine the usefulness of this feature through testing.
+This option probably has limited effect on current \fIWindows\fP versions
+as they already perform GDI batching.
+This parameter works in conjunction with engines 1, 2, and 4 (Shadow
+GDI, Shadow DirectDraw, and Shadow DirectDraw Non-Locking,
+respectively).
+.TP 8
+.B "\-engine \fIengine_type_id\fP"
+This option, which is intended for Cygwin/X developers,
+overrides the server's automatically selected drawing engine type. This
+parameter will be ignored if the specified drawing engine type is not
+supported on the current system.
+
+Default behavior is to select the drawing engine with optimum performance that
+supports the specified depth and window configuration.
+
+The engine type ids are:
+.RS
+.IP 1 4
+Shadow GDI
+.IP 2 4
+Shadow DirectDraw
+.IP 4 4
+Shadow DirectDraw Non-Locking
+.IP 8 4
+Primary DirectDraw (unsupported, obsolete)
+.IP 16 4
+Native GDI (unsupported, experimental and barely functional)
+.RE
+
+.SH FULLSCREEN OPTIONS
+.TP 8
+.B "\-depth \fIdepth\fP"
+Specify the color depth, in bits per pixel, to use when running in
+fullscreen with a DirectDraw engine. This parameter is ignored if
+\fB\-fullscreen\fP is not specified.
+.TP 8
+.B "\-refresh \fIrate_in_Hz\fP"
+Specify an optional refresh rate to use when running in
+fullscreen with a DirectDraw engine. This parameter is ignored if
+\fB\-fullscreen\fP is not specified.
+
+.SH MISCELLANEOUS OPTIONS
+See also the normal server options described in the \fIXserver(1)\fP
+manual page
+
+.TP 8
+.B \-help
+Write a help text listing supported command line options and their description to the console.
+.TP 8
+.B \-ignoreinput
+Ignore keyboard and mouse input. This is usually only used for testing
+and debugging purposes.
+.TP 8
+.B "\-logfile \fIfilename\fP"
+Change the server log file from the default of \fI
+__logdir__/XWin.n.log\fP,
+where \fIn\fP is the display number of the XWin server, to \fIfilename\fP.
+.TP 8
+.B "\-logverbose \fIlevel\fP"
+Control the degree of verbosity of the log messages with the integer
+parameter \fIlevel\fP. For \fIlevel\fP=0 only fatal errors are
+reported, for \fIlevel\fP=1 simple information about
+configuration is also given, for \fIlevel\fP=2 (default)
+additional runtime information is recorded
+and for \fIlevel\fP=3 detailed log
+information (including trace and debug output) is produced. Bigger
+values will yield a still more detailed debug output.
+.TP 8
+.B \-silent-dup-error
+If another instance of \fIXWin\fP with the same display number is found running,
+exit silently and don't display any error message.
+.TP 8
+.B "\-xkblayout \fIlayout\fP"
+.TP 8
+.B "\-xkbmodel \fImodel\fP"
+.TP 8
+.B "\-xkboptions \fIoption\fP"
+.TP 8
+.B "\-xkbrules \fIrule\fP"
+.TP 8
+.B "\-xkbvariant \fIvariant\fp"
+These options configure the xkeyboard extension to load
+a particular keyboard map as the X server starts. The behavior is similar
+to the \fIsetxkbmap\fP program. The layout data is located at \fI
+__datadir__/X11/xkb/\fP. Additional information is found in the
+README files therein and in the man page of \fIsetxkbmap\fP. For example
+in order to load a German layout for a pc105 keyboard one uses
+the options:
+.br
+.I " \-xkblayout de \-xkbmodel pc105"
+
+Alternatively one may use the \fIsetxkbmap\fP program after \fIXWin\fP is
+running.
+
+The default is to select a configuration matching your current layout as
+reported by \fIWindows\fP, if known, or the default X server configuration
+if no matching keyboard configuration was found.
+
+.SH UNDOCUMENTED OPTIONS
+These options are undocumented. Do not use them.
+
+.TP 8
+.B \-emulatepseudo
+Create a depth 8 PseudoColor visual when running in depths 15, 16, 24,
+or 32, collectively known as TrueColor depths.
+Color map manipulation is not supported, so the PseudoColor visual will
+not have the correct colors.
+This option is intended to allow applications which only work with a depth 8
+visual to operate in TrueColor modes.
+.TP 8
+.B \-internalwm
+Run the internal window manager.
+
+.SH LOG FILE
+As it runs \fIXWin\fP writes messages indicating the most relevant events
+to the console
+from which it was called and to a log file that by default is located at \fI
+__logdir__/XWin.0.log\fP. This file is mainly for debugging purposes.
+
+
+.SH PREFERENCES FILE
+On startup \fIXWin\fP looks for the file \fI$HOME/.XWinrc\fP or, if
+the previous file does not exist, \fI
+__sysconfdir__/X11/system.XWinrc\fP. \fI.XWinrc\fP allows setting
+preferences for the following:
+.br
+* To include items into the menu associated with the \fIXWin\fP icon
+which is in the \fIWindows\fP system tray. This functions in all
+modes that have a tray icon.
+.br
+* To include items in the system menu which is associated with the \fIWindows\fP
+window that \fIXWin -multiwindow\fP produces for each top-level X
+window, in both the generic case and for particular programs.
+.br
+* To change the icon that is associated to the \fIWindows\fP window that
+\fIXWin -multiwindow\fP produces for each top-level X-window.
+.br
+* To change the style that is associated to the \fIWindows\fP window that
+\fXWin I-multiwindow\fP produces for each top-level X window.
+.PP
+The format of the \fI.XWinrc\fP file is given in the man page XWinrc(5).
+
+.SH EXAMPLES
+Need some examples
+
+
+.SH "SEE ALSO"
+X(__miscmansuffix__), Xserver(1), xdm(1), xinit(1), XWinrc(__filemansuffix__),
+setxkbmap(1), xkeyboard-config (__miscmansuffix__).
+
+
+.SH BUGS
+.I XWin
+and this man page still have many limitations.
+
+The \fIXWin\fP software is continuously developing; it is therefore possible that
+this man page is not up to date. It is always prudent to
+look also at the output of \fIXWin -help\fP in order to
+check the options that are operative.
+
+
+.SH AUTHORS
+This list is by no means complete, but direct contributors to the
+Cygwin/X project include (in alphabetical order by last name): Stuart
+Adamson, Michael Bax, Jehan Bing, Lev Bishop, Dr. Peter Busch, Biju G
+C, Robert Collins, Nick Crabtree, Early Ehlinger, Christopher Faylor,
+John Fortin, Brian Genisio, Fabrizio Gennari, Alexander Gottwald, Ralf
+Habacker, Colin Harrison, Matthieu Herrb, Alan Hourihane, Pierre A
+Humblet, Harold L Hunt II, Dakshinamurthy Karra, Joe Krahn,
+Paul Loewenstein, Kensuke Matsuzaki,
+Takuma Murakami, Earle F. Philhower III, Benjamin Riefenstahl, Yaakov Selkowitz,
+Suhaib Siddiqi, Jack Tanner, Jon Turney and Nicholas Wourms.
diff --git a/xorg-server/hw/xwin/win.h b/xorg-server/hw/xwin/win.h
index 614c6b23f..a71635d67 100644
--- a/xorg-server/hw/xwin/win.h
+++ b/xorg-server/hw/xwin/win.h
@@ -1,1464 +1,1464 @@
-/*
- *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
-
-/*
- * 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 "micoord.h"
-#include "dix.h"
-#include "miline.h"
-#include "shadow.h"
-#include "fb.h"
-#include "rootless.h"
-
-#include "mipict.h"
-#include "picturestr.h"
-
-#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 (*winFreeFBProcPtr)(ScreenPtr);
-
-typedef void (*winShadowUpdateProcPtr)(ScreenPtr, shadowBufPtr);
-
-typedef Bool (*winInitScreenProcPtr)(ScreenPtr);
-
-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);
-
-#ifdef XWIN_NATIVEGDI
-/* Typedefs for native GDI wrappers */
-typedef Bool (*RealizeFontPtr) (ScreenPtr pScreen, FontPtr pFont);
-typedef Bool (*UnrealizeFontPtr)(ScreenPtr pScreen, FontPtr pFont);
-#endif
-
-
-/*
- * 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;
-
-/*
- * Resize modes
- */
-typedef enum {
- notAllowed,
- resizeWithScrollbars,
- resizeWithRandr
-} winResizeMode;
-
-/*
- * 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;
-
- int iMonitor;
- DWORD dwUserWidth;
- DWORD dwUserHeight;
- DWORD dwWidth;
- DWORD dwHeight;
- 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 fAnotherWMRunning;
-#endif
-#ifdef XWIN_MULTIWINDOWINTWM
- Bool fInternalWM;
-#endif
- Bool fRootless;
-#ifdef XWIN_MULTIWINDOW
- Bool fMultiWindow;
-#endif
-#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
- Bool fMultiMonitorOverride;
-#endif
- Bool fMultipleMonitors;
- Bool fLessPointer;
- winResizeMode iResizeMode;
- 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;
-
- /* 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;
- BITMAPINFOHEADER *pbmih;
-
- /* Privates used by shadow fb and primary fb DirectDraw servers */
- LPDIRECTDRAW pdd;
- LPDIRECTDRAWSURFACE pddsPrimary;
- LPDIRECTDRAW2 pdd2;
-
- /* Privates used by shadow fb DirectDraw server */
- LPDIRECTDRAWSURFACE pddsShadow;
- LPDDSURFACEDESC pddsdShadow;
-
-#ifdef XWIN_PRIMARYFB
- /* Privates used by primary fb DirectDraw server */
- LPDIRECTDRAWSURFACE pddsOffscreen;
- LPDDSURFACEDESC pddsdOffscreen;
- LPDDSURFACEDESC pddsdPrimary;
-#endif
-
- /* 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;
- winFreeFBProcPtr pwinFreeFB;
- winShadowUpdateProcPtr pwinShadowUpdate;
- winInitScreenProcPtr pwinInitScreen;
- 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;
-
-#ifdef XWIN_NATIVEGDI
- RealizeFontPtr RealizeFont;
- UnrealizeFontPtr UnrealizeFont;
-#endif
-
-} 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
- */
-
-#include "winglobals.h"
-
-extern winScreenInfo * g_ScreenInfo;
-extern miPointerScreenFuncRec g_winPointerCursorFuncs;
-extern DWORD g_dwEvents;
-#ifdef HAS_DEVWINDOWS
-extern int g_fdMessageQueue;
-#endif
-extern DevPrivateKeyRec g_iScreenPrivateKeyRec;
-#define g_iScreenPrivateKey (&g_iScreenPrivateKeyRec)
-extern DevPrivateKeyRec g_iCmapPrivateKeyRec;
-#define g_iCmapPrivateKey (&g_iCmapPrivateKeyRec)
-extern DevPrivateKeyRec g_iGCPrivateKeyRec;
-#define g_iGCPrivateKey (&g_iGCPrivateKeyRec)
-extern DevPrivateKeyRec g_iPixmapPrivateKeyRec;
-#define g_iPixmapPrivateKey (&g_iPixmapPrivateKeyRec)
-extern DevPrivateKeyRec g_iWindowPrivateKeyRec;
-#define g_iWindowPrivateKey (&g_iWindowPrivateKeyRec)
-
-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 library function pointers
- */
-
-extern FARPROC g_fpDirectDrawCreate;
-extern FARPROC g_fpDirectDrawCreateClipper;
-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 (int Removed);
-#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);
-
-void
-winReleaseDDProcAddresses(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, int kind);
-
-
-/*
- * 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, int kind);
-
-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
-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);
-
-void
-winMWExtWMRestackWindows (ScreenPtr pScreen);
-#endif
-#ifdef XWIN_MULTIWINDOWINTWM
-Bool
-winIsInternalWMRunning (winScreenInfoPtr pScreenInfo);
-#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);
-
-/*
- * winprocarg.c
- */
-void
-winInitializeScreens(int maxscreens);
-
-/*
- * windisplay.c
- */
-
-void
-winGetDisplayName(char *szDisplay, unsigned int screen);
-
-/*
- * winrandr.c
- */
-Bool
-winRandRInit (ScreenPtr pScreen);
-void
-winDoRandRScreenSetSize (ScreenPtr pScreen,
- CARD16 width,
- CARD16 height,
- CARD32 mmWidth,
- CARD32 mmHeight);
-
-/*
- * 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
+
+/*
+ * 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 "micoord.h"
+#include "dix.h"
+#include "miline.h"
+#include "shadow.h"
+#include "fb.h"
+#include "rootless.h"
+
+#include "mipict.h"
+#include "picturestr.h"
+
+#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 (*winFreeFBProcPtr)(ScreenPtr);
+
+typedef void (*winShadowUpdateProcPtr)(ScreenPtr, shadowBufPtr);
+
+typedef Bool (*winInitScreenProcPtr)(ScreenPtr);
+
+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);
+
+#ifdef XWIN_NATIVEGDI
+/* Typedefs for native GDI wrappers */
+typedef Bool (*RealizeFontPtr) (ScreenPtr pScreen, FontPtr pFont);
+typedef Bool (*UnrealizeFontPtr)(ScreenPtr pScreen, FontPtr pFont);
+#endif
+
+
+/*
+ * 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;
+
+/*
+ * Resize modes
+ */
+typedef enum {
+ notAllowed,
+ resizeWithScrollbars,
+ resizeWithRandr
+} winResizeMode;
+
+/*
+ * 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;
+
+ int iMonitor;
+ DWORD dwUserWidth;
+ DWORD dwUserHeight;
+ DWORD dwWidth;
+ DWORD dwHeight;
+ 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 fAnotherWMRunning;
+#endif
+#ifdef XWIN_MULTIWINDOWINTWM
+ Bool fInternalWM;
+#endif
+ Bool fRootless;
+#ifdef XWIN_MULTIWINDOW
+ Bool fMultiWindow;
+#endif
+#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
+ Bool fMultiMonitorOverride;
+#endif
+ Bool fMultipleMonitors;
+ Bool fLessPointer;
+ winResizeMode iResizeMode;
+ 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;
+
+ /* 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;
+ BITMAPINFOHEADER *pbmih;
+
+ /* Privates used by shadow fb and primary fb DirectDraw servers */
+ LPDIRECTDRAW pdd;
+ LPDIRECTDRAWSURFACE pddsPrimary;
+ LPDIRECTDRAW2 pdd2;
+
+ /* Privates used by shadow fb DirectDraw server */
+ LPDIRECTDRAWSURFACE pddsShadow;
+ LPDDSURFACEDESC pddsdShadow;
+
+#ifdef XWIN_PRIMARYFB
+ /* Privates used by primary fb DirectDraw server */
+ LPDIRECTDRAWSURFACE pddsOffscreen;
+ LPDDSURFACEDESC pddsdOffscreen;
+ LPDDSURFACEDESC pddsdPrimary;
+#endif
+
+ /* 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;
+ winFreeFBProcPtr pwinFreeFB;
+ winShadowUpdateProcPtr pwinShadowUpdate;
+ winInitScreenProcPtr pwinInitScreen;
+ 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;
+
+#ifdef XWIN_NATIVEGDI
+ RealizeFontPtr RealizeFont;
+ UnrealizeFontPtr UnrealizeFont;
+#endif
+
+} 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
+ */
+
+#include "winglobals.h"
+
+extern winScreenInfo * g_ScreenInfo;
+extern miPointerScreenFuncRec g_winPointerCursorFuncs;
+extern DWORD g_dwEvents;
+#ifdef HAS_DEVWINDOWS
+extern int g_fdMessageQueue;
+#endif
+extern DevPrivateKeyRec g_iScreenPrivateKeyRec;
+#define g_iScreenPrivateKey (&g_iScreenPrivateKeyRec)
+extern DevPrivateKeyRec g_iCmapPrivateKeyRec;
+#define g_iCmapPrivateKey (&g_iCmapPrivateKeyRec)
+extern DevPrivateKeyRec g_iGCPrivateKeyRec;
+#define g_iGCPrivateKey (&g_iGCPrivateKeyRec)
+extern DevPrivateKeyRec g_iPixmapPrivateKeyRec;
+#define g_iPixmapPrivateKey (&g_iPixmapPrivateKeyRec)
+extern DevPrivateKeyRec g_iWindowPrivateKeyRec;
+#define g_iWindowPrivateKey (&g_iWindowPrivateKeyRec)
+
+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 library function pointers
+ */
+
+extern FARPROC g_fpDirectDrawCreate;
+extern FARPROC g_fpDirectDrawCreateClipper;
+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 (int Removed);
+#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);
+
+void
+winReleaseDDProcAddresses(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, int kind);
+
+
+/*
+ * 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, int kind);
+
+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
+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);
+
+void
+winMWExtWMRestackWindows (ScreenPtr pScreen);
+#endif
+#ifdef XWIN_MULTIWINDOWINTWM
+Bool
+winIsInternalWMRunning (winScreenInfoPtr pScreenInfo);
+#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);
+
+/*
+ * winprocarg.c
+ */
+void
+winInitializeScreens(int maxscreens);
+
+/*
+ * windisplay.c
+ */
+
+void
+winGetDisplayName(char *szDisplay, unsigned int screen);
+
+/*
+ * winrandr.c
+ */
+Bool
+winRandRInit (ScreenPtr pScreen);
+void
+winDoRandRScreenSetSize (ScreenPtr pScreen,
+ CARD16 width,
+ CARD16 height,
+ CARD32 mmWidth,
+ CARD32 mmHeight);
+
+/*
+ * END DDX and DIX Function Prototypes
+ */
+
+#endif /* _WIN_H_ */
+
diff --git a/xorg-server/hw/xwin/winclipboardtextconv.c b/xorg-server/hw/xwin/winclipboardtextconv.c
index 487df81ef..400f560fa 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/winclipboardwndproc.c b/xorg-server/hw/xwin/winclipboardwndproc.c
index 57413b1c3..1dbee9b6f 100644
--- a/xorg-server/hw/xwin/winclipboardwndproc.c
+++ b/xorg-server/hw/xwin/winclipboardwndproc.c
@@ -1,566 +1,566 @@
-/*
- *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"
-#include "objbase.h"
-#include "ddraw.h"
-#include "winwindow.h"
-
-/*
- * Constants
- */
-
-#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;
-extern Bool g_fClipboardPrimary;
-
-/*
- * 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)
- {
- /* Bail out if 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);
- #ifdef _DEBUG
- if (s_hwndNextViewer== hwnd)
- {
- ErrorF("WM_CREATE: SetClipboardViewer returned own window. This causes an endless loop, so reset s_hwndNextViewer. ");
- s_hwndNextViewer=NULL;
- }
- #endif
-
- }
- 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)
- {
- winDebug("WM_CHANGECBCHAIN: trying to set s_hwndNextViewer to own window. Resetting it back to NULL. ");
- s_hwndNextViewer=NULL; /* This would cause an endless loop, so break it by ending the loop here. I have seen this happening, why??? */
- }
- }
- 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);
- if (!wParam) ChangeClipboardChain (hwnd, s_hwndNextViewer); /* When wParam is set, the window was already removed from the chain */
- winDebug (" WM_WM_REINIT: Putting us back at head of chain.\n");
- s_hwndNextViewer = SetClipboardViewer (hwnd);
- #ifdef _DEBUG
- if (s_hwndNextViewer== hwnd)
- {
- ErrorF("WM_WM_REINIT: SetClipboardViewer returned own window. This causes an endless loop, so reset s_hwndNextViewer. ");
- s_hwndNextViewer=NULL;
- }
- #endif
- }
- 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(1);
- 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);
-
- if (g_fClipboardPrimary)
- {
- /* 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)
- {
- if (g_fClipboardPrimary)
- {
- /* 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 */
- do {
- iReturn = winProcessXEventsTimeout (hwnd,
- iWindow,
- pDisplay,
- fConvertToUnicode,
- WIN_POLL_TIMEOUT);
- } while (WIN_XEVENTS_CONVERT == iReturn);
-
-
- /*
- * The last call 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;
-}
+/*
+ *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"
+#include "objbase.h"
+#include "ddraw.h"
+#include "winwindow.h"
+
+/*
+ * Constants
+ */
+
+#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;
+extern Bool g_fClipboardPrimary;
+
+/*
+ * 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)
+ {
+ /* Bail out if 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);
+ #ifdef _DEBUG
+ if (s_hwndNextViewer== hwnd)
+ {
+ ErrorF("WM_CREATE: SetClipboardViewer returned own window. This causes an endless loop, so reset s_hwndNextViewer. ");
+ s_hwndNextViewer=NULL;
+ }
+ #endif
+
+ }
+ 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)
+ {
+ winDebug("WM_CHANGECBCHAIN: trying to set s_hwndNextViewer to own window. Resetting it back to NULL. ");
+ s_hwndNextViewer=NULL; /* This would cause an endless loop, so break it by ending the loop here. I have seen this happening, why??? */
+ }
+ }
+ 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);
+ if (!wParam) ChangeClipboardChain (hwnd, s_hwndNextViewer); /* When wParam is set, the window was already removed from the chain */
+ winDebug (" WM_WM_REINIT: Putting us back at head of chain.\n");
+ s_hwndNextViewer = SetClipboardViewer (hwnd);
+ #ifdef _DEBUG
+ if (s_hwndNextViewer== hwnd)
+ {
+ ErrorF("WM_WM_REINIT: SetClipboardViewer returned own window. This causes an endless loop, so reset s_hwndNextViewer. ");
+ s_hwndNextViewer=NULL;
+ }
+ #endif
+ }
+ 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(1);
+ 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);
+
+ if (g_fClipboardPrimary)
+ {
+ /* 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)
+ {
+ if (g_fClipboardPrimary)
+ {
+ /* 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 */
+ do {
+ iReturn = winProcessXEventsTimeout (hwnd,
+ iWindow,
+ pDisplay,
+ fConvertToUnicode,
+ WIN_POLL_TIMEOUT);
+ } while (WIN_XEVENTS_CONVERT == iReturn);
+
+
+ /*
+ * The last call 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/winclipboardxevents.c b/xorg-server/hw/xwin/winclipboardxevents.c
index b3ed5eba5..53b4d7d77 100644
--- a/xorg-server/hw/xwin/winclipboardxevents.c
+++ b/xorg-server/hw/xwin/winclipboardxevents.c
@@ -1,843 +1,843 @@
-/*
- *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;
-extern Bool g_fClipboardPrimary;
-
-
-/*
- * 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;
- 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: %08lx\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 */
- if (g_fClipboardPrimary) XSetSelectionOwner (pDisplay, XA_PRIMARY, None, CurrentTime);
- XSetSelectionOwner (pDisplay, XInternAtom (pDisplay, "CLIPBOARD", False), None, CurrentTime);
- }
- ErrorF ("winClipboardFlushXEvents - SelectionRequest - "
- "GetClipboardData () failed: %08lx\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;
- }
- 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 XLocaleNotSupported:
- ErrorF ("XLocaleNotSupported\n");
- break;
- case XConverterNotFound:
- ErrorF ("XConverterNotFound\n");
- break;
- default:
- ErrorF ("%d\n", 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;
- }
- free(pszConvertData);
- 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;
-
- case MappingNotify:
- XRefreshKeyboardMapping((XMappingEvent *)&event);
- 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;
+extern Bool g_fClipboardPrimary;
+
+
+/*
+ * 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;
+ 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: %08lx\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 */
+ if (g_fClipboardPrimary) XSetSelectionOwner (pDisplay, XA_PRIMARY, None, CurrentTime);
+ XSetSelectionOwner (pDisplay, XInternAtom (pDisplay, "CLIPBOARD", False), None, CurrentTime);
+ }
+ ErrorF ("winClipboardFlushXEvents - SelectionRequest - "
+ "GetClipboardData () failed: %08lx\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;
+ }
+ 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 XLocaleNotSupported:
+ ErrorF ("XLocaleNotSupported\n");
+ break;
+ case XConverterNotFound:
+ ErrorF ("XConverterNotFound\n");
+ break;
+ default:
+ ErrorF ("%d\n", 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;
+ }
+ free(pszConvertData);
+ 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;
+
+ case MappingNotify:
+ XRefreshKeyboardMapping((XMappingEvent *)&event);
+ break;
+
+ default:
+ ErrorF ("winClipboardFlushXEvents - unexpected event type %d\n", event.type);
+ break;
+ }
+ }
+
+ return WIN_XEVENTS_SUCCESS;
+}
diff --git a/xorg-server/hw/xwin/winkeybd.c b/xorg-server/hw/xwin/winkeybd.c
index 2cd8caff1..f82ef0d51 100644
--- a/xorg-server/hw/xwin/winkeybd.c
+++ b/xorg-server/hw/xwin/winkeybd.c
@@ -1,539 +1,539 @@
-/*
- *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
-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);
-
- winDebug("winTranslateKey: wParam %08x lParam %08x\n", wParam, lParam);
-
-/* 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;
- }
-}
-
-
-/* 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");
- }
-
- break;
-
- case DEVICE_ON:
- pDevice->on = TRUE;
-
- // immediately copy the state of this keyboard device to the VCK
- // (which otherwise happens lazily after the first keypress)
- CopyKeyClass(pDeviceInt, inputInfo.keyboard);
- 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 (screenInfo.screens[0]->root && screenInfo.screens[0]->root->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);
-
- {
- /* Make sure the message queue is empty, otherwise the GetKeyState will not always
- return the correct state of the numlock key, capslock key, ...
- This is mainly because this function is called from the WM_SETFOCUS handler.
- From MSDN GetKeyState: The key status returned from this function changes as a thread
- reads key messages from its message queue.*/
- MSG msg;
-
- /* Process all messages on our queue */
- while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
- {
- DispatchMessage (&msg);
- }
- }
-
- /*
- * 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)
-{
- /*
- * 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;
-
- QueueKeyboardEvents(g_pwinKeyboard, fDown ? KeyPress : KeyRelease, dwKey + MIN_KEYCODE, NULL);
-
- winDebug("winSendKeyEvent: dwKey: %d, fDown: %d\n",
- dwKey, fDown);
-}
-
-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
+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);
+
+ winDebug("winTranslateKey: wParam %08x lParam %08x\n", wParam, lParam);
+
+/* 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;
+ }
+}
+
+
+/* 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");
+ }
+
+ break;
+
+ case DEVICE_ON:
+ pDevice->on = TRUE;
+
+ // immediately copy the state of this keyboard device to the VCK
+ // (which otherwise happens lazily after the first keypress)
+ CopyKeyClass(pDeviceInt, inputInfo.keyboard);
+ 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 (screenInfo.screens[0]->root && screenInfo.screens[0]->root->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);
+
+ {
+ /* Make sure the message queue is empty, otherwise the GetKeyState will not always
+ return the correct state of the numlock key, capslock key, ...
+ This is mainly because this function is called from the WM_SETFOCUS handler.
+ From MSDN GetKeyState: The key status returned from this function changes as a thread
+ reads key messages from its message queue.*/
+ MSG msg;
+
+ /* Process all messages on our queue */
+ while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
+ {
+ DispatchMessage (&msg);
+ }
+ }
+
+ /*
+ * 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)
+{
+ /*
+ * 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;
+
+ QueueKeyboardEvents(g_pwinKeyboard, fDown ? KeyPress : KeyRelease, dwKey + MIN_KEYCODE, NULL);
+
+ winDebug("winSendKeyEvent: dwKey: %d, fDown: %d\n",
+ dwKey, fDown);
+}
+
+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/winmonitors.c b/xorg-server/hw/xwin/winmonitors.c
index f78734b9b..876d23437 100644
--- a/xorg-server/hw/xwin/winmonitors.c
+++ b/xorg-server/hw/xwin/winmonitors.c
@@ -1,73 +1,73 @@
-/*
-
-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"
-#define COMPILE_MULTIMON_STUBS
-#include <multimon.h>
-#include "winmonitors.h"
-
-/*
- * getMonitorInfo - callback function used to return information from the enumeration of monitors attached
- */
-
-static
-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;
-}
-
-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;
-}
+/*
+
+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"
+#define COMPILE_MULTIMON_STUBS
+#include <multimon.h>
+#include "winmonitors.h"
+
+/*
+ * getMonitorInfo - callback function used to return information from the enumeration of monitors attached
+ */
+
+static
+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;
+}
+
+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;
+}
diff --git a/xorg-server/hw/xwin/winmouse.c b/xorg-server/hw/xwin/winmouse.c
index efe71103c..6af887826 100644
--- a/xorg-server/hw/xwin/winmouse.c
+++ b/xorg-server/hw/xwin/winmouse.c
@@ -1,380 +1,380 @@
-/*
- *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"
-#include "inpututils.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)
-{
- ValuatorMask mask;
-
- if (g_winMouseButtonMap)
- iButton = g_winMouseButtonMap[iButton];
-
- valuator_mask_zero(&mask);
- QueuePointerEvents(g_pwinPointer, iEventType, iButton,
- POINTER_RELATIVE, &mask);
-
- winDebug("winMouseButtonsSendEvent: iEventType: %d, iButton: %d\n",
- iEventType, iButton);
-}
-
-
-/*
- * 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 valuators[2];
- ValuatorMask mask;
-
- miPointerSetPosition(g_pwinPointer, POINTER_RELATIVE, &x, &y);
- valuators[0] = x;
- valuators[1] = y;
-
- valuator_mask_set_range(&mask, 0, 2, valuators);
- QueuePointerEvents(g_pwinPointer, MotionNotify, 0,
- POINTER_ABSOLUTE | POINTER_SCREEN, &mask);
-
-}
+/*
+ *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"
+#include "inpututils.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)
+{
+ ValuatorMask mask;
+
+ if (g_winMouseButtonMap)
+ iButton = g_winMouseButtonMap[iButton];
+
+ valuator_mask_zero(&mask);
+ QueuePointerEvents(g_pwinPointer, iEventType, iButton,
+ POINTER_RELATIVE, &mask);
+
+ winDebug("winMouseButtonsSendEvent: iEventType: %d, iButton: %d\n",
+ iEventType, iButton);
+}
+
+
+/*
+ * 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 valuators[2];
+ ValuatorMask mask;
+
+ miPointerSetPosition(g_pwinPointer, POINTER_RELATIVE, &x, &y);
+ valuators[0] = x;
+ valuators[1] = y;
+
+ valuator_mask_set_range(&mask, 0, 2, valuators);
+ QueuePointerEvents(g_pwinPointer, MotionNotify, 0,
+ POINTER_ABSOLUTE | POINTER_SCREEN, &mask);
+
+}
diff --git a/xorg-server/hw/xwin/winmultiwindowicons.c b/xorg-server/hw/xwin/winmultiwindowicons.c
index 853d63864..d534cf0b7 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 "windowstr.h"
-
-
-/*
- * 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;
- BITMAPV5HEADER bmh;
-
- /* Define an ARGB pixel format used for Color+Alpha icons */
- ZeroMemory(&bmh,sizeof(bmh));
- bmh.bV5Size = sizeof(bmh);
- bmh.bV5Width = width;
- bmh.bV5Height = -height; /* Invert the image */
- bmh.bV5Planes = 1;
- bmh.bV5BitCount = 32;
- bmh.bV5Compression = BI_BITFIELDS;
- bmh.bV5AlphaMask = 0xFF000000;
- bmh.bV5RedMask = 0x00FF0000;
- bmh.bV5GreenMask = 0x0000FF00;
- bmh.bV5BlueMask = 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) */
- ii.fIcon = TRUE;
- ii.xHotspot = 0;
- ii.yHotspot = 0;
- 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;
-
- 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);
-
- ii.fIcon = TRUE;
- ii.xHotspot = 0;
- ii.yHotspot = 0;
- 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 one of the application defaults or an override */
- 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 "windowstr.h"
+
+
+/*
+ * 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;
+ BITMAPV5HEADER bmh;
+
+ /* Define an ARGB pixel format used for Color+Alpha icons */
+ ZeroMemory(&bmh,sizeof(bmh));
+ bmh.bV5Size = sizeof(bmh);
+ bmh.bV5Width = width;
+ bmh.bV5Height = -height; /* Invert the image */
+ bmh.bV5Planes = 1;
+ bmh.bV5BitCount = 32;
+ bmh.bV5Compression = BI_BITFIELDS;
+ bmh.bV5AlphaMask = 0xFF000000;
+ bmh.bV5RedMask = 0x00FF0000;
+ bmh.bV5GreenMask = 0x0000FF00;
+ bmh.bV5BlueMask = 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) */
+ ii.fIcon = TRUE;
+ ii.xHotspot = 0;
+ ii.yHotspot = 0;
+ 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;
+
+ 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);
+
+ ii.fIcon = TRUE;
+ ii.xHotspot = 0;
+ ii.yHotspot = 0;
+ 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 one of the application defaults or an override */
+ if (hIcon &&
+ hIcon != g_hIconX &&
+ hIcon != g_hSmallIconX &&
+ !winIconIsOverride((unsigned long)hIcon))
+ DestroyIcon (hIcon);
+}
+#endif
diff --git a/xorg-server/hw/xwin/winmultiwindowwindow.c b/xorg-server/hw/xwin/winmultiwindowwindow.c
index c73d192f3..f87da410e 100644
--- a/xorg-server/hw/xwin/winmultiwindowwindow.c
+++ b/xorg-server/hw/xwin/winmultiwindowwindow.c
@@ -1,1021 +1,1021 @@
-/*
- *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"
-
-/*
- * 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 | (g_fNativeGl ? CS_OWNDC : 0);
- 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;
-#ifdef XWIN_GLX_WINDOWS
- pWinPriv->fWglUsed = FALSE;
-#endif
-
- 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");
- if (pWin->redirectDraw != RedirectDrawNone)
- {
- winDebug("winPositionWindowMultiWindow: Calling compReallocPixmap to make sure the pixmap buffer is valid.\n");
- compReallocPixmap(pWin, x, y, pWin->drawable.width, pWin->drawable.height, pWin->borderWidth);
- }
- 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 */
- if (pWinPriv->fWglUsed)
- {
- int iWidth=rcNew.right - rcNew.left;
- int iHeight=rcNew.bottom - rcNew.top;
- ScreenToClient(GetParent(hWnd), (LPPOINT)&rcNew);
- MoveWindow (hWnd,
- rcNew.left, rcNew.top,
- iWidth, iHeight,
- TRUE);
- }
- else
- 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);
-
- winDebug("winReparentMultiWindow - pWin:%08x XID:0x%x, reparent from pWin:%08x XID:0x%x to pWin:%08x XID:0x%x\n",
- pWin, pWin->drawable.id, pPriorParent, pPriorParent->drawable.id, pWin->parent, pWin->parent->drawable.id);
-
- 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;
- DWORD dwStyle, dwExStyle;
- RECT rc;
-
- winInitMultiWindowClass();
-
- winDebug("winCreateWindowsTopLevelWindow - pWin:%08x XID:0x%x \n", pWin, pWin->drawable.id);
-
- iX = pWin->drawable.x + GetSystemMetrics (SM_XVIRTUALSCREEN);
- iY = pWin->drawable.y + GetSystemMetrics (SM_YVIRTUALSCREEN);
-
- iWidth = pWin->drawable.width;
- iHeight = pWin->drawable.height;
-
- /* If it's an InputOutput window, and so is going to end up being made visible,
- make sure the window actually ends up somewhere where it will be visible
- Dont't do it by making just one of the two iX and iY CW_USEDEFAULT since
- this will create a window at place CW_USEDEFAULT which is 0x80000000 */
- if (pWin->drawable.class != InputOnly)
- {
- while (1)
- {
- if (iX < GetSystemMetrics (SM_XVIRTUALSCREEN))
- {
- iX = GetSystemMetrics (SM_XVIRTUALSCREEN);
- ErrorF("Resetting iX to %d\n",iX);
- }
- else if (iX > GetSystemMetrics (SM_CXVIRTUALSCREEN))
- {
- iX = GetSystemMetrics (SM_CXVIRTUALSCREEN)-iWidth;
- ErrorF("Resetting iX to %d\n",iX);
- }
- else
- break;
- }
-
- while (1)
- {
- if (iY < GetSystemMetrics (SM_YVIRTUALSCREEN))
- {
- iY = GetSystemMetrics (SM_YVIRTUALSCREEN);
- ErrorF("Resetting iY to %d\n",iY);
- }
- else if (iY > GetSystemMetrics (SM_CYVIRTUALSCREEN))
- {
- iY = GetSystemMetrics (SM_CYVIRTUALSCREEN)-iHeight;
- ErrorF("Resetting iY to %d\n",iY);
- }
- else
- break;
- }
- }
-
- winDebug("winCreateWindowsWindow - %dx%d @ %dx%d\n", iWidth, iHeight, iX, iY);
-
- 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;
- }
- }
-
- /* Make it WS_OVERLAPPED in create call since WS_POPUP doesn't support */
- /* CW_USEDEFAULT, change back to popup after creation */
- dwStyle = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
- dwExStyle = WS_EX_TOOLWINDOW;
-
- /*
- Calculate the window coordinates containing the requested client area,
- being careful to preseve CW_USEDEFAULT
- */
- rc.top = (iY != CW_USEDEFAULT) ? iY : 0;
- rc.left = (iX != CW_USEDEFAULT) ? iX : 0;
- rc.bottom = rc.top + iHeight;
- rc.right = rc.left + iWidth;
- AdjustWindowRectEx(&rc, dwStyle, FALSE, dwExStyle);
- if (iY != CW_USEDEFAULT) iY = rc.top;
- if (iX != CW_USEDEFAULT) iX = rc.left;
- iHeight = rc.bottom - rc.top;
- iWidth = rc.right - rc.left;
-
- winDebug("winCreateWindowsWindow - %dx%d @ %dx%d\n", iWidth, iHeight, iX, iY);
-
- /* Create the window */
- hWnd = CreateWindowExA (dwExStyle, /* Extended styles */
- WINDOW_CLASS_X, /* Class name */
- WINDOW_TITLE_X, /* Window name */
- dwStyle, /* Styles */
- 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);
-
- /* If we asked the native WM to place the window, synchronize the X window position.
- Do this before the next SetWindowPos because this one is generating a WM_STYLECHANGED
- message which is causing a window move, which is wrong if the Xwindow does not
- have the correct coordinates yet */
- if (iX == CW_USEDEFAULT)
- {
- winAdjustXWindow(pWin, hWnd);
- }
-
- /* 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;
- HICON hIcon;
- HICON hIconSm;
-
- winDebug("winDestroyWindowsWindow - pWin:%08x XID:0x%x \n", pWin, pWin->drawable.id);
-
- /* Bail out if the Windows window handle is invalid */
- if (pWinPriv->hWnd == NULL)
- return;
-
- winInDestroyWindowsWindow = TRUE;
-
- /* Store the info we need to destroy after this window is gone */
- hIcon = (HICON)SendMessage(pWinPriv->hWnd, WM_GETICON, ICON_BIG, 0);
- hIconSm = (HICON)SendMessage(pWinPriv->hWnd, WM_GETICON, ICON_SMALL, 0);
-
- 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;
-
- /* Destroy any icons we created for this window */
- winDestroyIcon(hIcon);
- winDestroyIcon(hIconSm);
-
-#ifdef XWIN_GLX_WINDOWS
- /* No longer note WGL used on this window */
- pWinPriv->fWglUsed = FALSE;
-#endif
-
- /* 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;
-
- winDebug("winDestroyWindowsWindow - done\n");
-}
-
-
-/*
- * 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 */
- if (pWin->drawable.class != InputOnly)
- ShowWindow (pWinPriv->hWnd, SW_SHOWNOACTIVATE);
-
- /* Send first paint message */
- UpdateWindow (pWinPriv->hWnd);
- }
- else if (hWnd != NULL)
- {
- if (pWinPriv->fWglUsed)
- {
- /* We do not need to destroy the window but to reparent it and move it to the
- correct place when it is an opengl window */
- int offsetx;
- int offsety;
- HWND hParentWnd;
- WindowPtr pParent=pWin->parent;
-
- while (pParent)
- {
- winWindowPriv(pParent);
- hParentWnd=pWinPriv->hWnd;
- if (hParentWnd)
- break;
- pParent=pParent->parent;
- }
-
- if (pParent)
- {
- offsetx=pParent->drawable.x;
- offsety=pParent->drawable.y;
- }
- else
- {
- offsetx=0;
- offsety=0;
- }
- winDebug ("-winUpdateWindowsWindow: %x changing parent to %x and moving to %d,%d\n",pWinPriv->hWnd,hParentWnd,pWin->drawable.x-offsetx,pWin->drawable.y-offsety);
- SetParent(pWinPriv->hWnd,hParentWnd);
- SetWindowPos(pWinPriv->hWnd,NULL,pWin->drawable.x-offsetx,pWin->drawable.y-offsety,0,0,SWP_NOSIZE|SWP_NOZORDER|SWP_SHOWWINDOW);
- }
- else
- {
- /* Destroy the Windows window if its parents are destroyed */
- /* First check if we need to release the DC when it is an opengl window */
- 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_MULTIWINDOWINTWM
- 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
-}
-
+/*
+ *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"
+
+/*
+ * 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 | (g_fNativeGl ? CS_OWNDC : 0);
+ 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;
+#ifdef XWIN_GLX_WINDOWS
+ pWinPriv->fWglUsed = FALSE;
+#endif
+
+ 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");
+ if (pWin->redirectDraw != RedirectDrawNone)
+ {
+ winDebug("winPositionWindowMultiWindow: Calling compReallocPixmap to make sure the pixmap buffer is valid.\n");
+ compReallocPixmap(pWin, x, y, pWin->drawable.width, pWin->drawable.height, pWin->borderWidth);
+ }
+ 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 */
+ if (pWinPriv->fWglUsed)
+ {
+ int iWidth=rcNew.right - rcNew.left;
+ int iHeight=rcNew.bottom - rcNew.top;
+ ScreenToClient(GetParent(hWnd), (LPPOINT)&rcNew);
+ MoveWindow (hWnd,
+ rcNew.left, rcNew.top,
+ iWidth, iHeight,
+ TRUE);
+ }
+ else
+ 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);
+
+ winDebug("winReparentMultiWindow - pWin:%08x XID:0x%x, reparent from pWin:%08x XID:0x%x to pWin:%08x XID:0x%x\n",
+ pWin, pWin->drawable.id, pPriorParent, pPriorParent->drawable.id, pWin->parent, pWin->parent->drawable.id);
+
+ 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;
+ DWORD dwStyle, dwExStyle;
+ RECT rc;
+
+ winInitMultiWindowClass();
+
+ winDebug("winCreateWindowsTopLevelWindow - pWin:%08x XID:0x%x \n", pWin, pWin->drawable.id);
+
+ iX = pWin->drawable.x + GetSystemMetrics (SM_XVIRTUALSCREEN);
+ iY = pWin->drawable.y + GetSystemMetrics (SM_YVIRTUALSCREEN);
+
+ iWidth = pWin->drawable.width;
+ iHeight = pWin->drawable.height;
+
+ /* If it's an InputOutput window, and so is going to end up being made visible,
+ make sure the window actually ends up somewhere where it will be visible
+ Dont't do it by making just one of the two iX and iY CW_USEDEFAULT since
+ this will create a window at place CW_USEDEFAULT which is 0x80000000 */
+ if (pWin->drawable.class != InputOnly)
+ {
+ while (1)
+ {
+ if (iX < GetSystemMetrics (SM_XVIRTUALSCREEN))
+ {
+ iX = GetSystemMetrics (SM_XVIRTUALSCREEN);
+ ErrorF("Resetting iX to %d\n",iX);
+ }
+ else if (iX > GetSystemMetrics (SM_CXVIRTUALSCREEN))
+ {
+ iX = GetSystemMetrics (SM_CXVIRTUALSCREEN)-iWidth;
+ ErrorF("Resetting iX to %d\n",iX);
+ }
+ else
+ break;
+ }
+
+ while (1)
+ {
+ if (iY < GetSystemMetrics (SM_YVIRTUALSCREEN))
+ {
+ iY = GetSystemMetrics (SM_YVIRTUALSCREEN);
+ ErrorF("Resetting iY to %d\n",iY);
+ }
+ else if (iY > GetSystemMetrics (SM_CYVIRTUALSCREEN))
+ {
+ iY = GetSystemMetrics (SM_CYVIRTUALSCREEN)-iHeight;
+ ErrorF("Resetting iY to %d\n",iY);
+ }
+ else
+ break;
+ }
+ }
+
+ winDebug("winCreateWindowsWindow - %dx%d @ %dx%d\n", iWidth, iHeight, iX, iY);
+
+ 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;
+ }
+ }
+
+ /* Make it WS_OVERLAPPED in create call since WS_POPUP doesn't support */
+ /* CW_USEDEFAULT, change back to popup after creation */
+ dwStyle = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
+ dwExStyle = WS_EX_TOOLWINDOW;
+
+ /*
+ Calculate the window coordinates containing the requested client area,
+ being careful to preseve CW_USEDEFAULT
+ */
+ rc.top = (iY != CW_USEDEFAULT) ? iY : 0;
+ rc.left = (iX != CW_USEDEFAULT) ? iX : 0;
+ rc.bottom = rc.top + iHeight;
+ rc.right = rc.left + iWidth;
+ AdjustWindowRectEx(&rc, dwStyle, FALSE, dwExStyle);
+ if (iY != CW_USEDEFAULT) iY = rc.top;
+ if (iX != CW_USEDEFAULT) iX = rc.left;
+ iHeight = rc.bottom - rc.top;
+ iWidth = rc.right - rc.left;
+
+ winDebug("winCreateWindowsWindow - %dx%d @ %dx%d\n", iWidth, iHeight, iX, iY);
+
+ /* Create the window */
+ hWnd = CreateWindowExA (dwExStyle, /* Extended styles */
+ WINDOW_CLASS_X, /* Class name */
+ WINDOW_TITLE_X, /* Window name */
+ dwStyle, /* Styles */
+ 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);
+
+ /* If we asked the native WM to place the window, synchronize the X window position.
+ Do this before the next SetWindowPos because this one is generating a WM_STYLECHANGED
+ message which is causing a window move, which is wrong if the Xwindow does not
+ have the correct coordinates yet */
+ if (iX == CW_USEDEFAULT)
+ {
+ winAdjustXWindow(pWin, hWnd);
+ }
+
+ /* 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;
+ HICON hIcon;
+ HICON hIconSm;
+
+ winDebug("winDestroyWindowsWindow - pWin:%08x XID:0x%x \n", pWin, pWin->drawable.id);
+
+ /* Bail out if the Windows window handle is invalid */
+ if (pWinPriv->hWnd == NULL)
+ return;
+
+ winInDestroyWindowsWindow = TRUE;
+
+ /* Store the info we need to destroy after this window is gone */
+ hIcon = (HICON)SendMessage(pWinPriv->hWnd, WM_GETICON, ICON_BIG, 0);
+ hIconSm = (HICON)SendMessage(pWinPriv->hWnd, WM_GETICON, ICON_SMALL, 0);
+
+ 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;
+
+ /* Destroy any icons we created for this window */
+ winDestroyIcon(hIcon);
+ winDestroyIcon(hIconSm);
+
+#ifdef XWIN_GLX_WINDOWS
+ /* No longer note WGL used on this window */
+ pWinPriv->fWglUsed = FALSE;
+#endif
+
+ /* 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;
+
+ winDebug("winDestroyWindowsWindow - done\n");
+}
+
+
+/*
+ * 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 */
+ if (pWin->drawable.class != InputOnly)
+ ShowWindow (pWinPriv->hWnd, SW_SHOWNOACTIVATE);
+
+ /* Send first paint message */
+ UpdateWindow (pWinPriv->hWnd);
+ }
+ else if (hWnd != NULL)
+ {
+ if (pWinPriv->fWglUsed)
+ {
+ /* We do not need to destroy the window but to reparent it and move it to the
+ correct place when it is an opengl window */
+ int offsetx;
+ int offsety;
+ HWND hParentWnd;
+ WindowPtr pParent=pWin->parent;
+
+ while (pParent)
+ {
+ winWindowPriv(pParent);
+ hParentWnd=pWinPriv->hWnd;
+ if (hParentWnd)
+ break;
+ pParent=pParent->parent;
+ }
+
+ if (pParent)
+ {
+ offsetx=pParent->drawable.x;
+ offsety=pParent->drawable.y;
+ }
+ else
+ {
+ offsetx=0;
+ offsety=0;
+ }
+ winDebug ("-winUpdateWindowsWindow: %x changing parent to %x and moving to %d,%d\n",pWinPriv->hWnd,hParentWnd,pWin->drawable.x-offsetx,pWin->drawable.y-offsety);
+ SetParent(pWinPriv->hWnd,hParentWnd);
+ SetWindowPos(pWinPriv->hWnd,NULL,pWin->drawable.x-offsetx,pWin->drawable.y-offsety,0,0,SWP_NOSIZE|SWP_NOZORDER|SWP_SHOWWINDOW);
+ }
+ else
+ {
+ /* Destroy the Windows window if its parents are destroyed */
+ /* First check if we need to release the DC when it is an opengl window */
+ 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_MULTIWINDOWINTWM
+ 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 16db73c91..4e4d52be8 100644
--- a/xorg-server/hw/xwin/winmultiwindowwm.c
+++ b/xorg-server/hw/xwin/winmultiwindowwm.c
@@ -1,1755 +1,1755 @@
-/*
- *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/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"
-#include "winmultiwindowclass.h"
-
-#ifdef XWIN_MULTIWINDOWEXTWM
-#define _WINDOWSWM_SERVER_
-#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;
-#ifdef _DEBUG
- int nQueueSize;
-#endif
-} WMMsgQueueRec, *WMMsgQueuePtr;
-
-typedef struct _WMInfo {
- Display *pDisplay;
- WMMsgQueueRec wmMsgQueue;
- Atom atmWmProtos;
- Atom atmWmDelete;
- Atom atmPrivMap;
-#ifdef XWIN_MULTIWINDOWINTWM
- Bool fAllowOtherWM;
-#endif
-} 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 void
-winMultiWindowThreadExit(void *arg);
-
-static int
-winRedirectErrorHandler (Display *pDisplay, XErrorEvent *pErr);
-
-static void
-winInitMultiWindowWM (WMInfoPtr pWMInfo, WMProcArgPtr pProcArg);
-
-static Bool
-CheckAnotherWindowManager (Display *pDisplay, DWORD dwScreen, Bool fAllowOtherWM);
-
-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 XIOErrorHandler g_winMultiWindowWMOldIOErrorHandler;
-static pthread_t g_winMultiWindowWMThread;
-static jmp_buf g_jmpXMsgProcEntry;
-static XIOErrorHandler g_winMultiWindowXMsgProcOldIOErrorHandler;
-static pthread_t g_winMultiWindowXMsgProcThread;
-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;
- }
-
-#ifdef _DEBUG
- /* Increase the count of elements in the queue by one */
- ++(pQueue->nQueueSize);
-#endif
-
- /* 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;
- }
-
- #ifdef _DEBUG
- /* Drop the number of elements in the queue by one */
- --(pQueue->nQueueSize);
-
- winDebug ("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 */
- #ifdef _DEBUG
- pQueue->nQueueSize = 0;
-
- winDebug ("InitQueue - Queue Size %d %d\n", pQueue->nQueueSize,
- QueueSize(pQueue));
- #endif
-
- 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]);
- if (ppList) XFreeStringList (ppList);
- }
- 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);
- 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;
-
- pthread_cleanup_push(&winMultiWindowThreadExit, NULL);
-
- /* Initialize the Window Manager */
- winInitMultiWindowWM (pWMInfo, pProcArg);
-
- winDebug ("winMultiWindowWMProc ()\n");
-
- /* Loop until we explicitly break out */
- for (;;)
- {
- WMMsgNodePtr pNode;
-
-#ifdef XWIN_MULTIWINDOWINTWM
- if(g_fAnotherWMRunning)/* Another Window manager exists. */
- {
- Sleep (1000);
- continue;
- }
-#endif
-
- /* 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");
-
- pthread_cleanup_pop(0);
-
- 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;
-
- pthread_cleanup_push(&winMultiWindowThreadExit, NULL);
-
- 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");
-
- /* Release the server started mutex */
- pthread_mutex_unlock (pProcArg->ppmServerStarted);
-
- winDebug ("winMultiWindowXMsgProc - pthread_mutex_unlock () returned.\n");
-
- /* Install our error handler */
- XSetErrorHandler (winMultiWindowXMsgProcErrorHandler);
- g_winMultiWindowXMsgProcThread = pthread_self();
- g_winMultiWindowXMsgProcOldIOErrorHandler = XSetIOErrorHandler (winMultiWindowXMsgProcIOErrorHandler);
-
- /* 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);
- }
-
- /* Setup the display connection string x */
- winGetDisplayName(pszDisplay, (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",
- 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 */
-#ifdef XWIN_MULTIWINDOWINTWM
- g_fAnotherWMRunning = CheckAnotherWindowManager (pProcArg->pDisplay, pProcArg->dwScreen, pProcArg->pWMInfo->fAllowOtherWM);
-#else
- g_fAnotherWMRunning = CheckAnotherWindowManager (pProcArg->pDisplay, pProcArg->dwScreen, FALSE);
-#endif
-
- if (g_fAnotherWMRunning
-#ifdef XWIN_MULTIWINDOWINTWM
- && !pProcArg->pWMInfo->fAllowOtherWM
-#endif
- )
- {
- 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;
-
-#ifdef XWIN_MULTIWINDOWINTWM
- if (pProcArg->pWMInfo->fAllowOtherWM && !XPending (pProcArg->pDisplay))
- {
- if (CheckAnotherWindowManager (pProcArg->pDisplay, pProcArg->dwScreen, TRUE))
- {
- 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;
- }
-#endif
-
- /* 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;
- event_send.xreparent.override_redirect = False;
-
- XSendEvent(event.xmap.display,
- event.xmap.window,
- True, StructureNotifyMask,
- &event_send);
- }
- }
- }
- else if (event.type == ConfigureNotify)
- {
- if (!event.xconfigure.send_event)
- {
- /*
- Java applications using AWT on JRE 1.6.0 break with non-reparenting WMs AWT
- doesn't explicitly know about (See sun bug #6434227)
-
- XDecoratedPeer.handleConfigureNotifyEvent() only processes non-synthetic
- ConfigureNotify events to update window location if it's identified the
- WM as a non-reparenting WM it knows about (compiz or lookingglass)
-
- Rather than tell all sorts of lies to get XWM to recognize us as one of
- those, simply send a synthetic ConfigureNotify for every non-synthetic one
- */
- XEvent event_send = event;
- event_send.xconfigure.send_event = TRUE;
- event_send.xconfigure.event = event.xconfigure.window;
- XSendEvent(event.xconfigure.display,
- event.xconfigure.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_cleanup_pop(0);
- 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;
-#ifdef XWIN_MULTIWINDOWINTWM
- pWMInfo->fAllowOtherWM = allowOtherWM;
-#endif
-
- /* 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");
-
- /* Release the server started mutex */
- pthread_mutex_unlock (pProcArg->ppmServerStarted);
-
- winDebug ("winInitMultiWindowWM - pthread_mutex_unlock () returned.\n");
-
- /* Install our error handler */
- XSetErrorHandler (winMultiWindowWMErrorHandler);
- g_winMultiWindowWMThread = pthread_self();
- g_winMultiWindowWMOldIOErrorHandler = XSetIOErrorHandler (winMultiWindowWMIOErrorHandler);
-
- /* 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);
- }
-
- /* Setup the display connection string x */
- winGetDisplayName(pszDisplay, (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",
- 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 ("winMultiWindowWMIOErrorHandler!\n\n");
-
- if (pthread_equal(pthread_self(),g_winMultiWindowWMThread))
- {
- if (g_shutdown)
- pthread_exit(NULL);
-
- /* Restart at the main entry point */
- longjmp (g_jmpWMEntry, WIN_JMP_ERROR_IO);
- }
-
- if (g_winMultiWindowWMOldIOErrorHandler)
- g_winMultiWindowWMOldIOErrorHandler(pDisplay);
-
- 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 ("winMultiWindowXMsgProcIOErrorHandler!\n\n");
-
- if (pthread_equal(pthread_self(),g_winMultiWindowXMsgProcThread))
- {
- /* Restart at the main entry point */
- longjmp (g_jmpXMsgProcEntry, WIN_JMP_ERROR_IO);
- }
-
- if (g_winMultiWindowXMsgProcOldIOErrorHandler)
- g_winMultiWindowXMsgProcOldIOErrorHandler(pDisplay);
-
- return 0;
-}
-
-/*
- * winMultiWindowThreadExit - Thread exit handler
- */
-
-static void
-winMultiWindowThreadExit(void *arg)
-{
- AbortDDX(EXIT_ERR_ABORT);
-
- /* multiwindow client thread has exited, stop server as well */
- TerminateProcess(GetCurrentProcess(),1);
-}
-
-/*
- * 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, Bool fAllowOtherWM)
-{
- /*
- 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...
-
- If other WMs are not allowed, also select one of the events which only one client
- at a time is allowed to select, so other window managers won't start...
- */
- XSelectInput(pDisplay, RootWindow (pDisplay, dwScreen),
- SubstructureNotifyMask | ( !fAllowOtherWM ? ButtonPressMask : 0));
- 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)
-#define HINT_NOMAXIMIZE (1L<<4)
-/* 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;
- WinXSizeHints SizeHints;
-
- 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);
- }
-
- {
- XSizeHints *normal_hint = XAllocSizeHints();
- long supplied;
- if (normal_hint && (XGetWMNormalHints(pDisplay, iWindow, normal_hint, &supplied) == Success))
- {
- if (normal_hint->flags & PMaxSize)
- {
- /* Not maximizable if a maximum size is specified */
- hint |= HINT_NOMAXIMIZE;
-
- if (normal_hint->flags & PMinSize)
- {
- /*
- If both minimum size and maximum size are specified and are the same,
- don't bother with a resizing frame
- */
- if ((normal_hint->min_width == normal_hint->max_width)
- && (normal_hint->min_height == normal_hint->max_height))
- hint = (hint & ~HINT_SIZEBOX);
- }
- }
- }
- XFree(normal_hint);
- }
-
- /* Override hint settings from above with settings from config file */
- {
- XClassHint class_hint = {0,0};
-
- if (XGetClassHint(pDisplay, iWindow, &class_hint))
- {
- char *window_name = 0;
- XFetchName(pDisplay, iWindow, &window_name);
-
- style = winOverrideStyle(class_hint.res_name, class_hint.res_class, window_name);
-
- if (class_hint.res_name) XFree(class_hint.res_name);
- if (class_hint.res_class) XFree(class_hint.res_class);
- if (window_name) XFree(window_name);
- }
- else
- {
- style = STYLE_NONE;
- }
- }
-
- 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_CAPTION) | HINT_BORDER;
- else if (style & STYLE_NOFRAME)
- hint = (hint & ~HINT_BORDER & ~HINT_CAPTION) | HINT_NOFRAME;
-
- /* Now apply styles to window */
- style = GetWindowLongPtr(hWnd, GWL_STYLE) & ~WS_CAPTION & ~WS_SIZEBOX; /* Just in case */
- if (!hint) /* All on, but no resize of children is allowed */
- style = style | WS_CAPTION;
- else if (hint & HINT_NOFRAME) /* All off */
- style = style & ~WS_CAPTION & ~WS_SIZEBOX;
- else style = style | ((hint & HINT_BORDER) ? WS_BORDER : 0) |
- ((hint & HINT_SIZEBOX) ? WS_SIZEBOX : 0) |
- ((hint & HINT_CAPTION) ? WS_CAPTION : 0);
-
- if (hint & HINT_NOMAXIMIZE)
- style = style & ~WS_MAXIMIZEBOX;
-
- if (!IsWindow (hWnd))
- {
- ErrorF("Windows window 0x%x has become invalid, so returning without applying hints\n",hWnd);
- return;
- }
-
- if (winMultiWindowGetWMNormalHints(pWin, &SizeHints))
- {
- if (!(SizeHints.max_width&&SizeHints.max_height&&(SizeHints.min_width == SizeHints.max_width)&&(SizeHints.min_height == SizeHints.max_height) ))
- style|=WS_SIZEBOX;
- }
- else
- style|=WS_SIZEBOX;
- 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);
- }
-}
+/*
+ *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/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"
+#include "winmultiwindowclass.h"
+
+#ifdef XWIN_MULTIWINDOWEXTWM
+#define _WINDOWSWM_SERVER_
+#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;
+#ifdef _DEBUG
+ int nQueueSize;
+#endif
+} WMMsgQueueRec, *WMMsgQueuePtr;
+
+typedef struct _WMInfo {
+ Display *pDisplay;
+ WMMsgQueueRec wmMsgQueue;
+ Atom atmWmProtos;
+ Atom atmWmDelete;
+ Atom atmPrivMap;
+#ifdef XWIN_MULTIWINDOWINTWM
+ Bool fAllowOtherWM;
+#endif
+} 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 void
+winMultiWindowThreadExit(void *arg);
+
+static int
+winRedirectErrorHandler (Display *pDisplay, XErrorEvent *pErr);
+
+static void
+winInitMultiWindowWM (WMInfoPtr pWMInfo, WMProcArgPtr pProcArg);
+
+static Bool
+CheckAnotherWindowManager (Display *pDisplay, DWORD dwScreen, Bool fAllowOtherWM);
+
+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 XIOErrorHandler g_winMultiWindowWMOldIOErrorHandler;
+static pthread_t g_winMultiWindowWMThread;
+static jmp_buf g_jmpXMsgProcEntry;
+static XIOErrorHandler g_winMultiWindowXMsgProcOldIOErrorHandler;
+static pthread_t g_winMultiWindowXMsgProcThread;
+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;
+ }
+
+#ifdef _DEBUG
+ /* Increase the count of elements in the queue by one */
+ ++(pQueue->nQueueSize);
+#endif
+
+ /* 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;
+ }
+
+ #ifdef _DEBUG
+ /* Drop the number of elements in the queue by one */
+ --(pQueue->nQueueSize);
+
+ winDebug ("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 */
+ #ifdef _DEBUG
+ pQueue->nQueueSize = 0;
+
+ winDebug ("InitQueue - Queue Size %d %d\n", pQueue->nQueueSize,
+ QueueSize(pQueue));
+ #endif
+
+ 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]);
+ if (ppList) XFreeStringList (ppList);
+ }
+ 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);
+ 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;
+
+ pthread_cleanup_push(&winMultiWindowThreadExit, NULL);
+
+ /* Initialize the Window Manager */
+ winInitMultiWindowWM (pWMInfo, pProcArg);
+
+ winDebug ("winMultiWindowWMProc ()\n");
+
+ /* Loop until we explicitly break out */
+ for (;;)
+ {
+ WMMsgNodePtr pNode;
+
+#ifdef XWIN_MULTIWINDOWINTWM
+ if(g_fAnotherWMRunning)/* Another Window manager exists. */
+ {
+ Sleep (1000);
+ continue;
+ }
+#endif
+
+ /* 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");
+
+ pthread_cleanup_pop(0);
+
+ 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;
+
+ pthread_cleanup_push(&winMultiWindowThreadExit, NULL);
+
+ 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");
+
+ /* Release the server started mutex */
+ pthread_mutex_unlock (pProcArg->ppmServerStarted);
+
+ winDebug ("winMultiWindowXMsgProc - pthread_mutex_unlock () returned.\n");
+
+ /* Install our error handler */
+ XSetErrorHandler (winMultiWindowXMsgProcErrorHandler);
+ g_winMultiWindowXMsgProcThread = pthread_self();
+ g_winMultiWindowXMsgProcOldIOErrorHandler = XSetIOErrorHandler (winMultiWindowXMsgProcIOErrorHandler);
+
+ /* 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);
+ }
+
+ /* Setup the display connection string x */
+ winGetDisplayName(pszDisplay, (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",
+ 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 */
+#ifdef XWIN_MULTIWINDOWINTWM
+ g_fAnotherWMRunning = CheckAnotherWindowManager (pProcArg->pDisplay, pProcArg->dwScreen, pProcArg->pWMInfo->fAllowOtherWM);
+#else
+ g_fAnotherWMRunning = CheckAnotherWindowManager (pProcArg->pDisplay, pProcArg->dwScreen, FALSE);
+#endif
+
+ if (g_fAnotherWMRunning
+#ifdef XWIN_MULTIWINDOWINTWM
+ && !pProcArg->pWMInfo->fAllowOtherWM
+#endif
+ )
+ {
+ 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;
+
+#ifdef XWIN_MULTIWINDOWINTWM
+ if (pProcArg->pWMInfo->fAllowOtherWM && !XPending (pProcArg->pDisplay))
+ {
+ if (CheckAnotherWindowManager (pProcArg->pDisplay, pProcArg->dwScreen, TRUE))
+ {
+ 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;
+ }
+#endif
+
+ /* 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;
+ event_send.xreparent.override_redirect = False;
+
+ XSendEvent(event.xmap.display,
+ event.xmap.window,
+ True, StructureNotifyMask,
+ &event_send);
+ }
+ }
+ }
+ else if (event.type == ConfigureNotify)
+ {
+ if (!event.xconfigure.send_event)
+ {
+ /*
+ Java applications using AWT on JRE 1.6.0 break with non-reparenting WMs AWT
+ doesn't explicitly know about (See sun bug #6434227)
+
+ XDecoratedPeer.handleConfigureNotifyEvent() only processes non-synthetic
+ ConfigureNotify events to update window location if it's identified the
+ WM as a non-reparenting WM it knows about (compiz or lookingglass)
+
+ Rather than tell all sorts of lies to get XWM to recognize us as one of
+ those, simply send a synthetic ConfigureNotify for every non-synthetic one
+ */
+ XEvent event_send = event;
+ event_send.xconfigure.send_event = TRUE;
+ event_send.xconfigure.event = event.xconfigure.window;
+ XSendEvent(event.xconfigure.display,
+ event.xconfigure.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_cleanup_pop(0);
+ 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;
+#ifdef XWIN_MULTIWINDOWINTWM
+ pWMInfo->fAllowOtherWM = allowOtherWM;
+#endif
+
+ /* 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");
+
+ /* Release the server started mutex */
+ pthread_mutex_unlock (pProcArg->ppmServerStarted);
+
+ winDebug ("winInitMultiWindowWM - pthread_mutex_unlock () returned.\n");
+
+ /* Install our error handler */
+ XSetErrorHandler (winMultiWindowWMErrorHandler);
+ g_winMultiWindowWMThread = pthread_self();
+ g_winMultiWindowWMOldIOErrorHandler = XSetIOErrorHandler (winMultiWindowWMIOErrorHandler);
+
+ /* 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);
+ }
+
+ /* Setup the display connection string x */
+ winGetDisplayName(pszDisplay, (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",
+ 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 ("winMultiWindowWMIOErrorHandler!\n\n");
+
+ if (pthread_equal(pthread_self(),g_winMultiWindowWMThread))
+ {
+ if (g_shutdown)
+ pthread_exit(NULL);
+
+ /* Restart at the main entry point */
+ longjmp (g_jmpWMEntry, WIN_JMP_ERROR_IO);
+ }
+
+ if (g_winMultiWindowWMOldIOErrorHandler)
+ g_winMultiWindowWMOldIOErrorHandler(pDisplay);
+
+ 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 ("winMultiWindowXMsgProcIOErrorHandler!\n\n");
+
+ if (pthread_equal(pthread_self(),g_winMultiWindowXMsgProcThread))
+ {
+ /* Restart at the main entry point */
+ longjmp (g_jmpXMsgProcEntry, WIN_JMP_ERROR_IO);
+ }
+
+ if (g_winMultiWindowXMsgProcOldIOErrorHandler)
+ g_winMultiWindowXMsgProcOldIOErrorHandler(pDisplay);
+
+ return 0;
+}
+
+/*
+ * winMultiWindowThreadExit - Thread exit handler
+ */
+
+static void
+winMultiWindowThreadExit(void *arg)
+{
+ AbortDDX(EXIT_ERR_ABORT);
+
+ /* multiwindow client thread has exited, stop server as well */
+ TerminateProcess(GetCurrentProcess(),1);
+}
+
+/*
+ * 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, Bool fAllowOtherWM)
+{
+ /*
+ 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...
+
+ If other WMs are not allowed, also select one of the events which only one client
+ at a time is allowed to select, so other window managers won't start...
+ */
+ XSelectInput(pDisplay, RootWindow (pDisplay, dwScreen),
+ SubstructureNotifyMask | ( !fAllowOtherWM ? ButtonPressMask : 0));
+ 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)
+#define HINT_NOMAXIMIZE (1L<<4)
+/* 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;
+ WinXSizeHints SizeHints;
+
+ 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);
+ }
+
+ {
+ XSizeHints *normal_hint = XAllocSizeHints();
+ long supplied;
+ if (normal_hint && (XGetWMNormalHints(pDisplay, iWindow, normal_hint, &supplied) == Success))
+ {
+ if (normal_hint->flags & PMaxSize)
+ {
+ /* Not maximizable if a maximum size is specified */
+ hint |= HINT_NOMAXIMIZE;
+
+ if (normal_hint->flags & PMinSize)
+ {
+ /*
+ If both minimum size and maximum size are specified and are the same,
+ don't bother with a resizing frame
+ */
+ if ((normal_hint->min_width == normal_hint->max_width)
+ && (normal_hint->min_height == normal_hint->max_height))
+ hint = (hint & ~HINT_SIZEBOX);
+ }
+ }
+ }
+ XFree(normal_hint);
+ }
+
+ /* Override hint settings from above with settings from config file */
+ {
+ XClassHint class_hint = {0,0};
+
+ if (XGetClassHint(pDisplay, iWindow, &class_hint))
+ {
+ char *window_name = 0;
+ XFetchName(pDisplay, iWindow, &window_name);
+
+ style = winOverrideStyle(class_hint.res_name, class_hint.res_class, window_name);
+
+ if (class_hint.res_name) XFree(class_hint.res_name);
+ if (class_hint.res_class) XFree(class_hint.res_class);
+ if (window_name) XFree(window_name);
+ }
+ else
+ {
+ style = STYLE_NONE;
+ }
+ }
+
+ 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_CAPTION) | HINT_BORDER;
+ else if (style & STYLE_NOFRAME)
+ hint = (hint & ~HINT_BORDER & ~HINT_CAPTION) | HINT_NOFRAME;
+
+ /* Now apply styles to window */
+ style = GetWindowLongPtr(hWnd, GWL_STYLE) & ~WS_CAPTION & ~WS_SIZEBOX; /* Just in case */
+ if (!hint) /* All on, but no resize of children is allowed */
+ style = style | WS_CAPTION;
+ else if (hint & HINT_NOFRAME) /* All off */
+ style = style & ~WS_CAPTION & ~WS_SIZEBOX;
+ else style = style | ((hint & HINT_BORDER) ? WS_BORDER : 0) |
+ ((hint & HINT_SIZEBOX) ? WS_SIZEBOX : 0) |
+ ((hint & HINT_CAPTION) ? WS_CAPTION : 0);
+
+ if (hint & HINT_NOMAXIMIZE)
+ style = style & ~WS_MAXIMIZEBOX;
+
+ if (!IsWindow (hWnd))
+ {
+ ErrorF("Windows window 0x%x has become invalid, so returning without applying hints\n",hWnd);
+ return;
+ }
+
+ if (winMultiWindowGetWMNormalHints(pWin, &SizeHints))
+ {
+ if (!(SizeHints.max_width&&SizeHints.max_height&&(SizeHints.min_width == SizeHints.max_width)&&(SizeHints.min_height == SizeHints.max_height) ))
+ style|=WS_SIZEBOX;
+ }
+ else
+ style|=WS_SIZEBOX;
+ 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/winpfbdd.c b/xorg-server/hw/xwin/winpfbdd.c
index 02f6ffc1f..a8ea9fb90 100644
--- a/xorg-server/hw/xwin/winpfbdd.c
+++ b/xorg-server/hw/xwin/winpfbdd.c
@@ -1,675 +1,675 @@
-/*
- *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 function prototypes
- */
-
-static Bool
-winAllocateFBPrimaryDD (ScreenPtr pScreen);
-
-static Bool
-winCloseScreenPrimaryDD (int nIndex, ScreenPtr pScreen);
-
-static Bool
-winInitVisualsPrimaryDD (ScreenPtr pScreen);
-
-static Bool
-winAdjustVideoModePrimaryDD (ScreenPtr pScreen);
-
-static Bool
-winActivateAppPrimaryDD (ScreenPtr pScreen);
-
-static Bool
-winHotKeyAltTabPrimaryDD (ScreenPtr pScreen);
-
-
-/*
- * Create a DirectDraw primary surface
- */
-
-static Bool
-winAllocateFBPrimaryDD (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- HRESULT ddrval = DD_OK;
- DDSURFACEDESC ddsd;
- DDSURFACEDESC *pddsdPrimary = NULL;
- DDSURFACEDESC *pddsdOffscreen = NULL;
- RECT rcClient;
-
- winDebug ("winAllocateFBPrimaryDD\n");
-
- /* Get client area location in screen coords */
- GetClientRect (pScreenPriv->hwndScreen, &rcClient);
- MapWindowPoints (pScreenPriv->hwndScreen,
- HWND_DESKTOP,
- (LPPOINT)&rcClient, 2);
-
- /* Create a DirectDraw object, store the address at lpdd */
- ddrval = (*g_fpDirectDrawCreate) (NULL, &pScreenPriv->pdd, NULL);
- if (ddrval != DD_OK)
- FatalError ("winAllocateFBPrimaryDD - Could not start DirectDraw\n");
-
- /* Get a DirectDraw2 interface pointer */
- ddrval = IDirectDraw_QueryInterface (pScreenPriv->pdd,
- &IID_IDirectDraw2,
- (LPVOID*) &pScreenPriv->pdd2);
- if (FAILED (ddrval))
- {
- ErrorF ("winAllocateFBShadowDD - Failed DD2 query: %08x\n",
- (unsigned int) ddrval);
- return FALSE;
- }
-
-
- winDebug ("winAllocateFBPrimaryDD - Created and initialized DD\n");
-
- /* Are we windowed or fullscreen? */
- if (pScreenInfo->fFullScreen)
- {
- /* Full screen mode */
- ddrval = IDirectDraw2_SetCooperativeLevel (pScreenPriv->pdd2,
- pScreenPriv->hwndScreen,
- DDSCL_FULLSCREEN
- | DDSCL_EXCLUSIVE);
- if (FAILED (ddrval))
- FatalError ("winAllocateFBPrimaryDD - Could not set "
- "cooperative level\n");
-
- /* Change the video mode to the mode requested */
- ddrval = IDirectDraw2_SetDisplayMode (pScreenPriv->pdd2,
- pScreenInfo->dwWidth,
- pScreenInfo->dwHeight,
- pScreenInfo->dwBPP,
- pScreenInfo->dwRefreshRate,
- 0);
- if (FAILED (ddrval))
- FatalError ("winAllocateFBPrimaryDD - Could not set "
- "full screen display mode\n");
- }
- else
- {
- /* Windowed mode */
- ddrval = IDirectDraw2_SetCooperativeLevel (pScreenPriv->pdd2,
- pScreenPriv->hwndScreen,
- DDSCL_NORMAL);
- if (FAILED (ddrval))
- FatalError ("winAllocateFBPrimaryDD - Could not set "
- "cooperative level\n");
- }
-
- /* Describe the primary surface */
- ZeroMemory (&ddsd, sizeof (ddsd));
- ddsd.dwSize = sizeof (ddsd);
- ddsd.dwFlags = DDSD_CAPS;
- ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
-
- /* Create the primary surface */
- ddrval = IDirectDraw2_CreateSurface (pScreenPriv->pdd2,
- &ddsd,
- &pScreenPriv->pddsPrimary,
- NULL);
- if (FAILED (ddrval))
- FatalError ("winAllocateFBPrimaryDD - Could not create primary "
- "surface %08x\n", (unsigned int) ddrval);
-
- winDebug ("winAllocateFBPrimaryDD - Created primary\n");
-
- /* Allocate a DD surface description for our screen privates */
- pddsdPrimary = pScreenPriv->pddsdPrimary
- = malloc (sizeof (DDSURFACEDESC));
- if (pddsdPrimary == NULL)
- FatalError ("winAllocateFBPrimaryDD - Could not allocate surface "
- "description memory\n");
- ZeroMemory (pddsdPrimary, sizeof (*pddsdPrimary));
- pddsdPrimary->dwSize = sizeof (*pddsdPrimary);
-
- /* Describe the offscreen surface to be created */
- /*
- * NOTE: Do not use a DDSCAPS_VIDEOMEMORY surface,
- * as drawing, locking, and unlocking take forever
- * with video memory surfaces. In addition,
- * video memory is a somewhat scarce resource,
- * so you shouldn't be allocating video memory when
- * you have the option of using system memory instead.
- */
- ZeroMemory (&ddsd, sizeof (ddsd));
- ddsd.dwSize = sizeof (ddsd);
- ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
- ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
- ddsd.dwHeight = pScreenInfo->dwHeight;
- ddsd.dwWidth = pScreenInfo->dwWidth;
-
- /* Create the shadow surface */
- ddrval = IDirectDraw2_CreateSurface (pScreenPriv->pdd2,
- &ddsd,
- &pScreenPriv->pddsOffscreen,
- NULL);
- if (ddrval != DD_OK)
- FatalError ("winAllocateFBPrimaryDD - Could not create shadow "
- "surface\n");
-
- winDebug ("winAllocateFBPrimaryDD - Created offscreen\n");
-
- /* Allocate a DD surface description for our screen privates */
- pddsdOffscreen = pScreenPriv->pddsdOffscreen
- = malloc (sizeof (DDSURFACEDESC));
- if (pddsdOffscreen == NULL)
- FatalError ("winAllocateFBPrimaryDD - Could not allocate surface "
- "description memory\n");
- ZeroMemory (pddsdOffscreen, sizeof (*pddsdOffscreen));
- pddsdOffscreen->dwSize = sizeof (*pddsdOffscreen);
-
- winDebug ("winAllocateFBPrimaryDD - Locking primary\n");
-
- /* Lock the primary surface */
- ddrval = IDirectDrawSurface2_Lock (pScreenPriv->pddsPrimary,
- pScreenInfo->fFullScreen ? NULL:&rcClient,
- pddsdPrimary,
- DDLOCK_WAIT,
- NULL);
- if (ddrval != DD_OK || pddsdPrimary->lpSurface == NULL)
- FatalError ("winAllocateFBPrimaryDD - Could not lock "
- "primary surface\n");
-
- winDebug ("winAllocateFBPrimaryDD - Locked primary\n");
-
- /* We don't know how to deal with anything other than RGB */
- if (!(pddsdPrimary->ddpfPixelFormat.dwFlags & DDPF_RGB))
- FatalError ("winAllocateFBPrimaryDD - Color format other than RGB\n");
-
- /* Grab the pitch from the surface desc */
- pScreenInfo->dwStride = (pddsdPrimary->u1.lPitch * 8)
- / pScreenInfo->dwBPP;
-
- /* Save the pointer to our surface memory */
- pScreenInfo->pfb = pddsdPrimary->lpSurface;
-
- /* Grab the color depth and masks from the surface description */
- pScreenPriv->dwRedMask = pddsdPrimary->ddpfPixelFormat.u2.dwRBitMask;
- pScreenPriv->dwGreenMask = pddsdPrimary->ddpfPixelFormat.u3.dwGBitMask;
- pScreenPriv->dwBlueMask = pddsdPrimary->ddpfPixelFormat.u4.dwBBitMask;
-
- winDebug ("winAllocateFBPrimaryDD - Returning\n");
-
- return TRUE;
-}
-
-static void
-winFreeFBPrimaryDD (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-
- /* Free the offscreen surface, if there is one */
- if (pScreenPriv->pddsOffscreen)
- {
- IDirectDrawSurface2_Unlock (pScreenPriv->pddsOffscreen, NULL);
- IDirectDrawSurface2_Release (pScreenPriv->pddsOffscreen);
- pScreenPriv->pddsOffscreen = NULL;
- }
-
- /* Release the primary surface, if there is one */
- if (pScreenPriv->pddsPrimary)
- {
- IDirectDrawSurface2_Unlock (pScreenPriv->pddsPrimary, NULL);
- IDirectDrawSurface2_Release (pScreenPriv->pddsPrimary);
- pScreenPriv->pddsPrimary = NULL;
- }
-
- /* Free the DirectDraw object, if there is one */
- if (pScreenPriv->pdd)
- {
- IDirectDraw2_RestoreDisplayMode (pScreenPriv->pdd);
- IDirectDraw2_Release (pScreenPriv->pdd);
- pScreenPriv->pdd = NULL;
- }
-
- /* Invalidate the ScreenInfo's fb pointer */
- pScreenInfo->pfb = NULL;
-}
-
-static Bool
-winInitScreenPrimaryDD(ScreenPtr pScreen)
-{
- return winAllocateFBPrimaryDD(pScreen);
-}
-
-/*
- * Call the wrapped CloseScreen function.
- *
- * Free our resources and private structures.
- */
-
-static Bool
-winCloseScreenPrimaryDD (int nIndex, ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- Bool fReturn;
-
- ErrorF ("winCloseScreenPrimaryDD - Freeing screen resources\n");
-
- /* Flag that the screen is closed */
- pScreenPriv->fClosed = TRUE;
- pScreenPriv->fActive = FALSE;
-
- /* Call the wrapped CloseScreen procedure */
- WIN_UNWRAP(CloseScreen);
- if (pScreen->CloseScreen)
- fReturn = (*pScreen->CloseScreen) (nIndex, pScreen);
-
- /* Delete the window property */
- RemoveProp (pScreenPriv->hwndScreen, WIN_SCR_PROP);
-
- winFreeFBPrimaryDD(pScreen);
-
- /* Delete tray icon, if we have one */
- if (!pScreenInfo->fNoTrayIcon)
- winDeleteNotifyIcon (pScreenPriv);
-
- /* Free the exit confirmation dialog box, if it exists */
- if (g_hDlgExit != NULL)
- {
- DestroyWindow (g_hDlgExit);
- g_hDlgExit = NULL;
- }
-
- /* Kill our window */
- if (pScreenPriv->hwndScreen)
- {
- DestroyWindow (pScreenPriv->hwndScreen);
- pScreenPriv->hwndScreen = NULL;
- }
-
- /* Kill our screeninfo's pointer to the screen */
- pScreenInfo->pScreen = NULL;
-
- /* Free the screen privates for this screen */
- free ((pointer) pScreenPriv);
-
- return fReturn;
-}
-
-
-/*
- * Tell mi what sort of visuals we need.
- *
- * Generally we only need one visual, as our screen can only
- * handle one format at a time, I believe. You may want
- * to verify that last sentence.
- */
-
-static Bool
-winInitVisualsPrimaryDD (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- DWORD dwRedBits, dwGreenBits, dwBlueBits;
-
- /* Count the number of ones in each color mask */
- dwRedBits = winCountBits (pScreenPriv->dwRedMask);
- dwGreenBits = winCountBits (pScreenPriv->dwGreenMask);
- dwBlueBits = winCountBits (pScreenPriv->dwBlueMask);
-
- /* Store the maximum number of ones in a color mask as the bitsPerRGB */
- if (dwRedBits > dwGreenBits && dwRedBits > dwBlueBits)
- pScreenPriv->dwBitsPerRGB = dwRedBits;
- else if (dwGreenBits > dwRedBits && dwGreenBits > dwBlueBits)
- pScreenPriv->dwBitsPerRGB = dwGreenBits;
- else
- pScreenPriv->dwBitsPerRGB = dwBlueBits;
-
- winDebug ("winInitVisualsPrimaryDD - Masks: %08x %08x %08x bpRGB: %d\n",
- (unsigned int) pScreenPriv->dwRedMask,
- (unsigned int) pScreenPriv->dwGreenMask,
- (unsigned int) pScreenPriv->dwBlueMask,
- (int) pScreenPriv->dwBitsPerRGB);
-
- /* Create a single visual according to the Windows screen depth */
- switch (pScreenInfo->dwDepth)
- {
- case 24:
- case 16:
- case 15:
- if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
- TrueColorMask,
- pScreenPriv->dwBitsPerRGB,
- TrueColor,
- pScreenPriv->dwRedMask,
- pScreenPriv->dwGreenMask,
- pScreenPriv->dwBlueMask))
- {
- ErrorF ("winInitVisualsPrimaryDD - "
- "miSetVisualTypesAndMasks failed\n");
- return FALSE;
- }
- break;
-
- case 8:
- winDebug ("winInitVisuals - Calling miSetVisualTypesAndMasks\n");
- if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
- PseudoColorMask,
- pScreenPriv->dwBitsPerRGB,
- PseudoColor,
- pScreenPriv->dwRedMask,
- pScreenPriv->dwGreenMask,
- pScreenPriv->dwBlueMask))
- {
- ErrorF ("winInitVisualsPrimaryDD - "
- "miSetVisualTypesAndMasks failed\n");
- return FALSE;
- }
- winDebug ("winInitVisualsPrimaryDD - Returned from "
- "miSetVisualTypesAndMasks\n");
- break;
-
- default:
- ErrorF ("winInitVisualsPrimaryDD - Unknown screen depth\n");
- return FALSE;
- }
-
- winDebug ("winInitVisualsPrimaryDD - Returning\n");
-
- return TRUE;
-}
-
-
-static Bool
-winAdjustVideoModePrimaryDD (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- HDC hdc = NULL;
- DWORD dwBPP;
-
- /* We're in serious trouble if we can't get a DC */
- hdc = GetDC (NULL);
- if (hdc == NULL)
- {
- ErrorF ("winAdjustVideoModePrimaryDD - GetDC failed\n");
- return FALSE;
- }
-
- /* Query GDI for current display depth */
- dwBPP = GetDeviceCaps (hdc, BITSPIXEL);
-
- /* DirectDraw can only change the depth in fullscreen mode */
- if (!(pScreenInfo->fFullScreen &&
- (pScreenInfo->dwBPP != WIN_DEFAULT_BPP)))
- {
- /* Otherwise, We'll use GDI's depth */
- pScreenInfo->dwBPP = dwBPP;
- }
-
- /* Release our DC */
- ReleaseDC (NULL, hdc);
-
- return TRUE;
-}
-
-
-/*
- * We need to blit our offscreen fb to
- * the screen when we are activated, and we need to point
- * the fb code back to the primary surface memory.
- */
-
-static Bool
-winActivateAppPrimaryDD (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- RECT rcSrc, rcClient;
- HRESULT ddrval = DD_OK;
-
- /* Check for errors */
- if (pScreenPriv == NULL
- || pScreenPriv->pddsPrimary == NULL
- || pScreenPriv->pddsOffscreen == NULL)
- return FALSE;
-
- /* Check for do-nothing */
- if (!pScreenPriv->fActive)
- return TRUE;
-
- /* We are activating */
- ddrval = IDirectDrawSurface2_IsLost (pScreenPriv->pddsOffscreen);
- if (ddrval == DD_OK)
- {
- IDirectDrawSurface2_Unlock (pScreenPriv->pddsOffscreen,
- NULL);
- /*
- * We don't check for an error from Unlock, because it
- * doesn't matter if the Unlock failed.
- */
- }
-
- /* Restore both surfaces, just cause I like it that way */
- IDirectDrawSurface2_Restore (pScreenPriv->pddsOffscreen);
- IDirectDrawSurface2_Restore (pScreenPriv->pddsPrimary);
-
- /* Get client area in screen coords */
- GetClientRect (pScreenPriv->hwndScreen, &rcClient);
- MapWindowPoints (pScreenPriv->hwndScreen,
- HWND_DESKTOP,
- (LPPOINT)&rcClient, 2);
-
- /* Setup a source rectangle */
- rcSrc.left = 0;
- rcSrc.top = 0;
- rcSrc.right = pScreenInfo->dwWidth;
- rcSrc.bottom = pScreenInfo->dwHeight;
-
- ddrval = IDirectDrawSurface2_Blt (pScreenPriv->pddsPrimary,
- &rcClient,
- pScreenPriv->pddsOffscreen,
- &rcSrc,
- DDBLT_WAIT,
- NULL);
- if (ddrval != DD_OK)
- FatalError ("winActivateAppPrimaryDD () - Failed blitting offscreen "
- "surface to primary surface %08x\n", (unsigned int) ddrval);
-
- /* Lock the primary surface */
- ddrval = IDirectDrawSurface2_Lock (pScreenPriv->pddsPrimary,
- &rcClient,
- pScreenPriv->pddsdPrimary,
- DDLOCK_WAIT,
- NULL);
- if (ddrval != DD_OK
- || pScreenPriv->pddsdPrimary->lpSurface == NULL)
- FatalError ("winActivateAppPrimaryDD () - Could not lock "
- "primary surface\n");
-
- /* Notify FB of the new memory pointer */
- winUpdateFBPointer (pScreen,
- pScreenPriv->pddsdPrimary->lpSurface);
-
- /*
- * Register the Alt-Tab combo as a hotkey so we can copy
- * the primary framebuffer before the display mode changes
- */
- RegisterHotKey (pScreenPriv->hwndScreen, 1, MOD_ALT, 9);
-
- return TRUE;
-}
-
-
-/*
- * Handle the Alt+Tab hotkey.
- *
- * We need to save the primary fb to an offscreen fb when
- * we get deactivated, and point the fb code at the offscreen
- * fb for the duration of the deactivation.
- */
-
-static Bool
-winHotKeyAltTabPrimaryDD (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- RECT rcClient, rcSrc;
- HRESULT ddrval = DD_OK;
-
- winDebug ("\nwinHotKeyAltTabPrimaryDD\n\n");
-
- /* Alt+Tab was pressed, we will lose focus very soon */
- pScreenPriv->fActive = FALSE;
-
- /* Check for error conditions */
- if (pScreenPriv->pddsPrimary == NULL
- || pScreenPriv->pddsOffscreen == NULL)
- return FALSE;
-
- /* Get client area in screen coords */
- GetClientRect (pScreenPriv->hwndScreen, &rcClient);
- MapWindowPoints (pScreenPriv->hwndScreen,
- HWND_DESKTOP,
- (LPPOINT)&rcClient, 2);
-
- /* Did we loose the primary surface? */
- ddrval = IDirectDrawSurface2_IsLost (pScreenPriv->pddsPrimary);
- if (ddrval == DD_OK)
- {
- ddrval = IDirectDrawSurface2_Unlock (pScreenPriv->pddsPrimary,
- NULL);
- if (FAILED (ddrval))
- FatalError ("winHotKeyAltTabPrimaryDD - Failed unlocking primary "
- "surface\n");
- }
-
- /* Setup a source rectangle */
- rcSrc.left = 0;
- rcSrc.top = 0;
- rcSrc.right = pScreenInfo->dwWidth;
- rcSrc.bottom = pScreenInfo->dwHeight;
-
- /* Blit the primary surface to the offscreen surface */
- ddrval = IDirectDrawSurface2_Blt (pScreenPriv->pddsOffscreen,
- NULL, /* should be rcDest */
- pScreenPriv->pddsPrimary,
- NULL,
- DDBLT_WAIT,
- NULL);
- if (ddrval == DDERR_SURFACELOST)
- {
- IDirectDrawSurface2_Restore (pScreenPriv->pddsOffscreen);
- IDirectDrawSurface2_Restore (pScreenPriv->pddsPrimary);
-
- /* Blit the primary surface to the offscreen surface */
- ddrval = IDirectDrawSurface2_Blt (pScreenPriv->pddsOffscreen,
- NULL,
- pScreenPriv->pddsPrimary,
- NULL,
- DDBLT_WAIT,
- NULL);
- if (FAILED (ddrval))
- FatalError ("winHotKeyAltTabPrimaryDD - Failed blitting primary "
- "surface to offscreen surface: %08x\n",
- (unsigned int) ddrval);
- }
- else
- {
- FatalError ("winHotKeyAltTabPrimaryDD - Unknown error from "
- "Blt: %08dx\n", (unsigned int) ddrval);
- }
-
- /* Lock the offscreen surface */
- ddrval = IDirectDrawSurface2_Lock (pScreenPriv->pddsOffscreen,
- NULL,
- pScreenPriv->pddsdOffscreen,
- DDLOCK_WAIT,
- NULL);
- if (ddrval != DD_OK
- || pScreenPriv->pddsdPrimary->lpSurface == NULL)
- FatalError ("winHotKeyAltTabPrimaryDD - Could not lock "
- "offscreen surface\n");
-
- /* Notify FB of the new memory pointer */
- winUpdateFBPointer (pScreen,
- pScreenPriv->pddsdOffscreen->lpSurface);
-
- /* Unregister our hotkey */
- UnregisterHotKey (pScreenPriv->hwndScreen, 1);
-
- return TRUE;
-}
-
-
-/* Set engine specific functions */
-Bool
-winSetEngineFunctionsPrimaryDD (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-
- /* Set our pointers */
- pScreenPriv->pwinAllocateFB = winAllocateFBPrimaryDD;
- pScreenPriv->pwinFreeFB = winFreeFBPrimaryDD;
- pScreenPriv->pwinShadowUpdate = (winShadowUpdateProcPtr) (void (*)(void))NoopDDA;
- pScreenPriv->pwinInitScreen = winInitScreenPrimaryDD;
- pScreenPriv->pwinCloseScreen = winCloseScreenPrimaryDD;
- pScreenPriv->pwinInitVisuals = winInitVisualsPrimaryDD;
- pScreenPriv->pwinAdjustVideoMode = winAdjustVideoModePrimaryDD;
- if (pScreenInfo->fFullScreen)
- pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowFullScreen;
- else
- pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowWindowed;
- pScreenPriv->pwinFinishScreenInit = winFinishScreenInitFB;
- pScreenPriv->pwinBltExposedRegions = (winBltExposedRegionsProcPtr) (void (*)(void))NoopDDA;
- pScreenPriv->pwinActivateApp = winActivateAppPrimaryDD;
- pScreenPriv->pwinRedrawScreen = NULL;
- pScreenPriv->pwinRealizeInstalledPalette = NULL;
- pScreenPriv->pwinInstallColormap = NULL;
- pScreenPriv->pwinStoreColors = NULL;
- pScreenPriv->pwinCreateColormap = NULL;
- pScreenPriv->pwinDestroyColormap = NULL;
- pScreenPriv->pwinHotKeyAltTab = winHotKeyAltTabPrimaryDD;
- pScreenPriv->pwinCreatePrimarySurface = (winCreatePrimarySurfaceProcPtr) (void (*)(void))NoopDDA;
- pScreenPriv->pwinReleasePrimarySurface = (winReleasePrimarySurfaceProcPtr) (void (*)(void))NoopDDA;
-#ifdef XWIN_MULTIWINDOW
- pScreenPriv->pwinFinishCreateWindowsWindow =
- (winFinishCreateWindowsWindowProcPtr) (void (*)(void))NoopDDA;
-#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 function prototypes
+ */
+
+static Bool
+winAllocateFBPrimaryDD (ScreenPtr pScreen);
+
+static Bool
+winCloseScreenPrimaryDD (int nIndex, ScreenPtr pScreen);
+
+static Bool
+winInitVisualsPrimaryDD (ScreenPtr pScreen);
+
+static Bool
+winAdjustVideoModePrimaryDD (ScreenPtr pScreen);
+
+static Bool
+winActivateAppPrimaryDD (ScreenPtr pScreen);
+
+static Bool
+winHotKeyAltTabPrimaryDD (ScreenPtr pScreen);
+
+
+/*
+ * Create a DirectDraw primary surface
+ */
+
+static Bool
+winAllocateFBPrimaryDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ HRESULT ddrval = DD_OK;
+ DDSURFACEDESC ddsd;
+ DDSURFACEDESC *pddsdPrimary = NULL;
+ DDSURFACEDESC *pddsdOffscreen = NULL;
+ RECT rcClient;
+
+ winDebug ("winAllocateFBPrimaryDD\n");
+
+ /* Get client area location in screen coords */
+ GetClientRect (pScreenPriv->hwndScreen, &rcClient);
+ MapWindowPoints (pScreenPriv->hwndScreen,
+ HWND_DESKTOP,
+ (LPPOINT)&rcClient, 2);
+
+ /* Create a DirectDraw object, store the address at lpdd */
+ ddrval = (*g_fpDirectDrawCreate) (NULL, &pScreenPriv->pdd, NULL);
+ if (ddrval != DD_OK)
+ FatalError ("winAllocateFBPrimaryDD - Could not start DirectDraw\n");
+
+ /* Get a DirectDraw2 interface pointer */
+ ddrval = IDirectDraw_QueryInterface (pScreenPriv->pdd,
+ &IID_IDirectDraw2,
+ (LPVOID*) &pScreenPriv->pdd2);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDD - Failed DD2 query: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+
+
+ winDebug ("winAllocateFBPrimaryDD - Created and initialized DD\n");
+
+ /* Are we windowed or fullscreen? */
+ if (pScreenInfo->fFullScreen)
+ {
+ /* Full screen mode */
+ ddrval = IDirectDraw2_SetCooperativeLevel (pScreenPriv->pdd2,
+ pScreenPriv->hwndScreen,
+ DDSCL_FULLSCREEN
+ | DDSCL_EXCLUSIVE);
+ if (FAILED (ddrval))
+ FatalError ("winAllocateFBPrimaryDD - Could not set "
+ "cooperative level\n");
+
+ /* Change the video mode to the mode requested */
+ ddrval = IDirectDraw2_SetDisplayMode (pScreenPriv->pdd2,
+ pScreenInfo->dwWidth,
+ pScreenInfo->dwHeight,
+ pScreenInfo->dwBPP,
+ pScreenInfo->dwRefreshRate,
+ 0);
+ if (FAILED (ddrval))
+ FatalError ("winAllocateFBPrimaryDD - Could not set "
+ "full screen display mode\n");
+ }
+ else
+ {
+ /* Windowed mode */
+ ddrval = IDirectDraw2_SetCooperativeLevel (pScreenPriv->pdd2,
+ pScreenPriv->hwndScreen,
+ DDSCL_NORMAL);
+ if (FAILED (ddrval))
+ FatalError ("winAllocateFBPrimaryDD - Could not set "
+ "cooperative level\n");
+ }
+
+ /* Describe the primary surface */
+ ZeroMemory (&ddsd, sizeof (ddsd));
+ ddsd.dwSize = sizeof (ddsd);
+ ddsd.dwFlags = DDSD_CAPS;
+ ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
+
+ /* Create the primary surface */
+ ddrval = IDirectDraw2_CreateSurface (pScreenPriv->pdd2,
+ &ddsd,
+ &pScreenPriv->pddsPrimary,
+ NULL);
+ if (FAILED (ddrval))
+ FatalError ("winAllocateFBPrimaryDD - Could not create primary "
+ "surface %08x\n", (unsigned int) ddrval);
+
+ winDebug ("winAllocateFBPrimaryDD - Created primary\n");
+
+ /* Allocate a DD surface description for our screen privates */
+ pddsdPrimary = pScreenPriv->pddsdPrimary
+ = malloc (sizeof (DDSURFACEDESC));
+ if (pddsdPrimary == NULL)
+ FatalError ("winAllocateFBPrimaryDD - Could not allocate surface "
+ "description memory\n");
+ ZeroMemory (pddsdPrimary, sizeof (*pddsdPrimary));
+ pddsdPrimary->dwSize = sizeof (*pddsdPrimary);
+
+ /* Describe the offscreen surface to be created */
+ /*
+ * NOTE: Do not use a DDSCAPS_VIDEOMEMORY surface,
+ * as drawing, locking, and unlocking take forever
+ * with video memory surfaces. In addition,
+ * video memory is a somewhat scarce resource,
+ * so you shouldn't be allocating video memory when
+ * you have the option of using system memory instead.
+ */
+ ZeroMemory (&ddsd, sizeof (ddsd));
+ ddsd.dwSize = sizeof (ddsd);
+ ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
+ ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
+ ddsd.dwHeight = pScreenInfo->dwHeight;
+ ddsd.dwWidth = pScreenInfo->dwWidth;
+
+ /* Create the shadow surface */
+ ddrval = IDirectDraw2_CreateSurface (pScreenPriv->pdd2,
+ &ddsd,
+ &pScreenPriv->pddsOffscreen,
+ NULL);
+ if (ddrval != DD_OK)
+ FatalError ("winAllocateFBPrimaryDD - Could not create shadow "
+ "surface\n");
+
+ winDebug ("winAllocateFBPrimaryDD - Created offscreen\n");
+
+ /* Allocate a DD surface description for our screen privates */
+ pddsdOffscreen = pScreenPriv->pddsdOffscreen
+ = malloc (sizeof (DDSURFACEDESC));
+ if (pddsdOffscreen == NULL)
+ FatalError ("winAllocateFBPrimaryDD - Could not allocate surface "
+ "description memory\n");
+ ZeroMemory (pddsdOffscreen, sizeof (*pddsdOffscreen));
+ pddsdOffscreen->dwSize = sizeof (*pddsdOffscreen);
+
+ winDebug ("winAllocateFBPrimaryDD - Locking primary\n");
+
+ /* Lock the primary surface */
+ ddrval = IDirectDrawSurface2_Lock (pScreenPriv->pddsPrimary,
+ pScreenInfo->fFullScreen ? NULL:&rcClient,
+ pddsdPrimary,
+ DDLOCK_WAIT,
+ NULL);
+ if (ddrval != DD_OK || pddsdPrimary->lpSurface == NULL)
+ FatalError ("winAllocateFBPrimaryDD - Could not lock "
+ "primary surface\n");
+
+ winDebug ("winAllocateFBPrimaryDD - Locked primary\n");
+
+ /* We don't know how to deal with anything other than RGB */
+ if (!(pddsdPrimary->ddpfPixelFormat.dwFlags & DDPF_RGB))
+ FatalError ("winAllocateFBPrimaryDD - Color format other than RGB\n");
+
+ /* Grab the pitch from the surface desc */
+ pScreenInfo->dwStride = (pddsdPrimary->u1.lPitch * 8)
+ / pScreenInfo->dwBPP;
+
+ /* Save the pointer to our surface memory */
+ pScreenInfo->pfb = pddsdPrimary->lpSurface;
+
+ /* Grab the color depth and masks from the surface description */
+ pScreenPriv->dwRedMask = pddsdPrimary->ddpfPixelFormat.u2.dwRBitMask;
+ pScreenPriv->dwGreenMask = pddsdPrimary->ddpfPixelFormat.u3.dwGBitMask;
+ pScreenPriv->dwBlueMask = pddsdPrimary->ddpfPixelFormat.u4.dwBBitMask;
+
+ winDebug ("winAllocateFBPrimaryDD - Returning\n");
+
+ return TRUE;
+}
+
+static void
+winFreeFBPrimaryDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /* Free the offscreen surface, if there is one */
+ if (pScreenPriv->pddsOffscreen)
+ {
+ IDirectDrawSurface2_Unlock (pScreenPriv->pddsOffscreen, NULL);
+ IDirectDrawSurface2_Release (pScreenPriv->pddsOffscreen);
+ pScreenPriv->pddsOffscreen = NULL;
+ }
+
+ /* Release the primary surface, if there is one */
+ if (pScreenPriv->pddsPrimary)
+ {
+ IDirectDrawSurface2_Unlock (pScreenPriv->pddsPrimary, NULL);
+ IDirectDrawSurface2_Release (pScreenPriv->pddsPrimary);
+ pScreenPriv->pddsPrimary = NULL;
+ }
+
+ /* Free the DirectDraw object, if there is one */
+ if (pScreenPriv->pdd)
+ {
+ IDirectDraw2_RestoreDisplayMode (pScreenPriv->pdd);
+ IDirectDraw2_Release (pScreenPriv->pdd);
+ pScreenPriv->pdd = NULL;
+ }
+
+ /* Invalidate the ScreenInfo's fb pointer */
+ pScreenInfo->pfb = NULL;
+}
+
+static Bool
+winInitScreenPrimaryDD(ScreenPtr pScreen)
+{
+ return winAllocateFBPrimaryDD(pScreen);
+}
+
+/*
+ * Call the wrapped CloseScreen function.
+ *
+ * Free our resources and private structures.
+ */
+
+static Bool
+winCloseScreenPrimaryDD (int nIndex, ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ Bool fReturn;
+
+ ErrorF ("winCloseScreenPrimaryDD - Freeing screen resources\n");
+
+ /* Flag that the screen is closed */
+ pScreenPriv->fClosed = TRUE;
+ pScreenPriv->fActive = FALSE;
+
+ /* Call the wrapped CloseScreen procedure */
+ WIN_UNWRAP(CloseScreen);
+ if (pScreen->CloseScreen)
+ fReturn = (*pScreen->CloseScreen) (nIndex, pScreen);
+
+ /* Delete the window property */
+ RemoveProp (pScreenPriv->hwndScreen, WIN_SCR_PROP);
+
+ winFreeFBPrimaryDD(pScreen);
+
+ /* Delete tray icon, if we have one */
+ if (!pScreenInfo->fNoTrayIcon)
+ winDeleteNotifyIcon (pScreenPriv);
+
+ /* Free the exit confirmation dialog box, if it exists */
+ if (g_hDlgExit != NULL)
+ {
+ DestroyWindow (g_hDlgExit);
+ g_hDlgExit = NULL;
+ }
+
+ /* Kill our window */
+ if (pScreenPriv->hwndScreen)
+ {
+ DestroyWindow (pScreenPriv->hwndScreen);
+ pScreenPriv->hwndScreen = NULL;
+ }
+
+ /* Kill our screeninfo's pointer to the screen */
+ pScreenInfo->pScreen = NULL;
+
+ /* Free the screen privates for this screen */
+ free ((pointer) pScreenPriv);
+
+ return fReturn;
+}
+
+
+/*
+ * Tell mi what sort of visuals we need.
+ *
+ * Generally we only need one visual, as our screen can only
+ * handle one format at a time, I believe. You may want
+ * to verify that last sentence.
+ */
+
+static Bool
+winInitVisualsPrimaryDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ DWORD dwRedBits, dwGreenBits, dwBlueBits;
+
+ /* Count the number of ones in each color mask */
+ dwRedBits = winCountBits (pScreenPriv->dwRedMask);
+ dwGreenBits = winCountBits (pScreenPriv->dwGreenMask);
+ dwBlueBits = winCountBits (pScreenPriv->dwBlueMask);
+
+ /* Store the maximum number of ones in a color mask as the bitsPerRGB */
+ if (dwRedBits > dwGreenBits && dwRedBits > dwBlueBits)
+ pScreenPriv->dwBitsPerRGB = dwRedBits;
+ else if (dwGreenBits > dwRedBits && dwGreenBits > dwBlueBits)
+ pScreenPriv->dwBitsPerRGB = dwGreenBits;
+ else
+ pScreenPriv->dwBitsPerRGB = dwBlueBits;
+
+ winDebug ("winInitVisualsPrimaryDD - Masks: %08x %08x %08x bpRGB: %d\n",
+ (unsigned int) pScreenPriv->dwRedMask,
+ (unsigned int) pScreenPriv->dwGreenMask,
+ (unsigned int) pScreenPriv->dwBlueMask,
+ (int) pScreenPriv->dwBitsPerRGB);
+
+ /* Create a single visual according to the Windows screen depth */
+ switch (pScreenInfo->dwDepth)
+ {
+ case 24:
+ case 16:
+ case 15:
+ if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
+ TrueColorMask,
+ pScreenPriv->dwBitsPerRGB,
+ TrueColor,
+ pScreenPriv->dwRedMask,
+ pScreenPriv->dwGreenMask,
+ pScreenPriv->dwBlueMask))
+ {
+ ErrorF ("winInitVisualsPrimaryDD - "
+ "miSetVisualTypesAndMasks failed\n");
+ return FALSE;
+ }
+ break;
+
+ case 8:
+ winDebug ("winInitVisuals - Calling miSetVisualTypesAndMasks\n");
+ if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
+ PseudoColorMask,
+ pScreenPriv->dwBitsPerRGB,
+ PseudoColor,
+ pScreenPriv->dwRedMask,
+ pScreenPriv->dwGreenMask,
+ pScreenPriv->dwBlueMask))
+ {
+ ErrorF ("winInitVisualsPrimaryDD - "
+ "miSetVisualTypesAndMasks failed\n");
+ return FALSE;
+ }
+ winDebug ("winInitVisualsPrimaryDD - Returned from "
+ "miSetVisualTypesAndMasks\n");
+ break;
+
+ default:
+ ErrorF ("winInitVisualsPrimaryDD - Unknown screen depth\n");
+ return FALSE;
+ }
+
+ winDebug ("winInitVisualsPrimaryDD - Returning\n");
+
+ return TRUE;
+}
+
+
+static Bool
+winAdjustVideoModePrimaryDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ HDC hdc = NULL;
+ DWORD dwBPP;
+
+ /* We're in serious trouble if we can't get a DC */
+ hdc = GetDC (NULL);
+ if (hdc == NULL)
+ {
+ ErrorF ("winAdjustVideoModePrimaryDD - GetDC failed\n");
+ return FALSE;
+ }
+
+ /* Query GDI for current display depth */
+ dwBPP = GetDeviceCaps (hdc, BITSPIXEL);
+
+ /* DirectDraw can only change the depth in fullscreen mode */
+ if (!(pScreenInfo->fFullScreen &&
+ (pScreenInfo->dwBPP != WIN_DEFAULT_BPP)))
+ {
+ /* Otherwise, We'll use GDI's depth */
+ pScreenInfo->dwBPP = dwBPP;
+ }
+
+ /* Release our DC */
+ ReleaseDC (NULL, hdc);
+
+ return TRUE;
+}
+
+
+/*
+ * We need to blit our offscreen fb to
+ * the screen when we are activated, and we need to point
+ * the fb code back to the primary surface memory.
+ */
+
+static Bool
+winActivateAppPrimaryDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ RECT rcSrc, rcClient;
+ HRESULT ddrval = DD_OK;
+
+ /* Check for errors */
+ if (pScreenPriv == NULL
+ || pScreenPriv->pddsPrimary == NULL
+ || pScreenPriv->pddsOffscreen == NULL)
+ return FALSE;
+
+ /* Check for do-nothing */
+ if (!pScreenPriv->fActive)
+ return TRUE;
+
+ /* We are activating */
+ ddrval = IDirectDrawSurface2_IsLost (pScreenPriv->pddsOffscreen);
+ if (ddrval == DD_OK)
+ {
+ IDirectDrawSurface2_Unlock (pScreenPriv->pddsOffscreen,
+ NULL);
+ /*
+ * We don't check for an error from Unlock, because it
+ * doesn't matter if the Unlock failed.
+ */
+ }
+
+ /* Restore both surfaces, just cause I like it that way */
+ IDirectDrawSurface2_Restore (pScreenPriv->pddsOffscreen);
+ IDirectDrawSurface2_Restore (pScreenPriv->pddsPrimary);
+
+ /* Get client area in screen coords */
+ GetClientRect (pScreenPriv->hwndScreen, &rcClient);
+ MapWindowPoints (pScreenPriv->hwndScreen,
+ HWND_DESKTOP,
+ (LPPOINT)&rcClient, 2);
+
+ /* Setup a source rectangle */
+ rcSrc.left = 0;
+ rcSrc.top = 0;
+ rcSrc.right = pScreenInfo->dwWidth;
+ rcSrc.bottom = pScreenInfo->dwHeight;
+
+ ddrval = IDirectDrawSurface2_Blt (pScreenPriv->pddsPrimary,
+ &rcClient,
+ pScreenPriv->pddsOffscreen,
+ &rcSrc,
+ DDBLT_WAIT,
+ NULL);
+ if (ddrval != DD_OK)
+ FatalError ("winActivateAppPrimaryDD () - Failed blitting offscreen "
+ "surface to primary surface %08x\n", (unsigned int) ddrval);
+
+ /* Lock the primary surface */
+ ddrval = IDirectDrawSurface2_Lock (pScreenPriv->pddsPrimary,
+ &rcClient,
+ pScreenPriv->pddsdPrimary,
+ DDLOCK_WAIT,
+ NULL);
+ if (ddrval != DD_OK
+ || pScreenPriv->pddsdPrimary->lpSurface == NULL)
+ FatalError ("winActivateAppPrimaryDD () - Could not lock "
+ "primary surface\n");
+
+ /* Notify FB of the new memory pointer */
+ winUpdateFBPointer (pScreen,
+ pScreenPriv->pddsdPrimary->lpSurface);
+
+ /*
+ * Register the Alt-Tab combo as a hotkey so we can copy
+ * the primary framebuffer before the display mode changes
+ */
+ RegisterHotKey (pScreenPriv->hwndScreen, 1, MOD_ALT, 9);
+
+ return TRUE;
+}
+
+
+/*
+ * Handle the Alt+Tab hotkey.
+ *
+ * We need to save the primary fb to an offscreen fb when
+ * we get deactivated, and point the fb code at the offscreen
+ * fb for the duration of the deactivation.
+ */
+
+static Bool
+winHotKeyAltTabPrimaryDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ RECT rcClient, rcSrc;
+ HRESULT ddrval = DD_OK;
+
+ winDebug ("\nwinHotKeyAltTabPrimaryDD\n\n");
+
+ /* Alt+Tab was pressed, we will lose focus very soon */
+ pScreenPriv->fActive = FALSE;
+
+ /* Check for error conditions */
+ if (pScreenPriv->pddsPrimary == NULL
+ || pScreenPriv->pddsOffscreen == NULL)
+ return FALSE;
+
+ /* Get client area in screen coords */
+ GetClientRect (pScreenPriv->hwndScreen, &rcClient);
+ MapWindowPoints (pScreenPriv->hwndScreen,
+ HWND_DESKTOP,
+ (LPPOINT)&rcClient, 2);
+
+ /* Did we loose the primary surface? */
+ ddrval = IDirectDrawSurface2_IsLost (pScreenPriv->pddsPrimary);
+ if (ddrval == DD_OK)
+ {
+ ddrval = IDirectDrawSurface2_Unlock (pScreenPriv->pddsPrimary,
+ NULL);
+ if (FAILED (ddrval))
+ FatalError ("winHotKeyAltTabPrimaryDD - Failed unlocking primary "
+ "surface\n");
+ }
+
+ /* Setup a source rectangle */
+ rcSrc.left = 0;
+ rcSrc.top = 0;
+ rcSrc.right = pScreenInfo->dwWidth;
+ rcSrc.bottom = pScreenInfo->dwHeight;
+
+ /* Blit the primary surface to the offscreen surface */
+ ddrval = IDirectDrawSurface2_Blt (pScreenPriv->pddsOffscreen,
+ NULL, /* should be rcDest */
+ pScreenPriv->pddsPrimary,
+ NULL,
+ DDBLT_WAIT,
+ NULL);
+ if (ddrval == DDERR_SURFACELOST)
+ {
+ IDirectDrawSurface2_Restore (pScreenPriv->pddsOffscreen);
+ IDirectDrawSurface2_Restore (pScreenPriv->pddsPrimary);
+
+ /* Blit the primary surface to the offscreen surface */
+ ddrval = IDirectDrawSurface2_Blt (pScreenPriv->pddsOffscreen,
+ NULL,
+ pScreenPriv->pddsPrimary,
+ NULL,
+ DDBLT_WAIT,
+ NULL);
+ if (FAILED (ddrval))
+ FatalError ("winHotKeyAltTabPrimaryDD - Failed blitting primary "
+ "surface to offscreen surface: %08x\n",
+ (unsigned int) ddrval);
+ }
+ else
+ {
+ FatalError ("winHotKeyAltTabPrimaryDD - Unknown error from "
+ "Blt: %08dx\n", (unsigned int) ddrval);
+ }
+
+ /* Lock the offscreen surface */
+ ddrval = IDirectDrawSurface2_Lock (pScreenPriv->pddsOffscreen,
+ NULL,
+ pScreenPriv->pddsdOffscreen,
+ DDLOCK_WAIT,
+ NULL);
+ if (ddrval != DD_OK
+ || pScreenPriv->pddsdPrimary->lpSurface == NULL)
+ FatalError ("winHotKeyAltTabPrimaryDD - Could not lock "
+ "offscreen surface\n");
+
+ /* Notify FB of the new memory pointer */
+ winUpdateFBPointer (pScreen,
+ pScreenPriv->pddsdOffscreen->lpSurface);
+
+ /* Unregister our hotkey */
+ UnregisterHotKey (pScreenPriv->hwndScreen, 1);
+
+ return TRUE;
+}
+
+
+/* Set engine specific functions */
+Bool
+winSetEngineFunctionsPrimaryDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /* Set our pointers */
+ pScreenPriv->pwinAllocateFB = winAllocateFBPrimaryDD;
+ pScreenPriv->pwinFreeFB = winFreeFBPrimaryDD;
+ pScreenPriv->pwinShadowUpdate = (winShadowUpdateProcPtr) (void (*)(void))NoopDDA;
+ pScreenPriv->pwinInitScreen = winInitScreenPrimaryDD;
+ pScreenPriv->pwinCloseScreen = winCloseScreenPrimaryDD;
+ pScreenPriv->pwinInitVisuals = winInitVisualsPrimaryDD;
+ pScreenPriv->pwinAdjustVideoMode = winAdjustVideoModePrimaryDD;
+ if (pScreenInfo->fFullScreen)
+ pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowFullScreen;
+ else
+ pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowWindowed;
+ pScreenPriv->pwinFinishScreenInit = winFinishScreenInitFB;
+ pScreenPriv->pwinBltExposedRegions = (winBltExposedRegionsProcPtr) (void (*)(void))NoopDDA;
+ pScreenPriv->pwinActivateApp = winActivateAppPrimaryDD;
+ pScreenPriv->pwinRedrawScreen = NULL;
+ pScreenPriv->pwinRealizeInstalledPalette = NULL;
+ pScreenPriv->pwinInstallColormap = NULL;
+ pScreenPriv->pwinStoreColors = NULL;
+ pScreenPriv->pwinCreateColormap = NULL;
+ pScreenPriv->pwinDestroyColormap = NULL;
+ pScreenPriv->pwinHotKeyAltTab = winHotKeyAltTabPrimaryDD;
+ pScreenPriv->pwinCreatePrimarySurface = (winCreatePrimarySurfaceProcPtr) (void (*)(void))NoopDDA;
+ pScreenPriv->pwinReleasePrimarySurface = (winReleasePrimarySurfaceProcPtr) (void (*)(void))NoopDDA;
+#ifdef XWIN_MULTIWINDOW
+ pScreenPriv->pwinFinishCreateWindowsWindow =
+ (winFinishCreateWindowsWindowProcPtr) (void (*)(void))NoopDDA;
+#endif
+
+ return TRUE;
+}
diff --git a/xorg-server/hw/xwin/winprefs.c b/xorg-server/hw/xwin/winprefs.c
index e92e95f2b..440cdd2e7 100644
--- a/xorg-server/hw/xwin/winprefs.c
+++ b/xorg-server/hw/xwin/winprefs.c
@@ -1,840 +1,840 @@
-/*
- * 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
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include <stdio.h>
-#include <stdlib.h>
-#ifdef __CYGWIN__
-#include <sys/resource.h>
-#endif
-#include "win.h"
-
-#include <X11/Xwindows.h>
-#include <shellapi.h>
-
-#include "winprefs.h"
-#include "winmultiwindowclass.h"
-
-/* Where will the custom menu commands start counting from? */
-#define STARTMENUID WM_USER
-
-extern const char *winGetBaseDir(void);
-
-extern const char *g_pszLogFile;
-
-/* From winmultiwindowflex.l, the real parser */
-extern void parse_file (FILE *fp);
-
-
-/* Currently in use command ID, incremented each new menu item created */
-static int g_cmdid = STARTMENUID;
-
-
-/* Defined in DIX */
-extern char *display;
-
-/* Local function to handle comma-ified icon names */
-static HICON
-LoadImageComma (char *fname, int sx, int sy, int flags);
-
-
-/*
- * Creates or appends a menu from a MENUPARSED structure
- */
-static HMENU
-MakeMenu (char *name,
- HMENU editMenu,
- int editItem)
-{
- int i;
- int item;
- MENUPARSED *m;
- HMENU hmenu, hsub;
-
- for (i=0; i<pref.menuItems; i++)
- {
- if (!strcmp(name, pref.menu[i].menuName))
- break;
- }
-
- /* Didn't find a match, bummer */
- if (i==pref.menuItems)
- {
- ErrorF("MakeMenu: Can't find menu %s\n", name);
- return NULL;
- }
-
- m = &(pref.menu[i]);
-
- if (editMenu)
- {
- hmenu = editMenu;
- item = editItem;
- }
- else
- {
- hmenu = CreatePopupMenu();
- if (!hmenu)
- {
- ErrorF("MakeMenu: Unable to CreatePopupMenu() %s\n", name);
- return NULL;
- }
- item = 0;
- }
-
- /* Add the menu items */
- for (i=0; i<m->menuItems; i++)
- {
- /* Only assign IDs one time... */
- if ( m->menuItem[i].commandID == 0 )
- m->menuItem[i].commandID = g_cmdid++;
-
- switch (m->menuItem[i].cmd)
- {
- case CMD_EXEC:
- case CMD_ALWAYSONTOP:
- case CMD_RELOAD:
- InsertMenu (hmenu,
- item,
- MF_BYPOSITION|MF_ENABLED|MF_STRING,
- m->menuItem[i].commandID,
- m->menuItem[i].text);
- break;
-
- case CMD_SEPARATOR:
- InsertMenu (hmenu,
- item,
- MF_BYPOSITION|MF_SEPARATOR,
- 0,
- NULL);
- break;
-
- case CMD_MENU:
- /* Recursive! */
- hsub = MakeMenu (m->menuItem[i].param, 0, 0);
- if (hsub)
- InsertMenu (hmenu,
- item,
- MF_BYPOSITION|MF_POPUP|MF_ENABLED|MF_STRING,
- (UINT_PTR)hsub,
- m->menuItem[i].text);
- break;
- }
-
- /* If item==-1 (means to add at end of menu) don't increment) */
- if (item>=0)
- item++;
- }
-
- return hmenu;
-}
-
-
-#ifdef XWIN_MULTIWINDOW
-/*
- * Callback routine that is executed once per window class.
- * Removes or creates custom window settings depending on LPARAM
- */
-static wBOOL CALLBACK
-ReloadEnumWindowsProc (HWND hwnd, LPARAM lParam)
-{
- HICON hicon;
- Window wid;
-
- if (!hwnd) {
- ErrorF("ReloadEnumWindowsProc: hwnd==NULL!\n");
- return FALSE;
- }
-
- /* It's our baby, either clean or dirty it */
- if (lParam==FALSE)
- {
- /* Reset the window's icon to undefined. */
- hicon = (HICON)SendMessage(hwnd, WM_SETICON, ICON_BIG, 0);
-
- /* If the old icon is generated on-the-fly, get rid of it, will regen */
- winDestroyIcon (hicon);
-
- /* Same for the small icon */
- hicon = (HICON)SendMessage(hwnd, WM_SETICON, ICON_SMALL, 0);
- winDestroyIcon (hicon);
-
- /* Remove any menu additions; bRevert=TRUE destroys any modified menus */
- GetSystemMenu (hwnd, TRUE);
-
- /* This window is now clean of our taint (but with undefined icons) */
- }
- else
- {
- /* winUpdateIcon() will set the icon default, dynamic, or from xwinrc */
- wid = (Window)GetProp (hwnd, WIN_WID_PROP);
- if (wid)
- winUpdateIcon (wid);
-
- /* Update the system menu for this window */
- SetupSysMenu ((unsigned long)hwnd);
-
- /* That was easy... */
- }
-
- return TRUE;
-}
-#endif
-
-
-/*
- * Removes any custom icons in classes, custom menus, etc.
- * Frees all members in pref structure.
- * Reloads the preferences file.
- * Set custom icons and menus again.
- */
-static void
-ReloadPrefs (void)
-{
- int i;
-
-#ifdef XWIN_MULTIWINDOW
- /* First, iterate over all windows, deleting their icons and custom menus.
- * This is really only needed because winDestroyIcon() will try to
- * destroy the old global icons, which will have changed.
- * It is probably better to set a windows USER_DATA to flag locally defined
- * icons, and use that to accurately know when to destroy old icons.
- */
- EnumThreadWindows (g_dwCurrentThreadID, ReloadEnumWindowsProc, FALSE);
-#endif
-
- /* Now, free/clear all info from our prefs structure */
- for (i=0; i<pref.menuItems; i++)
- free (pref.menu[i].menuItem);
- free (pref.menu);
- pref.menu = NULL;
- pref.menuItems = 0;
-
- pref.rootMenuName[0] = 0;
-
- free (pref.sysMenu);
- pref.sysMenuItems = 0;
-
- pref.defaultSysMenuName[0] = 0;
- pref.defaultSysMenuPos = 0;
-
- pref.iconDirectory[0] = 0;
- pref.defaultIconName[0] = 0;
- pref.trayIconName[0] = 0;
-
- for (i=0; i<pref.iconItems; i++)
- if (pref.icon[i].hicon)
- DestroyIcon ((HICON)pref.icon[i].hicon);
- free (pref.icon);
- pref.icon = NULL;
- pref.iconItems = 0;
-
- /* Free global default X icon */
- if (g_hIconX)
- DestroyIcon (g_hIconX);
- if (g_hSmallIconX)
- DestroyIcon (g_hSmallIconX);
-
- /* Reset the custom command IDs */
- g_cmdid = STARTMENUID;
-
- /* Load the updated resource file */
- LoadPreferences();
-
- g_hIconX = NULL;
- g_hSmallIconX = NULL;
-
-#ifdef XWIN_MULTIWINDOW
- winInitGlobalIcons();
-#endif
-
-#ifdef XWIN_MULTIWINDOW
- /* Rebuild the icons and menus */
- EnumThreadWindows (g_dwCurrentThreadID, ReloadEnumWindowsProc, TRUE);
-#endif
-
- /* Whew, done */
-}
-
-/*
- * Check/uncheck the ALWAYSONTOP items in this menu
- */
-void
-HandleCustomWM_INITMENU(unsigned long hwndIn,
- unsigned long hmenuIn)
-{
- HWND hwnd;
- HMENU hmenu;
- DWORD dwExStyle;
- int i, j;
-
- hwnd = (HWND)hwndIn;
- hmenu = (HMENU)hmenuIn;
- if (!hwnd || !hmenu)
- return;
-
- if (GetWindowLongPtr(hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST)
- dwExStyle = MF_BYCOMMAND | MF_CHECKED;
- else
- dwExStyle = MF_BYCOMMAND | MF_UNCHECKED;
-
- for (i=0; i<pref.menuItems; i++)
- for (j=0; j<pref.menu[i].menuItems; j++)
- if (pref.menu[i].menuItem[j].cmd==CMD_ALWAYSONTOP)
- CheckMenuItem (hmenu, pref.menu[i].menuItem[j].commandID, dwExStyle );
-
-}
-
-/*
- * Searches for the custom WM_COMMAND command ID and performs action.
- * Return TRUE if command is proccessed, FALSE otherwise.
- */
-Bool
-HandleCustomWM_COMMAND (unsigned long hwndIn,
- int command)
-{
- HWND hwnd;
- int i, j;
- MENUPARSED *m;
- DWORD dwExStyle;
-
- hwnd = (HWND)hwndIn;
-
- if (!command)
- return FALSE;
-
- for (i=0; i<pref.menuItems; i++)
- {
- m = &(pref.menu[i]);
- for (j=0; j<m->menuItems; j++)
- {
- if (command==m->menuItem[j].commandID)
- {
- /* Match! */
- switch(m->menuItem[j].cmd)
- {
-#ifdef __CYGWIN__
- case CMD_EXEC:
- if (fork()==0)
- {
- struct rlimit rl;
- unsigned long i;
-
- /* Close any open descriptors except for STD* */
- getrlimit (RLIMIT_NOFILE, &rl);
- for (i = STDERR_FILENO+1; i < rl.rlim_cur; i++)
- close(i);
-
- /* Disassociate any TTYs */
- setsid();
-
- execl ("/bin/sh",
- "/bin/sh",
- "-c",
- m->menuItem[j].param,
- NULL);
- exit (0);
- }
- else
- return TRUE;
- break;
-#else
- case CMD_EXEC:
- {
- /* Start process without console window */
- STARTUPINFO start;
- PROCESS_INFORMATION child;
-
- memset (&start, 0, sizeof (start));
- start.cb = sizeof (start);
- //start.dwFlags = STARTF_USESHOWWINDOW;
- //start.wShowWindow = SW_HIDE;
-
- memset (&child, 0, sizeof (child));
-
- if (CreateProcess (NULL, m->menuItem[j].param, NULL, NULL, FALSE, 0,
- NULL, NULL, &start, &child))
- {
- CloseHandle (child.hThread);
- CloseHandle (child.hProcess);
- }
- else
- MessageBox(NULL, m->menuItem[j].param, "VcXsrv Exec Command Error!", MB_OK | MB_ICONEXCLAMATION);
- }
- return TRUE;
-#endif
- case CMD_ALWAYSONTOP:
- if (!hwnd)
- return FALSE;
-
- /* Get extended window style */
- dwExStyle = GetWindowLongPtr(hwnd, GWL_EXSTYLE);
-
- /* Handle topmost windows */
- if (dwExStyle & WS_EX_TOPMOST)
- SetWindowPos (hwnd,
- HWND_NOTOPMOST,
- 0, 0,
- 0, 0,
- SWP_NOSIZE | SWP_NOMOVE);
- else
- SetWindowPos (hwnd,
- HWND_TOPMOST,
- 0, 0,
- 0, 0,
- SWP_NOSIZE | SWP_NOMOVE);
-#if XWIN_MULTIWINDOW
- /* Reflect the changed Z order */
- winReorderWindowsMultiWindow ();
-#endif
- return TRUE;
-
- case CMD_RELOAD:
- ReloadPrefs();
- return TRUE;
-
- default:
- return FALSE;
- }
- } /* match */
- } /* for j */
- } /* for i */
-
- return FALSE;
-}
-
-
-#ifdef XWIN_MULTIWINDOW
-/*
- * Add the default or a custom menu depending on the class match
- */
-void
-SetupSysMenu (unsigned long hwndIn)
-{
- HWND hwnd;
- HMENU sys;
- int i;
- WindowPtr pWin;
- char *res_name, *res_class;
-
- hwnd = (HWND)hwndIn;
- if (!hwnd)
- return;
-
- pWin = GetProp (hwnd, WIN_WINDOW_PROP);
-
- sys = GetSystemMenu (hwnd, FALSE);
- if (!sys)
- return;
-
- if (pWin)
- {
- /* First see if there's a class match... */
- if (winMultiWindowGetClassHint (pWin, &res_name, &res_class))
- {
- for (i=0; i<pref.sysMenuItems; i++)
- {
- if (!strcmp(pref.sysMenu[i].match, res_name) ||
- !strcmp(pref.sysMenu[i].match, res_class) )
- {
- free(res_name);
- free(res_class);
-
- MakeMenu (pref.sysMenu[i].menuName, sys,
- pref.sysMenu[i].menuPos==AT_START?0:-1);
- return;
- }
- }
-
- /* No match, just free alloc'd strings */
- free(res_name);
- free(res_class);
- } /* Found wm_class */
- } /* if pwin */
-
- /* Fallback to system default */
- if (pref.defaultSysMenuName[0])
- {
- if (pref.defaultSysMenuPos==AT_START)
- MakeMenu (pref.defaultSysMenuName, sys, 0);
- else
- MakeMenu (pref.defaultSysMenuName, sys, -1);
- }
-}
-#endif
-
-
-/*
- * Possibly add a menu to the toolbar icon
- */
-void
-SetupRootMenu (unsigned long hmenuRoot)
-{
- HMENU root;
-
- root = (HMENU)hmenuRoot;
- if (!root)
- return;
-
- if (pref.rootMenuName[0])
- {
- MakeMenu(pref.rootMenuName, root, 0);
- }
-}
-
-
-/*
- * Check for and return an overridden default ICON specified in the prefs
- */
-HICON
-winOverrideDefaultIcon(int size)
-{
- HICON hicon;
-
- if (pref.defaultIconName[0])
- {
- hicon = LoadImageComma (pref.defaultIconName, size, size, 0);
- if (hicon==NULL)
- ErrorF ("winOverrideDefaultIcon: LoadImageComma(%s) failed\n",
- pref.defaultIconName);
-
- return hicon;
- }
-
- return 0;
-}
-
-
-/*
- * Return the HICON to use in the taskbar notification area
- */
-HICON
-winTaskbarIcon(void)
-{
- HICON hicon;
-
- hicon = 0;
- /* First try and load an overridden, if success then return it */
- if (pref.trayIconName[0])
- {
- hicon = LoadImageComma (pref.trayIconName,
- GetSystemMetrics (SM_CXSMICON),
- GetSystemMetrics (SM_CYSMICON),
- 0 );
- }
-
- /* Otherwise return the default */
- if (!hicon)
- hicon = (HICON) LoadImage (g_hInstance,
- MAKEINTRESOURCE(IDI_XWIN),
- IMAGE_ICON,
- GetSystemMetrics (SM_CXSMICON),
- GetSystemMetrics (SM_CYSMICON),
- 0);
-
- return hicon;
-}
-
-
-/*
- * Parse a filename to extract an icon:
- * If fname is exactly ",nnn" then extract icon from our resource
- * else if it is "file,nnn" then extract icon nnn from that file
- * else try to load it as an .ico file and if that fails return NULL
- */
-static HICON
-LoadImageComma (char *fname, int sx, int sy, int flags)
-{
- HICON hicon;
- int index;
- char file[PATH_MAX+NAME_MAX+2];
-
- /* Some input error checking */
- if (!fname || !fname[0])
- return NULL;
-
- index = 0;
- hicon = NULL;
-
- if (fname[0]==',')
- {
- /* It's the XWIN.EXE resource they want */
- index = atoi (fname+1);
- hicon = LoadImage (g_hInstance,
- MAKEINTRESOURCE(index),
- IMAGE_ICON,
- sx,
- sy,
- flags);
- }
- else
- {
- file[0] = 0;
- /* Prepend path if not given a "X:\" filename */
- if ( !(fname[0] && fname[1]==':' && fname[2]=='\\') )
- {
- strcpy (file, pref.iconDirectory);
- if (pref.iconDirectory[0])
- if (fname[strlen(fname)-1]!='\\')
- strcat (file, "\\");
- }
- strcat (file, fname);
-
- if (strrchr (file, ','))
- {
- /* Specified as <fname>,<index> */
-
- *(strrchr (file, ',')) = 0; /* End string at comma */
- index = atoi (strrchr (fname, ',') + 1);
- hicon = ExtractIcon (g_hInstance, file, index);
- }
- else
- {
- /* Just an .ico file... */
-
- hicon = (HICON)LoadImage (NULL,
- file,
- IMAGE_ICON,
- sx,
- sy,
- LR_LOADFROMFILE|flags);
- }
- }
- return hicon;
-}
-
-/*
- * Check for a match of the window class to one specified in the
- * ICONS{} section in the prefs file, and load the icon from a file
- */
-HICON
-winOverrideIcon (unsigned long longWin)
-{
- WindowPtr pWin = (WindowPtr) longWin;
- char *res_name, *res_class;
- int i;
- HICON hicon;
- char *wmName;
-
- if (pWin==NULL)
- return 0;
-
- /* If we can't find the class, we can't override from default! */
- if (!winMultiWindowGetClassHint (pWin, &res_name, &res_class))
- return 0;
-
- winMultiWindowGetWMName (pWin, &wmName);
-
- for (i=0; i<pref.iconItems; i++) {
- if (!strcmp(pref.icon[i].match, res_name) ||
- !strcmp(pref.icon[i].match, res_class) ||
- (wmName && strstr(wmName, pref.icon[i].match)))
- {
- free (res_name);
- free (res_class);
- free(wmName);
-
- if (pref.icon[i].hicon)
- return pref.icon[i].hicon;
-
- hicon = LoadImageComma (pref.icon[i].iconFile, 0, 0, LR_DEFAULTSIZE);
- if (hicon==NULL)
- ErrorF ("winOverrideIcon: LoadImageComma(%s) failed\n",
- pref.icon[i].iconFile);
-
- pref.icon[i].hicon = hicon;
- return hicon;
- }
- }
-
- /* Didn't find the icon, fail gracefully */
- free (res_name);
- free (res_class);
- free(wmName);
-
- return 0;
-}
-
-
-/*
- * Should we free this icon or leave it in memory (is it part of our
- * ICONS{} overrides)?
- */
-int
-winIconIsOverride(unsigned hiconIn)
-{
- HICON hicon;
- int i;
-
- hicon = (HICON)hiconIn;
-
- if (!hicon)
- return 0;
-
- for (i=0; i<pref.iconItems; i++)
- if ((HICON)pref.icon[i].hicon == hicon)
- return 1;
-
- return 0;
-}
-
-
-
-/*
- * Try and open ~/.XWinrc and system.XWinrc
- * Load it into prefs structure for use by other functions
- */
-void
-LoadPreferences (void)
-{
- char *home;
- char fname[PATH_MAX+NAME_MAX+2];
- FILE *prefFile;
- char szDisplay[512];
- char *szEnvDisplay;
- int i, j;
- char param[PARAM_MAX+1];
- char *srcParam, *dstParam;
-
- /* First, clear all preference settings */
- memset (&pref, 0, sizeof(pref));
- prefFile = NULL;
-
- /* Now try and find a ~/.xwinrc file */
- home = getenv ("HOME");
- if (home)
- {
- strcpy (fname, home);
- if (fname[strlen(fname)-1]!='/')
- strcat (fname, "/");
- strcat (fname, ".XWinrc");
-
- prefFile = fopen (fname, "r");
- if (prefFile)
- {
- winDebug ("winPrefsLoadPreferences: %s\n", fname);
- }
- }
-
- /* No home file found, check system default */
- if (!prefFile)
- {
- char buffer[MAX_PATH];
-#ifdef RELOCATE_PROJECTROOT
- snprintf(buffer, sizeof(buffer), "%s\\system.XWinrc", winGetBaseDir());
-#else
- strncpy(buffer, SYSCONFDIR"/X11/system.XWinrc", sizeof(buffer));
-#endif
- buffer[sizeof(buffer)-1] = 0;
- prefFile = fopen (buffer, "r");
- if (prefFile)
- {
- winDebug ("winPrefsLoadPreferences: %s\n", buffer);
- }
- }
-
- /* If we could open it, then read the settings and close it */
- if (prefFile)
- {
- parse_file (prefFile);
- fclose (prefFile);
- }
-
- /* Setup a DISPLAY environment variable, need to allocate on heap */
- /* because putenv doesn't copy the argument... Always use screen 0 */
- winGetDisplayName(szDisplay, 0);
- szEnvDisplay = (char *)(malloc(strlen(szDisplay)+9/*strlen("DISPLAY=")+1*/));
- snprintf(szEnvDisplay, 512, "DISPLAY=%s", szDisplay);
- putenv (szEnvDisplay);
-
- /* Replace any "%display%" in menu commands with display string */
- for (i=0; i<pref.menuItems; i++)
- {
- for (j=0; j<pref.menu[i].menuItems; j++)
- {
- if (pref.menu[i].menuItem[j].cmd==CMD_EXEC)
- {
- srcParam = pref.menu[i].menuItem[j].param;
- dstParam = param;
- while (*srcParam) {
- if (!strncmp(srcParam, "%display%", 9))
- {
- memcpy (dstParam, szDisplay, strlen(szDisplay));
- dstParam += strlen(szDisplay);
- srcParam += 9;
- }
- else if (!strncmp(srcParam, "%logfile%", 9))
- {
- memcpy (dstParam, g_pszLogFile, strlen(g_pszLogFile));
- dstParam += strlen(g_pszLogFile);
- srcParam += 9;
- }
- else
- {
- *dstParam = *srcParam;
- dstParam++;
- srcParam++;
- }
- }
- *dstParam = 0;
- strcpy (pref.menu[i].menuItem[j].param, param);
- } /* cmd==cmd_exec */
- } /* for all menuitems */
- } /* for all menus */
-
-}
-
-
-/*
- * Check for a match of the window class to one specified in the
- * STYLES{} section in the prefs file, and return the style type
- */
-unsigned long
-winOverrideStyle (char *res_name, char *res_class, char *wmName)
-{
- int i;
-
- for (i=0; i<pref.styleItems; i++) {
- if ((res_name && !strcmp(pref.style[i].match, res_name)) ||
- (res_class && !strcmp(pref.style[i].match, res_class)) ||
- (wmName && strstr(wmName, pref.style[i].match)))
- {
- if (pref.style[i].type)
- return pref.style[i].type;
- }
- }
-
- /* Didn't find the style, fail gracefully */
- return STYLE_NONE;
-}
+/*
+ * 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
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#ifdef __CYGWIN__
+#include <sys/resource.h>
+#endif
+#include "win.h"
+
+#include <X11/Xwindows.h>
+#include <shellapi.h>
+
+#include "winprefs.h"
+#include "winmultiwindowclass.h"
+
+/* Where will the custom menu commands start counting from? */
+#define STARTMENUID WM_USER
+
+extern const char *winGetBaseDir(void);
+
+extern const char *g_pszLogFile;
+
+/* From winmultiwindowflex.l, the real parser */
+extern void parse_file (FILE *fp);
+
+
+/* Currently in use command ID, incremented each new menu item created */
+static int g_cmdid = STARTMENUID;
+
+
+/* Defined in DIX */
+extern char *display;
+
+/* Local function to handle comma-ified icon names */
+static HICON
+LoadImageComma (char *fname, int sx, int sy, int flags);
+
+
+/*
+ * Creates or appends a menu from a MENUPARSED structure
+ */
+static HMENU
+MakeMenu (char *name,
+ HMENU editMenu,
+ int editItem)
+{
+ int i;
+ int item;
+ MENUPARSED *m;
+ HMENU hmenu, hsub;
+
+ for (i=0; i<pref.menuItems; i++)
+ {
+ if (!strcmp(name, pref.menu[i].menuName))
+ break;
+ }
+
+ /* Didn't find a match, bummer */
+ if (i==pref.menuItems)
+ {
+ ErrorF("MakeMenu: Can't find menu %s\n", name);
+ return NULL;
+ }
+
+ m = &(pref.menu[i]);
+
+ if (editMenu)
+ {
+ hmenu = editMenu;
+ item = editItem;
+ }
+ else
+ {
+ hmenu = CreatePopupMenu();
+ if (!hmenu)
+ {
+ ErrorF("MakeMenu: Unable to CreatePopupMenu() %s\n", name);
+ return NULL;
+ }
+ item = 0;
+ }
+
+ /* Add the menu items */
+ for (i=0; i<m->menuItems; i++)
+ {
+ /* Only assign IDs one time... */
+ if ( m->menuItem[i].commandID == 0 )
+ m->menuItem[i].commandID = g_cmdid++;
+
+ switch (m->menuItem[i].cmd)
+ {
+ case CMD_EXEC:
+ case CMD_ALWAYSONTOP:
+ case CMD_RELOAD:
+ InsertMenu (hmenu,
+ item,
+ MF_BYPOSITION|MF_ENABLED|MF_STRING,
+ m->menuItem[i].commandID,
+ m->menuItem[i].text);
+ break;
+
+ case CMD_SEPARATOR:
+ InsertMenu (hmenu,
+ item,
+ MF_BYPOSITION|MF_SEPARATOR,
+ 0,
+ NULL);
+ break;
+
+ case CMD_MENU:
+ /* Recursive! */
+ hsub = MakeMenu (m->menuItem[i].param, 0, 0);
+ if (hsub)
+ InsertMenu (hmenu,
+ item,
+ MF_BYPOSITION|MF_POPUP|MF_ENABLED|MF_STRING,
+ (UINT_PTR)hsub,
+ m->menuItem[i].text);
+ break;
+ }
+
+ /* If item==-1 (means to add at end of menu) don't increment) */
+ if (item>=0)
+ item++;
+ }
+
+ return hmenu;
+}
+
+
+#ifdef XWIN_MULTIWINDOW
+/*
+ * Callback routine that is executed once per window class.
+ * Removes or creates custom window settings depending on LPARAM
+ */
+static wBOOL CALLBACK
+ReloadEnumWindowsProc (HWND hwnd, LPARAM lParam)
+{
+ HICON hicon;
+ Window wid;
+
+ if (!hwnd) {
+ ErrorF("ReloadEnumWindowsProc: hwnd==NULL!\n");
+ return FALSE;
+ }
+
+ /* It's our baby, either clean or dirty it */
+ if (lParam==FALSE)
+ {
+ /* Reset the window's icon to undefined. */
+ hicon = (HICON)SendMessage(hwnd, WM_SETICON, ICON_BIG, 0);
+
+ /* If the old icon is generated on-the-fly, get rid of it, will regen */
+ winDestroyIcon (hicon);
+
+ /* Same for the small icon */
+ hicon = (HICON)SendMessage(hwnd, WM_SETICON, ICON_SMALL, 0);
+ winDestroyIcon (hicon);
+
+ /* Remove any menu additions; bRevert=TRUE destroys any modified menus */
+ GetSystemMenu (hwnd, TRUE);
+
+ /* This window is now clean of our taint (but with undefined icons) */
+ }
+ else
+ {
+ /* winUpdateIcon() will set the icon default, dynamic, or from xwinrc */
+ wid = (Window)GetProp (hwnd, WIN_WID_PROP);
+ if (wid)
+ winUpdateIcon (wid);
+
+ /* Update the system menu for this window */
+ SetupSysMenu ((unsigned long)hwnd);
+
+ /* That was easy... */
+ }
+
+ return TRUE;
+}
+#endif
+
+
+/*
+ * Removes any custom icons in classes, custom menus, etc.
+ * Frees all members in pref structure.
+ * Reloads the preferences file.
+ * Set custom icons and menus again.
+ */
+static void
+ReloadPrefs (void)
+{
+ int i;
+
+#ifdef XWIN_MULTIWINDOW
+ /* First, iterate over all windows, deleting their icons and custom menus.
+ * This is really only needed because winDestroyIcon() will try to
+ * destroy the old global icons, which will have changed.
+ * It is probably better to set a windows USER_DATA to flag locally defined
+ * icons, and use that to accurately know when to destroy old icons.
+ */
+ EnumThreadWindows (g_dwCurrentThreadID, ReloadEnumWindowsProc, FALSE);
+#endif
+
+ /* Now, free/clear all info from our prefs structure */
+ for (i=0; i<pref.menuItems; i++)
+ free (pref.menu[i].menuItem);
+ free (pref.menu);
+ pref.menu = NULL;
+ pref.menuItems = 0;
+
+ pref.rootMenuName[0] = 0;
+
+ free (pref.sysMenu);
+ pref.sysMenuItems = 0;
+
+ pref.defaultSysMenuName[0] = 0;
+ pref.defaultSysMenuPos = 0;
+
+ pref.iconDirectory[0] = 0;
+ pref.defaultIconName[0] = 0;
+ pref.trayIconName[0] = 0;
+
+ for (i=0; i<pref.iconItems; i++)
+ if (pref.icon[i].hicon)
+ DestroyIcon ((HICON)pref.icon[i].hicon);
+ free (pref.icon);
+ pref.icon = NULL;
+ pref.iconItems = 0;
+
+ /* Free global default X icon */
+ if (g_hIconX)
+ DestroyIcon (g_hIconX);
+ if (g_hSmallIconX)
+ DestroyIcon (g_hSmallIconX);
+
+ /* Reset the custom command IDs */
+ g_cmdid = STARTMENUID;
+
+ /* Load the updated resource file */
+ LoadPreferences();
+
+ g_hIconX = NULL;
+ g_hSmallIconX = NULL;
+
+#ifdef XWIN_MULTIWINDOW
+ winInitGlobalIcons();
+#endif
+
+#ifdef XWIN_MULTIWINDOW
+ /* Rebuild the icons and menus */
+ EnumThreadWindows (g_dwCurrentThreadID, ReloadEnumWindowsProc, TRUE);
+#endif
+
+ /* Whew, done */
+}
+
+/*
+ * Check/uncheck the ALWAYSONTOP items in this menu
+ */
+void
+HandleCustomWM_INITMENU(unsigned long hwndIn,
+ unsigned long hmenuIn)
+{
+ HWND hwnd;
+ HMENU hmenu;
+ DWORD dwExStyle;
+ int i, j;
+
+ hwnd = (HWND)hwndIn;
+ hmenu = (HMENU)hmenuIn;
+ if (!hwnd || !hmenu)
+ return;
+
+ if (GetWindowLongPtr(hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST)
+ dwExStyle = MF_BYCOMMAND | MF_CHECKED;
+ else
+ dwExStyle = MF_BYCOMMAND | MF_UNCHECKED;
+
+ for (i=0; i<pref.menuItems; i++)
+ for (j=0; j<pref.menu[i].menuItems; j++)
+ if (pref.menu[i].menuItem[j].cmd==CMD_ALWAYSONTOP)
+ CheckMenuItem (hmenu, pref.menu[i].menuItem[j].commandID, dwExStyle );
+
+}
+
+/*
+ * Searches for the custom WM_COMMAND command ID and performs action.
+ * Return TRUE if command is proccessed, FALSE otherwise.
+ */
+Bool
+HandleCustomWM_COMMAND (unsigned long hwndIn,
+ int command)
+{
+ HWND hwnd;
+ int i, j;
+ MENUPARSED *m;
+ DWORD dwExStyle;
+
+ hwnd = (HWND)hwndIn;
+
+ if (!command)
+ return FALSE;
+
+ for (i=0; i<pref.menuItems; i++)
+ {
+ m = &(pref.menu[i]);
+ for (j=0; j<m->menuItems; j++)
+ {
+ if (command==m->menuItem[j].commandID)
+ {
+ /* Match! */
+ switch(m->menuItem[j].cmd)
+ {
+#ifdef __CYGWIN__
+ case CMD_EXEC:
+ if (fork()==0)
+ {
+ struct rlimit rl;
+ unsigned long i;
+
+ /* Close any open descriptors except for STD* */
+ getrlimit (RLIMIT_NOFILE, &rl);
+ for (i = STDERR_FILENO+1; i < rl.rlim_cur; i++)
+ close(i);
+
+ /* Disassociate any TTYs */
+ setsid();
+
+ execl ("/bin/sh",
+ "/bin/sh",
+ "-c",
+ m->menuItem[j].param,
+ NULL);
+ exit (0);
+ }
+ else
+ return TRUE;
+ break;
+#else
+ case CMD_EXEC:
+ {
+ /* Start process without console window */
+ STARTUPINFO start;
+ PROCESS_INFORMATION child;
+
+ memset (&start, 0, sizeof (start));
+ start.cb = sizeof (start);
+ //start.dwFlags = STARTF_USESHOWWINDOW;
+ //start.wShowWindow = SW_HIDE;
+
+ memset (&child, 0, sizeof (child));
+
+ if (CreateProcess (NULL, m->menuItem[j].param, NULL, NULL, FALSE, 0,
+ NULL, NULL, &start, &child))
+ {
+ CloseHandle (child.hThread);
+ CloseHandle (child.hProcess);
+ }
+ else
+ MessageBox(NULL, m->menuItem[j].param, "VcXsrv Exec Command Error!", MB_OK | MB_ICONEXCLAMATION);
+ }
+ return TRUE;
+#endif
+ case CMD_ALWAYSONTOP:
+ if (!hwnd)
+ return FALSE;
+
+ /* Get extended window style */
+ dwExStyle = GetWindowLongPtr(hwnd, GWL_EXSTYLE);
+
+ /* Handle topmost windows */
+ if (dwExStyle & WS_EX_TOPMOST)
+ SetWindowPos (hwnd,
+ HWND_NOTOPMOST,
+ 0, 0,
+ 0, 0,
+ SWP_NOSIZE | SWP_NOMOVE);
+ else
+ SetWindowPos (hwnd,
+ HWND_TOPMOST,
+ 0, 0,
+ 0, 0,
+ SWP_NOSIZE | SWP_NOMOVE);
+#if XWIN_MULTIWINDOW
+ /* Reflect the changed Z order */
+ winReorderWindowsMultiWindow ();
+#endif
+ return TRUE;
+
+ case CMD_RELOAD:
+ ReloadPrefs();
+ return TRUE;
+
+ default:
+ return FALSE;
+ }
+ } /* match */
+ } /* for j */
+ } /* for i */
+
+ return FALSE;
+}
+
+
+#ifdef XWIN_MULTIWINDOW
+/*
+ * Add the default or a custom menu depending on the class match
+ */
+void
+SetupSysMenu (unsigned long hwndIn)
+{
+ HWND hwnd;
+ HMENU sys;
+ int i;
+ WindowPtr pWin;
+ char *res_name, *res_class;
+
+ hwnd = (HWND)hwndIn;
+ if (!hwnd)
+ return;
+
+ pWin = GetProp (hwnd, WIN_WINDOW_PROP);
+
+ sys = GetSystemMenu (hwnd, FALSE);
+ if (!sys)
+ return;
+
+ if (pWin)
+ {
+ /* First see if there's a class match... */
+ if (winMultiWindowGetClassHint (pWin, &res_name, &res_class))
+ {
+ for (i=0; i<pref.sysMenuItems; i++)
+ {
+ if (!strcmp(pref.sysMenu[i].match, res_name) ||
+ !strcmp(pref.sysMenu[i].match, res_class) )
+ {
+ free(res_name);
+ free(res_class);
+
+ MakeMenu (pref.sysMenu[i].menuName, sys,
+ pref.sysMenu[i].menuPos==AT_START?0:-1);
+ return;
+ }
+ }
+
+ /* No match, just free alloc'd strings */
+ free(res_name);
+ free(res_class);
+ } /* Found wm_class */
+ } /* if pwin */
+
+ /* Fallback to system default */
+ if (pref.defaultSysMenuName[0])
+ {
+ if (pref.defaultSysMenuPos==AT_START)
+ MakeMenu (pref.defaultSysMenuName, sys, 0);
+ else
+ MakeMenu (pref.defaultSysMenuName, sys, -1);
+ }
+}
+#endif
+
+
+/*
+ * Possibly add a menu to the toolbar icon
+ */
+void
+SetupRootMenu (unsigned long hmenuRoot)
+{
+ HMENU root;
+
+ root = (HMENU)hmenuRoot;
+ if (!root)
+ return;
+
+ if (pref.rootMenuName[0])
+ {
+ MakeMenu(pref.rootMenuName, root, 0);
+ }
+}
+
+
+/*
+ * Check for and return an overridden default ICON specified in the prefs
+ */
+HICON
+winOverrideDefaultIcon(int size)
+{
+ HICON hicon;
+
+ if (pref.defaultIconName[0])
+ {
+ hicon = LoadImageComma (pref.defaultIconName, size, size, 0);
+ if (hicon==NULL)
+ ErrorF ("winOverrideDefaultIcon: LoadImageComma(%s) failed\n",
+ pref.defaultIconName);
+
+ return hicon;
+ }
+
+ return 0;
+}
+
+
+/*
+ * Return the HICON to use in the taskbar notification area
+ */
+HICON
+winTaskbarIcon(void)
+{
+ HICON hicon;
+
+ hicon = 0;
+ /* First try and load an overridden, if success then return it */
+ if (pref.trayIconName[0])
+ {
+ hicon = LoadImageComma (pref.trayIconName,
+ GetSystemMetrics (SM_CXSMICON),
+ GetSystemMetrics (SM_CYSMICON),
+ 0 );
+ }
+
+ /* Otherwise return the default */
+ if (!hicon)
+ hicon = (HICON) LoadImage (g_hInstance,
+ MAKEINTRESOURCE(IDI_XWIN),
+ IMAGE_ICON,
+ GetSystemMetrics (SM_CXSMICON),
+ GetSystemMetrics (SM_CYSMICON),
+ 0);
+
+ return hicon;
+}
+
+
+/*
+ * Parse a filename to extract an icon:
+ * If fname is exactly ",nnn" then extract icon from our resource
+ * else if it is "file,nnn" then extract icon nnn from that file
+ * else try to load it as an .ico file and if that fails return NULL
+ */
+static HICON
+LoadImageComma (char *fname, int sx, int sy, int flags)
+{
+ HICON hicon;
+ int index;
+ char file[PATH_MAX+NAME_MAX+2];
+
+ /* Some input error checking */
+ if (!fname || !fname[0])
+ return NULL;
+
+ index = 0;
+ hicon = NULL;
+
+ if (fname[0]==',')
+ {
+ /* It's the XWIN.EXE resource they want */
+ index = atoi (fname+1);
+ hicon = LoadImage (g_hInstance,
+ MAKEINTRESOURCE(index),
+ IMAGE_ICON,
+ sx,
+ sy,
+ flags);
+ }
+ else
+ {
+ file[0] = 0;
+ /* Prepend path if not given a "X:\" filename */
+ if ( !(fname[0] && fname[1]==':' && fname[2]=='\\') )
+ {
+ strcpy (file, pref.iconDirectory);
+ if (pref.iconDirectory[0])
+ if (fname[strlen(fname)-1]!='\\')
+ strcat (file, "\\");
+ }
+ strcat (file, fname);
+
+ if (strrchr (file, ','))
+ {
+ /* Specified as <fname>,<index> */
+
+ *(strrchr (file, ',')) = 0; /* End string at comma */
+ index = atoi (strrchr (fname, ',') + 1);
+ hicon = ExtractIcon (g_hInstance, file, index);
+ }
+ else
+ {
+ /* Just an .ico file... */
+
+ hicon = (HICON)LoadImage (NULL,
+ file,
+ IMAGE_ICON,
+ sx,
+ sy,
+ LR_LOADFROMFILE|flags);
+ }
+ }
+ return hicon;
+}
+
+/*
+ * Check for a match of the window class to one specified in the
+ * ICONS{} section in the prefs file, and load the icon from a file
+ */
+HICON
+winOverrideIcon (unsigned long longWin)
+{
+ WindowPtr pWin = (WindowPtr) longWin;
+ char *res_name, *res_class;
+ int i;
+ HICON hicon;
+ char *wmName;
+
+ if (pWin==NULL)
+ return 0;
+
+ /* If we can't find the class, we can't override from default! */
+ if (!winMultiWindowGetClassHint (pWin, &res_name, &res_class))
+ return 0;
+
+ winMultiWindowGetWMName (pWin, &wmName);
+
+ for (i=0; i<pref.iconItems; i++) {
+ if (!strcmp(pref.icon[i].match, res_name) ||
+ !strcmp(pref.icon[i].match, res_class) ||
+ (wmName && strstr(wmName, pref.icon[i].match)))
+ {
+ free (res_name);
+ free (res_class);
+ free(wmName);
+
+ if (pref.icon[i].hicon)
+ return pref.icon[i].hicon;
+
+ hicon = LoadImageComma (pref.icon[i].iconFile, 0, 0, LR_DEFAULTSIZE);
+ if (hicon==NULL)
+ ErrorF ("winOverrideIcon: LoadImageComma(%s) failed\n",
+ pref.icon[i].iconFile);
+
+ pref.icon[i].hicon = hicon;
+ return hicon;
+ }
+ }
+
+ /* Didn't find the icon, fail gracefully */
+ free (res_name);
+ free (res_class);
+ free(wmName);
+
+ return 0;
+}
+
+
+/*
+ * Should we free this icon or leave it in memory (is it part of our
+ * ICONS{} overrides)?
+ */
+int
+winIconIsOverride(unsigned hiconIn)
+{
+ HICON hicon;
+ int i;
+
+ hicon = (HICON)hiconIn;
+
+ if (!hicon)
+ return 0;
+
+ for (i=0; i<pref.iconItems; i++)
+ if ((HICON)pref.icon[i].hicon == hicon)
+ return 1;
+
+ return 0;
+}
+
+
+
+/*
+ * Try and open ~/.XWinrc and system.XWinrc
+ * Load it into prefs structure for use by other functions
+ */
+void
+LoadPreferences (void)
+{
+ char *home;
+ char fname[PATH_MAX+NAME_MAX+2];
+ FILE *prefFile;
+ char szDisplay[512];
+ char *szEnvDisplay;
+ int i, j;
+ char param[PARAM_MAX+1];
+ char *srcParam, *dstParam;
+
+ /* First, clear all preference settings */
+ memset (&pref, 0, sizeof(pref));
+ prefFile = NULL;
+
+ /* Now try and find a ~/.xwinrc file */
+ home = getenv ("HOME");
+ if (home)
+ {
+ strcpy (fname, home);
+ if (fname[strlen(fname)-1]!='/')
+ strcat (fname, "/");
+ strcat (fname, ".XWinrc");
+
+ prefFile = fopen (fname, "r");
+ if (prefFile)
+ {
+ winDebug ("winPrefsLoadPreferences: %s\n", fname);
+ }
+ }
+
+ /* No home file found, check system default */
+ if (!prefFile)
+ {
+ char buffer[MAX_PATH];
+#ifdef RELOCATE_PROJECTROOT
+ snprintf(buffer, sizeof(buffer), "%s\\system.XWinrc", winGetBaseDir());
+#else
+ strncpy(buffer, SYSCONFDIR"/X11/system.XWinrc", sizeof(buffer));
+#endif
+ buffer[sizeof(buffer)-1] = 0;
+ prefFile = fopen (buffer, "r");
+ if (prefFile)
+ {
+ winDebug ("winPrefsLoadPreferences: %s\n", buffer);
+ }
+ }
+
+ /* If we could open it, then read the settings and close it */
+ if (prefFile)
+ {
+ parse_file (prefFile);
+ fclose (prefFile);
+ }
+
+ /* Setup a DISPLAY environment variable, need to allocate on heap */
+ /* because putenv doesn't copy the argument... Always use screen 0 */
+ winGetDisplayName(szDisplay, 0);
+ szEnvDisplay = (char *)(malloc(strlen(szDisplay)+9/*strlen("DISPLAY=")+1*/));
+ snprintf(szEnvDisplay, 512, "DISPLAY=%s", szDisplay);
+ putenv (szEnvDisplay);
+
+ /* Replace any "%display%" in menu commands with display string */
+ for (i=0; i<pref.menuItems; i++)
+ {
+ for (j=0; j<pref.menu[i].menuItems; j++)
+ {
+ if (pref.menu[i].menuItem[j].cmd==CMD_EXEC)
+ {
+ srcParam = pref.menu[i].menuItem[j].param;
+ dstParam = param;
+ while (*srcParam) {
+ if (!strncmp(srcParam, "%display%", 9))
+ {
+ memcpy (dstParam, szDisplay, strlen(szDisplay));
+ dstParam += strlen(szDisplay);
+ srcParam += 9;
+ }
+ else if (!strncmp(srcParam, "%logfile%", 9))
+ {
+ memcpy (dstParam, g_pszLogFile, strlen(g_pszLogFile));
+ dstParam += strlen(g_pszLogFile);
+ srcParam += 9;
+ }
+ else
+ {
+ *dstParam = *srcParam;
+ dstParam++;
+ srcParam++;
+ }
+ }
+ *dstParam = 0;
+ strcpy (pref.menu[i].menuItem[j].param, param);
+ } /* cmd==cmd_exec */
+ } /* for all menuitems */
+ } /* for all menus */
+
+}
+
+
+/*
+ * Check for a match of the window class to one specified in the
+ * STYLES{} section in the prefs file, and return the style type
+ */
+unsigned long
+winOverrideStyle (char *res_name, char *res_class, char *wmName)
+{
+ int i;
+
+ for (i=0; i<pref.styleItems; i++) {
+ if ((res_name && !strcmp(pref.style[i].match, res_name)) ||
+ (res_class && !strcmp(pref.style[i].match, res_class)) ||
+ (wmName && strstr(wmName, pref.style[i].match)))
+ {
+ if (pref.style[i].type)
+ return pref.style[i].type;
+ }
+ }
+
+ /* Didn't find the style, fail gracefully */
+ return STYLE_NONE;
+}
diff --git a/xorg-server/hw/xwin/winprefs.h b/xorg-server/hw/xwin/winprefs.h
index 00f01348d..ecd0a3fbd 100644
--- a/xorg-server/hw/xwin/winprefs.h
+++ b/xorg-server/hw/xwin/winprefs.h
@@ -1,190 +1,190 @@
-#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;
-
-/* The global pref settings structure loaded by the winprefyacc.y parser */
-extern WINPREFS pref;
-
-
-/* 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 (char *res_name, char *res_class, char *wmName);
-
-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;
+
+/* The global pref settings structure loaded by the winprefyacc.y parser */
+extern WINPREFS pref;
+
+
+/* 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 (char *res_name, char *res_class, char *wmName);
+
+HICON
+winTaskbarIcon(void);
+
+HICON
+winOverrideDefaultIcon(int size);
+#endif
diff --git a/xorg-server/hw/xwin/winprefsyacc.y b/xorg-server/hw/xwin/winprefsyacc.y
index b9e961622..d28fbeb8f 100644
--- a/xorg-server/hw/xwin/winprefsyacc.y
+++ b/xorg-server/hw/xwin/winprefsyacc.y
@@ -1,460 +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"
-#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 DEBUGOUTPUT "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: DEBUGOUTPUT 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)
-{
-}
-
+%{
+/*
+ * 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 DEBUGOUTPUT "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: DEBUGOUTPUT 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/winrandr.c b/xorg-server/hw/xwin/winrandr.c
index 7b7ec0c60..596c1ab9d 100644
--- a/xorg-server/hw/xwin/winrandr.c
+++ b/xorg-server/hw/xwin/winrandr.c
@@ -1,221 +1,221 @@
-/*
- *Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved.
- *Copyright (C) 2009-2010 Jon TURNEY
- *
- *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 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 author(s)
- *
- * Authors: Harold L Hunt II
- * Jon TURNEY
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-#include "mivalidate.h" // for union _Validate used by windowstr.h
-
-#ifndef RANDR_12_INTERFACE
-#error X server must have RandR 1.2 interface
-#endif
-
-
-/*
- * Answer queries about the RandR features supported.
- */
-
-static Bool
-winRandRGetInfo (ScreenPtr pScreen, Rotation *pRotations)
-{
- winDebug ("winRandRGetInfo ()\n");
-
- /* Don't support rotations */
- *pRotations = RR_Rotate_0;
-
- /*
- The screen doesn't have to be limited to the actual
- monitor size (we can have scrollbars :-), so what is
- the upper limit?
- */
- RRScreenSetSizeRange(pScreen, 0, 0, 4096, 4096);
-
- return TRUE;
-}
-
-/*
-
-*/
-void
-winDoRandRScreenSetSize (ScreenPtr pScreen,
- CARD16 width,
- CARD16 height,
- CARD32 mmWidth,
- CARD32 mmHeight)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- WindowPtr pRoot = pScreen->root;
-
- // Prevent screen updates while we change things around
- SetRootClip(pScreen, FALSE);
-
- /* Update the screen size as requested */
- pScreenInfo->dwWidth = width;
- pScreenInfo->dwHeight = height;
-
- /* Reallocate the framebuffer used by the drawing engine */
- (*pScreenPriv->pwinFreeFB)(pScreen);
- if (!(*pScreenPriv->pwinAllocateFB)(pScreen))
- {
- ErrorF ("winDoRandRScreenSetSize - Could not reallocate framebuffer\n");
- }
-
- pScreen->width = width;
- pScreen->height = height;
- pScreen->mmWidth = mmWidth;
- pScreen->mmHeight = mmHeight;
-
- /* Update the screen pixmap to point to the new framebuffer */
- winUpdateFBPointer(pScreen, pScreenInfo->pfb);
-
- // pScreen->devPrivate == pScreen->GetScreenPixmap(screen) ?
- // resize the root window
- //pScreen->ResizeWindow(pRoot, 0, 0, width, height, NULL);
- // does this emit a ConfigureNotify??
-
- // Restore the ability to update screen, now with new dimensions
- SetRootClip(pScreen, TRUE);
-
- // and arrange for it to be repainted
- miPaintWindow(pRoot, &pRoot->borderClip, PW_BACKGROUND);
-
- /* Indicate that a screen size change took place */
- RRScreenSizeNotify(pScreen);
-}
-
-/*
- * Respond to resize request
- */
-static
-Bool
-winRandRScreenSetSize (ScreenPtr pScreen,
- CARD16 width,
- CARD16 height,
- CARD32 mmWidth,
- CARD32 mmHeight)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-
- winDebug ("winRandRScreenSetSize ()\n");
-
- /*
- It doesn't currently make sense to allow resize in fullscreen mode
- (we'd actually have to list the supported resolutions)
- */
- if (pScreenInfo->fFullScreen)
- {
- ErrorF ("winRandRScreenSetSize - resize not supported in fullscreen mode\n");
- return FALSE;
- }
-
- /*
- Client resize requests aren't allowed in rootless modes, even if
- the X screen is monitor or virtual desktop size, we'd need to
- resize the native display size
- */
- if (FALSE
-#ifdef XWIN_MULTIWINDOWEXTWM
- || pScreenInfo->fMWExtWM
-#endif
- || pScreenInfo->fRootless
-#ifdef XWIN_MULTIWINDOW
- || pScreenInfo->fMultiWindow
-#endif
- )
- {
- ErrorF ("winRandRScreenSetSize - resize not supported in rootless modes\n");
- return FALSE;
- }
-
- winDoRandRScreenSetSize(pScreen, width, height, mmWidth, mmHeight);
-
- /* Cause the native window for the screen to resize itself */
- {
- DWORD dwStyle, dwExStyle;
- RECT rcClient;
-
- rcClient.left = 0;
- rcClient.top = 0;
- rcClient.right = width;
- rcClient.bottom = height;
-
- ErrorF ("winRandRScreenSetSize new client area w: %d h: %d\n", width, height);
-
- /* Get the Windows window style and extended style */
- dwExStyle = GetWindowLongPtr(pScreenPriv->hwndScreen, GWL_EXSTYLE);
- dwStyle = GetWindowLongPtr(pScreenPriv->hwndScreen, GWL_STYLE);
-
- /*
- * Calculate the window size needed for the given client area
- * adjusting for any decorations it will have
- */
- AdjustWindowRectEx(&rcClient, dwStyle, FALSE, dwExStyle);
-
- ErrorF ("winRandRScreenSetSize new window area w: %ld h: %ld\n", rcClient.right-rcClient.left, rcClient.bottom-rcClient.top);
-
- SetWindowPos(pScreenPriv->hwndScreen, NULL,
- 0, 0, rcClient.right-rcClient.left, rcClient.bottom-rcClient.top,
- SWP_NOZORDER | SWP_NOMOVE);
- }
-
- return TRUE;
-}
-
-/*
- * Initialize the RandR layer.
- */
-
-Bool
-winRandRInit (ScreenPtr pScreen)
-{
- rrScrPrivPtr pRRScrPriv;
- winDebug ("winRandRInit ()\n");
-
- if (!RRScreenInit (pScreen))
- {
- ErrorF ("winRandRInit () - RRScreenInit () failed\n");
- return FALSE;
- }
-
- /* Set some RandR function pointers */
- pRRScrPriv = rrGetScrPriv (pScreen);
- pRRScrPriv->rrGetInfo = winRandRGetInfo;
- pRRScrPriv->rrSetConfig = NULL;
- pRRScrPriv->rrScreenSetSize = winRandRScreenSetSize;
- pRRScrPriv->rrCrtcSet = NULL;
- pRRScrPriv->rrCrtcSetGamma = NULL;
-
- return TRUE;
-}
+/*
+ *Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved.
+ *Copyright (C) 2009-2010 Jon TURNEY
+ *
+ *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 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 author(s)
+ *
+ * Authors: Harold L Hunt II
+ * Jon TURNEY
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+#include "mivalidate.h" // for union _Validate used by windowstr.h
+
+#ifndef RANDR_12_INTERFACE
+#error X server must have RandR 1.2 interface
+#endif
+
+
+/*
+ * Answer queries about the RandR features supported.
+ */
+
+static Bool
+winRandRGetInfo (ScreenPtr pScreen, Rotation *pRotations)
+{
+ winDebug ("winRandRGetInfo ()\n");
+
+ /* Don't support rotations */
+ *pRotations = RR_Rotate_0;
+
+ /*
+ The screen doesn't have to be limited to the actual
+ monitor size (we can have scrollbars :-), so what is
+ the upper limit?
+ */
+ RRScreenSetSizeRange(pScreen, 0, 0, 4096, 4096);
+
+ return TRUE;
+}
+
+/*
+
+*/
+void
+winDoRandRScreenSetSize (ScreenPtr pScreen,
+ CARD16 width,
+ CARD16 height,
+ CARD32 mmWidth,
+ CARD32 mmHeight)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ WindowPtr pRoot = pScreen->root;
+
+ // Prevent screen updates while we change things around
+ SetRootClip(pScreen, FALSE);
+
+ /* Update the screen size as requested */
+ pScreenInfo->dwWidth = width;
+ pScreenInfo->dwHeight = height;
+
+ /* Reallocate the framebuffer used by the drawing engine */
+ (*pScreenPriv->pwinFreeFB)(pScreen);
+ if (!(*pScreenPriv->pwinAllocateFB)(pScreen))
+ {
+ ErrorF ("winDoRandRScreenSetSize - Could not reallocate framebuffer\n");
+ }
+
+ pScreen->width = width;
+ pScreen->height = height;
+ pScreen->mmWidth = mmWidth;
+ pScreen->mmHeight = mmHeight;
+
+ /* Update the screen pixmap to point to the new framebuffer */
+ winUpdateFBPointer(pScreen, pScreenInfo->pfb);
+
+ // pScreen->devPrivate == pScreen->GetScreenPixmap(screen) ?
+ // resize the root window
+ //pScreen->ResizeWindow(pRoot, 0, 0, width, height, NULL);
+ // does this emit a ConfigureNotify??
+
+ // Restore the ability to update screen, now with new dimensions
+ SetRootClip(pScreen, TRUE);
+
+ // and arrange for it to be repainted
+ miPaintWindow(pRoot, &pRoot->borderClip, PW_BACKGROUND);
+
+ /* Indicate that a screen size change took place */
+ RRScreenSizeNotify(pScreen);
+}
+
+/*
+ * Respond to resize request
+ */
+static
+Bool
+winRandRScreenSetSize (ScreenPtr pScreen,
+ CARD16 width,
+ CARD16 height,
+ CARD32 mmWidth,
+ CARD32 mmHeight)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ winDebug ("winRandRScreenSetSize ()\n");
+
+ /*
+ It doesn't currently make sense to allow resize in fullscreen mode
+ (we'd actually have to list the supported resolutions)
+ */
+ if (pScreenInfo->fFullScreen)
+ {
+ ErrorF ("winRandRScreenSetSize - resize not supported in fullscreen mode\n");
+ return FALSE;
+ }
+
+ /*
+ Client resize requests aren't allowed in rootless modes, even if
+ the X screen is monitor or virtual desktop size, we'd need to
+ resize the native display size
+ */
+ if (FALSE
+#ifdef XWIN_MULTIWINDOWEXTWM
+ || pScreenInfo->fMWExtWM
+#endif
+ || pScreenInfo->fRootless
+#ifdef XWIN_MULTIWINDOW
+ || pScreenInfo->fMultiWindow
+#endif
+ )
+ {
+ ErrorF ("winRandRScreenSetSize - resize not supported in rootless modes\n");
+ return FALSE;
+ }
+
+ winDoRandRScreenSetSize(pScreen, width, height, mmWidth, mmHeight);
+
+ /* Cause the native window for the screen to resize itself */
+ {
+ DWORD dwStyle, dwExStyle;
+ RECT rcClient;
+
+ rcClient.left = 0;
+ rcClient.top = 0;
+ rcClient.right = width;
+ rcClient.bottom = height;
+
+ ErrorF ("winRandRScreenSetSize new client area w: %d h: %d\n", width, height);
+
+ /* Get the Windows window style and extended style */
+ dwExStyle = GetWindowLongPtr(pScreenPriv->hwndScreen, GWL_EXSTYLE);
+ dwStyle = GetWindowLongPtr(pScreenPriv->hwndScreen, GWL_STYLE);
+
+ /*
+ * Calculate the window size needed for the given client area
+ * adjusting for any decorations it will have
+ */
+ AdjustWindowRectEx(&rcClient, dwStyle, FALSE, dwExStyle);
+
+ ErrorF ("winRandRScreenSetSize new window area w: %ld h: %ld\n", rcClient.right-rcClient.left, rcClient.bottom-rcClient.top);
+
+ SetWindowPos(pScreenPriv->hwndScreen, NULL,
+ 0, 0, rcClient.right-rcClient.left, rcClient.bottom-rcClient.top,
+ SWP_NOZORDER | SWP_NOMOVE);
+ }
+
+ return TRUE;
+}
+
+/*
+ * Initialize the RandR layer.
+ */
+
+Bool
+winRandRInit (ScreenPtr pScreen)
+{
+ rrScrPrivPtr pRRScrPriv;
+ winDebug ("winRandRInit ()\n");
+
+ if (!RRScreenInit (pScreen))
+ {
+ ErrorF ("winRandRInit () - RRScreenInit () failed\n");
+ return FALSE;
+ }
+
+ /* Set some RandR function pointers */
+ pRRScrPriv = rrGetScrPriv (pScreen);
+ pRRScrPriv->rrGetInfo = winRandRGetInfo;
+ pRRScrPriv->rrSetConfig = NULL;
+ pRRScrPriv->rrScreenSetSize = winRandRScreenSetSize;
+ pRRScrPriv->rrCrtcSet = NULL;
+ pRRScrPriv->rrCrtcSetGamma = NULL;
+
+ return TRUE;
+}
diff --git a/xorg-server/hw/xwin/winscrinit.c b/xorg-server/hw/xwin/winscrinit.c
index baa2b7f3a..3cf74cdcc 100644
--- a/xorg-server/hw/xwin/winscrinit.c
+++ b/xorg-server/hw/xwin/winscrinit.c
@@ -1,760 +1,760 @@
-/*
- *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,
- winMWExtWMDamageRects,
- winMWExtWMRootlessSwitchWindow,
- NULL,//winMWExtWMDoReorderWindow,
- NULL,//winMWExtWMHideWindow,
- NULL,//winMWExtWMUpdateColorMap,
-
- NULL,//winMWExtWMCopyBytes,
- winMWExtWMCopyWindow
-};
-#endif
-
-/*
- * Prototypes
- */
-
-/*
- * 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;
- DWORD dwInitialBPP;
-
- 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;
- }
-
- /* Horribly misnamed function: Allow engine to adjust BPP for screen */
- dwInitialBPP = pScreenInfo->dwBPP;
-
- if (pScreenPriv->pwinAdjustVideoMode && !(*pScreenPriv->pwinAdjustVideoMode) (pScreen))
- {
- ErrorF ("winScreenInit - winAdjustVideoMode () failed\n");
- return FALSE;
- }
-
- if (dwInitialBPP == WIN_DEFAULT_BPP)
- {
- /* No -depth parameter was passed, let the user know the depth being used */
- winDebug ("winScreenInit - Using Windows display depth of %d bits per pixel\n", (int) pScreenInfo->dwBPP);
- }
- else if (dwInitialBPP != pScreenInfo->dwBPP)
- {
- /* Warn user if engine forced a depth different to -depth parameter */
- winDebug ("winScreenInit - Command line depth of %d bpp overidden by engine, using %d bpp\n", (int) dwInitialBPP, (int) pScreenInfo->dwBPP);
- }
- else
- {
- winDebug ("winScreenInit - Using command line depth of %d bpp\n", (int) pScreenInfo->dwBPP);
- }
-
- /* 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");
- if (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_GDI)
- {
- ErrorF ("winScreenInit - Performance may suffer off primary display.\n");
- }
- else
- {
- ErrorF ("winScreenInit - 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);
-
- /* Are we using multiple monitors? */
- if (pScreenInfo->fMultipleMonitors)
- {
- /*
- * In this case, some of the defaults set in
- * winInitializeScreenDefaults() are not correct ...
- */
- if (!pScreenInfo->fUserGaveHeightAndWidth)
- {
- pScreenInfo->dwWidth = GetSystemMetrics (SM_CXVIRTUALSCREEN);
- pScreenInfo->dwHeight = GetSystemMetrics (SM_CYVIRTUALSCREEN);
- }
- }
-
- /* Release the device context */
- ReleaseDC (pScreenPriv->hwndScreen, hdc);
-
- /* Clear the visuals list */
- miClearVisualTypes ();
-
- /* Call the engine dependent screen initialization procedure */
- if (pScreenPriv->pwinFinishScreenInit && !((*pScreenPriv->pwinFinishScreenInit) (index, pScreen, argc, argv)))
- {
- ErrorF ("winScreenInit - winFinishScreenInit () failed\n");
-
- /* call the engine dependent screen close procedure to clean up from a failure */
- pScreenPriv->pwinCloseScreen(index, pScreen);
-
- 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
- */
- pScreen->x = pScreenInfo->dwInitialX - GetSystemMetrics(SM_XVIRTUALSCREEN);
- pScreen->y = pScreenInfo->dwInitialY - GetSystemMetrics(SM_YVIRTUALSCREEN);
-
- winDebug("Screen %d added at virtual desktop coordinate (%d,%d).\n",
- index, pScreen->x, pScreen->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->pwinInitScreen) (pScreen))
- {
- ErrorF ("winFinishScreenInitFB - Could not allocate framebuffer\n");
- return FALSE;
- }
-
- /*
- * Calculate the number of bits that are used to represent color in each pixel,
- * the color depth for the screen
- */
- 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;
-
- /* Render extension initialization, calls miPictureInit */
- if (!fbPictureInit (pScreen, NULL, 0))
- {
- ErrorF ("winFinishScreenInitFB - fbPictureInit () failed\n");
- return FALSE;
- }
-
-#ifdef RANDR
- /* Initialize resize and rotate support */
- if (!winRandRInit (pScreen))
- {
- ErrorF ("winFinishScreenInitFB - winRandRInit () failed\n");
- return FALSE;
- }
-#endif
-
- /* 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;
- /* 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_MULTIWINDOWINTWM
- || 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_MULTIWINDOWINTWM
- 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;
-}
+/*
+ *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,
+ winMWExtWMDamageRects,
+ winMWExtWMRootlessSwitchWindow,
+ NULL,//winMWExtWMDoReorderWindow,
+ NULL,//winMWExtWMHideWindow,
+ NULL,//winMWExtWMUpdateColorMap,
+
+ NULL,//winMWExtWMCopyBytes,
+ winMWExtWMCopyWindow
+};
+#endif
+
+/*
+ * Prototypes
+ */
+
+/*
+ * 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;
+ DWORD dwInitialBPP;
+
+ 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;
+ }
+
+ /* Horribly misnamed function: Allow engine to adjust BPP for screen */
+ dwInitialBPP = pScreenInfo->dwBPP;
+
+ if (pScreenPriv->pwinAdjustVideoMode && !(*pScreenPriv->pwinAdjustVideoMode) (pScreen))
+ {
+ ErrorF ("winScreenInit - winAdjustVideoMode () failed\n");
+ return FALSE;
+ }
+
+ if (dwInitialBPP == WIN_DEFAULT_BPP)
+ {
+ /* No -depth parameter was passed, let the user know the depth being used */
+ winDebug ("winScreenInit - Using Windows display depth of %d bits per pixel\n", (int) pScreenInfo->dwBPP);
+ }
+ else if (dwInitialBPP != pScreenInfo->dwBPP)
+ {
+ /* Warn user if engine forced a depth different to -depth parameter */
+ winDebug ("winScreenInit - Command line depth of %d bpp overidden by engine, using %d bpp\n", (int) dwInitialBPP, (int) pScreenInfo->dwBPP);
+ }
+ else
+ {
+ winDebug ("winScreenInit - Using command line depth of %d bpp\n", (int) pScreenInfo->dwBPP);
+ }
+
+ /* 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");
+ if (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_GDI)
+ {
+ ErrorF ("winScreenInit - Performance may suffer off primary display.\n");
+ }
+ else
+ {
+ ErrorF ("winScreenInit - 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);
+
+ /* Are we using multiple monitors? */
+ if (pScreenInfo->fMultipleMonitors)
+ {
+ /*
+ * In this case, some of the defaults set in
+ * winInitializeScreenDefaults() are not correct ...
+ */
+ if (!pScreenInfo->fUserGaveHeightAndWidth)
+ {
+ pScreenInfo->dwWidth = GetSystemMetrics (SM_CXVIRTUALSCREEN);
+ pScreenInfo->dwHeight = GetSystemMetrics (SM_CYVIRTUALSCREEN);
+ }
+ }
+
+ /* Release the device context */
+ ReleaseDC (pScreenPriv->hwndScreen, hdc);
+
+ /* Clear the visuals list */
+ miClearVisualTypes ();
+
+ /* Call the engine dependent screen initialization procedure */
+ if (pScreenPriv->pwinFinishScreenInit && !((*pScreenPriv->pwinFinishScreenInit) (index, pScreen, argc, argv)))
+ {
+ ErrorF ("winScreenInit - winFinishScreenInit () failed\n");
+
+ /* call the engine dependent screen close procedure to clean up from a failure */
+ pScreenPriv->pwinCloseScreen(index, pScreen);
+
+ 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
+ */
+ pScreen->x = pScreenInfo->dwInitialX - GetSystemMetrics(SM_XVIRTUALSCREEN);
+ pScreen->y = pScreenInfo->dwInitialY - GetSystemMetrics(SM_YVIRTUALSCREEN);
+
+ winDebug("Screen %d added at virtual desktop coordinate (%d,%d).\n",
+ index, pScreen->x, pScreen->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->pwinInitScreen) (pScreen))
+ {
+ ErrorF ("winFinishScreenInitFB - Could not allocate framebuffer\n");
+ return FALSE;
+ }
+
+ /*
+ * Calculate the number of bits that are used to represent color in each pixel,
+ * the color depth for the screen
+ */
+ 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;
+
+ /* Render extension initialization, calls miPictureInit */
+ if (!fbPictureInit (pScreen, NULL, 0))
+ {
+ ErrorF ("winFinishScreenInitFB - fbPictureInit () failed\n");
+ return FALSE;
+ }
+
+#ifdef RANDR
+ /* Initialize resize and rotate support */
+ if (!winRandRInit (pScreen))
+ {
+ ErrorF ("winFinishScreenInitFB - winRandRInit () failed\n");
+ return FALSE;
+ }
+#endif
+
+ /* 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;
+ /* 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_MULTIWINDOWINTWM
+ || 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_MULTIWINDOWINTWM
+ 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 0f6afe2f3..b4fa47bae 100644
--- a/xorg-server/hw/xwin/winshaddd.c
+++ b/xorg-server/hw/xwin/winshaddd.c
@@ -1,1326 +1,1326 @@
-/*
- *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 Bool
-winAllocateFBShadowDD (ScreenPtr pScreen);
-
-static void
-winShadowUpdateDD (ScreenPtr pScreen,
- shadowBufPtr pBuf);
-
-static Bool
-winCloseScreenShadowDD (int nIndex, ScreenPtr pScreen);
-
-static Bool
-winInitVisualsShadowDD (ScreenPtr pScreen);
-
-static Bool
-winAdjustVideoModeShadowDD (ScreenPtr pScreen);
-
-static Bool
-winBltExposedRegionsShadowDD (ScreenPtr pScreen);
-
-static Bool
-winActivateAppShadowDD (ScreenPtr pScreen);
-
-static Bool
-winRedrawScreenShadowDD (ScreenPtr pScreen);
-
-static Bool
-winRealizeInstalledPaletteShadowDD (ScreenPtr pScreen);
-
-static Bool
-winInstallColormapShadowDD (ColormapPtr pColormap);
-
-static Bool
-winStoreColorsShadowDD (ColormapPtr pmap,
- int ndef,
- xColorItem *pdefs);
-
-static Bool
-winCreateColormapShadowDD (ColormapPtr pColormap);
-
-static Bool
-winDestroyColormapShadowDD (ColormapPtr pColormap);
-
-static Bool
-winCreatePrimarySurfaceShadowDD (ScreenPtr pScreen);
-
-static Bool
-winReleasePrimarySurfaceShadowDD (ScreenPtr pScreen);
-
-
-/*
- * Create the primary surface and attach the clipper.
- * Used for both the initial surface creation and during
- * WM_DISPLAYCHANGE messages.
- */
-
-static Bool
-winCreatePrimarySurfaceShadowDD (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- HRESULT ddrval = DD_OK;
- DDSURFACEDESC ddsd;
-
- /* Describe the primary surface */
- ZeroMemory (&ddsd, sizeof (ddsd));
- ddsd.dwSize = sizeof (ddsd);
- ddsd.dwFlags = DDSD_CAPS;
- ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
-
- /* Create the primary surface */
- ddrval = IDirectDraw2_CreateSurface (pScreenPriv->pdd2,
- &ddsd,
- &pScreenPriv->pddsPrimary,
- NULL);
- if (FAILED (ddrval))
- {
- ErrorF ("winCreatePrimarySurfaceShadowDD - Could not create primary "
- "surface: %08x\n", (unsigned int) ddrval);
- return FALSE;
- }
-
- winDebug ("winCreatePrimarySurfaceShadowDD - Created primary surface\n");
-
- /*
- * Attach a clipper to the primary surface that will clip our blits to our
- * display window.
- */
- ddrval = IDirectDrawSurface2_SetClipper (pScreenPriv->pddsPrimary,
- pScreenPriv->pddcPrimary);
- if (FAILED (ddrval))
- {
- ErrorF ("winCreatePrimarySurfaceShadowDD - Primary attach clipper "
- "failed: %08x\n",
- (unsigned int) ddrval);
- return FALSE;
- }
-
- winDebug ("winCreatePrimarySurfaceShadowDD - Attached clipper to "
- "primary surface\n");
-
- /* Everything was correct */
- return TRUE;
-}
-
-
-/*
- * Detach the clipper and release the primary surface.
- * Called from WM_DISPLAYCHANGE.
- */
-
-static Bool
-winReleasePrimarySurfaceShadowDD (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
-
- winDebug ("winReleasePrimarySurfaceShadowDD - Hello\n");
-
- /* Release the primary surface and clipper, if they exist */
- if (pScreenPriv->pddsPrimary)
- {
- /*
- * Detach the clipper from the primary surface.
- * NOTE: We do this explicity for clarity. The Clipper is not released.
- */
- IDirectDrawSurface2_SetClipper (pScreenPriv->pddsPrimary,
- NULL);
-
- winDebug ("winReleasePrimarySurfaceShadowDD - Detached clipper\n");
-
- /* Release the primary surface */
- IDirectDrawSurface2_Release (pScreenPriv->pddsPrimary);
- pScreenPriv->pddsPrimary = NULL;
- }
-
- winDebug ("winReleasePrimarySurfaceShadowDD - Released primary surface\n");
-
- return TRUE;
-}
-
-
-/*
- * Create a DirectDraw surface for the shadow framebuffer; also create
- * a primary surface object so we can blit to the display.
- *
- * Install a DirectDraw clipper on our primary surface object
- * that clips our blits to the unobscured client area of our display window.
- */
-
-static Bool
-winAllocateFBShadowDD (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- HRESULT ddrval = DD_OK;
- DDSURFACEDESC ddsd;
- DDSURFACEDESC *pddsdShadow = NULL;
-
- winDebug ("winAllocateFBShadowDD\n");
-
- /* Create a clipper */
- ddrval = (*g_fpDirectDrawCreateClipper) (0,
- &pScreenPriv->pddcPrimary,
- NULL);
- if (FAILED (ddrval))
- {
- ErrorF ("winAllocateFBShadowDD - Could not create clipper: %08x\n",
- (unsigned int) ddrval);
- return FALSE;
- }
-
- winDebug ("winAllocateFBShadowDD - Created a clipper\n");
-
- /* Attach the clipper to our display window */
- ddrval = IDirectDrawClipper_SetHWnd (pScreenPriv->pddcPrimary,
- 0,
- pScreenPriv->hwndScreen);
- if (FAILED (ddrval))
- {
- ErrorF ("winAllocateFBShadowDD - Clipper not attached to "
- "window: %08x\n",
- (unsigned int) ddrval);
- return FALSE;
- }
-
- winDebug ("winAllocateFBShadowDD - Attached clipper to window\n");
-
- /* Create a DirectDraw object, store the address at lpdd */
- ddrval = (*g_fpDirectDrawCreate) (NULL, &pScreenPriv->pdd, NULL);
- if (FAILED (ddrval))
- {
- ErrorF ("winAllocateFBShadowDD - Could not start DirectDraw: %08x\n",
- (unsigned int) ddrval);
- return FALSE;
- }
-
- winDebug ("winAllocateFBShadowDD () - Created and initialized DD\n");
-
- /* Get a DirectDraw2 interface pointer */
- ddrval = IDirectDraw_QueryInterface (pScreenPriv->pdd,
- &IID_IDirectDraw2,
- (LPVOID*) &pScreenPriv->pdd2);
- if (FAILED (ddrval))
- {
- ErrorF ("winAllocateFBShadowDD - Failed DD2 query: %08x\n",
- (unsigned int) ddrval);
- return FALSE;
- }
-
- /* Are we full screen? */
- if (pScreenInfo->fFullScreen)
- {
- DDSURFACEDESC ddsdCurrent;
- DWORD dwRefreshRateCurrent = 0;
- HDC hdc = NULL;
-
- /* Set the cooperative level to full screen */
- ddrval = IDirectDraw2_SetCooperativeLevel (pScreenPriv->pdd2,
- pScreenPriv->hwndScreen,
- DDSCL_EXCLUSIVE
- | DDSCL_FULLSCREEN);
- if (FAILED (ddrval))
- {
- ErrorF ("winAllocateFBShadowDD - Could not set "
- "cooperative level: %08x\n",
- (unsigned int) ddrval);
- return FALSE;
- }
-
- /*
- * We only need to get the current refresh rate for comparison
- * if a refresh rate has been passed on the command line.
- */
- if (pScreenInfo->dwRefreshRate != 0)
- {
- ZeroMemory (&ddsdCurrent, sizeof (ddsdCurrent));
- ddsdCurrent.dwSize = sizeof (ddsdCurrent);
-
- /* Get information about current display settings */
- ddrval = IDirectDraw2_GetDisplayMode (pScreenPriv->pdd2,
- &ddsdCurrent);
- if (FAILED (ddrval))
- {
- ErrorF ("winAllocateFBShadowDD - Could not get current "
- "refresh rate: %08x. Continuing.\n",
- (unsigned int) ddrval);
- dwRefreshRateCurrent = 0;
- }
- else
- {
- /* Grab the current refresh rate */
- dwRefreshRateCurrent = ddsdCurrent.u2.dwRefreshRate;
- }
- }
-
- /* Clean up the refresh rate */
- if (dwRefreshRateCurrent == pScreenInfo->dwRefreshRate)
- {
- /*
- * Refresh rate is non-specified or equal to current.
- */
- pScreenInfo->dwRefreshRate = 0;
- }
-
- /* Grab a device context for the screen */
- hdc = GetDC (NULL);
- if (hdc == NULL)
- {
- ErrorF ("winAllocateFBShadowDD - GetDC () failed\n");
- return FALSE;
- }
-
- /* Only change the video mode when different than current mode */
- if (!pScreenInfo->fMultipleMonitors
- && (pScreenInfo->dwWidth != GetSystemMetrics (SM_CXSCREEN)
- || pScreenInfo->dwHeight != GetSystemMetrics (SM_CYSCREEN)
- || pScreenInfo->dwBPP != GetDeviceCaps (hdc, BITSPIXEL)
- || pScreenInfo->dwRefreshRate != 0))
- {
- 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,
- pScreenInfo->dwWidth,
- pScreenInfo->dwHeight,
- pScreenInfo->dwBPP,
- pScreenInfo->dwRefreshRate,
- 0);
- if (FAILED (ddrval))
- {
- ErrorF ("winAllocateFBShadowDD - Could not set "\
- "full screen display mode: %08x\n",
- (unsigned int) ddrval);
- ErrorF ("winAllocateFBShadowDD - Using default driver refresh rate\n");
- ddrval = IDirectDraw2_SetDisplayMode (pScreenPriv->pdd2,
- pScreenInfo->dwWidth,
- pScreenInfo->dwHeight,
- pScreenInfo->dwBPP,
- 0,
- 0);
- if (FAILED(ddrval))
- {
- ErrorF ("winAllocateFBShadowDD - Could not set default refresh rate "
- "full screen display mode: %08x\n",
- (unsigned int) ddrval);
- return FALSE;
- }
- }
- }
- else
- {
- winDebug ("winAllocateFBShadowDD - Not changing video mode\n");
- }
-
- /* Release our DC */
- ReleaseDC (NULL, hdc);
- hdc = NULL;
- }
- else
- {
- /* Set the cooperative level for windowed mode */
- ddrval = IDirectDraw2_SetCooperativeLevel (pScreenPriv->pdd2,
- pScreenPriv->hwndScreen,
- DDSCL_NORMAL);
- if (FAILED (ddrval))
- {
- ErrorF ("winAllocateFBShadowDD - Could not set "\
- "cooperative level: %08x\n",
- (unsigned int) ddrval);
- return FALSE;
- }
- }
-
- /* Create the primary surface */
- if (!winCreatePrimarySurfaceShadowDD (pScreen))
- {
- ErrorF ("winAllocateFBShadowDD - winCreatePrimarySurfaceShadowDD "
- "failed\n");
- return FALSE;
- }
-
- /* Describe the shadow surface to be created */
- /* NOTE: Do not use a DDSCAPS_VIDEOMEMORY surface,
- * as drawing, locking, and unlocking take forever
- * with video memory surfaces. In addition,
- * video memory is a somewhat scarce resource,
- * so you shouldn't be allocating video memory when
- * you have the option of using system memory instead.
- */
- ZeroMemory (&ddsd, sizeof (ddsd));
- ddsd.dwSize = sizeof (ddsd);
- ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
- ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
- ddsd.dwHeight = pScreenInfo->dwHeight;
- ddsd.dwWidth = pScreenInfo->dwWidth;
-
- /* Create the shadow surface */
- ddrval = IDirectDraw2_CreateSurface (pScreenPriv->pdd2,
- &ddsd,
- &pScreenPriv->pddsShadow,
- NULL);
- if (FAILED (ddrval))
- {
- ErrorF ("winAllocateFBShadowDD - Could not create shadow "\
- "surface: %08x\n", (unsigned int) ddrval);
- return FALSE;
- }
-
- winDebug ("winAllocateFBShadowDD - Created shadow\n");
-
- /* Allocate a DD surface description for our screen privates */
- pddsdShadow = pScreenPriv->pddsdShadow = malloc (sizeof (DDSURFACEDESC));
- if (pddsdShadow == NULL)
- {
- ErrorF ("winAllocateFBShadowDD - Could not allocate surface "\
- "description memory\n");
- return FALSE;
- }
- ZeroMemory (pddsdShadow, sizeof (*pddsdShadow));
- pddsdShadow->dwSize = sizeof (*pddsdShadow);
-
- winDebug ("winAllocateFBShadowDD - Locking shadow\n");
-
- /* Lock the shadow surface */
- ddrval = IDirectDrawSurface2_Lock (pScreenPriv->pddsShadow,
- NULL,
- pddsdShadow,
- DDLOCK_WAIT,
- NULL);
- if (FAILED (ddrval) || pddsdShadow->lpSurface == NULL)
- {
- ErrorF ("winAllocateFBShadowDD - Could not lock shadow "\
- "surface: %08x\n", (unsigned int) ddrval);
- return FALSE;
- }
-
- winDebug ("winAllocateFBShadowDD - Locked shadow\n");
-
- /* We don't know how to deal with anything other than RGB */
- if (!(pddsdShadow->ddpfPixelFormat.dwFlags & DDPF_RGB))
- {
- ErrorF ("winAllocateFBShadowDD - Color format other than RGB\n");
- return FALSE;
- }
-
- /* Grab the pitch from the surface desc */
- pScreenInfo->dwStride = (pddsdShadow->u1.lPitch * 8)
- / pScreenInfo->dwBPP;
-
- /* Save the pointer to our surface memory */
- pScreenInfo->pfb = pddsdShadow->lpSurface;
-
- /* Grab the color depth and masks from the surface description */
- pScreenPriv->dwRedMask = pddsdShadow->ddpfPixelFormat.u2.dwRBitMask;
- pScreenPriv->dwGreenMask = pddsdShadow->ddpfPixelFormat.u3.dwGBitMask;
- pScreenPriv->dwBlueMask = pddsdShadow->ddpfPixelFormat.u4.dwBBitMask;
-
- winDebug ("winAllocateFBShadowDD - Returning\n");
-
- return TRUE;
-}
-
-static void
-winFreeFBShadowDD (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-
- /* Free the shadow surface, if there is one */
- if (pScreenPriv->pddsShadow)
- {
- IDirectDrawSurface2_Unlock (pScreenPriv->pddsShadow, NULL);
- IDirectDrawSurface2_Release (pScreenPriv->pddsShadow);
- pScreenPriv->pddsShadow = NULL;
- }
-
- /* Detach the clipper from the primary surface and release the primary surface, if there is one */
- winReleasePrimarySurfaceShadowDD(pScreen);
-
- /* Release the clipper object */
- if (pScreenPriv->pddcPrimary)
- {
- IDirectDrawClipper_Release (pScreenPriv->pddcPrimary);
- pScreenPriv->pddcPrimary = NULL;
- }
-
- /* Free the DirectDraw2 object, if there is one */
- if (pScreenPriv->pdd2)
- {
- IDirectDraw2_RestoreDisplayMode (pScreenPriv->pdd2);
- IDirectDraw2_Release (pScreenPriv->pdd2);
- pScreenPriv->pdd2 = NULL;
- }
-
- /* Free the DirectDraw object, if there is one */
- if (pScreenPriv->pdd)
- {
- IDirectDraw_Release (pScreenPriv->pdd);
- pScreenPriv->pdd = NULL;
- }
-
- /* Invalidate the ScreenInfo's fb pointer */
- pScreenInfo->pfb = NULL;
-}
-
-/*
- * Transfer the damaged regions of the shadow framebuffer to the display.
- */
-
-static void
-winShadowUpdateDD (ScreenPtr pScreen,
- shadowBufPtr pBuf)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- RegionPtr damage = shadowDamage(pBuf);
- HRESULT ddrval = DD_OK;
- RECT rcDest, rcSrc;
- POINT ptOrigin;
- DWORD dwBox = RegionNumRects (damage);
- BoxPtr pBox = RegionRects (damage);
- HRGN hrgnTemp = NULL, hrgnCombined = NULL;
-
- /*
- * Return immediately if the app is not active
- * and we are fullscreen, or if we have a bad display depth
- */
- if ((!pScreenPriv->fActive && pScreenInfo->fFullScreen)
- || pScreenPriv->fBadDepth) return;
-
- /* Return immediately if we didn't get needed surfaces */
- if (!pScreenPriv->pddsPrimary || !pScreenPriv->pddsShadow)
- return;
-
- /* Get the origin of the window in the screen coords */
- ptOrigin.x = pScreenInfo->dwXOffset;
- ptOrigin.y = pScreenInfo->dwYOffset;
- MapWindowPoints (pScreenPriv->hwndScreen,
- HWND_DESKTOP,
- (LPPOINT)&ptOrigin, 1);
-
- /* Unlock the shadow surface, so we can blit */
- ddrval = IDirectDrawSurface2_Unlock (pScreenPriv->pddsShadow, NULL);
- if (FAILED (ddrval))
- {
- ErrorF ("winShadowUpdateDD - Unlock failed\n");
- return;
- }
-
- /*
- * Handle small regions with multiple blits,
- * handle large regions by creating a clipping region and
- * doing a single blit constrained to that clipping region.
- */
- if (pScreenInfo->dwClipUpdatesNBoxes == 0
- || dwBox < pScreenInfo->dwClipUpdatesNBoxes)
- {
- /* Loop through all boxes in the damaged region */
- while (dwBox--)
- {
- /* Assign damage box to source rectangle */
- rcSrc.left = pBox->x1;
- rcSrc.top = pBox->y1;
- rcSrc.right = pBox->x2;
- rcSrc.bottom = pBox->y2;
-
- /* Calculate destination rectange */
- rcDest.left = ptOrigin.x + rcSrc.left;
- rcDest.top = ptOrigin.y + rcSrc.top;
- rcDest.right = ptOrigin.x + rcSrc.right;
- rcDest.bottom = ptOrigin.y + rcSrc.bottom;
-
- /* Blit the damaged areas */
- ddrval = IDirectDrawSurface2_Blt (pScreenPriv->pddsPrimary,
- &rcDest,
- pScreenPriv->pddsShadow,
- &rcSrc,
- DDBLT_WAIT,
- NULL);
-
- /* Get a pointer to the next box */
- ++pBox;
- }
- }
- else
- {
- BoxPtr pBoxExtents = RegionExtents(damage);
-
- /* Compute a GDI region from the damaged region */
- hrgnCombined = CreateRectRgn (pBox->x1, pBox->y1, pBox->x2, pBox->y2);
- dwBox--;
- pBox++;
- while (dwBox--)
- {
- hrgnTemp = CreateRectRgn (pBox->x1, pBox->y1, pBox->x2, pBox->y2);
- CombineRgn (hrgnCombined, hrgnCombined, hrgnTemp, RGN_OR);
- DeleteObject (hrgnTemp);
- pBox++;
- }
-
- /* Install the GDI region as a clipping region */
- SelectClipRgn (pScreenPriv->hdcScreen, hrgnCombined);
- DeleteObject (hrgnCombined);
- hrgnCombined = NULL;
-
- /* Calculating a bounding box for the source is easy */
- rcSrc.left = pBoxExtents->x1;
- rcSrc.top = pBoxExtents->y1;
- rcSrc.right = pBoxExtents->x2;
- rcSrc.bottom = pBoxExtents->y2;
-
- /* Calculating a bounding box for the destination is trickier */
- rcDest.left = ptOrigin.x + rcSrc.left;
- rcDest.top = ptOrigin.y + rcSrc.top;
- rcDest.right = ptOrigin.x + rcSrc.right;
- rcDest.bottom = ptOrigin.y + rcSrc.bottom;
-
- /* Our Blt should be clipped to the invalidated region */
- ddrval = IDirectDrawSurface2_Blt (pScreenPriv->pddsPrimary,
- &rcDest,
- pScreenPriv->pddsShadow,
- &rcSrc,
- DDBLT_WAIT,
- NULL);
-
- /* Reset the clip region */
- SelectClipRgn (pScreenPriv->hdcScreen, NULL);
- }
-
- /* Relock the shadow surface */
- ddrval = IDirectDrawSurface2_Lock (pScreenPriv->pddsShadow,
- NULL,
- pScreenPriv->pddsdShadow,
- DDLOCK_WAIT,
- NULL);
- if (FAILED (ddrval))
- {
- ErrorF ("winShadowUpdateDD - Lock failed\n");
- return;
- }
-
- /* Has our memory pointer changed? */
- if (pScreenInfo->pfb != pScreenPriv->pddsdShadow->lpSurface)
- {
- extern const 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 "
- "this message and "PROJECT_NAME" freezes or crashes "
- "after this message then send a problem report and your "
- "%s file to " BUILDERADDR "\n", g_pszLogFile);
-
- /* Location of shadow framebuffer has changed */
- winUpdateFBPointer(pScreen, pScreenPriv->pddsdShadow->lpSurface);
- }
-}
-
-static Bool
-winInitScreenShadowDD (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
-
- /* Get a device context for the screen */
- pScreenPriv->hdcScreen = GetDC (pScreenPriv->hwndScreen);
-
- return winAllocateFBShadowDD(pScreen);
-}
-
-/*
- * Call the wrapped CloseScreen function.
- *
- * Free our resources and private structures.
- */
-
-static Bool
-winCloseScreenShadowDD (int nIndex, ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- Bool fReturn;
-
- winDebug ("winCloseScreenShadowDD - Freeing screen resources\n");
-
- /* Flag that the screen is closed */
- pScreenPriv->fClosed = TRUE;
- pScreenPriv->fActive = FALSE;
-
- /* Call the wrapped CloseScreen procedure */
- WIN_UNWRAP(CloseScreen);
- if (pScreen->CloseScreen)
- fReturn = (*pScreen->CloseScreen) (nIndex, pScreen);
-
- winFreeFBShadowDD(pScreen);
-
- /* Free the screen DC */
- ReleaseDC (pScreenPriv->hwndScreen, pScreenPriv->hdcScreen);
-
- /* Delete the window property */
- RemoveProp (pScreenPriv->hwndScreen, WIN_SCR_PROP);
-
- /* Delete tray icon, if we have one */
- if (!pScreenInfo->fNoTrayIcon)
- winDeleteNotifyIcon (pScreenPriv);
-
- /* Free the exit confirmation dialog box, if it exists */
- if (g_hDlgExit != NULL)
- {
- DestroyWindow (g_hDlgExit);
- g_hDlgExit = NULL;
- }
-
- /* Kill our window */
- if (pScreenPriv->hwndScreen)
- {
- DestroyWindow (pScreenPriv->hwndScreen);
- pScreenPriv->hwndScreen = NULL;
- }
-
-#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
- /* Destroy the thread startup mutex */
- pthread_mutex_destroy (&pScreenPriv->pmServerStarted);
-#endif
-
- /* Kill our screeninfo's pointer to the screen */
- pScreenInfo->pScreen = NULL;
-
- /* Free the screen privates for this screen */
- free ((pointer) pScreenPriv);
-
- return fReturn;
-}
-
-
-/*
- * Tell mi what sort of visuals we need.
- *
- * Generally we only need one visual, as our screen can only
- * handle one format at a time, I believe. You may want
- * to verify that last sentence.
- */
-
-static Bool
-winInitVisualsShadowDD (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- DWORD dwRedBits, dwGreenBits, dwBlueBits;
-
- /* Count the number of ones in each color mask */
- dwRedBits = winCountBits (pScreenPriv->dwRedMask);
- dwGreenBits = winCountBits (pScreenPriv->dwGreenMask);
- dwBlueBits = winCountBits (pScreenPriv->dwBlueMask);
-
- /* Store the maximum number of ones in a color mask as the bitsPerRGB */
- if (dwRedBits == 0 || dwGreenBits == 0 || dwBlueBits == 0)
- pScreenPriv->dwBitsPerRGB = 8;
- else if (dwRedBits > dwGreenBits && dwRedBits > dwBlueBits)
- pScreenPriv->dwBitsPerRGB = dwRedBits;
- else if (dwGreenBits > dwRedBits && dwGreenBits > dwBlueBits)
- pScreenPriv->dwBitsPerRGB = dwGreenBits;
- else
- pScreenPriv->dwBitsPerRGB = dwBlueBits;
-
- winDebug ("winInitVisualsShadowDD - Masks %08x %08x %08x BPRGB %d d %d "
- "bpp %d\n",
- (unsigned int) pScreenPriv->dwRedMask,
- (unsigned int) pScreenPriv->dwGreenMask,
- (unsigned int) pScreenPriv->dwBlueMask,
- (int) pScreenPriv->dwBitsPerRGB,
- (int) pScreenInfo->dwDepth,
- (int) pScreenInfo->dwBPP);
-
- /* Create a single visual according to the Windows screen depth */
- switch (pScreenInfo->dwDepth)
- {
- case 24:
- case 16:
- case 15:
- /* Create the real visual */
- if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
- TrueColorMask,
- pScreenPriv->dwBitsPerRGB,
- TrueColor,
- pScreenPriv->dwRedMask,
- pScreenPriv->dwGreenMask,
- pScreenPriv->dwBlueMask))
- {
- ErrorF ("winInitVisualsShadowDD - miSetVisualTypesAndMasks "
- "failed for TrueColor\n");
- return FALSE;
- }
-
-#ifdef XWIN_EMULATEPSEUDO
- if (!pScreenInfo->fEmulatePseudo)
- break;
-
- /* Setup a pseudocolor visual */
- if (!miSetVisualTypesAndMasks (8,
- PseudoColorMask,
- 8,
- -1,
- 0,
- 0,
- 0))
- {
- ErrorF ("winInitVisualsShadowDD - miSetVisualTypesAndMasks "
- "failed for PseudoColor\n");
- return FALSE;
- }
-#endif
- break;
-
- case 8:
- if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
- pScreenInfo->fFullScreen
- ? PseudoColorMask : StaticColorMask,
- pScreenPriv->dwBitsPerRGB,
- pScreenInfo->fFullScreen
- ? PseudoColor : StaticColor,
- pScreenPriv->dwRedMask,
- pScreenPriv->dwGreenMask,
- pScreenPriv->dwBlueMask))
- {
- ErrorF ("winInitVisualsShadowDD - miSetVisualTypesAndMasks "
- "failed\n");
- return FALSE;
- }
- break;
-
- default:
- ErrorF ("winInitVisualsShadowDD - Unknown screen depth\n");
- return FALSE;
- }
-
- winDebug ("winInitVisualsShadowDD - Returning\n");
-
- return TRUE;
-}
-
-
-/*
- * Adjust the user proposed video mode
- */
-
-static Bool
-winAdjustVideoModeShadowDD (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- HDC hdc = NULL;
- DWORD dwBPP;
-
- /* We're in serious trouble if we can't get a DC */
- hdc = GetDC (NULL);
- if (hdc == NULL)
- {
- ErrorF ("winAdjustVideoModeShadowDD - GetDC () failed\n");
- return FALSE;
- }
-
- /* Query GDI for current display depth */
- dwBPP = GetDeviceCaps (hdc, BITSPIXEL);
-
- /* DirectDraw can only change the depth in fullscreen mode */
- if (!(pScreenInfo->fFullScreen &&
- (pScreenInfo->dwBPP != WIN_DEFAULT_BPP)))
- {
- /* Otherwise, We'll use GDI's depth */
- pScreenInfo->dwBPP = dwBPP;
- }
-
- /* Release our DC */
- ReleaseDC (NULL, hdc);
- return TRUE;
-}
-
-
-/*
- * Blt exposed regions to the screen
- */
-
-static Bool
-winBltExposedRegionsShadowDD (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- RECT rcSrc, rcDest;
- POINT ptOrigin;
- HDC hdcUpdate = NULL;
- PAINTSTRUCT ps;
- HRESULT ddrval = DD_OK;
- Bool fReturn = TRUE;
- Bool fLocked = TRUE;
- int i;
-
- /* BeginPaint gives us an hdc that clips to the invalidated region */
- hdcUpdate = BeginPaint (pScreenPriv->hwndScreen, &ps);
- if (hdcUpdate == NULL)
- {
- ErrorF ("winBltExposedRegionsShadowDD - BeginPaint () returned "
- "a NULL device context handle. Aborting blit attempt.\n");
- return FALSE;
- }
-
- /* Unlock the shadow surface, so we can blit */
- ddrval = IDirectDrawSurface2_Unlock (pScreenPriv->pddsShadow, NULL);
- if (FAILED (ddrval))
- {
- fReturn = FALSE;
- goto winBltExposedRegionsShadowDD_Exit;
- }
- else
- {
- /* Flag that we have unlocked the shadow surface */
- fLocked = FALSE;
- }
-
- /* Get the origin of the window in the screen coords */
- ptOrigin.x = pScreenInfo->dwXOffset;
- ptOrigin.y = pScreenInfo->dwYOffset;
-
- MapWindowPoints (pScreenPriv->hwndScreen,
- HWND_DESKTOP,
- (LPPOINT)&ptOrigin, 1);
- rcDest.left = ptOrigin.x;
- rcDest.right = ptOrigin.x + pScreenInfo->dwWidth;
- rcDest.top = ptOrigin.y;
- rcDest.bottom = ptOrigin.y + pScreenInfo->dwHeight;
-
- /* Source can be enter shadow surface, as Blt should clip */
- rcSrc.left = 0;
- rcSrc.top = 0;
- rcSrc.right = pScreenInfo->dwWidth;
- rcSrc.bottom = pScreenInfo->dwHeight;
-
- /* Try to regain the primary surface and blit again if we've lost it */
- for (i = 0; i <= WIN_REGAIN_SURFACE_RETRIES; ++i)
- {
- /* Our Blt should be clipped to the invalidated region */
- ddrval = IDirectDrawSurface2_Blt (pScreenPriv->pddsPrimary,
- &rcDest,
- pScreenPriv->pddsShadow,
- &rcSrc,
- DDBLT_WAIT,
- NULL);
- if (ddrval == DDERR_SURFACELOST)
- {
- /* Surface was lost */
- ErrorF ("winBltExposedRegionsShadowDD - IDirectDrawSurface2_Blt "
- "reported that the primary surface was lost, "
- "trying to restore, retry: %d\n", i + 1);
-
- /* Try to restore the surface, once */
- ddrval = IDirectDrawSurface2_Restore (pScreenPriv->pddsPrimary);
- ErrorF ("winBltExposedRegionsShadowDD - "
- "IDirectDrawSurface2_Restore returned: ");
- if (ddrval == DD_OK)
- ErrorF ("DD_OK\n");
- else if (ddrval == DDERR_WRONGMODE)
- ErrorF ("DDERR_WRONGMODE\n");
- else if (ddrval == DDERR_INCOMPATIBLEPRIMARY)
- ErrorF ("DDERR_INCOMPATIBLEPRIMARY\n");
- else if (ddrval == DDERR_UNSUPPORTED)
- ErrorF ("DDERR_UNSUPPORTED\n");
- else if (ddrval == DDERR_INVALIDPARAMS)
- ErrorF ("DDERR_INVALIDPARAMS\n");
- else if (ddrval == DDERR_INVALIDOBJECT)
- ErrorF ("DDERR_INVALIDOBJECT\n");
- else
- ErrorF ("unknown error: %08x\n", (unsigned int) ddrval);
-
- /* Loop around to try the blit one more time */
- continue;
- }
- else if (FAILED (ddrval))
- {
- fReturn = FALSE;
- ErrorF ("winBltExposedRegionsShadowDD - IDirectDrawSurface2_Blt "
- "failed, but surface not lost: %08x %d\n",
- (unsigned int) ddrval, (int) ddrval);
- goto winBltExposedRegionsShadowDD_Exit;
- }
- else
- {
- /* Success, stop looping */
- break;
- }
- }
-
- /* Relock the shadow surface */
- ddrval = IDirectDrawSurface2_Lock (pScreenPriv->pddsShadow,
- NULL,
- pScreenPriv->pddsdShadow,
- DDLOCK_WAIT,
- NULL);
- if (FAILED (ddrval))
- {
- fReturn = FALSE;
- ErrorF ("winBltExposedRegionsShadowDD - IDirectDrawSurface2_Lock "
- "failed\n");
- goto winBltExposedRegionsShadowDD_Exit;
- }
- else
- {
- /* Indicate that we have relocked the shadow surface */
- fLocked = TRUE;
- }
-
- /* Has our memory pointer changed? */
- if (pScreenInfo->pfb != pScreenPriv->pddsdShadow->lpSurface)
- winUpdateFBPointer (pScreen,
- pScreenPriv->pddsdShadow->lpSurface);
-
- winBltExposedRegionsShadowDD_Exit:
- /* EndPaint frees the DC */
- if (hdcUpdate != NULL)
- EndPaint (pScreenPriv->hwndScreen, &ps);
-
- /*
- * Relock the surface if it is not locked. We don't care if locking fails,
- * as it will cause the server to shutdown within a few more operations.
- */
- if (!fLocked)
- {
- IDirectDrawSurface2_Lock (pScreenPriv->pddsShadow,
- NULL,
- pScreenPriv->pddsdShadow,
- DDLOCK_WAIT,
- NULL);
-
- /* Has our memory pointer changed? */
- if (pScreenInfo->pfb != pScreenPriv->pddsdShadow->lpSurface)
- winUpdateFBPointer (pScreen,
- pScreenPriv->pddsdShadow->lpSurface);
-
- fLocked = TRUE;
- }
- return fReturn;
-}
-
-
-/*
- * Do any engine-specific appliation-activation processing
- */
-
-static Bool
-winActivateAppShadowDD (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
-
- /*
- * Do we have a surface?
- * Are we active?
- * Are we fullscreen?
- */
- if (pScreenPriv != NULL
- && pScreenPriv->pddsPrimary != NULL
- && pScreenPriv->fActive)
- {
- /* Primary surface was lost, restore it */
- IDirectDrawSurface2_Restore (pScreenPriv->pddsPrimary);
- }
-
- return TRUE;
-}
-
-
-/*
- * Reblit the shadow framebuffer to the screen.
- */
-
-static Bool
-winRedrawScreenShadowDD (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- HRESULT ddrval = DD_OK;
- RECT rcSrc, rcDest;
- POINT ptOrigin;
-
- /* Get the origin of the window in the screen coords */
- ptOrigin.x = pScreenInfo->dwXOffset;
- ptOrigin.y = pScreenInfo->dwYOffset;
- MapWindowPoints (pScreenPriv->hwndScreen,
- HWND_DESKTOP,
- (LPPOINT)&ptOrigin, 1);
- rcDest.left = ptOrigin.x;
- rcDest.right = ptOrigin.x + pScreenInfo->dwWidth;
- rcDest.top = ptOrigin.y;
- rcDest.bottom = ptOrigin.y + pScreenInfo->dwHeight;
-
- /* Source can be entire shadow surface, as Blt should clip for us */
- rcSrc.left = 0;
- rcSrc.top = 0;
- rcSrc.right = pScreenInfo->dwWidth;
- rcSrc.bottom = pScreenInfo->dwHeight;
-
- /* Redraw the whole window, to take account for the new colors */
- ddrval = IDirectDrawSurface2_Blt (pScreenPriv->pddsPrimary,
- &rcDest,
- pScreenPriv->pddsShadow,
- &rcSrc,
- DDBLT_WAIT,
- NULL);
- if (FAILED (ddrval))
- {
- ErrorF ("winRedrawScreenShadowDD - IDirectDrawSurface_Blt () "
- "failed: %08x\n",
- (unsigned int) ddrval);
- }
-
- return TRUE;
-}
-
-
-/*
- * Realize the currently installed colormap
- */
-
-static Bool
-winRealizeInstalledPaletteShadowDD (ScreenPtr pScreen)
-{
- return TRUE;
-}
-
-
-/*
- * Install the specified colormap
- */
-
-static Bool
-winInstallColormapShadowDD (ColormapPtr pColormap)
-{
- ScreenPtr pScreen = pColormap->pScreen;
- winScreenPriv(pScreen);
- winCmapPriv(pColormap);
- HRESULT ddrval = DD_OK;
-
- /* Install the DirectDraw palette on the primary surface */
- ddrval = IDirectDrawSurface2_SetPalette (pScreenPriv->pddsPrimary,
- pCmapPriv->lpDDPalette);
- if (FAILED (ddrval))
- {
- ErrorF ("winInstallColormapShadowDD - Failed installing the "
- "DirectDraw palette.\n");
- return FALSE;
- }
-
- /* Save a pointer to the newly installed colormap */
- pScreenPriv->pcmapInstalled = pColormap;
-
- return TRUE;
-}
-
-
-/*
- * Store the specified colors in the specified colormap
- */
-
-static Bool
-winStoreColorsShadowDD (ColormapPtr pColormap,
- int ndef,
- xColorItem *pdefs)
-{
- ScreenPtr pScreen = pColormap->pScreen;
- winScreenPriv(pScreen);
- winCmapPriv(pColormap);
- ColormapPtr curpmap = pScreenPriv->pcmapInstalled;
- HRESULT ddrval = DD_OK;
-
- /* Put the X colormap entries into the Windows logical palette */
- ddrval = IDirectDrawPalette_SetEntries (pCmapPriv->lpDDPalette,
- 0,
- pdefs[0].pixel,
- ndef,
- pCmapPriv->peColors
- + pdefs[0].pixel);
- if (FAILED (ddrval))
- {
- ErrorF ("winStoreColorsShadowDD - SetEntries () failed\n");
- return FALSE;
- }
-
- /* Don't install the DirectDraw palette if the colormap is not installed */
- if (pColormap != curpmap)
- {
- return TRUE;
- }
-
- if (!winInstallColormapShadowDD (pColormap))
- {
- ErrorF ("winStoreColorsShadowDD - Failed installing colormap\n");
- return FALSE;
- }
-
- return TRUE;
-}
-
-
-/*
- * Colormap initialization procedure
- */
-
-static Bool
-winCreateColormapShadowDD (ColormapPtr pColormap)
-{
- HRESULT ddrval = DD_OK;
- ScreenPtr pScreen = pColormap->pScreen;
- winScreenPriv(pScreen);
- winCmapPriv(pColormap);
-
- /* Create a DirectDraw palette */
- ddrval = IDirectDraw2_CreatePalette (pScreenPriv->pdd,
- DDPCAPS_8BIT | DDPCAPS_ALLOW256,
- pCmapPriv->peColors,
- &pCmapPriv->lpDDPalette,
- NULL);
- if (FAILED (ddrval))
- {
- ErrorF ("winCreateColormapShadowDD - CreatePalette failed\n");
- return FALSE;
- }
-
- return TRUE;
-}
-
-
-/*
- * Colormap destruction procedure
- */
-
-static Bool
-winDestroyColormapShadowDD (ColormapPtr pColormap)
-{
- winScreenPriv(pColormap->pScreen);
- winCmapPriv(pColormap);
- HRESULT ddrval = DD_OK;
-
- /*
- * Is colormap to be destroyed the default?
- *
- * Non-default colormaps should have had winUninstallColormap
- * called on them before we get here. The default colormap
- * will not have had winUninstallColormap called on it. Thus,
- * we need to handle the default colormap in a special way.
- */
- if (pColormap->flags & IsDefault)
- {
- winDebug ("winDestroyColormapShadowDD - Destroying default "
- "colormap\n");
-
- /*
- * FIXME: Walk the list of all screens, popping the default
- * palette out of each screen device context.
- */
-
- /* Pop the palette out of the primary surface */
- ddrval = IDirectDrawSurface2_SetPalette (pScreenPriv->pddsPrimary,
- NULL);
- if (FAILED (ddrval))
- {
- ErrorF ("winDestroyColormapShadowDD - Failed freeing the "
- "default colormap DirectDraw palette.\n");
- return FALSE;
- }
-
- /* Clear our private installed colormap pointer */
- pScreenPriv->pcmapInstalled = NULL;
- }
-
- /* Release the palette */
- IDirectDrawPalette_Release (pCmapPriv->lpDDPalette);
-
- /* Invalidate the colormap privates */
- pCmapPriv->lpDDPalette = NULL;
-
- return TRUE;
-}
-
-
-/*
- * Set engine specific functions
- */
-
-Bool
-winSetEngineFunctionsShadowDD (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-
- /* Set our pointers */
- pScreenPriv->pwinAllocateFB = winAllocateFBShadowDD;
- pScreenPriv->pwinFreeFB = winFreeFBShadowDD;
- pScreenPriv->pwinShadowUpdate = winShadowUpdateDD;
- pScreenPriv->pwinInitScreen = winInitScreenShadowDD;
- pScreenPriv->pwinCloseScreen = winCloseScreenShadowDD;
- pScreenPriv->pwinInitVisuals = winInitVisualsShadowDD;
- pScreenPriv->pwinAdjustVideoMode = winAdjustVideoModeShadowDD;
- if (pScreenInfo->fFullScreen)
- pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowFullScreen;
- else
- pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowWindowed;
- pScreenPriv->pwinFinishScreenInit = winFinishScreenInitFB;
- pScreenPriv->pwinBltExposedRegions = winBltExposedRegionsShadowDD;
- pScreenPriv->pwinActivateApp = winActivateAppShadowDD;
- pScreenPriv->pwinRedrawScreen = winRedrawScreenShadowDD;
- pScreenPriv->pwinRealizeInstalledPalette
- = winRealizeInstalledPaletteShadowDD;
- pScreenPriv->pwinInstallColormap = winInstallColormapShadowDD;
- pScreenPriv->pwinStoreColors = winStoreColorsShadowDD;
- pScreenPriv->pwinCreateColormap = winCreateColormapShadowDD;
- pScreenPriv->pwinDestroyColormap = winDestroyColormapShadowDD;
- pScreenPriv->pwinHotKeyAltTab = (winHotKeyAltTabProcPtr) (void (*)(void))NoopDDA;
- pScreenPriv->pwinCreatePrimarySurface = winCreatePrimarySurfaceShadowDD;
- pScreenPriv->pwinReleasePrimarySurface = winReleasePrimarySurfaceShadowDD;
-#ifdef XWIN_MULTIWINDOW
- pScreenPriv->pwinFinishCreateWindowsWindow =
- (winFinishCreateWindowsWindowProcPtr) (void (*)(void))NoopDDA;
-#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 Bool
+winAllocateFBShadowDD (ScreenPtr pScreen);
+
+static void
+winShadowUpdateDD (ScreenPtr pScreen,
+ shadowBufPtr pBuf);
+
+static Bool
+winCloseScreenShadowDD (int nIndex, ScreenPtr pScreen);
+
+static Bool
+winInitVisualsShadowDD (ScreenPtr pScreen);
+
+static Bool
+winAdjustVideoModeShadowDD (ScreenPtr pScreen);
+
+static Bool
+winBltExposedRegionsShadowDD (ScreenPtr pScreen);
+
+static Bool
+winActivateAppShadowDD (ScreenPtr pScreen);
+
+static Bool
+winRedrawScreenShadowDD (ScreenPtr pScreen);
+
+static Bool
+winRealizeInstalledPaletteShadowDD (ScreenPtr pScreen);
+
+static Bool
+winInstallColormapShadowDD (ColormapPtr pColormap);
+
+static Bool
+winStoreColorsShadowDD (ColormapPtr pmap,
+ int ndef,
+ xColorItem *pdefs);
+
+static Bool
+winCreateColormapShadowDD (ColormapPtr pColormap);
+
+static Bool
+winDestroyColormapShadowDD (ColormapPtr pColormap);
+
+static Bool
+winCreatePrimarySurfaceShadowDD (ScreenPtr pScreen);
+
+static Bool
+winReleasePrimarySurfaceShadowDD (ScreenPtr pScreen);
+
+
+/*
+ * Create the primary surface and attach the clipper.
+ * Used for both the initial surface creation and during
+ * WM_DISPLAYCHANGE messages.
+ */
+
+static Bool
+winCreatePrimarySurfaceShadowDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ HRESULT ddrval = DD_OK;
+ DDSURFACEDESC ddsd;
+
+ /* Describe the primary surface */
+ ZeroMemory (&ddsd, sizeof (ddsd));
+ ddsd.dwSize = sizeof (ddsd);
+ ddsd.dwFlags = DDSD_CAPS;
+ ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
+
+ /* Create the primary surface */
+ ddrval = IDirectDraw2_CreateSurface (pScreenPriv->pdd2,
+ &ddsd,
+ &pScreenPriv->pddsPrimary,
+ NULL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winCreatePrimarySurfaceShadowDD - Could not create primary "
+ "surface: %08x\n", (unsigned int) ddrval);
+ return FALSE;
+ }
+
+ winDebug ("winCreatePrimarySurfaceShadowDD - Created primary surface\n");
+
+ /*
+ * Attach a clipper to the primary surface that will clip our blits to our
+ * display window.
+ */
+ ddrval = IDirectDrawSurface2_SetClipper (pScreenPriv->pddsPrimary,
+ pScreenPriv->pddcPrimary);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winCreatePrimarySurfaceShadowDD - Primary attach clipper "
+ "failed: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+
+ winDebug ("winCreatePrimarySurfaceShadowDD - Attached clipper to "
+ "primary surface\n");
+
+ /* Everything was correct */
+ return TRUE;
+}
+
+
+/*
+ * Detach the clipper and release the primary surface.
+ * Called from WM_DISPLAYCHANGE.
+ */
+
+static Bool
+winReleasePrimarySurfaceShadowDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+
+ winDebug ("winReleasePrimarySurfaceShadowDD - Hello\n");
+
+ /* Release the primary surface and clipper, if they exist */
+ if (pScreenPriv->pddsPrimary)
+ {
+ /*
+ * Detach the clipper from the primary surface.
+ * NOTE: We do this explicity for clarity. The Clipper is not released.
+ */
+ IDirectDrawSurface2_SetClipper (pScreenPriv->pddsPrimary,
+ NULL);
+
+ winDebug ("winReleasePrimarySurfaceShadowDD - Detached clipper\n");
+
+ /* Release the primary surface */
+ IDirectDrawSurface2_Release (pScreenPriv->pddsPrimary);
+ pScreenPriv->pddsPrimary = NULL;
+ }
+
+ winDebug ("winReleasePrimarySurfaceShadowDD - Released primary surface\n");
+
+ return TRUE;
+}
+
+
+/*
+ * Create a DirectDraw surface for the shadow framebuffer; also create
+ * a primary surface object so we can blit to the display.
+ *
+ * Install a DirectDraw clipper on our primary surface object
+ * that clips our blits to the unobscured client area of our display window.
+ */
+
+static Bool
+winAllocateFBShadowDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ HRESULT ddrval = DD_OK;
+ DDSURFACEDESC ddsd;
+ DDSURFACEDESC *pddsdShadow = NULL;
+
+ winDebug ("winAllocateFBShadowDD\n");
+
+ /* Create a clipper */
+ ddrval = (*g_fpDirectDrawCreateClipper) (0,
+ &pScreenPriv->pddcPrimary,
+ NULL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDD - Could not create clipper: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+
+ winDebug ("winAllocateFBShadowDD - Created a clipper\n");
+
+ /* Attach the clipper to our display window */
+ ddrval = IDirectDrawClipper_SetHWnd (pScreenPriv->pddcPrimary,
+ 0,
+ pScreenPriv->hwndScreen);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDD - Clipper not attached to "
+ "window: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+
+ winDebug ("winAllocateFBShadowDD - Attached clipper to window\n");
+
+ /* Create a DirectDraw object, store the address at lpdd */
+ ddrval = (*g_fpDirectDrawCreate) (NULL, &pScreenPriv->pdd, NULL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDD - Could not start DirectDraw: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+
+ winDebug ("winAllocateFBShadowDD () - Created and initialized DD\n");
+
+ /* Get a DirectDraw2 interface pointer */
+ ddrval = IDirectDraw_QueryInterface (pScreenPriv->pdd,
+ &IID_IDirectDraw2,
+ (LPVOID*) &pScreenPriv->pdd2);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDD - Failed DD2 query: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+
+ /* Are we full screen? */
+ if (pScreenInfo->fFullScreen)
+ {
+ DDSURFACEDESC ddsdCurrent;
+ DWORD dwRefreshRateCurrent = 0;
+ HDC hdc = NULL;
+
+ /* Set the cooperative level to full screen */
+ ddrval = IDirectDraw2_SetCooperativeLevel (pScreenPriv->pdd2,
+ pScreenPriv->hwndScreen,
+ DDSCL_EXCLUSIVE
+ | DDSCL_FULLSCREEN);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDD - Could not set "
+ "cooperative level: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+
+ /*
+ * We only need to get the current refresh rate for comparison
+ * if a refresh rate has been passed on the command line.
+ */
+ if (pScreenInfo->dwRefreshRate != 0)
+ {
+ ZeroMemory (&ddsdCurrent, sizeof (ddsdCurrent));
+ ddsdCurrent.dwSize = sizeof (ddsdCurrent);
+
+ /* Get information about current display settings */
+ ddrval = IDirectDraw2_GetDisplayMode (pScreenPriv->pdd2,
+ &ddsdCurrent);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDD - Could not get current "
+ "refresh rate: %08x. Continuing.\n",
+ (unsigned int) ddrval);
+ dwRefreshRateCurrent = 0;
+ }
+ else
+ {
+ /* Grab the current refresh rate */
+ dwRefreshRateCurrent = ddsdCurrent.u2.dwRefreshRate;
+ }
+ }
+
+ /* Clean up the refresh rate */
+ if (dwRefreshRateCurrent == pScreenInfo->dwRefreshRate)
+ {
+ /*
+ * Refresh rate is non-specified or equal to current.
+ */
+ pScreenInfo->dwRefreshRate = 0;
+ }
+
+ /* Grab a device context for the screen */
+ hdc = GetDC (NULL);
+ if (hdc == NULL)
+ {
+ ErrorF ("winAllocateFBShadowDD - GetDC () failed\n");
+ return FALSE;
+ }
+
+ /* Only change the video mode when different than current mode */
+ if (!pScreenInfo->fMultipleMonitors
+ && (pScreenInfo->dwWidth != GetSystemMetrics (SM_CXSCREEN)
+ || pScreenInfo->dwHeight != GetSystemMetrics (SM_CYSCREEN)
+ || pScreenInfo->dwBPP != GetDeviceCaps (hdc, BITSPIXEL)
+ || pScreenInfo->dwRefreshRate != 0))
+ {
+ 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,
+ pScreenInfo->dwWidth,
+ pScreenInfo->dwHeight,
+ pScreenInfo->dwBPP,
+ pScreenInfo->dwRefreshRate,
+ 0);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDD - Could not set "\
+ "full screen display mode: %08x\n",
+ (unsigned int) ddrval);
+ ErrorF ("winAllocateFBShadowDD - Using default driver refresh rate\n");
+ ddrval = IDirectDraw2_SetDisplayMode (pScreenPriv->pdd2,
+ pScreenInfo->dwWidth,
+ pScreenInfo->dwHeight,
+ pScreenInfo->dwBPP,
+ 0,
+ 0);
+ if (FAILED(ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDD - Could not set default refresh rate "
+ "full screen display mode: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+ }
+ }
+ else
+ {
+ winDebug ("winAllocateFBShadowDD - Not changing video mode\n");
+ }
+
+ /* Release our DC */
+ ReleaseDC (NULL, hdc);
+ hdc = NULL;
+ }
+ else
+ {
+ /* Set the cooperative level for windowed mode */
+ ddrval = IDirectDraw2_SetCooperativeLevel (pScreenPriv->pdd2,
+ pScreenPriv->hwndScreen,
+ DDSCL_NORMAL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDD - Could not set "\
+ "cooperative level: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+ }
+
+ /* Create the primary surface */
+ if (!winCreatePrimarySurfaceShadowDD (pScreen))
+ {
+ ErrorF ("winAllocateFBShadowDD - winCreatePrimarySurfaceShadowDD "
+ "failed\n");
+ return FALSE;
+ }
+
+ /* Describe the shadow surface to be created */
+ /* NOTE: Do not use a DDSCAPS_VIDEOMEMORY surface,
+ * as drawing, locking, and unlocking take forever
+ * with video memory surfaces. In addition,
+ * video memory is a somewhat scarce resource,
+ * so you shouldn't be allocating video memory when
+ * you have the option of using system memory instead.
+ */
+ ZeroMemory (&ddsd, sizeof (ddsd));
+ ddsd.dwSize = sizeof (ddsd);
+ ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
+ ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
+ ddsd.dwHeight = pScreenInfo->dwHeight;
+ ddsd.dwWidth = pScreenInfo->dwWidth;
+
+ /* Create the shadow surface */
+ ddrval = IDirectDraw2_CreateSurface (pScreenPriv->pdd2,
+ &ddsd,
+ &pScreenPriv->pddsShadow,
+ NULL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDD - Could not create shadow "\
+ "surface: %08x\n", (unsigned int) ddrval);
+ return FALSE;
+ }
+
+ winDebug ("winAllocateFBShadowDD - Created shadow\n");
+
+ /* Allocate a DD surface description for our screen privates */
+ pddsdShadow = pScreenPriv->pddsdShadow = malloc (sizeof (DDSURFACEDESC));
+ if (pddsdShadow == NULL)
+ {
+ ErrorF ("winAllocateFBShadowDD - Could not allocate surface "\
+ "description memory\n");
+ return FALSE;
+ }
+ ZeroMemory (pddsdShadow, sizeof (*pddsdShadow));
+ pddsdShadow->dwSize = sizeof (*pddsdShadow);
+
+ winDebug ("winAllocateFBShadowDD - Locking shadow\n");
+
+ /* Lock the shadow surface */
+ ddrval = IDirectDrawSurface2_Lock (pScreenPriv->pddsShadow,
+ NULL,
+ pddsdShadow,
+ DDLOCK_WAIT,
+ NULL);
+ if (FAILED (ddrval) || pddsdShadow->lpSurface == NULL)
+ {
+ ErrorF ("winAllocateFBShadowDD - Could not lock shadow "\
+ "surface: %08x\n", (unsigned int) ddrval);
+ return FALSE;
+ }
+
+ winDebug ("winAllocateFBShadowDD - Locked shadow\n");
+
+ /* We don't know how to deal with anything other than RGB */
+ if (!(pddsdShadow->ddpfPixelFormat.dwFlags & DDPF_RGB))
+ {
+ ErrorF ("winAllocateFBShadowDD - Color format other than RGB\n");
+ return FALSE;
+ }
+
+ /* Grab the pitch from the surface desc */
+ pScreenInfo->dwStride = (pddsdShadow->u1.lPitch * 8)
+ / pScreenInfo->dwBPP;
+
+ /* Save the pointer to our surface memory */
+ pScreenInfo->pfb = pddsdShadow->lpSurface;
+
+ /* Grab the color depth and masks from the surface description */
+ pScreenPriv->dwRedMask = pddsdShadow->ddpfPixelFormat.u2.dwRBitMask;
+ pScreenPriv->dwGreenMask = pddsdShadow->ddpfPixelFormat.u3.dwGBitMask;
+ pScreenPriv->dwBlueMask = pddsdShadow->ddpfPixelFormat.u4.dwBBitMask;
+
+ winDebug ("winAllocateFBShadowDD - Returning\n");
+
+ return TRUE;
+}
+
+static void
+winFreeFBShadowDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /* Free the shadow surface, if there is one */
+ if (pScreenPriv->pddsShadow)
+ {
+ IDirectDrawSurface2_Unlock (pScreenPriv->pddsShadow, NULL);
+ IDirectDrawSurface2_Release (pScreenPriv->pddsShadow);
+ pScreenPriv->pddsShadow = NULL;
+ }
+
+ /* Detach the clipper from the primary surface and release the primary surface, if there is one */
+ winReleasePrimarySurfaceShadowDD(pScreen);
+
+ /* Release the clipper object */
+ if (pScreenPriv->pddcPrimary)
+ {
+ IDirectDrawClipper_Release (pScreenPriv->pddcPrimary);
+ pScreenPriv->pddcPrimary = NULL;
+ }
+
+ /* Free the DirectDraw2 object, if there is one */
+ if (pScreenPriv->pdd2)
+ {
+ IDirectDraw2_RestoreDisplayMode (pScreenPriv->pdd2);
+ IDirectDraw2_Release (pScreenPriv->pdd2);
+ pScreenPriv->pdd2 = NULL;
+ }
+
+ /* Free the DirectDraw object, if there is one */
+ if (pScreenPriv->pdd)
+ {
+ IDirectDraw_Release (pScreenPriv->pdd);
+ pScreenPriv->pdd = NULL;
+ }
+
+ /* Invalidate the ScreenInfo's fb pointer */
+ pScreenInfo->pfb = NULL;
+}
+
+/*
+ * Transfer the damaged regions of the shadow framebuffer to the display.
+ */
+
+static void
+winShadowUpdateDD (ScreenPtr pScreen,
+ shadowBufPtr pBuf)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ RegionPtr damage = shadowDamage(pBuf);
+ HRESULT ddrval = DD_OK;
+ RECT rcDest, rcSrc;
+ POINT ptOrigin;
+ DWORD dwBox = RegionNumRects (damage);
+ BoxPtr pBox = RegionRects (damage);
+ HRGN hrgnTemp = NULL, hrgnCombined = NULL;
+
+ /*
+ * Return immediately if the app is not active
+ * and we are fullscreen, or if we have a bad display depth
+ */
+ if ((!pScreenPriv->fActive && pScreenInfo->fFullScreen)
+ || pScreenPriv->fBadDepth) return;
+
+ /* Return immediately if we didn't get needed surfaces */
+ if (!pScreenPriv->pddsPrimary || !pScreenPriv->pddsShadow)
+ return;
+
+ /* Get the origin of the window in the screen coords */
+ ptOrigin.x = pScreenInfo->dwXOffset;
+ ptOrigin.y = pScreenInfo->dwYOffset;
+ MapWindowPoints (pScreenPriv->hwndScreen,
+ HWND_DESKTOP,
+ (LPPOINT)&ptOrigin, 1);
+
+ /* Unlock the shadow surface, so we can blit */
+ ddrval = IDirectDrawSurface2_Unlock (pScreenPriv->pddsShadow, NULL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winShadowUpdateDD - Unlock failed\n");
+ return;
+ }
+
+ /*
+ * Handle small regions with multiple blits,
+ * handle large regions by creating a clipping region and
+ * doing a single blit constrained to that clipping region.
+ */
+ if (pScreenInfo->dwClipUpdatesNBoxes == 0
+ || dwBox < pScreenInfo->dwClipUpdatesNBoxes)
+ {
+ /* Loop through all boxes in the damaged region */
+ while (dwBox--)
+ {
+ /* Assign damage box to source rectangle */
+ rcSrc.left = pBox->x1;
+ rcSrc.top = pBox->y1;
+ rcSrc.right = pBox->x2;
+ rcSrc.bottom = pBox->y2;
+
+ /* Calculate destination rectange */
+ rcDest.left = ptOrigin.x + rcSrc.left;
+ rcDest.top = ptOrigin.y + rcSrc.top;
+ rcDest.right = ptOrigin.x + rcSrc.right;
+ rcDest.bottom = ptOrigin.y + rcSrc.bottom;
+
+ /* Blit the damaged areas */
+ ddrval = IDirectDrawSurface2_Blt (pScreenPriv->pddsPrimary,
+ &rcDest,
+ pScreenPriv->pddsShadow,
+ &rcSrc,
+ DDBLT_WAIT,
+ NULL);
+
+ /* Get a pointer to the next box */
+ ++pBox;
+ }
+ }
+ else
+ {
+ BoxPtr pBoxExtents = RegionExtents(damage);
+
+ /* Compute a GDI region from the damaged region */
+ hrgnCombined = CreateRectRgn (pBox->x1, pBox->y1, pBox->x2, pBox->y2);
+ dwBox--;
+ pBox++;
+ while (dwBox--)
+ {
+ hrgnTemp = CreateRectRgn (pBox->x1, pBox->y1, pBox->x2, pBox->y2);
+ CombineRgn (hrgnCombined, hrgnCombined, hrgnTemp, RGN_OR);
+ DeleteObject (hrgnTemp);
+ pBox++;
+ }
+
+ /* Install the GDI region as a clipping region */
+ SelectClipRgn (pScreenPriv->hdcScreen, hrgnCombined);
+ DeleteObject (hrgnCombined);
+ hrgnCombined = NULL;
+
+ /* Calculating a bounding box for the source is easy */
+ rcSrc.left = pBoxExtents->x1;
+ rcSrc.top = pBoxExtents->y1;
+ rcSrc.right = pBoxExtents->x2;
+ rcSrc.bottom = pBoxExtents->y2;
+
+ /* Calculating a bounding box for the destination is trickier */
+ rcDest.left = ptOrigin.x + rcSrc.left;
+ rcDest.top = ptOrigin.y + rcSrc.top;
+ rcDest.right = ptOrigin.x + rcSrc.right;
+ rcDest.bottom = ptOrigin.y + rcSrc.bottom;
+
+ /* Our Blt should be clipped to the invalidated region */
+ ddrval = IDirectDrawSurface2_Blt (pScreenPriv->pddsPrimary,
+ &rcDest,
+ pScreenPriv->pddsShadow,
+ &rcSrc,
+ DDBLT_WAIT,
+ NULL);
+
+ /* Reset the clip region */
+ SelectClipRgn (pScreenPriv->hdcScreen, NULL);
+ }
+
+ /* Relock the shadow surface */
+ ddrval = IDirectDrawSurface2_Lock (pScreenPriv->pddsShadow,
+ NULL,
+ pScreenPriv->pddsdShadow,
+ DDLOCK_WAIT,
+ NULL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winShadowUpdateDD - Lock failed\n");
+ return;
+ }
+
+ /* Has our memory pointer changed? */
+ if (pScreenInfo->pfb != pScreenPriv->pddsdShadow->lpSurface)
+ {
+ extern const 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 "
+ "this message and "PROJECT_NAME" freezes or crashes "
+ "after this message then send a problem report and your "
+ "%s file to " BUILDERADDR "\n", g_pszLogFile);
+
+ /* Location of shadow framebuffer has changed */
+ winUpdateFBPointer(pScreen, pScreenPriv->pddsdShadow->lpSurface);
+ }
+}
+
+static Bool
+winInitScreenShadowDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+
+ /* Get a device context for the screen */
+ pScreenPriv->hdcScreen = GetDC (pScreenPriv->hwndScreen);
+
+ return winAllocateFBShadowDD(pScreen);
+}
+
+/*
+ * Call the wrapped CloseScreen function.
+ *
+ * Free our resources and private structures.
+ */
+
+static Bool
+winCloseScreenShadowDD (int nIndex, ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ Bool fReturn;
+
+ winDebug ("winCloseScreenShadowDD - Freeing screen resources\n");
+
+ /* Flag that the screen is closed */
+ pScreenPriv->fClosed = TRUE;
+ pScreenPriv->fActive = FALSE;
+
+ /* Call the wrapped CloseScreen procedure */
+ WIN_UNWRAP(CloseScreen);
+ if (pScreen->CloseScreen)
+ fReturn = (*pScreen->CloseScreen) (nIndex, pScreen);
+
+ winFreeFBShadowDD(pScreen);
+
+ /* Free the screen DC */
+ ReleaseDC (pScreenPriv->hwndScreen, pScreenPriv->hdcScreen);
+
+ /* Delete the window property */
+ RemoveProp (pScreenPriv->hwndScreen, WIN_SCR_PROP);
+
+ /* Delete tray icon, if we have one */
+ if (!pScreenInfo->fNoTrayIcon)
+ winDeleteNotifyIcon (pScreenPriv);
+
+ /* Free the exit confirmation dialog box, if it exists */
+ if (g_hDlgExit != NULL)
+ {
+ DestroyWindow (g_hDlgExit);
+ g_hDlgExit = NULL;
+ }
+
+ /* Kill our window */
+ if (pScreenPriv->hwndScreen)
+ {
+ DestroyWindow (pScreenPriv->hwndScreen);
+ pScreenPriv->hwndScreen = NULL;
+ }
+
+#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
+ /* Destroy the thread startup mutex */
+ pthread_mutex_destroy (&pScreenPriv->pmServerStarted);
+#endif
+
+ /* Kill our screeninfo's pointer to the screen */
+ pScreenInfo->pScreen = NULL;
+
+ /* Free the screen privates for this screen */
+ free ((pointer) pScreenPriv);
+
+ return fReturn;
+}
+
+
+/*
+ * Tell mi what sort of visuals we need.
+ *
+ * Generally we only need one visual, as our screen can only
+ * handle one format at a time, I believe. You may want
+ * to verify that last sentence.
+ */
+
+static Bool
+winInitVisualsShadowDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ DWORD dwRedBits, dwGreenBits, dwBlueBits;
+
+ /* Count the number of ones in each color mask */
+ dwRedBits = winCountBits (pScreenPriv->dwRedMask);
+ dwGreenBits = winCountBits (pScreenPriv->dwGreenMask);
+ dwBlueBits = winCountBits (pScreenPriv->dwBlueMask);
+
+ /* Store the maximum number of ones in a color mask as the bitsPerRGB */
+ if (dwRedBits == 0 || dwGreenBits == 0 || dwBlueBits == 0)
+ pScreenPriv->dwBitsPerRGB = 8;
+ else if (dwRedBits > dwGreenBits && dwRedBits > dwBlueBits)
+ pScreenPriv->dwBitsPerRGB = dwRedBits;
+ else if (dwGreenBits > dwRedBits && dwGreenBits > dwBlueBits)
+ pScreenPriv->dwBitsPerRGB = dwGreenBits;
+ else
+ pScreenPriv->dwBitsPerRGB = dwBlueBits;
+
+ winDebug ("winInitVisualsShadowDD - Masks %08x %08x %08x BPRGB %d d %d "
+ "bpp %d\n",
+ (unsigned int) pScreenPriv->dwRedMask,
+ (unsigned int) pScreenPriv->dwGreenMask,
+ (unsigned int) pScreenPriv->dwBlueMask,
+ (int) pScreenPriv->dwBitsPerRGB,
+ (int) pScreenInfo->dwDepth,
+ (int) pScreenInfo->dwBPP);
+
+ /* Create a single visual according to the Windows screen depth */
+ switch (pScreenInfo->dwDepth)
+ {
+ case 24:
+ case 16:
+ case 15:
+ /* Create the real visual */
+ if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
+ TrueColorMask,
+ pScreenPriv->dwBitsPerRGB,
+ TrueColor,
+ pScreenPriv->dwRedMask,
+ pScreenPriv->dwGreenMask,
+ pScreenPriv->dwBlueMask))
+ {
+ ErrorF ("winInitVisualsShadowDD - miSetVisualTypesAndMasks "
+ "failed for TrueColor\n");
+ return FALSE;
+ }
+
+#ifdef XWIN_EMULATEPSEUDO
+ if (!pScreenInfo->fEmulatePseudo)
+ break;
+
+ /* Setup a pseudocolor visual */
+ if (!miSetVisualTypesAndMasks (8,
+ PseudoColorMask,
+ 8,
+ -1,
+ 0,
+ 0,
+ 0))
+ {
+ ErrorF ("winInitVisualsShadowDD - miSetVisualTypesAndMasks "
+ "failed for PseudoColor\n");
+ return FALSE;
+ }
+#endif
+ break;
+
+ case 8:
+ if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
+ pScreenInfo->fFullScreen
+ ? PseudoColorMask : StaticColorMask,
+ pScreenPriv->dwBitsPerRGB,
+ pScreenInfo->fFullScreen
+ ? PseudoColor : StaticColor,
+ pScreenPriv->dwRedMask,
+ pScreenPriv->dwGreenMask,
+ pScreenPriv->dwBlueMask))
+ {
+ ErrorF ("winInitVisualsShadowDD - miSetVisualTypesAndMasks "
+ "failed\n");
+ return FALSE;
+ }
+ break;
+
+ default:
+ ErrorF ("winInitVisualsShadowDD - Unknown screen depth\n");
+ return FALSE;
+ }
+
+ winDebug ("winInitVisualsShadowDD - Returning\n");
+
+ return TRUE;
+}
+
+
+/*
+ * Adjust the user proposed video mode
+ */
+
+static Bool
+winAdjustVideoModeShadowDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ HDC hdc = NULL;
+ DWORD dwBPP;
+
+ /* We're in serious trouble if we can't get a DC */
+ hdc = GetDC (NULL);
+ if (hdc == NULL)
+ {
+ ErrorF ("winAdjustVideoModeShadowDD - GetDC () failed\n");
+ return FALSE;
+ }
+
+ /* Query GDI for current display depth */
+ dwBPP = GetDeviceCaps (hdc, BITSPIXEL);
+
+ /* DirectDraw can only change the depth in fullscreen mode */
+ if (!(pScreenInfo->fFullScreen &&
+ (pScreenInfo->dwBPP != WIN_DEFAULT_BPP)))
+ {
+ /* Otherwise, We'll use GDI's depth */
+ pScreenInfo->dwBPP = dwBPP;
+ }
+
+ /* Release our DC */
+ ReleaseDC (NULL, hdc);
+ return TRUE;
+}
+
+
+/*
+ * Blt exposed regions to the screen
+ */
+
+static Bool
+winBltExposedRegionsShadowDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ RECT rcSrc, rcDest;
+ POINT ptOrigin;
+ HDC hdcUpdate = NULL;
+ PAINTSTRUCT ps;
+ HRESULT ddrval = DD_OK;
+ Bool fReturn = TRUE;
+ Bool fLocked = TRUE;
+ int i;
+
+ /* BeginPaint gives us an hdc that clips to the invalidated region */
+ hdcUpdate = BeginPaint (pScreenPriv->hwndScreen, &ps);
+ if (hdcUpdate == NULL)
+ {
+ ErrorF ("winBltExposedRegionsShadowDD - BeginPaint () returned "
+ "a NULL device context handle. Aborting blit attempt.\n");
+ return FALSE;
+ }
+
+ /* Unlock the shadow surface, so we can blit */
+ ddrval = IDirectDrawSurface2_Unlock (pScreenPriv->pddsShadow, NULL);
+ if (FAILED (ddrval))
+ {
+ fReturn = FALSE;
+ goto winBltExposedRegionsShadowDD_Exit;
+ }
+ else
+ {
+ /* Flag that we have unlocked the shadow surface */
+ fLocked = FALSE;
+ }
+
+ /* Get the origin of the window in the screen coords */
+ ptOrigin.x = pScreenInfo->dwXOffset;
+ ptOrigin.y = pScreenInfo->dwYOffset;
+
+ MapWindowPoints (pScreenPriv->hwndScreen,
+ HWND_DESKTOP,
+ (LPPOINT)&ptOrigin, 1);
+ rcDest.left = ptOrigin.x;
+ rcDest.right = ptOrigin.x + pScreenInfo->dwWidth;
+ rcDest.top = ptOrigin.y;
+ rcDest.bottom = ptOrigin.y + pScreenInfo->dwHeight;
+
+ /* Source can be enter shadow surface, as Blt should clip */
+ rcSrc.left = 0;
+ rcSrc.top = 0;
+ rcSrc.right = pScreenInfo->dwWidth;
+ rcSrc.bottom = pScreenInfo->dwHeight;
+
+ /* Try to regain the primary surface and blit again if we've lost it */
+ for (i = 0; i <= WIN_REGAIN_SURFACE_RETRIES; ++i)
+ {
+ /* Our Blt should be clipped to the invalidated region */
+ ddrval = IDirectDrawSurface2_Blt (pScreenPriv->pddsPrimary,
+ &rcDest,
+ pScreenPriv->pddsShadow,
+ &rcSrc,
+ DDBLT_WAIT,
+ NULL);
+ if (ddrval == DDERR_SURFACELOST)
+ {
+ /* Surface was lost */
+ ErrorF ("winBltExposedRegionsShadowDD - IDirectDrawSurface2_Blt "
+ "reported that the primary surface was lost, "
+ "trying to restore, retry: %d\n", i + 1);
+
+ /* Try to restore the surface, once */
+ ddrval = IDirectDrawSurface2_Restore (pScreenPriv->pddsPrimary);
+ ErrorF ("winBltExposedRegionsShadowDD - "
+ "IDirectDrawSurface2_Restore returned: ");
+ if (ddrval == DD_OK)
+ ErrorF ("DD_OK\n");
+ else if (ddrval == DDERR_WRONGMODE)
+ ErrorF ("DDERR_WRONGMODE\n");
+ else if (ddrval == DDERR_INCOMPATIBLEPRIMARY)
+ ErrorF ("DDERR_INCOMPATIBLEPRIMARY\n");
+ else if (ddrval == DDERR_UNSUPPORTED)
+ ErrorF ("DDERR_UNSUPPORTED\n");
+ else if (ddrval == DDERR_INVALIDPARAMS)
+ ErrorF ("DDERR_INVALIDPARAMS\n");
+ else if (ddrval == DDERR_INVALIDOBJECT)
+ ErrorF ("DDERR_INVALIDOBJECT\n");
+ else
+ ErrorF ("unknown error: %08x\n", (unsigned int) ddrval);
+
+ /* Loop around to try the blit one more time */
+ continue;
+ }
+ else if (FAILED (ddrval))
+ {
+ fReturn = FALSE;
+ ErrorF ("winBltExposedRegionsShadowDD - IDirectDrawSurface2_Blt "
+ "failed, but surface not lost: %08x %d\n",
+ (unsigned int) ddrval, (int) ddrval);
+ goto winBltExposedRegionsShadowDD_Exit;
+ }
+ else
+ {
+ /* Success, stop looping */
+ break;
+ }
+ }
+
+ /* Relock the shadow surface */
+ ddrval = IDirectDrawSurface2_Lock (pScreenPriv->pddsShadow,
+ NULL,
+ pScreenPriv->pddsdShadow,
+ DDLOCK_WAIT,
+ NULL);
+ if (FAILED (ddrval))
+ {
+ fReturn = FALSE;
+ ErrorF ("winBltExposedRegionsShadowDD - IDirectDrawSurface2_Lock "
+ "failed\n");
+ goto winBltExposedRegionsShadowDD_Exit;
+ }
+ else
+ {
+ /* Indicate that we have relocked the shadow surface */
+ fLocked = TRUE;
+ }
+
+ /* Has our memory pointer changed? */
+ if (pScreenInfo->pfb != pScreenPriv->pddsdShadow->lpSurface)
+ winUpdateFBPointer (pScreen,
+ pScreenPriv->pddsdShadow->lpSurface);
+
+ winBltExposedRegionsShadowDD_Exit:
+ /* EndPaint frees the DC */
+ if (hdcUpdate != NULL)
+ EndPaint (pScreenPriv->hwndScreen, &ps);
+
+ /*
+ * Relock the surface if it is not locked. We don't care if locking fails,
+ * as it will cause the server to shutdown within a few more operations.
+ */
+ if (!fLocked)
+ {
+ IDirectDrawSurface2_Lock (pScreenPriv->pddsShadow,
+ NULL,
+ pScreenPriv->pddsdShadow,
+ DDLOCK_WAIT,
+ NULL);
+
+ /* Has our memory pointer changed? */
+ if (pScreenInfo->pfb != pScreenPriv->pddsdShadow->lpSurface)
+ winUpdateFBPointer (pScreen,
+ pScreenPriv->pddsdShadow->lpSurface);
+
+ fLocked = TRUE;
+ }
+ return fReturn;
+}
+
+
+/*
+ * Do any engine-specific appliation-activation processing
+ */
+
+static Bool
+winActivateAppShadowDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+
+ /*
+ * Do we have a surface?
+ * Are we active?
+ * Are we fullscreen?
+ */
+ if (pScreenPriv != NULL
+ && pScreenPriv->pddsPrimary != NULL
+ && pScreenPriv->fActive)
+ {
+ /* Primary surface was lost, restore it */
+ IDirectDrawSurface2_Restore (pScreenPriv->pddsPrimary);
+ }
+
+ return TRUE;
+}
+
+
+/*
+ * Reblit the shadow framebuffer to the screen.
+ */
+
+static Bool
+winRedrawScreenShadowDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ HRESULT ddrval = DD_OK;
+ RECT rcSrc, rcDest;
+ POINT ptOrigin;
+
+ /* Get the origin of the window in the screen coords */
+ ptOrigin.x = pScreenInfo->dwXOffset;
+ ptOrigin.y = pScreenInfo->dwYOffset;
+ MapWindowPoints (pScreenPriv->hwndScreen,
+ HWND_DESKTOP,
+ (LPPOINT)&ptOrigin, 1);
+ rcDest.left = ptOrigin.x;
+ rcDest.right = ptOrigin.x + pScreenInfo->dwWidth;
+ rcDest.top = ptOrigin.y;
+ rcDest.bottom = ptOrigin.y + pScreenInfo->dwHeight;
+
+ /* Source can be entire shadow surface, as Blt should clip for us */
+ rcSrc.left = 0;
+ rcSrc.top = 0;
+ rcSrc.right = pScreenInfo->dwWidth;
+ rcSrc.bottom = pScreenInfo->dwHeight;
+
+ /* Redraw the whole window, to take account for the new colors */
+ ddrval = IDirectDrawSurface2_Blt (pScreenPriv->pddsPrimary,
+ &rcDest,
+ pScreenPriv->pddsShadow,
+ &rcSrc,
+ DDBLT_WAIT,
+ NULL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winRedrawScreenShadowDD - IDirectDrawSurface_Blt () "
+ "failed: %08x\n",
+ (unsigned int) ddrval);
+ }
+
+ return TRUE;
+}
+
+
+/*
+ * Realize the currently installed colormap
+ */
+
+static Bool
+winRealizeInstalledPaletteShadowDD (ScreenPtr pScreen)
+{
+ return TRUE;
+}
+
+
+/*
+ * Install the specified colormap
+ */
+
+static Bool
+winInstallColormapShadowDD (ColormapPtr pColormap)
+{
+ ScreenPtr pScreen = pColormap->pScreen;
+ winScreenPriv(pScreen);
+ winCmapPriv(pColormap);
+ HRESULT ddrval = DD_OK;
+
+ /* Install the DirectDraw palette on the primary surface */
+ ddrval = IDirectDrawSurface2_SetPalette (pScreenPriv->pddsPrimary,
+ pCmapPriv->lpDDPalette);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winInstallColormapShadowDD - Failed installing the "
+ "DirectDraw palette.\n");
+ return FALSE;
+ }
+
+ /* Save a pointer to the newly installed colormap */
+ pScreenPriv->pcmapInstalled = pColormap;
+
+ return TRUE;
+}
+
+
+/*
+ * Store the specified colors in the specified colormap
+ */
+
+static Bool
+winStoreColorsShadowDD (ColormapPtr pColormap,
+ int ndef,
+ xColorItem *pdefs)
+{
+ ScreenPtr pScreen = pColormap->pScreen;
+ winScreenPriv(pScreen);
+ winCmapPriv(pColormap);
+ ColormapPtr curpmap = pScreenPriv->pcmapInstalled;
+ HRESULT ddrval = DD_OK;
+
+ /* Put the X colormap entries into the Windows logical palette */
+ ddrval = IDirectDrawPalette_SetEntries (pCmapPriv->lpDDPalette,
+ 0,
+ pdefs[0].pixel,
+ ndef,
+ pCmapPriv->peColors
+ + pdefs[0].pixel);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winStoreColorsShadowDD - SetEntries () failed\n");
+ return FALSE;
+ }
+
+ /* Don't install the DirectDraw palette if the colormap is not installed */
+ if (pColormap != curpmap)
+ {
+ return TRUE;
+ }
+
+ if (!winInstallColormapShadowDD (pColormap))
+ {
+ ErrorF ("winStoreColorsShadowDD - Failed installing colormap\n");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+/*
+ * Colormap initialization procedure
+ */
+
+static Bool
+winCreateColormapShadowDD (ColormapPtr pColormap)
+{
+ HRESULT ddrval = DD_OK;
+ ScreenPtr pScreen = pColormap->pScreen;
+ winScreenPriv(pScreen);
+ winCmapPriv(pColormap);
+
+ /* Create a DirectDraw palette */
+ ddrval = IDirectDraw2_CreatePalette (pScreenPriv->pdd,
+ DDPCAPS_8BIT | DDPCAPS_ALLOW256,
+ pCmapPriv->peColors,
+ &pCmapPriv->lpDDPalette,
+ NULL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winCreateColormapShadowDD - CreatePalette failed\n");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+/*
+ * Colormap destruction procedure
+ */
+
+static Bool
+winDestroyColormapShadowDD (ColormapPtr pColormap)
+{
+ winScreenPriv(pColormap->pScreen);
+ winCmapPriv(pColormap);
+ HRESULT ddrval = DD_OK;
+
+ /*
+ * Is colormap to be destroyed the default?
+ *
+ * Non-default colormaps should have had winUninstallColormap
+ * called on them before we get here. The default colormap
+ * will not have had winUninstallColormap called on it. Thus,
+ * we need to handle the default colormap in a special way.
+ */
+ if (pColormap->flags & IsDefault)
+ {
+ winDebug ("winDestroyColormapShadowDD - Destroying default "
+ "colormap\n");
+
+ /*
+ * FIXME: Walk the list of all screens, popping the default
+ * palette out of each screen device context.
+ */
+
+ /* Pop the palette out of the primary surface */
+ ddrval = IDirectDrawSurface2_SetPalette (pScreenPriv->pddsPrimary,
+ NULL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winDestroyColormapShadowDD - Failed freeing the "
+ "default colormap DirectDraw palette.\n");
+ return FALSE;
+ }
+
+ /* Clear our private installed colormap pointer */
+ pScreenPriv->pcmapInstalled = NULL;
+ }
+
+ /* Release the palette */
+ IDirectDrawPalette_Release (pCmapPriv->lpDDPalette);
+
+ /* Invalidate the colormap privates */
+ pCmapPriv->lpDDPalette = NULL;
+
+ return TRUE;
+}
+
+
+/*
+ * Set engine specific functions
+ */
+
+Bool
+winSetEngineFunctionsShadowDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /* Set our pointers */
+ pScreenPriv->pwinAllocateFB = winAllocateFBShadowDD;
+ pScreenPriv->pwinFreeFB = winFreeFBShadowDD;
+ pScreenPriv->pwinShadowUpdate = winShadowUpdateDD;
+ pScreenPriv->pwinInitScreen = winInitScreenShadowDD;
+ pScreenPriv->pwinCloseScreen = winCloseScreenShadowDD;
+ pScreenPriv->pwinInitVisuals = winInitVisualsShadowDD;
+ pScreenPriv->pwinAdjustVideoMode = winAdjustVideoModeShadowDD;
+ if (pScreenInfo->fFullScreen)
+ pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowFullScreen;
+ else
+ pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowWindowed;
+ pScreenPriv->pwinFinishScreenInit = winFinishScreenInitFB;
+ pScreenPriv->pwinBltExposedRegions = winBltExposedRegionsShadowDD;
+ pScreenPriv->pwinActivateApp = winActivateAppShadowDD;
+ pScreenPriv->pwinRedrawScreen = winRedrawScreenShadowDD;
+ pScreenPriv->pwinRealizeInstalledPalette
+ = winRealizeInstalledPaletteShadowDD;
+ pScreenPriv->pwinInstallColormap = winInstallColormapShadowDD;
+ pScreenPriv->pwinStoreColors = winStoreColorsShadowDD;
+ pScreenPriv->pwinCreateColormap = winCreateColormapShadowDD;
+ pScreenPriv->pwinDestroyColormap = winDestroyColormapShadowDD;
+ pScreenPriv->pwinHotKeyAltTab = (winHotKeyAltTabProcPtr) (void (*)(void))NoopDDA;
+ pScreenPriv->pwinCreatePrimarySurface = winCreatePrimarySurfaceShadowDD;
+ pScreenPriv->pwinReleasePrimarySurface = winReleasePrimarySurfaceShadowDD;
+#ifdef XWIN_MULTIWINDOW
+ pScreenPriv->pwinFinishCreateWindowsWindow =
+ (winFinishCreateWindowsWindowProcPtr) (void (*)(void))NoopDDA;
+#endif
+
+ return TRUE;
+}
diff --git a/xorg-server/hw/xwin/winshadddnl.c b/xorg-server/hw/xwin/winshadddnl.c
index da3c56160..b7ba8ef94 100644
--- a/xorg-server/hw/xwin/winshadddnl.c
+++ b/xorg-server/hw/xwin/winshadddnl.c
@@ -1,1360 +1,1360 @@
-/*
- *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"
-
-
-/*
- * 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
- * here manually. Should be handled by ddraw.h
- */
-#ifndef IID_IDirectDraw4
-DEFINE_GUID( IID_IDirectDraw4, 0x9c59509a,0x39bd,0x11d1,0x8c,0x4a,0x00,0xc0,0x4f,0xd9,0x30,0xc5 );
-#endif /* IID_IDirectDraw4 */
-
-#define FAIL_MSG_MAX_BLT 10
-
-
-/*
- * Local prototypes
- */
-
-static Bool
-winAllocateFBShadowDDNL (ScreenPtr pScreen);
-
-static void
-winShadowUpdateDDNL (ScreenPtr pScreen,
- shadowBufPtr pBuf);
-
-static Bool
-winCloseScreenShadowDDNL (int nIndex, ScreenPtr pScreen);
-
-static Bool
-winInitVisualsShadowDDNL (ScreenPtr pScreen);
-
-static Bool
-winAdjustVideoModeShadowDDNL (ScreenPtr pScreen);
-
-static Bool
-winBltExposedRegionsShadowDDNL (ScreenPtr pScreen);
-
-static Bool
-winActivateAppShadowDDNL (ScreenPtr pScreen);
-
-static Bool
-winRedrawScreenShadowDDNL (ScreenPtr pScreen);
-
-static Bool
-winRealizeInstalledPaletteShadowDDNL (ScreenPtr pScreen);
-
-static Bool
-winInstallColormapShadowDDNL (ColormapPtr pColormap);
-
-static Bool
-winStoreColorsShadowDDNL (ColormapPtr pmap,
- int ndef,
- xColorItem *pdefs);
-
-static Bool
-winCreateColormapShadowDDNL (ColormapPtr pColormap);
-
-static Bool
-winDestroyColormapShadowDDNL (ColormapPtr pColormap);
-
-static Bool
-winCreatePrimarySurfaceShadowDDNL (ScreenPtr pScreen);
-
-static Bool
-winReleasePrimarySurfaceShadowDDNL (ScreenPtr pScreen);
-
-static HRESULT myIDirectDrawSurface4_Blt( ScreenPtr pScreen, RECT *pRect, RECT *prcSrc)
-{
- HRESULT ddrval = DD_OK;
- unsigned i;
- winScreenPriv(pScreen);
-
- for (i = 0; i < 3; ++i)
- {
- ddrval = IDirectDrawSurface4_Blt(pScreenPriv->pddsPrimary4, pRect, pScreenPriv->pddsShadow4, prcSrc, DDBLT_WAIT, NULL);
- /* Try to regain the primary surface and blit again if we've lost it */
- if (ddrval == DDERR_SURFACELOST)
- {
- /* Surface was lost */
- ErrorF ("IDirectDrawSurface4_Blt reported that the primary "
- "surface was lost, trying to restore, retry: %d\n", i + 1);
-
- /* Try to restore the surface, once */
-
- if (i==1)
- {
- ErrorF("Recreating DDraw surface because restoring of surface didn't work.\n");
- winAllocateFBShadowDDNL(pScreen);
- }
- else
- {
- ddrval = IDirectDraw4_RestoreAllSurfaces (pScreenPriv->pdd4);
- ErrorF ("IDirectDraw4_RestoreAllSurfaces returned: ");
- if (ddrval == DD_OK)
- ErrorF ("DD_OK\n");
- else if (ddrval == DDERR_WRONGMODE)
- ErrorF ("DDERR_WRONGMODE\n");
- else if (ddrval == DDERR_INCOMPATIBLEPRIMARY)
- ErrorF ("DDERR_INCOMPATIBLEPRIMARY\n");
- else if (ddrval == DDERR_UNSUPPORTED)
- ErrorF ("DDERR_UNSUPPORTED\n");
- else if (ddrval == DDERR_INVALIDPARAMS)
- ErrorF ("DDERR_INVALIDPARAMS\n");
- else if (ddrval == DDERR_INVALIDOBJECT)
- ErrorF ("DDERR_INVALIDOBJECT\n");
- else
- ErrorF ("unknown error: %08x\n", ddrval);
- }
- /* Loop around to try the blit one more time */
- continue;
- }
- else if (FAILED (ddrval))
- {
- ErrorF ("IDirectDrawSurface4_Blt failed, but surface not "
- "lost: %08x %d\n", ddrval, ddrval);
- }
- break;
- }
- return ddrval;
-}
-
-
-/*
- * Create the primary surface and attach the clipper.
- * Used for both the initial surface creation and during
- * WM_DISPLAYCHANGE messages.
- */
-
-static Bool
-winCreatePrimarySurfaceShadowDDNL (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- HRESULT ddrval = DD_OK;
- DDSURFACEDESC2 ddsd;
-
- winDebug ("winCreatePrimarySurfaceShadowDDNL - Creating primary surface\n");
-
- /* Describe the primary surface */
- ZeroMemory (&ddsd, sizeof (ddsd));
- ddsd.dwSize = sizeof (ddsd);
- ddsd.dwFlags = DDSD_CAPS;
- ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
-
- /* Create the primary surface */
- ddrval = IDirectDraw4_CreateSurface (pScreenPriv->pdd4,
- &ddsd,
- &pScreenPriv->pddsPrimary4,
- NULL);
- pScreenPriv->fRetryCreateSurface = FALSE;
- if (FAILED (ddrval))
- {
- if (ddrval == DDERR_NOEXCLUSIVEMODE)
- {
- /* Recreating the surface failed. Mark screen to retry later */
- pScreenPriv->fRetryCreateSurface = TRUE;
- winDebug ("winCreatePrimarySurfaceShadowDDNL - Could not create "
- "primary surface: DDERR_NOEXCLUSIVEMODE\n");
- }
- else
- {
- ErrorF ("winCreatePrimarySurfaceShadowDDNL - Could not create "
- "primary surface: %08x\n", (unsigned int) ddrval);
- }
- return FALSE;
- }
-
- winDebug ("winCreatePrimarySurfaceShadowDDNL - Created primary surface\n");
-
- /* Attach our clipper to our primary surface handle */
- ddrval = IDirectDrawSurface4_SetClipper (pScreenPriv->pddsPrimary4,
- pScreenPriv->pddcPrimary);
- if (FAILED (ddrval))
- {
- ErrorF ("winCreatePrimarySurfaceShadowDDNL - Primary attach clipper "
- "failed: %08x\n",
- (unsigned int) ddrval);
- return FALSE;
- }
-
- winDebug ("winCreatePrimarySurfaceShadowDDNL - Attached clipper to primary "
- "surface\n");
-
- /* Everything was correct */
- return TRUE;
-}
-
-
-static void ClosePrimarySurfaceShadowDDNL (winPrivScreenPtr pScreenPriv)
-{
- /* Release the primary surface and clipper, if they exist */
- if (pScreenPriv->pddsPrimary4)
- {
- /*
- * Detach the clipper from the primary surface.
- * NOTE: We do this explicity for clarity. The Clipper is not released.
- */
- IDirectDrawSurface4_SetClipper (pScreenPriv->pddsPrimary4, NULL);
-
- winDebug ("winReleasePrimarySurfaceShadowDDNL - Detached clipper\n");
-
- /* Release the primary surface */
- IDirectDrawSurface4_Release (pScreenPriv->pddsPrimary4);
- pScreenPriv->pddsPrimary4 = NULL;
- }
-
-}
-
-static void ReleaseDDNL(winPrivScreenPtr pScreenPriv)
-{
- /* Release the clipper object */
- if (pScreenPriv->pddcPrimary)
- {
- IDirectDrawClipper_Release (pScreenPriv->pddcPrimary);
- pScreenPriv->pddcPrimary = NULL;
- }
-
- /* Free the DirectDraw4 object, if there is one */
- if (pScreenPriv->pdd4)
- {
- IDirectDraw4_RestoreDisplayMode (pScreenPriv->pdd4);
- IDirectDraw4_Release (pScreenPriv->pdd4);
- pScreenPriv->pdd4 = NULL;
- }
-
- /* Free the DirectDraw object, if there is one */
- if (pScreenPriv->pdd)
- {
- IDirectDraw_Release (pScreenPriv->pdd);
- pScreenPriv->pdd = NULL;
- }
-}
-
-/*
- * Detach the clipper and release the primary surface.
- * Called from WM_DISPLAYCHANGE.
- */
-
-static Bool
-winReleasePrimarySurfaceShadowDDNL (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
-
- winDebug ("winReleasePrimarySurfaceShadowDDNL - Hello\n");
-
- ClosePrimarySurfaceShadowDDNL(pScreenPriv);
-
- winDebug ("winReleasePrimarySurfaceShadowDDNL - Released primary surface\n");
-
- return TRUE;
-}
-
-
-/*
- * Create a DirectDraw surface for the shadow framebuffer; also create
- * a primary surface object so we can blit to the display.
- *
- * Install a DirectDraw clipper on our primary surface object
- * that clips our blits to the unobscured client area of our display window.
- */
-
-Bool
-winAllocateFBShadowDDNL (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- HRESULT ddrval = DD_OK;
- DDSURFACEDESC2 ddsdShadow;
- char *lpSurface = NULL;
- DDPIXELFORMAT ddpfPrimary;
-
- winDebug ("winAllocateFBShadowDDNL - w %d h %d d %d\n",
- pScreenInfo->dwWidth, pScreenInfo->dwHeight, pScreenInfo->dwDepth);
-
- /* Set the padded screen width */
- pScreenInfo->dwPaddedWidth = PixmapBytePad (pScreenInfo->dwWidth,
- pScreenInfo->dwBPP);
-
- if ( pScreenInfo->pfb)
- {
- ErrorF("winAllocateFBShadowDDNL calling for the second time, reallocating\n");
- lpSurface=pScreenInfo->pfb;
-
- if (pScreenPriv->pddsShadow4)
- {
- IDirectDrawSurface4_Release (pScreenPriv->pddsShadow4);
- pScreenPriv->pddsShadow4 = NULL;
- }
- ClosePrimarySurfaceShadowDDNL(pScreenPriv);
- ReleaseDDNL(pScreenPriv);
- }
- else
- {
- /* Allocate memory for our shadow surface */
- lpSurface = malloc (pScreenInfo->dwPaddedWidth * pScreenInfo->dwHeight);
- if (lpSurface == NULL)
- {
- ErrorF ("winAllocateFBShadowDDNL - Could not allocate bits\n");
- return FALSE;
- }
-
- /*
- * Initialize the framebuffer memory so we don't get a
- * strange display at startup
- */
- ZeroMemory (lpSurface, pScreenInfo->dwPaddedWidth * pScreenInfo->dwHeight);
- }
- /* Create a clipper */
- ddrval = (*g_fpDirectDrawCreateClipper) (0,
- &pScreenPriv->pddcPrimary,
- NULL);
- if (FAILED (ddrval))
- {
- ErrorF ("winAllocateFBShadowDDNL - Could not attach clipper: %08x\n",
- (unsigned int) ddrval);
- return FALSE;
- }
-
- winDebug ("winAllocateFBShadowDDNL - Created a clipper\n");
-
- /* Attach the clipper to our display window */
- ddrval = IDirectDrawClipper_SetHWnd (pScreenPriv->pddcPrimary,
- 0,
- pScreenPriv->hwndScreen);
- if (FAILED (ddrval))
- {
- ErrorF ("winAllocateFBShadowDDNL - Clipper not attached "
- "to window: %08x\n",
- (unsigned int) ddrval);
- return FALSE;
- }
-
- winDebug ("winAllocateFBShadowDDNL - Attached clipper to window\n");
-
- /* Create a DirectDraw object, store the address at lpdd */
- ddrval = (*g_fpDirectDrawCreate) (NULL,
- (LPDIRECTDRAW*) &pScreenPriv->pdd,
- NULL);
- if (FAILED (ddrval))
- {
- ErrorF ("winAllocateFBShadowDDNL - Could not start "
- "DirectDraw: %08x\n",
- (unsigned int) ddrval);
- return FALSE;
- }
-
- winDebug ("winAllocateFBShadowDDNL - Created and initialized DD\n");
-
- /* Get a DirectDraw4 interface pointer */
- ddrval = IDirectDraw_QueryInterface (pScreenPriv->pdd,
- &IID_IDirectDraw4,
- (LPVOID*) &pScreenPriv->pdd4);
- if (FAILED (ddrval))
- {
- ErrorF ("winAllocateFBShadowDDNL - Failed DD4 query: %08x\n",
- (unsigned int) ddrval);
- return FALSE;
- }
-
- /* Are we full screen? */
- if (pScreenInfo->fFullScreen)
- {
- DDSURFACEDESC2 ddsdCurrent;
- DWORD dwRefreshRateCurrent = 0;
- HDC hdc = NULL;
-
- /* Set the cooperative level to full screen */
- ddrval = IDirectDraw4_SetCooperativeLevel (pScreenPriv->pdd4,
- pScreenPriv->hwndScreen,
- DDSCL_EXCLUSIVE
- | DDSCL_FULLSCREEN);
- if (FAILED (ddrval))
- {
- ErrorF ("winAllocateFBShadowDDNL - Could not set "
- "cooperative level: %08x\n",
- (unsigned int) ddrval);
- return FALSE;
- }
-
- /*
- * We only need to get the current refresh rate for comparison
- * if a refresh rate has been passed on the command line.
- */
- if (pScreenInfo->dwRefreshRate != 0)
- {
- ZeroMemory (&ddsdCurrent, sizeof (ddsdCurrent));
- ddsdCurrent.dwSize = sizeof (ddsdCurrent);
-
- /* Get information about current display settings */
- ddrval = IDirectDraw4_GetDisplayMode (pScreenPriv->pdd4,
- &ddsdCurrent);
- if (FAILED (ddrval))
- {
- ErrorF ("winAllocateFBShadowDDNL - Could not get current "
- "refresh rate: %08x. Continuing.\n",
- (unsigned int) ddrval);
- dwRefreshRateCurrent = 0;
- }
- else
- {
- /* Grab the current refresh rate */
- dwRefreshRateCurrent = ddsdCurrent.u2.dwRefreshRate;
- }
- }
-
- /* Clean up the refresh rate */
- if (dwRefreshRateCurrent == pScreenInfo->dwRefreshRate)
- {
- /*
- * Refresh rate is non-specified or equal to current.
- */
- pScreenInfo->dwRefreshRate = 0;
- }
-
- /* Grab a device context for the screen */
- hdc = GetDC (NULL);
- if (hdc == NULL)
- {
- ErrorF ("winAllocateFBShadowDDNL - GetDC () failed\n");
- return FALSE;
- }
-
- /* Only change the video mode when different than current mode */
- if (!pScreenInfo->fMultipleMonitors
- && (pScreenInfo->dwWidth != GetSystemMetrics (SM_CXSCREEN)
- || pScreenInfo->dwHeight != GetSystemMetrics (SM_CYSCREEN)
- || pScreenInfo->dwBPP != GetDeviceCaps (hdc, BITSPIXEL)
- || pScreenInfo->dwRefreshRate != 0))
- {
- winDebug ("winAllocateFBShadowDDNL - Changing video mode\n");
-
- /* Change the video mode to the mode requested, and use the driver default refresh rate on failure */
- ddrval = IDirectDraw4_SetDisplayMode (pScreenPriv->pdd4,
- pScreenInfo->dwWidth,
- pScreenInfo->dwHeight,
- pScreenInfo->dwBPP,
- pScreenInfo->dwRefreshRate,
- 0);
- if (FAILED (ddrval))
- {
- ErrorF ("winAllocateFBShadowDDNL - Could not set "
- "full screen display mode: %08x\n",
- (unsigned int) ddrval);
- ErrorF ("winAllocateFBShadowDDNL - Using default driver refresh rate\n");
- ddrval = IDirectDraw4_SetDisplayMode (pScreenPriv->pdd4,
- pScreenInfo->dwWidth,
- pScreenInfo->dwHeight,
- pScreenInfo->dwBPP,
- 0,
- 0);
- if (FAILED(ddrval))
- {
- ErrorF ("winAllocateFBShadowDDNL - Could not set default refresh rate "
- "full screen display mode: %08x\n",
- (unsigned int) ddrval);
- return FALSE;
- }
- }
- }
- else
- {
- winDebug ("winAllocateFBShadowDDNL - Not changing video mode\n");
- }
-
- /* Release our DC */
- ReleaseDC (NULL, hdc);
- hdc = NULL;
- }
- else
- {
- /* Set the cooperative level for windowed mode */
- ddrval = IDirectDraw4_SetCooperativeLevel (pScreenPriv->pdd4,
- pScreenPriv->hwndScreen,
- DDSCL_NORMAL);
- if (FAILED (ddrval))
- {
- ErrorF ("winAllocateFBShadowDDNL - Could not set "
- "cooperative level: %08x\n",
- (unsigned int) ddrval);
- return FALSE;
- }
- }
-
- /* Create the primary surface */
- if (!winCreatePrimarySurfaceShadowDDNL (pScreen))
- {
- ErrorF ("winAllocateFBShadowDDNL - winCreatePrimarySurfaceShadowDDNL "
- "failed\n");
- return FALSE;
- }
-
- /* Get primary surface's pixel format */
- ZeroMemory (&ddpfPrimary, sizeof (ddpfPrimary));
- ddpfPrimary.dwSize = sizeof (ddpfPrimary);
- ddrval = IDirectDrawSurface4_GetPixelFormat (pScreenPriv->pddsPrimary4,
- &ddpfPrimary);
- if (FAILED (ddrval))
- {
- ErrorF ("winAllocateFBShadowDDNL - Could not get primary "
- "pixformat: %08x\n",
- (unsigned int) ddrval);
- return FALSE;
- }
-
- winDebug ("winAllocateFBShadowDDNL - Primary masks: %08x %08x %08x "
- "dwRGBBitCount: %d\n",
- ddpfPrimary.u2.dwRBitMask,
- ddpfPrimary.u3.dwGBitMask,
- ddpfPrimary.u4.dwBBitMask,
- ddpfPrimary.u1.dwRGBBitCount);
-
- /* Describe the shadow surface to be created */
- /*
- * NOTE: Do not use a DDSCAPS_VIDEOMEMORY surface,
- * as drawing, locking, and unlocking take forever
- * with video memory surfaces. In addition,
- * video memory is a somewhat scarce resource,
- * so you shouldn't be allocating video memory when
- * you have the option of using system memory instead.
- */
- ZeroMemory (&ddsdShadow, sizeof (ddsdShadow));
- ddsdShadow.dwSize = sizeof (ddsdShadow);
- ddsdShadow.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH
- | DDSD_LPSURFACE | DDSD_PITCH | DDSD_PIXELFORMAT;
- ddsdShadow.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
- ddsdShadow.dwHeight = pScreenInfo->dwHeight;
- ddsdShadow.dwWidth = pScreenInfo->dwWidth;
- ddsdShadow.u1.lPitch = pScreenInfo->dwPaddedWidth;
- ddsdShadow.lpSurface = lpSurface;
- ddsdShadow.u4.ddpfPixelFormat = ddpfPrimary;
-
- winDebug ("winAllocateFBShadowDDNL - lPitch: %d\n",
- (int) pScreenInfo->dwPaddedWidth);
-
- /* Create the shadow surface */
- ddrval = IDirectDraw4_CreateSurface (pScreenPriv->pdd4,
- &ddsdShadow,
- &pScreenPriv->pddsShadow4,
- NULL);
- if (FAILED (ddrval))
- {
- ErrorF ("winAllocateFBShadowDDNL - Could not create shadow "
- "surface: %08x\n", (unsigned int) ddrval);
- return FALSE;
- }
-
- winDebug ("winAllocateFBShadowDDNL - Created shadow pitch: %d\n",
- (int) ddsdShadow.u1.lPitch);
-
- /* Grab the pitch from the surface desc */
- pScreenInfo->dwStride = (ddsdShadow.u1.lPitch * 8)
- / pScreenInfo->dwBPP;
-
- winDebug ("winAllocateFBShadowDDNL - Created shadow stride: %d\n",
- (int) pScreenInfo->dwStride);
-
- /* Save the pointer to our surface memory */
- pScreenInfo->pfb = lpSurface;
-
- /* Grab the masks from the surface description */
- pScreenPriv->dwRedMask = ddsdShadow.u4.ddpfPixelFormat.u2.dwRBitMask;
- pScreenPriv->dwGreenMask = ddsdShadow.u4.ddpfPixelFormat.u3.dwGBitMask;
- pScreenPriv->dwBlueMask = ddsdShadow.u4.ddpfPixelFormat.u4.dwBBitMask;
-
- winDebug ("winAllocateFBShadowDDNL - Returning\n");
-
- return TRUE;
-}
-
-static void
-winFreeFBShadowDDNL(ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-
- /* Free the shadow surface, if there is one */
- if (pScreenPriv->pddsShadow4)
- {
- IDirectDrawSurface4_Release (pScreenPriv->pddsShadow4);
- free (pScreenInfo->pfb);
- pScreenInfo->pfb = NULL;
- pScreenPriv->pddsShadow4 = NULL;
- }
-
- /* Detach the clipper from the primary surface and release the primary surface, if there is one */
- winReleasePrimarySurfaceShadowDDNL(pScreen);
-
- ReleaseDDNL(pScreenPriv);
-
- /* Invalidate the ScreenInfo's fb pointer */
- pScreenInfo->pfb = NULL;
-}
-
-#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
-/*
- * Create a DirectDraw surface for the new multi-window window
- */
-
-static
-Bool
-winFinishCreateWindowsWindowDDNL (WindowPtr pWin)
-{
- winWindowPriv(pWin);
- winPrivScreenPtr pScreenPriv = pWinPriv->pScreenPriv;
- HRESULT ddrval = DD_OK;
- DDSURFACEDESC2 ddsd;
- int iWidth, iHeight;
- int iX, iY;
-
- winDebug ("winFinishCreateWindowsWindowDDNL!\n\n");
-
- iX = pWin->drawable.x + GetSystemMetrics (SM_XVIRTUALSCREEN);
- iY = pWin->drawable.y + GetSystemMetrics (SM_YVIRTUALSCREEN);
-
- iWidth = pWin->drawable.width;
- iHeight = pWin->drawable.height;
-
- /* Describe the primary surface */
- ZeroMemory (&ddsd, sizeof (ddsd));
- ddsd.dwSize = sizeof (ddsd);
- ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
- ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
- ddsd.dwHeight = iHeight;
- ddsd.dwWidth = iWidth;
-
- /* Create the primary surface */
- ddrval = IDirectDraw4_CreateSurface (pScreenPriv->pdd4,
- &ddsd,
- &pWinPriv->pddsPrimary4,
- NULL);
- if (FAILED (ddrval))
- {
- ErrorF ("winFinishCreateWindowsWindowDDNL - Could not create primary "
- "surface: %08x\n",
- (unsigned int)ddrval);
- return FALSE;
- }
- return TRUE;
-}
-#endif
-
-
-/*
- * Transfer the damaged regions of the shadow framebuffer to the display.
- */
-
-static void
-winShadowUpdateDDNL (ScreenPtr pScreen,
- shadowBufPtr pBuf)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- RegionPtr damage = shadowDamage(pBuf);
- RECT rcDest, rcSrc;
- POINT ptOrigin;
- DWORD dwBox = RegionNumRects (damage);
- BoxPtr pBox = RegionRects (damage);
- HRGN hrgnTemp = NULL, hrgnCombined = NULL;
-
- /*
- * Return immediately if the app is not active
- * and we are fullscreen, or if we have a bad display depth
- */
- if ((!pScreenPriv->fActive && pScreenInfo->fFullScreen)
- || pScreenPriv->fBadDepth) return;
-
- /* Return immediately if we didn't get needed surfaces */
- if (!pScreenPriv->pddsPrimary4 || !pScreenPriv->pddsShadow4)
- return;
-
- /* Get the origin of the window in the screen coords */
- ptOrigin.x = pScreenInfo->dwXOffset;
- ptOrigin.y = pScreenInfo->dwYOffset;
- MapWindowPoints (pScreenPriv->hwndScreen,
- HWND_DESKTOP,
- (LPPOINT)&ptOrigin, 1);
-
- /*
- * Handle small regions with multiple blits,
- * handle large regions by creating a clipping region and
- * doing a single blit constrained to that clipping region.
- */
- if (pScreenInfo->dwClipUpdatesNBoxes == 0
- || dwBox < pScreenInfo->dwClipUpdatesNBoxes)
- {
- /* Loop through all boxes in the damaged region */
- while (dwBox--)
- {
- /* Assign damage box to source rectangle */
- rcSrc.left = pBox->x1;
- rcSrc.top = pBox->y1;
- rcSrc.right = pBox->x2;
- rcSrc.bottom = pBox->y2;
-
- /* Calculate destination rectangle */
- rcDest.left = ptOrigin.x + rcSrc.left;
- rcDest.top = ptOrigin.y + rcSrc.top;
- rcDest.right = ptOrigin.x + rcSrc.right;
- rcDest.bottom = ptOrigin.y + rcSrc.bottom;
-
- /* Blit the damaged areas */
- if (pScreenPriv->pddsPrimary4)
- myIDirectDrawSurface4_Blt (pScreen,
- &rcDest,
- &rcSrc);
-
- /* Get a pointer to the next box */
- ++pBox;
- }
- }
- else
- {
- BoxPtr pBoxExtents = RegionExtents(damage);
-
- /* Compute a GDI region from the damaged region */
- hrgnCombined = CreateRectRgn (pBox->x1, pBox->y1, pBox->x2, pBox->y2);
- dwBox--;
- pBox++;
- while (dwBox--)
- {
- hrgnTemp = CreateRectRgn (pBox->x1, pBox->y1, pBox->x2, pBox->y2);
- CombineRgn (hrgnCombined, hrgnCombined, hrgnTemp, RGN_OR);
- DeleteObject (hrgnTemp);
- pBox++;
- }
-
- /* Install the GDI region as a clipping region */
- SelectClipRgn (pScreenPriv->hdcScreen, hrgnCombined);
- DeleteObject (hrgnCombined);
- hrgnCombined = NULL;
-
- winDebug ("winShadowUpdateDDNL - be x1 %d y1 %d x2 %d y2 %d\n",
- pBoxExtents->x1, pBoxExtents->y1,
- pBoxExtents->x2, pBoxExtents->y2);
-
- /* Calculating a bounding box for the source is easy */
- rcSrc.left = pBoxExtents->x1;
- rcSrc.top = pBoxExtents->y1;
- rcSrc.right = pBoxExtents->x2;
- rcSrc.bottom = pBoxExtents->y2;
-
- /* Calculating a bounding box for the destination is trickier */
- rcDest.left = ptOrigin.x + rcSrc.left;
- rcDest.top = ptOrigin.y + rcSrc.top;
- rcDest.right = ptOrigin.x + rcSrc.right;
- rcDest.bottom = ptOrigin.y + rcSrc.bottom;
-
- /* Our Blt should be clipped to the invalidated region */
- myIDirectDrawSurface4_Blt (pScreen, &rcDest, &rcSrc);
-
- /* Reset the clip region */
- SelectClipRgn (pScreenPriv->hdcScreen, NULL);
- }
-}
-
-static Bool
-winInitScreenShadowDDNL(ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
-
- /* Get a device context for the screen */
- pScreenPriv->hdcScreen = GetDC (pScreenPriv->hwndScreen);
-
- return winAllocateFBShadowDDNL(pScreen);
-}
-
-/*
- * Call the wrapped CloseScreen function.
- *
- * Free our resources and private structures.
- */
-
-static Bool
-winCloseScreenShadowDDNL (int nIndex, ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- Bool fReturn;
-
- winDebug ("winCloseScreenShadowDDNL - Freeing screen resources\n");
-
- /* Flag that the screen is closed */
- pScreenPriv->fClosed = TRUE;
- pScreenPriv->fActive = FALSE;
-
- /* Call the wrapped CloseScreen procedure */
- WIN_UNWRAP(CloseScreen);
- if (pScreen->CloseScreen)
- fReturn = (*pScreen->CloseScreen) (nIndex, pScreen);
-
- winFreeFBShadowDDNL(pScreen);
-
- /* Free the screen DC */
- ReleaseDC (pScreenPriv->hwndScreen, pScreenPriv->hdcScreen);
-
- /* Delete the window property */
- RemoveProp (pScreenPriv->hwndScreen, WIN_SCR_PROP);
-
- /* Delete tray icon, if we have one */
- if (!pScreenInfo->fNoTrayIcon)
- winDeleteNotifyIcon (pScreenPriv);
-
- /* Free the exit confirmation dialog box, if it exists */
- if (g_hDlgExit != NULL)
- {
- DestroyWindow (g_hDlgExit);
- g_hDlgExit = NULL;
- }
-
- /* Kill our window */
- if (pScreenPriv->hwndScreen)
- {
- DestroyWindow (pScreenPriv->hwndScreen);
- pScreenPriv->hwndScreen = NULL;
- }
-
-#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
- /* Destroy the thread startup mutex */
- pthread_mutex_destroy (&pScreenPriv->pmServerStarted);
-#endif
-
- /* Kill our screeninfo's pointer to the screen */
- pScreenInfo->pScreen = NULL;
-
- /* Free the screen privates for this screen */
- free ((pointer) pScreenPriv);
-
- return fReturn;
-}
-
-
-/*
- * Tell mi what sort of visuals we need.
- *
- * Generally we only need one visual, as our screen can only
- * handle one format at a time, I believe. You may want
- * to verify that last sentence.
- */
-
-static Bool
-winInitVisualsShadowDDNL (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- DWORD dwRedBits, dwGreenBits, dwBlueBits;
-
- /* Count the number of ones in each color mask */
- dwRedBits = winCountBits (pScreenPriv->dwRedMask);
- dwGreenBits = winCountBits (pScreenPriv->dwGreenMask);
- dwBlueBits = winCountBits (pScreenPriv->dwBlueMask);
-
- /* Store the maximum number of ones in a color mask as the bitsPerRGB */
- if (dwRedBits == 0 || dwGreenBits == 0 || dwBlueBits == 0)
- pScreenPriv->dwBitsPerRGB = 8;
- else if (dwRedBits > dwGreenBits && dwRedBits > dwBlueBits)
- pScreenPriv->dwBitsPerRGB = dwRedBits;
- else if (dwGreenBits > dwRedBits && dwGreenBits > dwBlueBits)
- pScreenPriv->dwBitsPerRGB = dwGreenBits;
- else
- pScreenPriv->dwBitsPerRGB = dwBlueBits;
-
- winDebug ("winInitVisualsShadowDDNL - Masks %08x %08x %08x BPRGB %d d %d "
- "bpp %d\n",
- (unsigned int) pScreenPriv->dwRedMask,
- (unsigned int) pScreenPriv->dwGreenMask,
- (unsigned int) pScreenPriv->dwBlueMask,
- (int) pScreenPriv->dwBitsPerRGB,
- (int) pScreenInfo->dwDepth,
- (int) pScreenInfo->dwBPP);
-
- /* Create a single visual according to the Windows screen depth */
- switch (pScreenInfo->dwDepth)
- {
- case 24:
- case 16:
- case 15:
- /* Setup the real visual */
- if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
- TrueColorMask,
- pScreenPriv->dwBitsPerRGB,
- -1,
- pScreenPriv->dwRedMask,
- pScreenPriv->dwGreenMask,
- pScreenPriv->dwBlueMask))
- {
- ErrorF ("winInitVisualsShadowDDNL - miSetVisualTypesAndMasks "
- "failed for TrueColor\n");
- return FALSE;
- }
-
-#ifdef XWIN_EMULATEPSEUDO
- if (!pScreenInfo->fEmulatePseudo)
- break;
-
- /* Setup a pseudocolor visual */
- if (!miSetVisualTypesAndMasks (8,
- PseudoColorMask,
- 8,
- -1,
- 0,
- 0,
- 0))
- {
- ErrorF ("winInitVisualsShadowDDNL - miSetVisualTypesAndMasks "
- "failed for PseudoColor\n");
- return FALSE;
- }
-#endif
- break;
-
- case 8:
- if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
- pScreenInfo->fFullScreen
- ? PseudoColorMask : StaticColorMask,
- pScreenPriv->dwBitsPerRGB,
- pScreenInfo->fFullScreen
- ? PseudoColor : StaticColor,
- pScreenPriv->dwRedMask,
- pScreenPriv->dwGreenMask,
- pScreenPriv->dwBlueMask))
- {
- ErrorF ("winInitVisualsShadowDDNL - miSetVisualTypesAndMasks "
- "failed\n");
- return FALSE;
- }
- break;
-
- default:
- ErrorF ("winInitVisualsShadowDDNL - Unknown screen depth\n");
- return FALSE;
- }
-
- winDebug ("winInitVisualsShadowDDNL - Returning\n");
-
- return TRUE;
-}
-
-
-/*
- * Adjust the user proposed video mode
- */
-
-static Bool
-winAdjustVideoModeShadowDDNL (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- HDC hdc = NULL;
- DWORD dwBPP;
-
- /* We're in serious trouble if we can't get a DC */
- hdc = GetDC (NULL);
- if (hdc == NULL)
- {
- ErrorF ("winAdjustVideoModeShadowDDNL - GetDC () failed\n");
- return FALSE;
- }
-
- /* Query GDI for current display depth */
- dwBPP = GetDeviceCaps (hdc, BITSPIXEL);
-
- /* DirectDraw can only change the depth in fullscreen mode */
- if (!(pScreenInfo->fFullScreen &&
- (pScreenInfo->dwBPP != WIN_DEFAULT_BPP)))
- {
- /* Otherwise, We'll use GDI's depth */
- pScreenInfo->dwBPP = dwBPP;
- }
-
- /* Release our DC */
- ReleaseDC (NULL, hdc);
-
- return TRUE;
-}
-
-
-/*
- * Blt exposed regions to the screen
- */
-
-static Bool
-winBltExposedRegionsShadowDDNL (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- RECT rcSrc, rcDest;
- POINT ptOrigin;
- HDC hdcUpdate;
- PAINTSTRUCT ps;
- HRESULT ddrval = DD_OK;
- Bool fReturn = TRUE;
- int i;
-
- /* Quite common case. The primary surface was lost (maybe because of depth
- * change). Try to create a new primary surface. Bail out if this fails */
- if (pScreenPriv->pddsPrimary4 == NULL && pScreenPriv->fRetryCreateSurface &&
- !winCreatePrimarySurfaceShadowDDNL(pScreen))
- {
- Sleep(100);
- return FALSE;
- }
- if (pScreenPriv->pddsPrimary4 == NULL)
- return FALSE;
-
- /* BeginPaint gives us an hdc that clips to the invalidated region */
- hdcUpdate = BeginPaint (pScreenPriv->hwndScreen, &ps);
- if (hdcUpdate == NULL)
- {
- fReturn = FALSE;
- ErrorF ("winBltExposedRegionsShadowDDNL - BeginPaint () returned "
- "a NULL device context handle. Aborting blit attempt.\n");
- goto winBltExposedRegionsShadowDDNL_Exit;
- }
-
- /* Get the origin of the window in the screen coords */
- ptOrigin.x = pScreenInfo->dwXOffset;
- ptOrigin.y = pScreenInfo->dwYOffset;
-
- MapWindowPoints (pScreenPriv->hwndScreen,
- HWND_DESKTOP,
- (LPPOINT)&ptOrigin, 1);
- rcDest.left = ptOrigin.x;
- rcDest.right = ptOrigin.x + pScreenInfo->dwWidth;
- rcDest.top = ptOrigin.y;
- rcDest.bottom = ptOrigin.y + pScreenInfo->dwHeight;
-
- /* Source can be entire shadow surface, as Blt should clip for us */
- rcSrc.left = 0;
- rcSrc.top = 0;
- rcSrc.right = pScreenInfo->dwWidth;
- rcSrc.bottom = pScreenInfo->dwHeight;
-
- /* Our Blt should be clipped to the invalidated region */
- ddrval = myIDirectDrawSurface4_Blt (pScreen, &rcDest, &rcSrc);
- if (FAILED (ddrval))
- {
- fReturn = FALSE;
- }
-
-winBltExposedRegionsShadowDDNL_Exit:
- /* EndPaint frees the DC */
- if (hdcUpdate != NULL)
- EndPaint (pScreenPriv->hwndScreen, &ps);
- return fReturn;
-}
-
-
-/*
- * Do any engine-specific application-activation processing
- */
-
-static Bool
-winActivateAppShadowDDNL (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
-
- /*
- * Do we have a surface?
- * Are we active?
- * Are we full screen?
- */
- if (pScreenPriv != NULL
- && pScreenPriv->pddsPrimary4 != NULL
- && pScreenPriv->fActive)
- {
- /* Primary surface was lost, restore it */
- IDirectDrawSurface4_Restore (pScreenPriv->pddsPrimary4);
- }
-
- return TRUE;
-}
-
-
-/*
- * Reblit the shadow framebuffer to the screen.
- */
-
-static Bool
-winRedrawScreenShadowDDNL (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- RECT rcSrc, rcDest;
- POINT ptOrigin;
-
- /* Get the origin of the window in the screen coords */
- ptOrigin.x = pScreenInfo->dwXOffset;
- ptOrigin.y = pScreenInfo->dwYOffset;
- MapWindowPoints (pScreenPriv->hwndScreen,
- HWND_DESKTOP,
- (LPPOINT)&ptOrigin, 1);
- rcDest.left = ptOrigin.x;
- rcDest.right = ptOrigin.x + pScreenInfo->dwWidth;
- rcDest.top = ptOrigin.y;
- rcDest.bottom = ptOrigin.y + pScreenInfo->dwHeight;
-
- /* Source can be entire shadow surface, as Blt should clip for us */
- rcSrc.left = 0;
- rcSrc.top = 0;
- rcSrc.right = pScreenInfo->dwWidth;
- rcSrc.bottom = pScreenInfo->dwHeight;
-
- /* Redraw the whole window, to take account for the new colors */
- myIDirectDrawSurface4_Blt (pScreen, &rcDest, &rcSrc);
- return TRUE;
-}
-
-
-/*
- * Realize the currently installed colormap
- */
-
-static Bool
-winRealizeInstalledPaletteShadowDDNL (ScreenPtr pScreen)
-{
- return TRUE;
-}
-
-
-/*
- * Install the specified colormap
- */
-
-static Bool
-winInstallColormapShadowDDNL (ColormapPtr pColormap)
-{
- ScreenPtr pScreen = pColormap->pScreen;
- winScreenPriv(pScreen);
- winCmapPriv(pColormap);
- HRESULT ddrval = DD_OK;
-
- /* Install the DirectDraw palette on the primary surface */
- ddrval = IDirectDrawSurface4_SetPalette (pScreenPriv->pddsPrimary4,
- pCmapPriv->lpDDPalette);
- if (FAILED (ddrval))
- {
- ErrorF ("winInstallColormapShadowDDNL - Failed installing the "
- "DirectDraw palette.\n");
- return FALSE;
- }
-
- /* Save a pointer to the newly installed colormap */
- pScreenPriv->pcmapInstalled = pColormap;
-
- return TRUE;
-}
-
-
-/*
- * Store the specified colors in the specified colormap
- */
-
-static Bool
-winStoreColorsShadowDDNL (ColormapPtr pColormap,
- int ndef,
- xColorItem *pdefs)
-{
- ScreenPtr pScreen = pColormap->pScreen;
- winScreenPriv(pScreen);
- winCmapPriv(pColormap);
- ColormapPtr curpmap = pScreenPriv->pcmapInstalled;
- HRESULT ddrval = DD_OK;
-
- /* Put the X colormap entries into the Windows logical palette */
- ddrval = IDirectDrawPalette_SetEntries (pCmapPriv->lpDDPalette,
- 0,
- pdefs[0].pixel,
- ndef,
- pCmapPriv->peColors
- + pdefs[0].pixel);
- if (FAILED (ddrval))
- {
- ErrorF ("winStoreColorsShadowDDNL - SetEntries () failed: %08x\n", (unsigned int) ddrval);
- return FALSE;
- }
-
- /* Don't install the DirectDraw palette if the colormap is not installed */
- if (pColormap != curpmap)
- {
- return TRUE;
- }
-
- if (!winInstallColormapShadowDDNL (pColormap))
- {
- ErrorF ("winStoreColorsShadowDDNL - Failed installing colormap\n");
- return FALSE;
- }
-
- return TRUE;
-}
-
-
-/*
- * Colormap initialization procedure
- */
-
-static Bool
-winCreateColormapShadowDDNL (ColormapPtr pColormap)
-{
- HRESULT ddrval = DD_OK;
- ScreenPtr pScreen = pColormap->pScreen;
- winScreenPriv(pScreen);
- winCmapPriv(pColormap);
-
- /* Create a DirectDraw palette */
- ddrval = IDirectDraw4_CreatePalette (pScreenPriv->pdd4,
- DDPCAPS_8BIT | DDPCAPS_ALLOW256,
- pCmapPriv->peColors,
- &pCmapPriv->lpDDPalette,
- NULL);
- if (FAILED (ddrval))
- {
- ErrorF ("winCreateColormapShadowDDNL - CreatePalette failed\n");
- return FALSE;
- }
-
- return TRUE;
-}
-
-
-/*
- * Colormap destruction procedure
- */
-
-static Bool
-winDestroyColormapShadowDDNL (ColormapPtr pColormap)
-{
- winScreenPriv(pColormap->pScreen);
- winCmapPriv(pColormap);
- HRESULT ddrval = DD_OK;
-
- /*
- * Is colormap to be destroyed the default?
- *
- * Non-default colormaps should have had winUninstallColormap
- * called on them before we get here. The default colormap
- * will not have had winUninstallColormap called on it. Thus,
- * we need to handle the default colormap in a special way.
- */
- if (pColormap->flags & IsDefault)
- {
- winDebug ("winDestroyColormapShadowDDNL - Destroying default colormap\n");
-
- /*
- * FIXME: Walk the list of all screens, popping the default
- * palette out of each screen device context.
- */
-
- /* Pop the palette out of the primary surface */
- ddrval = IDirectDrawSurface4_SetPalette (pScreenPriv->pddsPrimary4,
- NULL);
- if (FAILED (ddrval))
- {
- ErrorF ("winDestroyColormapShadowDDNL - Failed freeing the "
- "default colormap DirectDraw palette.\n");
- return FALSE;
- }
-
- /* Clear our private installed colormap pointer */
- pScreenPriv->pcmapInstalled = NULL;
- }
-
- /* Release the palette */
- IDirectDrawPalette_Release (pCmapPriv->lpDDPalette);
-
- /* Invalidate the colormap privates */
- pCmapPriv->lpDDPalette = NULL;
-
- return TRUE;
-}
-
-
-/*
- * Set pointers to our engine specific functions
- */
-
-Bool
-winSetEngineFunctionsShadowDDNL (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-
- /* Set our pointers */
- pScreenPriv->pwinAllocateFB = winAllocateFBShadowDDNL;
- pScreenPriv->pwinFreeFB = winFreeFBShadowDDNL;
- pScreenPriv->pwinShadowUpdate = winShadowUpdateDDNL;
- pScreenPriv->pwinInitScreen = winInitScreenShadowDDNL;
- pScreenPriv->pwinCloseScreen = winCloseScreenShadowDDNL;
- pScreenPriv->pwinInitVisuals = winInitVisualsShadowDDNL;
- pScreenPriv->pwinAdjustVideoMode = winAdjustVideoModeShadowDDNL;
- if (pScreenInfo->fFullScreen)
- pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowFullScreen;
- else
- pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowWindowed;
- pScreenPriv->pwinFinishScreenInit = winFinishScreenInitFB;
- pScreenPriv->pwinBltExposedRegions = winBltExposedRegionsShadowDDNL;
- pScreenPriv->pwinActivateApp = winActivateAppShadowDDNL;
- pScreenPriv->pwinRedrawScreen = winRedrawScreenShadowDDNL;
- pScreenPriv->pwinRealizeInstalledPalette
- = winRealizeInstalledPaletteShadowDDNL;
- pScreenPriv->pwinInstallColormap = winInstallColormapShadowDDNL;
- pScreenPriv->pwinStoreColors = winStoreColorsShadowDDNL;
- pScreenPriv->pwinCreateColormap = winCreateColormapShadowDDNL;
- pScreenPriv->pwinDestroyColormap = winDestroyColormapShadowDDNL;
- pScreenPriv->pwinHotKeyAltTab = (winHotKeyAltTabProcPtr) (void (*)(void))NoopDDA;
- pScreenPriv->pwinCreatePrimarySurface = winCreatePrimarySurfaceShadowDDNL;
- pScreenPriv->pwinReleasePrimarySurface = winReleasePrimarySurfaceShadowDDNL;
-#ifdef XWIN_MULTIWINDOW
- pScreenPriv->pwinFinishCreateWindowsWindow
- = winFinishCreateWindowsWindowDDNL;
-#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"
+
+
+/*
+ * 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
+ * here manually. Should be handled by ddraw.h
+ */
+#ifndef IID_IDirectDraw4
+DEFINE_GUID( IID_IDirectDraw4, 0x9c59509a,0x39bd,0x11d1,0x8c,0x4a,0x00,0xc0,0x4f,0xd9,0x30,0xc5 );
+#endif /* IID_IDirectDraw4 */
+
+#define FAIL_MSG_MAX_BLT 10
+
+
+/*
+ * Local prototypes
+ */
+
+static Bool
+winAllocateFBShadowDDNL (ScreenPtr pScreen);
+
+static void
+winShadowUpdateDDNL (ScreenPtr pScreen,
+ shadowBufPtr pBuf);
+
+static Bool
+winCloseScreenShadowDDNL (int nIndex, ScreenPtr pScreen);
+
+static Bool
+winInitVisualsShadowDDNL (ScreenPtr pScreen);
+
+static Bool
+winAdjustVideoModeShadowDDNL (ScreenPtr pScreen);
+
+static Bool
+winBltExposedRegionsShadowDDNL (ScreenPtr pScreen);
+
+static Bool
+winActivateAppShadowDDNL (ScreenPtr pScreen);
+
+static Bool
+winRedrawScreenShadowDDNL (ScreenPtr pScreen);
+
+static Bool
+winRealizeInstalledPaletteShadowDDNL (ScreenPtr pScreen);
+
+static Bool
+winInstallColormapShadowDDNL (ColormapPtr pColormap);
+
+static Bool
+winStoreColorsShadowDDNL (ColormapPtr pmap,
+ int ndef,
+ xColorItem *pdefs);
+
+static Bool
+winCreateColormapShadowDDNL (ColormapPtr pColormap);
+
+static Bool
+winDestroyColormapShadowDDNL (ColormapPtr pColormap);
+
+static Bool
+winCreatePrimarySurfaceShadowDDNL (ScreenPtr pScreen);
+
+static Bool
+winReleasePrimarySurfaceShadowDDNL (ScreenPtr pScreen);
+
+static HRESULT myIDirectDrawSurface4_Blt( ScreenPtr pScreen, RECT *pRect, RECT *prcSrc)
+{
+ HRESULT ddrval = DD_OK;
+ unsigned i;
+ winScreenPriv(pScreen);
+
+ for (i = 0; i < 3; ++i)
+ {
+ ddrval = IDirectDrawSurface4_Blt(pScreenPriv->pddsPrimary4, pRect, pScreenPriv->pddsShadow4, prcSrc, DDBLT_WAIT, NULL);
+ /* Try to regain the primary surface and blit again if we've lost it */
+ if (ddrval == DDERR_SURFACELOST)
+ {
+ /* Surface was lost */
+ ErrorF ("IDirectDrawSurface4_Blt reported that the primary "
+ "surface was lost, trying to restore, retry: %d\n", i + 1);
+
+ /* Try to restore the surface, once */
+
+ if (i==1)
+ {
+ ErrorF("Recreating DDraw surface because restoring of surface didn't work.\n");
+ winAllocateFBShadowDDNL(pScreen);
+ }
+ else
+ {
+ ddrval = IDirectDraw4_RestoreAllSurfaces (pScreenPriv->pdd4);
+ ErrorF ("IDirectDraw4_RestoreAllSurfaces returned: ");
+ if (ddrval == DD_OK)
+ ErrorF ("DD_OK\n");
+ else if (ddrval == DDERR_WRONGMODE)
+ ErrorF ("DDERR_WRONGMODE\n");
+ else if (ddrval == DDERR_INCOMPATIBLEPRIMARY)
+ ErrorF ("DDERR_INCOMPATIBLEPRIMARY\n");
+ else if (ddrval == DDERR_UNSUPPORTED)
+ ErrorF ("DDERR_UNSUPPORTED\n");
+ else if (ddrval == DDERR_INVALIDPARAMS)
+ ErrorF ("DDERR_INVALIDPARAMS\n");
+ else if (ddrval == DDERR_INVALIDOBJECT)
+ ErrorF ("DDERR_INVALIDOBJECT\n");
+ else
+ ErrorF ("unknown error: %08x\n", ddrval);
+ }
+ /* Loop around to try the blit one more time */
+ continue;
+ }
+ else if (FAILED (ddrval))
+ {
+ ErrorF ("IDirectDrawSurface4_Blt failed, but surface not "
+ "lost: %08x %d\n", ddrval, ddrval);
+ }
+ break;
+ }
+ return ddrval;
+}
+
+
+/*
+ * Create the primary surface and attach the clipper.
+ * Used for both the initial surface creation and during
+ * WM_DISPLAYCHANGE messages.
+ */
+
+static Bool
+winCreatePrimarySurfaceShadowDDNL (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ HRESULT ddrval = DD_OK;
+ DDSURFACEDESC2 ddsd;
+
+ winDebug ("winCreatePrimarySurfaceShadowDDNL - Creating primary surface\n");
+
+ /* Describe the primary surface */
+ ZeroMemory (&ddsd, sizeof (ddsd));
+ ddsd.dwSize = sizeof (ddsd);
+ ddsd.dwFlags = DDSD_CAPS;
+ ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
+
+ /* Create the primary surface */
+ ddrval = IDirectDraw4_CreateSurface (pScreenPriv->pdd4,
+ &ddsd,
+ &pScreenPriv->pddsPrimary4,
+ NULL);
+ pScreenPriv->fRetryCreateSurface = FALSE;
+ if (FAILED (ddrval))
+ {
+ if (ddrval == DDERR_NOEXCLUSIVEMODE)
+ {
+ /* Recreating the surface failed. Mark screen to retry later */
+ pScreenPriv->fRetryCreateSurface = TRUE;
+ winDebug ("winCreatePrimarySurfaceShadowDDNL - Could not create "
+ "primary surface: DDERR_NOEXCLUSIVEMODE\n");
+ }
+ else
+ {
+ ErrorF ("winCreatePrimarySurfaceShadowDDNL - Could not create "
+ "primary surface: %08x\n", (unsigned int) ddrval);
+ }
+ return FALSE;
+ }
+
+ winDebug ("winCreatePrimarySurfaceShadowDDNL - Created primary surface\n");
+
+ /* Attach our clipper to our primary surface handle */
+ ddrval = IDirectDrawSurface4_SetClipper (pScreenPriv->pddsPrimary4,
+ pScreenPriv->pddcPrimary);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winCreatePrimarySurfaceShadowDDNL - Primary attach clipper "
+ "failed: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+
+ winDebug ("winCreatePrimarySurfaceShadowDDNL - Attached clipper to primary "
+ "surface\n");
+
+ /* Everything was correct */
+ return TRUE;
+}
+
+
+static void ClosePrimarySurfaceShadowDDNL (winPrivScreenPtr pScreenPriv)
+{
+ /* Release the primary surface and clipper, if they exist */
+ if (pScreenPriv->pddsPrimary4)
+ {
+ /*
+ * Detach the clipper from the primary surface.
+ * NOTE: We do this explicity for clarity. The Clipper is not released.
+ */
+ IDirectDrawSurface4_SetClipper (pScreenPriv->pddsPrimary4, NULL);
+
+ winDebug ("winReleasePrimarySurfaceShadowDDNL - Detached clipper\n");
+
+ /* Release the primary surface */
+ IDirectDrawSurface4_Release (pScreenPriv->pddsPrimary4);
+ pScreenPriv->pddsPrimary4 = NULL;
+ }
+
+}
+
+static void ReleaseDDNL(winPrivScreenPtr pScreenPriv)
+{
+ /* Release the clipper object */
+ if (pScreenPriv->pddcPrimary)
+ {
+ IDirectDrawClipper_Release (pScreenPriv->pddcPrimary);
+ pScreenPriv->pddcPrimary = NULL;
+ }
+
+ /* Free the DirectDraw4 object, if there is one */
+ if (pScreenPriv->pdd4)
+ {
+ IDirectDraw4_RestoreDisplayMode (pScreenPriv->pdd4);
+ IDirectDraw4_Release (pScreenPriv->pdd4);
+ pScreenPriv->pdd4 = NULL;
+ }
+
+ /* Free the DirectDraw object, if there is one */
+ if (pScreenPriv->pdd)
+ {
+ IDirectDraw_Release (pScreenPriv->pdd);
+ pScreenPriv->pdd = NULL;
+ }
+}
+
+/*
+ * Detach the clipper and release the primary surface.
+ * Called from WM_DISPLAYCHANGE.
+ */
+
+static Bool
+winReleasePrimarySurfaceShadowDDNL (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+
+ winDebug ("winReleasePrimarySurfaceShadowDDNL - Hello\n");
+
+ ClosePrimarySurfaceShadowDDNL(pScreenPriv);
+
+ winDebug ("winReleasePrimarySurfaceShadowDDNL - Released primary surface\n");
+
+ return TRUE;
+}
+
+
+/*
+ * Create a DirectDraw surface for the shadow framebuffer; also create
+ * a primary surface object so we can blit to the display.
+ *
+ * Install a DirectDraw clipper on our primary surface object
+ * that clips our blits to the unobscured client area of our display window.
+ */
+
+Bool
+winAllocateFBShadowDDNL (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ HRESULT ddrval = DD_OK;
+ DDSURFACEDESC2 ddsdShadow;
+ char *lpSurface = NULL;
+ DDPIXELFORMAT ddpfPrimary;
+
+ winDebug ("winAllocateFBShadowDDNL - w %d h %d d %d\n",
+ pScreenInfo->dwWidth, pScreenInfo->dwHeight, pScreenInfo->dwDepth);
+
+ /* Set the padded screen width */
+ pScreenInfo->dwPaddedWidth = PixmapBytePad (pScreenInfo->dwWidth,
+ pScreenInfo->dwBPP);
+
+ if ( pScreenInfo->pfb)
+ {
+ ErrorF("winAllocateFBShadowDDNL calling for the second time, reallocating\n");
+ lpSurface=pScreenInfo->pfb;
+
+ if (pScreenPriv->pddsShadow4)
+ {
+ IDirectDrawSurface4_Release (pScreenPriv->pddsShadow4);
+ pScreenPriv->pddsShadow4 = NULL;
+ }
+ ClosePrimarySurfaceShadowDDNL(pScreenPriv);
+ ReleaseDDNL(pScreenPriv);
+ }
+ else
+ {
+ /* Allocate memory for our shadow surface */
+ lpSurface = malloc (pScreenInfo->dwPaddedWidth * pScreenInfo->dwHeight);
+ if (lpSurface == NULL)
+ {
+ ErrorF ("winAllocateFBShadowDDNL - Could not allocate bits\n");
+ return FALSE;
+ }
+
+ /*
+ * Initialize the framebuffer memory so we don't get a
+ * strange display at startup
+ */
+ ZeroMemory (lpSurface, pScreenInfo->dwPaddedWidth * pScreenInfo->dwHeight);
+ }
+ /* Create a clipper */
+ ddrval = (*g_fpDirectDrawCreateClipper) (0,
+ &pScreenPriv->pddcPrimary,
+ NULL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDDNL - Could not attach clipper: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+
+ winDebug ("winAllocateFBShadowDDNL - Created a clipper\n");
+
+ /* Attach the clipper to our display window */
+ ddrval = IDirectDrawClipper_SetHWnd (pScreenPriv->pddcPrimary,
+ 0,
+ pScreenPriv->hwndScreen);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDDNL - Clipper not attached "
+ "to window: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+
+ winDebug ("winAllocateFBShadowDDNL - Attached clipper to window\n");
+
+ /* Create a DirectDraw object, store the address at lpdd */
+ ddrval = (*g_fpDirectDrawCreate) (NULL,
+ (LPDIRECTDRAW*) &pScreenPriv->pdd,
+ NULL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDDNL - Could not start "
+ "DirectDraw: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+
+ winDebug ("winAllocateFBShadowDDNL - Created and initialized DD\n");
+
+ /* Get a DirectDraw4 interface pointer */
+ ddrval = IDirectDraw_QueryInterface (pScreenPriv->pdd,
+ &IID_IDirectDraw4,
+ (LPVOID*) &pScreenPriv->pdd4);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDDNL - Failed DD4 query: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+
+ /* Are we full screen? */
+ if (pScreenInfo->fFullScreen)
+ {
+ DDSURFACEDESC2 ddsdCurrent;
+ DWORD dwRefreshRateCurrent = 0;
+ HDC hdc = NULL;
+
+ /* Set the cooperative level to full screen */
+ ddrval = IDirectDraw4_SetCooperativeLevel (pScreenPriv->pdd4,
+ pScreenPriv->hwndScreen,
+ DDSCL_EXCLUSIVE
+ | DDSCL_FULLSCREEN);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDDNL - Could not set "
+ "cooperative level: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+
+ /*
+ * We only need to get the current refresh rate for comparison
+ * if a refresh rate has been passed on the command line.
+ */
+ if (pScreenInfo->dwRefreshRate != 0)
+ {
+ ZeroMemory (&ddsdCurrent, sizeof (ddsdCurrent));
+ ddsdCurrent.dwSize = sizeof (ddsdCurrent);
+
+ /* Get information about current display settings */
+ ddrval = IDirectDraw4_GetDisplayMode (pScreenPriv->pdd4,
+ &ddsdCurrent);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDDNL - Could not get current "
+ "refresh rate: %08x. Continuing.\n",
+ (unsigned int) ddrval);
+ dwRefreshRateCurrent = 0;
+ }
+ else
+ {
+ /* Grab the current refresh rate */
+ dwRefreshRateCurrent = ddsdCurrent.u2.dwRefreshRate;
+ }
+ }
+
+ /* Clean up the refresh rate */
+ if (dwRefreshRateCurrent == pScreenInfo->dwRefreshRate)
+ {
+ /*
+ * Refresh rate is non-specified or equal to current.
+ */
+ pScreenInfo->dwRefreshRate = 0;
+ }
+
+ /* Grab a device context for the screen */
+ hdc = GetDC (NULL);
+ if (hdc == NULL)
+ {
+ ErrorF ("winAllocateFBShadowDDNL - GetDC () failed\n");
+ return FALSE;
+ }
+
+ /* Only change the video mode when different than current mode */
+ if (!pScreenInfo->fMultipleMonitors
+ && (pScreenInfo->dwWidth != GetSystemMetrics (SM_CXSCREEN)
+ || pScreenInfo->dwHeight != GetSystemMetrics (SM_CYSCREEN)
+ || pScreenInfo->dwBPP != GetDeviceCaps (hdc, BITSPIXEL)
+ || pScreenInfo->dwRefreshRate != 0))
+ {
+ winDebug ("winAllocateFBShadowDDNL - Changing video mode\n");
+
+ /* Change the video mode to the mode requested, and use the driver default refresh rate on failure */
+ ddrval = IDirectDraw4_SetDisplayMode (pScreenPriv->pdd4,
+ pScreenInfo->dwWidth,
+ pScreenInfo->dwHeight,
+ pScreenInfo->dwBPP,
+ pScreenInfo->dwRefreshRate,
+ 0);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDDNL - Could not set "
+ "full screen display mode: %08x\n",
+ (unsigned int) ddrval);
+ ErrorF ("winAllocateFBShadowDDNL - Using default driver refresh rate\n");
+ ddrval = IDirectDraw4_SetDisplayMode (pScreenPriv->pdd4,
+ pScreenInfo->dwWidth,
+ pScreenInfo->dwHeight,
+ pScreenInfo->dwBPP,
+ 0,
+ 0);
+ if (FAILED(ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDDNL - Could not set default refresh rate "
+ "full screen display mode: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+ }
+ }
+ else
+ {
+ winDebug ("winAllocateFBShadowDDNL - Not changing video mode\n");
+ }
+
+ /* Release our DC */
+ ReleaseDC (NULL, hdc);
+ hdc = NULL;
+ }
+ else
+ {
+ /* Set the cooperative level for windowed mode */
+ ddrval = IDirectDraw4_SetCooperativeLevel (pScreenPriv->pdd4,
+ pScreenPriv->hwndScreen,
+ DDSCL_NORMAL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDDNL - Could not set "
+ "cooperative level: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+ }
+
+ /* Create the primary surface */
+ if (!winCreatePrimarySurfaceShadowDDNL (pScreen))
+ {
+ ErrorF ("winAllocateFBShadowDDNL - winCreatePrimarySurfaceShadowDDNL "
+ "failed\n");
+ return FALSE;
+ }
+
+ /* Get primary surface's pixel format */
+ ZeroMemory (&ddpfPrimary, sizeof (ddpfPrimary));
+ ddpfPrimary.dwSize = sizeof (ddpfPrimary);
+ ddrval = IDirectDrawSurface4_GetPixelFormat (pScreenPriv->pddsPrimary4,
+ &ddpfPrimary);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDDNL - Could not get primary "
+ "pixformat: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+
+ winDebug ("winAllocateFBShadowDDNL - Primary masks: %08x %08x %08x "
+ "dwRGBBitCount: %d\n",
+ ddpfPrimary.u2.dwRBitMask,
+ ddpfPrimary.u3.dwGBitMask,
+ ddpfPrimary.u4.dwBBitMask,
+ ddpfPrimary.u1.dwRGBBitCount);
+
+ /* Describe the shadow surface to be created */
+ /*
+ * NOTE: Do not use a DDSCAPS_VIDEOMEMORY surface,
+ * as drawing, locking, and unlocking take forever
+ * with video memory surfaces. In addition,
+ * video memory is a somewhat scarce resource,
+ * so you shouldn't be allocating video memory when
+ * you have the option of using system memory instead.
+ */
+ ZeroMemory (&ddsdShadow, sizeof (ddsdShadow));
+ ddsdShadow.dwSize = sizeof (ddsdShadow);
+ ddsdShadow.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH
+ | DDSD_LPSURFACE | DDSD_PITCH | DDSD_PIXELFORMAT;
+ ddsdShadow.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
+ ddsdShadow.dwHeight = pScreenInfo->dwHeight;
+ ddsdShadow.dwWidth = pScreenInfo->dwWidth;
+ ddsdShadow.u1.lPitch = pScreenInfo->dwPaddedWidth;
+ ddsdShadow.lpSurface = lpSurface;
+ ddsdShadow.u4.ddpfPixelFormat = ddpfPrimary;
+
+ winDebug ("winAllocateFBShadowDDNL - lPitch: %d\n",
+ (int) pScreenInfo->dwPaddedWidth);
+
+ /* Create the shadow surface */
+ ddrval = IDirectDraw4_CreateSurface (pScreenPriv->pdd4,
+ &ddsdShadow,
+ &pScreenPriv->pddsShadow4,
+ NULL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winAllocateFBShadowDDNL - Could not create shadow "
+ "surface: %08x\n", (unsigned int) ddrval);
+ return FALSE;
+ }
+
+ winDebug ("winAllocateFBShadowDDNL - Created shadow pitch: %d\n",
+ (int) ddsdShadow.u1.lPitch);
+
+ /* Grab the pitch from the surface desc */
+ pScreenInfo->dwStride = (ddsdShadow.u1.lPitch * 8)
+ / pScreenInfo->dwBPP;
+
+ winDebug ("winAllocateFBShadowDDNL - Created shadow stride: %d\n",
+ (int) pScreenInfo->dwStride);
+
+ /* Save the pointer to our surface memory */
+ pScreenInfo->pfb = lpSurface;
+
+ /* Grab the masks from the surface description */
+ pScreenPriv->dwRedMask = ddsdShadow.u4.ddpfPixelFormat.u2.dwRBitMask;
+ pScreenPriv->dwGreenMask = ddsdShadow.u4.ddpfPixelFormat.u3.dwGBitMask;
+ pScreenPriv->dwBlueMask = ddsdShadow.u4.ddpfPixelFormat.u4.dwBBitMask;
+
+ winDebug ("winAllocateFBShadowDDNL - Returning\n");
+
+ return TRUE;
+}
+
+static void
+winFreeFBShadowDDNL(ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /* Free the shadow surface, if there is one */
+ if (pScreenPriv->pddsShadow4)
+ {
+ IDirectDrawSurface4_Release (pScreenPriv->pddsShadow4);
+ free (pScreenInfo->pfb);
+ pScreenInfo->pfb = NULL;
+ pScreenPriv->pddsShadow4 = NULL;
+ }
+
+ /* Detach the clipper from the primary surface and release the primary surface, if there is one */
+ winReleasePrimarySurfaceShadowDDNL(pScreen);
+
+ ReleaseDDNL(pScreenPriv);
+
+ /* Invalidate the ScreenInfo's fb pointer */
+ pScreenInfo->pfb = NULL;
+}
+
+#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
+/*
+ * Create a DirectDraw surface for the new multi-window window
+ */
+
+static
+Bool
+winFinishCreateWindowsWindowDDNL (WindowPtr pWin)
+{
+ winWindowPriv(pWin);
+ winPrivScreenPtr pScreenPriv = pWinPriv->pScreenPriv;
+ HRESULT ddrval = DD_OK;
+ DDSURFACEDESC2 ddsd;
+ int iWidth, iHeight;
+ int iX, iY;
+
+ winDebug ("winFinishCreateWindowsWindowDDNL!\n\n");
+
+ iX = pWin->drawable.x + GetSystemMetrics (SM_XVIRTUALSCREEN);
+ iY = pWin->drawable.y + GetSystemMetrics (SM_YVIRTUALSCREEN);
+
+ iWidth = pWin->drawable.width;
+ iHeight = pWin->drawable.height;
+
+ /* Describe the primary surface */
+ ZeroMemory (&ddsd, sizeof (ddsd));
+ ddsd.dwSize = sizeof (ddsd);
+ ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
+ ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
+ ddsd.dwHeight = iHeight;
+ ddsd.dwWidth = iWidth;
+
+ /* Create the primary surface */
+ ddrval = IDirectDraw4_CreateSurface (pScreenPriv->pdd4,
+ &ddsd,
+ &pWinPriv->pddsPrimary4,
+ NULL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winFinishCreateWindowsWindowDDNL - Could not create primary "
+ "surface: %08x\n",
+ (unsigned int)ddrval);
+ return FALSE;
+ }
+ return TRUE;
+}
+#endif
+
+
+/*
+ * Transfer the damaged regions of the shadow framebuffer to the display.
+ */
+
+static void
+winShadowUpdateDDNL (ScreenPtr pScreen,
+ shadowBufPtr pBuf)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ RegionPtr damage = shadowDamage(pBuf);
+ RECT rcDest, rcSrc;
+ POINT ptOrigin;
+ DWORD dwBox = RegionNumRects (damage);
+ BoxPtr pBox = RegionRects (damage);
+ HRGN hrgnTemp = NULL, hrgnCombined = NULL;
+
+ /*
+ * Return immediately if the app is not active
+ * and we are fullscreen, or if we have a bad display depth
+ */
+ if ((!pScreenPriv->fActive && pScreenInfo->fFullScreen)
+ || pScreenPriv->fBadDepth) return;
+
+ /* Return immediately if we didn't get needed surfaces */
+ if (!pScreenPriv->pddsPrimary4 || !pScreenPriv->pddsShadow4)
+ return;
+
+ /* Get the origin of the window in the screen coords */
+ ptOrigin.x = pScreenInfo->dwXOffset;
+ ptOrigin.y = pScreenInfo->dwYOffset;
+ MapWindowPoints (pScreenPriv->hwndScreen,
+ HWND_DESKTOP,
+ (LPPOINT)&ptOrigin, 1);
+
+ /*
+ * Handle small regions with multiple blits,
+ * handle large regions by creating a clipping region and
+ * doing a single blit constrained to that clipping region.
+ */
+ if (pScreenInfo->dwClipUpdatesNBoxes == 0
+ || dwBox < pScreenInfo->dwClipUpdatesNBoxes)
+ {
+ /* Loop through all boxes in the damaged region */
+ while (dwBox--)
+ {
+ /* Assign damage box to source rectangle */
+ rcSrc.left = pBox->x1;
+ rcSrc.top = pBox->y1;
+ rcSrc.right = pBox->x2;
+ rcSrc.bottom = pBox->y2;
+
+ /* Calculate destination rectangle */
+ rcDest.left = ptOrigin.x + rcSrc.left;
+ rcDest.top = ptOrigin.y + rcSrc.top;
+ rcDest.right = ptOrigin.x + rcSrc.right;
+ rcDest.bottom = ptOrigin.y + rcSrc.bottom;
+
+ /* Blit the damaged areas */
+ if (pScreenPriv->pddsPrimary4)
+ myIDirectDrawSurface4_Blt (pScreen,
+ &rcDest,
+ &rcSrc);
+
+ /* Get a pointer to the next box */
+ ++pBox;
+ }
+ }
+ else
+ {
+ BoxPtr pBoxExtents = RegionExtents(damage);
+
+ /* Compute a GDI region from the damaged region */
+ hrgnCombined = CreateRectRgn (pBox->x1, pBox->y1, pBox->x2, pBox->y2);
+ dwBox--;
+ pBox++;
+ while (dwBox--)
+ {
+ hrgnTemp = CreateRectRgn (pBox->x1, pBox->y1, pBox->x2, pBox->y2);
+ CombineRgn (hrgnCombined, hrgnCombined, hrgnTemp, RGN_OR);
+ DeleteObject (hrgnTemp);
+ pBox++;
+ }
+
+ /* Install the GDI region as a clipping region */
+ SelectClipRgn (pScreenPriv->hdcScreen, hrgnCombined);
+ DeleteObject (hrgnCombined);
+ hrgnCombined = NULL;
+
+ winDebug ("winShadowUpdateDDNL - be x1 %d y1 %d x2 %d y2 %d\n",
+ pBoxExtents->x1, pBoxExtents->y1,
+ pBoxExtents->x2, pBoxExtents->y2);
+
+ /* Calculating a bounding box for the source is easy */
+ rcSrc.left = pBoxExtents->x1;
+ rcSrc.top = pBoxExtents->y1;
+ rcSrc.right = pBoxExtents->x2;
+ rcSrc.bottom = pBoxExtents->y2;
+
+ /* Calculating a bounding box for the destination is trickier */
+ rcDest.left = ptOrigin.x + rcSrc.left;
+ rcDest.top = ptOrigin.y + rcSrc.top;
+ rcDest.right = ptOrigin.x + rcSrc.right;
+ rcDest.bottom = ptOrigin.y + rcSrc.bottom;
+
+ /* Our Blt should be clipped to the invalidated region */
+ myIDirectDrawSurface4_Blt (pScreen, &rcDest, &rcSrc);
+
+ /* Reset the clip region */
+ SelectClipRgn (pScreenPriv->hdcScreen, NULL);
+ }
+}
+
+static Bool
+winInitScreenShadowDDNL(ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+
+ /* Get a device context for the screen */
+ pScreenPriv->hdcScreen = GetDC (pScreenPriv->hwndScreen);
+
+ return winAllocateFBShadowDDNL(pScreen);
+}
+
+/*
+ * Call the wrapped CloseScreen function.
+ *
+ * Free our resources and private structures.
+ */
+
+static Bool
+winCloseScreenShadowDDNL (int nIndex, ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ Bool fReturn;
+
+ winDebug ("winCloseScreenShadowDDNL - Freeing screen resources\n");
+
+ /* Flag that the screen is closed */
+ pScreenPriv->fClosed = TRUE;
+ pScreenPriv->fActive = FALSE;
+
+ /* Call the wrapped CloseScreen procedure */
+ WIN_UNWRAP(CloseScreen);
+ if (pScreen->CloseScreen)
+ fReturn = (*pScreen->CloseScreen) (nIndex, pScreen);
+
+ winFreeFBShadowDDNL(pScreen);
+
+ /* Free the screen DC */
+ ReleaseDC (pScreenPriv->hwndScreen, pScreenPriv->hdcScreen);
+
+ /* Delete the window property */
+ RemoveProp (pScreenPriv->hwndScreen, WIN_SCR_PROP);
+
+ /* Delete tray icon, if we have one */
+ if (!pScreenInfo->fNoTrayIcon)
+ winDeleteNotifyIcon (pScreenPriv);
+
+ /* Free the exit confirmation dialog box, if it exists */
+ if (g_hDlgExit != NULL)
+ {
+ DestroyWindow (g_hDlgExit);
+ g_hDlgExit = NULL;
+ }
+
+ /* Kill our window */
+ if (pScreenPriv->hwndScreen)
+ {
+ DestroyWindow (pScreenPriv->hwndScreen);
+ pScreenPriv->hwndScreen = NULL;
+ }
+
+#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
+ /* Destroy the thread startup mutex */
+ pthread_mutex_destroy (&pScreenPriv->pmServerStarted);
+#endif
+
+ /* Kill our screeninfo's pointer to the screen */
+ pScreenInfo->pScreen = NULL;
+
+ /* Free the screen privates for this screen */
+ free ((pointer) pScreenPriv);
+
+ return fReturn;
+}
+
+
+/*
+ * Tell mi what sort of visuals we need.
+ *
+ * Generally we only need one visual, as our screen can only
+ * handle one format at a time, I believe. You may want
+ * to verify that last sentence.
+ */
+
+static Bool
+winInitVisualsShadowDDNL (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ DWORD dwRedBits, dwGreenBits, dwBlueBits;
+
+ /* Count the number of ones in each color mask */
+ dwRedBits = winCountBits (pScreenPriv->dwRedMask);
+ dwGreenBits = winCountBits (pScreenPriv->dwGreenMask);
+ dwBlueBits = winCountBits (pScreenPriv->dwBlueMask);
+
+ /* Store the maximum number of ones in a color mask as the bitsPerRGB */
+ if (dwRedBits == 0 || dwGreenBits == 0 || dwBlueBits == 0)
+ pScreenPriv->dwBitsPerRGB = 8;
+ else if (dwRedBits > dwGreenBits && dwRedBits > dwBlueBits)
+ pScreenPriv->dwBitsPerRGB = dwRedBits;
+ else if (dwGreenBits > dwRedBits && dwGreenBits > dwBlueBits)
+ pScreenPriv->dwBitsPerRGB = dwGreenBits;
+ else
+ pScreenPriv->dwBitsPerRGB = dwBlueBits;
+
+ winDebug ("winInitVisualsShadowDDNL - Masks %08x %08x %08x BPRGB %d d %d "
+ "bpp %d\n",
+ (unsigned int) pScreenPriv->dwRedMask,
+ (unsigned int) pScreenPriv->dwGreenMask,
+ (unsigned int) pScreenPriv->dwBlueMask,
+ (int) pScreenPriv->dwBitsPerRGB,
+ (int) pScreenInfo->dwDepth,
+ (int) pScreenInfo->dwBPP);
+
+ /* Create a single visual according to the Windows screen depth */
+ switch (pScreenInfo->dwDepth)
+ {
+ case 24:
+ case 16:
+ case 15:
+ /* Setup the real visual */
+ if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
+ TrueColorMask,
+ pScreenPriv->dwBitsPerRGB,
+ -1,
+ pScreenPriv->dwRedMask,
+ pScreenPriv->dwGreenMask,
+ pScreenPriv->dwBlueMask))
+ {
+ ErrorF ("winInitVisualsShadowDDNL - miSetVisualTypesAndMasks "
+ "failed for TrueColor\n");
+ return FALSE;
+ }
+
+#ifdef XWIN_EMULATEPSEUDO
+ if (!pScreenInfo->fEmulatePseudo)
+ break;
+
+ /* Setup a pseudocolor visual */
+ if (!miSetVisualTypesAndMasks (8,
+ PseudoColorMask,
+ 8,
+ -1,
+ 0,
+ 0,
+ 0))
+ {
+ ErrorF ("winInitVisualsShadowDDNL - miSetVisualTypesAndMasks "
+ "failed for PseudoColor\n");
+ return FALSE;
+ }
+#endif
+ break;
+
+ case 8:
+ if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
+ pScreenInfo->fFullScreen
+ ? PseudoColorMask : StaticColorMask,
+ pScreenPriv->dwBitsPerRGB,
+ pScreenInfo->fFullScreen
+ ? PseudoColor : StaticColor,
+ pScreenPriv->dwRedMask,
+ pScreenPriv->dwGreenMask,
+ pScreenPriv->dwBlueMask))
+ {
+ ErrorF ("winInitVisualsShadowDDNL - miSetVisualTypesAndMasks "
+ "failed\n");
+ return FALSE;
+ }
+ break;
+
+ default:
+ ErrorF ("winInitVisualsShadowDDNL - Unknown screen depth\n");
+ return FALSE;
+ }
+
+ winDebug ("winInitVisualsShadowDDNL - Returning\n");
+
+ return TRUE;
+}
+
+
+/*
+ * Adjust the user proposed video mode
+ */
+
+static Bool
+winAdjustVideoModeShadowDDNL (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ HDC hdc = NULL;
+ DWORD dwBPP;
+
+ /* We're in serious trouble if we can't get a DC */
+ hdc = GetDC (NULL);
+ if (hdc == NULL)
+ {
+ ErrorF ("winAdjustVideoModeShadowDDNL - GetDC () failed\n");
+ return FALSE;
+ }
+
+ /* Query GDI for current display depth */
+ dwBPP = GetDeviceCaps (hdc, BITSPIXEL);
+
+ /* DirectDraw can only change the depth in fullscreen mode */
+ if (!(pScreenInfo->fFullScreen &&
+ (pScreenInfo->dwBPP != WIN_DEFAULT_BPP)))
+ {
+ /* Otherwise, We'll use GDI's depth */
+ pScreenInfo->dwBPP = dwBPP;
+ }
+
+ /* Release our DC */
+ ReleaseDC (NULL, hdc);
+
+ return TRUE;
+}
+
+
+/*
+ * Blt exposed regions to the screen
+ */
+
+static Bool
+winBltExposedRegionsShadowDDNL (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ RECT rcSrc, rcDest;
+ POINT ptOrigin;
+ HDC hdcUpdate;
+ PAINTSTRUCT ps;
+ HRESULT ddrval = DD_OK;
+ Bool fReturn = TRUE;
+ int i;
+
+ /* Quite common case. The primary surface was lost (maybe because of depth
+ * change). Try to create a new primary surface. Bail out if this fails */
+ if (pScreenPriv->pddsPrimary4 == NULL && pScreenPriv->fRetryCreateSurface &&
+ !winCreatePrimarySurfaceShadowDDNL(pScreen))
+ {
+ Sleep(100);
+ return FALSE;
+ }
+ if (pScreenPriv->pddsPrimary4 == NULL)
+ return FALSE;
+
+ /* BeginPaint gives us an hdc that clips to the invalidated region */
+ hdcUpdate = BeginPaint (pScreenPriv->hwndScreen, &ps);
+ if (hdcUpdate == NULL)
+ {
+ fReturn = FALSE;
+ ErrorF ("winBltExposedRegionsShadowDDNL - BeginPaint () returned "
+ "a NULL device context handle. Aborting blit attempt.\n");
+ goto winBltExposedRegionsShadowDDNL_Exit;
+ }
+
+ /* Get the origin of the window in the screen coords */
+ ptOrigin.x = pScreenInfo->dwXOffset;
+ ptOrigin.y = pScreenInfo->dwYOffset;
+
+ MapWindowPoints (pScreenPriv->hwndScreen,
+ HWND_DESKTOP,
+ (LPPOINT)&ptOrigin, 1);
+ rcDest.left = ptOrigin.x;
+ rcDest.right = ptOrigin.x + pScreenInfo->dwWidth;
+ rcDest.top = ptOrigin.y;
+ rcDest.bottom = ptOrigin.y + pScreenInfo->dwHeight;
+
+ /* Source can be entire shadow surface, as Blt should clip for us */
+ rcSrc.left = 0;
+ rcSrc.top = 0;
+ rcSrc.right = pScreenInfo->dwWidth;
+ rcSrc.bottom = pScreenInfo->dwHeight;
+
+ /* Our Blt should be clipped to the invalidated region */
+ ddrval = myIDirectDrawSurface4_Blt (pScreen, &rcDest, &rcSrc);
+ if (FAILED (ddrval))
+ {
+ fReturn = FALSE;
+ }
+
+winBltExposedRegionsShadowDDNL_Exit:
+ /* EndPaint frees the DC */
+ if (hdcUpdate != NULL)
+ EndPaint (pScreenPriv->hwndScreen, &ps);
+ return fReturn;
+}
+
+
+/*
+ * Do any engine-specific application-activation processing
+ */
+
+static Bool
+winActivateAppShadowDDNL (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+
+ /*
+ * Do we have a surface?
+ * Are we active?
+ * Are we full screen?
+ */
+ if (pScreenPriv != NULL
+ && pScreenPriv->pddsPrimary4 != NULL
+ && pScreenPriv->fActive)
+ {
+ /* Primary surface was lost, restore it */
+ IDirectDrawSurface4_Restore (pScreenPriv->pddsPrimary4);
+ }
+
+ return TRUE;
+}
+
+
+/*
+ * Reblit the shadow framebuffer to the screen.
+ */
+
+static Bool
+winRedrawScreenShadowDDNL (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ RECT rcSrc, rcDest;
+ POINT ptOrigin;
+
+ /* Get the origin of the window in the screen coords */
+ ptOrigin.x = pScreenInfo->dwXOffset;
+ ptOrigin.y = pScreenInfo->dwYOffset;
+ MapWindowPoints (pScreenPriv->hwndScreen,
+ HWND_DESKTOP,
+ (LPPOINT)&ptOrigin, 1);
+ rcDest.left = ptOrigin.x;
+ rcDest.right = ptOrigin.x + pScreenInfo->dwWidth;
+ rcDest.top = ptOrigin.y;
+ rcDest.bottom = ptOrigin.y + pScreenInfo->dwHeight;
+
+ /* Source can be entire shadow surface, as Blt should clip for us */
+ rcSrc.left = 0;
+ rcSrc.top = 0;
+ rcSrc.right = pScreenInfo->dwWidth;
+ rcSrc.bottom = pScreenInfo->dwHeight;
+
+ /* Redraw the whole window, to take account for the new colors */
+ myIDirectDrawSurface4_Blt (pScreen, &rcDest, &rcSrc);
+ return TRUE;
+}
+
+
+/*
+ * Realize the currently installed colormap
+ */
+
+static Bool
+winRealizeInstalledPaletteShadowDDNL (ScreenPtr pScreen)
+{
+ return TRUE;
+}
+
+
+/*
+ * Install the specified colormap
+ */
+
+static Bool
+winInstallColormapShadowDDNL (ColormapPtr pColormap)
+{
+ ScreenPtr pScreen = pColormap->pScreen;
+ winScreenPriv(pScreen);
+ winCmapPriv(pColormap);
+ HRESULT ddrval = DD_OK;
+
+ /* Install the DirectDraw palette on the primary surface */
+ ddrval = IDirectDrawSurface4_SetPalette (pScreenPriv->pddsPrimary4,
+ pCmapPriv->lpDDPalette);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winInstallColormapShadowDDNL - Failed installing the "
+ "DirectDraw palette.\n");
+ return FALSE;
+ }
+
+ /* Save a pointer to the newly installed colormap */
+ pScreenPriv->pcmapInstalled = pColormap;
+
+ return TRUE;
+}
+
+
+/*
+ * Store the specified colors in the specified colormap
+ */
+
+static Bool
+winStoreColorsShadowDDNL (ColormapPtr pColormap,
+ int ndef,
+ xColorItem *pdefs)
+{
+ ScreenPtr pScreen = pColormap->pScreen;
+ winScreenPriv(pScreen);
+ winCmapPriv(pColormap);
+ ColormapPtr curpmap = pScreenPriv->pcmapInstalled;
+ HRESULT ddrval = DD_OK;
+
+ /* Put the X colormap entries into the Windows logical palette */
+ ddrval = IDirectDrawPalette_SetEntries (pCmapPriv->lpDDPalette,
+ 0,
+ pdefs[0].pixel,
+ ndef,
+ pCmapPriv->peColors
+ + pdefs[0].pixel);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winStoreColorsShadowDDNL - SetEntries () failed: %08x\n", (unsigned int) ddrval);
+ return FALSE;
+ }
+
+ /* Don't install the DirectDraw palette if the colormap is not installed */
+ if (pColormap != curpmap)
+ {
+ return TRUE;
+ }
+
+ if (!winInstallColormapShadowDDNL (pColormap))
+ {
+ ErrorF ("winStoreColorsShadowDDNL - Failed installing colormap\n");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+/*
+ * Colormap initialization procedure
+ */
+
+static Bool
+winCreateColormapShadowDDNL (ColormapPtr pColormap)
+{
+ HRESULT ddrval = DD_OK;
+ ScreenPtr pScreen = pColormap->pScreen;
+ winScreenPriv(pScreen);
+ winCmapPriv(pColormap);
+
+ /* Create a DirectDraw palette */
+ ddrval = IDirectDraw4_CreatePalette (pScreenPriv->pdd4,
+ DDPCAPS_8BIT | DDPCAPS_ALLOW256,
+ pCmapPriv->peColors,
+ &pCmapPriv->lpDDPalette,
+ NULL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winCreateColormapShadowDDNL - CreatePalette failed\n");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+/*
+ * Colormap destruction procedure
+ */
+
+static Bool
+winDestroyColormapShadowDDNL (ColormapPtr pColormap)
+{
+ winScreenPriv(pColormap->pScreen);
+ winCmapPriv(pColormap);
+ HRESULT ddrval = DD_OK;
+
+ /*
+ * Is colormap to be destroyed the default?
+ *
+ * Non-default colormaps should have had winUninstallColormap
+ * called on them before we get here. The default colormap
+ * will not have had winUninstallColormap called on it. Thus,
+ * we need to handle the default colormap in a special way.
+ */
+ if (pColormap->flags & IsDefault)
+ {
+ winDebug ("winDestroyColormapShadowDDNL - Destroying default colormap\n");
+
+ /*
+ * FIXME: Walk the list of all screens, popping the default
+ * palette out of each screen device context.
+ */
+
+ /* Pop the palette out of the primary surface */
+ ddrval = IDirectDrawSurface4_SetPalette (pScreenPriv->pddsPrimary4,
+ NULL);
+ if (FAILED (ddrval))
+ {
+ ErrorF ("winDestroyColormapShadowDDNL - Failed freeing the "
+ "default colormap DirectDraw palette.\n");
+ return FALSE;
+ }
+
+ /* Clear our private installed colormap pointer */
+ pScreenPriv->pcmapInstalled = NULL;
+ }
+
+ /* Release the palette */
+ IDirectDrawPalette_Release (pCmapPriv->lpDDPalette);
+
+ /* Invalidate the colormap privates */
+ pCmapPriv->lpDDPalette = NULL;
+
+ return TRUE;
+}
+
+
+/*
+ * Set pointers to our engine specific functions
+ */
+
+Bool
+winSetEngineFunctionsShadowDDNL (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /* Set our pointers */
+ pScreenPriv->pwinAllocateFB = winAllocateFBShadowDDNL;
+ pScreenPriv->pwinFreeFB = winFreeFBShadowDDNL;
+ pScreenPriv->pwinShadowUpdate = winShadowUpdateDDNL;
+ pScreenPriv->pwinInitScreen = winInitScreenShadowDDNL;
+ pScreenPriv->pwinCloseScreen = winCloseScreenShadowDDNL;
+ pScreenPriv->pwinInitVisuals = winInitVisualsShadowDDNL;
+ pScreenPriv->pwinAdjustVideoMode = winAdjustVideoModeShadowDDNL;
+ if (pScreenInfo->fFullScreen)
+ pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowFullScreen;
+ else
+ pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowWindowed;
+ pScreenPriv->pwinFinishScreenInit = winFinishScreenInitFB;
+ pScreenPriv->pwinBltExposedRegions = winBltExposedRegionsShadowDDNL;
+ pScreenPriv->pwinActivateApp = winActivateAppShadowDDNL;
+ pScreenPriv->pwinRedrawScreen = winRedrawScreenShadowDDNL;
+ pScreenPriv->pwinRealizeInstalledPalette
+ = winRealizeInstalledPaletteShadowDDNL;
+ pScreenPriv->pwinInstallColormap = winInstallColormapShadowDDNL;
+ pScreenPriv->pwinStoreColors = winStoreColorsShadowDDNL;
+ pScreenPriv->pwinCreateColormap = winCreateColormapShadowDDNL;
+ pScreenPriv->pwinDestroyColormap = winDestroyColormapShadowDDNL;
+ pScreenPriv->pwinHotKeyAltTab = (winHotKeyAltTabProcPtr) (void (*)(void))NoopDDA;
+ pScreenPriv->pwinCreatePrimarySurface = winCreatePrimarySurfaceShadowDDNL;
+ pScreenPriv->pwinReleasePrimarySurface = winReleasePrimarySurfaceShadowDDNL;
+#ifdef XWIN_MULTIWINDOW
+ pScreenPriv->pwinFinishCreateWindowsWindow
+ = winFinishCreateWindowsWindowDDNL;
+#endif
+
+ return TRUE;
+}
diff --git a/xorg-server/hw/xwin/winshadgdi.c b/xorg-server/hw/xwin/winshadgdi.c
index bcb2051fc..718101299 100644
--- a/xorg-server/hw/xwin/winshadgdi.c
+++ b/xorg-server/hw/xwin/winshadgdi.c
@@ -1,1238 +1,1238 @@
-/*
- *Copyright (C) 2001-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"
-
-
-/*
- * Local function prototypes
- */
-
-#ifdef XWIN_MULTIWINDOW
-static wBOOL CALLBACK
-winRedrawAllProcShadowGDI (HWND hwnd, LPARAM lParam);
-
-static wBOOL CALLBACK
-winRedrawDamagedWindowShadowGDI (HWND hwnd, LPARAM lParam);
-#endif
-
-static Bool
-winAllocateFBShadowGDI (ScreenPtr pScreen);
-
-static void
-winShadowUpdateGDI (ScreenPtr pScreen,
- shadowBufPtr pBuf);
-
-static Bool
-winCloseScreenShadowGDI (int nIndex, ScreenPtr pScreen);
-
-static Bool
-winInitVisualsShadowGDI (ScreenPtr pScreen);
-
-static Bool
-winAdjustVideoModeShadowGDI (ScreenPtr pScreen);
-
-static Bool
-winBltExposedRegionsShadowGDI (ScreenPtr pScreen);
-
-static Bool
-winActivateAppShadowGDI (ScreenPtr pScreen);
-
-static Bool
-winRedrawScreenShadowGDI (ScreenPtr pScreen);
-
-static Bool
-winRealizeInstalledPaletteShadowGDI (ScreenPtr pScreen);
-
-static Bool
-winInstallColormapShadowGDI (ColormapPtr pColormap);
-
-static Bool
-winStoreColorsShadowGDI (ColormapPtr pmap,
- int ndef,
- xColorItem *pdefs);
-
-static Bool
-winCreateColormapShadowGDI (ColormapPtr pColormap);
-
-static Bool
-winDestroyColormapShadowGDI (ColormapPtr pColormap);
-
-
-/*
- * Internal function to get the DIB format that is compatible with the screen
- */
-
-static
-Bool
-winQueryScreenDIBFormat (ScreenPtr pScreen, BITMAPINFOHEADER *pbmih)
-{
- winScreenPriv(pScreen);
- HBITMAP hbmp;
-#ifdef WINDBG
- LPDWORD pdw = NULL;
-#endif
-
- /* Create a memory bitmap compatible with the screen */
- hbmp = CreateCompatibleBitmap (pScreenPriv->hdcScreen, 1, 1);
- if (hbmp == NULL)
- {
- ErrorF ("winQueryScreenDIBFormat - CreateCompatibleBitmap failed\n");
- return FALSE;
- }
-
- /* Initialize our bitmap info header */
- ZeroMemory (pbmih, sizeof (BITMAPINFOHEADER) + 256 * sizeof (RGBQUAD));
- pbmih->biSize = sizeof (BITMAPINFOHEADER);
-
- /* Get the biBitCount */
- if (!GetDIBits (pScreenPriv->hdcScreen,
- hbmp,
- 0, 1,
- NULL,
- (BITMAPINFO*) pbmih,
- DIB_RGB_COLORS))
- {
- ErrorF ("winQueryScreenDIBFormat - First call to GetDIBits failed\n");
- DeleteObject (hbmp);
- return FALSE;
- }
-
-#ifdef WINDBG
- /* Get a pointer to bitfields */
- pdw = (DWORD*) ((CARD8*)pbmih + sizeof (BITMAPINFOHEADER));
-
- winDebug ("winQueryScreenDIBFormat - First call masks: %08x %08x %08x\n",
- pdw[0], pdw[1], pdw[2]);
-#endif
-
- /* Get optimal color table, or the optimal bitfields */
- if (!GetDIBits (pScreenPriv->hdcScreen,
- hbmp,
- 0, 1,
- NULL,
- (BITMAPINFO*)pbmih,
- DIB_RGB_COLORS))
- {
- ErrorF ("winQueryScreenDIBFormat - Second call to GetDIBits "
- "failed\n");
- DeleteObject (hbmp);
- return FALSE;
- }
-
- /* Free memory */
- DeleteObject (hbmp);
-
- return TRUE;
-}
-
-
-/*
- * Internal function to determine the GDI bits per rgb and bit masks
- */
-
-static
-Bool
-winQueryRGBBitsAndMasks (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- BITMAPINFOHEADER *pbmih = NULL;
- Bool fReturn = TRUE;
- LPDWORD pdw = NULL;
- DWORD dwRedBits, dwGreenBits, dwBlueBits;
-
- /* Color masks for 8 bpp are standardized */
- if (GetDeviceCaps (pScreenPriv->hdcScreen, RASTERCAPS) & RC_PALETTE)
- {
- /*
- * RGB BPP for 8 bit palletes is always 8
- * and the color masks are always 0.
- */
- pScreenPriv->dwBitsPerRGB = 8;
- pScreenPriv->dwRedMask = 0x0L;
- pScreenPriv->dwGreenMask = 0x0L;
- pScreenPriv->dwBlueMask = 0x0L;
- return TRUE;
- }
-
- /* Color masks for 24 bpp are standardized */
- if (GetDeviceCaps (pScreenPriv->hdcScreen, PLANES)
- * GetDeviceCaps (pScreenPriv->hdcScreen, BITSPIXEL) == 24)
- {
- winDebug ("winQueryRGBBitsAndMasks - GetDeviceCaps (BITSPIXEL) "
- "returned 24 for the screen. Using default 24bpp masks.\n");
-
- /* 8 bits per primary color */
- pScreenPriv->dwBitsPerRGB = 8;
-
- /* Set screen privates masks */
- pScreenPriv->dwRedMask = WIN_24BPP_MASK_RED;
- pScreenPriv->dwGreenMask = WIN_24BPP_MASK_GREEN;
- pScreenPriv->dwBlueMask = WIN_24BPP_MASK_BLUE;
-
- return TRUE;
- }
-
- /* Allocate a bitmap header and color table */
- pbmih = (BITMAPINFOHEADER*) malloc (sizeof (BITMAPINFOHEADER)
- + 256 * sizeof (RGBQUAD));
- if (pbmih == NULL)
- {
- ErrorF ("winQueryRGBBitsAndMasks - malloc failed\n");
- return FALSE;
- }
-
- /* Get screen description */
- if (winQueryScreenDIBFormat (pScreen, pbmih))
- {
- /* Get a pointer to bitfields */
- pdw = (DWORD*) ((CARD8*)pbmih + sizeof (BITMAPINFOHEADER));
-
-#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__,
- pbmih->biWidth, pbmih->biHeight, pbmih->biBitCount, pbmih->biPlanes);
- winDebug ("%s - Compression: %d %s\n", __FUNCTION__,
- pbmih->biCompression,
- (pbmih->biCompression == BI_RGB?"(BI_RGB)":
- (pbmih->biCompression == BI_RLE8?"(BI_RLE8)":
- (pbmih->biCompression == BI_RLE4?"(BI_RLE4)":
- (pbmih->biCompression == BI_BITFIELDS?"(BI_BITFIELDS)":""
- )))));
-#endif
-
- /* Handle BI_RGB case, which is returned by Wine */
- if (pbmih->biCompression == BI_RGB)
- {
- dwRedBits = 5;
- dwGreenBits = 5;
- dwBlueBits = 5;
-
- pScreenPriv->dwBitsPerRGB = 5;
-
- /* Set screen privates masks */
- pScreenPriv->dwRedMask = 0x7c00;
- pScreenPriv->dwGreenMask = 0x03e0;
- pScreenPriv->dwBlueMask = 0x001f;
- }
- else
- {
- /* Count the number of bits in each mask */
- dwRedBits = winCountBits (pdw[0]);
- dwGreenBits = winCountBits (pdw[1]);
- dwBlueBits = winCountBits (pdw[2]);
-
- /* Find maximum bits per red, green, blue */
- if (dwRedBits > dwGreenBits && dwRedBits > dwBlueBits)
- pScreenPriv->dwBitsPerRGB = dwRedBits;
- else if (dwGreenBits > dwRedBits && dwGreenBits > dwBlueBits)
- pScreenPriv->dwBitsPerRGB = dwGreenBits;
- else
- pScreenPriv->dwBitsPerRGB = dwBlueBits;
-
- /* Set screen privates masks */
- pScreenPriv->dwRedMask = pdw[0];
- pScreenPriv->dwGreenMask = pdw[1];
- pScreenPriv->dwBlueMask = pdw[2];
- }
- }
- else
- {
- ErrorF ("winQueryRGBBitsAndMasks - winQueryScreenDIBFormat failed\n");
- free (pbmih);
- fReturn = FALSE;
- }
-
- /* Free memory */
- free (pbmih);
-
- return fReturn;
-}
-
-
-#ifdef XWIN_MULTIWINDOW
-/*
- * Redraw all ---?
- */
-
-static wBOOL CALLBACK
-winRedrawAllProcShadowGDI (HWND hwnd, LPARAM lParam)
-{
- if (hwnd == (HWND)lParam)
- return TRUE;
- InvalidateRect (hwnd, NULL, FALSE);
- UpdateWindow (hwnd);
- return TRUE;
-}
-
-static wBOOL CALLBACK
-winRedrawDamagedWindowShadowGDI (HWND hwnd, LPARAM lParam)
-{
- BoxPtr pDamage = (BoxPtr)lParam;
- RECT rcClient, rcDamage, rcRedraw;
- POINT topLeft, bottomRight;
-
- if (IsIconic (hwnd))
- return TRUE; /* Don't care minimized windows */
-
- /* Convert the damaged area from Screen coords to Client coords */
- topLeft.x = pDamage->x1; topLeft.y = pDamage->y1;
- bottomRight.x = pDamage->x2; bottomRight.y = pDamage->y2;
- topLeft.x += GetSystemMetrics (SM_XVIRTUALSCREEN);
- bottomRight.x += GetSystemMetrics (SM_XVIRTUALSCREEN);
- topLeft.y += GetSystemMetrics (SM_YVIRTUALSCREEN);
- bottomRight.y += GetSystemMetrics (SM_YVIRTUALSCREEN);
- ScreenToClient (hwnd, &topLeft);
- ScreenToClient (hwnd, &bottomRight);
- SetRect (&rcDamage, topLeft.x, topLeft.y, bottomRight.x, bottomRight.y);
-
- GetClientRect (hwnd, &rcClient);
-
- if (IntersectRect (&rcRedraw, &rcClient, &rcDamage))
- {
- InvalidateRect (hwnd, &rcRedraw, FALSE);
- UpdateWindow (hwnd);
- }
- return TRUE;
-}
-#endif
-
-
-/*
- * Allocate a DIB for the shadow framebuffer GDI server
- */
-
-static Bool
-winAllocateFBShadowGDI (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- DIBSECTION dibsection;
- Bool fReturn = TRUE;
-
- /* Describe shadow bitmap to be created */
- pScreenPriv->pbmih->biWidth = pScreenInfo->dwWidth;
- pScreenPriv->pbmih->biHeight = -pScreenInfo->dwHeight;
-
- winDebug ("winAllocateFBShadowGDI - Creating DIB with width: %d height: %d "
- "depth: %d\n",
- (int) pScreenPriv->pbmih->biWidth, (int) -pScreenPriv->pbmih->biHeight, pScreenPriv->pbmih->biBitCount);
-
- /* Create a DI shadow bitmap with a bit pointer */
- pScreenPriv->hbmpShadow = CreateDIBSection (pScreenPriv->hdcScreen,
- (BITMAPINFO *) pScreenPriv->pbmih,
- DIB_RGB_COLORS,
- (VOID**) &pScreenInfo->pfb,
- NULL,
- 0);
- if (pScreenPriv->hbmpShadow == NULL || pScreenInfo->pfb == NULL)
- {
- winW32Error ("winAllocateFBShadowGDI - CreateDIBSection failed:");
- return FALSE;
- }
- else
- {
- winDebug ("winAllocateFBShadowGDI - Shadow buffer allocated\n");
- }
-
- /* Get information about the bitmap that was allocated */
- GetObject (pScreenPriv->hbmpShadow,
- sizeof (dibsection),
- &dibsection);
-
- /* 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);
-
- /* Select the shadow bitmap into the shadow DC */
- SelectObject (pScreenPriv->hdcShadow,
- pScreenPriv->hbmpShadow);
-
- winDebug ("winAllocateFBShadowGDI - Attempting a shadow blit\n");
-
- /* Do a test blit from the shadow to the screen, I think */
- fReturn = BitBlt (pScreenPriv->hdcScreen,
- 0, 0,
- pScreenInfo->dwWidth, pScreenInfo->dwHeight,
- pScreenPriv->hdcShadow,
- 0, 0,
- SRCCOPY);
- if (fReturn)
- {
- winDebug ("winAllocateFBShadowGDI - Shadow blit success\n");
- }
- 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;
- }
-
- /* Look for height weirdness */
- if (dibsection.dsBmih.biHeight < 0)
- {
- dibsection.dsBmih.biHeight = -dibsection.dsBmih.biHeight;
- }
-
- /* Set screeninfo stride */
- pScreenInfo->dwStride = ((dibsection.dsBmih.biSizeImage
- / dibsection.dsBmih.biHeight)
- * 8) / pScreenInfo->dwBPP;
-
- winDebug ("winAllocateFBShadowGDI - Created shadow stride: %d\n",
- (int) pScreenInfo->dwStride);
-
-#ifdef XWIN_MULTIWINDOW
- /* Redraw all windows */
- if (pScreenInfo->fMultiWindow)
- EnumThreadWindows (g_dwCurrentThreadID, winRedrawAllProcShadowGDI, 0);
-#endif
-
- return fReturn;
-}
-
-static void
-winFreeFBShadowGDI (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-
- /* Free the shadow bitmap */
- DeleteObject (pScreenPriv->hbmpShadow);
-
- /* Invalidate the ScreenInfo's fb pointer */
- pScreenInfo->pfb = NULL;
-}
-
-/*
- * Blit the damaged regions of the shadow fb to the screen
- */
-
-static void
-winShadowUpdateGDI (ScreenPtr pScreen,
- shadowBufPtr pBuf)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- RegionPtr damage = shadowDamage(pBuf);
- DWORD dwBox = RegionNumRects (damage);
- BoxPtr pBox = RegionRects (damage);
- int x, y, w, h;
- HRGN hrgnTemp = NULL, hrgnCombined = NULL;
-#ifdef XWIN_UPDATESTATS
- static DWORD s_dwNonUnitRegions = 0;
- static DWORD s_dwTotalUpdates = 0;
- static DWORD s_dwTotalBoxes = 0;
-#endif
- BoxPtr pBoxExtents = RegionExtents(damage);
-
- /*
- * Return immediately if the app is not active
- * and we are fullscreen, or if we have a bad display depth
- */
- if ((!pScreenPriv->fActive && pScreenInfo->fFullScreen)
- || pScreenPriv->fBadDepth) return;
-
-#ifdef XWIN_UPDATESTATS
- ++s_dwTotalUpdates;
- s_dwTotalBoxes += dwBox;
-
- if (dwBox != 1)
- {
- ++s_dwNonUnitRegions;
- winDebug ("winShadowUpdatGDI - dwBox: %d\n", dwBox);
- }
-
- if ((s_dwTotalUpdates % 100) == 0)
- {
- 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 */
-
- /*
- * Handle small regions with multiple blits,
- * handle large regions by creating a clipping region and
- * doing a single blit constrained to that clipping region.
- */
- if (!pScreenInfo->fMultiWindow &&
- (pScreenInfo->dwClipUpdatesNBoxes == 0 ||
- dwBox < pScreenInfo->dwClipUpdatesNBoxes))
- {
- /* Loop through all boxes in the damaged region */
- while (dwBox--)
- {
- /*
- * Calculate x offset, y offset, width, and height for
- * current damage box
- */
- x = pBox->x1;
- y = pBox->y1;
- w = pBox->x2 - pBox->x1;
- h = pBox->y2 - pBox->y1;
-
- BitBlt (pScreenPriv->hdcScreen,
- x, y,
- w, h,
- pScreenPriv->hdcShadow,
- x, y,
- SRCCOPY);
-
- /* Get a pointer to the next box */
- ++pBox;
- }
- }
- else if (!pScreenInfo->fMultiWindow)
- {
- /* Compute a GDI region from the damaged region */
- hrgnCombined = CreateRectRgn (pBox->x1, pBox->y1, pBox->x2, pBox->y2);
- dwBox--;
- pBox++;
- while (dwBox--)
- {
- hrgnTemp = CreateRectRgn (pBox->x1, pBox->y1, pBox->x2, pBox->y2);
- CombineRgn (hrgnCombined, hrgnCombined, hrgnTemp, RGN_OR);
- DeleteObject (hrgnTemp);
- pBox++;
- }
-
- /* Install the GDI region as a clipping region */
- SelectClipRgn (pScreenPriv->hdcScreen, hrgnCombined);
- DeleteObject (hrgnCombined);
- hrgnCombined = NULL;
-
- /*
- * Blit the shadow buffer to the screen,
- * constrained to the clipping region.
- */
- BitBlt (pScreenPriv->hdcScreen,
- pBoxExtents->x1, pBoxExtents->y1,
- pBoxExtents->x2 - pBoxExtents->x1,
- pBoxExtents->y2 - pBoxExtents->y1,
- pScreenPriv->hdcShadow,
- pBoxExtents->x1, pBoxExtents->y1,
- SRCCOPY);
-
- /* Reset the clip region */
- SelectClipRgn (pScreenPriv->hdcScreen, NULL);
- }
-
-#ifdef XWIN_MULTIWINDOW
- /* Redraw all multiwindow windows */
- if (pScreenInfo->fMultiWindow)
- EnumThreadWindows (g_dwCurrentThreadID,
- winRedrawDamagedWindowShadowGDI,
- (LPARAM)pBoxExtents);
-#endif
-}
-
-
-static Bool
-winInitScreenShadowGDI (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
-
- /* Get device contexts for the screen and shadow bitmap */
- pScreenPriv->hdcScreen = GetDC (pScreenPriv->hwndScreen);
- pScreenPriv->hdcShadow = CreateCompatibleDC (pScreenPriv->hdcScreen);
-
- /* Allocate bitmap info header */
- pScreenPriv->pbmih = (BITMAPINFOHEADER*) malloc (sizeof (BITMAPINFOHEADER)
- + 256 * sizeof (RGBQUAD));
- if (pScreenPriv->pbmih == NULL)
- {
- ErrorF ("winInitScreenShadowGDI - malloc () failed\n");
- return FALSE;
- }
-
- /* Query the screen format */
- if (!winQueryScreenDIBFormat (pScreen, pScreenPriv->pbmih))
- {
- ErrorF ("winInitScreenShadowGDI - winQueryScreenDIBFormat failed\n");
- return FALSE;
- }
-
- /* Determine our color masks */
- if (!winQueryRGBBitsAndMasks (pScreen))
- {
- ErrorF ("winInitScreenShadowGDI - winQueryRGBBitsAndMasks failed\n");
- return FALSE;
- }
-
- return winAllocateFBShadowGDI(pScreen);
-}
-
-/* See Porting Layer Definition - p. 33 */
-/*
- * We wrap whatever CloseScreen procedure was specified by fb;
- * a pointer to said procedure is stored in our privates.
- */
-
-static Bool
-winCloseScreenShadowGDI (int nIndex, ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- Bool fReturn;
-
- winDebug ("winCloseScreenShadowGDI - Freeing screen resources\n");
-
- /* Flag that the screen is closed */
- pScreenPriv->fClosed = TRUE;
- pScreenPriv->fActive = FALSE;
-
- /* Call the wrapped CloseScreen procedure */
- WIN_UNWRAP(CloseScreen);
- if (pScreen->CloseScreen)
- fReturn = (*pScreen->CloseScreen) (nIndex, pScreen);
-
- /* Delete the window property */
- RemoveProp (pScreenPriv->hwndScreen, WIN_SCR_PROP);
-
- /* Free the shadow DC; which allows the bitmap to be freed */
- DeleteDC (pScreenPriv->hdcShadow);
-
- winFreeFBShadowGDI(pScreen);
-
- /* Free the screen DC */
- ReleaseDC (pScreenPriv->hwndScreen, pScreenPriv->hdcScreen);
-
- /* Delete tray icon, if we have one */
- if (!pScreenInfo->fNoTrayIcon)
- winDeleteNotifyIcon (pScreenPriv);
-
- /* Free the exit confirmation dialog box, if it exists */
- if (g_hDlgExit != NULL)
- {
- DestroyWindow (g_hDlgExit);
- g_hDlgExit = NULL;
- }
-
- /* Kill our window */
- if (pScreenPriv->hwndScreen)
- {
- DestroyWindow (pScreenPriv->hwndScreen);
- pScreenPriv->hwndScreen = NULL;
- }
-
-#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
- /* Destroy the thread startup mutex */
- pthread_mutex_destroy (&pScreenPriv->pmServerStarted);
-#endif
-
- /* Invalidate our screeninfo's pointer to the screen */
- pScreenInfo->pScreen = NULL;
-
- /* Free the screen privates for this screen */
- free ((pointer) pScreenPriv);
-
- return fReturn;
-}
-
-
-/*
- * Tell mi what sort of visuals we need.
- *
- * Generally we only need one visual, as our screen can only
- * handle one format at a time, I believe. You may want
- * to verify that last sentence.
- */
-
-static Bool
-winInitVisualsShadowGDI (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-
- /* Display debugging information */
- winDebug ("winInitVisualsShadowGDI - Masks %08x %08x %08x BPRGB %d d %d "
- "bpp %d\n",
- (unsigned int) pScreenPriv->dwRedMask,
- (unsigned int) pScreenPriv->dwGreenMask,
- (unsigned int) pScreenPriv->dwBlueMask,
- (int) pScreenPriv->dwBitsPerRGB,
- (int) pScreenInfo->dwDepth,
- (int) pScreenInfo->dwBPP);
-
- /* Create a single visual according to the Windows screen depth */
- switch (pScreenInfo->dwDepth)
- {
- case 24:
- case 16:
- case 15:
- /* Setup the real visual */
- if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
- TrueColorMask,
- pScreenPriv->dwBitsPerRGB,
- -1,
- pScreenPriv->dwRedMask,
- pScreenPriv->dwGreenMask,
- pScreenPriv->dwBlueMask))
- {
- ErrorF ("winInitVisualsShadowGDI - miSetVisualTypesAndMasks "
- "failed\n");
- return FALSE;
- }
-
-#ifdef XWIN_EMULATEPSEUDO
- if (!pScreenInfo->fEmulatePseudo)
- break;
-
- /* Setup a pseudocolor visual */
- if (!miSetVisualTypesAndMasks (8,
- PseudoColorMask,
- 8,
- -1,
- 0,
- 0,
- 0))
- {
- ErrorF ("winInitVisualsShadowGDI - miSetVisualTypesAndMasks "
- "failed for PseudoColor\n");
- return FALSE;
- }
-#endif
- break;
-
- case 8:
- if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
- PseudoColorMask,
- pScreenPriv->dwBitsPerRGB,
- PseudoColor,
- pScreenPriv->dwRedMask,
- pScreenPriv->dwGreenMask,
- pScreenPriv->dwBlueMask))
- {
- ErrorF ("winInitVisualsShadowGDI - miSetVisualTypesAndMasks "
- "failed\n");
- return FALSE;
- }
- break;
-
- default:
- ErrorF ("winInitVisualsShadowGDI - Unknown screen depth\n");
- return FALSE;
- }
-
- winDebug ("winInitVisualsShadowGDI - Returning\n");
-
- return TRUE;
-}
-
-
-/*
- * Adjust the proposed video mode
- */
-
-static Bool
-winAdjustVideoModeShadowGDI (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- HDC hdc;
- DWORD dwBPP;
-
- hdc = GetDC (NULL);
-
- /* We're in serious trouble if we can't get a DC */
- if (hdc == NULL)
- {
- ErrorF ("winAdjustVideoModeShadowGDI - GetDC () failed\n");
- return FALSE;
- }
-
- /* Query GDI for current display depth */
- dwBPP = GetDeviceCaps (hdc, BITSPIXEL);
-
- /* GDI cannot change the screen depth, so always use GDI's depth */
- pScreenInfo->dwBPP = dwBPP;
-
- /* Release our DC */
- ReleaseDC (NULL, hdc);
- hdc = NULL;
-
- return TRUE;
-}
-
-
-/*
- * Blt exposed regions to the screen
- */
-
-static Bool
-winBltExposedRegionsShadowGDI (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- winPrivCmapPtr pCmapPriv = NULL;
- HDC hdcUpdate;
- PAINTSTRUCT ps;
-
- /* BeginPaint gives us an hdc that clips to the invalidated region */
- hdcUpdate = BeginPaint (pScreenPriv->hwndScreen, &ps);
-
- /* Realize the palette, if we have one */
- if (pScreenPriv->pcmapInstalled != NULL)
- {
- pCmapPriv = winGetCmapPriv (pScreenPriv->pcmapInstalled);
-
- SelectPalette (hdcUpdate, pCmapPriv->hPalette, FALSE);
- RealizePalette (hdcUpdate);
- }
-
- /* Our BitBlt will be clipped to the invalidated region */
- BitBlt (hdcUpdate,
- 0, 0,
- pScreenInfo->dwWidth, pScreenInfo->dwHeight,
- pScreenPriv->hdcShadow,
- 0, 0,
- SRCCOPY);
-
- /* EndPaint frees the DC */
- EndPaint (pScreenPriv->hwndScreen, &ps);
-
-#ifdef XWIN_MULTIWINDOW
- /* Redraw all windows */
- if (pScreenInfo->fMultiWindow)
- EnumThreadWindows(g_dwCurrentThreadID, winRedrawAllProcShadowGDI,
- (LPARAM)pScreenPriv->hwndScreen);
-#endif
-
- return TRUE;
-}
-
-
-/*
- * Do any engine-specific appliation-activation processing
- */
-
-static Bool
-winActivateAppShadowGDI (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-
- /*
- * 2004/04/12 - Harold - We perform the restoring or minimizing
- * manually for ShadowGDI in fullscreen modes so that this engine
- * will perform just like ShadowDD and ShadowDDNL in fullscreen mode;
- * if we do not do this then our fullscreen window will appear in the
- * z-order when it is deactivated and it can be uncovered by resizing
- * or minimizing another window that is on top of it, which is not how
- * the DirectDraw engines work. Therefore we keep this code here to
- * make sure that all engines work the same in fullscreen mode.
- */
-
- /*
- * Are we active?
- * Are we fullscreen?
- */
- if (pScreenPriv->fActive
- && pScreenInfo->fFullScreen)
- {
- /*
- * Activating, attempt to bring our window
- * to the top of the display
- */
- ShowWindow (pScreenPriv->hwndScreen, SW_RESTORE);
- }
- else if (!pScreenPriv->fActive
- && pScreenInfo->fFullScreen)
- {
- /*
- * Deactivating, stuff our window onto the
- * task bar.
- */
- ShowWindow (pScreenPriv->hwndScreen, SW_MINIMIZE);
- }
-
- return TRUE;
-}
-
-
-/*
- * Reblit the shadow framebuffer to the screen.
- */
-
-static Bool
-winRedrawScreenShadowGDI (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-
- /* Redraw the whole window, to take account for the new colors */
- BitBlt (pScreenPriv->hdcScreen,
- 0, 0,
- pScreenInfo->dwWidth, pScreenInfo->dwHeight,
- pScreenPriv->hdcShadow,
- 0, 0,
- SRCCOPY);
-
-#ifdef XWIN_MULTIWINDOW
- /* Redraw all windows */
- if (pScreenInfo->fMultiWindow)
- EnumThreadWindows(g_dwCurrentThreadID, winRedrawAllProcShadowGDI, 0);
-#endif
-
- return TRUE;
-}
-
-
-
-/*
- * Realize the currently installed colormap
- */
-
-static Bool
-winRealizeInstalledPaletteShadowGDI (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winPrivCmapPtr pCmapPriv = NULL;
-
- winDebug ("winRealizeInstalledPaletteShadowGDI\n");
-
- /* Don't do anything if there is not a colormap */
- if (pScreenPriv->pcmapInstalled == NULL)
- {
- winDebug ("winRealizeInstalledPaletteShadowGDI - No colormap "
- "installed\n");
- return TRUE;
- }
-
- pCmapPriv = winGetCmapPriv (pScreenPriv->pcmapInstalled);
-
- /* Realize our palette for the screen */
- if (RealizePalette (pScreenPriv->hdcScreen) == GDI_ERROR)
- {
- ErrorF ("winRealizeInstalledPaletteShadowGDI - RealizePalette () "
- "failed\n");
- return FALSE;
- }
-
- /* Set the DIB color table */
- if (SetDIBColorTable (pScreenPriv->hdcShadow,
- 0,
- WIN_NUM_PALETTE_ENTRIES,
- pCmapPriv->rgbColors) == 0)
- {
- ErrorF ("winRealizeInstalledPaletteShadowGDI - SetDIBColorTable () "
- "failed\n");
- return FALSE;
- }
-
- return TRUE;
-}
-
-
-/*
- * Install the specified colormap
- */
-
-static Bool
-winInstallColormapShadowGDI (ColormapPtr pColormap)
-{
- ScreenPtr pScreen = pColormap->pScreen;
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- winCmapPriv(pColormap);
-
- /*
- * Tell Windows to install the new colormap
- */
- if (SelectPalette (pScreenPriv->hdcScreen,
- pCmapPriv->hPalette,
- FALSE) == NULL)
- {
- ErrorF ("winInstallColormapShadowGDI - SelectPalette () failed\n");
- return FALSE;
- }
-
- /* Realize the palette */
- if (GDI_ERROR == RealizePalette (pScreenPriv->hdcScreen))
- {
- ErrorF ("winInstallColormapShadowGDI - RealizePalette () failed\n");
- return FALSE;
- }
-
- /* Set the DIB color table */
- if (SetDIBColorTable (pScreenPriv->hdcShadow,
- 0,
- WIN_NUM_PALETTE_ENTRIES,
- pCmapPriv->rgbColors) == 0)
- {
- ErrorF ("winInstallColormapShadowGDI - SetDIBColorTable () failed\n");
- return FALSE;
- }
-
- /* Redraw the whole window, to take account for the new colors */
- BitBlt (pScreenPriv->hdcScreen,
- 0, 0,
- pScreenInfo->dwWidth, pScreenInfo->dwHeight,
- pScreenPriv->hdcShadow,
- 0, 0,
- SRCCOPY);
-
- /* Save a pointer to the newly installed colormap */
- pScreenPriv->pcmapInstalled = pColormap;
-
-#ifdef XWIN_MULTIWINDOW
- /* Redraw all windows */
- if (pScreenInfo->fMultiWindow)
- EnumThreadWindows (g_dwCurrentThreadID, winRedrawAllProcShadowGDI, 0);
-#endif
-
- return TRUE;
-}
-
-
-/*
- * Store the specified colors in the specified colormap
- */
-
-static Bool
-winStoreColorsShadowGDI (ColormapPtr pColormap,
- int ndef,
- xColorItem *pdefs)
-{
- ScreenPtr pScreen = pColormap->pScreen;
- winScreenPriv(pScreen);
- winCmapPriv(pColormap);
- ColormapPtr curpmap = pScreenPriv->pcmapInstalled;
-
- /* Put the X colormap entries into the Windows logical palette */
- if (SetPaletteEntries (pCmapPriv->hPalette,
- pdefs[0].pixel,
- ndef,
- pCmapPriv->peColors + pdefs[0].pixel) == 0)
- {
- ErrorF ("winStoreColorsShadowGDI - SetPaletteEntries () failed\n");
- return FALSE;
- }
-
- /* Don't install the Windows palette if the colormap is not installed */
- if (pColormap != curpmap)
- {
- return TRUE;
- }
-
- /* Try to install the newly modified colormap */
- if (!winInstallColormapShadowGDI (pColormap))
- {
- ErrorF ("winInstallColormapShadowGDI - winInstallColormapShadowGDI "
- "failed\n");
- return FALSE;
- }
-
-#if 0
- /* Tell Windows that the palette has changed */
- RealizePalette (pScreenPriv->hdcScreen);
-
- /* Set the DIB color table */
- if (SetDIBColorTable (pScreenPriv->hdcShadow,
- pdefs[0].pixel,
- ndef,
- pCmapPriv->rgbColors + pdefs[0].pixel) == 0)
- {
- ErrorF ("winInstallColormapShadowGDI - SetDIBColorTable () failed\n");
- return FALSE;
- }
-
- /* Save a pointer to the newly installed colormap */
- pScreenPriv->pcmapInstalled = pColormap;
-#endif
-
- return TRUE;
-}
-
-
-/*
- * Colormap initialization procedure
- */
-
-static Bool
-winCreateColormapShadowGDI (ColormapPtr pColormap)
-{
- LPLOGPALETTE lpPaletteNew = NULL;
- DWORD dwEntriesMax;
- VisualPtr pVisual;
- HPALETTE hpalNew = NULL;
- winCmapPriv(pColormap);
-
- /* Get a pointer to the visual that the colormap belongs to */
- pVisual = pColormap->pVisual;
-
- /* Get the maximum number of palette entries for this visual */
- dwEntriesMax = pVisual->ColormapEntries;
-
- /* Allocate a Windows logical color palette with max entries */
- lpPaletteNew = malloc (sizeof (LOGPALETTE)
- + (dwEntriesMax - 1) * sizeof (PALETTEENTRY));
- if (lpPaletteNew == NULL)
- {
- ErrorF ("winCreateColormapShadowGDI - Couldn't allocate palette "
- "with %d entries\n",
- (int) dwEntriesMax);
- return FALSE;
- }
-
- /* Zero out the colormap */
- ZeroMemory (lpPaletteNew, sizeof (LOGPALETTE)
- + (dwEntriesMax - 1) * sizeof (PALETTEENTRY));
-
- /* Set the logical palette structure */
- lpPaletteNew->palVersion = 0x0300;
- lpPaletteNew->palNumEntries = dwEntriesMax;
-
- /* Tell Windows to create the palette */
- hpalNew = CreatePalette (lpPaletteNew);
- if (hpalNew == NULL)
- {
- ErrorF ("winCreateColormapShadowGDI - CreatePalette () failed\n");
- free (lpPaletteNew);
- return FALSE;
- }
-
- /* Save the Windows logical palette handle in the X colormaps' privates */
- pCmapPriv->hPalette = hpalNew;
-
- /* Free the palette initialization memory */
- free (lpPaletteNew);
-
- return TRUE;
-}
-
-
-/*
- * Colormap destruction procedure
- */
-
-static Bool
-winDestroyColormapShadowGDI (ColormapPtr pColormap)
-{
- winScreenPriv(pColormap->pScreen);
- winCmapPriv(pColormap);
-
- /*
- * Is colormap to be destroyed the default?
- *
- * Non-default colormaps should have had winUninstallColormap
- * called on them before we get here. The default colormap
- * will not have had winUninstallColormap called on it. Thus,
- * we need to handle the default colormap in a special way.
- */
- if (pColormap->flags & IsDefault)
- {
- winDebug ("winDestroyColormapShadowGDI - Destroying default "
- "colormap\n");
-
- /*
- * FIXME: Walk the list of all screens, popping the default
- * palette out of each screen device context.
- */
-
- /* Pop the palette out of the device context */
- SelectPalette (pScreenPriv->hdcScreen,
- GetStockObject (DEFAULT_PALETTE),
- FALSE);
-
- /* Clear our private installed colormap pointer */
- pScreenPriv->pcmapInstalled = NULL;
- }
-
- /* Try to delete the logical palette */
- if (DeleteObject (pCmapPriv->hPalette) == 0)
- {
- ErrorF ("winDestroyColormap - DeleteObject () failed\n");
- return FALSE;
- }
-
- /* Invalidate the colormap privates */
- pCmapPriv->hPalette = NULL;
-
- return TRUE;
-}
-
-
-/*
- * Set engine specific funtions
- */
-
-Bool
-winSetEngineFunctionsShadowGDI (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-
- /* Set our pointers */
- pScreenPriv->pwinAllocateFB = winAllocateFBShadowGDI;
- pScreenPriv->pwinFreeFB = winFreeFBShadowGDI;
- pScreenPriv->pwinShadowUpdate = winShadowUpdateGDI;
- pScreenPriv->pwinInitScreen = winInitScreenShadowGDI;
- pScreenPriv->pwinCloseScreen = winCloseScreenShadowGDI;
- pScreenPriv->pwinInitVisuals = winInitVisualsShadowGDI;
- pScreenPriv->pwinAdjustVideoMode = winAdjustVideoModeShadowGDI;
- if (pScreenInfo->fFullScreen)
- pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowFullScreen;
- else
- pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowWindowed;
- pScreenPriv->pwinFinishScreenInit = winFinishScreenInitFB;
- pScreenPriv->pwinBltExposedRegions = winBltExposedRegionsShadowGDI;
- pScreenPriv->pwinActivateApp = winActivateAppShadowGDI;
- pScreenPriv->pwinRedrawScreen = winRedrawScreenShadowGDI;
- pScreenPriv->pwinRealizeInstalledPalette =
- winRealizeInstalledPaletteShadowGDI;
- pScreenPriv->pwinInstallColormap = winInstallColormapShadowGDI;
- pScreenPriv->pwinStoreColors = winStoreColorsShadowGDI;
- pScreenPriv->pwinCreateColormap = winCreateColormapShadowGDI;
- pScreenPriv->pwinDestroyColormap = winDestroyColormapShadowGDI;
- pScreenPriv->pwinHotKeyAltTab = (winHotKeyAltTabProcPtr) (void (*)(void))NoopDDA;
- pScreenPriv->pwinCreatePrimarySurface
- = (winCreatePrimarySurfaceProcPtr) (void (*)(void))NoopDDA;
- pScreenPriv->pwinReleasePrimarySurface
- = (winReleasePrimarySurfaceProcPtr) (void (*)(void))NoopDDA;
-#ifdef XWIN_MULTIWINDOW
- pScreenPriv->pwinFinishCreateWindowsWindow =
- (winFinishCreateWindowsWindowProcPtr) (void (*)(void))NoopDDA;
-#endif
-
- return TRUE;
-}
+/*
+ *Copyright (C) 2001-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"
+
+
+/*
+ * Local function prototypes
+ */
+
+#ifdef XWIN_MULTIWINDOW
+static wBOOL CALLBACK
+winRedrawAllProcShadowGDI (HWND hwnd, LPARAM lParam);
+
+static wBOOL CALLBACK
+winRedrawDamagedWindowShadowGDI (HWND hwnd, LPARAM lParam);
+#endif
+
+static Bool
+winAllocateFBShadowGDI (ScreenPtr pScreen);
+
+static void
+winShadowUpdateGDI (ScreenPtr pScreen,
+ shadowBufPtr pBuf);
+
+static Bool
+winCloseScreenShadowGDI (int nIndex, ScreenPtr pScreen);
+
+static Bool
+winInitVisualsShadowGDI (ScreenPtr pScreen);
+
+static Bool
+winAdjustVideoModeShadowGDI (ScreenPtr pScreen);
+
+static Bool
+winBltExposedRegionsShadowGDI (ScreenPtr pScreen);
+
+static Bool
+winActivateAppShadowGDI (ScreenPtr pScreen);
+
+static Bool
+winRedrawScreenShadowGDI (ScreenPtr pScreen);
+
+static Bool
+winRealizeInstalledPaletteShadowGDI (ScreenPtr pScreen);
+
+static Bool
+winInstallColormapShadowGDI (ColormapPtr pColormap);
+
+static Bool
+winStoreColorsShadowGDI (ColormapPtr pmap,
+ int ndef,
+ xColorItem *pdefs);
+
+static Bool
+winCreateColormapShadowGDI (ColormapPtr pColormap);
+
+static Bool
+winDestroyColormapShadowGDI (ColormapPtr pColormap);
+
+
+/*
+ * Internal function to get the DIB format that is compatible with the screen
+ */
+
+static
+Bool
+winQueryScreenDIBFormat (ScreenPtr pScreen, BITMAPINFOHEADER *pbmih)
+{
+ winScreenPriv(pScreen);
+ HBITMAP hbmp;
+#ifdef WINDBG
+ LPDWORD pdw = NULL;
+#endif
+
+ /* Create a memory bitmap compatible with the screen */
+ hbmp = CreateCompatibleBitmap (pScreenPriv->hdcScreen, 1, 1);
+ if (hbmp == NULL)
+ {
+ ErrorF ("winQueryScreenDIBFormat - CreateCompatibleBitmap failed\n");
+ return FALSE;
+ }
+
+ /* Initialize our bitmap info header */
+ ZeroMemory (pbmih, sizeof (BITMAPINFOHEADER) + 256 * sizeof (RGBQUAD));
+ pbmih->biSize = sizeof (BITMAPINFOHEADER);
+
+ /* Get the biBitCount */
+ if (!GetDIBits (pScreenPriv->hdcScreen,
+ hbmp,
+ 0, 1,
+ NULL,
+ (BITMAPINFO*) pbmih,
+ DIB_RGB_COLORS))
+ {
+ ErrorF ("winQueryScreenDIBFormat - First call to GetDIBits failed\n");
+ DeleteObject (hbmp);
+ return FALSE;
+ }
+
+#ifdef WINDBG
+ /* Get a pointer to bitfields */
+ pdw = (DWORD*) ((CARD8*)pbmih + sizeof (BITMAPINFOHEADER));
+
+ winDebug ("winQueryScreenDIBFormat - First call masks: %08x %08x %08x\n",
+ pdw[0], pdw[1], pdw[2]);
+#endif
+
+ /* Get optimal color table, or the optimal bitfields */
+ if (!GetDIBits (pScreenPriv->hdcScreen,
+ hbmp,
+ 0, 1,
+ NULL,
+ (BITMAPINFO*)pbmih,
+ DIB_RGB_COLORS))
+ {
+ ErrorF ("winQueryScreenDIBFormat - Second call to GetDIBits "
+ "failed\n");
+ DeleteObject (hbmp);
+ return FALSE;
+ }
+
+ /* Free memory */
+ DeleteObject (hbmp);
+
+ return TRUE;
+}
+
+
+/*
+ * Internal function to determine the GDI bits per rgb and bit masks
+ */
+
+static
+Bool
+winQueryRGBBitsAndMasks (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ BITMAPINFOHEADER *pbmih = NULL;
+ Bool fReturn = TRUE;
+ LPDWORD pdw = NULL;
+ DWORD dwRedBits, dwGreenBits, dwBlueBits;
+
+ /* Color masks for 8 bpp are standardized */
+ if (GetDeviceCaps (pScreenPriv->hdcScreen, RASTERCAPS) & RC_PALETTE)
+ {
+ /*
+ * RGB BPP for 8 bit palletes is always 8
+ * and the color masks are always 0.
+ */
+ pScreenPriv->dwBitsPerRGB = 8;
+ pScreenPriv->dwRedMask = 0x0L;
+ pScreenPriv->dwGreenMask = 0x0L;
+ pScreenPriv->dwBlueMask = 0x0L;
+ return TRUE;
+ }
+
+ /* Color masks for 24 bpp are standardized */
+ if (GetDeviceCaps (pScreenPriv->hdcScreen, PLANES)
+ * GetDeviceCaps (pScreenPriv->hdcScreen, BITSPIXEL) == 24)
+ {
+ winDebug ("winQueryRGBBitsAndMasks - GetDeviceCaps (BITSPIXEL) "
+ "returned 24 for the screen. Using default 24bpp masks.\n");
+
+ /* 8 bits per primary color */
+ pScreenPriv->dwBitsPerRGB = 8;
+
+ /* Set screen privates masks */
+ pScreenPriv->dwRedMask = WIN_24BPP_MASK_RED;
+ pScreenPriv->dwGreenMask = WIN_24BPP_MASK_GREEN;
+ pScreenPriv->dwBlueMask = WIN_24BPP_MASK_BLUE;
+
+ return TRUE;
+ }
+
+ /* Allocate a bitmap header and color table */
+ pbmih = (BITMAPINFOHEADER*) malloc (sizeof (BITMAPINFOHEADER)
+ + 256 * sizeof (RGBQUAD));
+ if (pbmih == NULL)
+ {
+ ErrorF ("winQueryRGBBitsAndMasks - malloc failed\n");
+ return FALSE;
+ }
+
+ /* Get screen description */
+ if (winQueryScreenDIBFormat (pScreen, pbmih))
+ {
+ /* Get a pointer to bitfields */
+ pdw = (DWORD*) ((CARD8*)pbmih + sizeof (BITMAPINFOHEADER));
+
+#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__,
+ pbmih->biWidth, pbmih->biHeight, pbmih->biBitCount, pbmih->biPlanes);
+ winDebug ("%s - Compression: %d %s\n", __FUNCTION__,
+ pbmih->biCompression,
+ (pbmih->biCompression == BI_RGB?"(BI_RGB)":
+ (pbmih->biCompression == BI_RLE8?"(BI_RLE8)":
+ (pbmih->biCompression == BI_RLE4?"(BI_RLE4)":
+ (pbmih->biCompression == BI_BITFIELDS?"(BI_BITFIELDS)":""
+ )))));
+#endif
+
+ /* Handle BI_RGB case, which is returned by Wine */
+ if (pbmih->biCompression == BI_RGB)
+ {
+ dwRedBits = 5;
+ dwGreenBits = 5;
+ dwBlueBits = 5;
+
+ pScreenPriv->dwBitsPerRGB = 5;
+
+ /* Set screen privates masks */
+ pScreenPriv->dwRedMask = 0x7c00;
+ pScreenPriv->dwGreenMask = 0x03e0;
+ pScreenPriv->dwBlueMask = 0x001f;
+ }
+ else
+ {
+ /* Count the number of bits in each mask */
+ dwRedBits = winCountBits (pdw[0]);
+ dwGreenBits = winCountBits (pdw[1]);
+ dwBlueBits = winCountBits (pdw[2]);
+
+ /* Find maximum bits per red, green, blue */
+ if (dwRedBits > dwGreenBits && dwRedBits > dwBlueBits)
+ pScreenPriv->dwBitsPerRGB = dwRedBits;
+ else if (dwGreenBits > dwRedBits && dwGreenBits > dwBlueBits)
+ pScreenPriv->dwBitsPerRGB = dwGreenBits;
+ else
+ pScreenPriv->dwBitsPerRGB = dwBlueBits;
+
+ /* Set screen privates masks */
+ pScreenPriv->dwRedMask = pdw[0];
+ pScreenPriv->dwGreenMask = pdw[1];
+ pScreenPriv->dwBlueMask = pdw[2];
+ }
+ }
+ else
+ {
+ ErrorF ("winQueryRGBBitsAndMasks - winQueryScreenDIBFormat failed\n");
+ free (pbmih);
+ fReturn = FALSE;
+ }
+
+ /* Free memory */
+ free (pbmih);
+
+ return fReturn;
+}
+
+
+#ifdef XWIN_MULTIWINDOW
+/*
+ * Redraw all ---?
+ */
+
+static wBOOL CALLBACK
+winRedrawAllProcShadowGDI (HWND hwnd, LPARAM lParam)
+{
+ if (hwnd == (HWND)lParam)
+ return TRUE;
+ InvalidateRect (hwnd, NULL, FALSE);
+ UpdateWindow (hwnd);
+ return TRUE;
+}
+
+static wBOOL CALLBACK
+winRedrawDamagedWindowShadowGDI (HWND hwnd, LPARAM lParam)
+{
+ BoxPtr pDamage = (BoxPtr)lParam;
+ RECT rcClient, rcDamage, rcRedraw;
+ POINT topLeft, bottomRight;
+
+ if (IsIconic (hwnd))
+ return TRUE; /* Don't care minimized windows */
+
+ /* Convert the damaged area from Screen coords to Client coords */
+ topLeft.x = pDamage->x1; topLeft.y = pDamage->y1;
+ bottomRight.x = pDamage->x2; bottomRight.y = pDamage->y2;
+ topLeft.x += GetSystemMetrics (SM_XVIRTUALSCREEN);
+ bottomRight.x += GetSystemMetrics (SM_XVIRTUALSCREEN);
+ topLeft.y += GetSystemMetrics (SM_YVIRTUALSCREEN);
+ bottomRight.y += GetSystemMetrics (SM_YVIRTUALSCREEN);
+ ScreenToClient (hwnd, &topLeft);
+ ScreenToClient (hwnd, &bottomRight);
+ SetRect (&rcDamage, topLeft.x, topLeft.y, bottomRight.x, bottomRight.y);
+
+ GetClientRect (hwnd, &rcClient);
+
+ if (IntersectRect (&rcRedraw, &rcClient, &rcDamage))
+ {
+ InvalidateRect (hwnd, &rcRedraw, FALSE);
+ UpdateWindow (hwnd);
+ }
+ return TRUE;
+}
+#endif
+
+
+/*
+ * Allocate a DIB for the shadow framebuffer GDI server
+ */
+
+static Bool
+winAllocateFBShadowGDI (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ DIBSECTION dibsection;
+ Bool fReturn = TRUE;
+
+ /* Describe shadow bitmap to be created */
+ pScreenPriv->pbmih->biWidth = pScreenInfo->dwWidth;
+ pScreenPriv->pbmih->biHeight = -pScreenInfo->dwHeight;
+
+ winDebug ("winAllocateFBShadowGDI - Creating DIB with width: %d height: %d "
+ "depth: %d\n",
+ (int) pScreenPriv->pbmih->biWidth, (int) -pScreenPriv->pbmih->biHeight, pScreenPriv->pbmih->biBitCount);
+
+ /* Create a DI shadow bitmap with a bit pointer */
+ pScreenPriv->hbmpShadow = CreateDIBSection (pScreenPriv->hdcScreen,
+ (BITMAPINFO *) pScreenPriv->pbmih,
+ DIB_RGB_COLORS,
+ (VOID**) &pScreenInfo->pfb,
+ NULL,
+ 0);
+ if (pScreenPriv->hbmpShadow == NULL || pScreenInfo->pfb == NULL)
+ {
+ winW32Error ("winAllocateFBShadowGDI - CreateDIBSection failed:");
+ return FALSE;
+ }
+ else
+ {
+ winDebug ("winAllocateFBShadowGDI - Shadow buffer allocated\n");
+ }
+
+ /* Get information about the bitmap that was allocated */
+ GetObject (pScreenPriv->hbmpShadow,
+ sizeof (dibsection),
+ &dibsection);
+
+ /* 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);
+
+ /* Select the shadow bitmap into the shadow DC */
+ SelectObject (pScreenPriv->hdcShadow,
+ pScreenPriv->hbmpShadow);
+
+ winDebug ("winAllocateFBShadowGDI - Attempting a shadow blit\n");
+
+ /* Do a test blit from the shadow to the screen, I think */
+ fReturn = BitBlt (pScreenPriv->hdcScreen,
+ 0, 0,
+ pScreenInfo->dwWidth, pScreenInfo->dwHeight,
+ pScreenPriv->hdcShadow,
+ 0, 0,
+ SRCCOPY);
+ if (fReturn)
+ {
+ winDebug ("winAllocateFBShadowGDI - Shadow blit success\n");
+ }
+ 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;
+ }
+
+ /* Look for height weirdness */
+ if (dibsection.dsBmih.biHeight < 0)
+ {
+ dibsection.dsBmih.biHeight = -dibsection.dsBmih.biHeight;
+ }
+
+ /* Set screeninfo stride */
+ pScreenInfo->dwStride = ((dibsection.dsBmih.biSizeImage
+ / dibsection.dsBmih.biHeight)
+ * 8) / pScreenInfo->dwBPP;
+
+ winDebug ("winAllocateFBShadowGDI - Created shadow stride: %d\n",
+ (int) pScreenInfo->dwStride);
+
+#ifdef XWIN_MULTIWINDOW
+ /* Redraw all windows */
+ if (pScreenInfo->fMultiWindow)
+ EnumThreadWindows (g_dwCurrentThreadID, winRedrawAllProcShadowGDI, 0);
+#endif
+
+ return fReturn;
+}
+
+static void
+winFreeFBShadowGDI (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /* Free the shadow bitmap */
+ DeleteObject (pScreenPriv->hbmpShadow);
+
+ /* Invalidate the ScreenInfo's fb pointer */
+ pScreenInfo->pfb = NULL;
+}
+
+/*
+ * Blit the damaged regions of the shadow fb to the screen
+ */
+
+static void
+winShadowUpdateGDI (ScreenPtr pScreen,
+ shadowBufPtr pBuf)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ RegionPtr damage = shadowDamage(pBuf);
+ DWORD dwBox = RegionNumRects (damage);
+ BoxPtr pBox = RegionRects (damage);
+ int x, y, w, h;
+ HRGN hrgnTemp = NULL, hrgnCombined = NULL;
+#ifdef XWIN_UPDATESTATS
+ static DWORD s_dwNonUnitRegions = 0;
+ static DWORD s_dwTotalUpdates = 0;
+ static DWORD s_dwTotalBoxes = 0;
+#endif
+ BoxPtr pBoxExtents = RegionExtents(damage);
+
+ /*
+ * Return immediately if the app is not active
+ * and we are fullscreen, or if we have a bad display depth
+ */
+ if ((!pScreenPriv->fActive && pScreenInfo->fFullScreen)
+ || pScreenPriv->fBadDepth) return;
+
+#ifdef XWIN_UPDATESTATS
+ ++s_dwTotalUpdates;
+ s_dwTotalBoxes += dwBox;
+
+ if (dwBox != 1)
+ {
+ ++s_dwNonUnitRegions;
+ winDebug ("winShadowUpdatGDI - dwBox: %d\n", dwBox);
+ }
+
+ if ((s_dwTotalUpdates % 100) == 0)
+ {
+ 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 */
+
+ /*
+ * Handle small regions with multiple blits,
+ * handle large regions by creating a clipping region and
+ * doing a single blit constrained to that clipping region.
+ */
+ if (!pScreenInfo->fMultiWindow &&
+ (pScreenInfo->dwClipUpdatesNBoxes == 0 ||
+ dwBox < pScreenInfo->dwClipUpdatesNBoxes))
+ {
+ /* Loop through all boxes in the damaged region */
+ while (dwBox--)
+ {
+ /*
+ * Calculate x offset, y offset, width, and height for
+ * current damage box
+ */
+ x = pBox->x1;
+ y = pBox->y1;
+ w = pBox->x2 - pBox->x1;
+ h = pBox->y2 - pBox->y1;
+
+ BitBlt (pScreenPriv->hdcScreen,
+ x, y,
+ w, h,
+ pScreenPriv->hdcShadow,
+ x, y,
+ SRCCOPY);
+
+ /* Get a pointer to the next box */
+ ++pBox;
+ }
+ }
+ else if (!pScreenInfo->fMultiWindow)
+ {
+ /* Compute a GDI region from the damaged region */
+ hrgnCombined = CreateRectRgn (pBox->x1, pBox->y1, pBox->x2, pBox->y2);
+ dwBox--;
+ pBox++;
+ while (dwBox--)
+ {
+ hrgnTemp = CreateRectRgn (pBox->x1, pBox->y1, pBox->x2, pBox->y2);
+ CombineRgn (hrgnCombined, hrgnCombined, hrgnTemp, RGN_OR);
+ DeleteObject (hrgnTemp);
+ pBox++;
+ }
+
+ /* Install the GDI region as a clipping region */
+ SelectClipRgn (pScreenPriv->hdcScreen, hrgnCombined);
+ DeleteObject (hrgnCombined);
+ hrgnCombined = NULL;
+
+ /*
+ * Blit the shadow buffer to the screen,
+ * constrained to the clipping region.
+ */
+ BitBlt (pScreenPriv->hdcScreen,
+ pBoxExtents->x1, pBoxExtents->y1,
+ pBoxExtents->x2 - pBoxExtents->x1,
+ pBoxExtents->y2 - pBoxExtents->y1,
+ pScreenPriv->hdcShadow,
+ pBoxExtents->x1, pBoxExtents->y1,
+ SRCCOPY);
+
+ /* Reset the clip region */
+ SelectClipRgn (pScreenPriv->hdcScreen, NULL);
+ }
+
+#ifdef XWIN_MULTIWINDOW
+ /* Redraw all multiwindow windows */
+ if (pScreenInfo->fMultiWindow)
+ EnumThreadWindows (g_dwCurrentThreadID,
+ winRedrawDamagedWindowShadowGDI,
+ (LPARAM)pBoxExtents);
+#endif
+}
+
+
+static Bool
+winInitScreenShadowGDI (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+
+ /* Get device contexts for the screen and shadow bitmap */
+ pScreenPriv->hdcScreen = GetDC (pScreenPriv->hwndScreen);
+ pScreenPriv->hdcShadow = CreateCompatibleDC (pScreenPriv->hdcScreen);
+
+ /* Allocate bitmap info header */
+ pScreenPriv->pbmih = (BITMAPINFOHEADER*) malloc (sizeof (BITMAPINFOHEADER)
+ + 256 * sizeof (RGBQUAD));
+ if (pScreenPriv->pbmih == NULL)
+ {
+ ErrorF ("winInitScreenShadowGDI - malloc () failed\n");
+ return FALSE;
+ }
+
+ /* Query the screen format */
+ if (!winQueryScreenDIBFormat (pScreen, pScreenPriv->pbmih))
+ {
+ ErrorF ("winInitScreenShadowGDI - winQueryScreenDIBFormat failed\n");
+ return FALSE;
+ }
+
+ /* Determine our color masks */
+ if (!winQueryRGBBitsAndMasks (pScreen))
+ {
+ ErrorF ("winInitScreenShadowGDI - winQueryRGBBitsAndMasks failed\n");
+ return FALSE;
+ }
+
+ return winAllocateFBShadowGDI(pScreen);
+}
+
+/* See Porting Layer Definition - p. 33 */
+/*
+ * We wrap whatever CloseScreen procedure was specified by fb;
+ * a pointer to said procedure is stored in our privates.
+ */
+
+static Bool
+winCloseScreenShadowGDI (int nIndex, ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ Bool fReturn;
+
+ winDebug ("winCloseScreenShadowGDI - Freeing screen resources\n");
+
+ /* Flag that the screen is closed */
+ pScreenPriv->fClosed = TRUE;
+ pScreenPriv->fActive = FALSE;
+
+ /* Call the wrapped CloseScreen procedure */
+ WIN_UNWRAP(CloseScreen);
+ if (pScreen->CloseScreen)
+ fReturn = (*pScreen->CloseScreen) (nIndex, pScreen);
+
+ /* Delete the window property */
+ RemoveProp (pScreenPriv->hwndScreen, WIN_SCR_PROP);
+
+ /* Free the shadow DC; which allows the bitmap to be freed */
+ DeleteDC (pScreenPriv->hdcShadow);
+
+ winFreeFBShadowGDI(pScreen);
+
+ /* Free the screen DC */
+ ReleaseDC (pScreenPriv->hwndScreen, pScreenPriv->hdcScreen);
+
+ /* Delete tray icon, if we have one */
+ if (!pScreenInfo->fNoTrayIcon)
+ winDeleteNotifyIcon (pScreenPriv);
+
+ /* Free the exit confirmation dialog box, if it exists */
+ if (g_hDlgExit != NULL)
+ {
+ DestroyWindow (g_hDlgExit);
+ g_hDlgExit = NULL;
+ }
+
+ /* Kill our window */
+ if (pScreenPriv->hwndScreen)
+ {
+ DestroyWindow (pScreenPriv->hwndScreen);
+ pScreenPriv->hwndScreen = NULL;
+ }
+
+#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
+ /* Destroy the thread startup mutex */
+ pthread_mutex_destroy (&pScreenPriv->pmServerStarted);
+#endif
+
+ /* Invalidate our screeninfo's pointer to the screen */
+ pScreenInfo->pScreen = NULL;
+
+ /* Free the screen privates for this screen */
+ free ((pointer) pScreenPriv);
+
+ return fReturn;
+}
+
+
+/*
+ * Tell mi what sort of visuals we need.
+ *
+ * Generally we only need one visual, as our screen can only
+ * handle one format at a time, I believe. You may want
+ * to verify that last sentence.
+ */
+
+static Bool
+winInitVisualsShadowGDI (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /* Display debugging information */
+ winDebug ("winInitVisualsShadowGDI - Masks %08x %08x %08x BPRGB %d d %d "
+ "bpp %d\n",
+ (unsigned int) pScreenPriv->dwRedMask,
+ (unsigned int) pScreenPriv->dwGreenMask,
+ (unsigned int) pScreenPriv->dwBlueMask,
+ (int) pScreenPriv->dwBitsPerRGB,
+ (int) pScreenInfo->dwDepth,
+ (int) pScreenInfo->dwBPP);
+
+ /* Create a single visual according to the Windows screen depth */
+ switch (pScreenInfo->dwDepth)
+ {
+ case 24:
+ case 16:
+ case 15:
+ /* Setup the real visual */
+ if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
+ TrueColorMask,
+ pScreenPriv->dwBitsPerRGB,
+ -1,
+ pScreenPriv->dwRedMask,
+ pScreenPriv->dwGreenMask,
+ pScreenPriv->dwBlueMask))
+ {
+ ErrorF ("winInitVisualsShadowGDI - miSetVisualTypesAndMasks "
+ "failed\n");
+ return FALSE;
+ }
+
+#ifdef XWIN_EMULATEPSEUDO
+ if (!pScreenInfo->fEmulatePseudo)
+ break;
+
+ /* Setup a pseudocolor visual */
+ if (!miSetVisualTypesAndMasks (8,
+ PseudoColorMask,
+ 8,
+ -1,
+ 0,
+ 0,
+ 0))
+ {
+ ErrorF ("winInitVisualsShadowGDI - miSetVisualTypesAndMasks "
+ "failed for PseudoColor\n");
+ return FALSE;
+ }
+#endif
+ break;
+
+ case 8:
+ if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
+ PseudoColorMask,
+ pScreenPriv->dwBitsPerRGB,
+ PseudoColor,
+ pScreenPriv->dwRedMask,
+ pScreenPriv->dwGreenMask,
+ pScreenPriv->dwBlueMask))
+ {
+ ErrorF ("winInitVisualsShadowGDI - miSetVisualTypesAndMasks "
+ "failed\n");
+ return FALSE;
+ }
+ break;
+
+ default:
+ ErrorF ("winInitVisualsShadowGDI - Unknown screen depth\n");
+ return FALSE;
+ }
+
+ winDebug ("winInitVisualsShadowGDI - Returning\n");
+
+ return TRUE;
+}
+
+
+/*
+ * Adjust the proposed video mode
+ */
+
+static Bool
+winAdjustVideoModeShadowGDI (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ HDC hdc;
+ DWORD dwBPP;
+
+ hdc = GetDC (NULL);
+
+ /* We're in serious trouble if we can't get a DC */
+ if (hdc == NULL)
+ {
+ ErrorF ("winAdjustVideoModeShadowGDI - GetDC () failed\n");
+ return FALSE;
+ }
+
+ /* Query GDI for current display depth */
+ dwBPP = GetDeviceCaps (hdc, BITSPIXEL);
+
+ /* GDI cannot change the screen depth, so always use GDI's depth */
+ pScreenInfo->dwBPP = dwBPP;
+
+ /* Release our DC */
+ ReleaseDC (NULL, hdc);
+ hdc = NULL;
+
+ return TRUE;
+}
+
+
+/*
+ * Blt exposed regions to the screen
+ */
+
+static Bool
+winBltExposedRegionsShadowGDI (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ winPrivCmapPtr pCmapPriv = NULL;
+ HDC hdcUpdate;
+ PAINTSTRUCT ps;
+
+ /* BeginPaint gives us an hdc that clips to the invalidated region */
+ hdcUpdate = BeginPaint (pScreenPriv->hwndScreen, &ps);
+
+ /* Realize the palette, if we have one */
+ if (pScreenPriv->pcmapInstalled != NULL)
+ {
+ pCmapPriv = winGetCmapPriv (pScreenPriv->pcmapInstalled);
+
+ SelectPalette (hdcUpdate, pCmapPriv->hPalette, FALSE);
+ RealizePalette (hdcUpdate);
+ }
+
+ /* Our BitBlt will be clipped to the invalidated region */
+ BitBlt (hdcUpdate,
+ 0, 0,
+ pScreenInfo->dwWidth, pScreenInfo->dwHeight,
+ pScreenPriv->hdcShadow,
+ 0, 0,
+ SRCCOPY);
+
+ /* EndPaint frees the DC */
+ EndPaint (pScreenPriv->hwndScreen, &ps);
+
+#ifdef XWIN_MULTIWINDOW
+ /* Redraw all windows */
+ if (pScreenInfo->fMultiWindow)
+ EnumThreadWindows(g_dwCurrentThreadID, winRedrawAllProcShadowGDI,
+ (LPARAM)pScreenPriv->hwndScreen);
+#endif
+
+ return TRUE;
+}
+
+
+/*
+ * Do any engine-specific appliation-activation processing
+ */
+
+static Bool
+winActivateAppShadowGDI (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /*
+ * 2004/04/12 - Harold - We perform the restoring or minimizing
+ * manually for ShadowGDI in fullscreen modes so that this engine
+ * will perform just like ShadowDD and ShadowDDNL in fullscreen mode;
+ * if we do not do this then our fullscreen window will appear in the
+ * z-order when it is deactivated and it can be uncovered by resizing
+ * or minimizing another window that is on top of it, which is not how
+ * the DirectDraw engines work. Therefore we keep this code here to
+ * make sure that all engines work the same in fullscreen mode.
+ */
+
+ /*
+ * Are we active?
+ * Are we fullscreen?
+ */
+ if (pScreenPriv->fActive
+ && pScreenInfo->fFullScreen)
+ {
+ /*
+ * Activating, attempt to bring our window
+ * to the top of the display
+ */
+ ShowWindow (pScreenPriv->hwndScreen, SW_RESTORE);
+ }
+ else if (!pScreenPriv->fActive
+ && pScreenInfo->fFullScreen)
+ {
+ /*
+ * Deactivating, stuff our window onto the
+ * task bar.
+ */
+ ShowWindow (pScreenPriv->hwndScreen, SW_MINIMIZE);
+ }
+
+ return TRUE;
+}
+
+
+/*
+ * Reblit the shadow framebuffer to the screen.
+ */
+
+static Bool
+winRedrawScreenShadowGDI (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /* Redraw the whole window, to take account for the new colors */
+ BitBlt (pScreenPriv->hdcScreen,
+ 0, 0,
+ pScreenInfo->dwWidth, pScreenInfo->dwHeight,
+ pScreenPriv->hdcShadow,
+ 0, 0,
+ SRCCOPY);
+
+#ifdef XWIN_MULTIWINDOW
+ /* Redraw all windows */
+ if (pScreenInfo->fMultiWindow)
+ EnumThreadWindows(g_dwCurrentThreadID, winRedrawAllProcShadowGDI, 0);
+#endif
+
+ return TRUE;
+}
+
+
+
+/*
+ * Realize the currently installed colormap
+ */
+
+static Bool
+winRealizeInstalledPaletteShadowGDI (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winPrivCmapPtr pCmapPriv = NULL;
+
+ winDebug ("winRealizeInstalledPaletteShadowGDI\n");
+
+ /* Don't do anything if there is not a colormap */
+ if (pScreenPriv->pcmapInstalled == NULL)
+ {
+ winDebug ("winRealizeInstalledPaletteShadowGDI - No colormap "
+ "installed\n");
+ return TRUE;
+ }
+
+ pCmapPriv = winGetCmapPriv (pScreenPriv->pcmapInstalled);
+
+ /* Realize our palette for the screen */
+ if (RealizePalette (pScreenPriv->hdcScreen) == GDI_ERROR)
+ {
+ ErrorF ("winRealizeInstalledPaletteShadowGDI - RealizePalette () "
+ "failed\n");
+ return FALSE;
+ }
+
+ /* Set the DIB color table */
+ if (SetDIBColorTable (pScreenPriv->hdcShadow,
+ 0,
+ WIN_NUM_PALETTE_ENTRIES,
+ pCmapPriv->rgbColors) == 0)
+ {
+ ErrorF ("winRealizeInstalledPaletteShadowGDI - SetDIBColorTable () "
+ "failed\n");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+/*
+ * Install the specified colormap
+ */
+
+static Bool
+winInstallColormapShadowGDI (ColormapPtr pColormap)
+{
+ ScreenPtr pScreen = pColormap->pScreen;
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ winCmapPriv(pColormap);
+
+ /*
+ * Tell Windows to install the new colormap
+ */
+ if (SelectPalette (pScreenPriv->hdcScreen,
+ pCmapPriv->hPalette,
+ FALSE) == NULL)
+ {
+ ErrorF ("winInstallColormapShadowGDI - SelectPalette () failed\n");
+ return FALSE;
+ }
+
+ /* Realize the palette */
+ if (GDI_ERROR == RealizePalette (pScreenPriv->hdcScreen))
+ {
+ ErrorF ("winInstallColormapShadowGDI - RealizePalette () failed\n");
+ return FALSE;
+ }
+
+ /* Set the DIB color table */
+ if (SetDIBColorTable (pScreenPriv->hdcShadow,
+ 0,
+ WIN_NUM_PALETTE_ENTRIES,
+ pCmapPriv->rgbColors) == 0)
+ {
+ ErrorF ("winInstallColormapShadowGDI - SetDIBColorTable () failed\n");
+ return FALSE;
+ }
+
+ /* Redraw the whole window, to take account for the new colors */
+ BitBlt (pScreenPriv->hdcScreen,
+ 0, 0,
+ pScreenInfo->dwWidth, pScreenInfo->dwHeight,
+ pScreenPriv->hdcShadow,
+ 0, 0,
+ SRCCOPY);
+
+ /* Save a pointer to the newly installed colormap */
+ pScreenPriv->pcmapInstalled = pColormap;
+
+#ifdef XWIN_MULTIWINDOW
+ /* Redraw all windows */
+ if (pScreenInfo->fMultiWindow)
+ EnumThreadWindows (g_dwCurrentThreadID, winRedrawAllProcShadowGDI, 0);
+#endif
+
+ return TRUE;
+}
+
+
+/*
+ * Store the specified colors in the specified colormap
+ */
+
+static Bool
+winStoreColorsShadowGDI (ColormapPtr pColormap,
+ int ndef,
+ xColorItem *pdefs)
+{
+ ScreenPtr pScreen = pColormap->pScreen;
+ winScreenPriv(pScreen);
+ winCmapPriv(pColormap);
+ ColormapPtr curpmap = pScreenPriv->pcmapInstalled;
+
+ /* Put the X colormap entries into the Windows logical palette */
+ if (SetPaletteEntries (pCmapPriv->hPalette,
+ pdefs[0].pixel,
+ ndef,
+ pCmapPriv->peColors + pdefs[0].pixel) == 0)
+ {
+ ErrorF ("winStoreColorsShadowGDI - SetPaletteEntries () failed\n");
+ return FALSE;
+ }
+
+ /* Don't install the Windows palette if the colormap is not installed */
+ if (pColormap != curpmap)
+ {
+ return TRUE;
+ }
+
+ /* Try to install the newly modified colormap */
+ if (!winInstallColormapShadowGDI (pColormap))
+ {
+ ErrorF ("winInstallColormapShadowGDI - winInstallColormapShadowGDI "
+ "failed\n");
+ return FALSE;
+ }
+
+#if 0
+ /* Tell Windows that the palette has changed */
+ RealizePalette (pScreenPriv->hdcScreen);
+
+ /* Set the DIB color table */
+ if (SetDIBColorTable (pScreenPriv->hdcShadow,
+ pdefs[0].pixel,
+ ndef,
+ pCmapPriv->rgbColors + pdefs[0].pixel) == 0)
+ {
+ ErrorF ("winInstallColormapShadowGDI - SetDIBColorTable () failed\n");
+ return FALSE;
+ }
+
+ /* Save a pointer to the newly installed colormap */
+ pScreenPriv->pcmapInstalled = pColormap;
+#endif
+
+ return TRUE;
+}
+
+
+/*
+ * Colormap initialization procedure
+ */
+
+static Bool
+winCreateColormapShadowGDI (ColormapPtr pColormap)
+{
+ LPLOGPALETTE lpPaletteNew = NULL;
+ DWORD dwEntriesMax;
+ VisualPtr pVisual;
+ HPALETTE hpalNew = NULL;
+ winCmapPriv(pColormap);
+
+ /* Get a pointer to the visual that the colormap belongs to */
+ pVisual = pColormap->pVisual;
+
+ /* Get the maximum number of palette entries for this visual */
+ dwEntriesMax = pVisual->ColormapEntries;
+
+ /* Allocate a Windows logical color palette with max entries */
+ lpPaletteNew = malloc (sizeof (LOGPALETTE)
+ + (dwEntriesMax - 1) * sizeof (PALETTEENTRY));
+ if (lpPaletteNew == NULL)
+ {
+ ErrorF ("winCreateColormapShadowGDI - Couldn't allocate palette "
+ "with %d entries\n",
+ (int) dwEntriesMax);
+ return FALSE;
+ }
+
+ /* Zero out the colormap */
+ ZeroMemory (lpPaletteNew, sizeof (LOGPALETTE)
+ + (dwEntriesMax - 1) * sizeof (PALETTEENTRY));
+
+ /* Set the logical palette structure */
+ lpPaletteNew->palVersion = 0x0300;
+ lpPaletteNew->palNumEntries = dwEntriesMax;
+
+ /* Tell Windows to create the palette */
+ hpalNew = CreatePalette (lpPaletteNew);
+ if (hpalNew == NULL)
+ {
+ ErrorF ("winCreateColormapShadowGDI - CreatePalette () failed\n");
+ free (lpPaletteNew);
+ return FALSE;
+ }
+
+ /* Save the Windows logical palette handle in the X colormaps' privates */
+ pCmapPriv->hPalette = hpalNew;
+
+ /* Free the palette initialization memory */
+ free (lpPaletteNew);
+
+ return TRUE;
+}
+
+
+/*
+ * Colormap destruction procedure
+ */
+
+static Bool
+winDestroyColormapShadowGDI (ColormapPtr pColormap)
+{
+ winScreenPriv(pColormap->pScreen);
+ winCmapPriv(pColormap);
+
+ /*
+ * Is colormap to be destroyed the default?
+ *
+ * Non-default colormaps should have had winUninstallColormap
+ * called on them before we get here. The default colormap
+ * will not have had winUninstallColormap called on it. Thus,
+ * we need to handle the default colormap in a special way.
+ */
+ if (pColormap->flags & IsDefault)
+ {
+ winDebug ("winDestroyColormapShadowGDI - Destroying default "
+ "colormap\n");
+
+ /*
+ * FIXME: Walk the list of all screens, popping the default
+ * palette out of each screen device context.
+ */
+
+ /* Pop the palette out of the device context */
+ SelectPalette (pScreenPriv->hdcScreen,
+ GetStockObject (DEFAULT_PALETTE),
+ FALSE);
+
+ /* Clear our private installed colormap pointer */
+ pScreenPriv->pcmapInstalled = NULL;
+ }
+
+ /* Try to delete the logical palette */
+ if (DeleteObject (pCmapPriv->hPalette) == 0)
+ {
+ ErrorF ("winDestroyColormap - DeleteObject () failed\n");
+ return FALSE;
+ }
+
+ /* Invalidate the colormap privates */
+ pCmapPriv->hPalette = NULL;
+
+ return TRUE;
+}
+
+
+/*
+ * Set engine specific funtions
+ */
+
+Bool
+winSetEngineFunctionsShadowGDI (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /* Set our pointers */
+ pScreenPriv->pwinAllocateFB = winAllocateFBShadowGDI;
+ pScreenPriv->pwinFreeFB = winFreeFBShadowGDI;
+ pScreenPriv->pwinShadowUpdate = winShadowUpdateGDI;
+ pScreenPriv->pwinInitScreen = winInitScreenShadowGDI;
+ pScreenPriv->pwinCloseScreen = winCloseScreenShadowGDI;
+ pScreenPriv->pwinInitVisuals = winInitVisualsShadowGDI;
+ pScreenPriv->pwinAdjustVideoMode = winAdjustVideoModeShadowGDI;
+ if (pScreenInfo->fFullScreen)
+ pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowFullScreen;
+ else
+ pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowWindowed;
+ pScreenPriv->pwinFinishScreenInit = winFinishScreenInitFB;
+ pScreenPriv->pwinBltExposedRegions = winBltExposedRegionsShadowGDI;
+ pScreenPriv->pwinActivateApp = winActivateAppShadowGDI;
+ pScreenPriv->pwinRedrawScreen = winRedrawScreenShadowGDI;
+ pScreenPriv->pwinRealizeInstalledPalette =
+ winRealizeInstalledPaletteShadowGDI;
+ pScreenPriv->pwinInstallColormap = winInstallColormapShadowGDI;
+ pScreenPriv->pwinStoreColors = winStoreColorsShadowGDI;
+ pScreenPriv->pwinCreateColormap = winCreateColormapShadowGDI;
+ pScreenPriv->pwinDestroyColormap = winDestroyColormapShadowGDI;
+ pScreenPriv->pwinHotKeyAltTab = (winHotKeyAltTabProcPtr) (void (*)(void))NoopDDA;
+ pScreenPriv->pwinCreatePrimarySurface
+ = (winCreatePrimarySurfaceProcPtr) (void (*)(void))NoopDDA;
+ pScreenPriv->pwinReleasePrimarySurface
+ = (winReleasePrimarySurfaceProcPtr) (void (*)(void))NoopDDA;
+#ifdef XWIN_MULTIWINDOW
+ pScreenPriv->pwinFinishCreateWindowsWindow =
+ (winFinishCreateWindowsWindowProcPtr) (void (*)(void))NoopDDA;
+#endif
+
+ return TRUE;
+}
diff --git a/xorg-server/hw/xwin/winvideo.c b/xorg-server/hw/xwin/winvideo.c
index 10f48b564..ed205448d 100644
--- a/xorg-server/hw/xwin/winvideo.c
+++ b/xorg-server/hw/xwin/winvideo.c
@@ -1,208 +1,208 @@
-/*
- *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 <X11/extensions/Xv.h>
-#include <X11/extensions/Xvproto.h>
-
-void
-winInitVideo (ScreenPtr pScreen);
-
-/*
- * winInitVideo - Initialize support for the X Video (Xv) Extension.
- */
-
-void
-winInitVideo (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-
- if (pScreenInfo->dwBPP > 8)
- {
-
- }
-
-
-}
-
-
-
-
-
-
-
-#if 0
-#include "../xfree86/common/xf86.h"
-#include "../Xext/xvdix.h"
-#include "../xfree86/common/xf86xv.h"
-#include <X11/extensions/Xv.h>
-#endif
-
-
-
-#if 0
-/* client libraries expect an encoding */
-static XF86VideoEncodingRec DummyEncoding[1] =
-{
- {
- 0,
- "XV_IMAGE",
- IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT,
- {1, 1}
- }
-};
-
-#define NUM_FORMATS 3
-
-static XF86VideoFormatRec Formats[NUM_FORMATS] =
-{
- {15, TrueColor}, {16, TrueColor}, {24, TrueColor}
-};
-
-#define NUM_ATTRIBUTES 3
-
-static XF86AttributeRec Attributes[NUM_ATTRIBUTES] =
-{
- {XvSettable | XvGettable, 0, (1 << 24) - 1, "XV_COLORKEY"},
- {XvSettable | XvGettable, -128, 127, "XV_BRIGHTNESS"},
- {XvSettable | XvGettable, 0, 255, "XV_CONTRAST"}
-};
-
-#define NUM_IMAGES 4
-
-static XF86ImageRec Images[NUM_IMAGES] =
-{
- XVIMAGE_YUY2,
- XVIMAGE_YV12,
- XVIMAGE_I420,
- XVIMAGE_UYVY
-};
-
-
-
-/*
- * winInitVideo - Initialize support for the X Video (Xv) Extension.
- */
-
-void
-winInitVideo (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- XF86VideoAdaptorPtr newAdaptor = NULL;
-
- if (pScreenInfo->dwBPP > 8)
- {
- newAdaptor = I810SetupImageVideo (pScreen);
- I810InitOffscreenImages (pScreen);
- }
-
- xf86XVScreenInit (pScreen, adaptors, 1);
-}
-
-
-static XF86VideoAdaptorPtr
-winSetupImageVideo (ScreenPtr pScreen)
-{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
-#if 0
- I810Ptr pI810 = I810PTR(pScrn);
-#endif
- XF86VideoAdaptorPtr adapt;
-
- if (!(adapt = calloc(1, sizeof(XF86VideoAdaptorRec))))
- return NULL;
-
- adapt->type = XvWindowMask | XvInputMask | XvImageMask;
- adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT;
- adapt->name = PROJECT_NAME " Video Overlay";
- adapt->nEncodings = 1;
- adapt->pEncodings = DummyEncoding;
- adapt->nFormats = NUM_FORMATS;
- adapt->pFormats = Formats;
- adapt->nPorts = 1;
- adapt->pPortPrivates = NULL;
-
- adapt->pPortPrivates[0].ptr = NULL;
- adapt->pAttributes = Attributes;
- adapt->nImages = NUM_IMAGES;
- adapt->nAttributes = NUM_ATTRIBUTES;
- adapt->pImages = Images;
- adapt->PutVideo = NULL;
- adapt->PutStill = NULL;
- adapt->GetVideo = NULL;
- adapt->GetStill = NULL;
-#if 0
- adapt->StopVideo = I810StopVideo;
- adapt->SetPortAttribute = I810SetPortAttribute;
- adapt->GetPortAttribute = I810GetPortAttribute;
- adapt->QueryBestSize = I810QueryBestSize;
- adapt->PutImage = I810PutImage;
- adapt->QueryImageAttributes = I810QueryImageAttributes;
-#endif
-
-#if 0
- pPriv->colorKey = pI810->colorKey & ((1 << pScrn->depth) - 1);
-#endif
- pPriv->videoStatus = 0;
- pPriv->brightness = 0;
- pPriv->contrast = 64;
- pPriv->linear = NULL;
- pPriv->currentBuf = 0;
-
-#if 0
- /* gotta uninit this someplace */
- RegionNull(&pPriv->clip);
-#endif
-
-#if 0
- pI810->adaptor = adapt;
-
- pI810->BlockHandler = pScreen->BlockHandler;
- pScreen->BlockHandler = I810BlockHandler;
-#endif
-
-#if 0
- xvBrightness = MAKE_ATOM("XV_BRIGHTNESS");
- xvContrast = MAKE_ATOM("XV_CONTRAST");
- xvColorKey = MAKE_ATOM("XV_COLORKEY");
-#endif
-
-#if 0
- I810ResetVideo(pScrn);
-#endif
-
- return adapt;
-}
-#endif
+/*
+ *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 <X11/extensions/Xv.h>
+#include <X11/extensions/Xvproto.h>
+
+void
+winInitVideo (ScreenPtr pScreen);
+
+/*
+ * winInitVideo - Initialize support for the X Video (Xv) Extension.
+ */
+
+void
+winInitVideo (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ if (pScreenInfo->dwBPP > 8)
+ {
+
+ }
+
+
+}
+
+
+
+
+
+
+
+#if 0
+#include "../xfree86/common/xf86.h"
+#include "../Xext/xvdix.h"
+#include "../xfree86/common/xf86xv.h"
+#include <X11/extensions/Xv.h>
+#endif
+
+
+
+#if 0
+/* client libraries expect an encoding */
+static XF86VideoEncodingRec DummyEncoding[1] =
+{
+ {
+ 0,
+ "XV_IMAGE",
+ IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT,
+ {1, 1}
+ }
+};
+
+#define NUM_FORMATS 3
+
+static XF86VideoFormatRec Formats[NUM_FORMATS] =
+{
+ {15, TrueColor}, {16, TrueColor}, {24, TrueColor}
+};
+
+#define NUM_ATTRIBUTES 3
+
+static XF86AttributeRec Attributes[NUM_ATTRIBUTES] =
+{
+ {XvSettable | XvGettable, 0, (1 << 24) - 1, "XV_COLORKEY"},
+ {XvSettable | XvGettable, -128, 127, "XV_BRIGHTNESS"},
+ {XvSettable | XvGettable, 0, 255, "XV_CONTRAST"}
+};
+
+#define NUM_IMAGES 4
+
+static XF86ImageRec Images[NUM_IMAGES] =
+{
+ XVIMAGE_YUY2,
+ XVIMAGE_YV12,
+ XVIMAGE_I420,
+ XVIMAGE_UYVY
+};
+
+
+
+/*
+ * winInitVideo - Initialize support for the X Video (Xv) Extension.
+ */
+
+void
+winInitVideo (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ XF86VideoAdaptorPtr newAdaptor = NULL;
+
+ if (pScreenInfo->dwBPP > 8)
+ {
+ newAdaptor = I810SetupImageVideo (pScreen);
+ I810InitOffscreenImages (pScreen);
+ }
+
+ xf86XVScreenInit (pScreen, adaptors, 1);
+}
+
+
+static XF86VideoAdaptorPtr
+winSetupImageVideo (ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+#if 0
+ I810Ptr pI810 = I810PTR(pScrn);
+#endif
+ XF86VideoAdaptorPtr adapt;
+
+ if (!(adapt = calloc(1, sizeof(XF86VideoAdaptorRec))))
+ return NULL;
+
+ adapt->type = XvWindowMask | XvInputMask | XvImageMask;
+ adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT;
+ adapt->name = PROJECT_NAME " Video Overlay";
+ adapt->nEncodings = 1;
+ adapt->pEncodings = DummyEncoding;
+ adapt->nFormats = NUM_FORMATS;
+ adapt->pFormats = Formats;
+ adapt->nPorts = 1;
+ adapt->pPortPrivates = NULL;
+
+ adapt->pPortPrivates[0].ptr = NULL;
+ adapt->pAttributes = Attributes;
+ adapt->nImages = NUM_IMAGES;
+ adapt->nAttributes = NUM_ATTRIBUTES;
+ adapt->pImages = Images;
+ adapt->PutVideo = NULL;
+ adapt->PutStill = NULL;
+ adapt->GetVideo = NULL;
+ adapt->GetStill = NULL;
+#if 0
+ adapt->StopVideo = I810StopVideo;
+ adapt->SetPortAttribute = I810SetPortAttribute;
+ adapt->GetPortAttribute = I810GetPortAttribute;
+ adapt->QueryBestSize = I810QueryBestSize;
+ adapt->PutImage = I810PutImage;
+ adapt->QueryImageAttributes = I810QueryImageAttributes;
+#endif
+
+#if 0
+ pPriv->colorKey = pI810->colorKey & ((1 << pScrn->depth) - 1);
+#endif
+ pPriv->videoStatus = 0;
+ pPriv->brightness = 0;
+ pPriv->contrast = 64;
+ pPriv->linear = NULL;
+ pPriv->currentBuf = 0;
+
+#if 0
+ /* gotta uninit this someplace */
+ RegionNull(&pPriv->clip);
+#endif
+
+#if 0
+ pI810->adaptor = adapt;
+
+ pI810->BlockHandler = pScreen->BlockHandler;
+ pScreen->BlockHandler = I810BlockHandler;
+#endif
+
+#if 0
+ xvBrightness = MAKE_ATOM("XV_BRIGHTNESS");
+ xvContrast = MAKE_ATOM("XV_CONTRAST");
+ xvColorKey = MAKE_ATOM("XV_COLORKEY");
+#endif
+
+#if 0
+ I810ResetVideo(pScrn);
+#endif
+
+ return adapt;
+}
+#endif
diff --git a/xorg-server/hw/xwin/winwin32rootless.c b/xorg-server/hw/xwin/winwin32rootless.c
index 2f8ace57a..d630f1d90 100644
--- a/xorg-server/hw/xwin/winwin32rootless.c
+++ b/xorg-server/hw/xwin/winwin32rootless.c
@@ -1,883 +1,883 @@
-/*
- *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: Kensuke Matsuzaki
- * Earle F. Philhower, III
- * Harold L Hunt II
- */
-/*
- * Look at hw/darwin/quartz/xpr/xprFrame.c and hw/darwin/quartz/cr/crFrame.c
- */
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-#include <winuser.h>
-#define _WINDOWSWM_SERVER_
-#include <X11/extensions/windowswmstr.h>
-#include "dixevents.h"
-#include "winmultiwindowclass.h"
-#include <X11/Xatom.h>
-
-
-/*
- * Constant defines
- */
-
-#ifndef ULW_COLORKEY
-#define ULW_COLORKEY 0x00000001
-#endif
-#ifndef ULW_ALPHA
-#define ULW_ALPHA 0x00000002
-#endif
-#ifndef ULW_OPAQUE
-#define ULW_OPAQUE 0x00000004
-#endif
-#define AC_SRC_ALPHA 0x01
-
-/*
- * Local function
- */
-
-DEFINE_ATOM_HELPER(AtmWindowsWmNativeHwnd, WINDOWSWM_NATIVE_HWND)
-static void
-winMWExtWMSetNativeProperty (RootlessWindowPtr pFrame);
-
-/*
- * Global variables
- */
-
-Bool g_fNoConfigureWindow = FALSE;
-
-/*
- * Internal function to get the DIB format that is compatible with the screen
- * Fixme: Share code with winshadgdi.c
- */
-
-static
-Bool
-winMWExtWMQueryDIBFormat (win32RootlessWindowPtr pRLWinPriv, BITMAPINFOHEADER *pbmih)
-{
- HBITMAP hbmp;
-#ifdef _DEBUG
- LPDWORD pdw = NULL;
-#endif
-
- /* Create a memory bitmap compatible with the screen */
- hbmp = CreateCompatibleBitmap (pRLWinPriv->hdcScreen, 1, 1);
- if (hbmp == NULL)
- {
- ErrorF ("winMWExtWMQueryDIBFormat - CreateCompatibleBitmap failed\n");
- return FALSE;
- }
-
- /* Initialize our bitmap info header */
- ZeroMemory (pbmih, sizeof (BITMAPINFOHEADER) + 256 * sizeof (RGBQUAD));
- pbmih->biSize = sizeof (BITMAPINFOHEADER);
-
- /* Get the biBitCount */
- if (!GetDIBits (pRLWinPriv->hdcScreen,
- hbmp,
- 0, 1,
- NULL,
- (BITMAPINFO*) pbmih,
- DIB_RGB_COLORS))
- {
- ErrorF ("winMWExtWMQueryDIBFormat - First call to GetDIBits failed\n");
- DeleteObject (hbmp);
- return FALSE;
- }
-
-#ifdef _DEBUG
- /* Get a pointer to bitfields */
- pdw = (DWORD*) ((CARD8*)pbmih + sizeof (BITMAPINFOHEADER));
-
- winDebug ("winMWExtWMQueryDIBFormat - First call masks: %08x %08x %08x\n",
- (unsigned int)pdw[0], (unsigned int)pdw[1], (unsigned int)pdw[2]);
-#endif
-
- /* Get optimal color table, or the optimal bitfields */
- if (!GetDIBits (pRLWinPriv->hdcScreen,
- hbmp,
- 0, 1,
- NULL,
- (BITMAPINFO*)pbmih,
- DIB_RGB_COLORS))
- {
- ErrorF ("winMWExtWMQueryDIBFormat - Second call to GetDIBits "
- "failed\n");
- DeleteObject (hbmp);
- return FALSE;
- }
-
- /* Free memory */
- DeleteObject (hbmp);
-
- return TRUE;
-}
-
-static HRGN
-winMWExtWMCreateRgnFromRegion (RegionPtr pShape)
-{
- int nRects;
- BoxPtr pRects, pEnd;
- HRGN hRgn, hRgnRect;
-
- if (pShape == NULL) return NULL;
-
- nRects = RegionNumRects(pShape);
- pRects = RegionRects(pShape);
-
- hRgn = CreateRectRgn (0, 0, 0, 0);
- if (hRgn == NULL)
- {
- ErrorF ("winReshape - Initial CreateRectRgn (%d, %d, %d, %d) "
- "failed: %d\n",
- 0, 0, 0, 0, (int) GetLastError ());
- }
-
- /* Loop through all rectangles in the X region */
- for (pEnd = pRects + nRects; pRects < pEnd; pRects++)
- {
- /* Create a Windows region for the X rectangle */
- hRgnRect = CreateRectRgn (pRects->x1,
- pRects->y1,
- pRects->x2,
- pRects->y2);
- if (hRgnRect == NULL)
- {
- ErrorF ("winReshape - Loop CreateRectRgn (%d, %d, %d, %d) "
- "failed: %d\n",
- pRects->x1,
- pRects->y1,
- pRects->x2,
- pRects->y2,
- (int) GetLastError ());
- }
-
- /* Merge the Windows region with the accumulated region */
- if (CombineRgn (hRgn, hRgn, hRgnRect, RGN_OR) == ERROR)
- {
- ErrorF ("winReshape - CombineRgn () failed: %d\n",
- (int) GetLastError ());
- }
-
- /* Delete the temporary Windows region */
- DeleteObject (hRgnRect);
- }
-
- return hRgn;
-}
-
-static void
-InitWin32RootlessEngine (win32RootlessWindowPtr pRLWinPriv)
-{
- pRLWinPriv->hdcScreen = GetDC (pRLWinPriv->hWnd);
- pRLWinPriv->hdcShadow = CreateCompatibleDC (pRLWinPriv->hdcScreen);
- pRLWinPriv->hbmpShadow = NULL;
-
- /* Allocate bitmap info header */
- pRLWinPriv->pbmihShadow = (BITMAPINFOHEADER*) malloc (sizeof (BITMAPINFOHEADER)
- + 256 * sizeof (RGBQUAD));
- if (pRLWinPriv->pbmihShadow == NULL)
- {
- ErrorF ("InitWin32RootlessEngine - malloc () failed\n");
- return;
- }
-
- /* Query the screen format */
- winMWExtWMQueryDIBFormat (pRLWinPriv,
- pRLWinPriv->pbmihShadow);
-}
-
-Bool
-winMWExtWMCreateFrame (RootlessWindowPtr pFrame, ScreenPtr pScreen,
- int newX, int newY, RegionPtr pShape)
-{
-#define CLASS_NAME_LENGTH 512
- Bool fResult = TRUE;
- win32RootlessWindowPtr pRLWinPriv;
- WNDCLASSEX wc;
- char pszClass[CLASS_NAME_LENGTH], pszWindowID[12];
- HICON hIcon;
- HICON hIconSmall;
- char *res_name, *res_class, *res_role;
- static int s_iWindowID = 0;
-
- winDebug ("winMWExtWMCreateFrame %d %d - %d %d\n",
- newX, newY, pFrame->width, pFrame->height);
-
- pRLWinPriv = (win32RootlessWindowPtr) malloc (sizeof (win32RootlessWindowRec));
- pRLWinPriv->pFrame = pFrame;
- pRLWinPriv->pfb = NULL;
- pRLWinPriv->hbmpShadow = NULL;
- pRLWinPriv->hdcShadow = NULL;
- pRLWinPriv->hdcScreen = NULL;
- pRLWinPriv->pbmihShadow = NULL;
- pRLWinPriv->fResized = TRUE;
- pRLWinPriv->fClose = FALSE;
- pRLWinPriv->fRestackingNow = FALSE;
- pRLWinPriv->fDestroyed = FALSE;
- pRLWinPriv->fMovingOrSizing = FALSE;
-
- // Store the implementation private frame ID
- pFrame->wid = (RootlessFrameID) pRLWinPriv;
-
- winSelectIcons(pFrame->win, &hIcon, &hIconSmall);
-
- /* Set standard class name prefix so we can identify window easily */
- strncpy (pszClass, WINDOW_CLASS_X, sizeof(pszClass));
-
- if (winMultiWindowGetClassHint (pFrame->win, &res_name, &res_class))
- {
- strncat (pszClass, "-", 1);
- strncat (pszClass, res_name, CLASS_NAME_LENGTH - strlen (pszClass));
- strncat (pszClass, "-", 1);
- strncat (pszClass, res_class, CLASS_NAME_LENGTH - strlen (pszClass));
-
- /* Check if a window class is provided by the WM_WINDOW_ROLE property,
- * if not use the WM_CLASS information.
- * For further information see:
- * http://tronche.com/gui/x/icccm/sec-5.html
- */
- if (winMultiWindowGetWindowRole (pFrame->win, &res_role) )
- {
- strcat (pszClass, "-");
- strcat (pszClass, res_role);
- free (res_role);
- }
-
- free (res_name);
- free (res_class);
- }
-
- /* Add incrementing window ID to make unique class name */
- snprintf (pszWindowID, sizeof(pszWindowID), "-%x", s_iWindowID++);
- pszWindowID[sizeof(pszWindowID)-1] = 0;
- strcat (pszClass, pszWindowID);
-
- winDebug ("winCreateWindowsWindow - Creating class: %s\n", pszClass);
-
- /* Setup our window class */
- wc.cbSize = sizeof(wc);
- wc.style = CS_HREDRAW | CS_VREDRAW;
- wc.lpfnWndProc = winMWExtWMWindowProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = g_hInstance;
- wc.hIcon = hIcon;
- wc.hIconSm = hIconSmall;
- wc.hCursor = 0;
- wc.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
- wc.lpszMenuName = NULL;
- wc.lpszClassName = pszClass;
- RegisterClassEx (&wc);
-
- /* Create the window */
- g_fNoConfigureWindow = TRUE;
- pRLWinPriv->hWnd = CreateWindowExA (WS_EX_TOOLWINDOW, /* Extended styles */
- pszClass, /* Class name */
- WINDOW_TITLE_X, /* Window name */
- WS_POPUP | WS_CLIPCHILDREN,
- newX, /* Horizontal position */
- newY, /* Vertical position */
- pFrame->width, /* Right edge */
- pFrame->height, /* Bottom edge */
- (HWND) NULL, /* No parent or owner window */
- (HMENU) NULL, /* No menu */
- GetModuleHandle (NULL), /* Instance handle */
- pRLWinPriv); /* ScreenPrivates */
- if (pRLWinPriv->hWnd == NULL)
- {
- ErrorF ("winMWExtWMCreateFrame - CreateWindowExA () failed: %d\n",
- (int) GetLastError ());
- fResult = FALSE;
- }
-
- winDebug ("winMWExtWMCreateFrame - ShowWindow\n");
-
- //ShowWindow (pRLWinPriv->hWnd, SW_SHOWNOACTIVATE);
- g_fNoConfigureWindow = FALSE;
-
- if (pShape != NULL)
- {
- winMWExtWMReshapeFrame (pFrame->wid, pShape);
- }
-
- winDebug ("winMWExtWMCreateFrame - (%08x) %08x\n",
- (int) pFrame->wid, (int) pRLWinPriv->hWnd);
-
- winMWExtWMSetNativeProperty (pFrame);
-
- return fResult;
-}
-
-void
-winMWExtWMDestroyFrame (RootlessFrameID wid)
-{
- win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
- HICON hIcon;
- HICON hIconSm;
- HMODULE hInstance;
- int iReturn;
- char pszClass[CLASS_NAME_LENGTH];
-
- winDebug ("winMWExtWMDestroyFrame (%08x) %08x\n",
- (int) pRLWinPriv, (int) pRLWinPriv->hWnd);
-
- /* Store the info we need to destroy after this window is gone */
- hInstance = (HINSTANCE) GetClassLongPtr (pRLWinPriv->hWnd, GCLP_HMODULE);
- hIcon = (HICON)SendMessage(pRLWinPriv->hWnd, WM_GETICON, ICON_BIG, 0);
- hIconSm = (HICON)SendMessage(pRLWinPriv->hWnd, WM_GETICON, ICON_SMALL, 0);
- iReturn = GetClassName (pRLWinPriv->hWnd, pszClass, CLASS_NAME_LENGTH);
-
- pRLWinPriv->fClose = TRUE;
- pRLWinPriv->fDestroyed = TRUE;
-
- /* Destroy the Windows window */
- DestroyWindow (pRLWinPriv->hWnd);
-
- /* Only if we were able to get the name */
- if (iReturn)
- {
- winDebug ("winMWExtWMDestroyFrame - Unregistering %s: ", pszClass);
- iReturn = UnregisterClass (pszClass, hInstance);
-
- winDebug ("winMWExtWMDestroyFramew - Deleting Icon\n");
- }
-
- winDestroyIcon(hiconClass);
- winDestroyIcon(hiconSmClass);
-
- winDebug ("winMWExtWMDestroyFrame - done\n");
-}
-
-void
-winMWExtWMMoveFrame (RootlessFrameID wid, ScreenPtr pScreen, int iNewX, int iNewY)
-{
- win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
- RECT rcNew;
- DWORD dwExStyle;
- DWORD dwStyle;
- int iX, iY, iWidth, iHeight;
-
- winDebug ("winMWExtWMMoveFrame (%08x) (%d %d)\n", (int) pRLWinPriv, iNewX, iNewY);
-
- /* Get the Windows window style and extended style */
- dwExStyle = GetWindowLongPtr (pRLWinPriv->hWnd, GWL_EXSTYLE);
- dwStyle = GetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE);
-
- /* Get the X and Y location of the X window */
- iX = iNewX + GetSystemMetrics (SM_XVIRTUALSCREEN);
- iY = iNewY + GetSystemMetrics (SM_YVIRTUALSCREEN);
-
- /* Get the height and width of the X window */
- iWidth = pRLWinPriv->pFrame->width;
- iHeight = pRLWinPriv->pFrame->height;
-
- /* Store the origin, height, and width in a rectangle structure */
- SetRect (&rcNew, iX, iY, iX + iWidth, iY + iHeight);
-
- winDebug("\tWindow {%d, %d, %d, %d}, {%d, %d}\n",
- rcNew.left, rcNew.top, rcNew.right, rcNew.bottom,
- rcNew.right - rcNew.left, rcNew.bottom - rcNew.top);
- /*
- * Calculate the required size of the Windows window rectangle,
- * given the size of the Windows window client area.
- */
- AdjustWindowRectEx (&rcNew, dwStyle, FALSE, dwExStyle);
-
- winDebug("\tAdjusted {%d, %d, %d, %d}, {%d, %d}\n",
- rcNew.left, rcNew.top, rcNew.right, rcNew.bottom,
- rcNew.right - rcNew.left, rcNew.bottom - rcNew.top);
- g_fNoConfigureWindow = TRUE;
- SetWindowPos (pRLWinPriv->hWnd, NULL, rcNew.left, rcNew.top, 0, 0,
- SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER);
- g_fNoConfigureWindow = FALSE;
- winDebug ("winMWExtWMMoveFrame (%08x) done\n", (int) pRLWinPriv);
-}
-
-void
-winMWExtWMResizeFrame (RootlessFrameID wid, ScreenPtr pScreen,
- int iNewX, int iNewY,
- unsigned int uiNewWidth, unsigned int uiNewHeight,
- unsigned int uiGravity)
-{
- win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
- RECT rcNew;
- RECT rcOld;
- DWORD dwExStyle;
- DWORD dwStyle;
- int iX, iY;
-
- winDebug ("winMWExtWMResizeFrame (%08x) (%d %d)-(%d %d)\n",
- (int) pRLWinPriv, iNewX, iNewY, uiNewWidth, uiNewHeight);
-
- pRLWinPriv->fResized = TRUE;
-
- /* Get the Windows window style and extended style */
- dwExStyle = GetWindowLongPtr (pRLWinPriv->hWnd, GWL_EXSTYLE);
- dwStyle = GetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE);
-
- /* Get the X and Y location of the X window */
- iX = iNewX + GetSystemMetrics (SM_XVIRTUALSCREEN);
- iY = iNewY + GetSystemMetrics (SM_YVIRTUALSCREEN);
-
- /* Store the origin, height, and width in a rectangle structure */
- SetRect (&rcNew, iX, iY, iX + uiNewWidth, iY + uiNewHeight);
-
- /*
- * 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 (pRLWinPriv->hWnd, &rcOld);
-
- /* Check if the old rectangle and new rectangle are the same */
- if (!EqualRect (&rcNew, &rcOld))
- {
-
- g_fNoConfigureWindow = TRUE;
- MoveWindow (pRLWinPriv->hWnd,
- rcNew.left, rcNew.top,
- rcNew.right - rcNew.left, rcNew.bottom - rcNew.top,
- TRUE);
- g_fNoConfigureWindow = FALSE;
- }
-}
-
-void
-winMWExtWMRestackFrame (RootlessFrameID wid, RootlessFrameID nextWid)
-{
- win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
- win32RootlessWindowPtr pRLNextWinPriv = (win32RootlessWindowPtr) nextWid;
- winScreenPriv(pRLWinPriv->pFrame->win->drawable.pScreen);
- winScreenInfo *pScreenInfo = NULL;
- DWORD dwCurrentProcessID = GetCurrentProcessId ();
- DWORD dwWindowProcessID = 0;
- HWND hWnd;
- Bool fFirst = TRUE;
- Bool fNeedRestack = TRUE;
-
- winDebug ("winMWExtWMRestackFrame (%08x)\n", (int) pRLWinPriv);
-
-
- if (pScreenPriv->fRestacking) return;
-
- if (pScreenPriv) pScreenInfo = pScreenPriv->pScreenInfo;
-
- pRLWinPriv->fRestackingNow = TRUE;
-
- /* Show window */
- if(!IsWindowVisible (pRLWinPriv->hWnd))
- ShowWindow (pRLWinPriv->hWnd, SW_SHOWNOACTIVATE);
-
- if (pRLNextWinPriv == NULL)
- {
- winDebug ("Win %08x is top\n", pRLWinPriv);
- pScreenPriv->widTop = wid;
- SetWindowPos (pRLWinPriv->hWnd, HWND_TOP,
- 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
- }
-#ifdef XWIN_MULTIWINDOWINTWM
- else if (winIsInternalWMRunning(pScreenInfo))
- {
- /* using mulwinidow wm */
- winDebug ("Win %08x is not top\n", pRLWinPriv);
-
- for (hWnd = GetNextWindow (pRLWinPriv->hWnd, GW_HWNDPREV);
- fNeedRestack && hWnd != NULL;
- hWnd = GetNextWindow (hWnd, GW_HWNDPREV))
- {
- GetWindowThreadProcessId (hWnd, &dwWindowProcessID);
-
- if ((dwWindowProcessID == dwCurrentProcessID)
- && GetProp (hWnd, WIN_WINDOW_PROP))
- {
- if (hWnd == pRLNextWinPriv->hWnd)
- {
- /* Enable interleave X window and Windows window */
- if (!fFirst)
- {
- winDebug ("raise: Insert after Win %08x\n", pRLNextWinPriv);
-
- SetWindowPos (pRLWinPriv->hWnd, pRLNextWinPriv->hWnd,
- 0, 0, 0, 0,
- SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
- }
- else
- {
- winDebug ("No change\n");
- }
- fNeedRestack = FALSE;
- break;
- }
- if (fFirst) fFirst = FALSE;
- }
- }
-
- for (hWnd = GetNextWindow (pRLWinPriv->hWnd, GW_HWNDNEXT);
- fNeedRestack && hWnd != NULL;
- hWnd = GetNextWindow (hWnd, GW_HWNDNEXT))
- {
- GetWindowThreadProcessId (hWnd, &dwWindowProcessID);
-
- if ((dwWindowProcessID == dwCurrentProcessID)
- && GetProp (hWnd, WIN_WINDOW_PROP))
- {
- if (hWnd == pRLNextWinPriv->hWnd)
- {
- winDebug ("lower: Insert after Win %08x\n", pRLNextWinPriv);
-
- SetWindowPos (pRLWinPriv->hWnd, pRLNextWinPriv->hWnd,
- 0, 0, 0, 0,
- SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
- fNeedRestack = FALSE;
- break;
- }
- }
- }
- }
-#endif
- else
- {
- /* using general wm like twm, wmaker etc.
- Interleave X window and Windows window will cause problem. */
- SetWindowPos (pRLWinPriv->hWnd, pRLNextWinPriv->hWnd,
- 0, 0, 0, 0,
- SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
- }
- winDebug ("winMWExtWMRestackFrame - done (%08x)\n", (int) pRLWinPriv);
-
- pRLWinPriv->fRestackingNow = FALSE;
-}
-
-void
-winMWExtWMReshapeFrame (RootlessFrameID wid, RegionPtr pShape)
-{
- win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
- HRGN hRgn, hRgnWindow, hRgnClient;
- RECT rcWindow, rcClient;
-
- winDebug ("winMWExtWMReshapeFrame (%08x)\n", (int) pRLWinPriv);
-
- hRgn = winMWExtWMCreateRgnFromRegion (pShape);
-
- /* Create region for non-client area */
- GetWindowRect (pRLWinPriv->hWnd, &rcWindow);
- GetClientRect (pRLWinPriv->hWnd, &rcClient);
- MapWindowPoints (pRLWinPriv->hWnd, HWND_DESKTOP, (LPPOINT)&rcClient, 2);
- OffsetRgn (hRgn, rcClient.left - rcWindow.left, rcClient.top - rcWindow.top);
- OffsetRect (&rcClient, -rcWindow.left, -rcWindow.top);
- OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
- hRgnWindow = CreateRectRgnIndirect (&rcWindow);
- hRgnClient = CreateRectRgnIndirect (&rcClient);
- CombineRgn (hRgnWindow, hRgnWindow, hRgnClient, RGN_DIFF);
- CombineRgn (hRgn, hRgnWindow, hRgn, RGN_OR);
-
-
- SetWindowRgn (pRLWinPriv->hWnd, hRgn, TRUE);
-
- DeleteObject (hRgnWindow);
- DeleteObject (hRgnClient);
-}
-
-void
-winMWExtWMUnmapFrame (RootlessFrameID wid)
-{
- win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
-
- winDebug ("winMWExtWMUnmapFrame (%08x)\n", (int) pRLWinPriv);
-
- g_fNoConfigureWindow = TRUE;
- //ShowWindow (pRLWinPriv->hWnd, SW_MINIMIZE);
- ShowWindow (pRLWinPriv->hWnd, SW_HIDE);
- g_fNoConfigureWindow = FALSE;
-}
-
-/*
- * Fixme: Code sharing with winshadgdi.c and other engine support
- */
-void
-winMWExtWMStartDrawing (RootlessFrameID wid, char **pixelData, int *bytesPerRow)
-{
- win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
- winPrivScreenPtr pScreenPriv = NULL;
- winScreenInfo *pScreenInfo = NULL;
- ScreenPtr pScreen = NULL;
- DIBSECTION dibsection;
- Bool fReturn = TRUE;
- HDC hdcNew;
- HBITMAP hbmpNew;
-
- winDebug ("winMWExtWMStartDrawing (%08x) %08x\n", (int) pRLWinPriv, pRLWinPriv->fDestroyed);
-
- if (!pRLWinPriv->fDestroyed)
- {
- pScreen = pRLWinPriv->pFrame->win->drawable.pScreen;
- if (pScreen) pScreenPriv = winGetScreenPriv(pScreen);
- if (pScreenPriv) pScreenInfo = pScreenPriv->pScreenInfo;
-
- winDebug ("\tpScreenPriv %08X\n", (int) pScreenPriv);
- winDebug ("\tpScreenInfo %08X\n", (int) pScreenInfo);
- winDebug ("\t(%d, %d)\n", (int)pRLWinPriv->pFrame->width,
- (int) pRLWinPriv->pFrame->height);
-
- if (pRLWinPriv->hdcScreen == NULL)
- {
- InitWin32RootlessEngine (pRLWinPriv);
- }
-
- if (pRLWinPriv->fResized)
- {
- /* width * bpp must be multiple of 4 to match 32bit alignment */
- int stridesize;
- int misalignment;
-
- pRLWinPriv->pbmihShadow->biWidth = pRLWinPriv->pFrame->width;
- pRLWinPriv->pbmihShadow->biHeight = -pRLWinPriv->pFrame->height;
-
- stridesize = pRLWinPriv->pFrame->width * (pScreenInfo->dwBPP >> 3);
- misalignment = stridesize & 3;
- if (misalignment != 0)
- {
- stridesize += 4 - misalignment;
- pRLWinPriv->pbmihShadow->biWidth = stridesize / (pScreenInfo->dwBPP >> 3);
- winDebug("\tresizing to %d (was %d)\n",
- pRLWinPriv->pbmihShadow->biWidth, pRLWinPriv->pFrame->width);
- }
-
- hdcNew = CreateCompatibleDC (pRLWinPriv->hdcScreen);
- /* Create a DI shadow bitmap with a bit pointer */
- hbmpNew = CreateDIBSection (pRLWinPriv->hdcScreen,
- (BITMAPINFO *) pRLWinPriv->pbmihShadow,
- DIB_RGB_COLORS,
- (VOID**) &pRLWinPriv->pfb,
- NULL,
- 0);
- if (hbmpNew == NULL || pRLWinPriv->pfb == NULL)
- {
- ErrorF ("winMWExtWMStartDrawing - CreateDIBSection failed\n");
- //return FALSE;
- }
- else
- {
- winDebug ("winMWExtWMStartDrawing - Shadow buffer allocated\n");
- }
-
- /* Get information about the bitmap that was allocated */
- GetObject (hbmpNew, sizeof (dibsection), &dibsection);
-
- /* Print information about bitmap allocated */
- winDebug ("winMWExtWMStartDrawing - Dibsection width: %d height: %d "
- "depth: %d size image: %d\n",
- (unsigned int)dibsection.dsBmih.biWidth,
- (unsigned int)dibsection.dsBmih.biHeight,
- (unsigned int)dibsection.dsBmih.biBitCount,
- (unsigned int)dibsection.dsBmih.biSizeImage);
-
- /* Select the shadow bitmap into the shadow DC */
- SelectObject (hdcNew, hbmpNew);
-
- winDebug ("winMWExtWMStartDrawing - Attempting a shadow blit\n");
-
- /* Blit from the old shadow to the new shadow */
- fReturn = BitBlt (hdcNew,
- 0, 0,
- pRLWinPriv->pFrame->width, pRLWinPriv->pFrame->height,
- pRLWinPriv->hdcShadow,
- 0, 0,
- SRCCOPY);
- if (fReturn)
- {
- winDebug ("winMWExtWMStartDrawing - Shadow blit success\n");
- }
- else
- {
- ErrorF ("winMWExtWMStartDrawing - Shadow blit failure\n");
- }
-
- /* Look for height weirdness */
- if (dibsection.dsBmih.biHeight < 0)
- {
- /* FIXME: Figure out why biHeight is sometimes negative */
- ErrorF ("winMWExtWMStartDrawing - WEIRDNESS - "
- "biHeight still negative: %d\n",
- (int) dibsection.dsBmih.biHeight);
- ErrorF ("winMWExtWMStartDrawing - WEIRDNESS - "
- "Flipping biHeight sign\n");
- dibsection.dsBmih.biHeight = -dibsection.dsBmih.biHeight;
- }
-
- pRLWinPriv->dwWidthBytes = dibsection.dsBm.bmWidthBytes;
-
- winDebug ("winMWExtWMStartDrawing - bytesPerRow: %d\n",
- (unsigned int)dibsection.dsBm.bmWidthBytes);
-
- /* Free the old shadow bitmap */
- DeleteObject (pRLWinPriv->hdcShadow);
- DeleteObject (pRLWinPriv->hbmpShadow);
-
- pRLWinPriv->hdcShadow = hdcNew;
- pRLWinPriv->hbmpShadow = hbmpNew;
-
- pRLWinPriv->fResized = FALSE;
- winDebug ("winMWExtWMStartDrawing - 0x%08x %d\n",
- (unsigned int)pRLWinPriv->pfb,
- (unsigned int)dibsection.dsBm.bmWidthBytes);
- }
- }
- else
- {
- ErrorF ("winMWExtWMStartDrawing - Already window was destroyed \n");
- }
- winDebug ("winMWExtWMStartDrawing - done (0x%08x) 0x%08x %d\n",
- (int) pRLWinPriv,
- (unsigned int)pRLWinPriv->pfb, (unsigned int)pRLWinPriv->dwWidthBytes);
- *pixelData = pRLWinPriv->pfb;
- *bytesPerRow = pRLWinPriv->dwWidthBytes;
-}
-
-void
-winMWExtWMStopDrawing (RootlessFrameID wid, Bool fFlush)
-{
-}
-
-void
-winMWExtWMUpdateRegion (RootlessFrameID wid, RegionPtr pDamage)
-{
- win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
- if (!g_fNoConfigureWindow) UpdateWindow (pRLWinPriv->hWnd);
-}
-
-void
-winMWExtWMDamageRects (RootlessFrameID wid, int nCount, const BoxRec *pRects,
- int shift_x, int shift_y)
-{
- win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
- const BoxRec *pEnd;
- winDebug ("winMWExtWMDamageRects (%08x, %d, %08x, %d, %d)\n",
- pRLWinPriv, nCount, pRects, shift_x, shift_y);
-
- for (pEnd = pRects + nCount; pRects < pEnd; pRects++) {
- RECT rcDmg;
- rcDmg.left = pRects->x1 + shift_x;
- rcDmg.top = pRects->y1 + shift_y;
- rcDmg.right = pRects->x2 + shift_x;
- rcDmg.bottom = pRects->y2 + shift_y;
-
- InvalidateRect (pRLWinPriv->hWnd, &rcDmg, FALSE);
- }
-}
-
-void
-winMWExtWMRootlessSwitchWindow (RootlessWindowPtr pFrame, WindowPtr oldWin)
-{
- win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) pFrame->wid;
- winDebug ("winMWExtWMRootlessSwitchWindow (%08x) %08x\n",
- (int) pRLWinPriv, (int) pRLWinPriv->hWnd);
- pRLWinPriv->pFrame = pFrame;
- pRLWinPriv->fResized = TRUE;
-
- /* Set the window extended style flags */
- SetWindowLongPtr (pRLWinPriv->hWnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
-
- /* Set the window standard style flags */
- SetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE,
- WS_POPUP | WS_CLIPCHILDREN);
-
- DeleteProperty (serverClient, oldWin, AtmWindowsWmNativeHwnd ());
- winMWExtWMSetNativeProperty (pFrame);
-}
-
-void
-winMWExtWMCopyBytes (unsigned int width, unsigned int height,
- const void *src, unsigned int srcRowBytes,
- void *dst, unsigned int dstRowBytes)
-{
- winDebug ("winMWExtWMCopyBytes - Not implemented\n");
-}
-
-void
-winMWExtWMCopyWindow (RootlessFrameID wid, int nDstRects, const BoxRec *pDstRects,
- int nDx, int nDy)
-{
- win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
- const BoxRec *pEnd;
- RECT rcDmg;
- winDebug ("winMWExtWMCopyWindow (%08x, %d, %08x, %d, %d)\n",
- (int) pRLWinPriv, nDstRects, (int) pDstRects, nDx, nDy);
-
- for (pEnd = pDstRects + nDstRects; pDstRects < pEnd; pDstRects++)
- {
- 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);
-
- if (!BitBlt (pRLWinPriv->hdcShadow,
- pDstRects->x1, pDstRects->y1,
- pDstRects->x2 - pDstRects->x1,
- pDstRects->y2 - pDstRects->y1,
- pRLWinPriv->hdcShadow,
- pDstRects->x1 + nDx, pDstRects->y1 + nDy,
- SRCCOPY))
- {
- ErrorF ("winMWExtWMCopyWindow - BitBlt failed.\n");
- }
-
- rcDmg.left = pDstRects->x1;
- rcDmg.top = pDstRects->y1;
- rcDmg.right = pDstRects->x2;
- rcDmg.bottom = pDstRects->y2;
-
- InvalidateRect (pRLWinPriv->hWnd, &rcDmg, FALSE);
- }
- winDebug ("winMWExtWMCopyWindow - done\n");
-}
-
-
-/*
- * winMWExtWMSetNativeProperty
- */
-
-static void
-winMWExtWMSetNativeProperty (RootlessWindowPtr pFrame)
-{
- win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) pFrame->wid;
- long lData;
-
- /* FIXME: move this to WindowsWM extension */
-
- lData = (long) pRLWinPriv->hWnd;
- dixChangeWindowProperty(serverClient, pFrame->win, AtmWindowsWmNativeHwnd(),
- XA_INTEGER, 32, PropModeReplace, 1, &lData, 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: Kensuke Matsuzaki
+ * Earle F. Philhower, III
+ * Harold L Hunt II
+ */
+/*
+ * Look at hw/darwin/quartz/xpr/xprFrame.c and hw/darwin/quartz/cr/crFrame.c
+ */
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+#include <winuser.h>
+#define _WINDOWSWM_SERVER_
+#include <X11/extensions/windowswmstr.h>
+#include "dixevents.h"
+#include "winmultiwindowclass.h"
+#include <X11/Xatom.h>
+
+
+/*
+ * Constant defines
+ */
+
+#ifndef ULW_COLORKEY
+#define ULW_COLORKEY 0x00000001
+#endif
+#ifndef ULW_ALPHA
+#define ULW_ALPHA 0x00000002
+#endif
+#ifndef ULW_OPAQUE
+#define ULW_OPAQUE 0x00000004
+#endif
+#define AC_SRC_ALPHA 0x01
+
+/*
+ * Local function
+ */
+
+DEFINE_ATOM_HELPER(AtmWindowsWmNativeHwnd, WINDOWSWM_NATIVE_HWND)
+static void
+winMWExtWMSetNativeProperty (RootlessWindowPtr pFrame);
+
+/*
+ * Global variables
+ */
+
+Bool g_fNoConfigureWindow = FALSE;
+
+/*
+ * Internal function to get the DIB format that is compatible with the screen
+ * Fixme: Share code with winshadgdi.c
+ */
+
+static
+Bool
+winMWExtWMQueryDIBFormat (win32RootlessWindowPtr pRLWinPriv, BITMAPINFOHEADER *pbmih)
+{
+ HBITMAP hbmp;
+#ifdef _DEBUG
+ LPDWORD pdw = NULL;
+#endif
+
+ /* Create a memory bitmap compatible with the screen */
+ hbmp = CreateCompatibleBitmap (pRLWinPriv->hdcScreen, 1, 1);
+ if (hbmp == NULL)
+ {
+ ErrorF ("winMWExtWMQueryDIBFormat - CreateCompatibleBitmap failed\n");
+ return FALSE;
+ }
+
+ /* Initialize our bitmap info header */
+ ZeroMemory (pbmih, sizeof (BITMAPINFOHEADER) + 256 * sizeof (RGBQUAD));
+ pbmih->biSize = sizeof (BITMAPINFOHEADER);
+
+ /* Get the biBitCount */
+ if (!GetDIBits (pRLWinPriv->hdcScreen,
+ hbmp,
+ 0, 1,
+ NULL,
+ (BITMAPINFO*) pbmih,
+ DIB_RGB_COLORS))
+ {
+ ErrorF ("winMWExtWMQueryDIBFormat - First call to GetDIBits failed\n");
+ DeleteObject (hbmp);
+ return FALSE;
+ }
+
+#ifdef _DEBUG
+ /* Get a pointer to bitfields */
+ pdw = (DWORD*) ((CARD8*)pbmih + sizeof (BITMAPINFOHEADER));
+
+ winDebug ("winMWExtWMQueryDIBFormat - First call masks: %08x %08x %08x\n",
+ (unsigned int)pdw[0], (unsigned int)pdw[1], (unsigned int)pdw[2]);
+#endif
+
+ /* Get optimal color table, or the optimal bitfields */
+ if (!GetDIBits (pRLWinPriv->hdcScreen,
+ hbmp,
+ 0, 1,
+ NULL,
+ (BITMAPINFO*)pbmih,
+ DIB_RGB_COLORS))
+ {
+ ErrorF ("winMWExtWMQueryDIBFormat - Second call to GetDIBits "
+ "failed\n");
+ DeleteObject (hbmp);
+ return FALSE;
+ }
+
+ /* Free memory */
+ DeleteObject (hbmp);
+
+ return TRUE;
+}
+
+static HRGN
+winMWExtWMCreateRgnFromRegion (RegionPtr pShape)
+{
+ int nRects;
+ BoxPtr pRects, pEnd;
+ HRGN hRgn, hRgnRect;
+
+ if (pShape == NULL) return NULL;
+
+ nRects = RegionNumRects(pShape);
+ pRects = RegionRects(pShape);
+
+ hRgn = CreateRectRgn (0, 0, 0, 0);
+ if (hRgn == NULL)
+ {
+ ErrorF ("winReshape - Initial CreateRectRgn (%d, %d, %d, %d) "
+ "failed: %d\n",
+ 0, 0, 0, 0, (int) GetLastError ());
+ }
+
+ /* Loop through all rectangles in the X region */
+ for (pEnd = pRects + nRects; pRects < pEnd; pRects++)
+ {
+ /* Create a Windows region for the X rectangle */
+ hRgnRect = CreateRectRgn (pRects->x1,
+ pRects->y1,
+ pRects->x2,
+ pRects->y2);
+ if (hRgnRect == NULL)
+ {
+ ErrorF ("winReshape - Loop CreateRectRgn (%d, %d, %d, %d) "
+ "failed: %d\n",
+ pRects->x1,
+ pRects->y1,
+ pRects->x2,
+ pRects->y2,
+ (int) GetLastError ());
+ }
+
+ /* Merge the Windows region with the accumulated region */
+ if (CombineRgn (hRgn, hRgn, hRgnRect, RGN_OR) == ERROR)
+ {
+ ErrorF ("winReshape - CombineRgn () failed: %d\n",
+ (int) GetLastError ());
+ }
+
+ /* Delete the temporary Windows region */
+ DeleteObject (hRgnRect);
+ }
+
+ return hRgn;
+}
+
+static void
+InitWin32RootlessEngine (win32RootlessWindowPtr pRLWinPriv)
+{
+ pRLWinPriv->hdcScreen = GetDC (pRLWinPriv->hWnd);
+ pRLWinPriv->hdcShadow = CreateCompatibleDC (pRLWinPriv->hdcScreen);
+ pRLWinPriv->hbmpShadow = NULL;
+
+ /* Allocate bitmap info header */
+ pRLWinPriv->pbmihShadow = (BITMAPINFOHEADER*) malloc (sizeof (BITMAPINFOHEADER)
+ + 256 * sizeof (RGBQUAD));
+ if (pRLWinPriv->pbmihShadow == NULL)
+ {
+ ErrorF ("InitWin32RootlessEngine - malloc () failed\n");
+ return;
+ }
+
+ /* Query the screen format */
+ winMWExtWMQueryDIBFormat (pRLWinPriv,
+ pRLWinPriv->pbmihShadow);
+}
+
+Bool
+winMWExtWMCreateFrame (RootlessWindowPtr pFrame, ScreenPtr pScreen,
+ int newX, int newY, RegionPtr pShape)
+{
+#define CLASS_NAME_LENGTH 512
+ Bool fResult = TRUE;
+ win32RootlessWindowPtr pRLWinPriv;
+ WNDCLASSEX wc;
+ char pszClass[CLASS_NAME_LENGTH], pszWindowID[12];
+ HICON hIcon;
+ HICON hIconSmall;
+ char *res_name, *res_class, *res_role;
+ static int s_iWindowID = 0;
+
+ winDebug ("winMWExtWMCreateFrame %d %d - %d %d\n",
+ newX, newY, pFrame->width, pFrame->height);
+
+ pRLWinPriv = (win32RootlessWindowPtr) malloc (sizeof (win32RootlessWindowRec));
+ pRLWinPriv->pFrame = pFrame;
+ pRLWinPriv->pfb = NULL;
+ pRLWinPriv->hbmpShadow = NULL;
+ pRLWinPriv->hdcShadow = NULL;
+ pRLWinPriv->hdcScreen = NULL;
+ pRLWinPriv->pbmihShadow = NULL;
+ pRLWinPriv->fResized = TRUE;
+ pRLWinPriv->fClose = FALSE;
+ pRLWinPriv->fRestackingNow = FALSE;
+ pRLWinPriv->fDestroyed = FALSE;
+ pRLWinPriv->fMovingOrSizing = FALSE;
+
+ // Store the implementation private frame ID
+ pFrame->wid = (RootlessFrameID) pRLWinPriv;
+
+ winSelectIcons(pFrame->win, &hIcon, &hIconSmall);
+
+ /* Set standard class name prefix so we can identify window easily */
+ strncpy (pszClass, WINDOW_CLASS_X, sizeof(pszClass));
+
+ if (winMultiWindowGetClassHint (pFrame->win, &res_name, &res_class))
+ {
+ strncat (pszClass, "-", 1);
+ strncat (pszClass, res_name, CLASS_NAME_LENGTH - strlen (pszClass));
+ strncat (pszClass, "-", 1);
+ strncat (pszClass, res_class, CLASS_NAME_LENGTH - strlen (pszClass));
+
+ /* Check if a window class is provided by the WM_WINDOW_ROLE property,
+ * if not use the WM_CLASS information.
+ * For further information see:
+ * http://tronche.com/gui/x/icccm/sec-5.html
+ */
+ if (winMultiWindowGetWindowRole (pFrame->win, &res_role) )
+ {
+ strcat (pszClass, "-");
+ strcat (pszClass, res_role);
+ free (res_role);
+ }
+
+ free (res_name);
+ free (res_class);
+ }
+
+ /* Add incrementing window ID to make unique class name */
+ snprintf (pszWindowID, sizeof(pszWindowID), "-%x", s_iWindowID++);
+ pszWindowID[sizeof(pszWindowID)-1] = 0;
+ strcat (pszClass, pszWindowID);
+
+ winDebug ("winCreateWindowsWindow - Creating class: %s\n", pszClass);
+
+ /* Setup our window class */
+ wc.cbSize = sizeof(wc);
+ wc.style = CS_HREDRAW | CS_VREDRAW;
+ wc.lpfnWndProc = winMWExtWMWindowProc;
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 0;
+ wc.hInstance = g_hInstance;
+ wc.hIcon = hIcon;
+ wc.hIconSm = hIconSmall;
+ wc.hCursor = 0;
+ wc.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
+ wc.lpszMenuName = NULL;
+ wc.lpszClassName = pszClass;
+ RegisterClassEx (&wc);
+
+ /* Create the window */
+ g_fNoConfigureWindow = TRUE;
+ pRLWinPriv->hWnd = CreateWindowExA (WS_EX_TOOLWINDOW, /* Extended styles */
+ pszClass, /* Class name */
+ WINDOW_TITLE_X, /* Window name */
+ WS_POPUP | WS_CLIPCHILDREN,
+ newX, /* Horizontal position */
+ newY, /* Vertical position */
+ pFrame->width, /* Right edge */
+ pFrame->height, /* Bottom edge */
+ (HWND) NULL, /* No parent or owner window */
+ (HMENU) NULL, /* No menu */
+ GetModuleHandle (NULL), /* Instance handle */
+ pRLWinPriv); /* ScreenPrivates */
+ if (pRLWinPriv->hWnd == NULL)
+ {
+ ErrorF ("winMWExtWMCreateFrame - CreateWindowExA () failed: %d\n",
+ (int) GetLastError ());
+ fResult = FALSE;
+ }
+
+ winDebug ("winMWExtWMCreateFrame - ShowWindow\n");
+
+ //ShowWindow (pRLWinPriv->hWnd, SW_SHOWNOACTIVATE);
+ g_fNoConfigureWindow = FALSE;
+
+ if (pShape != NULL)
+ {
+ winMWExtWMReshapeFrame (pFrame->wid, pShape);
+ }
+
+ winDebug ("winMWExtWMCreateFrame - (%08x) %08x\n",
+ (int) pFrame->wid, (int) pRLWinPriv->hWnd);
+
+ winMWExtWMSetNativeProperty (pFrame);
+
+ return fResult;
+}
+
+void
+winMWExtWMDestroyFrame (RootlessFrameID wid)
+{
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
+ HICON hIcon;
+ HICON hIconSm;
+ HMODULE hInstance;
+ int iReturn;
+ char pszClass[CLASS_NAME_LENGTH];
+
+ winDebug ("winMWExtWMDestroyFrame (%08x) %08x\n",
+ (int) pRLWinPriv, (int) pRLWinPriv->hWnd);
+
+ /* Store the info we need to destroy after this window is gone */
+ hInstance = (HINSTANCE) GetClassLongPtr (pRLWinPriv->hWnd, GCLP_HMODULE);
+ hIcon = (HICON)SendMessage(pRLWinPriv->hWnd, WM_GETICON, ICON_BIG, 0);
+ hIconSm = (HICON)SendMessage(pRLWinPriv->hWnd, WM_GETICON, ICON_SMALL, 0);
+ iReturn = GetClassName (pRLWinPriv->hWnd, pszClass, CLASS_NAME_LENGTH);
+
+ pRLWinPriv->fClose = TRUE;
+ pRLWinPriv->fDestroyed = TRUE;
+
+ /* Destroy the Windows window */
+ DestroyWindow (pRLWinPriv->hWnd);
+
+ /* Only if we were able to get the name */
+ if (iReturn)
+ {
+ winDebug ("winMWExtWMDestroyFrame - Unregistering %s: ", pszClass);
+ iReturn = UnregisterClass (pszClass, hInstance);
+
+ winDebug ("winMWExtWMDestroyFramew - Deleting Icon\n");
+ }
+
+ winDestroyIcon(hiconClass);
+ winDestroyIcon(hiconSmClass);
+
+ winDebug ("winMWExtWMDestroyFrame - done\n");
+}
+
+void
+winMWExtWMMoveFrame (RootlessFrameID wid, ScreenPtr pScreen, int iNewX, int iNewY)
+{
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
+ RECT rcNew;
+ DWORD dwExStyle;
+ DWORD dwStyle;
+ int iX, iY, iWidth, iHeight;
+
+ winDebug ("winMWExtWMMoveFrame (%08x) (%d %d)\n", (int) pRLWinPriv, iNewX, iNewY);
+
+ /* Get the Windows window style and extended style */
+ dwExStyle = GetWindowLongPtr (pRLWinPriv->hWnd, GWL_EXSTYLE);
+ dwStyle = GetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE);
+
+ /* Get the X and Y location of the X window */
+ iX = iNewX + GetSystemMetrics (SM_XVIRTUALSCREEN);
+ iY = iNewY + GetSystemMetrics (SM_YVIRTUALSCREEN);
+
+ /* Get the height and width of the X window */
+ iWidth = pRLWinPriv->pFrame->width;
+ iHeight = pRLWinPriv->pFrame->height;
+
+ /* Store the origin, height, and width in a rectangle structure */
+ SetRect (&rcNew, iX, iY, iX + iWidth, iY + iHeight);
+
+ winDebug("\tWindow {%d, %d, %d, %d}, {%d, %d}\n",
+ rcNew.left, rcNew.top, rcNew.right, rcNew.bottom,
+ rcNew.right - rcNew.left, rcNew.bottom - rcNew.top);
+ /*
+ * Calculate the required size of the Windows window rectangle,
+ * given the size of the Windows window client area.
+ */
+ AdjustWindowRectEx (&rcNew, dwStyle, FALSE, dwExStyle);
+
+ winDebug("\tAdjusted {%d, %d, %d, %d}, {%d, %d}\n",
+ rcNew.left, rcNew.top, rcNew.right, rcNew.bottom,
+ rcNew.right - rcNew.left, rcNew.bottom - rcNew.top);
+ g_fNoConfigureWindow = TRUE;
+ SetWindowPos (pRLWinPriv->hWnd, NULL, rcNew.left, rcNew.top, 0, 0,
+ SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER);
+ g_fNoConfigureWindow = FALSE;
+ winDebug ("winMWExtWMMoveFrame (%08x) done\n", (int) pRLWinPriv);
+}
+
+void
+winMWExtWMResizeFrame (RootlessFrameID wid, ScreenPtr pScreen,
+ int iNewX, int iNewY,
+ unsigned int uiNewWidth, unsigned int uiNewHeight,
+ unsigned int uiGravity)
+{
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
+ RECT rcNew;
+ RECT rcOld;
+ DWORD dwExStyle;
+ DWORD dwStyle;
+ int iX, iY;
+
+ winDebug ("winMWExtWMResizeFrame (%08x) (%d %d)-(%d %d)\n",
+ (int) pRLWinPriv, iNewX, iNewY, uiNewWidth, uiNewHeight);
+
+ pRLWinPriv->fResized = TRUE;
+
+ /* Get the Windows window style and extended style */
+ dwExStyle = GetWindowLongPtr (pRLWinPriv->hWnd, GWL_EXSTYLE);
+ dwStyle = GetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE);
+
+ /* Get the X and Y location of the X window */
+ iX = iNewX + GetSystemMetrics (SM_XVIRTUALSCREEN);
+ iY = iNewY + GetSystemMetrics (SM_YVIRTUALSCREEN);
+
+ /* Store the origin, height, and width in a rectangle structure */
+ SetRect (&rcNew, iX, iY, iX + uiNewWidth, iY + uiNewHeight);
+
+ /*
+ * 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 (pRLWinPriv->hWnd, &rcOld);
+
+ /* Check if the old rectangle and new rectangle are the same */
+ if (!EqualRect (&rcNew, &rcOld))
+ {
+
+ g_fNoConfigureWindow = TRUE;
+ MoveWindow (pRLWinPriv->hWnd,
+ rcNew.left, rcNew.top,
+ rcNew.right - rcNew.left, rcNew.bottom - rcNew.top,
+ TRUE);
+ g_fNoConfigureWindow = FALSE;
+ }
+}
+
+void
+winMWExtWMRestackFrame (RootlessFrameID wid, RootlessFrameID nextWid)
+{
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
+ win32RootlessWindowPtr pRLNextWinPriv = (win32RootlessWindowPtr) nextWid;
+ winScreenPriv(pRLWinPriv->pFrame->win->drawable.pScreen);
+ winScreenInfo *pScreenInfo = NULL;
+ DWORD dwCurrentProcessID = GetCurrentProcessId ();
+ DWORD dwWindowProcessID = 0;
+ HWND hWnd;
+ Bool fFirst = TRUE;
+ Bool fNeedRestack = TRUE;
+
+ winDebug ("winMWExtWMRestackFrame (%08x)\n", (int) pRLWinPriv);
+
+
+ if (pScreenPriv->fRestacking) return;
+
+ if (pScreenPriv) pScreenInfo = pScreenPriv->pScreenInfo;
+
+ pRLWinPriv->fRestackingNow = TRUE;
+
+ /* Show window */
+ if(!IsWindowVisible (pRLWinPriv->hWnd))
+ ShowWindow (pRLWinPriv->hWnd, SW_SHOWNOACTIVATE);
+
+ if (pRLNextWinPriv == NULL)
+ {
+ winDebug ("Win %08x is top\n", pRLWinPriv);
+ pScreenPriv->widTop = wid;
+ SetWindowPos (pRLWinPriv->hWnd, HWND_TOP,
+ 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
+ }
+#ifdef XWIN_MULTIWINDOWINTWM
+ else if (winIsInternalWMRunning(pScreenInfo))
+ {
+ /* using mulwinidow wm */
+ winDebug ("Win %08x is not top\n", pRLWinPriv);
+
+ for (hWnd = GetNextWindow (pRLWinPriv->hWnd, GW_HWNDPREV);
+ fNeedRestack && hWnd != NULL;
+ hWnd = GetNextWindow (hWnd, GW_HWNDPREV))
+ {
+ GetWindowThreadProcessId (hWnd, &dwWindowProcessID);
+
+ if ((dwWindowProcessID == dwCurrentProcessID)
+ && GetProp (hWnd, WIN_WINDOW_PROP))
+ {
+ if (hWnd == pRLNextWinPriv->hWnd)
+ {
+ /* Enable interleave X window and Windows window */
+ if (!fFirst)
+ {
+ winDebug ("raise: Insert after Win %08x\n", pRLNextWinPriv);
+
+ SetWindowPos (pRLWinPriv->hWnd, pRLNextWinPriv->hWnd,
+ 0, 0, 0, 0,
+ SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
+ }
+ else
+ {
+ winDebug ("No change\n");
+ }
+ fNeedRestack = FALSE;
+ break;
+ }
+ if (fFirst) fFirst = FALSE;
+ }
+ }
+
+ for (hWnd = GetNextWindow (pRLWinPriv->hWnd, GW_HWNDNEXT);
+ fNeedRestack && hWnd != NULL;
+ hWnd = GetNextWindow (hWnd, GW_HWNDNEXT))
+ {
+ GetWindowThreadProcessId (hWnd, &dwWindowProcessID);
+
+ if ((dwWindowProcessID == dwCurrentProcessID)
+ && GetProp (hWnd, WIN_WINDOW_PROP))
+ {
+ if (hWnd == pRLNextWinPriv->hWnd)
+ {
+ winDebug ("lower: Insert after Win %08x\n", pRLNextWinPriv);
+
+ SetWindowPos (pRLWinPriv->hWnd, pRLNextWinPriv->hWnd,
+ 0, 0, 0, 0,
+ SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
+ fNeedRestack = FALSE;
+ break;
+ }
+ }
+ }
+ }
+#endif
+ else
+ {
+ /* using general wm like twm, wmaker etc.
+ Interleave X window and Windows window will cause problem. */
+ SetWindowPos (pRLWinPriv->hWnd, pRLNextWinPriv->hWnd,
+ 0, 0, 0, 0,
+ SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
+ }
+ winDebug ("winMWExtWMRestackFrame - done (%08x)\n", (int) pRLWinPriv);
+
+ pRLWinPriv->fRestackingNow = FALSE;
+}
+
+void
+winMWExtWMReshapeFrame (RootlessFrameID wid, RegionPtr pShape)
+{
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
+ HRGN hRgn, hRgnWindow, hRgnClient;
+ RECT rcWindow, rcClient;
+
+ winDebug ("winMWExtWMReshapeFrame (%08x)\n", (int) pRLWinPriv);
+
+ hRgn = winMWExtWMCreateRgnFromRegion (pShape);
+
+ /* Create region for non-client area */
+ GetWindowRect (pRLWinPriv->hWnd, &rcWindow);
+ GetClientRect (pRLWinPriv->hWnd, &rcClient);
+ MapWindowPoints (pRLWinPriv->hWnd, HWND_DESKTOP, (LPPOINT)&rcClient, 2);
+ OffsetRgn (hRgn, rcClient.left - rcWindow.left, rcClient.top - rcWindow.top);
+ OffsetRect (&rcClient, -rcWindow.left, -rcWindow.top);
+ OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
+ hRgnWindow = CreateRectRgnIndirect (&rcWindow);
+ hRgnClient = CreateRectRgnIndirect (&rcClient);
+ CombineRgn (hRgnWindow, hRgnWindow, hRgnClient, RGN_DIFF);
+ CombineRgn (hRgn, hRgnWindow, hRgn, RGN_OR);
+
+
+ SetWindowRgn (pRLWinPriv->hWnd, hRgn, TRUE);
+
+ DeleteObject (hRgnWindow);
+ DeleteObject (hRgnClient);
+}
+
+void
+winMWExtWMUnmapFrame (RootlessFrameID wid)
+{
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
+
+ winDebug ("winMWExtWMUnmapFrame (%08x)\n", (int) pRLWinPriv);
+
+ g_fNoConfigureWindow = TRUE;
+ //ShowWindow (pRLWinPriv->hWnd, SW_MINIMIZE);
+ ShowWindow (pRLWinPriv->hWnd, SW_HIDE);
+ g_fNoConfigureWindow = FALSE;
+}
+
+/*
+ * Fixme: Code sharing with winshadgdi.c and other engine support
+ */
+void
+winMWExtWMStartDrawing (RootlessFrameID wid, char **pixelData, int *bytesPerRow)
+{
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
+ winPrivScreenPtr pScreenPriv = NULL;
+ winScreenInfo *pScreenInfo = NULL;
+ ScreenPtr pScreen = NULL;
+ DIBSECTION dibsection;
+ Bool fReturn = TRUE;
+ HDC hdcNew;
+ HBITMAP hbmpNew;
+
+ winDebug ("winMWExtWMStartDrawing (%08x) %08x\n", (int) pRLWinPriv, pRLWinPriv->fDestroyed);
+
+ if (!pRLWinPriv->fDestroyed)
+ {
+ pScreen = pRLWinPriv->pFrame->win->drawable.pScreen;
+ if (pScreen) pScreenPriv = winGetScreenPriv(pScreen);
+ if (pScreenPriv) pScreenInfo = pScreenPriv->pScreenInfo;
+
+ winDebug ("\tpScreenPriv %08X\n", (int) pScreenPriv);
+ winDebug ("\tpScreenInfo %08X\n", (int) pScreenInfo);
+ winDebug ("\t(%d, %d)\n", (int)pRLWinPriv->pFrame->width,
+ (int) pRLWinPriv->pFrame->height);
+
+ if (pRLWinPriv->hdcScreen == NULL)
+ {
+ InitWin32RootlessEngine (pRLWinPriv);
+ }
+
+ if (pRLWinPriv->fResized)
+ {
+ /* width * bpp must be multiple of 4 to match 32bit alignment */
+ int stridesize;
+ int misalignment;
+
+ pRLWinPriv->pbmihShadow->biWidth = pRLWinPriv->pFrame->width;
+ pRLWinPriv->pbmihShadow->biHeight = -pRLWinPriv->pFrame->height;
+
+ stridesize = pRLWinPriv->pFrame->width * (pScreenInfo->dwBPP >> 3);
+ misalignment = stridesize & 3;
+ if (misalignment != 0)
+ {
+ stridesize += 4 - misalignment;
+ pRLWinPriv->pbmihShadow->biWidth = stridesize / (pScreenInfo->dwBPP >> 3);
+ winDebug("\tresizing to %d (was %d)\n",
+ pRLWinPriv->pbmihShadow->biWidth, pRLWinPriv->pFrame->width);
+ }
+
+ hdcNew = CreateCompatibleDC (pRLWinPriv->hdcScreen);
+ /* Create a DI shadow bitmap with a bit pointer */
+ hbmpNew = CreateDIBSection (pRLWinPriv->hdcScreen,
+ (BITMAPINFO *) pRLWinPriv->pbmihShadow,
+ DIB_RGB_COLORS,
+ (VOID**) &pRLWinPriv->pfb,
+ NULL,
+ 0);
+ if (hbmpNew == NULL || pRLWinPriv->pfb == NULL)
+ {
+ ErrorF ("winMWExtWMStartDrawing - CreateDIBSection failed\n");
+ //return FALSE;
+ }
+ else
+ {
+ winDebug ("winMWExtWMStartDrawing - Shadow buffer allocated\n");
+ }
+
+ /* Get information about the bitmap that was allocated */
+ GetObject (hbmpNew, sizeof (dibsection), &dibsection);
+
+ /* Print information about bitmap allocated */
+ winDebug ("winMWExtWMStartDrawing - Dibsection width: %d height: %d "
+ "depth: %d size image: %d\n",
+ (unsigned int)dibsection.dsBmih.biWidth,
+ (unsigned int)dibsection.dsBmih.biHeight,
+ (unsigned int)dibsection.dsBmih.biBitCount,
+ (unsigned int)dibsection.dsBmih.biSizeImage);
+
+ /* Select the shadow bitmap into the shadow DC */
+ SelectObject (hdcNew, hbmpNew);
+
+ winDebug ("winMWExtWMStartDrawing - Attempting a shadow blit\n");
+
+ /* Blit from the old shadow to the new shadow */
+ fReturn = BitBlt (hdcNew,
+ 0, 0,
+ pRLWinPriv->pFrame->width, pRLWinPriv->pFrame->height,
+ pRLWinPriv->hdcShadow,
+ 0, 0,
+ SRCCOPY);
+ if (fReturn)
+ {
+ winDebug ("winMWExtWMStartDrawing - Shadow blit success\n");
+ }
+ else
+ {
+ ErrorF ("winMWExtWMStartDrawing - Shadow blit failure\n");
+ }
+
+ /* Look for height weirdness */
+ if (dibsection.dsBmih.biHeight < 0)
+ {
+ /* FIXME: Figure out why biHeight is sometimes negative */
+ ErrorF ("winMWExtWMStartDrawing - WEIRDNESS - "
+ "biHeight still negative: %d\n",
+ (int) dibsection.dsBmih.biHeight);
+ ErrorF ("winMWExtWMStartDrawing - WEIRDNESS - "
+ "Flipping biHeight sign\n");
+ dibsection.dsBmih.biHeight = -dibsection.dsBmih.biHeight;
+ }
+
+ pRLWinPriv->dwWidthBytes = dibsection.dsBm.bmWidthBytes;
+
+ winDebug ("winMWExtWMStartDrawing - bytesPerRow: %d\n",
+ (unsigned int)dibsection.dsBm.bmWidthBytes);
+
+ /* Free the old shadow bitmap */
+ DeleteObject (pRLWinPriv->hdcShadow);
+ DeleteObject (pRLWinPriv->hbmpShadow);
+
+ pRLWinPriv->hdcShadow = hdcNew;
+ pRLWinPriv->hbmpShadow = hbmpNew;
+
+ pRLWinPriv->fResized = FALSE;
+ winDebug ("winMWExtWMStartDrawing - 0x%08x %d\n",
+ (unsigned int)pRLWinPriv->pfb,
+ (unsigned int)dibsection.dsBm.bmWidthBytes);
+ }
+ }
+ else
+ {
+ ErrorF ("winMWExtWMStartDrawing - Already window was destroyed \n");
+ }
+ winDebug ("winMWExtWMStartDrawing - done (0x%08x) 0x%08x %d\n",
+ (int) pRLWinPriv,
+ (unsigned int)pRLWinPriv->pfb, (unsigned int)pRLWinPriv->dwWidthBytes);
+ *pixelData = pRLWinPriv->pfb;
+ *bytesPerRow = pRLWinPriv->dwWidthBytes;
+}
+
+void
+winMWExtWMStopDrawing (RootlessFrameID wid, Bool fFlush)
+{
+}
+
+void
+winMWExtWMUpdateRegion (RootlessFrameID wid, RegionPtr pDamage)
+{
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
+ if (!g_fNoConfigureWindow) UpdateWindow (pRLWinPriv->hWnd);
+}
+
+void
+winMWExtWMDamageRects (RootlessFrameID wid, int nCount, const BoxRec *pRects,
+ int shift_x, int shift_y)
+{
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
+ const BoxRec *pEnd;
+ winDebug ("winMWExtWMDamageRects (%08x, %d, %08x, %d, %d)\n",
+ pRLWinPriv, nCount, pRects, shift_x, shift_y);
+
+ for (pEnd = pRects + nCount; pRects < pEnd; pRects++) {
+ RECT rcDmg;
+ rcDmg.left = pRects->x1 + shift_x;
+ rcDmg.top = pRects->y1 + shift_y;
+ rcDmg.right = pRects->x2 + shift_x;
+ rcDmg.bottom = pRects->y2 + shift_y;
+
+ InvalidateRect (pRLWinPriv->hWnd, &rcDmg, FALSE);
+ }
+}
+
+void
+winMWExtWMRootlessSwitchWindow (RootlessWindowPtr pFrame, WindowPtr oldWin)
+{
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) pFrame->wid;
+ winDebug ("winMWExtWMRootlessSwitchWindow (%08x) %08x\n",
+ (int) pRLWinPriv, (int) pRLWinPriv->hWnd);
+ pRLWinPriv->pFrame = pFrame;
+ pRLWinPriv->fResized = TRUE;
+
+ /* Set the window extended style flags */
+ SetWindowLongPtr (pRLWinPriv->hWnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
+
+ /* Set the window standard style flags */
+ SetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE,
+ WS_POPUP | WS_CLIPCHILDREN);
+
+ DeleteProperty (serverClient, oldWin, AtmWindowsWmNativeHwnd ());
+ winMWExtWMSetNativeProperty (pFrame);
+}
+
+void
+winMWExtWMCopyBytes (unsigned int width, unsigned int height,
+ const void *src, unsigned int srcRowBytes,
+ void *dst, unsigned int dstRowBytes)
+{
+ winDebug ("winMWExtWMCopyBytes - Not implemented\n");
+}
+
+void
+winMWExtWMCopyWindow (RootlessFrameID wid, int nDstRects, const BoxRec *pDstRects,
+ int nDx, int nDy)
+{
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
+ const BoxRec *pEnd;
+ RECT rcDmg;
+ winDebug ("winMWExtWMCopyWindow (%08x, %d, %08x, %d, %d)\n",
+ (int) pRLWinPriv, nDstRects, (int) pDstRects, nDx, nDy);
+
+ for (pEnd = pDstRects + nDstRects; pDstRects < pEnd; pDstRects++)
+ {
+ 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);
+
+ if (!BitBlt (pRLWinPriv->hdcShadow,
+ pDstRects->x1, pDstRects->y1,
+ pDstRects->x2 - pDstRects->x1,
+ pDstRects->y2 - pDstRects->y1,
+ pRLWinPriv->hdcShadow,
+ pDstRects->x1 + nDx, pDstRects->y1 + nDy,
+ SRCCOPY))
+ {
+ ErrorF ("winMWExtWMCopyWindow - BitBlt failed.\n");
+ }
+
+ rcDmg.left = pDstRects->x1;
+ rcDmg.top = pDstRects->y1;
+ rcDmg.right = pDstRects->x2;
+ rcDmg.bottom = pDstRects->y2;
+
+ InvalidateRect (pRLWinPriv->hWnd, &rcDmg, FALSE);
+ }
+ winDebug ("winMWExtWMCopyWindow - done\n");
+}
+
+
+/*
+ * winMWExtWMSetNativeProperty
+ */
+
+static void
+winMWExtWMSetNativeProperty (RootlessWindowPtr pFrame)
+{
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) pFrame->wid;
+ long lData;
+
+ /* FIXME: move this to WindowsWM extension */
+
+ lData = (long) pRLWinPriv->hWnd;
+ dixChangeWindowProperty(serverClient, pFrame->win, AtmWindowsWmNativeHwnd(),
+ XA_INTEGER, 32, PropModeReplace, 1, &lData, TRUE);
+}