aboutsummaryrefslogtreecommitdiff
path: root/xorg-server
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2010-10-19 21:03:53 +0000
committermarha <marha@users.sourceforge.net>2010-10-19 21:03:53 +0000
commitbe10ad8a9efe4131c14c2dde36adaf11e7b125aa (patch)
tree0a0f9305b181d427c5581f7a072e69e52199bdbb /xorg-server
parent2197318e5fc026ee57325ce953113d1963e7dc82 (diff)
parent6ab3babba7b1b74528c2194a495fa1e2e67faa55 (diff)
downloadvcxsrv-be10ad8a9efe4131c14c2dde36adaf11e7b125aa.tar.gz
vcxsrv-be10ad8a9efe4131c14c2dde36adaf11e7b125aa.tar.bz2
vcxsrv-be10ad8a9efe4131c14c2dde36adaf11e7b125aa.zip
svn merge ^/branches/released .
Diffstat (limited to 'xorg-server')
-rw-r--r--xorg-server/composite/compalloc.c42
-rw-r--r--xorg-server/configure.ac7
-rw-r--r--xorg-server/dix/getevents.c24
-rw-r--r--xorg-server/hw/xfree86/common/xf86Config.c54
-rw-r--r--xorg-server/hw/xfree86/common/xf86Mode.c64
-rw-r--r--xorg-server/hw/xfree86/common/xf86Xinput.c35
-rw-r--r--xorg-server/hw/xfree86/common/xf86Xinput.h2
-rw-r--r--xorg-server/hw/xfree86/ddc/ddc.c4
-rw-r--r--xorg-server/hw/xfree86/doc/man/xorg.conf.man.pre6
-rw-r--r--xorg-server/hw/xfree86/os-support/shared/sigio.c627
-rw-r--r--xorg-server/hw/xfree86/parser/DRI.c310
-rw-r--r--xorg-server/hw/xfree86/parser/scan.c63
-rw-r--r--xorg-server/hw/xfree86/parser/xf86Parser.h11
-rw-r--r--xorg-server/hw/xfree86/parser/xf86tokens.h1
-rw-r--r--xorg-server/hw/xwin/InitInput.c15
-rw-r--r--xorg-server/hw/xwin/InitOutput.c46
-rw-r--r--xorg-server/hw/xwin/Makefile.am4
-rw-r--r--xorg-server/hw/xwin/XWin.man.pre692
-rw-r--r--xorg-server/hw/xwin/win.h14
-rw-r--r--xorg-server/hw/xwin/winblock.c202
-rw-r--r--xorg-server/hw/xwin/winclipboardthread.c2
-rw-r--r--xorg-server/hw/xwin/winclipboardxevents.c6
-rw-r--r--xorg-server/hw/xwin/winconfig.c12
-rw-r--r--xorg-server/hw/xwin/wincursor.c1258
-rw-r--r--xorg-server/hw/xwin/windialogs.c12
-rw-r--r--xorg-server/hw/xwin/winengine.c688
-rw-r--r--xorg-server/hw/xwin/winerror.c17
-rw-r--r--xorg-server/hw/xwin/winglobals.c8
-rw-r--r--xorg-server/hw/xwin/winglobals.h88
-rw-r--r--xorg-server/hw/xwin/winkeyhook.c376
-rw-r--r--xorg-server/hw/xwin/winlayouts.h192
-rw-r--r--xorg-server/hw/xwin/winmouse.c771
-rw-r--r--xorg-server/hw/xwin/winmultiwindowicons.c7
-rw-r--r--xorg-server/hw/xwin/winmultiwindowwindow.c10
-rw-r--r--xorg-server/hw/xwin/winmultiwindowwm.c4
-rw-r--r--xorg-server/hw/xwin/winmultiwindowwndproc.c2075
-rw-r--r--xorg-server/hw/xwin/winnativegdi.c1085
-rw-r--r--xorg-server/hw/xwin/winpfbdd.c1351
-rw-r--r--xorg-server/hw/xwin/winprefs.c11
-rw-r--r--xorg-server/hw/xwin/winprefs.h3
-rw-r--r--xorg-server/hw/xwin/winprocarg.c2484
-rw-r--r--xorg-server/hw/xwin/winscrinit.c8
-rw-r--r--xorg-server/hw/xwin/winshaddd.c54
-rw-r--r--xorg-server/hw/xwin/winshadddnl.c55
-rw-r--r--xorg-server/hw/xwin/winshadgdi.c57
-rw-r--r--xorg-server/hw/xwin/winvalargs.c367
-rw-r--r--xorg-server/hw/xwin/winwakeup.c132
-rw-r--r--xorg-server/hw/xwin/winwin32rootless.c1
-rw-r--r--xorg-server/hw/xwin/winwin32rootlesswndproc.c2662
-rw-r--r--xorg-server/hw/xwin/winwindowswm.c30
-rw-r--r--xorg-server/hw/xwin/winwndproc.c2486
-rw-r--r--xorg-server/include/eventstr.h2
-rw-r--r--xorg-server/os/access.c137
-rw-r--r--xorg-server/os/connection.c11
-rw-r--r--xorg-server/os/xdmcp.c2
-rw-r--r--xorg-server/randr/Makefile.am59
-rw-r--r--xorg-server/randr/makefile1
-rw-r--r--xorg-server/randr/mirandr.c165
-rw-r--r--xorg-server/randr/randrstr.h37
59 files changed, 9111 insertions, 9838 deletions
diff --git a/xorg-server/composite/compalloc.c b/xorg-server/composite/compalloc.c
index c578fe45c..d5fe30315 100644
--- a/xorg-server/composite/compalloc.c
+++ b/xorg-server/composite/compalloc.c
@@ -472,8 +472,19 @@ compUnredirectOneSubwindow (WindowPtr pParent, WindowPtr pWin)
return Success;
}
+static int
+bgNoneVisitWindow(WindowPtr pWin, void *null)
+{
+ if (pWin->backgroundState != BackgroundPixmap)
+ return WT_WALKCHILDREN;
+ if (pWin->background.pixmap != None)
+ return WT_WALKCHILDREN;
+
+ return WT_STOPWALKING;
+}
+
static PixmapPtr
-compNewPixmap (WindowPtr pWin, int x, int y, int w, int h)
+compNewPixmap (WindowPtr pWin, int x, int y, int w, int h, Bool map)
{
ScreenPtr pScreen = pWin->drawable.pScreen;
WindowPtr pParent = pWin->parent;
@@ -487,15 +498,30 @@ compNewPixmap (WindowPtr pWin, int x, int y, int w, int h)
pPixmap->screen_x = x;
pPixmap->screen_y = y;
-
+
+ /* resize allocations will update later in compCopyWindow, not here */
+ if (!map)
+ return pPixmap;
+
+ /*
+ * If there's no bg=None in the tree, we're done.
+ *
+ * We could optimize this more by collection the regions of all the
+ * bg=None subwindows and feeding that in as the clip for the
+ * CopyArea below, but since window trees are shallow these days it
+ * might not be worth the effort.
+ */
+ if (TraverseTree(pWin, bgNoneVisitWindow, NULL) == WT_NOMATCH)
+ return pPixmap;
+
+ /*
+ * Copy bits from the parent into the new pixmap so that it will
+ * have "reasonable" contents in case for background None areas.
+ */
if (pParent->drawable.depth == pWin->drawable.depth)
{
GCPtr pGC = GetScratchGC (pWin->drawable.depth, pScreen);
- /*
- * Copy bits from the parent into the new pixmap so that it will
- * have "reasonable" contents in case for background None areas.
- */
if (pGC)
{
ChangeGCVal val;
@@ -558,7 +584,7 @@ compAllocPixmap (WindowPtr pWin)
int y = pWin->drawable.y - bw;
int w = pWin->drawable.width + (bw << 1);
int h = pWin->drawable.height + (bw << 1);
- PixmapPtr pPixmap = compNewPixmap (pWin, x, y, w, h);
+ PixmapPtr pPixmap = compNewPixmap (pWin, x, y, w, h, TRUE);
CompWindowPtr cw = GetCompWindow (pWin);
if (!pPixmap)
@@ -632,7 +658,7 @@ compReallocPixmap (WindowPtr pWin, int draw_x, int draw_y,
pix_h = h + (bw << 1);
if (pix_w != pOld->drawable.width || pix_h != pOld->drawable.height)
{
- pNew = compNewPixmap (pWin, pix_x, pix_y, pix_w, pix_h);
+ pNew = compNewPixmap (pWin, pix_x, pix_y, pix_w, pix_h, FALSE);
if (!pNew)
return FALSE;
cw->pOldPixmap = pOld;
diff --git a/xorg-server/configure.ac b/xorg-server/configure.ac
index 0d97d488a..b53b3aaa8 100644
--- a/xorg-server/configure.ac
+++ b/xorg-server/configure.ac
@@ -2034,7 +2034,10 @@ if test "$KDRIVE" = yes; then
PKG_CHECK_MODULES([TSLIB], [tslib-0.0], [HAVE_TSLIB="yes"], [HAVE_TSLIB="no"])
if test "x$HAVE_TSLIB" = xno; then
- AC_CHECK_LIB(ts, ts_open, [HAVE_TSLIB="yes"])
+ AC_CHECK_LIB(ts, ts_open, [
+ HAVE_TSLIB="yes"
+ TSLIB_LIBS="-lts"
+ ])
fi
if test "xTSLIB" = xauto; then
@@ -2119,7 +2122,7 @@ if test "$KDRIVE" = yes; then
KDRIVE_LOCAL_LIBS="$MAIN_LIB $DIX_LIB $KDRIVE_LIB $KDRIVE_STUB_LIB"
KDRIVE_LOCAL_LIBS="$KDRIVE_LOCAL_LIBS $FB_LIB $MI_LIB $KDRIVE_PURE_LIBS"
KDRIVE_LOCAL_LIBS="$KDRIVE_LOCAL_LIBS $KDRIVE_OS_LIB $OS_LIB"
- KDRIVE_LIBS="$TSLIB_LIBS $KDRIVE_LOCAL_LIBS $XSERVER_SYS_LIBS $GLX_SYS_LIBS $DLOPEN_LIBS"
+ KDRIVE_LIBS="$KDRIVE_LOCAL_LIBS $XSERVER_SYS_LIBS $GLX_SYS_LIBS $DLOPEN_LIBS $TSLIB_LIBS"
AC_SUBST([XEPHYR_LIBS])
AC_SUBST([XEPHYR_INCS])
diff --git a/xorg-server/dix/getevents.c b/xorg-server/dix/getevents.c
index 171868e26..c13ff9808 100644
--- a/xorg-server/dix/getevents.c
+++ b/xorg-server/dix/getevents.c
@@ -225,7 +225,7 @@ set_valuators(DeviceIntPtr dev, DeviceEvent* event, int first_valuator,
}
memcpy(&event->valuators.data[first_valuator],
- valuators, num_valuators * sizeof(uint32_t));
+ valuators, num_valuators * sizeof(int32_t));
}
@@ -909,20 +909,12 @@ GetKeyboardEvents(EventList *events, DeviceIntPtr pDev, int type, int key_code)
/**
- * Returns a set of keyboard events for KeyPress/KeyRelease, optionally
- * also with valuator events. Handles Xi and XKB.
- *
- * DOES NOT GENERATE CORE EVENTS! Core events are created when processing the
- * event (ProcessOtherEvent).
+ * Returns a set of InternalEvents for KeyPress/KeyRelease, optionally
+ * also with valuator events.
*
* events is not NULL-terminated; the return value is the number of events.
* The DDX is responsible for allocating the event structure in the first
* place via GetMaximumEventsNum(), and for freeing it.
- *
- * This function does not change the core keymap to that of the device;
- * that is done by SwitchCoreKeyboard, which is called from
- * mieqProcessInputEvents. If replacing that function, take care to call
- * SetCoreKeyboard before processInputProc, so keymaps are altered to suit.
*/
int
GetKeyboardValuatorEvents(EventList *events, DeviceIntPtr pDev, int type,
@@ -1065,11 +1057,8 @@ transformAbsolute(DeviceIntPtr dev, int v[MAX_VALUATORS])
}
/**
- * Generate a series of xEvents (filled into the EventList) representing
- * pointer motion, or button presses. Xi and XKB-aware.
- *
- * DOES NOT GENERATE CORE EVENTS! Core events are created when processing the
- * event (ProcessOtherEvent).
+ * Generate a series of InternalEvents (filled into the EventList)
+ * representing pointer motion, or button presses.
*
* events is not NULL-terminated; the return value is the number of events.
* The DDX is responsible for allocating the event structure in the first
@@ -1198,7 +1187,8 @@ GetPointerEvents(EventList *events, DeviceIntPtr pDev, int type, int buttons,
/**
- * Post ProximityIn/ProximityOut events, accompanied by valuators.
+ * Generate ProximityIn/ProximityOut InternalEvents, accompanied by
+ * valuators.
*
* events is not NULL-terminated; the return value is the number of events.
* The DDX is responsible for allocating the event structure in the first
diff --git a/xorg-server/hw/xfree86/common/xf86Config.c b/xorg-server/hw/xfree86/common/xf86Config.c
index 3a8380121..faeda92ee 100644
--- a/xorg-server/hw/xfree86/common/xf86Config.c
+++ b/xorg-server/hw/xfree86/common/xf86Config.c
@@ -78,19 +78,19 @@ extern DeviceAssocRec mouse_assoc;
"/etc/X11/%R," "%P/etc/X11/%R," \
"%E," "%F," \
"/etc/X11/%F," "%P/etc/X11/%F," \
- "/etc/X11/%X-%M," "/etc/X11/%X," "/etc/%X," \
- "%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \
+ "/etc/X11/%X," "/etc/%X," \
+ "%P/etc/X11/%X.%H," \
"%P/etc/X11/%X," \
- "%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \
+ "%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-%M," "/etc/X11/%X," "/etc/%X," \
- "%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \
+ "/etc/X11/%X," "/etc/%X," \
+ "%P/etc/X11/%X.%H," \
"%P/etc/X11/%X," \
- "%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \
+ "%P/lib/X11/%X.%H," \
"%P/lib/X11/%X"
#endif
#ifndef ROOT_CONFIGDIRPATH
@@ -524,24 +524,6 @@ fixup_video_driver_list(char **drivers)
}
}
}
- /*
- * since the ati wrapper driver is gross and awful, sort ati before
- * atimisc, which makes sure all the ati symbols are visible in xorgcfg.
- */
- for (drv = drivers; drv != end; drv++) {
- if (!strcmp(*drv, "atimisc")) {
- atimisc = drv;
- for (drv = atimisc; drv != end; drv++) {
- if (!strcmp(*drv, "ati")) {
- ati = drv;
- x = *ati; *ati = *atimisc; *atimisc = x;
- return;
- }
- }
- /* if we get here, ati was already ahead of atimisc */
- return;
- }
- }
}
static char **
@@ -549,7 +531,7 @@ GenerateDriverlist(char * dirname)
{
char **ret;
const char *subdirs[] = { dirname, NULL };
- static const char *patlist[] = {"(.*)_drv\\.so", "(.*)_drv\\.o", NULL};
+ static const char *patlist[] = {"(.*)_drv\\.so", NULL};
ret = LoaderListDirs(subdirs, patlist);
/* fix up the probe order for video drivers */
@@ -2229,15 +2211,11 @@ configDevice(GDevPtr devicep, XF86ConfDevicePtr conf_device, Bool active)
static void
configDRI(XF86ConfDRIPtr drip)
{
- int count = 0;
- XF86ConfBuffersPtr bufs;
int i;
struct group *grp;
xf86ConfigDRI.group = -1;
xf86ConfigDRI.mode = 0;
- xf86ConfigDRI.bufs_count = 0;
- xf86ConfigDRI.bufs = NULL;
if (drip) {
if (drip->dri_group_name) {
@@ -2248,24 +2226,6 @@ configDRI(XF86ConfDRIPtr drip)
xf86ConfigDRI.group = drip->dri_group;
}
xf86ConfigDRI.mode = drip->dri_mode;
- for (bufs = drip->dri_buffers_lst; bufs; bufs = bufs->list.next)
- ++count;
-
- xf86ConfigDRI.bufs_count = count;
- xf86ConfigDRI.bufs = xnfalloc(count * sizeof(*xf86ConfigDRI.bufs));
-
- for (i = 0, bufs = drip->dri_buffers_lst;
- i < count;
- i++, bufs = bufs->list.next) {
-
- xf86ConfigDRI.bufs[i].count = bufs->buf_count;
- xf86ConfigDRI.bufs[i].size = bufs->buf_size;
- /* FIXME: Flags not implemented. These
- could be used, for example, to specify a
- contiguous block and/or write-combining
- cache policy. */
- xf86ConfigDRI.bufs[i].flags = 0;
- }
}
}
#endif
diff --git a/xorg-server/hw/xfree86/common/xf86Mode.c b/xorg-server/hw/xfree86/common/xf86Mode.c
index af738e703..c3a190777 100644
--- a/xorg-server/hw/xfree86/common/xf86Mode.c
+++ b/xorg-server/hw/xfree86/common/xf86Mode.c
@@ -1831,8 +1831,6 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
numModes++;
}
-#undef _VIRTUALX
-
/*
* If we estimated the virtual size above, we may have filtered away all
* the modes that maximally match that size; scan again to find out and
@@ -1847,13 +1845,69 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
}
}
if (vx < virtX || vy < virtY) {
+ const int types[] = {
+ M_T_BUILTIN | M_T_PREFERRED,
+ M_T_BUILTIN,
+ M_T_DRIVER | M_T_PREFERRED,
+ M_T_DRIVER,
+ 0
+ };
+ const int ntypes = sizeof(types) / sizeof(int);
+ int n;
+
+ /*
+ * We did not find the estimated virtual size. So now we want to
+ * find the largest mode available, but we want to search in the
+ * modes in the order of "types" listed above.
+ */
+ for (n = 0; n < ntypes; n++) {
+ int type = types[n];
+
+ vx = 0; vy = 0;
+ for (p = scrp->modes; p; p = p->next) {
+ /* scan through the modes in the sort order above */
+ if ((p->type & type) != type)
+ continue;
+ if (p->HDisplay > vx && p->VDisplay > vy) {
+ vx = p->HDisplay;
+ vy = p->VDisplay;
+ }
+ }
+ if (vx && vy)
+ /* Found one */
+ break;
+ }
xf86DrvMsg(scrp->scrnIndex, X_WARNING,
"Shrinking virtual size estimate from %dx%d to %dx%d\n",
virtX, virtY, vx, vy);
- virtX = vx;
+ virtX = _VIRTUALX(vx);
virtY = vy;
- linePitch = scanLineWidth(vx, vy, minPitch, apertureSize,
- BankFormat, pitchInc);
+ for (p = scrp->modes; p; p = p->next) {
+ if (numModes > 0) {
+ if (p->HDisplay > virtX)
+ p->status = MODE_VIRTUAL_X;
+ if (p->VDisplay > virtY)
+ p->status = MODE_VIRTUAL_Y;
+ if (p->status != MODE_OK) {
+ numModes--;
+ printModeRejectMessage(scrp->scrnIndex, p, p->status);
+ }
+ }
+ }
+ if (linePitches != NULL) {
+ for (i = 0; linePitches[i] != 0; i++) {
+ if ((linePitches[i] >= virtX) &&
+ (linePitches[i] ==
+ scanLineWidth(virtX, virtY, linePitches[i],
+ apertureSize, BankFormat, pitchInc))) {
+ linePitch = linePitches[i];
+ break;
+ }
+ }
+ } else {
+ linePitch = scanLineWidth(virtX, virtY, minPitch,
+ apertureSize, BankFormat, pitchInc);
+ }
}
}
diff --git a/xorg-server/hw/xfree86/common/xf86Xinput.c b/xorg-server/hw/xfree86/common/xf86Xinput.c
index 585be69a5..3542abd4a 100644
--- a/xorg-server/hw/xfree86/common/xf86Xinput.c
+++ b/xorg-server/hw/xfree86/common/xf86Xinput.c
@@ -1238,40 +1238,43 @@ xf86FirstLocalDevice(void)
/*
* Cx - raw data from touch screen
- * Sxhigh - scaled highest dimension
+ * to_max - scaled highest dimension
* (remember, this is of rows - 1 because of 0 origin)
- * Sxlow - scaled lowest dimension
- * Rxhigh - highest raw value from touch screen calibration
- * Rxlow - lowest raw value from touch screen calibration
+ * 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 Sxhigh,
- int Sxlow,
- int Rxhigh,
- int Rxlow )
+ int to_max,
+ int to_min,
+ int from_max,
+ int from_min )
{
int X;
- int64_t dSx = Sxhigh - Sxlow;
- int64_t dRx = Rxhigh - Rxlow;
+ int64_t to_width = to_max - to_min;
+ int64_t from_width = from_max - from_min;
- if (dRx) {
- X = (int)(((dSx * (Cx - Rxlow)) / dRx) + Sxlow);
+ if (from_width) {
+ X = (int)(((to_width * (Cx - from_min)) / from_width) + to_min);
}
else {
X = 0;
ErrorF ("Divide by Zero in xf86ScaleAxis");
}
- if (X > Sxhigh)
- X = Sxhigh;
- if (X < Sxlow)
- X = Sxlow;
+ if (X > to_max)
+ X = to_max;
+ if (X < to_min)
+ X = to_min;
return X;
}
diff --git a/xorg-server/hw/xfree86/common/xf86Xinput.h b/xorg-server/hw/xfree86/common/xf86Xinput.h
index 1e5671574..727f26107 100644
--- a/xorg-server/hw/xfree86/common/xf86Xinput.h
+++ b/xorg-server/hw/xfree86/common/xf86Xinput.h
@@ -184,7 +184,7 @@ extern _X_EXPORT void xf86PostKeyboardEvent(DeviceIntPtr device, unsigned int ke
int is_down);
extern _X_EXPORT int xf86ActivateDevice(LocalDevicePtr local);
extern _X_EXPORT LocalDevicePtr xf86FirstLocalDevice(void);
-extern _X_EXPORT int xf86ScaleAxis(int Cx, int Sxhigh, int Sxlow, int Rxhigh, int Rxlow);
+extern _X_EXPORT int xf86ScaleAxis(int Cx, int to_max, int to_min, int from_max, int from_min);
extern _X_EXPORT void xf86XInputSetScreen(LocalDevicePtr local, int screen_number, int x, int y);
extern _X_EXPORT void xf86ProcessCommonOptions(InputInfoPtr pInfo, pointer options);
extern _X_EXPORT void xf86InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, Atom label, int minval,
diff --git a/xorg-server/hw/xfree86/ddc/ddc.c b/xorg-server/hw/xfree86/ddc/ddc.c
index 975e07620..e9b8a52eb 100644
--- a/xorg-server/hw/xfree86/ddc/ddc.c
+++ b/xorg-server/hw/xfree86/ddc/ddc.c
@@ -314,10 +314,6 @@ DDC2Init(int scrnIndex, I2CBusPtr pBus)
dev = DDC2MakeDevice(pBus, 0x00A0, "ddc2");
if (xf86I2CProbeAddress(pBus, 0x0060))
DDC2MakeDevice(pBus, 0x0060, "E-EDID segment register");
- if (xf86I2CProbeAddress(pBus, 0x0062))
- DDC2MakeDevice(pBus, 0x0062, "EDID EEPROM interface");
- if (xf86I2CProbeAddress(pBus, 0x006E))
- DDC2MakeDevice(pBus, 0x006E, "DDC control interface");
return dev;
}
diff --git a/xorg-server/hw/xfree86/doc/man/xorg.conf.man.pre b/xorg-server/hw/xfree86/doc/man/xorg.conf.man.pre
index 1bec1bf27..8d09862b3 100644
--- a/xorg-server/hw/xfree86/doc/man/xorg.conf.man.pre
+++ b/xorg-server/hw/xfree86/doc/man/xorg.conf.man.pre
@@ -39,14 +39,11 @@ server is started as a normal user:
.IR __projectroot__/etc/X11/ <cmdline>
.IB /etc/X11/ $XORGCONFIG
.IB __projectroot__/etc/X11/ $XORGCONFIG
-.I /etc/X11/__xconfigfile__\-4
.I /etc/X11/__xconfigfile__
.I /etc/__xconfigfile__
.IR __projectroot__/etc/X11/__xconfigfile__. <hostname>
-.I __projectroot__/etc/X11/__xconfigfile__\-4
.I __projectroot__/etc/X11/__xconfigfile__
.IR __projectroot__/lib/X11/__xconfigfile__. <hostname>
-.I __projectroot__/lib/X11/__xconfigfile__\-4
.I __projectroot__/lib/X11/__xconfigfile__
.fi
.RE
@@ -74,14 +71,11 @@ search locations are as follows:
.B $XORGCONFIG
.IB /etc/X11/ $XORGCONFIG
.IB __projectroot__/etc/X11/ $XORGCONFIG
-.I /etc/X11/__xconfigfile__\-4
.I /etc/X11/__xconfigfile__
.I /etc/__xconfigfile__
.IR __projectroot__/etc/X11/__xconfigfile__. <hostname>
-.I __projectroot__/etc/X11/__xconfigfile__\-4
.I __projectroot__/etc/X11/__xconfigfile__
.IR __projectroot__/lib/X11/__xconfigfile__. <hostname>
-.I __projectroot__/lib/X11/__xconfigfile__\-4
.I __projectroot__/lib/X11/__xconfigfile__
.fi
.RE
diff --git a/xorg-server/hw/xfree86/os-support/shared/sigio.c b/xorg-server/hw/xfree86/os-support/shared/sigio.c
index aed5654e8..ef04c1140 100644
--- a/xorg-server/hw/xfree86/os-support/shared/sigio.c
+++ b/xorg-server/hw/xfree86/os-support/shared/sigio.c
@@ -1,318 +1,309 @@
-
-/* sigio.c -- Support for SIGIO handler installation and removal
- * Created: Thu Jun 3 15:39:18 1999 by faith@precisioninsight.com
- *
- * Copyright 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 (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * 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: Rickard E. (Rik) Faith <faith@valinux.com>
- */
-/*
- * Copyright (c) 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 <X11/X.h>
-# include "xf86.h"
-# include "xf86Priv.h"
-# include "xf86_OSlib.h"
-# include "inputstr.h"
-
-#ifdef HAVE_STROPTS_H
-# include <stropts.h>
-#endif
-
-/*
- * Linux libc5 defines FASYNC, but not O_ASYNC. Don't know if it is
- * functional or not.
- */
-#if defined(FASYNC) && !defined(O_ASYNC)
-# define O_ASYNC FASYNC
-#endif
-
-#ifdef MAXDEVICES
-/* MAXDEVICES represents the maximimum number of input devices usable
- * at the same time plus one entry for DRM support.
- */
-# define MAX_FUNCS (MAXDEVICES + 1)
-#else
-# define MAX_FUNCS 16
-#endif
-
-typedef struct _xf86SigIOFunc {
- void (*f) (int, void *);
- int fd;
- void *closure;
-} Xf86SigIOFunc;
-
-static Xf86SigIOFunc xf86SigIOFuncs[MAX_FUNCS];
-static int xf86SigIOMax;
-static int xf86SigIOMaxFd;
-static fd_set xf86SigIOMask;
-
-/*
- * SIGIO gives no way of discovering which fd signalled, select
- * to discover
- */
-static void
-xf86SIGIO (int sig)
-{
- int i;
- fd_set ready;
- struct timeval to;
- int save_errno = errno; /* do not clobber the global errno */
- int r;
-
- ready = xf86SigIOMask;
- to.tv_sec = 0;
- to.tv_usec = 0;
- SYSCALL (r = select (xf86SigIOMaxFd, &ready, 0, 0, &to));
- for (i = 0; r > 0 && i < xf86SigIOMax; i++)
- if (xf86SigIOFuncs[i].f && FD_ISSET (xf86SigIOFuncs[i].fd, &ready))
- {
- (*xf86SigIOFuncs[i].f)(xf86SigIOFuncs[i].fd,
- xf86SigIOFuncs[i].closure);
- r--;
- }
- if (r > 0) {
- xf86Msg(X_ERROR, "SIGIO %d descriptors not handled\n", r);
- }
- /* restore global errno */
- errno = save_errno;
-}
-
-static int
-xf86IsPipe (int fd)
-{
- struct stat buf;
-
- if (fstat (fd, &buf) < 0)
- return 0;
- return S_ISFIFO(buf.st_mode);
-}
-
-int
-xf86InstallSIGIOHandler(int fd, void (*f)(int, void *), void *closure)
-{
- struct sigaction sa;
- struct sigaction osa;
- int i;
- int blocked;
- int installed = FALSE;
-
- if (!xf86Info.useSIGIO)
- return 0;
-
- for (i = 0; i < MAX_FUNCS; i++)
- {
- if (!xf86SigIOFuncs[i].f)
- {
- if (xf86IsPipe (fd))
- return 0;
- blocked = xf86BlockSIGIO();
-#ifdef O_ASYNC
- if (fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_ASYNC) == -1) {
- xf86Msg(X_WARNING, "fcntl(%d, O_ASYNC): %s\n",
- fd, strerror(errno));
- } else {
- if (fcntl(fd, F_SETOWN, getpid()) == -1) {
- xf86Msg(X_WARNING, "fcntl(%d, F_SETOWN): %s\n",
- fd, strerror(errno));
- } else {
- installed = TRUE;
- }
- }
-#endif
-#ifdef I_SETSIG /* System V Streams - used on Solaris for input devices */
- if (!installed && isastream(fd)) {
- if (ioctl(fd, I_SETSIG, S_INPUT | S_ERROR | S_HANGUP) == -1) {
- xf86Msg(X_WARNING, "fcntl(%d, I_SETSIG): %s\n",
- fd, strerror(errno));
- } else {
- installed = TRUE;
- }
- }
-#endif
- if (!installed) {
- xf86UnblockSIGIO(blocked);
- return 0;
- }
- sigemptyset(&sa.sa_mask);
- sigaddset(&sa.sa_mask, SIGIO);
- sa.sa_flags = 0;
- sa.sa_handler = xf86SIGIO;
- sigaction(SIGIO, &sa, &osa);
- xf86SigIOFuncs[i].fd = fd;
- xf86SigIOFuncs[i].closure = closure;
- xf86SigIOFuncs[i].f = f;
- if (i >= xf86SigIOMax)
- xf86SigIOMax = i+1;
- if (fd >= xf86SigIOMaxFd)
- xf86SigIOMaxFd = fd + 1;
- FD_SET (fd, &xf86SigIOMask);
- xf86UnblockSIGIO(blocked);
- return 1;
- }
- /* Allow overwriting of the closure and callback */
- else if (xf86SigIOFuncs[i].fd == fd)
- {
- xf86SigIOFuncs[i].closure = closure;
- xf86SigIOFuncs[i].f = f;
- return 1;
- }
- }
- return 0;
-}
-
-int
-xf86RemoveSIGIOHandler(int fd)
-{
- struct sigaction sa;
- struct sigaction osa;
- int i;
- int max;
- int maxfd;
- int ret;
-
- if (!xf86Info.useSIGIO)
- return 0;
-
- max = 0;
- maxfd = -1;
- ret = 0;
- for (i = 0; i < MAX_FUNCS; i++)
- {
- if (xf86SigIOFuncs[i].f)
- {
- if (xf86SigIOFuncs[i].fd == fd)
- {
- xf86SigIOFuncs[i].f = 0;
- xf86SigIOFuncs[i].fd = 0;
- xf86SigIOFuncs[i].closure = 0;
- FD_CLR (fd, &xf86SigIOMask);
- ret = 1;
- }
- else
- {
- max = i + 1;
- if (xf86SigIOFuncs[i].fd >= maxfd)
- maxfd = xf86SigIOFuncs[i].fd + 1;
- }
- }
- }
- if (ret)
- {
-#ifdef O_ASYNC
- fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) & ~O_ASYNC);
-#endif
-#ifdef I_SETSIG
- if (isastream(fd)) {
- if (ioctl(fd, I_SETSIG, 0) == -1) {
- xf86Msg(X_WARNING, "fcntl(%d, I_SETSIG, 0): %s\n",
- fd, strerror(errno));
- }
- }
-#endif
- xf86SigIOMax = max;
- xf86SigIOMaxFd = maxfd;
- if (!max)
- {
- sigemptyset(&sa.sa_mask);
- sigaddset(&sa.sa_mask, SIGIO);
- sa.sa_flags = 0;
- sa.sa_handler = SIG_IGN;
- sigaction(SIGIO, &sa, &osa);
- }
- }
- return ret;
-}
-
-int
-xf86BlockSIGIO (void)
-{
- sigset_t set, old;
- int ret;
-
- sigemptyset (&set);
- sigaddset (&set, SIGIO);
- sigprocmask (SIG_BLOCK, &set, &old);
- ret = sigismember (&old, SIGIO);
- return ret;
-}
-
-void
-xf86UnblockSIGIO (int wasset)
-{
- sigset_t set;
-
- if (!wasset)
- {
- sigemptyset (&set);
- sigaddset (&set, SIGIO);
- sigprocmask (SIG_UNBLOCK, &set, NULL);
- }
-}
-
-void
-xf86AssertBlockedSIGIO (char *where)
-{
- sigset_t set, old;
-
- sigemptyset (&set);
- sigprocmask (SIG_BLOCK, &set, &old);
- if (!sigismember (&old, SIGIO))
- xf86Msg (X_ERROR, "SIGIO not blocked at %s\n", where);
-}
-
-/* XXX This is a quick hack for the benefit of xf86SetSilkenMouse() */
-
-int
-xf86SIGIOSupported (void)
-{
- return 1;
-}
+/* sigio.c -- Support for SIGIO handler installation and removal
+ * Created: Thu Jun 3 15:39:18 1999 by faith@precisioninsight.com
+ *
+ * Copyright 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 (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * 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: Rickard E. (Rik) Faith <faith@valinux.com>
+ */
+/*
+ * Copyright (c) 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 <X11/X.h>
+# include "xf86.h"
+# include "xf86Priv.h"
+# include "xf86_OSlib.h"
+# include "inputstr.h"
+
+#ifdef HAVE_STROPTS_H
+# include <stropts.h>
+#endif
+
+#ifdef MAXDEVICES
+/* MAXDEVICES represents the maximimum number of input devices usable
+ * at the same time plus one entry for DRM support.
+ */
+# define MAX_FUNCS (MAXDEVICES + 1)
+#else
+# define MAX_FUNCS 16
+#endif
+
+typedef struct _xf86SigIOFunc {
+ void (*f) (int, void *);
+ int fd;
+ void *closure;
+} Xf86SigIOFunc;
+
+static Xf86SigIOFunc xf86SigIOFuncs[MAX_FUNCS];
+static int xf86SigIOMax;
+static int xf86SigIOMaxFd;
+static fd_set xf86SigIOMask;
+
+/*
+ * SIGIO gives no way of discovering which fd signalled, select
+ * to discover
+ */
+static void
+xf86SIGIO (int sig)
+{
+ int i;
+ fd_set ready;
+ struct timeval to;
+ int save_errno = errno; /* do not clobber the global errno */
+ int r;
+
+ ready = xf86SigIOMask;
+ to.tv_sec = 0;
+ to.tv_usec = 0;
+ SYSCALL (r = select (xf86SigIOMaxFd, &ready, 0, 0, &to));
+ for (i = 0; r > 0 && i < xf86SigIOMax; i++)
+ if (xf86SigIOFuncs[i].f && FD_ISSET (xf86SigIOFuncs[i].fd, &ready))
+ {
+ (*xf86SigIOFuncs[i].f)(xf86SigIOFuncs[i].fd,
+ xf86SigIOFuncs[i].closure);
+ r--;
+ }
+ if (r > 0) {
+ xf86Msg(X_ERROR, "SIGIO %d descriptors not handled\n", r);
+ }
+ /* restore global errno */
+ errno = save_errno;
+}
+
+static int
+xf86IsPipe (int fd)
+{
+ struct stat buf;
+
+ if (fstat (fd, &buf) < 0)
+ return 0;
+ return S_ISFIFO(buf.st_mode);
+}
+
+int
+xf86InstallSIGIOHandler(int fd, void (*f)(int, void *), void *closure)
+{
+ struct sigaction sa;
+ struct sigaction osa;
+ int i;
+ int blocked;
+ int installed = FALSE;
+
+ if (!xf86Info.useSIGIO)
+ return 0;
+
+ for (i = 0; i < MAX_FUNCS; i++)
+ {
+ if (!xf86SigIOFuncs[i].f)
+ {
+ if (xf86IsPipe (fd))
+ return 0;
+ blocked = xf86BlockSIGIO();
+#ifdef O_ASYNC
+ if (fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_ASYNC) == -1) {
+ xf86Msg(X_WARNING, "fcntl(%d, O_ASYNC): %s\n",
+ fd, strerror(errno));
+ } else {
+ if (fcntl(fd, F_SETOWN, getpid()) == -1) {
+ xf86Msg(X_WARNING, "fcntl(%d, F_SETOWN): %s\n",
+ fd, strerror(errno));
+ } else {
+ installed = TRUE;
+ }
+ }
+#endif
+#ifdef I_SETSIG /* System V Streams - used on Solaris for input devices */
+ if (!installed && isastream(fd)) {
+ if (ioctl(fd, I_SETSIG, S_INPUT | S_ERROR | S_HANGUP) == -1) {
+ xf86Msg(X_WARNING, "fcntl(%d, I_SETSIG): %s\n",
+ fd, strerror(errno));
+ } else {
+ installed = TRUE;
+ }
+ }
+#endif
+ if (!installed) {
+ xf86UnblockSIGIO(blocked);
+ return 0;
+ }
+ sigemptyset(&sa.sa_mask);
+ sigaddset(&sa.sa_mask, SIGIO);
+ sa.sa_flags = 0;
+ sa.sa_handler = xf86SIGIO;
+ sigaction(SIGIO, &sa, &osa);
+ xf86SigIOFuncs[i].fd = fd;
+ xf86SigIOFuncs[i].closure = closure;
+ xf86SigIOFuncs[i].f = f;
+ if (i >= xf86SigIOMax)
+ xf86SigIOMax = i+1;
+ if (fd >= xf86SigIOMaxFd)
+ xf86SigIOMaxFd = fd + 1;
+ FD_SET (fd, &xf86SigIOMask);
+ xf86UnblockSIGIO(blocked);
+ return 1;
+ }
+ /* Allow overwriting of the closure and callback */
+ else if (xf86SigIOFuncs[i].fd == fd)
+ {
+ xf86SigIOFuncs[i].closure = closure;
+ xf86SigIOFuncs[i].f = f;
+ return 1;
+ }
+ }
+ return 0;
+}
+
+int
+xf86RemoveSIGIOHandler(int fd)
+{
+ struct sigaction sa;
+ struct sigaction osa;
+ int i;
+ int max;
+ int maxfd;
+ int ret;
+
+ if (!xf86Info.useSIGIO)
+ return 0;
+
+ max = 0;
+ maxfd = -1;
+ ret = 0;
+ for (i = 0; i < MAX_FUNCS; i++)
+ {
+ if (xf86SigIOFuncs[i].f)
+ {
+ if (xf86SigIOFuncs[i].fd == fd)
+ {
+ xf86SigIOFuncs[i].f = 0;
+ xf86SigIOFuncs[i].fd = 0;
+ xf86SigIOFuncs[i].closure = 0;
+ FD_CLR (fd, &xf86SigIOMask);
+ ret = 1;
+ }
+ else
+ {
+ max = i + 1;
+ if (xf86SigIOFuncs[i].fd >= maxfd)
+ maxfd = xf86SigIOFuncs[i].fd + 1;
+ }
+ }
+ }
+ if (ret)
+ {
+#ifdef O_ASYNC
+ fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) & ~O_ASYNC);
+#endif
+#ifdef I_SETSIG
+ if (isastream(fd)) {
+ if (ioctl(fd, I_SETSIG, 0) == -1) {
+ xf86Msg(X_WARNING, "fcntl(%d, I_SETSIG, 0): %s\n",
+ fd, strerror(errno));
+ }
+ }
+#endif
+ xf86SigIOMax = max;
+ xf86SigIOMaxFd = maxfd;
+ if (!max)
+ {
+ sigemptyset(&sa.sa_mask);
+ sigaddset(&sa.sa_mask, SIGIO);
+ sa.sa_flags = 0;
+ sa.sa_handler = SIG_IGN;
+ sigaction(SIGIO, &sa, &osa);
+ }
+ }
+ return ret;
+}
+
+int
+xf86BlockSIGIO (void)
+{
+ sigset_t set, old;
+ int ret;
+
+ sigemptyset (&set);
+ sigaddset (&set, SIGIO);
+ sigprocmask (SIG_BLOCK, &set, &old);
+ ret = sigismember (&old, SIGIO);
+ return ret;
+}
+
+void
+xf86UnblockSIGIO (int wasset)
+{
+ sigset_t set;
+
+ if (!wasset)
+ {
+ sigemptyset (&set);
+ sigaddset (&set, SIGIO);
+ sigprocmask (SIG_UNBLOCK, &set, NULL);
+ }
+}
+
+void
+xf86AssertBlockedSIGIO (char *where)
+{
+ sigset_t set, old;
+
+ sigemptyset (&set);
+ sigprocmask (SIG_BLOCK, &set, &old);
+ if (!sigismember (&old, SIGIO))
+ xf86Msg (X_ERROR, "SIGIO not blocked at %s\n", where);
+}
+
+/* XXX This is a quick hack for the benefit of xf86SetSilkenMouse() */
+
+int
+xf86SIGIOSupported (void)
+{
+ return 1;
+}
diff --git a/xorg-server/hw/xfree86/parser/DRI.c b/xorg-server/hw/xfree86/parser/DRI.c
index 12b8d1d1a..4847bef2c 100644
--- a/xorg-server/hw/xfree86/parser/DRI.c
+++ b/xorg-server/hw/xfree86/parser/DRI.c
@@ -1,187 +1,123 @@
-/* DRI.c -- DRI Section in XF86Config file
- * Created: Fri Mar 19 08:40:22 1999 by faith@precisioninsight.com
- * Revised: Thu Jun 17 16:08:05 1999 by faith@precisioninsight.com
- *
- * Copyright 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 (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- *
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86Parser.h"
-#include "xf86tokens.h"
-#include "Configint.h"
-
-extern LexRec val;
-
-static xf86ConfigSymTabRec DRITab[] =
-{
- {ENDSECTION, "endsection"},
- {GROUP, "group"},
- {BUFFERS, "buffers"},
- {MODE, "mode"},
- {-1, ""},
-};
-
-#define CLEANUP xf86freeBuffersList
-
-static void
-xf86freeBuffersList (XF86ConfBuffersPtr ptr)
-{
- XF86ConfBuffersPtr prev;
-
- while (ptr) {
- TestFree (ptr->buf_flags);
- TestFree (ptr->buf_comment);
- prev = ptr;
- ptr = ptr->list.next;
- free (prev);
- }
-}
-
-static XF86ConfBuffersPtr
-xf86parseBuffers (void)
-{
- int token;
- parsePrologue (XF86ConfBuffersPtr, XF86ConfBuffersRec)
-
- if (xf86getSubToken (&(ptr->buf_comment)) != NUMBER)
- Error ("Buffers count expected", NULL);
- ptr->buf_count = val.num;
-
- if (xf86getSubToken (&(ptr->buf_comment)) != NUMBER)
- Error ("Buffers size expected", NULL);
- ptr->buf_size = val.num;
-
- if ((token = xf86getSubToken (&(ptr->buf_comment))) == STRING) {
- ptr->buf_flags = val.str;
- if ((token = xf86getToken (NULL)) == COMMENT)
- ptr->buf_comment = xf86addComment(ptr->buf_comment, val.str);
- else
- xf86unGetToken(token);
- }
-
-#ifdef DEBUG
- printf ("Buffers parsed\n");
-#endif
-
- return ptr;
-}
-
-#undef CLEANUP
-
-#define CLEANUP xf86freeDRI
-
-XF86ConfDRIPtr
-xf86parseDRISection (void)
-{
- int token;
- parsePrologue (XF86ConfDRIPtr, XF86ConfDRIRec);
-
- /* Zero is a valid value for this. */
- ptr->dri_group = -1;
- while ((token = xf86getToken (DRITab)) != ENDSECTION) {
- switch (token)
- {
- case GROUP:
- if ((token = xf86getSubToken (&(ptr->dri_comment))) == STRING)
- ptr->dri_group_name = val.str;
- else if (token == NUMBER)
- ptr->dri_group = val.num;
- else
- Error (GROUP_MSG, NULL);
- break;
- case MODE:
- if (xf86getSubToken (&(ptr->dri_comment)) != NUMBER)
- Error (NUMBER_MSG, "Mode");
- if (val.numType != PARSE_OCTAL)
- Error (MUST_BE_OCTAL_MSG, val.num);
- ptr->dri_mode = val.num;
- break;
- case BUFFERS:
- HANDLE_LIST (dri_buffers_lst, xf86parseBuffers,
- XF86ConfBuffersPtr);
- break;
- case EOF_TOKEN:
- Error (UNEXPECTED_EOF_MSG, NULL);
- break;
- case COMMENT:
- ptr->dri_comment = xf86addComment(ptr->dri_comment, val.str);
- break;
- default:
- Error (INVALID_KEYWORD_MSG, xf86tokenString ());
- break;
- }
- }
-
-#ifdef DEBUG
- ErrorF("DRI section parsed\n");
-#endif
-
- return ptr;
-}
-
-#undef CLEANUP
-
-void
-xf86printDRISection (FILE * cf, XF86ConfDRIPtr ptr)
-{
- XF86ConfBuffersPtr bufs;
-
- if (ptr == NULL)
- return;
-
- fprintf (cf, "Section \"DRI\"\n");
- if (ptr->dri_comment)
- fprintf (cf, "%s", ptr->dri_comment);
- if (ptr->dri_group_name)
- fprintf (cf, "\tGroup \"%s\"\n", ptr->dri_group_name);
- else if (ptr->dri_group >= 0)
- fprintf (cf, "\tGroup %d\n", ptr->dri_group);
- if (ptr->dri_mode)
- fprintf (cf, "\tMode 0%o\n", ptr->dri_mode);
- for (bufs = ptr->dri_buffers_lst; bufs; bufs = bufs->list.next) {
- fprintf (cf, "\tBuffers %d %d",
- bufs->buf_count, bufs->buf_size);
- if (bufs->buf_flags) fprintf (cf, " \"%s\"", bufs->buf_flags);
- if (bufs->buf_comment)
- fprintf(cf, "%s", bufs->buf_comment);
- else
- fprintf (cf, "\n");
- }
- fprintf (cf, "EndSection\n\n");
-}
-
-void
-xf86freeDRI (XF86ConfDRIPtr ptr)
-{
- if (ptr == NULL)
- return;
-
- xf86freeBuffersList (ptr->dri_buffers_lst);
- TestFree (ptr->dri_comment);
- free (ptr);
-}
+/* DRI.c -- DRI Section in XF86Config file
+ * Created: Fri Mar 19 08:40:22 1999 by faith@precisioninsight.com
+ * Revised: Thu Jun 17 16:08:05 1999 by faith@precisioninsight.com
+ *
+ * Copyright 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 (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+
+extern LexRec val;
+
+static xf86ConfigSymTabRec DRITab[] =
+{
+ {ENDSECTION, "endsection"},
+ {GROUP, "group"},
+ {MODE, "mode"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeDRI
+
+XF86ConfDRIPtr
+xf86parseDRISection (void)
+{
+ int token;
+ parsePrologue (XF86ConfDRIPtr, XF86ConfDRIRec);
+
+ /* Zero is a valid value for this. */
+ ptr->dri_group = -1;
+ while ((token = xf86getToken (DRITab)) != ENDSECTION) {
+ switch (token)
+ {
+ case GROUP:
+ if ((token = xf86getSubToken (&(ptr->dri_comment))) == STRING)
+ ptr->dri_group_name = val.str;
+ else if (token == NUMBER)
+ ptr->dri_group = val.num;
+ else
+ Error (GROUP_MSG, NULL);
+ break;
+ case MODE:
+ if (xf86getSubToken (&(ptr->dri_comment)) != NUMBER)
+ Error (NUMBER_MSG, "Mode");
+ if (val.numType != PARSE_OCTAL)
+ Error (MUST_BE_OCTAL_MSG, val.num);
+ ptr->dri_mode = val.num;
+ break;
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ case COMMENT:
+ ptr->dri_comment = xf86addComment(ptr->dri_comment, val.str);
+ break;
+ default:
+ Error (INVALID_KEYWORD_MSG, xf86tokenString ());
+ break;
+ }
+ }
+
+#ifdef DEBUG
+ ErrorF("DRI section parsed\n");
+#endif
+
+ return ptr;
+}
+
+#undef CLEANUP
+
+void
+xf86printDRISection (FILE * cf, XF86ConfDRIPtr ptr)
+{
+ if (ptr == NULL)
+ return;
+
+ fprintf (cf, "Section \"DRI\"\n");
+ if (ptr->dri_comment)
+ fprintf (cf, "%s", ptr->dri_comment);
+ if (ptr->dri_group_name)
+ fprintf (cf, "\tGroup \"%s\"\n", ptr->dri_group_name);
+ else if (ptr->dri_group >= 0)
+ fprintf (cf, "\tGroup %d\n", ptr->dri_group);
+ if (ptr->dri_mode)
+ fprintf (cf, "\tMode 0%o\n", ptr->dri_mode);
+ fprintf (cf, "EndSection\n\n");
+}
+
+void
+xf86freeDRI (XF86ConfDRIPtr ptr)
+{
+ if (ptr == NULL)
+ return;
+
+ TestFree (ptr->dri_comment);
+ free (ptr);
+}
diff --git a/xorg-server/hw/xfree86/parser/scan.c b/xorg-server/hw/xfree86/parser/scan.c
index 783a42545..b829868f7 100644
--- a/xorg-server/hw/xfree86/parser/scan.c
+++ b/xorg-server/hw/xfree86/parser/scan.c
@@ -115,53 +115,6 @@ static int pushToken = LOCK_TOKEN;
static int eol_seen = 0; /* private state to handle comments */
LexRec val;
-/*
- * xf86strToUL --
- *
- * A portable, but restricted, version of strtoul(). It only understands
- * hex, octal, and decimal. But it's good enough for our needs.
- */
-static unsigned int
-xf86strToUL (char *str)
-{
- int base = 10;
- char *p = str;
- unsigned int tot = 0;
-
- if (*p == '0')
- {
- p++;
- if ((*p == 'x') || (*p == 'X'))
- {
- p++;
- base = 16;
- }
- else
- base = 8;
- }
- while (*p)
- {
- if ((*p >= '0') && (*p <= ((base == 8) ? '7' : '9')))
- {
- tot = tot * base + (*p - '0');
- }
- else if ((base == 16) && (*p >= 'a') && (*p <= 'f'))
- {
- tot = tot * base + 10 + (*p - 'a');
- }
- else if ((base == 16) && (*p >= 'A') && (*p <= 'F'))
- {
- tot = tot * base + 10 + (*p - 'A');
- }
- else
- {
- return tot;
- }
- p++;
- }
- return tot;
-}
-
/*
* xf86getNextLine --
*
@@ -434,7 +387,7 @@ again:
configRBuf[i++] = c;
configPos--; /* GJA -- one too far */
configRBuf[i] = '\0';
- val.num = xf86strToUL (configRBuf);
+ val.num = strtoul (configRBuf, NULL, 0);
val.realnum = atof (configRBuf);
return NUMBER;
}
@@ -601,7 +554,6 @@ xf86pathIsSafe(const char *path)
* %P projroot
* %C sysconfdir
* %D datadir
- * %M config file format version number
* %% %
*/
@@ -626,11 +578,6 @@ xf86pathIsSafe(const char *path)
#ifndef XCONFENV
#define XCONFENV "XORGCONFIG"
#endif
-/* xorg.conf is based on XF86Config version 4. If we ever break
- compatibility of the xorg.conf syntax, we'll bump this version number. */
-#ifndef CONFIG_FILE_VERSION
-#define CONFIG_FILE_VERSION 4
-#endif
#define BAIL_OUT do { \
free(result); \
@@ -661,7 +608,6 @@ DoSubstitution(const char *template, const char *cmdline, const char *projroot,
int i, l;
static const char *env = NULL;
static char *hostname = NULL;
- static char majorvers[3] = "";
if (!template)
return NULL;
@@ -762,13 +708,6 @@ DoSubstitution(const char *template, const char *cmdline, const char *projroot,
case 'D':
APPEND_STR(DATADIR);
break;
- case 'M':
- if (!majorvers[0]) {
- snprintf(majorvers, sizeof(majorvers),
- "%d", CONFIG_FILE_VERSION);
- }
- APPEND_STR(majorvers);
- break;
case '%':
result[l++] = '%';
CHECK_LENGTH;
diff --git a/xorg-server/hw/xfree86/parser/xf86Parser.h b/xorg-server/hw/xfree86/parser/xf86Parser.h
index d35bbab27..f8c9c3cde 100644
--- a/xorg-server/hw/xfree86/parser/xf86Parser.h
+++ b/xorg-server/hw/xfree86/parser/xf86Parser.h
@@ -442,20 +442,9 @@ XF86ConfVendorRec, *XF86ConfVendorPtr;
typedef struct
{
- GenericListRec list;
- int buf_count;
- int buf_size;
- char *buf_flags;
- char *buf_comment;
-}
-XF86ConfBuffersRec, *XF86ConfBuffersPtr;
-
-typedef struct
-{
char *dri_group_name;
int dri_group;
int dri_mode;
- XF86ConfBuffersPtr dri_buffers_lst;
char *dri_comment;
}
XF86ConfDRIRec, *XF86ConfDRIPtr;
diff --git a/xorg-server/hw/xfree86/parser/xf86tokens.h b/xorg-server/hw/xfree86/parser/xf86tokens.h
index 3bea43d15..8c7ea1b28 100644
--- a/xorg-server/hw/xfree86/parser/xf86tokens.h
+++ b/xorg-server/hw/xfree86/parser/xf86tokens.h
@@ -273,7 +273,6 @@ typedef enum {
/* DRI Tokens */
GROUP,
- BUFFERS,
/* InputClass Tokens */
MATCH_PRODUCT,
diff --git a/xorg-server/hw/xwin/InitInput.c b/xorg-server/hw/xwin/InitInput.c
index 8740319cf..7560e6920 100644
--- a/xorg-server/hw/xwin/InitInput.c
+++ b/xorg-server/hw/xwin/InitInput.c
@@ -52,21 +52,6 @@ int winProcSetSelectionOwner(ClientPtr /* client */);
DeviceIntPtr g_pwinPointer;
DeviceIntPtr g_pwinKeyboard;
-
-/*
- * References to external symbols
- */
-
-#ifdef HAS_DEVWINDOWS
-extern int g_fdMessageQueue;
-#endif
-extern Bool g_fXdmcpEnabled;
-#ifdef XWIN_CLIPBOARD
-extern winDispatchProcPtr winProcEstablishConnectionOrig;
-extern winDispatchProcPtr winProcQueryTreeOrig;
-#endif
-
-
/* Called from dix/devices.c */
/*
* All of our keys generate up and down transition notifications,
diff --git a/xorg-server/hw/xwin/InitOutput.c b/xorg-server/hw/xwin/InitOutput.c
index da4e03e98..377877ba9 100644
--- a/xorg-server/hw/xwin/InitOutput.c
+++ b/xorg-server/hw/xwin/InitOutput.c
@@ -59,29 +59,9 @@ typedef HRESULT (__stdcall * SHGETFOLDERPATHPROC)(
);
#endif
-
/*
* References to external symbols
*/
-
-extern int g_iNumScreens;
-extern winScreenInfo * g_ScreenInfo;
-extern char * g_pszCommandLine;
-extern Bool g_fSilentFatalError;
-
-extern const char * g_pszLogFile;
-extern Bool g_fLogFileChanged;
-extern int g_iLogVerbose;
-Bool g_fLogInited;
-
-extern Bool g_fXdmcpEnabled;
-extern Bool g_fAuthEnabled;
-#ifdef HAS_DEVWINDOWS
-extern int g_fdMessageQueue;
-#endif
-extern const char * g_pszQueryHost;
-extern HINSTANCE g_hInstance;
-
#ifdef XWIN_CLIPBOARD
extern Bool g_fUnicodeClipboard;
extern Bool g_fClipboardLaunched;
@@ -91,15 +71,11 @@ extern HWND g_hwndClipboard;
extern Bool g_fClipboard;
#endif
-extern HMODULE g_hmodDirectDraw;
-extern FARPROC g_fpDirectDrawCreate;
-extern FARPROC g_fpDirectDrawCreateClipper;
-
-extern HMODULE g_hmodCommonControls;
-extern FARPROC g_fpTrackMouseEvent;
-extern Bool g_fNoHelpMessageBox;
-extern Bool g_fSilentDupError;
-extern Bool g_fNativeGl;
+
+/*
+ module handle for dynamically loaded comctl32 library
+*/
+static HMODULE g_hmodCommonControls = NULL;
/*
* Function prototypes
@@ -244,13 +220,7 @@ ddxGiveUp (void)
* At this point we aren't creating any new screens, so
* we are guaranteed to not need the DirectDraw functions.
*/
- if (g_hmodDirectDraw != NULL)
- {
- FreeLibrary (g_hmodDirectDraw);
- g_hmodDirectDraw = NULL;
- g_fpDirectDrawCreate = NULL;
- g_fpDirectDrawCreateClipper = NULL;
- }
+ winReleaseDDProcAddresses();
/* Unload our TrackMouseEvent function pointer */
if (g_hmodCommonControls != NULL)
@@ -433,7 +403,7 @@ winFixupPaths (void)
int needs_sep = TRUE;
int comment_block = FALSE;
- /* get defautl fontpath */
+ /* get default fontpath */
char *fontpath = strdup(defaultFontPath);
size_t size = strlen(fontpath);
@@ -881,7 +851,7 @@ winUseMsg (void)
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");
+ "\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"
diff --git a/xorg-server/hw/xwin/Makefile.am b/xorg-server/hw/xwin/Makefile.am
index b32331315..3173fb59d 100644
--- a/xorg-server/hw/xwin/Makefile.am
+++ b/xorg-server/hw/xwin/Makefile.am
@@ -163,8 +163,8 @@ AM_YFLAGS = -d
AM_LFLAGS = -i
AM_CFLAGS = -DHAVE_XWIN_CONFIG_H $(DIX_CFLAGS) \
$(XWINMODULES_CFLAGS) \
- -DXFree86Server \
- -I$(top_srcdir)
+ -I$(top_srcdir) \
+ -Wno-bad-function-cast
MAN_SRCS = XWin.man.pre XWinrc.man.pre
diff --git a/xorg-server/hw/xwin/XWin.man.pre b/xorg-server/hw/xwin/XWin.man.pre
index 6b28b51d4..356eb625d 100644
--- a/xorg-server/hw/xwin/XWin.man.pre
+++ b/xorg-server/hw/xwin/XWin.man.pre
@@ -1,346 +1,346 @@
-.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, such as \fB\-fullscreen\fP, 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-multwindow\fP or \fB-rootless\fP mode
-.TP 8
-.B "\-fullscreen"
-The X server window takes the full screen, covering completely the
-\fIWindows\fP desktop.
-.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
-In windowed mode, allow screens bigger than the \fIWindows\fP desktop.
-Moreover, if the window has decorations, one can now resize it.
-This parameter is ignored when the \fB\-fullscreen\fP parameter is specified.
-
-
-.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]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 engine type. This
-parameter will be ignored if the specified engine type is not
-supported on the current system. The supported engine type ids are 1
-- Shadow GDI, 2 - Shadow DirectDraw, and 4 - Shadow DirectDraw Non-Locking.
-Additionally, there are engines with type ids
-8 - Primary DirectDraw (obsolete) and 16 - Native GDI (experimental and barely functional).
-Default behavior is to determine the engine with optimum performance that
-supports the specified depth and window configuration.
-
-.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 implement the xkeyboard extension for loading
-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 layout matching your current layout as
-reported by \fIWindows\fP if known, or the default X server layout
-if no matching keyboard layout 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)
-
-
-.SH BUGS
-.I XWin
-and this man page still have many limitations. Some of the more obvious
-ones are:
-.br
-- The display mode can not be changed once the X server has started.
-.br
-- 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, such as \fB\-fullscreen\fP, 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-multwindow\fP or \fB-rootless\fP mode
+.TP 8
+.B "\-fullscreen"
+The X server window takes the full screen, covering completely the
+\fIWindows\fP desktop.
+.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
+In windowed mode, allow screens bigger than the \fIWindows\fP desktop.
+Moreover, if the window has decorations, one can now resize it.
+This parameter is ignored when the \fB\-fullscreen\fP parameter is specified.
+
+
+.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]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 engine type. This
+parameter will be ignored if the specified engine type is not
+supported on the current system. The supported engine type ids are 1
+- Shadow GDI, 2 - Shadow DirectDraw, and 4 - Shadow DirectDraw Non-Locking.
+Additionally, there are engines with type ids
+8 - Primary DirectDraw (obsolete) and 16 - Native GDI (experimental and barely functional).
+Default behavior is to determine the engine with optimum performance that
+supports the specified depth and window configuration.
+
+.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)
+
+
+.SH BUGS
+.I XWin
+and this man page still have many limitations. Some of the more obvious
+ones are:
+.br
+- The display mode can not be changed once the X server has started.
+.br
+- 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 18148e63c..99882d4d5 100644
--- a/xorg-server/hw/xwin/win.h
+++ b/xorg-server/hw/xwin/win.h
@@ -275,9 +275,6 @@ typedef Bool (*winFinishCreateWindowsWindowProcPtr)(WindowPtr pWin);
typedef Bool (*winCreateScreenResourcesProc)(ScreenPtr);
-/* Typedef for DIX wrapper functions */
-typedef int (*winDispatchProcPtr) (ClientPtr);
-
/*
* GC (graphics context) privates
@@ -590,6 +587,8 @@ typedef struct {
* Extern declares for general global variables
*/
+#include "winglobals.h"
+
extern winScreenInfo * g_ScreenInfo;
extern miPointerScreenFuncRec g_winPointerCursorFuncs;
extern DWORD g_dwEvents;
@@ -616,16 +615,12 @@ extern const char * g_pszQueryHost;
extern DeviceIntPtr g_pwinPointer;
extern DeviceIntPtr g_pwinKeyboard;
-
/*
- * Extern declares for dynamically loaded libraries and function pointers
+ * Extern declares for dynamically loaded library function pointers
*/
-extern HMODULE g_hmodDirectDraw;
extern FARPROC g_fpDirectDrawCreate;
extern FARPROC g_fpDirectDrawCreateClipper;
-
-extern HMODULE g_hmodCommonControls;
extern FARPROC g_fpTrackMouseEvent;
@@ -830,6 +825,9 @@ winSetEngine (ScreenPtr pScreen);
Bool
winGetDDProcAddresses (void);
+void
+winReleaseDDProcAddresses(void);
+
/*
* winerror.c
diff --git a/xorg-server/hw/xwin/winblock.c b/xorg-server/hw/xwin/winblock.c
index abea60e0f..a70d7a42a 100644
--- a/xorg-server/hw/xwin/winblock.c
+++ b/xorg-server/hw/xwin/winblock.c
@@ -1,106 +1,96 @@
-/*
- *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"
-#include "winmsg.h"
-
-
-/*
- * References to external symbols
- */
-
-extern HWND g_hDlgDepthChange;
-extern HWND g_hDlgExit;
-extern HWND g_hDlgAbout;
-
-
-/* See Porting Layer Definition - p. 6 */
-void
-winBlockHandler (int nScreen,
- pointer pBlockData,
- pointer pTimeout,
- pointer pReadMask)
-{
-#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
- winScreenPriv((ScreenPtr)pBlockData);
-#endif
- MSG msg;
-#ifndef HAS_DEVWINDOWS
- struct timeval **tvp = pTimeout;
- if (*tvp != NULL)
- {
- (*tvp)->tv_sec = 0;
- (*tvp)->tv_usec = 100;
- }
-#endif
-
-#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
- /* Signal threaded modules to begin */
- if (pScreenPriv != NULL && !pScreenPriv->fServerStarted)
- {
- int iReturn;
-
- winDebug ("winBlockHandler - Releasing pmServerStarted\n");
-
- /* Flag that modules are to be started */
- pScreenPriv->fServerStarted = TRUE;
-
- /* Unlock the mutex for threaded modules */
- iReturn = pthread_mutex_unlock (&pScreenPriv->pmServerStarted);
- if (iReturn != 0)
- {
- ErrorF ("winBlockHandler - pthread_mutex_unlock () failed: %d\n",
- iReturn);
- goto winBlockHandler_ProcessMessages;
- }
-
- winDebug ("winBlockHandler - pthread_mutex_unlock () returned\n");
- }
-
-winBlockHandler_ProcessMessages:
-#endif
-
- /* Process all messages on our queue */
- while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
- {
- if ((g_hDlgDepthChange == 0
- || !IsDialogMessage (g_hDlgDepthChange, &msg))
- && (g_hDlgExit == 0
- || !IsDialogMessage (g_hDlgExit, &msg))
- && (g_hDlgAbout == 0
- || !IsDialogMessage (g_hDlgAbout, &msg)))
- {
- DispatchMessage (&msg);
- }
- }
-}
+/*
+ *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"
+#include "winmsg.h"
+
+/* See Porting Layer Definition - p. 6 */
+void
+winBlockHandler (int nScreen,
+ pointer pBlockData,
+ pointer pTimeout,
+ pointer pReadMask)
+{
+#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
+ winScreenPriv((ScreenPtr)pBlockData);
+#endif
+ MSG msg;
+#ifndef HAS_DEVWINDOWS
+ struct timeval **tvp = pTimeout;
+ if (*tvp != NULL)
+ {
+ (*tvp)->tv_sec = 0;
+ (*tvp)->tv_usec = 100;
+ }
+#endif
+
+#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
+ /* Signal threaded modules to begin */
+ if (pScreenPriv != NULL && !pScreenPriv->fServerStarted)
+ {
+ int iReturn;
+
+ winDebug ("winBlockHandler - Releasing pmServerStarted\n");
+
+ /* Flag that modules are to be started */
+ pScreenPriv->fServerStarted = TRUE;
+
+ /* Unlock the mutex for threaded modules */
+ iReturn = pthread_mutex_unlock (&pScreenPriv->pmServerStarted);
+ if (iReturn != 0)
+ {
+ ErrorF ("winBlockHandler - pthread_mutex_unlock () failed: %d\n",
+ iReturn);
+ goto winBlockHandler_ProcessMessages;
+ }
+
+ winDebug ("winBlockHandler - pthread_mutex_unlock () returned\n");
+ }
+
+winBlockHandler_ProcessMessages:
+#endif
+
+ /* Process all messages on our queue */
+ while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
+ {
+ if ((g_hDlgDepthChange == 0
+ || !IsDialogMessage (g_hDlgDepthChange, &msg))
+ && (g_hDlgExit == 0
+ || !IsDialogMessage (g_hDlgExit, &msg))
+ && (g_hDlgAbout == 0
+ || !IsDialogMessage (g_hDlgAbout, &msg)))
+ {
+ DispatchMessage (&msg);
+ }
+ }
+}
diff --git a/xorg-server/hw/xwin/winclipboardthread.c b/xorg-server/hw/xwin/winclipboardthread.c
index 423a174f3..315d2967e 100644
--- a/xorg-server/hw/xwin/winclipboardthread.c
+++ b/xorg-server/hw/xwin/winclipboardthread.c
@@ -480,7 +480,7 @@ winClipboardErrorHandler (Display *pDisplay, XErrorEvent *pErr)
sizeof (pszErrorMsg));
ErrorF ("winClipboardErrorHandler - ERROR: \n\t%s\n"
" errorCode %d\n"
- " serial %d\n"
+ " serial %lu\n"
" resourceID 0x%x\n"
" majorCode %d\n"
" minorCode %d\n"
diff --git a/xorg-server/hw/xwin/winclipboardxevents.c b/xorg-server/hw/xwin/winclipboardxevents.c
index a3d333d80..c21e7e1b5 100644
--- a/xorg-server/hw/xwin/winclipboardxevents.c
+++ b/xorg-server/hw/xwin/winclipboardxevents.c
@@ -78,7 +78,7 @@ winClipboardFlushXEvents (HWND hwnd,
XEvent event;
XSelectionEvent eventSelection;
unsigned long ulReturnBytesLeft;
- unsigned char *pszReturnData = NULL;
+ char *pszReturnData = NULL;
char *pszGlobalData = NULL;
int iReturn;
HGLOBAL hGlobal = NULL;
@@ -225,7 +225,7 @@ winClipboardFlushXEvents (HWND hwnd,
if (!OpenClipboard (hwnd))
{
ErrorF ("winClipboardFlushXEvents - SelectionRequest - "
- "OpenClipboard () failed: %08x\n",
+ "OpenClipboard () failed: %08lx\n",
GetLastError ());
/* Abort */
@@ -275,7 +275,7 @@ winClipboardFlushXEvents (HWND hwnd,
XSetSelectionOwner (pDisplay, XInternAtom (pDisplay, "CLIPBOARD", False), None, CurrentTime);
}
ErrorF ("winClipboardFlushXEvents - SelectionRequest - "
- "GetClipboardData () failed: %08x\n",
+ "GetClipboardData () failed: %08lx\n",
GetLastError ());
/* Abort */
diff --git a/xorg-server/hw/xwin/winconfig.c b/xorg-server/hw/xwin/winconfig.c
index 8357ff576..f654d13da 100644
--- a/xorg-server/hw/xwin/winconfig.c
+++ b/xorg-server/hw/xwin/winconfig.c
@@ -709,8 +709,8 @@ winNameCompare (const char *s1, const char *s2)
while (*s2 == '_' || *s2 == ' ' || *s2 == '\t')
s2++;
- c1 = (isupper (*s1) ? tolower (*s1) : *s1);
- c2 = (isupper (*s2) ? tolower (*s2) : *s2);
+ c1 = (isupper ((int)*s1) ? tolower ((int)*s1) : *s1);
+ c2 = (isupper ((int)*s2) ? tolower ((int)*s2) : *s2);
while (c1 == c2)
{
@@ -724,8 +724,8 @@ winNameCompare (const char *s1, const char *s2)
while (*s2 == '_' || *s2 == ' ' || *s2 == '\t')
s2++;
- c1 = (isupper (*s1) ? tolower (*s1) : *s1);
- c2 = (isupper (*s2) ? tolower (*s2) : *s2);
+ c1 = (isupper ((int)*s1) ? tolower ((int)*s1) : *s1);
+ c2 = (isupper ((int)*s2) ? tolower ((int)*s2) : *s2);
}
return c1 - c2;
}
@@ -1076,8 +1076,8 @@ winNormalizeName (const char *s)
case '\t':
continue;
default:
- if (isupper (*p))
- *q++ = tolower (*p);
+ if (isupper ((int)*p))
+ *q++ = tolower ((int)*p);
else
*q++ = *p;
}
diff --git a/xorg-server/hw/xwin/wincursor.c b/xorg-server/hw/xwin/wincursor.c
index a29e90c66..3cae2361b 100644
--- a/xorg-server/hw/xwin/wincursor.c
+++ b/xorg-server/hw/xwin/wincursor.c
@@ -1,630 +1,628 @@
-/*
- *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 "winmsg.h"
-#include <cursorstr.h>
-#include <mipointrst.h>
-#include <servermd.h>
-#include "misc.h"
-
-extern Bool g_fSoftwareCursor;
-
-#define BRIGHTNESS(x) (x##Red * 0.299 + x##Green * 0.587 + x##Blue * 0.114)
-
-#ifdef _MSC_VER
-#define min(a,b) (((a) < (b)) ? (a) : (b))
-#define max(a,b) (((a) > (b)) ? (a) : (b))
-#endif
-
-/*
- * Local function prototypes
- */
-
-static void
-winPointerWarpCursor (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y);
-
-static Bool
-winCursorOffScreen (ScreenPtr *ppScreen, int *x, int *y);
-
-static void
-winCrossScreen (ScreenPtr pScreen, Bool fEntering);
-
-miPointerScreenFuncRec g_winPointerCursorFuncs =
-{
- winCursorOffScreen,
- winCrossScreen,
- winPointerWarpCursor
-};
-
-
-static void
-winPointerWarpCursor (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
-{
- winScreenPriv(pScreen);
- RECT rcClient;
- static Bool s_fInitialWarp = TRUE;
-
- /* Discard first warp call */
- if (s_fInitialWarp)
- {
- /* First warp moves mouse to center of window, just ignore it */
-
- /* Don't ignore subsequent warps */
- s_fInitialWarp = FALSE;
-
- winDebug ("winPointerWarpCursor - Discarding first warp: %d %d\n",
- x, y);
-
- return;
- }
-
- /*
- Only update the Windows cursor position if root window is active,
- or we are in a rootless mode
- */
- if ((pScreenPriv->hwndScreen == GetForegroundWindow ())
- || pScreenPriv->pScreenInfo->fRootless
-#ifdef XWIN_MULTIWINDOW
- || pScreenPriv->pScreenInfo->fMultiWindow
-#endif
- )
- {
- /* Get the client area coordinates */
- GetClientRect (pScreenPriv->hwndScreen, &rcClient);
-
- /* Translate the client area coords to screen coords */
- MapWindowPoints (pScreenPriv->hwndScreen,
- HWND_DESKTOP,
- (LPPOINT)&rcClient,
- 2);
-
- /*
- * Update the Windows cursor position so that we don't
- * immediately warp back to the current position.
- */
- SetCursorPos (rcClient.left + x, rcClient.top + y);
- }
-
- /* Call the mi warp procedure to do the actual warping in X. */
- miPointerWarpCursor (pDev, pScreen, x, y);
-}
-
-static Bool
-winCursorOffScreen (ScreenPtr *ppScreen, int *x, int *y)
-{
- return FALSE;
-}
-
-static void
-winCrossScreen (ScreenPtr pScreen, Bool fEntering)
-{
-}
-
-static unsigned char
-reverse(unsigned char c)
-{
- int i;
- unsigned char ret = 0;
- for (i = 0; i < 8; ++i)
- {
- ret |= ((c >> i)&1) << (7 - i);
- }
- return ret;
-}
-
-/*
- * Convert X cursor to Windows cursor
- * FIXME: Perhaps there are more smart code
- */
-static HCURSOR
-winLoadCursor (ScreenPtr pScreen, CursorPtr pCursor, int screen)
-{
- winScreenPriv(pScreen);
- HCURSOR hCursor = NULL;
- unsigned char *pAnd;
- unsigned char *pXor;
- int nCX, nCY;
- int nBytes;
- double dForeY, dBackY;
- BOOL fReverse;
- HBITMAP hAnd, hXor;
- ICONINFO ii;
- unsigned char *pCur;
- int x, y;
- unsigned char bit;
- HDC hDC;
- BITMAPV4HEADER bi;
- BITMAPINFO *pbmi;
- unsigned long *lpBits;
-
- winDebug("winLoadCursor: Win32: %dx%d X11: %dx%d hotspot: %d,%d\n",
- pScreenPriv->cursor.sm_cx, pScreenPriv->cursor.sm_cy,
- pCursor->bits->width, pCursor->bits->height,
- pCursor->bits->xhot, pCursor->bits->yhot
- );
-
- /* We can use only White and Black, so calc brightness of color
- * Also check if the cursor is inverted */
- dForeY = BRIGHTNESS(pCursor->fore);
- dBackY = BRIGHTNESS(pCursor->back);
- fReverse = dForeY < dBackY;
-
- /* Check wether the X11 cursor is bigger than the win32 cursor */
- if (pScreenPriv->cursor.sm_cx < pCursor->bits->width ||
- pScreenPriv->cursor.sm_cy < pCursor->bits->height)
- {
- ErrorF ("winLoadCursor - Windows requires %dx%d cursor but X requires %dx%d\n",
- pScreenPriv->cursor.sm_cx, pScreenPriv->cursor.sm_cy,
- pCursor->bits->width, pCursor->bits->height);
- }
-
- /* Get the number of bytes required to store the whole cursor image
- * This is roughly (sm_cx * sm_cy) / 8
- * round up to 8 pixel boundary so we can convert whole bytes */
- nBytes = bits_to_bytes(pScreenPriv->cursor.sm_cx) * pScreenPriv->cursor.sm_cy;
-
- /* Get the effective width and height */
- nCX = min(pScreenPriv->cursor.sm_cx, pCursor->bits->width);
- nCY = min(pScreenPriv->cursor.sm_cy, pCursor->bits->height);
-
- /* Allocate memory for the bitmaps */
- pAnd = malloc (nBytes);
- memset (pAnd, 0xFF, nBytes);
- pXor = calloc (1, nBytes);
-
- /* Convert the X11 bitmap to a win32 bitmap
- * The first is for an empty mask */
- if (pCursor->bits->emptyMask)
- {
- int x, y, xmax = bits_to_bytes(nCX);
- for (y = 0; y < nCY; ++y)
- for (x = 0; x < xmax; ++x)
- {
- int nWinPix = bits_to_bytes(pScreenPriv->cursor.sm_cx) * y + x;
- int nXPix = BitmapBytePad(pCursor->bits->width) * y + x;
-
- pAnd[nWinPix] = 0;
- if (fReverse)
- pXor[nWinPix] = reverse (~pCursor->bits->source[nXPix]);
- else
- pXor[nWinPix] = reverse (pCursor->bits->source[nXPix]);
- }
- }
- else
- {
- int x, y, xmax = bits_to_bytes(nCX);
- for (y = 0; y < nCY; ++y)
- for (x = 0; x < xmax; ++x)
- {
- int nWinPix = bits_to_bytes(pScreenPriv->cursor.sm_cx) * y + x;
- int nXPix = BitmapBytePad(pCursor->bits->width) * y + x;
-
- unsigned char mask = pCursor->bits->mask[nXPix];
- pAnd[nWinPix] = reverse (~mask);
- if (fReverse)
- pXor[nWinPix] = reverse (~pCursor->bits->source[nXPix] & mask);
- else
- pXor[nWinPix] = reverse (pCursor->bits->source[nXPix] & mask);
- }
- }
-
- /* prepare the pointers */
- hCursor = NULL;
- lpBits = NULL;
-
- /* We have a truecolor alpha-blended cursor and can use it! */
- if (pCursor->bits->argb)
- {
- winDebug("winLoadCursor: Trying truecolor alphablended cursor\n");
- memset (&bi, 0, sizeof (BITMAPV4HEADER));
- bi.bV4Size = sizeof(BITMAPV4HEADER);
- bi.bV4Width = pScreenPriv->cursor.sm_cx;
- bi.bV4Height = -(pScreenPriv->cursor.sm_cy); /* right-side up */
- bi.bV4Planes = 1;
- bi.bV4BitCount = 32;
- bi.bV4V4Compression = BI_BITFIELDS;
- bi.bV4RedMask = 0x00FF0000;
- bi.bV4GreenMask = 0x0000FF00;
- bi.bV4BlueMask = 0x000000FF;
- bi.bV4AlphaMask = 0xFF000000;
-
- lpBits = (unsigned long *) calloc (pScreenPriv->cursor.sm_cx*pScreenPriv->cursor.sm_cy,
- sizeof (unsigned long));
-
- if (lpBits)
- {
- for (y=0; y<nCY; y++)
- {
- unsigned long *src, *dst;
- src = &(pCursor->bits->argb[y * pCursor->bits->width]);
- dst = &(lpBits[y * pScreenPriv->cursor.sm_cx]);
- memcpy (dst, src, 4*nCX);
- }
- }
- } /* End if-truecolor-icon */
-
- if (!lpBits)
- {
- /* Bicolor, use a palettized DIB */
- winDebug("winLoadCursor: Trying two color cursor\n");
- pbmi = (BITMAPINFO*)&bi;
- memset (pbmi, 0, sizeof (BITMAPINFOHEADER));
- pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- pbmi->bmiHeader.biWidth = pScreenPriv->cursor.sm_cx;
- pbmi->bmiHeader.biHeight = -abs(pScreenPriv->cursor.sm_cy); /* right-side up */
- pbmi->bmiHeader.biPlanes = 1;
- pbmi->bmiHeader.biBitCount = 8;
- pbmi->bmiHeader.biCompression = BI_RGB;
- pbmi->bmiHeader.biSizeImage = 0;
- pbmi->bmiHeader.biClrUsed = 3;
- pbmi->bmiHeader.biClrImportant = 3;
- pbmi->bmiColors[0].rgbRed = 0; /* Empty */
- pbmi->bmiColors[0].rgbGreen = 0;
- pbmi->bmiColors[0].rgbBlue = 0;
- pbmi->bmiColors[0].rgbReserved = 0;
- pbmi->bmiColors[1].rgbRed = pCursor->backRed>>8; /* Background */
- pbmi->bmiColors[1].rgbGreen = pCursor->backGreen>>8;
- pbmi->bmiColors[1].rgbBlue = pCursor->backBlue>>8;
- pbmi->bmiColors[1].rgbReserved = 0;
- pbmi->bmiColors[2].rgbRed = pCursor->foreRed>>8; /* Foreground */
- pbmi->bmiColors[2].rgbGreen = pCursor->foreGreen>>8;
- pbmi->bmiColors[2].rgbBlue = pCursor->foreBlue>>8;
- pbmi->bmiColors[2].rgbReserved = 0;
-
- lpBits = (unsigned long *) calloc (pScreenPriv->cursor.sm_cx*pScreenPriv->cursor.sm_cy,
- sizeof (char));
-
- pCur = (unsigned char *)lpBits;
- if (lpBits)
- {
- for (y=0; y<pScreenPriv->cursor.sm_cy; y++)
- {
- for (x=0; x<pScreenPriv->cursor.sm_cx; x++)
- {
- if (x>=nCX || y>=nCY) /* Outside of X11 icon bounds */
- (*pCur++) = 0;
- else /* Within X11 icon bounds */
- {
- int nWinPix = bits_to_bytes(pScreenPriv->cursor.sm_cx) * y + (x/8);
-
- bit = pAnd[nWinPix];
- bit = bit & (1<<(7-(x&7)));
- if (!bit) /* Within the cursor mask? */
- {
- int nXPix = BitmapBytePad(pCursor->bits->width) * y + (x/8);
- bit = ~reverse(~pCursor->bits->source[nXPix] & pCursor->bits->mask[nXPix]);
- bit = bit & (1<<(7-(x&7)));
- if (bit) /* Draw foreground */
- (*pCur++) = 2;
- else /* Draw background */
- (*pCur++) = 1;
- }
- else /* Outside the cursor mask */
- (*pCur++) = 0;
- }
- } /* end for (x) */
- } /* end for (y) */
- } /* end if (lpbits) */
- }
-
- /* If one of the previous two methods gave us the bitmap we need, make a cursor */
- if (lpBits)
- {
- winDebug("winLoadCursor: Creating bitmap cursor: hotspot %d,%d\n",
- pCursor->bits->xhot, pCursor->bits->yhot);
-
- hAnd = NULL;
- hXor = NULL;
-
- hAnd = CreateBitmap (pScreenPriv->cursor.sm_cx, pScreenPriv->cursor.sm_cy, 1, 1, pAnd);
-
- hDC = GetDC (NULL);
- if (hDC)
- {
- hXor = CreateCompatibleBitmap (hDC, pScreenPriv->cursor.sm_cx, pScreenPriv->cursor.sm_cy);
- SetDIBits (hDC, hXor, 0, pScreenPriv->cursor.sm_cy, lpBits, (BITMAPINFO*)&bi, DIB_RGB_COLORS);
- ReleaseDC (NULL, hDC);
- }
- free (lpBits);
-
-
- if (hAnd && hXor)
- {
- ii.fIcon = FALSE;
- ii.xHotspot = pCursor->bits->xhot;
- ii.yHotspot = pCursor->bits->yhot;
- ii.hbmMask = hAnd;
- ii.hbmColor = hXor;
- hCursor = (HCURSOR) CreateIconIndirect( &ii );
-
- if (hCursor == NULL)
- winW32Error("winLoadCursor - CreateIconIndirect failed:");
- else
- {
- if (GetIconInfo(hCursor, &ii))
- {
- if (ii.fIcon)
- {
- winDebug("winLoadCursor: CreateIconIndirect returned no cursor. Trying again.\n");
-
- DestroyCursor(hCursor);
-
- ii.fIcon = FALSE;
- ii.xHotspot = pCursor->bits->xhot;
- ii.yHotspot = pCursor->bits->yhot;
- hCursor = (HCURSOR) CreateIconIndirect( &ii );
-
- if (hCursor == NULL)
- winW32Error("winLoadCursor - CreateIconIndirect failed:");
- }
- /* GetIconInfo creates new bitmaps. Destroy them again */
- if (ii.hbmMask)
- DeleteObject(ii.hbmMask);
- if (ii.hbmColor)
- DeleteObject(ii.hbmColor);
- }
- }
- }
-
- if (hAnd)
- DeleteObject (hAnd);
- if (hXor)
- DeleteObject (hXor);
- }
-
- if (!hCursor)
- {
- /* We couldn't make a color cursor for this screen, use
- black and white instead */
- hCursor = CreateCursor (g_hInstance,
- pCursor->bits->xhot, pCursor->bits->yhot,
- pScreenPriv->cursor.sm_cx, pScreenPriv->cursor.sm_cy,
- pAnd, pXor);
- if (hCursor == NULL)
- winW32Error("winLoadCursor - CreateCursor failed:");
- }
- free (pAnd);
- free (pXor);
-
- return hCursor;
-}
-
-/*
-===========================================================================
-
- Pointer sprite functions
-
-===========================================================================
-*/
-
-/*
- * winRealizeCursor
- * Convert the X cursor representation to native format if possible.
- */
-static Bool
-winRealizeCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
-{
- if(pCursor == NULL || pCursor->bits == NULL)
- return FALSE;
-
- /* FIXME: cache ARGB8888 representation? */
-
- return TRUE;
-}
-
-
-/*
- * winUnrealizeCursor
- * Free the storage space associated with a realized cursor.
- */
-static Bool
-winUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
-{
- return TRUE;
-}
-
-
-/*
- * winSetCursor
- * Set the cursor sprite and position.
- */
-static void
-winSetCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, int x, int y)
-{
- POINT ptCurPos, ptTemp;
- HWND hwnd;
- RECT rcClient;
- BOOL bInhibit;
- winScreenPriv(pScreen);
- winDebug("winSetCursor: cursor=%p\n", pCursor);
-
- /* Inhibit changing the cursor if the mouse is not in a client area */
- bInhibit = FALSE;
- if (GetCursorPos (&ptCurPos))
- {
- hwnd = WindowFromPoint (ptCurPos);
- if (hwnd)
- {
- if (GetClientRect (hwnd, &rcClient))
- {
- ptTemp.x = rcClient.left;
- ptTemp.y = rcClient.top;
- if (ClientToScreen (hwnd, &ptTemp))
- {
- rcClient.left = ptTemp.x;
- rcClient.top = ptTemp.y;
- ptTemp.x = rcClient.right;
- ptTemp.y = rcClient.bottom;
- if (ClientToScreen (hwnd, &ptTemp))
- {
- rcClient.right = ptTemp.x;
- rcClient.bottom = ptTemp.y;
- if (!PtInRect (&rcClient, ptCurPos))
- bInhibit = TRUE;
- }
- }
- }
- }
- }
-
- if (pCursor == NULL)
- {
- if (pScreenPriv->cursor.visible)
- {
- if (!bInhibit && g_fSoftwareCursor)
- ShowCursor (FALSE);
- pScreenPriv->cursor.visible = FALSE;
- }
- }
- else
- {
- if (pScreenPriv->cursor.handle)
- {
- if (!bInhibit)
- SetCursor (NULL);
- DestroyCursor (pScreenPriv->cursor.handle);
- pScreenPriv->cursor.handle = NULL;
- }
- pScreenPriv->cursor.handle =
- winLoadCursor (pScreen, pCursor, pScreen->myNum);
- winDebug("winSetCursor: handle=%p\n", pScreenPriv->cursor.handle);
-
- if (!bInhibit)
- SetCursor (pScreenPriv->cursor.handle);
-
- if (!pScreenPriv->cursor.visible)
- {
- if (!bInhibit && g_fSoftwareCursor)
- ShowCursor (TRUE);
- pScreenPriv->cursor.visible = TRUE;
- }
- }
-}
-
-
-/*
- * winMoveCursor
- * Move the cursor. This is a noop for us.
- */
-static void
-winMoveCursor (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
-{
-}
-
-static Bool
-winDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScr)
-{
- winScreenPriv(pScr);
- return pScreenPriv->cursor.spriteFuncs->DeviceCursorInitialize(pDev, pScr);
-}
-
-static void
-winDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScr)
-{
- winScreenPriv(pScr);
- pScreenPriv->cursor.spriteFuncs->DeviceCursorCleanup(pDev, pScr);
-}
-
-static miPointerSpriteFuncRec winSpriteFuncsRec = {
- winRealizeCursor,
- winUnrealizeCursor,
- winSetCursor,
- winMoveCursor,
- winDeviceCursorInitialize,
- winDeviceCursorCleanup
-};
-
-
-/*
-===========================================================================
-
- Other screen functions
-
-===========================================================================
-*/
-
-/*
- * winCursorQueryBestSize
- * Handle queries for best cursor size
- */
-static void
-winCursorQueryBestSize (int class, unsigned short *width,
- unsigned short *height, ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
-
- if (class == CursorShape)
- {
- *width = pScreenPriv->cursor.sm_cx;
- *height = pScreenPriv->cursor.sm_cy;
- }
- else
- {
- if (pScreenPriv->cursor.QueryBestSize)
- (*pScreenPriv->cursor.QueryBestSize)(class, width, height, pScreen);
- }
-}
-
-/*
- * winInitCursor
- * Initialize cursor support
- */
-Bool
-winInitCursor (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- miPointerScreenPtr pPointPriv;
- /* override some screen procedures */
- pScreenPriv->cursor.QueryBestSize = pScreen->QueryBestSize;
- pScreen->QueryBestSize = winCursorQueryBestSize;
-
- pPointPriv = (miPointerScreenPtr)
- dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey);
-
- if (pPointPriv)
- {
- pScreenPriv->cursor.spriteFuncs = pPointPriv->spriteFuncs;
- pPointPriv->spriteFuncs = &winSpriteFuncsRec;
- }
- pScreenPriv->cursor.handle = NULL;
- pScreenPriv->cursor.visible = FALSE;
-
- pScreenPriv->cursor.sm_cx = GetSystemMetrics (SM_CXCURSOR);
- pScreenPriv->cursor.sm_cy = GetSystemMetrics (SM_CYCURSOR);
-
- 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"
+#include "winmsg.h"
+#include <cursorstr.h>
+#include <mipointrst.h>
+#include <servermd.h>
+#include "misc.h"
+
+#define BRIGHTNESS(x) (x##Red * 0.299 + x##Green * 0.587 + x##Blue * 0.114)
+
+#ifdef _MSC_VER
+#define min(a,b) (((a) < (b)) ? (a) : (b))
+#define max(a,b) (((a) > (b)) ? (a) : (b))
+#endif
+
+/*
+ * Local function prototypes
+ */
+
+static void
+winPointerWarpCursor (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y);
+
+static Bool
+winCursorOffScreen (ScreenPtr *ppScreen, int *x, int *y);
+
+static void
+winCrossScreen (ScreenPtr pScreen, Bool fEntering);
+
+miPointerScreenFuncRec g_winPointerCursorFuncs =
+{
+ winCursorOffScreen,
+ winCrossScreen,
+ winPointerWarpCursor
+};
+
+
+static void
+winPointerWarpCursor (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
+{
+ winScreenPriv(pScreen);
+ RECT rcClient;
+ static Bool s_fInitialWarp = TRUE;
+
+ /* Discard first warp call */
+ if (s_fInitialWarp)
+ {
+ /* First warp moves mouse to center of window, just ignore it */
+
+ /* Don't ignore subsequent warps */
+ s_fInitialWarp = FALSE;
+
+ winDebug ("winPointerWarpCursor - Discarding first warp: %d %d\n",
+ x, y);
+
+ return;
+ }
+
+ /*
+ Only update the Windows cursor position if root window is active,
+ or we are in a rootless mode
+ */
+ if ((pScreenPriv->hwndScreen == GetForegroundWindow ())
+ || pScreenPriv->pScreenInfo->fRootless
+#ifdef XWIN_MULTIWINDOW
+ || pScreenPriv->pScreenInfo->fMultiWindow
+#endif
+ )
+ {
+ /* Get the client area coordinates */
+ GetClientRect (pScreenPriv->hwndScreen, &rcClient);
+
+ /* Translate the client area coords to screen coords */
+ MapWindowPoints (pScreenPriv->hwndScreen,
+ HWND_DESKTOP,
+ (LPPOINT)&rcClient,
+ 2);
+
+ /*
+ * Update the Windows cursor position so that we don't
+ * immediately warp back to the current position.
+ */
+ SetCursorPos (rcClient.left + x, rcClient.top + y);
+ }
+
+ /* Call the mi warp procedure to do the actual warping in X. */
+ miPointerWarpCursor (pDev, pScreen, x, y);
+}
+
+static Bool
+winCursorOffScreen (ScreenPtr *ppScreen, int *x, int *y)
+{
+ return FALSE;
+}
+
+static void
+winCrossScreen (ScreenPtr pScreen, Bool fEntering)
+{
+}
+
+static unsigned char
+reverse(unsigned char c)
+{
+ int i;
+ unsigned char ret = 0;
+ for (i = 0; i < 8; ++i)
+ {
+ ret |= ((c >> i)&1) << (7 - i);
+ }
+ return ret;
+}
+
+/*
+ * Convert X cursor to Windows cursor
+ * FIXME: Perhaps there are more smart code
+ */
+static HCURSOR
+winLoadCursor (ScreenPtr pScreen, CursorPtr pCursor, int screen)
+{
+ winScreenPriv(pScreen);
+ HCURSOR hCursor = NULL;
+ unsigned char *pAnd;
+ unsigned char *pXor;
+ int nCX, nCY;
+ int nBytes;
+ double dForeY, dBackY;
+ BOOL fReverse;
+ HBITMAP hAnd, hXor;
+ ICONINFO ii;
+ unsigned char *pCur;
+ int x, y;
+ unsigned char bit;
+ HDC hDC;
+ BITMAPV4HEADER bi;
+ BITMAPINFO *pbmi;
+ unsigned long *lpBits;
+
+ winDebug("winLoadCursor: Win32: %dx%d X11: %dx%d hotspot: %d,%d\n",
+ pScreenPriv->cursor.sm_cx, pScreenPriv->cursor.sm_cy,
+ pCursor->bits->width, pCursor->bits->height,
+ pCursor->bits->xhot, pCursor->bits->yhot
+ );
+
+ /* We can use only White and Black, so calc brightness of color
+ * Also check if the cursor is inverted */
+ dForeY = BRIGHTNESS(pCursor->fore);
+ dBackY = BRIGHTNESS(pCursor->back);
+ fReverse = dForeY < dBackY;
+
+ /* Check wether the X11 cursor is bigger than the win32 cursor */
+ if (pScreenPriv->cursor.sm_cx < pCursor->bits->width ||
+ pScreenPriv->cursor.sm_cy < pCursor->bits->height)
+ {
+ ErrorF ("winLoadCursor - Windows requires %dx%d cursor but X requires %dx%d\n",
+ pScreenPriv->cursor.sm_cx, pScreenPriv->cursor.sm_cy,
+ pCursor->bits->width, pCursor->bits->height);
+ }
+
+ /* Get the number of bytes required to store the whole cursor image
+ * This is roughly (sm_cx * sm_cy) / 8
+ * round up to 8 pixel boundary so we can convert whole bytes */
+ nBytes = bits_to_bytes(pScreenPriv->cursor.sm_cx) * pScreenPriv->cursor.sm_cy;
+
+ /* Get the effective width and height */
+ nCX = min(pScreenPriv->cursor.sm_cx, pCursor->bits->width);
+ nCY = min(pScreenPriv->cursor.sm_cy, pCursor->bits->height);
+
+ /* Allocate memory for the bitmaps */
+ pAnd = malloc (nBytes);
+ memset (pAnd, 0xFF, nBytes);
+ pXor = calloc (1, nBytes);
+
+ /* Convert the X11 bitmap to a win32 bitmap
+ * The first is for an empty mask */
+ if (pCursor->bits->emptyMask)
+ {
+ int x, y, xmax = bits_to_bytes(nCX);
+ for (y = 0; y < nCY; ++y)
+ for (x = 0; x < xmax; ++x)
+ {
+ int nWinPix = bits_to_bytes(pScreenPriv->cursor.sm_cx) * y + x;
+ int nXPix = BitmapBytePad(pCursor->bits->width) * y + x;
+
+ pAnd[nWinPix] = 0;
+ if (fReverse)
+ pXor[nWinPix] = reverse (~pCursor->bits->source[nXPix]);
+ else
+ pXor[nWinPix] = reverse (pCursor->bits->source[nXPix]);
+ }
+ }
+ else
+ {
+ int x, y, xmax = bits_to_bytes(nCX);
+ for (y = 0; y < nCY; ++y)
+ for (x = 0; x < xmax; ++x)
+ {
+ int nWinPix = bits_to_bytes(pScreenPriv->cursor.sm_cx) * y + x;
+ int nXPix = BitmapBytePad(pCursor->bits->width) * y + x;
+
+ unsigned char mask = pCursor->bits->mask[nXPix];
+ pAnd[nWinPix] = reverse (~mask);
+ if (fReverse)
+ pXor[nWinPix] = reverse (~pCursor->bits->source[nXPix] & mask);
+ else
+ pXor[nWinPix] = reverse (pCursor->bits->source[nXPix] & mask);
+ }
+ }
+
+ /* prepare the pointers */
+ hCursor = NULL;
+ lpBits = NULL;
+
+ /* We have a truecolor alpha-blended cursor and can use it! */
+ if (pCursor->bits->argb)
+ {
+ winDebug("winLoadCursor: Trying truecolor alphablended cursor\n");
+ memset (&bi, 0, sizeof (BITMAPV4HEADER));
+ bi.bV4Size = sizeof(BITMAPV4HEADER);
+ bi.bV4Width = pScreenPriv->cursor.sm_cx;
+ bi.bV4Height = -(pScreenPriv->cursor.sm_cy); /* right-side up */
+ bi.bV4Planes = 1;
+ bi.bV4BitCount = 32;
+ bi.bV4V4Compression = BI_BITFIELDS;
+ bi.bV4RedMask = 0x00FF0000;
+ bi.bV4GreenMask = 0x0000FF00;
+ bi.bV4BlueMask = 0x000000FF;
+ bi.bV4AlphaMask = 0xFF000000;
+
+ lpBits = (unsigned long *) calloc (pScreenPriv->cursor.sm_cx*pScreenPriv->cursor.sm_cy,
+ sizeof (unsigned long));
+
+ if (lpBits)
+ {
+ for (y=0; y<nCY; y++)
+ {
+ unsigned long *src, *dst;
+ src = &(pCursor->bits->argb[y * pCursor->bits->width]);
+ dst = &(lpBits[y * pScreenPriv->cursor.sm_cx]);
+ memcpy (dst, src, 4*nCX);
+ }
+ }
+ } /* End if-truecolor-icon */
+
+ if (!lpBits)
+ {
+ /* Bicolor, use a palettized DIB */
+ winDebug("winLoadCursor: Trying two color cursor\n");
+ pbmi = (BITMAPINFO*)&bi;
+ memset (pbmi, 0, sizeof (BITMAPINFOHEADER));
+ pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+ pbmi->bmiHeader.biWidth = pScreenPriv->cursor.sm_cx;
+ pbmi->bmiHeader.biHeight = -abs(pScreenPriv->cursor.sm_cy); /* right-side up */
+ pbmi->bmiHeader.biPlanes = 1;
+ pbmi->bmiHeader.biBitCount = 8;
+ pbmi->bmiHeader.biCompression = BI_RGB;
+ pbmi->bmiHeader.biSizeImage = 0;
+ pbmi->bmiHeader.biClrUsed = 3;
+ pbmi->bmiHeader.biClrImportant = 3;
+ pbmi->bmiColors[0].rgbRed = 0; /* Empty */
+ pbmi->bmiColors[0].rgbGreen = 0;
+ pbmi->bmiColors[0].rgbBlue = 0;
+ pbmi->bmiColors[0].rgbReserved = 0;
+ pbmi->bmiColors[1].rgbRed = pCursor->backRed>>8; /* Background */
+ pbmi->bmiColors[1].rgbGreen = pCursor->backGreen>>8;
+ pbmi->bmiColors[1].rgbBlue = pCursor->backBlue>>8;
+ pbmi->bmiColors[1].rgbReserved = 0;
+ pbmi->bmiColors[2].rgbRed = pCursor->foreRed>>8; /* Foreground */
+ pbmi->bmiColors[2].rgbGreen = pCursor->foreGreen>>8;
+ pbmi->bmiColors[2].rgbBlue = pCursor->foreBlue>>8;
+ pbmi->bmiColors[2].rgbReserved = 0;
+
+ lpBits = (unsigned long *) calloc (pScreenPriv->cursor.sm_cx*pScreenPriv->cursor.sm_cy,
+ sizeof (char));
+
+ pCur = (unsigned char *)lpBits;
+ if (lpBits)
+ {
+ for (y=0; y<pScreenPriv->cursor.sm_cy; y++)
+ {
+ for (x=0; x<pScreenPriv->cursor.sm_cx; x++)
+ {
+ if (x>=nCX || y>=nCY) /* Outside of X11 icon bounds */
+ (*pCur++) = 0;
+ else /* Within X11 icon bounds */
+ {
+ int nWinPix = bits_to_bytes(pScreenPriv->cursor.sm_cx) * y + (x/8);
+
+ bit = pAnd[nWinPix];
+ bit = bit & (1<<(7-(x&7)));
+ if (!bit) /* Within the cursor mask? */
+ {
+ int nXPix = BitmapBytePad(pCursor->bits->width) * y + (x/8);
+ bit = ~reverse(~pCursor->bits->source[nXPix] & pCursor->bits->mask[nXPix]);
+ bit = bit & (1<<(7-(x&7)));
+ if (bit) /* Draw foreground */
+ (*pCur++) = 2;
+ else /* Draw background */
+ (*pCur++) = 1;
+ }
+ else /* Outside the cursor mask */
+ (*pCur++) = 0;
+ }
+ } /* end for (x) */
+ } /* end for (y) */
+ } /* end if (lpbits) */
+ }
+
+ /* If one of the previous two methods gave us the bitmap we need, make a cursor */
+ if (lpBits)
+ {
+ winDebug("winLoadCursor: Creating bitmap cursor: hotspot %d,%d\n",
+ pCursor->bits->xhot, pCursor->bits->yhot);
+
+ hAnd = NULL;
+ hXor = NULL;
+
+ hAnd = CreateBitmap (pScreenPriv->cursor.sm_cx, pScreenPriv->cursor.sm_cy, 1, 1, pAnd);
+
+ hDC = GetDC (NULL);
+ if (hDC)
+ {
+ hXor = CreateCompatibleBitmap (hDC, pScreenPriv->cursor.sm_cx, pScreenPriv->cursor.sm_cy);
+ SetDIBits (hDC, hXor, 0, pScreenPriv->cursor.sm_cy, lpBits, (BITMAPINFO*)&bi, DIB_RGB_COLORS);
+ ReleaseDC (NULL, hDC);
+ }
+ free (lpBits);
+
+
+ if (hAnd && hXor)
+ {
+ ii.fIcon = FALSE;
+ ii.xHotspot = pCursor->bits->xhot;
+ ii.yHotspot = pCursor->bits->yhot;
+ ii.hbmMask = hAnd;
+ ii.hbmColor = hXor;
+ hCursor = (HCURSOR) CreateIconIndirect( &ii );
+
+ if (hCursor == NULL)
+ winW32Error("winLoadCursor - CreateIconIndirect failed:");
+ else
+ {
+ if (GetIconInfo(hCursor, &ii))
+ {
+ if (ii.fIcon)
+ {
+ winDebug("winLoadCursor: CreateIconIndirect returned no cursor. Trying again.\n");
+
+ DestroyCursor(hCursor);
+
+ ii.fIcon = FALSE;
+ ii.xHotspot = pCursor->bits->xhot;
+ ii.yHotspot = pCursor->bits->yhot;
+ hCursor = (HCURSOR) CreateIconIndirect( &ii );
+
+ if (hCursor == NULL)
+ winW32Error("winLoadCursor - CreateIconIndirect failed:");
+ }
+ /* GetIconInfo creates new bitmaps. Destroy them again */
+ if (ii.hbmMask)
+ DeleteObject(ii.hbmMask);
+ if (ii.hbmColor)
+ DeleteObject(ii.hbmColor);
+ }
+ }
+ }
+
+ if (hAnd)
+ DeleteObject (hAnd);
+ if (hXor)
+ DeleteObject (hXor);
+ }
+
+ if (!hCursor)
+ {
+ /* We couldn't make a color cursor for this screen, use
+ black and white instead */
+ hCursor = CreateCursor (g_hInstance,
+ pCursor->bits->xhot, pCursor->bits->yhot,
+ pScreenPriv->cursor.sm_cx, pScreenPriv->cursor.sm_cy,
+ pAnd, pXor);
+ if (hCursor == NULL)
+ winW32Error("winLoadCursor - CreateCursor failed:");
+ }
+ free (pAnd);
+ free (pXor);
+
+ return hCursor;
+}
+
+/*
+===========================================================================
+
+ Pointer sprite functions
+
+===========================================================================
+*/
+
+/*
+ * winRealizeCursor
+ * Convert the X cursor representation to native format if possible.
+ */
+static Bool
+winRealizeCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
+{
+ if(pCursor == NULL || pCursor->bits == NULL)
+ return FALSE;
+
+ /* FIXME: cache ARGB8888 representation? */
+
+ return TRUE;
+}
+
+
+/*
+ * winUnrealizeCursor
+ * Free the storage space associated with a realized cursor.
+ */
+static Bool
+winUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
+{
+ return TRUE;
+}
+
+
+/*
+ * winSetCursor
+ * Set the cursor sprite and position.
+ */
+static void
+winSetCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, int x, int y)
+{
+ POINT ptCurPos, ptTemp;
+ HWND hwnd;
+ RECT rcClient;
+ BOOL bInhibit;
+ winScreenPriv(pScreen);
+ winDebug("winSetCursor: cursor=%p\n", pCursor);
+
+ /* Inhibit changing the cursor if the mouse is not in a client area */
+ bInhibit = FALSE;
+ if (GetCursorPos (&ptCurPos))
+ {
+ hwnd = WindowFromPoint (ptCurPos);
+ if (hwnd)
+ {
+ if (GetClientRect (hwnd, &rcClient))
+ {
+ ptTemp.x = rcClient.left;
+ ptTemp.y = rcClient.top;
+ if (ClientToScreen (hwnd, &ptTemp))
+ {
+ rcClient.left = ptTemp.x;
+ rcClient.top = ptTemp.y;
+ ptTemp.x = rcClient.right;
+ ptTemp.y = rcClient.bottom;
+ if (ClientToScreen (hwnd, &ptTemp))
+ {
+ rcClient.right = ptTemp.x;
+ rcClient.bottom = ptTemp.y;
+ if (!PtInRect (&rcClient, ptCurPos))
+ bInhibit = TRUE;
+ }
+ }
+ }
+ }
+ }
+
+ if (pCursor == NULL)
+ {
+ if (pScreenPriv->cursor.visible)
+ {
+ if (!bInhibit && g_fSoftwareCursor)
+ ShowCursor (FALSE);
+ pScreenPriv->cursor.visible = FALSE;
+ }
+ }
+ else
+ {
+ if (pScreenPriv->cursor.handle)
+ {
+ if (!bInhibit)
+ SetCursor (NULL);
+ DestroyCursor (pScreenPriv->cursor.handle);
+ pScreenPriv->cursor.handle = NULL;
+ }
+ pScreenPriv->cursor.handle =
+ winLoadCursor (pScreen, pCursor, pScreen->myNum);
+ winDebug("winSetCursor: handle=%p\n", pScreenPriv->cursor.handle);
+
+ if (!bInhibit)
+ SetCursor (pScreenPriv->cursor.handle);
+
+ if (!pScreenPriv->cursor.visible)
+ {
+ if (!bInhibit && g_fSoftwareCursor)
+ ShowCursor (TRUE);
+ pScreenPriv->cursor.visible = TRUE;
+ }
+ }
+}
+
+
+/*
+ * winMoveCursor
+ * Move the cursor. This is a noop for us.
+ */
+static void
+winMoveCursor (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
+{
+}
+
+static Bool
+winDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScr)
+{
+ winScreenPriv(pScr);
+ return pScreenPriv->cursor.spriteFuncs->DeviceCursorInitialize(pDev, pScr);
+}
+
+static void
+winDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScr)
+{
+ winScreenPriv(pScr);
+ pScreenPriv->cursor.spriteFuncs->DeviceCursorCleanup(pDev, pScr);
+}
+
+static miPointerSpriteFuncRec winSpriteFuncsRec = {
+ winRealizeCursor,
+ winUnrealizeCursor,
+ winSetCursor,
+ winMoveCursor,
+ winDeviceCursorInitialize,
+ winDeviceCursorCleanup
+};
+
+
+/*
+===========================================================================
+
+ Other screen functions
+
+===========================================================================
+*/
+
+/*
+ * winCursorQueryBestSize
+ * Handle queries for best cursor size
+ */
+static void
+winCursorQueryBestSize (int class, unsigned short *width,
+ unsigned short *height, ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+
+ if (class == CursorShape)
+ {
+ *width = pScreenPriv->cursor.sm_cx;
+ *height = pScreenPriv->cursor.sm_cy;
+ }
+ else
+ {
+ if (pScreenPriv->cursor.QueryBestSize)
+ (*pScreenPriv->cursor.QueryBestSize)(class, width, height, pScreen);
+ }
+}
+
+/*
+ * winInitCursor
+ * Initialize cursor support
+ */
+Bool
+winInitCursor (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ miPointerScreenPtr pPointPriv;
+ /* override some screen procedures */
+ pScreenPriv->cursor.QueryBestSize = pScreen->QueryBestSize;
+ pScreen->QueryBestSize = winCursorQueryBestSize;
+
+ pPointPriv = (miPointerScreenPtr)
+ dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey);
+
+ if (pPointPriv)
+ {
+ pScreenPriv->cursor.spriteFuncs = pPointPriv->spriteFuncs;
+ pPointPriv->spriteFuncs = &winSpriteFuncsRec;
+ }
+ pScreenPriv->cursor.handle = NULL;
+ pScreenPriv->cursor.visible = FALSE;
+
+ pScreenPriv->cursor.sm_cx = GetSystemMetrics (SM_CXCURSOR);
+ pScreenPriv->cursor.sm_cy = GetSystemMetrics (SM_CYCURSOR);
+
+ return TRUE;
+}
diff --git a/xorg-server/hw/xwin/windialogs.c b/xorg-server/hw/xwin/windialogs.c
index 17d4d3226..839498fbc 100644
--- a/xorg-server/hw/xwin/windialogs.c
+++ b/xorg-server/hw/xwin/windialogs.c
@@ -44,21 +44,9 @@
* References to external globals
*/
-extern Bool g_fCursor;
-extern HWND g_hDlgDepthChange;
-extern HWND g_hDlgExit;
-extern HWND g_hDlgAbout;
-extern WINPREFS pref;
#ifdef XWIN_CLIPBOARD
extern Bool g_fClipboardStarted;
#endif
-extern Bool g_fSoftwareCursor;
-
-#if defined(XWIN_MULTIWINDOW)
-extern HICON g_hIconX;
-extern HICON g_hSmallIconX;
-#endif
-
/*
* Local function prototypes
*/
diff --git a/xorg-server/hw/xwin/winengine.c b/xorg-server/hw/xwin/winengine.c
index fadd11b39..a1fecacdd 100644
--- a/xorg-server/hw/xwin/winengine.c
+++ b/xorg-server/hw/xwin/winengine.c
@@ -1,336 +1,352 @@
-/*
- *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"
-#include "winmsg.h"
-
-
-/*
- * External global variables
- */
-
-extern const GUID _IID_IDirectDraw4;
-
-
-/*
- * Detect engines supported by current Windows version
- * DirectDraw version and hardware
- */
-
-void
-winDetectSupportedEngines (void)
-{
- OSVERSIONINFO osvi;
-
- /* Initialize the engine support flags */
- g_dwEnginesSupported = WIN_SERVER_SHADOW_GDI;
-
-#ifdef XWIN_NATIVEGDI
- g_dwEnginesSupported |= WIN_SERVER_NATIVE_GDI;
-#endif
-
- /* Get operating system version information */
- ZeroMemory (&osvi, sizeof (osvi));
- osvi.dwOSVersionInfoSize = sizeof (osvi);
- GetVersionEx (&osvi);
-
- /* Branch on platform ID */
- switch (osvi.dwPlatformId)
- {
- case VER_PLATFORM_WIN32_NT:
- /* Engine 4 is supported on NT only */
- winDebug ("winDetectSupportedEngines - Windows NT/2000/XP\n");
- break;
-
- case VER_PLATFORM_WIN32_WINDOWS:
- /* Engine 4 is supported on NT only */
- winDebug ("winDetectSupportedEngines - Windows 95/98/Me\n");
- break;
- }
-
- /* Do we have DirectDraw? */
- if (g_hmodDirectDraw != NULL)
- {
- LPDIRECTDRAW lpdd = NULL;
- LPDIRECTDRAW4 lpdd4 = NULL;
- HRESULT ddrval;
-
- /* Was the DirectDrawCreate function found? */
- if (g_fpDirectDrawCreate == NULL)
- {
- /* No DirectDraw support */
- return;
- }
-
- /* DirectDrawCreate exists, try to call it */
- /* Create a DirectDraw object, store the address at lpdd */
- ddrval = (*g_fpDirectDrawCreate) (NULL,
- (void**) &lpdd,
- NULL);
- if (FAILED (ddrval))
- {
- /* No DirectDraw support */
- winDebug ("winDetectSupportedEngines - DirectDraw not installed\n");
- return;
- }
- else
- {
- /* We have DirectDraw */
- winDebug ("winDetectSupportedEngines - DirectDraw installed\n");
- g_dwEnginesSupported |= WIN_SERVER_SHADOW_DD;
-
-#ifdef XWIN_PRIMARYFB
- /* Allow PrimaryDD engine if NT */
- if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT)
- {
- g_dwEnginesSupported |= WIN_SERVER_PRIMARY_DD;
- winDebug ("winDetectSupportedEngines - Allowing PrimaryDD\n");
- }
-#endif
- }
-
- /* Try to query for DirectDraw4 interface */
- ddrval = IDirectDraw_QueryInterface (lpdd,
- &IID_IDirectDraw4,
- (LPVOID*) &lpdd4);
- if (SUCCEEDED (ddrval))
- {
- /* We have DirectDraw4 */
- winDebug ("winDetectSupportedEngines - DirectDraw4 installed\n");
- g_dwEnginesSupported |= WIN_SERVER_SHADOW_DDNL;
- }
-
- /* Cleanup DirectDraw interfaces */
- if (lpdd4 != NULL)
- IDirectDraw_Release (lpdd4);
- if (lpdd != NULL)
- IDirectDraw_Release (lpdd);
- }
-
- winDebug ("winDetectSupportedEngines - Returning, supported engines %08x\n",
- (unsigned int) g_dwEnginesSupported);
-}
-
-
-/*
- * Set the engine type, depending on the engines
- * supported for this screen, and whether the user
- * suggested an engine type
- */
-
-Bool
-winSetEngine (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- HDC hdc;
- DWORD dwBPP;
-
- /* Get a DC */
- hdc = GetDC (NULL);
- if (hdc == NULL)
- {
- ErrorF ("winSetEngine - Couldn't get an HDC\n");
- return FALSE;
- }
-
- /*
- * pScreenInfo->dwBPP may be 0 to indicate that the current screen
- * depth is to be used. Thus, we must query for the current display
- * depth here.
- */
- dwBPP = GetDeviceCaps (hdc, BITSPIXEL);
-
- /* Release the DC */
- ReleaseDC (NULL, hdc);
- hdc = NULL;
-
- /* ShadowGDI is the only engine that supports windowed PseudoColor */
- if (dwBPP == 8 && !pScreenInfo->fFullScreen)
- {
- winDebug ("winSetEngine - Windowed && PseudoColor => ShadowGDI\n");
- pScreenInfo->dwEngine = WIN_SERVER_SHADOW_GDI;
-
- /* Set engine function pointers */
- winSetEngineFunctionsShadowGDI (pScreen);
- return TRUE;
- }
-
- /* ShadowGDI is the only engine that supports Multi Window Mode */
- if (
-#ifdef XWIN_MULTIWINDOWEXTWM
- pScreenInfo->fMWExtWM
-#else
- FALSE
-#endif
-#ifdef XWIN_MULTIWINDOW
- || pScreenInfo->fMultiWindow
-#else
- || FALSE
-#endif
- )
- {
- winDebug ("winSetEngine - Multi Window or Rootless => ShadowGDI\n");
- pScreenInfo->dwEngine = WIN_SERVER_SHADOW_GDI;
-
- /* Set engine function pointers */
- winSetEngineFunctionsShadowGDI (pScreen);
- return TRUE;
- }
-
- /* If the user's choice is supported, we'll use that */
- if (g_dwEnginesSupported & pScreenInfo->dwEnginePreferred)
- {
- winDebug ("winSetEngine - Using user's preference: %d\n",
- (int) pScreenInfo->dwEnginePreferred);
- pScreenInfo->dwEngine = pScreenInfo->dwEnginePreferred;
-
- /* Setup engine function pointers */
- switch (pScreenInfo->dwEngine)
- {
- case WIN_SERVER_SHADOW_GDI:
- winSetEngineFunctionsShadowGDI (pScreen);
- break;
- case WIN_SERVER_SHADOW_DD:
- winSetEngineFunctionsShadowDD (pScreen);
- break;
- case WIN_SERVER_SHADOW_DDNL:
- winSetEngineFunctionsShadowDDNL (pScreen);
- break;
-#ifdef XWIN_PRIMARYFB
- case WIN_SERVER_PRIMARY_DD:
- winSetEngineFunctionsPrimaryDD (pScreen);
- break;
-#endif
-#ifdef XWIN_NATIVEGDI
- case WIN_SERVER_NATIVE_GDI:
- winSetEngineFunctionsNativeGDI (pScreen);
- break;
-#endif
- default:
- FatalError ("winSetEngine - Invalid engine type\n");
- }
- return TRUE;
- }
-
- /* ShadowDDNL has good performance, so why not */
- if (g_dwEnginesSupported & WIN_SERVER_SHADOW_DDNL)
- {
- winDebug ("winSetEngine - Using Shadow DirectDraw NonLocking\n");
- pScreenInfo->dwEngine = WIN_SERVER_SHADOW_DDNL;
-
- /* Set engine function pointers */
- winSetEngineFunctionsShadowDDNL (pScreen);
- return TRUE;
- }
-
- /* ShadowDD is next in line */
- if (g_dwEnginesSupported & WIN_SERVER_SHADOW_DD)
- {
- winDebug ("winSetEngine - Using Shadow DirectDraw\n");
- pScreenInfo->dwEngine = WIN_SERVER_SHADOW_DD;
-
- /* Set engine function pointers */
- winSetEngineFunctionsShadowDD (pScreen);
- return TRUE;
- }
-
- /* ShadowGDI is next in line */
- if (g_dwEnginesSupported & WIN_SERVER_SHADOW_GDI)
- {
- winDebug ("winSetEngine - Using Shadow GDI DIB\n");
- pScreenInfo->dwEngine = WIN_SERVER_SHADOW_GDI;
-
- /* Set engine function pointers */
- winSetEngineFunctionsShadowGDI (pScreen);
- return TRUE;
- }
-
- return TRUE;
-}
-
-
-/*
- * Get procedure addresses for DirectDrawCreate and DirectDrawCreateClipper
- */
-
-Bool
-winGetDDProcAddresses (void)
-{
- Bool fReturn = TRUE;
-
- /* Load the DirectDraw library */
- g_hmodDirectDraw = LoadLibraryEx ("ddraw.dll", NULL, 0);
- if (g_hmodDirectDraw == NULL)
- {
- ErrorF ("winGetDDProcAddresses - Could not load ddraw.dll\n");
- fReturn = TRUE;
- goto winGetDDProcAddresses_Exit;
- }
-
- /* Try to get the DirectDrawCreate address */
- g_fpDirectDrawCreate = GetProcAddress (g_hmodDirectDraw,
- "DirectDrawCreate");
- if (g_fpDirectDrawCreate == NULL)
- {
- ErrorF ("winGetDDProcAddresses - Could not get DirectDrawCreate "
- "address\n");
- fReturn = TRUE;
- goto winGetDDProcAddresses_Exit;
- }
-
- /* Try to get the DirectDrawCreateClipper address */
- g_fpDirectDrawCreateClipper = GetProcAddress (g_hmodDirectDraw,
- "DirectDrawCreateClipper");
- if (g_fpDirectDrawCreateClipper == NULL)
- {
- ErrorF ("winGetDDProcAddresses - Could not get "
- "DirectDrawCreateClipper address\n");
- fReturn = FALSE;
- goto winGetDDProcAddresses_Exit;
- }
-
- /*
- * Note: Do not unload ddraw.dll here. Do it in GiveUp
- */
-
- winGetDDProcAddresses_Exit:
- /* Unload the DirectDraw library if we failed to initialize */
- if (!fReturn && g_hmodDirectDraw != NULL)
- {
- FreeLibrary (g_hmodDirectDraw);
- g_hmodDirectDraw = NULL;
- }
-
- return fReturn;
-}
+/*
+ *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"
+#include "winmsg.h"
+
+/*
+ * Global variables for function pointers into
+ * dynamically loaded libraries
+ */
+FARPROC g_fpDirectDrawCreate = NULL;
+FARPROC g_fpDirectDrawCreateClipper = NULL;
+
+/*
+ module handle for dynamically loaded directdraw library
+*/
+static HMODULE g_hmodDirectDraw = NULL;
+
+/*
+ * Detect engines supported by current Windows version
+ * DirectDraw version and hardware
+ */
+
+void
+winDetectSupportedEngines (void)
+{
+ OSVERSIONINFO osvi;
+
+ /* Initialize the engine support flags */
+ g_dwEnginesSupported = WIN_SERVER_SHADOW_GDI;
+
+#ifdef XWIN_NATIVEGDI
+ g_dwEnginesSupported |= WIN_SERVER_NATIVE_GDI;
+#endif
+
+ /* Get operating system version information */
+ ZeroMemory (&osvi, sizeof (osvi));
+ osvi.dwOSVersionInfoSize = sizeof (osvi);
+ GetVersionEx (&osvi);
+
+ /* Branch on platform ID */
+ switch (osvi.dwPlatformId)
+ {
+ case VER_PLATFORM_WIN32_NT:
+ /* Engine 4 is supported on NT only */
+ winDebug ("winDetectSupportedEngines - Windows NT/2000/XP\n");
+ break;
+
+ case VER_PLATFORM_WIN32_WINDOWS:
+ /* Engine 4 is supported on NT only */
+ winDebug ("winDetectSupportedEngines - Windows 95/98/Me\n");
+ break;
+ }
+
+ /* Do we have DirectDraw? */
+ if (g_hmodDirectDraw != NULL)
+ {
+ LPDIRECTDRAW lpdd = NULL;
+ LPDIRECTDRAW4 lpdd4 = NULL;
+ HRESULT ddrval;
+
+ /* Was the DirectDrawCreate function found? */
+ if (g_fpDirectDrawCreate == NULL)
+ {
+ /* No DirectDraw support */
+ return;
+ }
+
+ /* DirectDrawCreate exists, try to call it */
+ /* Create a DirectDraw object, store the address at lpdd */
+ ddrval = (*g_fpDirectDrawCreate) (NULL,
+ (void**) &lpdd,
+ NULL);
+ if (FAILED (ddrval))
+ {
+ /* No DirectDraw support */
+ winDebug ("winDetectSupportedEngines - DirectDraw not installed\n");
+ return;
+ }
+ else
+ {
+ /* We have DirectDraw */
+ winDebug ("winDetectSupportedEngines - DirectDraw installed\n");
+ g_dwEnginesSupported |= WIN_SERVER_SHADOW_DD;
+
+#ifdef XWIN_PRIMARYFB
+ /* Allow PrimaryDD engine if NT */
+ if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT)
+ {
+ g_dwEnginesSupported |= WIN_SERVER_PRIMARY_DD;
+ winDebug ("winDetectSupportedEngines - Allowing PrimaryDD\n");
+ }
+#endif
+ }
+
+ /* Try to query for DirectDraw4 interface */
+ ddrval = IDirectDraw_QueryInterface (lpdd,
+ &IID_IDirectDraw4,
+ (LPVOID*) &lpdd4);
+ if (SUCCEEDED (ddrval))
+ {
+ /* We have DirectDraw4 */
+ winDebug ("winDetectSupportedEngines - DirectDraw4 installed\n");
+ g_dwEnginesSupported |= WIN_SERVER_SHADOW_DDNL;
+ }
+
+ /* Cleanup DirectDraw interfaces */
+ if (lpdd4 != NULL)
+ IDirectDraw_Release (lpdd4);
+ if (lpdd != NULL)
+ IDirectDraw_Release (lpdd);
+ }
+
+ winDebug ("winDetectSupportedEngines - Returning, supported engines %08x\n",
+ (unsigned int) g_dwEnginesSupported);
+}
+
+
+/*
+ * Set the engine type, depending on the engines
+ * supported for this screen, and whether the user
+ * suggested an engine type
+ */
+
+Bool
+winSetEngine (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ HDC hdc;
+ DWORD dwBPP;
+
+ /* Get a DC */
+ hdc = GetDC (NULL);
+ if (hdc == NULL)
+ {
+ ErrorF ("winSetEngine - Couldn't get an HDC\n");
+ return FALSE;
+ }
+
+ /*
+ * pScreenInfo->dwBPP may be 0 to indicate that the current screen
+ * depth is to be used. Thus, we must query for the current display
+ * depth here.
+ */
+ dwBPP = GetDeviceCaps (hdc, BITSPIXEL);
+
+ /* Release the DC */
+ ReleaseDC (NULL, hdc);
+ hdc = NULL;
+
+ /* ShadowGDI is the only engine that supports windowed PseudoColor */
+ if (dwBPP == 8 && !pScreenInfo->fFullScreen)
+ {
+ winDebug ("winSetEngine - Windowed && PseudoColor => ShadowGDI\n");
+ pScreenInfo->dwEngine = WIN_SERVER_SHADOW_GDI;
+
+ /* Set engine function pointers */
+ winSetEngineFunctionsShadowGDI (pScreen);
+ return TRUE;
+ }
+
+ /* ShadowGDI is the only engine that supports Multi Window Mode */
+ if (
+#ifdef XWIN_MULTIWINDOWEXTWM
+ pScreenInfo->fMWExtWM
+#else
+ FALSE
+#endif
+#ifdef XWIN_MULTIWINDOW
+ || pScreenInfo->fMultiWindow
+#else
+ || FALSE
+#endif
+ )
+ {
+ winDebug ("winSetEngine - Multi Window or Rootless => ShadowGDI\n");
+ pScreenInfo->dwEngine = WIN_SERVER_SHADOW_GDI;
+
+ /* Set engine function pointers */
+ winSetEngineFunctionsShadowGDI (pScreen);
+ return TRUE;
+ }
+
+ /* If the user's choice is supported, we'll use that */
+ if (g_dwEnginesSupported & pScreenInfo->dwEnginePreferred)
+ {
+ winDebug ("winSetEngine - Using user's preference: %d\n",
+ (int) pScreenInfo->dwEnginePreferred);
+ pScreenInfo->dwEngine = pScreenInfo->dwEnginePreferred;
+
+ /* Setup engine function pointers */
+ switch (pScreenInfo->dwEngine)
+ {
+ case WIN_SERVER_SHADOW_GDI:
+ winSetEngineFunctionsShadowGDI (pScreen);
+ break;
+ case WIN_SERVER_SHADOW_DD:
+ winSetEngineFunctionsShadowDD (pScreen);
+ break;
+ case WIN_SERVER_SHADOW_DDNL:
+ winSetEngineFunctionsShadowDDNL (pScreen);
+ break;
+#ifdef XWIN_PRIMARYFB
+ case WIN_SERVER_PRIMARY_DD:
+ winSetEngineFunctionsPrimaryDD (pScreen);
+ break;
+#endif
+#ifdef XWIN_NATIVEGDI
+ case WIN_SERVER_NATIVE_GDI:
+ winSetEngineFunctionsNativeGDI (pScreen);
+ break;
+#endif
+ default:
+ FatalError ("winSetEngine - Invalid engine type\n");
+ }
+ return TRUE;
+ }
+
+ /* ShadowDDNL has good performance, so why not */
+ if (g_dwEnginesSupported & WIN_SERVER_SHADOW_DDNL)
+ {
+ winDebug ("winSetEngine - Using Shadow DirectDraw NonLocking\n");
+ pScreenInfo->dwEngine = WIN_SERVER_SHADOW_DDNL;
+
+ /* Set engine function pointers */
+ winSetEngineFunctionsShadowDDNL (pScreen);
+ return TRUE;
+ }
+
+ /* ShadowDD is next in line */
+ if (g_dwEnginesSupported & WIN_SERVER_SHADOW_DD)
+ {
+ winDebug ("winSetEngine - Using Shadow DirectDraw\n");
+ pScreenInfo->dwEngine = WIN_SERVER_SHADOW_DD;
+
+ /* Set engine function pointers */
+ winSetEngineFunctionsShadowDD (pScreen);
+ return TRUE;
+ }
+
+ /* ShadowGDI is next in line */
+ if (g_dwEnginesSupported & WIN_SERVER_SHADOW_GDI)
+ {
+ winDebug ("winSetEngine - Using Shadow GDI DIB\n");
+ pScreenInfo->dwEngine = WIN_SERVER_SHADOW_GDI;
+
+ /* Set engine function pointers */
+ winSetEngineFunctionsShadowGDI (pScreen);
+ return TRUE;
+ }
+
+ return TRUE;
+}
+
+
+/*
+ * Get procedure addresses for DirectDrawCreate and DirectDrawCreateClipper
+ */
+
+Bool
+winGetDDProcAddresses (void)
+{
+ Bool fReturn = TRUE;
+
+ /* Load the DirectDraw library */
+ g_hmodDirectDraw = LoadLibraryEx ("ddraw.dll", NULL, 0);
+ if (g_hmodDirectDraw == NULL)
+ {
+ ErrorF ("winGetDDProcAddresses - Could not load ddraw.dll\n");
+ fReturn = TRUE;
+ goto winGetDDProcAddresses_Exit;
+ }
+
+ /* Try to get the DirectDrawCreate address */
+ g_fpDirectDrawCreate = GetProcAddress (g_hmodDirectDraw,
+ "DirectDrawCreate");
+ if (g_fpDirectDrawCreate == NULL)
+ {
+ ErrorF ("winGetDDProcAddresses - Could not get DirectDrawCreate "
+ "address\n");
+ fReturn = TRUE;
+ goto winGetDDProcAddresses_Exit;
+ }
+
+ /* Try to get the DirectDrawCreateClipper address */
+ g_fpDirectDrawCreateClipper = GetProcAddress (g_hmodDirectDraw,
+ "DirectDrawCreateClipper");
+ if (g_fpDirectDrawCreateClipper == NULL)
+ {
+ ErrorF ("winGetDDProcAddresses - Could not get "
+ "DirectDrawCreateClipper address\n");
+ fReturn = FALSE;
+ goto winGetDDProcAddresses_Exit;
+ }
+
+ /*
+ * Note: Do not unload ddraw.dll here. Do it in GiveUp
+ */
+
+ winGetDDProcAddresses_Exit:
+ /* Unload the DirectDraw library if we failed to initialize */
+ if (!fReturn && g_hmodDirectDraw != NULL)
+ {
+ FreeLibrary (g_hmodDirectDraw);
+ g_hmodDirectDraw = NULL;
+ }
+
+ return fReturn;
+}
+
+void
+winReleaseDDProcAddresses(void)
+{
+ if (g_hmodDirectDraw != NULL)
+ {
+ FreeLibrary (g_hmodDirectDraw);
+ g_hmodDirectDraw = NULL;
+ g_fpDirectDrawCreate = NULL;
+ g_fpDirectDrawCreateClipper = NULL;
+ }
+}
diff --git a/xorg-server/hw/xwin/winerror.c b/xorg-server/hw/xwin/winerror.c
index 97ac23998..edcc4db65 100644
--- a/xorg-server/hw/xwin/winerror.c
+++ b/xorg-server/hw/xwin/winerror.c
@@ -31,21 +31,11 @@
#ifdef HAVE_XWIN_CONFIG_H
#include <xwin-config.h>
#endif
-#ifdef XVENDORNAME
-#define VENDOR_STRING XVENDORNAME
-#define VENDOR_CONTACT BUILDERADDR
-#endif
#include <../xfree86/common/xorgVersion.h>
#include "win.h"
-/* References to external symbols */
-extern char * g_pszCommandLine;
-extern const char * g_pszLogFile;
-extern Bool g_fSilentFatalError;
extern Bool g_fSilentDupError;
-extern Bool g_fLogInited;
-
#ifdef DDXOSVERRORF
/* Prototype */
void
@@ -149,11 +139,12 @@ winMessageBoxF (const char *pszError, UINT uType, ...)
"%s\n"
pszMsgBox = Xprintf (MESSAGEBOXF,
- pszErrorF, VENDOR_STRING,
+ pszErrorF, XVENDORNAME,
XORG_VERSION_MAJOR, XORG_VERSION_MINOR, XORG_VERSION_PATCH, XORG_VERSION_SNAP, XORG_VERSION_CURRENT,
- VENDOR_CONTACT,
+ BUILDERADDR,
BUILDERSTRING,
- g_pszCommandLine);
+ g_pszCommandLine);
+
if (!pszMsgBox)
goto winMessageBoxF_Cleanup;
diff --git a/xorg-server/hw/xwin/winglobals.c b/xorg-server/hw/xwin/winglobals.c
index 5d5c79677..f80d09364 100644
--- a/xorg-server/hw/xwin/winglobals.c
+++ b/xorg-server/hw/xwin/winglobals.c
@@ -73,8 +73,6 @@ char * g_pszCommandLine = NULL;
Bool g_fSilentFatalError = FALSE;
DWORD g_dwCurrentThreadID = 0;
Bool g_fKeyboardHookLL = FALSE;
-HHOOK g_hhookKeyboardLL = NULL;
-HWND g_hwndKeyboardFocus = NULL;
Bool g_fNoHelpMessageBox = FALSE;
Bool g_fSoftwareCursor = FALSE;
Bool g_fSilentDupError = FALSE;
@@ -85,11 +83,6 @@ Bool g_fNativeGl = FALSE;
* their function pointers
*/
-HMODULE g_hmodDirectDraw = NULL;
-FARPROC g_fpDirectDrawCreate = NULL;
-FARPROC g_fpDirectDrawCreateClipper = NULL;
-
-HMODULE g_hmodCommonControls = NULL;
FARPROC g_fpTrackMouseEvent = (FARPROC) (void (*)(void))NoopDDA;
@@ -127,7 +120,6 @@ void
winInitializeGlobals (void)
{
g_dwCurrentThreadID = GetCurrentThreadId ();
- g_hwndKeyboardFocus = NULL;
#ifdef XWIN_CLIPBOARD
g_iClipboardWindow = None;
g_pClipboardDisplay = NULL;
diff --git a/xorg-server/hw/xwin/winglobals.h b/xorg-server/hw/xwin/winglobals.h
new file mode 100644
index 000000000..898b9388a
--- /dev/null
+++ b/xorg-server/hw/xwin/winglobals.h
@@ -0,0 +1,88 @@
+/*
+ File: winglobals.h
+ Purpose: declarations for global variables
+
+ 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 (including the next
+ paragraph) shall be included in all copies or substantial portions of the
+ Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+
+*/
+
+#ifndef WINGLOBALS_H
+#define WINGLOBALS_H
+
+/*
+ * References to external symbols
+ */
+
+extern int g_iNumScreens;
+extern int g_iLastScreen;
+extern char * g_pszCommandLine;
+extern Bool g_fSilentFatalError;
+extern const char * g_pszLogFile;
+#ifdef RELOCATE_PROJECTROOT
+extern Bool g_fLogFileChanged;
+#endif
+extern int g_iLogVerbose;
+extern Bool g_fLogInited;
+
+extern Bool g_fAuthEnabled;
+extern Bool g_fXdmcpEnabled;
+
+extern Bool g_fNoHelpMessageBox;
+extern Bool g_fSilentDupError;
+extern Bool g_fNativeGl;
+
+extern HWND g_hDlgDepthChange;
+extern HWND g_hDlgExit;
+extern HWND g_hDlgAbout;
+
+extern Bool g_fSoftwareCursor;
+extern Bool g_fCursor;
+
+#ifdef XWIN_CLIPBOARD
+
+/* Typedef for DIX wrapper functions */
+typedef int (*winDispatchProcPtr) (ClientPtr);
+
+/*
+ * Wrapped DIX functions
+ */
+extern winDispatchProcPtr winProcEstablishConnectionOrig;
+extern winDispatchProcPtr winProcQueryTreeOrig;
+extern winDispatchProcPtr winProcSetSelectionOwnerOrig;
+#endif
+
+/* The global X default icons */
+#if defined(XWIN_MULTIWINDOW)
+extern HICON g_hIconX;
+extern HICON g_hSmallIconX;
+#endif
+
+#ifdef XWIN_MULTIWINDOW
+extern DWORD g_dwCurrentThreadID;
+#endif
+
+extern Bool g_fKeyboardHookLL;
+extern Bool g_fButton[3];
+
+#ifdef XWIN_MULTIWINDOWEXTWM
+extern Bool g_fNoConfigureWindow;
+#endif
+
+#endif /* WINGLOBALS_H */
diff --git a/xorg-server/hw/xwin/winkeyhook.c b/xorg-server/hw/xwin/winkeyhook.c
index 82e30df88..7f75a563b 100644
--- a/xorg-server/hw/xwin/winkeyhook.c
+++ b/xorg-server/hw/xwin/winkeyhook.c
@@ -1,191 +1,185 @@
-/*
- *Copyright (C) 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"
-
-
-/*
- * References to external symbols
- */
-
-extern HHOOK g_hhookKeyboardLL;
-extern DWORD g_dwCurrentThreadID;
-extern HWND g_hwndKeyboardFocus;
-
-
-/*
- * Function prototypes
- */
-
-static LRESULT CALLBACK
-winKeyboardMessageHookLL (int iCode, WPARAM wParam, LPARAM lParam);
-
-
-#ifndef LLKHF_EXTENDED
-# define LLKHF_EXTENDED 0x00000001
-#endif
-#ifndef LLKHF_UP
-# define LLKHF_UP 0x00000080
-#endif
-
-
-/*
- * KeyboardMessageHook
- */
-
-static LRESULT CALLBACK
-winKeyboardMessageHookLL (int iCode, WPARAM wParam, LPARAM lParam)
-{
- BOOL fPassKeystroke = FALSE;
- BOOL fPassAltTab = TRUE;
- PKBDLLHOOKSTRUCT p = (PKBDLLHOOKSTRUCT) lParam;
- HWND hwnd = GetActiveWindow();
-#ifdef XWIN_MULTIWINDOW
- WindowPtr pWin = NULL;
- winPrivWinPtr pWinPriv = NULL;
- winPrivScreenPtr pScreenPriv = NULL;
- winScreenInfo *pScreenInfo = NULL;
-
- /* Check if the Windows window property for our X window pointer is valid */
- if ((pWin = GetProp (hwnd, WIN_WINDOW_PROP)) != NULL)
- {
- /* Get a pointer to our window privates */
- pWinPriv = winGetWindowPriv(pWin);
-
- /* Get pointers to our screen privates and screen info */
- pScreenPriv = pWinPriv->pScreenPriv;
- pScreenInfo = pScreenPriv->pScreenInfo;
-
- if (pScreenInfo->fMultiWindow)
- fPassAltTab = FALSE;
- }
-#endif
-
- /* Pass keystrokes on to our main message loop */
- if (iCode == HC_ACTION)
- {
-
- switch (wParam)
- {
- case WM_KEYDOWN: case WM_SYSKEYDOWN:
- case WM_KEYUP: case WM_SYSKEYUP:
- fPassKeystroke =
- (fPassAltTab &&
- (p->vkCode == VK_TAB) && ((p->flags & LLKHF_ALTDOWN) != 0))
- || (p->vkCode == VK_LWIN) || (p->vkCode == VK_RWIN)
- ;
- break;
- }
- }
-
- /*
- * Pass message on to our main message loop.
- * We process this immediately with SendMessage so that the keystroke
- * appears in, hopefully, the correct order.
- */
- if (fPassKeystroke)
- {
- LPARAM lParamKey = 0x0;
-
- /* Construct the lParam from KBDLLHOOKSTRUCT */
- lParamKey = lParamKey | (0x0000FFFF & 0x00000001); /* Repeat count */
- lParamKey = lParamKey | (0x00FF0000 & (p->scanCode << 16));
- lParamKey = lParamKey
- | (0x01000000 & ((p->flags & LLKHF_EXTENDED) << 23));
- lParamKey = lParamKey
- | (0x20000000
- & ((p->flags & LLKHF_ALTDOWN) << 24));
- lParamKey = lParamKey | (0x80000000 & ((p->flags & LLKHF_UP) << 24));
-
- /* Send message to our main window that has the keyboard focus */
- PostMessage (hwnd,
- (UINT) wParam,
- (WPARAM) p->vkCode,
- lParamKey);
-
- return 1;
- }
-
- /* Call next hook */
- return CallNextHookEx (NULL, iCode, wParam, lParam);
-}
-
-
-/*
- * Attempt to install the keyboard hook, return FALSE if it was not installed
- */
-
-Bool
-winInstallKeyboardHookLL (void)
-{
- OSVERSIONINFO osvi = {0};
-
- /* Get operating system version information */
- osvi.dwOSVersionInfoSize = sizeof (osvi);
- GetVersionEx (&osvi);
-
- /* Branch on platform ID */
- switch (osvi.dwPlatformId)
- {
- case VER_PLATFORM_WIN32_NT:
- /* Low-level is supported on NT 4.0 SP3+ only */
- /* TODO: Return FALSE on NT 4.0 with no SP, SP1, or SP2 */
- break;
-
- case VER_PLATFORM_WIN32_WINDOWS:
- /* Low-level hook is not supported on non-NT */
- return FALSE;
- }
-
- /* Install the hook only once */
- if (!g_hhookKeyboardLL)
- g_hhookKeyboardLL = SetWindowsHookEx (WH_KEYBOARD_LL,
- winKeyboardMessageHookLL,
- g_hInstance,
- 0);
-
- return TRUE;
-}
-
-
-/*
- * Remove the keyboard hook if it is installed
- */
-
-void
-winRemoveKeyboardHookLL (void)
-{
- if (g_hhookKeyboardLL)
- UnhookWindowsHookEx (g_hhookKeyboardLL);
- g_hhookKeyboardLL = NULL;
-}
+/*
+ *Copyright (C) 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"
+
+
+static HHOOK g_hhookKeyboardLL = NULL;
+
+
+/*
+ * Function prototypes
+ */
+
+static LRESULT CALLBACK
+winKeyboardMessageHookLL (int iCode, WPARAM wParam, LPARAM lParam);
+
+
+#ifndef LLKHF_EXTENDED
+# define LLKHF_EXTENDED 0x00000001
+#endif
+#ifndef LLKHF_UP
+# define LLKHF_UP 0x00000080
+#endif
+
+
+/*
+ * KeyboardMessageHook
+ */
+
+static LRESULT CALLBACK
+winKeyboardMessageHookLL (int iCode, WPARAM wParam, LPARAM lParam)
+{
+ BOOL fPassKeystroke = FALSE;
+ BOOL fPassAltTab = TRUE;
+ PKBDLLHOOKSTRUCT p = (PKBDLLHOOKSTRUCT) lParam;
+ HWND hwnd = GetActiveWindow();
+#ifdef XWIN_MULTIWINDOW
+ WindowPtr pWin = NULL;
+ winPrivWinPtr pWinPriv = NULL;
+ winPrivScreenPtr pScreenPriv = NULL;
+ winScreenInfo *pScreenInfo = NULL;
+
+ /* Check if the Windows window property for our X window pointer is valid */
+ if ((pWin = GetProp (hwnd, WIN_WINDOW_PROP)) != NULL)
+ {
+ /* Get a pointer to our window privates */
+ pWinPriv = winGetWindowPriv(pWin);
+
+ /* Get pointers to our screen privates and screen info */
+ pScreenPriv = pWinPriv->pScreenPriv;
+ pScreenInfo = pScreenPriv->pScreenInfo;
+
+ if (pScreenInfo->fMultiWindow)
+ fPassAltTab = FALSE;
+ }
+#endif
+
+ /* Pass keystrokes on to our main message loop */
+ if (iCode == HC_ACTION)
+ {
+
+ switch (wParam)
+ {
+ case WM_KEYDOWN: case WM_SYSKEYDOWN:
+ case WM_KEYUP: case WM_SYSKEYUP:
+ fPassKeystroke =
+ (fPassAltTab &&
+ (p->vkCode == VK_TAB) && ((p->flags & LLKHF_ALTDOWN) != 0))
+ || (p->vkCode == VK_LWIN) || (p->vkCode == VK_RWIN)
+ ;
+ break;
+ }
+ }
+
+ /*
+ * Pass message on to our main message loop.
+ * We process this immediately with SendMessage so that the keystroke
+ * appears in, hopefully, the correct order.
+ */
+ if (fPassKeystroke)
+ {
+ LPARAM lParamKey = 0x0;
+
+ /* Construct the lParam from KBDLLHOOKSTRUCT */
+ lParamKey = lParamKey | (0x0000FFFF & 0x00000001); /* Repeat count */
+ lParamKey = lParamKey | (0x00FF0000 & (p->scanCode << 16));
+ lParamKey = lParamKey
+ | (0x01000000 & ((p->flags & LLKHF_EXTENDED) << 23));
+ lParamKey = lParamKey
+ | (0x20000000
+ & ((p->flags & LLKHF_ALTDOWN) << 24));
+ lParamKey = lParamKey | (0x80000000 & ((p->flags & LLKHF_UP) << 24));
+
+ /* Send message to our main window that has the keyboard focus */
+ PostMessage (hwnd,
+ (UINT) wParam,
+ (WPARAM) p->vkCode,
+ lParamKey);
+
+ return 1;
+ }
+
+ /* Call next hook */
+ return CallNextHookEx (NULL, iCode, wParam, lParam);
+}
+
+
+/*
+ * Attempt to install the keyboard hook, return FALSE if it was not installed
+ */
+
+Bool
+winInstallKeyboardHookLL (void)
+{
+ OSVERSIONINFO osvi = {0};
+
+ /* Get operating system version information */
+ osvi.dwOSVersionInfoSize = sizeof (osvi);
+ GetVersionEx (&osvi);
+
+ /* Branch on platform ID */
+ switch (osvi.dwPlatformId)
+ {
+ case VER_PLATFORM_WIN32_NT:
+ /* Low-level is supported on NT 4.0 SP3+ only */
+ /* TODO: Return FALSE on NT 4.0 with no SP, SP1, or SP2 */
+ break;
+
+ case VER_PLATFORM_WIN32_WINDOWS:
+ /* Low-level hook is not supported on non-NT */
+ return FALSE;
+ }
+
+ /* Install the hook only once */
+ if (!g_hhookKeyboardLL)
+ g_hhookKeyboardLL = SetWindowsHookEx (WH_KEYBOARD_LL,
+ winKeyboardMessageHookLL,
+ g_hInstance,
+ 0);
+
+ return TRUE;
+}
+
+
+/*
+ * Remove the keyboard hook if it is installed
+ */
+
+void
+winRemoveKeyboardHookLL (void)
+{
+ if (g_hhookKeyboardLL)
+ UnhookWindowsHookEx (g_hhookKeyboardLL);
+ g_hhookKeyboardLL = NULL;
+}
diff --git a/xorg-server/hw/xwin/winlayouts.h b/xorg-server/hw/xwin/winlayouts.h
index 5d290f643..882e4f71c 100644
--- a/xorg-server/hw/xwin/winlayouts.h
+++ b/xorg-server/hw/xwin/winlayouts.h
@@ -1,96 +1,96 @@
-/*
- * Copyright (c) 2005 Alexander Gottwald
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name(s) of the above copyright
- * holders shall not be used in advertising or otherwise to promote the sale,
- * use or other dealings in this Software without prior written authorization.
- */
-/* Definitions for various keyboard layouts from windows and their
- * XKB settings.
- */
-
-typedef struct
-{
- unsigned int winlayout;
- int winkbtype;
- char *xkbmodel;
- char *xkblayout;
- char *xkbvariant;
- char *xkboptions;
- char *layoutname;
-} WinKBLayoutRec, *WinKBLayoutPtr;
-
-/*
- This table is sorted by low byte of winlayout, then by next byte, etc.
-*/
-
-WinKBLayoutRec winKBLayouts[] =
-{
- { 0x404, -1, "pc105", "zh_TW", NULL, NULL, "Chinese (Taiwan)"},
- { 0x405, -1, "pc105", "cz", NULL, NULL, "Czech"},
- {0x10405, -1, "pc105", "cz_qwerty", NULL, NULL, "Czech (QWERTY)"},
- { 0x406, -1, "pc105", "dk", NULL, NULL, "Danish"},
- { 0x407, -1, "pc105", "de", NULL, NULL, "German (Germany)"},
- {0x10407, -1, "pc105", "de", NULL, NULL, "German (Germany, IBM)"},
- { 0x807, -1, "pc105", "ch", "de", NULL, "German (Switzerland)"},
- { 0x409, -1, "pc105", "us", NULL, NULL, "English (USA)"},
- {0x10409, -1, "pc105", "dvorak", NULL, NULL, "English (USA, Dvorak)"},
- {0x20409, -1, "pc105", "us_intl", NULL, NULL, "English (USA, International)"},
- { 0x809, -1, "pc105", "gb", NULL, NULL, "English (United Kingdom)"},
- { 0x1009, -1, "pc105", "ca", "fr", NULL, "French (Canada)"},
- {0x11009, -1, "pc105", "ca", "multix", NULL, "Candian Multilingual Standard"},
- { 0x1809, -1, "pc105", "ie", NULL, NULL, "Irish"},
- { 0x40a, -1, "pc105", "es", NULL, NULL, "Spanish (Spain, Traditional Sort)"},
- { 0x80a, -1, "pc105", "latam", NULL, NULL, "Latin American"},
- { 0x40b, -1, "pc105", "fi", NULL, NULL, "Finnish"},
- { 0x40c, -1, "pc105", "fr", NULL, NULL, "French (Standard)"},
- { 0x80c, -1, "pc105", "be", NULL, NULL, "French (Belgian)"},
- {0x1080c, -1, "pc105", "be", NULL, NULL, "Belgian (Comma)"},
- { 0xc0c, -1, "pc105", "ca", "fr-legacy", NULL, "French (Canada) (Legacy)"},
- { 0x100c, -1, "pc105", "ch", "fr", NULL, "French (Switzerland)"},
- { 0x40d, -1, "pc105", "il", NULL, NULL, "Hebrew"},
- { 0x40e, -1, "pc105", "hu", NULL, NULL, "Hungarian"},
- { 0x40f, -1, "pc105", "is", NULL, NULL, "Icelandic"},
- { 0x410, -1, "pc105", "it", NULL, NULL, "Italian"},
- {0x10410, -1, "pc105", "it", NULL, NULL, "Italian (142)"},
- {0xa0000410,-1, "macbook79","it", "mac",NULL, "Italiano (Apple)"},
- { 0x411, 7, "jp106", "jp", NULL, NULL, "Japanese"},
- { 0x413, -1, "pc105", "nl", NULL, NULL, "Dutch"},
- { 0x813, -1, "pc105", "be", NULL, NULL, "Dutch (Belgian)"},
- { 0x414, -1, "pc105", "no", NULL, NULL, "Norwegian"},
- { 0x415, -1, "pc105", "pl", NULL, NULL, "Polish (Programmers)"},
- { 0x416, -1, "pc105", "br", NULL, NULL, "Portuguese (Brazil, ABNT)"},
- {0x10416, -1, "abnt2", "br", NULL, NULL, "Portuguese (Brazil, ABNT2)"},
- { 0x816, -1, "pc105", "pt", NULL, NULL, "Portuguese (Portugal)"},
- { 0x41a, -1, "pc105", "hr", NULL, NULL, "Croatian"},
- { 0x41d, -1, "pc105", "se", NULL, NULL, "Swedish (Sweden)"},
- { 0x424, -1, "pc105", "si", NULL, NULL, "Slovenian"},
- { 0x425, -1, "pc105", "ee", NULL, NULL, "Estonian"},
- { 0x452, -1, "pc105", "gb", "intl", NULL, "United Kingdom (Extended)"},
- { -1, -1, NULL, NULL, NULL, NULL, NULL}
-};
-
-/*
- See http://technet.microsoft.com/en-us/library/cc766503%28WS.10%29.aspx
- for a listing of input locale (keyboard layout) codes
-*/
-
-
+/*
+ * Copyright (c) 2005 Alexander Gottwald
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* Definitions for various keyboard layouts from windows and their
+ * XKB settings.
+ */
+
+typedef struct
+{
+ unsigned int winlayout;
+ int winkbtype;
+ char *xkbmodel;
+ char *xkblayout;
+ char *xkbvariant;
+ char *xkboptions;
+ char *layoutname;
+} WinKBLayoutRec, *WinKBLayoutPtr;
+
+/*
+ This table is sorted by low byte of winlayout, then by next byte, etc.
+*/
+
+WinKBLayoutRec winKBLayouts[] =
+{
+ { 0x00000404, -1, "pc105", "zh_TW", NULL, NULL, "Chinese (Taiwan)"},
+ { 0x00000405, -1, "pc105", "cz", NULL, NULL, "Czech"},
+ { 0x00010405, -1, "pc105", "cz_qwerty", NULL, NULL, "Czech (QWERTY)"},
+ { 0x00000406, -1, "pc105", "dk", NULL, NULL, "Danish"},
+ { 0x00000407, -1, "pc105", "de", NULL, NULL, "German (Germany)"},
+ { 0x00010407, -1, "pc105", "de", NULL, NULL, "German (Germany,IBM)"},
+ { 0x00000807, -1, "pc105", "ch", "de", NULL, "German (Switzerland)"},
+ { 0x00000409, -1, "pc105", "us", NULL, NULL, "English (USA)"},
+ { 0x00010409, -1, "pc105", "dvorak", NULL, NULL, "English (USA,Dvorak)"},
+ { 0x00020409, -1, "pc105", "us_intl", NULL, NULL, "English (USA,International)"},
+ { 0x00000809, -1, "pc105", "gb", NULL, NULL, "English (United Kingdom)"},
+ { 0x00001009, -1, "pc105", "ca", "fr", NULL, "French (Canada)"},
+ { 0x00011009, -1, "pc105", "ca", "multix", NULL, "Candian Multilingual Standard"},
+ { 0x00001809, -1, "pc105", "ie", NULL, NULL, "Irish"},
+ { 0x0000040a, -1, "pc105", "es", NULL, NULL, "Spanish (Spain,Traditional Sort)"},
+ { 0x0000080a, -1, "pc105", "latam", NULL, NULL, "Latin American"},
+ { 0x0000040b, -1, "pc105", "fi", NULL, NULL, "Finnish"},
+ { 0x0000040c, -1, "pc105", "fr", NULL, NULL, "French (Standard)"},
+ { 0x0000080c, -1, "pc105", "be", NULL, NULL, "French (Belgian)"},
+ { 0x0001080c, -1, "pc105", "be", NULL, NULL, "Belgian (Comma)"},
+ { 0x00000c0c, -1, "pc105", "ca", "fr-legacy", NULL, "French (Canada) (Legacy)"},
+ { 0x0000100c, -1, "pc105", "ch", "fr", NULL, "French (Switzerland)"},
+ { 0x0000040d, -1, "pc105", "il", NULL, NULL, "Hebrew"},
+ { 0x0000040e, -1, "pc105", "hu", NULL, NULL, "Hungarian"},
+ { 0x0000040f, -1, "pc105", "is", NULL, NULL, "Icelandic"},
+ { 0x00000410, -1, "pc105", "it", NULL, NULL, "Italian"},
+ { 0x00010410, -1, "pc105", "it", NULL, NULL, "Italian (142)"},
+ { 0xa0000410, -1, "macbook79", "it", "mac", NULL, "Italiano (Apple)"},
+ { 0x00000411, 7, "jp106", "jp", NULL, NULL, "Japanese"},
+ { 0x00000413, -1, "pc105", "nl", NULL, NULL, "Dutch"},
+ { 0x00000813, -1, "pc105", "be", NULL, NULL, "Dutch (Belgian)"},
+ { 0x00000414, -1, "pc105", "no", NULL, NULL, "Norwegian"},
+ { 0x00000415, -1, "pc105", "pl", NULL, NULL, "Polish (Programmers)"},
+ { 0x00000416, -1, "pc105", "br", NULL, NULL, "Portuguese (Brazil,ABNT)"},
+ { 0x00010416, -1, "abnt2", "br", NULL, NULL, "Portuguese (Brazil,ABNT2)"},
+ { 0x00000816, -1, "pc105", "pt", NULL, NULL, "Portuguese (Portugal)"},
+ { 0x0000041a, -1, "pc105", "hr", NULL, NULL, "Croatian"},
+ { 0x0000041d, -1, "pc105", "se", NULL, NULL, "Swedish (Sweden)"},
+ { 0x00000424, -1, "pc105", "si", NULL, NULL, "Slovenian"},
+ { 0x00000425, -1, "pc105", "ee", NULL, NULL, "Estonian"},
+ { 0x00000452, -1, "pc105", "gb", "intl", NULL, "United Kingdom (Extended)"},
+ { -1, -1, NULL, NULL, NULL, NULL, NULL}
+};
+
+/*
+ See http://technet.microsoft.com/en-us/library/cc766503%28WS.10%29.aspx
+ for a listing of input locale (keyboard layout) codes
+*/
+
+
diff --git a/xorg-server/hw/xwin/winmouse.c b/xorg-server/hw/xwin/winmouse.c
index e150247db..b37d5cf67 100644
--- a/xorg-server/hw/xwin/winmouse.c
+++ b/xorg-server/hw/xwin/winmouse.c
@@ -1,385 +1,386 @@
-/*
- *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, sublicense, and/or sell copies of the Software, and to
- *permit persons to whom the Software is furnished to do so, subject to
- *the following conditions:
- *
- *The above copyright notice and this permission notice shall be
- *included in all copies or substantial portions of the Software.
- *
- *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
- *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *Except as contained in this notice, the name of the XFree86 Project
- *shall not be used in advertising or otherwise to promote the sale, use
- *or other dealings in this Software without prior written authorization
- *from the XFree86 Project.
- *
- * Authors: Dakshinamurthy Karra
- * Suhaib M Siddiqi
- * Peter Busch
- * Harold L Hunt II
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-
-#ifdef XKB
-#ifndef XKB_IN_SERVER
-#define XKB_IN_SERVER
-#endif
-#include <xkbsrv.h>
-#endif
-
-#include "inputstr.h"
-#include "exevents.h" /* for button/axes labels */
-#include "xserver-properties.h"
-
-/* Peek the internal button mapping */
-static CARD8 const *g_winMouseButtonMap = NULL;
-
-
-/*
- * Local prototypes
- */
-
-static void
-winMouseCtrl (DeviceIntPtr pDevice, PtrCtrl *pCtrl);
-
-
-static void
-winMouseCtrl (DeviceIntPtr pDevice, PtrCtrl *pCtrl)
-{
-}
-
-
-/*
- * See Porting Layer Definition - p. 18
- * This is known as a DeviceProc
- */
-
-int
-winMouseProc (DeviceIntPtr pDeviceInt, int iState)
-{
- int lngMouseButtons, i;
- int lngWheelEvents = 2;
- CARD8 *map;
- DevicePtr pDevice = (DevicePtr) pDeviceInt;
- Atom *btn_labels;
- Atom axes_labels[2];
-
- switch (iState)
- {
- case DEVICE_INIT:
- /* Get number of mouse buttons */
- lngMouseButtons = GetSystemMetrics(SM_CMOUSEBUTTONS);
-
- /* Mapping of windows events to X events:
- * LEFT:1 MIDDLE:2 RIGHT:3
- * SCROLL_UP:4 SCROLL_DOWN:5
- * XBUTTON 1:6 XBUTTON 2:7 ...
- *
- * To map scroll wheel correctly we need at least the 3 normal buttons
- */
- if (lngMouseButtons < 3)
- lngMouseButtons = 3;
- winDebug("%d mouse buttons found\n", lngMouseButtons);
-
- /* allocate memory:
- * number of buttons + 2x mouse wheel event + 1 extra (offset for map)
- */
- map = malloc(sizeof(CARD8) * (lngMouseButtons + lngWheelEvents + 1));
-
- /* initalize button map */
- map[0] = 0;
- for (i=1; i <= lngMouseButtons + lngWheelEvents; i++)
- map[i] = i;
-
- btn_labels = calloc((lngMouseButtons + lngWheelEvents), sizeof(Atom));
- btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
- btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
- btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
- btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
- btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN);
-
- axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
- axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
-
- InitPointerDeviceStruct (pDevice,
- map,
- lngMouseButtons + lngWheelEvents,
- btn_labels,
- winMouseCtrl,
- GetMotionHistorySize(),
- 2,
- axes_labels);
- free(map);
- free(btn_labels);
-
- g_winMouseButtonMap = pDeviceInt->button->map;
- break;
-
- case DEVICE_ON:
- pDevice->on = TRUE;
- break;
-
- case DEVICE_CLOSE:
- g_winMouseButtonMap = NULL;
- case DEVICE_OFF:
- pDevice->on = FALSE;
- break;
- }
- return Success;
-}
-
-
-/* Handle the mouse wheel */
-int
-winMouseWheel (ScreenPtr pScreen, int iDeltaZ)
-{
- winScreenPriv(pScreen);
- int button; /* Button4 or Button5 */
-
- /* Button4 = WheelUp */
- /* Button5 = WheelDown */
-
- /* Do we have any previous delta stored? */
- if ((pScreenPriv->iDeltaZ > 0
- && iDeltaZ > 0)
- || (pScreenPriv->iDeltaZ < 0
- && iDeltaZ < 0))
- {
- /* Previous delta and of same sign as current delta */
- iDeltaZ += pScreenPriv->iDeltaZ;
- pScreenPriv->iDeltaZ = 0;
- }
- else
- {
- /*
- * Previous delta of different sign, or zero.
- * We will set it to zero for either case,
- * as blindly setting takes just as much time
- * as checking, then setting if necessary :)
- */
- pScreenPriv->iDeltaZ = 0;
- }
-
- /*
- * Only process this message if the wheel has moved further than
- * WHEEL_DELTA
- */
- if (iDeltaZ >= WHEEL_DELTA || (-1 * iDeltaZ) >= WHEEL_DELTA)
- {
- pScreenPriv->iDeltaZ = 0;
-
- /* Figure out how many whole deltas of the wheel we have */
- iDeltaZ /= WHEEL_DELTA;
- }
- else
- {
- /*
- * Wheel has not moved past WHEEL_DELTA threshold;
- * we will store the wheel delta until the threshold
- * has been reached.
- */
- pScreenPriv->iDeltaZ = iDeltaZ;
- return 0;
- }
-
- /* Set the button to indicate up or down wheel delta */
- if (iDeltaZ > 0)
- {
- button = Button4;
- }
- else
- {
- button = Button5;
- }
-
- /*
- * Flip iDeltaZ to positive, if negative,
- * because always need to generate a *positive* number of
- * button clicks for the Z axis.
- */
- if (iDeltaZ < 0)
- {
- iDeltaZ *= -1;
- }
-
- /* Generate X input messages for each wheel delta we have seen */
- while (iDeltaZ--)
- {
- /* Push the wheel button */
- winMouseButtonsSendEvent (ButtonPress, button);
-
- /* Release the wheel button */
- winMouseButtonsSendEvent (ButtonRelease, button);
- }
-
- return 0;
-}
-
-
-/*
- * Enqueue a mouse button event
- */
-
-void
-winMouseButtonsSendEvent (int iEventType, int iButton)
-{
- EventListPtr events;
- int i, nevents;
-
- if (g_winMouseButtonMap)
- iButton = g_winMouseButtonMap[iButton];
-
- GetEventList(&events);
- nevents = GetPointerEvents(events, g_pwinPointer, iEventType, iButton,
- POINTER_RELATIVE, 0, 0, NULL);
-
- for (i = 0; i < nevents; i++)
- mieqEnqueue(g_pwinPointer, (InternalEvent*)events[i].event);
-
- winDebug("winMouseButtonsSendEvent: iEventType: %d, iButton: %d, nEvents %d\n",
- iEventType, iButton, nevents);
-}
-
-
-/*
- * Decide what to do with a Windows mouse message
- */
-
-int
-winMouseButtonsHandle (ScreenPtr pScreen,
- int iEventType, int iButton,
- WPARAM wParam)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-
- /* Send button events right away if emulate 3 buttons is off */
- if (pScreenInfo->iE3BTimeout == WIN_E3B_OFF)
- {
- /* Emulate 3 buttons is off, send the button event */
- winMouseButtonsSendEvent (iEventType, iButton);
- return 0;
- }
-
- /* Emulate 3 buttons is on, let the fun begin */
- if (iEventType == ButtonPress
- && pScreenPriv->iE3BCachedPress == 0
- && !pScreenPriv->fE3BFakeButton2Sent)
- {
- /*
- * Button was pressed, no press is cached,
- * and there is no fake button 2 release pending.
- */
-
- /* Store button press type */
- pScreenPriv->iE3BCachedPress = iButton;
-
- /*
- * Set a timer to send this button press if the other button
- * is not pressed within the timeout time.
- */
- SetTimer (pScreenPriv->hwndScreen,
- WIN_E3B_TIMER_ID,
- pScreenInfo->iE3BTimeout,
- NULL);
- }
- else if (iEventType == ButtonPress
- && pScreenPriv->iE3BCachedPress != 0
- && pScreenPriv->iE3BCachedPress != iButton
- && !pScreenPriv->fE3BFakeButton2Sent)
- {
- /*
- * Button press is cached, other button was pressed,
- * and there is no fake button 2 release pending.
- */
-
- /* Mouse button was cached and other button was pressed */
- KillTimer (pScreenPriv->hwndScreen, WIN_E3B_TIMER_ID);
- pScreenPriv->iE3BCachedPress = 0;
-
- /* Send fake middle button */
- winMouseButtonsSendEvent (ButtonPress, Button2);
-
- /* Indicate that a fake middle button event was sent */
- pScreenPriv->fE3BFakeButton2Sent = TRUE;
- }
- else if (iEventType == ButtonRelease
- && pScreenPriv->iE3BCachedPress == iButton)
- {
- /*
- * Cached button was released before timer ran out,
- * and before the other mouse button was pressed.
- */
- KillTimer (pScreenPriv->hwndScreen, WIN_E3B_TIMER_ID);
- pScreenPriv->iE3BCachedPress = 0;
-
- /* Send cached press, then send release */
- winMouseButtonsSendEvent (ButtonPress, iButton);
- winMouseButtonsSendEvent (ButtonRelease, iButton);
- }
- else if (iEventType == ButtonRelease
- && pScreenPriv->fE3BFakeButton2Sent
- && !(wParam & MK_LBUTTON)
- && !(wParam & MK_RBUTTON))
- {
- /*
- * Fake button 2 was sent and both mouse buttons have now been released
- */
- pScreenPriv->fE3BFakeButton2Sent = FALSE;
-
- /* Send middle mouse button release */
- winMouseButtonsSendEvent (ButtonRelease, Button2);
- }
- else if (iEventType == ButtonRelease
- && pScreenPriv->iE3BCachedPress == 0
- && !pScreenPriv->fE3BFakeButton2Sent)
- {
- /*
- * Button was release, no button is cached,
- * and there is no fake button 2 release is pending.
- */
- winMouseButtonsSendEvent (ButtonRelease, iButton);
- }
-
- return 0;
-}
-
-/**
- * Enqueue a motion event.
- *
- * XXX: miPointerMove does exactly this, but is static :-( (and uses a static buffer)
- *
- */
-void winEnqueueMotion(int x, int y)
-{
- int i, nevents;
- int valuators[2];
- EventListPtr events;
-
- miPointerSetPosition(g_pwinPointer, &x, &y);
- valuators[0] = x;
- valuators[1] = y;
-
- GetEventList(&events);
- nevents = GetPointerEvents(events, g_pwinPointer, MotionNotify, 0,
- POINTER_ABSOLUTE | POINTER_SCREEN, 0, 2, valuators);
-
- for (i = 0; i < nevents; i++)
- mieqEnqueue(g_pwinPointer, (InternalEvent*)events[i].event);
-}
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Dakshinamurthy Karra
+ * Suhaib M Siddiqi
+ * Peter Busch
+ * Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+#ifdef XKB
+#ifndef XKB_IN_SERVER
+#define XKB_IN_SERVER
+#endif
+#include <xkbsrv.h>
+#endif
+
+#include "inputstr.h"
+#include "exevents.h" /* for button/axes labels */
+#include "xserver-properties.h"
+
+/* Peek the internal button mapping */
+static CARD8 const *g_winMouseButtonMap = NULL;
+
+
+/*
+ * Local prototypes
+ */
+
+static void
+winMouseCtrl (DeviceIntPtr pDevice, PtrCtrl *pCtrl);
+
+
+static void
+winMouseCtrl (DeviceIntPtr pDevice, PtrCtrl *pCtrl)
+{
+}
+
+
+/*
+ * See Porting Layer Definition - p. 18
+ * This is known as a DeviceProc
+ */
+
+int
+winMouseProc (DeviceIntPtr pDeviceInt, int iState)
+{
+ int lngMouseButtons, i;
+ int lngWheelEvents = 2;
+ CARD8 *map;
+ DevicePtr pDevice = (DevicePtr) pDeviceInt;
+ Atom *btn_labels;
+ Atom axes_labels[2];
+
+ switch (iState)
+ {
+ case DEVICE_INIT:
+ /* Get number of mouse buttons */
+ lngMouseButtons = GetSystemMetrics(SM_CMOUSEBUTTONS);
+
+ /* Mapping of windows events to X events:
+ * LEFT:1 MIDDLE:2 RIGHT:3
+ * SCROLL_UP:4 SCROLL_DOWN:5
+ * XBUTTON 1:6 XBUTTON 2:7 ...
+ *
+ * To map scroll wheel correctly we need at least the 3 normal buttons
+ */
+ if (lngMouseButtons < 3)
+ lngMouseButtons = 3;
+ winDebug("%d mouse buttons found\n", lngMouseButtons);
+
+ /* allocate memory:
+ * number of buttons + 2x mouse wheel event + 1 extra (offset for map)
+ */
+ map = malloc(sizeof(CARD8) * (lngMouseButtons + lngWheelEvents + 1));
+
+ /* initalize button map */
+ map[0] = 0;
+ for (i=1; i <= lngMouseButtons + lngWheelEvents; i++)
+ map[i] = i;
+
+ btn_labels = calloc((lngMouseButtons + lngWheelEvents), sizeof(Atom));
+ btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
+ btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
+ btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
+ btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
+ btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN);
+
+ axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
+ axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
+
+ InitPointerDeviceStruct (pDevice,
+ map,
+ lngMouseButtons + lngWheelEvents,
+ btn_labels,
+ winMouseCtrl,
+ GetMotionHistorySize(),
+ 2,
+ axes_labels);
+ free(map);
+ free(btn_labels);
+
+ g_winMouseButtonMap = pDeviceInt->button->map;
+ break;
+
+ case DEVICE_ON:
+ pDevice->on = TRUE;
+ break;
+
+ case DEVICE_CLOSE:
+ g_winMouseButtonMap = NULL;
+
+ case DEVICE_OFF:
+ pDevice->on = FALSE;
+ break;
+ }
+ return Success;
+}
+
+
+/* Handle the mouse wheel */
+int
+winMouseWheel (ScreenPtr pScreen, int iDeltaZ)
+{
+ winScreenPriv(pScreen);
+ int button; /* Button4 or Button5 */
+
+ /* Button4 = WheelUp */
+ /* Button5 = WheelDown */
+
+ /* Do we have any previous delta stored? */
+ if ((pScreenPriv->iDeltaZ > 0
+ && iDeltaZ > 0)
+ || (pScreenPriv->iDeltaZ < 0
+ && iDeltaZ < 0))
+ {
+ /* Previous delta and of same sign as current delta */
+ iDeltaZ += pScreenPriv->iDeltaZ;
+ pScreenPriv->iDeltaZ = 0;
+ }
+ else
+ {
+ /*
+ * Previous delta of different sign, or zero.
+ * We will set it to zero for either case,
+ * as blindly setting takes just as much time
+ * as checking, then setting if necessary :)
+ */
+ pScreenPriv->iDeltaZ = 0;
+ }
+
+ /*
+ * Only process this message if the wheel has moved further than
+ * WHEEL_DELTA
+ */
+ if (iDeltaZ >= WHEEL_DELTA || (-1 * iDeltaZ) >= WHEEL_DELTA)
+ {
+ pScreenPriv->iDeltaZ = 0;
+
+ /* Figure out how many whole deltas of the wheel we have */
+ iDeltaZ /= WHEEL_DELTA;
+ }
+ else
+ {
+ /*
+ * Wheel has not moved past WHEEL_DELTA threshold;
+ * we will store the wheel delta until the threshold
+ * has been reached.
+ */
+ pScreenPriv->iDeltaZ = iDeltaZ;
+ return 0;
+ }
+
+ /* Set the button to indicate up or down wheel delta */
+ if (iDeltaZ > 0)
+ {
+ button = Button4;
+ }
+ else
+ {
+ button = Button5;
+ }
+
+ /*
+ * Flip iDeltaZ to positive, if negative,
+ * because always need to generate a *positive* number of
+ * button clicks for the Z axis.
+ */
+ if (iDeltaZ < 0)
+ {
+ iDeltaZ *= -1;
+ }
+
+ /* Generate X input messages for each wheel delta we have seen */
+ while (iDeltaZ--)
+ {
+ /* Push the wheel button */
+ winMouseButtonsSendEvent (ButtonPress, button);
+
+ /* Release the wheel button */
+ winMouseButtonsSendEvent (ButtonRelease, button);
+ }
+
+ return 0;
+}
+
+
+/*
+ * Enqueue a mouse button event
+ */
+
+void
+winMouseButtonsSendEvent (int iEventType, int iButton)
+{
+ EventListPtr events;
+ int i, nevents;
+
+ if (g_winMouseButtonMap)
+ iButton = g_winMouseButtonMap[iButton];
+
+ GetEventList(&events);
+ nevents = GetPointerEvents(events, g_pwinPointer, iEventType, iButton,
+ POINTER_RELATIVE, 0, 0, NULL);
+
+ for (i = 0; i < nevents; i++)
+ mieqEnqueue(g_pwinPointer, (InternalEvent*)events[i].event);
+
+ winDebug("winMouseButtonsSendEvent: iEventType: %d, iButton: %d, nEvents %d\n",
+ iEventType, iButton, nevents);
+}
+
+
+/*
+ * Decide what to do with a Windows mouse message
+ */
+
+int
+winMouseButtonsHandle (ScreenPtr pScreen,
+ int iEventType, int iButton,
+ WPARAM wParam)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /* Send button events right away if emulate 3 buttons is off */
+ if (pScreenInfo->iE3BTimeout == WIN_E3B_OFF)
+ {
+ /* Emulate 3 buttons is off, send the button event */
+ winMouseButtonsSendEvent (iEventType, iButton);
+ return 0;
+ }
+
+ /* Emulate 3 buttons is on, let the fun begin */
+ if (iEventType == ButtonPress
+ && pScreenPriv->iE3BCachedPress == 0
+ && !pScreenPriv->fE3BFakeButton2Sent)
+ {
+ /*
+ * Button was pressed, no press is cached,
+ * and there is no fake button 2 release pending.
+ */
+
+ /* Store button press type */
+ pScreenPriv->iE3BCachedPress = iButton;
+
+ /*
+ * Set a timer to send this button press if the other button
+ * is not pressed within the timeout time.
+ */
+ SetTimer (pScreenPriv->hwndScreen,
+ WIN_E3B_TIMER_ID,
+ pScreenInfo->iE3BTimeout,
+ NULL);
+ }
+ else if (iEventType == ButtonPress
+ && pScreenPriv->iE3BCachedPress != 0
+ && pScreenPriv->iE3BCachedPress != iButton
+ && !pScreenPriv->fE3BFakeButton2Sent)
+ {
+ /*
+ * Button press is cached, other button was pressed,
+ * and there is no fake button 2 release pending.
+ */
+
+ /* Mouse button was cached and other button was pressed */
+ KillTimer (pScreenPriv->hwndScreen, WIN_E3B_TIMER_ID);
+ pScreenPriv->iE3BCachedPress = 0;
+
+ /* Send fake middle button */
+ winMouseButtonsSendEvent (ButtonPress, Button2);
+
+ /* Indicate that a fake middle button event was sent */
+ pScreenPriv->fE3BFakeButton2Sent = TRUE;
+ }
+ else if (iEventType == ButtonRelease
+ && pScreenPriv->iE3BCachedPress == iButton)
+ {
+ /*
+ * Cached button was released before timer ran out,
+ * and before the other mouse button was pressed.
+ */
+ KillTimer (pScreenPriv->hwndScreen, WIN_E3B_TIMER_ID);
+ pScreenPriv->iE3BCachedPress = 0;
+
+ /* Send cached press, then send release */
+ winMouseButtonsSendEvent (ButtonPress, iButton);
+ winMouseButtonsSendEvent (ButtonRelease, iButton);
+ }
+ else if (iEventType == ButtonRelease
+ && pScreenPriv->fE3BFakeButton2Sent
+ && !(wParam & MK_LBUTTON)
+ && !(wParam & MK_RBUTTON))
+ {
+ /*
+ * Fake button 2 was sent and both mouse buttons have now been released
+ */
+ pScreenPriv->fE3BFakeButton2Sent = FALSE;
+
+ /* Send middle mouse button release */
+ winMouseButtonsSendEvent (ButtonRelease, Button2);
+ }
+ else if (iEventType == ButtonRelease
+ && pScreenPriv->iE3BCachedPress == 0
+ && !pScreenPriv->fE3BFakeButton2Sent)
+ {
+ /*
+ * Button was release, no button is cached,
+ * and there is no fake button 2 release is pending.
+ */
+ winMouseButtonsSendEvent (ButtonRelease, iButton);
+ }
+
+ return 0;
+}
+
+/**
+ * Enqueue a motion event.
+ *
+ * XXX: miPointerMove does exactly this, but is static :-( (and uses a static buffer)
+ *
+ */
+void winEnqueueMotion(int x, int y)
+{
+ int i, nevents;
+ int valuators[2];
+ EventListPtr events;
+
+ miPointerSetPosition(g_pwinPointer, &x, &y);
+ valuators[0] = x;
+ valuators[1] = y;
+
+ GetEventList(&events);
+ nevents = GetPointerEvents(events, g_pwinPointer, MotionNotify, 0,
+ POINTER_ABSOLUTE | POINTER_SCREEN, 0, 2, valuators);
+
+ for (i = 0; i < nevents; i++)
+ mieqEnqueue(g_pwinPointer, (InternalEvent*)events[i].event);
+}
diff --git a/xorg-server/hw/xwin/winmultiwindowicons.c b/xorg-server/hw/xwin/winmultiwindowicons.c
index 8dae068af..3186cd7a0 100644
--- a/xorg-server/hw/xwin/winmultiwindowicons.c
+++ b/xorg-server/hw/xwin/winmultiwindowicons.c
@@ -41,13 +41,6 @@
#include "propertyst.h"
#include "windowstr.h"
-/*
- * External global variables
- */
-
-extern HICON g_hIconX;
-extern HICON g_hSmallIconX;
-
/*
* Prototypes for local functions
diff --git a/xorg-server/hw/xwin/winmultiwindowwindow.c b/xorg-server/hw/xwin/winmultiwindowwindow.c
index 36640faec..3044eda9c 100644
--- a/xorg-server/hw/xwin/winmultiwindowwindow.c
+++ b/xorg-server/hw/xwin/winmultiwindowwindow.c
@@ -38,16 +38,6 @@
#include "win.h"
#include "dixevents.h"
#include "winmultiwindowclass.h"
-#include "winprefs.h"
-
-/*
- * External global variables
- */
-
-extern HICON g_hIconX;
-extern HICON g_hSmallIconX;
-extern HWND g_hDlgDepthChange;
-extern Bool g_fNativeGl;
/*
* Prototypes for local functions
diff --git a/xorg-server/hw/xwin/winmultiwindowwm.c b/xorg-server/hw/xwin/winmultiwindowwm.c
index b5b0fef84..0f3e36504 100644
--- a/xorg-server/hw/xwin/winmultiwindowwm.c
+++ b/xorg-server/hw/xwin/winmultiwindowwm.c
@@ -586,7 +586,7 @@ winMultiWindowWMProc (void *pArg)
winDebug ("winMultiWindowWMProc ()\n");
- /* Loop until we explicity break out */
+ /* Loop until we explicitly break out */
for (;;)
{
WMMsgNodePtr pNode;
@@ -1531,7 +1531,7 @@ winApplyHints (Display *pDisplay, Window iWindow, HWND hWnd, HWND *zstyle)
int format;
unsigned long hint = 0, maxmin = 0, style, nitems = 0 , left = 0;
WindowPtr pWin = GetProp (hWnd, WIN_WINDOW_PROP);
- MwmHints *mwm_hint = NULL;
+ MwmHints *mwm_hint = NULL;
WinXSizeHints SizeHints;
if (!hWnd) return;
diff --git a/xorg-server/hw/xwin/winmultiwindowwndproc.c b/xorg-server/hw/xwin/winmultiwindowwndproc.c
index 3ddb071e4..5a1fcd6f5 100644
--- a/xorg-server/hw/xwin/winmultiwindowwndproc.c
+++ b/xorg-server/hw/xwin/winmultiwindowwndproc.c
@@ -1,1042 +1,1033 @@
-/*
- *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
- *Copyright (C) Colin Harrison 2005-2008
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, sublicense, and/or sell copies of the Software, and to
- *permit persons to whom the Software is furnished to do so, subject to
- *the following conditions:
- *
- *The above copyright notice and this permission notice shall be
- *included in all copies or substantial portions of the Software.
- *
- *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
- *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *Except as contained in this notice, the name of the XFree86 Project
- *shall not be used in advertising or otherwise to promote the sale, use
- *or other dealings in this Software without prior written authorization
- *from the XFree86 Project.
- *
- * Authors: Kensuke Matsuzaki
- * Earle F. Philhower, III
- * Harold L Hunt II
- * Colin Harrison
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-#include "dixevents.h"
-#include "winmultiwindowclass.h"
-#include "winprefs.h"
-#include "winmsg.h"
-#include "inputstr.h"
-
-#ifdef XKB
-#ifndef XKB_IN_SERVER
-#define XKB_IN_SERVER
-#endif
-#include <xkbsrv.h>
-#endif
-
-/*
- * External global variables
- */
-
-extern Bool g_fCursor;
-extern Bool g_fKeyboardHookLL;
-extern Bool g_fSoftwareCursor;
-extern Bool g_fButton[3];
-
-extern void winUpdateWindowPosition (HWND hWnd, Bool reshape, HWND *zstyle);
-
-
-/*
- * Local globals
- */
-
-static UINT_PTR g_uipMousePollingTimerID = 0;
-
-
-/*
- * Constant defines
- */
-
-#define WIN_MULTIWINDOW_SHAPE YES
-
-
-/*
- * ConstrainSize - Taken from TWM sources - Respects hints for sizing
- */
-#define makemult(a,b) ((b==1) ? (a) : (((int)((a)/(b))) * (b)) )
-static void
-ConstrainSize (WinXSizeHints hints, int *widthp, int *heightp)
-{
- int minWidth, minHeight, maxWidth, maxHeight, xinc, yinc, delta;
- int baseWidth, baseHeight;
- int dwidth = *widthp, dheight = *heightp;
-
- if (hints.flags & PMinSize)
- {
- minWidth = hints.min_width;
- minHeight = hints.min_height;
- }
- else if (hints.flags & PBaseSize)
- {
- minWidth = hints.base_width;
- minHeight = hints.base_height;
- }
- else
- minWidth = minHeight = 1;
-
- if (hints.flags & PBaseSize)
- {
- baseWidth = hints.base_width;
- baseHeight = hints.base_height;
- }
- else if (hints.flags & PMinSize)
- {
- baseWidth = hints.min_width;
- baseHeight = hints.min_height;
- }
- else
- baseWidth = baseHeight = 0;
-
- if (hints.flags & PMaxSize)
- {
- maxWidth = hints.max_width;
- maxHeight = hints.max_height;
- }
- else
- {
- maxWidth = MAXINT;
- maxHeight = MAXINT;
- }
-
- if (hints.flags & PResizeInc)
- {
- xinc = hints.width_inc;
- yinc = hints.height_inc;
- }
- else
- xinc = yinc = 1;
-
- /*
- * First, clamp to min and max values
- */
- if (dwidth < minWidth)
- dwidth = minWidth;
- if (dheight < minHeight)
- dheight = minHeight;
-
- if (dwidth > maxWidth)
- dwidth = maxWidth;
- if (dheight > maxHeight)
- dheight = maxHeight;
-
- /*
- * Second, fit to base + N * inc
- */
- dwidth = ((dwidth - baseWidth) / xinc * xinc) + baseWidth;
- dheight = ((dheight - baseHeight) / yinc * yinc) + baseHeight;
-
- /*
- * Third, adjust for aspect ratio
- */
-
- /*
- * The math looks like this:
- *
- * minAspectX dwidth maxAspectX
- * ---------- <= ------- <= ----------
- * minAspectY dheight maxAspectY
- *
- * If that is multiplied out, then the width and height are
- * invalid in the following situations:
- *
- * minAspectX * dheight > minAspectY * dwidth
- * maxAspectX * dheight < maxAspectY * dwidth
- *
- */
-
- if (hints.flags & PAspect)
- {
- if (hints.min_aspect.x * dheight > hints.min_aspect.y * dwidth)
- {
- delta = makemult(hints.min_aspect.x * dheight / hints.min_aspect.y - dwidth, xinc);
- if (dwidth + delta <= maxWidth)
- dwidth += delta;
- else
- {
- delta = makemult(dheight - dwidth*hints.min_aspect.y/hints.min_aspect.x, yinc);
- if (dheight - delta >= minHeight)
- dheight -= delta;
- }
- }
-
- if (hints.max_aspect.x * dheight < hints.max_aspect.y * dwidth)
- {
- delta = makemult(dwidth * hints.max_aspect.y / hints.max_aspect.x - dheight, yinc);
- if (dheight + delta <= maxHeight)
- dheight += delta;
- else
- {
- delta = makemult(dwidth - hints.max_aspect.x*dheight/hints.max_aspect.y, xinc);
- if (dwidth - delta >= minWidth)
- dwidth -= delta;
- }
- }
- }
-
- /* Return computed values */
- *widthp = dwidth;
- *heightp = dheight;
-}
-#undef makemult
-
-
-
-/*
- * ValidateSizing - Ensures size request respects hints
- */
-static int
-ValidateSizing (HWND hwnd, WindowPtr pWin,
- WPARAM wParam, LPARAM lParam)
-{
- WinXSizeHints sizeHints;
- RECT *rect;
- int iWidth, iHeight;
- RECT rcClient, rcWindow;
- int iBorderWidthX, iBorderWidthY;
-
- /* Invalid input checking */
- if (pWin==NULL || lParam==0)
- return FALSE;
-
- /* No size hints, no checking */
- if (!winMultiWindowGetWMNormalHints (pWin, &sizeHints))
- return FALSE;
-
- /* Avoid divide-by-zero */
- if (sizeHints.flags & PResizeInc)
- {
- if (sizeHints.width_inc == 0) sizeHints.width_inc = 1;
- if (sizeHints.height_inc == 0) sizeHints.height_inc = 1;
- }
-
- rect = (RECT*)lParam;
-
- iWidth = rect->right - rect->left;
- iHeight = rect->bottom - rect->top;
-
- /* Now remove size of any borders and title bar */
- GetClientRect(hwnd, &rcClient);
- GetWindowRect(hwnd, &rcWindow);
- iBorderWidthX = (rcWindow.right - rcWindow.left) - (rcClient.right - rcClient.left);
- iBorderWidthY = (rcWindow.bottom - rcWindow.top) - (rcClient.bottom - rcClient.top);
- iWidth -= iBorderWidthX;
- iHeight -= iBorderWidthY;
-
- /* Constrain the size to legal values */
- ConstrainSize (sizeHints, &iWidth, &iHeight);
-
- /* Add back the size of borders and title bar */
- iWidth += iBorderWidthX;
- iHeight += iBorderWidthY;
-
- /* Adjust size according to where we're dragging from */
- switch(wParam) {
- case WMSZ_TOP:
- case WMSZ_TOPRIGHT:
- case WMSZ_BOTTOM:
- case WMSZ_BOTTOMRIGHT:
- case WMSZ_RIGHT:
- rect->right = rect->left + iWidth;
- break;
- default:
- rect->left = rect->right - iWidth;
- break;
- }
- switch(wParam) {
- case WMSZ_BOTTOM:
- case WMSZ_BOTTOMRIGHT:
- case WMSZ_BOTTOMLEFT:
- case WMSZ_RIGHT:
- case WMSZ_LEFT:
- rect->bottom = rect->top + iHeight;
- break;
- default:
- rect->top = rect->bottom - iHeight;
- break;
- }
- return TRUE;
-}
-
-extern Bool winInDestroyWindowsWindow;
-static Bool winInRaiseWindow = FALSE;
-static void winRaiseWindow(WindowPtr pWin)
-{
- if (!winInDestroyWindowsWindow && !winInRaiseWindow)
- {
- BOOL oldstate = winInRaiseWindow;
- XID vlist[1] = { 0 };
- winInRaiseWindow = TRUE;
- /* Call configure window directly to make sure it gets processed
- * in time
- */
- ConfigureWindow(pWin, CWStackMode, vlist, serverClient);
- winInRaiseWindow = oldstate;
- }
-}
-
-static
-void winStartMousePolling(winPrivScreenPtr s_pScreenPriv)
-{
- /*
- * Timer to poll mouse position. This is needed to make
- * programs like xeyes follow the mouse properly when the
- * mouse pointer is outside of any X window.
- */
- if (g_uipMousePollingTimerID == 0)
- g_uipMousePollingTimerID = SetTimer (s_pScreenPriv->hwndScreen,
- WIN_POLLING_MOUSE_TIMER_ID,
- MOUSE_POLLING_INTERVAL,
- NULL);
-}
-
-/*
- * winTopLevelWindowProc - Window procedure for all top-level Windows windows.
- */
-
-LRESULT CALLBACK
-winTopLevelWindowProc (HWND hwnd, UINT message,
- WPARAM wParam, LPARAM lParam)
-{
- POINT ptMouse;
- HDC hdcUpdate;
- PAINTSTRUCT ps;
- WindowPtr pWin = NULL;
- winPrivWinPtr pWinPriv = NULL;
- ScreenPtr s_pScreen = NULL;
- winPrivScreenPtr s_pScreenPriv = NULL;
- winScreenInfo *s_pScreenInfo = NULL;
- HWND hwndScreen = NULL;
- DrawablePtr pDraw = NULL;
- winWMMessageRec wmMsg;
- Bool fWMMsgInitialized = FALSE;
- static Bool s_fTracking = FALSE;
- Bool needRestack = FALSE;
- LRESULT ret;
-
- winDebugWin32Message("winTopLevelWindowProc", hwnd, message, wParam, lParam);
-
- /* Check if the Windows window property for our X window pointer is valid */
- if ((pWin = GetProp (hwnd, WIN_WINDOW_PROP)) != NULL)
- {
- /* Our X window pointer is valid */
-
- /* Get pointers to the drawable and the screen */
- pDraw = &pWin->drawable;
- s_pScreen = pWin->drawable.pScreen;
-
- /* Get a pointer to our window privates */
- pWinPriv = winGetWindowPriv(pWin);
-
- /* Get pointers to our screen privates and screen info */
- s_pScreenPriv = pWinPriv->pScreenPriv;
- s_pScreenInfo = s_pScreenPriv->pScreenInfo;
-
- /* Get the handle for our screen-sized window */
- hwndScreen = s_pScreenPriv->hwndScreen;
-
- /* */
- wmMsg.msg = 0;
- wmMsg.hwndWindow = hwnd;
- wmMsg.iWindow = (Window)GetProp (hwnd, WIN_WID_PROP);
-
- wmMsg.iX = pDraw->x;
- wmMsg.iY = pDraw->y;
- wmMsg.iWidth = pDraw->width;
- wmMsg.iHeight = pDraw->height;
-
- fWMMsgInitialized = TRUE;
-
- }
-
- /* Branch on message type */
- switch (message)
- {
- case WM_CREATE:
-
- /* */
- SetProp (hwnd,
- WIN_WINDOW_PROP,
- (HANDLE)((LPCREATESTRUCT) lParam)->lpCreateParams);
-
- /* */
- SetProp (hwnd,
- WIN_WID_PROP,
- (HANDLE)winGetWindowID (((LPCREATESTRUCT) lParam)->lpCreateParams));
-
- /*
- * Make X windows' Z orders sync with Windows windows because
- * there can be AlwaysOnTop windows overlapped on the window
- * currently being created.
- */
- winReorderWindowsMultiWindow ();
-
- /* Fix a 'round title bar corner background should be transparent not black' problem when first painted */
- {
- RECT rWindow;
- HRGN hRgnWindow;
- GetWindowRect(hwnd, &rWindow);
- hRgnWindow = CreateRectRgnIndirect(&rWindow);
- SetWindowRgn (hwnd, hRgnWindow, TRUE);
- DeleteObject(hRgnWindow);
- }
-
- SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)VCXSRV_SIGNATURE);
-
- return 0;
-
- case WM_INIT_SYS_MENU:
- /*
- * Add whatever the setup file wants to for this window
- */
- SetupSysMenu ((unsigned long)hwnd);
- return 0;
-
- case WM_SYSCOMMAND:
- /*
- * Any window menu items go through here
- */
- if (HandleCustomWM_COMMAND ((unsigned long)hwnd, LOWORD(wParam)))
- {
- /* Don't pass customized menus to DefWindowProc */
- return 0;
- }
- if (wParam == SC_RESTORE || wParam == SC_MAXIMIZE)
- {
- WINDOWPLACEMENT wndpl;
- wndpl.length = sizeof(wndpl);
- if (GetWindowPlacement(hwnd, &wndpl) && wndpl.showCmd == SW_SHOWMINIMIZED)
- needRestack = TRUE;
- }
- break;
-
- case WM_INITMENU:
- /* Checks/Unchecks any menu items before they are displayed */
- HandleCustomWM_INITMENU ((unsigned long)hwnd, wParam);
- break;
-
- case WM_ERASEBKGND:
- /*
- * Pretend that we did erase the background but we don't care,
- * since we repaint the entire region anyhow
- * This avoids some flickering when resizing.
- */
- return TRUE;
-
- case WM_PAINT:
- /* Only paint if our window handle is valid */
- if (hwndScreen == NULL)
- break;
-
- /* BeginPaint gives us an hdc that clips to the invalidated region */
- hdcUpdate = BeginPaint (hwnd, &ps);
- /* Avoid the BitBlt's if the PAINTSTRUCT is bogus */
- if (ps.rcPaint.right==0 && ps.rcPaint.bottom==0 && ps.rcPaint.left==0 && ps.rcPaint.top==0)
- {
- EndPaint (hwnd, &ps);
- return 0;
- }
-
- /* Try to copy from the shadow buffer */
- if (!BitBlt (hdcUpdate,
- ps.rcPaint.left, ps.rcPaint.top,
- ps.rcPaint.right - ps.rcPaint.left, ps.rcPaint.bottom - ps.rcPaint.top,
- s_pScreenPriv->hdcShadow,
- ps.rcPaint.left + pWin->drawable.x, ps.rcPaint.top + pWin->drawable.y,
- SRCCOPY))
- {
- 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 ("winTopLevelWindowProc - BitBlt failed: %s\n",
- (LPSTR)lpMsgBuf);
- LocalFree (lpMsgBuf);
- }
-
- /* EndPaint frees the DC */
- EndPaint (hwnd, &ps);
- return 0;
-
- case WM_MOUSEMOVE:
- /* Unpack the client area mouse coordinates */
- ptMouse.x = GET_X_LPARAM(lParam);
- ptMouse.y = GET_Y_LPARAM(lParam);
-
- /* Translate the client area mouse coordinates to screen coordinates */
- ClientToScreen (hwnd, &ptMouse);
-
- /* Screen Coords from (-X, -Y) -> Root Window (0, 0) */
- ptMouse.x -= GetSystemMetrics (SM_XVIRTUALSCREEN);
- ptMouse.y -= GetSystemMetrics (SM_YVIRTUALSCREEN);
-
- /* We can't do anything without privates */
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
-
- /* Has the mouse pointer crossed screens? */
- if (s_pScreen != miPointerGetScreen(g_pwinPointer))
- miPointerSetScreen (g_pwinPointer, s_pScreenInfo->dwScreen,
- ptMouse.x - s_pScreenInfo->dwXOffset,
- ptMouse.y - s_pScreenInfo->dwYOffset);
-
- /* Are we tracking yet? */
- if (!s_fTracking)
- {
- TRACKMOUSEEVENT tme;
-
- /* Setup data structure */
- ZeroMemory (&tme, sizeof (tme));
- tme.cbSize = sizeof (tme);
- tme.dwFlags = TME_LEAVE;
- tme.hwndTrack = hwnd;
-
- /* Call the tracking function */
- if (!(*g_fpTrackMouseEvent) (&tme))
- ErrorF ("winTopLevelWindowProc - _TrackMouseEvent failed\n");
-
- /* Flag that we are tracking now */
- s_fTracking = TRUE;
- }
-
- /* Hide or show the Windows mouse cursor */
- if (g_fSoftwareCursor && g_fCursor)
- {
- /* Hide Windows cursor */
- g_fCursor = FALSE;
- ShowCursor (FALSE);
- }
-
- /* Kill the timer used to poll mouse events */
- if (g_uipMousePollingTimerID != 0)
- {
- KillTimer (s_pScreenPriv->hwndScreen, WIN_POLLING_MOUSE_TIMER_ID);
- g_uipMousePollingTimerID = 0;
- }
-
- /* Deliver absolute cursor position to X Server */
- winEnqueueMotion(ptMouse.x - s_pScreenInfo->dwXOffset,
- ptMouse.y - s_pScreenInfo->dwYOffset);
-
- return 0;
-
- case WM_NCMOUSEMOVE:
- /*
- * We break instead of returning 0 since we need to call
- * DefWindowProc to get the mouse cursor changes
- * and min/max/close button highlighting in Windows XP.
- * The Platform SDK says that you should return 0 if you
- * process this message, but it fails to mention that you
- * will give up any default functionality if you do return 0.
- */
-
- /* We can't do anything without privates */
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
-
- /* Non-client mouse movement, show Windows cursor */
- if (g_fSoftwareCursor && !g_fCursor)
- {
- g_fCursor = TRUE;
- ShowCursor (TRUE);
- }
-
- winStartMousePolling(s_pScreenPriv);
-
- break;
-
- case WM_MOUSELEAVE:
- /* Mouse has left our client area */
-
- /* Flag that we are no longer tracking */
- s_fTracking = FALSE;
-
- /* Show the mouse cursor, if necessary */
- if (g_fSoftwareCursor && !g_fCursor)
- {
- g_fCursor = TRUE;
- ShowCursor (TRUE);
- }
-
- winStartMousePolling(s_pScreenPriv);
-
- return 0;
-
- case WM_LBUTTONDBLCLK:
- case WM_LBUTTONDOWN:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
- g_fButton[0] = TRUE;
- SetCapture(hwnd);
- return winMouseButtonsHandle (s_pScreen, ButtonPress, Button1, wParam);
-
- case WM_LBUTTONUP:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
- g_fButton[0] = FALSE;
- ReleaseCapture();
- winStartMousePolling(s_pScreenPriv);
- return winMouseButtonsHandle (s_pScreen, ButtonRelease, Button1, wParam);
-
- case WM_MBUTTONDBLCLK:
- case WM_MBUTTONDOWN:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
- g_fButton[1] = TRUE;
- SetCapture(hwnd);
- return winMouseButtonsHandle (s_pScreen, ButtonPress, Button2, wParam);
-
- case WM_MBUTTONUP:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
- g_fButton[1] = FALSE;
- ReleaseCapture();
- winStartMousePolling(s_pScreenPriv);
- return winMouseButtonsHandle (s_pScreen, ButtonRelease, Button2, wParam);
-
- case WM_RBUTTONDBLCLK:
- case WM_RBUTTONDOWN:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
- g_fButton[2] = TRUE;
- SetCapture(hwnd);
- return winMouseButtonsHandle (s_pScreen, ButtonPress, Button3, wParam);
-
- case WM_RBUTTONUP:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
- g_fButton[2] = FALSE;
- ReleaseCapture();
- winStartMousePolling(s_pScreenPriv);
- return winMouseButtonsHandle (s_pScreen, ButtonRelease, Button3, wParam);
-
- case WM_XBUTTONDBLCLK:
- case WM_XBUTTONDOWN:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
- SetCapture(hwnd);
- return winMouseButtonsHandle (s_pScreen, ButtonPress, HIWORD(wParam) + 5, wParam);
-
- case WM_XBUTTONUP:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
- ReleaseCapture();
- winStartMousePolling(s_pScreenPriv);
- return winMouseButtonsHandle (s_pScreen, ButtonRelease, HIWORD(wParam) + 5, wParam);
-
- case WM_MOUSEWHEEL:
- if (SendMessage(hwnd, WM_NCHITTEST, 0, MAKELONG(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))) == HTCLIENT)
- {
- /* Pass the message to the root window */
- SendMessage (hwndScreen, message, wParam, lParam);
- return 0;
- }
- else break;
-
- case WM_SETFOCUS:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
-
- {
- /* Get the parent window for transient handling */
- HWND hParent = GetParent(hwnd);
- if (hParent && IsIconic(hParent)) ShowWindow (hParent, SW_RESTORE);
- }
-
- winRestoreModeKeyStates ();
-
- /* Add the keyboard hook if possible */
- if (g_fKeyboardHookLL)
- g_fKeyboardHookLL = winInstallKeyboardHookLL ();
- return 0;
-
- case WM_KILLFOCUS:
- /* Pop any pressed keys since we are losing keyboard focus */
- winKeybdReleaseKeys ();
-
- /* Remove our keyboard hook if it is installed */
- winRemoveKeyboardHookLL ();
- if (!wParam)
- /* Revert the X focus as well, but only if the Windows focus is going to another window */
- DeleteWindowFromAnyEvents(pWin, FALSE);
- return 0;
-
- case WM_SYSDEADCHAR:
- case WM_DEADCHAR:
- /*
- * NOTE: We do nothing with WM_*CHAR messages,
- * nor does the root window, so we can just toss these messages.
- */
- return 0;
-
- case WM_SYSKEYDOWN:
- case WM_KEYDOWN:
-
- /*
- * Don't pass Alt-F4 key combo to root window,
- * let Windows translate to WM_CLOSE and close this top-level window.
- *
- * NOTE: We purposely don't check the fUseWinKillKey setting because
- * it should only apply to the key handling for the root window,
- * not for top-level window-manager windows.
- *
- * ALSO NOTE: We do pass Ctrl-Alt-Backspace to the root window
- * because that is a key combo that no X app should be expecting to
- * receive, since it has historically been used to shutdown the X server.
- * Passing Ctrl-Alt-Backspace to the root window preserves that
- * behavior, assuming that -unixkill has been passed as a parameter.
- */
- if (wParam == VK_F4 && (GetKeyState (VK_MENU) & 0x8000))
- break;
-
-#ifdef WINDBG
- if (wParam == VK_ESCAPE)
- {
- /* Place for debug: put any tests and dumps here */
- WINDOWPLACEMENT windPlace;
- RECT rc;
- LPRECT pRect;
-
- windPlace.length = sizeof (WINDOWPLACEMENT);
- GetWindowPlacement (hwnd, &windPlace);
- pRect = &windPlace.rcNormalPosition;
- winDebug ("\nCYGWINDOWING Dump:\n"
- "\tdrawable: (%hd, %hd) - %hdx%hd\n", pDraw->x,
- pDraw->y, pDraw->width, pDraw->height);
- winDebug ("\twindPlace: (%ld, %ld) - %ldx%ld\n", pRect->left,
- pRect->top, pRect->right - pRect->left,
- pRect->bottom - pRect->top);
- if (GetClientRect (hwnd, &rc))
- {
- pRect = &rc;
- winDebug ("\tClientRect: (%ld, %ld) - %ldx%ld\n", pRect->left,
- pRect->top, pRect->right - pRect->left,
- pRect->bottom - pRect->top);
- }
- if (GetWindowRect (hwnd, &rc))
- {
- pRect = &rc;
- winDebug ("\tWindowRect: (%ld, %ld) - %ldx%ld\n", pRect->left,
- pRect->top, pRect->right - pRect->left,
- pRect->bottom - pRect->top);
- }
- winDebug ("\n");
- }
-#endif
-
- /* Pass the message to the root window */
- return winWindowProc(hwndScreen, message, wParam, lParam);
-
- case WM_SYSKEYUP:
- case WM_KEYUP:
-
-
- /* Pass the message to the root window */
- return winWindowProc(hwndScreen, message, wParam, lParam);
-
- case WM_HOTKEY:
-
- /* Pass the message to the root window */
- SendMessage (hwndScreen, message, wParam, lParam);
- return 0;
-
- case WM_ACTIVATE:
-
- /* Pass the message to the root window */
- SendMessage (hwndScreen, message, wParam, lParam);
-
- if (LOWORD(wParam) != WA_INACTIVE)
- {
- /* Raise the window to the top in Z order */
- /* ago: Activate does not mean putting it to front! */
- /*
- wmMsg.msg = WM_WM_RAISE;
- if (fWMMsgInitialized)
- winSendMessageToWM (s_pScreenPriv->pWMInfo, &wmMsg);
- */
-
- /* Tell our Window Manager thread to activate the window */
- wmMsg.msg = WM_WM_ACTIVATE;
- if (fWMMsgInitialized && pWin->realized && !pWin->overrideRedirect /* for OOo menus */)
- winSendMessageToWM (s_pScreenPriv->pWMInfo, &wmMsg);
- }
- /* Prevent the mouse wheel from stalling when another window is minimized */
- if (HIWORD(wParam) == 0 && LOWORD(wParam) == WA_ACTIVE &&
- (HWND)lParam != NULL && (HWND)lParam != (HWND)GetParent(hwnd))
- SetFocus(hwnd);
- return 0;
-
- case WM_ACTIVATEAPP:
- /*
- * This message is also sent to the root window
- * so we do nothing for individual multiwindow windows
- */
- break;
-
- case WM_CLOSE:
- /* Branch on if the window was killed in X already */
- if (pWinPriv->fXKilled)
- {
- /* Window was killed, go ahead and destroy the window */
- DestroyWindow (hwnd);
- }
- else
- {
- /* Tell our Window Manager thread to kill the window */
- wmMsg.msg = WM_WM_KILL;
- if (fWMMsgInitialized)
- winSendMessageToWM (s_pScreenPriv->pWMInfo, &wmMsg);
- }
- return 0;
-
- case WM_DESTROY:
-
- /* Branch on if the window was killed in X already */
- if (pWinPriv && !pWinPriv->fXKilled)
- {
- winDebug ("winTopLevelWindowProc - WM_DESTROY - WM_WM_KILL\n");
-
- /* Tell our Window Manager thread to kill the window */
- wmMsg.msg = WM_WM_KILL;
- if (fWMMsgInitialized)
- winSendMessageToWM (s_pScreenPriv->pWMInfo, &wmMsg);
- }
-
- RemoveProp (hwnd, WIN_WINDOW_PROP);
- RemoveProp (hwnd, WIN_WID_PROP);
- RemoveProp (hwnd, WIN_NEEDMANAGE_PROP);
-
- break;
-
- case WM_MOVE:
- /* Adjust the X Window to the moved Windows window */
- winAdjustXWindow (pWin, hwnd);
- return 0;
-
- case WM_SHOWWINDOW:
- /* Bail out if the window is being hidden */
- if (!wParam)
- return 0;
-
- /* */
- if (!pWin->overrideRedirect)
- {
- /* Flag that this window needs to be made active when clicked */
- SetProp (hwnd, WIN_NEEDMANAGE_PROP, (HANDLE) 1);
-
- if (!(GetWindowLongPtr (hwnd, GWL_EXSTYLE) & WS_EX_APPWINDOW))
- {
- HWND zstyle = HWND_NOTOPMOST;
-
- /* Set the window extended style flags */
- SetWindowLongPtr (hwnd, GWL_EXSTYLE, WS_EX_APPWINDOW);
-
- /* Set the transient style flags */
- if (GetParent(hwnd)) SetWindowLongPtr (hwnd, GWL_STYLE,
- WS_POPUP | WS_OVERLAPPED | WS_SYSMENU | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
- /* Set the window standard style flags */
- else SetWindowLongPtr (hwnd, GWL_STYLE,
- (WS_POPUP | WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS)
- & ~WS_CAPTION & ~WS_SIZEBOX);
-
- winUpdateWindowPosition (hwnd, FALSE, &zstyle);
- SetForegroundWindow (hwnd);
- }
- wmMsg.msg = WM_WM_MAP3;
- }
- else /* It is an overridden window so make it top of Z stack */
- {
- HWND forHwnd = GetForegroundWindow();
- winDebug ("overridden window is shown\n");
- if (forHwnd != NULL)
- {
- if (GetWindowLongPtr(forHwnd, GWLP_USERDATA) & (LONG_PTR)VCXSRV_SIGNATURE)
- {
- if (GetWindowLongPtr(forHwnd, GWL_EXSTYLE) & WS_EX_TOPMOST)
- SetWindowPos (hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
- else
- SetWindowPos (hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
- }
- }
- wmMsg.msg = WM_WM_MAP2;
- }
-
- /* Tell our Window Manager thread to map the window */
- if (fWMMsgInitialized)
- winSendMessageToWM (s_pScreenPriv->pWMInfo, &wmMsg);
-
- winStartMousePolling(s_pScreenPriv);
-
- return 0;
-
- case WM_SIZING:
- /* Need to legalize the size according to WM_NORMAL_HINTS */
- /* for applications like xterm */
- return ValidateSizing (hwnd, pWin, wParam, lParam);
-
- case WM_WINDOWPOSCHANGED:
- {
- LPWINDOWPOS pWinPos = (LPWINDOWPOS) lParam;
-
- if (!(pWinPos->flags & SWP_NOZORDER))
- {
-#if CYGWINDOWING_DEBUG
- winDebug ("\twindow z order was changed\n");
-#endif
- if (pWinPos->hwndInsertAfter == HWND_TOP
- ||pWinPos->hwndInsertAfter == HWND_TOPMOST
- ||pWinPos->hwndInsertAfter == HWND_NOTOPMOST)
- {
-#if CYGWINDOWING_DEBUG
- winDebug ("\traise to top\n");
-#endif
- /* Raise the window to the top in Z order */
- winRaiseWindow(pWin);
- }
- else if (pWinPos->hwndInsertAfter == HWND_BOTTOM)
- {
- }
- else
- {
- /* Check if this window is top of X windows. */
- HWND hWndAbove = NULL;
- DWORD dwCurrentProcessID = GetCurrentProcessId ();
- DWORD dwWindowProcessID = 0;
-
- for (hWndAbove = pWinPos->hwndInsertAfter;
- hWndAbove != NULL;
- hWndAbove = GetNextWindow (hWndAbove, GW_HWNDPREV))
- {
- /* Ignore other XWin process's window */
- GetWindowThreadProcessId (hWndAbove, &dwWindowProcessID);
-
- if ((dwWindowProcessID == dwCurrentProcessID)
- && GetProp (hWndAbove, WIN_WINDOW_PROP)
- && !IsWindowVisible (hWndAbove)
- && !IsIconic (hWndAbove) ) /* ignore minimized windows */
- break;
- }
- /* If this is top of X windows in Windows stack,
- raise it in X stack. */
- if (hWndAbove == NULL)
- {
-#if CYGWINDOWING_DEBUG
- winDebug ("\traise to top\n");
-#endif
- winRaiseWindow(pWin);
- }
- }
- }
- }
- /*
- * Pass the message to DefWindowProc to let the function
- * break down WM_WINDOWPOSCHANGED to WM_MOVE and WM_SIZE.
- */
- break;
-
- case WM_SIZE:
- /* see dix/window.c */
-#ifdef WINDBG
- {
- char buf[64];
- switch (wParam)
- {
- case SIZE_MINIMIZED:
- strcpy(buf, "SIZE_MINIMIZED");
- break;
- case SIZE_MAXIMIZED:
- strcpy(buf, "SIZE_MAXIMIZED");
- break;
- case SIZE_RESTORED:
- strcpy(buf, "SIZE_RESTORED");
- break;
- default:
- strcpy(buf, "UNKNOWN_FLAG");
- }
- winDebug ("winTopLevelWindowProc - WM_SIZE to %dx%d (%s) - %d ms\n",
- (int)LOWORD(lParam), (int)HIWORD(lParam), buf,
- (int)(GetTickCount ()));
- }
-#endif
- /* Adjust the X Window to the moved Windows window */
- winAdjustXWindow (pWin, hwnd);
- if (wParam == SIZE_MINIMIZED) winReorderWindowsMultiWindow();
- return 0; /* end of WM_SIZE handler */
-
- case WM_STYLECHANGED:
- /* when the style changes, adjust the window size so the client area remains the same */
- {
- LONG x,y;
- DrawablePtr pDraw = &pWin->drawable;
- x = pDraw->x - wBorderWidth(pWin);
- y = pDraw->y - wBorderWidth(pWin);
- winPositionWindowMultiWindow(pWin, x, y);
- }
- return 0;
-
- case WM_MOUSEACTIVATE:
-
- /* Check if this window needs to be made active when clicked */
- if (!GetProp (pWinPriv->hWnd, WIN_NEEDMANAGE_PROP))
- {
- winDebug ("winTopLevelWindowProc - WM_MOUSEACTIVATE - "
- "MA_NOACTIVATE\n");
-
- /* */
- return MA_NOACTIVATE;
- }
- break;
-
- case WM_SETCURSOR:
- if (LOWORD(lParam) == HTCLIENT)
- {
- if (!g_fSoftwareCursor) SetCursor (s_pScreenPriv->cursor.handle);
- return TRUE;
- }
- break;
-
- default:
- break;
- }
-
- ret = DefWindowProc (hwnd, message, wParam, lParam);
- /*
- * If the window was minized we get the stack change before the window is restored
- * and so it gets lost. Ensure there stacking order is correct.
- */
- if (needRestack)
- winReorderWindowsMultiWindow();
- return ret;
-}
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *Copyright (C) Colin Harrison 2005-2008
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Kensuke Matsuzaki
+ * Earle F. Philhower, III
+ * Harold L Hunt II
+ * Colin Harrison
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+#include "dixevents.h"
+#include "winmultiwindowclass.h"
+#include "winprefs.h"
+#include "winmsg.h"
+#include "inputstr.h"
+
+#ifdef XKB
+#ifndef XKB_IN_SERVER
+#define XKB_IN_SERVER
+#endif
+#include <xkbsrv.h>
+#endif
+
+extern void winUpdateWindowPosition (HWND hWnd, Bool reshape, HWND *zstyle);
+
+
+/*
+ * Local globals
+ */
+
+static UINT_PTR g_uipMousePollingTimerID = 0;
+
+
+/*
+ * Constant defines
+ */
+
+#define WIN_MULTIWINDOW_SHAPE YES
+
+
+/*
+ * ConstrainSize - Taken from TWM sources - Respects hints for sizing
+ */
+#define makemult(a,b) ((b==1) ? (a) : (((int)((a)/(b))) * (b)) )
+static void
+ConstrainSize (WinXSizeHints hints, int *widthp, int *heightp)
+{
+ int minWidth, minHeight, maxWidth, maxHeight, xinc, yinc, delta;
+ int baseWidth, baseHeight;
+ int dwidth = *widthp, dheight = *heightp;
+
+ if (hints.flags & PMinSize)
+ {
+ minWidth = hints.min_width;
+ minHeight = hints.min_height;
+ }
+ else if (hints.flags & PBaseSize)
+ {
+ minWidth = hints.base_width;
+ minHeight = hints.base_height;
+ }
+ else
+ minWidth = minHeight = 1;
+
+ if (hints.flags & PBaseSize)
+ {
+ baseWidth = hints.base_width;
+ baseHeight = hints.base_height;
+ }
+ else if (hints.flags & PMinSize)
+ {
+ baseWidth = hints.min_width;
+ baseHeight = hints.min_height;
+ }
+ else
+ baseWidth = baseHeight = 0;
+
+ if (hints.flags & PMaxSize)
+ {
+ maxWidth = hints.max_width;
+ maxHeight = hints.max_height;
+ }
+ else
+ {
+ maxWidth = MAXINT;
+ maxHeight = MAXINT;
+ }
+
+ if (hints.flags & PResizeInc)
+ {
+ xinc = hints.width_inc;
+ yinc = hints.height_inc;
+ }
+ else
+ xinc = yinc = 1;
+
+ /*
+ * First, clamp to min and max values
+ */
+ if (dwidth < minWidth)
+ dwidth = minWidth;
+ if (dheight < minHeight)
+ dheight = minHeight;
+
+ if (dwidth > maxWidth)
+ dwidth = maxWidth;
+ if (dheight > maxHeight)
+ dheight = maxHeight;
+
+ /*
+ * Second, fit to base + N * inc
+ */
+ dwidth = ((dwidth - baseWidth) / xinc * xinc) + baseWidth;
+ dheight = ((dheight - baseHeight) / yinc * yinc) + baseHeight;
+
+ /*
+ * Third, adjust for aspect ratio
+ */
+
+ /*
+ * The math looks like this:
+ *
+ * minAspectX dwidth maxAspectX
+ * ---------- <= ------- <= ----------
+ * minAspectY dheight maxAspectY
+ *
+ * If that is multiplied out, then the width and height are
+ * invalid in the following situations:
+ *
+ * minAspectX * dheight > minAspectY * dwidth
+ * maxAspectX * dheight < maxAspectY * dwidth
+ *
+ */
+
+ if (hints.flags & PAspect)
+ {
+ if (hints.min_aspect.x * dheight > hints.min_aspect.y * dwidth)
+ {
+ delta = makemult(hints.min_aspect.x * dheight / hints.min_aspect.y - dwidth, xinc);
+ if (dwidth + delta <= maxWidth)
+ dwidth += delta;
+ else
+ {
+ delta = makemult(dheight - dwidth*hints.min_aspect.y/hints.min_aspect.x, yinc);
+ if (dheight - delta >= minHeight)
+ dheight -= delta;
+ }
+ }
+
+ if (hints.max_aspect.x * dheight < hints.max_aspect.y * dwidth)
+ {
+ delta = makemult(dwidth * hints.max_aspect.y / hints.max_aspect.x - dheight, yinc);
+ if (dheight + delta <= maxHeight)
+ dheight += delta;
+ else
+ {
+ delta = makemult(dwidth - hints.max_aspect.x*dheight/hints.max_aspect.y, xinc);
+ if (dwidth - delta >= minWidth)
+ dwidth -= delta;
+ }
+ }
+ }
+
+ /* Return computed values */
+ *widthp = dwidth;
+ *heightp = dheight;
+}
+#undef makemult
+
+
+
+/*
+ * ValidateSizing - Ensures size request respects hints
+ */
+static int
+ValidateSizing (HWND hwnd, WindowPtr pWin,
+ WPARAM wParam, LPARAM lParam)
+{
+ WinXSizeHints sizeHints;
+ RECT *rect;
+ int iWidth, iHeight;
+ RECT rcClient, rcWindow;
+ int iBorderWidthX, iBorderWidthY;
+
+ /* Invalid input checking */
+ if (pWin==NULL || lParam==0)
+ return FALSE;
+
+ /* No size hints, no checking */
+ if (!winMultiWindowGetWMNormalHints (pWin, &sizeHints))
+ return FALSE;
+
+ /* Avoid divide-by-zero */
+ if (sizeHints.flags & PResizeInc)
+ {
+ if (sizeHints.width_inc == 0) sizeHints.width_inc = 1;
+ if (sizeHints.height_inc == 0) sizeHints.height_inc = 1;
+ }
+
+ rect = (RECT*)lParam;
+
+ iWidth = rect->right - rect->left;
+ iHeight = rect->bottom - rect->top;
+
+ /* Now remove size of any borders and title bar */
+ GetClientRect(hwnd, &rcClient);
+ GetWindowRect(hwnd, &rcWindow);
+ iBorderWidthX = (rcWindow.right - rcWindow.left) - (rcClient.right - rcClient.left);
+ iBorderWidthY = (rcWindow.bottom - rcWindow.top) - (rcClient.bottom - rcClient.top);
+ iWidth -= iBorderWidthX;
+ iHeight -= iBorderWidthY;
+
+ /* Constrain the size to legal values */
+ ConstrainSize (sizeHints, &iWidth, &iHeight);
+
+ /* Add back the size of borders and title bar */
+ iWidth += iBorderWidthX;
+ iHeight += iBorderWidthY;
+
+ /* Adjust size according to where we're dragging from */
+ switch(wParam) {
+ case WMSZ_TOP:
+ case WMSZ_TOPRIGHT:
+ case WMSZ_BOTTOM:
+ case WMSZ_BOTTOMRIGHT:
+ case WMSZ_RIGHT:
+ rect->right = rect->left + iWidth;
+ break;
+ default:
+ rect->left = rect->right - iWidth;
+ break;
+ }
+ switch(wParam) {
+ case WMSZ_BOTTOM:
+ case WMSZ_BOTTOMRIGHT:
+ case WMSZ_BOTTOMLEFT:
+ case WMSZ_RIGHT:
+ case WMSZ_LEFT:
+ rect->bottom = rect->top + iHeight;
+ break;
+ default:
+ rect->top = rect->bottom - iHeight;
+ break;
+ }
+ return TRUE;
+}
+
+extern Bool winInDestroyWindowsWindow;
+static Bool winInRaiseWindow = FALSE;
+static void winRaiseWindow(WindowPtr pWin)
+{
+ if (!winInDestroyWindowsWindow && !winInRaiseWindow)
+ {
+ BOOL oldstate = winInRaiseWindow;
+ XID vlist[1] = { 0 };
+ winInRaiseWindow = TRUE;
+ /* Call configure window directly to make sure it gets processed
+ * in time
+ */
+ ConfigureWindow(pWin, CWStackMode, vlist, serverClient);
+ winInRaiseWindow = oldstate;
+ }
+}
+
+static
+void winStartMousePolling(winPrivScreenPtr s_pScreenPriv)
+{
+ /*
+ * Timer to poll mouse position. This is needed to make
+ * programs like xeyes follow the mouse properly when the
+ * mouse pointer is outside of any X window.
+ */
+ if (g_uipMousePollingTimerID == 0)
+ g_uipMousePollingTimerID = SetTimer (s_pScreenPriv->hwndScreen,
+ WIN_POLLING_MOUSE_TIMER_ID,
+ MOUSE_POLLING_INTERVAL,
+ NULL);
+}
+
+/*
+ * winTopLevelWindowProc - Window procedure for all top-level Windows windows.
+ */
+
+LRESULT CALLBACK
+winTopLevelWindowProc (HWND hwnd, UINT message,
+ WPARAM wParam, LPARAM lParam)
+{
+ POINT ptMouse;
+ HDC hdcUpdate;
+ PAINTSTRUCT ps;
+ WindowPtr pWin = NULL;
+ winPrivWinPtr pWinPriv = NULL;
+ ScreenPtr s_pScreen = NULL;
+ winPrivScreenPtr s_pScreenPriv = NULL;
+ winScreenInfo *s_pScreenInfo = NULL;
+ HWND hwndScreen = NULL;
+ DrawablePtr pDraw = NULL;
+ winWMMessageRec wmMsg;
+ Bool fWMMsgInitialized = FALSE;
+ static Bool s_fTracking = FALSE;
+ Bool needRestack = FALSE;
+ LRESULT ret;
+
+ winDebugWin32Message("winTopLevelWindowProc", hwnd, message, wParam, lParam);
+
+ /* Check if the Windows window property for our X window pointer is valid */
+ if ((pWin = GetProp (hwnd, WIN_WINDOW_PROP)) != NULL)
+ {
+ /* Our X window pointer is valid */
+
+ /* Get pointers to the drawable and the screen */
+ pDraw = &pWin->drawable;
+ s_pScreen = pWin->drawable.pScreen;
+
+ /* Get a pointer to our window privates */
+ pWinPriv = winGetWindowPriv(pWin);
+
+ /* Get pointers to our screen privates and screen info */
+ s_pScreenPriv = pWinPriv->pScreenPriv;
+ s_pScreenInfo = s_pScreenPriv->pScreenInfo;
+
+ /* Get the handle for our screen-sized window */
+ hwndScreen = s_pScreenPriv->hwndScreen;
+
+ /* */
+ wmMsg.msg = 0;
+ wmMsg.hwndWindow = hwnd;
+ wmMsg.iWindow = (Window)GetProp (hwnd, WIN_WID_PROP);
+
+ wmMsg.iX = pDraw->x;
+ wmMsg.iY = pDraw->y;
+ wmMsg.iWidth = pDraw->width;
+ wmMsg.iHeight = pDraw->height;
+
+ fWMMsgInitialized = TRUE;
+
+ }
+
+ /* Branch on message type */
+ switch (message)
+ {
+ case WM_CREATE:
+
+ /* */
+ SetProp (hwnd,
+ WIN_WINDOW_PROP,
+ (HANDLE)((LPCREATESTRUCT) lParam)->lpCreateParams);
+
+ /* */
+ SetProp (hwnd,
+ WIN_WID_PROP,
+ (HANDLE)winGetWindowID (((LPCREATESTRUCT) lParam)->lpCreateParams));
+
+ /*
+ * Make X windows' Z orders sync with Windows windows because
+ * there can be AlwaysOnTop windows overlapped on the window
+ * currently being created.
+ */
+ winReorderWindowsMultiWindow ();
+
+ /* Fix a 'round title bar corner background should be transparent not black' problem when first painted */
+ {
+ RECT rWindow;
+ HRGN hRgnWindow;
+ GetWindowRect(hwnd, &rWindow);
+ hRgnWindow = CreateRectRgnIndirect(&rWindow);
+ SetWindowRgn (hwnd, hRgnWindow, TRUE);
+ DeleteObject(hRgnWindow);
+ }
+
+ SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)VCXSRV_SIGNATURE);
+
+ return 0;
+
+ case WM_INIT_SYS_MENU:
+ /*
+ * Add whatever the setup file wants to for this window
+ */
+ SetupSysMenu ((unsigned long)hwnd);
+ return 0;
+
+ case WM_SYSCOMMAND:
+ /*
+ * Any window menu items go through here
+ */
+ if (HandleCustomWM_COMMAND ((unsigned long)hwnd, LOWORD(wParam)))
+ {
+ /* Don't pass customized menus to DefWindowProc */
+ return 0;
+ }
+ if (wParam == SC_RESTORE || wParam == SC_MAXIMIZE)
+ {
+ WINDOWPLACEMENT wndpl;
+ wndpl.length = sizeof(wndpl);
+ if (GetWindowPlacement(hwnd, &wndpl) && wndpl.showCmd == SW_SHOWMINIMIZED)
+ needRestack = TRUE;
+ }
+ break;
+
+ case WM_INITMENU:
+ /* Checks/Unchecks any menu items before they are displayed */
+ HandleCustomWM_INITMENU ((unsigned long)hwnd, wParam);
+ break;
+
+ case WM_ERASEBKGND:
+ /*
+ * Pretend that we did erase the background but we don't care,
+ * since we repaint the entire region anyhow
+ * This avoids some flickering when resizing.
+ */
+ return TRUE;
+
+ case WM_PAINT:
+ /* Only paint if our window handle is valid */
+ if (hwndScreen == NULL)
+ break;
+
+ /* BeginPaint gives us an hdc that clips to the invalidated region */
+ hdcUpdate = BeginPaint (hwnd, &ps);
+ /* Avoid the BitBlt's if the PAINTSTRUCT is bogus */
+ if (ps.rcPaint.right==0 && ps.rcPaint.bottom==0 && ps.rcPaint.left==0 && ps.rcPaint.top==0)
+ {
+ EndPaint (hwnd, &ps);
+ return 0;
+ }
+
+ /* Try to copy from the shadow buffer */
+ if (!BitBlt (hdcUpdate,
+ ps.rcPaint.left, ps.rcPaint.top,
+ ps.rcPaint.right - ps.rcPaint.left, ps.rcPaint.bottom - ps.rcPaint.top,
+ s_pScreenPriv->hdcShadow,
+ ps.rcPaint.left + pWin->drawable.x, ps.rcPaint.top + pWin->drawable.y,
+ SRCCOPY))
+ {
+ 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 ("winTopLevelWindowProc - BitBlt failed: %s\n",
+ (LPSTR)lpMsgBuf);
+ LocalFree (lpMsgBuf);
+ }
+
+ /* EndPaint frees the DC */
+ EndPaint (hwnd, &ps);
+ return 0;
+
+ case WM_MOUSEMOVE:
+ /* Unpack the client area mouse coordinates */
+ ptMouse.x = GET_X_LPARAM(lParam);
+ ptMouse.y = GET_Y_LPARAM(lParam);
+
+ /* Translate the client area mouse coordinates to screen coordinates */
+ ClientToScreen (hwnd, &ptMouse);
+
+ /* Screen Coords from (-X, -Y) -> Root Window (0, 0) */
+ ptMouse.x -= GetSystemMetrics (SM_XVIRTUALSCREEN);
+ ptMouse.y -= GetSystemMetrics (SM_YVIRTUALSCREEN);
+
+ /* We can't do anything without privates */
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+
+ /* Has the mouse pointer crossed screens? */
+ if (s_pScreen != miPointerGetScreen(g_pwinPointer))
+ miPointerSetScreen (g_pwinPointer, s_pScreenInfo->dwScreen,
+ ptMouse.x - s_pScreenInfo->dwXOffset,
+ ptMouse.y - s_pScreenInfo->dwYOffset);
+
+ /* Are we tracking yet? */
+ if (!s_fTracking)
+ {
+ TRACKMOUSEEVENT tme;
+
+ /* Setup data structure */
+ ZeroMemory (&tme, sizeof (tme));
+ tme.cbSize = sizeof (tme);
+ tme.dwFlags = TME_LEAVE;
+ tme.hwndTrack = hwnd;
+
+ /* Call the tracking function */
+ if (!(*g_fpTrackMouseEvent) (&tme))
+ ErrorF ("winTopLevelWindowProc - _TrackMouseEvent failed\n");
+
+ /* Flag that we are tracking now */
+ s_fTracking = TRUE;
+ }
+
+ /* Hide or show the Windows mouse cursor */
+ if (g_fSoftwareCursor && g_fCursor)
+ {
+ /* Hide Windows cursor */
+ g_fCursor = FALSE;
+ ShowCursor (FALSE);
+ }
+
+ /* Kill the timer used to poll mouse events */
+ if (g_uipMousePollingTimerID != 0)
+ {
+ KillTimer (s_pScreenPriv->hwndScreen, WIN_POLLING_MOUSE_TIMER_ID);
+ g_uipMousePollingTimerID = 0;
+ }
+
+ /* Deliver absolute cursor position to X Server */
+ winEnqueueMotion(ptMouse.x - s_pScreenInfo->dwXOffset,
+ ptMouse.y - s_pScreenInfo->dwYOffset);
+
+ return 0;
+
+ case WM_NCMOUSEMOVE:
+ /*
+ * We break instead of returning 0 since we need to call
+ * DefWindowProc to get the mouse cursor changes
+ * and min/max/close button highlighting in Windows XP.
+ * The Platform SDK says that you should return 0 if you
+ * process this message, but it fails to mention that you
+ * will give up any default functionality if you do return 0.
+ */
+
+ /* We can't do anything without privates */
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+
+ /* Non-client mouse movement, show Windows cursor */
+ if (g_fSoftwareCursor && !g_fCursor)
+ {
+ g_fCursor = TRUE;
+ ShowCursor (TRUE);
+ }
+
+ winStartMousePolling(s_pScreenPriv);
+
+ break;
+
+ case WM_MOUSELEAVE:
+ /* Mouse has left our client area */
+
+ /* Flag that we are no longer tracking */
+ s_fTracking = FALSE;
+
+ /* Show the mouse cursor, if necessary */
+ if (g_fSoftwareCursor && !g_fCursor)
+ {
+ g_fCursor = TRUE;
+ ShowCursor (TRUE);
+ }
+
+ winStartMousePolling(s_pScreenPriv);
+
+ return 0;
+
+ case WM_LBUTTONDBLCLK:
+ case WM_LBUTTONDOWN:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ g_fButton[0] = TRUE;
+ SetCapture(hwnd);
+ return winMouseButtonsHandle (s_pScreen, ButtonPress, Button1, wParam);
+
+ case WM_LBUTTONUP:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ g_fButton[0] = FALSE;
+ ReleaseCapture();
+ winStartMousePolling(s_pScreenPriv);
+ return winMouseButtonsHandle (s_pScreen, ButtonRelease, Button1, wParam);
+
+ case WM_MBUTTONDBLCLK:
+ case WM_MBUTTONDOWN:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ g_fButton[1] = TRUE;
+ SetCapture(hwnd);
+ return winMouseButtonsHandle (s_pScreen, ButtonPress, Button2, wParam);
+
+ case WM_MBUTTONUP:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ g_fButton[1] = FALSE;
+ ReleaseCapture();
+ winStartMousePolling(s_pScreenPriv);
+ return winMouseButtonsHandle (s_pScreen, ButtonRelease, Button2, wParam);
+
+ case WM_RBUTTONDBLCLK:
+ case WM_RBUTTONDOWN:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ g_fButton[2] = TRUE;
+ SetCapture(hwnd);
+ return winMouseButtonsHandle (s_pScreen, ButtonPress, Button3, wParam);
+
+ case WM_RBUTTONUP:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ g_fButton[2] = FALSE;
+ ReleaseCapture();
+ winStartMousePolling(s_pScreenPriv);
+ return winMouseButtonsHandle (s_pScreen, ButtonRelease, Button3, wParam);
+
+ case WM_XBUTTONDBLCLK:
+ case WM_XBUTTONDOWN:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ SetCapture(hwnd);
+ return winMouseButtonsHandle (s_pScreen, ButtonPress, HIWORD(wParam) + 5, wParam);
+
+ case WM_XBUTTONUP:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ ReleaseCapture();
+ winStartMousePolling(s_pScreenPriv);
+ return winMouseButtonsHandle (s_pScreen, ButtonRelease, HIWORD(wParam) + 5, wParam);
+
+ case WM_MOUSEWHEEL:
+ if (SendMessage(hwnd, WM_NCHITTEST, 0, MAKELONG(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))) == HTCLIENT)
+ {
+ /* Pass the message to the root window */
+ SendMessage (hwndScreen, message, wParam, lParam);
+ return 0;
+ }
+ else break;
+
+ case WM_SETFOCUS:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+
+ {
+ /* Get the parent window for transient handling */
+ HWND hParent = GetParent(hwnd);
+ if (hParent && IsIconic(hParent)) ShowWindow (hParent, SW_RESTORE);
+ }
+
+ winRestoreModeKeyStates ();
+
+ /* Add the keyboard hook if possible */
+ if (g_fKeyboardHookLL)
+ g_fKeyboardHookLL = winInstallKeyboardHookLL ();
+ return 0;
+
+ case WM_KILLFOCUS:
+ /* Pop any pressed keys since we are losing keyboard focus */
+ winKeybdReleaseKeys ();
+
+ /* Remove our keyboard hook if it is installed */
+ winRemoveKeyboardHookLL ();
+ if (!wParam)
+ /* Revert the X focus as well, but only if the Windows focus is going to another window */
+ DeleteWindowFromAnyEvents(pWin, FALSE);
+ return 0;
+
+ case WM_SYSDEADCHAR:
+ case WM_DEADCHAR:
+ /*
+ * NOTE: We do nothing with WM_*CHAR messages,
+ * nor does the root window, so we can just toss these messages.
+ */
+ return 0;
+
+ case WM_SYSKEYDOWN:
+ case WM_KEYDOWN:
+
+ /*
+ * Don't pass Alt-F4 key combo to root window,
+ * let Windows translate to WM_CLOSE and close this top-level window.
+ *
+ * NOTE: We purposely don't check the fUseWinKillKey setting because
+ * it should only apply to the key handling for the root window,
+ * not for top-level window-manager windows.
+ *
+ * ALSO NOTE: We do pass Ctrl-Alt-Backspace to the root window
+ * because that is a key combo that no X app should be expecting to
+ * receive, since it has historically been used to shutdown the X server.
+ * Passing Ctrl-Alt-Backspace to the root window preserves that
+ * behavior, assuming that -unixkill has been passed as a parameter.
+ */
+ if (wParam == VK_F4 && (GetKeyState (VK_MENU) & 0x8000))
+ break;
+
+#ifdef WINDBG
+ if (wParam == VK_ESCAPE)
+ {
+ /* Place for debug: put any tests and dumps here */
+ WINDOWPLACEMENT windPlace;
+ RECT rc;
+ LPRECT pRect;
+
+ windPlace.length = sizeof (WINDOWPLACEMENT);
+ GetWindowPlacement (hwnd, &windPlace);
+ pRect = &windPlace.rcNormalPosition;
+ winDebug ("\nCYGWINDOWING Dump:\n"
+ "\tdrawable: (%hd, %hd) - %hdx%hd\n", pDraw->x,
+ pDraw->y, pDraw->width, pDraw->height);
+ winDebug ("\twindPlace: (%ld, %ld) - %ldx%ld\n", pRect->left,
+ pRect->top, pRect->right - pRect->left,
+ pRect->bottom - pRect->top);
+ if (GetClientRect (hwnd, &rc))
+ {
+ pRect = &rc;
+ winDebug ("\tClientRect: (%ld, %ld) - %ldx%ld\n", pRect->left,
+ pRect->top, pRect->right - pRect->left,
+ pRect->bottom - pRect->top);
+ }
+ if (GetWindowRect (hwnd, &rc))
+ {
+ pRect = &rc;
+ winDebug ("\tWindowRect: (%ld, %ld) - %ldx%ld\n", pRect->left,
+ pRect->top, pRect->right - pRect->left,
+ pRect->bottom - pRect->top);
+ }
+ winDebug ("\n");
+ }
+#endif
+
+ /* Pass the message to the root window */
+ return winWindowProc(hwndScreen, message, wParam, lParam);
+
+ case WM_SYSKEYUP:
+ case WM_KEYUP:
+
+
+ /* Pass the message to the root window */
+ return winWindowProc(hwndScreen, message, wParam, lParam);
+
+ case WM_HOTKEY:
+
+ /* Pass the message to the root window */
+ SendMessage (hwndScreen, message, wParam, lParam);
+ return 0;
+
+ case WM_ACTIVATE:
+
+ /* Pass the message to the root window */
+ SendMessage (hwndScreen, message, wParam, lParam);
+
+ if (LOWORD(wParam) != WA_INACTIVE)
+ {
+ /* Raise the window to the top in Z order */
+ /* ago: Activate does not mean putting it to front! */
+ /*
+ wmMsg.msg = WM_WM_RAISE;
+ if (fWMMsgInitialized)
+ winSendMessageToWM (s_pScreenPriv->pWMInfo, &wmMsg);
+ */
+
+ /* Tell our Window Manager thread to activate the window */
+ wmMsg.msg = WM_WM_ACTIVATE;
+ if (fWMMsgInitialized && pWin->realized && !pWin->overrideRedirect /* for OOo menus */)
+ winSendMessageToWM (s_pScreenPriv->pWMInfo, &wmMsg);
+ }
+ /* Prevent the mouse wheel from stalling when another window is minimized */
+ if (HIWORD(wParam) == 0 && LOWORD(wParam) == WA_ACTIVE &&
+ (HWND)lParam != NULL && (HWND)lParam != (HWND)GetParent(hwnd))
+ SetFocus(hwnd);
+ return 0;
+
+ case WM_ACTIVATEAPP:
+ /*
+ * This message is also sent to the root window
+ * so we do nothing for individual multiwindow windows
+ */
+ break;
+
+ case WM_CLOSE:
+ /* Branch on if the window was killed in X already */
+ if (pWinPriv->fXKilled)
+ {
+ /* Window was killed, go ahead and destroy the window */
+ DestroyWindow (hwnd);
+ }
+ else
+ {
+ /* Tell our Window Manager thread to kill the window */
+ wmMsg.msg = WM_WM_KILL;
+ if (fWMMsgInitialized)
+ winSendMessageToWM (s_pScreenPriv->pWMInfo, &wmMsg);
+ }
+ return 0;
+
+ case WM_DESTROY:
+
+ /* Branch on if the window was killed in X already */
+ if (pWinPriv && !pWinPriv->fXKilled)
+ {
+ winDebug ("winTopLevelWindowProc - WM_DESTROY - WM_WM_KILL\n");
+
+ /* Tell our Window Manager thread to kill the window */
+ wmMsg.msg = WM_WM_KILL;
+ if (fWMMsgInitialized)
+ winSendMessageToWM (s_pScreenPriv->pWMInfo, &wmMsg);
+ }
+
+ RemoveProp (hwnd, WIN_WINDOW_PROP);
+ RemoveProp (hwnd, WIN_WID_PROP);
+ RemoveProp (hwnd, WIN_NEEDMANAGE_PROP);
+
+ break;
+
+ case WM_MOVE:
+ /* Adjust the X Window to the moved Windows window */
+ winAdjustXWindow (pWin, hwnd);
+ return 0;
+
+ case WM_SHOWWINDOW:
+ /* Bail out if the window is being hidden */
+ if (!wParam)
+ return 0;
+
+ /* */
+ if (!pWin->overrideRedirect)
+ {
+ /* Flag that this window needs to be made active when clicked */
+ SetProp (hwnd, WIN_NEEDMANAGE_PROP, (HANDLE) 1);
+
+ if (!(GetWindowLongPtr (hwnd, GWL_EXSTYLE) & WS_EX_APPWINDOW))
+ {
+ HWND zstyle = HWND_NOTOPMOST;
+
+ /* Set the window extended style flags */
+ SetWindowLongPtr (hwnd, GWL_EXSTYLE, WS_EX_APPWINDOW);
+
+ /* Set the transient style flags */
+ if (GetParent(hwnd)) SetWindowLongPtr (hwnd, GWL_STYLE,
+ WS_POPUP | WS_OVERLAPPED | WS_SYSMENU | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
+ /* Set the window standard style flags */
+ else SetWindowLongPtr (hwnd, GWL_STYLE,
+ (WS_POPUP | WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS)
+ & ~WS_CAPTION & ~WS_SIZEBOX);
+
+ winUpdateWindowPosition (hwnd, FALSE, &zstyle);
+ SetForegroundWindow (hwnd);
+ }
+ wmMsg.msg = WM_WM_MAP3;
+ }
+ else /* It is an overridden window so make it top of Z stack */
+ {
+ HWND forHwnd = GetForegroundWindow();
+ winDebug ("overridden window is shown\n");
+ if (forHwnd != NULL)
+ {
+ if (GetWindowLongPtr(forHwnd, GWLP_USERDATA) & (LONG_PTR)VCXSRV_SIGNATURE)
+ {
+ if (GetWindowLongPtr(forHwnd, GWL_EXSTYLE) & WS_EX_TOPMOST)
+ SetWindowPos (hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
+ else
+ SetWindowPos (hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
+ }
+ }
+ wmMsg.msg = WM_WM_MAP2;
+ }
+
+ /* Tell our Window Manager thread to map the window */
+ if (fWMMsgInitialized)
+ winSendMessageToWM (s_pScreenPriv->pWMInfo, &wmMsg);
+
+ winStartMousePolling(s_pScreenPriv);
+
+ return 0;
+
+ case WM_SIZING:
+ /* Need to legalize the size according to WM_NORMAL_HINTS */
+ /* for applications like xterm */
+ return ValidateSizing (hwnd, pWin, wParam, lParam);
+
+ case WM_WINDOWPOSCHANGED:
+ {
+ LPWINDOWPOS pWinPos = (LPWINDOWPOS) lParam;
+
+ if (!(pWinPos->flags & SWP_NOZORDER))
+ {
+#if CYGWINDOWING_DEBUG
+ winDebug ("\twindow z order was changed\n");
+#endif
+ if (pWinPos->hwndInsertAfter == HWND_TOP
+ ||pWinPos->hwndInsertAfter == HWND_TOPMOST
+ ||pWinPos->hwndInsertAfter == HWND_NOTOPMOST)
+ {
+#if CYGWINDOWING_DEBUG
+ winDebug ("\traise to top\n");
+#endif
+ /* Raise the window to the top in Z order */
+ winRaiseWindow(pWin);
+ }
+ else if (pWinPos->hwndInsertAfter == HWND_BOTTOM)
+ {
+ }
+ else
+ {
+ /* Check if this window is top of X windows. */
+ HWND hWndAbove = NULL;
+ DWORD dwCurrentProcessID = GetCurrentProcessId ();
+ DWORD dwWindowProcessID = 0;
+
+ for (hWndAbove = pWinPos->hwndInsertAfter;
+ hWndAbove != NULL;
+ hWndAbove = GetNextWindow (hWndAbove, GW_HWNDPREV))
+ {
+ /* Ignore other XWin process's window */
+ GetWindowThreadProcessId (hWndAbove, &dwWindowProcessID);
+
+ if ((dwWindowProcessID == dwCurrentProcessID)
+ && GetProp (hWndAbove, WIN_WINDOW_PROP)
+ && !IsWindowVisible (hWndAbove)
+ && !IsIconic (hWndAbove) ) /* ignore minimized windows */
+ break;
+ }
+ /* If this is top of X windows in Windows stack,
+ raise it in X stack. */
+ if (hWndAbove == NULL)
+ {
+#if CYGWINDOWING_DEBUG
+ winDebug ("\traise to top\n");
+#endif
+ winRaiseWindow(pWin);
+ }
+ }
+ }
+ }
+ /*
+ * Pass the message to DefWindowProc to let the function
+ * break down WM_WINDOWPOSCHANGED to WM_MOVE and WM_SIZE.
+ */
+ break;
+
+ case WM_SIZE:
+ /* see dix/window.c */
+#ifdef WINDBG
+ {
+ char buf[64];
+ switch (wParam)
+ {
+ case SIZE_MINIMIZED:
+ strcpy(buf, "SIZE_MINIMIZED");
+ break;
+ case SIZE_MAXIMIZED:
+ strcpy(buf, "SIZE_MAXIMIZED");
+ break;
+ case SIZE_RESTORED:
+ strcpy(buf, "SIZE_RESTORED");
+ break;
+ default:
+ strcpy(buf, "UNKNOWN_FLAG");
+ }
+ winDebug ("winTopLevelWindowProc - WM_SIZE to %dx%d (%s) - %d ms\n",
+ (int)LOWORD(lParam), (int)HIWORD(lParam), buf,
+ (int)(GetTickCount ()));
+ }
+#endif
+ /* Adjust the X Window to the moved Windows window */
+ winAdjustXWindow (pWin, hwnd);
+ if (wParam == SIZE_MINIMIZED) winReorderWindowsMultiWindow();
+ return 0; /* end of WM_SIZE handler */
+
+ case WM_STYLECHANGED:
+ /* when the style changes, adjust the window size so the client area remains the same */
+ {
+ LONG x,y;
+ DrawablePtr pDraw = &pWin->drawable;
+ x = pDraw->x - wBorderWidth(pWin);
+ y = pDraw->y - wBorderWidth(pWin);
+ winPositionWindowMultiWindow(pWin, x, y);
+ }
+ return 0;
+
+ case WM_MOUSEACTIVATE:
+
+ /* Check if this window needs to be made active when clicked */
+ if (!GetProp (pWinPriv->hWnd, WIN_NEEDMANAGE_PROP))
+ {
+ winDebug ("winTopLevelWindowProc - WM_MOUSEACTIVATE - "
+ "MA_NOACTIVATE\n");
+
+ /* */
+ return MA_NOACTIVATE;
+ }
+ break;
+
+ case WM_SETCURSOR:
+ if (LOWORD(lParam) == HTCLIENT)
+ {
+ if (!g_fSoftwareCursor) SetCursor (s_pScreenPriv->cursor.handle);
+ return TRUE;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ ret = DefWindowProc (hwnd, message, wParam, lParam);
+ /*
+ * If the window was minized we get the stack change before the window is restored
+ * and so it gets lost. Ensure there stacking order is correct.
+ */
+ if (needRestack)
+ winReorderWindowsMultiWindow();
+ return ret;
+}
diff --git a/xorg-server/hw/xwin/winnativegdi.c b/xorg-server/hw/xwin/winnativegdi.c
index 7b4f7e0e4..005760d98 100644
--- a/xorg-server/hw/xwin/winnativegdi.c
+++ b/xorg-server/hw/xwin/winnativegdi.c
@@ -1,546 +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: Harold L Hunt II
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-
-
-/*
- * External symbols
- */
-
-extern HWND g_hDlgExit;
-
-
-/*
- * Local function prototypes
- */
-
-static Bool
-winAllocateFBNativeGDI (ScreenPtr pScreen);
-
-static void
-winShadowUpdateNativeGDI (ScreenPtr pScreen,
- shadowBufPtr pBuf);
-
-static Bool
-winCloseScreenNativeGDI (int nIndex, ScreenPtr pScreen);
-
-static Bool
-winInitVisualsNativeGDI (ScreenPtr pScreen);
-
-static Bool
-winAdjustVideoModeNativeGDI (ScreenPtr pScreen);
-
-#if 0
-static Bool
-winBltExposedRegionsNativeGDI (ScreenPtr pScreen);
-#endif
-
-static Bool
-winActivateAppNativeGDI (ScreenPtr pScreen);
-
-static Bool
-winRedrawScreenNativeGDI (ScreenPtr pScreen);
-
-static Bool
-winRealizeInstalledPaletteNativeGDI (ScreenPtr pScreen);
-
-static Bool
-winInstallColormapNativeGDI (ColormapPtr pColormap);
-
-static Bool
-winStoreColorsNativeGDI (ColormapPtr pmap,
- int ndef,
- xColorItem *pdefs);
-
-static Bool
-winCreateColormapNativeGDI (ColormapPtr pColormap);
-
-static Bool
-winDestroyColormapNativeGDI (ColormapPtr pColormap);
-
-
-
-static Bool
-winAllocateFBNativeGDI (ScreenPtr pScreen)
-{
- FatalError ("winAllocateFBNativeGDI\n");
-
- return TRUE;
-}
-
-
-/*
- * We wrap whatever CloseScreen procedure was specified by fb;
- * a pointer to said procedure is stored in our privates.
- */
-
-static Bool
-winCloseScreenNativeGDI (int nIndex, ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-
- winDebug ("winCloseScreenNativeGDI - Freeing screen resources\n");
-
- /* Flag that the screen is closed */
- pScreenPriv->fClosed = TRUE;
- pScreenPriv->fActive = FALSE;
-
- /*
- * NOTE: mi doesn't use a CloseScreen procedure, so we do not
- * need to call a wrapped procedure here.
- */
-
- /* Delete the window property */
- RemoveProp (pScreenPriv->hwndScreen, WIN_SCR_PROP);
-
- winDebug ("winCloseScreenNativeGDI - Destroying window\n");
-
- /* 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;
- }
-
- /* Invalidate our screeninfo's pointer to the screen */
- pScreenInfo->pScreen = NULL;
-
- /* Free the screen privates for this screen */
- free (pScreenPriv);
-
- winDebug ("winCloseScreenNativeGDI - Returning\n");
-
- return TRUE;
-}
-
-
-static void
-winShadowUpdateNativeGDI (ScreenPtr pScreen,
- shadowBufPtr pBuf)
-{
- FatalError ("winShadowUpdateNativeGDI\n");
- return;
-}
-
-
-static Bool
-winInitVisualsNativeGDI (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-
- /* Set the bitsPerRGB and bit masks */
- switch (pScreenInfo->dwDepth)
- {
- case 24:
- pScreenPriv->dwBitsPerRGB = 8;
- pScreenPriv->dwRedMask = 0x00FF0000;
- pScreenPriv->dwGreenMask = 0x0000FF00;
- pScreenPriv->dwBlueMask = 0x000000FF;
- break;
-
- case 16:
- pScreenPriv->dwBitsPerRGB = 6;
- pScreenPriv->dwRedMask = 0xF800;
- pScreenPriv->dwGreenMask = 0x07E0;
- pScreenPriv->dwBlueMask = 0x001F;
- break;
-
- case 15:
- pScreenPriv->dwBitsPerRGB = 5;
- pScreenPriv->dwRedMask = 0x7C00;
- pScreenPriv->dwGreenMask = 0x03E0;
- pScreenPriv->dwBlueMask = 0x001F;
- break;
-
- case 8:
- pScreenPriv->dwBitsPerRGB = 8;
- pScreenPriv->dwRedMask = 0;
- pScreenPriv->dwGreenMask = 0;
- pScreenPriv->dwBlueMask = 0;
- break;
-
- default:
- ErrorF ("winInitVisualsNativeGDI - Unknown screen depth\n");
- return FALSE;
- break;
- }
-
- /* Tell the user how many bits per RGB we are using */
- winDebug ("winInitVisualsNativeGDI - Using dwBitsPerRGB: %d\n",
- (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 ("winInitVisuals - miSetVisualTypesAndMasks failed\n");
- return FALSE;
- }
- break;
-
- case 8:
- winDebug ("winInitVisuals - Calling miSetVisualTypesAndMasks\n");
- if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
- StaticColorMask,
- pScreenPriv->dwBitsPerRGB,
- StaticColor,
- pScreenPriv->dwRedMask,
- pScreenPriv->dwGreenMask,
- pScreenPriv->dwBlueMask))
- {
- ErrorF ("winInitVisuals - miSetVisualTypesAndMasks failed\n");
- return FALSE;
- }
- break;
-
- default:
- ErrorF ("winInitVisualsNativeGDI - Unknown screen depth\n");
- return FALSE;
- }
-
- winDebug ("winInitVisualsNativeGDI - Returning\n");
-
- return TRUE;
-}
-
-
-/* Adjust the video mode */
-static Bool
-winAdjustVideoModeNativeGDI (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- HDC hdc = NULL;
- DWORD dwBPP;
-
- hdc = GetDC (NULL);
-
- /* We're in serious trouble if we can't get a DC */
- if (hdc == NULL)
- {
- ErrorF ("winAdjustVideoModeNativeGDI - GetDC () failed\n");
- return FALSE;
- }
-
- /* Query GDI for current display depth */
- dwBPP = GetDeviceCaps (hdc, BITSPIXEL);
- pScreenInfo->dwDepth = GetDeviceCaps (hdc, PLANES);
-
- switch (pScreenInfo->dwDepth) {
- case 24:
- case 16:
- case 15:
- case 8:
- break;
- default:
- if (dwBPP == 32)
- pScreenInfo->dwDepth = 24;
- else
- pScreenInfo->dwDepth = dwBPP;
- break;
- }
-
- /* GDI cannot change the screen depth */
- if (pScreenInfo->dwBPP == WIN_DEFAULT_BPP)
- {
- /* No -depth parameter passed, let the user know the depth being used */
- winDebug ("winAdjustVideoModeNativeGDI - Using Windows display "
- "depth of %d bits per pixel, %d depth\n",
- (int) dwBPP, (int) pScreenInfo->dwDepth);
-
- /* Use GDI's depth */
- pScreenInfo->dwBPP = dwBPP;
- }
- else if (dwBPP != pScreenInfo->dwBPP)
- {
- /* Warn user if GDI depth is different than -depth parameter */
- winDebug ("winAdjustVideoModeNativeGDI - Command line bpp: %d, "\
- "using bpp: %d\n",
- (int) pScreenInfo->dwBPP, (int) dwBPP);
-
- /* We'll use GDI's depth */
- pScreenInfo->dwBPP = dwBPP;
- }
-
- /* Release our DC */
- ReleaseDC (NULL, hdc);
-
- return TRUE;
-}
-
-
-static Bool
-winActivateAppNativeGDI (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-
- /*
- * Are we active?
- * Are we fullscreen?
- */
- if (pScreenPriv != NULL
- && pScreenPriv->fActive
- && pScreenInfo->fFullScreen)
- {
- /*
- * Activating, attempt to bring our window
- * to the top of the display
- */
- ShowWindow (pScreenPriv->hwndScreen, SW_RESTORE);
- }
-
- /*
- * Are we inactive?
- * Are we fullscreen?
- */
- if (pScreenPriv != NULL
- && !pScreenPriv->fActive
- && pScreenInfo->fFullScreen)
- {
- /*
- * Deactivating, stuff our window onto the
- * task bar.
- */
- ShowWindow (pScreenPriv->hwndScreen, SW_MINIMIZE);
- }
-
- return TRUE;
-}
-
-
-HBITMAP
-winCreateDIBNativeGDI (int iWidth, int iHeight, int iDepth,
- BYTE **ppbBits, BITMAPINFO **ppbmi)
-{
- BITMAPINFOHEADER *pbmih = NULL;
- HBITMAP hBitmap = NULL;
- BITMAPINFO *pbmi = NULL;
-
- /* Don't create an invalid bitmap */
- if (iWidth == 0
- || iHeight == 0
- || iDepth == 0)
- {
- ErrorF ("\nwinCreateDIBNativeGDI - Invalid specs w %d h %d d %d\n\n",
- iWidth, iHeight, iDepth);
- return NULL;
- }
-
- /* Allocate bitmap info header */
- pbmih = (BITMAPINFOHEADER*) malloc (sizeof (BITMAPINFOHEADER)
- + 256 * sizeof (RGBQUAD));
- if (pbmih == NULL)
- {
- ErrorF ("winCreateDIBNativeGDI - malloc () failed\n");
- return FALSE;
- }
- ZeroMemory (pbmih, sizeof(BITMAPINFOHEADER) + 256 * sizeof (RGBQUAD));
-
- /* Describe bitmap to be created */
- pbmih->biSize = sizeof (BITMAPINFOHEADER);
- pbmih->biWidth = iWidth;
- pbmih->biHeight = -iHeight;
- pbmih->biPlanes = 1;
- pbmih->biBitCount = iDepth;
- pbmih->biCompression = BI_RGB;
- /*
- pbmih->biSizeImage = 0;
- pbmih->biXPelsPerMeter = 0;
- pbmih->biYPelsPerMeter = 0;
- pbmih->biClrUsed = 0;
- pbmih->biClrImportant = 0;
- */
-
- /* Setup color table for mono DIBs */
- if (iDepth == 1)
- {
- pbmi = (BITMAPINFO*) pbmih;
- pbmi->bmiColors[1].rgbBlue = 255;
- pbmi->bmiColors[1].rgbGreen = 255;
- pbmi->bmiColors[1].rgbRed = 255;
- }
-
- /* Create a DIB with a bit pointer */
- hBitmap = CreateDIBSection (NULL,
- (BITMAPINFO *) pbmih,
- DIB_RGB_COLORS,
- (void **) ppbBits,
- NULL,
- 0);
- if (hBitmap == NULL)
- {
- ErrorF ("winCreateDIBNativeGDI - CreateDIBSection () failed\n");
- return NULL;
- }
-
- /* Free the bitmap info header memory */
- if (ppbmi != NULL)
- {
- /* Store the address of the BMIH in the ppbmih parameter */
- *ppbmi = (BITMAPINFO *) pbmih;
- }
- else
- {
- free (pbmih);
- pbmih = NULL;
- }
-
- return hBitmap;
-}
-
-
-#if 0
-static Bool
-winBltExposedRegionsNativeGDI (ScreenPtr pScreen)
-{
-
- return TRUE;
-}
-#endif
-
-
-static Bool
-winRedrawScreenNativeGDI (ScreenPtr pScreen)
-{
- FatalError ("winRedrawScreenNativeGDI\n");
- return TRUE;
-}
-
-
-static Bool
-winRealizeInstalledPaletteNativeGDI (ScreenPtr pScreen)
-{
- FatalError ("winRealizeInstalledPaletteNativeGDI\n");
- return TRUE;
-}
-
-
-static Bool
-winInstallColormapNativeGDI (ColormapPtr pColormap)
-{
- FatalError ("winInstallColormapNativeGDI\n");
- return TRUE;
-}
-
-
-static Bool
-winStoreColorsNativeGDI (ColormapPtr pmap,
- int ndef,
- xColorItem *pdefs)
-{
- FatalError ("winStoreColorsNativeGDI\n");
- return TRUE;
-}
-
-
-static Bool
-winCreateColormapNativeGDI (ColormapPtr pColormap)
-{
- FatalError ("winCreateColormapNativeGDI\n");
- return TRUE;
-}
-
-
-static Bool
-winDestroyColormapNativeGDI (ColormapPtr pColormap)
-{
- FatalError ("winDestroyColormapNativeGDI\n");
- return TRUE;
-}
-
-
-/* Set engine specific funtions */
-Bool
-winSetEngineFunctionsNativeGDI (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-
- /* Set our pointers */
- pScreenPriv->pwinAllocateFB = winAllocateFBNativeGDI;
- pScreenPriv->pwinShadowUpdate = winShadowUpdateNativeGDI;
- pScreenPriv->pwinCloseScreen = winCloseScreenNativeGDI;
- pScreenPriv->pwinInitVisuals = winInitVisualsNativeGDI;
- pScreenPriv->pwinAdjustVideoMode = winAdjustVideoModeNativeGDI;
- if (pScreenInfo->fFullScreen)
- pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowFullScreen;
- else
- pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowWindowed;
- pScreenPriv->pwinFinishScreenInit = winFinishScreenInitNativeGDI;
- /*
- * WARNING: Do not set the BltExposedRegions procedure pointer to anything
- * other than NULL until a working painting procedure is in place.
- * Else, winWindowProc will get stuck in an infinite loop because
- * Windows expects the BeginPaint and EndPaint functions to be called
- * before a WM_PAINT message can be removed from the queue. We are
- * using NULL here as a signal for winWindowProc that it should
- * not signal that the WM_PAINT message has been processed.
- */
- pScreenPriv->pwinBltExposedRegions = NULL;
- pScreenPriv->pwinActivateApp = winActivateAppNativeGDI;
- pScreenPriv->pwinRedrawScreen = winRedrawScreenNativeGDI;
- pScreenPriv->pwinRealizeInstalledPalette =
- winRealizeInstalledPaletteNativeGDI;
- pScreenPriv->pwinInstallColormap = winInstallColormapNativeGDI;
- pScreenPriv->pwinStoreColors = winStoreColorsNativeGDI;
- pScreenPriv->pwinCreateColormap = winCreateColormapNativeGDI;
- pScreenPriv->pwinDestroyColormap = winDestroyColormapNativeGDI;
- pScreenPriv->pwinHotKeyAltTab = (winHotKeyAltTabProcPtr) (void (*)(void))NoopDDA;
-
- 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: Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+
+/*
+ * Local function prototypes
+ */
+
+static Bool
+winAllocateFBNativeGDI (ScreenPtr pScreen);
+
+static void
+winShadowUpdateNativeGDI (ScreenPtr pScreen,
+ shadowBufPtr pBuf);
+
+static Bool
+winCloseScreenNativeGDI (int nIndex, ScreenPtr pScreen);
+
+static Bool
+winInitVisualsNativeGDI (ScreenPtr pScreen);
+
+static Bool
+winAdjustVideoModeNativeGDI (ScreenPtr pScreen);
+
+#if 0
+static Bool
+winBltExposedRegionsNativeGDI (ScreenPtr pScreen);
+#endif
+
+static Bool
+winActivateAppNativeGDI (ScreenPtr pScreen);
+
+static Bool
+winRedrawScreenNativeGDI (ScreenPtr pScreen);
+
+static Bool
+winRealizeInstalledPaletteNativeGDI (ScreenPtr pScreen);
+
+static Bool
+winInstallColormapNativeGDI (ColormapPtr pColormap);
+
+static Bool
+winStoreColorsNativeGDI (ColormapPtr pmap,
+ int ndef,
+ xColorItem *pdefs);
+
+static Bool
+winCreateColormapNativeGDI (ColormapPtr pColormap);
+
+static Bool
+winDestroyColormapNativeGDI (ColormapPtr pColormap);
+
+
+
+static Bool
+winAllocateFBNativeGDI (ScreenPtr pScreen)
+{
+ FatalError ("winAllocateFBNativeGDI\n");
+
+ return TRUE;
+}
+
+
+/*
+ * We wrap whatever CloseScreen procedure was specified by fb;
+ * a pointer to said procedure is stored in our privates.
+ */
+
+static Bool
+winCloseScreenNativeGDI (int nIndex, ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ winDebug ("winCloseScreenNativeGDI - Freeing screen resources\n");
+
+ /* Flag that the screen is closed */
+ pScreenPriv->fClosed = TRUE;
+ pScreenPriv->fActive = FALSE;
+
+ /*
+ * NOTE: mi doesn't use a CloseScreen procedure, so we do not
+ * need to call a wrapped procedure here.
+ */
+
+ /* Delete the window property */
+ RemoveProp (pScreenPriv->hwndScreen, WIN_SCR_PROP);
+
+ winDebug ("winCloseScreenNativeGDI - Destroying window\n");
+
+ /* 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;
+ }
+
+ /* Invalidate our screeninfo's pointer to the screen */
+ pScreenInfo->pScreen = NULL;
+
+ /* Free the screen privates for this screen */
+ free (pScreenPriv);
+
+ winDebug ("winCloseScreenNativeGDI - Returning\n");
+
+ return TRUE;
+}
+
+
+static void
+winShadowUpdateNativeGDI (ScreenPtr pScreen,
+ shadowBufPtr pBuf)
+{
+ FatalError ("winShadowUpdateNativeGDI\n");
+ return;
+}
+
+
+static Bool
+winInitVisualsNativeGDI (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /* Set the bitsPerRGB and bit masks */
+ switch (pScreenInfo->dwDepth)
+ {
+ case 24:
+ pScreenPriv->dwBitsPerRGB = 8;
+ pScreenPriv->dwRedMask = 0x00FF0000;
+ pScreenPriv->dwGreenMask = 0x0000FF00;
+ pScreenPriv->dwBlueMask = 0x000000FF;
+ break;
+
+ case 16:
+ pScreenPriv->dwBitsPerRGB = 6;
+ pScreenPriv->dwRedMask = 0xF800;
+ pScreenPriv->dwGreenMask = 0x07E0;
+ pScreenPriv->dwBlueMask = 0x001F;
+ break;
+
+ case 15:
+ pScreenPriv->dwBitsPerRGB = 5;
+ pScreenPriv->dwRedMask = 0x7C00;
+ pScreenPriv->dwGreenMask = 0x03E0;
+ pScreenPriv->dwBlueMask = 0x001F;
+ break;
+
+ case 8:
+ pScreenPriv->dwBitsPerRGB = 8;
+ pScreenPriv->dwRedMask = 0;
+ pScreenPriv->dwGreenMask = 0;
+ pScreenPriv->dwBlueMask = 0;
+ break;
+
+ default:
+ ErrorF ("winInitVisualsNativeGDI - Unknown screen depth\n");
+ return FALSE;
+ break;
+ }
+
+ /* Tell the user how many bits per RGB we are using */
+ winDebug ("winInitVisualsNativeGDI - Using dwBitsPerRGB: %d\n",
+ (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 ("winInitVisuals - miSetVisualTypesAndMasks failed\n");
+ return FALSE;
+ }
+ break;
+
+ case 8:
+ winDebug ("winInitVisuals - Calling miSetVisualTypesAndMasks\n");
+ if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
+ StaticColorMask,
+ pScreenPriv->dwBitsPerRGB,
+ StaticColor,
+ pScreenPriv->dwRedMask,
+ pScreenPriv->dwGreenMask,
+ pScreenPriv->dwBlueMask))
+ {
+ ErrorF ("winInitVisuals - miSetVisualTypesAndMasks failed\n");
+ return FALSE;
+ }
+ break;
+
+ default:
+ ErrorF ("winInitVisualsNativeGDI - Unknown screen depth\n");
+ return FALSE;
+ }
+
+ winDebug ("winInitVisualsNativeGDI - Returning\n");
+
+ return TRUE;
+}
+
+
+/* Adjust the video mode */
+static Bool
+winAdjustVideoModeNativeGDI (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ HDC hdc = NULL;
+ DWORD dwBPP;
+
+ hdc = GetDC (NULL);
+
+ /* We're in serious trouble if we can't get a DC */
+ if (hdc == NULL)
+ {
+ ErrorF ("winAdjustVideoModeNativeGDI - GetDC () failed\n");
+ return FALSE;
+ }
+
+ /* Query GDI for current display depth */
+ dwBPP = GetDeviceCaps (hdc, BITSPIXEL);
+ pScreenInfo->dwDepth = GetDeviceCaps (hdc, PLANES);
+
+ switch (pScreenInfo->dwDepth) {
+ case 24:
+ case 16:
+ case 15:
+ case 8:
+ break;
+ default:
+ if (dwBPP == 32)
+ pScreenInfo->dwDepth = 24;
+ else
+ pScreenInfo->dwDepth = dwBPP;
+ break;
+ }
+
+ /* GDI cannot change the screen depth */
+ if (pScreenInfo->dwBPP == WIN_DEFAULT_BPP)
+ {
+ /* No -depth parameter passed, let the user know the depth being used */
+ winDebug ("winAdjustVideoModeNativeGDI - Using Windows display "
+ "depth of %d bits per pixel, %d depth\n",
+ (int) dwBPP, (int) pScreenInfo->dwDepth);
+
+ /* Use GDI's depth */
+ pScreenInfo->dwBPP = dwBPP;
+ }
+ else if (dwBPP != pScreenInfo->dwBPP)
+ {
+ /* Warn user if GDI depth is different than -depth parameter */
+ winDebug ("winAdjustVideoModeNativeGDI - Command line bpp: %d, "\
+ "using bpp: %d\n",
+ (int) pScreenInfo->dwBPP, (int) dwBPP);
+
+ /* We'll use GDI's depth */
+ pScreenInfo->dwBPP = dwBPP;
+ }
+
+ /* Release our DC */
+ ReleaseDC (NULL, hdc);
+
+ return TRUE;
+}
+
+
+static Bool
+winActivateAppNativeGDI (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /*
+ * Are we active?
+ * Are we fullscreen?
+ */
+ if (pScreenPriv != NULL
+ && pScreenPriv->fActive
+ && pScreenInfo->fFullScreen)
+ {
+ /*
+ * Activating, attempt to bring our window
+ * to the top of the display
+ */
+ ShowWindow (pScreenPriv->hwndScreen, SW_RESTORE);
+ }
+
+ /*
+ * Are we inactive?
+ * Are we fullscreen?
+ */
+ if (pScreenPriv != NULL
+ && !pScreenPriv->fActive
+ && pScreenInfo->fFullScreen)
+ {
+ /*
+ * Deactivating, stuff our window onto the
+ * task bar.
+ */
+ ShowWindow (pScreenPriv->hwndScreen, SW_MINIMIZE);
+ }
+
+ return TRUE;
+}
+
+
+HBITMAP
+winCreateDIBNativeGDI (int iWidth, int iHeight, int iDepth,
+ BYTE **ppbBits, BITMAPINFO **ppbmi)
+{
+ BITMAPINFOHEADER *pbmih = NULL;
+ HBITMAP hBitmap = NULL;
+ BITMAPINFO *pbmi = NULL;
+
+ /* Don't create an invalid bitmap */
+ if (iWidth == 0
+ || iHeight == 0
+ || iDepth == 0)
+ {
+ ErrorF ("\nwinCreateDIBNativeGDI - Invalid specs w %d h %d d %d\n\n",
+ iWidth, iHeight, iDepth);
+ return NULL;
+ }
+
+ /* Allocate bitmap info header */
+ pbmih = (BITMAPINFOHEADER*) malloc (sizeof (BITMAPINFOHEADER)
+ + 256 * sizeof (RGBQUAD));
+ if (pbmih == NULL)
+ {
+ ErrorF ("winCreateDIBNativeGDI - malloc () failed\n");
+ return FALSE;
+ }
+ ZeroMemory (pbmih, sizeof(BITMAPINFOHEADER) + 256 * sizeof (RGBQUAD));
+
+ /* Describe bitmap to be created */
+ pbmih->biSize = sizeof (BITMAPINFOHEADER);
+ pbmih->biWidth = iWidth;
+ pbmih->biHeight = -iHeight;
+ pbmih->biPlanes = 1;
+ pbmih->biBitCount = iDepth;
+ pbmih->biCompression = BI_RGB;
+ /*
+ pbmih->biSizeImage = 0;
+ pbmih->biXPelsPerMeter = 0;
+ pbmih->biYPelsPerMeter = 0;
+ pbmih->biClrUsed = 0;
+ pbmih->biClrImportant = 0;
+ */
+
+ /* Setup color table for mono DIBs */
+ if (iDepth == 1)
+ {
+ pbmi = (BITMAPINFO*) pbmih;
+ pbmi->bmiColors[1].rgbBlue = 255;
+ pbmi->bmiColors[1].rgbGreen = 255;
+ pbmi->bmiColors[1].rgbRed = 255;
+ }
+
+ /* Create a DIB with a bit pointer */
+ hBitmap = CreateDIBSection (NULL,
+ (BITMAPINFO *) pbmih,
+ DIB_RGB_COLORS,
+ (void **) ppbBits,
+ NULL,
+ 0);
+ if (hBitmap == NULL)
+ {
+ ErrorF ("winCreateDIBNativeGDI - CreateDIBSection () failed\n");
+ return NULL;
+ }
+
+ /* Free the bitmap info header memory */
+ if (ppbmi != NULL)
+ {
+ /* Store the address of the BMIH in the ppbmih parameter */
+ *ppbmi = (BITMAPINFO *) pbmih;
+ }
+ else
+ {
+ free (pbmih);
+ pbmih = NULL;
+ }
+
+ return hBitmap;
+}
+
+
+#if 0
+static Bool
+winBltExposedRegionsNativeGDI (ScreenPtr pScreen)
+{
+
+ return TRUE;
+}
+#endif
+
+
+static Bool
+winRedrawScreenNativeGDI (ScreenPtr pScreen)
+{
+ FatalError ("winRedrawScreenNativeGDI\n");
+ return TRUE;
+}
+
+
+static Bool
+winRealizeInstalledPaletteNativeGDI (ScreenPtr pScreen)
+{
+ FatalError ("winRealizeInstalledPaletteNativeGDI\n");
+ return TRUE;
+}
+
+
+static Bool
+winInstallColormapNativeGDI (ColormapPtr pColormap)
+{
+ FatalError ("winInstallColormapNativeGDI\n");
+ return TRUE;
+}
+
+
+static Bool
+winStoreColorsNativeGDI (ColormapPtr pmap,
+ int ndef,
+ xColorItem *pdefs)
+{
+ FatalError ("winStoreColorsNativeGDI\n");
+ return TRUE;
+}
+
+
+static Bool
+winCreateColormapNativeGDI (ColormapPtr pColormap)
+{
+ FatalError ("winCreateColormapNativeGDI\n");
+ return TRUE;
+}
+
+
+static Bool
+winDestroyColormapNativeGDI (ColormapPtr pColormap)
+{
+ FatalError ("winDestroyColormapNativeGDI\n");
+ return TRUE;
+}
+
+
+/* Set engine specific funtions */
+Bool
+winSetEngineFunctionsNativeGDI (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /* Set our pointers */
+ pScreenPriv->pwinAllocateFB = winAllocateFBNativeGDI;
+ pScreenPriv->pwinShadowUpdate = winShadowUpdateNativeGDI;
+ pScreenPriv->pwinCloseScreen = winCloseScreenNativeGDI;
+ pScreenPriv->pwinInitVisuals = winInitVisualsNativeGDI;
+ pScreenPriv->pwinAdjustVideoMode = winAdjustVideoModeNativeGDI;
+ if (pScreenInfo->fFullScreen)
+ pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowFullScreen;
+ else
+ pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowWindowed;
+ pScreenPriv->pwinFinishScreenInit = winFinishScreenInitNativeGDI;
+ /*
+ * WARNING: Do not set the BltExposedRegions procedure pointer to anything
+ * other than NULL until a working painting procedure is in place.
+ * Else, winWindowProc will get stuck in an infinite loop because
+ * Windows expects the BeginPaint and EndPaint functions to be called
+ * before a WM_PAINT message can be removed from the queue. We are
+ * using NULL here as a signal for winWindowProc that it should
+ * not signal that the WM_PAINT message has been processed.
+ */
+ pScreenPriv->pwinBltExposedRegions = NULL;
+ pScreenPriv->pwinActivateApp = winActivateAppNativeGDI;
+ pScreenPriv->pwinRedrawScreen = winRedrawScreenNativeGDI;
+ pScreenPriv->pwinRealizeInstalledPalette =
+ winRealizeInstalledPaletteNativeGDI;
+ pScreenPriv->pwinInstallColormap = winInstallColormapNativeGDI;
+ pScreenPriv->pwinStoreColors = winStoreColorsNativeGDI;
+ pScreenPriv->pwinCreateColormap = winCreateColormapNativeGDI;
+ pScreenPriv->pwinDestroyColormap = winDestroyColormapNativeGDI;
+ pScreenPriv->pwinHotKeyAltTab = (winHotKeyAltTabProcPtr) (void (*)(void))NoopDDA;
+
+ return TRUE;
+}
diff --git a/xorg-server/hw/xwin/winpfbdd.c b/xorg-server/hw/xwin/winpfbdd.c
index 63a16b8b3..eaa0499fe 100644
--- a/xorg-server/hw/xwin/winpfbdd.c
+++ b/xorg-server/hw/xwin/winpfbdd.c
@@ -1,679 +1,672 @@
-/*
- *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"
-
-
-/*
- * External symbols
- */
-
-extern HWND g_hDlgExit;
-
-
-/*
- * 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;
-}
-
-
-/*
- * 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;
-
- winDebug ("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);
- fReturn = (*pScreen->CloseScreen) (nIndex, pScreen);
-
- /* Delete the window property */
- RemoveProp (pScreenPriv->hwndScreen, WIN_SCR_PROP);
-
- /* 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;
- }
-
- /* 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;
-
- /* Invalidate the ScreenInfo's fb pointer */
- pScreenInfo->pfb = 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->dwBPP == WIN_DEFAULT_BPP)
- {
- /* No -depth parameter passed, let the user know the depth being used */
- winDebug ("winAdjustVideoModePrimaryDD - Using Windows display "
- "depth of %d bits per pixel\n", (int) dwBPP);
-
- /* Use GDI's depth */
- pScreenInfo->dwBPP = dwBPP;
- }
- else if (pScreenInfo->fFullScreen
- && pScreenInfo->dwBPP != dwBPP)
- {
- /* FullScreen, and GDI depth differs from -depth parameter */
- winDebug ("winAdjustVideoModePrimaryDD - FullScreen, using command "
- "line depth: %d\n", (int) pScreenInfo->dwBPP);
- }
- else if (dwBPP != pScreenInfo->dwBPP)
- {
- /* Windowed, and GDI depth differs from -depth parameter */
- winDebug ("winAdjustVideoModePrimaryDD - Windowed, command line "
- "depth: %d, using depth: %d\n",
- (int) pScreenInfo->dwBPP, (int) dwBPP);
-
- /* 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->pwinShadowUpdate
- = (winShadowUpdateProcPtr) (void (*)(void))NoopDDA;
- 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->pwinHotKeyAltTab = winHotKeyAltTabPrimaryDD;
-#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;
+}
+
+
+/*
+ * 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;
+
+ winDebug ("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);
+ fReturn = (*pScreen->CloseScreen) (nIndex, pScreen);
+
+ /* Delete the window property */
+ RemoveProp (pScreenPriv->hwndScreen, WIN_SCR_PROP);
+
+ /* 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;
+ }
+
+ /* 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;
+
+ /* Invalidate the ScreenInfo's fb pointer */
+ pScreenInfo->pfb = 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->dwBPP == WIN_DEFAULT_BPP)
+ {
+ /* No -depth parameter passed, let the user know the depth being used */
+ winDebug ("winAdjustVideoModePrimaryDD - Using Windows display "
+ "depth of %d bits per pixel\n", (int) dwBPP);
+
+ /* Use GDI's depth */
+ pScreenInfo->dwBPP = dwBPP;
+ }
+ else if (pScreenInfo->fFullScreen
+ && pScreenInfo->dwBPP != dwBPP)
+ {
+ /* FullScreen, and GDI depth differs from -depth parameter */
+ winDebug ("winAdjustVideoModePrimaryDD - FullScreen, using command "
+ "line depth: %d\n", (int) pScreenInfo->dwBPP);
+ }
+ else if (dwBPP != pScreenInfo->dwBPP)
+ {
+ /* Windowed, and GDI depth differs from -depth parameter */
+ winDebug ("winAdjustVideoModePrimaryDD - Windowed, command line "
+ "depth: %d, using depth: %d\n",
+ (int) pScreenInfo->dwBPP, (int) dwBPP);
+
+ /* 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->pwinShadowUpdate
+ = (winShadowUpdateProcPtr) (void (*)(void))NoopDDA;
+ 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->pwinHotKeyAltTab = winHotKeyAltTabPrimaryDD;
+#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 4d34e41a1..f24074636 100644
--- a/xorg-server/hw/xwin/winprefs.c
+++ b/xorg-server/hw/xwin/winprefs.c
@@ -49,11 +49,6 @@
/* Where will the custom menu commands start counting from? */
#define STARTMENUID WM_USER
-/* External global variables */
-#ifdef XWIN_MULTIWINDOW
-extern DWORD g_dwCurrentThreadID;
-#endif
-
extern const char *winGetBaseDir(void);
extern const char *g_pszLogFile;
@@ -61,12 +56,6 @@ extern const char *g_pszLogFile;
/* From winmultiwindowflex.l, the real parser */
extern void parse_file (FILE *fp);
-/* From winprefyacc.y, the pref structure loaded by the parser */
-extern WINPREFS pref;
-
-/* The global X default icon */
-extern HICON g_hIconX;
-extern HICON g_hSmallIconX;
/* Currently in use command ID, incremented each new menu item created */
static int g_cmdid = STARTMENUID;
diff --git a/xorg-server/hw/xwin/winprefs.h b/xorg-server/hw/xwin/winprefs.h
index ccd771d72..66fab626a 100644
--- a/xorg-server/hw/xwin/winprefs.h
+++ b/xorg-server/hw/xwin/winprefs.h
@@ -151,7 +151,8 @@ typedef struct WINPREFS
} WINPREFS;
-
+/* The global pref settings structure loaded by the winprefyacc.y parser */
+extern WINPREFS pref;
/* Functions */
diff --git a/xorg-server/hw/xwin/winprocarg.c b/xorg-server/hw/xwin/winprocarg.c
index 50e15ec10..cfe1a6f20 100644
--- a/xorg-server/hw/xwin/winprocarg.c
+++ b/xorg-server/hw/xwin/winprocarg.c
@@ -1,1252 +1,1232 @@
-/*
-
-Copyright 1993, 1998 The Open Group
-Copyright (C) Colin Harrison 2005-2008
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
-OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall
-not be used in advertising or otherwise to promote the sale, use or
-other dealings in this Software without prior written authorization
-from The Open Group.
-
-*/
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#ifdef XVENDORNAME
-#define VENDOR_STRING XVENDORNAME
-#define VENDOR_CONTACT BUILDERADDR
-#endif
-#include <../xfree86/common/xorgVersion.h>
-#include "win.h"
-#include "winconfig.h"
-#include "winprefs.h"
-#include "winmsg.h"
-#define COMPILE_MULTIMON_STUBS
-#include <multimon.h>
-/*
- * References to external symbols
- */
-
-extern int g_iNumScreens;
-extern winScreenInfo * g_ScreenInfo;
-#ifdef XWIN_CLIPBOARD
-extern Bool g_fUnicodeClipboard;
-extern Bool g_fClipboard;
-#endif
-extern int g_iLogVerbose;
-extern const char * g_pszLogFile;
-#ifdef RELOCATE_PROJECTROOT
-extern Bool g_fLogFileChanged;
-#endif
-extern Bool g_fXdmcpEnabled;
-extern Bool g_fAuthEnabled;
-extern char * g_pszCommandLine;
-extern Bool g_fKeyboardHookLL;
-extern Bool g_fNoHelpMessageBox;
-extern Bool g_fSoftwareCursor;
-extern Bool g_fSilentDupError;
-extern Bool g_fNativeGl;
-
-/* globals required by callback function for monitor information */
-struct GetMonitorInfoData {
- int requestedMonitor;
- int monitorNum;
- Bool bUserSpecifiedMonitor;
- Bool bMonitorSpecifiedExists;
- int monitorOffsetX;
- int monitorOffsetY;
- int monitorHeight;
- int monitorWidth;
-};
-
-wBOOL CALLBACK getMonitorInfo(HMONITOR hMonitor, HDC hdc, LPRECT rect, LPARAM _data);
-
-static Bool QueryMonitor(int index, struct GetMonitorInfoData *data)
-{
- /* prepare data */
- if (data == NULL)
- return FALSE;
- memset(data, 0, sizeof(*data));
- data->requestedMonitor = index;
-
- /* query information */
- xEnumDisplayMonitors(NULL, NULL, getMonitorInfo, (LPARAM) data);
-
- return TRUE;
-}
-
-/*
- * Function prototypes
- */
-
-void
-winLogCommandLine (int argc, char *argv[]);
-
-void
-winLogVersionInfo (void);
-
-#ifdef DDXOSVERRORF
-void OsVendorVErrorF (const char *pszFormat, va_list va_args);
-#endif
-
-/*
- * Process arguments on the command line
- */
-
-static int iLastScreen = -1;
-static winScreenInfo defaultScreenInfo;
-
-static void
-winInitializeScreenDefaults(void)
-{
- DWORD dwWidth, dwHeight;
- static Bool fInitializedScreenDefaults = FALSE;
-
- /* Bail out early if default screen has already been initialized */
- if (fInitializedScreenDefaults)
- return;
-
- /* Zero the memory used for storing the screen info */
- memset(&defaultScreenInfo, 0, sizeof(winScreenInfo));
-
- /* Get default width and height */
- /*
- * NOTE: These defaults will cause the window to cover only
- * the primary monitor in the case that we have multiple monitors.
- */
- dwWidth = GetSystemMetrics (SM_CXSCREEN);
- dwHeight = GetSystemMetrics (SM_CYSCREEN);
-
- winDebug ("winInitializeScreenDefaults - w %d h %d\n",
- (int) dwWidth, (int) dwHeight);
-
- /* Set a default DPI, if no parameter was passed */
- if (monitorResolution == 0)
- monitorResolution = WIN_DEFAULT_DPI;
-
- defaultScreenInfo.dwWidth = dwWidth;
- defaultScreenInfo.dwHeight = dwHeight;
- defaultScreenInfo.dwUserWidth = dwWidth;
- defaultScreenInfo.dwUserHeight = dwHeight;
- defaultScreenInfo.fUserGaveHeightAndWidth = WIN_DEFAULT_USER_GAVE_HEIGHT_AND_WIDTH;
- defaultScreenInfo.fUserGavePosition = FALSE;
- defaultScreenInfo.dwBPP = WIN_DEFAULT_BPP;
- defaultScreenInfo.dwClipUpdatesNBoxes = WIN_DEFAULT_CLIP_UPDATES_NBOXES;
-#ifdef XWIN_EMULATEPSEUDO
- defaultScreenInfo.fEmulatePseudo = WIN_DEFAULT_EMULATE_PSEUDO;
-#endif
- defaultScreenInfo.dwRefreshRate = WIN_DEFAULT_REFRESH;
- defaultScreenInfo.pfb = NULL;
- defaultScreenInfo.fFullScreen = FALSE;
- defaultScreenInfo.fDecoration = TRUE;
-#ifdef XWIN_MULTIWINDOWEXTWM
- defaultScreenInfo.fMWExtWM = FALSE;
- defaultScreenInfo.fInternalWM = FALSE;
-#endif
- defaultScreenInfo.fRootless = FALSE;
-#ifdef XWIN_MULTIWINDOW
- defaultScreenInfo.fMultiWindow = FALSE;
-#endif
-#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
- defaultScreenInfo.fMultiMonitorOverride = FALSE;
-#endif
- defaultScreenInfo.fMultipleMonitors = FALSE;
- defaultScreenInfo.fLessPointer = FALSE;
- defaultScreenInfo.fScrollbars = FALSE;
- defaultScreenInfo.fNoTrayIcon = FALSE;
- defaultScreenInfo.iE3BTimeout = WIN_E3B_OFF;
- defaultScreenInfo.dwWidth_mm = (dwWidth / WIN_DEFAULT_DPI) * 25.4;
- defaultScreenInfo.dwHeight_mm = (dwHeight / WIN_DEFAULT_DPI) * 25.4;
- defaultScreenInfo.fUseWinKillKey = WIN_DEFAULT_WIN_KILL;
- defaultScreenInfo.fUseUnixKillKey = WIN_DEFAULT_UNIX_KILL;
- defaultScreenInfo.fIgnoreInput = FALSE;
- defaultScreenInfo.fExplicitScreen = FALSE;
-
- /* Note that the default screen has been initialized */
- fInitializedScreenDefaults = TRUE;
-}
-
-static void
-winInitializeScreen(int i)
-{
- winDebug ("winInitializeScreen - %d\n",i);
-
- /* Initialize default screen values, if needed */
- winInitializeScreenDefaults();
-
- /* Copy the default screen info */
- g_ScreenInfo[i] = defaultScreenInfo;
-
- /* Set the screen number */
- g_ScreenInfo[i].dwScreen = i;
-}
-
-void
-winInitializeScreens(int maxscreens)
-{
- int i;
- winDebug ("winInitializeScreens - %i\n", maxscreens);
-
- if (maxscreens > g_iNumScreens)
- {
- /* Reallocate the memory for DDX-specific screen info */
- g_ScreenInfo = realloc(g_ScreenInfo, maxscreens * sizeof (winScreenInfo));
-
- /* Set default values for any new screens */
- for (i = g_iNumScreens; i < maxscreens ; i++)
- winInitializeScreen(i);
-
- /* Keep a count of the number of screens */
- g_iNumScreens = maxscreens;
- }
-}
-
-/* See Porting Layer Definition - p. 57 */
-/*
- * INPUT
- * argv: pointer to an array of null-terminated strings, one for
- * each token in the X Server command line; the first token
- * is 'XWin.exe', or similar.
- * argc: a count of the number of tokens stored in argv.
- * i: a zero-based index into argv indicating the current token being
- * processed.
- *
- * OUTPUT
- * return: return the number of tokens processed correctly.
- *
- * NOTE
- * When looking for n tokens, check that i + n is less than argc. Or,
- * you may check if i is greater than or equal to argc, in which case
- * you should display the UseMsg () and return 0.
- */
-
-/* Check if enough arguments are given for the option */
-#define CHECK_ARGS(count) if (i + count >= argc) { UseMsg (); return 0; }
-
-/* Compare the current option with the string. */
-#define IS_OPTION(name) (strcmp (argv[i], name) == 0)
-
-int
-ddxProcessArgument (int argc, char *argv[], int i)
-{
- static Bool s_fBeenHere = FALSE;
- winScreenInfo *screenInfoPtr = NULL;
-
- /* Initialize once */
- if (!s_fBeenHere)
- {
-#ifdef DDXOSVERRORF
- /*
- * This initialises our hook into VErrorF () for catching log messages
- * that are generated before OsInit () is called.
- */
- OsVendorVErrorFProc = OsVendorVErrorF;
-#endif
-
- s_fBeenHere = TRUE;
-
- /* Initialize only if option is not -help */
- if (!IS_OPTION("-help") && !IS_OPTION("-h") && !IS_OPTION("--help") &&
- !IS_OPTION("-version") && !IS_OPTION("--version"))
- {
-
- /* Log the version information */
- winLogVersionInfo ();
-
- /* Log the command line */
- winLogCommandLine (argc, argv);
-
- /*
- * Initialize default screen settings. We have to do this before
- * OsVendorInit () gets called, otherwise we will overwrite
- * settings changed by parameters such as -fullscreen, etc.
- */
- winDebug ("ddxProcessArgument - Initializing default "
- "screens\n");
- winInitializeScreenDefaults();
- }
- }
-
- winDebug ("ddxProcessArgument - arg: %s\n", argv[i]);
-
- /*
- * Look for the '-help' and similar options
- */
- if (IS_OPTION ("-help") || IS_OPTION("-h") || IS_OPTION("--help"))
- {
- /* Reset logfile. We don't need that helpmessage in the logfile */
- g_pszLogFile = NULL;
- g_fNoHelpMessageBox = TRUE;
- UseMsg();
- exit (0);
- return 1;
- }
-
- if (IS_OPTION ("-version") || IS_OPTION("--version"))
- {
- /* Reset logfile. We don't need that versioninfo in the logfile */
- g_pszLogFile = NULL;
- winLogVersionInfo ();
- exit (0);
- return 1;
- }
-
- /*
- * Look for the '-screen scr_num [width height]' argument
- */
- if (IS_OPTION ("-screen"))
- {
- int iArgsProcessed = 1;
- int nScreenNum;
- int iWidth, iHeight, iX, iY;
- int iMonitor;
-
- winDebug ("ddxProcessArgument - screen - argc: %d i: %d\n",
- argc, i);
-
- /* Display the usage message if the argument is malformed */
- if (i + 1 >= argc)
- {
- return 0;
- }
-
- /* Grab screen number */
- nScreenNum = atoi (argv[i + 1]);
-
- /* Validate the specified screen number */
- if (nScreenNum < 0)
- {
- ErrorF ("ddxProcessArgument - screen - Invalid screen number %d\n",
- nScreenNum);
- UseMsg ();
- return 0;
- }
-
- /*
- Initialize default values for any new screens
-
- Note that default values can't change after a -screen option is
- seen, so it's safe to do this for each screen as it is introduced
- */
- winInitializeScreens(nScreenNum+1);
-
- /* look for @m where m is monitor number */
- if (i + 2 < argc
- && 1 == sscanf(argv[i + 2], "@%d", (int *) &iMonitor))
- {
- struct GetMonitorInfoData data;
- if (!QueryMonitor(iMonitor, &data))
- {
- ErrorF ("ddxProcessArgument - screen - "
- "Querying monitors is not supported on NT4 and Win95\n");
- } else if (data.bMonitorSpecifiedExists == TRUE)
- {
- winDebug("ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n", iMonitor);
- iArgsProcessed = 3;
- g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = FALSE;
- g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE;
- g_ScreenInfo[nScreenNum].dwWidth = data.monitorWidth;
- g_ScreenInfo[nScreenNum].dwHeight = data.monitorHeight;
- g_ScreenInfo[nScreenNum].dwUserWidth = data.monitorWidth;
- g_ScreenInfo[nScreenNum].dwUserHeight = data.monitorHeight;
- g_ScreenInfo[nScreenNum].dwInitialX = data.monitorOffsetX;
- g_ScreenInfo[nScreenNum].dwInitialY = data.monitorOffsetY;
- }
- else
- {
- /* monitor does not exist, error out */
- ErrorF ("ddxProcessArgument - screen - Invalid monitor number %d\n",
- iMonitor);
- UseMsg ();
- exit (0);
- return 0;
- }
- }
-
- /* Look for 'WxD' or 'W D' */
- else if (i + 2 < argc
- && 2 == sscanf (argv[i + 2], "%dx%d",
- (int *) &iWidth,
- (int *) &iHeight))
- {
- winDebug ("ddxProcessArgument - screen - Found ``WxD'' arg\n");
- iArgsProcessed = 3;
- g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = TRUE;
- g_ScreenInfo[nScreenNum].dwWidth = iWidth;
- g_ScreenInfo[nScreenNum].dwHeight = iHeight;
- g_ScreenInfo[nScreenNum].dwUserWidth = iWidth;
- g_ScreenInfo[nScreenNum].dwUserHeight = iHeight;
- /* Look for WxD+X+Y */
- if (2 == sscanf (argv[i + 2], "%*dx%*d+%d+%d",
- (int *) &iX,
- (int *) &iY))
- {
- winDebug("ddxProcessArgument - screen - Found ``X+Y'' arg\n");
- g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE;
- g_ScreenInfo[nScreenNum].dwInitialX = iX;
- g_ScreenInfo[nScreenNum].dwInitialY = iY;
-
- /* look for WxD+X+Y@m where m is monitor number. take X,Y to be offsets from monitor's root position */
- if (1 == sscanf (argv[i + 2], "%*dx%*d+%*d+%*d@%d",
- (int *) &iMonitor))
- {
- struct GetMonitorInfoData data;
- if (!QueryMonitor(iMonitor, &data))
- {
- ErrorF ("ddxProcessArgument - screen - "
- "Querying monitors is not supported on NT4 and Win95\n");
- } else if (data.bMonitorSpecifiedExists == TRUE)
- {
- g_ScreenInfo[nScreenNum].dwInitialX += data.monitorOffsetX;
- g_ScreenInfo[nScreenNum].dwInitialY += data.monitorOffsetY;
- }
- else
- {
- /* monitor does not exist, error out */
- ErrorF ("ddxProcessArgument - screen - Invalid monitor number %d\n",
- iMonitor);
- UseMsg ();
- exit (0);
- return 0;
- }
-
- }
- }
-
- /* look for WxD@m where m is monitor number */
- else if (1 == sscanf(argv[i + 2], "%*dx%*d@%d",
- (int *) &iMonitor))
- {
- struct GetMonitorInfoData data;
- if (!QueryMonitor(iMonitor, &data))
- {
- ErrorF ("ddxProcessArgument - screen - "
- "Querying monitors is not supported on NT4 and Win95\n");
- } else if (data.bMonitorSpecifiedExists == TRUE)
- {
- winDebug ("ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n", iMonitor);
- g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE;
- g_ScreenInfo[nScreenNum].dwInitialX = data.monitorOffsetX;
- g_ScreenInfo[nScreenNum].dwInitialY = data.monitorOffsetY;
- }
- else
- {
- /* monitor does not exist, error out */
- ErrorF ("ddxProcessArgument - screen - Invalid monitor number %d\n",
- iMonitor);
- UseMsg ();
- exit (0);
- return 0;
- }
-
- }
- }
- else if (i + 3 < argc
- && 1 == sscanf (argv[i + 2], "%d",
- (int *) &iWidth)
- && 1 == sscanf (argv[i + 3], "%d",
- (int *) &iHeight))
- {
- winDebug ("ddxProcessArgument - screen - Found ``W D'' arg\n");
- iArgsProcessed = 4;
- g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = TRUE;
- g_ScreenInfo[nScreenNum].dwWidth = iWidth;
- g_ScreenInfo[nScreenNum].dwHeight = iHeight;
- g_ScreenInfo[nScreenNum].dwUserWidth = iWidth;
- g_ScreenInfo[nScreenNum].dwUserHeight = iHeight;
- if (i + 5 < argc
- && 1 == sscanf (argv[i + 4], "%d",
- (int *) &iX)
- && 1 == sscanf (argv[i + 5], "%d",
- (int *) &iY))
- {
- winDebug ("ddxProcessArgument - screen - Found ``X Y'' arg\n");
- iArgsProcessed = 6;
- g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE;
- g_ScreenInfo[nScreenNum].dwInitialX = iX;
- g_ScreenInfo[nScreenNum].dwInitialY = iY;
- }
- }
- else
- {
- ErrorF ("ddxProcessArgument - screen - Did not find size arg. "
- "dwWidth: %d dwHeight: %d\n",
- (int) g_ScreenInfo[nScreenNum].dwWidth,
- (int) g_ScreenInfo[nScreenNum].dwHeight);
- iArgsProcessed = 2;
- g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = FALSE;
- }
-
- /* Calculate the screen width and height in millimeters */
- if (g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth)
- {
- g_ScreenInfo[nScreenNum].dwWidth_mm
- = (g_ScreenInfo[nScreenNum].dwWidth
- / monitorResolution) * 25.4;
- g_ScreenInfo[nScreenNum].dwHeight_mm
- = (g_ScreenInfo[nScreenNum].dwHeight
- / monitorResolution) * 25.4;
- }
-
- /* Flag that this screen was explicity specified by the user */
- g_ScreenInfo[nScreenNum].fExplicitScreen = TRUE;
-
- /*
- * Keep track of the last screen number seen, as parameters seen
- * before a screen number apply to all screens, whereas parameters
- * seen after a screen number apply to that screen number only.
- */
- iLastScreen = nScreenNum;
-
- return iArgsProcessed;
- }
-
-
- /*
- * Is this parameter attached to a screen or global?
- *
- * If the parameter is for all screens (appears before
- * any -screen option), store it in the default screen
- * info
- *
- * If the parameter is for a single screen (appears
- * after a -screen option), store it in the screen info
- * for that screen
- *
- */
- if (iLastScreen == -1)
- {
- screenInfoPtr = &defaultScreenInfo;
- }
- else
- {
- screenInfoPtr = &(g_ScreenInfo[iLastScreen]);
- }
-
- /*
- * Look for the '-engine n' argument
- */
- if (IS_OPTION ("-engine"))
- {
- DWORD dwEngine = 0;
- CARD8 c8OnBits = 0;
-
- /* Display the usage message if the argument is malformed */
- if (++i >= argc)
- {
- UseMsg ();
- return 0;
- }
-
- /* Grab the argument */
- dwEngine = atoi (argv[i]);
-
- /* Count the one bits in the engine argument */
- c8OnBits = winCountBits (dwEngine);
-
- /* Argument should only have a single bit on */
- if (c8OnBits != 1)
- {
- UseMsg ();
- return 0;
- }
-
- screenInfoPtr->dwEnginePreferred = dwEngine;
-
- /* Indicate that we have processed the argument */
- return 2;
- }
-
- /*
- * Look for the '-fullscreen' argument
- */
- if (IS_OPTION ("-fullscreen"))
- {
-#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
- if (!screenInfoPtr->fMultiMonitorOverride)
- screenInfoPtr->fMultipleMonitors = FALSE;
-#endif
- screenInfoPtr->fFullScreen = TRUE;
-
- /* Indicate that we have processed this argument */
- return 1;
- }
-
- /*
- * Look for the '-lesspointer' argument
- */
- if (IS_OPTION ("-lesspointer"))
- {
- screenInfoPtr->fLessPointer = TRUE;
-
- /* Indicate that we have processed this argument */
- return 1;
- }
-
- /*
- * Look for the '-nodecoration' argument
- */
- if (IS_OPTION ("-nodecoration"))
- {
-#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
- if (!screenInfoPtr->fMultiMonitorOverride)
- screenInfoPtr->fMultipleMonitors = FALSE;
-#endif
- screenInfoPtr->fDecoration = FALSE;
-
- /* Indicate that we have processed this argument */
- return 1;
- }
-
-#ifdef XWIN_MULTIWINDOWEXTWM
- /*
- * Look for the '-mwextwm' argument
- */
- if (IS_OPTION ("-mwextwm"))
- {
- if (!screenInfoPtr->fMultiMonitorOverride)
- screenInfoPtr->fMultipleMonitors = TRUE;
- screenInfoPtr->fMWExtWM = TRUE;
-
- /* Indicate that we have processed this argument */
- return 1;
- }
- /*
- * Look for the '-internalwm' argument
- */
- if (IS_OPTION ("-internalwm"))
- {
- if (!screenInfoPtr->fMultiMonitorOverride)
- screenInfoPtr->fMultipleMonitors = TRUE;
- screenInfoPtr->fMWExtWM = TRUE;
- screenInfoPtr->fInternalWM = TRUE;
-
- /* Indicate that we have processed this argument */
- return 1;
- }
-#endif
-
- /*
- * Look for the '-rootless' argument
- */
- if (IS_OPTION ("-rootless"))
- {
-#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
- if (!screenInfoPtr->fMultiMonitorOverride)
- screenInfoPtr->fMultipleMonitors = FALSE;
-#endif
- screenInfoPtr->fRootless = TRUE;
-
- /* Indicate that we have processed this argument */
- return 1;
- }
-
-#ifdef XWIN_MULTIWINDOW
- /*
- * Look for the '-multiwindow' argument
- */
- if (IS_OPTION ("-multiwindow"))
- {
-#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
- if (!screenInfoPtr->fMultiMonitorOverride)
- screenInfoPtr->fMultipleMonitors = TRUE;
-#endif
- screenInfoPtr->fMultiWindow = TRUE;
-
- /* Indicate that we have processed this argument */
- return 1;
- }
-#endif
-
- /*
- * Look for the '-multiplemonitors' argument
- */
- if (IS_OPTION ("-multiplemonitors")
- || IS_OPTION ("-multimonitors"))
- {
-#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
- screenInfoPtr->fMultiMonitorOverride = TRUE;
-#endif
- screenInfoPtr->fMultipleMonitors = TRUE;
-
- /* Indicate that we have processed this argument */
- return 1;
- }
-
- /*
- * Look for the '-nomultiplemonitors' argument
- */
- if (IS_OPTION ("-nomultiplemonitors")
- || IS_OPTION ("-nomultimonitors"))
- {
-#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
- screenInfoPtr->fMultiMonitorOverride = TRUE;
-#endif
- screenInfoPtr->fMultipleMonitors = FALSE;
-
- /* Indicate that we have processed this argument */
- return 1;
- }
-
-
- /*
- * Look for the '-scrollbars' argument
- */
- if (IS_OPTION ("-scrollbars"))
- {
- screenInfoPtr->fScrollbars = TRUE;
-
- /* Indicate that we have processed this argument */
- return 1;
- }
-
-
-#ifdef XWIN_CLIPBOARD
- /*
- * Look for the '-clipboard' argument
- */
- if (IS_OPTION ("-clipboard"))
- {
- /* Now the default, we still accept the arg for backwards compatibility */
- g_fClipboard = TRUE;
-
- /* Indicate that we have processed this argument */
- return 1;
- }
-
- /*
- * Look for the '-noclipboard' argument
- */
- if (IS_OPTION ("-noclipboard"))
- {
- g_fClipboard = FALSE;
-
- /* Indicate that we have processed this argument */
- return 1;
- }
-#endif
-
-
- /*
- * Look for the '-ignoreinput' argument
- */
- if (IS_OPTION ("-ignoreinput"))
- {
- screenInfoPtr->fIgnoreInput = TRUE;
-
- /* Indicate that we have processed this argument */
- return 1;
- }
-
- /*
- * Look for the '-emulate3buttons' argument
- */
- if (IS_OPTION ("-emulate3buttons"))
- {
- int iArgsProcessed = 1;
- int iE3BTimeout = WIN_DEFAULT_E3B_TIME;
-
- /* Grab the optional timeout value */
- if (i + 1 < argc
- && 1 == sscanf (argv[i + 1], "%d",
- &iE3BTimeout))
- {
- /* Indicate that we have processed the next argument */
- iArgsProcessed++;
- }
- else
- {
- /*
- * sscanf () won't modify iE3BTimeout if it doesn't find
- * the specified format; however, I want to be explicit
- * about setting the default timeout in such cases to
- * prevent some programs (me) from getting confused.
- */
- iE3BTimeout = WIN_DEFAULT_E3B_TIME;
- }
-
- screenInfoPtr->iE3BTimeout = iE3BTimeout;
-
- /* Indicate that we have processed this argument */
- return iArgsProcessed;
- }
-
- /*
- * Look for the '-depth n' argument
- */
- if (IS_OPTION ("-depth"))
- {
- DWORD dwBPP = 0;
-
- /* Display the usage message if the argument is malformed */
- if (++i >= argc)
- {
- UseMsg ();
- return 0;
- }
-
- /* Grab the argument */
- dwBPP = atoi (argv[i]);
-
- screenInfoPtr->dwBPP = dwBPP;
-
- /* Indicate that we have processed the argument */
- return 2;
- }
-
- /*
- * Look for the '-refresh n' argument
- */
- if (IS_OPTION ("-refresh"))
- {
- DWORD dwRefreshRate = 0;
-
- /* Display the usage message if the argument is malformed */
- if (++i >= argc)
- {
- UseMsg ();
- return 0;
- }
-
- /* Grab the argument */
- dwRefreshRate = atoi (argv[i]);
-
- screenInfoPtr->dwRefreshRate = dwRefreshRate;
-
- /* Indicate that we have processed the argument */
- return 2;
- }
-
- /*
- * Look for the '-clipupdates num_boxes' argument
- */
- if (IS_OPTION ("-clipupdates"))
- {
- DWORD dwNumBoxes = 0;
-
- /* Display the usage message if the argument is malformed */
- if (++i >= argc)
- {
- UseMsg ();
- return 0;
- }
-
- /* Grab the argument */
- dwNumBoxes = atoi (argv[i]);
-
- screenInfoPtr->dwClipUpdatesNBoxes = dwNumBoxes;
-
- /* Indicate that we have processed the argument */
- return 2;
- }
-
-#ifdef XWIN_EMULATEPSEUDO
- /*
- * Look for the '-emulatepseudo' argument
- */
- if (IS_OPTION ("-emulatepseudo"))
- {
- screenInfoPtr->fEmulatePseudo = TRUE;
-
- /* Indicate that we have processed this argument */
- return 1;
- }
-#endif
-
- /*
- * Look for the '-nowinkill' argument
- */
- if (IS_OPTION ("-nowinkill"))
- {
- screenInfoPtr->fUseWinKillKey = FALSE;
-
- /* Indicate that we have processed this argument */
- return 1;
- }
-
- /*
- * Look for the '-winkill' argument
- */
- if (IS_OPTION ("-winkill"))
- {
- screenInfoPtr->fUseWinKillKey = TRUE;
-
- /* Indicate that we have processed this argument */
- return 1;
- }
-
- /*
- * Look for the '-nounixkill' argument
- */
- if (IS_OPTION ("-nounixkill"))
- {
- screenInfoPtr->fUseUnixKillKey = FALSE;
-
- /* Indicate that we have processed this argument */
- return 1;
- }
-
- /*
- * Look for the '-unixkill' argument
- */
- if (IS_OPTION ("-unixkill"))
- {
- screenInfoPtr->fUseUnixKillKey = TRUE;
-
- /* Indicate that we have processed this argument */
- return 1;
- }
-
- /*
- * Look for the '-notrayicon' argument
- */
- if (IS_OPTION ("-notrayicon"))
- {
- screenInfoPtr->fNoTrayIcon = TRUE;
-
- /* Indicate that we have processed this argument */
- return 1;
- }
-
- /*
- * Look for the '-trayicon' argument
- */
- if (IS_OPTION ("-trayicon"))
- {
- screenInfoPtr->fNoTrayIcon = FALSE;
-
- /* Indicate that we have processed this argument */
- return 1;
- }
-
- /*
- * Look for the '-fp' argument
- */
- if (IS_OPTION ("-fp"))
- {
- CHECK_ARGS (1);
- g_cmdline.fontPath = argv[++i];
- return 0; /* Let DIX parse this again */
- }
-
- /*
- * Look for the '-query' argument
- */
- if (IS_OPTION ("-query"))
- {
- CHECK_ARGS (1);
- g_fXdmcpEnabled = TRUE;
- g_pszQueryHost = argv[++i];
- return 0; /* Let DIX parse this again */
- }
-
- /*
- * Look for the '-auth' argument
- */
- if (IS_OPTION ("-auth"))
- {
- g_fAuthEnabled = TRUE;
- return 0; /* Let DIX parse this again */
- }
-
- /*
- * Look for the '-indirect' or '-broadcast' arguments
- */
- if (IS_OPTION ("-indirect")
- || IS_OPTION ("-broadcast"))
- {
- g_fXdmcpEnabled = TRUE;
- return 0; /* Let DIX parse this again */
- }
-
- /*
- * Look for the '-config' argument
- */
- if (IS_OPTION ("-config")
- || IS_OPTION ("-xf86config"))
- {
- CHECK_ARGS (1);
-#ifdef XWIN_XF86CONFIG
- g_cmdline.configFile = argv[++i];
-#else
- winMessageBoxF ("The %s option is not supported in this "
- "release.\n"
- "Ignoring this option and continuing.\n",
- MB_ICONINFORMATION,
- argv[i]);
-#endif
- return 2;
- }
-
- /*
- * Look for the '-configdir' argument
- */
- if (IS_OPTION ("-configdir"))
- {
- CHECK_ARGS (1);
-#ifdef XWIN_XF86CONFIG
- g_cmdline.configDir = argv[++i];
-#else
- winMessageBoxF ("The %s option is not supported in this "
- "release.\n"
- "Ignoring this option and continuing.\n",
- MB_ICONINFORMATION,
- argv[i]);
-#endif
- return 2;
- }
-
- /*
- * Look for the '-keyboard' argument
- */
- if (IS_OPTION ("-keyboard"))
- {
-#ifdef XWIN_XF86CONFIG
- CHECK_ARGS (1);
- g_cmdline.keyboard = argv[++i];
-#else
- winMessageBoxF ("The -keyboard option is not supported in this "
- "release.\n"
- "Ignoring this option and continuing.\n",
- MB_ICONINFORMATION);
-#endif
- return 2;
- }
-
- /*
- * Look for the '-logfile' argument
- */
- if (IS_OPTION ("-logfile"))
- {
- CHECK_ARGS (1);
- g_pszLogFile = argv[++i];
-#ifdef RELOCATE_PROJECTROOT
- g_fLogFileChanged = TRUE;
-#endif
- return 2;
- }
-
- /*
- * Look for the '-logverbose' argument
- */
- if (IS_OPTION ("-logverbose"))
- {
- CHECK_ARGS (1);
- g_iLogVerbose = atoi(argv[++i]);
- return 2;
- }
-
-#ifdef XWIN_CLIPBOARD
- /*
- * Look for the '-nounicodeclipboard' argument
- */
- if (IS_OPTION ("-nounicodeclipboard"))
- {
- g_fUnicodeClipboard = FALSE;
- /* Indicate that we have processed the argument */
- return 1;
- }
-#endif
-
- if (IS_OPTION ("-xkbrules"))
- {
- CHECK_ARGS (1);
- g_cmdline.xkbRules = argv[++i];
- return 2;
- }
- if (IS_OPTION ("-xkbmodel"))
- {
- CHECK_ARGS (1);
- g_cmdline.xkbModel = argv[++i];
- return 2;
- }
- if (IS_OPTION ("-xkblayout"))
- {
- CHECK_ARGS (1);
- g_cmdline.xkbLayout = argv[++i];
- return 2;
- }
- if (IS_OPTION ("-xkbvariant"))
- {
- CHECK_ARGS (1);
- g_cmdline.xkbVariant = argv[++i];
- return 2;
- }
- if (IS_OPTION ("-xkboptions"))
- {
- CHECK_ARGS (1);
- g_cmdline.xkbOptions = argv[++i];
- return 2;
- }
-
- if (IS_OPTION ("-keyhook"))
- {
- g_fKeyboardHookLL = TRUE;
- return 1;
- }
-
- if (IS_OPTION ("-nokeyhook"))
- {
- g_fKeyboardHookLL = FALSE;
- return 1;
- }
-
- if (IS_OPTION ("-swcursor"))
- {
- g_fSoftwareCursor = TRUE;
- return 1;
- }
-
- if (IS_OPTION ("-silent-dup-error"))
- {
- g_fSilentDupError = TRUE;
- return 1;
- }
-
- if (IS_OPTION("-wgl"))
- {
- g_fNativeGl = TRUE;
- return 1;
- }
-
- if (IS_OPTION("-nowgl"))
- {
- g_fNativeGl = FALSE;
- return 1;
- }
-
- return 0;
-}
-
-
-/*
- * winLogCommandLine - Write entire command line to the log file
- */
-
-void
-winLogCommandLine (int argc, char *argv[])
-{
- int i;
- int iSize = 0;
- int iCurrLen = 0;
-
-#define CHARS_PER_LINE 60
-
- /* Bail if command line has already been logged */
- if (g_pszCommandLine)
- return;
-
- /* Count how much memory is needed for concatenated command line */
- for (i = 0, iCurrLen = 0; i < argc; ++i)
- if (argv[i])
- {
- /* Adds two characters for lines that overflow */
- if ((strlen (argv[i]) < CHARS_PER_LINE
- && iCurrLen + strlen (argv[i]) > CHARS_PER_LINE)
- || strlen (argv[i]) > CHARS_PER_LINE)
- {
- iCurrLen = 0;
- iSize += 2;
- }
-
- /* Add space for item and trailing space */
- iSize += strlen (argv[i]) + 1;
-
- /* Update current line length */
- iCurrLen += strlen (argv[i]);
- }
-
- /* Allocate memory for concatenated command line */
- g_pszCommandLine = malloc (iSize + 1);
- if (!g_pszCommandLine)
- FatalError ("winLogCommandLine - Could not allocate memory for "
- "command line string. Exiting.\n");
-
- /* Set first character to concatenated command line to null */
- g_pszCommandLine[0] = '\0';
-
- /* Loop through all args */
- for (i = 0, iCurrLen = 0; i < argc; ++i)
- {
- /* Add a character for lines that overflow */
- if ((strlen (argv[i]) < CHARS_PER_LINE
- && iCurrLen + strlen (argv[i]) > CHARS_PER_LINE)
- || strlen (argv[i]) > CHARS_PER_LINE)
- {
- iCurrLen = 0;
-
- /* Add line break if it fits */
- strncat (g_pszCommandLine, "\n ", iSize - strlen (g_pszCommandLine));
- }
-
- strncat (g_pszCommandLine, argv[i], iSize - strlen (g_pszCommandLine));
- strncat (g_pszCommandLine, " ", iSize - strlen (g_pszCommandLine));
-
- /* Save new line length */
- iCurrLen += strlen (argv[i]);
- }
-
- winDebug ("XWin was started with the following command line:\n\n"
- "%s\n\n", g_pszCommandLine);
-}
-
-
-/*
- * winLogVersionInfo - Log Cygwin/X version information
- */
-
-void
-winLogVersionInfo (void)
-{
-#ifdef WINDBG
- static Bool s_fBeenHere = FALSE;
-
- if (s_fBeenHere)
- return;
- s_fBeenHere = TRUE;
-
- winDebug ("Welcome to the VcXsrv X Server\n");
- winDebug ("Vendor: %s\n", VENDOR_STRING);
- winDebug ("Release: %d.%d.%d.%d (%d)\n\n", XORG_VERSION_MAJOR, XORG_VERSION_MINOR, XORG_VERSION_PATCH, XORG_VERSION_SNAP, XORG_VERSION_CURRENT);
- winDebug ("%s\n\n", BUILDERSTRING);
- winDebug ("Contact: %s\n\n", VENDOR_CONTACT);
-#endif
-}
-/*
- * getMonitorInfo - callback function used to return information from the enumeration of monitors attached
- */
-
-wBOOL CALLBACK getMonitorInfo(HMONITOR hMonitor, HDC hdc, LPRECT rect, LPARAM _data)
-{
- struct GetMonitorInfoData* data = (struct GetMonitorInfoData*)_data;
- // only get data for monitor number specified in <data>
- data->monitorNum++;
- if (data->monitorNum == data->requestedMonitor)
- {
- data->bMonitorSpecifiedExists = TRUE;
- data->monitorOffsetX = rect->left;
- data->monitorOffsetY = rect->top;
- data->monitorHeight = rect->bottom - rect->top;
- data->monitorWidth = rect->right - rect->left;
- return FALSE;
- }
- return TRUE;
-}
+/*
+
+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 <../xfree86/common/xorgVersion.h>
+#include "win.h"
+#include "winconfig.h"
+#include "winmsg.h"
+#define COMPILE_MULTIMON_STUBS
+#include <multimon.h>
+/*
+ * References to external symbols
+ */
+
+#ifdef XWIN_CLIPBOARD
+extern Bool g_fUnicodeClipboard;
+extern Bool g_fClipboard;
+#endif
+/* globals required by callback function for monitor information */
+struct GetMonitorInfoData {
+ int requestedMonitor;
+ int monitorNum;
+ Bool bUserSpecifiedMonitor;
+ Bool bMonitorSpecifiedExists;
+ int monitorOffsetX;
+ int monitorOffsetY;
+ int monitorHeight;
+ int monitorWidth;
+};
+
+wBOOL CALLBACK getMonitorInfo(HMONITOR hMonitor, HDC hdc, LPRECT rect, LPARAM _data);
+
+static Bool QueryMonitor(int index, struct GetMonitorInfoData *data)
+{
+ /* prepare data */
+ if (data == NULL)
+ return FALSE;
+ memset(data, 0, sizeof(*data));
+ data->requestedMonitor = index;
+
+ /* query information */
+ xEnumDisplayMonitors(NULL, NULL, getMonitorInfo, (LPARAM) data);
+
+ return TRUE;
+}
+
+/*
+ * Function prototypes
+ */
+
+void
+winLogCommandLine (int argc, char *argv[]);
+
+void
+winLogVersionInfo (void);
+
+#ifdef DDXOSVERRORF
+void OsVendorVErrorF (const char *pszFormat, va_list va_args);
+#endif
+
+/*
+ * Process arguments on the command line
+ */
+
+static int iLastScreen = -1;
+static winScreenInfo defaultScreenInfo;
+
+static void
+winInitializeScreenDefaults(void)
+{
+ DWORD dwWidth, dwHeight;
+ static Bool fInitializedScreenDefaults = FALSE;
+
+ /* Bail out early if default screen has already been initialized */
+ if (fInitializedScreenDefaults)
+ return;
+
+ /* Zero the memory used for storing the screen info */
+ memset(&defaultScreenInfo, 0, sizeof(winScreenInfo));
+
+ /* Get default width and height */
+ /*
+ * NOTE: These defaults will cause the window to cover only
+ * the primary monitor in the case that we have multiple monitors.
+ */
+ dwWidth = GetSystemMetrics (SM_CXSCREEN);
+ dwHeight = GetSystemMetrics (SM_CYSCREEN);
+
+ winDebug ("winInitializeScreenDefaults - w %d h %d\n",
+ (int) dwWidth, (int) dwHeight);
+
+ /* Set a default DPI, if no parameter was passed */
+ if (monitorResolution == 0)
+ monitorResolution = WIN_DEFAULT_DPI;
+
+ defaultScreenInfo.dwWidth = dwWidth;
+ defaultScreenInfo.dwHeight = dwHeight;
+ defaultScreenInfo.dwUserWidth = dwWidth;
+ defaultScreenInfo.dwUserHeight = dwHeight;
+ defaultScreenInfo.fUserGaveHeightAndWidth = WIN_DEFAULT_USER_GAVE_HEIGHT_AND_WIDTH;
+ defaultScreenInfo.fUserGavePosition = FALSE;
+ defaultScreenInfo.dwBPP = WIN_DEFAULT_BPP;
+ defaultScreenInfo.dwClipUpdatesNBoxes = WIN_DEFAULT_CLIP_UPDATES_NBOXES;
+#ifdef XWIN_EMULATEPSEUDO
+ defaultScreenInfo.fEmulatePseudo = WIN_DEFAULT_EMULATE_PSEUDO;
+#endif
+ defaultScreenInfo.dwRefreshRate = WIN_DEFAULT_REFRESH;
+ defaultScreenInfo.pfb = NULL;
+ defaultScreenInfo.fFullScreen = FALSE;
+ defaultScreenInfo.fDecoration = TRUE;
+#ifdef XWIN_MULTIWINDOWEXTWM
+ defaultScreenInfo.fMWExtWM = FALSE;
+ defaultScreenInfo.fInternalWM = FALSE;
+#endif
+ defaultScreenInfo.fRootless = FALSE;
+#ifdef XWIN_MULTIWINDOW
+ defaultScreenInfo.fMultiWindow = FALSE;
+#endif
+#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
+ defaultScreenInfo.fMultiMonitorOverride = FALSE;
+#endif
+ defaultScreenInfo.fMultipleMonitors = FALSE;
+ defaultScreenInfo.fLessPointer = FALSE;
+ defaultScreenInfo.fScrollbars = FALSE;
+ defaultScreenInfo.fNoTrayIcon = FALSE;
+ defaultScreenInfo.iE3BTimeout = WIN_E3B_OFF;
+ defaultScreenInfo.dwWidth_mm = (dwWidth / WIN_DEFAULT_DPI) * 25.4;
+ defaultScreenInfo.dwHeight_mm = (dwHeight / WIN_DEFAULT_DPI) * 25.4;
+ defaultScreenInfo.fUseWinKillKey = WIN_DEFAULT_WIN_KILL;
+ defaultScreenInfo.fUseUnixKillKey = WIN_DEFAULT_UNIX_KILL;
+ defaultScreenInfo.fIgnoreInput = FALSE;
+ defaultScreenInfo.fExplicitScreen = FALSE;
+
+ /* Note that the default screen has been initialized */
+ fInitializedScreenDefaults = TRUE;
+}
+
+static void
+winInitializeScreen(int i)
+{
+ winDebug ("winInitializeScreen - %d\n",i);
+
+ /* Initialize default screen values, if needed */
+ winInitializeScreenDefaults();
+
+ /* Copy the default screen info */
+ g_ScreenInfo[i] = defaultScreenInfo;
+
+ /* Set the screen number */
+ g_ScreenInfo[i].dwScreen = i;
+}
+
+void
+winInitializeScreens(int maxscreens)
+{
+ int i;
+ winDebug ("winInitializeScreens - %i\n", maxscreens);
+
+ if (maxscreens > g_iNumScreens)
+ {
+ /* Reallocate the memory for DDX-specific screen info */
+ g_ScreenInfo = realloc(g_ScreenInfo, maxscreens * sizeof (winScreenInfo));
+
+ /* Set default values for any new screens */
+ for (i = g_iNumScreens; i < maxscreens ; i++)
+ winInitializeScreen(i);
+
+ /* Keep a count of the number of screens */
+ g_iNumScreens = maxscreens;
+ }
+}
+
+/* See Porting Layer Definition - p. 57 */
+/*
+ * INPUT
+ * argv: pointer to an array of null-terminated strings, one for
+ * each token in the X Server command line; the first token
+ * is 'XWin.exe', or similar.
+ * argc: a count of the number of tokens stored in argv.
+ * i: a zero-based index into argv indicating the current token being
+ * processed.
+ *
+ * OUTPUT
+ * return: return the number of tokens processed correctly.
+ *
+ * NOTE
+ * When looking for n tokens, check that i + n is less than argc. Or,
+ * you may check if i is greater than or equal to argc, in which case
+ * you should display the UseMsg () and return 0.
+ */
+
+/* Check if enough arguments are given for the option */
+#define CHECK_ARGS(count) if (i + count >= argc) { UseMsg (); return 0; }
+
+/* Compare the current option with the string. */
+#define IS_OPTION(name) (strcmp (argv[i], name) == 0)
+
+int
+ddxProcessArgument (int argc, char *argv[], int i)
+{
+ static Bool s_fBeenHere = FALSE;
+ winScreenInfo *screenInfoPtr = NULL;
+
+ /* Initialize once */
+ if (!s_fBeenHere)
+ {
+#ifdef DDXOSVERRORF
+ /*
+ * This initialises our hook into VErrorF () for catching log messages
+ * that are generated before OsInit () is called.
+ */
+ OsVendorVErrorFProc = OsVendorVErrorF;
+#endif
+
+ s_fBeenHere = TRUE;
+
+ /* Initialize only if option is not -help */
+ if (!IS_OPTION("-help") && !IS_OPTION("-h") && !IS_OPTION("--help") &&
+ !IS_OPTION("-version") && !IS_OPTION("--version"))
+ {
+
+ /* Log the version information */
+ winLogVersionInfo ();
+
+ /* Log the command line */
+ winLogCommandLine (argc, argv);
+
+ /*
+ * Initialize default screen settings. We have to do this before
+ * OsVendorInit () gets called, otherwise we will overwrite
+ * settings changed by parameters such as -fullscreen, etc.
+ */
+ winDebug ("ddxProcessArgument - Initializing default "
+ "screens\n");
+ winInitializeScreenDefaults();
+ }
+ }
+
+ winDebug ("ddxProcessArgument - arg: %s\n", argv[i]);
+
+ /*
+ * Look for the '-help' and similar options
+ */
+ if (IS_OPTION ("-help") || IS_OPTION("-h") || IS_OPTION("--help"))
+ {
+ /* Reset logfile. We don't need that helpmessage in the logfile */
+ g_pszLogFile = NULL;
+ g_fNoHelpMessageBox = TRUE;
+ UseMsg();
+ exit (0);
+ return 1;
+ }
+
+ if (IS_OPTION ("-version") || IS_OPTION("--version"))
+ {
+ /* Reset logfile. We don't need that versioninfo in the logfile */
+ g_pszLogFile = NULL;
+ winLogVersionInfo ();
+ exit (0);
+ return 1;
+ }
+
+ /*
+ * Look for the '-screen scr_num [width height]' argument
+ */
+ if (IS_OPTION ("-screen"))
+ {
+ int iArgsProcessed = 1;
+ int nScreenNum;
+ int iWidth, iHeight, iX, iY;
+ int iMonitor;
+
+ winDebug ("ddxProcessArgument - screen - argc: %d i: %d\n",
+ argc, i);
+
+ /* Display the usage message if the argument is malformed */
+ if (i + 1 >= argc)
+ {
+ return 0;
+ }
+
+ /* Grab screen number */
+ nScreenNum = atoi (argv[i + 1]);
+
+ /* Validate the specified screen number */
+ if (nScreenNum < 0)
+ {
+ ErrorF ("ddxProcessArgument - screen - Invalid screen number %d\n",
+ nScreenNum);
+ UseMsg ();
+ return 0;
+ }
+
+ /*
+ Initialize default values for any new screens
+
+ Note that default values can't change after a -screen option is
+ seen, so it's safe to do this for each screen as it is introduced
+ */
+ winInitializeScreens(nScreenNum+1);
+
+ /* look for @m where m is monitor number */
+ if (i + 2 < argc
+ && 1 == sscanf(argv[i + 2], "@%d", (int *) &iMonitor))
+ {
+ struct GetMonitorInfoData data;
+ if (!QueryMonitor(iMonitor, &data))
+ {
+ ErrorF ("ddxProcessArgument - screen - "
+ "Querying monitors is not supported on NT4 and Win95\n");
+ } else if (data.bMonitorSpecifiedExists == TRUE)
+ {
+ winDebug("ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n", iMonitor);
+ iArgsProcessed = 3;
+ g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = FALSE;
+ g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE;
+ g_ScreenInfo[nScreenNum].dwWidth = data.monitorWidth;
+ g_ScreenInfo[nScreenNum].dwHeight = data.monitorHeight;
+ g_ScreenInfo[nScreenNum].dwUserWidth = data.monitorWidth;
+ g_ScreenInfo[nScreenNum].dwUserHeight = data.monitorHeight;
+ g_ScreenInfo[nScreenNum].dwInitialX = data.monitorOffsetX;
+ g_ScreenInfo[nScreenNum].dwInitialY = data.monitorOffsetY;
+ }
+ else
+ {
+ /* monitor does not exist, error out */
+ ErrorF ("ddxProcessArgument - screen - Invalid monitor number %d\n",
+ iMonitor);
+ UseMsg ();
+ exit (0);
+ return 0;
+ }
+ }
+
+ /* Look for 'WxD' or 'W D' */
+ else if (i + 2 < argc
+ && 2 == sscanf (argv[i + 2], "%dx%d",
+ (int *) &iWidth,
+ (int *) &iHeight))
+ {
+ winDebug ("ddxProcessArgument - screen - Found ``WxD'' arg\n");
+ iArgsProcessed = 3;
+ g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = TRUE;
+ g_ScreenInfo[nScreenNum].dwWidth = iWidth;
+ g_ScreenInfo[nScreenNum].dwHeight = iHeight;
+ g_ScreenInfo[nScreenNum].dwUserWidth = iWidth;
+ g_ScreenInfo[nScreenNum].dwUserHeight = iHeight;
+ /* Look for WxD+X+Y */
+ if (2 == sscanf (argv[i + 2], "%*dx%*d+%d+%d",
+ (int *) &iX,
+ (int *) &iY))
+ {
+ winDebug("ddxProcessArgument - screen - Found ``X+Y'' arg\n");
+ g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE;
+ g_ScreenInfo[nScreenNum].dwInitialX = iX;
+ g_ScreenInfo[nScreenNum].dwInitialY = iY;
+
+ /* look for WxD+X+Y@m where m is monitor number. take X,Y to be offsets from monitor's root position */
+ if (1 == sscanf (argv[i + 2], "%*dx%*d+%*d+%*d@%d",
+ (int *) &iMonitor))
+ {
+ struct GetMonitorInfoData data;
+ if (!QueryMonitor(iMonitor, &data))
+ {
+ ErrorF ("ddxProcessArgument - screen - "
+ "Querying monitors is not supported on NT4 and Win95\n");
+ } else if (data.bMonitorSpecifiedExists == TRUE)
+ {
+ g_ScreenInfo[nScreenNum].dwInitialX += data.monitorOffsetX;
+ g_ScreenInfo[nScreenNum].dwInitialY += data.monitorOffsetY;
+ }
+ else
+ {
+ /* monitor does not exist, error out */
+ ErrorF ("ddxProcessArgument - screen - Invalid monitor number %d\n",
+ iMonitor);
+ UseMsg ();
+ exit (0);
+ return 0;
+ }
+
+ }
+ }
+
+ /* look for WxD@m where m is monitor number */
+ else if (1 == sscanf(argv[i + 2], "%*dx%*d@%d",
+ (int *) &iMonitor))
+ {
+ struct GetMonitorInfoData data;
+ if (!QueryMonitor(iMonitor, &data))
+ {
+ ErrorF ("ddxProcessArgument - screen - "
+ "Querying monitors is not supported on NT4 and Win95\n");
+ } else if (data.bMonitorSpecifiedExists == TRUE)
+ {
+ winDebug ("ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n", iMonitor);
+ g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE;
+ g_ScreenInfo[nScreenNum].dwInitialX = data.monitorOffsetX;
+ g_ScreenInfo[nScreenNum].dwInitialY = data.monitorOffsetY;
+ }
+ else
+ {
+ /* monitor does not exist, error out */
+ ErrorF ("ddxProcessArgument - screen - Invalid monitor number %d\n",
+ iMonitor);
+ UseMsg ();
+ exit (0);
+ return 0;
+ }
+
+ }
+ }
+ else if (i + 3 < argc
+ && 1 == sscanf (argv[i + 2], "%d",
+ (int *) &iWidth)
+ && 1 == sscanf (argv[i + 3], "%d",
+ (int *) &iHeight))
+ {
+ winDebug ("ddxProcessArgument - screen - Found ``W D'' arg\n");
+ iArgsProcessed = 4;
+ g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = TRUE;
+ g_ScreenInfo[nScreenNum].dwWidth = iWidth;
+ g_ScreenInfo[nScreenNum].dwHeight = iHeight;
+ g_ScreenInfo[nScreenNum].dwUserWidth = iWidth;
+ g_ScreenInfo[nScreenNum].dwUserHeight = iHeight;
+ if (i + 5 < argc
+ && 1 == sscanf (argv[i + 4], "%d",
+ (int *) &iX)
+ && 1 == sscanf (argv[i + 5], "%d",
+ (int *) &iY))
+ {
+ winDebug ("ddxProcessArgument - screen - Found ``X Y'' arg\n");
+ iArgsProcessed = 6;
+ g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE;
+ g_ScreenInfo[nScreenNum].dwInitialX = iX;
+ g_ScreenInfo[nScreenNum].dwInitialY = iY;
+ }
+ }
+ else
+ {
+ ErrorF ("ddxProcessArgument - screen - Did not find size arg. "
+ "dwWidth: %d dwHeight: %d\n",
+ (int) g_ScreenInfo[nScreenNum].dwWidth,
+ (int) g_ScreenInfo[nScreenNum].dwHeight);
+ iArgsProcessed = 2;
+ g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = FALSE;
+ }
+
+ /* Calculate the screen width and height in millimeters */
+ if (g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth)
+ {
+ g_ScreenInfo[nScreenNum].dwWidth_mm
+ = (g_ScreenInfo[nScreenNum].dwWidth
+ / monitorResolution) * 25.4;
+ g_ScreenInfo[nScreenNum].dwHeight_mm
+ = (g_ScreenInfo[nScreenNum].dwHeight
+ / monitorResolution) * 25.4;
+ }
+
+ /* Flag that this screen was explicity specified by the user */
+ g_ScreenInfo[nScreenNum].fExplicitScreen = TRUE;
+
+ /*
+ * Keep track of the last screen number seen, as parameters seen
+ * before a screen number apply to all screens, whereas parameters
+ * seen after a screen number apply to that screen number only.
+ */
+ iLastScreen = nScreenNum;
+
+ return iArgsProcessed;
+ }
+
+
+ /*
+ * Is this parameter attached to a screen or global?
+ *
+ * If the parameter is for all screens (appears before
+ * any -screen option), store it in the default screen
+ * info
+ *
+ * If the parameter is for a single screen (appears
+ * after a -screen option), store it in the screen info
+ * for that screen
+ *
+ */
+ if (iLastScreen == -1)
+ {
+ screenInfoPtr = &defaultScreenInfo;
+ }
+ else
+ {
+ screenInfoPtr = &(g_ScreenInfo[iLastScreen]);
+ }
+
+ /*
+ * Look for the '-engine n' argument
+ */
+ if (IS_OPTION ("-engine"))
+ {
+ DWORD dwEngine = 0;
+ CARD8 c8OnBits = 0;
+
+ /* Display the usage message if the argument is malformed */
+ if (++i >= argc)
+ {
+ UseMsg ();
+ return 0;
+ }
+
+ /* Grab the argument */
+ dwEngine = atoi (argv[i]);
+
+ /* Count the one bits in the engine argument */
+ c8OnBits = winCountBits (dwEngine);
+
+ /* Argument should only have a single bit on */
+ if (c8OnBits != 1)
+ {
+ UseMsg ();
+ return 0;
+ }
+
+ screenInfoPtr->dwEnginePreferred = dwEngine;
+
+ /* Indicate that we have processed the argument */
+ return 2;
+ }
+
+ /*
+ * Look for the '-fullscreen' argument
+ */
+ if (IS_OPTION ("-fullscreen"))
+ {
+#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
+ if (!screenInfoPtr->fMultiMonitorOverride)
+ screenInfoPtr->fMultipleMonitors = FALSE;
+#endif
+ screenInfoPtr->fFullScreen = TRUE;
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+ /*
+ * Look for the '-lesspointer' argument
+ */
+ if (IS_OPTION ("-lesspointer"))
+ {
+ screenInfoPtr->fLessPointer = TRUE;
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+ /*
+ * Look for the '-nodecoration' argument
+ */
+ if (IS_OPTION ("-nodecoration"))
+ {
+#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
+ if (!screenInfoPtr->fMultiMonitorOverride)
+ screenInfoPtr->fMultipleMonitors = FALSE;
+#endif
+ screenInfoPtr->fDecoration = FALSE;
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+#ifdef XWIN_MULTIWINDOWEXTWM
+ /*
+ * Look for the '-mwextwm' argument
+ */
+ if (IS_OPTION ("-mwextwm"))
+ {
+ if (!screenInfoPtr->fMultiMonitorOverride)
+ screenInfoPtr->fMultipleMonitors = TRUE;
+ screenInfoPtr->fMWExtWM = TRUE;
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+ /*
+ * Look for the '-internalwm' argument
+ */
+ if (IS_OPTION ("-internalwm"))
+ {
+ if (!screenInfoPtr->fMultiMonitorOverride)
+ screenInfoPtr->fMultipleMonitors = TRUE;
+ screenInfoPtr->fMWExtWM = TRUE;
+ screenInfoPtr->fInternalWM = TRUE;
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+#endif
+
+ /*
+ * Look for the '-rootless' argument
+ */
+ if (IS_OPTION ("-rootless"))
+ {
+#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
+ if (!screenInfoPtr->fMultiMonitorOverride)
+ screenInfoPtr->fMultipleMonitors = FALSE;
+#endif
+ screenInfoPtr->fRootless = TRUE;
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+#ifdef XWIN_MULTIWINDOW
+ /*
+ * Look for the '-multiwindow' argument
+ */
+ if (IS_OPTION ("-multiwindow"))
+ {
+#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
+ if (!screenInfoPtr->fMultiMonitorOverride)
+ screenInfoPtr->fMultipleMonitors = TRUE;
+#endif
+ screenInfoPtr->fMultiWindow = TRUE;
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+#endif
+
+ /*
+ * Look for the '-multiplemonitors' argument
+ */
+ if (IS_OPTION ("-multiplemonitors")
+ || IS_OPTION ("-multimonitors"))
+ {
+#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
+ screenInfoPtr->fMultiMonitorOverride = TRUE;
+#endif
+ screenInfoPtr->fMultipleMonitors = TRUE;
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+ /*
+ * Look for the '-nomultiplemonitors' argument
+ */
+ if (IS_OPTION ("-nomultiplemonitors")
+ || IS_OPTION ("-nomultimonitors"))
+ {
+#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
+ screenInfoPtr->fMultiMonitorOverride = TRUE;
+#endif
+ screenInfoPtr->fMultipleMonitors = FALSE;
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+
+ /*
+ * Look for the '-scrollbars' argument
+ */
+ if (IS_OPTION ("-scrollbars"))
+ {
+ screenInfoPtr->fScrollbars = TRUE;
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+
+#ifdef XWIN_CLIPBOARD
+ /*
+ * Look for the '-clipboard' argument
+ */
+ if (IS_OPTION ("-clipboard"))
+ {
+ /* Now the default, we still accept the arg for backwards compatibility */
+ g_fClipboard = TRUE;
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+ /*
+ * Look for the '-noclipboard' argument
+ */
+ if (IS_OPTION ("-noclipboard"))
+ {
+ g_fClipboard = FALSE;
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+#endif
+
+
+ /*
+ * Look for the '-ignoreinput' argument
+ */
+ if (IS_OPTION ("-ignoreinput"))
+ {
+ screenInfoPtr->fIgnoreInput = TRUE;
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+ /*
+ * Look for the '-emulate3buttons' argument
+ */
+ if (IS_OPTION ("-emulate3buttons"))
+ {
+ int iArgsProcessed = 1;
+ int iE3BTimeout = WIN_DEFAULT_E3B_TIME;
+
+ /* Grab the optional timeout value */
+ if (i + 1 < argc
+ && 1 == sscanf (argv[i + 1], "%d",
+ &iE3BTimeout))
+ {
+ /* Indicate that we have processed the next argument */
+ iArgsProcessed++;
+ }
+ else
+ {
+ /*
+ * sscanf () won't modify iE3BTimeout if it doesn't find
+ * the specified format; however, I want to be explicit
+ * about setting the default timeout in such cases to
+ * prevent some programs (me) from getting confused.
+ */
+ iE3BTimeout = WIN_DEFAULT_E3B_TIME;
+ }
+
+ screenInfoPtr->iE3BTimeout = iE3BTimeout;
+
+ /* Indicate that we have processed this argument */
+ return iArgsProcessed;
+ }
+
+ /*
+ * Look for the '-depth n' argument
+ */
+ if (IS_OPTION ("-depth"))
+ {
+ DWORD dwBPP = 0;
+
+ /* Display the usage message if the argument is malformed */
+ if (++i >= argc)
+ {
+ UseMsg ();
+ return 0;
+ }
+
+ /* Grab the argument */
+ dwBPP = atoi (argv[i]);
+
+ screenInfoPtr->dwBPP = dwBPP;
+
+ /* Indicate that we have processed the argument */
+ return 2;
+ }
+
+ /*
+ * Look for the '-refresh n' argument
+ */
+ if (IS_OPTION ("-refresh"))
+ {
+ DWORD dwRefreshRate = 0;
+
+ /* Display the usage message if the argument is malformed */
+ if (++i >= argc)
+ {
+ UseMsg ();
+ return 0;
+ }
+
+ /* Grab the argument */
+ dwRefreshRate = atoi (argv[i]);
+
+ screenInfoPtr->dwRefreshRate = dwRefreshRate;
+
+ /* Indicate that we have processed the argument */
+ return 2;
+ }
+
+ /*
+ * Look for the '-clipupdates num_boxes' argument
+ */
+ if (IS_OPTION ("-clipupdates"))
+ {
+ DWORD dwNumBoxes = 0;
+
+ /* Display the usage message if the argument is malformed */
+ if (++i >= argc)
+ {
+ UseMsg ();
+ return 0;
+ }
+
+ /* Grab the argument */
+ dwNumBoxes = atoi (argv[i]);
+
+ screenInfoPtr->dwClipUpdatesNBoxes = dwNumBoxes;
+
+ /* Indicate that we have processed the argument */
+ return 2;
+ }
+
+#ifdef XWIN_EMULATEPSEUDO
+ /*
+ * Look for the '-emulatepseudo' argument
+ */
+ if (IS_OPTION ("-emulatepseudo"))
+ {
+ screenInfoPtr->fEmulatePseudo = TRUE;
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+#endif
+
+ /*
+ * Look for the '-nowinkill' argument
+ */
+ if (IS_OPTION ("-nowinkill"))
+ {
+ screenInfoPtr->fUseWinKillKey = FALSE;
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+ /*
+ * Look for the '-winkill' argument
+ */
+ if (IS_OPTION ("-winkill"))
+ {
+ screenInfoPtr->fUseWinKillKey = TRUE;
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+ /*
+ * Look for the '-nounixkill' argument
+ */
+ if (IS_OPTION ("-nounixkill"))
+ {
+ screenInfoPtr->fUseUnixKillKey = FALSE;
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+ /*
+ * Look for the '-unixkill' argument
+ */
+ if (IS_OPTION ("-unixkill"))
+ {
+ screenInfoPtr->fUseUnixKillKey = TRUE;
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+ /*
+ * Look for the '-notrayicon' argument
+ */
+ if (IS_OPTION ("-notrayicon"))
+ {
+ screenInfoPtr->fNoTrayIcon = TRUE;
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+ /*
+ * Look for the '-trayicon' argument
+ */
+ if (IS_OPTION ("-trayicon"))
+ {
+ screenInfoPtr->fNoTrayIcon = FALSE;
+
+ /* Indicate that we have processed this argument */
+ return 1;
+ }
+
+ /*
+ * Look for the '-fp' argument
+ */
+ if (IS_OPTION ("-fp"))
+ {
+ CHECK_ARGS (1);
+ g_cmdline.fontPath = argv[++i];
+ return 0; /* Let DIX parse this again */
+ }
+
+ /*
+ * Look for the '-query' argument
+ */
+ if (IS_OPTION ("-query"))
+ {
+ CHECK_ARGS (1);
+ g_fXdmcpEnabled = TRUE;
+ g_pszQueryHost = argv[++i];
+ return 0; /* Let DIX parse this again */
+ }
+
+ /*
+ * Look for the '-auth' argument
+ */
+ if (IS_OPTION ("-auth"))
+ {
+ g_fAuthEnabled = TRUE;
+ return 0; /* Let DIX parse this again */
+ }
+
+ /*
+ * Look for the '-indirect' or '-broadcast' arguments
+ */
+ if (IS_OPTION ("-indirect")
+ || IS_OPTION ("-broadcast"))
+ {
+ g_fXdmcpEnabled = TRUE;
+ return 0; /* Let DIX parse this again */
+ }
+
+ /*
+ * Look for the '-config' argument
+ */
+ if (IS_OPTION ("-config")
+ || IS_OPTION ("-xf86config"))
+ {
+ CHECK_ARGS (1);
+#ifdef XWIN_XF86CONFIG
+ g_cmdline.configFile = argv[++i];
+#else
+ winMessageBoxF ("The %s option is not supported in this "
+ "release.\n"
+ "Ignoring this option and continuing.\n",
+ MB_ICONINFORMATION,
+ argv[i]);
+#endif
+ return 2;
+ }
+
+ /*
+ * Look for the '-configdir' argument
+ */
+ if (IS_OPTION ("-configdir"))
+ {
+ CHECK_ARGS (1);
+#ifdef XWIN_XF86CONFIG
+ g_cmdline.configDir = argv[++i];
+#else
+ winMessageBoxF ("The %s option is not supported in this "
+ "release.\n"
+ "Ignoring this option and continuing.\n",
+ MB_ICONINFORMATION,
+ argv[i]);
+#endif
+ return 2;
+ }
+
+ /*
+ * Look for the '-keyboard' argument
+ */
+ if (IS_OPTION ("-keyboard"))
+ {
+#ifdef XWIN_XF86CONFIG
+ CHECK_ARGS (1);
+ g_cmdline.keyboard = argv[++i];
+#else
+ winMessageBoxF ("The -keyboard option is not supported in this "
+ "release.\n"
+ "Ignoring this option and continuing.\n",
+ MB_ICONINFORMATION);
+#endif
+ return 2;
+ }
+
+ /*
+ * Look for the '-logfile' argument
+ */
+ if (IS_OPTION ("-logfile"))
+ {
+ CHECK_ARGS (1);
+ g_pszLogFile = argv[++i];
+#ifdef RELOCATE_PROJECTROOT
+ g_fLogFileChanged = TRUE;
+#endif
+ return 2;
+ }
+
+ /*
+ * Look for the '-logverbose' argument
+ */
+ if (IS_OPTION ("-logverbose"))
+ {
+ CHECK_ARGS (1);
+ g_iLogVerbose = atoi(argv[++i]);
+ return 2;
+ }
+
+#ifdef XWIN_CLIPBOARD
+ /*
+ * Look for the '-nounicodeclipboard' argument
+ */
+ if (IS_OPTION ("-nounicodeclipboard"))
+ {
+ g_fUnicodeClipboard = FALSE;
+ /* Indicate that we have processed the argument */
+ return 1;
+ }
+#endif
+
+ if (IS_OPTION ("-xkbrules"))
+ {
+ CHECK_ARGS (1);
+ g_cmdline.xkbRules = argv[++i];
+ return 2;
+ }
+ if (IS_OPTION ("-xkbmodel"))
+ {
+ CHECK_ARGS (1);
+ g_cmdline.xkbModel = argv[++i];
+ return 2;
+ }
+ if (IS_OPTION ("-xkblayout"))
+ {
+ CHECK_ARGS (1);
+ g_cmdline.xkbLayout = argv[++i];
+ return 2;
+ }
+ if (IS_OPTION ("-xkbvariant"))
+ {
+ CHECK_ARGS (1);
+ g_cmdline.xkbVariant = argv[++i];
+ return 2;
+ }
+ if (IS_OPTION ("-xkboptions"))
+ {
+ CHECK_ARGS (1);
+ g_cmdline.xkbOptions = argv[++i];
+ return 2;
+ }
+
+ if (IS_OPTION ("-keyhook"))
+ {
+ g_fKeyboardHookLL = TRUE;
+ return 1;
+ }
+
+ if (IS_OPTION ("-nokeyhook"))
+ {
+ g_fKeyboardHookLL = FALSE;
+ return 1;
+ }
+
+ if (IS_OPTION ("-swcursor"))
+ {
+ g_fSoftwareCursor = TRUE;
+ return 1;
+ }
+
+ if (IS_OPTION ("-silent-dup-error"))
+ {
+ g_fSilentDupError = TRUE;
+ return 1;
+ }
+
+ if (IS_OPTION("-wgl"))
+ {
+ g_fNativeGl = TRUE;
+ return 1;
+ }
+
+ if (IS_OPTION("-nowgl"))
+ {
+ g_fNativeGl = FALSE;
+ return 1;
+ }
+
+ return 0;
+}
+
+
+/*
+ * winLogCommandLine - Write entire command line to the log file
+ */
+
+void
+winLogCommandLine (int argc, char *argv[])
+{
+ int i;
+ int iSize = 0;
+ int iCurrLen = 0;
+
+#define CHARS_PER_LINE 60
+
+ /* Bail if command line has already been logged */
+ if (g_pszCommandLine)
+ return;
+
+ /* Count how much memory is needed for concatenated command line */
+ for (i = 0, iCurrLen = 0; i < argc; ++i)
+ if (argv[i])
+ {
+ /* Adds two characters for lines that overflow */
+ if ((strlen (argv[i]) < CHARS_PER_LINE
+ && iCurrLen + strlen (argv[i]) > CHARS_PER_LINE)
+ || strlen (argv[i]) > CHARS_PER_LINE)
+ {
+ iCurrLen = 0;
+ iSize += 2;
+ }
+
+ /* Add space for item and trailing space */
+ iSize += strlen (argv[i]) + 1;
+
+ /* Update current line length */
+ iCurrLen += strlen (argv[i]);
+ }
+
+ /* Allocate memory for concatenated command line */
+ g_pszCommandLine = malloc (iSize + 1);
+ if (!g_pszCommandLine)
+ FatalError ("winLogCommandLine - Could not allocate memory for "
+ "command line string. Exiting.\n");
+
+ /* Set first character to concatenated command line to null */
+ g_pszCommandLine[0] = '\0';
+
+ /* Loop through all args */
+ for (i = 0, iCurrLen = 0; i < argc; ++i)
+ {
+ /* Add a character for lines that overflow */
+ if ((strlen (argv[i]) < CHARS_PER_LINE
+ && iCurrLen + strlen (argv[i]) > CHARS_PER_LINE)
+ || strlen (argv[i]) > CHARS_PER_LINE)
+ {
+ iCurrLen = 0;
+
+ /* Add line break if it fits */
+ strncat (g_pszCommandLine, "\n ", iSize - strlen (g_pszCommandLine));
+ }
+
+ strncat (g_pszCommandLine, argv[i], iSize - strlen (g_pszCommandLine));
+ strncat (g_pszCommandLine, " ", iSize - strlen (g_pszCommandLine));
+
+ /* Save new line length */
+ iCurrLen += strlen (argv[i]);
+ }
+
+ winDebug ("XWin was started with the following command line:\n\n"
+ "%s\n\n", g_pszCommandLine);
+}
+
+
+/*
+ * winLogVersionInfo - Log Cygwin/X version information
+ */
+
+void
+winLogVersionInfo (void)
+{
+#ifdef WINDBG
+ static Bool s_fBeenHere = FALSE;
+
+ if (s_fBeenHere)
+ return;
+ s_fBeenHere = TRUE;
+
+ winDebug ("Welcome to the VcXsrv X Server\n");
+ winDebug ("Vendor: %s\n", XVENDORNAME);
+ winDebug ("Release: %d.%d.%d.%d (%d)\n\n", XORG_VERSION_MAJOR, XORG_VERSION_MINOR, XORG_VERSION_PATCH, XORG_VERSION_SNAP, XORG_VERSION_CURRENT);
+ winDebug ("%s\n\n", BUILDERSTRING);
+ winDebug ("Contact: %s\n\n", BUILDERADDR);
+#endif
+}
+/*
+ * getMonitorInfo - callback function used to return information from the enumeration of monitors attached
+ */
+
+wBOOL CALLBACK getMonitorInfo(HMONITOR hMonitor, HDC hdc, LPRECT rect, LPARAM _data)
+{
+ struct GetMonitorInfoData* data = (struct GetMonitorInfoData*)_data;
+ // only get data for monitor number specified in <data>
+ data->monitorNum++;
+ if (data->monitorNum == data->requestedMonitor)
+ {
+ data->bMonitorSpecifiedExists = TRUE;
+ data->monitorOffsetX = rect->left;
+ data->monitorOffsetY = rect->top;
+ data->monitorHeight = rect->bottom - rect->top;
+ data->monitorWidth = rect->right - rect->left;
+ return FALSE;
+ }
+ return TRUE;
+}
diff --git a/xorg-server/hw/xwin/winscrinit.c b/xorg-server/hw/xwin/winscrinit.c
index e5847453c..0905b2227 100644
--- a/xorg-server/hw/xwin/winscrinit.c
+++ b/xorg-server/hw/xwin/winscrinit.c
@@ -65,14 +65,6 @@ winMWExtWMProcs = {
};
#endif
-
-/*
- * References to external symbols
- */
-
-extern Bool g_fSoftwareCursor;
-
-
/*
* Prototypes
*/
diff --git a/xorg-server/hw/xwin/winshaddd.c b/xorg-server/hw/xwin/winshaddd.c
index 8d4cfdc63..da2e8ebee 100644
--- a/xorg-server/hw/xwin/winshaddd.c
+++ b/xorg-server/hw/xwin/winshaddd.c
@@ -38,12 +38,6 @@
/*
- * External symbols
- */
-
-extern HWND g_hDlgExit;
-extern const char *g_pszLogFile;
-
/*
@@ -794,7 +788,6 @@ winInitVisualsShadowDD (ScreenPtr pScreen)
case 24:
case 16:
case 15:
-#if defined(XFree86Server)
/* Create the real visual */
if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
TrueColorMask,
@@ -827,42 +820,9 @@ winInitVisualsShadowDD (ScreenPtr pScreen)
return FALSE;
}
#endif
-#else /* XFree86Server */
- /* Create the real visual */
- if (!fbSetVisualTypesAndMasks (pScreenInfo->dwDepth,
- TrueColorMask,
- pScreenPriv->dwBitsPerRGB,
- pScreenPriv->dwRedMask,
- pScreenPriv->dwGreenMask,
- pScreenPriv->dwBlueMask))
- {
- ErrorF ("winInitVisualsShadowDD - fbSetVisualTypesAndMasks "
- "failed for TrueColor\n");
- return FALSE;
- }
-
-#ifdef XWIN_EMULATEPSEUDO
- if (!pScreenInfo->fEmulatePseudo)
- break;
-
- /* Setup a pseudocolor visual */
- if (!fbSetVisualTypesAndMasks (8,
- PseudoColorMask,
- 8,
- 0,
- 0,
- 0))
- {
- ErrorF ("winInitVisualsShadowDD - fbSetVisualTypesAndMasks "
- "failed for PseudoColor\n");
- return FALSE;
- }
-#endif
-#endif /* XFree86Server */
break;
case 8:
-#if defined(XFree86Server)
if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
pScreenInfo->fFullScreen
? PseudoColorMask : StaticColorMask,
@@ -877,20 +837,6 @@ winInitVisualsShadowDD (ScreenPtr pScreen)
"failed\n");
return FALSE;
}
-#else /* XFree86Server */
- if (!fbSetVisualTypesAndMasks (pScreenInfo->dwDepth,
- pScreenInfo->fFullScreen
- ? PseudoColorMask : StaticColorMask,
- pScreenPriv->dwBitsPerRGB,
- pScreenPriv->dwRedMask,
- pScreenPriv->dwGreenMask,
- pScreenPriv->dwBlueMask))
- {
- ErrorF ("winInitVisualsShadowDD - fbSetVisualTypesAndMasks "
- "failed\n");
- return FALSE;
- }
-#endif /* XFree86Server */
break;
default:
diff --git a/xorg-server/hw/xwin/winshadddnl.c b/xorg-server/hw/xwin/winshadddnl.c
index 59a0b655e..39f03326f 100644
--- a/xorg-server/hw/xwin/winshadddnl.c
+++ b/xorg-server/hw/xwin/winshadddnl.c
@@ -38,13 +38,6 @@
/*
- * External symbols
- */
-
-extern HWND g_hDlgExit;
-
-
-/*
* FIXME: Headers are broken, DEFINE_GUID doesn't work correctly,
* so we have to redefine it here.
*/
@@ -901,7 +894,6 @@ winInitVisualsShadowDDNL (ScreenPtr pScreen)
case 24:
case 16:
case 15:
-#if defined(XFree86Server)
/* Setup the real visual */
if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
TrueColorMask,
@@ -934,42 +926,9 @@ winInitVisualsShadowDDNL (ScreenPtr pScreen)
return FALSE;
}
#endif
-#else /* XFree86Server */
- /* Setup the real visual */
- if (!fbSetVisualTypesAndMasks (pScreenInfo->dwDepth,
- TrueColorMask,
- pScreenPriv->dwBitsPerRGB,
- pScreenPriv->dwRedMask,
- pScreenPriv->dwGreenMask,
- pScreenPriv->dwBlueMask))
- {
- ErrorF ("winInitVisualsShadowDDNL - fbSetVisualTypesAndMasks "
- "failed for TrueColor\n");
- return FALSE;
- }
-
-#ifdef XWIN_EMULATEPSEUDO
- if (!pScreenInfo->fEmulatePseudo)
- break;
-
- /* Setup a pseudocolor visual */
- if (!fbSetVisualTypesAndMasks (8,
- PseudoColorMask,
- 8,
- 0,
- 0,
- 0))
- {
- ErrorF ("winInitVisualsShadowDDNL - fbSetVisualTypesAndMasks "
- "failed for PseudoColor\n");
- return FALSE;
- }
-#endif
-#endif /* XFree86Server */
break;
case 8:
-#if defined(XFree86Server)
if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
pScreenInfo->fFullScreen
? PseudoColorMask : StaticColorMask,
@@ -984,20 +943,6 @@ winInitVisualsShadowDDNL (ScreenPtr pScreen)
"failed\n");
return FALSE;
}
-#else /* XFree86Server */
- if (!fbSetVisualTypesAndMasks (pScreenInfo->dwDepth,
- pScreenInfo->fFullScreen
- ? PseudoColorMask : StaticColorMask,
- pScreenPriv->dwBitsPerRGB,
- pScreenPriv->dwRedMask,
- pScreenPriv->dwGreenMask,
- pScreenPriv->dwBlueMask))
- {
- ErrorF ("winInitVisualsShadowDDNL - fbSetVisualTypesAndMasks "
- "failed\n");
- return FALSE;
- }
-#endif /* XFree86Server */
break;
default:
diff --git a/xorg-server/hw/xwin/winshadgdi.c b/xorg-server/hw/xwin/winshadgdi.c
index 09135c702..37ef476cf 100644
--- a/xorg-server/hw/xwin/winshadgdi.c
+++ b/xorg-server/hw/xwin/winshadgdi.c
@@ -35,16 +35,6 @@
/*
- * External symbols
- */
-
-#ifdef XWIN_MULTIWINDOW
-extern DWORD g_dwCurrentThreadID;
-#endif
-extern HWND g_hDlgExit;
-
-
-/*
* Local function prototypes
*/
@@ -701,7 +691,6 @@ winInitVisualsShadowGDI (ScreenPtr pScreen)
case 24:
case 16:
case 15:
-#if defined(XFree86Server)
/* Setup the real visual */
if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
TrueColorMask,
@@ -734,42 +723,9 @@ winInitVisualsShadowGDI (ScreenPtr pScreen)
return FALSE;
}
#endif
-#else /* XFree86Server */
- /* Setup the real visual */
- if (!fbSetVisualTypesAndMasks (pScreenInfo->dwDepth,
- TrueColorMask,
- pScreenPriv->dwBitsPerRGB,
- pScreenPriv->dwRedMask,
- pScreenPriv->dwGreenMask,
- pScreenPriv->dwBlueMask))
- {
- ErrorF ("winInitVisualsShadowGDI - fbSetVisualTypesAndMasks "
- "failed for TrueColor\n");
- return FALSE;
- }
-
-#ifdef XWIN_EMULATEPSEUDO
- if (!pScreenInfo->fEmulatePseudo)
- break;
-
- /* Setup a pseudocolor visual */
- if (!fbSetVisualTypesAndMasks (8,
- PseudoColorMask,
- 8,
- 0,
- 0,
- 0))
- {
- ErrorF ("winInitVisualsShadowGDI - fbSetVisualTypesAndMasks "
- "failed for PseudoColor\n");
- return FALSE;
- }
-#endif
-#endif /* XFree86Server */
break;
case 8:
-#if defined(XFree86Server)
if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
PseudoColorMask,
pScreenPriv->dwBitsPerRGB,
@@ -782,19 +738,6 @@ winInitVisualsShadowGDI (ScreenPtr pScreen)
"failed\n");
return FALSE;
}
-#else /* XFree86Server */
- if (!fbSetVisualTypesAndMasks (pScreenInfo->dwDepth,
- PseudoColorMask,
- pScreenPriv->dwBitsPerRGB,
- pScreenPriv->dwRedMask,
- pScreenPriv->dwGreenMask,
- pScreenPriv->dwBlueMask))
- {
- ErrorF ("winInitVisualsShadowGDI - fbSetVisualTypesAndMasks "
- "failed\n");
- return FALSE;
- }
-#endif
break;
default:
diff --git a/xorg-server/hw/xwin/winvalargs.c b/xorg-server/hw/xwin/winvalargs.c
index bc56bf0b5..12e3afe4e 100644
--- a/xorg-server/hw/xwin/winvalargs.c
+++ b/xorg-server/hw/xwin/winvalargs.c
@@ -1,187 +1,180 @@
-/*
- *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 "winmsg.h"
-
-
-/*
- * References to external symbols
- */
-
-extern int g_iNumScreens;
-extern winScreenInfo * g_ScreenInfo;
-extern Bool g_fXdmcpEnabled;
-
-
-/*
- * Verify all screens have been explicitly specified
- */
-static BOOL
-isEveryScreenExplicit(void)
-{
- int i;
-
- for (i = 0; i < g_iNumScreens; i++)
- if (!g_ScreenInfo[i].fExplicitScreen)
- return FALSE;
-
- return TRUE;
-}
-
-/*
- * winValidateArgs - Look for invalid argument combinations
- */
-
-Bool
-winValidateArgs (void)
-{
- int i;
- int iMaxConsecutiveScreen = 0;
- BOOL fHasNormalScreen0 = FALSE;
- BOOL fImplicitScreenFound = FALSE;
-
- /*
- * Check for a malformed set of -screen parameters.
- * Examples of malformed parameters:
- * XWin -screen 1
- * XWin -screen 0 -screen 2
- * XWin -screen 1 -screen 2
- */
- if (!isEveryScreenExplicit())
- {
- ErrorF ("winValidateArgs - Malformed set of screen parameter(s). "
- "Screens must be specified consecutively starting with "
- "screen 0. That is, you cannot have only a screen 1, nor "
- "could you have screen 0 and screen 2. You instead must "
- "have screen 0, or screen 0 and screen 1, respectively. "
- "You can specify as many screens as you want.\n");
- return FALSE;
- }
-
- /* Loop through all screens */
- for (i = 0; i < g_iNumScreens; ++i)
- {
- /*
- * Check for any combination of
- * -multiwindow, -mwextwm, and -rootless.
- */
- {
- int iCount = 0;
-
- /* Count conflicting options */
-#ifdef XWIN_MULTIWINDOW
- if (g_ScreenInfo[i].fMultiWindow)
- ++iCount;
-#endif
-#ifdef XWIN_MULTIWINDOWEXTWM
- if (g_ScreenInfo[i].fMWExtWM)
- ++iCount;
-#endif
- if (g_ScreenInfo[i].fRootless)
- ++iCount;
-
- /* Check if the first screen is without rootless and multiwindow */
- if (iCount == 0 && i == 0)
- fHasNormalScreen0 = TRUE;
-
- /* Fail if two or more conflicting options */
- if (iCount > 1)
- {
- ErrorF ("winValidateArgs - Only one of -multiwindow, -mwextwm, "
- "and -rootless can be specific at a time.\n");
- return FALSE;
- }
- }
-
- /* Check for -multiwindow or -mwextwm and Xdmcp */
- /* allow xdmcp if screen 0 is normal. */
- if (g_fXdmcpEnabled && !fHasNormalScreen0
- && (FALSE
-#ifdef XWIN_MULTIWINDOW
- || g_ScreenInfo[i].fMultiWindow
-#endif
-#ifdef XWIN_MULTIWINDOWEXTWM
- || g_ScreenInfo[i].fMWExtWM
-#endif
- )
- )
- {
- ErrorF ("winValidateArgs - Xdmcp (-query, -broadcast, or -indirect) "
- "is invalid with -multiwindow or -mwextwm.\n");
- return FALSE;
- }
-
- /* Check for -multiwindow, -mwextwm, or -rootless and fullscreen */
- if (g_ScreenInfo[i].fFullScreen
- && (FALSE
-#ifdef XWIN_MULTIWINDOW
- || g_ScreenInfo[i].fMultiWindow
-#endif
-#ifdef XWIN_MULTIWINDOWEXTWM
- || g_ScreenInfo[i].fMWExtWM
-#endif
- || g_ScreenInfo[i].fRootless)
- )
- {
- ErrorF ("winValidateArgs - -fullscreen is invalid with "
- "-multiwindow, -mwextwm, or -rootless.\n");
- return FALSE;
- }
-
- /* Check for !fullscreen and any fullscreen-only parameters */
- if (!g_ScreenInfo[i].fFullScreen
- && (g_ScreenInfo[i].dwRefreshRate != WIN_DEFAULT_REFRESH
- || g_ScreenInfo[i].dwBPP != WIN_DEFAULT_BPP))
- {
- ErrorF ("winValidateArgs - -refresh and -depth are only valid "
- "with -fullscreen.\n");
- return FALSE;
- }
-
- /* Check for fullscreen and any non-fullscreen parameters */
- if (g_ScreenInfo[i].fFullScreen
- && (g_ScreenInfo[i].fScrollbars
- || !g_ScreenInfo[i].fDecoration
- || g_ScreenInfo[i].fLessPointer))
- {
- ErrorF ("winValidateArgs - -fullscreen is invalid with "
- "-scrollbars, -nodecoration, or -lesspointer.\n");
- return FALSE;
- }
- }
-
- winDebug ("winValidateArgs - Returning.\n");
-
- return TRUE;
-}
+/*
+ *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 "winmsg.h"
+
+
+
+
+/*
+ * Verify all screens have been explicitly specified
+ */
+static BOOL
+isEveryScreenExplicit(void)
+{
+ int i;
+
+ for (i = 0; i < g_iNumScreens; i++)
+ if (!g_ScreenInfo[i].fExplicitScreen)
+ return FALSE;
+
+ return TRUE;
+}
+
+/*
+ * winValidateArgs - Look for invalid argument combinations
+ */
+
+Bool
+winValidateArgs (void)
+{
+ int i;
+ int iMaxConsecutiveScreen = 0;
+ BOOL fHasNormalScreen0 = FALSE;
+ BOOL fImplicitScreenFound = FALSE;
+
+ /*
+ * Check for a malformed set of -screen parameters.
+ * Examples of malformed parameters:
+ * XWin -screen 1
+ * XWin -screen 0 -screen 2
+ * XWin -screen 1 -screen 2
+ */
+ if (!isEveryScreenExplicit())
+ {
+ ErrorF ("winValidateArgs - Malformed set of screen parameter(s). "
+ "Screens must be specified consecutively starting with "
+ "screen 0. That is, you cannot have only a screen 1, nor "
+ "could you have screen 0 and screen 2. You instead must "
+ "have screen 0, or screen 0 and screen 1, respectively. "
+ "You can specify as many screens as you want.\n");
+ return FALSE;
+ }
+
+ /* Loop through all screens */
+ for (i = 0; i < g_iNumScreens; ++i)
+ {
+ /*
+ * Check for any combination of
+ * -multiwindow, -mwextwm, and -rootless.
+ */
+ {
+ int iCount = 0;
+
+ /* Count conflicting options */
+#ifdef XWIN_MULTIWINDOW
+ if (g_ScreenInfo[i].fMultiWindow)
+ ++iCount;
+#endif
+#ifdef XWIN_MULTIWINDOWEXTWM
+ if (g_ScreenInfo[i].fMWExtWM)
+ ++iCount;
+#endif
+ if (g_ScreenInfo[i].fRootless)
+ ++iCount;
+
+ /* Check if the first screen is without rootless and multiwindow */
+ if (iCount == 0 && i == 0)
+ fHasNormalScreen0 = TRUE;
+
+ /* Fail if two or more conflicting options */
+ if (iCount > 1)
+ {
+ ErrorF ("winValidateArgs - Only one of -multiwindow, -mwextwm, "
+ "and -rootless can be specific at a time.\n");
+ return FALSE;
+ }
+ }
+
+ /* Check for -multiwindow or -mwextwm and Xdmcp */
+ /* allow xdmcp if screen 0 is normal. */
+ if (g_fXdmcpEnabled && !fHasNormalScreen0
+ && (FALSE
+#ifdef XWIN_MULTIWINDOW
+ || g_ScreenInfo[i].fMultiWindow
+#endif
+#ifdef XWIN_MULTIWINDOWEXTWM
+ || g_ScreenInfo[i].fMWExtWM
+#endif
+ )
+ )
+ {
+ ErrorF ("winValidateArgs - Xdmcp (-query, -broadcast, or -indirect) "
+ "is invalid with -multiwindow or -mwextwm.\n");
+ return FALSE;
+ }
+
+ /* Check for -multiwindow, -mwextwm, or -rootless and fullscreen */
+ if (g_ScreenInfo[i].fFullScreen
+ && (FALSE
+#ifdef XWIN_MULTIWINDOW
+ || g_ScreenInfo[i].fMultiWindow
+#endif
+#ifdef XWIN_MULTIWINDOWEXTWM
+ || g_ScreenInfo[i].fMWExtWM
+#endif
+ || g_ScreenInfo[i].fRootless)
+ )
+ {
+ ErrorF ("winValidateArgs - -fullscreen is invalid with "
+ "-multiwindow, -mwextwm, or -rootless.\n");
+ return FALSE;
+ }
+
+ /* Check for !fullscreen and any fullscreen-only parameters */
+ if (!g_ScreenInfo[i].fFullScreen
+ && (g_ScreenInfo[i].dwRefreshRate != WIN_DEFAULT_REFRESH
+ || g_ScreenInfo[i].dwBPP != WIN_DEFAULT_BPP))
+ {
+ ErrorF ("winValidateArgs - -refresh and -depth are only valid "
+ "with -fullscreen.\n");
+ return FALSE;
+ }
+
+ /* Check for fullscreen and any non-fullscreen parameters */
+ if (g_ScreenInfo[i].fFullScreen
+ && (g_ScreenInfo[i].fScrollbars
+ || !g_ScreenInfo[i].fDecoration
+ || g_ScreenInfo[i].fLessPointer))
+ {
+ ErrorF ("winValidateArgs - -fullscreen is invalid with "
+ "-scrollbars, -nodecoration, or -lesspointer.\n");
+ return FALSE;
+ }
+ }
+
+ winDebug ("winValidateArgs - Returning.\n");
+
+ return TRUE;
+}
diff --git a/xorg-server/hw/xwin/winwakeup.c b/xorg-server/hw/xwin/winwakeup.c
index e1eece34a..64c202fed 100644
--- a/xorg-server/hw/xwin/winwakeup.c
+++ b/xorg-server/hw/xwin/winwakeup.c
@@ -1,71 +1,61 @@
-/*
- *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"
-
-
-/*
- * References to external symbols
- */
-
-extern HWND g_hDlgDepthChange;
-extern HWND g_hDlgExit;
-extern HWND g_hDlgAbout;
-
-
-/* See Porting Layer Definition - p. 7 */
-void
-winWakeupHandler (int nScreen,
- pointer pWakeupData,
- unsigned long ulResult,
- pointer pReadmask)
-{
- MSG msg;
-
- /* Process all messages on our queue */
- while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
- {
- if ((g_hDlgDepthChange == 0
- || !IsDialogMessage (g_hDlgDepthChange, &msg))
- && (g_hDlgExit == 0
- || !IsDialogMessage (g_hDlgExit, &msg))
- && (g_hDlgAbout == 0
- || !IsDialogMessage (g_hDlgAbout, &msg)))
- {
- DispatchMessage (&msg);
- }
- }
-}
+/*
+ *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"
+
+/* See Porting Layer Definition - p. 7 */
+void
+winWakeupHandler (int nScreen,
+ pointer pWakeupData,
+ unsigned long ulResult,
+ pointer pReadmask)
+{
+ MSG msg;
+
+ /* Process all messages on our queue */
+ while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
+ {
+ if ((g_hDlgDepthChange == 0
+ || !IsDialogMessage (g_hDlgDepthChange, &msg))
+ && (g_hDlgExit == 0
+ || !IsDialogMessage (g_hDlgExit, &msg))
+ && (g_hDlgAbout == 0
+ || !IsDialogMessage (g_hDlgAbout, &msg)))
+ {
+ DispatchMessage (&msg);
+ }
+ }
+}
diff --git a/xorg-server/hw/xwin/winwin32rootless.c b/xorg-server/hw/xwin/winwin32rootless.c
index 32b124685..f638c9891 100644
--- a/xorg-server/hw/xwin/winwin32rootless.c
+++ b/xorg-server/hw/xwin/winwin32rootless.c
@@ -41,7 +41,6 @@
#include <X11/extensions/windowswmstr.h>
#include "dixevents.h"
#include "winmultiwindowclass.h"
-#include "winprefs.h"
#include <X11/Xatom.h>
diff --git a/xorg-server/hw/xwin/winwin32rootlesswndproc.c b/xorg-server/hw/xwin/winwin32rootlesswndproc.c
index 71979456d..1c3583594 100644
--- a/xorg-server/hw/xwin/winwin32rootlesswndproc.c
+++ b/xorg-server/hw/xwin/winwin32rootlesswndproc.c
@@ -1,1335 +1,1327 @@
-/*
- *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
- */
-#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 "propertyst.h"
-#include <X11/Xatom.h>
-#include "winmultiwindowclass.h"
-#include "winmsg.h"
-#include "inputstr.h"
-
-
-/*
- * Constant defines
- */
-
-#define MOUSE_ACTIVATE_DEFAULT TRUE
-#define RAISE_ON_CLICK_DEFAULT FALSE
-
-
-/*
- * Global variables
- */
-
-extern Bool g_fNoConfigureWindow;
-extern Bool g_fSoftwareCursor;
-
-
-/*
- * Local globals
- */
-
-static UINT_PTR g_uipMousePollingTimerID = 0;
-
-
-/*
- * Local function
- */
-
-DEFINE_ATOM_HELPER(AtmWindowsWmRaiseOnClick, WINDOWSWM_RAISE_ON_CLICK)
-DEFINE_ATOM_HELPER(AtmWindowsWMMouseActivate, WINDOWSWM_MOUSE_ACTIVATE)
-/* DEFINE_ATOM_HELPER(AtmWindowsWMClientWindow, WINDOWSWM_CLIENT_WINDOW) */
-
-/*
- * ConstrainSize - Taken from TWM sources - Respects hints for sizing
- */
-#define makemult(a,b) ((b==1) ? (a) : (((int)((a)/(b))) * (b)) )
-static void
-ConstrainSize (WinXSizeHints hints, int *widthp, int *heightp)
-{
- int minWidth, minHeight, maxWidth, maxHeight, xinc, yinc, delta;
- int baseWidth, baseHeight;
- int dwidth = *widthp, dheight = *heightp;
-
- if (hints.flags & PMinSize)
- {
- minWidth = hints.min_width;
- minHeight = hints.min_height;
- }
- else if (hints.flags & PBaseSize)
- {
- minWidth = hints.base_width;
- minHeight = hints.base_height;
- }
- else
- minWidth = minHeight = 1;
-
- if (hints.flags & PBaseSize)
- {
- baseWidth = hints.base_width;
- baseHeight = hints.base_height;
- }
- else if (hints.flags & PMinSize)
- {
- baseWidth = hints.min_width;
- baseHeight = hints.min_height;
- }
- else
- baseWidth = baseHeight = 0;
-
- if (hints.flags & PMaxSize)
- {
- maxWidth = hints.max_width;
- maxHeight = hints.max_height;
- }
- else
- {
- maxWidth = MAXINT;
- maxHeight = MAXINT;
- }
-
- if (hints.flags & PResizeInc)
- {
- xinc = hints.width_inc;
- yinc = hints.height_inc;
- }
- else
- xinc = yinc = 1;
-
- /*
- * First, clamp to min and max values
- */
- if (dwidth < minWidth)
- dwidth = minWidth;
- if (dheight < minHeight)
- dheight = minHeight;
-
- if (dwidth > maxWidth)
- dwidth = maxWidth;
- if (dheight > maxHeight)
- dheight = maxHeight;
-
- /*
- * Second, fit to base + N * inc
- */
- dwidth = ((dwidth - baseWidth) / xinc * xinc) + baseWidth;
- dheight = ((dheight - baseHeight) / yinc * yinc) + baseHeight;
-
- /*
- * Third, adjust for aspect ratio
- */
-
- /*
- * The math looks like this:
- *
- * minAspectX dwidth maxAspectX
- * ---------- <= ------- <= ----------
- * minAspectY dheight maxAspectY
- *
- * If that is multiplied out, then the width and height are
- * invalid in the following situations:
- *
- * minAspectX * dheight > minAspectY * dwidth
- * maxAspectX * dheight < maxAspectY * dwidth
- *
- */
-
- if (hints.flags & PAspect)
- {
- if (hints.min_aspect.x * dheight > hints.min_aspect.y * dwidth)
- {
- delta = makemult(hints.min_aspect.x * dheight / hints.min_aspect.y - dwidth, xinc);
- if (dwidth + delta <= maxWidth)
- dwidth += delta;
- else
- {
- delta = makemult(dheight - dwidth*hints.min_aspect.y/hints.min_aspect.x, yinc);
- if (dheight - delta >= minHeight)
- dheight -= delta;
- }
- }
-
- if (hints.max_aspect.x * dheight < hints.max_aspect.y * dwidth)
- {
- delta = makemult(dwidth * hints.max_aspect.y / hints.max_aspect.x - dheight, yinc);
- if (dheight + delta <= maxHeight)
- dheight += delta;
- else
- {
- delta = makemult(dwidth - hints.max_aspect.x*dheight/hints.max_aspect.y, xinc);
- if (dwidth - delta >= minWidth)
- dwidth -= delta;
- }
- }
- }
-
- /* Return computed values */
- *widthp = dwidth;
- *heightp = dheight;
-}
-#undef makemult
-
-
-
-/*
- * ValidateSizing - Ensures size request respects hints
- */
-static int
-ValidateSizing (HWND hwnd, WindowPtr pWin,
- WPARAM wParam, LPARAM lParam)
-{
- WinXSizeHints sizeHints;
- RECT *rect;
- int iWidth, iHeight, iTopBorder;
- POINT pt;
-
- /* Invalid input checking */
- if (pWin==NULL || lParam==0)
- {
- ErrorF ("Invalid input checking\n");
- return FALSE;
- }
-
- /* No size hints, no checking */
- if (!winMultiWindowGetWMNormalHints (pWin, &sizeHints))
- {
- ErrorF ("No size hints, no checking\n");
- return FALSE;
- }
-
- /* Avoid divide-by-zero */
- if (sizeHints.flags & PResizeInc)
- {
- if (sizeHints.width_inc == 0) sizeHints.width_inc = 1;
- if (sizeHints.height_inc == 0) sizeHints.height_inc = 1;
- }
-
- rect = (RECT*)lParam;
-
- iWidth = rect->right - rect->left;
- iHeight = rect->bottom - rect->top;
-
- /* Get title bar height, there must be an easier way?! */
- pt.x = pt.y = 0;
- ClientToScreen(hwnd, &pt);
- iTopBorder = pt.y - rect->top;
-
- /* Now remove size of any borders */
- iWidth -= 2 * GetSystemMetrics(SM_CXSIZEFRAME);
- iHeight -= GetSystemMetrics(SM_CYSIZEFRAME) + iTopBorder;
-
- /* Constrain the size to legal values */
- ConstrainSize (sizeHints, &iWidth, &iHeight);
-
- /* Add back the borders */
- iWidth += 2 * GetSystemMetrics(SM_CXSIZEFRAME);
- iHeight += GetSystemMetrics(SM_CYSIZEFRAME) + iTopBorder;
-
- /* Adjust size according to where we're dragging from */
- switch(wParam) {
- case WMSZ_TOP:
- case WMSZ_TOPRIGHT:
- case WMSZ_BOTTOM:
- case WMSZ_BOTTOMRIGHT:
- case WMSZ_RIGHT:
- rect->right = rect->left + iWidth;
- break;
- default:
- rect->left = rect->right - iWidth;
- break;
- }
- switch(wParam) {
- case WMSZ_BOTTOM:
- case WMSZ_BOTTOMRIGHT:
- case WMSZ_BOTTOMLEFT:
- case WMSZ_RIGHT:
- case WMSZ_LEFT:
- rect->bottom = rect->top + iHeight;
- break;
- default:
- rect->top = rect->bottom - iHeight;
- break;
- }
- return TRUE;
-}
-
-
-/*
- * IsRaiseOnClick
- */
-
-static Bool
-IsRaiseOnClick (WindowPtr pWin)
-{
-
- struct _Window *pwin;
- struct _Property *prop;
- /* XXX We're getting inputInfo.poniter here, but this might be really wrong.
- * Which pointer's current window do we want? */
- WindowPtr pRoot = GetCurrentRootWindow (inputInfo.pointer);
-
- if (!pWin)
- {
- ErrorF ("IsRaiseOnClick - no prop use default value:%d\n",
- RAISE_ON_CLICK_DEFAULT);
- return RAISE_ON_CLICK_DEFAULT;
- }
-
- pwin = (struct _Window*) pWin;
-
- if (pwin->optional)
- prop = (struct _Property *) pwin->optional->userProps;
- else
- prop = NULL;
-
- while (prop)
- {
- if (prop->propertyName == AtmWindowsWmRaiseOnClick ()
- && prop->type == XA_INTEGER
- && prop->format == 32)
- {
- return *(int*)prop->data;
- }
- else
- prop = prop->next;
- }
-
- if (pWin != pRoot)
- {
- return IsRaiseOnClick (pRoot);
- }
- else
- {
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("IsRaiseOnClick - no prop use default value:%d\n",
- RAISE_ON_CLICK_DEFAULT);
-#endif
- return RAISE_ON_CLICK_DEFAULT;
- }
-}
-
-
-/*
- * IsMouseActive
- */
-
-static Bool
-IsMouseActive (WindowPtr pWin)
-{
-
- struct _Window *pwin;
- struct _Property *prop;
- /* XXX We're getting inputInfo.poniter here, but this might be really wrong.
- * Which pointer's current window do we want? */
- WindowPtr pRoot = GetCurrentRootWindow (inputInfo.pointer);
-
- if (!pWin)
- {
- ErrorF ("IsMouseActive - pWin was NULL use default value:%d\n",
- MOUSE_ACTIVATE_DEFAULT);
- return MOUSE_ACTIVATE_DEFAULT;
- }
-
- pwin = (struct _Window*) pWin;
-
- if (pwin->optional)
- prop = (struct _Property *) pwin->optional->userProps;
- else
- prop = NULL;
-
- while (prop)
- {
- if (prop->propertyName == AtmWindowsWMMouseActivate ()
- && prop->type == XA_INTEGER
- && prop->format == 32)
- {
- return *(int*)prop->data;
- }
- else
- prop = prop->next;
- }
-
- if (pWin != pRoot)
- {
- return IsMouseActive (pRoot);
- }
- else
- {
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("IsMouseActive - no prop use default value:%d\n",
- MOUSE_ACTIVATE_DEFAULT);
-#endif
- return MOUSE_ACTIVATE_DEFAULT;
- }
-}
-
-
-/*
- * winMWExtWMWindowProc - Window procedure
- */
-
-LRESULT CALLBACK
-winMWExtWMWindowProc (HWND hwnd, UINT message,
- WPARAM wParam, LPARAM lParam)
-{
- WindowPtr pWin = NULL;
- win32RootlessWindowPtr pRLWinPriv = NULL;
- ScreenPtr pScreen = NULL;
- winPrivScreenPtr pScreenPriv = NULL;
- winScreenInfo *pScreenInfo = NULL;
- HWND hwndScreen = NULL;
- POINT ptMouse;
- static Bool s_fTracking = FALSE;
- HDC hdcUpdate;
- PAINTSTRUCT ps;
- LPWINDOWPOS pWinPos = NULL;
- RECT rcClient;
- winWMMessageRec wmMsg;
- Bool fWMMsgInitialized = FALSE;
-
- /* Check if the Windows window property for our X window pointer is valid */
- if ((pRLWinPriv = (win32RootlessWindowPtr)GetProp (hwnd, WIN_WINDOW_PROP)) != NULL)
- {
- pWin = pRLWinPriv->pFrame->win;
- pScreen = pWin->drawable.pScreen;
- if (pScreen) pScreenPriv = winGetScreenPriv(pScreen);
- if (pScreenPriv) pScreenInfo = pScreenPriv->pScreenInfo;
- if (pScreenPriv) hwndScreen = pScreenPriv->hwndScreen;
-
- wmMsg.msg = 0;
- wmMsg.hwndWindow = hwnd;
- wmMsg.iWindow = (Window)pWin->drawable.id;
-
- wmMsg.iX = pRLWinPriv->pFrame->x;
- wmMsg.iY = pRLWinPriv->pFrame->y;
- wmMsg.iWidth = pRLWinPriv->pFrame->width;
- wmMsg.iHeight = pRLWinPriv->pFrame->height;
-
- fWMMsgInitialized = TRUE;
- winDebugWin32Message("winMWExtWMWindowProc", hwnd, message, wParam, lParam);
-
- winDebug ("\thWnd %08X\n", hwnd);
- winDebug ("\tpScreenPriv %08X\n", pScreenPriv);
- winDebug ("\tpScreenInfo %08X\n", pScreenInfo);
- winDebug ("\thwndScreen %08X\n", hwndScreen);
- winDebug ("winMWExtWMWindowProc (%08x) %08x %08x %08x\n",
- pRLWinPriv, message, wParam, lParam);
- }
- /* Branch on message type */
- switch (message)
- {
- case WM_CREATE:
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_CREATE\n");
-#endif
- /* */
- SetProp (hwnd,
- WIN_WINDOW_PROP,
- (HANDLE)((LPCREATESTRUCT) lParam)->lpCreateParams);
- return 0;
-
- case WM_CLOSE:
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_CLOSE %d\n", pRLWinPriv->fClose);
-#endif
- /* Tell window-manager to close window */
- if (pRLWinPriv->fClose)
- {
- DestroyWindow (hwnd);
- }
- else
- {
- if (winIsInternalWMRunning(pScreenInfo))
- {
- /* Tell our Window Manager thread to kill the window */
- wmMsg.msg = WM_WM_KILL;
- if (fWMMsgInitialized)
- winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
- }
- winWindowsWMSendEvent(WindowsWMControllerNotify,
- WindowsWMControllerNotifyMask,
- 1,
- WindowsWMCloseWindow,
- pWin->drawable.id,
- 0, 0, 0, 0);
- }
- return 0;
-
- case WM_DESTROY:
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_DESTROY\n");
-#endif
- /* Free the shaodw DC; which allows the bitmap to be freed */
- DeleteDC (pRLWinPriv->hdcShadow);
- pRLWinPriv->hdcShadow = NULL;
-
- /* Free the shadow bitmap */
- DeleteObject (pRLWinPriv->hbmpShadow);
- pRLWinPriv->hbmpShadow = NULL;
-
- /* Free the screen DC */
- ReleaseDC (pRLWinPriv->hWnd, pRLWinPriv->hdcScreen);
- pRLWinPriv->hdcScreen = NULL;
-
- /* Free shadow buffer info header */
- free (pRLWinPriv->pbmihShadow);
- pRLWinPriv->pbmihShadow = NULL;
-
- pRLWinPriv->fResized = FALSE;
- pRLWinPriv->pfb = NULL;
- free (pRLWinPriv);
- RemoveProp (hwnd, WIN_WINDOW_PROP);
- break;
-
- case WM_MOUSEMOVE:
-#if CYGMULTIWINDOW_DEBUG && 0
- winDebug ("winMWExtWMWindowProc - WM_MOUSEMOVE\n");
-#endif
- /* Unpack the client area mouse coordinates */
- ptMouse.x = GET_X_LPARAM(lParam);
- ptMouse.y = GET_Y_LPARAM(lParam);
-
- /* Translate the client area mouse coordinates to screen coordinates */
- ClientToScreen (hwnd, &ptMouse);
-
- /* Screen Coords from (-X, -Y) -> Root Window (0, 0) */
- ptMouse.x -= GetSystemMetrics (SM_XVIRTUALSCREEN);
- ptMouse.y -= GetSystemMetrics (SM_YVIRTUALSCREEN);
-
- /* We can't do anything without privates */
- if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
- break;
-
- /* Has the mouse pointer crossed screens? */
- if (pScreen != miPointerGetScreen(inputInfo.pointer))
- miPointerSetScreen (inputInfo.pointer, pScreenInfo->dwScreen,
- ptMouse.x - pScreenInfo->dwXOffset,
- ptMouse.y - pScreenInfo->dwYOffset);
-
- /* Are we tracking yet? */
- if (!s_fTracking)
- {
- TRACKMOUSEEVENT tme;
-
- /* Setup data structure */
- ZeroMemory (&tme, sizeof (tme));
- tme.cbSize = sizeof (tme);
- tme.dwFlags = TME_LEAVE;
- tme.hwndTrack = hwnd;
-
- /* Call the tracking function */
- if (!(*g_fpTrackMouseEvent) (&tme))
- ErrorF ("winMWExtWMWindowProc - _TrackMouseEvent failed\n");
-
- /* Flag that we are tracking now */
- s_fTracking = TRUE;
- }
-
- /* Kill the timer used to poll mouse events */
- if (g_uipMousePollingTimerID != 0)
- {
- KillTimer (pScreenPriv->hwndScreen, WIN_POLLING_MOUSE_TIMER_ID);
- g_uipMousePollingTimerID = 0;
- }
-
- /* Deliver absolute cursor position to X Server */
- winEnqueueMotion(ptMouse.x - pScreenInfo->dwXOffset,
- ptMouse.y - pScreenInfo->dwYOffset);
-
- return 0;
-
- case WM_NCMOUSEMOVE:
-#if CYGMULTIWINDOW_DEBUG && 0
- winDebug ("winMWExtWMWindowProc - WM_NCMOUSEMOVE\n");
-#endif
- /*
- * We break instead of returning 0 since we need to call
- * DefWindowProc to get the mouse cursor changes
- * and min/max/close button highlighting in Windows XP.
- * The Platform SDK says that you should return 0 if you
- * process this message, but it fails to mention that you
- * will give up any default functionality if you do return 0.
- */
-
- /* We can't do anything without privates */
- if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
- break;
-
- /*
- * Timer to poll mouse events. This is needed to make
- * programs like xeyes follow the mouse properly.
- */
- if (g_uipMousePollingTimerID == 0)
- g_uipMousePollingTimerID = SetTimer (pScreenPriv->hwndScreen,
- WIN_POLLING_MOUSE_TIMER_ID,
- MOUSE_POLLING_INTERVAL,
- NULL);
- break;
-
- case WM_MOUSELEAVE:
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_MOUSELEAVE\n");
-#endif
- /* Mouse has left our client area */
-
- /* Flag that we are no longer tracking */
- s_fTracking = FALSE;
-
- /*
- * Timer to poll mouse events. This is needed to make
- * programs like xeyes follow the mouse properly.
- */
- if (g_uipMousePollingTimerID == 0)
- g_uipMousePollingTimerID = SetTimer (pScreenPriv->hwndScreen,
- WIN_POLLING_MOUSE_TIMER_ID,
- MOUSE_POLLING_INTERVAL,
- NULL);
- return 0;
-
- case WM_LBUTTONDBLCLK:
- case WM_LBUTTONDOWN:
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_LBUTTONDBLCLK\n");
-#endif
- if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
- break;
- SetCapture (hwnd);
- return winMouseButtonsHandle (pScreen, ButtonPress, Button1, wParam);
-
- case WM_LBUTTONUP:
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_LBUTTONUP\n");
-#endif
- if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
- break;
- ReleaseCapture ();
- return winMouseButtonsHandle (pScreen, ButtonRelease, Button1, wParam);
-
- case WM_MBUTTONDBLCLK:
- case WM_MBUTTONDOWN:
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_MBUTTONDBLCLK\n");
-#endif
- if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
- break;
- SetCapture (hwnd);
- return winMouseButtonsHandle (pScreen, ButtonPress, Button2, wParam);
-
- case WM_MBUTTONUP:
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_MBUTTONUP\n");
-#endif
- if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
- break;
- ReleaseCapture ();
- return winMouseButtonsHandle (pScreen, ButtonRelease, Button2, wParam);
-
- case WM_RBUTTONDBLCLK:
- case WM_RBUTTONDOWN:
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_RBUTTONDBLCLK\n");
-#endif
- if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
- break;
- SetCapture (hwnd);
- return winMouseButtonsHandle (pScreen, ButtonPress, Button3, wParam);
-
- case WM_RBUTTONUP:
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_RBUTTONUP\n");
-#endif
- if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
- break;
- ReleaseCapture ();
- return winMouseButtonsHandle (pScreen, ButtonRelease, Button3, wParam);
-
- case WM_XBUTTONDBLCLK:
- case WM_XBUTTONDOWN:
- if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
- break;
- SetCapture (hwnd);
- return winMouseButtonsHandle (pScreen, ButtonPress, HIWORD(wParam) + 5, wParam);
- case WM_XBUTTONUP:
- if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
- break;
- ReleaseCapture ();
- return winMouseButtonsHandle (pScreen, ButtonRelease, HIWORD(wParam) + 5, wParam);
-
- case WM_MOUSEWHEEL:
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_MOUSEWHEEL\n");
-#endif
-
- /* Pass the message to the root window */
- SendMessage (hwndScreen, message, wParam, lParam);
- return 0;
-
- case WM_MOUSEACTIVATE:
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_MOUSEACTIVATE\n");
-#endif
-#if 1
- /* Check if this window needs to be made active when clicked */
- if (winIsInternalWMRunning(pScreenInfo) && pWin->overrideRedirect)
- {
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_MOUSEACTIVATE - "
- "MA_NOACTIVATE\n");
-#endif
-
- /* */
- return MA_NOACTIVATE;
- }
-#endif
- if (!winIsInternalWMRunning(pScreenInfo) && !IsMouseActive (pWin))
- return MA_NOACTIVATE;
-
- break;
-
- case WM_KILLFOCUS:
- /* Pop any pressed keys since we are losing keyboard focus */
- winKeybdReleaseKeys ();
- return 0;
-
- case WM_SYSDEADCHAR:
- case WM_DEADCHAR:
- /*
- * NOTE: We do nothing with WM_*CHAR messages,
- * nor does the root window, so we can just toss these messages.
- */
- return 0;
-
- case WM_SYSKEYDOWN:
- case WM_KEYDOWN:
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_*KEYDOWN\n");
-#endif
-
- /*
- * Don't pass Alt-F4 key combo to root window,
- * let Windows translate to WM_CLOSE and close this top-level window.
- *
- * NOTE: We purposely don't check the fUseWinKillKey setting because
- * it should only apply to the key handling for the root window,
- * not for top-level window-manager windows.
- *
- * ALSO NOTE: We do pass Ctrl-Alt-Backspace to the root window
- * because that is a key combo that no X app should be expecting to
- * receive, since it has historically been used to shutdown the X server.
- * Passing Ctrl-Alt-Backspace to the root window preserves that
- * behavior, assuming that -unixkill has been passed as a parameter.
- */
- if (wParam == VK_F4 && (GetKeyState (VK_MENU) & 0x8000))
- break;
-
- /* Pass the message to the root window */
- SendMessage (hwndScreen, message, wParam, lParam);
- return 0;
-
- case WM_SYSKEYUP:
- case WM_KEYUP:
-
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_*KEYUP\n");
-#endif
-
- /* Pass the message to the root window */
- SendMessage (hwndScreen, message, wParam, lParam);
- return 0;
-
- case WM_HOTKEY:
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_HOTKEY\n");
-#endif
-
- /* Pass the message to the root window */
- SendMessage (hwndScreen, message, wParam, lParam);
- return 0;
-
- case WM_ERASEBKGND:
- winDebug ("winMWExtWMWindowProc - WM_ERASEBKGND\n");
- /*
- * Pretend that we did erase the background but we don't care,
- * since we repaint the entire region anyhow
- * This avoids some flickering when resizing.
- */
- return TRUE;
-
- case WM_PAINT:
-
- /* BeginPaint gives us an hdc that clips to the invalidated region */
- hdcUpdate = BeginPaint (hwnd, &ps);
-
- /* Try to copy from the shadow buffer */
- if (!BitBlt (hdcUpdate,
- ps.rcPaint.left, ps.rcPaint.top,
- ps.rcPaint.right - ps.rcPaint.left,
- ps.rcPaint.bottom - ps.rcPaint.top,
- pRLWinPriv->hdcShadow,
- ps.rcPaint.left, ps.rcPaint.top,
- SRCCOPY))
- {
- 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 ("winMWExtWMWindowProc - BitBlt failed: %s\n",
- (LPSTR)lpMsgBuf);
- LocalFree (lpMsgBuf);
- }
-
- /* EndPaint frees the DC */
- EndPaint (hwnd, &ps);
- break;
-
- case WM_ACTIVATE:
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_ACTIVATE\n");
-#endif
- if (LOWORD(wParam) != WA_INACTIVE)
- {
- if (winIsInternalWMRunning(pScreenInfo))
- {
-#if 0
- /* Raise the window to the top in Z order */
- wmMsg.msg = WM_WM_RAISE;
- if (fWMMsgInitialized)
- winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
-#endif
- /* Tell our Window Manager thread to activate the window */
- wmMsg.msg = WM_WM_ACTIVATE;
- if (fWMMsgInitialized)
- if (!pWin || !pWin->overrideRedirect) /* for OOo menus */
- winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
- }
- winWindowsWMSendEvent(WindowsWMControllerNotify,
- WindowsWMControllerNotifyMask,
- 1,
- WindowsWMActivateWindow,
- pWin->drawable.id,
- 0, 0,
- 0, 0);
- }
- return 0;
-
-#if 1
- case WM_WINDOWPOSCHANGING:
- pWinPos = (LPWINDOWPOS)lParam;
- if (!(pWinPos->flags & SWP_NOZORDER))
- {
- if (pRLWinPriv->fRestackingNow || pScreenPriv->fRestacking)
- {
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("Win %08x is now restacking.\n", (unsigned int)pRLWinPriv);
-#endif
- break;
- }
-
- if (winIsInternalWMRunning(pScreenInfo) || IsRaiseOnClick (pWin))
- {
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("Win %08x has WINDOWSWM_RAISE_ON_CLICK.\n", (unsigned int)pRLWinPriv);
-#endif
- break;
- }
-
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("Win %08x forbid to change z order (%08x).\n",
- (unsigned int)pRLWinPriv, (unsigned int)pWinPos->hwndInsertAfter);
-#endif
- pWinPos->flags |= SWP_NOZORDER;
- }
- break;
-#endif
-
- case WM_MOVE:
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_MOVE - %d ms\n",
- (unsigned int)GetTickCount ());
-#endif
- if (g_fNoConfigureWindow) break;
-#if 0
- /* Bail if Windows window is not actually moving */
- if (pRLWinPriv->dwX == (short) LOWORD(lParam)
- && pRLWinPriv->dwY == (short) HIWORD(lParam))
- break;
-
- /* Also bail if we're maximizing, we'll do the whole thing in WM_SIZE */
- {
- WINDOWPLACEMENT windPlace;
- windPlace.length = sizeof (WINDOWPLACEMENT);
-
- /* Get current window placement */
- GetWindowPlacement (hwnd, &windPlace);
-
- /* Bail if maximizing */
- if (windPlace.showCmd == SW_MAXIMIZE
- || windPlace.showCmd == SW_SHOWMAXIMIZED)
- break;
- }
-#endif
-
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("\t(%d, %d)\n", (short) LOWORD(lParam), (short) HIWORD(lParam));
-#endif
- if (!pRLWinPriv->fMovingOrSizing)
- {
- if (winIsInternalWMRunning(pScreenInfo))
- winAdjustXWindow (pWin, hwnd);
-
- winMWExtWMMoveXWindow (pWin,
- (LOWORD(lParam) - wBorderWidth (pWin)
- - GetSystemMetrics (SM_XVIRTUALSCREEN)),
- (HIWORD(lParam) - wBorderWidth (pWin)
- - GetSystemMetrics (SM_YVIRTUALSCREEN)));
- }
- return 0;
-
- case WM_SHOWWINDOW:
-#if CYGMULTIWINDOW_DEBUG || TRUE
- winDebug ("winMWExtWMWindowProc - WM_SHOWWINDOW - %d ms\n",
- (unsigned int)GetTickCount ());
-#endif
- /* Bail out if the window is being hidden */
- if (!wParam)
- return 0;
-
- if (!pScreenInfo->fInternalWM)//XXXX
- return 0;
-
- winMWExtWMUpdateWindowDecoration (pRLWinPriv, pScreenInfo);
-
- if (winIsInternalWMRunning(pScreenInfo))
- {
-#if CYGMULTIWINDOW_DEBUG || TRUE
- winDebug ("\tMapWindow\n");
-#endif
- /* Tell X to map the window */
- MapWindow (pWin, wClient(pWin));
-
- if (!pRLWinPriv->pFrame->win->overrideRedirect)
- /* Bring the Windows window to the foreground */
- SetForegroundWindow (hwnd);
-
- /* Setup the Window Manager message */
- wmMsg.msg = WM_WM_MAP;
- wmMsg.iWidth = pRLWinPriv->pFrame->width;
- wmMsg.iHeight = pRLWinPriv->pFrame->height;
-
- /* Tell our Window Manager thread to map the window */
- if (fWMMsgInitialized)
- winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
- }
- break;
-
- case WM_SIZING:
- /* Need to legalize the size according to WM_NORMAL_HINTS */
- /* for applications like xterm */
- return ValidateSizing (hwnd, pWin, wParam, lParam);
-
- case WM_WINDOWPOSCHANGED:
- {
- pWinPos = (LPWINDOWPOS) lParam;
-#if CYGMULTIWINDOW_DEBUG
- winDebug("winMWExtWMWindowProc - WM_WINDOWPOSCHANGED\n");
- winDebug("\tflags: %s%s%s%s%s%s%s%s%s%s%s%s\n",
- (pWinPos->flags & SWP_DRAWFRAME)?"SWP_DRAWFRAME ":"",
- (pWinPos->flags & SWP_FRAMECHANGED)?"SWP_FRAMECHANGED ":"",
- (pWinPos->flags & SWP_HIDEWINDOW)?"SWP_HIDEWINDOW ":"",
- (pWinPos->flags & SWP_NOACTIVATE)?"SWP_NOACTIVATE ":"",
- (pWinPos->flags & SWP_NOCOPYBITS)?"SWP_NOCOPYBITS ":"",
- (pWinPos->flags & SWP_NOMOVE)?"SWP_NOMOVE ":"",
- (pWinPos->flags & SWP_NOOWNERZORDER)?"SWP_NOOWNERZORDER ":"",
- (pWinPos->flags & SWP_NOSIZE)?"SWP_NOSIZE ":"",
- (pWinPos->flags & SWP_NOREDRAW)?"SWP_NOREDRAW ":"",
- (pWinPos->flags & SWP_NOSENDCHANGING)?"SWP_NOSENDCHANGING ":"",
- (pWinPos->flags & SWP_NOZORDER)?"SWP_NOZORDER ":"",
- (pWinPos->flags & SWP_SHOWWINDOW)?"SWP_SHOWWINDOW ":"");
- winDebug("\tno_configure: %s\n", (g_fNoConfigureWindow?"Yes":"No"));
- winDebug("\textend: (%d, %d, %d, %d)\n",
- pWinPos->x, pWinPos->y, pWinPos->cx, pWinPos->cy);
-
-#endif
- if (pWinPos->flags & SWP_HIDEWINDOW) break;
-
- /* Reorder if window z order was changed */
- if ((pScreenPriv != NULL)
- && !(pWinPos->flags & SWP_NOZORDER)
- && !(pWinPos->flags & SWP_SHOWWINDOW)
- && winIsInternalWMRunning(pScreenInfo))
- {
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("\twindow z order was changed\n");
-#endif
- if (pWinPos->hwndInsertAfter == HWND_TOP
- ||pWinPos->hwndInsertAfter == HWND_TOPMOST
- ||pWinPos->hwndInsertAfter == HWND_NOTOPMOST)
- {
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("\traise to top\n");
-#endif
- /* Raise the window to the top in Z order */
- wmMsg.msg = WM_WM_RAISE;
- if (fWMMsgInitialized)
- winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
- }
-#if 1
- else if (pWinPos->hwndInsertAfter == HWND_BOTTOM)
- {
- }
- else
- {
- /* Check if this window is top of X windows. */
- HWND hWndAbove = NULL;
- DWORD dwCurrentProcessID = GetCurrentProcessId ();
- DWORD dwWindowProcessID = 0;
-
- for (hWndAbove = pWinPos->hwndInsertAfter;
- hWndAbove != NULL;
- hWndAbove = GetNextWindow (hWndAbove, GW_HWNDPREV))
- {
- /* Ignore other XWin process's window */
- GetWindowThreadProcessId (hWndAbove, &dwWindowProcessID);
-
- if ((dwWindowProcessID == dwCurrentProcessID)
- && GetProp (hWndAbove, WIN_WINDOW_PROP)
- && !IsWindowVisible (hWndAbove)
- && !IsIconic (hWndAbove) ) /* ignore minimized windows */
- break;
- }
- /* If this is top of X windows in Windows stack,
- raise it in X stack. */
- if (hWndAbove == NULL)
- {
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("\traise to top\n");
-#endif
- /* Raise the window to the top in Z order */
- wmMsg.msg = WM_WM_RAISE;
- if (fWMMsgInitialized)
- winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
- }
- }
-#endif
- }
-
- if (!(pWinPos->flags & SWP_NOSIZE)) {
- if (IsIconic(hwnd)){
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("\tIconic -> MINIMIZED\n");
-#endif
- if (winIsInternalWMRunning(pScreenInfo))
- {
- /* Raise the window to the top in Z order */
- wmMsg.msg = WM_WM_LOWER;
- if (fWMMsgInitialized)
- winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
- }
- winWindowsWMSendEvent(WindowsWMControllerNotify,
- WindowsWMControllerNotifyMask,
- 1,
- WindowsWMMinimizeWindow,
- pWin->drawable.id,
- 0, 0, 0, 0);
- } else if (IsZoomed(hwnd)){
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("\tZoomed -> MAXIMIZED\n");
-#endif
- winWindowsWMSendEvent(WindowsWMControllerNotify,
- WindowsWMControllerNotifyMask,
- 1,
- WindowsWMMaximizeWindow,
- pWin->drawable.id,
- 0, 0, 0, 0);
- } else {
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("\tnone -> RESTORED\n");
-#endif
- winWindowsWMSendEvent(WindowsWMControllerNotify,
- WindowsWMControllerNotifyMask,
- 1,
- WindowsWMRestoreWindow,
- pWin->drawable.id,
- 0, 0, 0, 0);
- }
- }
- if (!g_fNoConfigureWindow ) {
-
- if (!pRLWinPriv->fMovingOrSizing
- /*&& (pWinPos->flags & SWP_SHOWWINDOW)*/) {
- GetClientRect (hwnd, &rcClient);
- MapWindowPoints (hwnd, HWND_DESKTOP, (LPPOINT)&rcClient, 2);
-
- if (!(pWinPos->flags & SWP_NOMOVE)
- &&!(pWinPos->flags & SWP_NOSIZE)) {
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("\tmove & resize\n");
-#endif
- if (winIsInternalWMRunning(pScreenInfo))
- winAdjustXWindow (pWin, hwnd);
-
- winMWExtWMMoveResizeXWindow (pWin,
- rcClient.left - wBorderWidth (pWin)
- - GetSystemMetrics (SM_XVIRTUALSCREEN),
- rcClient.top - wBorderWidth (pWin)
- - GetSystemMetrics (SM_YVIRTUALSCREEN),
- rcClient.right - rcClient.left
- - wBorderWidth (pWin)*2,
- rcClient.bottom - rcClient.top
- - wBorderWidth (pWin)*2);
- } else if (!(pWinPos->flags & SWP_NOMOVE)) {
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("\tmove\n");
-#endif
- if (winIsInternalWMRunning(pScreenInfo))
- winAdjustXWindow (pWin, hwnd);
-
- winMWExtWMMoveResizeXWindow (pWin,
- rcClient.left - wBorderWidth (pWin)
- - GetSystemMetrics (SM_XVIRTUALSCREEN),
- rcClient.top - wBorderWidth (pWin)
- - GetSystemMetrics (SM_YVIRTUALSCREEN),
- rcClient.right - rcClient.left
- - wBorderWidth (pWin)*2,
- rcClient.bottom - rcClient.top
- - wBorderWidth (pWin)*2);
- } else if (!(pWinPos->flags & SWP_NOMOVE)) {
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("\tmove\n");
-#endif
- if (winIsInternalWMRunning(pScreenInfo))
- winAdjustXWindow (pWin, hwnd);
-
- winMWExtWMMoveXWindow (pWin,
- rcClient.left - wBorderWidth (pWin)
- - GetSystemMetrics (SM_XVIRTUALSCREEN),
- rcClient.top - wBorderWidth (pWin)
- - GetSystemMetrics (SM_YVIRTUALSCREEN));
- } else if (!(pWinPos->flags & SWP_NOSIZE)) {
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("\tresize\n");
-#endif
- if (winIsInternalWMRunning(pScreenInfo))
- winAdjustXWindow (pWin, hwnd);
-
- winMWExtWMResizeXWindow (pWin,
- rcClient.right - rcClient.left
- - wBorderWidth (pWin)*2,
- rcClient.bottom - rcClient.top
- - wBorderWidth (pWin)*2);
- }
- }
- }
- }
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_WINDOWPOSCHANGED - done.\n");
-#endif
- return 0;
-
- case WM_SIZE:
- /* see dix/window.c */
- /* FIXME: Maximize/Restore? */
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_SIZE - %d ms\n",
- (unsigned int)GetTickCount ());
-#endif
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("\t(%d, %d) %d\n", (short) LOWORD(lParam), (short) HIWORD(lParam), g_fNoConfigureWindow);
-#endif
- if (g_fNoConfigureWindow) break;
-
- /* Branch on type of resizing occurring */
- switch (wParam)
- {
- case SIZE_MINIMIZED:
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("\tSIZE_MINIMIZED\n");
-#endif
- if (winIsInternalWMRunning(pScreenInfo))
- {
- /* Raise the window to the top in Z order */
- wmMsg.msg = WM_WM_LOWER;
- if (fWMMsgInitialized)
- winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
- }
- winWindowsWMSendEvent(WindowsWMControllerNotify,
- WindowsWMControllerNotifyMask,
- 1,
- WindowsWMMinimizeWindow,
- pWin->drawable.id,
- 0, 0,
- LOWORD(lParam), HIWORD(lParam));
- break;
-
- case SIZE_RESTORED:
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("\tSIZE_RESTORED\n");
-#endif
- winWindowsWMSendEvent(WindowsWMControllerNotify,
- WindowsWMControllerNotifyMask,
- 1,
- WindowsWMRestoreWindow,
- pWin->drawable.id,
- 0, 0,
- LOWORD(lParam), HIWORD(lParam));
- break;
-
- case SIZE_MAXIMIZED:
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("\tSIZE_MAXIMIZED\n");
-#endif
- winWindowsWMSendEvent(WindowsWMControllerNotify,
- WindowsWMControllerNotifyMask,
- 1,
- WindowsWMMaximizeWindow,
- pWin->drawable.id,
- 0, 0,
- LOWORD(lParam), HIWORD(lParam));
- break;
- }
-
- /* Perform the resize and notify the X client */
- if (!pRLWinPriv->fMovingOrSizing)
- {
- if (winIsInternalWMRunning(pScreenInfo))
- winAdjustXWindow (pWin, hwnd);
-
- winMWExtWMResizeXWindow (pWin,
- (short) LOWORD(lParam)
- - wBorderWidth (pWin)*2,
- (short) HIWORD(lParam)
- - wBorderWidth (pWin)*2);
- }
- break;
-
- case WM_ACTIVATEAPP:
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_ACTIVATEAPP - %d ms\n",
- (unsigned int)GetTickCount ());
-#endif
- if (wParam)
- {
- if (winIsInternalWMRunning(pScreenInfo))
- {
- }
- else
- {
- }
- winWindowsWMSendEvent(WindowsWMActivationNotify,
- WindowsWMActivationNotifyMask,
- 1,
- WindowsWMIsActive,
- pWin->drawable.id,
- 0, 0,
- 0, 0);
- }
- else
- {
- winWindowsWMSendEvent(WindowsWMActivationNotify,
- WindowsWMActivationNotifyMask,
- 1,
- WindowsWMIsInactive,
- pWin->drawable.id,
- 0, 0,
- 0, 0);
- }
- break;
-
- case WM_SETCURSOR:
- if (LOWORD(lParam) == HTCLIENT)
- {
- if (!g_fSoftwareCursor) SetCursor (pScreenPriv->cursor.handle);
- return TRUE;
- }
- break;
-
- case WM_ENTERSIZEMOVE:
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_ENTERSIZEMOVE - %d ms\n",
- (unsigned int)GetTickCount ());
-#endif
- pRLWinPriv->fMovingOrSizing = TRUE;
- break;
-
- case WM_EXITSIZEMOVE:
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_EXITSIZEMOVE - %d ms\n",
- (unsigned int)GetTickCount ());
-#endif
- pRLWinPriv->fMovingOrSizing = FALSE;
-
- GetClientRect (hwnd, &rcClient);
-
- MapWindowPoints (hwnd, HWND_DESKTOP, (LPPOINT)&rcClient, 2);
-
- if (winIsInternalWMRunning(pScreenInfo))
- winAdjustXWindow (pWin, hwnd);
-
- winMWExtWMMoveResizeXWindow (pWin,
- rcClient.left - wBorderWidth (pWin)
- - GetSystemMetrics (SM_XVIRTUALSCREEN),
- rcClient.top - wBorderWidth (pWin)
- - GetSystemMetrics (SM_YVIRTUALSCREEN),
- rcClient.right - rcClient.left
- - wBorderWidth (pWin)*2,
- rcClient.bottom - rcClient.top
- - wBorderWidth (pWin)*2);
- break;
-
- case WM_MANAGE:
- winDebug ("winMWExtWMWindowProc - WM_MANAGE\n");
- break;
-
- case WM_UNMANAGE:
- winDebug ("winMWExtWMWindowProc - WM_UNMANAGE\n");
- break;
-
- default:
- break;
- }
-
- return DefWindowProc (hwnd, message, wParam, lParam);
-}
+/*
+ *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
+ */
+#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 "propertyst.h"
+#include <X11/Xatom.h>
+#include "winmultiwindowclass.h"
+#include "winmsg.h"
+#include "inputstr.h"
+
+
+/*
+ * Constant defines
+ */
+
+#define MOUSE_ACTIVATE_DEFAULT TRUE
+#define RAISE_ON_CLICK_DEFAULT FALSE
+
+
+/*
+ * Local globals
+ */
+
+static UINT_PTR g_uipMousePollingTimerID = 0;
+
+
+/*
+ * Local function
+ */
+
+DEFINE_ATOM_HELPER(AtmWindowsWmRaiseOnClick, WINDOWSWM_RAISE_ON_CLICK)
+DEFINE_ATOM_HELPER(AtmWindowsWMMouseActivate, WINDOWSWM_MOUSE_ACTIVATE)
+/* DEFINE_ATOM_HELPER(AtmWindowsWMClientWindow, WINDOWSWM_CLIENT_WINDOW) */
+
+/*
+ * ConstrainSize - Taken from TWM sources - Respects hints for sizing
+ */
+#define makemult(a,b) ((b==1) ? (a) : (((int)((a)/(b))) * (b)) )
+static void
+ConstrainSize (WinXSizeHints hints, int *widthp, int *heightp)
+{
+ int minWidth, minHeight, maxWidth, maxHeight, xinc, yinc, delta;
+ int baseWidth, baseHeight;
+ int dwidth = *widthp, dheight = *heightp;
+
+ if (hints.flags & PMinSize)
+ {
+ minWidth = hints.min_width;
+ minHeight = hints.min_height;
+ }
+ else if (hints.flags & PBaseSize)
+ {
+ minWidth = hints.base_width;
+ minHeight = hints.base_height;
+ }
+ else
+ minWidth = minHeight = 1;
+
+ if (hints.flags & PBaseSize)
+ {
+ baseWidth = hints.base_width;
+ baseHeight = hints.base_height;
+ }
+ else if (hints.flags & PMinSize)
+ {
+ baseWidth = hints.min_width;
+ baseHeight = hints.min_height;
+ }
+ else
+ baseWidth = baseHeight = 0;
+
+ if (hints.flags & PMaxSize)
+ {
+ maxWidth = hints.max_width;
+ maxHeight = hints.max_height;
+ }
+ else
+ {
+ maxWidth = MAXINT;
+ maxHeight = MAXINT;
+ }
+
+ if (hints.flags & PResizeInc)
+ {
+ xinc = hints.width_inc;
+ yinc = hints.height_inc;
+ }
+ else
+ xinc = yinc = 1;
+
+ /*
+ * First, clamp to min and max values
+ */
+ if (dwidth < minWidth)
+ dwidth = minWidth;
+ if (dheight < minHeight)
+ dheight = minHeight;
+
+ if (dwidth > maxWidth)
+ dwidth = maxWidth;
+ if (dheight > maxHeight)
+ dheight = maxHeight;
+
+ /*
+ * Second, fit to base + N * inc
+ */
+ dwidth = ((dwidth - baseWidth) / xinc * xinc) + baseWidth;
+ dheight = ((dheight - baseHeight) / yinc * yinc) + baseHeight;
+
+ /*
+ * Third, adjust for aspect ratio
+ */
+
+ /*
+ * The math looks like this:
+ *
+ * minAspectX dwidth maxAspectX
+ * ---------- <= ------- <= ----------
+ * minAspectY dheight maxAspectY
+ *
+ * If that is multiplied out, then the width and height are
+ * invalid in the following situations:
+ *
+ * minAspectX * dheight > minAspectY * dwidth
+ * maxAspectX * dheight < maxAspectY * dwidth
+ *
+ */
+
+ if (hints.flags & PAspect)
+ {
+ if (hints.min_aspect.x * dheight > hints.min_aspect.y * dwidth)
+ {
+ delta = makemult(hints.min_aspect.x * dheight / hints.min_aspect.y - dwidth, xinc);
+ if (dwidth + delta <= maxWidth)
+ dwidth += delta;
+ else
+ {
+ delta = makemult(dheight - dwidth*hints.min_aspect.y/hints.min_aspect.x, yinc);
+ if (dheight - delta >= minHeight)
+ dheight -= delta;
+ }
+ }
+
+ if (hints.max_aspect.x * dheight < hints.max_aspect.y * dwidth)
+ {
+ delta = makemult(dwidth * hints.max_aspect.y / hints.max_aspect.x - dheight, yinc);
+ if (dheight + delta <= maxHeight)
+ dheight += delta;
+ else
+ {
+ delta = makemult(dwidth - hints.max_aspect.x*dheight/hints.max_aspect.y, xinc);
+ if (dwidth - delta >= minWidth)
+ dwidth -= delta;
+ }
+ }
+ }
+
+ /* Return computed values */
+ *widthp = dwidth;
+ *heightp = dheight;
+}
+#undef makemult
+
+
+
+/*
+ * ValidateSizing - Ensures size request respects hints
+ */
+static int
+ValidateSizing (HWND hwnd, WindowPtr pWin,
+ WPARAM wParam, LPARAM lParam)
+{
+ WinXSizeHints sizeHints;
+ RECT *rect;
+ int iWidth, iHeight, iTopBorder;
+ POINT pt;
+
+ /* Invalid input checking */
+ if (pWin==NULL || lParam==0)
+ {
+ ErrorF ("Invalid input checking\n");
+ return FALSE;
+ }
+
+ /* No size hints, no checking */
+ if (!winMultiWindowGetWMNormalHints (pWin, &sizeHints))
+ {
+ ErrorF ("No size hints, no checking\n");
+ return FALSE;
+ }
+
+ /* Avoid divide-by-zero */
+ if (sizeHints.flags & PResizeInc)
+ {
+ if (sizeHints.width_inc == 0) sizeHints.width_inc = 1;
+ if (sizeHints.height_inc == 0) sizeHints.height_inc = 1;
+ }
+
+ rect = (RECT*)lParam;
+
+ iWidth = rect->right - rect->left;
+ iHeight = rect->bottom - rect->top;
+
+ /* Get title bar height, there must be an easier way?! */
+ pt.x = pt.y = 0;
+ ClientToScreen(hwnd, &pt);
+ iTopBorder = pt.y - rect->top;
+
+ /* Now remove size of any borders */
+ iWidth -= 2 * GetSystemMetrics(SM_CXSIZEFRAME);
+ iHeight -= GetSystemMetrics(SM_CYSIZEFRAME) + iTopBorder;
+
+ /* Constrain the size to legal values */
+ ConstrainSize (sizeHints, &iWidth, &iHeight);
+
+ /* Add back the borders */
+ iWidth += 2 * GetSystemMetrics(SM_CXSIZEFRAME);
+ iHeight += GetSystemMetrics(SM_CYSIZEFRAME) + iTopBorder;
+
+ /* Adjust size according to where we're dragging from */
+ switch(wParam) {
+ case WMSZ_TOP:
+ case WMSZ_TOPRIGHT:
+ case WMSZ_BOTTOM:
+ case WMSZ_BOTTOMRIGHT:
+ case WMSZ_RIGHT:
+ rect->right = rect->left + iWidth;
+ break;
+ default:
+ rect->left = rect->right - iWidth;
+ break;
+ }
+ switch(wParam) {
+ case WMSZ_BOTTOM:
+ case WMSZ_BOTTOMRIGHT:
+ case WMSZ_BOTTOMLEFT:
+ case WMSZ_RIGHT:
+ case WMSZ_LEFT:
+ rect->bottom = rect->top + iHeight;
+ break;
+ default:
+ rect->top = rect->bottom - iHeight;
+ break;
+ }
+ return TRUE;
+}
+
+
+/*
+ * IsRaiseOnClick
+ */
+
+static Bool
+IsRaiseOnClick (WindowPtr pWin)
+{
+
+ struct _Window *pwin;
+ struct _Property *prop;
+ /* XXX We're getting inputInfo.poniter here, but this might be really wrong.
+ * Which pointer's current window do we want? */
+ WindowPtr pRoot = GetCurrentRootWindow (inputInfo.pointer);
+
+ if (!pWin)
+ {
+ ErrorF ("IsRaiseOnClick - no prop use default value:%d\n",
+ RAISE_ON_CLICK_DEFAULT);
+ return RAISE_ON_CLICK_DEFAULT;
+ }
+
+ pwin = (struct _Window*) pWin;
+
+ if (pwin->optional)
+ prop = (struct _Property *) pwin->optional->userProps;
+ else
+ prop = NULL;
+
+ while (prop)
+ {
+ if (prop->propertyName == AtmWindowsWmRaiseOnClick ()
+ && prop->type == XA_INTEGER
+ && prop->format == 32)
+ {
+ return *(int*)prop->data;
+ }
+ else
+ prop = prop->next;
+ }
+
+ if (pWin != pRoot)
+ {
+ return IsRaiseOnClick (pRoot);
+ }
+ else
+ {
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("IsRaiseOnClick - no prop use default value:%d\n",
+ RAISE_ON_CLICK_DEFAULT);
+#endif
+ return RAISE_ON_CLICK_DEFAULT;
+ }
+}
+
+
+/*
+ * IsMouseActive
+ */
+
+static Bool
+IsMouseActive (WindowPtr pWin)
+{
+
+ struct _Window *pwin;
+ struct _Property *prop;
+ /* XXX We're getting inputInfo.poniter here, but this might be really wrong.
+ * Which pointer's current window do we want? */
+ WindowPtr pRoot = GetCurrentRootWindow (inputInfo.pointer);
+
+ if (!pWin)
+ {
+ ErrorF ("IsMouseActive - pWin was NULL use default value:%d\n",
+ MOUSE_ACTIVATE_DEFAULT);
+ return MOUSE_ACTIVATE_DEFAULT;
+ }
+
+ pwin = (struct _Window*) pWin;
+
+ if (pwin->optional)
+ prop = (struct _Property *) pwin->optional->userProps;
+ else
+ prop = NULL;
+
+ while (prop)
+ {
+ if (prop->propertyName == AtmWindowsWMMouseActivate ()
+ && prop->type == XA_INTEGER
+ && prop->format == 32)
+ {
+ return *(int*)prop->data;
+ }
+ else
+ prop = prop->next;
+ }
+
+ if (pWin != pRoot)
+ {
+ return IsMouseActive (pRoot);
+ }
+ else
+ {
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("IsMouseActive - no prop use default value:%d\n",
+ MOUSE_ACTIVATE_DEFAULT);
+#endif
+ return MOUSE_ACTIVATE_DEFAULT;
+ }
+}
+
+
+/*
+ * winMWExtWMWindowProc - Window procedure
+ */
+
+LRESULT CALLBACK
+winMWExtWMWindowProc (HWND hwnd, UINT message,
+ WPARAM wParam, LPARAM lParam)
+{
+ WindowPtr pWin = NULL;
+ win32RootlessWindowPtr pRLWinPriv = NULL;
+ ScreenPtr pScreen = NULL;
+ winPrivScreenPtr pScreenPriv = NULL;
+ winScreenInfo *pScreenInfo = NULL;
+ HWND hwndScreen = NULL;
+ POINT ptMouse;
+ static Bool s_fTracking = FALSE;
+ HDC hdcUpdate;
+ PAINTSTRUCT ps;
+ LPWINDOWPOS pWinPos = NULL;
+ RECT rcClient;
+ winWMMessageRec wmMsg;
+ Bool fWMMsgInitialized = FALSE;
+
+ /* Check if the Windows window property for our X window pointer is valid */
+ if ((pRLWinPriv = (win32RootlessWindowPtr)GetProp (hwnd, WIN_WINDOW_PROP)) != NULL)
+ {
+ pWin = pRLWinPriv->pFrame->win;
+ pScreen = pWin->drawable.pScreen;
+ if (pScreen) pScreenPriv = winGetScreenPriv(pScreen);
+ if (pScreenPriv) pScreenInfo = pScreenPriv->pScreenInfo;
+ if (pScreenPriv) hwndScreen = pScreenPriv->hwndScreen;
+
+ wmMsg.msg = 0;
+ wmMsg.hwndWindow = hwnd;
+ wmMsg.iWindow = (Window)pWin->drawable.id;
+
+ wmMsg.iX = pRLWinPriv->pFrame->x;
+ wmMsg.iY = pRLWinPriv->pFrame->y;
+ wmMsg.iWidth = pRLWinPriv->pFrame->width;
+ wmMsg.iHeight = pRLWinPriv->pFrame->height;
+
+ fWMMsgInitialized = TRUE;
+ winDebugWin32Message("winMWExtWMWindowProc", hwnd, message, wParam, lParam);
+
+ winDebug ("\thWnd %08X\n", hwnd);
+ winDebug ("\tpScreenPriv %08X\n", pScreenPriv);
+ winDebug ("\tpScreenInfo %08X\n", pScreenInfo);
+ winDebug ("\thwndScreen %08X\n", hwndScreen);
+ winDebug ("winMWExtWMWindowProc (%08x) %08x %08x %08x\n",
+ pRLWinPriv, message, wParam, lParam);
+ }
+ /* Branch on message type */
+ switch (message)
+ {
+ case WM_CREATE:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_CREATE\n");
+#endif
+ /* */
+ SetProp (hwnd,
+ WIN_WINDOW_PROP,
+ (HANDLE)((LPCREATESTRUCT) lParam)->lpCreateParams);
+ return 0;
+
+ case WM_CLOSE:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_CLOSE %d\n", pRLWinPriv->fClose);
+#endif
+ /* Tell window-manager to close window */
+ if (pRLWinPriv->fClose)
+ {
+ DestroyWindow (hwnd);
+ }
+ else
+ {
+ if (winIsInternalWMRunning(pScreenInfo))
+ {
+ /* Tell our Window Manager thread to kill the window */
+ wmMsg.msg = WM_WM_KILL;
+ if (fWMMsgInitialized)
+ winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
+ }
+ winWindowsWMSendEvent(WindowsWMControllerNotify,
+ WindowsWMControllerNotifyMask,
+ 1,
+ WindowsWMCloseWindow,
+ pWin->drawable.id,
+ 0, 0, 0, 0);
+ }
+ return 0;
+
+ case WM_DESTROY:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_DESTROY\n");
+#endif
+ /* Free the shaodw DC; which allows the bitmap to be freed */
+ DeleteDC (pRLWinPriv->hdcShadow);
+ pRLWinPriv->hdcShadow = NULL;
+
+ /* Free the shadow bitmap */
+ DeleteObject (pRLWinPriv->hbmpShadow);
+ pRLWinPriv->hbmpShadow = NULL;
+
+ /* Free the screen DC */
+ ReleaseDC (pRLWinPriv->hWnd, pRLWinPriv->hdcScreen);
+ pRLWinPriv->hdcScreen = NULL;
+
+ /* Free shadow buffer info header */
+ free (pRLWinPriv->pbmihShadow);
+ pRLWinPriv->pbmihShadow = NULL;
+
+ pRLWinPriv->fResized = FALSE;
+ pRLWinPriv->pfb = NULL;
+ free (pRLWinPriv);
+ RemoveProp (hwnd, WIN_WINDOW_PROP);
+ break;
+
+ case WM_MOUSEMOVE:
+#if CYGMULTIWINDOW_DEBUG && 0
+ winDebug ("winMWExtWMWindowProc - WM_MOUSEMOVE\n");
+#endif
+ /* Unpack the client area mouse coordinates */
+ ptMouse.x = GET_X_LPARAM(lParam);
+ ptMouse.y = GET_Y_LPARAM(lParam);
+
+ /* Translate the client area mouse coordinates to screen coordinates */
+ ClientToScreen (hwnd, &ptMouse);
+
+ /* Screen Coords from (-X, -Y) -> Root Window (0, 0) */
+ ptMouse.x -= GetSystemMetrics (SM_XVIRTUALSCREEN);
+ ptMouse.y -= GetSystemMetrics (SM_YVIRTUALSCREEN);
+
+ /* We can't do anything without privates */
+ if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
+ break;
+
+ /* Has the mouse pointer crossed screens? */
+ if (pScreen != miPointerGetScreen(inputInfo.pointer))
+ miPointerSetScreen (inputInfo.pointer, pScreenInfo->dwScreen,
+ ptMouse.x - pScreenInfo->dwXOffset,
+ ptMouse.y - pScreenInfo->dwYOffset);
+
+ /* Are we tracking yet? */
+ if (!s_fTracking)
+ {
+ TRACKMOUSEEVENT tme;
+
+ /* Setup data structure */
+ ZeroMemory (&tme, sizeof (tme));
+ tme.cbSize = sizeof (tme);
+ tme.dwFlags = TME_LEAVE;
+ tme.hwndTrack = hwnd;
+
+ /* Call the tracking function */
+ if (!(*g_fpTrackMouseEvent) (&tme))
+ ErrorF ("winMWExtWMWindowProc - _TrackMouseEvent failed\n");
+
+ /* Flag that we are tracking now */
+ s_fTracking = TRUE;
+ }
+
+ /* Kill the timer used to poll mouse events */
+ if (g_uipMousePollingTimerID != 0)
+ {
+ KillTimer (pScreenPriv->hwndScreen, WIN_POLLING_MOUSE_TIMER_ID);
+ g_uipMousePollingTimerID = 0;
+ }
+
+ /* Deliver absolute cursor position to X Server */
+ winEnqueueMotion(ptMouse.x - pScreenInfo->dwXOffset,
+ ptMouse.y - pScreenInfo->dwYOffset);
+
+ return 0;
+
+ case WM_NCMOUSEMOVE:
+#if CYGMULTIWINDOW_DEBUG && 0
+ winDebug ("winMWExtWMWindowProc - WM_NCMOUSEMOVE\n");
+#endif
+ /*
+ * We break instead of returning 0 since we need to call
+ * DefWindowProc to get the mouse cursor changes
+ * and min/max/close button highlighting in Windows XP.
+ * The Platform SDK says that you should return 0 if you
+ * process this message, but it fails to mention that you
+ * will give up any default functionality if you do return 0.
+ */
+
+ /* We can't do anything without privates */
+ if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
+ break;
+
+ /*
+ * Timer to poll mouse events. This is needed to make
+ * programs like xeyes follow the mouse properly.
+ */
+ if (g_uipMousePollingTimerID == 0)
+ g_uipMousePollingTimerID = SetTimer (pScreenPriv->hwndScreen,
+ WIN_POLLING_MOUSE_TIMER_ID,
+ MOUSE_POLLING_INTERVAL,
+ NULL);
+ break;
+
+ case WM_MOUSELEAVE:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_MOUSELEAVE\n");
+#endif
+ /* Mouse has left our client area */
+
+ /* Flag that we are no longer tracking */
+ s_fTracking = FALSE;
+
+ /*
+ * Timer to poll mouse events. This is needed to make
+ * programs like xeyes follow the mouse properly.
+ */
+ if (g_uipMousePollingTimerID == 0)
+ g_uipMousePollingTimerID = SetTimer (pScreenPriv->hwndScreen,
+ WIN_POLLING_MOUSE_TIMER_ID,
+ MOUSE_POLLING_INTERVAL,
+ NULL);
+ return 0;
+
+ case WM_LBUTTONDBLCLK:
+ case WM_LBUTTONDOWN:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_LBUTTONDBLCLK\n");
+#endif
+ if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
+ break;
+ SetCapture (hwnd);
+ return winMouseButtonsHandle (pScreen, ButtonPress, Button1, wParam);
+
+ case WM_LBUTTONUP:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_LBUTTONUP\n");
+#endif
+ if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
+ break;
+ ReleaseCapture ();
+ return winMouseButtonsHandle (pScreen, ButtonRelease, Button1, wParam);
+
+ case WM_MBUTTONDBLCLK:
+ case WM_MBUTTONDOWN:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_MBUTTONDBLCLK\n");
+#endif
+ if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
+ break;
+ SetCapture (hwnd);
+ return winMouseButtonsHandle (pScreen, ButtonPress, Button2, wParam);
+
+ case WM_MBUTTONUP:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_MBUTTONUP\n");
+#endif
+ if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
+ break;
+ ReleaseCapture ();
+ return winMouseButtonsHandle (pScreen, ButtonRelease, Button2, wParam);
+
+ case WM_RBUTTONDBLCLK:
+ case WM_RBUTTONDOWN:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_RBUTTONDBLCLK\n");
+#endif
+ if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
+ break;
+ SetCapture (hwnd);
+ return winMouseButtonsHandle (pScreen, ButtonPress, Button3, wParam);
+
+ case WM_RBUTTONUP:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_RBUTTONUP\n");
+#endif
+ if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
+ break;
+ ReleaseCapture ();
+ return winMouseButtonsHandle (pScreen, ButtonRelease, Button3, wParam);
+
+ case WM_XBUTTONDBLCLK:
+ case WM_XBUTTONDOWN:
+ if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
+ break;
+ SetCapture (hwnd);
+ return winMouseButtonsHandle (pScreen, ButtonPress, HIWORD(wParam) + 5, wParam);
+ case WM_XBUTTONUP:
+ if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
+ break;
+ ReleaseCapture ();
+ return winMouseButtonsHandle (pScreen, ButtonRelease, HIWORD(wParam) + 5, wParam);
+
+ case WM_MOUSEWHEEL:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_MOUSEWHEEL\n");
+#endif
+
+ /* Pass the message to the root window */
+ SendMessage (hwndScreen, message, wParam, lParam);
+ return 0;
+
+ case WM_MOUSEACTIVATE:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_MOUSEACTIVATE\n");
+#endif
+#if 1
+ /* Check if this window needs to be made active when clicked */
+ if (winIsInternalWMRunning(pScreenInfo) && pWin->overrideRedirect)
+ {
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_MOUSEACTIVATE - "
+ "MA_NOACTIVATE\n");
+#endif
+
+ /* */
+ return MA_NOACTIVATE;
+ }
+#endif
+ if (!winIsInternalWMRunning(pScreenInfo) && !IsMouseActive (pWin))
+ return MA_NOACTIVATE;
+
+ break;
+
+ case WM_KILLFOCUS:
+ /* Pop any pressed keys since we are losing keyboard focus */
+ winKeybdReleaseKeys ();
+ return 0;
+
+ case WM_SYSDEADCHAR:
+ case WM_DEADCHAR:
+ /*
+ * NOTE: We do nothing with WM_*CHAR messages,
+ * nor does the root window, so we can just toss these messages.
+ */
+ return 0;
+
+ case WM_SYSKEYDOWN:
+ case WM_KEYDOWN:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_*KEYDOWN\n");
+#endif
+
+ /*
+ * Don't pass Alt-F4 key combo to root window,
+ * let Windows translate to WM_CLOSE and close this top-level window.
+ *
+ * NOTE: We purposely don't check the fUseWinKillKey setting because
+ * it should only apply to the key handling for the root window,
+ * not for top-level window-manager windows.
+ *
+ * ALSO NOTE: We do pass Ctrl-Alt-Backspace to the root window
+ * because that is a key combo that no X app should be expecting to
+ * receive, since it has historically been used to shutdown the X server.
+ * Passing Ctrl-Alt-Backspace to the root window preserves that
+ * behavior, assuming that -unixkill has been passed as a parameter.
+ */
+ if (wParam == VK_F4 && (GetKeyState (VK_MENU) & 0x8000))
+ break;
+
+ /* Pass the message to the root window */
+ SendMessage (hwndScreen, message, wParam, lParam);
+ return 0;
+
+ case WM_SYSKEYUP:
+ case WM_KEYUP:
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_*KEYUP\n");
+#endif
+
+ /* Pass the message to the root window */
+ SendMessage (hwndScreen, message, wParam, lParam);
+ return 0;
+
+ case WM_HOTKEY:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_HOTKEY\n");
+#endif
+
+ /* Pass the message to the root window */
+ SendMessage (hwndScreen, message, wParam, lParam);
+ return 0;
+
+ case WM_ERASEBKGND:
+ winDebug ("winMWExtWMWindowProc - WM_ERASEBKGND\n");
+ /*
+ * Pretend that we did erase the background but we don't care,
+ * since we repaint the entire region anyhow
+ * This avoids some flickering when resizing.
+ */
+ return TRUE;
+
+ case WM_PAINT:
+
+ /* BeginPaint gives us an hdc that clips to the invalidated region */
+ hdcUpdate = BeginPaint (hwnd, &ps);
+
+ /* Try to copy from the shadow buffer */
+ if (!BitBlt (hdcUpdate,
+ ps.rcPaint.left, ps.rcPaint.top,
+ ps.rcPaint.right - ps.rcPaint.left,
+ ps.rcPaint.bottom - ps.rcPaint.top,
+ pRLWinPriv->hdcShadow,
+ ps.rcPaint.left, ps.rcPaint.top,
+ SRCCOPY))
+ {
+ 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 ("winMWExtWMWindowProc - BitBlt failed: %s\n",
+ (LPSTR)lpMsgBuf);
+ LocalFree (lpMsgBuf);
+ }
+
+ /* EndPaint frees the DC */
+ EndPaint (hwnd, &ps);
+ break;
+
+ case WM_ACTIVATE:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_ACTIVATE\n");
+#endif
+ if (LOWORD(wParam) != WA_INACTIVE)
+ {
+ if (winIsInternalWMRunning(pScreenInfo))
+ {
+#if 0
+ /* Raise the window to the top in Z order */
+ wmMsg.msg = WM_WM_RAISE;
+ if (fWMMsgInitialized)
+ winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
+#endif
+ /* Tell our Window Manager thread to activate the window */
+ wmMsg.msg = WM_WM_ACTIVATE;
+ if (fWMMsgInitialized)
+ if (!pWin || !pWin->overrideRedirect) /* for OOo menus */
+ winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
+ }
+ winWindowsWMSendEvent(WindowsWMControllerNotify,
+ WindowsWMControllerNotifyMask,
+ 1,
+ WindowsWMActivateWindow,
+ pWin->drawable.id,
+ 0, 0,
+ 0, 0);
+ }
+ return 0;
+
+#if 1
+ case WM_WINDOWPOSCHANGING:
+ pWinPos = (LPWINDOWPOS)lParam;
+ if (!(pWinPos->flags & SWP_NOZORDER))
+ {
+ if (pRLWinPriv->fRestackingNow || pScreenPriv->fRestacking)
+ {
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("Win %08x is now restacking.\n", (unsigned int)pRLWinPriv);
+#endif
+ break;
+ }
+
+ if (winIsInternalWMRunning(pScreenInfo) || IsRaiseOnClick (pWin))
+ {
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("Win %08x has WINDOWSWM_RAISE_ON_CLICK.\n", (unsigned int)pRLWinPriv);
+#endif
+ break;
+ }
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("Win %08x forbid to change z order (%08x).\n",
+ (unsigned int)pRLWinPriv, (unsigned int)pWinPos->hwndInsertAfter);
+#endif
+ pWinPos->flags |= SWP_NOZORDER;
+ }
+ break;
+#endif
+
+ case WM_MOVE:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_MOVE - %d ms\n",
+ (unsigned int)GetTickCount ());
+#endif
+ if (g_fNoConfigureWindow) break;
+#if 0
+ /* Bail if Windows window is not actually moving */
+ if (pRLWinPriv->dwX == (short) LOWORD(lParam)
+ && pRLWinPriv->dwY == (short) HIWORD(lParam))
+ break;
+
+ /* Also bail if we're maximizing, we'll do the whole thing in WM_SIZE */
+ {
+ WINDOWPLACEMENT windPlace;
+ windPlace.length = sizeof (WINDOWPLACEMENT);
+
+ /* Get current window placement */
+ GetWindowPlacement (hwnd, &windPlace);
+
+ /* Bail if maximizing */
+ if (windPlace.showCmd == SW_MAXIMIZE
+ || windPlace.showCmd == SW_SHOWMAXIMIZED)
+ break;
+ }
+#endif
+
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("\t(%d, %d)\n", (short) LOWORD(lParam), (short) HIWORD(lParam));
+#endif
+ if (!pRLWinPriv->fMovingOrSizing)
+ {
+ if (winIsInternalWMRunning(pScreenInfo))
+ winAdjustXWindow (pWin, hwnd);
+
+ winMWExtWMMoveXWindow (pWin,
+ (LOWORD(lParam) - wBorderWidth (pWin)
+ - GetSystemMetrics (SM_XVIRTUALSCREEN)),
+ (HIWORD(lParam) - wBorderWidth (pWin)
+ - GetSystemMetrics (SM_YVIRTUALSCREEN)));
+ }
+ return 0;
+
+ case WM_SHOWWINDOW:
+#if CYGMULTIWINDOW_DEBUG || TRUE
+ winDebug ("winMWExtWMWindowProc - WM_SHOWWINDOW - %d ms\n",
+ (unsigned int)GetTickCount ());
+#endif
+ /* Bail out if the window is being hidden */
+ if (!wParam)
+ return 0;
+
+ if (!pScreenInfo->fInternalWM)//XXXX
+ return 0;
+
+ winMWExtWMUpdateWindowDecoration (pRLWinPriv, pScreenInfo);
+
+ if (winIsInternalWMRunning(pScreenInfo))
+ {
+#if CYGMULTIWINDOW_DEBUG || TRUE
+ winDebug ("\tMapWindow\n");
+#endif
+ /* Tell X to map the window */
+ MapWindow (pWin, wClient(pWin));
+
+ if (!pRLWinPriv->pFrame->win->overrideRedirect)
+ /* Bring the Windows window to the foreground */
+ SetForegroundWindow (hwnd);
+
+ /* Setup the Window Manager message */
+ wmMsg.msg = WM_WM_MAP;
+ wmMsg.iWidth = pRLWinPriv->pFrame->width;
+ wmMsg.iHeight = pRLWinPriv->pFrame->height;
+
+ /* Tell our Window Manager thread to map the window */
+ if (fWMMsgInitialized)
+ winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
+ }
+ break;
+
+ case WM_SIZING:
+ /* Need to legalize the size according to WM_NORMAL_HINTS */
+ /* for applications like xterm */
+ return ValidateSizing (hwnd, pWin, wParam, lParam);
+
+ case WM_WINDOWPOSCHANGED:
+ {
+ pWinPos = (LPWINDOWPOS) lParam;
+#if CYGMULTIWINDOW_DEBUG
+ winDebug("winMWExtWMWindowProc - WM_WINDOWPOSCHANGED\n");
+ winDebug("\tflags: %s%s%s%s%s%s%s%s%s%s%s%s\n",
+ (pWinPos->flags & SWP_DRAWFRAME)?"SWP_DRAWFRAME ":"",
+ (pWinPos->flags & SWP_FRAMECHANGED)?"SWP_FRAMECHANGED ":"",
+ (pWinPos->flags & SWP_HIDEWINDOW)?"SWP_HIDEWINDOW ":"",
+ (pWinPos->flags & SWP_NOACTIVATE)?"SWP_NOACTIVATE ":"",
+ (pWinPos->flags & SWP_NOCOPYBITS)?"SWP_NOCOPYBITS ":"",
+ (pWinPos->flags & SWP_NOMOVE)?"SWP_NOMOVE ":"",
+ (pWinPos->flags & SWP_NOOWNERZORDER)?"SWP_NOOWNERZORDER ":"",
+ (pWinPos->flags & SWP_NOSIZE)?"SWP_NOSIZE ":"",
+ (pWinPos->flags & SWP_NOREDRAW)?"SWP_NOREDRAW ":"",
+ (pWinPos->flags & SWP_NOSENDCHANGING)?"SWP_NOSENDCHANGING ":"",
+ (pWinPos->flags & SWP_NOZORDER)?"SWP_NOZORDER ":"",
+ (pWinPos->flags & SWP_SHOWWINDOW)?"SWP_SHOWWINDOW ":"");
+ winDebug("\tno_configure: %s\n", (g_fNoConfigureWindow?"Yes":"No"));
+ winDebug("\textend: (%d, %d, %d, %d)\n",
+ pWinPos->x, pWinPos->y, pWinPos->cx, pWinPos->cy);
+
+#endif
+ if (pWinPos->flags & SWP_HIDEWINDOW) break;
+
+ /* Reorder if window z order was changed */
+ if ((pScreenPriv != NULL)
+ && !(pWinPos->flags & SWP_NOZORDER)
+ && !(pWinPos->flags & SWP_SHOWWINDOW)
+ && winIsInternalWMRunning(pScreenInfo))
+ {
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("\twindow z order was changed\n");
+#endif
+ if (pWinPos->hwndInsertAfter == HWND_TOP
+ ||pWinPos->hwndInsertAfter == HWND_TOPMOST
+ ||pWinPos->hwndInsertAfter == HWND_NOTOPMOST)
+ {
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("\traise to top\n");
+#endif
+ /* Raise the window to the top in Z order */
+ wmMsg.msg = WM_WM_RAISE;
+ if (fWMMsgInitialized)
+ winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
+ }
+#if 1
+ else if (pWinPos->hwndInsertAfter == HWND_BOTTOM)
+ {
+ }
+ else
+ {
+ /* Check if this window is top of X windows. */
+ HWND hWndAbove = NULL;
+ DWORD dwCurrentProcessID = GetCurrentProcessId ();
+ DWORD dwWindowProcessID = 0;
+
+ for (hWndAbove = pWinPos->hwndInsertAfter;
+ hWndAbove != NULL;
+ hWndAbove = GetNextWindow (hWndAbove, GW_HWNDPREV))
+ {
+ /* Ignore other XWin process's window */
+ GetWindowThreadProcessId (hWndAbove, &dwWindowProcessID);
+
+ if ((dwWindowProcessID == dwCurrentProcessID)
+ && GetProp (hWndAbove, WIN_WINDOW_PROP)
+ && !IsWindowVisible (hWndAbove)
+ && !IsIconic (hWndAbove) ) /* ignore minimized windows */
+ break;
+ }
+ /* If this is top of X windows in Windows stack,
+ raise it in X stack. */
+ if (hWndAbove == NULL)
+ {
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("\traise to top\n");
+#endif
+ /* Raise the window to the top in Z order */
+ wmMsg.msg = WM_WM_RAISE;
+ if (fWMMsgInitialized)
+ winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
+ }
+ }
+#endif
+ }
+
+ if (!(pWinPos->flags & SWP_NOSIZE)) {
+ if (IsIconic(hwnd)){
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("\tIconic -> MINIMIZED\n");
+#endif
+ if (winIsInternalWMRunning(pScreenInfo))
+ {
+ /* Raise the window to the top in Z order */
+ wmMsg.msg = WM_WM_LOWER;
+ if (fWMMsgInitialized)
+ winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
+ }
+ winWindowsWMSendEvent(WindowsWMControllerNotify,
+ WindowsWMControllerNotifyMask,
+ 1,
+ WindowsWMMinimizeWindow,
+ pWin->drawable.id,
+ 0, 0, 0, 0);
+ } else if (IsZoomed(hwnd)){
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("\tZoomed -> MAXIMIZED\n");
+#endif
+ winWindowsWMSendEvent(WindowsWMControllerNotify,
+ WindowsWMControllerNotifyMask,
+ 1,
+ WindowsWMMaximizeWindow,
+ pWin->drawable.id,
+ 0, 0, 0, 0);
+ } else {
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("\tnone -> RESTORED\n");
+#endif
+ winWindowsWMSendEvent(WindowsWMControllerNotify,
+ WindowsWMControllerNotifyMask,
+ 1,
+ WindowsWMRestoreWindow,
+ pWin->drawable.id,
+ 0, 0, 0, 0);
+ }
+ }
+ if (!g_fNoConfigureWindow ) {
+
+ if (!pRLWinPriv->fMovingOrSizing
+ /*&& (pWinPos->flags & SWP_SHOWWINDOW)*/) {
+ GetClientRect (hwnd, &rcClient);
+ MapWindowPoints (hwnd, HWND_DESKTOP, (LPPOINT)&rcClient, 2);
+
+ if (!(pWinPos->flags & SWP_NOMOVE)
+ &&!(pWinPos->flags & SWP_NOSIZE)) {
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("\tmove & resize\n");
+#endif
+ if (winIsInternalWMRunning(pScreenInfo))
+ winAdjustXWindow (pWin, hwnd);
+
+ winMWExtWMMoveResizeXWindow (pWin,
+ rcClient.left - wBorderWidth (pWin)
+ - GetSystemMetrics (SM_XVIRTUALSCREEN),
+ rcClient.top - wBorderWidth (pWin)
+ - GetSystemMetrics (SM_YVIRTUALSCREEN),
+ rcClient.right - rcClient.left
+ - wBorderWidth (pWin)*2,
+ rcClient.bottom - rcClient.top
+ - wBorderWidth (pWin)*2);
+ } else if (!(pWinPos->flags & SWP_NOMOVE)) {
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("\tmove\n");
+#endif
+ if (winIsInternalWMRunning(pScreenInfo))
+ winAdjustXWindow (pWin, hwnd);
+
+ winMWExtWMMoveResizeXWindow (pWin,
+ rcClient.left - wBorderWidth (pWin)
+ - GetSystemMetrics (SM_XVIRTUALSCREEN),
+ rcClient.top - wBorderWidth (pWin)
+ - GetSystemMetrics (SM_YVIRTUALSCREEN),
+ rcClient.right - rcClient.left
+ - wBorderWidth (pWin)*2,
+ rcClient.bottom - rcClient.top
+ - wBorderWidth (pWin)*2);
+ } else if (!(pWinPos->flags & SWP_NOMOVE)) {
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("\tmove\n");
+#endif
+ if (winIsInternalWMRunning(pScreenInfo))
+ winAdjustXWindow (pWin, hwnd);
+
+ winMWExtWMMoveXWindow (pWin,
+ rcClient.left - wBorderWidth (pWin)
+ - GetSystemMetrics (SM_XVIRTUALSCREEN),
+ rcClient.top - wBorderWidth (pWin)
+ - GetSystemMetrics (SM_YVIRTUALSCREEN));
+ } else if (!(pWinPos->flags & SWP_NOSIZE)) {
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("\tresize\n");
+#endif
+ if (winIsInternalWMRunning(pScreenInfo))
+ winAdjustXWindow (pWin, hwnd);
+
+ winMWExtWMResizeXWindow (pWin,
+ rcClient.right - rcClient.left
+ - wBorderWidth (pWin)*2,
+ rcClient.bottom - rcClient.top
+ - wBorderWidth (pWin)*2);
+ }
+ }
+ }
+ }
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_WINDOWPOSCHANGED - done.\n");
+#endif
+ return 0;
+
+ case WM_SIZE:
+ /* see dix/window.c */
+ /* FIXME: Maximize/Restore? */
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_SIZE - %d ms\n",
+ (unsigned int)GetTickCount ());
+#endif
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("\t(%d, %d) %d\n", (short) LOWORD(lParam), (short) HIWORD(lParam), g_fNoConfigureWindow);
+#endif
+ if (g_fNoConfigureWindow) break;
+
+ /* Branch on type of resizing occurring */
+ switch (wParam)
+ {
+ case SIZE_MINIMIZED:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("\tSIZE_MINIMIZED\n");
+#endif
+ if (winIsInternalWMRunning(pScreenInfo))
+ {
+ /* Raise the window to the top in Z order */
+ wmMsg.msg = WM_WM_LOWER;
+ if (fWMMsgInitialized)
+ winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
+ }
+ winWindowsWMSendEvent(WindowsWMControllerNotify,
+ WindowsWMControllerNotifyMask,
+ 1,
+ WindowsWMMinimizeWindow,
+ pWin->drawable.id,
+ 0, 0,
+ LOWORD(lParam), HIWORD(lParam));
+ break;
+
+ case SIZE_RESTORED:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("\tSIZE_RESTORED\n");
+#endif
+ winWindowsWMSendEvent(WindowsWMControllerNotify,
+ WindowsWMControllerNotifyMask,
+ 1,
+ WindowsWMRestoreWindow,
+ pWin->drawable.id,
+ 0, 0,
+ LOWORD(lParam), HIWORD(lParam));
+ break;
+
+ case SIZE_MAXIMIZED:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("\tSIZE_MAXIMIZED\n");
+#endif
+ winWindowsWMSendEvent(WindowsWMControllerNotify,
+ WindowsWMControllerNotifyMask,
+ 1,
+ WindowsWMMaximizeWindow,
+ pWin->drawable.id,
+ 0, 0,
+ LOWORD(lParam), HIWORD(lParam));
+ break;
+ }
+
+ /* Perform the resize and notify the X client */
+ if (!pRLWinPriv->fMovingOrSizing)
+ {
+ if (winIsInternalWMRunning(pScreenInfo))
+ winAdjustXWindow (pWin, hwnd);
+
+ winMWExtWMResizeXWindow (pWin,
+ (short) LOWORD(lParam)
+ - wBorderWidth (pWin)*2,
+ (short) HIWORD(lParam)
+ - wBorderWidth (pWin)*2);
+ }
+ break;
+
+ case WM_ACTIVATEAPP:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_ACTIVATEAPP - %d ms\n",
+ (unsigned int)GetTickCount ());
+#endif
+ if (wParam)
+ {
+ if (winIsInternalWMRunning(pScreenInfo))
+ {
+ }
+ else
+ {
+ }
+ winWindowsWMSendEvent(WindowsWMActivationNotify,
+ WindowsWMActivationNotifyMask,
+ 1,
+ WindowsWMIsActive,
+ pWin->drawable.id,
+ 0, 0,
+ 0, 0);
+ }
+ else
+ {
+ winWindowsWMSendEvent(WindowsWMActivationNotify,
+ WindowsWMActivationNotifyMask,
+ 1,
+ WindowsWMIsInactive,
+ pWin->drawable.id,
+ 0, 0,
+ 0, 0);
+ }
+ break;
+
+ case WM_SETCURSOR:
+ if (LOWORD(lParam) == HTCLIENT)
+ {
+ if (!g_fSoftwareCursor) SetCursor (pScreenPriv->cursor.handle);
+ return TRUE;
+ }
+ break;
+
+ case WM_ENTERSIZEMOVE:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_ENTERSIZEMOVE - %d ms\n",
+ (unsigned int)GetTickCount ());
+#endif
+ pRLWinPriv->fMovingOrSizing = TRUE;
+ break;
+
+ case WM_EXITSIZEMOVE:
+#if CYGMULTIWINDOW_DEBUG
+ winDebug ("winMWExtWMWindowProc - WM_EXITSIZEMOVE - %d ms\n",
+ (unsigned int)GetTickCount ());
+#endif
+ pRLWinPriv->fMovingOrSizing = FALSE;
+
+ GetClientRect (hwnd, &rcClient);
+
+ MapWindowPoints (hwnd, HWND_DESKTOP, (LPPOINT)&rcClient, 2);
+
+ if (winIsInternalWMRunning(pScreenInfo))
+ winAdjustXWindow (pWin, hwnd);
+
+ winMWExtWMMoveResizeXWindow (pWin,
+ rcClient.left - wBorderWidth (pWin)
+ - GetSystemMetrics (SM_XVIRTUALSCREEN),
+ rcClient.top - wBorderWidth (pWin)
+ - GetSystemMetrics (SM_YVIRTUALSCREEN),
+ rcClient.right - rcClient.left
+ - wBorderWidth (pWin)*2,
+ rcClient.bottom - rcClient.top
+ - wBorderWidth (pWin)*2);
+ break;
+
+ case WM_MANAGE:
+ winDebug ("winMWExtWMWindowProc - WM_MANAGE\n");
+ break;
+
+ case WM_UNMANAGE:
+ winDebug ("winMWExtWMWindowProc - WM_UNMANAGE\n");
+ break;
+
+ default:
+ break;
+ }
+
+ return DefWindowProc (hwnd, message, wParam, lParam);
+}
diff --git a/xorg-server/hw/xwin/winwindowswm.c b/xorg-server/hw/xwin/winwindowswm.c
index 3c4a50433..f839171e9 100644
--- a/xorg-server/hw/xwin/winwindowswm.c
+++ b/xorg-server/hw/xwin/winwindowswm.c
@@ -77,10 +77,10 @@ make_box (int x, int y, int w, int h)
}
static int
-ProcWindowsWMQueryVersion(register ClientPtr client)
+ProcWindowsWMQueryVersion(ClientPtr client)
{
xWindowsWMQueryVersionReply rep;
- register int n;
+ int n;
REQUEST_SIZE_MATCH(xWindowsWMQueryVersionReq);
rep.type = X_Reply;
@@ -158,7 +158,7 @@ WMFreeEvents (pointer data, XID id)
}
static int
-ProcWindowsWMSelectInput (register ClientPtr client)
+ProcWindowsWMSelectInput (ClientPtr client)
{
REQUEST(xWindowsWMSelectInputReq);
WMEventPtr pEvent, pNewEvent, *pHead;
@@ -293,7 +293,7 @@ winWindowsWMSendEvent (int type, unsigned int mask, int which, int arg,
/* general utility functions */
static int
-ProcWindowsWMDisableUpdate (register ClientPtr client)
+ProcWindowsWMDisableUpdate (ClientPtr client)
{
REQUEST_SIZE_MATCH(xWindowsWMDisableUpdateReq);
@@ -303,7 +303,7 @@ ProcWindowsWMDisableUpdate (register ClientPtr client)
}
static int
-ProcWindowsWMReenableUpdate (register ClientPtr client)
+ProcWindowsWMReenableUpdate (ClientPtr client)
{
REQUEST_SIZE_MATCH(xWindowsWMReenableUpdateReq);
@@ -316,7 +316,7 @@ ProcWindowsWMReenableUpdate (register ClientPtr client)
/* window functions */
static int
-ProcWindowsWMSetFrontProcess (register ClientPtr client)
+ProcWindowsWMSetFrontProcess (ClientPtr client)
{
REQUEST_SIZE_MATCH(xWindowsWMSetFrontProcessReq);
@@ -329,7 +329,7 @@ ProcWindowsWMSetFrontProcess (register ClientPtr client)
/* frame functions */
static int
-ProcWindowsWMFrameGetRect (register ClientPtr client)
+ProcWindowsWMFrameGetRect (ClientPtr client)
{
xWindowsWMFrameGetRectReply rep;
BoxRec ir;
@@ -377,7 +377,7 @@ ProcWindowsWMFrameGetRect (register ClientPtr client)
static int
-ProcWindowsWMFrameDraw (register ClientPtr client)
+ProcWindowsWMFrameDraw (ClientPtr client)
{
REQUEST(xWindowsWMFrameDrawReq);
WindowPtr pWin;
@@ -461,12 +461,10 @@ ProcWindowsWMFrameDraw (register ClientPtr client)
}
static int
-ProcWindowsWMFrameSetTitle(
- register ClientPtr client
- )
+ProcWindowsWMFrameSetTitle(ClientPtr client)
{
unsigned int title_length, title_max;
- unsigned char *title_bytes;
+ char *title_bytes;
REQUEST(xWindowsWMFrameSetTitleReq);
WindowPtr pWin;
win32RootlessWindowPtr pRLWinPriv;
@@ -515,7 +513,7 @@ ProcWindowsWMFrameSetTitle(
/* dispatch */
static int
-ProcWindowsWMDispatch (register ClientPtr client)
+ProcWindowsWMDispatch (ClientPtr client)
{
REQUEST(xReq);
@@ -561,16 +559,16 @@ SNotifyEvent (xWindowsWMNotifyEvent *from, xWindowsWMNotifyEvent *to)
}
static int
-SProcWindowsWMQueryVersion (register ClientPtr client)
+SProcWindowsWMQueryVersion (ClientPtr client)
{
- register int n;
+ int n;
REQUEST(xWindowsWMQueryVersionReq);
swaps(&stuff->length, n);
return ProcWindowsWMQueryVersion(client);
}
static int
-SProcWindowsWMDispatch (register ClientPtr client)
+SProcWindowsWMDispatch (ClientPtr client)
{
REQUEST(xReq);
diff --git a/xorg-server/hw/xwin/winwndproc.c b/xorg-server/hw/xwin/winwndproc.c
index ab01f44ea..2dc146169 100644
--- a/xorg-server/hw/xwin/winwndproc.c
+++ b/xorg-server/hw/xwin/winwndproc.c
@@ -1,1252 +1,1234 @@
-/*
- *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
- * MATSUZAKI Kensuke
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-#include <commctrl.h>
-#include "winprefs.h"
-#include "winconfig.h"
-#include "winmsg.h"
-#include "inputstr.h"
-
-#ifndef XKB_IN_SERVER
-#define XKB_IN_SERVER
-#endif
-#include <xkbsrv.h>
-/*
- * Global variables
- */
-
-extern Bool g_fClipboardStarted;
-Bool g_fCursor = TRUE;
-Bool g_fButton[3] = { FALSE, FALSE, FALSE };
-
-
-/*
- * References to external symbols
- */
-
-extern Bool g_fClipboard;
-extern HWND g_hDlgDepthChange;
-extern Bool g_fKeyboardHookLL;
-extern HWND g_hwndKeyboardFocus;
-extern Bool g_fSoftwareCursor;
-extern DWORD g_dwCurrentThreadID;
-
-
-/*
- * Called by winWakeupHandler
- * Processes current Windows message
- */
-
-LRESULT CALLBACK
-winWindowProc (HWND hwnd, UINT message,
- WPARAM wParam, LPARAM lParam)
-{
- static winPrivScreenPtr s_pScreenPriv = NULL;
- static winScreenInfo *s_pScreenInfo = NULL;
- static ScreenPtr s_pScreen = NULL;
- static HWND s_hwndLastPrivates = NULL;
- static HINSTANCE s_hInstance;
- static Bool s_fTracking = FALSE;
- static unsigned long s_ulServerGeneration = 0;
- static UINT s_uTaskbarRestart = 0;
- int iScanCode;
- int i;
-
- winDebugWin32Message("winWindowProc", hwnd, message, wParam, lParam);
-
- /* Watch for server regeneration */
- if (g_ulServerGeneration != s_ulServerGeneration)
- {
- /* Store new server generation */
- s_ulServerGeneration = g_ulServerGeneration;
- }
-
- /* Only retrieve new privates pointers if window handle is null or changed */
- if ((s_pScreenPriv == NULL || hwnd != s_hwndLastPrivates)
- && (s_pScreenPriv = GetProp (hwnd, WIN_SCR_PROP)) != NULL)
- {
- winDebug ("winWindowProc - Setting privates handle\n");
- s_pScreenInfo = s_pScreenPriv->pScreenInfo;
- s_pScreen = s_pScreenInfo->pScreen;
- s_hwndLastPrivates = hwnd;
- }
- else if (s_pScreenPriv == NULL)
- {
- /* For safety, handle case that should never happen */
- s_pScreenInfo = NULL;
- s_pScreen = NULL;
- s_hwndLastPrivates = NULL;
- }
-
- /* Branch on message type */
- switch (message)
- {
- case WM_TRAYICON:
- return winHandleIconMessage (hwnd, message, wParam, lParam,
- s_pScreenPriv);
-
- case WM_CREATE:
- winDebug ("winWindowProc - WM_CREATE\n");
-
- /*
- * Add a property to our display window that references
- * this screens' privates.
- *
- * This allows the window procedure to refer to the
- * appropriate window DC and shadow DC for the window that
- * it is processing. We use this to repaint exposed
- * areas of our display window.
- */
- s_pScreenPriv = ((LPCREATESTRUCT) lParam)->lpCreateParams;
- s_hInstance = ((LPCREATESTRUCT) lParam)->hInstance;
- s_pScreenInfo = s_pScreenPriv->pScreenInfo;
- s_pScreen = s_pScreenInfo->pScreen;
- s_hwndLastPrivates = hwnd;
- s_uTaskbarRestart = RegisterWindowMessage(TEXT("TaskbarCreated"));
- SetProp (hwnd, WIN_SCR_PROP, s_pScreenPriv);
-
- /* Setup tray icon */
- if (!s_pScreenInfo->fNoTrayIcon)
- {
- /*
- * NOTE: The WM_CREATE message is processed before CreateWindowEx
- * returns, so s_pScreenPriv->hwndScreen is invalid at this point.
- * We go ahead and copy our hwnd parameter over top of the screen
- * privates hwndScreen so that we have a valid value for
- * that member. Otherwise, the tray icon will disappear
- * the first time you move the mouse over top of it.
- */
-
- s_pScreenPriv->hwndScreen = hwnd;
-
- winInitNotifyIcon (s_pScreenPriv,FALSE);
- }
- return 0;
-
- case WM_DISPLAYCHANGE:
- /* We cannot handle a display mode change during initialization */
- if (s_pScreenInfo == NULL)
- FatalError ("winWindowProc - WM_DISPLAYCHANGE - The display "
- "mode changed while we were intializing. This is "
- "very bad and unexpected. Exiting.\n");
-
- /*
- * We do not care about display changes with
- * fullscreen DirectDraw engines, because those engines set
- * their own mode when they become active.
- */
- if (s_pScreenInfo->fFullScreen
- && (s_pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DD
- || s_pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL
-#ifdef XWIN_PRIMARYFB
- || s_pScreenInfo->dwEngine == WIN_SERVER_PRIMARY_DD
-#endif
- ))
- {
- /*
- * Store the new display dimensions and depth.
- * We do this here for future compatibility in case we
- * ever allow switching from fullscreen to windowed mode.
- */
- s_pScreenPriv->dwLastWindowsWidth = GetSystemMetrics (SM_CXSCREEN);
- s_pScreenPriv->dwLastWindowsHeight = GetSystemMetrics (SM_CYSCREEN);
- s_pScreenPriv->dwLastWindowsBitsPixel
- = GetDeviceCaps (s_pScreenPriv->hdcScreen, BITSPIXEL);
- break;
- }
-
- winDebug ("winWindowProc - WM_DISPLAYCHANGE - orig bpp: %d, last bpp: %d, "
- "new bpp: %d\n",
- (int) s_pScreenInfo->dwBPP,
- (int) s_pScreenPriv->dwLastWindowsBitsPixel,
- wParam);
-
- winDebug ("winWindowProc - WM_DISPLAYCHANGE - new width: %d "
- "new height: %d\n",
- LOWORD (lParam), HIWORD (lParam));
-
- /*
- * TrueColor --> TrueColor depth changes are disruptive for:
- * Windowed:
- * Shadow DirectDraw
- * Shadow DirectDraw Non-Locking
- * Primary DirectDraw
- *
- * TrueColor --> TrueColor depth changes are non-optimal for:
- * Windowed:
- * Shadow GDI
- *
- * FullScreen:
- * Shadow GDI
- *
- * TrueColor --> PseudoColor or vice versa are disruptive for:
- * Windowed:
- * Shadow DirectDraw
- * Shadow DirectDraw Non-Locking
- * Primary DirectDraw
- * Shadow GDI
- */
-
- /*
- * Check for a disruptive change in depth.
- * We can only display a message for a disruptive depth change,
- * we cannot do anything to correct the situation.
- */
- if ((s_pScreenInfo->dwBPP != wParam)
- && (s_pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DD
- || s_pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL
-#ifdef XWIN_PRIMARYFB
- || s_pScreenInfo->dwEngine == WIN_SERVER_PRIMARY_DD
-#endif
- ))
- {
- /* Cannot display the visual until the depth is restored */
- winDebug ("winWindowProc - Disruptive change in depth\n");
-
- /* Display Exit dialog */
- winDisplayDepthChangeDialog (s_pScreenPriv);
-
- /* Flag that we have an invalid screen depth */
- s_pScreenPriv->fBadDepth = TRUE;
-
- /* Minimize the display window */
- ShowWindow (hwnd, SW_MINIMIZE);
- }
- else
- {
- /* Flag that we have a valid screen depth */
- s_pScreenPriv->fBadDepth = FALSE;
- }
-
- /*
- * Check for a change in display dimensions.
- * We can simply recreate the same-sized primary surface when
- * the display dimensions change.
- */
- if (s_pScreenPriv->dwLastWindowsWidth != LOWORD (lParam)
- || s_pScreenPriv->dwLastWindowsHeight != HIWORD (lParam))
- {
- /*
- * NOTE: The non-DirectDraw engines set the ReleasePrimarySurface
- * and CreatePrimarySurface function pointers to point
- * to the no operation function, NoopDDA. This allows us
- * to blindly call these functions, even if they are not
- * relevant to the current engine (e.g., Shadow GDI).
- */
-
- winDebug ("winWindowProc - WM_DISPLAYCHANGE - Dimensions changed\n");
-
- /* Release the old primary surface */
- (*s_pScreenPriv->pwinReleasePrimarySurface) (s_pScreen);
-
- winDebug ("winWindowProc - WM_DISPLAYCHANGE - Released "
- "primary surface\n");
-
- /* Create the new primary surface */
- (*s_pScreenPriv->pwinCreatePrimarySurface) (s_pScreen);
-
- winDebug ("winWindowProc - WM_DISPLAYCHANGE - Recreated "
- "primary surface\n");
-
-#if 0
- /* Multi-Window mode uses RandR for resizes */
- if (s_pScreenInfo->fMultiWindow)
- {
- RRSetScreenConfig ();
- }
-#endif
- }
- else
- {
- winDebug ("winWindowProc - WM_DISPLAYCHANGE - Dimensions did not "
- "change\n");
- }
-
- /* Store the new display dimensions and depth */
- if (s_pScreenInfo->fMultipleMonitors)
- {
- s_pScreenPriv->dwLastWindowsWidth
- = GetSystemMetrics (SM_CXVIRTUALSCREEN);
- s_pScreenPriv->dwLastWindowsHeight
- = GetSystemMetrics (SM_CYVIRTUALSCREEN);
- }
- else
- {
- s_pScreenPriv->dwLastWindowsWidth
- = GetSystemMetrics (SM_CXSCREEN);
- s_pScreenPriv->dwLastWindowsHeight
- = GetSystemMetrics (SM_CYSCREEN);
- }
- s_pScreenPriv->dwLastWindowsBitsPixel
- = GetDeviceCaps (s_pScreenPriv->hdcScreen, BITSPIXEL);
- break;
-
- case WM_SIZE:
- {
- SCROLLINFO si;
- RECT rcWindow;
- int iWidth, iHeight;
-
- winDebug ("winWindowProc - WM_SIZE\n");
-
- /* Break if we do not use scrollbars */
- if (!s_pScreenInfo->fScrollbars
- || !s_pScreenInfo->fDecoration
-#ifdef XWIN_MULTIWINDOWEXTWM
- || s_pScreenInfo->fMWExtWM
-#endif
- || s_pScreenInfo->fRootless
-#ifdef XWIN_MULTIWINDOW
- || s_pScreenInfo->fMultiWindow
-#endif
- || s_pScreenInfo->fFullScreen)
- break;
-
- /* No need to resize if we get minimized */
- if (wParam == SIZE_MINIMIZED)
- return 0;
-
- /*
- * Get the size of the whole window, including client area,
- * scrollbars, and non-client area decorations (caption, borders).
- * We do this because we need to check if the client area
- * without scrollbars is large enough to display the whole visual.
- * The new client area size passed by lParam already subtracts
- * the size of the scrollbars if they are currently displayed.
- * So checking is LOWORD(lParam) == visual_width and
- * HIWORD(lParam) == visual_height will never tell us to hide
- * the scrollbars because the client area would always be too small.
- * GetClientRect returns the same sizes given by lParam, so we
- * cannot use GetClientRect either.
- */
- GetWindowRect (hwnd, &rcWindow);
- iWidth = rcWindow.right - rcWindow.left;
- iHeight = rcWindow.bottom - rcWindow.top;
-
- winDebug ("winWindowProc - WM_SIZE - window w: %d h: %d, "
- "new client area w: %d h: %d\n",
- iWidth, iHeight, LOWORD (lParam), HIWORD (lParam));
-
- /* Subtract the frame size from the window size. */
- iWidth -= 2 * GetSystemMetrics (SM_CXSIZEFRAME);
- iHeight -= (2 * GetSystemMetrics (SM_CYSIZEFRAME)
- + GetSystemMetrics (SM_CYCAPTION));
-
- /*
- * Update scrollbar page sizes.
- * NOTE: If page size == range, then the scrollbar is
- * automatically hidden.
- */
-
- /* Is the naked client area large enough to show the whole visual? */
- if (iWidth < s_pScreenInfo->dwWidth
- || iHeight < s_pScreenInfo->dwHeight)
- {
- /* Client area too small to display visual, use scrollbars */
- iWidth -= GetSystemMetrics (SM_CXVSCROLL);
- iHeight -= GetSystemMetrics (SM_CYHSCROLL);
- }
-
- /* Set the horizontal scrollbar page size */
- si.cbSize = sizeof (si);
- si.fMask = SIF_PAGE | SIF_RANGE;
- si.nMin = 0;
- si.nMax = s_pScreenInfo->dwWidth - 1;
- si.nPage = iWidth;
- SetScrollInfo (hwnd, SB_HORZ, &si, TRUE);
-
- /* Set the vertical scrollbar page size */
- si.cbSize = sizeof (si);
- si.fMask = SIF_PAGE | SIF_RANGE;
- si.nMin = 0;
- si.nMax = s_pScreenInfo->dwHeight - 1;
- si.nPage = iHeight;
- SetScrollInfo (hwnd, SB_VERT, &si, TRUE);
-
- /*
- * NOTE: Scrollbars may have moved if they were at the
- * far right/bottom, so we query their current position.
- */
-
- /* Get the horizontal scrollbar position and set the offset */
- si.cbSize = sizeof (si);
- si.fMask = SIF_POS;
- GetScrollInfo (hwnd, SB_HORZ, &si);
- s_pScreenInfo->dwXOffset = -si.nPos;
-
- /* Get the vertical scrollbar position and set the offset */
- si.cbSize = sizeof (si);
- si.fMask = SIF_POS;
- GetScrollInfo (hwnd, SB_VERT, &si);
- s_pScreenInfo->dwYOffset = -si.nPos;
- }
- return 0;
-
- case WM_VSCROLL:
- {
- SCROLLINFO si;
- int iVertPos;
-
- winDebug ("winWindowProc - WM_VSCROLL\n");
-
- /* Get vertical scroll bar info */
- si.cbSize = sizeof (si);
- si.fMask = SIF_ALL;
- GetScrollInfo (hwnd, SB_VERT, &si);
-
- /* Save the vertical position for comparison later */
- iVertPos = si.nPos;
-
- /*
- * Don't forget:
- * moving the scrollbar to the DOWN, scroll the content UP
- */
- switch (LOWORD(wParam))
- {
- case SB_TOP:
- si.nPos = si.nMin;
- break;
-
- case SB_BOTTOM:
- si.nPos = si.nMax - si.nPage + 1;
- break;
-
- case SB_LINEUP:
- si.nPos -= 1;
- break;
-
- case SB_LINEDOWN:
- si.nPos += 1;
- break;
-
- case SB_PAGEUP:
- si.nPos -= si.nPage;
- break;
-
- case SB_PAGEDOWN:
- si.nPos += si.nPage;
- break;
-
- case SB_THUMBTRACK:
- si.nPos = si.nTrackPos;
- break;
-
- default:
- break;
- }
-
- /*
- * We retrieve the position after setting it,
- * because Windows may adjust it.
- */
- si.fMask = SIF_POS;
- SetScrollInfo (hwnd, SB_VERT, &si, TRUE);
- GetScrollInfo (hwnd, SB_VERT, &si);
-
- /* Scroll the window if the position has changed */
- if (si.nPos != iVertPos)
- {
- /* Save the new offset for bit block transfers, etc. */
- s_pScreenInfo->dwYOffset = -si.nPos;
-
- /* Change displayed region in the window */
- ScrollWindowEx (hwnd,
- 0,
- iVertPos - si.nPos,
- NULL,
- NULL,
- NULL,
- NULL,
- SW_INVALIDATE);
-
- /* Redraw the window contents */
- UpdateWindow (hwnd);
- }
- }
- return 0;
-
- case WM_HSCROLL:
- {
- SCROLLINFO si;
- int iHorzPos;
-
- winDebug ("winWindowProc - WM_HSCROLL\n");
-
- /* Get horizontal scroll bar info */
- si.cbSize = sizeof (si);
- si.fMask = SIF_ALL;
- GetScrollInfo (hwnd, SB_HORZ, &si);
-
- /* Save the horizontal position for comparison later */
- iHorzPos = si.nPos;
-
- /*
- * Don't forget:
- * moving the scrollbar to the RIGHT, scroll the content LEFT
- */
- switch (LOWORD(wParam))
- {
- case SB_LEFT:
- si.nPos = si.nMin;
- break;
-
- case SB_RIGHT:
- si.nPos = si.nMax - si.nPage + 1;
- break;
-
- case SB_LINELEFT:
- si.nPos -= 1;
- break;
-
- case SB_LINERIGHT:
- si.nPos += 1;
- break;
-
- case SB_PAGELEFT:
- si.nPos -= si.nPage;
- break;
-
- case SB_PAGERIGHT:
- si.nPos += si.nPage;
- break;
-
- case SB_THUMBTRACK:
- si.nPos = si.nTrackPos;
- break;
-
- default:
- break;
- }
-
- /*
- * We retrieve the position after setting it,
- * because Windows may adjust it.
- */
- si.fMask = SIF_POS;
- SetScrollInfo (hwnd, SB_HORZ, &si, TRUE);
- GetScrollInfo (hwnd, SB_HORZ, &si);
-
- /* Scroll the window if the position has changed */
- if (si.nPos != iHorzPos)
- {
- /* Save the new offset for bit block transfers, etc. */
- s_pScreenInfo->dwXOffset = -si.nPos;
-
- /* Change displayed region in the window */
- ScrollWindowEx (hwnd,
- iHorzPos - si.nPos,
- 0,
- NULL,
- NULL,
- NULL,
- NULL,
- SW_INVALIDATE);
-
- /* Redraw the window contents */
- UpdateWindow (hwnd);
- }
- }
- return 0;
-
- case WM_GETMINMAXINFO:
- {
- MINMAXINFO *pMinMaxInfo = (MINMAXINFO *) lParam;
- int iCaptionHeight;
- int iBorderHeight, iBorderWidth;
-
- winDebug ("winWindowProc - WM_GETMINMAXINFO - pScreenInfo: %08x\n",
- s_pScreenInfo);
-
- /* Can't do anything without screen info */
- if (s_pScreenInfo == NULL
- || !s_pScreenInfo->fScrollbars
- || s_pScreenInfo->fFullScreen
- || !s_pScreenInfo->fDecoration
-#ifdef XWIN_MULTIWINDOWEXTWM
- || s_pScreenInfo->fMWExtWM
-#endif
- || s_pScreenInfo->fRootless
-#ifdef XWIN_MULTIWINDOW
- || s_pScreenInfo->fMultiWindow
-#endif
- )
- break;
-
- /*
- * Here we can override the maximum tracking size, which
- * is the largest size that can be assigned to our window
- * via the sizing border.
- */
-
- /*
- * FIXME: Do we only need to do this once, since our visual size
- * does not change? Does Windows store this value statically
- * once we have set it once?
- */
-
- /* Get the border and caption sizes */
- iCaptionHeight = GetSystemMetrics (SM_CYCAPTION);
- iBorderWidth = 2 * GetSystemMetrics (SM_CXSIZEFRAME);
- iBorderHeight = 2 * GetSystemMetrics (SM_CYSIZEFRAME);
-
- /* Allow the full visual to be displayed */
- pMinMaxInfo->ptMaxTrackSize.x
- = s_pScreenInfo->dwWidth + iBorderWidth;
- pMinMaxInfo->ptMaxTrackSize.y
- = s_pScreenInfo->dwHeight + iBorderHeight + iCaptionHeight;
- }
- return 0;
-
- case WM_ERASEBKGND:
- winDebug ("winWindowProc - WM_ERASEBKGND\n");
- /*
- * Pretend that we did erase the background but we don't care,
- * the application uses the full window estate. This avoids some
- * flickering when resizing.
- */
- return TRUE;
-
- case WM_PAINT:
- /* Only paint if we have privates and the server is enabled */
- if (s_pScreenPriv == NULL
- || !s_pScreenPriv->fEnabled
- || (s_pScreenInfo->fFullScreen && !s_pScreenPriv->fActive)
- || s_pScreenPriv->fBadDepth)
- {
- /* We don't want to paint */
- break;
- }
-
- /* Break out here if we don't have a valid paint routine */
- if (s_pScreenPriv->pwinBltExposedRegions == NULL)
- break;
-
- /* Call the engine dependent repainter */
- (*s_pScreenPriv->pwinBltExposedRegions) (s_pScreen);
- return 0;
-
- case WM_PALETTECHANGED:
- {
- winDebug ("winWindowProc - WM_PALETTECHANGED\n");
- /*
- * Don't process if we don't have privates or a colormap,
- * or if we have an invalid depth.
- */
- if (s_pScreenPriv == NULL
- || s_pScreenPriv->pcmapInstalled == NULL
- || s_pScreenPriv->fBadDepth)
- break;
-
- /* Return if we caused the palette to change */
- if ((HWND) wParam == hwnd)
- {
- /* Redraw the screen */
- (*s_pScreenPriv->pwinRedrawScreen) (s_pScreen);
- return 0;
- }
-
- /* Reinstall the windows palette */
- (*s_pScreenPriv->pwinRealizeInstalledPalette) (s_pScreen);
-
- /* Redraw the screen */
- (*s_pScreenPriv->pwinRedrawScreen) (s_pScreen);
- return 0;
- }
-
- case WM_MOUSEMOVE:
- /* We can't do anything without privates */
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
-
- /* We can't do anything without g_pwinPointer */
- if (g_pwinPointer == NULL)
- break;
-
- /* Has the mouse pointer crossed screens? */
- if (s_pScreen != miPointerGetScreen(g_pwinPointer))
- miPointerSetScreen (g_pwinPointer, s_pScreenInfo->dwScreen,
- GET_X_LPARAM(lParam)-s_pScreenInfo->dwXOffset,
- GET_Y_LPARAM(lParam)-s_pScreenInfo->dwYOffset);
-
- /* Are we tracking yet? */
- if (!s_fTracking)
- {
- TRACKMOUSEEVENT tme;
-
- /* Setup data structure */
- ZeroMemory (&tme, sizeof (tme));
- tme.cbSize = sizeof (tme);
- tme.dwFlags = TME_LEAVE;
- tme.hwndTrack = hwnd;
-
- /* Call the tracking function */
- if (!(*g_fpTrackMouseEvent) (&tme))
- ErrorF ("winWindowProc - _TrackMouseEvent failed\n");
-
- /* Flag that we are tracking now */
- s_fTracking = TRUE;
- }
-
- /* Hide or show the Windows mouse cursor */
- if (g_fSoftwareCursor && g_fCursor && (s_pScreenPriv->fActive || s_pScreenInfo->fLessPointer))
- {
- /* Hide Windows cursor */
- g_fCursor = FALSE;
- ShowCursor (FALSE);
- }
- else if (g_fSoftwareCursor && !g_fCursor && !s_pScreenPriv->fActive
- && !s_pScreenInfo->fLessPointer)
- {
- /* Show Windows cursor */
- g_fCursor = TRUE;
- ShowCursor (TRUE);
- }
-
- /* Deliver absolute cursor position to X Server */
- winEnqueueMotion(GET_X_LPARAM(lParam)-s_pScreenInfo->dwXOffset,
- GET_Y_LPARAM(lParam)-s_pScreenInfo->dwYOffset);
- return 0;
-
- case WM_NCMOUSEMOVE:
- /*
- * We break instead of returning 0 since we need to call
- * DefWindowProc to get the mouse cursor changes
- * and min/max/close button highlighting in Windows XP.
- * The Platform SDK says that you should return 0 if you
- * process this message, but it fails to mention that you
- * will give up any default functionality if you do return 0.
- */
-
- /* We can't do anything without privates */
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
-
- /* Non-client mouse movement, show Windows cursor */
- if (g_fSoftwareCursor && !g_fCursor)
- {
- g_fCursor = TRUE;
- ShowCursor (TRUE);
- }
- break;
-
- case WM_MOUSELEAVE:
- /* Mouse has left our client area */
-
- /* Flag that we are no longer tracking */
- s_fTracking = FALSE;
-
- /* Show the mouse cursor, if necessary */
- if (g_fSoftwareCursor && !g_fCursor)
- {
- g_fCursor = TRUE;
- ShowCursor (TRUE);
- }
- return 0;
-
- case WM_LBUTTONDBLCLK:
- case WM_LBUTTONDOWN:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
- if (s_pScreenInfo->fRootless
-#ifdef XWIN_MULTIWINDOWEXTWM
- || s_pScreenInfo->fMWExtWM
-#endif
- )
- SetCapture (hwnd);
- return winMouseButtonsHandle (s_pScreen, ButtonPress, Button1, wParam);
-
- case WM_LBUTTONUP:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
- if (s_pScreenInfo->fRootless
-#ifdef XWIN_MULTIWINDOWEXTWM
- || s_pScreenInfo->fMWExtWM
-#endif
- )
- ReleaseCapture ();
- return winMouseButtonsHandle (s_pScreen, ButtonRelease, Button1, wParam);
-
- case WM_MBUTTONDBLCLK:
- case WM_MBUTTONDOWN:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
- if (s_pScreenInfo->fRootless
-#ifdef XWIN_MULTIWINDOWEXTWM
- || s_pScreenInfo->fMWExtWM
-#endif
- )
- SetCapture (hwnd);
- return winMouseButtonsHandle (s_pScreen, ButtonPress, Button2, wParam);
-
- case WM_MBUTTONUP:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
- if (s_pScreenInfo->fRootless
-#ifdef XWIN_MULTIWINDOWEXTWM
- || s_pScreenInfo->fMWExtWM
-#endif
- )
- ReleaseCapture ();
- return winMouseButtonsHandle (s_pScreen, ButtonRelease, Button2, wParam);
-
- case WM_RBUTTONDBLCLK:
- case WM_RBUTTONDOWN:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
- if (s_pScreenInfo->fRootless
-#ifdef XWIN_MULTIWINDOWEXTWM
- || s_pScreenInfo->fMWExtWM
-#endif
- )
- SetCapture (hwnd);
- return winMouseButtonsHandle (s_pScreen, ButtonPress, Button3, wParam);
-
- case WM_RBUTTONUP:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
- if (s_pScreenInfo->fRootless
-#ifdef XWIN_MULTIWINDOWEXTWM
- || s_pScreenInfo->fMWExtWM
-#endif
- )
- ReleaseCapture ();
- return winMouseButtonsHandle (s_pScreen, ButtonRelease, Button3, wParam);
-
- case WM_XBUTTONDBLCLK:
- case WM_XBUTTONDOWN:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
- if (s_pScreenInfo->fRootless
-#ifdef XWIN_MULTIWINDOWEXTWM
- || s_pScreenInfo->fMWExtWM
-#endif
- )
- SetCapture (hwnd);
- return winMouseButtonsHandle (s_pScreen, ButtonPress, HIWORD(wParam) + 5, wParam);
- case WM_XBUTTONUP:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
- if (s_pScreenInfo->fRootless
-#ifdef XWIN_MULTIWINDOWEXTWM
- || s_pScreenInfo->fMWExtWM
-#endif
- )
- ReleaseCapture ();
- return winMouseButtonsHandle (s_pScreen, ButtonRelease, HIWORD(wParam) + 5, wParam);
-
- case WM_TIMER:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
-
- /* Branch on the timer id */
- switch (wParam)
- {
- case WIN_E3B_TIMER_ID:
- /* Send delayed button press */
- winMouseButtonsSendEvent (ButtonPress,
- s_pScreenPriv->iE3BCachedPress);
-
- /* Kill this timer */
- KillTimer (s_pScreenPriv->hwndScreen, WIN_E3B_TIMER_ID);
-
- /* Clear screen privates flags */
- s_pScreenPriv->iE3BCachedPress = 0;
- break;
-
- case WIN_POLLING_MOUSE_TIMER_ID:
- {
- POINT point;
- WPARAM wL, wM, wR, wShift, wCtrl;
- LPARAM lPos;
-
- /* Get the current position of the mouse cursor */
- GetCursorPos (&point);
-
- /* Map from screen (-X, -Y) to root (0, 0) */
- point.x -= GetSystemMetrics (SM_XVIRTUALSCREEN);
- point.y -= GetSystemMetrics (SM_YVIRTUALSCREEN);
-
- /* Deliver absolute cursor position to X Server */
- winEnqueueMotion(point.x , point.y);
-
- /* Check if a button was released but we didn't see it */
- GetCursorPos (&point);
- wL = (GetKeyState (VK_LBUTTON) & 0x8000)?MK_LBUTTON:0;
- wM = (GetKeyState (VK_MBUTTON) & 0x8000)?MK_MBUTTON:0;
- wR = (GetKeyState (VK_RBUTTON) & 0x8000)?MK_RBUTTON:0;
- wShift = (GetKeyState (VK_SHIFT) & 0x8000)?MK_SHIFT:0;
- wCtrl = (GetKeyState (VK_CONTROL) & 0x8000)?MK_CONTROL:0;
- lPos = MAKELPARAM(point.x, point.y);
- if (g_fButton[0] & !wL)
- PostMessage (hwnd, WM_LBUTTONUP, wCtrl|wM|wR|wShift, lPos);
- if (g_fButton[1] & !wM)
- PostMessage (hwnd, WM_MBUTTONUP, wCtrl|wL|wR|wShift, lPos);
- if (g_fButton[2] & !wR)
- PostMessage (hwnd, WM_RBUTTONUP, wCtrl|wL|wM|wShift, lPos);
- }
- }
- return 0;
-
- case WM_CTLCOLORSCROLLBAR:
- FatalError ("winWindowProc - WM_CTLCOLORSCROLLBAR - We are not "
- "supposed to get this message. Exiting.\n");
- return 0;
-
- case WM_MOUSEWHEEL:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
- winDebug ("winWindowProc - WM_MOUSEWHEEL\n");
- winMouseWheel (s_pScreen, GET_WHEEL_DELTA_WPARAM(wParam));
- break;
-
- case WM_SETFOCUS:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
-
- /* Save handle of our main window that last received focus */
- g_hwndKeyboardFocus = hwnd;
-
- /* Restore the state of all mode keys */
- winRestoreModeKeyStates ();
-
- /* Add the keyboard hook if possible */
- if (g_fKeyboardHookLL)
- g_fKeyboardHookLL = winInstallKeyboardHookLL ();
- return 0;
-
- case WM_KILLFOCUS:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
-
- /* Clear handle of our main window that last received focus */
- g_hwndKeyboardFocus = NULL;
-
- /* Release any pressed keys */
- winKeybdReleaseKeys ();
-
- /* Remove our keyboard hook if it is installed */
- winRemoveKeyboardHookLL ();
- return 0;
-
- case WM_SYSKEYDOWN:
- case WM_KEYDOWN:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
-
- /*
- * FIXME: Catching Alt-F4 like this is really terrible. This should
- * be generalized to handle other Windows keyboard signals. Actually,
- * the list keys to catch and the actions to perform when caught should
- * be configurable; that way user's can customize the keys that they
- * need to have passed through to their window manager or apps, or they
- * can remap certain actions to new key codes that do not conflict
- * with the X apps that they are using. Yeah, that'll take awhile.
- */
- if ((s_pScreenInfo->fUseWinKillKey && wParam == VK_F4
- && (GetKeyState (VK_MENU) & 0x8000))
- || (s_pScreenInfo->fUseUnixKillKey && wParam == VK_BACK
- && (GetKeyState (VK_MENU) & 0x8000)
- && (GetKeyState (VK_CONTROL) & 0x8000)))
- {
- /*
- * Better leave this message here, just in case some unsuspecting
- * user enters Alt + F4 and is surprised when the application
- * quits.
- */
- winDebug ("winWindowProc - WM_*KEYDOWN - Closekey hit, quitting\n");
-
- /* Display Exit dialog */
- winDisplayExitDialog (s_pScreenPriv);
- return 0;
- }
-
- /*
- * Don't do anything for the Windows keys, as focus will soon
- * be returned to Windows. We may be able to trap the Windows keys,
- * but we should determine if that is desirable before doing so.
- */
- if ((wParam == VK_LWIN || wParam == VK_RWIN) && !g_fKeyboardHookLL)
- break;
-
- /*
- * Discard presses generated from Windows auto-repeat
- */
- if (lParam & (1<<30))
- {
- switch (wParam)
- {
- /* ago: Pressing LControl while RControl is pressed is
- * Indicated as repeat. Fix this!
- */
- case VK_CONTROL:
- case VK_SHIFT:
- if (winCheckKeyPressed(wParam, lParam))
- return 0;
- break;
- default:
- return 0;
- }
- }
-
- /* Discard fake Ctrl_L presses that precede AltGR on non-US keyboards */
- if (winIsFakeCtrl_L (message, wParam, lParam))
- return 0;
-
- /* Translate Windows key code to X scan code */
- winTranslateKey (wParam, lParam, &iScanCode);
-
- /* Ignore repeats for CapsLock */
- if (wParam == VK_CAPITAL)
- lParam = 1;
-
- /* Send the key event(s) */
- for (i = 0; i < LOWORD(lParam); ++i)
- winSendKeyEvent (iScanCode, TRUE);
- return 0;
-
- case WM_SYSKEYUP:
- case WM_KEYUP:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
-
- /*
- * Don't do anything for the Windows keys, as focus will soon
- * be returned to Windows. We may be able to trap the Windows keys,
- * but we should determine if that is desirable before doing so.
- */
- if ((wParam == VK_LWIN || wParam == VK_RWIN) && !g_fKeyboardHookLL)
- break;
-
- /* Ignore the fake Ctrl_L that follows an AltGr release */
- if (winIsFakeCtrl_L (message, wParam, lParam))
- return 0;
-
- /* Enqueue a keyup event */
- winTranslateKey (wParam, lParam, &iScanCode);
- winSendKeyEvent (iScanCode, FALSE);
-
- /* Release all pressed shift keys */
- if (wParam == VK_SHIFT)
- winFixShiftKeys (iScanCode);
- return 0;
-
- case WM_HOTKEY:
- if (s_pScreenPriv == NULL)
- break;
-
- /* Call the engine-specific hot key handler */
- (*s_pScreenPriv->pwinHotKeyAltTab) (s_pScreen);
- return 0;
-
- case WM_ACTIVATE:
- if (s_pScreenPriv == NULL
- || s_pScreenInfo->fIgnoreInput)
- break;
-
- /* TODO: Override display of window when we have a bad depth */
- if (LOWORD(wParam) != WA_INACTIVE && s_pScreenPriv->fBadDepth)
- {
- winDebug ("winWindowProc - WM_ACTIVATE - Bad depth, trying "
- "to override window activation\n");
-
- /* Minimize the window */
- ShowWindow (hwnd, SW_MINIMIZE);
-
- /* Display dialog box */
- if (g_hDlgDepthChange != NULL)
- {
- /* Make the existing dialog box active */
- SetActiveWindow (g_hDlgDepthChange);
- }
- else
- {
- /* TODO: Recreate the dialog box and bring to the top */
- ShowWindow (g_hDlgDepthChange, SW_SHOWDEFAULT);
- }
-
- /* Don't do any other processing of this message */
- return 0;
- }
-
- winDebug ("winWindowProc - WM_ACTIVATE\n");
-
- /*
- * Focus is being changed to another window.
- * The other window may or may not belong to
- * our process.
- */
-
- /* Clear any lingering wheel delta */
- s_pScreenPriv->iDeltaZ = 0;
-
- /* Reshow the Windows mouse cursor if we are being deactivated */
- if (g_fSoftwareCursor && LOWORD(wParam) == WA_INACTIVE
- && !g_fCursor)
- {
- /* Show Windows cursor */
- g_fCursor = TRUE;
- ShowCursor (TRUE);
- }
- return 0;
-
- case WM_ACTIVATEAPP:
- if (s_pScreenPriv == NULL
- || s_pScreenInfo->fIgnoreInput)
- break;
-
- winDebug ("winWindowProc - WM_ACTIVATEAPP\n");
-
- /* Activate or deactivate */
- s_pScreenPriv->fActive = wParam;
-
- /* Reshow the Windows mouse cursor if we are being deactivated */
- if (g_fSoftwareCursor && !s_pScreenPriv->fActive
- && !g_fCursor)
- {
- /* Show Windows cursor */
- g_fCursor = TRUE;
- ShowCursor (TRUE);
- }
-
-#ifdef XWIN_CLIPBOARD
- /* Make sure the clipboard chain is ok. */
- winFixClipboardChain ();
-#endif
-
- /* Call engine specific screen activation/deactivation function */
- (*s_pScreenPriv->pwinActivateApp) (s_pScreen);
-
-#ifdef XWIN_MULTIWINDOWEXTWM
- if (s_pScreenPriv->fActive)
- {
- /* Restack all window unless using built-in wm. */
- if (s_pScreenInfo->fInternalWM && s_pScreenInfo->fAnotherWMRunning)
- winMWExtWMRestackWindows (s_pScreen);
- }
-#endif
-
- return 0;
-
- case WM_COMMAND:
- switch (LOWORD (wParam))
- {
- case ID_APP_EXIT:
- /* Display Exit dialog */
- winDisplayExitDialog (s_pScreenPriv);
- return 0;
-
-#ifdef XWIN_MULTIWINDOW
- case ID_APP_HIDE_ROOT:
- if (s_pScreenPriv->fRootWindowShown)
- ShowWindow (s_pScreenPriv->hwndScreen, SW_HIDE);
- else
- ShowWindow (s_pScreenPriv->hwndScreen, SW_SHOW);
- s_pScreenPriv->fRootWindowShown = !s_pScreenPriv->fRootWindowShown;
- return 0;
-#endif
-
- case ID_APP_ABOUT:
- /* Display the About box */
- winDisplayAboutDialog (s_pScreenPriv);
- return 0;
-
- default:
- /* It's probably one of the custom menus... */
- if (HandleCustomWM_COMMAND (0, LOWORD (wParam)))
- return 0;
- }
- break;
-
- case WM_ENDSESSION:
- case WM_GIVEUP:
- /* Tell X that we are giving up */
-#ifdef XWIN_MULTIWINDOW
- if (s_pScreenInfo->fMultiWindow)
- winDeinitMultiWindowWM ();
-#endif
- g_fClipboardStarted=FALSE; /* This is to avoid dead-locls caused by the clipboard thread still doing some stuff */
- GiveUp (0);
- return 0;
-
- case WM_CLOSE:
- /* Display Exit dialog */
- winDisplayExitDialog (s_pScreenPriv);
- return 0;
-
- case WM_SETCURSOR:
- if (LOWORD(lParam) == HTCLIENT)
- {
- if (!g_fSoftwareCursor) SetCursor (s_pScreenPriv->cursor.handle);
- return TRUE;
- }
- break;
-
-#ifdef XWIN_MULTIWINDOWEXTWM
- case WM_MANAGE:
- winDebug ("winWindowProc - WM_MANAGE\n");
- s_pScreenInfo->fAnotherWMRunning = FALSE;
-
- if (s_pScreenInfo->fInternalWM)
- {
- EnumThreadWindows (g_dwCurrentThreadID, winMWExtWMDecorateWindow, 0);
- //RootlessRepositionWindows (s_pScreen);
- }
- break;
-
- case WM_UNMANAGE:
- winDebug ("winWindowProc - WM_UNMANAGE\n");
- s_pScreenInfo->fAnotherWMRunning = TRUE;
-
- if (s_pScreenInfo->fInternalWM)
- {
- EnumThreadWindows (g_dwCurrentThreadID, winMWExtWMDecorateWindow, 0);
- winMWExtWMRestackWindows (s_pScreen);
- }
- break;
-#endif
-
- default:
- if(message == s_uTaskbarRestart)
- {
- winInitNotifyIcon (s_pScreenPriv,FALSE);
- }
- break;
- }
-
- return DefWindowProc (hwnd, message, wParam, lParam);
-}
+/*
+ *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
+ * MATSUZAKI Kensuke
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+#include <commctrl.h>
+#include "winprefs.h"
+#include "winconfig.h"
+#include "winmsg.h"
+#include "inputstr.h"
+
+#ifndef XKB_IN_SERVER
+#define XKB_IN_SERVER
+#endif
+#include <xkbsrv.h>
+/*
+ * Global variables
+ */
+
+extern Bool g_fClipboardStarted;
+Bool g_fCursor = TRUE;
+Bool g_fButton[3] = { FALSE, FALSE, FALSE };
+
+
+/*
+ * Called by winWakeupHandler
+ * Processes current Windows message
+ */
+
+LRESULT CALLBACK
+winWindowProc (HWND hwnd, UINT message,
+ WPARAM wParam, LPARAM lParam)
+{
+ static winPrivScreenPtr s_pScreenPriv = NULL;
+ static winScreenInfo *s_pScreenInfo = NULL;
+ static ScreenPtr s_pScreen = NULL;
+ static HWND s_hwndLastPrivates = NULL;
+ static HINSTANCE s_hInstance;
+ static Bool s_fTracking = FALSE;
+ static unsigned long s_ulServerGeneration = 0;
+ static UINT s_uTaskbarRestart = 0;
+ int iScanCode;
+ int i;
+
+ winDebugWin32Message("winWindowProc", hwnd, message, wParam, lParam);
+
+ /* Watch for server regeneration */
+ if (g_ulServerGeneration != s_ulServerGeneration)
+ {
+ /* Store new server generation */
+ s_ulServerGeneration = g_ulServerGeneration;
+ }
+
+ /* Only retrieve new privates pointers if window handle is null or changed */
+ if ((s_pScreenPriv == NULL || hwnd != s_hwndLastPrivates)
+ && (s_pScreenPriv = GetProp (hwnd, WIN_SCR_PROP)) != NULL)
+ {
+ winDebug ("winWindowProc - Setting privates handle\n");
+ s_pScreenInfo = s_pScreenPriv->pScreenInfo;
+ s_pScreen = s_pScreenInfo->pScreen;
+ s_hwndLastPrivates = hwnd;
+ }
+ else if (s_pScreenPriv == NULL)
+ {
+ /* For safety, handle case that should never happen */
+ s_pScreenInfo = NULL;
+ s_pScreen = NULL;
+ s_hwndLastPrivates = NULL;
+ }
+
+ /* Branch on message type */
+ switch (message)
+ {
+ case WM_TRAYICON:
+ return winHandleIconMessage (hwnd, message, wParam, lParam,
+ s_pScreenPriv);
+
+ case WM_CREATE:
+ winDebug ("winWindowProc - WM_CREATE\n");
+
+ /*
+ * Add a property to our display window that references
+ * this screens' privates.
+ *
+ * This allows the window procedure to refer to the
+ * appropriate window DC and shadow DC for the window that
+ * it is processing. We use this to repaint exposed
+ * areas of our display window.
+ */
+ s_pScreenPriv = ((LPCREATESTRUCT) lParam)->lpCreateParams;
+ s_hInstance = ((LPCREATESTRUCT) lParam)->hInstance;
+ s_pScreenInfo = s_pScreenPriv->pScreenInfo;
+ s_pScreen = s_pScreenInfo->pScreen;
+ s_hwndLastPrivates = hwnd;
+ s_uTaskbarRestart = RegisterWindowMessage(TEXT("TaskbarCreated"));
+ SetProp (hwnd, WIN_SCR_PROP, s_pScreenPriv);
+
+ /* Setup tray icon */
+ if (!s_pScreenInfo->fNoTrayIcon)
+ {
+ /*
+ * NOTE: The WM_CREATE message is processed before CreateWindowEx
+ * returns, so s_pScreenPriv->hwndScreen is invalid at this point.
+ * We go ahead and copy our hwnd parameter over top of the screen
+ * privates hwndScreen so that we have a valid value for
+ * that member. Otherwise, the tray icon will disappear
+ * the first time you move the mouse over top of it.
+ */
+
+ s_pScreenPriv->hwndScreen = hwnd;
+
+ winInitNotifyIcon (s_pScreenPriv,FALSE);
+ }
+ return 0;
+
+ case WM_DISPLAYCHANGE:
+ /* We cannot handle a display mode change during initialization */
+ if (s_pScreenInfo == NULL)
+ FatalError ("winWindowProc - WM_DISPLAYCHANGE - The display "
+ "mode changed while we were intializing. This is "
+ "very bad and unexpected. Exiting.\n");
+
+ /*
+ * We do not care about display changes with
+ * fullscreen DirectDraw engines, because those engines set
+ * their own mode when they become active.
+ */
+ if (s_pScreenInfo->fFullScreen
+ && (s_pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DD
+ || s_pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL
+#ifdef XWIN_PRIMARYFB
+ || s_pScreenInfo->dwEngine == WIN_SERVER_PRIMARY_DD
+#endif
+ ))
+ {
+ /*
+ * Store the new display dimensions and depth.
+ * We do this here for future compatibility in case we
+ * ever allow switching from fullscreen to windowed mode.
+ */
+ s_pScreenPriv->dwLastWindowsWidth = GetSystemMetrics (SM_CXSCREEN);
+ s_pScreenPriv->dwLastWindowsHeight = GetSystemMetrics (SM_CYSCREEN);
+ s_pScreenPriv->dwLastWindowsBitsPixel
+ = GetDeviceCaps (s_pScreenPriv->hdcScreen, BITSPIXEL);
+ break;
+ }
+
+ winDebug ("winWindowProc - WM_DISPLAYCHANGE - orig bpp: %d, last bpp: %d, "
+ "new bpp: %d\n",
+ (int) s_pScreenInfo->dwBPP,
+ (int) s_pScreenPriv->dwLastWindowsBitsPixel,
+ wParam);
+
+ winDebug ("winWindowProc - WM_DISPLAYCHANGE - new width: %d "
+ "new height: %d\n",
+ LOWORD (lParam), HIWORD (lParam));
+
+ /*
+ * TrueColor --> TrueColor depth changes are disruptive for:
+ * Windowed:
+ * Shadow DirectDraw
+ * Shadow DirectDraw Non-Locking
+ * Primary DirectDraw
+ *
+ * TrueColor --> TrueColor depth changes are non-optimal for:
+ * Windowed:
+ * Shadow GDI
+ *
+ * FullScreen:
+ * Shadow GDI
+ *
+ * TrueColor --> PseudoColor or vice versa are disruptive for:
+ * Windowed:
+ * Shadow DirectDraw
+ * Shadow DirectDraw Non-Locking
+ * Primary DirectDraw
+ * Shadow GDI
+ */
+
+ /*
+ * Check for a disruptive change in depth.
+ * We can only display a message for a disruptive depth change,
+ * we cannot do anything to correct the situation.
+ */
+ if ((s_pScreenInfo->dwBPP != wParam)
+ && (s_pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DD
+ || s_pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL
+#ifdef XWIN_PRIMARYFB
+ || s_pScreenInfo->dwEngine == WIN_SERVER_PRIMARY_DD
+#endif
+ ))
+ {
+ /* Cannot display the visual until the depth is restored */
+ winDebug ("winWindowProc - Disruptive change in depth\n");
+
+ /* Display Exit dialog */
+ winDisplayDepthChangeDialog (s_pScreenPriv);
+
+ /* Flag that we have an invalid screen depth */
+ s_pScreenPriv->fBadDepth = TRUE;
+
+ /* Minimize the display window */
+ ShowWindow (hwnd, SW_MINIMIZE);
+ }
+ else
+ {
+ /* Flag that we have a valid screen depth */
+ s_pScreenPriv->fBadDepth = FALSE;
+ }
+
+ /*
+ * Check for a change in display dimensions.
+ * We can simply recreate the same-sized primary surface when
+ * the display dimensions change.
+ */
+ if (s_pScreenPriv->dwLastWindowsWidth != LOWORD (lParam)
+ || s_pScreenPriv->dwLastWindowsHeight != HIWORD (lParam))
+ {
+ /*
+ * NOTE: The non-DirectDraw engines set the ReleasePrimarySurface
+ * and CreatePrimarySurface function pointers to point
+ * to the no operation function, NoopDDA. This allows us
+ * to blindly call these functions, even if they are not
+ * relevant to the current engine (e.g., Shadow GDI).
+ */
+
+ winDebug ("winWindowProc - WM_DISPLAYCHANGE - Dimensions changed\n");
+
+ /* Release the old primary surface */
+ (*s_pScreenPriv->pwinReleasePrimarySurface) (s_pScreen);
+
+ winDebug ("winWindowProc - WM_DISPLAYCHANGE - Released "
+ "primary surface\n");
+
+ /* Create the new primary surface */
+ (*s_pScreenPriv->pwinCreatePrimarySurface) (s_pScreen);
+
+ winDebug ("winWindowProc - WM_DISPLAYCHANGE - Recreated "
+ "primary surface\n");
+
+#if 0
+ /* Multi-Window mode uses RandR for resizes */
+ if (s_pScreenInfo->fMultiWindow)
+ {
+ RRSetScreenConfig ();
+ }
+#endif
+ }
+ else
+ {
+ winDebug ("winWindowProc - WM_DISPLAYCHANGE - Dimensions did not "
+ "change\n");
+ }
+
+ /* Store the new display dimensions and depth */
+ if (s_pScreenInfo->fMultipleMonitors)
+ {
+ s_pScreenPriv->dwLastWindowsWidth
+ = GetSystemMetrics (SM_CXVIRTUALSCREEN);
+ s_pScreenPriv->dwLastWindowsHeight
+ = GetSystemMetrics (SM_CYVIRTUALSCREEN);
+ }
+ else
+ {
+ s_pScreenPriv->dwLastWindowsWidth
+ = GetSystemMetrics (SM_CXSCREEN);
+ s_pScreenPriv->dwLastWindowsHeight
+ = GetSystemMetrics (SM_CYSCREEN);
+ }
+ s_pScreenPriv->dwLastWindowsBitsPixel
+ = GetDeviceCaps (s_pScreenPriv->hdcScreen, BITSPIXEL);
+ break;
+
+ case WM_SIZE:
+ {
+ SCROLLINFO si;
+ RECT rcWindow;
+ int iWidth, iHeight;
+
+ winDebug ("winWindowProc - WM_SIZE\n");
+
+ /* Break if we do not use scrollbars */
+ if (!s_pScreenInfo->fScrollbars
+ || !s_pScreenInfo->fDecoration
+#ifdef XWIN_MULTIWINDOWEXTWM
+ || s_pScreenInfo->fMWExtWM
+#endif
+ || s_pScreenInfo->fRootless
+#ifdef XWIN_MULTIWINDOW
+ || s_pScreenInfo->fMultiWindow
+#endif
+ || s_pScreenInfo->fFullScreen)
+ break;
+
+ /* No need to resize if we get minimized */
+ if (wParam == SIZE_MINIMIZED)
+ return 0;
+
+ /*
+ * Get the size of the whole window, including client area,
+ * scrollbars, and non-client area decorations (caption, borders).
+ * We do this because we need to check if the client area
+ * without scrollbars is large enough to display the whole visual.
+ * The new client area size passed by lParam already subtracts
+ * the size of the scrollbars if they are currently displayed.
+ * So checking is LOWORD(lParam) == visual_width and
+ * HIWORD(lParam) == visual_height will never tell us to hide
+ * the scrollbars because the client area would always be too small.
+ * GetClientRect returns the same sizes given by lParam, so we
+ * cannot use GetClientRect either.
+ */
+ GetWindowRect (hwnd, &rcWindow);
+ iWidth = rcWindow.right - rcWindow.left;
+ iHeight = rcWindow.bottom - rcWindow.top;
+
+ winDebug ("winWindowProc - WM_SIZE - window w: %d h: %d, "
+ "new client area w: %d h: %d\n",
+ iWidth, iHeight, LOWORD (lParam), HIWORD (lParam));
+
+ /* Subtract the frame size from the window size. */
+ iWidth -= 2 * GetSystemMetrics (SM_CXSIZEFRAME);
+ iHeight -= (2 * GetSystemMetrics (SM_CYSIZEFRAME)
+ + GetSystemMetrics (SM_CYCAPTION));
+
+ /*
+ * Update scrollbar page sizes.
+ * NOTE: If page size == range, then the scrollbar is
+ * automatically hidden.
+ */
+
+ /* Is the naked client area large enough to show the whole visual? */
+ if (iWidth < s_pScreenInfo->dwWidth
+ || iHeight < s_pScreenInfo->dwHeight)
+ {
+ /* Client area too small to display visual, use scrollbars */
+ iWidth -= GetSystemMetrics (SM_CXVSCROLL);
+ iHeight -= GetSystemMetrics (SM_CYHSCROLL);
+ }
+
+ /* Set the horizontal scrollbar page size */
+ si.cbSize = sizeof (si);
+ si.fMask = SIF_PAGE | SIF_RANGE;
+ si.nMin = 0;
+ si.nMax = s_pScreenInfo->dwWidth - 1;
+ si.nPage = iWidth;
+ SetScrollInfo (hwnd, SB_HORZ, &si, TRUE);
+
+ /* Set the vertical scrollbar page size */
+ si.cbSize = sizeof (si);
+ si.fMask = SIF_PAGE | SIF_RANGE;
+ si.nMin = 0;
+ si.nMax = s_pScreenInfo->dwHeight - 1;
+ si.nPage = iHeight;
+ SetScrollInfo (hwnd, SB_VERT, &si, TRUE);
+
+ /*
+ * NOTE: Scrollbars may have moved if they were at the
+ * far right/bottom, so we query their current position.
+ */
+
+ /* Get the horizontal scrollbar position and set the offset */
+ si.cbSize = sizeof (si);
+ si.fMask = SIF_POS;
+ GetScrollInfo (hwnd, SB_HORZ, &si);
+ s_pScreenInfo->dwXOffset = -si.nPos;
+
+ /* Get the vertical scrollbar position and set the offset */
+ si.cbSize = sizeof (si);
+ si.fMask = SIF_POS;
+ GetScrollInfo (hwnd, SB_VERT, &si);
+ s_pScreenInfo->dwYOffset = -si.nPos;
+ }
+ return 0;
+
+ case WM_VSCROLL:
+ {
+ SCROLLINFO si;
+ int iVertPos;
+
+ winDebug ("winWindowProc - WM_VSCROLL\n");
+
+ /* Get vertical scroll bar info */
+ si.cbSize = sizeof (si);
+ si.fMask = SIF_ALL;
+ GetScrollInfo (hwnd, SB_VERT, &si);
+
+ /* Save the vertical position for comparison later */
+ iVertPos = si.nPos;
+
+ /*
+ * Don't forget:
+ * moving the scrollbar to the DOWN, scroll the content UP
+ */
+ switch (LOWORD(wParam))
+ {
+ case SB_TOP:
+ si.nPos = si.nMin;
+ break;
+
+ case SB_BOTTOM:
+ si.nPos = si.nMax - si.nPage + 1;
+ break;
+
+ case SB_LINEUP:
+ si.nPos -= 1;
+ break;
+
+ case SB_LINEDOWN:
+ si.nPos += 1;
+ break;
+
+ case SB_PAGEUP:
+ si.nPos -= si.nPage;
+ break;
+
+ case SB_PAGEDOWN:
+ si.nPos += si.nPage;
+ break;
+
+ case SB_THUMBTRACK:
+ si.nPos = si.nTrackPos;
+ break;
+
+ default:
+ break;
+ }
+
+ /*
+ * We retrieve the position after setting it,
+ * because Windows may adjust it.
+ */
+ si.fMask = SIF_POS;
+ SetScrollInfo (hwnd, SB_VERT, &si, TRUE);
+ GetScrollInfo (hwnd, SB_VERT, &si);
+
+ /* Scroll the window if the position has changed */
+ if (si.nPos != iVertPos)
+ {
+ /* Save the new offset for bit block transfers, etc. */
+ s_pScreenInfo->dwYOffset = -si.nPos;
+
+ /* Change displayed region in the window */
+ ScrollWindowEx (hwnd,
+ 0,
+ iVertPos - si.nPos,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ SW_INVALIDATE);
+
+ /* Redraw the window contents */
+ UpdateWindow (hwnd);
+ }
+ }
+ return 0;
+
+ case WM_HSCROLL:
+ {
+ SCROLLINFO si;
+ int iHorzPos;
+
+ winDebug ("winWindowProc - WM_HSCROLL\n");
+
+ /* Get horizontal scroll bar info */
+ si.cbSize = sizeof (si);
+ si.fMask = SIF_ALL;
+ GetScrollInfo (hwnd, SB_HORZ, &si);
+
+ /* Save the horizontal position for comparison later */
+ iHorzPos = si.nPos;
+
+ /*
+ * Don't forget:
+ * moving the scrollbar to the RIGHT, scroll the content LEFT
+ */
+ switch (LOWORD(wParam))
+ {
+ case SB_LEFT:
+ si.nPos = si.nMin;
+ break;
+
+ case SB_RIGHT:
+ si.nPos = si.nMax - si.nPage + 1;
+ break;
+
+ case SB_LINELEFT:
+ si.nPos -= 1;
+ break;
+
+ case SB_LINERIGHT:
+ si.nPos += 1;
+ break;
+
+ case SB_PAGELEFT:
+ si.nPos -= si.nPage;
+ break;
+
+ case SB_PAGERIGHT:
+ si.nPos += si.nPage;
+ break;
+
+ case SB_THUMBTRACK:
+ si.nPos = si.nTrackPos;
+ break;
+
+ default:
+ break;
+ }
+
+ /*
+ * We retrieve the position after setting it,
+ * because Windows may adjust it.
+ */
+ si.fMask = SIF_POS;
+ SetScrollInfo (hwnd, SB_HORZ, &si, TRUE);
+ GetScrollInfo (hwnd, SB_HORZ, &si);
+
+ /* Scroll the window if the position has changed */
+ if (si.nPos != iHorzPos)
+ {
+ /* Save the new offset for bit block transfers, etc. */
+ s_pScreenInfo->dwXOffset = -si.nPos;
+
+ /* Change displayed region in the window */
+ ScrollWindowEx (hwnd,
+ iHorzPos - si.nPos,
+ 0,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ SW_INVALIDATE);
+
+ /* Redraw the window contents */
+ UpdateWindow (hwnd);
+ }
+ }
+ return 0;
+
+ case WM_GETMINMAXINFO:
+ {
+ MINMAXINFO *pMinMaxInfo = (MINMAXINFO *) lParam;
+ int iCaptionHeight;
+ int iBorderHeight, iBorderWidth;
+
+ winDebug ("winWindowProc - WM_GETMINMAXINFO - pScreenInfo: %08x\n",
+ s_pScreenInfo);
+
+ /* Can't do anything without screen info */
+ if (s_pScreenInfo == NULL
+ || !s_pScreenInfo->fScrollbars
+ || s_pScreenInfo->fFullScreen
+ || !s_pScreenInfo->fDecoration
+#ifdef XWIN_MULTIWINDOWEXTWM
+ || s_pScreenInfo->fMWExtWM
+#endif
+ || s_pScreenInfo->fRootless
+#ifdef XWIN_MULTIWINDOW
+ || s_pScreenInfo->fMultiWindow
+#endif
+ )
+ break;
+
+ /*
+ * Here we can override the maximum tracking size, which
+ * is the largest size that can be assigned to our window
+ * via the sizing border.
+ */
+
+ /*
+ * FIXME: Do we only need to do this once, since our visual size
+ * does not change? Does Windows store this value statically
+ * once we have set it once?
+ */
+
+ /* Get the border and caption sizes */
+ iCaptionHeight = GetSystemMetrics (SM_CYCAPTION);
+ iBorderWidth = 2 * GetSystemMetrics (SM_CXSIZEFRAME);
+ iBorderHeight = 2 * GetSystemMetrics (SM_CYSIZEFRAME);
+
+ /* Allow the full visual to be displayed */
+ pMinMaxInfo->ptMaxTrackSize.x
+ = s_pScreenInfo->dwWidth + iBorderWidth;
+ pMinMaxInfo->ptMaxTrackSize.y
+ = s_pScreenInfo->dwHeight + iBorderHeight + iCaptionHeight;
+ }
+ return 0;
+
+ case WM_ERASEBKGND:
+ winDebug ("winWindowProc - WM_ERASEBKGND\n");
+ /*
+ * Pretend that we did erase the background but we don't care,
+ * the application uses the full window estate. This avoids some
+ * flickering when resizing.
+ */
+ return TRUE;
+
+ case WM_PAINT:
+ /* Only paint if we have privates and the server is enabled */
+ if (s_pScreenPriv == NULL
+ || !s_pScreenPriv->fEnabled
+ || (s_pScreenInfo->fFullScreen && !s_pScreenPriv->fActive)
+ || s_pScreenPriv->fBadDepth)
+ {
+ /* We don't want to paint */
+ break;
+ }
+
+ /* Break out here if we don't have a valid paint routine */
+ if (s_pScreenPriv->pwinBltExposedRegions == NULL)
+ break;
+
+ /* Call the engine dependent repainter */
+ (*s_pScreenPriv->pwinBltExposedRegions) (s_pScreen);
+ return 0;
+
+ case WM_PALETTECHANGED:
+ {
+ winDebug ("winWindowProc - WM_PALETTECHANGED\n");
+ /*
+ * Don't process if we don't have privates or a colormap,
+ * or if we have an invalid depth.
+ */
+ if (s_pScreenPriv == NULL
+ || s_pScreenPriv->pcmapInstalled == NULL
+ || s_pScreenPriv->fBadDepth)
+ break;
+
+ /* Return if we caused the palette to change */
+ if ((HWND) wParam == hwnd)
+ {
+ /* Redraw the screen */
+ (*s_pScreenPriv->pwinRedrawScreen) (s_pScreen);
+ return 0;
+ }
+
+ /* Reinstall the windows palette */
+ (*s_pScreenPriv->pwinRealizeInstalledPalette) (s_pScreen);
+
+ /* Redraw the screen */
+ (*s_pScreenPriv->pwinRedrawScreen) (s_pScreen);
+ return 0;
+ }
+
+ case WM_MOUSEMOVE:
+ /* We can't do anything without privates */
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+
+ /* We can't do anything without g_pwinPointer */
+ if (g_pwinPointer == NULL)
+ break;
+
+ /* Has the mouse pointer crossed screens? */
+ if (s_pScreen != miPointerGetScreen(g_pwinPointer))
+ miPointerSetScreen (g_pwinPointer, s_pScreenInfo->dwScreen,
+ GET_X_LPARAM(lParam)-s_pScreenInfo->dwXOffset,
+ GET_Y_LPARAM(lParam)-s_pScreenInfo->dwYOffset);
+
+ /* Are we tracking yet? */
+ if (!s_fTracking)
+ {
+ TRACKMOUSEEVENT tme;
+
+ /* Setup data structure */
+ ZeroMemory (&tme, sizeof (tme));
+ tme.cbSize = sizeof (tme);
+ tme.dwFlags = TME_LEAVE;
+ tme.hwndTrack = hwnd;
+
+ /* Call the tracking function */
+ if (!(*g_fpTrackMouseEvent) (&tme))
+ ErrorF ("winWindowProc - _TrackMouseEvent failed\n");
+
+ /* Flag that we are tracking now */
+ s_fTracking = TRUE;
+ }
+
+ /* Hide or show the Windows mouse cursor */
+ if (g_fSoftwareCursor && g_fCursor && (s_pScreenPriv->fActive || s_pScreenInfo->fLessPointer))
+ {
+ /* Hide Windows cursor */
+ g_fCursor = FALSE;
+ ShowCursor (FALSE);
+ }
+ else if (g_fSoftwareCursor && !g_fCursor && !s_pScreenPriv->fActive
+ && !s_pScreenInfo->fLessPointer)
+ {
+ /* Show Windows cursor */
+ g_fCursor = TRUE;
+ ShowCursor (TRUE);
+ }
+
+ /* Deliver absolute cursor position to X Server */
+ winEnqueueMotion(GET_X_LPARAM(lParam)-s_pScreenInfo->dwXOffset,
+ GET_Y_LPARAM(lParam)-s_pScreenInfo->dwYOffset);
+ return 0;
+
+ case WM_NCMOUSEMOVE:
+ /*
+ * We break instead of returning 0 since we need to call
+ * DefWindowProc to get the mouse cursor changes
+ * and min/max/close button highlighting in Windows XP.
+ * The Platform SDK says that you should return 0 if you
+ * process this message, but it fails to mention that you
+ * will give up any default functionality if you do return 0.
+ */
+
+ /* We can't do anything without privates */
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+
+ /* Non-client mouse movement, show Windows cursor */
+ if (g_fSoftwareCursor && !g_fCursor)
+ {
+ g_fCursor = TRUE;
+ ShowCursor (TRUE);
+ }
+ break;
+
+ case WM_MOUSELEAVE:
+ /* Mouse has left our client area */
+
+ /* Flag that we are no longer tracking */
+ s_fTracking = FALSE;
+
+ /* Show the mouse cursor, if necessary */
+ if (g_fSoftwareCursor && !g_fCursor)
+ {
+ g_fCursor = TRUE;
+ ShowCursor (TRUE);
+ }
+ return 0;
+
+ case WM_LBUTTONDBLCLK:
+ case WM_LBUTTONDOWN:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ if (s_pScreenInfo->fRootless
+#ifdef XWIN_MULTIWINDOWEXTWM
+ || s_pScreenInfo->fMWExtWM
+#endif
+ )
+ SetCapture (hwnd);
+ return winMouseButtonsHandle (s_pScreen, ButtonPress, Button1, wParam);
+
+ case WM_LBUTTONUP:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ if (s_pScreenInfo->fRootless
+#ifdef XWIN_MULTIWINDOWEXTWM
+ || s_pScreenInfo->fMWExtWM
+#endif
+ )
+ ReleaseCapture ();
+ return winMouseButtonsHandle (s_pScreen, ButtonRelease, Button1, wParam);
+
+ case WM_MBUTTONDBLCLK:
+ case WM_MBUTTONDOWN:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ if (s_pScreenInfo->fRootless
+#ifdef XWIN_MULTIWINDOWEXTWM
+ || s_pScreenInfo->fMWExtWM
+#endif
+ )
+ SetCapture (hwnd);
+ return winMouseButtonsHandle (s_pScreen, ButtonPress, Button2, wParam);
+
+ case WM_MBUTTONUP:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ if (s_pScreenInfo->fRootless
+#ifdef XWIN_MULTIWINDOWEXTWM
+ || s_pScreenInfo->fMWExtWM
+#endif
+ )
+ ReleaseCapture ();
+ return winMouseButtonsHandle (s_pScreen, ButtonRelease, Button2, wParam);
+
+ case WM_RBUTTONDBLCLK:
+ case WM_RBUTTONDOWN:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ if (s_pScreenInfo->fRootless
+#ifdef XWIN_MULTIWINDOWEXTWM
+ || s_pScreenInfo->fMWExtWM
+#endif
+ )
+ SetCapture (hwnd);
+ return winMouseButtonsHandle (s_pScreen, ButtonPress, Button3, wParam);
+
+ case WM_RBUTTONUP:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ if (s_pScreenInfo->fRootless
+#ifdef XWIN_MULTIWINDOWEXTWM
+ || s_pScreenInfo->fMWExtWM
+#endif
+ )
+ ReleaseCapture ();
+ return winMouseButtonsHandle (s_pScreen, ButtonRelease, Button3, wParam);
+
+ case WM_XBUTTONDBLCLK:
+ case WM_XBUTTONDOWN:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ if (s_pScreenInfo->fRootless
+#ifdef XWIN_MULTIWINDOWEXTWM
+ || s_pScreenInfo->fMWExtWM
+#endif
+ )
+ SetCapture (hwnd);
+ return winMouseButtonsHandle (s_pScreen, ButtonPress, HIWORD(wParam) + 5, wParam);
+ case WM_XBUTTONUP:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ if (s_pScreenInfo->fRootless
+#ifdef XWIN_MULTIWINDOWEXTWM
+ || s_pScreenInfo->fMWExtWM
+#endif
+ )
+ ReleaseCapture ();
+ return winMouseButtonsHandle (s_pScreen, ButtonRelease, HIWORD(wParam) + 5, wParam);
+
+ case WM_TIMER:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+
+ /* Branch on the timer id */
+ switch (wParam)
+ {
+ case WIN_E3B_TIMER_ID:
+ /* Send delayed button press */
+ winMouseButtonsSendEvent (ButtonPress,
+ s_pScreenPriv->iE3BCachedPress);
+
+ /* Kill this timer */
+ KillTimer (s_pScreenPriv->hwndScreen, WIN_E3B_TIMER_ID);
+
+ /* Clear screen privates flags */
+ s_pScreenPriv->iE3BCachedPress = 0;
+ break;
+
+ case WIN_POLLING_MOUSE_TIMER_ID:
+ {
+ POINT point;
+ WPARAM wL, wM, wR, wShift, wCtrl;
+ LPARAM lPos;
+
+ /* Get the current position of the mouse cursor */
+ GetCursorPos (&point);
+
+ /* Map from screen (-X, -Y) to root (0, 0) */
+ point.x -= GetSystemMetrics (SM_XVIRTUALSCREEN);
+ point.y -= GetSystemMetrics (SM_YVIRTUALSCREEN);
+
+ /* Deliver absolute cursor position to X Server */
+ winEnqueueMotion(point.x , point.y);
+
+ /* Check if a button was released but we didn't see it */
+ GetCursorPos (&point);
+ wL = (GetKeyState (VK_LBUTTON) & 0x8000)?MK_LBUTTON:0;
+ wM = (GetKeyState (VK_MBUTTON) & 0x8000)?MK_MBUTTON:0;
+ wR = (GetKeyState (VK_RBUTTON) & 0x8000)?MK_RBUTTON:0;
+ wShift = (GetKeyState (VK_SHIFT) & 0x8000)?MK_SHIFT:0;
+ wCtrl = (GetKeyState (VK_CONTROL) & 0x8000)?MK_CONTROL:0;
+ lPos = MAKELPARAM(point.x, point.y);
+ if (g_fButton[0] & !wL)
+ PostMessage (hwnd, WM_LBUTTONUP, wCtrl|wM|wR|wShift, lPos);
+ if (g_fButton[1] & !wM)
+ PostMessage (hwnd, WM_MBUTTONUP, wCtrl|wL|wR|wShift, lPos);
+ if (g_fButton[2] & !wR)
+ PostMessage (hwnd, WM_RBUTTONUP, wCtrl|wL|wM|wShift, lPos);
+ }
+ }
+ return 0;
+
+ case WM_CTLCOLORSCROLLBAR:
+ FatalError ("winWindowProc - WM_CTLCOLORSCROLLBAR - We are not "
+ "supposed to get this message. Exiting.\n");
+ return 0;
+
+ case WM_MOUSEWHEEL:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ winDebug ("winWindowProc - WM_MOUSEWHEEL\n");
+ winMouseWheel (s_pScreen, GET_WHEEL_DELTA_WPARAM(wParam));
+ break;
+
+ case WM_SETFOCUS:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+
+ /* Restore the state of all mode keys */
+ winRestoreModeKeyStates ();
+
+ /* Add the keyboard hook if possible */
+ if (g_fKeyboardHookLL)
+ g_fKeyboardHookLL = winInstallKeyboardHookLL ();
+ return 0;
+
+ case WM_KILLFOCUS:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+
+ /* Release any pressed keys */
+ winKeybdReleaseKeys ();
+
+ /* Remove our keyboard hook if it is installed */
+ winRemoveKeyboardHookLL ();
+ return 0;
+
+ case WM_SYSKEYDOWN:
+ case WM_KEYDOWN:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+
+ /*
+ * FIXME: Catching Alt-F4 like this is really terrible. This should
+ * be generalized to handle other Windows keyboard signals. Actually,
+ * the list keys to catch and the actions to perform when caught should
+ * be configurable; that way user's can customize the keys that they
+ * need to have passed through to their window manager or apps, or they
+ * can remap certain actions to new key codes that do not conflict
+ * with the X apps that they are using. Yeah, that'll take awhile.
+ */
+ if ((s_pScreenInfo->fUseWinKillKey && wParam == VK_F4
+ && (GetKeyState (VK_MENU) & 0x8000))
+ || (s_pScreenInfo->fUseUnixKillKey && wParam == VK_BACK
+ && (GetKeyState (VK_MENU) & 0x8000)
+ && (GetKeyState (VK_CONTROL) & 0x8000)))
+ {
+ /*
+ * Better leave this message here, just in case some unsuspecting
+ * user enters Alt + F4 and is surprised when the application
+ * quits.
+ */
+ winDebug ("winWindowProc - WM_*KEYDOWN - Closekey hit, quitting\n");
+
+ /* Display Exit dialog */
+ winDisplayExitDialog (s_pScreenPriv);
+ return 0;
+ }
+
+ /*
+ * Don't do anything for the Windows keys, as focus will soon
+ * be returned to Windows. We may be able to trap the Windows keys,
+ * but we should determine if that is desirable before doing so.
+ */
+ if ((wParam == VK_LWIN || wParam == VK_RWIN) && !g_fKeyboardHookLL)
+ break;
+
+ /*
+ * Discard presses generated from Windows auto-repeat
+ */
+ if (lParam & (1<<30))
+ {
+ switch (wParam)
+ {
+ /* ago: Pressing LControl while RControl is pressed is
+ * Indicated as repeat. Fix this!
+ */
+ case VK_CONTROL:
+ case VK_SHIFT:
+ if (winCheckKeyPressed(wParam, lParam))
+ return 0;
+ break;
+ default:
+ return 0;
+ }
+ }
+
+ /* Discard fake Ctrl_L presses that precede AltGR on non-US keyboards */
+ if (winIsFakeCtrl_L (message, wParam, lParam))
+ return 0;
+
+ /* Translate Windows key code to X scan code */
+ winTranslateKey (wParam, lParam, &iScanCode);
+
+ /* Ignore repeats for CapsLock */
+ if (wParam == VK_CAPITAL)
+ lParam = 1;
+
+ /* Send the key event(s) */
+ for (i = 0; i < LOWORD(lParam); ++i)
+ winSendKeyEvent (iScanCode, TRUE);
+ return 0;
+
+ case WM_SYSKEYUP:
+ case WM_KEYUP:
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+
+ /*
+ * Don't do anything for the Windows keys, as focus will soon
+ * be returned to Windows. We may be able to trap the Windows keys,
+ * but we should determine if that is desirable before doing so.
+ */
+ if ((wParam == VK_LWIN || wParam == VK_RWIN) && !g_fKeyboardHookLL)
+ break;
+
+ /* Ignore the fake Ctrl_L that follows an AltGr release */
+ if (winIsFakeCtrl_L (message, wParam, lParam))
+ return 0;
+
+ /* Enqueue a keyup event */
+ winTranslateKey (wParam, lParam, &iScanCode);
+ winSendKeyEvent (iScanCode, FALSE);
+
+ /* Release all pressed shift keys */
+ if (wParam == VK_SHIFT)
+ winFixShiftKeys (iScanCode);
+ return 0;
+
+ case WM_HOTKEY:
+ if (s_pScreenPriv == NULL)
+ break;
+
+ /* Call the engine-specific hot key handler */
+ (*s_pScreenPriv->pwinHotKeyAltTab) (s_pScreen);
+ return 0;
+
+ case WM_ACTIVATE:
+ if (s_pScreenPriv == NULL
+ || s_pScreenInfo->fIgnoreInput)
+ break;
+
+ /* TODO: Override display of window when we have a bad depth */
+ if (LOWORD(wParam) != WA_INACTIVE && s_pScreenPriv->fBadDepth)
+ {
+ winDebug ("winWindowProc - WM_ACTIVATE - Bad depth, trying "
+ "to override window activation\n");
+
+ /* Minimize the window */
+ ShowWindow (hwnd, SW_MINIMIZE);
+
+ /* Display dialog box */
+ if (g_hDlgDepthChange != NULL)
+ {
+ /* Make the existing dialog box active */
+ SetActiveWindow (g_hDlgDepthChange);
+ }
+ else
+ {
+ /* TODO: Recreate the dialog box and bring to the top */
+ ShowWindow (g_hDlgDepthChange, SW_SHOWDEFAULT);
+ }
+
+ /* Don't do any other processing of this message */
+ return 0;
+ }
+
+ winDebug ("winWindowProc - WM_ACTIVATE\n");
+
+ /*
+ * Focus is being changed to another window.
+ * The other window may or may not belong to
+ * our process.
+ */
+
+ /* Clear any lingering wheel delta */
+ s_pScreenPriv->iDeltaZ = 0;
+
+ /* Reshow the Windows mouse cursor if we are being deactivated */
+ if (g_fSoftwareCursor && LOWORD(wParam) == WA_INACTIVE
+ && !g_fCursor)
+ {
+ /* Show Windows cursor */
+ g_fCursor = TRUE;
+ ShowCursor (TRUE);
+ }
+ return 0;
+
+ case WM_ACTIVATEAPP:
+ if (s_pScreenPriv == NULL
+ || s_pScreenInfo->fIgnoreInput)
+ break;
+
+ winDebug ("winWindowProc - WM_ACTIVATEAPP\n");
+
+ /* Activate or deactivate */
+ s_pScreenPriv->fActive = wParam;
+
+ /* Reshow the Windows mouse cursor if we are being deactivated */
+ if (g_fSoftwareCursor && !s_pScreenPriv->fActive
+ && !g_fCursor)
+ {
+ /* Show Windows cursor */
+ g_fCursor = TRUE;
+ ShowCursor (TRUE);
+ }
+
+#ifdef XWIN_CLIPBOARD
+ /* Make sure the clipboard chain is ok. */
+ winFixClipboardChain ();
+#endif
+
+ /* Call engine specific screen activation/deactivation function */
+ (*s_pScreenPriv->pwinActivateApp) (s_pScreen);
+
+#ifdef XWIN_MULTIWINDOWEXTWM
+ if (s_pScreenPriv->fActive)
+ {
+ /* Restack all window unless using built-in wm. */
+ if (s_pScreenInfo->fInternalWM && s_pScreenInfo->fAnotherWMRunning)
+ winMWExtWMRestackWindows (s_pScreen);
+ }
+#endif
+
+ return 0;
+
+ case WM_COMMAND:
+ switch (LOWORD (wParam))
+ {
+ case ID_APP_EXIT:
+ /* Display Exit dialog */
+ winDisplayExitDialog (s_pScreenPriv);
+ return 0;
+
+#ifdef XWIN_MULTIWINDOW
+ case ID_APP_HIDE_ROOT:
+ if (s_pScreenPriv->fRootWindowShown)
+ ShowWindow (s_pScreenPriv->hwndScreen, SW_HIDE);
+ else
+ ShowWindow (s_pScreenPriv->hwndScreen, SW_SHOW);
+ s_pScreenPriv->fRootWindowShown = !s_pScreenPriv->fRootWindowShown;
+ return 0;
+#endif
+
+ case ID_APP_ABOUT:
+ /* Display the About box */
+ winDisplayAboutDialog (s_pScreenPriv);
+ return 0;
+
+ default:
+ /* It's probably one of the custom menus... */
+ if (HandleCustomWM_COMMAND (0, LOWORD (wParam)))
+ return 0;
+ }
+ break;
+
+ case WM_ENDSESSION:
+ case WM_GIVEUP:
+ /* Tell X that we are giving up */
+#ifdef XWIN_MULTIWINDOW
+ if (s_pScreenInfo->fMultiWindow)
+ winDeinitMultiWindowWM ();
+#endif
+ g_fClipboardStarted=FALSE; /* This is to avoid dead-locls caused by the clipboard thread still doing some stuff */
+ GiveUp (0);
+ return 0;
+
+ case WM_CLOSE:
+ /* Display Exit dialog */
+ winDisplayExitDialog (s_pScreenPriv);
+ return 0;
+
+ case WM_SETCURSOR:
+ if (LOWORD(lParam) == HTCLIENT)
+ {
+ if (!g_fSoftwareCursor) SetCursor (s_pScreenPriv->cursor.handle);
+ return TRUE;
+ }
+ break;
+
+#ifdef XWIN_MULTIWINDOWEXTWM
+ case WM_MANAGE:
+ winDebug ("winWindowProc - WM_MANAGE\n");
+ s_pScreenInfo->fAnotherWMRunning = FALSE;
+
+ if (s_pScreenInfo->fInternalWM)
+ {
+ EnumThreadWindows (g_dwCurrentThreadID, winMWExtWMDecorateWindow, 0);
+ //RootlessRepositionWindows (s_pScreen);
+ }
+ break;
+
+ case WM_UNMANAGE:
+ winDebug ("winWindowProc - WM_UNMANAGE\n");
+ s_pScreenInfo->fAnotherWMRunning = TRUE;
+
+ if (s_pScreenInfo->fInternalWM)
+ {
+ EnumThreadWindows (g_dwCurrentThreadID, winMWExtWMDecorateWindow, 0);
+ winMWExtWMRestackWindows (s_pScreen);
+ }
+ break;
+#endif
+
+ default:
+ if(message == s_uTaskbarRestart)
+ {
+ winInitNotifyIcon (s_pScreenPriv,FALSE);
+ }
+ break;
+ }
+
+ return DefWindowProc (hwnd, message, wParam, lParam);
+}
diff --git a/xorg-server/include/eventstr.h b/xorg-server/include/eventstr.h
index 6a3410c19..1705900f8 100644
--- a/xorg-server/include/eventstr.h
+++ b/xorg-server/include/eventstr.h
@@ -99,7 +99,7 @@ struct _DeviceEvent
struct {
uint8_t mask[(MAX_VALUATORS + 7)/8]; /**< Valuator mask */
uint8_t mode[(MAX_VALUATORS + 7)/8]; /**< Valuator mode (Abs or Rel)*/
- int32_t data[MAX_VALUATORS]; /**< Valuator data */
+ int32_t data[MAX_VALUATORS]; /**< Valuator data */
int32_t data_frac[MAX_VALUATORS]; /**< Fractional part for data */
} valuators;
struct {
diff --git a/xorg-server/os/access.c b/xorg-server/os/access.c
index 6398a6f92..11c1319d2 100644
--- a/xorg-server/os/access.c
+++ b/xorg-server/os/access.c
@@ -104,11 +104,7 @@ SOFTWARE.
#if defined(TCPCONN) || defined(STREAMSCONN) || defined(__SCO__)
#include <netinet/in.h>
-#endif /* TCPCONN || STREAMSCONN || ISC || __SCO__ */
-#ifdef DNETCONN
-#include <netdnet/dn.h>
-#include <netdnet/dnetdb.h>
-#endif
+#endif /* TCPCONN || STREAMSCONN || __SCO__ */
#ifdef HAS_GETPEERUCRED
# include <ucred.h>
@@ -333,7 +329,7 @@ ifioctl (int fd, int cmd, char *arg)
}
#else /* Case sun, SCO325 and others */
#define ifioctl ioctl
-#endif /* ((SVR4 && !sun !SCO325) || ISC) && SIOCGIFCONF */
+#endif
/*
* DefineSelf (fd):
@@ -346,7 +342,7 @@ ifioctl (int fd, int cmd, char *arg)
void
DefineSelf (int fd)
{
-#if !defined(TCPCONN) && !defined(STREAMSCONN) && !defined(UNIXCONN) && !defined(MNX_TCPCONN)
+#if !defined(TCPCONN) && !defined(STREAMSCONN) && !defined(UNIXCONN)
return;
#else
register int n;
@@ -491,7 +487,7 @@ DefineLocalHost:
selfhosts = host;
}
}
-#endif /* !TCPCONN && !STREAMSCONN && !UNIXCONN && !MNX_TCPCONN */
+#endif /* !TCPCONN && !STREAMSCONN && !UNIXCONN */
}
#else
@@ -556,35 +552,6 @@ DefineSelf (int fd)
int family;
register HOST *host;
-#ifdef DNETCONN
- struct dn_naddr *dnaddr = getnodeadd();
- /*
- * AF_DECnet may not be listed in the interface list. Instead use
- * the supported library call to find out the local address (if any).
- */
- if (dnaddr)
- {
- addr = (unsigned char *) dnaddr;
- len = dnaddr->a_len + sizeof(dnaddr->a_len);
- family = FamilyDECnet;
- for (host = selfhosts;
- host && !addrEqual (family, addr, len, host);
- host = host->next)
- ;
- if (!host)
- {
- MakeHost(host,len)
- if (host)
- {
- host->family = family;
- host->len = len;
- acopy(addr, host->addr, len);
- host->next = selfhosts;
- selfhosts = host;
- }
- }
- }
-#endif /* DNETCONN */
#ifndef HAS_GETIFADDRS
len = sizeof(buf);
@@ -635,13 +602,6 @@ DefineSelf (int fd)
len = ifraddr_size (IFR_IFR_ADDR);
family = ConvertAddr ((struct sockaddr *) &IFR_IFR_ADDR,
&len, (pointer *)&addr);
-#ifdef DNETCONN
- /*
- * DECnet was handled up above.
- */
- if (family == AF_DECnet)
- continue;
-#endif /* DNETCONN */
if (family == -1 || family == FamilyLocal)
continue;
#if defined(IPv6) && defined(AF_INET6)
@@ -771,10 +731,6 @@ DefineSelf (int fd)
for (ifr = ifap; ifr != NULL; ifr = ifr->ifa_next) {
if (!ifr->ifa_addr)
continue;
-#ifdef DNETCONN
- if (ifr->ifa_addr.sa_family == AF_DECnet)
- continue;
-#endif /* DNETCONN */
len = sizeof(*(ifr->ifa_addr));
family = ConvertAddr((struct sockaddr *) ifr->ifa_addr, &len,
(pointer *)&addr);
@@ -930,22 +886,15 @@ ResetHosts (char *display)
FILE *fd;
char *ptr;
int i, hostlen;
-#if ((defined(TCPCONN) || defined(STREAMSCONN) || defined(MNX_TCPCONN)) && \
- (!defined(IPv6) || !defined(AF_INET6))) || defined(DNETCONN)
+#if (defined(TCPCONN) || defined(STREAMSCONN) ) && \
+ (!defined(IPv6) || !defined(AF_INET6))
union {
struct sockaddr sa;
-#if defined(TCPCONN) || defined(STREAMSCONN) || defined(MNX_TCPCONN)
+#if defined(TCPCONN) || defined(STREAMSCONN)
struct sockaddr_in in;
#endif /* TCPCONN || STREAMSCONN */
-#ifdef DNETCONN
- struct sockaddr_dn dn;
-#endif
} saddr;
#endif
-#ifdef DNETCONN
- struct nodeent *np;
- struct dn_naddr dnaddr, *dnaddrp, *dnet_addr();
-#endif
int family = 0;
pointer addr;
int len;
@@ -991,7 +940,7 @@ ResetHosts (char *display)
NewHost(family, "", 0, FALSE);
LocalHostRequested = TRUE; /* Fix for XFree86 bug #156 */
}
-#if defined(TCPCONN) || defined(STREAMSCONN) || defined(MNX_TCPCONN)
+#if defined(TCPCONN) || defined(STREAMSCONN)
else if (!strncmp("inet:", lhostname, 5))
{
family = FamilyInternet;
@@ -1005,13 +954,6 @@ ResetHosts (char *display)
}
#endif
#endif
-#ifdef DNETCONN
- else if (!strncmp("dnet:", lhostname, 5))
- {
- family = FamilyDECnet;
- hostname = ohostname + 5;
- }
-#endif
#ifdef SECURE_RPC
else if (!strncmp("nis:", lhostname, 4))
{
@@ -1035,32 +977,6 @@ ResetHosts (char *display)
}
}
else
-#ifdef DNETCONN
- if ((family == FamilyDECnet) || ((family == FamilyWild) &&
- (ptr = strchr(hostname, ':')) && (*(ptr + 1) == ':') &&
- !(*ptr = '\0'))) /* bash trailing colons if necessary */
- {
- /* node name (DECnet names end in "::") */
- dnaddrp = dnet_addr(hostname);
- if (!dnaddrp && (np = getnodebyname (hostname)))
- {
- /* node was specified by name */
- saddr.sa.sa_family = np->n_addrtype;
- len = sizeof(saddr.sa);
- if (ConvertAddr (&saddr.sa, &len, (pointer *)&addr) == FamilyDECnet)
- {
- memset((char *) &dnaddr, 0, sizeof (dnaddr));
- dnaddr.a_len = np->n_length;
- acopy (np->n_addr, dnaddr.a_addr, np->n_length);
- dnaddrp = &dnaddr;
- }
- }
- if (dnaddrp)
- (void) NewHost(FamilyDECnet, (pointer)dnaddrp,
- (int)(dnaddrp->a_len + sizeof(dnaddrp->a_len)), FALSE);
- }
- else
-#endif /* DNETCONN */
#ifdef SECURE_RPC
if ((family == FamilyNetname) || (strchr(hostname, '@')))
{
@@ -1069,7 +985,7 @@ ResetHosts (char *display)
}
else
#endif /* SECURE_RPC */
-#if defined(TCPCONN) || defined(STREAMSCONN) || defined(MNX_TCPCONN)
+#if defined(TCPCONN) || defined(STREAMSCONN)
{
#if defined(IPv6) && defined(AF_INET6)
if ( (family == FamilyInternet) || (family == FamilyInternet6) ||
@@ -1534,7 +1450,7 @@ CheckAddr (
switch (family)
{
-#if defined(TCPCONN) || defined(STREAMSCONN) || defined(MNX_TCPCONN)
+#if defined(TCPCONN) || defined(STREAMSCONN)
case FamilyInternet:
if (length == sizeof (struct in_addr))
len = length;
@@ -1550,21 +1466,6 @@ CheckAddr (
break;
#endif
#endif
-#ifdef DNETCONN
- case FamilyDECnet:
- {
- struct dn_naddr *dnaddr = (struct dn_naddr *) pAddr;
-
- if ((length < sizeof(dnaddr->a_len)) ||
- (length < dnaddr->a_len + sizeof(dnaddr->a_len)))
- len = -1;
- else
- len = dnaddr->a_len + sizeof(dnaddr->a_len);
- if (len > sizeof(struct dn_naddr))
- len = -1;
- }
- break;
-#endif
case FamilyServerInterpreted:
len = siCheckAddr(pAddr, length);
break;
@@ -1642,7 +1543,7 @@ ConvertAddr (
case AF_UNIX:
#endif
return FamilyLocal;
-#if defined(TCPCONN) || defined(STREAMSCONN) || defined(MNX_TCPCONN)
+#if defined(TCPCONN) || defined(STREAMSCONN)
case AF_INET:
#ifdef WIN32
if (16777343 == *(long*)&((struct sockaddr_in *) saddr)->sin_addr)
@@ -1667,22 +1568,6 @@ ConvertAddr (
}
#endif
#endif
-#ifdef DNETCONN
- case AF_DECnet:
- {
- struct sockaddr_dn *sdn = (struct sockaddr_dn *) saddr;
- *len = sdn->sdn_nodeaddrl + sizeof(sdn->sdn_nodeaddrl);
- *addr = (pointer) &(sdn->sdn_add);
- }
- return FamilyDECnet;
-#endif
-#ifdef CHAOSCONN
- case AF_CHAOS:
- {
- not implemented
- }
- return FamilyChaos;
-#endif
default:
return -1;
}
diff --git a/xorg-server/os/connection.c b/xorg-server/os/connection.c
index 24632f1c0..eb9969369 100644
--- a/xorg-server/os/connection.c
+++ b/xorg-server/os/connection.c
@@ -120,9 +120,6 @@ typedef int pid_t;
#define Pid_t pid_t
-#ifdef DNETCONN
-#include <netdnet/dn.h>
-#endif /* DNETCONN */
#ifdef HAS_GETPEERUCRED
# include <ucred.h>
@@ -545,7 +542,7 @@ AuthAudit (ClientPtr client, Bool letin,
#endif
strcpy(out, "local host");
break;
-#if defined(TCPCONN) || defined(STREAMSCONN) || defined(MNX_TCPCONN)
+#if defined(TCPCONN) || defined(STREAMSCONN)
case AF_INET:
sprintf(out, "IP %s",
inet_ntoa(((struct sockaddr_in *) saddr)->sin_addr));
@@ -560,12 +557,6 @@ AuthAudit (ClientPtr client, Bool letin,
break;
#endif
#endif
-#ifdef DNETCONN
- case AF_DECnet:
- sprintf(out, "DN %s",
- dnet_ntoa(&((struct sockaddr_dn *) saddr)->sdn_add));
- break;
-#endif
default:
strcpy(out, "unknown address");
}
diff --git a/xorg-server/os/xdmcp.c b/xorg-server/os/xdmcp.c
index b16fba61e..6429b8b77 100644
--- a/xorg-server/os/xdmcp.c
+++ b/xorg-server/os/xdmcp.c
@@ -1551,7 +1551,7 @@ get_addr_by_name(
#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
_Xgethostbynameparams hparams;
#endif
-#if defined(WIN32) && (defined(TCPCONN) || defined(DNETCONN))
+#if defined(WIN32) && defined(TCPCONN)
_XSERVTransWSAStartup();
#endif
if (!(hep = _XGethostbyname(namestr, hparams)))
diff --git a/xorg-server/randr/Makefile.am b/xorg-server/randr/Makefile.am
index 1f1bea082..4842df89c 100644
--- a/xorg-server/randr/Makefile.am
+++ b/xorg-server/randr/Makefile.am
@@ -1,30 +1,29 @@
-noinst_LTLIBRARIES = librandr.la
-
-AM_CFLAGS = $(DIX_CFLAGS)
-
-XINERAMA_SRCS = rrxinerama.c
-
-if XORG
-sdk_HEADERS = randrstr.h rrtransform.h
-endif
-
-librandr_la_SOURCES = \
- mirandr.c \
- randr.c \
- randrstr.h \
- rrcrtc.c \
- rrdispatch.c \
- rrinfo.c \
- rrmode.c \
- rroutput.c \
- rrpointer.c \
- rrproperty.c \
- rrscreen.c \
- rrsdispatch.c \
- rrtransform.h \
- rrtransform.c
-
-if XINERAMA
-librandr_la_SOURCES += ${XINERAMA_SRCS}
-endif
-
+noinst_LTLIBRARIES = librandr.la
+
+AM_CFLAGS = $(DIX_CFLAGS)
+
+XINERAMA_SRCS = rrxinerama.c
+
+if XORG
+sdk_HEADERS = randrstr.h rrtransform.h
+endif
+
+librandr_la_SOURCES = \
+ randr.c \
+ randrstr.h \
+ rrcrtc.c \
+ rrdispatch.c \
+ rrinfo.c \
+ rrmode.c \
+ rroutput.c \
+ rrpointer.c \
+ rrproperty.c \
+ rrscreen.c \
+ rrsdispatch.c \
+ rrtransform.h \
+ rrtransform.c
+
+if XINERAMA
+librandr_la_SOURCES += ${XINERAMA_SRCS}
+endif
+
diff --git a/xorg-server/randr/makefile b/xorg-server/randr/makefile
index f72a32e9b..ba472232d 100644
--- a/xorg-server/randr/makefile
+++ b/xorg-server/randr/makefile
@@ -2,7 +2,6 @@ LIBRARY=librandr
CSRCS = \
rrxinerama.c \
- mirandr.c \
randr.c \
rrcrtc.c \
rrdispatch.c \
diff --git a/xorg-server/randr/mirandr.c b/xorg-server/randr/mirandr.c
deleted file mode 100644
index 05375e46c..000000000
--- a/xorg-server/randr/mirandr.c
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Copyright © 2000 Compaq Computer Corporation
- * Copyright © 2002 Hewlett-Packard Company
- * Copyright © 2006 Intel 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 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.
- *
- * Author: Jim Gettys, Hewlett-Packard Company, Inc.
- * Keith Packard, Intel Corporation
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "scrnintstr.h"
-#include "mi.h"
-#include "randrstr.h"
-#include <stdio.h>
-
-Bool
-miRRGetInfo (ScreenPtr pScreen, Rotation *rotations)
-{
- return TRUE;
-}
-
-/*
- * Any hardware that can actually change anything will need something
- * different here
- */
-Bool
-miRRCrtcSet (ScreenPtr pScreen,
- RRCrtcPtr crtc,
- RRModePtr mode,
- int x,
- int y,
- Rotation rotation,
- int numOutput,
- RROutputPtr *outputs)
-{
- return TRUE;
-}
-
-static Bool
-miRRCrtcSetGamma (ScreenPtr pScreen,
- RRCrtcPtr crtc)
-{
- return TRUE;
-}
-
-Bool
-miRROutputSetProperty (ScreenPtr pScreen,
- RROutputPtr output,
- Atom property,
- RRPropertyValuePtr value)
-{
- return TRUE;
-}
-
-Bool
-miRROutputGetProperty (ScreenPtr pScreen,
- RROutputPtr output,
- Atom property)
-{
- return TRUE;
-}
-
-Bool
-miRROutputValidateMode (ScreenPtr pScreen,
- RROutputPtr output,
- RRModePtr mode)
-{
- return FALSE;
-}
-
-void
-miRRModeDestroy (ScreenPtr pScreen,
- RRModePtr mode)
-{
-}
-
-/*
- * This function assumes that only a single depth can be
- * displayed at a time, but that all visuals of that depth
- * can be displayed simultaneously. It further assumes that
- * only a single size is available. Hardware providing
- * additional capabilties should use different code.
- * XXX what to do here....
- */
-
-Bool
-miRandRInit (ScreenPtr pScreen)
-{
- rrScrPrivPtr pScrPriv;
-#if RANDR_12_INTERFACE
- RRModePtr mode;
- RRCrtcPtr crtc;
- RROutputPtr output;
- xRRModeInfo modeInfo;
- char name[64];
-#endif
-
- if (!RRScreenInit (pScreen))
- return FALSE;
- pScrPriv = rrGetScrPriv(pScreen);
- pScrPriv->rrGetInfo = miRRGetInfo;
-#if RANDR_12_INTERFACE
- pScrPriv->rrCrtcSet = miRRCrtcSet;
- pScrPriv->rrCrtcSetGamma = miRRCrtcSetGamma;
- pScrPriv->rrOutputSetProperty = miRROutputSetProperty;
-#if RANDR_13_INTERFACE
- pScrPriv->rrOutputGetProperty = miRROutputGetProperty;
-#endif
- pScrPriv->rrOutputValidateMode = miRROutputValidateMode;
- pScrPriv->rrModeDestroy = miRRModeDestroy;
-
- RRScreenSetSizeRange (pScreen,
- pScreen->width, pScreen->height,
- pScreen->width, pScreen->height);
-
- sprintf (name, "%dx%d", pScreen->width, pScreen->height);
- memset (&modeInfo, '\0', sizeof (modeInfo));
- modeInfo.width = pScreen->width;
- modeInfo.height = pScreen->height;
- modeInfo.nameLength = strlen (name);
-
- mode = RRModeGet (&modeInfo, name);
- if (!mode)
- return FALSE;
-
- crtc = RRCrtcCreate (pScreen, NULL);
- if (!crtc)
- return FALSE;
-
- output = RROutputCreate (pScreen, "screen", 6, NULL);
- if (!output)
- return FALSE;
- if (!RROutputSetClones (output, NULL, 0))
- return FALSE;
- if (!RROutputSetModes (output, &mode, 1, 0))
- return FALSE;
- if (!RROutputSetCrtcs (output, &crtc, 1))
- return FALSE;
- if (!RROutputSetConnection (output, RR_Connected))
- return FALSE;
- RRCrtcNotify (crtc, mode, 0, 0, RR_Rotate_0, NULL, 1, &output);
-#endif
- return TRUE;
-}
diff --git a/xorg-server/randr/randrstr.h b/xorg-server/randr/randrstr.h
index 2ad53c6dd..b4acfe12a 100644
--- a/xorg-server/randr/randrstr.h
+++ b/xorg-server/randr/randrstr.h
@@ -441,43 +441,6 @@ ProcRRGetScreenInfo (ClientPtr client);
extern _X_EXPORT void
RRDeliverScreenEvent (ClientPtr client, WindowPtr pWin, ScreenPtr pScreen);
-/* mirandr.c */
-extern _X_EXPORT Bool
-miRandRInit (ScreenPtr pScreen);
-
-extern _X_EXPORT Bool
-miRRGetInfo (ScreenPtr pScreen, Rotation *rotations);
-
-extern _X_EXPORT Bool
-miRRCrtcSet (ScreenPtr pScreen,
- RRCrtcPtr crtc,
- RRModePtr mode,
- int x,
- int y,
- Rotation rotation,
- int numOutput,
- RROutputPtr *outputs);
-
-extern _X_EXPORT Bool
-miRROutputSetProperty (ScreenPtr pScreen,
- RROutputPtr output,
- Atom property,
- RRPropertyValuePtr value);
-
-extern _X_EXPORT Bool
-miRROutputGetProperty (ScreenPtr pScreen,
- RROutputPtr output,
- Atom property);
-
-extern _X_EXPORT Bool
-miRROutputValidateMode (ScreenPtr pScreen,
- RROutputPtr output,
- RRModePtr mode);
-
-extern _X_EXPORT void
-miRRModeDestroy (ScreenPtr pScreen,
- RRModePtr mode);
-
/* randr.c */
/*
* Send all pending events