summaryrefslogtreecommitdiff
path: root/xc/programs/Xserver/hw/xwin
diff options
context:
space:
mode:
Diffstat (limited to 'xc/programs/Xserver/hw/xwin')
-rw-r--r--xc/programs/Xserver/hw/xwin/InitInput.c25
-rw-r--r--xc/programs/Xserver/hw/xwin/InitOutput.c129
-rw-r--r--xc/programs/Xserver/hw/xwin/win.h72
-rw-r--r--xc/programs/Xserver/hw/xwin/winallpriv.c7
-rw-r--r--xc/programs/Xserver/hw/xwin/wincmap.c115
-rw-r--r--xc/programs/Xserver/hw/xwin/wincursor.c3
-rw-r--r--xc/programs/Xserver/hw/xwin/winkeybd.c126
-rw-r--r--xc/programs/Xserver/hw/xwin/winkeymap.h400
-rw-r--r--xc/programs/Xserver/hw/xwin/winmisc.c14
-rw-r--r--xc/programs/Xserver/hw/xwin/winmouse.c216
-rw-r--r--xc/programs/Xserver/hw/xwin/winpfbdd.c150
-rw-r--r--xc/programs/Xserver/hw/xwin/winpixmap.c4
-rw-r--r--xc/programs/Xserver/hw/xwin/winscrinit.c136
-rw-r--r--xc/programs/Xserver/hw/xwin/winshaddd.c201
-rw-r--r--xc/programs/Xserver/hw/xwin/winshadddnl.c195
-rw-r--r--xc/programs/Xserver/hw/xwin/winshadgdi.c205
-rw-r--r--xc/programs/Xserver/hw/xwin/winwakeup.c3
-rw-r--r--xc/programs/Xserver/hw/xwin/winwndproc.c442
18 files changed, 1321 insertions, 1122 deletions
diff --git a/xc/programs/Xserver/hw/xwin/InitInput.c b/xc/programs/Xserver/hw/xwin/InitInput.c
index 4d008b272..355315f86 100644
--- a/xc/programs/Xserver/hw/xwin/InitInput.c
+++ b/xc/programs/Xserver/hw/xwin/InitInput.c
@@ -22,17 +22,20 @@
from The Open Group.
*/
-/* $XFree86: xc/programs/Xserver/hw/xwin/InitInput.c,v 1.3 2001/04/18 17:14:06 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xwin/InitInput.c,v 1.4 2001/05/02 00:45:26 alanh Exp $ */
#include "win.h"
-/* Called from dix/devices.c */
-/* All of our keys generate up and down transition notifications,
- so all of our keys can be used as modifiers.
+CARD32 g_c32LastInputEventTime = 0;
- An example of a modifier is mapping the A key to the Control key.
- A has to be a legal modifier. I think.
-*/
+/* Called from dix/devices.c */
+/*
+ * All of our keys generate up and down transition notifications,
+ * so all of our keys can be used as modifiers.
+ *
+ * An example of a modifier is mapping the A key to the Control key.
+ * A has to be a legal modifier. I think.
+ */
Bool
LegalModifier (unsigned int uiKey, DevicePtr pDevice)
{
@@ -48,6 +51,14 @@ ProcessInputEvents (void)
miPointerUpdate ();
}
+int
+TimeSinceLastInputEvent ()
+{
+ if (g_c32LastInputEventTime == 0)
+ g_c32LastInputEventTime = GetTickCount ();
+ return GetTickCount () - g_c32LastInputEventTime;
+}
+
/* See Porting Layer Definition - p. 17 */
void
InitInput (int argc, char *argv[])
diff --git a/xc/programs/Xserver/hw/xwin/InitOutput.c b/xc/programs/Xserver/hw/xwin/InitOutput.c
index fe098dbb9..31c3cdee3 100644
--- a/xc/programs/Xserver/hw/xwin/InitOutput.c
+++ b/xc/programs/Xserver/hw/xwin/InitOutput.c
@@ -22,7 +22,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
-/* $XFree86: xc/programs/Xserver/hw/xwin/InitOutput.c,v 1.5 2001/04/18 17:14:06 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xwin/InitOutput.c,v 1.8 2001/05/08 08:14:09 alanh Exp $ */
#include "win.h"
@@ -30,7 +30,7 @@ int g_nNumScreens;
winScreenInfo g_winScreens[MAXSCREENS];
int g_nLastScreen = -1;
ColormapPtr g_cmInstalledMaps[MAXSCREENS];
-int g_fdMessageQueue = -1;
+int g_fdMessageQueue = WIN_FD_INVALID;
int g_winScreenPrivateIndex = -1;
unsigned long g_winGeneration = 0;
@@ -40,7 +40,7 @@ static PixmapFormatRec g_PixmapFormats[] = {
{ 8, 8, BITMAP_SCANLINE_PAD },
{ 15, 16, BITMAP_SCANLINE_PAD },
{ 16, 16, BITMAP_SCANLINE_PAD },
- { 24, 32, BITMAP_SCANLINE_PAD },
+ { 24, 24, BITMAP_SCANLINE_PAD },
{ 32, 32, BITMAP_SCANLINE_PAD }
};
const int NUMFORMATS = sizeof (g_PixmapFormats) / sizeof (g_PixmapFormats[0]);
@@ -60,6 +60,8 @@ winInitializeDefaultScreens (void)
g_winScreens[i].pixelWhite = WIN_DEFAULT_WHITEPIXEL;
g_winScreens[i].dwLineBias = WIN_DEFAULT_LINEBIAS;
g_winScreens[i].pfb = NULL;
+ g_winScreens[i].fFullScreen = FALSE;
+ g_winScreens[i].iE3BTimeout = WIN_E3B_OFF;
}
g_nNumScreens = 1;
}
@@ -132,6 +134,8 @@ ddxUseMsg (void)
"\t\tDirectDraw4 blitter\t4\n");
ErrorF ("-fullscreen\n"
"\tRun the specified server engine in fullscreen mode\n");
+ ErrorF ("-emulate3buttons [n]\n"
+ "\tEmulate 3 button mouse with timeout of n milliseconds\n");
}
/* See Porting Layer Definition - p. 57 */
@@ -148,8 +152,8 @@ ddxProcessArgument (int argc, char *argv[], int i)
}
/*
- Look for the '-screen n WxHxD' arugment
- */
+ * Look for the '-screen n WxHxD' arugment
+ */
if (strcmp (argv[i], "-screen") == 0)
{
int nScreenNum;
@@ -163,17 +167,21 @@ ddxProcessArgument (int argc, char *argv[], int i)
nScreenNum = atoi (argv[i+1]);
+ /* Validate the specified screen number */
if (nScreenNum < 0 || nScreenNum >= MAXSCREENS)
{
ErrorF ("Invalid screen number %d\n", nScreenNum);
UseMsg ();
return 0;
}
+
+ /* Grab the height, width, and depth parameters */
if (3 != sscanf (argv[i+2], "%dx%dx%d",
(int*)&g_winScreens[nScreenNum].dwWidth,
(int*)&g_winScreens[nScreenNum].dwHeight,
(int*)&g_winScreens[nScreenNum].dwDepth))
{
+ /* I see no height, width, and depth here */
ErrorF ("Invalid screen configuration %s\n", argv[i+2]);
UseMsg ();
return 0;
@@ -186,8 +194,8 @@ ddxProcessArgument (int argc, char *argv[], int i)
}
/*
- Look for the '-blackpixel n' argument
- */
+ * Look for the '-blackpixel n' argument
+ */
if (strcmp (argv[i], "-blackpixel") == 0) /* -blackpixel n */
{
Pixel pix;
@@ -200,24 +208,29 @@ ddxProcessArgument (int argc, char *argv[], int i)
}
pix = atoi (argv[i]);
+
+ /* Is this parameter attached to a screen or global? */
if (-1 == g_nLastScreen)
{
- int i;
- for (i = 0; i < MAXSCREENS; i++)
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
{
- g_winScreens[i].pixelBlack = pix;
+ g_winScreens[j].pixelBlack = pix;
}
}
else
{
+ /* Parameter is for a single screen */
g_winScreens[g_nLastScreen].pixelBlack = pix;
}
return 2;
}
/*
- Look for the '-whitepixel n' argument
- */
+ * Look for the '-whitepixel n' argument
+ */
if (strcmp (argv[i], "-whitepixel") == 0) /* -whitepixel n */
{
Pixel pix;
@@ -230,24 +243,29 @@ ddxProcessArgument (int argc, char *argv[], int i)
}
pix = atoi (argv[i]);
+
+ /* Is this parameter attached to a screen or global? */
if (-1 == g_nLastScreen)
{
- int i;
- for (i = 0; i < MAXSCREENS; i++)
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
{
- g_winScreens[i].pixelWhite = pix;
+ g_winScreens[j].pixelWhite = pix;
}
}
else
{
+ /* Parameter is for a single screen */
g_winScreens[g_nLastScreen].pixelWhite = pix;
}
return 2;
}
/*
- Look for the '-linebias n' argument
- */
+ * Look for the '-linebias n' argument
+ */
if (strcmp (argv[i], "-linebias") == 0)
{
unsigned int uiLinebias;
@@ -261,25 +279,28 @@ ddxProcessArgument (int argc, char *argv[], int i)
uiLinebias = atoi (argv[i]);
+ /* Is this parameter attached to a screen or global? */
if (-1 == g_nLastScreen)
{
- int i;
+ int j;
- for (i = 0; i < MAXSCREENS; i++)
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
{
- g_winScreens[i].dwLineBias = uiLinebias;
+ g_winScreens[j].dwLineBias = uiLinebias;
}
}
else
{
+ /* Parameter is for a single screen */
g_winScreens[g_nLastScreen].dwLineBias = uiLinebias;
}
return 2;
}
/*
- Look for the '-engine n' argument
- */
+ * Look for the '-engine n' argument
+ */
if (strcmp (argv[i], "-engine") == 0)
{
DWORD dwEngine = 0;
@@ -308,12 +329,12 @@ ddxProcessArgument (int argc, char *argv[], int i)
/* Is this parameter attached to a screen or global? */
if (-1 == g_nLastScreen)
{
- int i;
+ int j;
/* Parameter is for all screens */
- for (i = 0; i < MAXSCREENS; i++)
+ for (j = 0; j < MAXSCREENS; j++)
{
- g_winScreens[i].dwEnginePreferred = dwEngine;
+ g_winScreens[j].dwEnginePreferred = dwEngine;
}
}
else
@@ -326,18 +347,20 @@ ddxProcessArgument (int argc, char *argv[], int i)
return 2;
}
- /* Look for the '-fullscreen' argument */
+ /*
+ * Look for the '-fullscreen' argument
+ */
if (strcmp(argv[i], "-fullscreen") == 0)
{
/* Is this parameter attached to a screen or is it global? */
if (-1 == g_nLastScreen)
{
- int i;
+ int j;
/* Parameter is for all screens */
- for (i = 0; i < MAXSCREENS; i++)
+ for (j = 0; j < MAXSCREENS; j++)
{
- g_winScreens[i].fFullScreen = TRUE;
+ g_winScreens[j].fFullScreen = TRUE;
}
}
else
@@ -350,6 +373,54 @@ ddxProcessArgument (int argc, char *argv[], int i)
return 1;
}
+ /*
+ * Look for the '-emulate3buttons' argument
+ */
+ if (strcmp(argv[i], "-emulate3buttons") == 0)
+ {
+ int iArgsProcessed = 1;
+ int iE3BTimeout = WIN_DEFAULT_E3B_TIME;
+
+ /* Grab the optional timeout value */
+ if (i + 1 < argc
+ && 1 == sscanf (argv[i + 1], "%d",
+ &iE3BTimeout))
+ {
+ /* Indicate that we have processed the next argument */
+ iArgsProcessed++;
+ }
+ else
+ {
+ /*
+ * sscanf () won't modify iE3BTimeout if it doesn't find
+ * the specified format; however, I want to be explicit
+ * about setting the default timeout in such cases to
+ * prevent some programs (me) from getting confused.
+ */
+ iE3BTimeout = WIN_DEFAULT_E3B_TIME;
+ }
+
+ /* Is this parameter attached to a screen or is it global? */
+ if (-1 == g_nLastScreen)
+ {
+ int j;
+
+ /* Parameter is for all screens */
+ for (j = 0; j < MAXSCREENS; j++)
+ {
+ g_winScreens[j].iE3BTimeout = iE3BTimeout;
+ }
+ }
+ else
+ {
+ /* Parameter is for a single screen */
+ g_winScreens[g_nLastScreen].iE3BTimeout = TRUE;
+ }
+
+ /* Indicate that we have processed this argument */
+ return iArgsProcessed;
+ }
+
return 0;
}
diff --git a/xc/programs/Xserver/hw/xwin/win.h b/xc/programs/Xserver/hw/xwin/win.h
index 691d8b908..0a380cb1e 100644
--- a/xc/programs/Xserver/hw/xwin/win.h
+++ b/xc/programs/Xserver/hw/xwin/win.h
@@ -30,7 +30,7 @@
* Peter Busch
* Harold L Hunt II
*/
-/* $XFree86: xc/programs/Xserver/hw/xwin/win.h,v 1.3 2001/04/19 12:56:03 alanh Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xwin/win.h,v 1.6 2001/05/08 08:14:09 alanh Exp $ */
#ifndef _WIN_H_
#define _WIN_H_
@@ -72,9 +72,6 @@
#define DEBUGPROC_MSG
#endif
-/* We use xor this macro for detecting toggle key state changes */
-#define WIN_XOR(a,b) ((!(a) && (b)) || ((a) && !(b)))
-
/* Constant strings */
#define WINDOW_CLASS "cygwin/xfree86"
#define WINDOW_TITLE "Cygwin/XFree86"
@@ -89,7 +86,10 @@
#define WIN_DEFAULT_WHITEPIXEL 255
#define WIN_DEFAULT_BLACKPIXEL 0
#define WIN_DEFAULT_LINEBIAS 0
+#define WIN_DEFAULT_E3B_TIME 50 /* milliseconds */
+#define WIN_E3B_OFF -1
+#define WIN_E3B_TIMER_ID 1
#define WIN_FD_INVALID -1
#define WIN_SERVER_NONE 0x0L /* 0 */
@@ -104,6 +104,10 @@
#define KanaMapIndex Mod4MapIndex
#define ScrollLockMapIndex Mod5MapIndex
+#define WIN_24BPP_MASK_RED 0x00FF0000
+#define WIN_24BPP_MASK_GREEN 0x0000FF00
+#define WIN_24BPP_MASK_BLUE 0x000000FF
+
/*
* We need symbols for the scan codes of keys.
*/
@@ -155,6 +159,7 @@
#include "fb.h"
#ifdef RENDER
+#include "mipict.h"
#include "picturestr.h"
#endif
@@ -193,6 +198,10 @@ typedef void (*winCreateBoundingWindowProcPtr)(ScreenPtr);
typedef Bool (*winFinishScreenInitProcPtr)(int, ScreenPtr, int, char **);
+typedef Bool (*winBltExposedRegionsProcPtr)(ScreenPtr);
+
+typedef Bool (*winActivateAppProcPtr)(ScreenPtr);
+
/*
* Privates structures
*/
@@ -228,6 +237,7 @@ typedef struct
DWORD dwEnginePreferred;
DWORD dwEnginesSupported;
Bool fFullScreen;
+ int iE3BTimeout;
} winScreenInfo, *winScreenInfoPtr;
typedef struct
@@ -250,6 +260,10 @@ typedef struct
DWORD dwModeKeyStates;
+ /* 3 button emulation variables */
+ int iE3BCachedPress;
+ Bool fE3BFakeButton2Sent;
+
/* Privates used by shadow fb GDI server */
HBITMAP hbmpShadow;
HDC hdcScreen;
@@ -286,6 +300,8 @@ typedef struct
winAdjustVideoModeProcPtr pwinAdjustVideoMode;
winCreateBoundingWindowProcPtr pwinCreateBoundingWindow;
winFinishScreenInitProcPtr pwinFinishScreenInit;
+ winBltExposedRegionsProcPtr pwinBltExposedRegions;
+ winActivateAppProcPtr pwinActivateApp;
} winPrivScreenRec, *winPrivScreenPtr;
extern ColormapPtr g_cmInstalledMaps[];
@@ -296,6 +312,7 @@ extern DWORD g_dwEvents;
extern int g_fdMessageQueue;
extern int g_winScreenPrivateIndex;
extern unsigned long g_winGeneration;
+extern CARD32 g_c32LastInputEventTime;
/*
* Screen privates macros
@@ -315,13 +332,17 @@ extern unsigned long g_winGeneration;
(_pWin)->devPrivates[winWindowPrivateIndex].ptr)
/*
- FIXME: Windows mouse wheel macro; should be in Cygwin w32api headers
-*/
+ * FIXME: Windows mouse wheel macro; should be in Cygwin w32api headers.
+ * Has been fixed after May 05, 2001. Remove this section after the
+ * fixed headers are in distribution.
+ */
#ifndef GET_WHEEL_DELTA_WPARAM
#define GET_WHEEL_DELTA_WPARAM(wparam) ((short)HIWORD (wparam))
#endif /* GET_WHEEL_DELTA_WPARAM */
-/* BEGIN DDX and DIX Function Prototypes */
+/*
+ * BEGIN DDX and DIX Function Prototypes
+ */
/*
* InitOutput.c
@@ -474,6 +495,7 @@ winGetSpansNativeGDI (DrawablePtr pDrawable,
/*
* winkeybd.c
*/
+
void
winTranslateKey (WPARAM wParam, LPARAM lParam, int *piScanCode);
@@ -499,6 +521,9 @@ winStoreModeKeyStates (ScreenPtr pScreen);
void
winRestoreModeKeyStates (ScreenPtr pScreen);
+Bool
+winIsFakeCtrl_L (UINT message, WPARAM wParam, LPARAM lParam);
+
/*
* winmisc.c
*/
@@ -523,6 +548,17 @@ winMouseCtrl (DeviceIntPtr pDevice, PtrCtrl *pCtrl);
int
winMouseProc (DeviceIntPtr pDeviceInt, int iState);
+int
+winMouseWheel (ScreenPtr pScreen, int iDeltaZ);
+
+void
+winMouseButtonsSendEvent (int iEventType, int iButton);
+
+int
+winMouseButtonsHandle (ScreenPtr pScreen,
+ int iEventType, int iButton,
+ WPARAM wParam);
+
/*
* winpfbddd.c
*/
@@ -540,6 +576,9 @@ Bool
winAdjustVideoModePrimaryDD (ScreenPtr pScreen);
Bool
+winActivateAppPrimaryDD (ScreenPtr pScreen);
+
+Bool
winSetEngineFunctionsPrimaryDD (ScreenPtr pScreen);
/*
@@ -669,6 +708,12 @@ Bool
winAdjustVideoModeShadowDD (ScreenPtr pScreen);
Bool
+winBltExposedRegionsShadowDD (ScreenPtr pScreen);
+
+Bool
+winActivateAppShadowDD (ScreenPtr pScreen);
+
+Bool
winSetEngineFunctionsShadowDD (ScreenPtr pScreen);
/*
@@ -707,6 +752,12 @@ Bool
winAdjustVideoModeShadowDDNL (ScreenPtr pScreen);
Bool
+winBltExposedRegionsShadowDDNL (ScreenPtr pScreen);
+
+Bool
+winActivateAppShadowDDNL (ScreenPtr pScreen);
+
+Bool
winSetEngineFunctionsShadowDDNL (ScreenPtr pScreen);
/*
@@ -745,6 +796,9 @@ Bool
winAdjustVideoModeShadowGDI (ScreenPtr pScreen);
Bool
+winActivateAppShadowGDI (ScreenPtr pScreen);
+
+Bool
winSetEngineFunctionsShadowGDI (ScreenPtr pScreen);
/*
@@ -794,7 +848,9 @@ winWindowProc (HWND hWnd, UINT message,
void
winRestoreModeKeyStates (ScreenPtr pScreen);
-/* END DDX and DIX Function Prototypes */
+/*
+ * END DDX and DIX Function Prototypes
+ */
#endif /* _WIN_H_ */
diff --git a/xc/programs/Xserver/hw/xwin/winallpriv.c b/xc/programs/Xserver/hw/xwin/winallpriv.c
index f0c033862..bc8700486 100644
--- a/xc/programs/Xserver/hw/xwin/winallpriv.c
+++ b/xc/programs/Xserver/hw/xwin/winallpriv.c
@@ -28,7 +28,7 @@
* Authors: Keith Packard, MIT X Consortium
* Harold L Hunt II
*/
-/* $XFree86: xc/programs/Xserver/hw/xwin/winallpriv.c,v 1.2 2001/04/18 17:14:06 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xwin/winallpriv.c,v 1.3 2001/05/14 16:52:33 alanh Exp $ */
#include "win.h"
@@ -49,7 +49,10 @@ winAllocatePrivates (ScreenPtr pScreen)
/* Allocate memory for our private structure */
pScreenPriv = (winPrivScreenPtr) xalloc (sizeof (*pScreenPriv));
if (!pScreenPriv)
- return FALSE;
+ {
+ ErrorF ("winAllocatePrivates () - xalloc () failed\n");
+ return FALSE;
+ }
/* Initialize the memory of the private structure */
ZeroMemory (pScreenPriv, sizeof (winPrivScreenRec));
diff --git a/xc/programs/Xserver/hw/xwin/wincmap.c b/xc/programs/Xserver/hw/xwin/wincmap.c
index b59da898d..bb728c595 100644
--- a/xc/programs/Xserver/hw/xwin/wincmap.c
+++ b/xc/programs/Xserver/hw/xwin/wincmap.c
@@ -30,7 +30,7 @@
* Peter Busch
* Harold L Hunt II
*/
-/* $XFree86: xc/programs/Xserver/hw/xwin/wincmap.c,v 1.2 2001/04/18 17:14:06 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xwin/wincmap.c,v 1.4 2001/05/14 16:52:33 alanh Exp $ */
#include "win.h"
@@ -38,7 +38,8 @@
int
winListInstalledColormapsNativeGDI (ScreenPtr pScreen, Colormap *pmaps)
{
- /* By the time we are processing requests, we can guarantee that there
+ /*
+ * By the time we are processing requests, we can guarantee that there
* is always a colormap installed
*/
@@ -68,7 +69,9 @@ void
winStoreColorsNativeGDI (ColormapPtr pmap, int ndef, xColorItem *pdefs)
{
ErrorF ("winStoreColors ()\n");
- //miStoreColors (pmap, ndef, pdefs);
+#if 0
+ miStoreColors (pmap, ndef, pdefs);
+#endif
}
/* See Porting Layer Definition - p. 30 */
@@ -88,7 +91,10 @@ Bool
winInitializeColormapNativeGDI (ColormapPtr pmap)
{
ErrorF ("\nwinInitializeColormap ()\n");
+#if 0
return miInitializeColormap (pmap);
+#endif
+ return TRUE;
}
int
@@ -102,61 +108,66 @@ winExpandDirectColorsNativeGDI (ColormapPtr pmap, int ndef,
Bool
winCreateDefColormapNativeGDI (ScreenPtr pScreen)
{
+ winScreenPriv(pScreen);
+ Bool fReturn = TRUE;
VisualPtr pVisual;
ColormapPtr pcmap = NULL;
- HBITMAP hbmp;
- HDC hdc = GetDC (NULL);
- BITMAPINFO *pbmi = xalloc (sizeof (BITMAPINFOHEADER)
- + 256 * sizeof (RGBQUAD));
int i;
Pixel pixel;
unsigned short nRed, nGreen, nBlue;
-
- ErrorF ("winCreateDefColormap () - sizeof (*pbmi): %d\n",
- sizeof (*pbmi));
+ UINT uiSystemPaletteEntries;
+ PALETTEENTRY *ppeColors = NULL;
/* Find the root visual */
for (pVisual = pScreen->visuals;
pVisual->vid != pScreen->rootVisual;
pVisual++);
- hbmp = CreateCompatibleBitmap (hdc, 1, 1);
+ /*
+ * AllocNone for Dynamic visual classes,
+ * AllocAll for non-Dynamic visual classes.
+ */
- /* Allocate a colormap */
+ /* Allocate an X colormap, owned by client 0 */
if (CreateColormap(pScreen->defColormap, pScreen, pVisual, &pcmap,
AllocNone, 0) != Success)
- return FALSE;
+ {
+ ErrorF ("winCreateDefColormapNativeGDI () - CreateColormap failed\n");
+ return FALSE;
+ }
if (pcmap == NULL)
{
- FatalError ("winCreateDefColormap () - Colormap could not be created\n");
+ ErrorF ("winCreateDefColormap () - Colormap could not be created\n");
+ return FALSE;
}
-
ErrorF ("winCreateDefColormap () - Created a colormap\n");
- /* Intialize memory of bitmap info header */
- ZeroMemory (pbmi, sizeof (*pbmi));
- pbmi->bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
-
- /* Get the screen bitmap format and colormap */
- GetDIBits (hdc, hbmp,
- 0, 0,
- NULL,
- pbmi,
- DIB_RGB_COLORS);
-
- ErrorF ("winCreateDefColormap () - Got screen colormap %d %d\n",
- pbmi->bmiHeader.biClrUsed, pbmi->bmiHeader.biClrImportant);
+ /* Get the number of entries in the system palette */
+ uiSystemPaletteEntries = GetSystemPaletteEntries (pScreenPriv->hdcScreen,
+ 0, 0, NULL);
+ ErrorF ("winCreateDefColormap () - uiSystemPaletteEntries %d\n",
+ uiSystemPaletteEntries);
+
+ /* Allocate palette entries structure */
+ ppeColors = xalloc (uiSystemPaletteEntries * sizeof (PALETTEENTRY));
+
+ /* Get system palette entries */
+ GetSystemPaletteEntries (pScreenPriv->hdcScreen,
+ 0, uiSystemPaletteEntries, ppeColors);
- /* Allocate an X colormap entry for each of Windows' colormap entries */
- for (i = 0; i < 8; ++i)
+ /* Allocate an X colormap entry for every system palette entry */
+ for (i = 0; i < uiSystemPaletteEntries; ++i)
{
pixel = i;
- nRed = pbmi->bmiColors[i].rgbRed;
- nGreen = pbmi->bmiColors[i].rgbGreen;
- nBlue = pbmi->bmiColors[i].rgbBlue;
+ /* Extract the color values for current palette entry */
+ nRed = ppeColors[i].peRed << 8;
+ nGreen = ppeColors[i].peGreen << 8;
+ nBlue = ppeColors[i].peBlue << 8;
- ErrorF ("winCreateDefColormap () - Allocating a color: %d; %d %d %d\n",
+#if 0
+ ErrorF ("winCreateDefColormap () - Allocating a color: %d; "\
+ "%d %d %d ",
pixel, nRed, nGreen, nBlue);
if (AllocColor (pcmap,
&nRed,
@@ -165,16 +176,31 @@ winCreateDefColormapNativeGDI (ScreenPtr pScreen)
&pixel,
0) != Success)
break;
+#endif
+
+ pcmap->red[i].co.local.red = nRed;
+ pcmap->red[i].co.local.green = nGreen;
+ pcmap->red[i].co.local.blue = nBlue;
}
- /* Free memory */
- ReleaseDC (NULL, hdc);
- DeleteObject (hbmp);
- xfree (pbmi);
+ if (uiSystemPaletteEntries == 0)
+ {
+ fbInitializeColormap (pcmap);
+ }
+ else
+ {
+ /* Set the black and white pixel indices */
+ pScreen->whitePixel = uiSystemPaletteEntries - 1;
+ pScreen->blackPixel = 0;
+ }
- ErrorF ("winCreateDefColormap () - Returning\n");
+ /* Free colormap */
+ free (ppeColors);
- return TRUE;
+ /* Install the created colormap */
+ (*pScreen->InstallColormap)(pcmap);
+
+ return fReturn;
}
void
@@ -221,10 +247,11 @@ winInitVisualsNativeGDI (ScreenPtr pScreen)
pbmi->bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
/* Call GetDIBits for the first time; doesn't do much */
- /* NOTE: This doesn't actually return the bits, because our
- data pointer is NULL; therefore, we don't have to free
- memory later.
- */
+ /*
+ * NOTE: This doesn't actually return the bits, because our
+ * data pointer is NULL; therefore, we don't have to free
+ * memory later.
+ */
GetDIBits (hdc, hbmp,
0, 0,
NULL,
diff --git a/xc/programs/Xserver/hw/xwin/wincursor.c b/xc/programs/Xserver/hw/xwin/wincursor.c
index f6baf40de..ed04f4b81 100644
--- a/xc/programs/Xserver/hw/xwin/wincursor.c
+++ b/xc/programs/Xserver/hw/xwin/wincursor.c
@@ -30,7 +30,7 @@
* Peter Busch
* Harold L Hunt II
*/
-/* $XFree86: xc/programs/Xserver/hw/xwin/wincursor.c,v 1.1 2001/04/05 20:13:49 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xwin/wincursor.c,v 1.2 2001/05/14 16:52:33 alanh Exp $ */
#include "win.h"
@@ -44,6 +44,7 @@ miPointerScreenFuncRec g_winPointerCursorFuncs =
Bool
winCursorOffScreen (ScreenPtr *ppScreen, int *x, int *y)
{
+ ErrorF ("winCursorOffScreen () - hmm...\n");
return FALSE;
}
diff --git a/xc/programs/Xserver/hw/xwin/winkeybd.c b/xc/programs/Xserver/hw/xwin/winkeybd.c
index 5df741748..05b5bf5d6 100644
--- a/xc/programs/Xserver/hw/xwin/winkeybd.c
+++ b/xc/programs/Xserver/hw/xwin/winkeybd.c
@@ -30,7 +30,7 @@
* Peter Busch
* Harold L Hunt II
*/
-/* $XFree86: xc/programs/Xserver/hw/xwin/winkeybd.c,v 1.1 2001/04/18 17:14:06 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xwin/winkeybd.c,v 1.2 2001/05/02 00:45:26 alanh Exp $ */
#include "win.h"
@@ -66,9 +66,9 @@ winTranslateKey (WPARAM wParam, LPARAM lParam, int *piScanCode)
}
/*
- Handle extended keys that weren't handled correctly as
- non-extended keys.
- */
+ * Handle extended keys that weren't handled correctly as
+ * non-extended keys.
+ */
if (HIWORD (lParam) & KF_EXTENDED)
{
switch (wParam)
@@ -235,7 +235,12 @@ void
winKeybdBell (int iPercent, DeviceIntPtr pDeviceInt,
pointer pCtrl, int iClass)
{
-
+ /*
+ * Window 95 and later ignore the parameters to Beep.
+ * Systems with sound cards will play the default sound event;
+ * systems without sound cards will play the standard system beep.
+ */
+ Beep (0, 0);
}
/* Change some keyboard configuration parameters */
@@ -356,9 +361,9 @@ winInitializeModeKeyStates (void)
}
/*
- We have to store the last state of each mode
- key before we lose the keyboard focus.
-*/
+ * We have to store the last state of each mode
+ * key before we lose the keyboard focus.
+ */
void
winStoreModeKeyStates (ScreenPtr pScreen)
{
@@ -381,10 +386,10 @@ winStoreModeKeyStates (ScreenPtr pScreen)
}
/*
- Upon regaining the keyboard focus we must
- resynchronize our internal mode key states
- with the actual state of the keys.
-*/
+ * Upon regaining the keyboard focus we must
+ * resynchronize our internal mode key states
+ * with the actual state of the keys.
+ */
void
winRestoreModeKeyStates (ScreenPtr pScreen)
{
@@ -393,8 +398,8 @@ winRestoreModeKeyStates (ScreenPtr pScreen)
ZeroMemory (&xCurrentEvent, sizeof (xCurrentEvent));
/* Has the key state changed? */
- if (WIN_XOR(pScreenPriv->dwModeKeyStates & NumLockMask,
- GetKeyState (VK_NUMLOCK) & 0x0001))
+ if ((pScreenPriv->dwModeKeyStates & NumLockMask)
+ ^ (GetKeyState (VK_NUMLOCK) & 0x0001))
{
xCurrentEvent.u.u.detail = KEY_NumLock + MIN_KEYCODE;
@@ -410,8 +415,8 @@ winRestoreModeKeyStates (ScreenPtr pScreen)
}
/* Has the key state changed? */
- if (WIN_XOR(pScreenPriv->dwModeKeyStates & LockMask,
- GetKeyState (VK_CAPITAL) & 0x0001))
+ if ((pScreenPriv->dwModeKeyStates & LockMask)
+ ^ (GetKeyState (VK_CAPITAL) & 0x0001))
{
xCurrentEvent.u.u.detail = KEY_CapsLock + MIN_KEYCODE;
@@ -427,8 +432,8 @@ winRestoreModeKeyStates (ScreenPtr pScreen)
}
/* Has the key state changed? */
- if (WIN_XOR(pScreenPriv->dwModeKeyStates & ScrollLockMask,
- GetKeyState (VK_SCROLL) & 0x0001))
+ if ((pScreenPriv->dwModeKeyStates & ScrollLockMask)
+ ^ (GetKeyState (VK_SCROLL) & 0x0001))
{
xCurrentEvent.u.u.detail = KEY_ScrollLock + MIN_KEYCODE;
@@ -444,8 +449,8 @@ winRestoreModeKeyStates (ScreenPtr pScreen)
}
/* Has the key state changed? */
- if (WIN_XOR(pScreenPriv->dwModeKeyStates & KanaMask,
- GetKeyState (VK_KANA) & 0x0001))
+ if ((pScreenPriv->dwModeKeyStates & KanaMask)
+ ^ (GetKeyState (VK_KANA) & 0x0001))
{
xCurrentEvent.u.u.detail = KEY_HKTG + MIN_KEYCODE;
@@ -461,5 +466,86 @@ winRestoreModeKeyStates (ScreenPtr pScreen)
}
}
+/*
+ * Look for the lovely fake Control_L press/release generated by Windows
+ * when AltGr is pressed/released on a non-U.S. keyboard.
+ */
+Bool
+winIsFakeCtrl_L (UINT message, WPARAM wParam, LPARAM lParam)
+{
+ MSG msgNext;
+ LONG lTime;
+ Bool fReturn;
+
+ /*
+ * Fake Ctrl_L presses will be followed by an Alt_R keypress
+ * with the same timestamp as the Ctrl_L press.
+ */
+ if (message == WM_KEYDOWN
+ && wParam == VK_CONTROL
+ && (HIWORD (lParam) & KF_EXTENDED) == 0)
+ {
+ /* Got a Ctrl_L press */
+
+ /* Get time of current message */
+ lTime = GetMessageTime ();
+
+ /* Look for fake Ctrl_L preceeding an Alt_R press. */
+ fReturn = PeekMessage (&msgNext, NULL,
+ WM_KEYDOWN, WM_KEYDOWN,
+ PM_NOREMOVE);
+
+ /* Is next press an Alt_R with the same timestamp? */
+ if (fReturn && msgNext.wParam == VK_MENU
+ && msgNext.time == lTime
+ && (HIWORD (msgNext.lParam) & KF_EXTENDED))
+ {
+ /*
+ * Next key press is Alt_R with same timestamp as current
+ * Ctrl_L message. Therefore, this Ctrl_L press is a fake
+ * event, so discard it.
+ */
+ return TRUE;
+ }
+ }
+
+ /*
+ * Fake Ctrl_L releases will be followed by an Alt_R release
+ * with the same timestamp as the Ctrl_L press.
+ */
+ if ((message == WM_KEYUP || message == WM_SYSKEYUP)
+ && wParam == VK_CONTROL
+ && (HIWORD (lParam) & KF_EXTENDED) == 0)
+ {
+ /* Got a Ctrl_L release */
+
+ /* Get time of current message */
+ lTime = GetMessageTime ();
+
+ /* Look for fake Ctrl_L release preceeding an Alt_R release. */
+ fReturn = PeekMessage (&msgNext, NULL,
+ WM_KEYUP, WM_SYSKEYUP,
+ PM_NOREMOVE);
+
+ /* Is next press an Alt_R with the same timestamp? */
+ if (fReturn
+ && (msgNext.message == WM_KEYUP
+ || msgNext.message == WM_SYSKEYUP)
+ && msgNext.wParam == VK_MENU
+ && msgNext.time == lTime
+ && (HIWORD (msgNext.lParam) & KF_EXTENDED))
+ {
+ /*
+ * Next key release is Alt_R with same timestamp as current
+ * Ctrl_L message. Therefore, this Ctrl_L release is a fake
+ * event, so discard it.
+ */
+ return TRUE;
+ }
+ }
+
+ /* Not a fake control left press/release */
+ return FALSE;
+}
diff --git a/xc/programs/Xserver/hw/xwin/winkeymap.h b/xc/programs/Xserver/hw/xwin/winkeymap.h
deleted file mode 100644
index 71ffc128f..000000000
--- a/xc/programs/Xserver/hw/xwin/winkeymap.h
+++ /dev/null
@@ -1,400 +0,0 @@
-/*
- *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
- */
-/* $XFree86: xc/programs/Xserver/hw/xwin/winkeymap.h,v 1.2 2001/04/05 20:13:49 dawes Exp $ */
-
-/* This table maps Windows Virtual Key Codes to X11 KeySyms.
-
- To map a particular VKey, lookup the value of the VKey
- in MSDN Library->Platform SDK->User Interface Services->
- Windows User Interface->User Input->Virtual-Key Codes,
- find the array position corresponding to the VKey code
- (e.g. 0x09 for VK_TAB), and fill in the first column
- in that row with the primary key cap, the second column
- with the secondary key (shift), and so on. Note that
- there are not generally any symbols in the third and fourth
- columns of a particular row.
-
- Lookup the XK constants in xc/include/keysymdef.h.
-*/
-static KeySym g_winKeySym[NUM_KEYCODES * GLYPHS_PER_KEY] = {
- /* 0x00 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
-
- /* 0x01 through 0x06 are mouse buttons */
- /* 0x01 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x02 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x03 */ XK_Cancel, NoSymbol, NoSymbol, NoSymbol,
- /* 0x04 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x05 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x06 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
-
- /* 0x07 undefined */
- /* 0x07 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
-
- /* 0x08 */ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol,
- /* 0x09 */ XK_Tab, NoSymbol, NoSymbol, NoSymbol,
-
- /* 0x0a through 0x0b reserved */
- /* 0x0a */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x0b */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
-
- /* 0x0c */ XK_Clear, NoSymbol, NoSymbol, NoSymbol,
- /* 0x0d */ XK_Return, NoSymbol, NoSymbol, NoSymbol,
-
- /* 0x0e through 0x0f undefined */
- /* We use 0x0e for the numeric keypad return key */
- /* 0x0e */ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol,
- /* 0x0f */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
-
- /* 0x10, 0x11, and 0x12 are Shift, Control, and Alt, but we don't use
- them because they do not distinquish between Left and Right keys.
-
- See keys 0xa0 through 0xa5 for Shift, Control, and Alt symbols.
- */
- /* 0x10 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x11 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x12 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x13 */ XK_Pause, NoSymbol, NoSymbol, NoSymbol,
- /* 0x14 */ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol,
- /* 0x15 */ XK_Kana_Lock, NoSymbol, NoSymbol, NoSymbol,
-
- /* 0x16 undefined */
- /* 0x16 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
-
- /* I don't know what to pass for Junja and Final mode keys,
- so I'm just passing a mode siwtch.
- */
- /* 0x19 for Kanji mode may be the wrong symbol */
- /* 0x17 */ XK_Mode_switch, NoSymbol, NoSymbol, NoSymbol,
- /* 0x18 */ XK_Mode_switch, NoSymbol, NoSymbol, NoSymbol,
- /* 0x19 */ XK_Kanji, NoSymbol, NoSymbol, NoSymbol,
-
- /* 0x1a undefined */
- /* 0x1a */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
-
- /* 0x1c, 0x1d, and 0x1e are probably wrong.
- Having a symbol passed at least allows people to map the key
- to something more useful.
- */
- /* 0x1b */ XK_Escape, NoSymbol, NoSymbol, NoSymbol,
- /* 0x1c */ XK_Henkan, NoSymbol, NoSymbol, NoSymbol,
- /* 0x1d */ XK_Muhenkan, NoSymbol, NoSymbol, NoSymbol,
- /* 0x1e */ XK_Kanji_Bangou,NoSymbol, NoSymbol, NoSymbol,
- /* 0x1f */ XK_Mode_switch, NoSymbol, NoSymbol, NoSymbol,
- /* 0x20 */ XK_space, NoSymbol, NoSymbol, NoSymbol,
- /* 0x21 */ XK_Page_Up, NoSymbol, NoSymbol, NoSymbol,
- /* 0x22 */ XK_Page_Down, NoSymbol, NoSymbol, NoSymbol,
- /* 0x23 */ XK_End, NoSymbol, NoSymbol, NoSymbol,
- /* 0x24 */ XK_Home, NoSymbol, NoSymbol, NoSymbol,
- /* 0x25 */ XK_Left, NoSymbol, NoSymbol, NoSymbol,
- /* 0x26 */ XK_Up, NoSymbol, NoSymbol, NoSymbol,
- /* 0x27 */ XK_Right, NoSymbol, NoSymbol, NoSymbol,
- /* 0x28 */ XK_Down, NoSymbol, NoSymbol, NoSymbol,
- /* 0x29 */ XK_Select, NoSymbol, NoSymbol, NoSymbol,
- /* 0x2a */ XK_Print, NoSymbol, NoSymbol, NoSymbol,
- /* 0x2b */ XK_Execute, NoSymbol, NoSymbol, NoSymbol,
- /* 0x2c */ XK_Print, NoSymbol, NoSymbol, NoSymbol,
- /* 0x2d */ XK_Insert, NoSymbol, NoSymbol, NoSymbol,
- /* 0x2e */ XK_Delete, NoSymbol, NoSymbol, NoSymbol,
- /* 0x2f */ XK_Help, NoSymbol, NoSymbol, NoSymbol,
- /* 0x30 */ XK_0, XK_parenright, NoSymbol, NoSymbol,
- /* 0x31 */ XK_1, XK_exclam, NoSymbol, NoSymbol,
- /* 0x32 */ XK_2, XK_at, NoSymbol, NoSymbol,
- /* 0x33 */ XK_3, XK_numbersign, NoSymbol, NoSymbol,
- /* 0x34 */ XK_4, XK_dollar, NoSymbol, NoSymbol,
- /* 0x35 */ XK_5, XK_percent, NoSymbol, NoSymbol,
- /* 0x36 */ XK_6, XK_asciicircum, NoSymbol, NoSymbol,
- /* 0x37 */ XK_7, XK_ampersand, NoSymbol, NoSymbol,
- /* 0x38 */ XK_8, XK_asterisk, NoSymbol, NoSymbol,
- /* 0x39 */ XK_9, XK_parenleft, NoSymbol, NoSymbol,
-
- /* 0x3a through 0x40 undefined */
- /* 0x3a */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x3b */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x3c */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x3d */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x3e */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x3f */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x40 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
-
- /* 0x41 */ XK_A, NoSymbol, NoSymbol, NoSymbol,
- /* 0x42 */ XK_B, NoSymbol, NoSymbol, NoSymbol,
- /* 0x43 */ XK_C, NoSymbol, NoSymbol, NoSymbol,
- /* 0x44 */ XK_D, NoSymbol, NoSymbol, NoSymbol,
- /* 0x45 */ XK_E, NoSymbol, NoSymbol, NoSymbol,
- /* 0x46 */ XK_F, NoSymbol, NoSymbol, NoSymbol,
- /* 0x47 */ XK_G, NoSymbol, NoSymbol, NoSymbol,
- /* 0x48 */ XK_H, NoSymbol, NoSymbol, NoSymbol,
- /* 0x49 */ XK_I, NoSymbol, NoSymbol, NoSymbol,
- /* 0x4a */ XK_J, NoSymbol, NoSymbol, NoSymbol,
- /* 0x4b */ XK_K, NoSymbol, NoSymbol, NoSymbol,
- /* 0x4c */ XK_L, NoSymbol, NoSymbol, NoSymbol,
- /* 0x4d */ XK_M, NoSymbol, NoSymbol, NoSymbol,
- /* 0x4e */ XK_N, NoSymbol, NoSymbol, NoSymbol,
- /* 0x4f */ XK_O, NoSymbol, NoSymbol, NoSymbol,
- /* 0x50 */ XK_P, NoSymbol, NoSymbol, NoSymbol,
- /* 0x51 */ XK_Q, NoSymbol, NoSymbol, NoSymbol,
- /* 0x52 */ XK_R, NoSymbol, NoSymbol, NoSymbol,
- /* 0x53 */ XK_S, NoSymbol, NoSymbol, NoSymbol,
- /* 0x54 */ XK_T, NoSymbol, NoSymbol, NoSymbol,
- /* 0x55 */ XK_U, NoSymbol, NoSymbol, NoSymbol,
- /* 0x56 */ XK_V, NoSymbol, NoSymbol, NoSymbol,
- /* 0x57 */ XK_W, NoSymbol, NoSymbol, NoSymbol,
- /* 0x58 */ XK_X, NoSymbol, NoSymbol, NoSymbol,
- /* 0x59 */ XK_Y, NoSymbol, NoSymbol, NoSymbol,
- /* 0x5a */ XK_Z, NoSymbol, NoSymbol, NoSymbol,
-
- /* 0x5b through 0x5f undefined */
- /* 0x5b */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x5c */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x5d */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x5e */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x5f */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
-
- /* 0x60 */ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol,
- /* 0x61 */ XK_KP_End, XK_KP_1, NoSymbol, NoSymbol,
- /* 0x62 */ XK_KP_Down, XK_KP_2, NoSymbol, NoSymbol,
- /* 0x63 */ XK_KP_Page_Down,XK_KP_3, NoSymbol, NoSymbol,
- /* 0x64 */ XK_KP_Left, XK_KP_4, NoSymbol, NoSymbol,
- /* 0x65 */ NoSymbol, XK_KP_5, NoSymbol, NoSymbol,
- /* 0x66 */ XK_KP_Right, XK_KP_6, NoSymbol, NoSymbol,
- /* 0x67 */ XK_KP_Home, XK_KP_7, NoSymbol, NoSymbol,
- /* 0x68 */ XK_KP_Up, XK_KP_8, NoSymbol, NoSymbol,
- /* 0x69 */ XK_KP_Page_Up, XK_KP_9, NoSymbol, NoSymbol,
- /* 0x6a */ XK_KP_Multiply, NoSymbol, NoSymbol, NoSymbol,
- /* 0x6b */ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol,
- /* 0x6c */ XK_KP_Separator,NoSymbol, NoSymbol, NoSymbol,
- /* 0x6d */ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol,
- /* 0x6e */ XK_KP_Delete, XK_KP_Decimal, NoSymbol, NoSymbol,
- /* 0x6f */ XK_KP_Divide, NoSymbol, NoSymbol, NoSymbol,
- /* 0x70 */ XK_F1, NoSymbol, NoSymbol, NoSymbol,
- /* 0x71 */ XK_F2, NoSymbol, NoSymbol, NoSymbol,
- /* 0x72 */ XK_F3, NoSymbol, NoSymbol, NoSymbol,
- /* 0x73 */ XK_F4, NoSymbol, NoSymbol, NoSymbol,
- /* 0x74 */ XK_F5, NoSymbol, NoSymbol, NoSymbol,
- /* 0x75 */ XK_F6, NoSymbol, NoSymbol, NoSymbol,
- /* 0x76 */ XK_F7, NoSymbol, NoSymbol, NoSymbol,
- /* 0x77 */ XK_F8, NoSymbol, NoSymbol, NoSymbol,
- /* 0x78 */ XK_F9, NoSymbol, NoSymbol, NoSymbol,
- /* 0x79 */ XK_F10, NoSymbol, NoSymbol, NoSymbol,
- /* 0x7a */ XK_F11, NoSymbol, NoSymbol, NoSymbol,
- /* 0x7b */ XK_F12, NoSymbol, NoSymbol, NoSymbol,
- /* 0x7c */ XK_F13, NoSymbol, NoSymbol, NoSymbol,
- /* 0x7d */ XK_F14, NoSymbol, NoSymbol, NoSymbol,
- /* 0x7e */ XK_F15, NoSymbol, NoSymbol, NoSymbol,
- /* 0x7f */ XK_F16, NoSymbol, NoSymbol, NoSymbol,
- /* 0x80 */ XK_F17, NoSymbol, NoSymbol, NoSymbol,
- /* 0x81 */ XK_F18, NoSymbol, NoSymbol, NoSymbol,
- /* 0x82 */ XK_F19, NoSymbol, NoSymbol, NoSymbol,
- /* 0x83 */ XK_F20, NoSymbol, NoSymbol, NoSymbol,
- /* 0x84 */ XK_F21, NoSymbol, NoSymbol, NoSymbol,
- /* 0x85 */ XK_F22, NoSymbol, NoSymbol, NoSymbol,
- /* 0x86 */ XK_F23, NoSymbol, NoSymbol, NoSymbol,
- /* 0x87 */ XK_F24, NoSymbol, NoSymbol, NoSymbol,
-
- /* 0x88 through 0x8f unassigned */
- /* 0x88 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x89 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x8a */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x8b */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x8c */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x8d */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x8e */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x8f */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
-
- /* 0x90 */ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol,
- /* 0x91 */ XK_Scroll_Lock, NoSymbol, NoSymbol, NoSymbol,
-
- /* 0x92 through 0x96 OEM specific */
- /* 0x92 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x93 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x94 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x95 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x96 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
-
- /* 0x97 through 0x9f unassigned */
- /* 0x97 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x98 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x99 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x9a */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x9b */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x9c */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x9d */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x9e */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0x9f */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
-
- /* 0xa0 */ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol,
- /* 0xa1 */ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol,
- /* 0xa2 */ XK_Control_L, NoSymbol, NoSymbol, NoSymbol,
- /* 0xa3 */ XK_Control_R, NoSymbol, NoSymbol, NoSymbol,
- /* 0xa4 */ XK_Alt_L, XK_Meta_L, NoSymbol, NoSymbol,
- /* 0xa5 */ XK_Alt_R, XK_Meta_R, NoSymbol, NoSymbol,
-
- /* 0xa6 through 0xb7 are MS Natural Keyboard Pro browser buttons, etc. */
- /* 0xa6 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xa7 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xa8 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xa9 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xaa */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xab */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xac */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xad */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xae */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xaf */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xb0 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xb1 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xb2 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xb3 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xb4 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xb5 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xb6 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xb7 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
-
- /* 0xb8 through 0xb9 reserved */
- /* 0xb8 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xb9 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
-
- /* 0xba */ XK_semicolon, XK_colon, NoSymbol, NoSymbol,
- /* 0xbb */ XK_equal, XK_plus, NoSymbol, NoSymbol,
- /* 0xbc */ XK_comma, XK_less, NoSymbol, NoSymbol,
- /* 0xbd */ XK_minus, XK_underscore, NoSymbol, NoSymbol,
- /* 0xbe */ XK_period, XK_greater, NoSymbol, NoSymbol,
- /* 0xbf */ XK_slash, XK_question, NoSymbol, NoSymbol,
- /* 0xc0 */ XK_quoteleft, XK_asciitilde, NoSymbol, NoSymbol,
-
- /* 0xc1 through 0xd7 reserved */
- /* 0xc1 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xc2 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xc3 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xc4 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xc5 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xc6 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xc7 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xc8 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xc9 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xca */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xcb */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xcc */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xcd */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xce */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xcf */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xd0 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xd1 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xd2 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xd3 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xd4 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xd5 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xd6 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xd7 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
-
- /* 0xd8 through 0xda unassigned */
- /* 0xd8 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xd9 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xda */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
-
- /* 0xdb */ XK_bracketleft, XK_braceleft, NoSymbol, NoSymbol,
- /* 0xdc */ XK_backslash, XK_bar, NoSymbol, NoSymbol,
- /* 0xdd */ XK_bracketright,XK_braceright, NoSymbol, NoSymbol,
- /* 0xde */ XK_apostrophe, XK_quotedbl, NoSymbol, NoSymbol,
- /* 0xdf */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
-
- /* 0xe0 reserved */
- /* 0xe0 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
-
- /* 0xe1 OEM specific */
- /* 0xe1 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
-
- /* 0xe2 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
-
- /* 0xe3 through 0xe4 OEM specific */
- /* 0xe3 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xe4 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
-
- /* 0xe5 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
-
- /* 0xe6 OEM specific */
- /* 0xe6 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
-
- /* 0xe7 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
-
- /* 0xe8 unassigned */
- /* 0xe8 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
-
- /* 0xe9 through 0xf5 OEM specific */
- /* 0xe9 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xea */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xeb */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xec */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xed */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xef */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xf0 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xf1 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xf2 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xf3 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xf4 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xf5 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
-
- /* 0xf6 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xf7 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xf8 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xf9 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xfa */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xfb */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xfc */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xfd */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xfe */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
- /* 0xff */ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
-
- /* For X Server NumLock handling */
- /* 0x100 */ XK_KP_7, NoSymbol, NoSymbol, NoSymbol,
- /* 0x101 */ XK_KP_8, NoSymbol, NoSymbol, NoSymbol,
- /* 0x102 */ XK_KP_9, NoSymbol, NoSymbol, NoSymbol,
- /* 0x103 */ XK_KP_4, NoSymbol, NoSymbol, NoSymbol,
- /* 0x104 */ XK_KP_5, NoSymbol, NoSymbol, NoSymbol,
- /* 0x105 */ XK_KP_6, NoSymbol, NoSymbol, NoSymbol,
- /* 0x106 */ XK_KP_1, NoSymbol, NoSymbol, NoSymbol,
- /* 0x107 */ XK_KP_2, NoSymbol, NoSymbol, NoSymbol,
- /* 0x108 */ XK_KP_3, NoSymbol, NoSymbol, NoSymbol,
- /* 0x109 */ XK_KP_0, NoSymbol, NoSymbol, NoSymbol,
- /* 0x10a */ XK_KP_Decimal, NoSymbol, NoSymbol, NoSymbol,
- /* 0x10b */ XK_KP_Home, NoSymbol, NoSymbol, NoSymbol,
- /* 0x10c */ XK_KP_Up, NoSymbol, NoSymbol, NoSymbol,
- /* 0x10d */ XK_KP_Prior, NoSymbol, NoSymbol, NoSymbol,
- /* 0x10e */ XK_KP_Left, NoSymbol, NoSymbol, NoSymbol,
- /* 0x10f */ XK_KP_Begin, NoSymbol, NoSymbol, NoSymbol,
- /* 0x110 */ XK_KP_Right, NoSymbol, NoSymbol, NoSymbol,
- /* 0x111 */ XK_KP_End, NoSymbol, NoSymbol, NoSymbol,
- /* 0x112 */ XK_KP_Down, NoSymbol, NoSymbol, NoSymbol,
- /* 0x113 */ XK_KP_Next, NoSymbol, NoSymbol, NoSymbol,
- /* 0x114 */ XK_KP_Insert, NoSymbol, NoSymbol, NoSymbol,
- /* 0x115 */ XK_KP_Delete, NoSymbol, NoSymbol, NoSymbol
-};
diff --git a/xc/programs/Xserver/hw/xwin/winmisc.c b/xc/programs/Xserver/hw/xwin/winmisc.c
index 320458d5d..f730a3ce4 100644
--- a/xc/programs/Xserver/hw/xwin/winmisc.c
+++ b/xc/programs/Xserver/hw/xwin/winmisc.c
@@ -27,23 +27,25 @@
*
* Authors: Harold L Hunt II
*/
-/* $XFree86: xc/programs/Xserver/hw/xwin/winmisc.c,v 1.2 2001/04/18 17:14:06 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xwin/winmisc.c,v 1.3 2001/05/02 00:45:26 alanh Exp $ */
#include "win.h"
/* See Porting Layer Definition - p. 33 */
-/* Called by clients, returns the best size for a cursor, tile, or
- stipple, specified by class (sometimes called kind) */
+/*
+ * Called by clients, returns the best size for a cursor, tile, or
+ * stipple, specified by class (sometimes called kind)
+ */
void
winQueryBestSizeNativeGDI (int class, unsigned short *pWidth,
unsigned short *pHeight, ScreenPtr pScreen)
{
- fprintf (stderr, "winQueryBestSize()\n");
+ ErrorF ("winQueryBestSize()\n");
}
/*
- Count the number of one bits in a color mask.
-*/
+ * Count the number of one bits in a color mask.
+ */
CARD8
winCountBits (DWORD dw)
{
diff --git a/xc/programs/Xserver/hw/xwin/winmouse.c b/xc/programs/Xserver/hw/xwin/winmouse.c
index a75e3bb5e..f448f6111 100644
--- a/xc/programs/Xserver/hw/xwin/winmouse.c
+++ b/xc/programs/Xserver/hw/xwin/winmouse.c
@@ -30,17 +30,17 @@
* Peter Busch
* Harold L Hunt II
*/
-/* $XFree86: xc/programs/Xserver/hw/xwin/winmouse.c,v 1.1 2001/04/18 17:14:06 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xwin/winmouse.c,v 1.3 2001/05/08 08:14:09 alanh Exp $ */
#include "win.h"
void
winMouseCtrl (DeviceIntPtr pDevice, PtrCtrl *pCtrl)
{
-
}
-/* See Porting Layer Definition - p. 18
+/*
+ * See Porting Layer Definition - p. 18
* This is known as a DeviceProc
*/
int
@@ -76,3 +76,213 @@ winMouseProc (DeviceIntPtr pDeviceInt, int iState)
}
return Success;
}
+
+/* Handle the mouse wheel */
+int
+winMouseWheel (ScreenPtr pScreen, int iDeltaZ)
+{
+ winScreenPriv(pScreen);
+ xEvent xCurrentEvent;
+
+ /* 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)
+ {
+ xCurrentEvent.u.u.detail = Button4;
+ }
+ else
+ {
+ xCurrentEvent.u.u.detail = 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 */
+ xCurrentEvent.u.u.type = ButtonPress;
+ xCurrentEvent.u.keyButtonPointer.time
+ = g_c32LastInputEventTime = GetTickCount ();
+ mieqEnqueue (&xCurrentEvent);
+
+ /* Release the wheel button */
+ xCurrentEvent.u.u.type = ButtonRelease;
+ xCurrentEvent.u.keyButtonPointer.time
+ = g_c32LastInputEventTime = GetTickCount ();
+ mieqEnqueue (&xCurrentEvent);
+ }
+
+ return 0;
+}
+
+/*
+ * Enqueue a mouse button event
+ */
+void
+winMouseButtonsSendEvent (int iEventType, int iButton)
+{
+ xEvent xCurrentEvent;
+
+ /* Load an xEvent and enqueue the event */
+ xCurrentEvent.u.u.type = iEventType;
+ xCurrentEvent.u.u.detail = iButton;
+ xCurrentEvent.u.keyButtonPointer.time
+ = g_c32LastInputEventTime = GetTickCount ();
+ mieqEnqueue (&xCurrentEvent);
+}
+
+/*
+ * 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;
+}
diff --git a/xc/programs/Xserver/hw/xwin/winpfbdd.c b/xc/programs/Xserver/hw/xwin/winpfbdd.c
index 44829b448..e020cb76f 100644
--- a/xc/programs/Xserver/hw/xwin/winpfbdd.c
+++ b/xc/programs/Xserver/hw/xwin/winpfbdd.c
@@ -30,13 +30,13 @@
* Peter Busch
* Harold L Hunt II
*/
-/* $XFree86: xc/programs/Xserver/hw/xwin/winpfbdd.c,v 1.2 2001/04/18 17:14:06 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xwin/winpfbdd.c,v 1.5 2001/05/14 16:52:33 alanh Exp $ */
#include "win.h"
/*
- Create a DirectDraw primary surface
-*/
+ * Create a DirectDraw primary surface
+ */
Bool
winAllocateFBPrimaryDD (ScreenPtr pScreen)
{
@@ -122,13 +122,14 @@ winAllocateFBPrimaryDD (ScreenPtr pScreen)
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 could use system memory instead.
- */
+ /*
+ * 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;
@@ -192,10 +193,10 @@ winAllocateFBPrimaryDD (ScreenPtr pScreen)
}
/*
- Call the wrapped CloseScreen function.
-
- Free our resources and private structures.
-*/
+ * Call the wrapped CloseScreen function.
+ *
+ * Free our resources and private structures.
+ */
Bool
winCloseScreenPrimaryDD (int nIndex, ScreenPtr pScreen)
{
@@ -264,12 +265,12 @@ winCloseScreenPrimaryDD (int nIndex, ScreenPtr pScreen)
}
/*
- 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.
-*/
+ * 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.
+ */
Bool
winInitVisualsPrimaryDD (ScreenPtr pScreen)
{
@@ -311,12 +312,16 @@ winInitVisualsPrimaryDD (ScreenPtr pScreen)
pScreenPriv->dwGreenMask,
pScreenPriv->dwBlueMask))
{
- FatalError ("winInitVisualsPrimaryDD () - miSetVisualTypesAndMasks failed\n");
+ ErrorF ("winInitVisualsPrimaryDD () - " \
+ "miSetVisualTypesAndMasks failed\n");
+ return FALSE;
}
break;
case 8:
+#if CYGDEBUG
ErrorF ("winInitVisuals () - Calling miSetVisualTypesAndMasks\n");
+#endif /* CYGDEBUG */
if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
PseudoColorMask,
pScreenPriv->dwBitsPerRGB,
@@ -325,13 +330,19 @@ winInitVisualsPrimaryDD (ScreenPtr pScreen)
pScreenPriv->dwGreenMask,
pScreenPriv->dwBlueMask))
{
- FatalError ("winInitVisualsPrimaryDD () - miSetVisualTypesAndMasks failed\n");
+ ErrorF ("winInitVisualsPrimaryDD () - "\
+ "miSetVisualTypesAndMasks failed\n");
+ return FALSE;
}
- ErrorF ("winInitVisualsPrimaryDD () - Returned from miSetVisualTypesAndMasks\n");
+#if CYGDEBUG
+ ErrorF ("winInitVisualsPrimaryDD () - Returned from "\
+ "miSetVisualTypesAndMasks\n");
+#endif /* CYGDEBUG */
break;
default:
- break;
+ ErrorF ("winInitVisualsPrimaryDD () - Unknown screen depth\n");
+ return FALSE;
}
/* Set DPI info */
@@ -361,7 +372,10 @@ winAdjustVideoModePrimaryDD (ScreenPtr pScreen)
/* We're in serious trouble if we can't get a DC */
hdc = GetDC (NULL);
if (hdc == NULL)
- return FALSE;
+ {
+ ErrorF ("winAdjustVideoModePrimaryDD () - GetDC failed\n");
+ return FALSE;
+ }
/* Query GDI for current display depth */
dwDepth = GetDeviceCaps (hdc, BITSPIXEL);
@@ -378,7 +392,88 @@ winAdjustVideoModePrimaryDD (ScreenPtr pScreen)
}
/* Release our DC */
- ReleaseDC ((HDC) hdc, NULL);
+ ReleaseDC (NULL, hdc);
+
+ return TRUE;
+}
+
+Bool
+winActivateAppPrimaryDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ RECT rcSrc, rcClient;
+ HRESULT ddrval = DD_OK;
+
+ /*
+ * 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.
+ */
+ if (pScreenPriv != NULL
+ && pScreenPriv->pddsPrimary != NULL
+ && pScreenPriv->pddsOffscreen != NULL
+ && pScreenPriv->fActive)
+ {
+ /* We are activating */
+ ddrval = IDirectDrawSurface_IsLost (pScreenPriv->pddsOffscreen);
+ if (ddrval == DD_OK)
+ {
+ IDirectDrawSurface_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 */
+ IDirectDrawSurface_Restore (pScreenPriv->pddsOffscreen);
+ IDirectDrawSurface_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 = IDirectDrawSurface_Blt (pScreenPriv->pddsPrimary,
+ &rcClient,
+ pScreenPriv->pddsOffscreen,
+ &rcSrc,
+ DDBLT_WAIT,
+ NULL);
+ if (FAILED (ddrval))
+ FatalError ("winWindowProc () - Failed blitting offscreen "\
+ "surface to primary surface %08x\n", ddrval);
+
+ /* Lock the primary surface */
+ ddrval = IDirectDrawSurface_Lock (pScreenPriv->pddsPrimary,
+ &rcClient,
+ pScreenPriv->pddsdPrimary,
+ DDLOCK_WAIT,
+ NULL);
+ if (ddrval != DD_OK
+ || pScreenPriv->pddsdPrimary->lpSurface == NULL)
+ FatalError ("winWindowProc () - 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;
}
@@ -404,6 +499,9 @@ winSetEngineFunctionsPrimaryDD (ScreenPtr pScreen)
else
pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowWindowed;
pScreenPriv->pwinFinishScreenInit = winFinishScreenInitFB;
+ pScreenPriv->pwinBltExposedRegions
+ = (winBltExposedRegionsProcPtr) (void (*)())NoopDDA;
+ pScreenPriv->pwinActivateApp = winActivateAppPrimaryDD;
return TRUE;
}
diff --git a/xc/programs/Xserver/hw/xwin/winpixmap.c b/xc/programs/Xserver/hw/xwin/winpixmap.c
index 9b008a514..b753f3c1a 100644
--- a/xc/programs/Xserver/hw/xwin/winpixmap.c
+++ b/xc/programs/Xserver/hw/xwin/winpixmap.c
@@ -28,7 +28,7 @@
* Authors: drewry, september 1986
* Harold L Hunt II
*/
-/* $XFree86: xc/programs/Xserver/hw/xwin/winpixmap.c,v 1.1 2001/04/05 20:13:50 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xwin/winpixmap.c,v 1.3 2001/05/02 00:45:26 alanh Exp $ */
#include "win.h"
@@ -116,7 +116,7 @@ winDestroyPixmapNativeGDI (PixmapPtr pPixmap)
HBITMAP hBitmap;
fprintf (stderr, "winDestroyPixmap - pPixmap->devPrivate.ptr: %08x\n",
- pPixmap->devPrivate.ptr);
+ (UINT) pPixmap->devPrivate.ptr);
/* Decrement reference count, and, if zero, free the pixmap */
--(pPixmap->refcnt);
diff --git a/xc/programs/Xserver/hw/xwin/winscrinit.c b/xc/programs/Xserver/hw/xwin/winscrinit.c
index b29de0ba4..32bc0de2f 100644
--- a/xc/programs/Xserver/hw/xwin/winscrinit.c
+++ b/xc/programs/Xserver/hw/xwin/winscrinit.c
@@ -30,7 +30,7 @@
* Peter Busch
* Harold L Hunt II
*/
-/* $XFree86: xc/programs/Xserver/hw/xwin/winscrinit.c,v 1.3 2001/04/22 19:52:36 alanh Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xwin/winscrinit.c,v 1.7 2001/05/14 16:52:33 alanh Exp $ */
#include "win.h"
@@ -65,18 +65,18 @@ winCreateBoundingWindowFullScreen (ScreenPtr pScreen)
RegisterClass (&wc);
/* Create the window */
- *phwnd = CreateWindowExA (WS_EX_TOPMOST, // Extended styles
- WINDOW_CLASS, // Class name
- WINDOW_TITLE, // Window name
+ *phwnd = CreateWindowExA (WS_EX_TOPMOST, /* Extended styles */
+ WINDOW_CLASS, /* Class name */
+ WINDOW_TITLE, /* Window name */
WS_POPUP,
- 0, // Horizontal position
- 0, // Vertical position
- iWidth, // Right edge
- iHeight, // Bottom edge
- (HWND) NULL, // No parent or owner window
- (HMENU) NULL, // No menu
- GetModuleHandle (NULL),// Instance handle
- pScreenPriv); // ScreenPrivates
+ 0, /* Horizontal position */
+ 0, /* Vertical position */
+ iWidth, /* Right edge */
+ iHeight, /* Bottom edge */
+ (HWND) NULL, /* No parent or owner window */
+ (HMENU) NULL, /* No menu */
+ GetModuleHandle (NULL),/* Instance handle */
+ pScreenPriv); /* ScreenPrivates */
/* Branch on the server engine */
switch (pScreenInfo->dwEngine)
@@ -151,13 +151,14 @@ winCreateBoundingWindowWindowed (ScreenPtr pScreen)
/* Trim window height to fit work area */
if (iHeight >= (rcWorkArea.bottom - rcWorkArea.top))
{
- /* FIXME: Currently chopping 1 off the maximum height
- to allow hidden start bars to pop up when the mouse
- reaches the bottom of the screen.
-
- This only works if the start menu is at the bottom
- of the screen.
- */
+ /*
+ * FIXME: Currently chopping 1 off the maximum height
+ * to allow hidden start bars to pop up when the mouse
+ * reaches the bottom of the screen.
+ *
+ * This only works if the start menu is at the bottom
+ * of the screen.
+ */
iHeight = rcWorkArea.bottom - rcWorkArea.top - 1;
pScreenInfo->dwHeight = iHeight
- 2 * GetSystemMetrics (SM_CYFIXEDFRAME)
@@ -171,21 +172,21 @@ winCreateBoundingWindowWindowed (ScreenPtr pScreen)
#endif
/* Create the window */
- *phwnd = CreateWindowExA (0, // Extended styles
- WINDOW_CLASS, // Class name
- WINDOW_TITLE, // Window name
+ *phwnd = CreateWindowExA (0, /* Extended styles */
+ WINDOW_CLASS, /* Class name */
+ WINDOW_TITLE, /* Window name */
WS_OVERLAPPED
| WS_CAPTION
| WS_SYSMENU
- | WS_MINIMIZEBOX, // Almost an OverlappedWindow
- 0, // Horizontal position
- 0, // Vertical position
- iWidth, // Right edge
- iHeight, // Bottom edge
- (HWND) NULL, // No parent or owner window
- (HMENU) NULL, // No menu
- GetModuleHandle (NULL),// Instance handle
- pScreenPriv); // ScreenPrivates
+ | WS_MINIMIZEBOX, /* Almost an OverlappedWindow */
+ 0, /* Horizontal position */
+ 0, /* Vertical position */
+ iWidth, /* Right edge */
+ iHeight, /* Bottom edge */
+ (HWND) NULL, /* No parent or owner window */
+ (HMENU) NULL, /* No menu */
+ GetModuleHandle (NULL),/* Instance handle */
+ pScreenPriv); /* ScreenPrivates */
/* Get the client area coordinates */
GetClientRect (*phwnd, &rcClient);
@@ -204,10 +205,10 @@ winCreateBoundingWindowWindowed (ScreenPtr pScreen)
}
/*
- Determine what type of screen we are initializing
- and call the appropriate procedure to intiailize
- that type of screen.
-*/
+ * Determine what type of screen we are initializing
+ * and call the appropriate procedure to intiailize
+ * that type of screen.
+ */
Bool
winScreenInit (int index,
ScreenPtr pScreen,
@@ -234,15 +235,24 @@ winScreenInit (int index,
/* Determine which engine to use */
if (!winSetEngine (pScreen))
- return FALSE;
+ {
+ ErrorF ("winScreenInit () - winSetEngine () failed\n");
+ return FALSE;
+ }
/* Adjust the video mode for our engine type */
if (!(*pScreenPriv->pwinAdjustVideoMode) (pScreen))
- return FALSE;
+ {
+ ErrorF ("winScreenInit () - winAdjustVideoMode () failed\n");
+ return FALSE;
+ }
/* Call the engine dependent screen initialization procedure */
if (!((*pScreenPriv->pwinFinishScreenInit) (index, pScreen, argc, argv)))
- return FALSE;
+ {
+ ErrorF ("winScreenInit () - winFinishScreenInit () failed\n");
+ return FALSE;
+ }
return TRUE;
}
@@ -293,7 +303,8 @@ winFinishScreenInitFB (int index,
/* Setup a local variable to point to the framebuffer */
pbits = pScreenInfo->pfb;
-
+
+ /* Apparently we need this for the render extension */
miSetPixmapDepths ();
/* Initialize the fb code */
@@ -337,11 +348,12 @@ winFinishScreenInitFB (int index,
pScreenPriv->pwinShadowWindow);
}
- /* Register our block and wakeup handlers; these procedures
- process messages in our Windows message queue; specifically,
- they process mouse and keyboard input.
- */
- RegisterBlockAndWakeupHandlers ((BlockHandlerProcPtr)NoopDDA,
+ /*
+ * Register our block and wakeup handlers; these procedures
+ * process messages in our Windows message queue; specifically,
+ * they process mouse and keyboard input.
+ */
+ RegisterBlockAndWakeupHandlers (winBlockHandler,
winWakeupHandler,
pScreen);
@@ -360,9 +372,10 @@ winFinishScreenInitFB (int index,
return fReturn;
}
-/* Detect engines supported by current Windows version
- DirectDraw version and hardware
-*/
+/*
+ * Detect engines supported by current Windows version
+ * DirectDraw version and hardware
+ */
Bool
winDetectSupportedEngines (ScreenPtr pScreen)
{
@@ -469,10 +482,11 @@ winDetectSupportedEngines (ScreenPtr pScreen)
return TRUE;
}
-/* Set the engine type, depending on the engines
- supported for this screen, and whether the user
- suggested an engine type
-*/
+/*
+ * Set the engine type, depending on the engines
+ * supported for this screen, and whether the user
+ * suggested an engine type
+ */
Bool
winSetEngine (ScreenPtr pScreen)
{
@@ -578,14 +592,17 @@ winFinishScreenInitNativeGDI (int index,
char *pbits = NULL;
VisualPtr pVisuals = NULL;
DepthPtr pDepths = NULL;
- VisualID rootVisual;
- int nVisuals, nDepths, nRootDepth = 0;
+ VisualID rootVisual = 0;
+ int nVisuals = 0, nDepths = 0, nRootDepth = 0;
winPrivScreenPtr pScreenPriv = NULL;
- fprintf (stderr, "winScreenInit ()\n");
+ ErrorF ("winScreenInit ()\n");
if (!winAllocatePrivates (pScreen))
- return FALSE;
+ {
+ ErrorF ("winFinishScreenInitNativeGDI () winAllocatePrivates failed\n");
+ return FALSE;
+ }
/* Get a pointer to the privates structure that was allocated */
pScreenPriv = winGetScreenPriv (pScreen);
@@ -728,9 +745,10 @@ winFinishScreenInitNativeGDI (int index,
pScreen->MarkUnrealizedWindow = miMarkUnrealizedWindow;
/* GC Handling Routines */
- /* All other GC handling routines are pointed to through
- pScreen->gcfuncs
- */
+ /*
+ * All other GC handling routines are pointed to through
+ * pScreen->gcfuncs
+ */
/* See Porting Layer Definition pp. 43-46 */
pScreen->CreateGC = winCreateGCNativeGDI;
@@ -771,7 +789,7 @@ winFinishScreenInitNativeGDI (int index,
miPointerSetNewScreen (pScreenInfo->dwScreen, 0, 0);
- fprintf (stderr, "winScreenInit () - calling miDCInitialize()\n");
+ ErrorF ("winScreenInit () - calling miDCInitialize()\n");
if (!miDCInitialize (pScreen, &g_winPointerCursorFuncs))
{
ErrorF ("winScreenInit () - miDCInitialize failed\n");
diff --git a/xc/programs/Xserver/hw/xwin/winshaddd.c b/xc/programs/Xserver/hw/xwin/winshaddd.c
index dc4bed83a..9735d4e9f 100644
--- a/xc/programs/Xserver/hw/xwin/winshaddd.c
+++ b/xc/programs/Xserver/hw/xwin/winshaddd.c
@@ -30,17 +30,17 @@
* Peter Busch
* Harold L Hunt II
*/
-/* $XFree86: xc/programs/Xserver/hw/xwin/winshaddd.c,v 1.2 2001/04/18 17:14:06 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xwin/winshaddd.c,v 1.5 2001/05/14 16:52:33 alanh Exp $ */
#include "win.h"
/*
- Create a DirectDraw surface for the shadow framebuffer; also create
- a primary surface object so we can blit to the display.
-
- Install a DirectDraw clipper on our primary surface object
- that clips our blits to the unobscured client area of our display window.
-*/
+ * Create a DirectDraw surface for the shadow framebuffer; also create
+ * a primary surface object so we can blit to the display.
+ *
+ * Install a DirectDraw clipper on our primary surface object
+ * that clips our blits to the unobscured client area of our display window.
+ */
Bool
winAllocateFBShadowDD (ScreenPtr pScreen)
{
@@ -157,6 +157,10 @@ winAllocateFBShadowDD (ScreenPtr pScreen)
ErrorF ("winAllocateFBShadowDD () - Created primary\n");
#endif
+ /*
+ * Attach a clipper to the primary surface that will clip our blits to our
+ * display window.
+ */
ddrval = IDirectDrawSurface_SetClipper (pScreenPriv->pddsPrimary,
pScreenPriv->pddcPrimary);
if (FAILED (ddrval))
@@ -171,12 +175,12 @@ winAllocateFBShadowDD (ScreenPtr pScreen)
/* Describe the shadow surface to be created */
/* NOTE: Do not use a DDSCAPS_VIDEOMEMORY surface,
- as drawing, locking, and unlocking take forever
- with video memory surfaces. In addition,
- video memory is a somewhat scarce resource,
- so you shouldn't be allocating video memory when
- you could use system memory instead.
- */
+ * 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;
@@ -259,8 +263,8 @@ winAllocateFBShadowDD (ScreenPtr pScreen)
}
/*
- Transfer the damaged regions of the shadow framebuffer to the display.
-*/
+ * Transfer the damaged regions of the shadow framebuffer to the display.
+ */
void
winShadowUpdateDD (ScreenPtr pScreen,
PixmapPtr pShadow,
@@ -287,7 +291,7 @@ winShadowUpdateDD (ScreenPtr pScreen,
if (FAILED (ddrval))
{
ErrorF ("winShadowUpdateProcDD () - Unlock failed\n");
- return FALSE;
+ return;
}
/* Loop through all boxes in the damaged region */
@@ -326,7 +330,7 @@ winShadowUpdateDD (ScreenPtr pScreen,
if (FAILED (ddrval))
{
ErrorF ("winShadowUpdateProcDD () - Lock failed\n");
- return FALSE;
+ return;
}
/* Has our memory pointer changed? */
@@ -347,16 +351,16 @@ winShadowUpdateDD (ScreenPtr pScreen,
{
ErrorF ("winShadowUpdateProcDD () - Bits changed, could not "\
"notify fb.\n");
- return FALSE;
+ return;
}
}
}
/*
- Return a pointer to some part of the shadow framebuffer.
-
- NOTE: I have not seen this function get called, yet.
-*/
+ * Return a pointer to some part of the shadow framebuffer.
+ *
+ * NOTE: I have not seen this function get called, yet.
+ */
void *
winShadowSetWindowLinearDD (ScreenPtr pScreen,
CARD32 dwRow,
@@ -368,18 +372,20 @@ winShadowSetWindowLinearDD (ScreenPtr pScreen,
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
*pdwSize = pScreenInfo->dwPaddedWidth;
- return (CARD8 *) pScreenInfo->pfb + dwRow * pScreenInfo->dwPaddedWidth + dwOffset;
+
+ return (CARD8 *) pScreenInfo->pfb
+ + dwRow * pScreenInfo->dwPaddedWidth + dwOffset;
}
/*
- Return a pointer to some part of the shadow framebuffer.
-
- NOTE: I have not seen this function get called, yet.
-
- We call winShadowSetWindowLinearDD because there could,
- theoretically, be other framebuffer styles that
- required a different calculation.
-*/
+ * Return a pointer to some part of the shadow framebuffer.
+ *
+ * NOTE: I have not seen this function get called, yet.
+ *
+ * We call winShadowSetWindowLinearDD because there could,
+ * theoretically, be other framebuffer styles that
+ * required a different calculation.
+ */
void *
winShadowWindowDD (ScreenPtr pScreen,
CARD32 row,
@@ -391,10 +397,10 @@ winShadowWindowDD (ScreenPtr pScreen,
}
/*
- Call the wrapped CloseScreen function.
-
- Free our resources and private structures.
-*/
+ * Call the wrapped CloseScreen function.
+ *
+ * Free our resources and private structures.
+ */
Bool
winCloseScreenShadowDD (int nIndex, ScreenPtr pScreen)
{
@@ -464,12 +470,12 @@ winCloseScreenShadowDD (int nIndex, ScreenPtr pScreen)
}
/*
- 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.
-*/
+ * 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.
+ */
Bool
winInitVisualsShadowDD (ScreenPtr pScreen)
{
@@ -518,7 +524,10 @@ winInitVisualsShadowDD (ScreenPtr pScreen)
break;
case 8:
- ErrorF ("winInitVisuals () - Calling miSetVisualTypesAndMasks\n");
+#if CYGDEBUG
+ ErrorF ("winInitVisualsShadowDD () - Calling "\
+ "miSetVisualTypesAndMasks\n");
+#endif /* CYGDEBUG */
if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
PseudoColorMask,
pScreenPriv->dwBitsPerRGB,
@@ -531,11 +540,15 @@ winInitVisualsShadowDD (ScreenPtr pScreen)
"failed\n");
return FALSE;
}
- ErrorF ("winInitVisualsShadowDD () - Returned from miSetVisualTypesAndMasks\n");
+#if CYGDEBUG
+ ErrorF ("winInitVisualsShadowDD () - Returned from "\
+ "miSetVisualTypesAndMasks\n");
+#endif /* CYGDEBUG */
break;
default:
- break;
+ ErrorF ("winInitVisualsDD () - Unknown screen depth\n");
+ return FALSE;
}
/* Set DPI info */
@@ -565,7 +578,10 @@ winAdjustVideoModeShadowDD (ScreenPtr pScreen)
/* We're in serious trouble if we can't get a DC */
hdc = GetDC (NULL);
if (hdc == NULL)
- return FALSE;
+ {
+ ErrorF ("winAdjustVideoModeShadowDD () - GetDC () failed\n");
+ return FALSE;
+ }
/* Query GDI for current display depth */
dwDepth = GetDeviceCaps (hdc, BITSPIXEL);
@@ -582,7 +598,96 @@ winAdjustVideoModeShadowDD (ScreenPtr pScreen)
}
/* Release our DC */
- ReleaseDC ((HDC) hdc, NULL);
+ ReleaseDC (NULL, hdc);
+ return TRUE;
+}
+
+/* Blt exposed regions to the screen */
+Bool
+winBltExposedRegionsShadowDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ RECT rcClient, rcSrc;
+ HDC hdcUpdate = NULL;
+ PAINTSTRUCT ps;
+ HRESULT ddrval = DD_OK;
+ Bool fReturn = TRUE;
+
+ /* BeginPaint gives us an hdc that clips to the invalidated region */
+ hdcUpdate = BeginPaint (pScreenPriv->hwndScreen, &ps);
+
+ /* Unlock the shadow surface, so we can blit */
+ ddrval = IDirectDrawSurface_Unlock (pScreenPriv->pddsShadow, NULL);
+ if (FAILED (ddrval))
+ {
+ fReturn = FALSE;
+ goto winBltExposedRegionsShadowDD_Exit;
+ }
+
+ /* Get client area in screen coords */
+ GetClientRect (pScreenPriv->hwndScreen, &rcClient);
+ MapWindowPoints (pScreenPriv->hwndScreen,
+ HWND_DESKTOP,
+ (LPPOINT)&rcClient, 2);
+
+ /* Source can be enter shadow surface, as Blt should clip */
+ rcSrc.left = 0;
+ rcSrc.top = 0;
+ rcSrc.right = pScreenInfo->dwWidth;
+ rcSrc.bottom = pScreenInfo->dwHeight;
+
+ /* Our Blt should be clipped to the invalidated region */
+ ddrval = IDirectDrawSurface_Blt (pScreenPriv->pddsPrimary,
+ &rcClient,
+ pScreenPriv->pddsShadow,
+ &rcSrc,
+ DDBLT_WAIT,
+ NULL);
+
+ /* Relock the shadow surface */
+ ddrval = IDirectDrawSurface_Lock (pScreenPriv->pddsShadow,
+ NULL,
+ pScreenPriv->pddsdShadow,
+ DDLOCK_WAIT,
+ NULL);
+ if (FAILED (ddrval))
+ {
+ fReturn = FALSE;
+ goto winBltExposedRegionsShadowDD_Exit;
+ }
+
+ /* Has our memory pointer changed? */
+ if (pScreenInfo->pfb != pScreenPriv->pddsdShadow->lpSurface)
+ winUpdateFBPointer (pScreen,
+ pScreenPriv->pddsdShadow->lpSurface);
+
+ winBltExposedRegionsShadowDD_Exit:
+ /* EndPaint frees the DC */
+ if (hdcUpdate != NULL)
+ EndPaint (pScreenPriv->hwndScreen, &ps);
+ return fReturn;
+}
+
+Bool
+winActivateAppShadowDD (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+
+ /*
+ * Do we have a surface?
+ * Are we active?
+ * Are we fullscreen?
+ */
+ if (pScreenPriv != NULL
+ && pScreenPriv->pddsPrimary != NULL
+ && pScreenPriv->fActive
+ )
+ {
+ /* Primary surface was lost, restore it */
+ IDirectDrawSurface_Restore (pScreenPriv->pddsPrimary);
+ }
+
return TRUE;
}
@@ -605,6 +710,10 @@ winSetEngineFunctionsShadowDD (ScreenPtr pScreen)
else
pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowWindowed;
pScreenPriv->pwinFinishScreenInit = winFinishScreenInitFB;
+ pScreenPriv->pwinBltExposedRegions = winBltExposedRegionsShadowDD;
+ pScreenPriv->pwinActivateApp = winActivateAppShadowDD;
return TRUE;
}
+
+
diff --git a/xc/programs/Xserver/hw/xwin/winshadddnl.c b/xc/programs/Xserver/hw/xwin/winshadddnl.c
index d78074654..3ef39252f 100644
--- a/xc/programs/Xserver/hw/xwin/winshadddnl.c
+++ b/xc/programs/Xserver/hw/xwin/winshadddnl.c
@@ -30,32 +30,34 @@
* Peter Busch
* Harold L Hunt II
*/
-/* $XFree86: xc/programs/Xserver/hw/xwin/winshadddnl.c,v 1.2 2001/04/18 17:14:06 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xwin/winshadddnl.c,v 1.5 2001/05/14 16:52:33 alanh Exp $ */
#include "win.h"
-/* FIXME: Headers are broken, DEFINE_GUID doesn't work correctly,
- so we have to redefine it here.
-*/
+/*
+ * FIXME: Headers are broken, DEFINE_GUID doesn't work correctly,
+ * so we have to redefine it here.
+ */
#ifdef DEFINE_GUID
#undef DEFINE_GUID
#define DEFINE_GUID(n,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) GUID_EXT const GUID n GUID_SECT = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}}
#endif /* DEFINE_GUID */
-/* FIXME: Headers are broken, IID_IDirectDraw4 has to be defined
- here manually. Should be handled by ddraw.h
-*/
+/*
+ * FIXME: Headers are broken, IID_IDirectDraw4 has to be defined
+ * here manually. Should be handled by ddraw.h
+ */
#ifndef IID_IDirectDraw4
DEFINE_GUID( IID_IDirectDraw4, 0x9c59509a,0x39bd,0x11d1,0x8c,0x4a,0x00,0xc0,0x4f,0xd9,0x30,0xc5 );
#endif /* IID_IDirectDraw4 */
/*
- Create a DirectDraw surface for the shadow framebuffer; also create
- a primary surface object so we can blit to the display.
-
- Install a DirectDraw clipper on our primary surface object
- that clips our blits to the unobscured client area of our display window.
-*/
+ * Create a DirectDraw surface for the shadow framebuffer; also create
+ * a primary surface object so we can blit to the display.
+ *
+ * Install a DirectDraw clipper on our primary surface object
+ * that clips our blits to the unobscured client area of our display window.
+ */
Bool
winAllocateFBShadowDDNL (ScreenPtr pScreen)
{
@@ -75,11 +77,15 @@ winAllocateFBShadowDDNL (ScreenPtr pScreen)
/* Allocate memory for our shadow surface */
lpSurface = xalloc (pScreenInfo->dwPaddedWidth * pScreenInfo->dwHeight);
if (lpSurface == NULL)
- FatalError ("winAllocateFBShadowDDNL () - Could not allocate bits\n");
-
- /* Initialize the framebuffer memory so we don't get a
- strange display at startup
- */
+ {
+ ErrorF ("winAllocateFBShadowDDNL () - Could not allocate bits\n");
+ return FALSE;
+ }
+
+ /*
+ * Initialize the framebuffer memory so we don't get a
+ * strange display at startup
+ */
ZeroMemory (lpSurface, pScreenInfo->dwPaddedWidth * pScreenInfo->dwHeight);
/* Create a clipper */
@@ -113,7 +119,7 @@ winAllocateFBShadowDDNL (ScreenPtr pScreen)
/* Create a DirectDraw object, store the address at lpdd */
ddrval = DirectDrawCreate (NULL,
- (void**) &pScreenPriv->pdd,
+ (LPDIRECTDRAW*) &pScreenPriv->pdd,
NULL);
if (ddrval != DD_OK)
{
@@ -186,7 +192,8 @@ winAllocateFBShadowDDNL (ScreenPtr pScreen)
/* Create the primary surface */
ddrval = IDirectDraw_CreateSurface (pScreenPriv->pdd4,
- &ddsdPrimary,
+ (LPDDSURFACEDESC)&ddsdPrimary,
+ (LPDIRECTDRAWSURFACE*)
&pScreenPriv->pddsPrimary4,
NULL);
if (FAILED (ddrval))
@@ -200,6 +207,7 @@ winAllocateFBShadowDDNL (ScreenPtr pScreen)
ErrorF ("winAllocateFBShadowDDNL () - Created primary\n");
#endif
+ /* Get primary surface's pixel format */
ZeroMemory (&ddpfPrimary, sizeof (ddpfPrimary));
ddpfPrimary.dwSize = sizeof (ddpfPrimary);
ddrval = IDirectDrawSurface_GetPixelFormat (pScreenPriv->pddsPrimary4,
@@ -236,13 +244,14 @@ winAllocateFBShadowDDNL (ScreenPtr pScreen)
#endif
/* Describe the shadow surface to be created */
- /* NOTE: Do not use a DDSCAPS_VIDEOMEMORY surface,
- as drawing, locking, and unlocking take forever
- with video memory surfaces. In addition,
- video memory is a somewhat scarce resource,
- so you shouldn't be allocating video memory when
- you could use system memory instead.
- */
+ /*
+ * NOTE: Do not use a DDSCAPS_VIDEOMEMORY surface,
+ * as drawing, locking, and unlocking take forever
+ * with video memory surfaces. In addition,
+ * video memory is a somewhat scarce resource,
+ * so you shouldn't be allocating video memory when
+ * you have the option of using system memory instead.
+ */
ZeroMemory (&ddsdShadow, sizeof (ddsdShadow));
ddsdShadow.dwSize = sizeof (ddsdShadow);
ddsdShadow.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH
@@ -256,7 +265,8 @@ winAllocateFBShadowDDNL (ScreenPtr pScreen)
/* Create the shadow surface */
ddrval = IDirectDraw_CreateSurface (pScreenPriv->pdd4,
- &ddsdShadow,
+ (LPDDSURFACEDESC)&ddsdShadow,
+ (LPDIRECTDRAWSURFACE*)
&pScreenPriv->pddsShadow4,
NULL);
if (ddrval != DD_OK)
@@ -291,8 +301,8 @@ winAllocateFBShadowDDNL (ScreenPtr pScreen)
}
/*
- Transfer the damaged regions of the shadow framebuffer to the display.
-*/
+ * Transfer the damaged regions of the shadow framebuffer to the display.
+ */
void
winShadowUpdateDDNL (ScreenPtr pScreen,
PixmapPtr pShadow,
@@ -343,10 +353,10 @@ winShadowUpdateDDNL (ScreenPtr pScreen,
}
/*
- Return a pointer to some part of the shadow framebuffer.
-
- NOTE: I have not seen this function get called, yet.
-*/
+ * Return a pointer to some part of the shadow framebuffer.
+ *
+ * NOTE: I have not seen this function get called, yet.
+ */
void *
winShadowSetWindowLinearDDNL (ScreenPtr pScreen,
CARD32 dwRow,
@@ -358,19 +368,19 @@ winShadowSetWindowLinearDDNL (ScreenPtr pScreen,
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
*pdwSize = pScreenInfo->dwPaddedWidth;
- return (CARD8 *) pScreenInfo->pfb + dwRow * pScreenInfo->dwPaddedWidth
- + dwOffset;
+ return (CARD8 *) pScreenInfo->pfb
+ + dwRow * pScreenInfo->dwPaddedWidth + dwOffset;
}
/*
- Return a pointer to some part of the shadow framebuffer.
-
- NOTE: I have not seen this function get called, yet.
-
- We call winShadowSetWindowLinearDD because there could,
- theoretically, be other framebuffer styles that
- required a different calculation.
-*/
+ * Return a pointer to some part of the shadow framebuffer.
+ *
+ * NOTE: I have not seen this function get called, yet.
+ *
+ * We call winShadowSetWindowLinearDD because there could,
+ * theoretically, be other framebuffer styles that
+ * required a different calculation.
+ */
void *
winShadowWindowDDNL (ScreenPtr pScreen,
CARD32 row,
@@ -385,10 +395,10 @@ winShadowWindowDDNL (ScreenPtr pScreen,
}
/*
- Call the wrapped CloseScreen function.
-
- Free our resources and private structures.
-*/
+ * Call the wrapped CloseScreen function.
+ *
+ * Free our resources and private structures.
+ */
Bool
winCloseScreenShadowDDNL (int nIndex, ScreenPtr pScreen)
{
@@ -463,12 +473,12 @@ winCloseScreenShadowDDNL (int nIndex, ScreenPtr pScreen)
}
/*
- 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.
-*/
+ * 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.
+ */
Bool
winInitVisualsShadowDDNL (ScreenPtr pScreen)
{
@@ -518,8 +528,10 @@ winInitVisualsShadowDDNL (ScreenPtr pScreen)
break;
case 8:
+#if CYGDEBUG
ErrorF ("winInitVisualsShadowDDNL () - Calling "\
"miSetVisualTypesAndMasks\n");
+#endif /* CYGDEBUG */
if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
PseudoColorMask,
pScreenPriv->dwBitsPerRGB,
@@ -535,7 +547,8 @@ winInitVisualsShadowDDNL (ScreenPtr pScreen)
break;
default:
- break;
+ ErrorF ("winInitVisualsDDNL () - Unknown screen depth\n");
+ return FALSE;
}
/* Set DPI info */
@@ -565,7 +578,10 @@ winAdjustVideoModeShadowDDNL (ScreenPtr pScreen)
/* We're in serious trouble if we can't get a DC */
hdc = GetDC (NULL);
if (hdc == NULL)
- return FALSE;
+ {
+ ErrorF ("winAdjustVideoModeShadowDDNL () - GetDC () failed\n");
+ return FALSE;
+ }
/* Query GDI for current display depth */
dwDepth = GetDeviceCaps (hdc, BITSPIXEL);
@@ -582,11 +598,72 @@ winAdjustVideoModeShadowDDNL (ScreenPtr pScreen)
}
/* Release our DC */
- ReleaseDC ((HDC) hdc, NULL);
+ ReleaseDC (NULL, hdc);
return TRUE;
}
+/* Blt exposed regions to the screen */
+Bool
+winBltExposedRegionsShadowDDNL (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ RECT rcClient, rcSrc;
+ HDC hdcUpdate;
+ PAINTSTRUCT ps;
+ HRESULT ddrval = DD_OK;
+
+ /* BeginPaint gives us an hdc that clips to the invalidated region */
+ hdcUpdate = BeginPaint (pScreenPriv->hwndScreen, &ps);
+
+ /* Get client area in screen coords */
+ GetClientRect (pScreenPriv->hwndScreen, &rcClient);
+ MapWindowPoints (pScreenPriv->hwndScreen,
+ HWND_DESKTOP,
+ (LPPOINT)&rcClient, 2);
+
+ /* Source can be enter shadow surface, as Blt should clip */
+ rcSrc.left = 0;
+ rcSrc.top = 0;
+ rcSrc.right = pScreenInfo->dwWidth;
+ rcSrc.bottom = pScreenInfo->dwHeight;
+
+ /* Our Blt should be clipped to the invalidated region */
+ ddrval = IDirectDrawSurface_Blt (pScreenPriv->pddsPrimary4,
+ &rcClient,
+ pScreenPriv->pddsShadow4,
+ &rcSrc,
+ DDBLT_WAIT,
+ NULL);
+
+ /* EndPaint frees the DC */
+ EndPaint (pScreenPriv->hwndScreen, &ps);
+
+ return TRUE;
+}
+
+Bool
+winActivateAppShadowDDNL (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+
+ /*
+ * Do we have a surface?
+ * Are we active?
+ * Are we full screen?
+ */
+ if (pScreenPriv != NULL
+ && pScreenPriv->pddsPrimary4 != NULL
+ && pScreenPriv->fActive
+ )
+ {
+ /* Primary surface was lost, restore it */
+ IDirectDrawSurface_Restore (pScreenPriv->pddsPrimary4);
+ }
+
+ return TRUE;
+}
/* Set pointers to our engine specific functions */
Bool
@@ -607,6 +684,10 @@ winSetEngineFunctionsShadowDDNL (ScreenPtr pScreen)
else
pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowWindowed;
pScreenPriv->pwinFinishScreenInit = winFinishScreenInitFB;
+ pScreenPriv->pwinBltExposedRegions = winBltExposedRegionsShadowDDNL;
+ pScreenPriv->pwinActivateApp = winActivateAppShadowDDNL;
return TRUE;
}
+
+
diff --git a/xc/programs/Xserver/hw/xwin/winshadgdi.c b/xc/programs/Xserver/hw/xwin/winshadgdi.c
index f16ab1037..3aac70b3b 100644
--- a/xc/programs/Xserver/hw/xwin/winshadgdi.c
+++ b/xc/programs/Xserver/hw/xwin/winshadgdi.c
@@ -27,7 +27,7 @@
*
* Authors: Harold L Hunt II
*/
-/* $XFree86: xc/programs/Xserver/hw/xwin/winshadgdi.c,v 1.2 2001/04/18 17:14:06 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xwin/winshadgdi.c,v 1.6 2001/05/14 16:52:33 alanh Exp $ */
#include "win.h"
@@ -37,38 +37,61 @@ winQueryScreenDIBFormat (ScreenPtr pScreen, BITMAPINFOHEADER *pbmih)
{
winScreenPriv(pScreen);
HBITMAP hbmp;
- Bool fReturn = TRUE;
+#if CYGDEBUG
+ LPDWORD pdw = NULL;
+#endif
/* Create a memory bitmap compatible with the screen */
hbmp = CreateCompatibleBitmap (pScreenPriv->hdcScreen, 1, 1);
if (hbmp == NULL)
- return FALSE;
+ {
+ ErrorF ("winQueryScreenDIBFormat () - CreateCompatibleBitmap failed\n");
+ return FALSE;
+ }
/* Initialize our bitmap info header */
ZeroMemory (pbmih, sizeof (BITMAPINFOHEADER) + 256 * sizeof (RGBQUAD));
pbmih->biSize = sizeof (BITMAPINFOHEADER);
/* Get the biBitCount */
- fReturn = GetDIBits (pScreenPriv->hdcScreen,
- hbmp,
- 0, 1,
- NULL,
- (BITMAPINFO*) pbmih,
- DIB_RGB_COLORS);
+ if (!GetDIBits (pScreenPriv->hdcScreen,
+ hbmp,
+ 0, 1,
+ NULL,
+ (BITMAPINFO*) pbmih,
+ DIB_RGB_COLORS))
+ {
+ ErrorF ("winQueryScreenDIBFormat () - First call to GetDIBits failed\n");
+ DeleteObject (hbmp);
+ return FALSE;
+ }
+
+#if CYGDEBUG
+ /* Get a pointer to bitfields */
+ pdw = (DWORD*) ((CARD8*)pbmih + sizeof (BITMAPINFOHEADER));
+
+ ErrorF ("winQueryScreenDIBFormat () - First call masks: %08x %08x %08x\n",
+ pdw[0], pdw[1], pdw[2]);
+#endif
/* Get optimal color table, or the optimal bitfields */
- if (fReturn)
- fReturn = GetDIBits (pScreenPriv->hdcScreen,
- hbmp,
- 0, 1,
- NULL,
- (BITMAPINFO*)pbmih,
- DIB_RGB_COLORS);
+ if (!GetDIBits (pScreenPriv->hdcScreen,
+ hbmp,
+ 0, 1,
+ NULL,
+ (BITMAPINFO*)pbmih,
+ DIB_RGB_COLORS))
+ {
+ ErrorF ("winQueryScreenDIBFormat () - Second call to GetDIBits "\
+ "failed\n");
+ DeleteObject (hbmp);
+ return FALSE;
+ }
/* Free memory */
DeleteObject (hbmp);
- return fReturn;
+ return TRUE;
}
static
@@ -79,19 +102,33 @@ winQueryRGBBitsAndMasks (ScreenPtr pScreen)
BITMAPINFOHEADER *pbmih = NULL;
Bool fReturn = TRUE;
LPDWORD pdw = NULL;
+ DWORD dwRedBits, dwGreenBits, dwBlueBits;
/* RGB BPP for 8 bit palletes is always 8 bits per pixel */
if (GetDeviceCaps (pScreenPriv->hdcScreen, RASTERCAPS) & RC_PALETTE)
{
+ /*
+ * FIXME: 8bpp doesn't work.
+ */
pScreenPriv->dwBitsPerRGB = 8;
+ pScreenPriv->dwRedMask = 0x0L;
+ pScreenPriv->dwGreenMask = 0x0L;
+ pScreenPriv->dwBlueMask = 0x0L;
return TRUE;
}
- /* 24bpp is easy */
+ /* Color masks for 24 bpp are standardized */
if (GetDeviceCaps (pScreenPriv->hdcScreen, PLANES)
* GetDeviceCaps (pScreenPriv->hdcScreen, BITSPIXEL) == 24)
{
+ /* 8 bits per primary color */
pScreenPriv->dwBitsPerRGB = 8;
+
+ /* Set screen privates masks */
+ pScreenPriv->dwRedMask = WIN_24BPP_MASK_RED;
+ pScreenPriv->dwGreenMask = WIN_24BPP_MASK_GREEN;
+ pScreenPriv->dwBlueMask = WIN_24BPP_MASK_BLUE;
+
return TRUE;
}
@@ -99,16 +136,22 @@ winQueryRGBBitsAndMasks (ScreenPtr pScreen)
pbmih = (BITMAPINFOHEADER*) xalloc (sizeof (BITMAPINFOHEADER)
+ 256 * sizeof (RGBQUAD));
if (pbmih == NULL)
- return FALSE;
+ {
+ ErrorF ("winQueryRGBBitsAndMasks () - xalloc failed\n");
+ return FALSE;
+ }
/* Get screen description */
if (winQueryScreenDIBFormat (pScreen, pbmih))
{
- DWORD dwRedBits, dwGreenBits, dwBlueBits;
-
/* Get a pointer to bitfields */
pdw = (DWORD*) ((CARD8*)pbmih + sizeof (BITMAPINFOHEADER));
+#if CYGDEBUG
+ ErrorF ("winQueryRGBBitsAndMasks () - Masks: %08x %08x %08x\n",
+ pdw[0], pdw[1], pdw[2]);
+#endif
+
/* Count the number of bits in each mask */
dwRedBits = winCountBits (pdw[0]);
dwGreenBits = winCountBits (pdw[1]);
@@ -129,6 +172,8 @@ winQueryRGBBitsAndMasks (ScreenPtr pScreen)
}
else
{
+ ErrorF ("winQueryRGBBitsAndMasks () - winQueryScreenDIBFormat failed\n");
+ xfree (pbmih);
fReturn = FALSE;
}
@@ -156,7 +201,10 @@ winAllocateFBShadowGDI (ScreenPtr pScreen)
pbmih = (BITMAPINFOHEADER*) xalloc (sizeof (BITMAPINFOHEADER)
+ 256 * sizeof (RGBQUAD));
if (pbmih == NULL)
- return FALSE;
+ {
+ ErrorF ("winAllocateFBShadowGDI - xalloc () failed\n");
+ return FALSE;
+ }
/* Query the screen format */
fReturn = winQueryScreenDIBFormat (pScreen, pbmih);
@@ -173,7 +221,10 @@ winAllocateFBShadowGDI (ScreenPtr pScreen)
NULL,
0);
if (pScreenPriv->hbmpShadow == NULL || pScreenInfo->pfb == NULL)
- return FALSE;
+ {
+ ErrorF ("winAllocateFBShadowGDI () - CreateDIBSection failed\n");
+ return FALSE;
+ }
else
{
#if CYGDEBUG
@@ -199,16 +250,23 @@ winAllocateFBShadowGDI (ScreenPtr pScreen)
ErrorF ("winAllocateFBShadowGDI () - Attempting a shadow blit\n");
#endif
- BitBlt (pScreenPriv->hdcScreen,
- 0, 0,
- pScreenInfo->dwWidth, pScreenInfo->dwHeight,
- pScreenPriv->hdcShadow,
- 0, 0,
- SRCCOPY);
-
+ fReturn = BitBlt (pScreenPriv->hdcScreen,
+ 0, 0,
+ pScreenInfo->dwWidth, pScreenInfo->dwHeight,
+ pScreenPriv->hdcShadow,
+ 0, 0,
+ SRCCOPY);
+ if (fReturn)
+ {
#if CYGDEBUG
- ErrorF ("winAllocateFBShadowGDI () - Shadow blit success\n");
+ ErrorF ("winAllocateFBShadowGDI () - Shadow blit success\n");
#endif
+ }
+ else
+ {
+ ErrorF ("winAllocateFBShadowGDI () - Shadow blit failure\n");
+ return FALSE;
+ }
/* Set screeninfo stride */
pScreenInfo->dwStrideBytes = pScreenInfo->dwPaddedWidth;
@@ -267,7 +325,8 @@ winShadowSetWindowLinearGDI (ScreenPtr pScreen,
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
*pdwSize = pScreenInfo->dwPaddedWidth;
- return (CARD8 *) pScreenInfo->pfb + dwRow * pScreenInfo->dwPaddedWidth + dwOffset;
+ return (CARD8 *) pScreenInfo->pfb
+ + dwRow * pScreenInfo->dwPaddedWidth + dwOffset;
}
void *
@@ -380,7 +439,9 @@ winInitVisualsShadowGDI (ScreenPtr pScreen)
break;
case 8:
+#if CYGDEBUG
ErrorF ("winInitVisualsGDI () - Calling miSetVisualTypesAndMasks\n");
+#endif /* CYGDEBUG */
if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
PseudoColorMask,
pScreenPriv->dwBitsPerRGB,
@@ -420,12 +481,17 @@ winAdjustVideoModeShadowGDI (ScreenPtr pScreen)
{
winScreenPriv(pScreen);
winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- HDC hdc = GetDC (NULL);
+ HDC hdc;
DWORD dwDepth;
+ hdc = GetDC (NULL);
+
/* We're in serious trouble if we can't get a DC */
if (hdc == NULL)
- return FALSE;
+ {
+ ErrorF ("winAdjustVideoModeShadowGDI () - GetDC () failed\n");
+ return FALSE;
+ }
/* Query GDI for current display depth */
dwDepth = GetDeviceCaps (hdc, BITSPIXEL);
@@ -442,8 +508,73 @@ winAdjustVideoModeShadowGDI (ScreenPtr pScreen)
}
/* Release our DC */
- ReleaseDC (hdc, NULL);
-
+ ReleaseDC (NULL, hdc);
+
+ return TRUE;
+}
+
+/* Blt exposed regions to the screen */
+Bool
+winBltExposedRegionsShadowGDI (ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ HDC hdcUpdate;
+ PAINTSTRUCT ps;
+
+ /* BeginPaint gives us an hdc that clips to the invalidated region */
+ hdcUpdate = BeginPaint (pScreenPriv->hwndScreen, &ps);
+
+ /* Our BitBlt will be clipped to the invalidated region */
+ BitBlt (hdcUpdate,
+ 0, 0,
+ pScreenInfo->dwWidth, pScreenInfo->dwHeight,
+ pScreenPriv->hdcShadow,
+ 0, 0,
+ SRCCOPY);
+
+ /* EndPaint frees the DC */
+ EndPaint (pScreenPriv->hwndScreen, &ps);
+
+ return TRUE;
+}
+
+Bool
+winActivateAppShadowGDI (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;
}
@@ -466,6 +597,8 @@ winSetEngineFunctionsShadowGDI (ScreenPtr pScreen)
else
pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowWindowed;
pScreenPriv->pwinFinishScreenInit = winFinishScreenInitFB;
+ pScreenPriv->pwinBltExposedRegions = winBltExposedRegionsShadowGDI;
+ pScreenPriv->pwinActivateApp = winActivateAppShadowGDI;
return TRUE;
}
diff --git a/xc/programs/Xserver/hw/xwin/winwakeup.c b/xc/programs/Xserver/hw/xwin/winwakeup.c
index b026f3bcb..09a264418 100644
--- a/xc/programs/Xserver/hw/xwin/winwakeup.c
+++ b/xc/programs/Xserver/hw/xwin/winwakeup.c
@@ -30,7 +30,7 @@
* Peter Busch
* Harold L Hunt II
*/
-/* $XFree86: xc/programs/Xserver/hw/xwin/winwakeup.c,v 1.2 2001/04/18 17:14:07 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xwin/winwakeup.c,v 1.3 2001/05/02 00:45:26 alanh Exp $ */
#include "win.h"
@@ -43,6 +43,7 @@ winWakeupHandler (pointer pWakeupData,
winScreenPriv((ScreenPtr)pWakeupData);
MSG msg;
+ /* Process all message on our queue */
while (PeekMessage (&msg, pScreenPriv->hwndScreen, 0, 0, PM_REMOVE))
{
DispatchMessage (&msg);
diff --git a/xc/programs/Xserver/hw/xwin/winwndproc.c b/xc/programs/Xserver/hw/xwin/winwndproc.c
index 35fb5369c..2e7f31f0f 100644
--- a/xc/programs/Xserver/hw/xwin/winwndproc.c
+++ b/xc/programs/Xserver/hw/xwin/winwndproc.c
@@ -30,12 +30,13 @@
* Peter Busch
* Harold L Hunt II
*/
-/* $XFree86: xc/programs/Xserver/hw/xwin/winwndproc.c,v 1.2 2001/04/18 17:14:07 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xwin/winwndproc.c,v 1.4 2001/05/08 08:14:09 alanh Exp $ */
#include "win.h"
-/* Called by the WakeupHandler
- * Processes and/or dispatches Windows messages
+/*
+ * Called by winWakeupHandler
+ * Processes current Windows message
*/
LRESULT CALLBACK
winWindowProc (HWND hWnd, UINT message,
@@ -45,9 +46,6 @@ winWindowProc (HWND hWnd, UINT message,
winScreenInfo *pScreenInfo = NULL;
ScreenPtr pScreen = NULL;
xEvent xCurrentEvent;
- int iDeltaZ;
- HDC hdcUpdate;
- PAINTSTRUCT ps;
LPCREATESTRUCT pcs;
HRESULT ddrval;
RECT rcClient, rcSrc;
@@ -68,14 +66,15 @@ winWindowProc (HWND hWnd, UINT message,
switch (message)
{
case WM_CREATE:
- /* 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.
- */
+ /*
+ * 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.
+ */
pcs = (LPCREATESTRUCT) lParam;
pScreenPriv = pcs->lpCreateParams;
pScreen = pScreenPriv->pScreenInfo->pScreen;
@@ -97,101 +96,8 @@ winWindowProc (HWND hWnd, UINT message,
break;
}
- /* BeginPaint gives us an hdc that clips to the invalidated region */
- hdcUpdate = BeginPaint (hWnd, &ps);
-
- /* Branch on server style */
- switch (pScreenInfo->dwEngine)
- {
- case WIN_SERVER_SHADOW_GDI:
- /* Our BitBlt will be clipped to the invalidated region */
- BitBlt (hdcUpdate,
- 0, 0,
- pScreenInfo->dwWidth, pScreenInfo->dwHeight,
- pScreenPriv->hdcShadow,
- 0, 0,
- SRCCOPY);
- break;
-
- case WIN_SERVER_SHADOW_DD:
- /* Unlock the shadow surface, so we can blit */
- ddrval = IDirectDrawSurface_Unlock (pScreenPriv->pddsShadow, NULL);
- if (FAILED (ddrval))
- FatalError ("winWindowProc () - DD unlock failed\n");
-
- /* Get client area in screen coords */
- GetClientRect (pScreenPriv->hwndScreen, &rcClient);
- MapWindowPoints (pScreenPriv->hwndScreen,
- HWND_DESKTOP,
- (LPPOINT)&rcClient, 2);
-
- /* Source can be enter shadow surface, as Blt should clip */
- rcSrc.left = 0;
- rcSrc.top = 0;
- rcSrc.right = pScreenInfo->dwWidth;
- rcSrc.bottom = pScreenInfo->dwHeight;
-
- /* Our Blt should be clipped to the invalidated region */
- ddrval = IDirectDrawSurface_Blt (pScreenPriv->pddsPrimary,
- &rcClient,
- pScreenPriv->pddsShadow,
- &rcSrc,
- DDBLT_WAIT,
- NULL);
-
- /* Relock the shadow surface */
- ddrval = IDirectDrawSurface_Lock (pScreenPriv->pddsShadow,
- NULL,
- pScreenPriv->pddsdShadow,
- DDLOCK_WAIT,
- NULL);
- if (FAILED (ddrval))
- FatalError ("winWindowProc () - DD lock failed\n");
-
- /* Has our memory pointer changed? */
- if (pScreenInfo->pfb != pScreenPriv->pddsdShadow->lpSurface)
- winUpdateFBPointer (pScreen,
- pScreenPriv->pddsdShadow->lpSurface);
- break;
-
- case WIN_SERVER_SHADOW_DDNL:
- /* Get client area in screen coords */
- GetClientRect (pScreenPriv->hwndScreen, &rcClient);
- MapWindowPoints (pScreenPriv->hwndScreen,
- HWND_DESKTOP,
- (LPPOINT)&rcClient, 2);
-
- /* Source can be enter shadow surface, as Blt should clip */
- rcSrc.left = 0;
- rcSrc.top = 0;
- rcSrc.right = pScreenInfo->dwWidth;
- rcSrc.bottom = pScreenInfo->dwHeight;
-
- /* Our Blt should be clipped to the invalidated region */
- ddrval = IDirectDrawSurface_Blt (pScreenPriv->pddsPrimary4,
- &rcClient,
- pScreenPriv->pddsShadow4,
- &rcSrc,
- DDBLT_WAIT,
- NULL);
- break;
-
- case WIN_SERVER_PRIMARY_DD:
- /* FIXME: We only run in fullscreen mode with primary fb
- DirectDraw server.
-
- We'll have to hand roll the clipping for windowed mode;
- the performance of the primary fb server is so bad
- that it probably wouldn't be worth the effort to write
- the clipping code.
- */
- break;
- default:
- FatalError ("winWindowProc () - WM_PAINT - Unknown engine type\n");
- }
-
- /* EndPaint frees the DC */
- EndPaint (hWnd, &ps);
+ /* Call the engine dependent repainter */
+ (*pScreenPriv->pwinBltExposedRegions) (pScreen);
return 0;
case WM_MOUSEMOVE:
@@ -218,7 +124,7 @@ winWindowProc (HWND hWnd, UINT message,
/* Deliver absolute cursor position to X Server */
miPointerAbsoluteCursor (GET_X_LPARAM(lParam),
GET_Y_LPARAM(lParam),
- GetTickCount ());
+ g_c32LastInputEventTime = GetTickCount ());
return 0;
case WM_NCMOUSEMOVE:
@@ -232,147 +138,66 @@ winWindowProc (HWND hWnd, UINT message,
case WM_LBUTTONDBLCLK:
case WM_LBUTTONDOWN:
- xCurrentEvent.u.u.type = ButtonPress;
- xCurrentEvent.u.u.detail = Button1;
- xCurrentEvent.u.keyButtonPointer.time = GetTickCount ();
- mieqEnqueue (&xCurrentEvent);
- return 0;
-
+ return winMouseButtonsHandle (pScreen, ButtonPress, Button1, wParam);
+
case WM_LBUTTONUP:
- xCurrentEvent.u.u.type = ButtonRelease;
- xCurrentEvent.u.u.detail = Button1;
- xCurrentEvent.u.keyButtonPointer.time = GetTickCount ();
- mieqEnqueue (&xCurrentEvent);
- return 0;
+ return winMouseButtonsHandle (pScreen, ButtonRelease, Button1, wParam);
case WM_MBUTTONDBLCLK:
case WM_MBUTTONDOWN:
- xCurrentEvent.u.u.type = ButtonPress;
- xCurrentEvent.u.u.detail = Button2;
- xCurrentEvent.u.keyButtonPointer.time = GetTickCount ();
- mieqEnqueue (&xCurrentEvent);
- return 0;
-
+ return winMouseButtonsHandle (pScreen, ButtonPress, Button2, wParam);
+
case WM_MBUTTONUP:
- xCurrentEvent.u.u.type = ButtonRelease;
- xCurrentEvent.u.u.detail = Button2;
- xCurrentEvent.u.keyButtonPointer.time = GetTickCount ();
- mieqEnqueue (&xCurrentEvent);
- return 0;
-
+ return winMouseButtonsHandle (pScreen, ButtonRelease, Button2, wParam);
+
case WM_RBUTTONDBLCLK:
case WM_RBUTTONDOWN:
- xCurrentEvent.u.u.type = ButtonPress;
- xCurrentEvent.u.u.detail = Button3;
- xCurrentEvent.u.keyButtonPointer.time = GetTickCount ();
- mieqEnqueue (&xCurrentEvent);
- return 0;
-
+ return winMouseButtonsHandle (pScreen, ButtonPress, Button3, wParam);
+
case WM_RBUTTONUP:
- xCurrentEvent.u.u.type = ButtonRelease;
- xCurrentEvent.u.u.detail = Button3;
- xCurrentEvent.u.keyButtonPointer.time = GetTickCount ();
- mieqEnqueue (&xCurrentEvent);
- return 0;
-
- case WM_MOUSEWHEEL:
- /* Button4 = WheelUp */
- /* Button5 = WheelDown */
-
- /* Find out how far the wheel has moved */
- iDeltaZ = GET_WHEEL_DELTA_WPARAM(wParam);
-
- /* 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;
- }
+ return winMouseButtonsHandle (pScreen, ButtonRelease, Button3, wParam);
- /* Set the button to indicate up or down wheel delta */
- if (iDeltaZ > 0)
+ case WM_TIMER:
+ switch (wParam)
{
- xCurrentEvent.u.u.detail = Button4;
- }
- else
- {
- xCurrentEvent.u.u.detail = Button5;
- }
+ case WIN_E3B_TIMER_ID:
+ /* Send delayed button press */
+ winMouseButtonsSendEvent (ButtonPress,
+ pScreenPriv->iE3BCachedPress);
- /*
- 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;
- }
+ /* Kill this timer */
+ KillTimer (pScreenPriv->hwndScreen, WIN_E3B_TIMER_ID);
- /* Generate X input messages for each wheel delta we have seen */
- while (iDeltaZ--)
- {
- /* Push the wheel button */
- xCurrentEvent.u.u.type = ButtonPress;
- xCurrentEvent.u.keyButtonPointer.time = GetTickCount ();
- mieqEnqueue (&xCurrentEvent);
-
- /* Release the wheel button */
- xCurrentEvent.u.u.type = ButtonRelease;
- xCurrentEvent.u.keyButtonPointer.time = GetTickCount ();
- mieqEnqueue (&xCurrentEvent);
+ /* Clear screen privates flags */
+ pScreenPriv->iE3BCachedPress = 0;
+ break;
}
return 0;
+ case WM_MOUSEWHEEL:
+ return winMouseWheel (pScreen, GET_WHEEL_DELTA_WPARAM(wParam));
+
case WM_SYSKEYDOWN:
case WM_KEYDOWN:
+ if (winIsFakeCtrl_L (message, wParam, lParam))
+ return 0;
winTranslateKey (wParam, lParam, &iScanCode);
xCurrentEvent.u.u.type = KeyPress;
xCurrentEvent.u.u.detail = iScanCode;
- xCurrentEvent.u.keyButtonPointer.time = GetTickCount ();
+ xCurrentEvent.u.keyButtonPointer.time
+ = g_c32LastInputEventTime = GetTickCount ();
mieqEnqueue (&xCurrentEvent);
return 0;
case WM_SYSKEYUP:
case WM_KEYUP:
+ if (winIsFakeCtrl_L (message, wParam, lParam))
+ return 0;
winTranslateKey (wParam, lParam, &iScanCode);
xCurrentEvent.u.u.type = KeyRelease;
xCurrentEvent.u.u.detail = iScanCode;
- xCurrentEvent.u.keyButtonPointer.time = GetTickCount ();
+ xCurrentEvent.u.keyButtonPointer.time
+ = g_c32LastInputEventTime = GetTickCount ();
mieqEnqueue (&xCurrentEvent);
return 0;
@@ -387,10 +212,11 @@ winWindowProc (HWND hWnd, UINT message,
/* Alt+Tab was pressed, we will lose focus very soon */
pScreenPriv->fActive = FALSE;
- /* 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.
- */
+ /*
+ * 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.
+ */
if (pScreenPriv != NULL
&& pScreenPriv->pddsPrimary != NULL
&& pScreenPriv->pddsPrimary != NULL)
@@ -473,15 +299,20 @@ winWindowProc (HWND hWnd, UINT message,
break;
case WM_ACTIVATE:
- /* Focus is being changed to another window.
- The other window may or may not belong to
- our process.
- */
+ /*
+ * Focus is being changed to another window.
+ * The other window may or may not belong to
+ * our process.
+ */
/* We can't do anything if we don't have screen privates */
if (pScreenPriv == NULL)
break;
+ /* Clear any lingering wheel delta */
+ pScreenPriv->iDeltaZ = 0;
+
+ /* Activating or deactivating? */
if (LOWORD (wParam) == WA_ACTIVE || LOWORD (wParam) == WA_CLICKACTIVE)
{
/* Restore the state of all mode keys */
@@ -492,9 +323,9 @@ winWindowProc (HWND hWnd, UINT message,
&& pScreen != miPointerCurrentScreen ())
{
/*
- Tell mi that we are changing the screen that receives
- mouse input events.
- */
+ * Tell mi that we are changing the screen that receives
+ * mouse input events.
+ */
miPointerSetNewScreen (pScreenInfo->dwScreen,
0, 0);
}
@@ -547,147 +378,8 @@ winWindowProc (HWND hWnd, UINT message,
ShowCursor (TRUE);
}
- /* Handle activation/deactivation for each engine */
- switch (pScreenInfo->dwEngine)
- {
- case WIN_SERVER_SHADOW_GDI:
- /*
- 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 (hWnd, SW_RESTORE);
- }
-
- /*
- Are we inactive?
- Are we fullscreen?
- */
- if (pScreenPriv != NULL
- && !pScreenPriv->fActive
- && pScreenInfo->fFullScreen)
- {
- /* Deactivating, stuff our window onto the
- task bar.
- */
- ShowWindow (hWnd, SW_MINIMIZE);
- }
- break;
-
- case WIN_SERVER_SHADOW_DD:
- /*
- Do we have a surface?
- Are we active?
- Are we fullscreen?
- */
- if (pScreenPriv != NULL
- && pScreenPriv->pddsPrimary != NULL
- && pScreenPriv->fActive
- //&& pScreenInfo->fFullScreen
- )
- {
- /* Primary surface was lost, restore it */
- IDirectDrawSurface_Restore (pScreenPriv->pddsPrimary);
- }
- break;
-
- case WIN_SERVER_SHADOW_DDNL:
- /*
- Do we have a surface?
- Are we active?
- Are we full screen?
- */
- if (pScreenPriv != NULL
- && pScreenPriv->pddsPrimary4 != NULL
- && pScreenPriv->fActive
- //&& pScreenInfo->fFullScreen
- )
- {
- /* Primary surface was lost, restore it */
- IDirectDrawSurface_Restore (pScreenPriv->pddsPrimary4);
- }
- break;
-
- case WIN_SERVER_PRIMARY_DD:
- /* 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.
- */
- if (pScreenPriv != NULL
- && pScreenPriv->pddsPrimary != NULL
- && pScreenPriv->pddsOffscreen != NULL
- && pScreenPriv->fActive)
- {
- /* We are activating */
- ddrval = IDirectDrawSurface_IsLost (pScreenPriv->pddsOffscreen);
- if (ddrval == DD_OK)
- {
- ddrval = IDirectDrawSurface_Unlock (pScreenPriv->pddsOffscreen,
- NULL);
-#if 0
- if (FAILED (ddrval))
- FatalError ("winWindowProc () - Failed unlocking "\
- "offscreen surface %08x\n", ddrval);
-#endif
- }
-
- /* Restore both surfaces, just cause I like it that way */
- IDirectDrawSurface_Restore (pScreenPriv->pddsOffscreen);
- IDirectDrawSurface_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 = IDirectDrawSurface_Blt (pScreenPriv->pddsPrimary,
- &rcClient,
- pScreenPriv->pddsOffscreen,
- &rcSrc,
- DDBLT_WAIT,
- NULL);
- if (FAILED (ddrval))
- FatalError ("winWindowProc () - Failed blitting offscreen "\
- "surface to primary surface %08x\n", ddrval);
-
- /* Lock the primary surface */
- ddrval = IDirectDrawSurface_Lock (pScreenPriv->pddsPrimary,
- &rcClient,
- pScreenPriv->pddsdPrimary,
- DDLOCK_WAIT,
- NULL);
- if (ddrval != DD_OK
- || pScreenPriv->pddsdPrimary->lpSurface == NULL)
- FatalError ("winWindowProc () - 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 (hWnd, 1, MOD_ALT, 9);
- }
- break;
- default:
- FatalError ("winWindowProc () - WM_ACTIVATEAPP - Unknown engine\n");
- }
+ /* Call engine specific screen activation/deactivation function */
+ (*pScreenPriv->pwinActivateApp) (pScreen);
return 0;
case WM_CLOSE: