aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xwin
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-03-26 14:23:28 +0200
committermarha <marha@users.sourceforge.net>2012-03-26 14:23:28 +0200
commit76bcc36ed305418a3ddc5752d287ede894243e1b (patch)
treebacb320c825768471ce56f058f17ce863d592376 /xorg-server/hw/xwin
parent7d894e32566b710952c44cbc71939ad1d9e2fa8d (diff)
parent0f834b91a4768673833ab4917e87d86c237bb1a6 (diff)
downloadvcxsrv-76bcc36ed305418a3ddc5752d287ede894243e1b.tar.gz
vcxsrv-76bcc36ed305418a3ddc5752d287ede894243e1b.tar.bz2
vcxsrv-76bcc36ed305418a3ddc5752d287ede894243e1b.zip
Merge remote-tracking branch 'origin/released'
Conflicts: pixman/pixman/pixman-mmx.c xorg-server/Xext/shm.c xorg-server/Xext/syncsrv.h xorg-server/Xext/xvmain.c xorg-server/Xi/exevents.c xorg-server/Xi/opendev.c xorg-server/composite/compalloc.c xorg-server/composite/compoverlay.c xorg-server/dix/colormap.c xorg-server/dix/devices.c xorg-server/dix/dispatch.c xorg-server/dix/dixfonts.c xorg-server/dix/eventconvert.c xorg-server/dix/events.c xorg-server/dix/gc.c xorg-server/dix/getevents.c xorg-server/dix/main.c xorg-server/dix/privates.c xorg-server/dix/registry.c xorg-server/dix/resource.c xorg-server/exa/exa_accel.c xorg-server/exa/exa_migration_classic.c xorg-server/exa/exa_unaccel.c xorg-server/fb/fb.h xorg-server/fb/fbcopy.c xorg-server/fb/fbpixmap.c xorg-server/glx/dispatch.h xorg-server/glx/glapi.h xorg-server/glx/glapi_gentable.c xorg-server/glx/glapitable.h xorg-server/glx/glprocs.h xorg-server/glx/glxcmds.c xorg-server/glx/glxcmdsswap.c xorg-server/glx/glxdricommon.c xorg-server/glx/glxdriswrast.c xorg-server/glx/glxext.c xorg-server/glx/indirect_dispatch.c xorg-server/glx/indirect_dispatch.h xorg-server/glx/indirect_dispatch_swap.c xorg-server/glx/indirect_size.h xorg-server/glx/indirect_size_get.h xorg-server/glx/indirect_table.c xorg-server/glx/indirect_util.c xorg-server/glx/rensize.c xorg-server/glx/single2swap.c xorg-server/glx/singlepix.c xorg-server/glx/singlepixswap.c xorg-server/glx/singlesize.c xorg-server/hw/dmx/dmxinit.c xorg-server/hw/kdrive/ephyr/ephyr.c xorg-server/hw/kdrive/ephyr/hostx.c xorg-server/hw/kdrive/ephyr/hostx.h xorg-server/hw/kdrive/src/kinput.c xorg-server/hw/xfree86/common/compiler.h xorg-server/hw/xwin/InitInput.c xorg-server/hw/xwin/InitOutput.c xorg-server/hw/xwin/ddraw.h xorg-server/hw/xwin/glx/glwrap.c xorg-server/hw/xwin/glx/indirect.c xorg-server/hw/xwin/glx/wgl_ext_api.h xorg-server/hw/xwin/glx/winpriv.c xorg-server/hw/xwin/win.h xorg-server/hw/xwin/winallpriv.c xorg-server/hw/xwin/winauth.c xorg-server/hw/xwin/winclipboard.h xorg-server/hw/xwin/winclipboardinit.c xorg-server/hw/xwin/winclipboardthread.c xorg-server/hw/xwin/winclipboardunicode.c xorg-server/hw/xwin/winclipboardwndproc.c xorg-server/hw/xwin/winclipboardwrappers.c xorg-server/hw/xwin/winclipboardxevents.c xorg-server/hw/xwin/wincmap.c xorg-server/hw/xwin/winconfig.c xorg-server/hw/xwin/wincreatewnd.c xorg-server/hw/xwin/wincursor.c xorg-server/hw/xwin/windialogs.c xorg-server/hw/xwin/winengine.c xorg-server/hw/xwin/winerror.c xorg-server/hw/xwin/wingc.c xorg-server/hw/xwin/wingetsp.c xorg-server/hw/xwin/winkeybd.c xorg-server/hw/xwin/winkeybd.h xorg-server/hw/xwin/winlayouts.h xorg-server/hw/xwin/winmisc.c xorg-server/hw/xwin/winmonitors.c xorg-server/hw/xwin/winmouse.c xorg-server/hw/xwin/winmsg.c xorg-server/hw/xwin/winmsg.h xorg-server/hw/xwin/winmultiwindowclass.c xorg-server/hw/xwin/winmultiwindowicons.c xorg-server/hw/xwin/winmultiwindowshape.c xorg-server/hw/xwin/winmultiwindowwindow.c xorg-server/hw/xwin/winmultiwindowwm.c xorg-server/hw/xwin/winmultiwindowwndproc.c xorg-server/hw/xwin/winnativegdi.c xorg-server/hw/xwin/winpfbdd.c xorg-server/hw/xwin/winpixmap.c xorg-server/hw/xwin/winpolyline.c xorg-server/hw/xwin/winprefs.c xorg-server/hw/xwin/winprocarg.c xorg-server/hw/xwin/winregistry.c xorg-server/hw/xwin/winscrinit.c xorg-server/hw/xwin/winsetsp.c xorg-server/hw/xwin/winshaddd.c xorg-server/hw/xwin/winshadddnl.c xorg-server/hw/xwin/winshadgdi.c xorg-server/hw/xwin/wintrayicon.c xorg-server/hw/xwin/winwin32rootless.c xorg-server/hw/xwin/winwin32rootlesswindow.c xorg-server/hw/xwin/winwin32rootlesswndproc.c xorg-server/hw/xwin/winwindow.c xorg-server/hw/xwin/winwindow.h xorg-server/hw/xwin/winwindowswm.c xorg-server/hw/xwin/winwndproc.c xorg-server/include/callback.h xorg-server/include/dixstruct.h xorg-server/include/misc.h xorg-server/include/os.h xorg-server/include/scrnintstr.h xorg-server/mi/micmap.c xorg-server/mi/miinitext.c xorg-server/mi/mioverlay.c xorg-server/mi/misprite.c xorg-server/mi/mivaltree.c xorg-server/mi/miwindow.c xorg-server/miext/damage/damage.c xorg-server/miext/rootless/rootlessGC.c xorg-server/miext/rootless/rootlessWindow.c xorg-server/os/WaitFor.c xorg-server/os/access.c xorg-server/os/connection.c xorg-server/os/io.c xorg-server/os/log.c xorg-server/os/osinit.c xorg-server/os/utils.c xorg-server/os/xdmcp.c xorg-server/os/xprintf.c xorg-server/os/xstrans.c xorg-server/render/mipict.c xorg-server/xkb/xkbActions.c xorg-server/xkb/xkbInit.c xorg-server/xkeyboard-config/compat/default.in
Diffstat (limited to 'xorg-server/hw/xwin')
-rw-r--r--xorg-server/hw/xwin/InitInput.c98
-rw-r--r--xorg-server/hw/xwin/InitOutput.c1082
-rw-r--r--xorg-server/hw/xwin/glx/glwindows.h20
-rw-r--r--xorg-server/hw/xwin/glx/glwrap.c84
-rw-r--r--xorg-server/hw/xwin/glx/indirect.c2531
-rw-r--r--xorg-server/hw/xwin/glx/wgl_ext_api.h170
-rw-r--r--xorg-server/hw/xwin/glx/winpriv.c52
-rw-r--r--xorg-server/hw/xwin/win.h981
-rw-r--r--xorg-server/hw/xwin/winallpriv.c346
-rw-r--r--xorg-server/hw/xwin/winauth.c413
-rw-r--r--xorg-server/hw/xwin/winblock.c185
-rw-r--r--xorg-server/hw/xwin/winclipboard.h39
-rw-r--r--xorg-server/hw/xwin/winclipboardinit.c285
-rw-r--r--xorg-server/hw/xwin/winclipboardtextconv.c166
-rw-r--r--xorg-server/hw/xwin/winclipboardthread.c562
-rw-r--r--xorg-server/hw/xwin/winclipboardunicode.c26
-rw-r--r--xorg-server/hw/xwin/winclipboardwndproc.c600
-rw-r--r--xorg-server/hw/xwin/winclipboardwrappers.c475
-rw-r--r--xorg-server/hw/xwin/winclipboardxevents.c1321
-rw-r--r--xorg-server/hw/xwin/wincmap.c1169
-rw-r--r--xorg-server/hw/xwin/winconfig.c1485
-rw-r--r--xorg-server/hw/xwin/winconfig.h588
-rw-r--r--xorg-server/hw/xwin/wincreatewnd.c850
-rw-r--r--xorg-server/hw/xwin/wincursor.c1241
-rw-r--r--xorg-server/hw/xwin/windialogs.c965
-rw-r--r--xorg-server/hw/xwin/winengine.c406
-rw-r--r--xorg-server/hw/xwin/winerror.c97
-rw-r--r--xorg-server/hw/xwin/winfillsp.c1673
-rw-r--r--xorg-server/hw/xwin/wingc.c318
-rw-r--r--xorg-server/hw/xwin/wingetsp.c321
-rw-r--r--xorg-server/hw/xwin/winkeybd.c638
-rw-r--r--xorg-server/hw/xwin/winkeybd.h520
-rw-r--r--xorg-server/hw/xwin/winkeyhook.c359
-rw-r--r--xorg-server/hw/xwin/winlayouts.h194
-rw-r--r--xorg-server/hw/xwin/winmisc.c119
-rw-r--r--xorg-server/hw/xwin/winmonitors.c33
-rw-r--r--xorg-server/hw/xwin/winmouse.c443
-rw-r--r--xorg-server/hw/xwin/winmsg.c90
-rw-r--r--xorg-server/hw/xwin/winmultiwindowclass.c450
-rw-r--r--xorg-server/hw/xwin/winmultiwindowicons.c1001
-rw-r--r--xorg-server/hw/xwin/winmultiwindowshape.c421
-rw-r--r--xorg-server/hw/xwin/winmultiwindowwindow.c1105
-rw-r--r--xorg-server/hw/xwin/winmultiwindowwm.c2401
-rw-r--r--xorg-server/hw/xwin/winmultiwindowwndproc.c1647
-rw-r--r--xorg-server/hw/xwin/winnativegdi.c627
-rw-r--r--xorg-server/hw/xwin/winpfbdd.c972
-rw-r--r--xorg-server/hw/xwin/winpixmap.c362
-rw-r--r--xorg-server/hw/xwin/winpolyline.c24
-rw-r--r--xorg-server/hw/xwin/winprefs.c1163
-rw-r--r--xorg-server/hw/xwin/winprefs.h159
-rw-r--r--xorg-server/hw/xwin/winprocarg.c1792
-rw-r--r--xorg-server/hw/xwin/winrandr.c228
-rw-r--r--xorg-server/hw/xwin/winregistry.c44
-rw-r--r--xorg-server/hw/xwin/winrop.c134
-rw-r--r--xorg-server/hw/xwin/winscrinit.c1084
-rw-r--r--xorg-server/hw/xwin/winsetsp.c357
-rw-r--r--xorg-server/hw/xwin/winshaddd.c1860
-rw-r--r--xorg-server/hw/xwin/winshadddnl.c1727
-rw-r--r--xorg-server/hw/xwin/winshadgdi.c1628
-rw-r--r--xorg-server/hw/xwin/wintrayicon.c266
-rw-r--r--xorg-server/hw/xwin/winvalargs.c210
-rw-r--r--xorg-server/hw/xwin/winvideo.c95
-rw-r--r--xorg-server/hw/xwin/winwakeup.c116
-rw-r--r--xorg-server/hw/xwin/winwin32rootless.c1285
-rw-r--r--xorg-server/hw/xwin/winwin32rootlesswindow.c578
-rw-r--r--xorg-server/hw/xwin/winwin32rootlesswndproc.c1944
-rw-r--r--xorg-server/hw/xwin/winwindow.c710
-rw-r--r--xorg-server/hw/xwin/winwindow.h84
-rw-r--r--xorg-server/hw/xwin/winwindowswm.c804
-rw-r--r--xorg-server/hw/xwin/winwndproc.c2055
70 files changed, 23209 insertions, 25069 deletions
diff --git a/xorg-server/hw/xwin/InitInput.c b/xorg-server/hw/xwin/InitInput.c
index 3e02633a5..e7f402f80 100644
--- a/xorg-server/hw/xwin/InitInput.c
+++ b/xorg-server/hw/xwin/InitInput.c
@@ -33,17 +33,15 @@
#include "dixstruct.h"
#include "inputstr.h"
#include <unistd.h>
-
/*
* Local function prototypes
*/
#ifdef XWIN_CLIPBOARD
-int winProcEstablishConnection(ClientPtr /* client */);
-int winProcSetSelectionOwner(ClientPtr /* client */);
+int winProcEstablishConnection(ClientPtr /* client */ );
+int winProcSetSelectionOwner(ClientPtr /* client */ );
#endif
-
/*
* Local global declarations
*/
@@ -61,89 +59,83 @@ DeviceIntPtr g_pwinKeyboard;
*/
Bool
-LegalModifier (unsigned int uiKey, DeviceIntPtr pDevice)
+LegalModifier(unsigned int uiKey, DeviceIntPtr pDevice)
{
- return TRUE;
+ return TRUE;
}
-
/* Called from dix/dispatch.c */
/*
* Run through the Windows message queue(s) one more time.
* Tell mi to dequeue the events that we have sent it.
*/
void
-ProcessInputEvents (void)
+ProcessInputEvents(void)
{
- mieqProcessInputEvents ();
+ mieqProcessInputEvents();
}
-
-void DDXRingBell(int volume, int pitch, int duration)
+void
+DDXRingBell(int volume, int pitch, int duration)
{
- /* winKeybdBell is used instead */
- return;
+ /* winKeybdBell is used instead */
+ return;
}
-
/* See Porting Layer Definition - p. 17 */
void
-InitInput (int argc, char *argv[])
+InitInput(int argc, char *argv[])
{
int rc;
- winDebug ("InitInput\n");
+ winDebug("InitInput\n");
#ifdef XWIN_CLIPBOARD
- /*
- * Wrap some functions at every generation of the server.
- */
- if (InitialVector[2] != winProcEstablishConnection)
- {
- winProcEstablishConnectionOrig = InitialVector[2];
- InitialVector[2] = winProcEstablishConnection;
+ /*
+ * Wrap some functions at every generation of the server.
+ */
+ if (InitialVector[2] != winProcEstablishConnection) {
+ winProcEstablishConnectionOrig = InitialVector[2];
+ InitialVector[2] = winProcEstablishConnection;
}
#endif
- rc = AllocDevicePair(serverClient, "Windows",
- &g_pwinPointer,
- &g_pwinKeyboard,
- winMouseProc,
- winKeybdProc,
- FALSE);
+ rc = AllocDevicePair(serverClient, "Windows",
+ &g_pwinPointer,
+ &g_pwinKeyboard,
+ winMouseProc,
+ winKeybdProc,
+ FALSE);
- if (rc != Success)
- FatalError("Failed to init vcxsrv default devices.\n");
+ if (rc != Success)
+ FatalError("Failed to init vcxsrv default devices.\n");
- mieqInit ();
+ mieqInit();
- /* Do not nitialize the mode key states here yet since the keyboard device is not started yet
- winInitializeModeKeyStates (); */
+ /* Do not nitialize the mode key states here yet since the keyboard device is not started yet
+ winInitializeModeKeyStates (); */
#ifdef HAS_DEVWINDOWS
- /* Only open the windows message queue device once */
- if (g_fdMessageQueue == WIN_FD_INVALID)
- {
- /* Open a file descriptor for the Windows message queue */
- g_fdMessageQueue = open (WIN_MSG_QUEUE_FNAME, O_RDONLY);
-
- if (g_fdMessageQueue == -1)
- {
- FatalError ("InitInput - Failed opening %s\n",
- WIN_MSG_QUEUE_FNAME);
- }
-
- /* Add the message queue as a device to wait for in WaitForSomething */
- AddEnabledDevice (g_fdMessageQueue);
+ /* Only open the windows message queue device once */
+ if (g_fdMessageQueue == WIN_FD_INVALID) {
+ /* Open a file descriptor for the Windows message queue */
+ g_fdMessageQueue = open(WIN_MSG_QUEUE_FNAME, O_RDONLY);
+
+ if (g_fdMessageQueue == -1) {
+ FatalError("InitInput - Failed opening %s\n", WIN_MSG_QUEUE_FNAME);
+ }
+
+ /* Add the message queue as a device to wait for in WaitForSomething */
+ AddEnabledDevice(g_fdMessageQueue);
}
#endif
- winDebug ("InitInput - returning\n");
+ winDebug("InitInput - returning\n");
}
void
-CloseInput (void)
+CloseInput(void)
{
- mieqFini ();
- g_pwinPointer=NULL;
- g_pwinKeyboard=NULL;
+ mieqFini();
+ g_pwinPointer=NULL;
+ g_pwinKeyboard=NULL;
}
diff --git a/xorg-server/hw/xwin/InitOutput.c b/xorg-server/hw/xwin/InitOutput.c
index 2a1635c92..ceb71ff07 100644
--- a/xorg-server/hw/xwin/InitOutput.c
+++ b/xorg-server/hw/xwin/InitOutput.c
@@ -48,25 +48,22 @@ from The Open Group.
#ifdef RELOCATE_PROJECTROOT
#undef Status
#include <shlobj.h>
-typedef HRESULT (__stdcall * SHGETFOLDERPATHPROC)(
- HWND hwndOwner,
- int nFolder,
- HANDLE hToken,
- DWORD dwFlags,
- LPSTR pszPath
-);
+typedef HRESULT (__stdcall * SHGETFOLDERPATHPROC)(HWND hwndOwner,
+ int nFolder,
+ HANDLE hToken,
+ DWORD dwFlags, LPTSTR pszPath);
#endif
/*
* References to external symbols
*/
#ifdef XWIN_CLIPBOARD
-extern Bool g_fUnicodeClipboard;
-extern Bool g_fClipboardLaunched;
-extern Bool g_fClipboardStarted;
-extern pthread_t g_ptClipboardProc;
-extern HWND g_hwndClipboard;
-extern Bool g_fClipboard;
+extern Bool g_fUnicodeClipboard;
+extern Bool g_fClipboardLaunched;
+extern Bool g_fClipboardStarted;
+extern pthread_t g_ptClipboardProc;
+extern HWND g_hwndClipboard;
+extern Bool g_fClipboard;
#endif
/*
@@ -75,29 +72,28 @@ extern Bool g_fClipboard;
#ifdef XWIN_CLIPBOARD
static void
-winClipboardShutdown (void);
+ winClipboardShutdown(void);
#endif
#if defined(DDXOSVERRORF)
void
-OsVendorVErrorF (const char *pszFormat, va_list va_args);
+ OsVendorVErrorF(const char *pszFormat, va_list va_args);
#endif
static Bool
-winCheckDisplayNumber (void);
+ winCheckDisplayNumber(void);
void
-winLogCommandLine (int argc, char *argv[]);
+ winLogCommandLine(int argc, char *argv[]);
void
-winLogVersionInfo (void);
+ winLogVersionInfo(void);
Bool
-winValidateArgs (void);
+ winValidateArgs(void);
#ifdef RELOCATE_PROJECTROOT
-const char *
-winGetBaseDir(void);
+const char *winGetBaseDir(void);
#endif
/*
@@ -114,38 +110,36 @@ winGetBaseDir(void);
*/
static PixmapFormatRec g_PixmapFormats[] = {
- { 1, 1, BITMAP_SCANLINE_PAD },
- { 4, 8, BITMAP_SCANLINE_PAD },
- { 8, 8, BITMAP_SCANLINE_PAD },
- { 15, 16, BITMAP_SCANLINE_PAD },
- { 16, 16, BITMAP_SCANLINE_PAD },
- { 24, 32, BITMAP_SCANLINE_PAD },
- { 32, 32, BITMAP_SCANLINE_PAD }
+ {1, 1, BITMAP_SCANLINE_PAD},
+ {4, 8, BITMAP_SCANLINE_PAD},
+ {8, 8, BITMAP_SCANLINE_PAD},
+ {15, 16, BITMAP_SCANLINE_PAD},
+ {16, 16, BITMAP_SCANLINE_PAD},
+ {24, 32, BITMAP_SCANLINE_PAD},
+ {32, 32, BITMAP_SCANLINE_PAD}
};
-const int NUMFORMATS = sizeof (g_PixmapFormats) / sizeof (g_PixmapFormats[0]);
+const int NUMFORMATS = sizeof(g_PixmapFormats) / sizeof(g_PixmapFormats[0]);
#ifdef XWIN_CLIPBOARD
static void
-winClipboardShutdown (void)
+winClipboardShutdown(void)
{
- /* Close down clipboard resources */
- if (g_fClipboard && g_fClipboardLaunched && g_fClipboardStarted)
- {
- /* Synchronously destroy the clipboard window */
- if (g_hwndClipboard != NULL)
- {
+ /* Close down clipboard resources */
+ if (g_fClipboard && g_fClipboardLaunched && g_fClipboardStarted) {
+ /* Synchronously destroy the clipboard window */
+ if (g_hwndClipboard != NULL) {
g_fClipboardStarted=FALSE; /* This is to avoid dead-locls caused by the clipboard thread still doing some stuff */
- SendMessage (g_hwndClipboard, WM_DESTROY, 0, 0);
- /* NOTE: g_hwndClipboard is set to NULL in winclipboardthread.c */
- }
- else
- return;
-
- /* Wait for the clipboard thread to exit */
- pthread_join (g_ptClipboardProc, NULL);
-
- winDebug ("winClipboardShutdown - Clipboard thread has exited.\n");
+ SendMessage(g_hwndClipboard, WM_DESTROY, 0, 0);
+ /* NOTE: g_hwndClipboard is set to NULL in winclipboardthread.c */
+ }
+ else
+ return;
+
+ /* Wait for the clipboard thread to exit */
+ pthread_join(g_ptClipboardProc, NULL);
+
+ winDebug("winClipboardShutdown - Clipboard thread has exited.\n");
}
}
#endif
@@ -158,91 +152,89 @@ winClipboardShutdown (void)
*/
void
-ddxBeforeReset (void)
+ddxBeforeReset(void)
{
- winDebug ("ddxBeforeReset - Hello\n");
+ winDebug("ddxBeforeReset - Hello\n");
#ifdef XWIN_CLIPBOARD
- winClipboardShutdown ();
+ winClipboardShutdown();
#endif
}
#endif
-
/* See Porting Layer Definition - p. 57 */
void
-ddxGiveUp (enum ExitCode error)
+ddxGiveUp(enum ExitCode error)
{
- int i;
+ int i;
- winDebug ("ddxGiveUp\n");
+ winDebug("ddxGiveUp\n");
- /* Perform per-screen deinitialization */
- for (i = 0; i < g_iNumScreens; ++i)
- {
- /* Delete the tray icon */
- if (!g_ScreenInfo[i].fNoTrayIcon && g_ScreenInfo[i].pScreen)
- winDeleteNotifyIcon (winGetScreenPriv (g_ScreenInfo[i].pScreen));
+ /* Perform per-screen deinitialization */
+ for (i = 0; i < g_iNumScreens; ++i) {
+ /* Delete the tray icon */
+ if (!g_ScreenInfo[i].fNoTrayIcon && g_ScreenInfo[i].pScreen)
+ winDeleteNotifyIcon(winGetScreenPriv(g_ScreenInfo[i].pScreen));
}
#ifdef XWIN_MULTIWINDOW
/* Unload libraries for taskbar grouping */
winTaskbarDestroy ();
- /* Notify the worker threads we're exiting */
- winDeinitMultiWindowWM ();
+ /* Notify the worker threads we're exiting */
+ winDeinitMultiWindowWM();
#endif
#ifdef HAS_DEVWINDOWS
- /* Close our handle to our message queue */
- if (g_fdMessageQueue != WIN_FD_INVALID)
- {
- /* Close /dev/windows */
- close (g_fdMessageQueue);
+ /* Close our handle to our message queue */
+ if (g_fdMessageQueue != WIN_FD_INVALID) {
+ /* Close /dev/windows */
+ close(g_fdMessageQueue);
- /* Set the file handle to invalid */
- g_fdMessageQueue = WIN_FD_INVALID;
+ /* Set the file handle to invalid */
+ g_fdMessageQueue = WIN_FD_INVALID;
}
#endif
- if (!g_fLogInited) {
- g_pszLogFile = LogInit (g_pszLogFile, NULL);
- g_fLogInited = TRUE;
- }
- LogClose (error);
-
- /*
- * At this point we aren't creating any new screens, so
- * we are guaranteed to not need the DirectDraw functions.
- */
- winReleaseDDProcAddresses();
-
- /* Free concatenated command line */
- free(g_pszCommandLine);
- g_pszCommandLine = NULL;
-
- /* Remove our keyboard hook if it is installed */
- winRemoveKeyboardHookLL ();
-
- /* Tell Windows that we want to end the app */
- PostQuitMessage (0);
-}
+ if (!g_fLogInited) {
+ g_pszLogFile = LogInit(g_pszLogFile, NULL);
+ g_fLogInited = TRUE;
+ }
+ LogClose(error);
+ /*
+ * At this point we aren't creating any new screens, so
+ * we are guaranteed to not need the DirectDraw functions.
+ */
+ winReleaseDDProcAddresses();
+
+ /* Free concatenated command line */
+ free(g_pszCommandLine);
+ g_pszCommandLine = NULL;
+
+ /* Remove our keyboard hook if it is installed */
+ winRemoveKeyboardHookLL();
+
+ /* Tell Windows that we want to end the app */
+ PostQuitMessage(0);
+}
/* See Porting Layer Definition - p. 57 */
void
-AbortDDX (enum ExitCode error)
+AbortDDX(enum ExitCode error)
{
- winDebug ("AbortDDX\n");
- ddxGiveUp (error);
+ winDebug("AbortDDX\n");
+ ddxGiveUp(error);
}
#ifdef __CYGWIN__
/* hasmntopt is currently not implemented for cygwin */
-static const char *winCheckMntOpt(const struct mntent *mnt, const char *opt)
+static const char *
+winCheckMntOpt(const struct mntent *mnt, const char *opt)
{
const char *s;
size_t len;
+
if (mnt == NULL)
return NULL;
if (opt == NULL)
@@ -254,101 +246,96 @@ static const char *winCheckMntOpt(const struct mntent *mnt, const char *opt)
s = strstr(mnt->mnt_opts, opt);
if (s == NULL)
return NULL;
- if ((s == mnt->mnt_opts || *(s-1) == ',') && (s[len] == 0 || s[len] == ','))
- return (char *)opt;
+ if ((s == mnt->mnt_opts || *(s - 1) == ',') &&
+ (s[len] == 0 || s[len] == ','))
+ return (char *) opt;
return NULL;
}
static void
winCheckMount(void)
{
- FILE *mnt;
- struct mntent *ent;
-
- enum { none = 0, sys_root, user_root, sys_tmp, user_tmp }
- level = none, curlevel;
- BOOL binary = TRUE;
-
- mnt = setmntent("/etc/mtab", "r");
- if (mnt == NULL)
- {
- ErrorF("setmntent failed");
- return;
- }
-
- while ((ent = getmntent(mnt)) != NULL)
- {
- BOOL system = (winCheckMntOpt(ent, "user") != NULL);
- BOOL root = (strcmp(ent->mnt_dir, "/") == 0);
- BOOL tmp = (strcmp(ent->mnt_dir, "/tmp") == 0);
-
- if (system)
- {
- if (root)
- curlevel = sys_root;
- else if (tmp)
- curlevel = sys_tmp;
- else
- continue;
+ FILE *mnt;
+ struct mntent *ent;
+
+ enum { none = 0, sys_root, user_root, sys_tmp, user_tmp }
+ level = none, curlevel;
+ BOOL binary = TRUE;
+
+ mnt = setmntent("/etc/mtab", "r");
+ if (mnt == NULL) {
+ ErrorF("setmntent failed");
+ return;
}
- else
- {
- if (root)
- curlevel = user_root;
- else if (tmp)
- curlevel = user_tmp;
- else
- continue;
+
+ while ((ent = getmntent(mnt)) != NULL) {
+ BOOL system = (winCheckMntOpt(ent, "user") != NULL);
+ BOOL root = (strcmp(ent->mnt_dir, "/") == 0);
+ BOOL tmp = (strcmp(ent->mnt_dir, "/tmp") == 0);
+
+ if (system) {
+ if (root)
+ curlevel = sys_root;
+ else if (tmp)
+ curlevel = sys_tmp;
+ else
+ continue;
+ }
+ else {
+ if (root)
+ curlevel = user_root;
+ else if (tmp)
+ curlevel = user_tmp;
+ else
+ continue;
+ }
+
+ if (curlevel <= level)
+ continue;
+ level = curlevel;
+
+ if ((winCheckMntOpt(ent, "binary") == NULL) &&
+ (winCheckMntOpt(ent, "binmode") == NULL))
+ binary = FALSE;
+ else
+ binary = TRUE;
+ }
+
+ if (endmntent(mnt) != 1) {
+ ErrorF("endmntent failed");
+ return;
}
- if (curlevel <= level)
- continue;
- level = curlevel;
-
- if ((winCheckMntOpt(ent, "binary") == NULL) &&
- (winCheckMntOpt(ent, "binmode") == NULL))
- binary = FALSE;
- else
- binary = TRUE;
- }
-
- if (endmntent(mnt) != 1)
- {
- ErrorF("endmntent failed");
- return;
- }
-
#ifdef WINDBG
- if (!binary)
- winDebug("/tmp mounted in textmode\n");
+ if (!binary)
+ winDebug("/tmp mounted in textmode\n");
#endif
}
#else
static void
-winCheckMount(void)
+winCheckMount(void)
{
}
#endif
#ifdef RELOCATE_PROJECTROOT
-const char *
+const char *
winGetBaseDir(void)
{
static BOOL inited = FALSE;
static char buffer[MAX_PATH];
- if (!inited)
- {
+
+ if (!inited) {
char *fendptr;
HMODULE module = GetModuleHandle(NULL);
DWORD size = GetModuleFileName(module, buffer, sizeof(buffer));
+
if (sizeof(buffer) > 0)
- buffer[sizeof(buffer)-1] = 0;
-
+ buffer[sizeof(buffer) - 1] = 0;
+
fendptr = buffer + size;
- while (fendptr > buffer)
- {
- if (*fendptr == '\\' || *fendptr == '/')
- {
+ while (fendptr > buffer) {
+ if (*fendptr == '\\' || *fendptr == '/') {
*fendptr = 0;
break;
}
@@ -361,10 +348,11 @@ winGetBaseDir(void)
#endif
static void
-winFixupPaths (void)
+winFixupPaths(void)
{
BOOL changed_fontpath = FALSE;
MessageType font_from = X_DEFAULT;
+
#ifdef RELOCATE_PROJECTROOT
const char *basedir = winGetBaseDir();
size_t basedirlen = strlen(basedir);
@@ -384,10 +372,9 @@ winFixupPaths (void)
#else
FILE *fontdirs = fopen(ETCX11DIR "/font-dirs", "rt");
#endif
- if (fontdirs != NULL)
- {
+ if (fontdirs != NULL) {
char buffer[256];
- int needs_sep = TRUE;
+ int needs_sep = TRUE;
int comment_block = FALSE;
/* get default fontpath */
@@ -395,8 +382,7 @@ winFixupPaths (void)
size_t size = strlen(fontpath);
/* read all lines */
- while (!feof(fontdirs))
- {
+ while (!feof(fontdirs)) {
size_t blen;
char *hashchar;
char *str;
@@ -404,29 +390,26 @@ winFixupPaths (void)
/* read one line */
str = fgets(buffer, sizeof(buffer), fontdirs);
- if (str == NULL) /* stop on error or eof */
+ if (str == NULL) /* stop on error or eof */
break;
if (strchr(str, '\n') != NULL)
has_eol = TRUE;
/* check if block is continued comment */
- if (comment_block)
- {
+ if (comment_block) {
/* ignore all input */
- *str = 0;
- blen = 0;
- if (has_eol) /* check if line ended in this block */
+ *str = 0;
+ blen = 0;
+ if (has_eol) /* check if line ended in this block */
comment_block = FALSE;
}
- else
- {
+ else {
/* find comment character. ignore all trailing input */
hashchar = strchr(str, '#');
- if (hashchar != NULL)
- {
+ if (hashchar != NULL) {
*hashchar = 0;
- if (!has_eol) /* mark next block as continued comment */
+ if (!has_eol) /* mark next block as continued comment */
comment_block = TRUE;
}
}
@@ -435,31 +418,30 @@ winFixupPaths (void)
while (*str == ' ' || *str == '\t')
str++;
- /* get size, strip whitespaces from end */
+ /* get size, strip whitespaces from end */
blen = strlen(str);
- while (blen > 0 && (str[blen-1] == ' ' ||
- str[blen-1] == '\t' || str[blen-1] == '\n'))
- {
+ while (blen > 0 && (str[blen - 1] == ' ' ||
+ str[blen - 1] == '\t' ||
+ str[blen - 1] == '\n')) {
str[--blen] = 0;
}
- /* still something left to add? */
- if (blen > 0)
- {
+ /* still something left to add? */
+ if (blen > 0) {
size_t newsize = size + blen;
+
/* reserve one character more for ',' */
if (needs_sep)
newsize++;
/* allocate memory */
if (fontpath == NULL)
- fontpath = malloc(newsize+1);
+ fontpath = malloc(newsize + 1);
else
- fontpath = realloc(fontpath, newsize+1);
+ fontpath = realloc(fontpath, newsize + 1);
/* add separator */
- if (needs_sep)
- {
+ if (needs_sep) {
fontpath[size] = ',';
size++;
needs_sep = FALSE;
@@ -477,14 +459,14 @@ winFixupPaths (void)
}
/* cleanup */
- fclose(fontdirs);
+ fclose(fontdirs);
defaultFontPath = strdup(fontpath);
free(fontpath);
changed_fontpath = TRUE;
font_from = X_CONFIG;
}
}
-#endif /* READ_FONTDIRS */
+#endif /* READ_FONTDIRS */
#ifdef RELOCATE_PROJECTROOT
{
const char *libx11dir = PROJECTROOT "/lib/X11";
@@ -497,20 +479,19 @@ winFixupPaths (void)
ptr = strchr(oldptr, ',');
if (ptr == NULL)
ptr = endptr;
- while (ptr != NULL)
- {
+ while (ptr != NULL) {
size_t oldfp_len = (ptr - oldptr);
size_t newsize = oldfp_len;
char *newpath = malloc(newsize + 1);
+
strncpy(newpath, oldptr, newsize);
newpath[newsize] = 0;
-
- if (strncmp(libx11dir, newpath, libx11dir_len) == 0)
- {
+ if (strncmp(libx11dir, newpath, libx11dir_len) == 0) {
char *compose;
+
newsize = newsize - libx11dir_len + basedirlen;
- compose = malloc(newsize + 1);
+ compose = malloc(newsize + 1);
strcpy(compose, basedir);
strncat(compose, newpath + libx11dir_len, newsize - basedirlen);
compose[newsize] = 0;
@@ -520,7 +501,7 @@ winFixupPaths (void)
oldfp_len = newfp_len;
if (oldfp_len > 0)
- newfp_len ++; /* space for separator */
+ newfp_len++; /* space for separator */
newfp_len += newsize;
if (newfp == NULL)
@@ -528,8 +509,7 @@ winFixupPaths (void)
else
newfp = realloc(newfp, newfp_len + 1);
- if (oldfp_len > 0)
- {
+ if (oldfp_len > 0) {
strcpy(newfp + oldfp_len, ",");
oldfp_len++;
}
@@ -537,82 +517,78 @@ winFixupPaths (void)
free(newpath);
- if (*ptr == 0)
- {
+ if (*ptr == 0) {
oldptr = ptr;
ptr = NULL;
- } else
- {
+ }
+ else {
oldptr = ptr + 1;
ptr = strchr(oldptr, ',');
if (ptr == NULL)
ptr = endptr;
}
- }
+ }
defaultFontPath = strdup(newfp);
free(newfp);
changed_fontpath = TRUE;
}
-#endif /* RELOCATE_PROJECTROOT */
+#endif /* RELOCATE_PROJECTROOT */
if (changed_fontpath)
winDebug ("FontPath set to \"%s\"\n", defaultFontPath);
#ifdef RELOCATE_PROJECTROOT
- if (getenv("XKEYSYMDB") == NULL)
- {
+ if (getenv("XKEYSYMDB") == NULL) {
char buffer[MAX_PATH];
- snprintf(buffer, sizeof(buffer), "XKEYSYMDB=%s\\XKeysymDB",
- basedir);
- buffer[sizeof(buffer)-1] = 0;
+
+ snprintf(buffer, sizeof(buffer), "XKEYSYMDB=%s\\XKeysymDB", basedir);
+ buffer[sizeof(buffer) - 1] = 0;
putenv(buffer);
}
- if (getenv("XERRORDB") == NULL)
- {
+ if (getenv("XERRORDB") == NULL) {
char buffer[MAX_PATH];
- snprintf(buffer, sizeof(buffer), "XERRORDB=%s\\XErrorDB",
- basedir);
- buffer[sizeof(buffer)-1] = 0;
+
+ snprintf(buffer, sizeof(buffer), "XERRORDB=%s\\XErrorDB", basedir);
+ buffer[sizeof(buffer) - 1] = 0;
putenv(buffer);
}
- if (getenv("XLOCALEDIR") == NULL)
- {
+ if (getenv("XLOCALEDIR") == NULL) {
char buffer[MAX_PATH];
- snprintf(buffer, sizeof(buffer), "XLOCALEDIR=%s\\locale",
- basedir);
- buffer[sizeof(buffer)-1] = 0;
+
+ snprintf(buffer, sizeof(buffer), "XLOCALEDIR=%s\\locale", basedir);
+ buffer[sizeof(buffer) - 1] = 0;
putenv(buffer);
}
- if (getenv("XHOSTPREFIX") == NULL)
- {
+ if (getenv("XHOSTPREFIX") == NULL) {
char buffer[MAX_PATH];
snprintf(buffer, sizeof(buffer), "XHOSTPREFIX=%s\\X",
basedir);
buffer[sizeof(buffer)-1] = 0;
putenv(buffer);
}
- if (getenv("HOME") == NULL)
- {
+ if (getenv("HOME") == NULL) {
char buffer[MAX_PATH + 5];
+
strncpy(buffer, "HOME=", 5);
/* query appdata directory */
- if (SHGetFolderPathA(NULL, CSIDL_APPDATA|CSIDL_FLAG_CREATE, NULL, 0, buffer + 5) == 0)
- {
+ if (SHGetFolderPathA
+ (NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0,
+ buffer + 5) == 0) {
putenv(buffer);
- } else
- {
+ }
+ else {
ErrorF ("Can not determine HOME directory\n");
}
}
if (!g_fLogFileChanged) {
static char buffer[MAX_PATH];
DWORD size = GetTempPath(sizeof(buffer), buffer);
- if (size && size < sizeof(buffer))
- {
- snprintf(buffer + size, sizeof(buffer) - size,
+
+ if (size && size < sizeof(buffer)) {
+ snprintf(buffer + size, sizeof(buffer) - size,
"VCXSrv.%s.log", display);
- buffer[sizeof(buffer)-1] = 0;
+ buffer[sizeof(buffer) - 1] = 0;
g_pszLogFile = buffer;
GetLongPathName(buffer, buffer, MAX_PATH);
winDebug ("Logfile set to \"%s\"\n", g_pszLogFile);
@@ -623,300 +599,288 @@ winFixupPaths (void)
snprintf(xkbbasedir, sizeof(xkbbasedir), "%s\\xkbdata", basedir);
if (sizeof(xkbbasedir) > 0)
- xkbbasedir[sizeof(xkbbasedir)-1] = 0;
+ xkbbasedir[sizeof(xkbbasedir) - 1] = 0;
XkbBaseDirectory = xkbbasedir;
- XkbBinDirectory = basedir;
+ XkbBinDirectory = basedir;
}
-#endif /* RELOCATE_PROJECTROOT */
+#endif /* RELOCATE_PROJECTROOT */
}
void
-OsVendorInit (void)
+OsVendorInit(void)
{
- /* Re-initialize global variables on server reset */
- winInitializeGlobals ();
+ /* Re-initialize global variables on server reset */
+ winInitializeGlobals();
- winFixupPaths();
+ winFixupPaths();
#ifdef DDXOSVERRORF
- if (!OsVendorVErrorFProc)
- OsVendorVErrorFProc = OsVendorVErrorF;
+ if (!OsVendorVErrorFProc)
+ OsVendorVErrorFProc = OsVendorVErrorF;
#endif
- if (!g_fLogInited) {
- /* keep this order. If LogInit fails it calls Abort which then calls
- * ddxGiveUp where LogInit is called again and creates an infinite
- * recursion. If we set g_fLogInited to TRUE before the init we
- * avoid the second call
- */
- g_fLogInited = TRUE;
- g_pszLogFile = LogInit (g_pszLogFile, NULL);
- }
- LogSetParameter (XLOG_FLUSH, 1);
- LogSetParameter (XLOG_VERBOSITY, g_iLogVerbose);
- LogSetParameter (XLOG_FILE_VERBOSITY, g_iLogVerbose);
-
- /* Log the version information */
- if (serverGeneration == 1)
- winLogVersionInfo ();
-
- winCheckMount();
-
- /* Add a default screen if no screens were specified */
- if (g_iNumScreens == 0)
- {
- winDebug ("OsVendorInit - Creating default screen 0\n");
-
- /*
- * We need to initialize the default screen 0 if no -screen
- * arguments were processed.
- *
- * Add a screen 0 using the defaults set by winInitializeDefaultScreens()
- * and any additional default screen parameters given
- */
- winInitializeScreens(1);
-
- /* We have to flag this as an explicit screen, even though it isn't */
- g_ScreenInfo[0].fExplicitScreen = TRUE;
+ if (!g_fLogInited) {
+ /* keep this order. If LogInit fails it calls Abort which then calls
+ * ddxGiveUp where LogInit is called again and creates an infinite
+ * recursion. If we set g_fLogInited to TRUE before the init we
+ * avoid the second call
+ */
+ g_fLogInited = TRUE;
+ g_pszLogFile = LogInit(g_pszLogFile, NULL);
+ }
+ LogSetParameter(XLOG_FLUSH, 1);
+ LogSetParameter(XLOG_VERBOSITY, g_iLogVerbose);
+ LogSetParameter(XLOG_FILE_VERBOSITY, g_iLogVerbose);
+
+ /* Log the version information */
+ if (serverGeneration == 1)
+ winLogVersionInfo();
+
+ winCheckMount();
+
+ /* Add a default screen if no screens were specified */
+ if (g_iNumScreens == 0) {
+ winDebug("OsVendorInit - Creating default screen 0\n");
+
+ /*
+ * We need to initialize the default screen 0 if no -screen
+ * arguments were processed.
+ *
+ * Add a screen 0 using the defaults set by winInitializeDefaultScreens()
+ * and any additional default screen parameters given
+ */
+ winInitializeScreens(1);
+
+ /* We have to flag this as an explicit screen, even though it isn't */
+ g_ScreenInfo[0].fExplicitScreen = TRUE;
}
- /* Work out what the default emulate3buttons setting should be, and apply
- it if nothing was explicitly specified */
- {
- int mouseButtons = GetSystemMetrics(SM_CMOUSEBUTTONS);
- int j;
-
- for (j = 0; j < g_iNumScreens; j++)
- {
- if (g_ScreenInfo[j].iE3BTimeout == WIN_E3B_DEFAULT)
- {
- if (mouseButtons < 3)
- {
- static Bool reportOnce = TRUE;
- g_ScreenInfo[j].iE3BTimeout = WIN_DEFAULT_E3B_TIME;
- if (reportOnce)
- {
- reportOnce = FALSE;
- winDebug("Windows reports only %d mouse buttons, defaulting to -emulate3buttons\n", mouseButtons);
- }
- }
- else
- {
- g_ScreenInfo[j].iE3BTimeout = WIN_E3B_OFF;
- }
- }
- }
- }
+ /* Work out what the default emulate3buttons setting should be, and apply
+ it if nothing was explicitly specified */
+ {
+ int mouseButtons = GetSystemMetrics(SM_CMOUSEBUTTONS);
+ int j;
+
+ for (j = 0; j < g_iNumScreens; j++) {
+ if (g_ScreenInfo[j].iE3BTimeout == WIN_E3B_DEFAULT) {
+ if (mouseButtons < 3) {
+ static Bool reportOnce = TRUE;
+
+ g_ScreenInfo[j].iE3BTimeout = WIN_DEFAULT_E3B_TIME;
+ if (reportOnce) {
+ reportOnce = FALSE;
+ winDebug("Windows reports only %d mouse buttons, defaulting to -emulate3buttons\n",
+ mouseButtons);
+ }
+ }
+ else {
+ g_ScreenInfo[j].iE3BTimeout = WIN_E3B_OFF;
+ }
+ }
+ }
+ }
}
static void
-winUseMsg (void)
+winUseMsg(void)
{
- ErrorF("\n");
- ErrorF("\n");
- ErrorF(EXECUTABLE_NAME " Device Dependent Usage:\n");
- ErrorF("\n");
+ ErrorF("\n");
+ ErrorF("\n");
+ ErrorF(EXECUTABLE_NAME " Device Dependent Usage:\n");
+ ErrorF("\n");
#ifdef XWIN_CLIPBOARD
- ErrorF ("-[no]clipboard\n"
- "\tEnable [disable] the clipboard integration. Default is enabled.\n");
+ ErrorF("-[no]clipboard\n"
+ "\tEnable [disable] the clipboard integration. Default is enabled.\n");
ErrorF ("-[no]clipboardprimary\n"
"\t[Do not] map the PRIMARY selection to the windows clipboard.\n"
"\tThe CLIPBOARD selection is always mapped if -clipboard is enabled.\n"
"\tDefault is mapped.\n");
#endif
- ErrorF ("-clipupdates num_boxes\n"
- "\tUse a clipping region to constrain shadow update blits to\n"
- "\tthe updated region when num_boxes, or more, are in the\n"
- "\tupdated region.\n");
+ ErrorF("-clipupdates num_boxes\n"
+ "\tUse a clipping region to constrain shadow update blits to\n"
+ "\tthe updated region when num_boxes, or more, are in the\n"
+ "\tupdated region.\n");
#ifdef XWIN_XF86CONFIG
- ErrorF ("-config\n"
- "\tSpecify a configuration file.\n");
+ ErrorF("-config\n" "\tSpecify a configuration file.\n");
- ErrorF ("-configdir\n"
- "\tSpecify a configuration directory.\n");
+ ErrorF("-configdir\n" "\tSpecify a configuration directory.\n");
#endif
- ErrorF ("-depth bits_per_pixel\n"
- "\tSpecify an optional bitdepth to use in fullscreen mode\n"
- "\twith a DirectDraw engine.\n");
+ ErrorF("-depth bits_per_pixel\n"
+ "\tSpecify an optional bitdepth to use in fullscreen mode\n"
+ "\twith a DirectDraw engine.\n");
- ErrorF ("-[no]emulate3buttons [timeout]\n"
- "\tEmulate 3 button mouse with an optional timeout in\n"
- "\tmilliseconds.\n");
+ ErrorF("-[no]emulate3buttons [timeout]\n"
+ "\tEmulate 3 button mouse with an optional timeout in\n"
+ "\tmilliseconds.\n");
#ifdef XWIN_EMULATEPSEUDO
- ErrorF ("-emulatepseudo\n"
- "\tCreate a depth 8 PseudoColor visual when running in\n"
- "\tdepths 15, 16, 24, or 32, collectively known as TrueColor\n"
- "\tdepths. The PseudoColor visual does not have correct colors,\n"
- "\tand it may crash, but it at least allows you to run your\n"
- "\tapplication in TrueColor modes.\n");
+ ErrorF("-emulatepseudo\n"
+ "\tCreate a depth 8 PseudoColor visual when running in\n"
+ "\tdepths 15, 16, 24, or 32, collectively known as TrueColor\n"
+ "\tdepths. The PseudoColor visual does not have correct colors,\n"
+ "\tand it may crash, but it at least allows you to run your\n"
+ "\tapplication in TrueColor modes.\n");
#endif
- ErrorF ("-engine engine_type_id\n"
- "\tOverride the server's automatically selected engine type:\n"
- "\t\t1 - Shadow GDI\n"
- "\t\t2 - Shadow DirectDraw\n"
- "\t\t4 - Shadow DirectDraw4 Non-Locking\n"
+ ErrorF("-engine engine_type_id\n"
+ "\tOverride the server's automatically selected engine type:\n"
+ "\t\t1 - Shadow GDI\n"
+ "\t\t2 - Shadow DirectDraw\n"
+ "\t\t4 - Shadow DirectDraw4 Non-Locking\n"
#ifdef XWIN_PRIMARYFB
- "\t\t8 - Primary DirectDraw - obsolete\n"
+ "\t\t8 - Primary DirectDraw - obsolete\n"
#endif
#ifdef XWIN_NATIVEGDI
- "\t\t16 - Native GDI - experimental\n"
+ "\t\t16 - Native GDI - experimental\n"
#endif
- );
+ );
- ErrorF ("-fullscreen\n"
- "\tRun the server in fullscreen mode.\n");
+ ErrorF("-fullscreen\n" "\tRun the server in fullscreen mode.\n");
- ErrorF ("-ignoreinput\n"
- "\tIgnore keyboard and mouse input.\n");
+ ErrorF("-ignoreinput\n" "\tIgnore keyboard and mouse input.\n");
#ifdef XWIN_MULTIWINDOWINTWM
- ErrorF ("-internalwm\n"
- "\tRun the internal window manager.\n");
+ ErrorF("-internalwm\n" "\tRun the internal window manager.\n");
#endif
#ifdef XWIN_XF86CONFIG
- ErrorF ("-keyboard\n"
- "\tSpecify a keyboard device from the configuration file.\n");
+ ErrorF("-keyboard\n"
+ "\tSpecify a keyboard device from the configuration file.\n");
#endif
- ErrorF ("-[no]keyhook\n"
- "\tGrab special Windows keypresses like Alt-Tab or the Menu "
- "key.\n");
+ ErrorF("-[no]keyhook\n"
+ "\tGrab special Windows keypresses like Alt-Tab or the Menu "
+ "key.\n");
- ErrorF ("-lesspointer\n"
- "\tHide the windows mouse pointer when it is over any\n"
- "\t" EXECUTABLE_NAME " window. This prevents ghost cursors appearing when\n"
- "\tthe Windows cursor is drawn on top of the X cursor\n");
+ ErrorF("-lesspointer\n"
+ "\tHide the windows mouse pointer when it is over any\n"
+ "\t" EXECUTABLE_NAME
+ " window. This prevents ghost cursors appearing when\n"
+ "\tthe Windows cursor is drawn on top of the X cursor\n");
- ErrorF ("-logfile filename\n"
- "\tWrite log messages to <filename>.\n");
+ ErrorF("-logfile filename\n" "\tWrite log messages to <filename>.\n");
- ErrorF ("-logverbose verbosity\n"
- "\tSet the verbosity of log messages. [NOTE: Only a few messages\n"
- "\trespect the settings yet]\n"
- "\t\t0 - only print fatal error.\n"
- "\t\t1 - print additional configuration information.\n"
- "\t\t2 - print additional runtime information [default].\n"
- "\t\t3 - print debugging and tracing information.\n");
+ ErrorF("-logverbose verbosity\n"
+ "\tSet the verbosity of log messages. [NOTE: Only a few messages\n"
+ "\trespect the settings yet]\n"
+ "\t\t0 - only print fatal error.\n"
+ "\t\t1 - print additional configuration information.\n"
+ "\t\t2 - print additional runtime information [default].\n"
+ "\t\t3 - print debugging and tracing information.\n");
- ErrorF ("-[no]multimonitors or -[no]multiplemonitors\n"
- "\tUse the entire virtual screen if multiple\n"
- "\tmonitors are present.\n");
+ ErrorF("-[no]multimonitors or -[no]multiplemonitors\n"
+ "\tUse the entire virtual screen if multiple\n"
+ "\tmonitors are present.\n");
#ifdef XWIN_MULTIWINDOW
- ErrorF ("-multiwindow\n"
- "\tRun the server in multi-window mode.\n");
+ ErrorF("-multiwindow\n" "\tRun the server in multi-window mode.\n");
#endif
#ifdef XWIN_MULTIWINDOWEXTWM
- ErrorF ("-mwextwm\n"
- "\tRun the server in multi-window external window manager mode.\n");
+ ErrorF("-mwextwm\n"
+ "\tRun the server in multi-window external window manager mode.\n");
#endif
- ErrorF ("-nodecoration\n"
- "\tDo not draw a window border, title bar, etc. Windowed\n"
- "\tmode only.\n");
+ ErrorF("-nodecoration\n"
+ "\tDo not draw a window border, title bar, etc. Windowed\n"
+ "\tmode only.\n");
#ifdef XWIN_CLIPBOARD
- ErrorF ("-nounicodeclipboard\n"
- "\tDo not use Unicode clipboard even if on a NT-based platform.\n");
+ ErrorF("-nounicodeclipboard\n"
+ "\tDo not use Unicode clipboard even if on a NT-based platform.\n");
#endif
- ErrorF ("-refresh rate_in_Hz\n"
- "\tSpecify an optional refresh rate to use in fullscreen mode\n"
- "\twith a DirectDraw engine.\n");
+ ErrorF("-refresh rate_in_Hz\n"
+ "\tSpecify an optional refresh rate to use in fullscreen mode\n"
+ "\twith a DirectDraw engine.\n");
- ErrorF ("-resize=none|scrollbars|randr"
- "\tIn windowed mode, [don't] allow resizing of the window. 'scrollbars'\n"
- "\tmode gives the window scrollbars as needed, 'randr' mode uses the RANR\n"
- "\textension to resize the X screen. 'randr' is the default.\n");
+ ErrorF("-resize=none|scrollbars|randr"
+ "\tIn windowed mode, [don't] allow resizing of the window. 'scrollbars'\n"
+ "\tmode gives the window scrollbars as needed, 'randr' mode uses the RANR\n"
+ "\textension to resize the X screen. 'randr' is the default.\n");
- ErrorF ("-rootless\n"
- "\tRun the server in rootless mode.\n");
+ ErrorF("-rootless\n" "\tRun the server in rootless mode.\n");
- ErrorF ("-screen scr_num [width height [x y] | [[WxH[+X+Y]][@m]] ]\n"
- "\tEnable screen scr_num and optionally specify a width and\n"
- "\theight and initial position for that screen. Additionally\n"
- "\ta monitor number can be specified to start the server on,\n"
- "\tat which point, all coordinates become relative to that\n"
- "\tmonitor. Examples:\n"
- "\t -screen 0 800x600+100+100@2 ; 2nd monitor offset 100,100 size 800x600\n"
- "\t -screen 0 1024x768@3 ; 3rd monitor size 1024x768\n"
- "\t -screen 0 @1 ; on 1st monitor using its full resolution (the default)\n");
+ ErrorF("-screen scr_num [width height [x y] | [[WxH[+X+Y]][@m]] ]\n"
+ "\tEnable screen scr_num and optionally specify a width and\n"
+ "\theight and initial position for that screen. Additionally\n"
+ "\ta monitor number can be specified to start the server on,\n"
+ "\tat which point, all coordinates become relative to that\n"
+ "\tmonitor. Examples:\n"
+ "\t -screen 0 800x600+100+100@2 ; 2nd monitor offset 100,100 size 800x600\n"
+ "\t -screen 0 1024x768@3 ; 3rd monitor size 1024x768\n"
+ "\t -screen 0 @1 ; on 1st monitor using its full resolution (the default)\n");
- ErrorF ("-silent-dup-error\n"
- "\tIf another instance of " EXECUTABLE_NAME " with the same display number is running\n"
- "\texit silently and don't display any error message.\n");
+ ErrorF("-silent-dup-error\n"
+ "\tIf another instance of " EXECUTABLE_NAME
+ " with the same display number is running\n"
+ "\texit silently and don't display any error message.\n");
- ErrorF ("-swcursor\n"
- "\tDisable the usage of the Windows cursor and use the X11 software\n"
- "\tcursor instead.\n");
+ ErrorF("-swcursor\n"
+ "\tDisable the usage of the Windows cursor and use the X11 software\n"
+ "\tcursor instead.\n");
- ErrorF ("-[no]trayicon\n"
- "\tDo not create a tray icon. Default is to create one\n"
- "\ticon per screen. You can globally disable tray icons with\n"
- "\t-notrayicon, then enable it for specific screens with\n"
- "\t-trayicon for those screens.\n");
+ ErrorF("-[no]trayicon\n"
+ "\tDo not create a tray icon. Default is to create one\n"
+ "\ticon per screen. You can globally disable tray icons with\n"
+ "\t-notrayicon, then enable it for specific screens with\n"
+ "\t-trayicon for those screens.\n");
- ErrorF ("-[no]unixkill\n"
- "\tCtrl+Alt+Backspace exits the X Server.\n");
+ ErrorF("-[no]unixkill\n" "\tCtrl+Alt+Backspace exits the X Server.\n");
- ErrorF ("-[no]wgl\n"
- "\tEnable the GLX extension to use the native Windows WGL interface for accelerated OpenGL\n");
+ ErrorF("-[no]wgl\n"
+ "\tEnable the GLX extension to use the native Windows WGL interface for accelerated OpenGL\n");
ErrorF ("-swrastwgl\n"
"\tEnable the GLX extension to use the native Windows WGL interface based on the swrast interface for accelerated OpenGL\n");
- ErrorF ("-[no]winkill\n"
- "\tAlt+F4 exits the X Server.\n");
+ ErrorF("-[no]winkill\n" "\tAlt+F4 exits the X Server.\n");
- ErrorF ("-xkblayout XKBLayout\n"
- "\tEquivalent to XKBLayout in XF86Config files.\n"
- "\tFor example: -xkblayout de\n");
+ ErrorF("-xkblayout XKBLayout\n"
+ "\tEquivalent to XKBLayout in XF86Config files.\n"
+ "\tFor example: -xkblayout de\n");
- ErrorF ("-xkbmodel XKBModel\n"
- "\tEquivalent to XKBModel in XF86Config files.\n");
+ ErrorF("-xkbmodel XKBModel\n"
+ "\tEquivalent to XKBModel in XF86Config files.\n");
- ErrorF ("-xkboptions XKBOptions\n"
- "\tEquivalent to XKBOptions in XF86Config files.\n");
+ ErrorF("-xkboptions XKBOptions\n"
+ "\tEquivalent to XKBOptions in XF86Config files.\n");
- ErrorF ("-xkbrules XKBRules\n"
- "\tEquivalent to XKBRules in XF86Config files.\n");
+ ErrorF("-xkbrules XKBRules\n"
+ "\tEquivalent to XKBRules in XF86Config files.\n");
- ErrorF ("-xkbvariant XKBVariant\n"
- "\tEquivalent to XKBVariant in XF86Config files.\n"
- "\tFor example: -xkbvariant nodeadkeys\n");
+ ErrorF("-xkbvariant XKBVariant\n"
+ "\tEquivalent to XKBVariant in XF86Config files.\n"
+ "\tFor example: -xkbvariant nodeadkeys\n");
}
/* See Porting Layer Definition - p. 57 */
void
ddxUseMsg(void)
{
- /* Set a flag so that FatalError won't give duplicate warning message */
- g_fSilentFatalError = TRUE;
-
- winUseMsg();
-
- /* Log file will not be opened for UseMsg unless we open it now */
- if (!g_fLogInited) {
- g_pszLogFile = LogInit (g_pszLogFile, NULL);
- g_fLogInited = TRUE;
- }
- LogClose (EXIT_NO_ERROR);
-
- /* Notify user where UseMsg text can be found.*/
- if (!g_fNoHelpMessageBox)
- winMessageBoxF ("The " PROJECT_NAME " help text has been printed to "
- "%s.\n"
- "Please open %s to read the help text.\n",
- MB_ICONINFORMATION, g_pszLogFile, g_pszLogFile);
+ /* Set a flag so that FatalError won't give duplicate warning message */
+ g_fSilentFatalError = TRUE;
+
+ winUseMsg();
+
+ /* Log file will not be opened for UseMsg unless we open it now */
+ if (!g_fLogInited) {
+ g_pszLogFile = LogInit(g_pszLogFile, NULL);
+ g_fLogInited = TRUE;
+ }
+ LogClose(EXIT_NO_ERROR);
+
+ /* Notify user where UseMsg text can be found. */
+ if (!g_fNoHelpMessageBox)
+ winMessageBoxF("The " PROJECT_NAME " help text has been printed to "
+ "%s.\n"
+ "Please open %s to read the help text.\n",
+ MB_ICONINFORMATION, g_pszLogFile, g_pszLogFile);
}
/* See Porting Layer Definition - p. 20 */
@@ -927,111 +891,104 @@ ddxUseMsg(void)
*/
void
-InitOutput (ScreenInfo *screenInfo, int argc, char *argv[])
+InitOutput(ScreenInfo * screenInfo, int argc, char *argv[])
{
- int i;
+ int i;
- /* Log the command line */
- winLogCommandLine (argc, argv);
+ /* Log the command line */
+ winLogCommandLine(argc, argv);
- winDebug ("InitOutput\n");
+ winDebug("InitOutput\n");
- /* Validate command-line arguments */
- if (serverGeneration == 1 && !winValidateArgs ())
- {
- FatalError ("InitOutput - Invalid command-line arguments found. "
- "Exiting.\n");
+ /* Validate command-line arguments */
+ if (serverGeneration == 1 && !winValidateArgs()) {
+ FatalError("InitOutput - Invalid command-line arguments found. "
+ "Exiting.\n");
}
- /* Check for duplicate invocation on same display number.*/
- if (serverGeneration == 1 && !winCheckDisplayNumber ())
- {
- if (g_fSilentDupError)
- g_fSilentFatalError = TRUE;
- FatalError ("InitOutput - Duplicate invocation on display "
- "number: %s. Exiting.\n", display);
+ /* Check for duplicate invocation on same display number. */
+ if (serverGeneration == 1 && !winCheckDisplayNumber()) {
+ if (g_fSilentDupError)
+ g_fSilentFatalError = TRUE;
+ FatalError("InitOutput - Duplicate invocation on display "
+ "number: %s. Exiting.\n", display);
}
#ifdef XWIN_XF86CONFIG
- /* Try to read the xorg.conf-style configuration file */
- if (!winReadConfigfile ())
- ErrorF ("InitOutput - Error reading config file\n");
+ /* Try to read the xorg.conf-style configuration file */
+ if (!winReadConfigfile())
+ ErrorF ("InitOutput - Error reading config file\n");
#else
- winConfigFiles ();
+ winConfigFiles();
#endif
- /* Load preferences from XWinrc file */
- LoadPreferences();
-
- /* Setup global screen info parameters */
- screenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
- screenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
- screenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
- screenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
- screenInfo->numPixmapFormats = NUMFORMATS;
-
- /* Describe how we want common pixmap formats padded */
- for (i = 0; i < NUMFORMATS; i++)
- {
- screenInfo->formats[i] = g_PixmapFormats[i];
+ /* Load preferences from XWinrc file */
+ LoadPreferences();
+
+ /* Setup global screen info parameters */
+ screenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
+ screenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
+ screenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
+ screenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
+ screenInfo->numPixmapFormats = NUMFORMATS;
+
+ /* Describe how we want common pixmap formats padded */
+ for (i = 0; i < NUMFORMATS; i++) {
+ screenInfo->formats[i] = g_PixmapFormats[i];
}
- /* Load pointers to DirectDraw functions */
- winGetDDProcAddresses ();
-
- /* Detect supported engines */
- winDetectSupportedEngines ();
+ /* Load pointers to DirectDraw functions */
+ winGetDDProcAddresses();
+
+ /* Detect supported engines */
+ winDetectSupportedEngines();
#ifdef XWIN_MULTIWINDOW
/* Load libraries for taskbar grouping */
winTaskbarInit ();
#endif
- /* Store the instance handle */
- g_hInstance = GetModuleHandle (NULL);
+ /* Store the instance handle */
+ g_hInstance = GetModuleHandle(NULL);
- /* Initialize each screen */
- for (i = 0; i < g_iNumScreens; ++i)
- {
- /* Initialize the screen */
- if (-1 == AddScreen (winScreenInit, argc, argv))
- {
- FatalError ("InitOutput - Couldn't add screen %d", i);
- }
+ /* Initialize each screen */
+ for (i = 0; i < g_iNumScreens; ++i) {
+ /* Initialize the screen */
+ if (-1 == AddScreen(winScreenInit, argc, argv)) {
+ FatalError("InitOutput - Couldn't add screen %d", i);
+ }
}
#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
- /* Generate a cookie used by internal clients for authorization */
- if (g_fXdmcpEnabled || g_fAuthEnabled)
- winGenerateAuthorization ();
-
- /* Perform some one time initialization */
- if (1 == serverGeneration)
- {
- /*
- * setlocale applies to all threads in the current process.
- * Apply locale specified in LANG environment variable.
- */
- if (!setlocale (LC_ALL, ""))
- {
- ErrorF ("setlocale failed.\n");
- }
+ /* Generate a cookie used by internal clients for authorization */
+ if (g_fXdmcpEnabled || g_fAuthEnabled)
+ winGenerateAuthorization();
+
+ /* Perform some one time initialization */
+ if (1 == serverGeneration) {
+ /*
+ * setlocale applies to all threads in the current process.
+ * Apply locale specified in LANG environment variable.
+ */
+ if (!setlocale (LC_ALL, ""))
+ {
+ ErrorF ("setlocale failed.\n");
+ }
- /* See if X supports the current locale */
- if (XSupportsLocale () == FALSE)
- {
- ErrorF ("Warning: Locale not supported by X, falling back to 'C' locale.\n");
- setlocale(LC_ALL, "C");
- }
+ /* See if X supports the current locale */
+ if (XSupportsLocale () == FALSE)
+ {
+ ErrorF ("Warning: Locale not supported by X, falling back to 'C' locale.\n");
+ setlocale(LC_ALL, "C");
+ }
}
#endif
- winDebug ("InitOutput - Returning.\n");
+ winDebug("InitOutput - Returning.\n");
}
-
/*
* winCheckDisplayNumber - Check if another instance of Cygwin/X is
* already running on the same display number. If no one exists,
@@ -1041,67 +998,60 @@ InitOutput (ScreenInfo *screenInfo, int argc, char *argv[])
*/
static Bool
-winCheckDisplayNumber (void)
+winCheckDisplayNumber(void)
{
- int nDisp;
- HANDLE mutex;
- char name[MAX_PATH];
- char * pszPrefix = '\0';
- OSVERSIONINFO osvi = {0};
-
- /* Check display range */
- nDisp = atoi (display);
- if (nDisp < 0 || nDisp > 59535)
- {
- ErrorF ("winCheckDisplayNumber - Bad display number: %d\n", nDisp);
- return FALSE;
+ int nDisp;
+ HANDLE mutex;
+ char name[MAX_PATH];
+ char *pszPrefix = '\0';
+ OSVERSIONINFO osvi = { 0 };
+
+ /* Check display range */
+ nDisp = atoi(display);
+ if (nDisp < 0 || nDisp > 59535) {
+ ErrorF("winCheckDisplayNumber - Bad display number: %d\n", nDisp);
+ return FALSE;
}
- /* Set first character of mutex name to null */
- name[0] = '\0';
+ /* Set first character of mutex name to null */
+ name[0] = '\0';
- /* Get operating system version information */
- osvi.dwOSVersionInfoSize = sizeof (osvi);
- GetVersionEx (&osvi);
+ /* Get operating system version information */
+ osvi.dwOSVersionInfoSize = sizeof(osvi);
+ GetVersionEx(&osvi);
- /* Want a mutex shared among all terminals on NT > 4.0 */
- if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT
- && osvi.dwMajorVersion >= 5)
- {
- pszPrefix = "Global\\";
+ /* Want a mutex shared among all terminals on NT > 4.0 */
+ if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT && osvi.dwMajorVersion >= 5) {
+ pszPrefix = "Global\\";
}
- /* Setup Cygwin/X specific part of name */
- snprintf (name, sizeof(name), "%sCYGWINX_DISPLAY:%d", pszPrefix, nDisp);
-
- /* Windows automatically releases the mutex when this process exits */
- mutex = CreateMutex (NULL, FALSE, name);
- if (!mutex)
- {
- LPVOID lpMsgBuf;
-
- /* Display a fancy error message */
- FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
- GetLastError (),
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPTSTR) &lpMsgBuf,
- 0, NULL);
- ErrorF ("winCheckDisplayNumber - CreateMutex failed: %s\n",
- (LPSTR)lpMsgBuf);
- LocalFree (lpMsgBuf);
-
- return FALSE;
+ /* Setup Cygwin/X specific part of name */
+ snprintf(name, sizeof(name), "%sCYGWINX_DISPLAY:%d", pszPrefix, nDisp);
+
+ /* Windows automatically releases the mutex when this process exits */
+ mutex = CreateMutex(NULL, FALSE, name);
+ if (!mutex) {
+ LPVOID lpMsgBuf;
+
+ /* Display a fancy error message */
+ FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ GetLastError(),
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPTSTR) & lpMsgBuf, 0, NULL);
+ ErrorF("winCheckDisplayNumber - CreateMutex failed: %s\n",
+ (LPSTR) lpMsgBuf);
+ LocalFree(lpMsgBuf);
+
+ return FALSE;
}
- if (GetLastError () == ERROR_ALREADY_EXISTS)
- {
- ErrorF ("winCheckDisplayNumber - "
- "VCXsrv, Xming or Cygwin/X is already running on display %d\n",
- nDisp);
- return FALSE;
+ if (GetLastError() == ERROR_ALREADY_EXISTS) {
+ ErrorF("winCheckDisplayNumber - "
+ "VCXsrv, Xming or Cygwin/X is already running on display %d\n", nDisp);
+ return FALSE;
}
- return TRUE;
+ return TRUE;
}
diff --git a/xorg-server/hw/xwin/glx/glwindows.h b/xorg-server/hw/xwin/glx/glwindows.h
index 72278df30..42adc5b60 100644
--- a/xorg-server/hw/xwin/glx/glwindows.h
+++ b/xorg-server/hw/xwin/glx/glwindows.h
@@ -28,25 +28,25 @@
* DEALINGS IN THE SOFTWARE.
*/
-
#include <GL/gl.h>
typedef struct {
- unsigned int enableDebug : 1;
- unsigned int enableTrace : 1;
- unsigned int dumpPFD : 1;
- unsigned int dumpHWND : 1;
- unsigned int dumpDC : 1;
- unsigned int enableGLcallTrace : 1;
- unsigned int enableWGLcallTrace :1;
+ unsigned int enableDebug:1;
+ unsigned int enableTrace:1;
+ unsigned int dumpPFD:1;
+ unsigned int dumpHWND:1;
+ unsigned int dumpDC:1;
+ unsigned int enableGLcallTrace:1;
+ unsigned int enableWGLcallTrace:1;
} glxWinDebugSettingsRec;
extern glxWinDebugSettingsRec glxWinDebugSettings;
void glWinCallDelta(void);
void glxWinPushNativeProvider(void);
-const GLubyte* glGetStringWrapperNonstatic(GLenum name);
-void glAddSwapHintRectWINWrapperNonstatic(GLint x, GLint y, GLsizei width, GLsizei height);
+const GLubyte *glGetStringWrapperNonstatic(GLenum name);
+void glAddSwapHintRectWINWrapperNonstatic(GLint x, GLint y, GLsizei width,
+ GLsizei height);
void glWinSetupDispatchTable(void);
#ifdef _DEBUG
diff --git a/xorg-server/hw/xwin/glx/glwrap.c b/xorg-server/hw/xwin/glx/glwrap.c
index fe59f71ef..21a42aa9c 100644
--- a/xorg-server/hw/xwin/glx/glwrap.c
+++ b/xorg-server/hw/xwin/glx/glwrap.c
@@ -53,55 +53,49 @@ static unsigned int glWinDirectProcCalls = 0;
void
glWinCallDelta(void)
{
- static unsigned int glWinIndirectProcCallsLast = 0;
- static unsigned int glWinDirectProcCallsLast = 0;
- if ((glWinIndirectProcCalls != glWinIndirectProcCallsLast) ||
- (glWinDirectProcCalls != glWinDirectProcCallsLast))
- {
- if (glxWinDebugSettings.enableTrace)
- {
- ErrorF("after %d direct and %d indirect GL calls\n",
- glWinDirectProcCalls - glWinDirectProcCallsLast,
- glWinIndirectProcCalls - glWinIndirectProcCallsLast);
+ static unsigned int glWinIndirectProcCallsLast = 0;
+ static unsigned int glWinDirectProcCallsLast = 0;
+
+ if ((glWinIndirectProcCalls != glWinIndirectProcCallsLast) ||
+ (glWinDirectProcCalls != glWinDirectProcCallsLast)) {
+ if (glxWinDebugSettings.enableTrace) {
+ ErrorF("after %d direct and %d indirect GL calls\n",
+ glWinDirectProcCalls - glWinDirectProcCallsLast,
+ glWinIndirectProcCalls - glWinIndirectProcCallsLast);
}
- glWinDirectProcCallsLast = glWinDirectProcCalls;
- glWinIndirectProcCallsLast = glWinIndirectProcCalls;
+ glWinDirectProcCallsLast = glWinDirectProcCalls;
+ glWinIndirectProcCallsLast = glWinIndirectProcCalls;
}
}
#endif
static PROC
-glWinResolveHelper(PROC *cache, char *symbol)
+glWinResolveHelper(PROC * cache, char *symbol)
{
- PROC proc = NULL;
-
- /* If not yet cached, call wglGetProcAddress */
- if ((*cache) == NULL)
- {
- proc = wglGetProcAddress(symbol);
- if (proc == NULL)
- {
- winDebug("glwrap: Can't resolve \"%s\"\n", symbol);
- (*cache) = (PROC)-1;
+ PROC proc = NULL;
+
+ /* If not yet cached, call wglGetProcAddress */
+ if ((*cache) == NULL) {
+ proc = wglGetProcAddress(symbol);
+ if (proc == NULL) {
+ winDebug("glwrap: Can't resolve \"%s\"\n", symbol);
+ (*cache) = (PROC) - 1;
}
- else
- {
- winDebug("glwrap: Resolved \"%s\"\n", symbol);
- (*cache) = proc;
+ else {
+ winDebug("glwrap: Resolved \"%s\"\n", symbol);
+ (*cache) = proc;
}
}
- /* Cached wglGetProcAddress failure */
- else if ((*cache) == (PROC)-1)
- {
- proc = 0;
+ /* Cached wglGetProcAddress failure */
+ else if ((*cache) == (PROC) - 1) {
+ proc = 0;
}
- /* Cached wglGetProcAddress result */
- else
- {
- proc = (*cache);
+ /* Cached wglGetProcAddress result */
+ else {
+ proc = (*cache);
}
- return proc;
+ return proc;
}
#ifdef _DEBUG
@@ -138,20 +132,24 @@ glWinResolveHelper(PROC *cache, char *symbol)
Special non-static wrapper for glGetString for debug output
*/
-const GLubyte* glGetStringWrapperNonstatic(GLenum name)
+const GLubyte *
+glGetStringWrapperNonstatic(GLenum name)
{
- return glGetString(name);
+ return glGetString(name);
}
/*
Special non-static wrapper for glAddSwapHintRectWIN for copySubBuffers
*/
-typedef void (__stdcall *PFNGLADDSWAPHINTRECTWIN)(GLint x, GLint y, GLsizei width, GLsizei height);
+typedef void (__stdcall * PFNGLADDSWAPHINTRECTWIN) (GLint x, GLint y,
+ GLsizei width,
+ GLsizei height);
-void glAddSwapHintRectWINWrapperNonstatic(GLint x, GLint y, GLsizei width, GLsizei height)
+void
+glAddSwapHintRectWINWrapperNonstatic(GLint x, GLint y, GLsizei width,
+ GLsizei height)
{
- RESOLVE(PFNGLADDSWAPHINTRECTWIN, "glAddSwapHintRectWIN");
- proc(x, y, width, height);
+ RESOLVE(PFNGLADDSWAPHINTRECTWIN, "glAddSwapHintRectWIN");
+ proc(x, y, width, height);
}
-
diff --git a/xorg-server/hw/xwin/glx/indirect.c b/xorg-server/hw/xwin/glx/indirect.c
index b60f0c87c..1a4916aaa 100644
--- a/xorg-server/hw/xwin/glx/indirect.c
+++ b/xorg-server/hw/xwin/glx/indirect.c
@@ -112,61 +112,58 @@ extern Bool g_fNativeGl;
* structure definitions
*/
-typedef struct __GLXWinContext __GLXWinContext;
+typedef struct __GLXWinContext __GLXWinContext;
typedef struct __GLXWinDrawable __GLXWinDrawable;
typedef struct __GLXWinScreen glxWinScreen;
typedef struct __GLXWinConfig GLXWinConfig;
struct __GLXWinContext {
- __GLXcontext base;
- HGLRC ctx; /* Windows GL Context */
+ __GLXcontext base;
+ HGLRC ctx; /* Windows GL Context */
HDC hDC; /* Windows device context */
HDC hreadDC; /* Windows device read context */
- __GLXWinContext *shareContext; /* Context with which we will share display lists and textures */
- HWND hwnd; /* For detecting when HWND has changed */
+ __GLXWinContext *shareContext; /* Context with which we will share display lists and textures */
+ HWND hwnd; /* For detecting when HWND has changed */
HWND hreadwnd;
struct _glapi_table *Dispatch;
};
-struct __GLXWinDrawable
-{
- __GLXdrawable base;
- __GLXWinContext *drawContext;
+struct __GLXWinDrawable {
+ __GLXdrawable base;
+ __GLXWinContext *drawContext;
- /* If this drawable is GLX_DRAWABLE_PBUFFER */
- HPBUFFERARB hPbuffer;
+ /* If this drawable is GLX_DRAWABLE_PBUFFER */
+ HPBUFFERARB hPbuffer;
- /* If this drawable is GLX_DRAWABLE_PIXMAP */
- HDC dibDC;
- HBITMAP hDIB;
- HBITMAP hOldDIB; /* original DIB for DC */
- void *pOldBits; /* original pBits for this drawable's pixmap */
+ /* If this drawable is GLX_DRAWABLE_PIXMAP */
+ HDC dibDC;
+ HBITMAP hDIB;
+ HBITMAP hOldDIB; /* original DIB for DC */
+ void *pOldBits; /* original pBits for this drawable's pixmap */
};
-struct __GLXWinScreen
-{
- __GLXscreen base;
+struct __GLXWinScreen {
+ __GLXscreen base;
- /* Supported GLX extensions */
- unsigned char glx_enable_bits[__GLX_EXT_BYTES];
+ /* Supported GLX extensions */
+ unsigned char glx_enable_bits[__GLX_EXT_BYTES];
- Bool has_WGL_ARB_multisample;
- Bool has_WGL_ARB_pixel_format;
- Bool has_WGL_ARB_pbuffer;
- Bool has_WGL_ARB_render_texture;
+ Bool has_WGL_ARB_multisample;
+ Bool has_WGL_ARB_pixel_format;
+ Bool has_WGL_ARB_pbuffer;
+ Bool has_WGL_ARB_render_texture;
- /* wrapped screen functions */
- RealizeWindowProcPtr RealizeWindow;
- UnrealizeWindowProcPtr UnrealizeWindow;
+ /* wrapped screen functions */
+ RealizeWindowProcPtr RealizeWindow;
+ UnrealizeWindowProcPtr UnrealizeWindow;
DestroyWindowProcPtr DestroyWindow;
- CopyWindowProcPtr CopyWindow;
+ CopyWindowProcPtr CopyWindow;
PositionWindowProcPtr PositionWindow;
};
-struct __GLXWinConfig
-{
- __GLXconfig base;
- int pixelFormatIndex;
+struct __GLXWinConfig {
+ __GLXconfig base;
+ int pixelFormatIndex;
};
/* ---------------------------------------------------------------------- */
@@ -203,9 +200,10 @@ void GLWIN_HDC_DEBUG_MSG(const char *Message, HDC hDc, HWND hwnd)
}
-glxWinDebugSettingsRec glxWinDebugSettings = { 0, 0, 0, 0, 0, 0};
+glxWinDebugSettingsRec glxWinDebugSettings = { 0, 0, 0, 0, 0, 0 };
-static void glxWinInitDebugSettings(void)
+static void
+glxWinInitDebugSettings(void)
{
char *envptr;
@@ -238,8 +236,7 @@ static void glxWinInitDebugSettings(void)
glxWinDebugSettings.enableWGLcallTrace = (atoi(envptr) == 1);
envptr = getenv("GLWIN_DEBUG_ALL");
- if (envptr != NULL)
- {
+ if (envptr != NULL) {
glxWinDebugSettings.enableDebug = 1;
glxWinDebugSettings.enableTrace = 1;
glxWinDebugSettings.dumpPFD = 1;
@@ -247,37 +244,34 @@ static void glxWinInitDebugSettings(void)
glxWinDebugSettings.dumpDC = 1;
glxWinDebugSettings.enableGLcallTrace = 1;
glxWinDebugSettings.enableWGLcallTrace = 1;
- }
+ }
}
#endif
static
-const char *glxWinErrorMessage(void)
+const char *
+glxWinErrorMessage(void)
{
- static char errorbuffer[1024];
- unsigned int last_error = GetLastError();
-
- if (!FormatMessage(
- FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK,
- NULL,
- last_error,
- 0,
- (LPTSTR) &errorbuffer,
- sizeof(errorbuffer),
- NULL ))
- {
- snprintf(errorbuffer, sizeof(errorbuffer), "Unknown error");
+ static char errorbuffer[1024];
+ unsigned int last_error = GetLastError();
+
+ if (!FormatMessage
+ (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS |
+ FORMAT_MESSAGE_MAX_WIDTH_MASK, NULL, last_error, 0,
+ (LPTSTR) & errorbuffer, sizeof(errorbuffer), NULL)) {
+ snprintf(errorbuffer, sizeof(errorbuffer), "Unknown error");
}
- if ((errorbuffer[strlen(errorbuffer)-1] == '\n') || (errorbuffer[strlen(errorbuffer)-1] == '\r'))
- errorbuffer[strlen(errorbuffer)-1] = 0;
+ if ((errorbuffer[strlen(errorbuffer) - 1] == '\n') ||
+ (errorbuffer[strlen(errorbuffer) - 1] == '\r'))
+ errorbuffer[strlen(errorbuffer) - 1] = 0;
- sprintf(errorbuffer + strlen(errorbuffer), " (%08x)", last_error);
+ sprintf(errorbuffer + strlen(errorbuffer), " (%08x)", last_error);
- return errorbuffer;
+ return errorbuffer;
}
-static void pfdOut(const PIXELFORMATDESCRIPTOR *pfd);
+static void pfdOut(const PIXELFORMATDESCRIPTOR * pfd);
#ifdef _DEBUG
@@ -287,36 +281,39 @@ static void pfdOut(const PIXELFORMATDESCRIPTOR *pfd);
pipesym = " | "; \
}
-static void pfdOut(const PIXELFORMATDESCRIPTOR *pfd)
+static void
+pfdOut(const PIXELFORMATDESCRIPTOR * pfd)
{
- const char *pipesym = ""; /* will be set after first flag dump */
+ const char *pipesym = ""; /* will be set after first flag dump */
+
ErrorF("PIXELFORMATDESCRIPTOR:\n");
ErrorF("nSize = %u\n", pfd->nSize);
ErrorF("nVersion = %u\n", pfd->nVersion);
ErrorF("dwFlags = %lu = {", pfd->dwFlags);
- DUMP_PFD_FLAG(PFD_DOUBLEBUFFER);
- DUMP_PFD_FLAG(PFD_STEREO);
- DUMP_PFD_FLAG(PFD_DRAW_TO_WINDOW);
- DUMP_PFD_FLAG(PFD_DRAW_TO_BITMAP);
- DUMP_PFD_FLAG(PFD_SUPPORT_GDI);
- DUMP_PFD_FLAG(PFD_SUPPORT_OPENGL);
- DUMP_PFD_FLAG(PFD_GENERIC_FORMAT);
- DUMP_PFD_FLAG(PFD_NEED_PALETTE);
- DUMP_PFD_FLAG(PFD_NEED_SYSTEM_PALETTE);
- DUMP_PFD_FLAG(PFD_SWAP_EXCHANGE);
- DUMP_PFD_FLAG(PFD_SWAP_COPY);
- DUMP_PFD_FLAG(PFD_SWAP_LAYER_BUFFERS);
- DUMP_PFD_FLAG(PFD_GENERIC_ACCELERATED);
- DUMP_PFD_FLAG(PFD_SUPPORT_DIRECTDRAW);
- DUMP_PFD_FLAG(PFD_DIRECT3D_ACCELERATED);
- DUMP_PFD_FLAG(PFD_SUPPORT_COMPOSITION);
- DUMP_PFD_FLAG(PFD_DEPTH_DONTCARE);
- DUMP_PFD_FLAG(PFD_DOUBLEBUFFER_DONTCARE);
- DUMP_PFD_FLAG(PFD_STEREO_DONTCARE);
+ DUMP_PFD_FLAG(PFD_DOUBLEBUFFER);
+ DUMP_PFD_FLAG(PFD_STEREO);
+ DUMP_PFD_FLAG(PFD_DRAW_TO_WINDOW);
+ DUMP_PFD_FLAG(PFD_DRAW_TO_BITMAP);
+ DUMP_PFD_FLAG(PFD_SUPPORT_GDI);
+ DUMP_PFD_FLAG(PFD_SUPPORT_OPENGL);
+ DUMP_PFD_FLAG(PFD_GENERIC_FORMAT);
+ DUMP_PFD_FLAG(PFD_NEED_PALETTE);
+ DUMP_PFD_FLAG(PFD_NEED_SYSTEM_PALETTE);
+ DUMP_PFD_FLAG(PFD_SWAP_EXCHANGE);
+ DUMP_PFD_FLAG(PFD_SWAP_COPY);
+ DUMP_PFD_FLAG(PFD_SWAP_LAYER_BUFFERS);
+ DUMP_PFD_FLAG(PFD_GENERIC_ACCELERATED);
+ DUMP_PFD_FLAG(PFD_SUPPORT_DIRECTDRAW);
+ DUMP_PFD_FLAG(PFD_DIRECT3D_ACCELERATED);
+ DUMP_PFD_FLAG(PFD_SUPPORT_COMPOSITION);
+ DUMP_PFD_FLAG(PFD_DEPTH_DONTCARE);
+ DUMP_PFD_FLAG(PFD_DOUBLEBUFFER_DONTCARE);
+ DUMP_PFD_FLAG(PFD_STEREO_DONTCARE);
ErrorF("}\n");
ErrorF("iPixelType = %hu = %s\n", pfd->iPixelType,
- (pfd->iPixelType == PFD_TYPE_RGBA ? "PFD_TYPE_RGBA" : "PFD_TYPE_COLORINDEX"));
+ (pfd->iPixelType ==
+ PFD_TYPE_RGBA ? "PFD_TYPE_RGBA" : "PFD_TYPE_COLORINDEX"));
ErrorF("cColorBits = %hhu\n", pfd->cColorBits);
ErrorF("cRedBits = %hhu\n", pfd->cRedBits);
ErrorF("cRedShift = %hhu\n", pfd->cRedShift);
@@ -345,87 +342,88 @@ static void pfdOut(const PIXELFORMATDESCRIPTOR *pfd)
static const char *
visual_class_name(int cls)
{
- switch (cls) {
- case GLX_STATIC_COLOR:
- return "StaticColor";
- case GLX_PSEUDO_COLOR:
- return "PseudoColor";
- case GLX_STATIC_GRAY:
- return "StaticGray";
- case GLX_GRAY_SCALE:
- return "GrayScale";
- case GLX_TRUE_COLOR:
- return "TrueColor";
- case GLX_DIRECT_COLOR:
- return "DirectColor";
- default:
- return "-none-";
- }
+ switch (cls) {
+ case GLX_STATIC_COLOR:
+ return "StaticColor";
+ case GLX_PSEUDO_COLOR:
+ return "PseudoColor";
+ case GLX_STATIC_GRAY:
+ return "StaticGray";
+ case GLX_GRAY_SCALE:
+ return "GrayScale";
+ case GLX_TRUE_COLOR:
+ return "TrueColor";
+ case GLX_DIRECT_COLOR:
+ return "DirectColor";
+ default:
+ return "-none-";
+ }
}
static const char *
swap_method_name(int mthd)
{
- switch (mthd)
- {
+ switch (mthd) {
case GLX_SWAP_EXCHANGE_OML:
- return "xchg";
+ return "xchg";
case GLX_SWAP_COPY_OML:
- return "copy";
+ return "copy";
case GLX_SWAP_UNDEFINED_OML:
- return " ";
+ return " ";
default:
- return "????";
+ return "????";
}
}
static void
-fbConfigsDump(unsigned int n, __GLXconfig *c)
+fbConfigsDump(unsigned int n, __GLXconfig * c)
{
- ErrorF("%d fbConfigs\n", n);
- ErrorF("pxf vis fb render Ste aux accum MS drawable Group/\n");
- ErrorF("idx ID ID VisualType Depth Lvl RGB CI DB Swap reo R G B A Z S buf AR AG AB AA bufs num W P Pb Float Trans Caveat\n");
- ErrorF("-----------------------------------------------------------------------------------------------------------------------------\n");
-
- while (c != NULL)
- {
- unsigned int i = ((GLXWinConfig *)c)->pixelFormatIndex;
-
- ErrorF("%3d %3x %3x "
- "%-11s"
- " %3d %3d %s %s %s %s %s "
- "%2d %2d %2d %2d "
- "%2d %2d "
- "%2d "
- "%2d %2d %2d %2d"
- " %2d %2d"
- " %s %s %s "
- " %s "
- " %s "
- " %d %s"
- "\n",
- i, c->visualID, c->fbconfigID,
- visual_class_name(c->visualType),
- c->rgbBits ? c->rgbBits : c->indexBits,
- c->level,
- (c->renderType & GLX_RGBA_BIT) ? "y" : ".",
- (c->renderType & GLX_COLOR_INDEX_BIT) ? "y" : ".",
- c->doubleBufferMode ? "y" : ".",
- swap_method_name(c->swapMethod),
- c->stereoMode ? "y" : ".",
- c->redBits, c->greenBits, c->blueBits, c->alphaBits,
- c->depthBits, c->stencilBits,
- c->numAuxBuffers,
- c->accumRedBits, c->accumGreenBits, c->accumBlueBits, c->accumAlphaBits,
- c->sampleBuffers, c->samples,
- (c->drawableType & GLX_WINDOW_BIT) ? "y" : ".",
- (c->drawableType & GLX_PIXMAP_BIT) ? "y" : ".",
- (c->drawableType & GLX_PBUFFER_BIT) ? "y" : ".",
- ".",
- (c->transparentPixel != GLX_NONE_EXT) ? "y" : ".",
- c->visualSelectGroup, (c->visualRating == GLX_SLOW_VISUAL_EXT) ? "*" : " ");
-
- c = c->next;
+ ErrorF("%d fbConfigs\n", n);
+ ErrorF
+ ("pxf vis fb render Ste aux accum MS drawable Group/\n");
+ ErrorF
+ ("idx ID ID VisualType Depth Lvl RGB CI DB Swap reo R G B A Z S buf AR AG AB AA bufs num W P Pb Float Trans Caveat\n");
+ ErrorF
+ ("-----------------------------------------------------------------------------------------------------------------------------\n");
+
+ while (c != NULL) {
+ unsigned int i = ((GLXWinConfig *) c)->pixelFormatIndex;
+
+ ErrorF("%3d %3x %3x "
+ "%-11s"
+ " %3d %3d %s %s %s %s %s "
+ "%2d %2d %2d %2d "
+ "%2d %2d "
+ "%2d "
+ "%2d %2d %2d %2d"
+ " %2d %2d"
+ " %s %s %s "
+ " %s "
+ " %s "
+ " %d %s"
+ "\n",
+ i, c->visualID, c->fbconfigID,
+ visual_class_name(c->visualType),
+ c->rgbBits ? c->rgbBits : c->indexBits,
+ c->level,
+ (c->renderType & GLX_RGBA_BIT) ? "y" : ".",
+ (c->renderType & GLX_COLOR_INDEX_BIT) ? "y" : ".",
+ c->doubleBufferMode ? "y" : ".",
+ swap_method_name(c->swapMethod),
+ c->stereoMode ? "y" : ".",
+ c->redBits, c->greenBits, c->blueBits, c->alphaBits,
+ c->depthBits, c->stencilBits,
+ c->numAuxBuffers,
+ c->accumRedBits, c->accumGreenBits, c->accumBlueBits,
+ c->accumAlphaBits, c->sampleBuffers, c->samples,
+ (c->drawableType & GLX_WINDOW_BIT) ? "y" : ".",
+ (c->drawableType & GLX_PIXMAP_BIT) ? "y" : ".",
+ (c->drawableType & GLX_PBUFFER_BIT) ? "y" : ".", ".",
+ (c->transparentPixel != GLX_NONE_EXT) ? "y" : ".",
+ c->visualSelectGroup,
+ (c->visualRating == GLX_SLOW_VISUAL_EXT) ? "*" : " ");
+
+ c = c->next;
}
}
#endif
@@ -436,30 +434,35 @@ fbConfigsDump(unsigned int n, __GLXconfig *c)
*/
static __GLXscreen *glxWinScreenProbe(ScreenPtr pScreen);
-static __GLXcontext *glxWinCreateContext(__GLXscreen *screen,
- __GLXconfig *modes,
- __GLXcontext *baseShareContext);
+static __GLXcontext *glxWinCreateContext(__GLXscreen * screen,
+ __GLXconfig * modes,
+ __GLXcontext * baseShareContext);
static __GLXdrawable *glxWinCreateDrawable(ClientPtr client,
- __GLXscreen *screen,
- DrawablePtr pDraw,
- XID drawId,
- int type,
- XID glxDrawId,
- __GLXconfig *conf);
+ __GLXscreen * screen,
+ DrawablePtr pDraw,
+ XID drawId,
+ int type,
+ XID glxDrawId, __GLXconfig * conf);
static Bool glxWinRealizeWindow(WindowPtr pWin);
static Bool glxWinUnrealizeWindow(WindowPtr pWin);
static Bool glxWinDestroyWindow(WindowPtr pWin);
-static void glxWinCopyWindow(WindowPtr pWindow, DDXPointRec ptOldOrg, RegionPtr prgnSrc);
+static void glxWinCopyWindow(WindowPtr pWindow, DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc);
static Bool glxWinPositionWindow(WindowPtr pWindow, int x, int y);
-static HDC glxWinMakeDC(__GLXWinContext *gc, __GLXWinDrawable *draw, HWND *hwnd);
-static void glxWinReleaseDC(HWND hwnd, HDC hdc, __GLXWinDrawable *draw);
+static HDC glxWinMakeDC(__GLXWinContext * gc, __GLXWinDrawable * draw,
+ HWND * hwnd);
+static void glxWinReleaseDC(HWND hwnd, HDC hdc, __GLXWinDrawable * draw);
-static void glxWinCreateConfigs(HDC dc, glxWinScreen *screen);
-static void glxWinCreateConfigsExt(HDC hdc, glxWinScreen *screen);
-static int fbConfigToPixelFormat(__GLXconfig *mode, PIXELFORMATDESCRIPTOR *pfdret, int drawableTypeOverride);
-static int fbConfigToPixelFormatIndex(HDC hdc, __GLXconfig *mode, int drawableTypeOverride, glxWinScreen *winScreen);
+static void glxWinCreateConfigs(HDC dc, glxWinScreen * screen);
+static void glxWinCreateConfigsExt(HDC hdc, glxWinScreen * screen);
+static int fbConfigToPixelFormat(__GLXconfig * mode,
+ PIXELFORMATDESCRIPTOR * pfdret,
+ int drawableTypeOverride);
+static int fbConfigToPixelFormatIndex(HDC hdc, __GLXconfig * mode,
+ int drawableTypeOverride,
+ glxWinScreen * winScreen);
/* ---------------------------------------------------------------------- */
/*
@@ -485,7 +488,7 @@ glxWinPushNativeProvider(void)
*/
static void
-glxWinScreenDestroy(__GLXscreen *screen)
+glxWinScreenDestroy(__GLXscreen * screen)
{
GLWIN_DEBUG_MSG("glxWinScreenDestroy(%p)", screen);
__glXScreenDestroy(screen);
@@ -493,14 +496,15 @@ glxWinScreenDestroy(__GLXscreen *screen)
}
static int
-glxWinScreenSwapInterval(__GLXdrawable *drawable, int interval)
+glxWinScreenSwapInterval(__GLXdrawable * drawable, int interval)
{
- BOOL ret = wglSwapIntervalEXTWrapper(interval);
- if (!ret)
- {
- ErrorF("wglSwapIntervalEXT interval %d failed:%s\n", interval, glxWinErrorMessage());
+ BOOL ret = wglSwapIntervalEXTWrapper(interval);
+
+ if (!ret) {
+ ErrorF("wglSwapIntervalEXT interval %d failed:%s\n", interval,
+ glxWinErrorMessage());
}
- return ret;
+ return ret;
}
static LRESULT CALLBACK GlxWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
@@ -519,51 +523,48 @@ static LRESULT CALLBACK GlxWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARA
static void
glxLogExtensions(const char *prefix, const char *extensions)
{
- int length = 0;
- char *strl;
- char *str = strdup(extensions);
+ int length = 0;
+ char *strl;
+ char *str = strdup(extensions);
- if (str == NULL)
- {
- ErrorF("glxLogExtensions: xalloc error\n");
- return;
+ if (str == NULL) {
+ ErrorF("glxLogExtensions: xalloc error\n");
+ return;
}
- strl = strtok(str, " ");
- if (!strl)
- {
- winDebug("%s", prefix);
- }
- else
- {
- winDebug("%s%s", prefix, strl);
- length = strlen(prefix) + strlen(strl);
- }
-
- while (1)
+ strl = strtok(str, " ");
+ if (!strl)
{
- strl = strtok(NULL, " ");
- if (strl == NULL) break;
+ winDebug("%s", prefix);
+ }
+ else
+ {
+ winDebug("%s%s", prefix, strl);
+ length = strlen(prefix) + strlen(strl);
+ }
- if (length + strlen(strl) + 1 > 120)
- {
- winDebug("\n");
- winDebug("%s",prefix);
- length = strlen(prefix);
+ while (1) {
+ strl = strtok(NULL, " ");
+ if (strl == NULL)
+ break;
+
+ if (length + strlen(strl) + 1 > 120) {
+ winDebug("\n");
+ winDebug("%s", prefix);
+ length = strlen(prefix);
}
- else
- {
- winDebug(" ");
- length++;
+ else {
+ winDebug(" ");
+ length++;
}
- winDebug("%s", strl);
- length = length + strlen(strl);
+ winDebug("%s", strl);
+ length = length + strlen(strl);
}
- winDebug("\n");
+ winDebug("\n");
- free(str);
+ free(str);
}
/* This is called by GlxExtensionInit() asking the GLX provider if it can handle the screen... */
@@ -584,18 +585,18 @@ glxWinScreenProbe(ScreenPtr pScreen)
#endif
if (pScreen == NULL)
- return NULL;
+ return NULL;
- if (!winCheckScreenAiglxIsSupported(pScreen))
- {
- LogMessage(X_ERROR,"AIGLX: No native OpenGL in modes with a root window\n");
+ if (!winCheckScreenAiglxIsSupported(pScreen)) {
+ LogMessage(X_ERROR,
+ "AIGLX: No native OpenGL in modes with a root window\n");
return NULL;
- }
+ }
screen = calloc(1, sizeof(glxWinScreen));
if (NULL == screen)
- return NULL;
+ return NULL;
/* Wrap RealizeWindow, UnrealizeWindow and CopyWindow on this screen */
screen->RealizeWindow = pScreen->RealizeWindow;
@@ -613,34 +614,36 @@ glxWinScreenProbe(ScreenPtr pScreen)
// create window class
{
- static wATOM glTestWndClass = 0;
- if (glTestWndClass == 0)
- {
- WNDCLASSEX wc;
- glTestWndClass=1;
- wc.cbSize = sizeof(WNDCLASSEX);
- wc.style = CS_OWNDC ;
- wc.lpfnWndProc = GlxWindowProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = g_hInstance;
- wc.hIcon = 0;
- wc.hCursor = 0;
- wc.hbrBackground = 0;
- wc.lpszMenuName = NULL;
- wc.lpszClassName = WIN_GL_WINDOW_CLASS;
- wc.hIconSm = 0;
- RegisterClassEx (&wc);
- }
+ static wATOM glTestWndClass = 0;
+
+ if (glTestWndClass == 0) {
+ WNDCLASSEX wc;
+ glTestWndClass=1;
+ wc.cbSize = sizeof(WNDCLASSEX);
+ wc.style = CS_OWNDC ;
+ wc.lpfnWndProc = GlxWindowProc;
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 0;
+ wc.hInstance = g_hInstance;
+ wc.hIcon = 0;
+ wc.hCursor = 0;
+ wc.hbrBackground = 0;
+ wc.lpszMenuName = NULL;
+ wc.lpszClassName = WIN_GL_WINDOW_CLASS;
+ wc.hIconSm = 0;
+ RegisterClassEx(&wc);
+ }
}
// create an invisible window for a scratch DC
hwnd = CreateWindowExA(0,
WIN_GL_WINDOW_CLASS,
"XWin GL Renderer Capabilities Test Window",
- 0, 0, 0, 0, 0, NULL, NULL, GetModuleHandle(NULL), NULL);
+ 0, 0, 0, 0, 0, NULL, NULL, GetModuleHandle(NULL),
+ NULL);
if (hwnd == NULL)
- LogMessage(X_ERROR,"AIGLX: Couldn't create a window for render capabilities testing\n");
+ LogMessage(X_ERROR,
+ "AIGLX: Couldn't create a window for render capabilities testing\n");
hdc = GetDC(hwnd);
@@ -660,10 +663,11 @@ glxWinScreenProbe(ScreenPtr pScreen)
winDebug("GL_VERSION: %s\n", glGetStringWrapperNonstatic(GL_VERSION));
winDebug("GL_VENDOR: %s\n", glGetStringWrapperNonstatic(GL_VENDOR));
winDebug("GL_RENDERER: %s\n", glGetStringWrapperNonstatic(GL_RENDERER));
- gl_extensions = (const char *)glGetStringWrapperNonstatic(GL_EXTENSIONS);
+ gl_extensions = (const char *) glGetStringWrapperNonstatic(GL_EXTENSIONS);
glxLogExtensions("GL_EXTENSIONS: ", gl_extensions);
wgl_extensions = wglGetExtensionsStringARBWrapper(hdc);
- if (!wgl_extensions) wgl_extensions = "";
+ if (!wgl_extensions)
+ wgl_extensions = "";
glxLogExtensions("WGL_EXTENSIONS: ", wgl_extensions);
// Can you see the problem here? The extensions string is DC specific
@@ -672,48 +676,50 @@ glxWinScreenProbe(ScreenPtr pScreen)
// those screens to be accelerated in XP and earlier...
{
- // testing facility to not use any WGL extensions
- char *envptr = getenv("GLWIN_NO_WGL_EXTENSIONS");
- if ((envptr != NULL) && (atoi(envptr) != 0))
- {
- ErrorF("GLWIN_NO_WGL_EXTENSIONS is set, ignoring WGL_EXTENSIONS\n");
- wgl_extensions = "";
+ // testing facility to not use any WGL extensions
+ char *envptr = getenv("GLWIN_NO_WGL_EXTENSIONS");
+
+ if ((envptr != NULL) && (atoi(envptr) != 0)) {
+ ErrorF("GLWIN_NO_WGL_EXTENSIONS is set, ignoring WGL_EXTENSIONS\n");
+ wgl_extensions = "";
}
}
{
- Bool glx_sgi_make_current_read = FALSE;
-
- //
- // Based on the WGL extensions available, enable various GLX extensions
- // XXX: make this table-driven ?
- //
- memset(screen->glx_enable_bits, 0, __GLX_EXT_BYTES);
-
- __glXEnableExtension(screen->glx_enable_bits, "GLX_EXT_visual_info");
- __glXEnableExtension(screen->glx_enable_bits, "GLX_EXT_visual_rating");
- __glXEnableExtension(screen->glx_enable_bits, "GLX_EXT_import_context");
- __glXEnableExtension(screen->glx_enable_bits, "GLX_OML_swap_method");
- __glXEnableExtension(screen->glx_enable_bits, "GLX_SGIX_fbconfig");
-
- if (strstr(wgl_extensions, "WGL_ARB_make_current_read"))
- {
- __glXEnableExtension(screen->glx_enable_bits, "GLX_SGI_make_current_read");
- LogMessage(X_INFO, "AIGLX: enabled GLX_SGI_make_current_read\n");
- glx_sgi_make_current_read = TRUE;
+ Bool glx_sgi_make_current_read = FALSE;
+
+ //
+ // Based on the WGL extensions available, enable various GLX extensions
+ // XXX: make this table-driven ?
+ //
+ memset(screen->glx_enable_bits, 0, __GLX_EXT_BYTES);
+
+ __glXEnableExtension(screen->glx_enable_bits, "GLX_EXT_visual_info");
+ __glXEnableExtension(screen->glx_enable_bits, "GLX_EXT_visual_rating");
+ __glXEnableExtension(screen->glx_enable_bits, "GLX_EXT_import_context");
+ __glXEnableExtension(screen->glx_enable_bits, "GLX_OML_swap_method");
+ __glXEnableExtension(screen->glx_enable_bits, "GLX_SGIX_fbconfig");
+
+ if (strstr(wgl_extensions, "WGL_ARB_make_current_read")) {
+ __glXEnableExtension(screen->glx_enable_bits,
+ "GLX_SGI_make_current_read");
+ LogMessage(X_INFO, "AIGLX: enabled GLX_SGI_make_current_read\n");
+ glx_sgi_make_current_read = TRUE;
}
- if (strstr(gl_extensions, "GL_WIN_swap_hint"))
- {
- __glXEnableExtension(screen->glx_enable_bits, "GLX_MESA_copy_sub_buffer");
- LogMessage(X_INFO, "AIGLX: enabled GLX_MESA_copy_sub_buffer\n");
+ if (strstr(gl_extensions, "GL_WIN_swap_hint")) {
+ __glXEnableExtension(screen->glx_enable_bits,
+ "GLX_MESA_copy_sub_buffer");
+ LogMessage(X_INFO, "AIGLX: enabled GLX_MESA_copy_sub_buffer\n");
}
- if (strstr(wgl_extensions, "WGL_EXT_swap_control"))
- {
- __glXEnableExtension(screen->glx_enable_bits, "GLX_SGI_swap_control");
- __glXEnableExtension(screen->glx_enable_bits, "GLX_MESA_swap_control");
- LogMessage(X_INFO, "AIGLX: enabled GLX_SGI_swap_control and GLX_MESA_swap_control\n");
+ if (strstr(wgl_extensions, "WGL_EXT_swap_control")) {
+ __glXEnableExtension(screen->glx_enable_bits,
+ "GLX_SGI_swap_control");
+ __glXEnableExtension(screen->glx_enable_bits,
+ "GLX_MESA_swap_control");
+ LogMessage(X_INFO,
+ "AIGLX: enabled GLX_SGI_swap_control and GLX_MESA_swap_control\n");
}
/* // Hmm? screen->texOffset */
@@ -724,107 +730,104 @@ glxWinScreenProbe(ScreenPtr pScreen)
/* screen->has_WGL_ARB_render_texture = TRUE; */
/* } */
- if (strstr(wgl_extensions, "WGL_ARB_pbuffer"))
- {
- __glXEnableExtension(screen->glx_enable_bits, "GLX_SGIX_pbuffer");
- LogMessage(X_INFO, "AIGLX: enabled GLX_SGIX_pbuffer\n");
- screen->has_WGL_ARB_pbuffer = TRUE;
+ if (strstr(wgl_extensions, "WGL_ARB_pbuffer")) {
+ __glXEnableExtension(screen->glx_enable_bits, "GLX_SGIX_pbuffer");
+ LogMessage(X_INFO, "AIGLX: enabled GLX_SGIX_pbuffer\n");
+ screen->has_WGL_ARB_pbuffer = TRUE;
}
- if (strstr(wgl_extensions, "WGL_ARB_multisample"))
- {
- __glXEnableExtension(screen->glx_enable_bits, "GLX_ARB_multisample");
- __glXEnableExtension(screen->glx_enable_bits, "GLX_SGIS_multisample");
- LogMessage(X_INFO, "AIGLX: enabled GLX_ARB_multisample and GLX_SGIS_multisample\n");
- screen->has_WGL_ARB_multisample = TRUE;
+ if (strstr(wgl_extensions, "WGL_ARB_multisample")) {
+ __glXEnableExtension(screen->glx_enable_bits,
+ "GLX_ARB_multisample");
+ __glXEnableExtension(screen->glx_enable_bits,
+ "GLX_SGIS_multisample");
+ LogMessage(X_INFO,
+ "AIGLX: enabled GLX_ARB_multisample and GLX_SGIS_multisample\n");
+ screen->has_WGL_ARB_multisample = TRUE;
}
- screen->base.destroy = glxWinScreenDestroy;
- screen->base.createContext = glxWinCreateContext;
- screen->base.createDrawable = glxWinCreateDrawable;
- screen->base.swapInterval = glxWinScreenSwapInterval;
- screen->base.pScreen = pScreen;
-
- // Creating the fbConfigs initializes screen->base.fbconfigs and screen->base.numFBConfigs
- if (strstr(wgl_extensions, "WGL_ARB_pixel_format"))
- {
- glxWinCreateConfigsExt(hdc, screen);
-
- /*
- Some graphics drivers appear to advertise WGL_ARB_pixel_format,
- but it doesn't work usefully, so we have to be prepared for it
- to fail and fall back to using DescribePixelFormat()
- */
- if (screen->base.numFBConfigs > 0)
- {
- screen->has_WGL_ARB_pixel_format = TRUE;
+ screen->base.destroy = glxWinScreenDestroy;
+ screen->base.createContext = glxWinCreateContext;
+ screen->base.createDrawable = glxWinCreateDrawable;
+ screen->base.swapInterval = glxWinScreenSwapInterval;
+ screen->base.pScreen = pScreen;
+
+ // Creating the fbConfigs initializes screen->base.fbconfigs and screen->base.numFBConfigs
+ if (strstr(wgl_extensions, "WGL_ARB_pixel_format")) {
+ glxWinCreateConfigsExt(hdc, screen);
+
+ /*
+ Some graphics drivers appear to advertise WGL_ARB_pixel_format,
+ but it doesn't work usefully, so we have to be prepared for it
+ to fail and fall back to using DescribePixelFormat()
+ */
+ if (screen->base.numFBConfigs > 0) {
+ screen->has_WGL_ARB_pixel_format = TRUE;
}
}
- if (screen->base.numFBConfigs <= 0)
- {
- glxWinCreateConfigs(hdc, screen);
- screen->has_WGL_ARB_pixel_format = FALSE;
+ if (screen->base.numFBConfigs <= 0) {
+ glxWinCreateConfigs(hdc, screen);
+ screen->has_WGL_ARB_pixel_format = FALSE;
}
- /*
- If we still didn't get any fbConfigs, we can't provide GLX for this screen
- */
- if (screen->base.numFBConfigs <= 0)
- {
- free(screen);
- LogMessage(X_ERROR,"AIGLX: No fbConfigs could be made from native OpenGL pixel formats\n");
- return NULL;
+ /*
+ If we still didn't get any fbConfigs, we can't provide GLX for this screen
+ */
+ if (screen->base.numFBConfigs <= 0) {
+ free(screen);
+ LogMessage(X_ERROR,
+ "AIGLX: No fbConfigs could be made from native OpenGL pixel formats\n");
+ return NULL;
}
- /* These will be set by __glXScreenInit */
- screen->base.visuals = NULL;
- screen->base.numVisuals = 0;
+ /* These will be set by __glXScreenInit */
+ screen->base.visuals = NULL;
+ screen->base.numVisuals = 0;
- __glXScreenInit(&screen->base, pScreen);
+ __glXScreenInit(&screen->base, pScreen);
#ifdef _DEBUG
- // dump out fbConfigs now fbConfigIds and visualIDs have been assigned
- fbConfigsDump(screen->base.numFBConfigs, screen->base.fbconfigs);
+ // dump out fbConfigs now fbConfigIds and visualIDs have been assigned
+ fbConfigsDump(screen->base.numFBConfigs, screen->base.fbconfigs);
#endif
- // Override the GL extensions string set by __glXScreenInit()
- screen->base.GLextensions = strdup(gl_extensions);
-
- // Generate the GLX extensions string (overrides that set by __glXScreenInit())
- {
- unsigned int buffer_size = __glXGetExtensionString(screen->glx_enable_bits, NULL);
- if (buffer_size > 0)
- {
- free(screen->base.GLXextensions);
-
- screen->base.GLXextensions = xnfalloc(buffer_size);
- __glXGetExtensionString(screen->glx_enable_bits, screen->base.GLXextensions);
- }
- }
+ // Override the GL extensions string set by __glXScreenInit()
+ screen->base.GLextensions = strdup(gl_extensions);
- //
- // Override the GLX version (__glXScreenInit() sets it to "1.2")
- // if we have all the needed extensions to operate as a higher version
- //
- // SGIX_fbconfig && SGIX_pbuffer && SGI_make_current_read -> 1.3
- // ARB_multisample -> 1.4
- //
- if (screen->has_WGL_ARB_pbuffer && glx_sgi_make_current_read)
+ // Generate the GLX extensions string (overrides that set by __glXScreenInit())
{
- if (screen->has_WGL_ARB_multisample)
- {
- screen->base.GLXmajor = 1;
- screen->base.GLXminor = 4;
+ unsigned int buffer_size =
+ __glXGetExtensionString(screen->glx_enable_bits, NULL);
+ if (buffer_size > 0) {
+ free(screen->base.GLXextensions);
+
+ screen->base.GLXextensions = xnfalloc(buffer_size);
+ __glXGetExtensionString(screen->glx_enable_bits,
+ screen->base.GLXextensions);
}
- else
- {
- screen->base.GLXmajor = 1;
- screen->base.GLXminor = 3;
+ }
+
+ //
+ // Override the GLX version (__glXScreenInit() sets it to "1.2")
+ // if we have all the needed extensions to operate as a higher version
+ //
+ // SGIX_fbconfig && SGIX_pbuffer && SGI_make_current_read -> 1.3
+ // ARB_multisample -> 1.4
+ //
+ if (screen->has_WGL_ARB_pbuffer && glx_sgi_make_current_read) {
+ if (screen->has_WGL_ARB_multisample) {
+ screen->base.GLXmajor = 1;
+ screen->base.GLXminor = 4;
+ }
+ else {
+ screen->base.GLXmajor = 1;
+ screen->base.GLXminor = 3;
}
}
}
- LogMessage(X_INFO, "AIGLX: Set GLX version to %d.%d\n", screen->base.GLXmajor, screen->base.GLXminor);
+ LogMessage(X_INFO, "AIGLX: Set GLX version to %d.%d\n",
+ screen->base.GLXmajor, screen->base.GLXminor);
wglMakeCurrent(NULL, NULL);
wglDeleteContext(hglrc);
@@ -862,7 +865,6 @@ glxWinRealizeWindow(WindowPtr pWin)
return result;
}
-
static void
glxWinCopyWindow(WindowPtr pWindow, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
{
@@ -872,9 +874,8 @@ glxWinCopyWindow(WindowPtr pWindow, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
GLWIN_TRACE_MSG("glxWinCopyWindow pWindow %p", pWindow);
- dixLookupResourceByType((pointer) &pGlxDraw, pWindow->drawable.id, __glXDrawableRes,
- NullClient, DixUnknownAccess);
-
+ dixLookupResourceByType((pointer) &pGlxDraw, pWindow->drawable.id,
+ __glXDrawableRes, NullClient, DixUnknownAccess);
/*
Discard any CopyWindow requests if a GL drawing context is pointing at the window
@@ -882,12 +883,11 @@ glxWinCopyWindow(WindowPtr pWindow, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
For regions which are being drawn by GL, the shadow framebuffer doesn't have the
correct bits, so we wish to avoid shadow framebuffer damage occuring, which will
cause those incorrect bits to be transferred to the display....
- */
- if (pGlxDraw && pGlxDraw->drawContext)
- {
+ */
+ if (pGlxDraw && pGlxDraw->drawContext) {
GLWIN_DEBUG_MSG("glxWinCopyWindow: discarding");
return;
- }
+ }
GLWIN_DEBUG_MSG("glxWinCopyWindow - passing to hw layer");
@@ -928,7 +928,7 @@ glxWinUnrealizeWindow(WindowPtr pWin)
{
Bool result;
ScreenPtr pScreen = pWin->drawable.pScreen;
- glxWinScreen *screenPriv = (glxWinScreen *)glxGetScreen(pScreen);
+ glxWinScreen *screenPriv = (glxWinScreen *) glxGetScreen(pScreen);
winWindowPriv(pWin);
GLWIN_DEBUG_MSG("glxWinUnrealizeWindow");
@@ -990,123 +990,117 @@ glxWinDestroyWindow(WindowPtr pWin)
*/
static GLboolean
-glxWinDrawableSwapBuffers(ClientPtr client, __GLXdrawable *base)
+glxWinDrawableSwapBuffers(ClientPtr client, __GLXdrawable * base)
{
BOOL ret;
- __GLXWinDrawable *draw = (__GLXWinDrawable *)base;
+ __GLXWinDrawable *draw = (__GLXWinDrawable *) base;
/* Swap buffers on the last active context for drawing on the drawable */
- if (draw->drawContext == NULL)
- {
+ if (draw->drawContext == NULL) {
GLWIN_TRACE_MSG("glxWinSwapBuffers - no context for drawable");
return GL_FALSE;
- }
+ }
- GLWIN_TRACE_MSG("glxWinSwapBuffers on drawable %p, last context %p (native ctx %p)", base, draw->drawContext, draw->drawContext->ctx);
+ GLWIN_TRACE_MSG
+ ("glxWinSwapBuffers on drawable %p, last context %p (native ctx %p)",
+ base, draw->drawContext, draw->drawContext->ctx);
/*
draw->drawContext->base.drawPriv will not be set if the context is not current anymore,
but if it is, it should point to this drawable....
- */
- assert((draw->drawContext->base.drawPriv == NULL) || (draw->drawContext->base.drawPriv == base));
+ */
+ assert((draw->drawContext->base.drawPriv == NULL) ||
+ (draw->drawContext->base.drawPriv == base));
ret = SwapBuffers(draw->drawContext->hDC);
- if (!ret)
- {
+ if (!ret) {
ErrorF("wglSwapBuffers failed: %s\n", glxWinErrorMessage());
return GL_FALSE;
- }
+ }
return GL_TRUE;
}
static void
-glxWinDrawableCopySubBuffer(__GLXdrawable *drawable,
+glxWinDrawableCopySubBuffer(__GLXdrawable * drawable,
int x, int y, int w, int h)
{
- glAddSwapHintRectWINWrapperNonstatic(x, y, w, h);
- glxWinDrawableSwapBuffers(NULL, drawable);
+ glAddSwapHintRectWINWrapperNonstatic(x, y, w, h);
+ glxWinDrawableSwapBuffers(NULL, drawable);
}
static void
-glxWinDrawableDestroy(__GLXdrawable *base)
+glxWinDrawableDestroy(__GLXdrawable * base)
{
- __GLXWinDrawable *glxPriv = (__GLXWinDrawable *)base;
-
- if (glxPriv->drawContext && (__glXLastContext == &((glxPriv->drawContext)->base)))
- {
- // if this context is current and has unflushed commands, say we have flushed them
- // (don't actually flush them, the window is going away anyhow, and an implict flush occurs
- // on the next context change)
- // (GLX core considers it an error when we try to select a new current context if the old one
- // has unflushed commands, but the window has disappeared..)
- __glXLastContext->hasUnflushedCommands = FALSE;
- __glXLastContext = NULL;
+ __GLXWinDrawable *glxPriv = (__GLXWinDrawable *) base;
+
+ if (glxPriv->drawContext &&
+ (__glXLastContext == &((glxPriv->drawContext)->base))) {
+ // if this context is current and has unflushed commands, say we have flushed them
+ // (don't actually flush them, the window is going away anyhow, and an implict flush occurs
+ // on the next context change)
+ // (GLX core considers it an error when we try to select a new current context if the old one
+ // has unflushed commands, but the window has disappeared..)
+ __glXLastContext->hasUnflushedCommands = FALSE;
+ __glXLastContext = NULL;
}
- if (glxPriv->hPbuffer)
- if (!wglDestroyPbufferARBWrapper(glxPriv->hPbuffer))
- {
- ErrorF("wglDestroyPbufferARB failed: %s\n", glxWinErrorMessage());
- }
+ if (glxPriv->hPbuffer)
+ if (!wglDestroyPbufferARBWrapper(glxPriv->hPbuffer)) {
+ ErrorF("wglDestroyPbufferARB failed: %s\n", glxWinErrorMessage());
+ }
- if (glxPriv->dibDC)
- {
- // restore the default DIB
- SelectObject(glxPriv->dibDC, glxPriv->hOldDIB);
+ if (glxPriv->dibDC) {
+ // restore the default DIB
+ SelectObject(glxPriv->dibDC, glxPriv->hOldDIB);
- if (!DeleteDC(glxPriv->dibDC))
- {
- ErrorF("DeleteDC failed: %s\n", glxWinErrorMessage());
+ if (!DeleteDC(glxPriv->dibDC)) {
+ ErrorF("DeleteDC failed: %s\n", glxWinErrorMessage());
}
}
- if (glxPriv->hDIB)
- {
- if (!DeleteObject(glxPriv->hDIB))
- {
- ErrorF("DeleteObject failed: %s\n", glxWinErrorMessage());
+ if (glxPriv->hDIB) {
+ if (!DeleteObject(glxPriv->hDIB)) {
+ ErrorF("DeleteObject failed: %s\n", glxWinErrorMessage());
}
- ((PixmapPtr)glxPriv->base.pDraw)->devPrivate.ptr = glxPriv->pOldBits;
- glxPriv->base.pDraw->pScreen->DestroyPixmap((PixmapPtr)glxPriv->base.pDraw); /* Decrement reference count since we do not use it any more */
+ ((PixmapPtr) glxPriv->base.pDraw)->devPrivate.ptr = glxPriv->pOldBits;
+ glxPriv->base.pDraw->pScreen->DestroyPixmap((PixmapPtr)glxPriv->base.pDraw); /* Decrement reference count since we do not use it any more */
}
- GLWIN_DEBUG_MSG("glxWinDestroyDrawable");
- free(glxPriv);
+ GLWIN_DEBUG_MSG("glxWinDestroyDrawable");
+ free(glxPriv);
}
static __GLXdrawable *
glxWinCreateDrawable(ClientPtr client,
- __GLXscreen *screen,
- DrawablePtr pDraw,
- XID drawId,
- int type,
- XID glxDrawId,
- __GLXconfig *conf)
+ __GLXscreen * screen,
+ DrawablePtr pDraw,
+ XID drawId, int type, XID glxDrawId, __GLXconfig * conf)
{
- __GLXWinDrawable *glxPriv;
+ __GLXWinDrawable *glxPriv;
- glxPriv = calloc(1,sizeof(*glxPriv));
+ glxPriv = calloc(1, sizeof *glxPriv);
- if (glxPriv == NULL)
- return NULL;
+ if (glxPriv == NULL)
+ return NULL;
- if(!__glXDrawableInit(&glxPriv->base, screen, pDraw, type, glxDrawId, conf)) {
- free(glxPriv);
- return NULL;
- }
+ if (!__glXDrawableInit
+ (&glxPriv->base, screen, pDraw, type, glxDrawId, conf)) {
+ free(glxPriv);
+ return NULL;
+ }
- glxPriv->base.destroy = glxWinDrawableDestroy;
- glxPriv->base.swapBuffers = glxWinDrawableSwapBuffers;
- glxPriv->base.copySubBuffer = glxWinDrawableCopySubBuffer;
- // glxPriv->base.waitX what are these for?
- // glxPriv->base.waitGL
+ glxPriv->base.destroy = glxWinDrawableDestroy;
+ glxPriv->base.swapBuffers = glxWinDrawableSwapBuffers;
+ glxPriv->base.copySubBuffer = glxWinDrawableCopySubBuffer;
+ // glxPriv->base.waitX what are these for?
+ // glxPriv->base.waitGL
- GLWIN_DEBUG_MSG("glxWinCreateDrawable %p", glxPriv);
+ GLWIN_DEBUG_MSG("glxWinCreateDrawable %p", glxPriv);
- return &glxPriv->base;
+ return &glxPriv->base;
}
/* ---------------------------------------------------------------------- */
@@ -1115,21 +1109,21 @@ glxWinCreateDrawable(ClientPtr client,
*/
static
-int glxWinBindTexImage(__GLXcontext *baseContext,
- int buffer,
- __GLXdrawable *pixmap)
+ int
+glxWinBindTexImage(__GLXcontext * baseContext,
+ int buffer, __GLXdrawable * pixmap)
{
- ErrorF("glxWinBindTexImage: not implemented\n");
- return FALSE;
+ ErrorF("glxWinBindTexImage: not implemented\n");
+ return FALSE;
}
static
-int glxWinReleaseTexImage(__GLXcontext *baseContext,
- int buffer,
- __GLXdrawable *pixmap)
+ int
+glxWinReleaseTexImage(__GLXcontext * baseContext,
+ int buffer, __GLXdrawable * pixmap)
{
- ErrorF(" glxWinReleaseTexImage: not implemented\n");
- return FALSE;
+ ErrorF(" glxWinReleaseTexImage: not implemented\n");
+ return FALSE;
}
/* ---------------------------------------------------------------------- */
@@ -1152,13 +1146,14 @@ int glxWinReleaseTexImage(__GLXcontext *baseContext,
*/
static Bool
-glxWinSetPixelFormat(__GLXWinContext *gc, HDC hdc, int bppOverride, int drawableTypeOverride)
+glxWinSetPixelFormat(__GLXWinContext * gc, HDC hdc, int bppOverride,
+ int drawableTypeOverride)
{
- __GLXscreen *screen = gc->base.pGlxScreen;
- glxWinScreen *winScreen = (glxWinScreen *)screen;
+ __GLXscreen *screen = gc->base.pGlxScreen;
+ glxWinScreen *winScreen = (glxWinScreen *) screen;
- __GLXconfig *config = gc->base.config;
- GLXWinConfig *winConfig = (GLXWinConfig *)config;
+ __GLXconfig *config = gc->base.config;
+ GLXWinConfig *winConfig = (GLXWinConfig *) config;
WindowPtr pWin;
@@ -1174,18 +1169,18 @@ glxWinSetPixelFormat(__GLXWinContext *gc, HDC hdc, int bppOverride, int drawable
}
GLWIN_DEBUG_MSG("glxWinSetPixelFormat: pixelFormatIndex %d", winConfig->pixelFormatIndex);
- /*
+ /*
Normally, we can just use the the pixelFormatIndex corresponding
to the fbconfig which has been specified by the client
*/
/*
- However, in certain special cases this pixel format will be incompatible with the
- use we are going to put it to, so we need to re-evaluate the pixel format to use:
+ However, in certain special cases this pixel format will be incompatible with the
+ use we are going to put it to, so we need to re-evaluate the pixel format to use:
- 1) When PFD_DRAW_TO_BITMAP is set, ChoosePixelFormat() always returns a format with
+ 1) When PFD_DRAW_TO_BITMAP is set, ChoosePixelFormat() always returns a format with
the cColorBits we asked for, so we need to ensure it matches the bpp of the bitmap
- 2) Applications may assume that visuals selected with glXChooseVisual() work with
+ 2) Applications may assume that visuals selected with glXChooseVisual() work with
pixmap drawables (there is no attribute to explicitly query for pixmap drawable
support as there is for glXChooseFBConfig())
(it's arguable this is an error in the application, but we try to make it work)
@@ -1194,63 +1189,63 @@ glxWinSetPixelFormat(__GLXWinContext *gc, HDC hdc, int bppOverride, int drawable
by default, but if the actual drawable type we're trying to select the context
on (drawableTypeOverride) isn't supported by the selected fbConfig, reconsider
and see if we can find a suitable one...
- */
- ErrorF("glxWinSetPixelFormat: having second thoughts: cColorbits %d, bppOveride %d; config->drawableType %d, drawableTypeOverride %d\n",
- (config->redBits + config->greenBits + config->blueBits), bppOverride, config->drawableType, drawableTypeOverride);
-
- if (!winScreen->has_WGL_ARB_pixel_format)
- {
- PIXELFORMATDESCRIPTOR pfd;
- int pixelFormat;
-
- /* convert fbConfig to PFD */
- if (fbConfigToPixelFormat(gc->base.config, &pfd, drawableTypeOverride))
- {
- ErrorF("glxWinSetPixelFormat: fbConfigToPixelFormat failed\n");
- return FALSE;
+ */
+ ErrorF
+ ("glxWinSetPixelFormat: having second thoughts: cColorbits %d, bppOveride %d; config->drawableType %d, drawableTypeOverride %d\n",
+ (config->redBits + config->greenBits + config->blueBits), bppOverride,
+ config->drawableType, drawableTypeOverride);
+
+ if (!winScreen->has_WGL_ARB_pixel_format) {
+ PIXELFORMATDESCRIPTOR pfd;
+ int pixelFormat;
+
+ /* convert fbConfig to PFD */
+ if (fbConfigToPixelFormat(gc->base.config, &pfd, drawableTypeOverride)) {
+ ErrorF("glxWinSetPixelFormat: fbConfigToPixelFormat failed\n");
+ return FALSE;
}
#ifdef _DEBUG
if (glxWinDebugSettings.dumpPFD)
- pfdOut(&pfd);
+ pfdOut(&pfd);
#endif
- if (bppOverride)
- {
- GLWIN_DEBUG_MSG("glxWinSetPixelFormat: Forcing bpp from %d to %d\n", pfd.cColorBits, bppOverride);
- pfd.cColorBits = bppOverride;
+ if (bppOverride) {
+ GLWIN_DEBUG_MSG("glxWinSetPixelFormat: Forcing bpp from %d to %d\n",
+ pfd.cColorBits, bppOverride);
+ pfd.cColorBits = bppOverride;
}
- pixelFormat = ChoosePixelFormat(hdc, &pfd);
- if (pixelFormat == 0)
- {
- ErrorF("ChoosePixelFormat error: %s\n", glxWinErrorMessage());
- return FALSE;
+ pixelFormat = ChoosePixelFormat(hdc, &pfd);
+ if (pixelFormat == 0) {
+ ErrorF("ChoosePixelFormat error: %s\n", glxWinErrorMessage());
+ return FALSE;
}
- GLWIN_DEBUG_MSG("ChoosePixelFormat: chose pixelFormatIndex %d", pixelFormat);
- ErrorF("ChoosePixelFormat: chose pixelFormatIndex %d (rather than %d as originally planned)\n", pixelFormat, winConfig->pixelFormatIndex);
+ GLWIN_DEBUG_MSG("ChoosePixelFormat: chose pixelFormatIndex %d",
+ pixelFormat);
+ ErrorF
+ ("ChoosePixelFormat: chose pixelFormatIndex %d (rather than %d as originally planned)\n",
+ pixelFormat, winConfig->pixelFormatIndex);
- ErrorF("Setting pixel format 2 to %d on hdc %x\n",pixelFormat,hdc);
- if (!SetPixelFormat(hdc, pixelFormat, &pfd))
- {
- ErrorF("SetPixelFormat error: %s\n", glxWinErrorMessage());
- return FALSE;
+ ErrorF("Setting pixel format 2 to %d on hdc %x\n",pixelFormat,hdc);
+ if (!SetPixelFormat(hdc, pixelFormat, &pfd)) {
+ ErrorF("SetPixelFormat error: %s\n", glxWinErrorMessage());
+ return FALSE;
}
}
- else
- {
- int pixelFormat = fbConfigToPixelFormatIndex(hdc, gc->base.config, drawableTypeOverride, winScreen);
- if (pixelFormat != 0)
- {
+ else {
+ int pixelFormat =
+ fbConfigToPixelFormatIndex(hdc, gc->base.config,
+ drawableTypeOverride, winScreen);
+ if (pixelFormat != 0) {
GLWIN_DEBUG_MSG("wglChoosePixelFormat: chose pixelFormatIndex %d", pixelFormat);
ErrorF("Setting pixel format 3 to %d on hdc %x\n",pixelFormat,hdc);
- if (!SetPixelFormat(hdc, pixelFormat, NULL))
- {
- ErrorF("SetPixelFormat error: %s\n", glxWinErrorMessage());
- return FALSE;
- }
+ if (!SetPixelFormat(hdc, pixelFormat, NULL)) {
+ ErrorF("SetPixelFormat error: %s\n", glxWinErrorMessage());
+ return FALSE;
+ }
return TRUE;
}
else
@@ -1290,40 +1285,37 @@ glxWinSetPixelFormat(__GLXWinContext *gc, HDC hdc, int bppOverride, int drawable
}
}
}
- return TRUE;
+ return TRUE;
}
static HDC
glxWinMakeDC(__GLXWinContext *gc, __GLXWinDrawable *draw, HWND *hwnd)
{
- HDC hdc = NULL;
- *hwnd = NULL;
+ HDC hdc = NULL;
+ *hwnd = NULL;
- if (draw == NULL)
- {
- GLWIN_TRACE_MSG("No drawable for context %p (native ctx %p)", gc, gc->ctx);
- return NULL;
+ if (draw == NULL) {
+ GLWIN_TRACE_MSG("No drawable for context %p (native ctx %p)", gc,
+ gc->ctx);
+ return NULL;
}
- switch (draw->base.type)
- {
+ switch (draw->base.type) {
case GLX_DRAWABLE_WINDOW:
{
- WindowPtr pWin;
+ WindowPtr pWin;
- pWin = (WindowPtr) draw->base.pDraw;
- if (pWin == NULL)
- {
- GLWIN_TRACE_MSG("for drawable %p, no WindowPtr", pWin);
- return NULL;
+ pWin = (WindowPtr) draw->base.pDraw;
+ if (pWin == NULL) {
+ GLWIN_TRACE_MSG("for drawable %p, no WindowPtr", pWin);
+ return NULL;
}
- *hwnd = winGetWindowInfo(pWin);
+ *hwnd = winGetWindowInfo(pWin);
- if (*hwnd == NULL)
- {
- ErrorF("No HWND error: %s\n", glxWinErrorMessage());
- return NULL;
+ if (*hwnd == NULL) {
+ ErrorF("No HWND error: %s\n", glxWinErrorMessage());
+ return NULL;
}
if (!gc->hDC)
@@ -1341,30 +1333,32 @@ glxWinMakeDC(__GLXWinContext *gc, __GLXWinDrawable *draw, HWND *hwnd)
}
#ifdef _DEBUG
- if (glxWinDebugSettings.enableTrace)
- GLWIN_DEBUG_HWND(*hwnd);
+ if (glxWinDebugSettings.enableTrace)
+ GLWIN_DEBUG_HWND(*hwnd);
- GLWIN_TRACE_MSG("for context %p (native ctx %p), hWnd changed from %p to %p", gc, gc->ctx, gc->hwnd, *hwnd);
+ GLWIN_TRACE_MSG
+ ("for context %p (native ctx %p), hWnd changed from %p to %p",
+ gc, gc->ctx, gc->hwnd, *hwnd);
#endif
if (gc->hwnd!=*hwnd)
ErrorF("Window changed handle from %x to %x\n", gc->hwnd, *hwnd);
gc->hwnd = *hwnd;
}
- break;
+ break;
- case GLX_DRAWABLE_PBUFFER:
+ case GLX_DRAWABLE_PBUFFER:
{
hdc = wglGetPbufferDCARBWrapper(draw->hPbuffer);
if (hdc == NULL)
- ErrorF("GetDC (pbuffer) error: %s\n", glxWinErrorMessage());
+ ErrorF("GetDC (pbuffer) error: %s\n", glxWinErrorMessage());
gc->ctx = wglCreateContext(hdc);
}
- break;
+ break;
- case GLX_DRAWABLE_PIXMAP:
+ case GLX_DRAWABLE_PIXMAP:
{
hdc = draw->dibDC;
#ifdef _DEBUG
@@ -1372,219 +1366,232 @@ glxWinMakeDC(__GLXWinContext *gc, __GLXWinDrawable *draw, HWND *hwnd)
GLWIN_DEBUG_MSG("Got PIXMAP HDC %p for window %p", hdc, *hwnd);
#endif
}
- break;
+ break;
- default:
+ default:
{
- ErrorF("glxWinMakeDC: tried to makeDC for unhandled drawable type %d\n", draw->base.type);
+ ErrorF("glxWinMakeDC: tried to makeDC for unhandled drawable type %d\n",
+ draw->base.type);
+ }
}
- }
#ifdef _DEBUG
- if (glxWinDebugSettings.dumpDC)
- GLWIN_HDC_DEBUG_MSG("Got HDC %p for window %p", hdc, *hwnd);
+ if (glxWinDebugSettings.dumpDC)
+ GLWIN_HDC_DEBUG_MSG("Got HDC %p for window %p", hdc, *hwnd);
#endif
return hdc;
}
static void
-glxWinReleaseDC(HWND hwnd, HDC hdc,__GLXWinDrawable *draw)
+glxWinReleaseDC(HWND hwnd, HDC hdc, __GLXWinDrawable * draw)
{
- switch (draw->base.type)
- {
+ switch (draw->base.type) {
case GLX_DRAWABLE_WINDOW:
{
- ReleaseDC(hwnd, hdc);
+ ReleaseDC(hwnd, hdc);
}
- break;
+ break;
- case GLX_DRAWABLE_PBUFFER:
+ case GLX_DRAWABLE_PBUFFER:
{
- if (!wglReleasePbufferDCARBWrapper(draw->hPbuffer, hdc))
- {
- ErrorF("wglReleasePbufferDCARB error: %s\n", glxWinErrorMessage());
+ if (!wglReleasePbufferDCARBWrapper(draw->hPbuffer, hdc)) {
+ ErrorF("wglReleasePbufferDCARB error: %s\n", glxWinErrorMessage());
}
}
- break;
+ break;
- case GLX_DRAWABLE_PIXMAP:
+ case GLX_DRAWABLE_PIXMAP:
{
- // don't release DC, the memory DC lives as long as the bitmap
+ // don't release DC, the memory DC lives as long as the bitmap
- // We must ensure that all GDI drawing into the bitmap has completed
- // in case we subsequently access the bits from it
- GdiFlush();
+ // We must ensure that all GDI drawing into the bitmap has completed
+ // in case we subsequently access the bits from it
+ GdiFlush();
}
- break;
+ break;
- default:
+ default:
{
- ErrorF("glxWinReleaseDC: tried to releaseDC for unhandled drawable type %d\n", draw->base.type);
+ ErrorF
+ ("glxWinReleaseDC: tried to releaseDC for unhandled drawable type %d\n",
+ draw->base.type);
+ }
}
- }
}
static void
-glxWinDeferredCreateContext(__GLXWinContext *gc, __GLXWinDrawable *draw)
+glxWinDeferredCreateContext(__GLXWinContext * gc, __GLXWinDrawable * draw)
{
- HWND hwnd;
- GLWIN_DEBUG_MSG("glxWinDeferredCreateContext: attach context %p to drawable %p", gc, draw);
+ HWND hwnd;
- switch (draw->base.type)
- {
+ GLWIN_DEBUG_MSG
+ ("glxWinDeferredCreateContext: attach context %p to drawable %p", gc,
+ draw);
+
+ switch (draw->base.type) {
case GLX_DRAWABLE_WINDOW:
{
- WindowPtr pWin = (WindowPtr) draw->base.pDraw;
+ WindowPtr pWin = (WindowPtr) draw->base.pDraw;
- if (!(gc->base.config->drawableType & GLX_WINDOW_BIT))
- {
- ErrorF("glxWinDeferredCreateContext: tried to attach a context whose fbConfig doesn't have drawableType GLX_WINDOW_BIT to a GLX_DRAWABLE_WINDOW drawable\n");
+ if (!(gc->base.config->drawableType & GLX_WINDOW_BIT)) {
+ ErrorF
+ ("glxWinDeferredCreateContext: tried to attach a context whose fbConfig doesn't have drawableType GLX_WINDOW_BIT to a GLX_DRAWABLE_WINDOW drawable\n");
}
- if (pWin == NULL)
- {
- GLWIN_DEBUG_MSG("Deferring until X window is created");
- return;
+ if (pWin == NULL) {
+ GLWIN_DEBUG_MSG("Deferring until X window is created");
+ return;
}
- GLWIN_DEBUG_MSG("glxWinDeferredCreateContext: pWin %p", pWin);
+ GLWIN_DEBUG_MSG("glxWinDeferredCreateContext: pWin %p", pWin);
- if (winGetWindowInfo(pWin) == NULL)
- {
- GLWIN_DEBUG_MSG("Deferring until native window is created");
- return;
+ if (winGetWindowInfo(pWin) == NULL) {
+ GLWIN_DEBUG_MSG("Deferring until native window is created");
+ return;
}
}
- break;
+ break;
case GLX_DRAWABLE_PBUFFER:
{
WindowPtr pWin = (WindowPtr) draw->base.pDraw;
- if (draw->hPbuffer == NULL)
- {
- __GLXscreen *screen;
- glxWinScreen *winScreen;
- int pixelFormat;
- // XXX: which DC are supposed to use???
- ScreenPtr pScreen = pWin->drawable.pScreen;
- winPrivScreenPtr pWinScreen = winGetScreenPriv(pScreen);
- HDC screenDC=pWinScreen->hdcScreen;
-
- if (!(gc->base.config->drawableType & GLX_PBUFFER_BIT))
- {
- ErrorF("glxWinDeferredCreateContext: tried to attach a context whose fbConfig doesn't have drawableType GLX_PBUFFER_BIT to a GLX_DRAWABLE_PBUFFER drawable\n");
+ if (draw->hPbuffer == NULL) {
+ __GLXscreen *screen;
+ glxWinScreen *winScreen;
+ int pixelFormat;
+
+ // XXX: which DC are supposed to use???
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ winPrivScreenPtr pWinScreen = winGetScreenPriv(pScreen);
+ HDC screenDC=pWinScreen->hdcScreen;
+
+ if (!(gc->base.config->drawableType & GLX_PBUFFER_BIT)) {
+ ErrorF
+ ("glxWinDeferredCreateContext: tried to attach a context whose fbConfig doesn't have drawableType GLX_PBUFFER_BIT to a GLX_DRAWABLE_PBUFFER drawable\n");
}
- screen = gc->base.pGlxScreen;
- winScreen = (glxWinScreen *)screen;
+ screen = gc->base.pGlxScreen;
+ winScreen = (glxWinScreen *) screen;
- pixelFormat = fbConfigToPixelFormatIndex(screenDC, gc->base.config, GLX_PBUFFER_BIT, winScreen);
- if (pixelFormat == 0)
- {
- ErrorF("wglChoosePixelFormat error: %s\n", glxWinErrorMessage());
- return;
+ pixelFormat =
+ fbConfigToPixelFormatIndex(screenDC, gc->base.config,
+ GLX_PBUFFER_BIT, winScreen);
+ if (pixelFormat == 0) {
+ ErrorF("wglChoosePixelFormat error: %s\n",
+ glxWinErrorMessage());
+ return;
}
- draw->hPbuffer = wglCreatePbufferARBWrapper(screenDC, pixelFormat, draw->base.pDraw->width, draw->base.pDraw->height, NULL);
+ draw->hPbuffer =
+ wglCreatePbufferARBWrapper(screenDC, pixelFormat,
+ draw->base.pDraw->width,
+ draw->base.pDraw->height, NULL);
- if (draw->hPbuffer == NULL)
- {
- ErrorF("wglCreatePbufferARBWrapper error: %s\n", glxWinErrorMessage());
- return;
+ if (draw->hPbuffer == NULL) {
+ ErrorF("wglCreatePbufferARBWrapper error: %s\n",
+ glxWinErrorMessage());
+ return;
}
- GLWIN_DEBUG_MSG("glxWinDeferredCreateContext: pBuffer %p created for drawable %p", draw->hPbuffer, draw);
+ GLWIN_DEBUG_MSG
+ ("glxWinDeferredCreateContext: pBuffer %p created for drawable %p",
+ draw->hPbuffer, draw);
}
}
- break;
+ break;
case GLX_DRAWABLE_PIXMAP:
{
- if (draw->dibDC == NULL)
- {
- BITMAPINFOHEADER bmpHeader;
- void *pBits;
-
- memset (&bmpHeader, 0, sizeof(BITMAPINFOHEADER));
- bmpHeader.biSize = sizeof(BITMAPINFOHEADER);
- bmpHeader.biWidth = draw->base.pDraw->width;
- bmpHeader.biHeight = draw->base.pDraw->height;
- bmpHeader.biPlanes = 1;
- bmpHeader.biBitCount = draw->base.pDraw->bitsPerPixel;
- bmpHeader.biCompression = BI_RGB;
-
- if (!(gc->base.config->drawableType & GLX_PIXMAP_BIT))
- {
- ErrorF("glxWinDeferredCreateContext: tried to attach a context whose fbConfig doesn't have drawableType GLX_PIXMAP_BIT to a GLX_DRAWABLE_PIXMAP drawable\n");
+ if (draw->dibDC == NULL) {
+ BITMAPINFOHEADER bmpHeader;
+ void *pBits;
+
+ memset(&bmpHeader, 0, sizeof(BITMAPINFOHEADER));
+ bmpHeader.biSize = sizeof(BITMAPINFOHEADER);
+ bmpHeader.biWidth = draw->base.pDraw->width;
+ bmpHeader.biHeight = draw->base.pDraw->height;
+ bmpHeader.biPlanes = 1;
+ bmpHeader.biBitCount = draw->base.pDraw->bitsPerPixel;
+ bmpHeader.biCompression = BI_RGB;
+
+ if (!(gc->base.config->drawableType & GLX_PIXMAP_BIT)) {
+ ErrorF
+ ("glxWinDeferredCreateContext: tried to attach a context whose fbConfig doesn't have drawableType GLX_PIXMAP_BIT to a GLX_DRAWABLE_PIXMAP drawable\n");
}
- draw->dibDC = CreateCompatibleDC(NULL);
- if (draw->dibDC == NULL)
- {
- ErrorF("CreateCompatibleDC error: %s\n", glxWinErrorMessage());
- return;
+ draw->dibDC = CreateCompatibleDC(NULL);
+ if (draw->dibDC == NULL) {
+ ErrorF("CreateCompatibleDC error: %s\n", glxWinErrorMessage());
+ return;
}
- draw->hDIB = CreateDIBSection(draw->dibDC, (BITMAPINFO *)&bmpHeader, DIB_RGB_COLORS, &pBits, 0, 0);
- if (draw->dibDC == NULL)
- {
- ErrorF("CreateDIBSection error: %s\n", glxWinErrorMessage());
- return;
+ draw->hDIB =
+ CreateDIBSection(draw->dibDC, (BITMAPINFO *) & bmpHeader,
+ DIB_RGB_COLORS, &pBits, 0, 0);
+ if (draw->dibDC == NULL) {
+ ErrorF("CreateDIBSection error: %s\n", glxWinErrorMessage());
+ return;
}
- // XXX: CreateDIBSection insists on allocating the bitmap memory for us, so we're going to
- // need some jiggery pokery to point the underlying X Drawable's bitmap at the same set of bits
- // so that they can be read with XGetImage as well as glReadPixels, assuming the formats are
- // even compatible ...
- draw->pOldBits = ((PixmapPtr)draw->base.pDraw)->devPrivate.ptr;
- ((PixmapPtr)draw->base.pDraw)->devPrivate.ptr = pBits;
+ // XXX: CreateDIBSection insists on allocating the bitmap memory for us, so we're going to
+ // need some jiggery pokery to point the underlying X Drawable's bitmap at the same set of bits
+ // so that they can be read with XGetImage as well as glReadPixels, assuming the formats are
+ // even compatible ...
+ draw->pOldBits = ((PixmapPtr) draw->base.pDraw)->devPrivate.ptr;
+ ((PixmapPtr) draw->base.pDraw)->devPrivate.ptr = pBits;
((PixmapPtr)draw->base.pDraw)->refcnt++; /* Increment reference count to be sure it is not freed before the glxdrawable is destroyed */
- // Select the DIB into the DC
- draw->hOldDIB = SelectObject(draw->dibDC, draw->hDIB);
- if (!draw->hOldDIB)
- {
- ErrorF("SelectObject error: %s\n", glxWinErrorMessage());
+ // Select the DIB into the DC
+ draw->hOldDIB = SelectObject(draw->dibDC, draw->hDIB);
+ if (!draw->hOldDIB) {
+ ErrorF("SelectObject error: %s\n", glxWinErrorMessage());
}
- // Set the pixel format of the bitmap
- glxWinSetPixelFormat(gc, draw->dibDC, draw->base.pDraw->bitsPerPixel, GLX_PIXMAP_BIT);
+ // Set the pixel format of the bitmap
+ glxWinSetPixelFormat(gc, draw->dibDC,
+ draw->base.pDraw->bitsPerPixel,
+ GLX_PIXMAP_BIT);
- GLWIN_DEBUG_MSG("glxWinDeferredCreateContext: DIB bitmap %p created for drawable %p", draw->hDIB, draw);
+ GLWIN_DEBUG_MSG
+ ("glxWinDeferredCreateContext: DIB bitmap %p created for drawable %p",
+ draw->hDIB, draw);
}
}
- break;
+ break;
default:
{
- ErrorF("glxWinDeferredCreateContext: tried to attach unhandled drawable type %d\n", draw->base.type);
- return;
+ ErrorF
+ ("glxWinDeferredCreateContext: tried to attach unhandled drawable type %d\n",
+ draw->base.type);
+ return;
+ }
}
- }
- gc->hDC = glxWinMakeDC(gc, draw, &hwnd);
+ gc->hDC = glxWinMakeDC(gc, draw, &hwnd);
- if (gc->ctx == NULL)
- {
+ if (gc->ctx == NULL) {
glxWinReleaseDC(hwnd, gc->hDC, draw);
gc->hDC=0;
- ErrorF("wglCreateContext error: %s\n", glxWinErrorMessage());
- return;
+ ErrorF("wglCreateContext error: %s\n", glxWinErrorMessage());
+ return;
}
- GLWIN_DEBUG_MSG("glxWinDeferredCreateContext: attached context %p to native context %p drawable %p", gc, gc->ctx, draw);
+ GLWIN_DEBUG_MSG
+ ("glxWinDeferredCreateContext: attached context %p to native context %p drawable %p",
+ gc, gc->ctx, draw);
- // if the native context was created successfully, shareLists if needed
- if (gc->ctx && gc->shareContext && gc->shareContext->ctx)
- {
- GLWIN_DEBUG_MSG("glxWinCreateContextReal shareLists with context %p (native ctx %p)", gc->shareContext, gc->shareContext->ctx);
+ // if the native context was created successfully, shareLists if needed
+ if (gc->ctx && gc->shareContext && gc->shareContext->ctx) {
+ GLWIN_DEBUG_MSG
+ ("glxWinCreateContextReal shareLists with context %p (native ctx %p)",
+ gc->shareContext, gc->shareContext->ctx);
- if (!wglShareLists(gc->shareContext->ctx, gc->ctx))
- {
- ErrorF("wglShareLists error: %s\n", glxWinErrorMessage());
+ if (!wglShareLists(gc->shareContext->ctx, gc->ctx)) {
+ ErrorF("wglShareLists error: %s\n", glxWinErrorMessage());
}
}
}
@@ -1594,70 +1601,64 @@ glxWinDeferredCreateContext(__GLXWinContext *gc, __GLXWinDrawable *draw)
* Context functions
*/
-
/* Context manipulation routines should return TRUE on success, FALSE on failure */
static int
-glxWinContextMakeCurrent(__GLXcontext *base)
+glxWinContextMakeCurrent(__GLXcontext * base)
{
- __GLXWinContext *gc = (__GLXWinContext *)base;
- BOOL ret;
- __GLXWinDrawable *drawPriv;
+ __GLXWinContext *gc = (__GLXWinContext *) base;
+ BOOL ret;
+ __GLXWinDrawable *drawPriv;
#ifdef _DEBUG
- GLWIN_TRACE_MSG("glxWinContextMakeCurrent context %p (native ctx %p)", gc, gc->ctx);
- glWinCallDelta();
+ GLWIN_TRACE_MSG("glxWinContextMakeCurrent context %p (native ctx %p)", gc, gc->ctx);
+ glWinCallDelta();
#endif
- /* Keep a note of the last active context in the drawable */
- drawPriv = (__GLXWinDrawable *)gc->base.drawPriv;
- drawPriv->drawContext = gc;
+ /* Keep a note of the last active context in the drawable */
+ drawPriv = (__GLXWinDrawable *)gc->base.drawPriv;
+ drawPriv->drawContext = gc;
- if (gc->ctx == NULL)
- {
- glxWinDeferredCreateContext(gc, drawPriv);
+ if (gc->ctx == NULL) {
+ glxWinDeferredCreateContext(gc, drawPriv);
}
- _glapi_set_dispatch(gc->Dispatch);
+ _glapi_set_dispatch(gc->Dispatch);
- if (gc->ctx == NULL)
- {
- ErrorF("glxWinContextMakeCurrent: Native context is NULL\n");
+ if (gc->ctx == NULL) {
+ ErrorF("glxWinContextMakeCurrent: Native context is NULL\n");
drawPriv->drawContext = NULL; /* clear last active context because we return error */
- return FALSE;
+ return FALSE;
}
- if ((gc->base.readPriv != NULL) && (gc->base.readPriv != gc->base.drawPriv))
- {
- // XXX: should only occur with WGL_ARB_make_current_read
- /*
- If there is a separate read drawable, create a separate read DC, and
- use the wglMakeContextCurrent extension to make the context current drawing
- to one DC and reading from the other
- */
- gc->hreadDC = glxWinMakeDC(gc, (__GLXWinDrawable *)gc->base.readPriv, &gc->hreadwnd);
- if (gc->hreadDC == NULL)
+ if ((gc->base.readPriv != NULL) && (gc->base.readPriv != gc->base.drawPriv)) {
+ // XXX: should only occur with WGL_ARB_make_current_read
+ /*
+ If there is a separate read drawable, create a separate read DC, and
+ use the wglMakeContextCurrent extension to make the context current drawing
+ to one DC and reading from the other
+ */
+ gc->hreadDC = glxWinMakeDC(gc, (__GLXWinDrawable *)gc->base.readPriv, &gc->hreadwnd);
+ if (gc->hreadDC == NULL)
{
- ErrorF("glxWinMakeDC failed for readDC\n");
- drawPriv->drawContext = NULL; /* clear last active context because we return error */
- return FALSE;
+ ErrorF("glxWinMakeDC failed for readDC\n");
+ drawPriv->drawContext = NULL; /* clear last active context because we return error */
+ return FALSE;
}
- ret = wglMakeContextCurrentARBWrapper(gc->hDC, gc->hreadDC, gc->ctx);
- if (!ret)
- {
- ErrorF("wglMakeContextCurrentARBWrapper error: %s\n", glxWinErrorMessage());
+ ret = wglMakeContextCurrentARBWrapper(gc->hDC, gc->hreadDC, gc->ctx);
+ if (!ret) {
+ ErrorF("wglMakeContextCurrentARBWrapper error: %s\n",
+ glxWinErrorMessage());
}
}
- else
- {
- /* Otherwise, just use wglMakeCurrent */
+ else {
+ /* Otherwise, just use wglMakeCurrent */
if (!gc->hDC)
{
/* It probably has been release by loseCurrent, so create it again */
gc->hDC = glxWinMakeDC(gc, drawPriv, &gc->hwnd);
}
ret = wglMakeCurrent(gc->hDC, gc->ctx);
- if (!ret)
- {
+ if (!ret) {
DWORD ErrorCode=GetLastError();
ErrorF("wglMakeCurrent error: %x dc %p ctx %p\n", ErrorCode,gc->hDC,gc->ctx);
if (!ErrorCode)
@@ -1668,128 +1669,125 @@ glxWinContextMakeCurrent(__GLXcontext *base)
}
}
- // apparently make current could fail if the context is current in a different thread,
- // but that shouldn't be able to happen in the current server...
- if (!ret)
- drawPriv->drawContext = NULL; /* clear last active context because we return error */
+ // apparently make current could fail if the context is current in a different thread,
+ // but that shouldn't be able to happen in the current server...
+ if (!ret)
+ drawPriv->drawContext = NULL; /* clear last active context because we return error */
- return ret;
+ return ret;
}
static int
-glxWinContextLoseCurrent(__GLXcontext *base)
+glxWinContextLoseCurrent(__GLXcontext * base)
{
- BOOL ret=TRUE;
- __GLXWinContext *gc = (__GLXWinContext *)base;
- __GLXWinDrawable *drawPriv = (__GLXWinDrawable *)gc->base.drawPriv;
+ BOOL ret=TRUE;
+ __GLXWinContext *gc = (__GLXWinContext *) base;
+ __GLXWinDrawable *drawPriv = (__GLXWinDrawable *)gc->base.drawPriv;
#ifdef _DEBUG
- GLWIN_TRACE_MSG("glxWinContextLoseCurrent context %p (native ctx %p)", gc, gc->ctx);
- glWinCallDelta();
+ GLWIN_TRACE_MSG("glxWinContextLoseCurrent context %p (native ctx %p)", gc, gc->ctx);
+ glWinCallDelta();
#endif
- /* Clear the last active context in the drawable */
- if (drawPriv) drawPriv->drawContext = NULL;
+ /* Clear the last active context in the drawable */
+ if (drawPriv) drawPriv->drawContext = NULL;
- if (wglGetCurrentContext()==gc->ctx)
- {
- /* Only do this when we are sure we are currently the active, otherwise we are deactivating the wrong one (this is happening!!!) */
- ret = wglMakeCurrent(NULL, NULL);
- if (!ret)
- ErrorF("glxWinContextLoseCurrent error: %s\n", glxWinErrorMessage());
- }
- else
- {
- return FALSE;
- }
+ if (wglGetCurrentContext()==gc->ctx)
+ {
+ /* Only do this when we are sure we are currently the active, otherwise we are deactivating the wrong one (this is happening!!!) */
+ ret = wglMakeCurrent(NULL, NULL);
+ if (!ret)
+ ErrorF("glxWinContextLoseCurrent error: %s\n", glxWinErrorMessage());
+ }
+ else
+ {
+ return FALSE;
+ }
- base->isCurrent=FALSE; /* It looks like glx is not doing this */
- _glapi_set_dispatch(NULL);
+ base->isCurrent=FALSE; /* It looks like glx is not doing this */
+ _glapi_set_dispatch(NULL);
- return ret;
+ return ret;
}
static int
-glxWinContextCopy(__GLXcontext *dst_base, __GLXcontext *src_base, unsigned long mask)
+glxWinContextCopy(__GLXcontext * dst_base, __GLXcontext * src_base,
+ unsigned long mask)
{
- __GLXWinContext *dst = (__GLXWinContext *)dst_base;
- __GLXWinContext *src = (__GLXWinContext *)src_base;
- BOOL ret;
+ __GLXWinContext *dst = (__GLXWinContext *) dst_base;
+ __GLXWinContext *src = (__GLXWinContext *) src_base;
+ BOOL ret;
- GLWIN_DEBUG_MSG("glxWinContextCopy");
+ GLWIN_DEBUG_MSG("glxWinContextCopy");
- ret = wglCopyContext(src->ctx, dst->ctx, mask);
- if (!ret)
- {
- ErrorF("wglCopyContext error: %s\n", glxWinErrorMessage());
+ ret = wglCopyContext(src->ctx, dst->ctx, mask);
+ if (!ret) {
+ ErrorF("wglCopyContext error: %s\n", glxWinErrorMessage());
}
- return ret;
+ return ret;
}
static void
-glxWinContextDestroy(__GLXcontext *base)
+glxWinContextDestroy(__GLXcontext * base)
{
- __GLXWinContext *gc = (__GLXWinContext *)base;
+ __GLXWinContext *gc = (__GLXWinContext *) base;
- if (gc != NULL)
- {
+ if (gc != NULL) {
__GLXWinDrawable *drawPriv = (__GLXWinDrawable *)gc->base.drawPriv;
- GLWIN_DEBUG_MSG("GLXcontext %p destroyed (native ctx %p)", base, gc->ctx);
+ GLWIN_DEBUG_MSG("GLXcontext %p destroyed (native ctx %p)", base,
+ gc->ctx);
- if (gc->ctx)
- {
- BOOL ret;
- /* It's bad style to delete the context while it's still current */
- if (wglGetCurrentContext() == gc->ctx)
- {
- wglMakeCurrent(NULL, NULL);
- }
+ if (gc->ctx) {
+ BOOL ret;
+ /* It's bad style to delete the context while it's still current */
+ if (wglGetCurrentContext() == gc->ctx) {
+ wglMakeCurrent(NULL, NULL);
+ }
+
+ ret = wglDeleteContext(gc->ctx);
- ret = wglDeleteContext(gc->ctx);
- if (!ret)
- ErrorF("wglDeleteContext error: %s\n", glxWinErrorMessage());
- if (drawPriv && gc->hDC) glxWinReleaseDC(gc->hwnd, gc->hDC, drawPriv);
- if (gc->base.readPriv && gc->hreadDC) glxWinReleaseDC(gc->hreadwnd, gc->hreadDC, (__GLXWinDrawable *)gc->base.readPriv);
- gc->hDC=NULL;
- gc->hreadDC=NULL;
- gc->ctx = NULL;
+ if (!ret)
+ ErrorF("wglDeleteContext error: %s\n", glxWinErrorMessage());
+ if (drawPriv && gc->hDC) glxWinReleaseDC(gc->hwnd, gc->hDC, drawPriv);
+ if (gc->base.readPriv && gc->hreadDC) glxWinReleaseDC(gc->hreadwnd, gc->hreadDC, (__GLXWinDrawable *)gc->base.readPriv);
+ gc->hDC=NULL;
+ gc->hreadDC=NULL;
+ gc->ctx = NULL;
}
- /* Clear the last active context in the drawable */
- if (drawPriv) drawPriv->drawContext = NULL;
+ /* Clear the last active context in the drawable */
+ if (drawPriv) drawPriv->drawContext = NULL;
- free(gc->Dispatch);
- free(gc);
- _glapi_set_dispatch(NULL);
+ free(gc->Dispatch);
+ free(gc);
+ _glapi_set_dispatch(NULL);
}
}
static __GLXcontext *
-glxWinCreateContext(__GLXscreen *screen,
- __GLXconfig *modes,
- __GLXcontext *baseShareContext)
+glxWinCreateContext(__GLXscreen * screen,
+ __GLXconfig * modes, __GLXcontext * baseShareContext)
{
__GLXWinContext *context;
- __GLXWinContext *shareContext = (__GLXWinContext *)baseShareContext;
+ __GLXWinContext *shareContext = (__GLXWinContext *) baseShareContext;
- static __GLXtextureFromPixmap glxWinTextureFromPixmap =
- {
+ static __GLXtextureFromPixmap glxWinTextureFromPixmap = {
glxWinBindTexImage,
glxWinReleaseTexImage
- };
+ };
- context = (__GLXWinContext *)calloc(1, sizeof(__GLXWinContext));
+ context = (__GLXWinContext *) calloc(1, sizeof(__GLXWinContext));
if (!context)
return NULL;
memset(context, 0, sizeof *context);
- context->base.destroy = glxWinContextDestroy;
- context->base.makeCurrent = glxWinContextMakeCurrent;
- context->base.loseCurrent = glxWinContextLoseCurrent;
- context->base.copy = glxWinContextCopy;
+ context->base.destroy = glxWinContextDestroy;
+ context->base.makeCurrent = glxWinContextMakeCurrent;
+ context->base.loseCurrent = glxWinContextLoseCurrent;
+ context->base.copy = glxWinContextCopy;
context->base.textureFromPixmap = &glxWinTextureFromPixmap;
context->base.config = modes;
context->base.pGlxScreen = screen;
@@ -1825,32 +1823,33 @@ static int GetShift(int Mask)
}
static int
-fbConfigToPixelFormat(__GLXconfig *mode, PIXELFORMATDESCRIPTOR *pfdret, int drawableTypeOverride)
+fbConfigToPixelFormat(__GLXconfig * mode, PIXELFORMATDESCRIPTOR * pfdret,
+ int drawableTypeOverride)
{
PIXELFORMATDESCRIPTOR pfd = {
- sizeof(PIXELFORMATDESCRIPTOR), /* size of this pfd */
- 1, /* version number */
- PFD_SUPPORT_OPENGL, /* support OpenGL */
- PFD_TYPE_RGBA, /* RGBA type */
- 24, /* 24-bit color depth */
- 0, 0, 0, 0, 0, 0, /* color bits ignored */
- 0, /* no alpha buffer */
- 0, /* shift bit ignored */
- 0, /* no accumulation buffer */
- 0, 0, 0, 0, /* accum bits ignored */
- 32, /* 32-bit z-buffer */
- 0, /* no stencil buffer */
- 0, /* no auxiliary buffer */
- PFD_MAIN_PLANE, /* main layer */
- 0, /* reserved */
- 0, 0, 0 /* layer masks ignored */
+ sizeof(PIXELFORMATDESCRIPTOR), /* size of this pfd */
+ 1, /* version number */
+ PFD_SUPPORT_OPENGL, /* support OpenGL */
+ PFD_TYPE_RGBA, /* RGBA type */
+ 24, /* 24-bit color depth */
+ 0, 0, 0, 0, 0, 0, /* color bits ignored */
+ 0, /* no alpha buffer */
+ 0, /* shift bit ignored */
+ 0, /* no accumulation buffer */
+ 0, 0, 0, 0, /* accum bits ignored */
+ 32, /* 32-bit z-buffer */
+ 0, /* no stencil buffer */
+ 0, /* no auxiliary buffer */
+ PFD_MAIN_PLANE, /* main layer */
+ 0, /* reserved */
+ 0, 0, 0 /* layer masks ignored */
};
if ((mode->drawableType | drawableTypeOverride) & GLX_WINDOW_BIT)
- pfd.dwFlags |= PFD_DRAW_TO_WINDOW; /* support window */
+ pfd.dwFlags |= PFD_DRAW_TO_WINDOW; /* support window */
if ((mode->drawableType | drawableTypeOverride) & GLX_PIXMAP_BIT)
- pfd.dwFlags |= (PFD_DRAW_TO_BITMAP | PFD_SUPPORT_GDI); /* supports software rendering to bitmap */
+ pfd.dwFlags |= (PFD_DRAW_TO_BITMAP | PFD_SUPPORT_GDI); /* supports software rendering to bitmap */
if (mode->stereoMode) {
pfd.dwFlags |= PFD_STEREO;
@@ -1880,7 +1879,9 @@ fbConfigToPixelFormat(__GLXconfig *mode, PIXELFORMATDESCRIPTOR *pfdret, int draw
pfd.dwVisibleMask = mode->transparentIndex;
}
- pfd.cAccumBits = mode->accumRedBits + mode->accumGreenBits + mode->accumBlueBits + mode->accumAlphaBits;
+ pfd.cAccumBits =
+ mode->accumRedBits + mode->accumGreenBits + mode->accumBlueBits +
+ mode->accumAlphaBits;
pfd.cAccumRedBits = mode->accumRedBits;
pfd.cAccumGreenBits = mode->accumGreenBits;
pfd.cAccumBlueBits = mode->accumBlueBits;
@@ -1901,94 +1902,98 @@ fbConfigToPixelFormat(__GLXconfig *mode, PIXELFORMATDESCRIPTOR *pfdret, int draw
#define SET_ATTR_VALUE(attr, value) { attribList[i++] = attr; attribList[i++] = value; assert(i < NUM_ELEMENTS(attribList)); }
static int
-fbConfigToPixelFormatIndex(HDC hdc, __GLXconfig *mode, int drawableTypeOverride, glxWinScreen *winScreen)
+fbConfigToPixelFormatIndex(HDC hdc, __GLXconfig * mode,
+ int drawableTypeOverride, glxWinScreen * winScreen)
{
- UINT numFormats;
- unsigned int i = 0;
-
- /* convert fbConfig to attr-value list */
- int attribList[60];
-
- SET_ATTR_VALUE(WGL_SUPPORT_OPENGL_ARB, TRUE);
- SET_ATTR_VALUE(WGL_PIXEL_TYPE_ARB, (mode->visualType == GLX_TRUE_COLOR) ? WGL_TYPE_RGBA_ARB : WGL_TYPE_COLORINDEX_ARB);
- SET_ATTR_VALUE(WGL_COLOR_BITS_ARB, (mode->visualType == GLX_TRUE_COLOR) ? mode->rgbBits : mode->indexBits);
- SET_ATTR_VALUE(WGL_RED_BITS_ARB, mode->redBits);
- SET_ATTR_VALUE(WGL_GREEN_BITS_ARB, mode->greenBits);
- SET_ATTR_VALUE(WGL_BLUE_BITS_ARB, mode->blueBits);
- SET_ATTR_VALUE(WGL_ALPHA_BITS_ARB, mode->alphaBits);
- SET_ATTR_VALUE(WGL_ACCUM_RED_BITS_ARB, mode->accumRedBits);
- SET_ATTR_VALUE(WGL_ACCUM_GREEN_BITS_ARB, mode->accumGreenBits);
- SET_ATTR_VALUE(WGL_ACCUM_BLUE_BITS_ARB, mode->accumBlueBits);
- SET_ATTR_VALUE(WGL_ACCUM_ALPHA_BITS_ARB, mode->accumAlphaBits);
- SET_ATTR_VALUE(WGL_DEPTH_BITS_ARB, mode->depthBits);
- SET_ATTR_VALUE(WGL_STENCIL_BITS_ARB, mode->stencilBits);
- SET_ATTR_VALUE(WGL_AUX_BUFFERS_ARB, mode->numAuxBuffers);
-
- if (mode->doubleBufferMode)
- SET_ATTR_VALUE(WGL_DOUBLE_BUFFER_ARB, TRUE);
-
- if (mode->stereoMode)
- SET_ATTR_VALUE(WGL_STEREO_ARB, TRUE);
-
- // Some attributes are only added to the list if the value requested is not 'don't care', as exactly matching that is daft..
- if (mode->swapMethod == GLX_SWAP_EXCHANGE_OML)
- SET_ATTR_VALUE(WGL_SWAP_METHOD_ARB, WGL_SWAP_EXCHANGE_ARB);
-
- if (mode->swapMethod == GLX_SWAP_COPY_OML)
- SET_ATTR_VALUE(WGL_SWAP_COPY_ARB, TRUE);
-
- // XXX: this should probably be the other way around, but that messes up drawableTypeOverride
- if (mode->visualRating == GLX_SLOW_VISUAL_EXT)
- SET_ATTR_VALUE(WGL_ACCELERATION_ARB, WGL_NO_ACCELERATION_ARB);
-
- // must support all the drawable types the mode supports
- if ((mode->drawableType | drawableTypeOverride) & GLX_WINDOW_BIT)
- SET_ATTR_VALUE(WGL_DRAW_TO_WINDOW_ARB,TRUE);
-
- // XXX: this is a horrible hacky heuristic, in fact this whole drawableTypeOverride thing is a bad idea
- // try to avoid asking for formats which don't exist (by not asking for all when adjusting the config to include the drawableTypeOverride)
- if (drawableTypeOverride == GLX_WINDOW_BIT)
- {
- if (mode->drawableType & GLX_PIXMAP_BIT)
- SET_ATTR_VALUE(WGL_DRAW_TO_BITMAP_ARB, TRUE);
+ UINT numFormats;
+ unsigned int i = 0;
+
+ /* convert fbConfig to attr-value list */
+ int attribList[60];
+
+ SET_ATTR_VALUE(WGL_SUPPORT_OPENGL_ARB, TRUE);
+ SET_ATTR_VALUE(WGL_PIXEL_TYPE_ARB,
+ (mode->visualType ==
+ GLX_TRUE_COLOR) ? WGL_TYPE_RGBA_ARB :
+ WGL_TYPE_COLORINDEX_ARB);
+ SET_ATTR_VALUE(WGL_COLOR_BITS_ARB,
+ (mode->visualType ==
+ GLX_TRUE_COLOR) ? mode->rgbBits : mode->indexBits);
+ SET_ATTR_VALUE(WGL_RED_BITS_ARB, mode->redBits);
+ SET_ATTR_VALUE(WGL_GREEN_BITS_ARB, mode->greenBits);
+ SET_ATTR_VALUE(WGL_BLUE_BITS_ARB, mode->blueBits);
+ SET_ATTR_VALUE(WGL_ALPHA_BITS_ARB, mode->alphaBits);
+ SET_ATTR_VALUE(WGL_ACCUM_RED_BITS_ARB, mode->accumRedBits);
+ SET_ATTR_VALUE(WGL_ACCUM_GREEN_BITS_ARB, mode->accumGreenBits);
+ SET_ATTR_VALUE(WGL_ACCUM_BLUE_BITS_ARB, mode->accumBlueBits);
+ SET_ATTR_VALUE(WGL_ACCUM_ALPHA_BITS_ARB, mode->accumAlphaBits);
+ SET_ATTR_VALUE(WGL_DEPTH_BITS_ARB, mode->depthBits);
+ SET_ATTR_VALUE(WGL_STENCIL_BITS_ARB, mode->stencilBits);
+ SET_ATTR_VALUE(WGL_AUX_BUFFERS_ARB, mode->numAuxBuffers);
+
+ if (mode->doubleBufferMode)
+ SET_ATTR_VALUE(WGL_DOUBLE_BUFFER_ARB, TRUE);
+
+ if (mode->stereoMode)
+ SET_ATTR_VALUE(WGL_STEREO_ARB, TRUE);
+
+ // Some attributes are only added to the list if the value requested is not 'don't care', as exactly matching that is daft..
+ if (mode->swapMethod == GLX_SWAP_EXCHANGE_OML)
+ SET_ATTR_VALUE(WGL_SWAP_METHOD_ARB, WGL_SWAP_EXCHANGE_ARB);
+
+ if (mode->swapMethod == GLX_SWAP_COPY_OML)
+ SET_ATTR_VALUE(WGL_SWAP_COPY_ARB, TRUE);
+
+ // XXX: this should probably be the other way around, but that messes up drawableTypeOverride
+ if (mode->visualRating == GLX_SLOW_VISUAL_EXT)
+ SET_ATTR_VALUE(WGL_ACCELERATION_ARB, WGL_NO_ACCELERATION_ARB);
+
+ // must support all the drawable types the mode supports
+ if ((mode->drawableType | drawableTypeOverride) & GLX_WINDOW_BIT)
+ SET_ATTR_VALUE(WGL_DRAW_TO_WINDOW_ARB, TRUE);
+
+ // XXX: this is a horrible hacky heuristic, in fact this whole drawableTypeOverride thing is a bad idea
+ // try to avoid asking for formats which don't exist (by not asking for all when adjusting the config to include the drawableTypeOverride)
+ if (drawableTypeOverride == GLX_WINDOW_BIT) {
+ if (mode->drawableType & GLX_PIXMAP_BIT)
+ SET_ATTR_VALUE(WGL_DRAW_TO_BITMAP_ARB, TRUE);
- if (mode->drawableType & GLX_PBUFFER_BIT)
- if (winScreen->has_WGL_ARB_pbuffer)
- SET_ATTR_VALUE(WGL_DRAW_TO_PBUFFER_ARB, TRUE);
+ if (mode->drawableType & GLX_PBUFFER_BIT)
+ if (winScreen->has_WGL_ARB_pbuffer)
+ SET_ATTR_VALUE(WGL_DRAW_TO_PBUFFER_ARB, TRUE);
}
- else
- {
- if (drawableTypeOverride & GLX_PIXMAP_BIT)
- SET_ATTR_VALUE(WGL_DRAW_TO_BITMAP_ARB, TRUE);
+ else {
+ if (drawableTypeOverride & GLX_PIXMAP_BIT)
+ SET_ATTR_VALUE(WGL_DRAW_TO_BITMAP_ARB, TRUE);
- if (drawableTypeOverride & GLX_PBUFFER_BIT)
- if (winScreen->has_WGL_ARB_pbuffer)
- SET_ATTR_VALUE(WGL_DRAW_TO_PBUFFER_ARB, TRUE);
+ if (drawableTypeOverride & GLX_PBUFFER_BIT)
+ if (winScreen->has_WGL_ARB_pbuffer)
+ SET_ATTR_VALUE(WGL_DRAW_TO_PBUFFER_ARB, TRUE);
}
- SET_ATTR_VALUE(0, 0); // terminator
+ SET_ATTR_VALUE(0, 0); // terminator
- /* choose the first match */
- {
- int pixelFormatIndex;
+ /* choose the first match */
+ {
+ int pixelFormatIndex;
- if (!wglChoosePixelFormatARBWrapper(hdc, attribList, NULL, 1, &pixelFormatIndex, &numFormats))
- {
- ErrorF("wglChoosePixelFormat error: %s\n", glxWinErrorMessage());
- }
- else
- {
- if (numFormats > 0)
- {
- GLWIN_DEBUG_MSG("wglChoosePixelFormat: chose pixelFormatIndex %d)", pixelFormatIndex);
- return pixelFormatIndex;
- }
- else
- ErrorF("wglChoosePixelFormat couldn't decide\n");
- }
- }
+ if (!wglChoosePixelFormatARBWrapper
+ (hdc, attribList, NULL, 1, &pixelFormatIndex, &numFormats)) {
+ ErrorF("wglChoosePixelFormat error: %s\n", glxWinErrorMessage());
+ }
+ else {
+ if (numFormats > 0) {
+ GLWIN_DEBUG_MSG
+ ("wglChoosePixelFormat: chose pixelFormatIndex %d)",
+ pixelFormatIndex);
+ return pixelFormatIndex;
+ }
+ else
+ ErrorF("wglChoosePixelFormat couldn't decide\n");
+ }
+ }
- return 0;
+ return 0;
}
/* ---------------------------------------------------------------------- */
@@ -1999,119 +2004,121 @@ fbConfigToPixelFormatIndex(HDC hdc, __GLXconfig *mode, int drawableTypeOverride,
// Create the GLXconfigs using DescribePixelFormat()
//
static void
-glxWinCreateConfigs(HDC hdc, glxWinScreen *screen)
+glxWinCreateConfigs(HDC hdc, glxWinScreen * screen)
{
- GLXWinConfig *c, *result, *prev = NULL;
- int numConfigs = 0;
- int i = 0;
- int n = 0;
- PIXELFORMATDESCRIPTOR pfd;
+ GLXWinConfig *c, *result, *prev = NULL;
+ int numConfigs = 0;
+ int i = 0;
+ int n = 0;
+ PIXELFORMATDESCRIPTOR pfd;
- GLWIN_DEBUG_MSG("glxWinCreateConfigs");
+ GLWIN_DEBUG_MSG("glxWinCreateConfigs");
- screen->base.numFBConfigs = 0;
- screen->base.fbconfigs = NULL;
+ screen->base.numFBConfigs = 0;
+ screen->base.fbconfigs = NULL;
- // get the number of pixelformats
- numConfigs = DescribePixelFormat(hdc, 1, sizeof(PIXELFORMATDESCRIPTOR), NULL);
- GLWIN_DEBUG_MSG("DescribePixelFormat says %d possible pixel formats", numConfigs);
+ // get the number of pixelformats
+ numConfigs =
+ DescribePixelFormat(hdc, 1, sizeof(PIXELFORMATDESCRIPTOR), NULL);
+ GLWIN_DEBUG_MSG("DescribePixelFormat says %d possible pixel formats",
+ numConfigs);
- /* alloc */
- result = malloc(sizeof(GLXWinConfig) * numConfigs);
+ /* alloc */
+ result = malloc(sizeof(GLXWinConfig) * numConfigs);
- if (NULL == result)
- {
- return;
+ if (NULL == result) {
+ return;
}
- memset(result, 0, sizeof(GLXWinConfig) * numConfigs);
- n = 0;
+ memset(result, 0, sizeof(GLXWinConfig) * numConfigs);
+ n = 0;
- /* fill in configs */
- for (i = 0; i < numConfigs; i++)
- {
- int rc;
+ /* fill in configs */
+ for (i = 0; i < numConfigs; i++) {
+ int rc;
- c = &(result[i]);
- c->base.next = NULL;
- c->pixelFormatIndex = i+1;
+ c = &(result[i]);
+ c->base.next = NULL;
+ c->pixelFormatIndex = i + 1;
- rc = DescribePixelFormat(hdc, i+1, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
+ rc = DescribePixelFormat(hdc, i + 1, sizeof(PIXELFORMATDESCRIPTOR),
+ &pfd);
- if (!rc)
- {
- ErrorF("DescribePixelFormat failed for index %d, error %s\n", i+1, glxWinErrorMessage());
- break;
+ if (!rc) {
+ ErrorF("DescribePixelFormat failed for index %d, error %s\n", i + 1,
+ glxWinErrorMessage());
+ break;
}
#ifdef _DEBUG
- if (glxWinDebugSettings.dumpPFD)
- pfdOut(&pfd);
+ if (glxWinDebugSettings.dumpPFD)
+ pfdOut(&pfd);
#endif
- if (!(pfd.dwFlags & (PFD_DRAW_TO_WINDOW | PFD_DRAW_TO_BITMAP)) || !(pfd.dwFlags & PFD_SUPPORT_OPENGL))
- {
- GLWIN_DEBUG_MSG("pixelFormat %d has unsuitable flags 0x%08lx, skipping", i+1, pfd.dwFlags);
- continue;
+ if (!(pfd.dwFlags & (PFD_DRAW_TO_WINDOW | PFD_DRAW_TO_BITMAP)) ||
+ !(pfd.dwFlags & PFD_SUPPORT_OPENGL)) {
+ GLWIN_DEBUG_MSG
+ ("pixelFormat %d has unsuitable flags 0x%08lx, skipping", i + 1,
+ pfd.dwFlags);
+ continue;
}
- c->base.doubleBufferMode = (pfd.dwFlags & PFD_DOUBLEBUFFER) ? GL_TRUE : GL_FALSE;
- c->base.stereoMode = (pfd.dwFlags & PFD_STEREO) ? GL_TRUE : GL_FALSE;
+ c->base.doubleBufferMode =
+ (pfd.dwFlags & PFD_DOUBLEBUFFER) ? GL_TRUE : GL_FALSE;
+ c->base.stereoMode = (pfd.dwFlags & PFD_STEREO) ? GL_TRUE : GL_FALSE;
- c->base.redBits = pfd.cRedBits;
- c->base.greenBits = pfd.cGreenBits;
- c->base.blueBits = pfd.cBlueBits;
- c->base.alphaBits = pfd.cAlphaBits;
+ c->base.redBits = pfd.cRedBits;
+ c->base.greenBits = pfd.cGreenBits;
+ c->base.blueBits = pfd.cBlueBits;
+ c->base.alphaBits = pfd.cAlphaBits;
- c->base.redMask = BITS_AND_SHIFT_TO_MASK(pfd.cRedBits, pfd.cRedShift);
- c->base.greenMask = BITS_AND_SHIFT_TO_MASK(pfd.cGreenBits, pfd.cGreenShift);
- c->base.blueMask = BITS_AND_SHIFT_TO_MASK(pfd.cBlueBits, pfd.cBlueShift);
- c->base.alphaMask = BITS_AND_SHIFT_TO_MASK(pfd.cAlphaBits, pfd.cAlphaShift);
+ c->base.redMask = BITS_AND_SHIFT_TO_MASK(pfd.cRedBits, pfd.cRedShift);
+ c->base.greenMask =
+ BITS_AND_SHIFT_TO_MASK(pfd.cGreenBits, pfd.cGreenShift);
+ c->base.blueMask =
+ BITS_AND_SHIFT_TO_MASK(pfd.cBlueBits, pfd.cBlueShift);
+ c->base.alphaMask =
+ BITS_AND_SHIFT_TO_MASK(pfd.cAlphaBits, pfd.cAlphaShift);
- c->base.rgbBits = pfd.cColorBits;
+ c->base.rgbBits = pfd.cColorBits;
- if (pfd.iPixelType == PFD_TYPE_COLORINDEX)
- {
- c->base.indexBits = pfd.cColorBits;
+ if (pfd.iPixelType == PFD_TYPE_COLORINDEX) {
+ c->base.indexBits = pfd.cColorBits;
}
- else
- {
- c->base.indexBits = 0;
+ else {
+ c->base.indexBits = 0;
}
- c->base.accumRedBits = pfd.cAccumRedBits;
- c->base.accumGreenBits = pfd.cAccumGreenBits;
- c->base.accumBlueBits = pfd.cAccumBlueBits;
- c->base.accumAlphaBits = pfd.cAccumAlphaBits;
- // pfd.cAccumBits;
+ c->base.accumRedBits = pfd.cAccumRedBits;
+ c->base.accumGreenBits = pfd.cAccumGreenBits;
+ c->base.accumBlueBits = pfd.cAccumBlueBits;
+ c->base.accumAlphaBits = pfd.cAccumAlphaBits;
+ // pfd.cAccumBits;
- c->base.depthBits = pfd.cDepthBits;
- c->base.stencilBits = pfd.cStencilBits;
- c->base.numAuxBuffers = pfd.cAuxBuffers;
+ c->base.depthBits = pfd.cDepthBits;
+ c->base.stencilBits = pfd.cStencilBits;
+ c->base.numAuxBuffers = pfd.cAuxBuffers;
- // pfd.iLayerType; // ignored
- c->base.level = 0;
- // pfd.dwLayerMask; // ignored
- // pfd.dwDamageMask; // ignored
+ // pfd.iLayerType; // ignored
+ c->base.level = 0;
+ // pfd.dwLayerMask; // ignored
+ // pfd.dwDamageMask; // ignored
- c->base.pixmapMode = 0;
- c->base.visualID = -1; // will be set by __glXScreenInit()
+ c->base.pixmapMode = 0;
+ c->base.visualID = -1; // will be set by __glXScreenInit()
- /* EXT_visual_rating / GLX 1.2 */
- if (pfd.dwFlags & PFD_GENERIC_FORMAT)
- {
- c->base.visualRating = GLX_SLOW_VISUAL_EXT;
+ /* EXT_visual_rating / GLX 1.2 */
+ if (pfd.dwFlags & PFD_GENERIC_FORMAT) {
+ c->base.visualRating = GLX_SLOW_VISUAL_EXT;
}
- else
- {
- // PFD_GENERIC_ACCELERATED is not considered, so this may be MCD or ICD acclerated...
- c->base.visualRating = GLX_NONE_EXT;
+ else {
+ // PFD_GENERIC_ACCELERATED is not considered, so this may be MCD or ICD acclerated...
+ c->base.visualRating = GLX_NONE_EXT;
}
- /* EXT_visual_info / GLX 1.2 */
- if (pfd.iPixelType == PFD_TYPE_COLORINDEX)
- {
- c->base.visualType = GLX_STATIC_COLOR;
+ /* EXT_visual_info / GLX 1.2 */
+ if (pfd.iPixelType == PFD_TYPE_COLORINDEX) {
+ c->base.visualType = GLX_STATIC_COLOR;
c->base.transparentRed = GLX_NONE;
c->base.transparentGreen = GLX_NONE;
c->base.transparentBlue = GLX_NONE;
@@ -2130,451 +2137,477 @@ glxWinCreateConfigs(HDC hdc, glxWinScreen *screen)
c->base.transparentPixel = GLX_TRANSPARENT_RGB;
}
- /* ARB_multisample / SGIS_multisample */
- c->base.sampleBuffers = 0;
- c->base.samples = 0;
+ /* ARB_multisample / SGIS_multisample */
+ c->base.sampleBuffers = 0;
+ c->base.samples = 0;
- /* SGIX_fbconfig / GLX 1.3 */
- c->base.drawableType = (((pfd.dwFlags & PFD_DRAW_TO_WINDOW) ? GLX_WINDOW_BIT : 0)
- | ((pfd.dwFlags & PFD_DRAW_TO_BITMAP) ? GLX_PIXMAP_BIT : 0));
+ /* SGIX_fbconfig / GLX 1.3 */
+ c->base.drawableType =
+ (((pfd.dwFlags & PFD_DRAW_TO_WINDOW) ? GLX_WINDOW_BIT : 0)
+ | ((pfd.dwFlags & PFD_DRAW_TO_BITMAP) ? GLX_PIXMAP_BIT : 0));
- if (pfd.iPixelType == PFD_TYPE_COLORINDEX)
- {
- c->base.renderType = GLX_RGBA_BIT | GLX_COLOR_INDEX_BIT;
+ if (pfd.iPixelType == PFD_TYPE_COLORINDEX) {
+ c->base.renderType = GLX_RGBA_BIT | GLX_COLOR_INDEX_BIT;
}
- else
- {
- c->base.renderType = GLX_RGBA_BIT;
+ else {
+ c->base.renderType = GLX_RGBA_BIT;
}
- c->base.xRenderable = GL_TRUE;
- c->base.fbconfigID = -1; // will be set by __glXScreenInit()
+ c->base.xRenderable = GL_TRUE;
+ c->base.fbconfigID = -1; // will be set by __glXScreenInit()
- /* SGIX_pbuffer / GLX 1.3 */
- // XXX: How can we find these values out ???
- c->base.maxPbufferWidth = -1;
- c->base.maxPbufferHeight = -1;
- c->base.maxPbufferPixels = -1;
- c->base.optimalPbufferWidth = 0; // there is no optimal value
- c->base.optimalPbufferHeight = 0;
+ /* SGIX_pbuffer / GLX 1.3 */
+ // XXX: How can we find these values out ???
+ c->base.maxPbufferWidth = -1;
+ c->base.maxPbufferHeight = -1;
+ c->base.maxPbufferPixels = -1;
+ c->base.optimalPbufferWidth = 0; // there is no optimal value
+ c->base.optimalPbufferHeight = 0;
- /* SGIX_visual_select_group */
- // arrange for visuals with the best acceleration to be preferred in selection
- switch (pfd.dwFlags & (PFD_GENERIC_FORMAT | PFD_GENERIC_ACCELERATED))
- {
+ /* SGIX_visual_select_group */
+ // arrange for visuals with the best acceleration to be preferred in selection
+ switch (pfd.dwFlags & (PFD_GENERIC_FORMAT | PFD_GENERIC_ACCELERATED)) {
case 0:
- c->base.visualSelectGroup = 2;
- break;
+ c->base.visualSelectGroup = 2;
+ break;
case PFD_GENERIC_ACCELERATED:
- c->base.visualSelectGroup = 1;
- break;
+ c->base.visualSelectGroup = 1;
+ break;
case PFD_GENERIC_FORMAT:
- c->base.visualSelectGroup = 0;
- break;
+ c->base.visualSelectGroup = 0;
+ break;
default:
- ;
- // "can't happen"
+ ;
+ // "can't happen"
}
- /* OML_swap_method */
- if (pfd.dwFlags & PFD_SWAP_EXCHANGE)
- c->base.swapMethod = GLX_SWAP_EXCHANGE_OML;
- else if (pfd.dwFlags & PFD_SWAP_COPY)
- c->base.swapMethod = GLX_SWAP_COPY_OML;
- else
- c->base.swapMethod = GLX_SWAP_UNDEFINED_OML;
+ /* OML_swap_method */
+ if (pfd.dwFlags & PFD_SWAP_EXCHANGE)
+ c->base.swapMethod = GLX_SWAP_EXCHANGE_OML;
+ else if (pfd.dwFlags & PFD_SWAP_COPY)
+ c->base.swapMethod = GLX_SWAP_COPY_OML;
+ else
+ c->base.swapMethod = GLX_SWAP_UNDEFINED_OML;
- /* EXT_import_context */
- c->base.screen = screen->base.pScreen->myNum;
+ /* EXT_import_context */
+ c->base.screen = screen->base.pScreen->myNum;
- /* EXT_texture_from_pixmap */
- c->base.bindToTextureRgb = -1;
- c->base.bindToTextureRgba = -1;
- c->base.bindToMipmapTexture = -1;
- c->base.bindToTextureTargets = -1;
- c->base.yInverted = -1;
+ /* EXT_texture_from_pixmap */
+ c->base.bindToTextureRgb = -1;
+ c->base.bindToTextureRgba = -1;
+ c->base.bindToMipmapTexture = -1;
+ c->base.bindToTextureTargets = -1;
+ c->base.yInverted = -1;
- n++;
+ n++;
- // update previous config to point to this config
- if (prev)
- prev->base.next = &(c->base);
+ // update previous config to point to this config
+ if (prev)
+ prev->base.next = &(c->base);
- prev = c;
+ prev = c;
}
- GLWIN_DEBUG_MSG("found %d pixelFormats suitable for conversion to fbConfigs", n);
+ GLWIN_DEBUG_MSG
+ ("found %d pixelFormats suitable for conversion to fbConfigs", n);
- screen->base.numFBConfigs = n;
- screen->base.fbconfigs = &(result->base);
+ screen->base.numFBConfigs = n;
+ screen->base.fbconfigs = &(result->base);
}
// helper function to access an attribute value from an attribute value array by attribute
static
-int getAttrValue(const int attrs[], int values[], unsigned int num, int attr, int fallback)
+ int
+getAttrValue(const int attrs[], int values[], unsigned int num, int attr,
+ int fallback)
{
- unsigned int i;
- for (i = 0; i < num; i++)
- {
- if (attrs[i] == attr)
- {
- GLWIN_TRACE_MSG("getAttrValue attr 0x%x, value %d", attr, values[i]);
- return values[i];
+ unsigned int i;
+
+ for (i = 0; i < num; i++) {
+ if (attrs[i] == attr) {
+ GLWIN_TRACE_MSG("getAttrValue attr 0x%x, value %d", attr,
+ values[i]);
+ return values[i];
}
}
- ErrorF("getAttrValue failed to find attr 0x%x, using default value %d\n", attr, fallback);
- return fallback;
+ ErrorF("getAttrValue failed to find attr 0x%x, using default value %d\n",
+ attr, fallback);
+ return fallback;
}
//
// Create the GLXconfigs using wglGetPixelFormatAttribfvARB() extension
//
static void
-glxWinCreateConfigsExt(HDC hdc, glxWinScreen *screen)
+glxWinCreateConfigsExt(HDC hdc, glxWinScreen * screen)
{
- GLXWinConfig *c, *result, *prev = NULL;
- int i = 0;
- int n = 0;
+ GLXWinConfig *c, *result, *prev = NULL;
+ int i = 0;
+ int n = 0;
- const int attr = WGL_NUMBER_PIXEL_FORMATS_ARB;
- int numConfigs;
+ const int attr = WGL_NUMBER_PIXEL_FORMATS_ARB;
+ int numConfigs;
- int attrs[50];
- unsigned int num_attrs = 0;
+ int attrs[50];
+ unsigned int num_attrs = 0;
- GLWIN_DEBUG_MSG("glxWinCreateConfigsExt");
+ GLWIN_DEBUG_MSG("glxWinCreateConfigsExt");
- screen->base.numFBConfigs = 0;
- screen->base.fbconfigs = NULL;
+ screen->base.numFBConfigs = 0;
+ screen->base.fbconfigs = NULL;
- if (!wglGetPixelFormatAttribivARBWrapper(hdc, 0, 0, 1, &attr, &numConfigs))
- {
- ErrorF("wglGetPixelFormatAttribivARB failed for WGL_NUMBER_PIXEL_FORMATS_ARB: %s\n", glxWinErrorMessage());
- return;
+ if (!wglGetPixelFormatAttribivARBWrapper(hdc, 0, 0, 1, &attr, &numConfigs)) {
+ ErrorF
+ ("wglGetPixelFormatAttribivARB failed for WGL_NUMBER_PIXEL_FORMATS_ARB: %s\n",
+ glxWinErrorMessage());
+ return;
}
- GLWIN_DEBUG_MSG("wglGetPixelFormatAttribivARB says %d possible pixel formats", numConfigs);
+ GLWIN_DEBUG_MSG
+ ("wglGetPixelFormatAttribivARB says %d possible pixel formats",
+ numConfigs);
- /* alloc */
- result = malloc(sizeof(GLXWinConfig) * numConfigs);
+ /* alloc */
+ result = malloc(sizeof(GLXWinConfig) * numConfigs);
- if (NULL == result)
- {
- return;
+ if (NULL == result) {
+ return;
}
- memset(result, 0, sizeof(GLXWinConfig) * numConfigs);
- n = 0;
+ memset(result, 0, sizeof(GLXWinConfig) * numConfigs);
+ n = 0;
#define ADD_ATTR(a) { attrs[num_attrs++] = a; assert(num_attrs < NUM_ELEMENTS(attrs)); }
- ADD_ATTR(WGL_DRAW_TO_WINDOW_ARB);
- ADD_ATTR(WGL_DRAW_TO_BITMAP_ARB);
- ADD_ATTR(WGL_ACCELERATION_ARB);
- ADD_ATTR(WGL_SWAP_LAYER_BUFFERS_ARB);
- ADD_ATTR(WGL_NUMBER_OVERLAYS_ARB);
- ADD_ATTR(WGL_NUMBER_UNDERLAYS_ARB);
- ADD_ATTR(WGL_TRANSPARENT_ARB);
- ADD_ATTR(WGL_TRANSPARENT_RED_VALUE_ARB);
- ADD_ATTR(WGL_TRANSPARENT_GREEN_VALUE_ARB);
- ADD_ATTR(WGL_TRANSPARENT_GREEN_VALUE_ARB);
- ADD_ATTR(WGL_TRANSPARENT_ALPHA_VALUE_ARB);
- ADD_ATTR(WGL_SUPPORT_OPENGL_ARB);
- ADD_ATTR(WGL_DOUBLE_BUFFER_ARB);
- ADD_ATTR(WGL_STEREO_ARB);
- ADD_ATTR(WGL_PIXEL_TYPE_ARB);
- ADD_ATTR(WGL_COLOR_BITS_ARB);
- ADD_ATTR(WGL_RED_BITS_ARB);
- ADD_ATTR(WGL_RED_SHIFT_ARB);
- ADD_ATTR(WGL_GREEN_BITS_ARB);
- ADD_ATTR(WGL_GREEN_SHIFT_ARB);
- ADD_ATTR(WGL_BLUE_BITS_ARB);
- ADD_ATTR(WGL_BLUE_SHIFT_ARB);
- ADD_ATTR(WGL_ALPHA_BITS_ARB);
- ADD_ATTR(WGL_ALPHA_SHIFT_ARB);
- ADD_ATTR(WGL_ACCUM_RED_BITS_ARB);
- ADD_ATTR(WGL_ACCUM_GREEN_BITS_ARB);
- ADD_ATTR(WGL_ACCUM_BLUE_BITS_ARB);
- ADD_ATTR(WGL_ACCUM_ALPHA_BITS_ARB);
- ADD_ATTR(WGL_DEPTH_BITS_ARB);
- ADD_ATTR(WGL_STENCIL_BITS_ARB);
- ADD_ATTR(WGL_AUX_BUFFERS_ARB);
- ADD_ATTR(WGL_SWAP_METHOD_ARB);
-
- if (screen->has_WGL_ARB_multisample)
- {
- // we may not query these attrs if WGL_ARB_multisample is not offered
- ADD_ATTR(WGL_SAMPLE_BUFFERS_ARB);
- ADD_ATTR(WGL_SAMPLES_ARB);
+ ADD_ATTR(WGL_DRAW_TO_WINDOW_ARB);
+ ADD_ATTR(WGL_DRAW_TO_BITMAP_ARB);
+ ADD_ATTR(WGL_ACCELERATION_ARB);
+ ADD_ATTR(WGL_SWAP_LAYER_BUFFERS_ARB);
+ ADD_ATTR(WGL_NUMBER_OVERLAYS_ARB);
+ ADD_ATTR(WGL_NUMBER_UNDERLAYS_ARB);
+ ADD_ATTR(WGL_TRANSPARENT_ARB);
+ ADD_ATTR(WGL_TRANSPARENT_RED_VALUE_ARB);
+ ADD_ATTR(WGL_TRANSPARENT_GREEN_VALUE_ARB);
+ ADD_ATTR(WGL_TRANSPARENT_GREEN_VALUE_ARB);
+ ADD_ATTR(WGL_TRANSPARENT_ALPHA_VALUE_ARB);
+ ADD_ATTR(WGL_SUPPORT_OPENGL_ARB);
+ ADD_ATTR(WGL_DOUBLE_BUFFER_ARB);
+ ADD_ATTR(WGL_STEREO_ARB);
+ ADD_ATTR(WGL_PIXEL_TYPE_ARB);
+ ADD_ATTR(WGL_COLOR_BITS_ARB);
+ ADD_ATTR(WGL_RED_BITS_ARB);
+ ADD_ATTR(WGL_RED_SHIFT_ARB);
+ ADD_ATTR(WGL_GREEN_BITS_ARB);
+ ADD_ATTR(WGL_GREEN_SHIFT_ARB);
+ ADD_ATTR(WGL_BLUE_BITS_ARB);
+ ADD_ATTR(WGL_BLUE_SHIFT_ARB);
+ ADD_ATTR(WGL_ALPHA_BITS_ARB);
+ ADD_ATTR(WGL_ALPHA_SHIFT_ARB);
+ ADD_ATTR(WGL_ACCUM_RED_BITS_ARB);
+ ADD_ATTR(WGL_ACCUM_GREEN_BITS_ARB);
+ ADD_ATTR(WGL_ACCUM_BLUE_BITS_ARB);
+ ADD_ATTR(WGL_ACCUM_ALPHA_BITS_ARB);
+ ADD_ATTR(WGL_DEPTH_BITS_ARB);
+ ADD_ATTR(WGL_STENCIL_BITS_ARB);
+ ADD_ATTR(WGL_AUX_BUFFERS_ARB);
+ ADD_ATTR(WGL_SWAP_METHOD_ARB);
+
+ if (screen->has_WGL_ARB_multisample) {
+ // we may not query these attrs if WGL_ARB_multisample is not offered
+ ADD_ATTR(WGL_SAMPLE_BUFFERS_ARB);
+ ADD_ATTR(WGL_SAMPLES_ARB);
}
- if (screen->has_WGL_ARB_render_texture)
- {
- // we may not query these attrs if WGL_ARB_render_texture is not offered
- ADD_ATTR(WGL_BIND_TO_TEXTURE_RGB_ARB);
- ADD_ATTR(WGL_BIND_TO_TEXTURE_RGBA_ARB);
+ if (screen->has_WGL_ARB_render_texture) {
+ // we may not query these attrs if WGL_ARB_render_texture is not offered
+ ADD_ATTR(WGL_BIND_TO_TEXTURE_RGB_ARB);
+ ADD_ATTR(WGL_BIND_TO_TEXTURE_RGBA_ARB);
}
- if (screen->has_WGL_ARB_pbuffer)
- {
- // we may not query these attrs if WGL_ARB_pbuffer is not offered
- ADD_ATTR(WGL_DRAW_TO_PBUFFER_ARB);
- ADD_ATTR(WGL_MAX_PBUFFER_PIXELS_ARB);
- ADD_ATTR(WGL_MAX_PBUFFER_WIDTH_ARB);
- ADD_ATTR(WGL_MAX_PBUFFER_HEIGHT_ARB);
+ if (screen->has_WGL_ARB_pbuffer) {
+ // we may not query these attrs if WGL_ARB_pbuffer is not offered
+ ADD_ATTR(WGL_DRAW_TO_PBUFFER_ARB);
+ ADD_ATTR(WGL_MAX_PBUFFER_PIXELS_ARB);
+ ADD_ATTR(WGL_MAX_PBUFFER_WIDTH_ARB);
+ ADD_ATTR(WGL_MAX_PBUFFER_HEIGHT_ARB);
}
- /* fill in configs */
- for (i = 0; i < numConfigs; i++)
- {
+ /* fill in configs */
+ for (i = 0; i < numConfigs; i++) {
int sizevalues=num_attrs*sizeof(int);
int *values=(int*)_alloca(sizevalues);
memset(values,0,sizevalues);
- c = &(result[i]);
- c->base.next = NULL;
- c->pixelFormatIndex = i+1;
+ c = &(result[i]);
+ c->base.next = NULL;
+ c->pixelFormatIndex = i + 1;
- if (!wglGetPixelFormatAttribivARBWrapper(hdc, i+1, 0, num_attrs, attrs, values))
- {
- ErrorF("wglGetPixelFormatAttribivARB failed for index %d, error %s\n", i+1, glxWinErrorMessage());
- break;
+ if (!wglGetPixelFormatAttribivARBWrapper
+ (hdc, i + 1, 0, num_attrs, attrs, values)) {
+ ErrorF
+ ("wglGetPixelFormatAttribivARB failed for index %d, error %s\n",
+ i + 1, glxWinErrorMessage());
+ break;
}
#define ATTR_VALUE(a, d) getAttrValue(attrs, values, num_attrs, (a), (d))
- if (!ATTR_VALUE(WGL_SUPPORT_OPENGL_ARB, 0))
- {
- GLWIN_DEBUG_MSG("pixelFormat %d isn't WGL_SUPPORT_OPENGL_ARB, skipping", i+1);
- continue;
+ if (!ATTR_VALUE(WGL_SUPPORT_OPENGL_ARB, 0)) {
+ GLWIN_DEBUG_MSG
+ ("pixelFormat %d isn't WGL_SUPPORT_OPENGL_ARB, skipping",
+ i + 1);
+ continue;
}
- c->base.doubleBufferMode = ATTR_VALUE(WGL_DOUBLE_BUFFER_ARB, 0) ? GL_TRUE : GL_FALSE;
- c->base.stereoMode = ATTR_VALUE(WGL_STEREO_ARB, 0) ? GL_TRUE : GL_FALSE;
-
- c->base.redBits = ATTR_VALUE(WGL_RED_BITS_ARB, 0);
- c->base.greenBits = ATTR_VALUE(WGL_GREEN_BITS_ARB, 0);
- c->base.blueBits = ATTR_VALUE(WGL_BLUE_BITS_ARB, 0);
- c->base.alphaBits = ATTR_VALUE(WGL_ALPHA_BITS_ARB, 0);
-
- c->base.redMask = BITS_AND_SHIFT_TO_MASK(c->base.redBits, ATTR_VALUE(WGL_RED_SHIFT_ARB, 0));
- c->base.greenMask = BITS_AND_SHIFT_TO_MASK(c->base.greenBits, ATTR_VALUE(WGL_GREEN_SHIFT_ARB, 0));
- c->base.blueMask = BITS_AND_SHIFT_TO_MASK(c->base.blueBits, ATTR_VALUE(WGL_BLUE_SHIFT_ARB, 0));
- c->base.alphaMask = BITS_AND_SHIFT_TO_MASK(c->base.alphaBits, ATTR_VALUE(WGL_ALPHA_SHIFT_ARB, 0));
-
- switch (ATTR_VALUE(WGL_PIXEL_TYPE_ARB, 0))
- {
+ c->base.doubleBufferMode =
+ ATTR_VALUE(WGL_DOUBLE_BUFFER_ARB, 0) ? GL_TRUE : GL_FALSE;
+ c->base.stereoMode = ATTR_VALUE(WGL_STEREO_ARB, 0) ? GL_TRUE : GL_FALSE;
+
+ c->base.redBits = ATTR_VALUE(WGL_RED_BITS_ARB, 0);
+ c->base.greenBits = ATTR_VALUE(WGL_GREEN_BITS_ARB, 0);
+ c->base.blueBits = ATTR_VALUE(WGL_BLUE_BITS_ARB, 0);
+ c->base.alphaBits = ATTR_VALUE(WGL_ALPHA_BITS_ARB, 0);
+
+ c->base.redMask =
+ BITS_AND_SHIFT_TO_MASK(c->base.redBits,
+ ATTR_VALUE(WGL_RED_SHIFT_ARB, 0));
+ c->base.greenMask =
+ BITS_AND_SHIFT_TO_MASK(c->base.greenBits,
+ ATTR_VALUE(WGL_GREEN_SHIFT_ARB, 0));
+ c->base.blueMask =
+ BITS_AND_SHIFT_TO_MASK(c->base.blueBits,
+ ATTR_VALUE(WGL_BLUE_SHIFT_ARB, 0));
+ c->base.alphaMask =
+ BITS_AND_SHIFT_TO_MASK(c->base.alphaBits,
+ ATTR_VALUE(WGL_ALPHA_SHIFT_ARB, 0));
+
+ switch (ATTR_VALUE(WGL_PIXEL_TYPE_ARB, 0)) {
case WGL_TYPE_COLORINDEX_ARB:
- c->base.indexBits = ATTR_VALUE(WGL_COLOR_BITS_ARB, 0);
- c->base.rgbBits = 0;
- c->base.visualType = GLX_STATIC_COLOR;
- break;
+ c->base.indexBits = ATTR_VALUE(WGL_COLOR_BITS_ARB, 0);
+ c->base.rgbBits = 0;
+ c->base.visualType = GLX_STATIC_COLOR;
+ break;
case WGL_TYPE_RGBA_FLOAT_ARB:
- GLWIN_DEBUG_MSG("pixelFormat %d is WGL_TYPE_RGBA_FLOAT_ARB, skipping", i+1);
- continue;
+ GLWIN_DEBUG_MSG
+ ("pixelFormat %d is WGL_TYPE_RGBA_FLOAT_ARB, skipping", i + 1);
+ continue;
case WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT:
- GLWIN_DEBUG_MSG("pixelFormat %d is WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT, skipping", i+1);
- continue;
+ GLWIN_DEBUG_MSG
+ ("pixelFormat %d is WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT, skipping",
+ i + 1);
+ continue;
case WGL_TYPE_RGBA_ARB:
- c->base.indexBits = 0;
- c->base.rgbBits = ATTR_VALUE(WGL_COLOR_BITS_ARB, 0);
- c->base.visualType = GLX_TRUE_COLOR;
- break;
+ c->base.indexBits = 0;
+ c->base.rgbBits = ATTR_VALUE(WGL_COLOR_BITS_ARB, 0);
+ c->base.visualType = GLX_TRUE_COLOR;
+ break;
default:
- ErrorF("wglGetPixelFormatAttribivARB returned unknown value 0x%x for WGL_PIXEL_TYPE_ARB\n", ATTR_VALUE(WGL_PIXEL_TYPE_ARB, 0));
- continue;
+ ErrorF
+ ("wglGetPixelFormatAttribivARB returned unknown value 0x%x for WGL_PIXEL_TYPE_ARB\n",
+ ATTR_VALUE(WGL_PIXEL_TYPE_ARB, 0));
+ continue;
}
- c->base.accumRedBits = ATTR_VALUE(WGL_ACCUM_RED_BITS_ARB, 0);
- c->base.accumGreenBits = ATTR_VALUE(WGL_ACCUM_GREEN_BITS_ARB, 0);
- c->base.accumBlueBits = ATTR_VALUE(WGL_ACCUM_BLUE_BITS_ARB, 0);
- c->base.accumAlphaBits = ATTR_VALUE(WGL_ACCUM_ALPHA_BITS_ARB, 0);
-
- c->base.depthBits = ATTR_VALUE(WGL_DEPTH_BITS_ARB, 0);
- c->base.stencilBits = ATTR_VALUE(WGL_STENCIL_BITS_ARB, 0);
- c->base.numAuxBuffers = ATTR_VALUE(WGL_AUX_BUFFERS_ARB, 0);
+ c->base.accumRedBits = ATTR_VALUE(WGL_ACCUM_RED_BITS_ARB, 0);
+ c->base.accumGreenBits = ATTR_VALUE(WGL_ACCUM_GREEN_BITS_ARB, 0);
+ c->base.accumBlueBits = ATTR_VALUE(WGL_ACCUM_BLUE_BITS_ARB, 0);
+ c->base.accumAlphaBits = ATTR_VALUE(WGL_ACCUM_ALPHA_BITS_ARB, 0);
- {
- int layers = ATTR_VALUE(WGL_NUMBER_OVERLAYS_ARB,0) + ATTR_VALUE(WGL_NUMBER_UNDERLAYS_ARB, 0);
+ c->base.depthBits = ATTR_VALUE(WGL_DEPTH_BITS_ARB, 0);
+ c->base.stencilBits = ATTR_VALUE(WGL_STENCIL_BITS_ARB, 0);
+ c->base.numAuxBuffers = ATTR_VALUE(WGL_AUX_BUFFERS_ARB, 0);
- if (layers > 0)
- {
- ErrorF("pixelFormat %d: has %d overlay, %d underlays which aren't currently handled", i, ATTR_VALUE(WGL_NUMBER_OVERLAYS_ARB,0), ATTR_VALUE(WGL_NUMBER_UNDERLAYS_ARB, 0));
- // XXX: need to iterate over layers?
- }
- }
- c->base.level = 0;
+ {
+ int layers =
+ ATTR_VALUE(WGL_NUMBER_OVERLAYS_ARB,
+ 0) + ATTR_VALUE(WGL_NUMBER_UNDERLAYS_ARB, 0);
+
+ if (layers > 0) {
+ ErrorF
+ ("pixelFormat %d: has %d overlay, %d underlays which aren't currently handled",
+ i, ATTR_VALUE(WGL_NUMBER_OVERLAYS_ARB, 0),
+ ATTR_VALUE(WGL_NUMBER_UNDERLAYS_ARB, 0));
+ // XXX: need to iterate over layers?
+ }
+ }
+ c->base.level = 0;
- c->base.pixmapMode = 0; // ???
- c->base.visualID = -1; // will be set by __glXScreenInit()
+ c->base.pixmapMode = 0; // ???
+ c->base.visualID = -1; // will be set by __glXScreenInit()
- /* EXT_visual_rating / GLX 1.2 */
- switch (ATTR_VALUE(WGL_ACCELERATION_ARB, 0))
- {
+ /* EXT_visual_rating / GLX 1.2 */
+ switch (ATTR_VALUE(WGL_ACCELERATION_ARB, 0)) {
default:
- ErrorF("wglGetPixelFormatAttribivARB returned unknown value 0x%x for WGL_ACCELERATION_ARB\n", ATTR_VALUE(WGL_ACCELERATION_ARB, 0));
+ ErrorF
+ ("wglGetPixelFormatAttribivARB returned unknown value 0x%x for WGL_ACCELERATION_ARB\n",
+ ATTR_VALUE(WGL_ACCELERATION_ARB, 0));
case WGL_NO_ACCELERATION_ARB:
- c->base.visualRating = GLX_SLOW_VISUAL_EXT;
- break;
+ c->base.visualRating = GLX_SLOW_VISUAL_EXT;
+ break;
case WGL_GENERIC_ACCELERATION_ARB:
case WGL_FULL_ACCELERATION_ARB:
- c->base.visualRating = GLX_NONE_EXT;
- break;
+ c->base.visualRating = GLX_NONE_EXT;
+ break;
}
- /* EXT_visual_info / GLX 1.2 */
- // c->base.visualType is set above
- if (ATTR_VALUE(WGL_TRANSPARENT_ARB, 0))
- {
- c->base.transparentPixel = (c->base.visualType == GLX_TRUE_COLOR) ? GLX_TRANSPARENT_RGB_EXT : GLX_TRANSPARENT_INDEX_EXT;
- c->base.transparentRed = ATTR_VALUE(WGL_TRANSPARENT_RED_VALUE_ARB, 0);
- c->base.transparentGreen = ATTR_VALUE(WGL_TRANSPARENT_GREEN_VALUE_ARB, 0);
- c->base.transparentBlue = ATTR_VALUE(WGL_TRANSPARENT_BLUE_VALUE_ARB, 0);
- c->base.transparentAlpha = ATTR_VALUE(WGL_TRANSPARENT_ALPHA_VALUE_ARB, 0);
- c->base.transparentIndex = ATTR_VALUE(WGL_TRANSPARENT_INDEX_VALUE_ARB, 0);
+ /* EXT_visual_info / GLX 1.2 */
+ // c->base.visualType is set above
+ if (ATTR_VALUE(WGL_TRANSPARENT_ARB, 0)) {
+ c->base.transparentPixel =
+ (c->base.visualType ==
+ GLX_TRUE_COLOR) ? GLX_TRANSPARENT_RGB_EXT :
+ GLX_TRANSPARENT_INDEX_EXT;
+ c->base.transparentRed =
+ ATTR_VALUE(WGL_TRANSPARENT_RED_VALUE_ARB, 0);
+ c->base.transparentGreen =
+ ATTR_VALUE(WGL_TRANSPARENT_GREEN_VALUE_ARB, 0);
+ c->base.transparentBlue =
+ ATTR_VALUE(WGL_TRANSPARENT_BLUE_VALUE_ARB, 0);
+ c->base.transparentAlpha =
+ ATTR_VALUE(WGL_TRANSPARENT_ALPHA_VALUE_ARB, 0);
+ c->base.transparentIndex =
+ ATTR_VALUE(WGL_TRANSPARENT_INDEX_VALUE_ARB, 0);
}
- else
- {
- c->base.transparentPixel = GLX_NONE_EXT;
- c->base.transparentRed = GLX_NONE;
- c->base.transparentGreen = GLX_NONE;
- c->base.transparentBlue = GLX_NONE;
- c->base.transparentAlpha = GLX_NONE;
- c->base.transparentIndex = GLX_NONE;
+ else {
+ c->base.transparentPixel = GLX_NONE_EXT;
+ c->base.transparentRed = GLX_NONE;
+ c->base.transparentGreen = GLX_NONE;
+ c->base.transparentBlue = GLX_NONE;
+ c->base.transparentAlpha = GLX_NONE;
+ c->base.transparentIndex = GLX_NONE;
}
- /* ARB_multisample / SGIS_multisample */
- if (screen->has_WGL_ARB_multisample)
- {
- c->base.sampleBuffers = ATTR_VALUE(WGL_SAMPLE_BUFFERS_ARB, 0);
- c->base.samples = ATTR_VALUE(WGL_SAMPLES_ARB, 0);
+ /* ARB_multisample / SGIS_multisample */
+ if (screen->has_WGL_ARB_multisample) {
+ c->base.sampleBuffers = ATTR_VALUE(WGL_SAMPLE_BUFFERS_ARB, 0);
+ c->base.samples = ATTR_VALUE(WGL_SAMPLES_ARB, 0);
}
- else
- {
- c->base.sampleBuffers = 0;
- c->base.samples = 0;
+ else {
+ c->base.sampleBuffers = 0;
+ c->base.samples = 0;
}
- /* SGIX_fbconfig / GLX 1.3 */
- c->base.drawableType = ((ATTR_VALUE(WGL_DRAW_TO_WINDOW_ARB, 0) ? GLX_WINDOW_BIT : 0)
- | (ATTR_VALUE(WGL_DRAW_TO_BITMAP_ARB, 0) ? GLX_PIXMAP_BIT : 0)
- | (ATTR_VALUE(WGL_DRAW_TO_PBUFFER_ARB, 0) ? GLX_PBUFFER_BIT : 0));
-
- /*
- Assume OpenGL RGBA rendering is available on all visuals
- (it is specified to render to red component in single-channel visuals,
- if supported, but there doesn't seem to be any mechanism to check if it
- is supported)
-
- Color index rendering is only supported on single-channel visuals
- */
- if (c->base.visualType == GLX_STATIC_COLOR)
- {
- c->base.renderType = GLX_RGBA_BIT | GLX_COLOR_INDEX_BIT;
+ /* SGIX_fbconfig / GLX 1.3 */
+ c->base.drawableType =
+ ((ATTR_VALUE(WGL_DRAW_TO_WINDOW_ARB, 0) ? GLX_WINDOW_BIT : 0)
+ | (ATTR_VALUE(WGL_DRAW_TO_BITMAP_ARB, 0) ? GLX_PIXMAP_BIT : 0)
+ | (ATTR_VALUE(WGL_DRAW_TO_PBUFFER_ARB, 0) ? GLX_PBUFFER_BIT : 0));
+
+ /*
+ Assume OpenGL RGBA rendering is available on all visuals
+ (it is specified to render to red component in single-channel visuals,
+ if supported, but there doesn't seem to be any mechanism to check if it
+ is supported)
+
+ Color index rendering is only supported on single-channel visuals
+ */
+ if (c->base.visualType == GLX_STATIC_COLOR) {
+ c->base.renderType = GLX_RGBA_BIT | GLX_COLOR_INDEX_BIT;
}
- else
- {
- c->base.renderType = GLX_RGBA_BIT;
+ else {
+ c->base.renderType = GLX_RGBA_BIT;
}
- c->base.xRenderable = GL_TRUE;
- c->base.fbconfigID = -1; // will be set by __glXScreenInit()
+ c->base.xRenderable = GL_TRUE;
+ c->base.fbconfigID = -1; // will be set by __glXScreenInit()
- /* SGIX_pbuffer / GLX 1.3 */
- if (screen->has_WGL_ARB_pbuffer)
- {
- c->base.maxPbufferWidth = ATTR_VALUE(WGL_MAX_PBUFFER_WIDTH_ARB, -1);
- c->base.maxPbufferHeight = ATTR_VALUE(WGL_MAX_PBUFFER_HEIGHT_ARB, -1);
- c->base.maxPbufferPixels = ATTR_VALUE(WGL_MAX_PBUFFER_PIXELS_ARB, -1);
+ /* SGIX_pbuffer / GLX 1.3 */
+ if (screen->has_WGL_ARB_pbuffer) {
+ c->base.maxPbufferWidth = ATTR_VALUE(WGL_MAX_PBUFFER_WIDTH_ARB, -1);
+ c->base.maxPbufferHeight =
+ ATTR_VALUE(WGL_MAX_PBUFFER_HEIGHT_ARB, -1);
+ c->base.maxPbufferPixels =
+ ATTR_VALUE(WGL_MAX_PBUFFER_PIXELS_ARB, -1);
}
- else
- {
- c->base.maxPbufferWidth = -1;
- c->base.maxPbufferHeight = -1;
- c->base.maxPbufferPixels = -1;
+ else {
+ c->base.maxPbufferWidth = -1;
+ c->base.maxPbufferHeight = -1;
+ c->base.maxPbufferPixels = -1;
}
- c->base.optimalPbufferWidth = 0; // there is no optimal value
- c->base.optimalPbufferHeight = 0;
+ c->base.optimalPbufferWidth = 0; // there is no optimal value
+ c->base.optimalPbufferHeight = 0;
- /* SGIX_visual_select_group */
- // arrange for visuals with the best acceleration to be preferred in selection
- switch (ATTR_VALUE(WGL_ACCELERATION_ARB, 0))
- {
+ /* SGIX_visual_select_group */
+ // arrange for visuals with the best acceleration to be preferred in selection
+ switch (ATTR_VALUE(WGL_ACCELERATION_ARB, 0)) {
case WGL_FULL_ACCELERATION_ARB:
- c->base.visualSelectGroup = 2;
- break;
+ c->base.visualSelectGroup = 2;
+ break;
case WGL_GENERIC_ACCELERATION_ARB:
- c->base.visualSelectGroup = 1;
- break;
+ c->base.visualSelectGroup = 1;
+ break;
default:
case WGL_NO_ACCELERATION_ARB:
- c->base.visualSelectGroup = 0;
- break;
+ c->base.visualSelectGroup = 0;
+ break;
}
- /* OML_swap_method */
- switch (ATTR_VALUE(WGL_SWAP_METHOD_ARB, 0))
- {
+ /* OML_swap_method */
+ switch (ATTR_VALUE(WGL_SWAP_METHOD_ARB, 0)) {
case WGL_SWAP_EXCHANGE_ARB:
- c->base.swapMethod = GLX_SWAP_EXCHANGE_OML;
- break;
+ c->base.swapMethod = GLX_SWAP_EXCHANGE_OML;
+ break;
case WGL_SWAP_COPY_ARB:
- c->base.swapMethod = GLX_SWAP_COPY_OML;
- break;
+ c->base.swapMethod = GLX_SWAP_COPY_OML;
+ break;
default:
- ErrorF("wglGetPixelFormatAttribivARB returned unknown value 0x%x for WGL_SWAP_METHOD_ARB\n", ATTR_VALUE(WGL_SWAP_METHOD_ARB, 0));
+ ErrorF
+ ("wglGetPixelFormatAttribivARB returned unknown value 0x%x for WGL_SWAP_METHOD_ARB\n",
+ ATTR_VALUE(WGL_SWAP_METHOD_ARB, 0));
case WGL_SWAP_UNDEFINED_ARB:
- c->base.swapMethod = GLX_SWAP_UNDEFINED_OML;
+ c->base.swapMethod = GLX_SWAP_UNDEFINED_OML;
}
- /* EXT_import_context */
- c->base.screen = screen->base.pScreen->myNum;
-
- /* EXT_texture_from_pixmap */
- /*
- Mesa's DRI configs always have bindToTextureRgb/Rgba TRUE (see driCreateConfigs(), so setting
- bindToTextureRgb/bindToTextureRgba to FALSE means that swrast can't find any fbConfigs to use,
- so setting these to 0, even if we know bindToTexture isn't available, isn't a good idea...
- */
- if (screen->has_WGL_ARB_render_texture)
- {
- c->base.bindToTextureRgb = ATTR_VALUE(WGL_BIND_TO_TEXTURE_RGB_ARB, -1);
- c->base.bindToTextureRgba = ATTR_VALUE(WGL_BIND_TO_TEXTURE_RGBA_ARB, -1);
+ /* EXT_import_context */
+ c->base.screen = screen->base.pScreen->myNum;
+
+ /* EXT_texture_from_pixmap */
+ /*
+ Mesa's DRI configs always have bindToTextureRgb/Rgba TRUE (see driCreateConfigs(), so setting
+ bindToTextureRgb/bindToTextureRgba to FALSE means that swrast can't find any fbConfigs to use,
+ so setting these to 0, even if we know bindToTexture isn't available, isn't a good idea...
+ */
+ if (screen->has_WGL_ARB_render_texture) {
+ c->base.bindToTextureRgb =
+ ATTR_VALUE(WGL_BIND_TO_TEXTURE_RGB_ARB, -1);
+ c->base.bindToTextureRgba =
+ ATTR_VALUE(WGL_BIND_TO_TEXTURE_RGBA_ARB, -1);
}
- else
- {
- c->base.bindToTextureRgb = -1;
- c->base.bindToTextureRgba = -1;
+ else {
+ c->base.bindToTextureRgb = -1;
+ c->base.bindToTextureRgba = -1;
}
- c->base.bindToMipmapTexture = -1;
- c->base.bindToTextureTargets = GLX_TEXTURE_1D_BIT_EXT | GLX_TEXTURE_2D_BIT_EXT | GLX_TEXTURE_RECTANGLE_BIT_EXT;
- c->base.yInverted = -1;
+ c->base.bindToMipmapTexture = -1;
+ c->base.bindToTextureTargets =
+ GLX_TEXTURE_1D_BIT_EXT | GLX_TEXTURE_2D_BIT_EXT |
+ GLX_TEXTURE_RECTANGLE_BIT_EXT;
+ c->base.yInverted = -1;
- n++;
+ n++;
- // update previous config to point to this config
- if (prev)
- prev->base.next = &(c->base);
+ // update previous config to point to this config
+ if (prev)
+ prev->base.next = &(c->base);
- prev = c;
+ prev = c;
}
- screen->base.numFBConfigs = n;
- screen->base.fbconfigs = &(result->base);
+ screen->base.numFBConfigs = n;
+ screen->base.fbconfigs = &(result->base);
}
diff --git a/xorg-server/hw/xwin/glx/wgl_ext_api.h b/xorg-server/hw/xwin/glx/wgl_ext_api.h
index 0edc6e6ed..63b1d7ef1 100644
--- a/xorg-server/hw/xwin/glx/wgl_ext_api.h
+++ b/xorg-server/hw/xwin/glx/wgl_ext_api.h
@@ -1,87 +1,83 @@
-/*
- * File: wgl_ext_api.h
- * Purpose: Wrapper functions for Win32 OpenGL wgl extension functions
- *
- * Authors: Jon TURNEY
- *
- * Copyright (c) Jon TURNEY 2009
- *
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-#ifndef wgl_ext_api_h
-#define wgl_ext_api_h
-
-#include "wglext.h"
-
-void wglResolveExtensionProcs(void);
-
-/*
- Prototypes for wrapper functions we actually use
- XXX: should be automatically generated as well
-*/
-
-const char * __stdcall wglGetExtensionsStringARBWrapper(HDC hdc);
-BOOL __stdcall wglMakeContextCurrentARBWrapper(HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
-HDC __stdcall wglGetCurrentReadDCARBWrapper(VOID);
-
-BOOL __stdcall wglGetPixelFormatAttribivARBWrapper(HDC hdc,
- int iPixelFormat,
- int iLayerPlane,
- UINT nAttributes,
- const int *piAttributes,
- int *piValues);
-
-BOOL __stdcall wglGetPixelFormatAttribfvARBWrapper(HDC hdc,
- int iPixelFormat,
- int iLayerPlane,
- UINT nAttributes,
- const int *piAttributes,
- FLOAT *pfValues);
-
-BOOL __stdcall wglChoosePixelFormatARBWrapper(HDC hdc,
- const int *piAttribIList,
- const FLOAT *pfAttribFList,
- UINT nMaxFormats,
- int *piFormats,
- UINT *nNumFormats);
-
-HPBUFFERARB __stdcall wglCreatePbufferARBWrapper(HDC hDC,
- int iPixelFormat,
- int iWidth,
- int iHeight,
- const int *piAttribList);
-
-HDC __stdcall wglGetPbufferDCARBWrapper(HPBUFFERARB hPbuffer);
-
-int __stdcall wglReleasePbufferDCARBWrapper(HPBUFFERARB hPbuffer,
- HDC hDC);
-
-BOOL __stdcall wglDestroyPbufferARBWrapper(HPBUFFERARB hPbuffer);
-
-BOOL __stdcall wglQueryPbufferARBWrapper(HPBUFFERARB hPbuffer,
- int iAttribute,
- int *piValue);
-
-BOOL __stdcall wglSwapIntervalEXTWrapper(int interval);
-
-int __stdcall wglGetSwapIntervalEXTWrapper(void);
-
-#endif /* wgl_ext_api_h */
+/*
+ * File: wgl_ext_api.h
+ * Purpose: Wrapper functions for Win32 OpenGL wgl extension functions
+ *
+ * Authors: Jon TURNEY
+ *
+ * Copyright (c) Jon TURNEY 2009
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef wgl_ext_api_h
+#define wgl_ext_api_h
+
+#include "wglext.h"
+
+void wglResolveExtensionProcs(void);
+
+/*
+ Prototypes for wrapper functions we actually use
+ XXX: should be automatically generated as well
+*/
+
+const char * __stdcall wglGetExtensionsStringARBWrapper(HDC hdc);
+BOOL __stdcall wglMakeContextCurrentARBWrapper(HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
+HDC __stdcall wglGetCurrentReadDCARBWrapper(VOID);
+
+BOOL __stdcall wglGetPixelFormatAttribivARBWrapper(HDC hdc,
+ int iPixelFormat,
+ int iLayerPlane,
+ UINT nAttributes,
+ const int *piAttributes,
+ int *piValues);
+
+BOOL __stdcall wglGetPixelFormatAttribfvARBWrapper(HDC hdc,
+ int iPixelFormat,
+ int iLayerPlane,
+ UINT nAttributes,
+ const int *piAttributes,
+ FLOAT * pfValues);
+
+BOOL __stdcall wglChoosePixelFormatARBWrapper(HDC hdc,
+ const int *piAttribIList,
+ const FLOAT * pfAttribFList,
+ UINT nMaxFormats,
+ int *piFormats, UINT * nNumFormats);
+
+HPBUFFERARB __stdcall wglCreatePbufferARBWrapper(HDC hDC,
+ int iPixelFormat,
+ int iWidth,
+ int iHeight, const int *piAttribList);
+
+HDC __stdcall wglGetPbufferDCARBWrapper(HPBUFFERARB hPbuffer);
+
+int __stdcall wglReleasePbufferDCARBWrapper(HPBUFFERARB hPbuffer, HDC hDC);
+
+BOOL __stdcall wglDestroyPbufferARBWrapper(HPBUFFERARB hPbuffer);
+
+BOOL __stdcall wglQueryPbufferARBWrapper(HPBUFFERARB hPbuffer,
+ int iAttribute, int *piValue);
+
+BOOL __stdcall wglSwapIntervalEXTWrapper(int interval);
+
+int __stdcall wglGetSwapIntervalEXTWrapper(void);
+
+#endif /* wgl_ext_api_h */
diff --git a/xorg-server/hw/xwin/glx/winpriv.c b/xorg-server/hw/xwin/glx/winpriv.c
index 4badb5320..4f2bc21a8 100644
--- a/xorg-server/hw/xwin/glx/winpriv.c
+++ b/xorg-server/hw/xwin/glx/winpriv.c
@@ -14,26 +14,26 @@
extern Bool g_fXdmcpEnabled;
void
-winCreateWindowsWindow (WindowPtr pWin);
+ winCreateWindowsWindow(WindowPtr pWin);
+
/**
* Return size and handles of a window.
* If pWin is NULL, then the information for the root window is requested.
*/
-HWND winGetWindowInfo(WindowPtr pWin)
+HWND
+winGetWindowInfo(WindowPtr pWin)
{
HWND hwnd = NULL;
winDebug("%s:%d pWin %p XID 0x%x\n", __FUNCTION__, __LINE__, pWin, pWin->drawable.id);
/* a real window was requested */
- if (pWin != NULL)
- {
+ if (pWin != NULL) {
/* Get the window and screen privates */
ScreenPtr pScreen = pWin->drawable.pScreen;
winPrivScreenPtr pWinScreen = winGetScreenPriv(pScreen);
winScreenInfoPtr pScreenInfo = NULL;
- if (pWinScreen == NULL)
- {
+ if (pWinScreen == NULL) {
ErrorF("winGetWindowInfo: screen has no privates\n");
return hwnd;
}
@@ -43,18 +43,15 @@ HWND winGetWindowInfo(WindowPtr pWin)
pScreenInfo = pWinScreen->pScreenInfo;
#ifdef XWIN_MULTIWINDOW
/* check for multiwindow mode */
- if (pScreenInfo->fMultiWindow)
- {
+ if (pScreenInfo->fMultiWindow) {
winWindowPriv(pWin);
- if (pWinPriv == NULL)
- {
+ if (pWinPriv == NULL) {
ErrorF("winGetWindowInfo: window has no privates\n");
return hwnd;
}
- if (pWinPriv->hWnd == NULL)
- {
+ if (pWinPriv->hWnd == NULL) {
if (pWin->parent && pWin->parent->parent)
{
int offsetx;
@@ -103,8 +100,7 @@ HWND winGetWindowInfo(WindowPtr pWin)
winDebug("winGetWindowInfo: forcing window to exist...\n");
}
}
- if (pWinPriv->hWnd != NULL)
- {
+ if (pWinPriv->hWnd != NULL) {
/* copy window handle */
hwnd = pWinPriv->hWnd;
}
@@ -157,30 +153,26 @@ HWND winGetWindowInfo(WindowPtr pWin)
#endif
#ifdef XWIN_MULTIWINDOWEXTWM
/* check for multiwindow external wm mode */
- if (pScreenInfo->fMWExtWM)
- {
+ if (pScreenInfo->fMWExtWM) {
win32RootlessWindowPtr pRLWinPriv
- = (win32RootlessWindowPtr) RootlessFrameForWindow (pWin, FALSE);
+ = (win32RootlessWindowPtr) RootlessFrameForWindow(pWin, FALSE);
if (pRLWinPriv == NULL) {
ErrorF("winGetWindowInfo: window has no privates\n");
}
- if (pRLWinPriv->hWnd != NULL)
- {
+ if (pRLWinPriv->hWnd != NULL) {
/* copy window handle */
hwnd = pRLWinPriv->hWnd;
}
}
#endif
}
- else
- {
+ else {
ScreenPtr pScreen = g_ScreenInfo[0].pScreen;
winPrivScreenPtr pWinScreen = winGetScreenPriv(pScreen);
- if (pWinScreen == NULL)
- {
+ if (pWinScreen == NULL) {
ErrorF("winGetWindowInfo: screen has no privates\n");
}
else
@@ -197,21 +189,21 @@ HWND winGetWindowInfo(WindowPtr pWin)
Bool
winCheckScreenAiglxIsSupported(ScreenPtr pScreen)
{
- winPrivScreenPtr pWinScreen = winGetScreenPriv(pScreen);
- winScreenInfoPtr pScreenInfo = pWinScreen->pScreenInfo;
+ winPrivScreenPtr pWinScreen = winGetScreenPriv(pScreen);
+ winScreenInfoPtr pScreenInfo = pWinScreen->pScreenInfo;
#ifdef XWIN_MULTIWINDOW
- if (pScreenInfo->fMultiWindow)
- return TRUE;
+ if (pScreenInfo->fMultiWindow)
+ return TRUE;
#endif
#ifdef XWIN_MULTIWINDOWEXTWM
- if (pScreenInfo->fMWExtWM)
- return TRUE;
+ if (pScreenInfo->fMWExtWM)
+ return TRUE;
#endif
if (g_fXdmcpEnabled)
return TRUE;
- return FALSE;
+ return FALSE;
}
diff --git a/xorg-server/hw/xwin/win.h b/xorg-server/hw/xwin/win.h
index aa01d6ed1..8c7df4cac 100644
--- a/xorg-server/hw/xwin/win.h
+++ b/xorg-server/hw/xwin/win.h
@@ -44,21 +44,20 @@
/* WM_XBUTTON Messages. They should go into w32api. */
#ifndef WM_XBUTTONDOWN
-# define WM_XBUTTONDOWN 523
+#define WM_XBUTTONDOWN 523
#endif
#ifndef WM_XBUTTONUP
-# define WM_XBUTTONUP 524
+#define WM_XBUTTONUP 524
#endif
#ifndef WM_XBUTTONDBLCLK
-# define WM_XBUTTONDBLCLK 525
+#define WM_XBUTTONDBLCLK 525
#endif
-
#define WIN_DEFAULT_BPP 0
#define WIN_DEFAULT_WHITEPIXEL 255
#define WIN_DEFAULT_BLACKPIXEL 0
#define WIN_DEFAULT_LINEBIAS 0
-#define WIN_DEFAULT_E3B_TIME 50 /* milliseconds */
+#define WIN_DEFAULT_E3B_TIME 50 /* milliseconds */
#define WIN_DEFAULT_DPI 96
#define WIN_DEFAULT_REFRESH 0
#define WIN_DEFAULT_WIN_KILL TRUE
@@ -101,15 +100,15 @@
#define WIN_FD_INVALID -1
-#define WIN_SERVER_NONE 0x0L /* 0 */
-#define WIN_SERVER_SHADOW_GDI 0x1L /* 1 */
-#define WIN_SERVER_SHADOW_DD 0x2L /* 2 */
-#define WIN_SERVER_SHADOW_DDNL 0x4L /* 4 */
+#define WIN_SERVER_NONE 0x0L /* 0 */
+#define WIN_SERVER_SHADOW_GDI 0x1L /* 1 */
+#define WIN_SERVER_SHADOW_DD 0x2L /* 2 */
+#define WIN_SERVER_SHADOW_DDNL 0x4L /* 4 */
#ifdef XWIN_PRIMARYFB
-#define WIN_SERVER_PRIMARY_DD 0x8L /* 8 */
+#define WIN_SERVER_PRIMARY_DD 0x8L /* 8 */
#endif
#ifdef XWIN_NATIVEGDI
-# define WIN_SERVER_NATIVE_GDI 0x10L /* 16 */
+#define WIN_SERVER_NATIVE_GDI 0x10L /* 16 */
#endif
#define AltMapIndex Mod1MapIndex
@@ -147,8 +146,8 @@ typedef int pid_t;
#include <sys/mman.h>
#ifndef MAP_FILE
#define MAP_FILE 0
-#endif /* MAP_FILE */
-#endif /* HAVE_MMAP */
+#endif /* MAP_FILE */
+#endif /* HAVE_MMAP */
#include <X11/X.h>
#include <X11/Xproto.h>
@@ -192,7 +191,6 @@ typedef int pid_t;
#include "winms.h"
#include "winresource.h"
-
/*
* Define Windows constants
*/
@@ -201,7 +199,6 @@ typedef int pid_t;
#define WM_INIT_SYS_MENU (WM_USER + 1001)
#define WM_GIVEUP (WM_USER + 1002)
-
/* Local includes */
#include "winwindow.h"
#include "winmsg.h"
@@ -213,7 +210,6 @@ if (++PROFPT##point % thresh == 0)\
ErrorF (#point ": PROFILEPOINT hit %u times\n", PROFPT##point);\
}
-
/* We use xor this macro for detecting toggle key state changes */
#define WIN_XOR(a,b) ((!(a) && (b)) || ((a) && !(b)))
@@ -232,117 +228,111 @@ static Atom func (void) { \
* Typedefs for engine dependent function pointers
*/
-typedef Bool (*winAllocateFBProcPtr)(ScreenPtr);
+typedef Bool (*winAllocateFBProcPtr) (ScreenPtr);
-typedef void (*winFreeFBProcPtr)(ScreenPtr);
+typedef void (*winFreeFBProcPtr) (ScreenPtr);
-typedef void (*winShadowUpdateProcPtr)(ScreenPtr, shadowBufPtr);
+typedef void (*winShadowUpdateProcPtr) (ScreenPtr, shadowBufPtr);
-typedef Bool (*winInitScreenProcPtr)(ScreenPtr);
+typedef Bool (*winInitScreenProcPtr) (ScreenPtr);
-typedef Bool (*winCloseScreenProcPtr)(int, ScreenPtr);
+typedef Bool (*winCloseScreenProcPtr) (int, ScreenPtr);
-typedef Bool (*winInitVisualsProcPtr)(ScreenPtr);
+typedef Bool (*winInitVisualsProcPtr) (ScreenPtr);
-typedef Bool (*winAdjustVideoModeProcPtr)(ScreenPtr);
+typedef Bool (*winAdjustVideoModeProcPtr) (ScreenPtr);
-typedef Bool (*winCreateBoundingWindowProcPtr)(ScreenPtr);
+typedef Bool (*winCreateBoundingWindowProcPtr) (ScreenPtr);
-typedef Bool (*winFinishScreenInitProcPtr)(int, ScreenPtr, int, char **);
+typedef Bool (*winFinishScreenInitProcPtr) (int, ScreenPtr, int, char **);
-typedef Bool (*winBltExposedRegionsProcPtr)(ScreenPtr);
+typedef Bool (*winBltExposedRegionsProcPtr) (ScreenPtr);
-typedef Bool (*winActivateAppProcPtr)(ScreenPtr);
+typedef Bool (*winActivateAppProcPtr) (ScreenPtr);
-typedef Bool (*winRedrawScreenProcPtr)(ScreenPtr pScreen);
+typedef Bool (*winRedrawScreenProcPtr) (ScreenPtr pScreen);
-typedef Bool (*winRealizeInstalledPaletteProcPtr)(ScreenPtr pScreen);
+typedef Bool (*winRealizeInstalledPaletteProcPtr) (ScreenPtr pScreen);
-typedef Bool (*winInstallColormapProcPtr)(ColormapPtr pColormap);
+typedef Bool (*winInstallColormapProcPtr) (ColormapPtr pColormap);
-typedef Bool (*winStoreColorsProcPtr)(ColormapPtr pmap,
- int ndef, xColorItem *pdefs);
+typedef Bool (*winStoreColorsProcPtr) (ColormapPtr pmap,
+ int ndef, xColorItem * pdefs);
-typedef Bool (*winCreateColormapProcPtr)(ColormapPtr pColormap);
+typedef Bool (*winCreateColormapProcPtr) (ColormapPtr pColormap);
-typedef Bool (*winDestroyColormapProcPtr)(ColormapPtr pColormap);
+typedef Bool (*winDestroyColormapProcPtr) (ColormapPtr pColormap);
-typedef Bool (*winHotKeyAltTabProcPtr)(ScreenPtr);
+typedef Bool (*winHotKeyAltTabProcPtr) (ScreenPtr);
-typedef Bool (*winCreatePrimarySurfaceProcPtr)(ScreenPtr);
+typedef Bool (*winCreatePrimarySurfaceProcPtr) (ScreenPtr);
-typedef Bool (*winReleasePrimarySurfaceProcPtr)(ScreenPtr);
+typedef Bool (*winReleasePrimarySurfaceProcPtr) (ScreenPtr);
-typedef Bool (*winFinishCreateWindowsWindowProcPtr)(WindowPtr pWin);
+typedef Bool (*winFinishCreateWindowsWindowProcPtr) (WindowPtr pWin);
-typedef Bool (*winCreateScreenResourcesProc)(ScreenPtr);
+typedef Bool (*winCreateScreenResourcesProc) (ScreenPtr);
#ifdef XWIN_NATIVEGDI
/* Typedefs for native GDI wrappers */
typedef Bool (*RealizeFontPtr) (ScreenPtr pScreen, FontPtr pFont);
-typedef Bool (*UnrealizeFontPtr)(ScreenPtr pScreen, FontPtr pFont);
+typedef Bool (*UnrealizeFontPtr) (ScreenPtr pScreen, FontPtr pFont);
#endif
-
/*
* GC (graphics context) privates
*/
-typedef struct
-{
- HDC hdc;
- HDC hdcMem;
+typedef struct {
+ HDC hdc;
+ HDC hdcMem;
} winPrivGCRec, *winPrivGCPtr;
-
/*
* Pixmap privates
*/
-typedef struct
-{
- HDC hdcSelected;
- HBITMAP hBitmap;
- BYTE *pbBits;
- DWORD dwScanlineBytes;
- BITMAPINFOHEADER *pbmih;
+typedef struct {
+ HDC hdcSelected;
+ HBITMAP hBitmap;
+ BYTE *pbBits;
+ DWORD dwScanlineBytes;
+ BITMAPINFOHEADER *pbmih;
} winPrivPixmapRec, *winPrivPixmapPtr;
-
/*
* Colormap privates
*/
-typedef struct
-{
- HPALETTE hPalette;
- LPDIRECTDRAWPALETTE lpDDPalette;
- RGBQUAD rgbColors[WIN_NUM_PALETTE_ENTRIES];
- PALETTEENTRY peColors[WIN_NUM_PALETTE_ENTRIES];
+typedef struct {
+ HPALETTE hPalette;
+ LPDIRECTDRAWPALETTE lpDDPalette;
+ RGBQUAD rgbColors[WIN_NUM_PALETTE_ENTRIES];
+ PALETTEENTRY peColors[WIN_NUM_PALETTE_ENTRIES];
} winPrivCmapRec, *winPrivCmapPtr;
/*
* Windows Cursor handling.
- */
-
+ */
+
typedef struct {
- /* from GetSystemMetrics */
- int sm_cx;
- int sm_cy;
-
- BOOL visible;
- HCURSOR handle;
- QueryBestSizeProcPtr QueryBestSize;
- miPointerSpriteFuncPtr spriteFuncs;
+ /* from GetSystemMetrics */
+ int sm_cx;
+ int sm_cy;
+
+ BOOL visible;
+ HCURSOR handle;
+ QueryBestSizeProcPtr QueryBestSize;
+ miPointerSpriteFuncPtr spriteFuncs;
} winCursorRec;
/*
* Resize modes
*/
typedef enum {
- notAllowed,
- resizeWithScrollbars,
- resizeWithRandr
+ notAllowed,
+ resizeWithScrollbars,
+ resizeWithRandr
} winResizeMode;
/*
@@ -350,297 +340,296 @@ typedef enum {
* in the server startup sequence.
*/
-typedef struct
-{
- ScreenPtr pScreen;
-
- /* Did the user specify a height and width? */
- Bool fUserGaveHeightAndWidth;
+typedef struct {
+ ScreenPtr pScreen;
+
+ /* Did the user specify a height and width? */
+ Bool fUserGaveHeightAndWidth;
- DWORD dwScreen;
+ DWORD dwScreen;
- int iMonitor;
+ int iMonitor;
HMONITOR hMonitor;
- DWORD dwUserWidth;
- DWORD dwUserHeight;
- DWORD dwWidth;
- DWORD dwHeight;
- DWORD dwPaddedWidth;
-
- /* Did the user specify a screen position? */
- Bool fUserGavePosition;
- DWORD dwInitialX;
- DWORD dwInitialY;
-
- /*
- * dwStride is the number of whole pixels that occupy a scanline,
- * including those pixels that are not displayed. This is basically
- * a rounding up of the width.
- */
- DWORD dwStride;
-
- /* Offset of the screen in the window when using scrollbars */
- DWORD dwXOffset;
- DWORD dwYOffset;
-
- DWORD dwBPP;
- DWORD dwDepth;
- DWORD dwRefreshRate;
- char *pfb;
- DWORD dwEngine;
- DWORD dwEnginePreferred;
- DWORD dwClipUpdatesNBoxes;
+ DWORD dwUserWidth;
+ DWORD dwUserHeight;
+ DWORD dwWidth;
+ DWORD dwHeight;
+ DWORD dwPaddedWidth;
+
+ /* Did the user specify a screen position? */
+ Bool fUserGavePosition;
+ DWORD dwInitialX;
+ DWORD dwInitialY;
+
+ /*
+ * dwStride is the number of whole pixels that occupy a scanline,
+ * including those pixels that are not displayed. This is basically
+ * a rounding up of the width.
+ */
+ DWORD dwStride;
+
+ /* Offset of the screen in the window when using scrollbars */
+ DWORD dwXOffset;
+ DWORD dwYOffset;
+
+ DWORD dwBPP;
+ DWORD dwDepth;
+ DWORD dwRefreshRate;
+ char *pfb;
+ DWORD dwEngine;
+ DWORD dwEnginePreferred;
+ DWORD dwClipUpdatesNBoxes;
#ifdef XWIN_EMULATEPSEUDO
- Bool fEmulatePseudo;
+ Bool fEmulatePseudo;
#endif
- Bool fFullScreen;
- Bool fDecoration;
+ Bool fFullScreen;
+ Bool fDecoration;
#ifdef XWIN_MULTIWINDOWEXTWM
- Bool fMWExtWM;
- Bool fAnotherWMRunning;
+ Bool fMWExtWM;
+ Bool fAnotherWMRunning;
#endif
#ifdef XWIN_MULTIWINDOWINTWM
Bool fInternalWM;
#endif
- Bool fRootless;
+ Bool fRootless;
#ifdef XWIN_MULTIWINDOW
- Bool fMultiWindow;
+ Bool fMultiWindow;
#endif
#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
- Bool fMultiMonitorOverride;
+ Bool fMultiMonitorOverride;
#endif
- Bool fMultipleMonitors;
- Bool fLessPointer;
- winResizeMode iResizeMode;
- Bool fNoTrayIcon;
- int iE3BTimeout;
- /* Windows (Alt+F4) and Unix (Ctrl+Alt+Backspace) Killkey */
- Bool fUseWinKillKey;
- Bool fUseUnixKillKey;
- Bool fIgnoreInput;
-
- /* Did the user explicitly set this screen? */
- Bool fExplicitScreen;
+ Bool fMultipleMonitors;
+ Bool fLessPointer;
+ winResizeMode iResizeMode;
+ Bool fNoTrayIcon;
+ int iE3BTimeout;
+ /* Windows (Alt+F4) and Unix (Ctrl+Alt+Backspace) Killkey */
+ Bool fUseWinKillKey;
+ Bool fUseUnixKillKey;
+ Bool fIgnoreInput;
+
+ /* Did the user explicitly set this screen? */
+ Bool fExplicitScreen;
} winScreenInfo, *winScreenInfoPtr;
-
/*
* Screen privates
*/
-typedef struct _winPrivScreenRec
-{
- winScreenInfoPtr pScreenInfo;
+typedef struct _winPrivScreenRec {
+ winScreenInfoPtr pScreenInfo;
- Bool fEnabled;
- Bool fClosed;
- Bool fActive;
- Bool fBadDepth;
+ Bool fEnabled;
+ Bool fClosed;
+ Bool fActive;
+ Bool fBadDepth;
- int iDeltaZ;
+ int iDeltaZ;
- int iConnectedClients;
+ int iConnectedClients;
- CloseScreenProcPtr CloseScreen;
+ CloseScreenProcPtr CloseScreen;
- DWORD dwRedMask;
- DWORD dwGreenMask;
- DWORD dwBlueMask;
- DWORD dwBitsPerRGB;
+ DWORD dwRedMask;
+ DWORD dwGreenMask;
+ DWORD dwBlueMask;
+ DWORD dwBitsPerRGB;
- DWORD dwModeKeyStates;
+ DWORD dwModeKeyStates;
- /* Handle to icons that must be freed */
- HICON hiconNotifyIcon;
+ /* Handle to icons that must be freed */
+ HICON hiconNotifyIcon;
- /* Palette management */
- ColormapPtr pcmapInstalled;
+ /* Palette management */
+ ColormapPtr pcmapInstalled;
- /* Pointer to the root visual so we only have to look it up once */
- VisualPtr pRootVisual;
+ /* Pointer to the root visual so we only have to look it up once */
+ VisualPtr pRootVisual;
- /* 3 button emulation variables */
- int iE3BCachedPress;
- Bool fE3BFakeButton2Sent;
+ /* 3 button emulation variables */
+ int iE3BCachedPress;
+ Bool fE3BFakeButton2Sent;
- /* Privates used by shadow fb GDI server */
- HBITMAP hbmpShadow;
- HDC hdcScreen;
- HDC hdcShadow;
- HWND hwndScreen;
- BITMAPINFOHEADER *pbmih;
+ /* Privates used by shadow fb GDI server */
+ HBITMAP hbmpShadow;
+ HDC hdcScreen;
+ HDC hdcShadow;
+ HWND hwndScreen;
+ BITMAPINFOHEADER *pbmih;
- /* Privates used by shadow fb and primary fb DirectDraw servers */
- LPDIRECTDRAW pdd;
- LPDIRECTDRAWSURFACE pddsPrimary;
- LPDIRECTDRAW2 pdd2;
+ /* Privates used by shadow fb and primary fb DirectDraw servers */
+ LPDIRECTDRAW pdd;
+ LPDIRECTDRAWSURFACE pddsPrimary;
+ LPDIRECTDRAW2 pdd2;
- /* Privates used by shadow fb DirectDraw server */
- LPDIRECTDRAWSURFACE pddsShadow;
- LPDDSURFACEDESC pddsdShadow;
+ /* Privates used by shadow fb DirectDraw server */
+ LPDIRECTDRAWSURFACE pddsShadow;
+ LPDDSURFACEDESC pddsdShadow;
#ifdef XWIN_PRIMARYFB
- /* Privates used by primary fb DirectDraw server */
- LPDIRECTDRAWSURFACE pddsOffscreen;
- LPDDSURFACEDESC pddsdOffscreen;
- LPDDSURFACEDESC pddsdPrimary;
+ /* Privates used by primary fb DirectDraw server */
+ LPDIRECTDRAWSURFACE pddsOffscreen;
+ LPDDSURFACEDESC pddsdOffscreen;
+ LPDDSURFACEDESC pddsdPrimary;
#endif
- /* Privates used by shadow fb DirectDraw Nonlocking server */
- LPDIRECTDRAW4 pdd4;
- LPDIRECTDRAWSURFACE4 pddsShadow4;
- LPDIRECTDRAWSURFACE4 pddsPrimary4;
- BOOL fRetryCreateSurface;
+ /* Privates used by shadow fb DirectDraw Nonlocking server */
+ LPDIRECTDRAW4 pdd4;
+ LPDIRECTDRAWSURFACE4 pddsShadow4;
+ LPDIRECTDRAWSURFACE4 pddsPrimary4;
+ BOOL fRetryCreateSurface;
- /* Privates used by both shadow fb DirectDraw servers */
- LPDIRECTDRAWCLIPPER pddcPrimary;
+ /* Privates used by both shadow fb DirectDraw servers */
+ LPDIRECTDRAWCLIPPER pddcPrimary;
#ifdef XWIN_MULTIWINDOWEXTWM
- /* Privates used by multi-window external window manager */
- RootlessFrameID widTop;
- Bool fRestacking;
+ /* Privates used by multi-window external window manager */
+ RootlessFrameID widTop;
+ Bool fRestacking;
#endif
#ifdef XWIN_MULTIWINDOW
- /* Privates used by multi-window */
- pthread_t ptWMProc;
- pthread_t ptXMsgProc;
- void *pWMInfo;
+ /* Privates used by multi-window */
+ pthread_t ptWMProc;
+ pthread_t ptXMsgProc;
+ void *pWMInfo;
#endif
#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
- /* Privates used by both multi-window and rootless */
- Bool fRootWindowShown;
+ /* Privates used by both multi-window and rootless */
+ Bool fRootWindowShown;
#endif
#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
- /* Privates used for any module running in a seperate thread */
- pthread_mutex_t pmServerStarted;
- Bool fServerStarted;
+ /* Privates used for any module running in a seperate thread */
+ pthread_mutex_t pmServerStarted;
+ Bool fServerStarted;
#endif
-
- /* Engine specific functions */
- winAllocateFBProcPtr pwinAllocateFB;
- winFreeFBProcPtr pwinFreeFB;
- winShadowUpdateProcPtr pwinShadowUpdate;
- winInitScreenProcPtr pwinInitScreen;
- winCloseScreenProcPtr pwinCloseScreen;
- winInitVisualsProcPtr pwinInitVisuals;
- winAdjustVideoModeProcPtr pwinAdjustVideoMode;
- winCreateBoundingWindowProcPtr pwinCreateBoundingWindow;
- winFinishScreenInitProcPtr pwinFinishScreenInit;
- winBltExposedRegionsProcPtr pwinBltExposedRegions;
- winActivateAppProcPtr pwinActivateApp;
- winRedrawScreenProcPtr pwinRedrawScreen;
- winRealizeInstalledPaletteProcPtr pwinRealizeInstalledPalette;
- winInstallColormapProcPtr pwinInstallColormap;
- winStoreColorsProcPtr pwinStoreColors;
- winCreateColormapProcPtr pwinCreateColormap;
- winDestroyColormapProcPtr pwinDestroyColormap;
- winHotKeyAltTabProcPtr pwinHotKeyAltTab;
- winCreatePrimarySurfaceProcPtr pwinCreatePrimarySurface;
- winReleasePrimarySurfaceProcPtr pwinReleasePrimarySurface;
-
- winCreateScreenResourcesProc pwinCreateScreenResources;
+
+ /* Engine specific functions */
+ winAllocateFBProcPtr pwinAllocateFB;
+ winFreeFBProcPtr pwinFreeFB;
+ winShadowUpdateProcPtr pwinShadowUpdate;
+ winInitScreenProcPtr pwinInitScreen;
+ winCloseScreenProcPtr pwinCloseScreen;
+ winInitVisualsProcPtr pwinInitVisuals;
+ winAdjustVideoModeProcPtr pwinAdjustVideoMode;
+ winCreateBoundingWindowProcPtr pwinCreateBoundingWindow;
+ winFinishScreenInitProcPtr pwinFinishScreenInit;
+ winBltExposedRegionsProcPtr pwinBltExposedRegions;
+ winActivateAppProcPtr pwinActivateApp;
+ winRedrawScreenProcPtr pwinRedrawScreen;
+ winRealizeInstalledPaletteProcPtr pwinRealizeInstalledPalette;
+ winInstallColormapProcPtr pwinInstallColormap;
+ winStoreColorsProcPtr pwinStoreColors;
+ winCreateColormapProcPtr pwinCreateColormap;
+ winDestroyColormapProcPtr pwinDestroyColormap;
+ winHotKeyAltTabProcPtr pwinHotKeyAltTab;
+ winCreatePrimarySurfaceProcPtr pwinCreatePrimarySurface;
+ winReleasePrimarySurfaceProcPtr pwinReleasePrimarySurface;
+
+ winCreateScreenResourcesProc pwinCreateScreenResources;
#ifdef XWIN_MULTIWINDOW
- /* Window Procedures for MultiWindow mode */
- winFinishCreateWindowsWindowProcPtr pwinFinishCreateWindowsWindow;
+ /* Window Procedures for MultiWindow mode */
+ winFinishCreateWindowsWindowProcPtr pwinFinishCreateWindowsWindow;
#endif
- /* Window Procedures for Rootless mode */
- CreateWindowProcPtr CreateWindow;
- DestroyWindowProcPtr DestroyWindow;
- PositionWindowProcPtr PositionWindow;
- ChangeWindowAttributesProcPtr ChangeWindowAttributes;
- RealizeWindowProcPtr RealizeWindow;
- UnrealizeWindowProcPtr UnrealizeWindow;
- ValidateTreeProcPtr ValidateTree;
- PostValidateTreeProcPtr PostValidateTree;
- CopyWindowProcPtr CopyWindow;
- ClearToBackgroundProcPtr ClearToBackground;
- ClipNotifyProcPtr ClipNotify;
- RestackWindowProcPtr RestackWindow;
- ReparentWindowProcPtr ReparentWindow;
- ResizeWindowProcPtr ResizeWindow;
- MoveWindowProcPtr MoveWindow;
- SetShapeProcPtr SetShape;
-
- winCursorRec cursor;
+ /* Window Procedures for Rootless mode */
+ CreateWindowProcPtr CreateWindow;
+ DestroyWindowProcPtr DestroyWindow;
+ PositionWindowProcPtr PositionWindow;
+ ChangeWindowAttributesProcPtr ChangeWindowAttributes;
+ RealizeWindowProcPtr RealizeWindow;
+ UnrealizeWindowProcPtr UnrealizeWindow;
+ ValidateTreeProcPtr ValidateTree;
+ PostValidateTreeProcPtr PostValidateTree;
+ CopyWindowProcPtr CopyWindow;
+ ClearToBackgroundProcPtr ClearToBackground;
+ ClipNotifyProcPtr ClipNotify;
+ RestackWindowProcPtr RestackWindow;
+ ReparentWindowProcPtr ReparentWindow;
+ ResizeWindowProcPtr ResizeWindow;
+ MoveWindowProcPtr MoveWindow;
+ SetShapeProcPtr SetShape;
+
+ winCursorRec cursor;
#ifdef XWIN_NATIVEGDI
- RealizeFontPtr RealizeFont;
- UnrealizeFontPtr UnrealizeFont;
+ RealizeFontPtr RealizeFont;
+ UnrealizeFontPtr UnrealizeFont;
#endif
} winPrivScreenRec;
-
#ifdef XWIN_MULTIWINDOWEXTWM
typedef struct {
- RootlessWindowPtr pFrame;
- HWND hWnd;
- int dwWidthBytes;
- BITMAPINFOHEADER *pbmihShadow;
- HBITMAP hbmpShadow;
- HDC hdcShadow;
- HDC hdcScreen;
- BOOL fResized;
- BOOL fRestackingNow;
- BOOL fClose;
- BOOL fMovingOrSizing;
- BOOL fDestroyed;//for debug
- char *pfb;
+ RootlessWindowPtr pFrame;
+ HWND hWnd;
+ int dwWidthBytes;
+ BITMAPINFOHEADER *pbmihShadow;
+ HBITMAP hbmpShadow;
+ HDC hdcShadow;
+ HDC hdcScreen;
+ BOOL fResized;
+ BOOL fRestackingNow;
+ BOOL fClose;
+ BOOL fMovingOrSizing;
+ BOOL fDestroyed; //for debug
+ char *pfb;
} win32RootlessWindowRec, *win32RootlessWindowPtr;
#endif
-
typedef struct {
- pointer value;
- XID id;
+ pointer value;
+ XID id;
} WindowIDPairRec, *WindowIDPairPtr;
-
/*
* Extern declares for general global variables
*/
#include "winglobals.h"
-extern winScreenInfo * g_ScreenInfo;
-extern miPointerScreenFuncRec g_winPointerCursorFuncs;
-extern DWORD g_dwEvents;
+extern winScreenInfo *g_ScreenInfo;
+extern miPointerScreenFuncRec g_winPointerCursorFuncs;
+extern DWORD g_dwEvents;
+
#ifdef HAS_DEVWINDOWS
-extern int g_fdMessageQueue;
+extern int g_fdMessageQueue;
#endif
-extern DevPrivateKeyRec g_iScreenPrivateKeyRec;
+extern DevPrivateKeyRec g_iScreenPrivateKeyRec;
+
#define g_iScreenPrivateKey (&g_iScreenPrivateKeyRec)
-extern DevPrivateKeyRec g_iCmapPrivateKeyRec;
+extern DevPrivateKeyRec g_iCmapPrivateKeyRec;
+
#define g_iCmapPrivateKey (&g_iCmapPrivateKeyRec)
-extern DevPrivateKeyRec g_iGCPrivateKeyRec;
+extern DevPrivateKeyRec g_iGCPrivateKeyRec;
+
#define g_iGCPrivateKey (&g_iGCPrivateKeyRec)
-extern DevPrivateKeyRec g_iPixmapPrivateKeyRec;
+extern DevPrivateKeyRec g_iPixmapPrivateKeyRec;
+
#define g_iPixmapPrivateKey (&g_iPixmapPrivateKeyRec)
-extern DevPrivateKeyRec g_iWindowPrivateKeyRec;
+extern DevPrivateKeyRec g_iWindowPrivateKeyRec;
+
#define g_iWindowPrivateKey (&g_iWindowPrivateKeyRec)
-extern unsigned long g_ulServerGeneration;
-extern DWORD g_dwEnginesSupported;
-extern HINSTANCE g_hInstance;
-extern int g_copyROP[];
-extern int g_patternROP[];
-extern const char * g_pszQueryHost;
-extern DeviceIntPtr g_pwinPointer;
-extern DeviceIntPtr g_pwinKeyboard;
+extern unsigned long g_ulServerGeneration;
+extern DWORD g_dwEnginesSupported;
+extern HINSTANCE g_hInstance;
+extern int g_copyROP[];
+extern int g_patternROP[];
+extern const char *g_pszQueryHost;
+extern DeviceIntPtr g_pwinPointer;
+extern DeviceIntPtr g_pwinKeyboard;
/*
* Extern declares for dynamically loaded library function pointers
*/
-extern FARPROC g_fpDirectDrawCreate;
-extern FARPROC g_fpDirectDrawCreateClipper;
-
+extern FARPROC g_fpDirectDrawCreate;
+extern FARPROC g_fpDirectDrawCreateClipper;
/*
* Screen privates macros
@@ -655,7 +644,6 @@ extern FARPROC g_fpDirectDrawCreateClipper;
#define winScreenPriv(pScreen) \
winPrivScreenPtr pScreenPriv = winGetScreenPriv(pScreen)
-
/*
* Colormap privates macros
*/
@@ -669,7 +657,6 @@ extern FARPROC g_fpDirectDrawCreateClipper;
#define winCmapPriv(pCmap) \
winPrivCmapPtr pCmapPriv = winGetCmapPriv(pCmap)
-
/*
* GC privates macros
*/
@@ -683,7 +670,6 @@ extern FARPROC g_fpDirectDrawCreateClipper;
#define winGCPriv(pGC) \
winPrivGCPtr pGCPriv = winGetGCPriv(pGC)
-
/*
* Pixmap privates macros
*/
@@ -697,7 +683,6 @@ extern FARPROC g_fpDirectDrawCreateClipper;
#define winPixmapPriv(pPixmap) \
winPrivPixmapPtr pPixmapPriv = winGetPixmapPriv(pPixmap)
-
/*
* Window privates macros
*/
@@ -723,7 +708,7 @@ extern FARPROC g_fpDirectDrawCreateClipper;
real->mem = priv->mem; \
}
-#define WIN_WRAP(mem, func) _WIN_WRAP(pScreenPriv, pScreen, mem, func)
+#define WIN_WRAP(mem, func) _WIN_WRAP(pScreenPriv, pScreen, mem, func)
#define WIN_UNWRAP(mem) _WIN_UNWRAP(pScreenPriv, pScreen, mem)
@@ -731,20 +716,18 @@ extern FARPROC g_fpDirectDrawCreateClipper;
* BEGIN DDX and DIX Function Prototypes
*/
-
/*
* winallpriv.c
*/
Bool
-winAllocatePrivates (ScreenPtr pScreen);
+ winAllocatePrivates(ScreenPtr pScreen);
Bool
-winInitCmapPrivates (ColormapPtr pCmap, int index);
+ winInitCmapPrivates(ColormapPtr pCmap, int index);
Bool
-winAllocateCmapPrivates (ColormapPtr pCmap);
-
+ winAllocateCmapPrivates(ColormapPtr pCmap);
/*
* winauth.c
@@ -752,21 +735,18 @@ winAllocateCmapPrivates (ColormapPtr pCmap);
#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
Bool
-winGenerateAuthorization (void);
+ winGenerateAuthorization(void);
void winSetAuthorization(void);
#endif
-
/*
* winblock.c
*/
void
-winBlockHandler (int nScreen,
- pointer pBlockData,
- pointer pTimeout,
- pointer pReadMask);
+winBlockHandler(int nScreen,
+ pointer pBlockData, pointer pTimeout, pointer pReadMask);
#ifdef XWIN_NATIVEGDI
/*
@@ -774,44 +754,40 @@ winBlockHandler (int nScreen,
*/
RegionPtr
-winPixmapToRegionNativeGDI (PixmapPtr pPix);
+ winPixmapToRegionNativeGDI(PixmapPtr pPix);
#endif
-
#ifdef XWIN_CLIPBOARD
/*
* winclipboardinit.c
*/
Bool
-winInitClipboard (void);
+ winInitClipboard(void);
void
-winFixClipboardChain (int Removed);
+ winFixClipboardChain (int Removed);
#endif
-
/*
* wincmap.c
*/
void
-winSetColormapFunctions (ScreenPtr pScreen);
+ winSetColormapFunctions(ScreenPtr pScreen);
Bool
-winCreateDefColormap (ScreenPtr pScreen);
-
+ winCreateDefColormap(ScreenPtr pScreen);
/*
* wincreatewnd.c
*/
Bool
-winCreateBoundingWindowFullScreen (ScreenPtr pScreen);
+ winCreateBoundingWindowFullScreen(ScreenPtr pScreen);
Bool
-winCreateBoundingWindowWindowed (ScreenPtr pScreen);
-
+ winCreateBoundingWindowWindowed(ScreenPtr pScreen);
/*
* windialogs.c
@@ -821,31 +797,29 @@ int
GetLiveClients (winPrivScreenPtr pScreenPriv);
void
-winDisplayExitDialog (winPrivScreenPtr pScreenPriv);
+ winDisplayExitDialog(winPrivScreenPtr pScreenPriv);
void
-winDisplayDepthChangeDialog (winPrivScreenPtr pScreenPriv);
+ winDisplayDepthChangeDialog(winPrivScreenPtr pScreenPriv);
void
-winDisplayAboutDialog (winPrivScreenPtr pScreenPriv);
-
+ winDisplayAboutDialog(winPrivScreenPtr pScreenPriv);
/*
* winengine.c
*/
void
-winDetectSupportedEngines (void);
+ winDetectSupportedEngines(void);
Bool
-winSetEngine (ScreenPtr pScreen);
+ winSetEngine(ScreenPtr pScreen);
Bool
-winGetDDProcAddresses (void);
+ winGetDDProcAddresses(void);
void
-winReleaseDDProcAddresses(void);
-
+ winReleaseDDProcAddresses(void);
/*
* winerror.c
@@ -853,12 +827,11 @@ winReleaseDDProcAddresses(void);
#ifdef DDXOSVERRORF
void
-OSVenderVErrorF (const char *pszFormat, va_list va_args);
+ OSVenderVErrorF(const char *pszFormat, va_list va_args);
#endif
void
-winMessageBoxF (const char *pszError, UINT uType, ...);
-
+ winMessageBoxF(const char *pszError, UINT uType, ...);
#ifdef XWIN_NATIVEGDI
/*
@@ -866,14 +839,12 @@ winMessageBoxF (const char *pszError, UINT uType, ...);
*/
void
-winFillSpansNativeGDI (DrawablePtr pDrawable,
- GCPtr pGC,
- int nSpans,
- DDXPointPtr pPoints,
- int *pWidths,
- int fSorted);
-#endif
+winFillSpansNativeGDI(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nSpans,
+ DDXPointPtr pPoints, int *pWidths, int fSorted);
+#endif
#ifdef XWIN_NATIVEGDI
/*
@@ -881,87 +852,79 @@ winFillSpansNativeGDI (DrawablePtr pDrawable,
*/
Bool
-winRealizeFontNativeGDI (ScreenPtr pScreen, FontPtr pFont);
+ winRealizeFontNativeGDI(ScreenPtr pScreen, FontPtr pFont);
Bool
-winUnrealizeFontNativeGDI (ScreenPtr pScreen, FontPtr pFont);
+ winUnrealizeFontNativeGDI(ScreenPtr pScreen, FontPtr pFont);
#endif
-
#ifdef XWIN_NATIVEGDI
/*
* wingc.c
*/
Bool
-winCreateGCNativeGDI (GCPtr pGC);
+ winCreateGCNativeGDI(GCPtr pGC);
#endif
-
#ifdef XWIN_NATIVEGDI
/*
* wingetsp.c
*/
void
-winGetSpansNativeGDI (DrawablePtr pDrawable,
- int wMax,
- DDXPointPtr pPoints,
- int *pWidths,
- int nSpans,
- char *pDst);
-#endif
+winGetSpansNativeGDI(DrawablePtr pDrawable,
+ int wMax,
+ DDXPointPtr pPoints, int *pWidths, int nSpans, char *pDst);
+#endif
/*
* winglobals.c
*/
void
-winInitializeGlobals (void);
-
+ winInitializeGlobals(void);
/*
* winkeybd.c
*/
void
-winTranslateKey (WPARAM wParam, LPARAM lParam, int *piScanCode);
+ winTranslateKey(WPARAM wParam, LPARAM lParam, int *piScanCode);
int
-winKeybdProc (DeviceIntPtr pDeviceInt, int iState);
+ winKeybdProc(DeviceIntPtr pDeviceInt, int iState);
void
-winInitializeModeKeyStates (void);
+ winInitializeModeKeyStates(void);
void
-winRestoreModeKeyStates (void);
+ winRestoreModeKeyStates(void);
Bool
-winIsFakeCtrl_L (UINT message, WPARAM wParam, LPARAM lParam);
+ winIsFakeCtrl_L(UINT message, WPARAM wParam, LPARAM lParam);
void
-winKeybdReleaseKeys (void);
+ winKeybdReleaseKeys(void);
void
-winSendKeyEvent (DWORD dwKey, Bool fDown);
+ winSendKeyEvent(DWORD dwKey, Bool fDown);
-BOOL
-winCheckKeyPressed(WPARAM wParam, LPARAM lParam);
+BOOL winCheckKeyPressed(WPARAM wParam, LPARAM lParam);
void
-winFixShiftKeys (int iScanCode);
+ winFixShiftKeys(int iScanCode);
/*
* winkeyhook.c
*/
Bool
-winInstallKeyboardHookLL (void);
+ winInstallKeyboardHookLL(void);
void
-winRemoveKeyboardHookLL (void);
-
+ winRemoveKeyboardHookLL(void);
/*
* winmisc.c
@@ -969,42 +932,41 @@ winRemoveKeyboardHookLL (void);
#ifdef XWIN_NATIVEGDI
void
-winQueryBestSizeNativeGDI (int class, unsigned short *pWidth,
- unsigned short *pHeight, ScreenPtr pScreen);
+
+winQueryBestSizeNativeGDI(int class, unsigned short *pWidth,
+ unsigned short *pHeight, ScreenPtr pScreen);
#endif
CARD8
-winCountBits (DWORD dw);
+ winCountBits(DWORD dw);
Bool
-winUpdateFBPointer (ScreenPtr pScreen, void *pbits);
+ winUpdateFBPointer(ScreenPtr pScreen, void *pbits);
#ifdef XWIN_NATIVEGDI
-BOOL
-winPaintBackground (HWND hwnd, COLORREF colorref);
+BOOL winPaintBackground(HWND hwnd, COLORREF colorref);
#endif
-
/*
* winmouse.c
*/
int
-winMouseProc (DeviceIntPtr pDeviceInt, int iState);
+ winMouseProc(DeviceIntPtr pDeviceInt, int iState);
int
-winMouseWheel (ScreenPtr pScreen, int iDeltaZ);
+ winMouseWheel(ScreenPtr pScreen, int iDeltaZ);
void
-winMouseButtonsSendEvent (int iEventType, int iButton);
+ winMouseButtonsSendEvent(int iEventType, int iButton);
int
-winMouseButtonsHandle (ScreenPtr pScreen,
- int iEventType, int iButton,
- WPARAM wParam);
+
+winMouseButtonsHandle(ScreenPtr pScreen,
+ int iEventType, int iButton, WPARAM wParam);
void
-winEnqueueMotion(int x, int y);
+ winEnqueueMotion(int x, int y);
#ifdef XWIN_NATIVEGDI
/*
@@ -1012,43 +974,42 @@ winEnqueueMotion(int x, int y);
*/
HBITMAP
-winCreateDIBNativeGDI (int iWidth, int iHeight, int iDepth,
- BYTE **ppbBits, BITMAPINFO **ppbmi);
+winCreateDIBNativeGDI(int iWidth, int iHeight, int iDepth,
+ BYTE ** ppbBits, BITMAPINFO ** ppbmi);
Bool
-winSetEngineFunctionsNativeGDI (ScreenPtr pScreen);
+ winSetEngineFunctionsNativeGDI(ScreenPtr pScreen);
#endif
-
#ifdef XWIN_PRIMARYFB
/*
* winpfbddd.c
*/
Bool
-winSetEngineFunctionsPrimaryDD (ScreenPtr pScreen);
+ winSetEngineFunctionsPrimaryDD(ScreenPtr pScreen);
#endif
-
#ifdef XWIN_NATIVEGDI
/*
* winpixmap.c
*/
PixmapPtr
-winCreatePixmapNativeGDI (ScreenPtr pScreen, int width, int height, int depth,
- unsigned usage_hint);
+
+winCreatePixmapNativeGDI(ScreenPtr pScreen, int width, int height, int depth,
+ unsigned usage_hint);
Bool
-winDestroyPixmapNativeGDI (PixmapPtr pPixmap);
+ winDestroyPixmapNativeGDI(PixmapPtr pPixmap);
Bool
-winModifyPixmapHeaderNativeGDI (PixmapPtr pPixmap,
- int iWidth, int iHeight,
- int iDepth,
- int iBitsPerPixel,
- int devKind,
- pointer pPixData);
+
+winModifyPixmapHeaderNativeGDI(PixmapPtr pPixmap,
+ int iWidth, int iHeight,
+ int iDepth,
+ int iBitsPerPixel,
+ int devKind, pointer pPixData);
#endif
#ifdef XWIN_NATIVEGDI
@@ -1057,13 +1018,10 @@ winModifyPixmapHeaderNativeGDI (PixmapPtr pPixmap,
*/
void
-winPolyLineNativeGDI (DrawablePtr pDrawable,
- GCPtr pGC,
- int mode,
- int npt,
- DDXPointPtr ppt);
-#endif
+winPolyLineNativeGDI(DrawablePtr pDrawable,
+ GCPtr pGC, int mode, int npt, DDXPointPtr ppt);
+#endif
#ifdef XWIN_NATIVEGDI
/*
@@ -1071,32 +1029,27 @@ winPolyLineNativeGDI (DrawablePtr pDrawable,
*/
void
-winPushPixels (GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDrawable,
- int dx, int dy, int xOrg, int yOrg);
-#endif
+winPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDrawable,
+ int dx, int dy, int xOrg, int yOrg);
+#endif
/*
* winscrinit.c
*/
Bool
-winScreenInit (int index,
- ScreenPtr pScreen,
- int argc, char **argv);
+ winScreenInit(int index, ScreenPtr pScreen, int argc, char **argv);
Bool
-winFinishScreenInitFB (int index,
- ScreenPtr pScreen,
- int argc, char **argv);
+ winFinishScreenInitFB(int index, ScreenPtr pScreen, int argc, char **argv);
#if defined(XWIN_NATIVEGDI)
Bool
-winFinishScreenInitNativeGDI (int index,
- ScreenPtr pScreen,
- int argc, char **argv);
-#endif
+winFinishScreenInitNativeGDI(int index,
+ ScreenPtr pScreen, int argc, char **argv);
+#endif
#ifdef XWIN_NATIVEGDI
/*
@@ -1104,50 +1057,43 @@ winFinishScreenInitNativeGDI (int index,
*/
void
-winSetSpansNativeGDI (DrawablePtr pDrawable,
- GCPtr pGC,
- char *pSrc,
- DDXPointPtr pPoints,
- int *pWidth,
- int nSpans,
- int fSorted);
-#endif
+winSetSpansNativeGDI(DrawablePtr pDrawable,
+ GCPtr pGC,
+ char *pSrc,
+ DDXPointPtr pPoints, int *pWidth, int nSpans, int fSorted);
+#endif
/*
* winshaddd.c
*/
Bool
-winSetEngineFunctionsShadowDD (ScreenPtr pScreen);
-
+ winSetEngineFunctionsShadowDD(ScreenPtr pScreen);
/*
* winshadddnl.c
*/
Bool
-winSetEngineFunctionsShadowDDNL (ScreenPtr pScreen);
-
+ winSetEngineFunctionsShadowDDNL(ScreenPtr pScreen);
/*
* winshadgdi.c
*/
Bool
-winSetEngineFunctionsShadowGDI (ScreenPtr pScreen);
-
+ winSetEngineFunctionsShadowGDI(ScreenPtr pScreen);
/*
* winwakeup.c
*/
void
-winWakeupHandler (int nScreen,
- pointer pWakeupData,
- unsigned long ulResult,
- pointer pReadmask);
+winWakeupHandler(int nScreen,
+ pointer pWakeupData,
+ unsigned long ulResult, pointer pReadmask);
/*
* winwindow.c
@@ -1155,60 +1101,57 @@ winWakeupHandler (int nScreen,
#ifdef XWIN_NATIVEGDI
Bool
-winCreateWindowNativeGDI (WindowPtr pWin);
+ winCreateWindowNativeGDI(WindowPtr pWin);
Bool
-winDestroyWindowNativeGDI (WindowPtr pWin);
+ winDestroyWindowNativeGDI(WindowPtr pWin);
Bool
-winPositionWindowNativeGDI (WindowPtr pWin, int x, int y);
+ winPositionWindowNativeGDI(WindowPtr pWin, int x, int y);
-void
-winCopyWindowNativeGDI (WindowPtr pWin,
- DDXPointRec ptOldOrg,
- RegionPtr prgnSrc);
+void
+
+winCopyWindowNativeGDI(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc);
Bool
-winChangeWindowAttributesNativeGDI (WindowPtr pWin, unsigned long mask);
+ winChangeWindowAttributesNativeGDI(WindowPtr pWin, unsigned long mask);
Bool
-winUnmapWindowNativeGDI (WindowPtr pWindow);
+ winUnmapWindowNativeGDI(WindowPtr pWindow);
Bool
-winMapWindowNativeGDI (WindowPtr pWindow);
+ winMapWindowNativeGDI(WindowPtr pWindow);
#endif
Bool
-winCreateWindowRootless (WindowPtr pWindow);
+ winCreateWindowRootless(WindowPtr pWindow);
Bool
-winDestroyWindowRootless (WindowPtr pWindow);
+ winDestroyWindowRootless(WindowPtr pWindow);
Bool
-winPositionWindowRootless (WindowPtr pWindow, int x, int y);
+ winPositionWindowRootless(WindowPtr pWindow, int x, int y);
Bool
-winChangeWindowAttributesRootless (WindowPtr pWindow, unsigned long mask);
+ winChangeWindowAttributesRootless(WindowPtr pWindow, unsigned long mask);
Bool
-winUnmapWindowRootless (WindowPtr pWindow);
+ winUnmapWindowRootless(WindowPtr pWindow);
Bool
-winMapWindowRootless (WindowPtr pWindow);
+ winMapWindowRootless(WindowPtr pWindow);
void
-winSetShapeRootless (WindowPtr pWindow, int kind);
-
+ winSetShapeRootless(WindowPtr pWindow, int kind);
/*
* winmultiwindowicons.c - Used by both multi-window and Win32Rootless
*/
-HICON
-winXIconToHICON (WindowPtr pWin, int iconSize);
+HICON winXIconToHICON(WindowPtr pWin, int iconSize);
void
-winSelectIcons(WindowPtr pWin, HICON *pIcon, HICON *pSmallIcon);
+ winSelectIcons(WindowPtr pWin, HICON * pIcon, HICON * pSmallIcon);
#ifdef XWIN_MULTIWINDOW
/*
@@ -1216,102 +1159,98 @@ winSelectIcons(WindowPtr pWin, HICON *pIcon, HICON *pSmallIcon);
*/
void
-winReshapeMultiWindow (WindowPtr pWin);
+ winReshapeMultiWindow(WindowPtr pWin);
void
-winSetShapeMultiWindow (WindowPtr pWindow, int kind);
+ winSetShapeMultiWindow(WindowPtr pWindow, int kind);
void
-winUpdateRgnMultiWindow (WindowPtr pWindow);
+ winUpdateRgnMultiWindow(WindowPtr pWindow);
#endif
-
#ifdef XWIN_MULTIWINDOW
/*
* winmultiwindowwindow.c
*/
Bool
-winCreateWindowMultiWindow (WindowPtr pWindow);
+ winCreateWindowMultiWindow(WindowPtr pWindow);
Bool
-winDestroyWindowMultiWindow (WindowPtr pWindow);
+ winDestroyWindowMultiWindow(WindowPtr pWindow);
Bool
-winPositionWindowMultiWindow (WindowPtr pWindow, int x, int y);
+ winPositionWindowMultiWindow(WindowPtr pWindow, int x, int y);
Bool
-winChangeWindowAttributesMultiWindow (WindowPtr pWindow, unsigned long mask);
+ winChangeWindowAttributesMultiWindow(WindowPtr pWindow, unsigned long mask);
Bool
-winUnmapWindowMultiWindow (WindowPtr pWindow);
+ winUnmapWindowMultiWindow(WindowPtr pWindow);
Bool
-winMapWindowMultiWindow (WindowPtr pWindow);
+ winMapWindowMultiWindow(WindowPtr pWindow);
void
-winReparentWindowMultiWindow (WindowPtr pWin, WindowPtr pPriorParent);
+ winReparentWindowMultiWindow(WindowPtr pWin, WindowPtr pPriorParent);
void
-winRestackWindowMultiWindow (WindowPtr pWin, WindowPtr pOldNextSib);
+ winRestackWindowMultiWindow(WindowPtr pWin, WindowPtr pOldNextSib);
void
-winReorderWindowsMultiWindow (void);
+ winReorderWindowsMultiWindow(void);
void
-winResizeWindowMultiWindow (WindowPtr pWin, int x, int y, unsigned int w,
- unsigned int h, WindowPtr pSib);
+
+winResizeWindowMultiWindow(WindowPtr pWin, int x, int y, unsigned int w,
+ unsigned int h, WindowPtr pSib);
void
-winMoveWindowMultiWindow (WindowPtr pWin, int x, int y,
- WindowPtr pSib, VTKind kind);
+
+winMoveWindowMultiWindow(WindowPtr pWin, int x, int y,
+ WindowPtr pSib, VTKind kind);
void
-winCopyWindowMultiWindow (WindowPtr pWin, DDXPointRec oldpt,
- RegionPtr oldRegion);
+
+winCopyWindowMultiWindow(WindowPtr pWin, DDXPointRec oldpt,
+ RegionPtr oldRegion);
XID
-winGetWindowID (WindowPtr pWin);
+ winGetWindowID(WindowPtr pWin);
int
-winAdjustXWindow (WindowPtr pWin, HWND hwnd);
+ winAdjustXWindow(WindowPtr pWin, HWND hwnd);
#endif
-
#ifdef XWIN_MULTIWINDOW
/*
* winmultiwindowwndproc.c
*/
LRESULT CALLBACK
-winTopLevelWindowProc (HWND hwnd, UINT message,
- WPARAM wParam, LPARAM lParam);
+winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
#endif
-
/*
* wintrayicon.c
*/
void
-winInitNotifyIcon (winPrivScreenPtr pScreenPriv, Bool Modify);
+ winInitNotifyIcon (winPrivScreenPtr pScreenPriv, Bool Modify);
void
-winDeleteNotifyIcon (winPrivScreenPtr pScreenPriv);
+ winDeleteNotifyIcon(winPrivScreenPtr pScreenPriv);
LRESULT
-winHandleIconMessage (HWND hwnd, UINT message,
- WPARAM wParam, LPARAM lParam,
- winPrivScreenPtr pScreenPriv);
-
+winHandleIconMessage(HWND hwnd, UINT message,
+ WPARAM wParam, LPARAM lParam,
+ winPrivScreenPtr pScreenPriv);
/*
* winwndproc.c
*/
LRESULT CALLBACK
-winWindowProc (HWND hWnd, UINT message,
- WPARAM wParam, LPARAM lParam);
-
+winWindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
#ifdef XWIN_MULTIWINDOWEXTWM
/*
@@ -1319,55 +1258,61 @@ winWindowProc (HWND hWnd, UINT message,
*/
Bool
-winMWExtWMCreateFrame (RootlessWindowPtr pFrame, ScreenPtr pScreen,
- int newX, int newY, RegionPtr pShape);
+
+winMWExtWMCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen,
+ int newX, int newY, RegionPtr pShape);
void
-winMWExtWMDestroyFrame (RootlessFrameID wid);
+ winMWExtWMDestroyFrame(RootlessFrameID wid);
void
-winMWExtWMMoveFrame (RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY);
+
+winMWExtWMMoveFrame(RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY);
void
-winMWExtWMResizeFrame (RootlessFrameID wid, ScreenPtr pScreen,
- int newX, int newY, unsigned int newW, unsigned int newH,
- unsigned int gravity);
+
+winMWExtWMResizeFrame(RootlessFrameID wid, ScreenPtr pScreen,
+ int newX, int newY, unsigned int newW, unsigned int newH,
+ unsigned int gravity);
void
-winMWExtWMRestackFrame (RootlessFrameID wid, RootlessFrameID nextWid);
+ winMWExtWMRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid);
void
-winMWExtWMReshapeFrame (RootlessFrameID wid, RegionPtr pShape);
+ winMWExtWMReshapeFrame(RootlessFrameID wid, RegionPtr pShape);
void
-winMWExtWMUnmapFrame (RootlessFrameID wid);
+ winMWExtWMUnmapFrame(RootlessFrameID wid);
void
-winMWExtWMStartDrawing (RootlessFrameID wid, char **pixelData, int *bytesPerRow);
+
+winMWExtWMStartDrawing(RootlessFrameID wid, char **pixelData, int *bytesPerRow);
void
-winMWExtWMStopDrawing (RootlessFrameID wid, Bool flush);
+ winMWExtWMStopDrawing(RootlessFrameID wid, Bool flush);
void
-winMWExtWMUpdateRegion (RootlessFrameID wid, RegionPtr pDamage);
+ winMWExtWMUpdateRegion(RootlessFrameID wid, RegionPtr pDamage);
void
-winMWExtWMDamageRects (RootlessFrameID wid, int count, const BoxRec *rects,
- int shift_x, int shift_y);
+
+winMWExtWMDamageRects(RootlessFrameID wid, int count, const BoxRec * rects,
+ int shift_x, int shift_y);
void
-winMWExtWMRootlessSwitchWindow (RootlessWindowPtr pFrame, WindowPtr oldWin);
+ winMWExtWMRootlessSwitchWindow(RootlessWindowPtr pFrame, WindowPtr oldWin);
void
-winMWExtWMCopyBytes (unsigned int width, unsigned int height,
- const void *src, unsigned int srcRowBytes,
- void *dst, unsigned int dstRowBytes);
+
+winMWExtWMCopyBytes(unsigned int width, unsigned int height,
+ const void *src, unsigned int srcRowBytes,
+ void *dst, unsigned int dstRowBytes);
void
-winMWExtWMCopyWindow (RootlessFrameID wid, int dstNrects, const BoxRec *dstRects,
- int dx, int dy);
-#endif
+winMWExtWMCopyWindow(RootlessFrameID wid, int dstNrects,
+ const BoxRec * dstRects, int dx, int dy);
+#endif
#ifdef XWIN_MULTIWINDOWEXTWM
/*
@@ -1375,69 +1320,67 @@ winMWExtWMCopyWindow (RootlessFrameID wid, int dstNrects, const BoxRec *dstRects
*/
void
-winMWExtWMReorderWindows (ScreenPtr pScreen);
+ winMWExtWMReorderWindows(ScreenPtr pScreen);
void
-winMWExtWMMoveXWindow (WindowPtr pWin, int x, int y);
+ winMWExtWMMoveXWindow(WindowPtr pWin, int x, int y);
void
-winMWExtWMResizeXWindow (WindowPtr pWin, int w, int h);
+ winMWExtWMResizeXWindow(WindowPtr pWin, int w, int h);
void
-winMWExtWMMoveResizeXWindow (WindowPtr pWin, int x, int y, int w, int h);
+ winMWExtWMMoveResizeXWindow(WindowPtr pWin, int x, int y, int w, int h);
void
-winMWExtWMUpdateIcon (Window id);
+ winMWExtWMUpdateIcon(Window id);
void
-winMWExtWMUpdateWindowDecoration (win32RootlessWindowPtr pRLWinPriv,
- winScreenInfoPtr pScreenInfo);
-wBOOL CALLBACK
-winMWExtWMDecorateWindow (HWND hwnd, LPARAM lParam);
+winMWExtWMUpdateWindowDecoration(win32RootlessWindowPtr pRLWinPriv,
+ winScreenInfoPtr pScreenInfo);
+
+wBOOL CALLBACK winMWExtWMDecorateWindow(HWND hwnd, LPARAM lParam);
void
-winMWExtWMRestackWindows (ScreenPtr pScreen);
+ winMWExtWMRestackWindows(ScreenPtr pScreen);
#endif
#ifdef XWIN_MULTIWINDOWINTWM
Bool
-winIsInternalWMRunning (winScreenInfoPtr pScreenInfo);
+ winIsInternalWMRunning (winScreenInfoPtr pScreenInfo);
#endif
-
#ifdef XWIN_MULTIWINDOWEXTWM
/*
* winwin32rootlesswndproc.c
*/
LRESULT CALLBACK
-winMWExtWMWindowProc (HWND hwnd, UINT message,
- WPARAM wParam, LPARAM lParam);
+winMWExtWMWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
#endif
-
/*
* winwindowswm.c
*/
void
-winWindowsWMSendEvent (int type, unsigned int mask, int which, int arg,
- Window window, int x, int y, int w, int h);
+
+winWindowsWMSendEvent(int type, unsigned int mask, int which, int arg,
+ Window window, int x, int y, int w, int h);
void
-winWindowsWMExtensionInit (void);
+ winWindowsWMExtensionInit(void);
/*
* wincursor.c
*/
Bool
-winInitCursor (ScreenPtr pScreen);
+ winInitCursor(ScreenPtr pScreen);
/*
* winprocarg.c
*/
void
-winInitializeScreens(int maxscreens);
+ winInitializeScreens(int maxscreens);
/*
* windisplay.c
@@ -1450,17 +1393,15 @@ winGetDisplayName(char *szDisplay, unsigned int screen);
* winrandr.c
*/
Bool
-winRandRInit (ScreenPtr pScreen);
+ winRandRInit(ScreenPtr pScreen);
void
-winDoRandRScreenSetSize (ScreenPtr pScreen,
- CARD16 width,
- CARD16 height,
- CARD32 mmWidth,
- CARD32 mmHeight);
+
+winDoRandRScreenSetSize(ScreenPtr pScreen,
+ CARD16 width,
+ CARD16 height, CARD32 mmWidth, CARD32 mmHeight);
/*
* END DDX and DIX Function Prototypes
*/
-#endif /* _WIN_H_ */
-
+#endif /* _WIN_H_ */
diff --git a/xorg-server/hw/xwin/winallpriv.c b/xorg-server/hw/xwin/winallpriv.c
index f4078207e..a263d3a7f 100644
--- a/xorg-server/hw/xwin/winallpriv.c
+++ b/xorg-server/hw/xwin/winallpriv.c
@@ -1,178 +1,168 @@
-/*
- *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: Keith Packard, MIT X Consortium
- * Harold L Hunt II
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-
-
-/* See Porting Layer Definition - p. 58 */
-/*
- * Allocate indexes for the privates that we use.
- * Allocate memory directly for the screen privates.
- * Reserve space in GCs and Pixmaps for our privates.
- * Colormap privates are handled in winAllocateCmapPrivates ()
- */
-
-Bool
-winAllocatePrivates (ScreenPtr pScreen)
-{
- winPrivScreenPtr pScreenPriv;
-
- winDebug ("winAllocateScreenPrivates - g_ulServerGeneration: %d "
- "serverGeneration: %d\n",
- g_ulServerGeneration, serverGeneration);
-
- /* We need a new slot for our privates if the screen gen has changed */
- if (g_ulServerGeneration != serverGeneration)
- {
- g_ulServerGeneration = serverGeneration;
- }
-
- /* Allocate memory for the screen private structure */
- pScreenPriv = (winPrivScreenPtr) malloc (sizeof (winPrivScreenRec));
- if (!pScreenPriv)
- {
- ErrorF ("winAllocateScreenPrivates - malloc () failed\n");
- return FALSE;
- }
-
- /* Initialize the memory of the private structure */
- ZeroMemory (pScreenPriv, sizeof (winPrivScreenRec));
-
- /* Intialize private structure members */
- pScreenPriv->fActive = TRUE;
-
- /* Register our screen private */
- if (!dixRegisterPrivateKey(g_iScreenPrivateKey, PRIVATE_SCREEN, 0))
- {
- ErrorF ("winAllocatePrivates - dixRegisterPrivateKey () failed\n");
- return FALSE;
- }
-
- /* Save the screen private pointer */
- winSetScreenPriv (pScreen, pScreenPriv);
-
- /* Reserve GC memory for our privates */
- if (!dixRegisterPrivateKey(g_iGCPrivateKey, PRIVATE_GC, sizeof (winPrivGCRec)))
- {
- ErrorF ("winAllocatePrivates - AllocateGCPrivate () failed\n");
- return FALSE;
- }
-
- /* Reserve Pixmap memory for our privates */
- if (!dixRegisterPrivateKey(g_iPixmapPrivateKey, PRIVATE_PIXMAP, sizeof (winPrivPixmapRec)))
- {
- ErrorF ("winAllocatePrivates - AllocatePixmapPrivates () failed\n");
- return FALSE;
- }
-
- /* Reserve Window memory for our privates */
- if (!dixRegisterPrivateKey(g_iWindowPrivateKey, PRIVATE_WINDOW, sizeof (winPrivWinRec)))
- {
- ErrorF ("winAllocatePrivates () - AllocateWindowPrivates () failed\n");
- return FALSE;
- }
-
- return TRUE;
-}
-
-
-/*
- * Colormap privates may be allocated after the default colormap has
- * already been created for some screens. This initialization procedure
- * is called for each default colormap that is found.
- */
-
-Bool
-winInitCmapPrivates (ColormapPtr pcmap, int index)
-{
- winDebug ("winInitCmapPrivates\n");
-
- /*
- * I see no way that this function can do anything useful
- * with only a ColormapPtr. We don't have the index for
- * our dev privates yet, so we can't really initialize
- * anything. Perhaps I am misunderstanding the purpose
- * of this function.
- */
- /* That's definitely true.
- * I therefore changed the API and added the index as argument.
- */
- return TRUE;
-}
-
-
-/*
- * Allocate memory for our colormap privates
- */
-
-Bool
-winAllocateCmapPrivates (ColormapPtr pCmap)
-{
- winPrivCmapPtr pCmapPriv;
- static unsigned long s_ulPrivateGeneration = 0;
-
- winDebug ("winAllocateCmapPrivates\n");
-
- /* Get a new privates index when the server generation changes */
- if (s_ulPrivateGeneration != serverGeneration)
- {
- /* Save the new server generation */
- s_ulPrivateGeneration = serverGeneration;
- }
-
- /* Allocate memory for our private structure */
- pCmapPriv = (winPrivCmapPtr) malloc (sizeof (winPrivCmapRec));
- if (!pCmapPriv)
- {
- ErrorF ("winAllocateCmapPrivates - malloc () failed\n");
- return FALSE;
- }
-
- /* Initialize the memory of the private structure */
- ZeroMemory (pCmapPriv, sizeof (winPrivCmapRec));
-
- /* Register our colourmap private */
- if (!dixRegisterPrivateKey(g_iCmapPrivateKey, PRIVATE_COLORMAP, 0))
- {
- ErrorF ("winAllocateCmapPrivates - AllocateCmapPrivate () failed\n");
- return FALSE;
- }
-
- /* Save the cmap private pointer */
- winSetCmapPriv (pCmap, pCmapPriv);
-
- winDebug ("winAllocateCmapPrivates - Returning\n");
-
- return TRUE;
-}
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Keith Packard, MIT X Consortium
+ * Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+/* See Porting Layer Definition - p. 58 */
+/*
+ * Allocate indexes for the privates that we use.
+ * Allocate memory directly for the screen privates.
+ * Reserve space in GCs and Pixmaps for our privates.
+ * Colormap privates are handled in winAllocateCmapPrivates ()
+ */
+
+Bool
+winAllocatePrivates(ScreenPtr pScreen)
+{
+ winPrivScreenPtr pScreenPriv;
+
+ winDebug("winAllocateScreenPrivates - g_ulServerGeneration: %d "
+ "serverGeneration: %d\n", g_ulServerGeneration, serverGeneration);
+
+ /* We need a new slot for our privates if the screen gen has changed */
+ if (g_ulServerGeneration != serverGeneration) {
+ g_ulServerGeneration = serverGeneration;
+ }
+
+ /* Allocate memory for the screen private structure */
+ pScreenPriv = (winPrivScreenPtr) malloc(sizeof(winPrivScreenRec));
+ if (!pScreenPriv) {
+ ErrorF("winAllocateScreenPrivates - malloc () failed\n");
+ return FALSE;
+ }
+
+ /* Initialize the memory of the private structure */
+ ZeroMemory(pScreenPriv, sizeof(winPrivScreenRec));
+
+ /* Intialize private structure members */
+ pScreenPriv->fActive = TRUE;
+
+ /* Register our screen private */
+ if (!dixRegisterPrivateKey(g_iScreenPrivateKey, PRIVATE_SCREEN, 0)) {
+ ErrorF ("winAllocatePrivates - dixRegisterPrivateKey () failed\n");
+ return FALSE;
+ }
+
+ /* Save the screen private pointer */
+ winSetScreenPriv(pScreen, pScreenPriv);
+
+ /* Reserve GC memory for our privates */
+ if (!dixRegisterPrivateKey
+ (g_iGCPrivateKey, PRIVATE_GC, sizeof(winPrivGCRec))) {
+ ErrorF("winAllocatePrivates - AllocateGCPrivate () failed\n");
+ return FALSE;
+ }
+
+ /* Reserve Pixmap memory for our privates */
+ if (!dixRegisterPrivateKey
+ (g_iPixmapPrivateKey, PRIVATE_PIXMAP, sizeof(winPrivPixmapRec))) {
+ ErrorF("winAllocatePrivates - AllocatePixmapPrivates () failed\n");
+ return FALSE;
+ }
+
+ /* Reserve Window memory for our privates */
+ if (!dixRegisterPrivateKey
+ (g_iWindowPrivateKey, PRIVATE_WINDOW, sizeof(winPrivWinRec))) {
+ ErrorF("winAllocatePrivates () - AllocateWindowPrivates () failed\n");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/*
+ * Colormap privates may be allocated after the default colormap has
+ * already been created for some screens. This initialization procedure
+ * is called for each default colormap that is found.
+ */
+
+Bool
+winInitCmapPrivates(ColormapPtr pcmap, int index)
+{
+ winDebug("winInitCmapPrivates\n");
+
+ /*
+ * I see no way that this function can do anything useful
+ * with only a ColormapPtr. We don't have the index for
+ * our dev privates yet, so we can't really initialize
+ * anything. Perhaps I am misunderstanding the purpose
+ * of this function.
+ */
+ /* That's definitely true.
+ * I therefore changed the API and added the index as argument.
+ */
+ return TRUE;
+}
+
+/*
+ * Allocate memory for our colormap privates
+ */
+
+Bool
+winAllocateCmapPrivates(ColormapPtr pCmap)
+{
+ winPrivCmapPtr pCmapPriv;
+ static unsigned long s_ulPrivateGeneration = 0;
+
+ winDebug("winAllocateCmapPrivates\n");
+
+ /* Get a new privates index when the server generation changes */
+ if (s_ulPrivateGeneration != serverGeneration) {
+ /* Save the new server generation */
+ s_ulPrivateGeneration = serverGeneration;
+ }
+
+ /* Allocate memory for our private structure */
+ pCmapPriv = (winPrivCmapPtr) malloc(sizeof(winPrivCmapRec));
+ if (!pCmapPriv) {
+ ErrorF("winAllocateCmapPrivates - malloc () failed\n");
+ return FALSE;
+ }
+
+ /* Initialize the memory of the private structure */
+ ZeroMemory(pCmapPriv, sizeof(winPrivCmapRec));
+
+ /* Register our colourmap private */
+ if (!dixRegisterPrivateKey(g_iCmapPrivateKey, PRIVATE_COLORMAP, 0)) {
+ ErrorF("winAllocateCmapPrivates - AllocateCmapPrivate () failed\n");
+ return FALSE;
+ }
+
+ /* Save the cmap private pointer */
+ winSetCmapPriv(pCmap, pCmapPriv);
+
+ winDebug("winAllocateCmapPrivates - Returning\n");
+
+ return TRUE;
+}
diff --git a/xorg-server/hw/xwin/winauth.c b/xorg-server/hw/xwin/winauth.c
index b603f70f5..18e370ef7 100644
--- a/xorg-server/hw/xwin/winauth.c
+++ b/xorg-server/hw/xwin/winauth.c
@@ -1,216 +1,197 @@
-/*
- *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, sublicense, and/or sell copies of the Software, and to
- *permit persons to whom the Software is furnished to do so, subject to
- *the following conditions:
- *
- *The above copyright notice and this permission notice shall be
- *included in all copies or substantial portions of the Software.
- *
- *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
- *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *Except as contained in this notice, the name of Harold L Hunt II
- *shall not be used in advertising or otherwise to promote the sale, use
- *or other dealings in this Software without prior written authorization
- *from Harold L Hunt II.
- *
- * Authors: Harold L Hunt II
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-
-#define GC X11_GC /* To avoid compilation errors later when including win.h (which also defines the GC type) */
-#include <X11/Xlib.h>
-#undef GC
-
-#include "win.h"
-
-/* Includes for authorization */
-#include "securitysrv.h"
-
-/*
- * Constants
- */
-
-#define AUTH_NAME "MIT-MAGIC-COOKIE-1"
-
-
-/*
- * Locals
- */
-
-static XID g_authId = 0;
-static unsigned int g_uiAuthDataLen = 0;
-static char *g_pAuthData = NULL;
-
-/*
- * Code to generate a MIT-MAGIC-COOKIE-1, copied from under XCSECURITY
- */
-
-
-
-#ifndef XCSECURITY
-static
-void
-GenerateRandomData (int len, char *buf)
-{
- int fd;
-#ifdef _MSC_VER
- static HANDLE hAdvApi32;
- static BOOLEAN (_stdcall * RtlGenRandom)(void *,unsigned long);
-
- if (!hAdvApi32)
- {
- hAdvApi32=LoadLibrary("advapi32.dll");
- RtlGenRandom=(BOOLEAN (_stdcall *)(void*,unsigned long))GetProcAddress(hAdvApi32,"SystemFunction036");
- }
- RtlGenRandom(buf, len);
-#else
- fd = open("/dev/urandom", O_RDONLY);
- read(fd, buf, len);
- close(fd);
-#endif
-}
-
-
-static char cookie[16]; /* 128 bits */
-
-XID
-static MitGenerateCookie (
- unsigned data_length,
- char *data,
- XID id,
- unsigned *data_length_return,
- char **data_return)
-{
- int i = 0;
- int status;
-
- while (data_length--)
- {
- cookie[i++] += *data++;
- if (i >= sizeof (cookie)) i = 0;
- }
- GenerateRandomData(sizeof (cookie), cookie);
- status = MitAddCookie(sizeof (cookie), cookie, id);
- if (!status)
- {
- id = -1;
- }
- else
- {
- *data_return = cookie;
- *data_length_return = sizeof (cookie);
- }
- return id;
-}
-
-static
-XID
-GenerateAuthorization(
- unsigned name_length,
- char *name,
- unsigned data_length,
- char *data,
- unsigned *data_length_return,
- char **data_return)
-{
- return MitGenerateCookie(data_length, data,
- FakeClientID(0), data_length_return, data_return);
-}
-#endif
-
-/*
- * Generate authorization cookie for internal server clients
- */
-
-Bool
-winGenerateAuthorization (void)
-{
- SecurityAuthorizationPtr pAuth = NULL;
-
- /* Call OS layer to generate authorization key */
- g_authId = GenerateAuthorization (strlen (AUTH_NAME),
- AUTH_NAME,
- 0,
- NULL,
- &g_uiAuthDataLen,
- &g_pAuthData);
- if ((XID) ~0L == g_authId)
- {
- ErrorF ("winGenerateAuthorization - GenerateAuthorization failed\n");
- goto auth_bailout;
- }
-#ifdef WINDBG
- else
- {
- winDebug("winGenerateAuthorization - GenerateAuthorization success!\n"
- "AuthDataLen: %d AuthData: %s\n",
- g_uiAuthDataLen, g_pAuthData);
- }
-#endif
-
-#ifdef XCSECURITY
- /* Allocate structure for additional auth information */
- pAuth = (SecurityAuthorizationPtr)
- malloc(sizeof (SecurityAuthorizationRec));
- if (!(pAuth))
- {
- ErrorF ("winGenerateAuthorization - Failed allocating "
- "SecurityAuthorizationPtr.\n");
- goto auth_bailout;
- }
-
- /* Fill in the auth fields */
- pAuth->id = g_authId;
- pAuth->timeout = 0; /* live for x seconds after refcnt == 0 */
- pAuth->group = None;
- pAuth->trustLevel = XSecurityClientTrusted;
- pAuth->refcnt = 1; /* this auth must stick around */
- pAuth->secondsRemaining = 0;
- pAuth->timer = NULL;
- pAuth->eventClients = NULL;
-
- /* Add the authorization to the server's auth list */
- if (!AddResource (g_authId,
- SecurityAuthorizationResType,
- pAuth))
- {
- ErrorF ("winGenerateAuthorization - AddResource failed for auth.\n");
- goto auth_bailout;
- }
-
- /* Don't free the auth data, since it is still used internally */
-#endif
-
- return TRUE;
-
- auth_bailout:
- free(pAuth);
-
- return FALSE;
-}
-
-/* Use our generated cookie for authentication */
-void
-winSetAuthorization(void)
-{
- if (g_pAuthData)
- XSetAuthorization (AUTH_NAME,
- strlen (AUTH_NAME),
- g_pAuthData,
- g_uiAuthDataLen);
-}
+/*
+ *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of Harold L Hunt II
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from Harold L Hunt II.
+ *
+ * Authors: Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+
+#define GC X11_GC /* To avoid compilation errors later when including win.h (which also defines the GC type) */
+#include <X11/Xlib.h>
+#undef GC
+
+#include "win.h"
+
+/* Includes for authorization */
+#include "securitysrv.h"
+
+/*
+ * Constants
+ */
+
+#define AUTH_NAME "MIT-MAGIC-COOKIE-1"
+
+/*
+ * Locals
+ */
+
+static XID g_authId = 0;
+static unsigned int g_uiAuthDataLen = 0;
+static char *g_pAuthData = NULL;
+
+/*
+ * Code to generate a MIT-MAGIC-COOKIE-1, copied from under XCSECURITY
+ */
+
+
+
+#ifndef XCSECURITY
+static
+ void
+GenerateRandomData(int len, char *buf)
+{
+ int fd;
+#ifdef _MSC_VER
+ static HANDLE hAdvApi32;
+ static BOOLEAN (_stdcall * RtlGenRandom)(void *,unsigned long);
+
+ if (!hAdvApi32)
+ {
+ hAdvApi32=LoadLibrary("advapi32.dll");
+ RtlGenRandom=(BOOLEAN (_stdcall *)(void*,unsigned long))GetProcAddress(hAdvApi32,"SystemFunction036");
+ }
+ RtlGenRandom(buf, len);
+#else
+ fd = open("/dev/urandom", O_RDONLY);
+ read(fd, buf, len);
+ close(fd);
+#endif
+}
+
+static char cookie[16]; /* 128 bits */
+
+XID
+ static
+MitGenerateCookie(unsigned data_length,
+ char *data,
+ XID id, unsigned *data_length_return, char **data_return)
+{
+ int i = 0;
+ int status;
+
+ while (data_length--) {
+ cookie[i++] += *data++;
+ if (i >= sizeof(cookie))
+ i = 0;
+ }
+ GenerateRandomData(sizeof(cookie), cookie);
+ status = MitAddCookie(sizeof(cookie), cookie, id);
+ if (!status) {
+ id = -1;
+ }
+ else {
+ *data_return = cookie;
+ *data_length_return = sizeof(cookie);
+ }
+ return id;
+}
+
+static
+ XID
+GenerateAuthorization(unsigned name_length,
+ char *name,
+ unsigned data_length,
+ char *data,
+ unsigned *data_length_return, char **data_return)
+{
+ return MitGenerateCookie(data_length, data,
+ FakeClientID(0), data_length_return, data_return);
+}
+#endif
+
+/*
+ * Generate authorization cookie for internal server clients
+ */
+
+Bool
+winGenerateAuthorization(void)
+{
+ SecurityAuthorizationPtr pAuth = NULL;
+
+ /* Call OS layer to generate authorization key */
+ g_authId = GenerateAuthorization(strlen(AUTH_NAME),
+ AUTH_NAME,
+ 0, NULL, &g_uiAuthDataLen, &g_pAuthData);
+ if ((XID) ~0L == g_authId) {
+ ErrorF("winGenerateAuthorization - GenerateAuthorization failed\n");
+ goto auth_bailout;
+ }
+#ifdef WINDBG
+ else {
+ winDebug("winGenerateAuthorization - GenerateAuthorization success!\n"
+ "AuthDataLen: %d AuthData: %s\n",
+ g_uiAuthDataLen, g_pAuthData);
+ }
+#endif
+
+#ifdef XCSECURITY
+ /* Allocate structure for additional auth information */
+ pAuth = (SecurityAuthorizationPtr)
+ malloc(sizeof(SecurityAuthorizationRec));
+ if (!(pAuth)) {
+ ErrorF("winGenerateAuthorization - Failed allocating "
+ "SecurityAuthorizationPtr.\n");
+ goto auth_bailout;
+ }
+
+ /* Fill in the auth fields */
+ pAuth->id = g_authId;
+ pAuth->timeout = 0; /* live for x seconds after refcnt == 0 */
+ pAuth->group = None;
+ pAuth->trustLevel = XSecurityClientTrusted;
+ pAuth->refcnt = 1; /* this auth must stick around */
+ pAuth->secondsRemaining = 0;
+ pAuth->timer = NULL;
+ pAuth->eventClients = NULL;
+
+ /* Add the authorization to the server's auth list */
+ if (!AddResource(g_authId, SecurityAuthorizationResType, pAuth)) {
+ ErrorF("winGenerateAuthorization - AddResource failed for auth.\n");
+ goto auth_bailout;
+ }
+
+ /* Don't free the auth data, since it is still used internally */
+#endif
+
+ return TRUE;
+
+ auth_bailout:
+ free(pAuth);
+
+ return FALSE;
+}
+
+/* Use our generated cookie for authentication */
+void
+winSetAuthorization(void)
+{
+ if (g_pAuthData)
+ XSetAuthorization(AUTH_NAME,
+ strlen(AUTH_NAME), g_pAuthData, g_uiAuthDataLen);
+}
diff --git a/xorg-server/hw/xwin/winblock.c b/xorg-server/hw/xwin/winblock.c
index a70d7a42a..c18d080fa 100644
--- a/xorg-server/hw/xwin/winblock.c
+++ b/xorg-server/hw/xwin/winblock.c
@@ -1,96 +1,89 @@
-/*
- *Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved.
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, sublicense, and/or sell copies of the Software, and to
- *permit persons to whom the Software is furnished to do so, subject to
- *the following conditions:
- *
- *The above copyright notice and this permission notice shall be
- *included in all copies or substantial portions of the Software.
- *
- *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
- *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *Except as contained in this notice, the name of Harold L Hunt II
- *shall not be used in advertising or otherwise to promote the sale, use
- *or other dealings in this Software without prior written authorization
- *from Harold L Hunt II.
- *
- * Authors: Harold L Hunt II
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-#include "winmsg.h"
-
-/* See Porting Layer Definition - p. 6 */
-void
-winBlockHandler (int nScreen,
- pointer pBlockData,
- pointer pTimeout,
- pointer pReadMask)
-{
-#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
- winScreenPriv((ScreenPtr)pBlockData);
-#endif
- MSG msg;
-#ifndef HAS_DEVWINDOWS
- struct timeval **tvp = pTimeout;
- if (*tvp != NULL)
- {
- (*tvp)->tv_sec = 0;
- (*tvp)->tv_usec = 100;
- }
-#endif
-
-#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
- /* Signal threaded modules to begin */
- if (pScreenPriv != NULL && !pScreenPriv->fServerStarted)
- {
- int iReturn;
-
- winDebug ("winBlockHandler - Releasing pmServerStarted\n");
-
- /* Flag that modules are to be started */
- pScreenPriv->fServerStarted = TRUE;
-
- /* Unlock the mutex for threaded modules */
- iReturn = pthread_mutex_unlock (&pScreenPriv->pmServerStarted);
- if (iReturn != 0)
- {
- ErrorF ("winBlockHandler - pthread_mutex_unlock () failed: %d\n",
- iReturn);
- goto winBlockHandler_ProcessMessages;
- }
-
- winDebug ("winBlockHandler - pthread_mutex_unlock () returned\n");
- }
-
-winBlockHandler_ProcessMessages:
-#endif
-
- /* Process all messages on our queue */
- while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
- {
- if ((g_hDlgDepthChange == 0
- || !IsDialogMessage (g_hDlgDepthChange, &msg))
- && (g_hDlgExit == 0
- || !IsDialogMessage (g_hDlgExit, &msg))
- && (g_hDlgAbout == 0
- || !IsDialogMessage (g_hDlgAbout, &msg)))
- {
- DispatchMessage (&msg);
- }
- }
-}
+/*
+ *Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of Harold L Hunt II
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from Harold L Hunt II.
+ *
+ * Authors: Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+#include "winmsg.h"
+
+/* See Porting Layer Definition - p. 6 */
+void
+winBlockHandler(int nScreen,
+ pointer pBlockData, pointer pTimeout, pointer pReadMask)
+{
+#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
+ winScreenPriv((ScreenPtr) pBlockData);
+#endif
+ MSG msg;
+
+#ifndef HAS_DEVWINDOWS
+ struct timeval **tvp = pTimeout;
+
+ if (*tvp != NULL) {
+ (*tvp)->tv_sec = 0;
+ (*tvp)->tv_usec = 100;
+ }
+#endif
+
+#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
+ /* Signal threaded modules to begin */
+ if (pScreenPriv != NULL && !pScreenPriv->fServerStarted) {
+ int iReturn;
+
+ winDebug("winBlockHandler - Releasing pmServerStarted\n");
+
+ /* Flag that modules are to be started */
+ pScreenPriv->fServerStarted = TRUE;
+
+ /* Unlock the mutex for threaded modules */
+ iReturn = pthread_mutex_unlock(&pScreenPriv->pmServerStarted);
+ if (iReturn != 0) {
+ ErrorF("winBlockHandler - pthread_mutex_unlock () failed: %d\n",
+ iReturn);
+ goto winBlockHandler_ProcessMessages;
+ }
+
+ winDebug("winBlockHandler - pthread_mutex_unlock () returned\n");
+ }
+
+ winBlockHandler_ProcessMessages:
+#endif
+
+ /* Process all messages on our queue */
+ while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
+ if ((g_hDlgDepthChange == 0
+ || !IsDialogMessage(g_hDlgDepthChange, &msg))
+ && (g_hDlgExit == 0 || !IsDialogMessage(g_hDlgExit, &msg))
+ && (g_hDlgAbout == 0 || !IsDialogMessage(g_hDlgAbout, &msg))) {
+ DispatchMessage(&msg);
+ }
+ }
+}
diff --git a/xorg-server/hw/xwin/winclipboard.h b/xorg-server/hw/xwin/winclipboard.h
index 41acfecce..d430b343f 100644
--- a/xorg-server/hw/xwin/winclipboard.h
+++ b/xorg-server/hw/xwin/winclipboard.h
@@ -58,12 +58,11 @@ typedef int pid_t;
/* Windows headers */
#include <X11/Xwindows.h>
-
/* Clipboard module constants */
#define WIN_CLIPBOARD_WINDOW_CLASS "xwinclip"
#define WIN_CLIPBOARD_WINDOW_TITLE "xwinclip"
#ifdef HAS_DEVWINDOWS
-# define WIN_MSG_QUEUE_FNAME "/dev/windows"
+#define WIN_MSG_QUEUE_FNAME "/dev/windows"
#endif
#define WIN_CONNECT_RETRIES 40
#define WIN_CONNECT_DELAY 4
@@ -82,68 +81,56 @@ typedef int pid_t;
*/
extern char *display;
-
/*
* winclipboardinit.c
*/
Bool
-winInitClipboard (void);
-
-HWND
-winClipboardCreateMessagingWindow (void);
+ winInitClipboard(void);
+HWND winClipboardCreateMessagingWindow(void);
/*
* winclipboardtextconv.c
*/
void
-winClipboardDOStoUNIX (char *pszData, int iLength);
+ winClipboardDOStoUNIX(char *pszData, int iLength);
void
-winClipboardUNIXtoDOS (unsigned char **ppszData, int iLength);
-
+ winClipboardUNIXtoDOS(unsigned char **ppszData, int iLength);
/*
* winclipboardthread.c
*/
-void *
-winClipboardProc (void *);
+void *winClipboardProc(void *);
void
-winDeinitClipboard (void);
-
+ winDeinitClipboard(void);
/*
* winclipboardunicode.c
*/
Bool
-winClipboardDetectUnicodeSupport (void);
-
+ winClipboardDetectUnicodeSupport(void);
/*
* winclipboardwndproc.c
*/
-BOOL
-winClipboardFlushWindowsMessageQueue (HWND hwnd);
+BOOL winClipboardFlushWindowsMessageQueue(HWND hwnd);
LRESULT CALLBACK
-winClipboardWindowProc (HWND hwnd, UINT message,
- WPARAM wParam, LPARAM lParam);
-
+winClipboardWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
/*
* winclipboardxevents.c
*/
int
-winClipboardFlushXEvents (HWND hwnd,
- int iWindow,
- Display *pDisplay,
- Bool fUnicodeSupport,
- Bool ClipboardOpened);
+
+winClipboardFlushXEvents(HWND hwnd,
+ int iWindow, Display * pDisplay, Bool fUnicodeSupport, Bool ClipboardOpened);
#endif
diff --git a/xorg-server/hw/xwin/winclipboardinit.c b/xorg-server/hw/xwin/winclipboardinit.c
index d5990900a..1ddb35775 100644
--- a/xorg-server/hw/xwin/winclipboardinit.c
+++ b/xorg-server/hw/xwin/winclipboardinit.c
@@ -1,148 +1,137 @@
-/*
- *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, sublicense, and/or sell copies of the Software, and to
- *permit persons to whom the Software is furnished to do so, subject to
- *the following conditions:
- *
- *The above copyright notice and this permission notice shall be
- *included in all copies or substantial portions of the Software.
- *
- *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
- *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *Except as contained in this notice, the name of Harold L Hunt II
- *shall not be used in advertising or otherwise to promote the sale, use
- *or other dealings in this Software without prior written authorization
- *from Harold L Hunt II.
- *
- * Authors: Harold L Hunt II
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "dixstruct.h"
-#include "winclipboard.h"
-#include "objbase.h"
-#include "ddraw.h"
-#include "winwindow.h"
-
-
-/*
- * Local typedefs
- */
-
-typedef int (*winDispatchProcPtr) (ClientPtr);
-
-int winProcSetSelectionOwner(ClientPtr /* client */);
-
-
-/*
- * References to external symbols
- */
-
-extern pthread_t g_ptClipboardProc;
-extern winDispatchProcPtr winProcSetSelectionOwnerOrig;
-extern Bool g_fClipboard;
-extern HWND g_hwndClipboard;
-
-
-/*
- * Intialize the Clipboard module
- */
-
-Bool
-winInitClipboard (void)
-{
- winDebug ("winInitClipboard ()\n");
-
- /* Wrap some internal server functions */
- if (ProcVector[X_SetSelectionOwner] != winProcSetSelectionOwner)
- {
- winProcSetSelectionOwnerOrig = ProcVector[X_SetSelectionOwner];
- ProcVector[X_SetSelectionOwner] = winProcSetSelectionOwner;
- }
-
- /* Spawn a thread for the Clipboard module */
- if (pthread_create (&g_ptClipboardProc,
- NULL,
- winClipboardProc,
- NULL))
- {
- /* Bail if thread creation failed */
- ErrorF ("winInitClipboard - pthread_create failed.\n");
- return FALSE;
- }
-
- return TRUE;
-}
-
-
-/*
- * Create the Windows window that we use to recieve Windows messages
- */
-
-HWND
-winClipboardCreateMessagingWindow (void)
-{
- WNDCLASSEX wc;
- HWND hwnd;
-
- /* Setup our window class */
- wc.cbSize=sizeof(WNDCLASSEX);
- wc.style = CS_HREDRAW | CS_VREDRAW;
- wc.lpfnWndProc = winClipboardWindowProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = GetModuleHandle (NULL);
- wc.hIcon = 0;
- wc.hCursor = 0;
- wc.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
- wc.lpszMenuName = NULL;
- wc.lpszClassName = WIN_CLIPBOARD_WINDOW_CLASS;
- wc.hIconSm = 0;
- RegisterClassEx (&wc);
-
- /* Create the window */
- hwnd = CreateWindowExA (0, /* Extended styles */
- WIN_CLIPBOARD_WINDOW_CLASS,/* Class name */
- WIN_CLIPBOARD_WINDOW_TITLE,/* Window name */
- WS_OVERLAPPED, /* Not visible anyway */
- CW_USEDEFAULT, /* Horizontal position */
- CW_USEDEFAULT, /* Vertical position */
- CW_USEDEFAULT, /* Right edge */
- CW_USEDEFAULT, /* Bottom edge */
- (HWND) NULL, /* No parent or owner window */
- (HMENU) NULL, /* No menu */
- GetModuleHandle (NULL),/* Instance handle */
- NULL); /* Creation data */
- assert (hwnd != NULL);
-
- /* I'm not sure, but we may need to call this to start message processing */
- ShowWindow (hwnd, SW_HIDE);
-
- /* Similarly, we may need a call to this even though we don't paint */
- UpdateWindow (hwnd);
-
- return hwnd;
-}
-
-void
-winFixClipboardChain (int Removed)
-{
- if (g_fClipboard
- && g_hwndClipboard)
- {
- PostMessage (g_hwndClipboard, WM_WM_REINIT, Removed, 0);
- }
-}
+/*
+ *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of Harold L Hunt II
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from Harold L Hunt II.
+ *
+ * Authors: Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "dixstruct.h"
+#include "winclipboard.h"
+#include "objbase.h"
+#include "ddraw.h"
+#include "winwindow.h"
+
+/*
+ * Local typedefs
+ */
+
+typedef int (*winDispatchProcPtr) (ClientPtr);
+
+int winProcSetSelectionOwner(ClientPtr /* client */ );
+
+/*
+ * References to external symbols
+ */
+
+extern pthread_t g_ptClipboardProc;
+extern winDispatchProcPtr winProcSetSelectionOwnerOrig;
+extern Bool g_fClipboard;
+extern HWND g_hwndClipboard;
+
+/*
+ * Intialize the Clipboard module
+ */
+
+Bool
+winInitClipboard(void)
+{
+ winDebug ("winInitClipboard ()\n");
+
+ /* Wrap some internal server functions */
+ if (ProcVector[X_SetSelectionOwner] != winProcSetSelectionOwner) {
+ winProcSetSelectionOwnerOrig = ProcVector[X_SetSelectionOwner];
+ ProcVector[X_SetSelectionOwner] = winProcSetSelectionOwner;
+ }
+
+ /* Spawn a thread for the Clipboard module */
+ if (pthread_create(&g_ptClipboardProc, NULL, winClipboardProc, NULL)) {
+ /* Bail if thread creation failed */
+ ErrorF("winInitClipboard - pthread_create failed.\n");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/*
+ * Create the Windows window that we use to recieve Windows messages
+ */
+
+HWND
+winClipboardCreateMessagingWindow(void)
+{
+ WNDCLASSEX wc;
+ HWND hwnd;
+
+ /* Setup our window class */
+ wc.cbSize = sizeof(WNDCLASSEX);
+ wc.style = CS_HREDRAW | CS_VREDRAW;
+ wc.lpfnWndProc = winClipboardWindowProc;
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 0;
+ wc.hInstance = GetModuleHandle(NULL);
+ wc.hIcon = 0;
+ wc.hCursor = 0;
+ wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
+ wc.lpszMenuName = NULL;
+ wc.lpszClassName = WIN_CLIPBOARD_WINDOW_CLASS;
+ wc.hIconSm = 0;
+ RegisterClassEx(&wc);
+
+ /* Create the window */
+ hwnd = CreateWindowExA(0, /* Extended styles */
+ WIN_CLIPBOARD_WINDOW_CLASS, /* Class name */
+ WIN_CLIPBOARD_WINDOW_TITLE, /* Window name */
+ WS_OVERLAPPED, /* Not visible anyway */
+ CW_USEDEFAULT, /* Horizontal position */
+ CW_USEDEFAULT, /* Vertical position */
+ CW_USEDEFAULT, /* Right edge */
+ CW_USEDEFAULT, /* Bottom edge */
+ (HWND) NULL, /* No parent or owner window */
+ (HMENU) NULL, /* No menu */
+ GetModuleHandle(NULL), /* Instance handle */
+ NULL); /* Creation data */
+ assert(hwnd != NULL);
+
+ /* I'm not sure, but we may need to call this to start message processing */
+ ShowWindow(hwnd, SW_HIDE);
+
+ /* Similarly, we may need a call to this even though we don't paint */
+ UpdateWindow(hwnd);
+
+ return hwnd;
+}
+
+void
+winFixClipboardChain(int Removed)
+{
+ if (g_fClipboard && g_hwndClipboard) {
+ PostMessage (g_hwndClipboard, WM_WM_REINIT, Removed, 0);
+ }
+}
diff --git a/xorg-server/hw/xwin/winclipboardtextconv.c b/xorg-server/hw/xwin/winclipboardtextconv.c
index 400f560fa..74a351b17 100644
--- a/xorg-server/hw/xwin/winclipboardtextconv.c
+++ b/xorg-server/hw/xwin/winclipboardtextconv.c
@@ -36,9 +36,9 @@
#include <stdlib.h>
void
-winClipboardDOStoUNIX (char *pszSrc, int iLength);
+ winClipboardDOStoUNIX(char *pszSrc, int iLength);
void
-winClipboardUNIXtoDOS (unsigned char **ppszData, int iLength);
+ winClipboardUNIXtoDOS(unsigned char **ppszData, int iLength);
/*
* Convert \r\n to \n
@@ -48,108 +48,100 @@ winClipboardUNIXtoDOS (unsigned char **ppszData, int iLength);
*/
void
-winClipboardDOStoUNIX (char *pszSrc, int iLength)
+winClipboardDOStoUNIX(char *pszSrc, int iLength)
{
- char *pszDest = pszSrc;
- char *pszEnd = pszSrc + iLength;
+ char *pszDest = pszSrc;
+ char *pszEnd = pszSrc + iLength;
- /* Loop until the last character */
- while (pszSrc < pszEnd)
- {
- /* Copy the current source character to current destination character */
- *pszDest = *pszSrc;
+ /* Loop until the last character */
+ while (pszSrc < pszEnd) {
+ /* Copy the current source character to current destination character */
+ *pszDest = *pszSrc;
- /* Advance to the next source character */
- pszSrc++;
+ /* Advance to the next source character */
+ pszSrc++;
- /* Don't advance the destination character if we need to drop an \r */
- if (*pszDest != '\r' || *pszSrc != '\n')
- pszDest++;
+ /* Don't advance the destination character if we need to drop an \r */
+ if (*pszDest != '\r' || *pszSrc != '\n')
+ pszDest++;
}
- /* Move the terminating null */
- *pszDest = '\0';
+ /* Move the terminating null */
+ *pszDest = '\0';
}
-
/*
* Convert \n to \r\n
*/
void
-winClipboardUNIXtoDOS (unsigned char **ppszData, int iLength)
+winClipboardUNIXtoDOS(unsigned char **ppszData, int iLength)
{
- int iNewlineCount = 0;
- unsigned char *pszSrc = *ppszData;
- unsigned char *pszEnd = pszSrc + iLength;
- unsigned char *pszDest = NULL, *pszDestBegin = NULL;
-
- winDebug("UNIXtoDOS () - Original data:'%s'\n", *ppszData);
-
- /* Count \n characters without leading \r */
- while (pszSrc < pszEnd)
- {
- /* Skip ahead two character if found set of \r\n */
- if (*pszSrc == '\r' && pszSrc + 1 < pszEnd && *(pszSrc + 1) == '\n')
- {
- pszSrc += 2;
- continue;
- }
-
- /* Increment the count if found naked \n */
- if (*pszSrc == '\n')
- {
- iNewlineCount++;
- }
-
- pszSrc++;
+ int iNewlineCount = 0;
+ unsigned char *pszSrc = *ppszData;
+ unsigned char *pszEnd = pszSrc + iLength;
+ unsigned char *pszDest = NULL, *pszDestBegin = NULL;
+
+ winDebug("UNIXtoDOS () - Original data:'%s'\n", *ppszData);
+
+ /* Count \n characters without leading \r */
+ while (pszSrc < pszEnd) {
+ /* Skip ahead two character if found set of \r\n */
+ if (*pszSrc == '\r' && pszSrc + 1 < pszEnd && *(pszSrc + 1) == '\n') {
+ pszSrc += 2;
+ continue;
+ }
+
+ /* Increment the count if found naked \n */
+ if (*pszSrc == '\n') {
+ iNewlineCount++;
+ }
+
+ pszSrc++;
}
-
- /* Return if no naked \n's */
- if (iNewlineCount == 0)
- return;
-
- /* Allocate a new string */
- pszDestBegin = pszDest = malloc (iLength + iNewlineCount + 1);
-
- /* Set source pointer to beginning of data string */
- pszSrc = *ppszData;
-
- /* Loop through all characters in source string */
- while (pszSrc < pszEnd)
- {
- /* Copy line endings that are already valid */
- if (*pszSrc == '\r' && pszSrc + 1 < pszEnd && *(pszSrc + 1) == '\n')
- {
- *pszDest = *pszSrc;
- *(pszDest + 1) = *(pszSrc + 1);
- pszDest += 2;
- pszSrc += 2;
- continue;
- }
-
- /* Add \r to naked \n's */
- if (*pszSrc == '\n')
- {
- *pszDest = '\r';
- *(pszDest + 1) = *pszSrc;
- pszDest += 2;
- pszSrc += 1;
- continue;
- }
-
- /* Copy normal characters */
- *pszDest = *pszSrc;
- pszSrc++;
- pszDest++;
+
+ /* Return if no naked \n's */
+ if (iNewlineCount == 0)
+ return;
+
+ /* Allocate a new string */
+ pszDestBegin = pszDest = malloc(iLength + iNewlineCount + 1);
+
+ /* Set source pointer to beginning of data string */
+ pszSrc = *ppszData;
+
+ /* Loop through all characters in source string */
+ while (pszSrc < pszEnd) {
+ /* Copy line endings that are already valid */
+ if (*pszSrc == '\r' && pszSrc + 1 < pszEnd && *(pszSrc + 1) == '\n') {
+ *pszDest = *pszSrc;
+ *(pszDest + 1) = *(pszSrc + 1);
+ pszDest += 2;
+ pszSrc += 2;
+ continue;
+ }
+
+ /* Add \r to naked \n's */
+ if (*pszSrc == '\n') {
+ *pszDest = '\r';
+ *(pszDest + 1) = *pszSrc;
+ pszDest += 2;
+ pszSrc += 1;
+ continue;
+ }
+
+ /* Copy normal characters */
+ *pszDest = *pszSrc;
+ pszSrc++;
+ pszDest++;
}
- /* Put terminating null at end of new string */
- *pszDest = '\0';
+ /* Put terminating null at end of new string */
+ *pszDest = '\0';
- /* Swap string pointers */
- free (*ppszData);
- *ppszData = pszDestBegin;
+ /* Swap string pointers */
+ free(*ppszData);
+ *ppszData = pszDestBegin;
- winDebug("UNIXtoDOS () - Final string:'%s'\n", pszDestBegin);
+ winDebug("UNIXtoDOS () - Final string:'%s'\n", pszDestBegin);
}
diff --git a/xorg-server/hw/xwin/winclipboardthread.c b/xorg-server/hw/xwin/winclipboardthread.c
index 758bbd32d..50643149b 100644
--- a/xorg-server/hw/xwin/winclipboardthread.c
+++ b/xorg-server/hw/xwin/winclipboardthread.c
@@ -46,42 +46,39 @@
#ifdef _MSC_VER
#define snprintf _snprintf
#endif
-
/*
* References to external symbols
*/
-extern Bool g_fUnicodeClipboard;
-extern unsigned long serverGeneration;
-extern Bool g_fClipboardStarted;
-extern Bool g_fClipboardLaunched;
-extern HWND g_hwndClipboard;
-extern void *g_pClipboardDisplay;
-extern Window g_iClipboardWindow;
+extern Bool g_fUnicodeClipboard;
+extern unsigned long serverGeneration;
+extern Bool g_fClipboardStarted;
+extern Bool g_fClipboardLaunched;
+extern HWND g_hwndClipboard;
+extern void *g_pClipboardDisplay;
+extern Window g_iClipboardWindow;
extern Bool g_fClipboardPrimary;
-
/*
* Global variables
*/
-static jmp_buf g_jmpEntry;
+static jmp_buf g_jmpEntry;
static XIOErrorHandler g_winClipboardOldIOErrorHandler;
static pthread_t g_winClipboardProcThread;
-Bool g_fUnicodeSupport = FALSE;
-Bool g_fUseUnicode = FALSE;
-
+Bool g_fUnicodeSupport = FALSE;
+Bool g_fUseUnicode = FALSE;
/*
* Local function prototypes
*/
static int
-winClipboardErrorHandler (Display *pDisplay, XErrorEvent *pErr);
+ winClipboardErrorHandler(Display * pDisplay, XErrorEvent * pErr);
static int
-winClipboardIOErrorHandler (Display *pDisplay);
+ winClipboardIOErrorHandler(Display * pDisplay);
static void
winClipboardThreadExit(void *arg);
@@ -90,348 +87,321 @@ winClipboardThreadExit(void *arg);
*/
void *
-winClipboardProc (void *pvNotUsed)
+winClipboardProc(void *pvNotUsed)
{
- Atom atomClipboard, atomClipboardManager;
- int iReturn;
- HWND hwnd = NULL;
- int iConnectionNumber = 0;
+ Atom atomClipboard, atomClipboardManager;
+ int iReturn;
+ HWND hwnd = NULL;
+ int iConnectionNumber = 0;
+
#ifdef HAS_DEVWINDOWS
- int fdMessageQueue = 0;
+ int fdMessageQueue = 0;
#else
- struct timeval tvTimeout;
+ struct timeval tvTimeout;
#endif
- fd_set fdsRead;
- int iMaxDescriptor;
- Display *pDisplay = NULL;
- Window iWindow = None;
- int iRetries;
- Bool fUseUnicode;
- char szDisplay[512];
- int iSelectError;
-
- pthread_cleanup_push(&winClipboardThreadExit, NULL);
+ fd_set fdsRead;
+ int iMaxDescriptor;
+ Display *pDisplay = NULL;
+ Window iWindow = None;
+ int iRetries;
+ Bool fUseUnicode;
+ char szDisplay[512];
+ int iSelectError;
- winDebug ("winClipboardProc - Hello\n");
+ pthread_cleanup_push(&winClipboardThreadExit, NULL);
- /* Do we have Unicode support? */
- g_fUnicodeSupport = winClipboardDetectUnicodeSupport ();
+ winDebug ("winClipboardProc - Hello\n");
- /* Do we use Unicode clipboard? */
- fUseUnicode = g_fUnicodeClipboard && g_fUnicodeSupport;
+ /* Do we have Unicode support? */
+ g_fUnicodeSupport = winClipboardDetectUnicodeSupport();
- /* Save the Unicode support flag in a global */
- g_fUseUnicode = fUseUnicode;
+ /* Do we use Unicode clipboard? */
+ fUseUnicode = g_fUnicodeClipboard && g_fUnicodeSupport;
- /* Create Windows messaging window */
- hwnd = winClipboardCreateMessagingWindow ();
-
- /* Save copy of HWND in screen privates */
- g_hwndClipboard = hwnd;
-
- /* Set error handler */
- XSetErrorHandler (winClipboardErrorHandler);
- g_winClipboardProcThread = pthread_self();
- g_winClipboardOldIOErrorHandler = XSetIOErrorHandler (winClipboardIOErrorHandler);
+ /* Save the Unicode support flag in a global */
+ g_fUseUnicode = fUseUnicode;
- /* Set jump point for Error exits */
- iReturn = setjmp (g_jmpEntry);
+ /* Create Windows messaging window */
+ hwnd = winClipboardCreateMessagingWindow ();
- /* Check if we should continue operations */
- if (iReturn != WIN_JMP_ERROR_IO
- && iReturn != WIN_JMP_OKAY)
- {
- /* setjmp returned an unknown value, exit */
- ErrorF ("winClipboardProc - setjmp returned: %d exiting\n",
- iReturn);
- goto thread_errorexit;
+ /* Save copy of HWND in screen privates */
+ g_hwndClipboard = hwnd;
+
+ /* Set error handler */
+ XSetErrorHandler(winClipboardErrorHandler);
+ g_winClipboardProcThread = pthread_self();
+ g_winClipboardOldIOErrorHandler =
+ XSetIOErrorHandler(winClipboardIOErrorHandler);
+
+ /* Set jump point for Error exits */
+ iReturn = setjmp(g_jmpEntry);
+
+ /* Check if we should continue operations */
+ if (iReturn != WIN_JMP_ERROR_IO && iReturn != WIN_JMP_OKAY) {
+ /* setjmp returned an unknown value, exit */
+ ErrorF("winClipboardProc - setjmp returned: %d exiting\n", iReturn);
+ goto thread_errorexit;
}
- else if (iReturn == WIN_JMP_ERROR_IO)
- {
- /* TODO: Cleanup the Win32 window and free any allocated memory */
- ErrorF ("winClipboardProc - setjmp returned for IO Error Handler.\n");
+ else if (iReturn == WIN_JMP_ERROR_IO) {
+ /* TODO: Cleanup the Win32 window and free any allocated memory */
+ ErrorF("winClipboardProc - setjmp returned for IO Error Handler.\n");
}
- /* Use our generated cookie for authentication */
- winSetAuthorization();
-
- /* Initialize retry count */
- iRetries = 0;
-
- /* Setup the display connection string x */
- /*
- * NOTE: Always connect to screen 0 since we require that screen
- * numbers start at 0 and increase without gaps. We only need
- * to connect to one screen on the display to get events
- * for all screens on the display. That is why there is only
- * one clipboard client thread.
- */
- winGetDisplayName(szDisplay,0);
-
- /* Print the display connection string */
- winDebug ("winClipboardProc - DISPLAY=%s\n", szDisplay);
-
- /* Open the X display */
- do
- {
- pDisplay = XOpenDisplay (szDisplay);
- if (pDisplay == NULL)
- {
- ErrorF ("winClipboardProc - Could not open display, "
- "try: %d, sleeping: %d\n",
- iRetries + 1, WIN_CONNECT_DELAY);
- ++iRetries;
- sleep (WIN_CONNECT_DELAY);
- continue;
- }
- else
- break;
+ /* Use our generated cookie for authentication */
+ winSetAuthorization();
+
+ /* Initialize retry count */
+ iRetries = 0;
+
+ /* Setup the display connection string x */
+ /*
+ * NOTE: Always connect to screen 0 since we require that screen
+ * numbers start at 0 and increase without gaps. We only need
+ * to connect to one screen on the display to get events
+ * for all screens on the display. That is why there is only
+ * one clipboard client thread.
+ */
+ winGetDisplayName(szDisplay,0);
+
+ /* Print the display connection string */
+ winDebug ("winClipboardProc - DISPLAY=%s\n", szDisplay);
+
+ /* Open the X display */
+ do {
+ pDisplay = XOpenDisplay(szDisplay);
+ if (pDisplay == NULL) {
+ ErrorF("winClipboardProc - Could not open display, "
+ "try: %d, sleeping: %d\n", iRetries + 1, WIN_CONNECT_DELAY);
+ ++iRetries;
+ sleep(WIN_CONNECT_DELAY);
+ continue;
+ }
+ else
+ break;
}
- while (pDisplay == NULL && iRetries < WIN_CONNECT_RETRIES);
+ while (pDisplay == NULL && iRetries < WIN_CONNECT_RETRIES);
- /* Make sure that the display opened */
- if (pDisplay == NULL)
- {
- ErrorF ("winClipboardProc - Failed opening the display, giving up\n");
- goto thread_errorexit;
+ /* Make sure that the display opened */
+ if (pDisplay == NULL) {
+ ErrorF("winClipboardProc - Failed opening the display, giving up\n");
+ goto thread_errorexit;
}
- /* Save the display in the screen privates */
- g_pClipboardDisplay = pDisplay;
+ /* Save the display in the screen privates */
+ g_pClipboardDisplay = pDisplay;
- winDebug ("winClipboardProc - XOpenDisplay () returned and "
- "successfully opened the display.\n");
+ winDebug ("winClipboardProc - XOpenDisplay () returned and "
+ "successfully opened the display.\n");
- /* Get our connection number */
- iConnectionNumber = ConnectionNumber (pDisplay);
+ /* Get our connection number */
+ iConnectionNumber = ConnectionNumber(pDisplay);
- winDebug("Clipboard is using socket %d\n",iConnectionNumber);
+ winDebug("Clipboard is using socket %d\n",iConnectionNumber);
#ifdef HAS_DEVWINDOWS
- /* Open a file descriptor for the windows message queue */
- fdMessageQueue = open (WIN_MSG_QUEUE_FNAME, _O_RDONLY);
- if (fdMessageQueue == -1)
- {
- ErrorF ("winClipboardProc - Failed opening %s\n", WIN_MSG_QUEUE_FNAME);
+ /* Open a file descriptor for the windows message queue */
+ fdMessageQueue = open (WIN_MSG_QUEUE_FNAME, _O_RDONLY);
+ if (fdMessageQueue == -1) {
+ ErrorF("winClipboardProc - Failed opening %s\n", WIN_MSG_QUEUE_FNAME);
goto thread_errorexit;
}
- /* Find max of our file descriptors */
- iMaxDescriptor = max (fdMessageQueue, iConnectionNumber) + 1;
+ /* Find max of our file descriptors */
+ iMaxDescriptor = max(fdMessageQueue, iConnectionNumber) + 1;
#else
- iMaxDescriptor = iConnectionNumber + 1;
+ iMaxDescriptor = iConnectionNumber + 1;
#endif
- /* Create atoms */
- atomClipboard = XInternAtom (pDisplay, "CLIPBOARD", False);
- atomClipboardManager = XInternAtom (pDisplay, "CLIPBOARD_MANAGER", False);
- XInternAtom (pDisplay, WIN_LOCAL_PROPERTY, False);
- XInternAtom (pDisplay, "UTF8_STRING", False);
- XInternAtom (pDisplay, "COMPOUND_TEXT", False);
- XInternAtom (pDisplay, "TARGETS", False);
-
- /* Create a messaging window */
- iWindow = XCreateSimpleWindow (pDisplay,
- DefaultRootWindow (pDisplay),
- 1, 1,
- 500, 500,
- 0,
- BlackPixel (pDisplay, 0),
- BlackPixel (pDisplay, 0));
- if (iWindow == 0)
- {
- ErrorF ("winClipboardProc - Could not create an X window.\n");
- goto thread_errorexit;
+ /* Create atoms */
+ atomClipboard = XInternAtom(pDisplay, "CLIPBOARD", False);
+ atomClipboardManager = XInternAtom(pDisplay, "CLIPBOARD_MANAGER", False);
+ XInternAtom (pDisplay, WIN_LOCAL_PROPERTY, False);
+ XInternAtom (pDisplay, "UTF8_STRING", False);
+ XInternAtom (pDisplay, "COMPOUND_TEXT", False);
+ XInternAtom (pDisplay, "TARGETS", False);
+
+ /* Create a messaging window */
+ iWindow = XCreateSimpleWindow(pDisplay,
+ DefaultRootWindow(pDisplay),
+ 1, 1,
+ 500, 500,
+ 0,
+ BlackPixel(pDisplay, 0),
+ BlackPixel(pDisplay, 0));
+ if (iWindow == 0) {
+ ErrorF("winClipboardProc - Could not create an X window.\n");
+ goto thread_errorexit;
}
- XStoreName(pDisplay, iWindow, "xwinclip");
+ XStoreName(pDisplay, iWindow, "xwinclip");
- /* Select event types to watch */
- if (XSelectInput (pDisplay,
- iWindow,
- PropertyChangeMask) == BadWindow)
- ErrorF ("winClipboardProc - XSelectInput generated BadWindow "
- "on messaging window\n");
+ /* Select event types to watch */
+ if (XSelectInput(pDisplay, iWindow, PropertyChangeMask) == BadWindow)
+ ErrorF("winClipboardProc - XSelectInput generated BadWindow "
+ "on messaging window\n");
- /* Save the window in the screen privates */
- g_iClipboardWindow = iWindow;
+ /* Save the window in the screen privates */
+ g_iClipboardWindow = iWindow;
- /* Assert ownership of selections if Win32 clipboard is owned */
- if (NULL != GetClipboardOwner ())
- {
+ /* Assert ownership of selections if Win32 clipboard is owned */
+ if (NULL != GetClipboardOwner()) {
if (g_fClipboardPrimary)
{
- /* PRIMARY */
- winDebug("winClipboardProc - asserted ownership.\n");
- iReturn = XSetSelectionOwner (pDisplay, XA_PRIMARY,
- iWindow, CurrentTime);
- if (iReturn == BadAtom || iReturn == BadWindow /*||
- XGetSelectionOwner (pDisplay, XA_PRIMARY) != iWindow*/)
- {
- ErrorF ("winClipboardProc - Could not set PRIMARY owner\n");
- goto thread_errorexit;
- }
+ /* PRIMARY */
+ winDebug("winClipboardProc - asserted ownership.\n");
+ iReturn = XSetSelectionOwner (pDisplay, XA_PRIMARY,
+ iWindow, CurrentTime);
+ if (iReturn == BadAtom || iReturn == BadWindow /*||
+ XGetSelectionOwner (pDisplay, XA_PRIMARY) != iWindow*/)
+ {
+ ErrorF ("winClipboardProc - Could not set PRIMARY owner\n");
+ goto thread_errorexit;
+ }
}
- /* CLIPBOARD */
- iReturn = XSetSelectionOwner (pDisplay, atomClipboard,
- iWindow, CurrentTime);
+ /* CLIPBOARD */
+ iReturn = XSetSelectionOwner(pDisplay, atomClipboard,
+ iWindow, CurrentTime);
if (iReturn == BadAtom || iReturn == BadWindow /*||
- XGetSelectionOwner (pDisplay, atomClipboard) != iWindow*/)
- {
- ErrorF ("winClipboardProc - Could not set CLIPBOARD owner\n");
- goto thread_errorexit;
- }
+ XGetSelectionOwner (pDisplay, atomClipboard) != iWindow*/)
+ {
+ ErrorF ("winClipboardProc - Could not set CLIPBOARD owner\n");
+ goto thread_errorexit;
+ }
}
- /* Pre-flush X events */
- /*
- * NOTE: Apparently you'll freeze if you don't do this,
- * because there may be events in local data structures
- * already.
- */
- /*winClipboardFlushXEvents (hwnd,
- iWindow,
- pDisplay,
- fUseUnicode);
- */
- /* Pre-flush Windows messages */
- winDebug ("Start flushing \n");
- if (!winClipboardFlushWindowsMessageQueue (hwnd))
- {
- ErrorF ("winClipboardFlushWindowsMessageQueue - returned 0\n");
- goto thread_errorexit;
- }
-
- winDebug ("winClipboardProc - Started\n");
- /* Signal that the clipboard client has started */
- g_fClipboardStarted = TRUE;
-
- /* Loop for X events */
- while (1)
+ /* Pre-flush X events */
+ /*
+ * NOTE: Apparently you'll freeze if you don't do this,
+ * because there may be events in local data structures
+ * already.
+ */
+ //winClipboardFlushXEvents(hwnd, iWindow, pDisplay, fUseUnicode);
+
+ /* Pre-flush Windows messages */
+ winDebug ("Start flushing \n");
+ if (!winClipboardFlushWindowsMessageQueue(hwnd))
{
- /* Setup the file descriptor set */
- /*
- * NOTE: You have to do this before every call to select
- * because select modifies the mask to indicate
- * which descriptors are ready.
- */
- FD_ZERO (&fdsRead);
- FD_SET (iConnectionNumber, &fdsRead);
+ ErrorF ("winClipboardFlushWindowsMessageQueue - returned 0\n");
+ goto thread_errorexit;
+ }
+
+ winDebug ("winClipboardProc - Started\n");
+ /* Signal that the clipboard client has started */
+ g_fClipboardStarted = TRUE;
+
+ /* Loop for X events */
+ while (1) {
+ /* Setup the file descriptor set */
+ /*
+ * NOTE: You have to do this before every call to select
+ * because select modifies the mask to indicate
+ * which descriptors are ready.
+ */
+ FD_ZERO(&fdsRead);
+ FD_SET(iConnectionNumber, &fdsRead);
#ifdef HAS_DEVWINDOWS
- FD_SET (fdMessageQueue, &fdsRead);
+ FD_SET(fdMessageQueue, &fdsRead);
#else
- tvTimeout.tv_sec = 0;
- tvTimeout.tv_usec = 100;
+ tvTimeout.tv_sec = 0;
+ tvTimeout.tv_usec = 100;
#endif
- /* Wait for a Windows event or an X event */
- iReturn = select (iMaxDescriptor, /* Highest fds number */
- &fdsRead, /* Read mask */
- NULL, /* No write mask */
- NULL, /* No exception mask */
+ /* Wait for a Windows event or an X event */
+ iReturn = select(iMaxDescriptor, /* Highest fds number */
+ &fdsRead, /* Read mask */
+ NULL, /* No write mask */
+ NULL, /* No exception mask */
#ifdef HAS_DEVWINDOWS
- NULL /* No timeout */
+ NULL /* No timeout */
#else
- &tvTimeout /* Set timeout */
+ &tvTimeout /* Set timeout */
#endif
- );
+ );
#ifndef HAS_WINSOCK
- iSelectError = errno;
+ iSelectError = errno;
#else
- iSelectError = WSAGetLastError();
+ iSelectError = WSAGetLastError();
#endif
- if (iReturn < 0)
- {
+ if (iReturn < 0) {
#ifndef HAS_WINSOCK
- if (iSelectError == EINTR)
+ if (iSelectError == EINTR)
#else
- if (iSelectError == WSAEINTR)
+ if (iSelectError == WSAEINTR)
#endif
- continue;
-
- ErrorF ("winClipboardProc - Call to select () failed: %d. "
- "Bailing.\n", iReturn);
- break;
- }
+ continue;
- /* Branch on which descriptor became active */
+ ErrorF("winClipboardProc - Call to select () failed: %d. "
+ "Bailing.\n", iReturn);
+ break;
+ }
+
+ /* Branch on which descriptor became active */
// if (FD_ISSET (iConnectionNumber, &fdsRead))
// { Also do it when no read since winClipboardFlushXEvents
// is sending the output.
- /* Process X events */
- /* Exit when we see that server is shutting down */
- iReturn = winClipboardFlushXEvents (hwnd,
- iWindow,
- pDisplay,
- fUseUnicode,
- FALSE
- );
- if (WIN_XEVENTS_SHUTDOWN == iReturn)
- {
- ErrorF ("winClipboardProc - winClipboardFlushXEvents "
- "trapped shutdown event, exiting main loop.\n");
- break;
- }
+ /* Process X events */
+ /* Exit when we see that server is shutting down */
+ iReturn = winClipboardFlushXEvents(hwnd,
+ iWindow, pDisplay, fUseUnicode, FALSE);
+ if (WIN_XEVENTS_SHUTDOWN == iReturn) {
+ ErrorF("winClipboardProc - winClipboardFlushXEvents "
+ "trapped shutdown event, exiting main loop.\n");
+ break;
+ }
// }
#ifdef HAS_DEVWINDOWS
- /* Check for Windows event ready */
- if (FD_ISSET (fdMessageQueue, &fdsRead))
+ /* Check for Windows event ready */
+ if (FD_ISSET(fdMessageQueue, &fdsRead))
#else
- if (1)
+ if (1)
#endif
- {
- /* Process Windows messages */
- if (!winClipboardFlushWindowsMessageQueue (hwnd))
- {
- ErrorF ("winClipboardProc - "
- "winClipboardFlushWindowsMessageQueue trapped "
- "WM_QUIT message, exiting main loop.\n");
- break;
- }
- }
+ {
+ /* Process Windows messages */
+ if (!winClipboardFlushWindowsMessageQueue(hwnd)) {
+ ErrorF("winClipboardProc - "
+ "winClipboardFlushWindowsMessageQueue trapped "
+ "WM_QUIT message, exiting main loop.\n");
+ break;
+ }
+ }
}
- /* Close our X window */
- if (pDisplay && iWindow)
- {
- iReturn = XDestroyWindow (pDisplay, iWindow);
- if (iReturn == BadWindow)
- ErrorF ("winClipboardProc - XDestroyWindow returned BadWindow.\n");
+ /* Close our X window */
+ if (pDisplay && iWindow) {
+ iReturn = XDestroyWindow(pDisplay, iWindow);
+ if (iReturn == BadWindow)
+ ErrorF("winClipboardProc - XDestroyWindow returned BadWindow.\n");
#ifdef WINDBG
- else
- winDebug ("winClipboardProc - XDestroyWindow succeeded.\n");
+ else
+ winDebug("winClipboardProc - XDestroyWindow succeeded.\n");
#endif
}
-
#ifdef HAS_DEVWINDOWS
- /* Close our Win32 message handle */
- if (fdMessageQueue)
- close (fdMessageQueue);
+ /* Close our Win32 message handle */
+ if (fdMessageQueue)
+ close(fdMessageQueue);
#endif
#if 0
- /*
- * FIXME: XCloseDisplay hangs if we call it, as of 2004/03/26. The
- * XSync and XSelectInput calls did not help.
- */
+ /*
+ * FIXME: XCloseDisplay hangs if we call it, as of 2004/03/26. The
+ * XSync and XSelectInput calls did not help.
+ */
- /* Discard any remaining events */
- XSync (pDisplay, TRUE);
+ /* Discard any remaining events */
+ XSync(pDisplay, TRUE);
- /* Select event types to watch */
- XSelectInput (pDisplay,
- DefaultRootWindow (pDisplay),
- None);
+ /* Select event types to watch */
+ XSelectInput(pDisplay, DefaultRootWindow(pDisplay), None);
- /* Close our X display */
- if (pDisplay)
- {
- XCloseDisplay (pDisplay);
+ /* Close our X display */
+ if (pDisplay) {
+ XCloseDisplay(pDisplay);
}
#endif
@@ -458,24 +428,20 @@ commonexit:
pthread_cleanup_pop(0);
- return NULL;
+ return NULL;
}
-
/*
* winClipboardErrorHandler - Our application specific error handler
*/
static int
-winClipboardErrorHandler (Display *pDisplay, XErrorEvent *pErr)
+winClipboardErrorHandler(Display * pDisplay, XErrorEvent * pErr)
{
- char pszErrorMsg[100];
-
- XGetErrorText (pDisplay,
- pErr->error_code,
- pszErrorMsg,
- sizeof (pszErrorMsg));
- ErrorF ("winClipboardErrorHandler - ERROR: \n\t%s\n"
+ char pszErrorMsg[100];
+
+ XGetErrorText(pDisplay, pErr->error_code, pszErrorMsg, sizeof(pszErrorMsg));
+ ErrorF("winClipboardErrorHandler - ERROR: \n\t%s\n"
" errorCode %d\n"
" serial %lu\n"
" resourceID 0x%x\n"
@@ -487,29 +453,27 @@ winClipboardErrorHandler (Display *pDisplay, XErrorEvent *pErr)
, pErr->resourceid
, pErr->request_code
, pErr->minor_code);
- return 0;
+ return 0;
}
-
/*
* winClipboardIOErrorHandler - Our application specific IO error handler
*/
static int
-winClipboardIOErrorHandler (Display *pDisplay)
+winClipboardIOErrorHandler(Display * pDisplay)
{
- ErrorF ("winClipboardIOErrorHandler!\n\n");
+ ErrorF("winClipboardIOErrorHandler!\n\n");
- if (pthread_equal(pthread_self(),g_winClipboardProcThread))
- {
- /* Restart at the main entry point */
- longjmp (g_jmpEntry, WIN_JMP_ERROR_IO);
+ if (pthread_equal(pthread_self(), g_winClipboardProcThread)) {
+ /* Restart at the main entry point */
+ longjmp(g_jmpEntry, WIN_JMP_ERROR_IO);
}
- if (g_winClipboardOldIOErrorHandler)
- g_winClipboardOldIOErrorHandler(pDisplay);
+ if (g_winClipboardOldIOErrorHandler)
+ g_winClipboardOldIOErrorHandler(pDisplay);
- return 0;
+ return 0;
}
/*
diff --git a/xorg-server/hw/xwin/winclipboardunicode.c b/xorg-server/hw/xwin/winclipboardunicode.c
index f49306904..530ad9a01 100644
--- a/xorg-server/hw/xwin/winclipboardunicode.c
+++ b/xorg-server/hw/xwin/winclipboardunicode.c
@@ -33,25 +33,23 @@
#endif
#include "winclipboard.h"
-
/*
* Determine whether we suport Unicode or not.
* NOTE: Currently, just check if we are on an NT-based platform or not.
*/
Bool
-winClipboardDetectUnicodeSupport (void)
+winClipboardDetectUnicodeSupport(void)
{
- Bool fReturn = FALSE;
- OSVERSIONINFOEX osvi = {0};
+ Bool fReturn = FALSE;
+ OSVERSIONINFOEX osvi = { 0 };
- /* Get operating system version information */
- osvi.dwOSVersionInfoSize = sizeof (osvi);
- GetVersionEx ((LPOSVERSIONINFO)&osvi);
+ /* Get operating system version information */
+ osvi.dwOSVersionInfoSize = sizeof(osvi);
+ GetVersionEx ((LPOSVERSIONINFO)&osvi);
- /* Branch on platform ID */
- switch (osvi.dwPlatformId)
- {
+ /* Branch on platform ID */
+ switch (osvi.dwPlatformId) {
case VER_PLATFORM_WIN32_NT:
if (osvi.dwMajorVersion >= 6)
{
@@ -71,17 +69,17 @@ winClipboardDetectUnicodeSupport (void)
else if (osvi.dwMinorVersion == 1)
{
winDebug ("OS: Windows XP\n");
- fReturn = TRUE;
+ fReturn = TRUE;
}
else if (osvi.dwMinorVersion == 0) winDebug ("OS: Windows 2000\n");
}
else if (osvi.dwMajorVersion <= 4) winDebug ("OS: Windows NT\n");
- break;
+ break;
case VER_PLATFORM_WIN32_WINDOWS:
winDebug ("OS: Windows 95/98/Me\n");
- break;
+ break;
}
- return fReturn;
+ return fReturn;
}
diff --git a/xorg-server/hw/xwin/winclipboardwndproc.c b/xorg-server/hw/xwin/winclipboardwndproc.c
index 50a63001f..0dd39703d 100644
--- a/xorg-server/hw/xwin/winclipboardwndproc.c
+++ b/xorg-server/hw/xwin/winclipboardwndproc.c
@@ -52,36 +52,35 @@
* References to external symbols
*/
-extern Bool g_fUseUnicode;
-extern Bool g_fUnicodeSupport;
-extern void *g_pClipboardDisplay;
-extern Window g_iClipboardWindow;
-extern Atom g_atomLastOwnedSelection;
+extern Bool g_fUseUnicode;
+extern Bool g_fUnicodeSupport;
+extern void *g_pClipboardDisplay;
+extern Window g_iClipboardWindow;
+extern Atom g_atomLastOwnedSelection;
extern Bool g_fClipboardStarted;
extern HWND g_hwndClipboard;
extern Bool g_fClipboardPrimary;
-
/*
* Local function prototypes
*/
static int
-winProcessXEventsTimeout (HWND hwnd, int iWindow, Display *pDisplay,
- Bool fUseUnicode, int iTimeoutSec);
+winProcessXEventsTimeout(HWND hwnd, int iWindow, Display * pDisplay,
+ Bool fUseUnicode, int iTimeoutSec);
/*
* Process X events up to specified timeout
*/
static int
-winProcessXEventsTimeout (HWND hwnd, int iWindow, Display *pDisplay,
- Bool fUseUnicode, int iTimeoutSec)
+winProcessXEventsTimeout(HWND hwnd, int iWindow, Display * pDisplay,
+ Bool fUseUnicode, int iTimeoutSec)
{
- int iConnNumber;
- struct timeval tv;
- int iReturn;
- DWORD dwStopTime = (GetTickCount () / 1000) + iTimeoutSec;
+ int iConnNumber;
+ struct timeval tv;
+ int iReturn;
+ DWORD dwStopTime = (GetTickCount() / 1000) + iTimeoutSec;
/* Make sure the output messages are sent before waiting on a response. */
iReturn = winClipboardFlushXEvents (hwnd,
@@ -95,58 +94,51 @@ winProcessXEventsTimeout (HWND hwnd, int iWindow, Display *pDisplay,
return iReturn;
}
- /* Get our connection number */
- iConnNumber = ConnectionNumber (pDisplay);
-
- /* Loop for X events */
- while (1)
- {
- fd_set fdsRead;
-
- /* Setup the file descriptor set */
- FD_ZERO (&fdsRead);
- FD_SET (iConnNumber, &fdsRead);
-
- /* Adjust timeout */
- tv.tv_sec = dwStopTime - (GetTickCount () / 1000);
- tv.tv_usec = 0;
-
- /* Break out if no time left */
- if (tv.tv_sec < 0)
- return WIN_XEVENTS_SUCCESS;
-
- /* Wait for an X event */
- iReturn = select (iConnNumber + 1,/* Highest fds number */
- &fdsRead, /* Read mask */
- NULL, /* No write mask */
- NULL, /* No exception mask */
- &tv); /* No timeout */
- if (iReturn < 0)
- {
- ErrorF ("winProcessXEventsTimeout - Call to select () failed: %d (%x). "
- "Bailing.\n", iReturn, WSAGetLastError());
- break;
- }
+ /* Get our connection number */
+ iConnNumber = ConnectionNumber(pDisplay);
+
+ /* Loop for X events */
+ while (1) {
+ fd_set fdsRead;
+
+ /* Setup the file descriptor set */
+ FD_ZERO(&fdsRead);
+ FD_SET(iConnNumber, &fdsRead);
+
+ /* Adjust timeout */
+ tv.tv_sec = dwStopTime - (GetTickCount() / 1000);
+ tv.tv_usec = 0;
+
+ /* Break out if no time left */
+ if (tv.tv_sec < 0)
+ return WIN_XEVENTS_SUCCESS;
+
+ /* Wait for an X event */
+ iReturn = select(iConnNumber + 1, /* Highest fds number */
+ &fdsRead, /* Read mask */
+ NULL, /* No write mask */
+ NULL, /* No exception mask */
+ &tv); /* No timeout */
+ if (iReturn < 0) {
+ ErrorF ("winProcessXEventsTimeout - Call to select () failed: %d (%x). "
+ "Bailing.\n", iReturn, WSAGetLastError());
+ break;
+ }
- /* Branch on which descriptor became active */
- if (FD_ISSET (iConnNumber, &fdsRead))
- {
- /* Process X events */
- /* Exit when we see that server is shutting down */
- iReturn = winClipboardFlushXEvents (hwnd,
- iWindow,
- pDisplay,
- fUseUnicode,
- TRUE);
- if (WIN_XEVENTS_NOTIFY == iReturn)
- {
- /* Bail out if notify processed */
- return iReturn;
- }
- }
+ /* Branch on which descriptor became active */
+ if (FD_ISSET(iConnNumber, &fdsRead)) {
+ /* Process X events */
+ /* Exit when we see that server is shutting down */
+ iReturn = winClipboardFlushXEvents(hwnd,
+ iWindow, pDisplay, fUseUnicode, TRUE);
+ if (WIN_XEVENTS_NOTIFY == iReturn) {
+ /* Bail out if notify processed */
+ return iReturn;
+ }
+ }
}
- return WIN_XEVENTS_SUCCESS;
+ return WIN_XEVENTS_SUCCESS;
}
/*
@@ -154,35 +146,33 @@ winProcessXEventsTimeout (HWND hwnd, int iWindow, Display *pDisplay,
*/
LRESULT CALLBACK
-winClipboardWindowProc (HWND hwnd, UINT message,
- WPARAM wParam, LPARAM lParam)
+winClipboardWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- static HWND s_hwndNextViewer;
+ static HWND s_hwndNextViewer;
- /* Branch on message type */
- switch (message)
- {
+ /* Branch on message type */
+ switch (message) {
case WM_DESTROY:
- {
- winDebug ("winClipboardWindowProc - WM_DESTROY\n");
+ {
+ winDebug("winClipboardWindowProc - WM_DESTROY\n");
- /* Remove ourselves from the clipboard chain */
- ChangeClipboardChain (hwnd, s_hwndNextViewer);
-
- s_hwndNextViewer = NULL;
- g_hwndClipboard = NULL;
- PostQuitMessage (0);
- }
- return 0;
+ /* Remove ourselves from the clipboard chain */
+ ChangeClipboardChain(hwnd, s_hwndNextViewer);
+ s_hwndNextViewer = NULL;
+ g_hwndClipboard = NULL;
+ PostQuitMessage(0);
+ }
+ return 0;
case WM_CREATE:
- {
- HWND first, next;
- DWORD error_code = 0;
- winDebug ("winClipboardWindowProc - WM_CREATE\n");
-
- /* Add ourselves to the clipboard viewer chain */
+ {
+ HWND first, next;
+ DWORD error_code = 0;
+
+ winDebug("winClipboardWindowProc - WM_CREATE\n");
+
+ /* Add ourselves to the clipboard viewer chain */
s_hwndNextViewer = SetClipboardViewer (hwnd);
#ifdef _DEBUG
if (s_hwndNextViewer== hwnd)
@@ -192,55 +182,51 @@ winClipboardWindowProc (HWND hwnd, UINT message,
}
#endif
- }
- return 0;
-
+ }
+ return 0;
case WM_CHANGECBCHAIN:
- {
- winDebug ("winClipboardWindowProc - WM_CHANGECBCHAIN: wParam(%x) "
- "lParam(%x) s_hwndNextViewer(%x)\n",
- wParam, lParam, s_hwndNextViewer);
+ {
+ winDebug("winClipboardWindowProc - WM_CHANGECBCHAIN: wParam(%x) "
+ "lParam(%x) s_hwndNextViewer(%x)\n",
+ wParam, lParam, s_hwndNextViewer);
- if ((HWND) wParam == s_hwndNextViewer)
- {
- s_hwndNextViewer = (HWND) lParam;
- if (s_hwndNextViewer == hwnd)
- {
+ if ((HWND) wParam == s_hwndNextViewer) {
+ s_hwndNextViewer = (HWND) lParam;
+ if (s_hwndNextViewer == hwnd) {
winDebug("WM_CHANGECBCHAIN: trying to set s_hwndNextViewer to own window. Resetting it back to NULL. ");
s_hwndNextViewer=NULL; /* This would cause an endless loop, so break it by ending the loop here. I have seen this happening, why??? */
- }
- }
- else if (s_hwndNextViewer)
- SendMessage (s_hwndNextViewer, message,
- wParam, lParam);
+ }
+ }
+ else if (s_hwndNextViewer)
+ SendMessage(s_hwndNextViewer, message, wParam, lParam);
- }
- winDebug ("winClipboardWindowProc - WM_CHANGECBCHAIN: Exit\n");
- return 0;
+ }
+ winDebug("winClipboardWindowProc - WM_CHANGECBCHAIN: Exit\n");
+ return 0;
case WM_WM_REINIT:
- {
+ {
/* Ensure that we're in the clipboard chain. Some apps,
* WinXP's remote desktop for one, don't play nice with the
* chain. This message is called whenever we receive a
* WM_ACTIVATEAPP message to ensure that we continue to
* receive clipboard messages.
- *
- * It might be possible to detect if we're still in the chain
- * by calling SendMessage (GetClipboardViewer(),
- * WM_DRAWCLIPBOARD, 0, 0); and then seeing if we get the
- * WM_DRAWCLIPBOARD message. That, however, might be more
- * expensive than just putting ourselves back into the chain.
- */
-
- HWND first, next;
- DWORD error_code = 0;
+ *
+ * It might be possible to detect if we're still in the chain
+ * by calling SendMessage (GetClipboardViewer(),
+ * WM_DRAWCLIPBOARD, 0, 0); and then seeing if we get the
+ * WM_DRAWCLIPBOARD message. That, however, might be more
+ * expensive than just putting ourselves back into the chain.
+ */
+
+ HWND first, next;
+ DWORD error_code = 0;
if (!g_hwndClipboard)
return 0;
- winDebug ("winClipboardWindowProc - WM_WM_REINIT: Enter\n");
+ winDebug("winClipboardWindowProc - WM_WM_REINIT: Enter\n");
- first = GetClipboardViewer(); /* Get handle to first viewer in chain. */
+ first = GetClipboardViewer(); /* Get handle to first viewer in chain. */
if (first != hwnd)
{
winDebug (" WM_WM_REINIT: Replacing us(%x) with %x at head "
@@ -258,17 +244,16 @@ winClipboardWindowProc (HWND hwnd, UINT message,
}
winDebug ("winClipboardWindowProc - WM_WM_REINIT: Exit\n");
}
- return 0;
-
+ return 0;
case WM_DRAWCLIPBOARD:
- {
- static Atom atomClipboard;
- static int generation;
- static Bool s_fProcessingDrawClipboard = FALSE;
- Display *pDisplay = g_pClipboardDisplay;
- Window iWindow = g_iClipboardWindow;
- int iReturn;
+ {
+ static Atom atomClipboard;
+ static int generation;
+ static Bool s_fProcessingDrawClipboard = FALSE;
+ Display *pDisplay = g_pClipboardDisplay;
+ Window iWindow = g_iClipboardWindow;
+ int iReturn;
winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD 0x%x 0x%x 0x%x: Enter\n",hwnd,wParam,lParam);
@@ -280,50 +265,46 @@ winClipboardWindowProc (HWND hwnd, UINT message,
return 0;
}
- if (generation != serverGeneration)
- {
+ if (generation != serverGeneration) {
generation = serverGeneration;
- atomClipboard = XInternAtom (pDisplay, "CLIPBOARD", False);
- }
-
- /*
- * We've occasionally seen a loop in the clipboard chain.
- * Try and fix it on the first hint of recursion.
- */
- if (! s_fProcessingDrawClipboard)
- {
- s_fProcessingDrawClipboard = TRUE;
- }
- else
- {
- /* Attempt to break the nesting by getting out of the chain, twice?, and then fix and bail */
- ChangeClipboardChain (hwnd, s_hwndNextViewer);
+ atomClipboard = XInternAtom(pDisplay, "CLIPBOARD", False);
+ }
+
+ /*
+ * We've occasionally seen a loop in the clipboard chain.
+ * Try and fix it on the first hint of recursion.
+ */
+ if (!s_fProcessingDrawClipboard) {
+ s_fProcessingDrawClipboard = TRUE;
+ }
+ else {
+ /* Attempt to break the nesting by getting out of the chain, twice?, and then fix and bail */
+ ChangeClipboardChain(hwnd, s_hwndNextViewer);
winFixClipboardChain(1);
ErrorF ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
- "Nested calls detected. Re-initing.\n");
- winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD: Exit\n");
- s_fProcessingDrawClipboard = FALSE;
- return 0;
- }
-
- /*
- * Do not take ownership of the X11 selections when something
- * other than CF_TEXT or CF_UNICODETEXT has been copied
- * into the Win32 clipboard.
- */
- if (!IsClipboardFormatAvailable (CF_TEXT)
- && !IsClipboardFormatAvailable (CF_UNICODETEXT))
- {
-
- winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
- "Clipboard does not contain CF_TEXT nor "
- "CF_UNICODETEXT.\n");
+ "Nested calls detected. Re-initing.\n");
+ winDebug("winClipboardWindowProc - WM_DRAWCLIPBOARD: Exit\n");
+ s_fProcessingDrawClipboard = FALSE;
+ return 0;
+ }
- /*
- * We need to make sure that the X Server has processed
- * previous XSetSelectionOwner messages.
- */
- XSync (pDisplay, FALSE);
+ /*
+ * Do not take ownership of the X11 selections when something
+ * other than CF_TEXT or CF_UNICODETEXT has been copied
+ * into the Win32 clipboard.
+ */
+ if (!IsClipboardFormatAvailable(CF_TEXT)
+ && !IsClipboardFormatAvailable(CF_UNICODETEXT)) {
+
+ winDebug("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
+ "Clipboard does not contain CF_TEXT nor "
+ "CF_UNICODETEXT.\n");
+
+ /*
+ * We need to make sure that the X Server has processed
+ * previous XSetSelectionOwner messages.
+ */
+ XSync(pDisplay, FALSE);
if (g_fClipboardPrimary)
{
@@ -342,28 +323,24 @@ winClipboardWindowProc (HWND hwnd, UINT message,
ErrorF ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
"XGetSelection failed for PRIMARY: %d\n", iReturn);
}
- /* Release CLIPBOARD selection if owned */
- iReturn = XGetSelectionOwner (pDisplay,
- atomClipboard);
- if (iReturn == g_iClipboardWindow)
- {
- winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
- "CLIPBOARD selection is owned by us.\n");
- XSetSelectionOwner (pDisplay,
- atomClipboard,
- None,
- CurrentTime);
- }
- else if (BadWindow == iReturn || BadAtom == iReturn)
- ErrorF ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
- "XGetSelection failed for CLIPBOARD: %d\n", iReturn);
-
- winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD: Exit\n");
- s_fProcessingDrawClipboard = FALSE;
- if (s_hwndNextViewer)
- SendMessage (s_hwndNextViewer, message, wParam, lParam);
- return 0;
- }
+ /* Release CLIPBOARD selection if owned */
+ iReturn = XGetSelectionOwner(pDisplay, atomClipboard);
+ if (iReturn == g_iClipboardWindow) {
+ winDebug("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
+ "CLIPBOARD selection is owned by us.\n");
+ XSetSelectionOwner(pDisplay, atomClipboard, None, CurrentTime);
+ }
+ else if (BadWindow == iReturn || BadAtom == iReturn)
+ ErrorF ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
+ "XGetSelection failed for CLIPBOARD: %d\n",
+ iReturn);
+
+ winDebug("winClipboardWindowProc - WM_DRAWCLIPBOARD: Exit\n");
+ s_fProcessingDrawClipboard = FALSE;
+ if (s_hwndNextViewer)
+ SendMessage(s_hwndNextViewer, message, wParam, lParam);
+ return 0;
+ }
/* Only reassert ownership when we did not change the clipboard ourselves */
if (hwnd!=(HWND)wParam)
{
@@ -403,159 +380,148 @@ winClipboardWindowProc (HWND hwnd, UINT message,
winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
"Reasserted ownership of CLIPBOARD\n");
}
-
+
/* Flush the pending SetSelectionOwner event now */
XFlush (pDisplay);
}
- s_fProcessingDrawClipboard = FALSE;
- winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD: Exit\n");
- /* Pass the message on the next window in the clipboard viewer chain */
- if (s_hwndNextViewer)
- SendMessage (s_hwndNextViewer, message, wParam, lParam);
- return 0;
+ s_fProcessingDrawClipboard = FALSE;
+ winDebug("winClipboardWindowProc - WM_DRAWCLIPBOARD: Exit\n");
+ /* Pass the message on the next window in the clipboard viewer chain */
+ if (s_hwndNextViewer)
+ SendMessage(s_hwndNextViewer, message, wParam, lParam);
+ return 0;
}
-
case WM_DESTROYCLIPBOARD:
- /*
- * NOTE: Intentionally do nothing.
- * Changes in the Win32 clipboard are handled by WM_DRAWCLIPBOARD
- * above. We only process this message to conform to the specs
- * for delayed clipboard rendering in Win32. You might think
- * that we need to release ownership of the X11 selections, but
- * we do not, because a WM_DRAWCLIPBOARD message will closely
- * follow this message and reassert ownership of the X11
- * selections, handling the issue for us.
- */
- winDebug ("winClipboardWindowProc - WM_DESTROYCLIPBOARD - Ignored.\n");
- return 0;
+ /*
+ * NOTE: Intentionally do nothing.
+ * Changes in the Win32 clipboard are handled by WM_DRAWCLIPBOARD
+ * above. We only process this message to conform to the specs
+ * for delayed clipboard rendering in Win32. You might think
+ * that we need to release ownership of the X11 selections, but
+ * we do not, because a WM_DRAWCLIPBOARD message will closely
+ * follow this message and reassert ownership of the X11
+ * selections, handling the issue for us.
+ */
+ winDebug("winClipboardWindowProc - WM_DESTROYCLIPBOARD - Ignored.\n");
+ return 0;
case WM_RENDERFORMAT:
case WM_RENDERALLFORMATS:
- {
- int iReturn;
- Display *pDisplay = g_pClipboardDisplay;
- Window iWindow = g_iClipboardWindow;
- Bool fConvertToUnicode;
-
- winDebug ("winClipboardWindowProc - WM_RENDER*FORMAT - Hello.\n");
-
- /* Flag whether to convert to Unicode or not */
- if (message == WM_RENDERALLFORMATS)
- fConvertToUnicode = FALSE;
- else
- fConvertToUnicode = g_fUnicodeSupport && (CF_UNICODETEXT == wParam);
-
- /* Request the selection contents */
- iReturn = XConvertSelection (pDisplay,
- g_atomLastOwnedSelection,
- XInternAtom (pDisplay,
- "COMPOUND_TEXT", False),
- XInternAtom (pDisplay,
- WIN_LOCAL_PROPERTY, False),
- iWindow,
- CurrentTime);
- if (iReturn == BadAtom || iReturn == BadWindow)
- {
- ErrorF ("winClipboardWindowProc - WM_RENDER*FORMAT - "
- "XConvertSelection () failed\n");
- break;
- }
+ {
+ int iReturn;
+ Display *pDisplay = g_pClipboardDisplay;
+ Window iWindow = g_iClipboardWindow;
+ Bool fConvertToUnicode;
+
+ winDebug("winClipboardWindowProc - WM_RENDER*FORMAT - Hello.\n");
+
+ /* Flag whether to convert to Unicode or not */
+ if (message == WM_RENDERALLFORMATS)
+ fConvertToUnicode = FALSE;
+ else
+ fConvertToUnicode = g_fUnicodeSupport && (CF_UNICODETEXT == wParam);
+
+ /* Request the selection contents */
+ iReturn = XConvertSelection(pDisplay,
+ g_atomLastOwnedSelection,
+ XInternAtom(pDisplay,
+ "COMPOUND_TEXT", False),
+ XInternAtom(pDisplay,
+ WIN_LOCAL_PROPERTY, False),
+ iWindow, CurrentTime);
+ if (iReturn == BadAtom || iReturn == BadWindow) {
+ ErrorF ("winClipboardWindowProc - WM_RENDER*FORMAT - "
+ "XConvertSelection () failed\n");
+ break;
+ }
- /* Special handling for WM_RENDERALLFORMATS */
- if (message == WM_RENDERALLFORMATS)
- {
- /* We must open and empty the clipboard */
- if (!OpenClipboard (hwnd))
- {
- ErrorF ("winClipboardWindowProc - WM_RENDER*FORMATS - "
- "OpenClipboard () failed: %08x\n",
- GetLastError ());
- break;
- }
-
- if (!EmptyClipboard ())
- {
- ErrorF ("winClipboardWindowProc - WM_RENDER*FORMATS - "
- "EmptyClipboard () failed: %08x\n",
- GetLastError ());
+ /* Special handling for WM_RENDERALLFORMATS */
+ if (message == WM_RENDERALLFORMATS) {
+ /* We must open and empty the clipboard */
+ if (!OpenClipboard(hwnd)) {
+ ErrorF ("winClipboardWindowProc - WM_RENDER*FORMATS - "
+ "OpenClipboard () failed: %08x\n",
+ GetLastError());
+ break;
+ }
+
+ if (!EmptyClipboard()) {
+ ErrorF ("winClipboardWindowProc - WM_RENDER*FORMATS - "
+ "EmptyClipboard () failed: %08x\n",
+ GetLastError());
CloseClipboard ();
- break;
- }
- }
+ break;
+ }
+ }
- /* Process the SelectionNotify event */
- iReturn = winProcessXEventsTimeout (hwnd,
- iWindow,
- pDisplay,
- fConvertToUnicode,
- WIN_POLL_TIMEOUT);
-
- /*
- * The last call to winProcessXEventsTimeout
- * from above had better have seen a notify event, or else we
- * are dealing with a buggy or old X11 app. In these cases we
- * have to paste some fake data to the Win32 clipboard to
- * satisfy the requirement that we write something to it.
- */
- if (WIN_XEVENTS_NOTIFY != iReturn)
- {
- ErrorF("winClipboardWindowProc - winProcessXEventsTimeout should have returned WIN_XEVENTS_NOTIFY was %d\n",iReturn);
- /* Paste no data, to satisfy required call to SetClipboardData */
- if (g_fUnicodeSupport)
- SetClipboardData (CF_UNICODETEXT, NULL);
- SetClipboardData (CF_TEXT, NULL);
+ /* Process the SelectionNotify event */
+ iReturn = winProcessXEventsTimeout(hwnd,
+ iWindow,
+ pDisplay,
+ fConvertToUnicode, WIN_POLL_TIMEOUT);
+
+ /*
+ * The last call to winProcessXEventsTimeout
+ * from above had better have seen a notify event, or else we
+ * are dealing with a buggy or old X11 app. In these cases we
+ * have to paste some fake data to the Win32 clipboard to
+ * satisfy the requirement that we write something to it.
+ */
+ if (WIN_XEVENTS_NOTIFY != iReturn) {
+ ErrorF("winClipboardWindowProc - winProcessXEventsTimeout should have returned WIN_XEVENTS_NOTIFY was %d\n",iReturn);
+ /* Paste no data, to satisfy required call to SetClipboardData */
+ if (g_fUnicodeSupport)
+ SetClipboardData(CF_UNICODETEXT, NULL);
+ SetClipboardData(CF_TEXT, NULL);
+
+ ErrorF
+ ("winClipboardWindowProc - timed out waiting for WIN_XEVENTS_NOTIFY\n");
+ }
- ErrorF("winClipboardWindowProc - timed out waiting for WIN_XEVENTS_NOTIFY\n");
- }
+ /* Special handling for WM_RENDERALLFORMATS */
+ if (message == WM_RENDERALLFORMATS) {
+ /* We must close the clipboard */
- /* Special handling for WM_RENDERALLFORMATS */
- if (message == WM_RENDERALLFORMATS)
- {
- /* We must close the clipboard */
-
- if (!CloseClipboard ())
- {
- ErrorF ("winClipboardWindowProc - WM_RENDERALLFORMATS - "
- "CloseClipboard () failed: %08x\n",
- GetLastError ());
- break;
- }
- }
+ if (!CloseClipboard()) {
+ ErrorF ("winClipboardWindowProc - WM_RENDERALLFORMATS - "
+ "CloseClipboard () failed: %08x\n",
+ GetLastError());
+ break;
+ }
+ }
- winDebug ("winClipboardWindowProc - WM_RENDER*FORMAT - Returning.\n");
- return 0;
- }
+ winDebug("winClipboardWindowProc - WM_RENDER*FORMAT - Returning.\n");
+ return 0;
+ }
}
- /* Let Windows perform default processing for unhandled messages */
- return DefWindowProc (hwnd, message, wParam, lParam);
+ /* Let Windows perform default processing for unhandled messages */
+ return DefWindowProc(hwnd, message, wParam, lParam);
}
-
/*
* Process any pending Windows messages
*/
BOOL
-winClipboardFlushWindowsMessageQueue (HWND hwnd)
+winClipboardFlushWindowsMessageQueue(HWND hwnd)
{
- MSG msg;
-
- /* Flush the messaging window queue */
- /* NOTE: Do not pass the hwnd of our messaging window to PeekMessage,
- * as this will filter out many non-window-specific messages that
- * are sent to our thread, such as WM_QUIT.
- */
- while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
- {
- /* Dispatch the message if not WM_QUIT */
- if (msg.message == WM_QUIT)
- return FALSE;
- else
- DispatchMessage (&msg);
+ MSG msg;
+
+ /* Flush the messaging window queue */
+ /* NOTE: Do not pass the hwnd of our messaging window to PeekMessage,
+ * as this will filter out many non-window-specific messages that
+ * are sent to our thread, such as WM_QUIT.
+ */
+ while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
+ /* Dispatch the message if not WM_QUIT */
+ if (msg.message == WM_QUIT)
+ return FALSE;
+ else
+ DispatchMessage(&msg);
}
-
- return TRUE;
+
+ return TRUE;
}
diff --git a/xorg-server/hw/xwin/winclipboardwrappers.c b/xorg-server/hw/xwin/winclipboardwrappers.c
index 3743b9edb..4005bf176 100644
--- a/xorg-server/hw/xwin/winclipboardwrappers.c
+++ b/xorg-server/hw/xwin/winclipboardwrappers.c
@@ -37,7 +37,6 @@
#include "dixstruct.h"
#include <X11/Xatom.h>
-
/*
* Constants
*/
@@ -46,37 +45,35 @@
#define CLIP_OWN_PRIMARY 0
#define CLIP_OWN_CLIPBOARD 1
-
/*
* Local function prototypes
*/
-int winProcEstablishConnection(ClientPtr /* client */);
-int winProcSetSelectionOwner(ClientPtr /* client */);
+int winProcEstablishConnection(ClientPtr /* client */ );
+int winProcSetSelectionOwner(ClientPtr /* client */ );
+
DISPATCH_PROC(winProcEstablishConnection);
DISPATCH_PROC(winProcSetSelectionOwner);
-
/*
* References to external symbols
*/
-extern Bool g_fUnicodeSupport;
-extern int g_iNumScreens;
-extern unsigned int g_uiAuthDataLen;
-extern char *g_pAuthData;
-extern Bool g_fXdmcpEnabled;
-extern Bool g_fClipboardLaunched;
-extern Bool g_fClipboardStarted;
-extern Bool g_fClipboard;
-extern Window g_iClipboardWindow;
-extern Atom g_atomLastOwnedSelection;
-extern HWND g_hwndClipboard;
+extern Bool g_fUnicodeSupport;
+extern int g_iNumScreens;
+extern unsigned int g_uiAuthDataLen;
+extern char *g_pAuthData;
+extern Bool g_fXdmcpEnabled;
+extern Bool g_fClipboardLaunched;
+extern Bool g_fClipboardStarted;
+extern Bool g_fClipboard;
+extern Window g_iClipboardWindow;
+extern Atom g_atomLastOwnedSelection;
+extern HWND g_hwndClipboard;
extern Bool g_fClipboardPrimary;
-extern winDispatchProcPtr winProcEstablishConnectionOrig;
-extern winDispatchProcPtr winProcSetSelectionOwnerOrig;
-
+extern winDispatchProcPtr winProcEstablishConnectionOrig;
+extern winDispatchProcPtr winProcSetSelectionOwnerOrig;
/*
* Wrapper for internal EstablishConnection function.
@@ -85,291 +82,269 @@ extern winDispatchProcPtr winProcSetSelectionOwnerOrig;
*/
int
-winProcEstablishConnection (ClientPtr client)
+winProcEstablishConnection(ClientPtr client)
{
- int iReturn;
- static int s_iCallCount = 0;
- static unsigned long s_ulServerGeneration = 0;
+ int iReturn;
+ static int s_iCallCount = 0;
+ static unsigned long s_ulServerGeneration = 0;
#ifdef WINDBG
if (s_iCallCount == 0) winDebug ("winProcEstablishConnection - Hello\n");
#endif
- /* Do nothing if clipboard is not enabled */
- if (!g_fClipboard)
- {
+ /* Do nothing if clipboard is not enabled */
+ if (!g_fClipboard) {
winDebug ("winProcEstablishConnection - Clipboard is not enabled, "
- "returning.\n");
-
- /* Unwrap the original function, call it, and return */
- InitialVector[2] = winProcEstablishConnectionOrig;
- iReturn = (*winProcEstablishConnectionOrig) (client);
- winProcEstablishConnectionOrig = NULL;
- return iReturn;
+ "returning.\n");
+
+ /* Unwrap the original function, call it, and return */
+ InitialVector[2] = winProcEstablishConnectionOrig;
+ iReturn = (*winProcEstablishConnectionOrig) (client);
+ winProcEstablishConnectionOrig = NULL;
+ return iReturn;
}
- /* Watch for server reset */
- if (s_ulServerGeneration != serverGeneration)
- {
- /* Save new generation number */
- s_ulServerGeneration = serverGeneration;
+ /* Watch for server reset */
+ if (s_ulServerGeneration != serverGeneration) {
+ /* Save new generation number */
+ s_ulServerGeneration = serverGeneration;
- /* Reset call count */
- s_iCallCount = 0;
+ /* Reset call count */
+ s_iCallCount = 0;
}
- /* Increment call count */
- ++s_iCallCount;
-
- /*
- * This procedure is only used for initialization.
- * We can unwrap the original procedure at this point
- * so that this function is no longer called until the
- * server resets and the function is wrapped again.
- */
- InitialVector[2] = winProcEstablishConnectionOrig;
-
- /*
- * Call original function and bail if it fails.
- * NOTE: We must do this first, since we need XdmcpOpenDisplay
- * to be called before we initialize our clipboard client.
- */
- iReturn = (*winProcEstablishConnectionOrig) (client);
- if (iReturn != 0)
- {
- ErrorF ("winProcEstablishConnection - ProcEstablishConnection "
- "failed, bailing.\n");
- return iReturn;
+ /* Increment call count */
+ ++s_iCallCount;
+
+ /*
+ * This procedure is only used for initialization.
+ * We can unwrap the original procedure at this point
+ * so that this function is no longer called until the
+ * server resets and the function is wrapped again.
+ */
+ InitialVector[2] = winProcEstablishConnectionOrig;
+
+ /*
+ * Call original function and bail if it fails.
+ * NOTE: We must do this first, since we need XdmcpOpenDisplay
+ * to be called before we initialize our clipboard client.
+ */
+ iReturn = (*winProcEstablishConnectionOrig) (client);
+ if (iReturn != 0) {
+ ErrorF("winProcEstablishConnection - ProcEstablishConnection "
+ "failed, bailing.\n");
+ return iReturn;
}
- /* Clear original function pointer */
- winProcEstablishConnectionOrig = NULL;
+ /* Clear original function pointer */
+ winProcEstablishConnectionOrig = NULL;
- /* If the clipboard client has already been started, abort */
- if (g_fClipboardLaunched)
- {
- winDebug ("winProcEstablishConnection - Clipboard client already "
- "launched, returning.\n");
- return iReturn;
+ /* If the clipboard client has already been started, abort */
+ if (g_fClipboardLaunched) {
+ winDebug ("winProcEstablishConnection - Clipboard client already "
+ "launched, returning.\n");
+ return iReturn;
}
- /* Startup the clipboard client if clipboard mode is being used */
- if (g_fClipboard)
- {
- /*
- * NOTE: The clipboard client is started here for a reason:
- * 1) Assume you are using XDMCP (e.g. XWin -query %hostname%)
- * 2) If the clipboard client attaches during X Server startup,
- * then it becomes the "magic client" that causes the X Server
- * to reset if it exits.
- * 3) XDMCP calls KillAllClients when it starts up.
- * 4) The clipboard client is a client, so it is killed.
- * 5) The clipboard client is the "magic client", so the X Server
- * resets itself.
- * 6) This repeats ad infinitum.
- * 7) We avoid this by waiting until at least one client (could
- * be XDM, could be another client) connects, which makes it
- * almost certain that the clipboard client will not connect
- * until after XDM when using XDMCP.
- */
-
- /* Create the clipboard client thread */
- if (!winInitClipboard ())
- {
- ErrorF ("winProcEstablishConnection - winClipboardInit "
- "failed.\n");
- return iReturn;
- }
-
- winDebug ("winProcEstablishConnection - winInitClipboard returned.\n");
+ /* Startup the clipboard client if clipboard mode is being used */
+ if (g_fClipboard) {
+ /*
+ * NOTE: The clipboard client is started here for a reason:
+ * 1) Assume you are using XDMCP (e.g. XWin -query %hostname%)
+ * 2) If the clipboard client attaches during X Server startup,
+ * then it becomes the "magic client" that causes the X Server
+ * to reset if it exits.
+ * 3) XDMCP calls KillAllClients when it starts up.
+ * 4) The clipboard client is a client, so it is killed.
+ * 5) The clipboard client is the "magic client", so the X Server
+ * resets itself.
+ * 6) This repeats ad infinitum.
+ * 7) We avoid this by waiting until at least one client (could
+ * be XDM, could be another client) connects, which makes it
+ * almost certain that the clipboard client will not connect
+ * until after XDM when using XDMCP.
+ */
+
+ /* Create the clipboard client thread */
+ if (!winInitClipboard()) {
+ ErrorF("winProcEstablishConnection - winClipboardInit "
+ "failed.\n");
+ return iReturn;
+ }
+
+ winDebug ("winProcEstablishConnection - winInitClipboard returned.\n");
}
-
- /* Flag that clipboard client has been launched */
- g_fClipboardLaunched = TRUE;
- return iReturn;
-}
+ /* Flag that clipboard client has been launched */
+ g_fClipboardLaunched = TRUE;
+ return iReturn;
+}
/*
* Wrapper for internal SetSelectionOwner function.
* Grabs ownership of Windows clipboard when X11 clipboard owner changes.
*/
int
-winProcSetSelectionOwner (ClientPtr client)
+winProcSetSelectionOwner(ClientPtr client)
{
- int i;
- DrawablePtr pDrawable;
- WindowPtr pWindow = None;
- static Window s_iOwners[CLIP_NUM_SELECTIONS] = {None};
- static unsigned long s_ulServerGeneration = 0;
- REQUEST(xSetSelectionOwnerReq);
-
- REQUEST_SIZE_MATCH(xSetSelectionOwnerReq);
-
- winDebug ("winProcSetSelectionOwner - Hello.\n");
-
- /* Watch for server reset */
- if (s_ulServerGeneration != serverGeneration)
- {
- /* Save new generation number */
- s_ulServerGeneration = serverGeneration;
+ int i;
+ DrawablePtr pDrawable;
+ WindowPtr pWindow = None;
+ static Window s_iOwners[CLIP_NUM_SELECTIONS] = { None };
+ static unsigned long s_ulServerGeneration = 0;
+
+ REQUEST(xSetSelectionOwnerReq);
+
+ REQUEST_SIZE_MATCH(xSetSelectionOwnerReq);
+
+ winDebug("winProcSetSelectionOwner - Hello.\n");
+
+ /* Watch for server reset */
+ if (s_ulServerGeneration != serverGeneration) {
+ /* Save new generation number */
+ s_ulServerGeneration = serverGeneration;
- /* Initialize static variables */
- for (i = 0; i < CLIP_NUM_SELECTIONS; ++i)
- s_iOwners[i] = None;
+ /* Initialize static variables */
+ for (i = 0; i < CLIP_NUM_SELECTIONS; ++i)
+ s_iOwners[i] = None;
}
- /* Abort if clipboard not completely initialized yet */
- if (!g_fClipboardStarted)
- {
+ /* Abort if clipboard not completely initialized yet */
+ if (!g_fClipboardStarted) {
winDebug ("winProcSetSelectionOwner - Clipboard not yet started, "
- "aborting.\n");
+ "aborting.\n");
goto winProcSetSelectionOwner_Done;
}
-
- /* Grab window if we have one */
- if (None != stuff->window)
- {
- /* Grab the Window from the request */
- int rc = dixLookupWindow(&pWindow, stuff->window, client, DixReadAccess);
- if (rc != Success) {
- ErrorF ("winProcSetSelectionOwner - Found BadWindow, aborting.\n");
- goto winProcSetSelectionOwner_Done;
- }
+
+ /* Grab window if we have one */
+ if (None != stuff->window) {
+ /* Grab the Window from the request */
+ int rc =
+ dixLookupWindow(&pWindow, stuff->window, client, DixReadAccess);
+ if (rc != Success) {
+ ErrorF("winProcSetSelectionOwner - Found BadWindow, aborting.\n");
+ goto winProcSetSelectionOwner_Done;
+ }
}
- /* Now we either have a valid window or None */
-
- /* Save selection owners for monitored selections, ignore other selections */
- if (XA_PRIMARY == stuff->selection && g_fClipboardPrimary)
- {
- /* Look for owned -> not owned transition */
- if (None == stuff->window
- && None != s_iOwners[CLIP_OWN_PRIMARY])
- {
- winDebug ("winProcSetSelectionOwner - PRIMARY - Going from "
- "owned to not owned.\n");
-
- /* Adjust last owned selection */
- if (None != s_iOwners[CLIP_OWN_CLIPBOARD])
- g_atomLastOwnedSelection = MakeAtom ("CLIPBOARD", 9, TRUE);
- else
- g_atomLastOwnedSelection = None;
- }
-
- /* Save new selection owner or None */
- s_iOwners[CLIP_OWN_PRIMARY] = stuff->window;
-
- winDebug ("winProcSetSelectionOwner - PRIMARY - Now owned by: 0x%x (clipboard is 0x%x)\n",
- stuff->window,g_iClipboardWindow);
+ /* Now we either have a valid window or None */
+
+ /* Save selection owners for monitored selections, ignore other selections */
+ if (XA_PRIMARY == stuff->selection && g_fClipboardPrimary) {
+ /* Look for owned -> not owned transition */
+ if (None == stuff->window && None != s_iOwners[CLIP_OWN_PRIMARY]) {
+ winDebug("winProcSetSelectionOwner - PRIMARY - Going from "
+ "owned to not owned.\n");
+
+ /* Adjust last owned selection */
+ if (None != s_iOwners[CLIP_OWN_CLIPBOARD])
+ g_atomLastOwnedSelection = MakeAtom("CLIPBOARD", 9, TRUE);
+ else
+ g_atomLastOwnedSelection = None;
+ }
+
+ /* Save new selection owner or None */
+ s_iOwners[CLIP_OWN_PRIMARY] = stuff->window;
+
+ winDebug ("winProcSetSelectionOwner - PRIMARY - Now owned by: 0x%x (clipboard is 0x%x)\n",
+ stuff->window,g_iClipboardWindow);
}
- else if (MakeAtom ("CLIPBOARD", 9, TRUE) == stuff->selection)
- {
- /* Look for owned -> not owned transition */
- if (None == stuff->window
- && None != s_iOwners[CLIP_OWN_CLIPBOARD])
- {
- winDebug ("winProcSetSelectionOwner - CLIPBOARD - Going from "
- "owned to not owned.\n");
-
- /* Adjust last owned selection */
- if ((None != s_iOwners[CLIP_OWN_PRIMARY]) && g_fClipboardPrimary)
- g_atomLastOwnedSelection = XA_PRIMARY;
- else
- g_atomLastOwnedSelection = None;
- }
-
- /* Save new selection owner or None */
- s_iOwners[CLIP_OWN_CLIPBOARD] = stuff->window;
-
- winDebug ("winProcSetSelectionOwner - CLIPBOARD - Now owned by: 0x%x, clipboard is 0x%x\n",
- stuff->window,g_iClipboardWindow);
+ else if (MakeAtom("CLIPBOARD", 9, TRUE) == stuff->selection) {
+ /* Look for owned -> not owned transition */
+ if (None == stuff->window && None != s_iOwners[CLIP_OWN_CLIPBOARD]) {
+ winDebug("winProcSetSelectionOwner - CLIPBOARD - Going from "
+ "owned to not owned.\n");
+
+ /* Adjust last owned selection */
+ if ((None != s_iOwners[CLIP_OWN_PRIMARY]) && g_fClipboardPrimary)
+ g_atomLastOwnedSelection = XA_PRIMARY;
+ else
+ g_atomLastOwnedSelection = None;
+ }
+
+ /* Save new selection owner or None */
+ s_iOwners[CLIP_OWN_CLIPBOARD] = stuff->window;
+
+ winDebug ("winProcSetSelectionOwner - CLIPBOARD - Now owned by: 0x%x, clipboard is 0x%x\n",
+ stuff->window,g_iClipboardWindow);
}
- else
- goto winProcSetSelectionOwner_Done;
-
- /*
- * At this point, if one of the selections is still owned by the
- * clipboard manager then it should be marked as unowned since
- * we will be taking ownership of the Win32 clipboard.
- */
- if (g_iClipboardWindow == s_iOwners[CLIP_OWN_PRIMARY])
- s_iOwners[CLIP_OWN_PRIMARY] = None;
- if (g_iClipboardWindow == s_iOwners[CLIP_OWN_CLIPBOARD])
- s_iOwners[CLIP_OWN_CLIPBOARD] = None;
-
- /* Abort if no window at this point */
- if (None == stuff->window)
- {
- winDebug ("winProcSetSelectionOwner - No window, returning.\n");
- goto winProcSetSelectionOwner_Done;
+ else
+ goto winProcSetSelectionOwner_Done;
+
+ /*
+ * At this point, if one of the selections is still owned by the
+ * clipboard manager then it should be marked as unowned since
+ * we will be taking ownership of the Win32 clipboard.
+ */
+ if (g_iClipboardWindow == s_iOwners[CLIP_OWN_PRIMARY])
+ s_iOwners[CLIP_OWN_PRIMARY] = None;
+ if (g_iClipboardWindow == s_iOwners[CLIP_OWN_CLIPBOARD])
+ s_iOwners[CLIP_OWN_CLIPBOARD] = None;
+
+ /* Abort if no window at this point */
+ if (None == stuff->window) {
+ winDebug ("winProcSetSelectionOwner - No window, returning.\n");
+ goto winProcSetSelectionOwner_Done;
}
- /* Abort if invalid selection */
- if (!ValidAtom (stuff->selection))
- {
- winDebug ("winProcSetSelectionOwner - Found BadAtom, aborting.\n");
- goto winProcSetSelectionOwner_Done;
+ /* Abort if invalid selection */
+ if (!ValidAtom(stuff->selection)) {
+ winDebug ("winProcSetSelectionOwner - Found BadAtom, aborting.\n");
+ goto winProcSetSelectionOwner_Done;
}
- /* Cast Window to Drawable */
- pDrawable = (DrawablePtr) pWindow;
-
- /* Abort if clipboard manager is owning the selection */
- if (pDrawable->id == g_iClipboardWindow)
- {
- winDebug ("winProcSetSelectionOwner - We changed ownership, "
- "aborting.\n");
- goto winProcSetSelectionOwner_Done;
+ /* Cast Window to Drawable */
+ pDrawable = (DrawablePtr) pWindow;
+
+ /* Abort if clipboard manager is owning the selection */
+ if (pDrawable->id == g_iClipboardWindow) {
+ winDebug ("winProcSetSelectionOwner - We changed ownership, "
+ "aborting.\n");
+ goto winProcSetSelectionOwner_Done;
}
- /* Abort if root window is taking ownership */
- if (pDrawable->id == 0)
- {
- winDebug ("winProcSetSelectionOwner - Root window taking ownership, "
- "aborting\n");
- goto winProcSetSelectionOwner_Done;
+ /* Abort if root window is taking ownership */
+ if (pDrawable->id == 0) {
+ winDebug ("winProcSetSelectionOwner - Root window taking ownership, "
+ "aborting\n");
+ goto winProcSetSelectionOwner_Done;
}
- /* Access the Windows clipboard */
- if (!OpenClipboard (g_hwndClipboard))
- {
- ErrorF ("winProcSetSelectionOwner - OpenClipboard () failed: %08x, hwnd: %08x\n",
- (int) GetLastError (),g_hwndClipboard);
- goto winProcSetSelectionOwner_Done;
+ /* Access the Windows clipboard */
+ if (!OpenClipboard(g_hwndClipboard)) {
+ ErrorF ("winProcSetSelectionOwner - OpenClipboard () failed: %08x, hwnd: %08x\n",
+ (int) GetLastError (),g_hwndClipboard);
+ goto winProcSetSelectionOwner_Done;
}
- /* Take ownership of the Windows clipboard */
- if (!EmptyClipboard ())
- {
- ErrorF ("winProcSetSelectionOwner - EmptyClipboard () failed: %08x\n",
- (int) GetLastError ());
- CloseClipboard ();
- goto winProcSetSelectionOwner_Done;
+ /* Take ownership of the Windows clipboard */
+ if (!EmptyClipboard()) {
+ ErrorF("winProcSetSelectionOwner - EmptyClipboard () failed: %08x\n",
+ (int) GetLastError());
+ CloseClipboard ();
+ goto winProcSetSelectionOwner_Done;
}
- winDebug("winProcSetSelectionOwner - SetClipboardData NULL\n");
+ winDebug("winProcSetSelectionOwner - SetClipboardData NULL\n");
- /* Advertise Unicode if we support it */
- if (g_fUnicodeSupport)
- SetClipboardData (CF_UNICODETEXT, NULL);
+ /* Advertise Unicode if we support it */
+ if (g_fUnicodeSupport)
+ SetClipboardData(CF_UNICODETEXT, NULL);
- /* Always advertise regular text */
- SetClipboardData (CF_TEXT, NULL);
+ /* Always advertise regular text */
+ SetClipboardData(CF_TEXT, NULL);
- /* Save handle to last owned selection */
- g_atomLastOwnedSelection = stuff->selection;
+ /* Save handle to last owned selection */
+ g_atomLastOwnedSelection = stuff->selection;
- /* Release the clipboard */
- if (!CloseClipboard ())
- {
- ErrorF ("winProcSetSelectionOwner - CloseClipboard () failed: "
- "%08x\n",
- (int) GetLastError ());
- goto winProcSetSelectionOwner_Done;
+ /* Release the clipboard */
+ if (!CloseClipboard()) {
+ ErrorF("winProcSetSelectionOwner - CloseClipboard () failed: "
+ "%08x\n", (int) GetLastError());
+ goto winProcSetSelectionOwner_Done;
}
winProcSetSelectionOwner_Done:
- return (*winProcSetSelectionOwnerOrig) (client);
+ return (*winProcSetSelectionOwnerOrig) (client);
}
diff --git a/xorg-server/hw/xwin/winclipboardxevents.c b/xorg-server/hw/xwin/winclipboardxevents.c
index 53b4d7d77..2be03b707 100644
--- a/xorg-server/hw/xwin/winclipboardxevents.c
+++ b/xorg-server/hw/xwin/winclipboardxevents.c
@@ -37,190 +37,176 @@
#include "misc.h"
#include "winmsg.h"
#include <unistd.h>
-
/*
* References to external symbols
*/
-extern Bool g_fUnicodeSupport;
+extern Bool g_fUnicodeSupport;
extern Bool g_fClipboardPrimary;
-
/*
* Process any pending X events
*/
int
-winClipboardFlushXEvents (HWND hwnd,
- int iWindow,
- Display *pDisplay,
- Bool fUseUnicode,
- Bool ClipboardOpened)
+winClipboardFlushXEvents(HWND hwnd,
+ int iWindow, Display * pDisplay, Bool fUseUnicode, Bool ClipboardOpened)
{
- static Atom atomLocalProperty;
- static Atom atomCompoundText;
- static Atom atomUTF8String;
- static Atom atomTargets;
- static int generation;
-
- if (generation != serverGeneration)
- {
- generation = serverGeneration;
- atomLocalProperty = XInternAtom (pDisplay, WIN_LOCAL_PROPERTY, False);
- atomUTF8String = XInternAtom (pDisplay, "UTF8_STRING", False);
- atomCompoundText = XInternAtom (pDisplay, "COMPOUND_TEXT", False);
- atomTargets = XInternAtom (pDisplay, "TARGETS", False);
+ static Atom atomLocalProperty;
+ static Atom atomCompoundText;
+ static Atom atomUTF8String;
+ static Atom atomTargets;
+ static int generation;
+
+ if (generation != serverGeneration) {
+ generation = serverGeneration;
+ atomLocalProperty = XInternAtom(pDisplay, WIN_LOCAL_PROPERTY, False);
+ atomUTF8String = XInternAtom(pDisplay, "UTF8_STRING", False);
+ atomCompoundText = XInternAtom(pDisplay, "COMPOUND_TEXT", False);
+ atomTargets = XInternAtom(pDisplay, "TARGETS", False);
}
- /* Process all pending events */
- while (XPending (pDisplay))
- {
- XTextProperty xtpText = {0};
- XEvent event;
- XSelectionEvent eventSelection;
- unsigned long ulReturnBytesLeft;
- char *pszReturnData = NULL;
- char *pszGlobalData = NULL;
- int iReturn;
- HGLOBAL hGlobal = NULL;
- XICCEncodingStyle xiccesStyle;
- int iConvertDataLen = 0;
- char *pszConvertData = NULL;
- char *pszTextList[2] = {NULL};
- int iCount;
- char **ppszTextList = NULL;
- wchar_t *pwszUnicodeStr = NULL;
- int iUnicodeLen = 0;
- int iReturnDataLen = 0;
- int i;
- Bool fAbort = FALSE;
- Bool fCloseClipboard = FALSE;
- Bool fSetClipboardData = TRUE;
-
- /* Get the next event - will not block because one is ready */
- XNextEvent (pDisplay, &event);
+ /* Process all pending events */
+ while (XPending(pDisplay)) {
+ XTextProperty xtpText = { 0 };
+ XEvent event;
+ XSelectionEvent eventSelection;
+ unsigned long ulReturnBytesLeft;
+ char *pszReturnData = NULL;
+ char *pszGlobalData = NULL;
+ int iReturn;
+ HGLOBAL hGlobal = NULL;
+ XICCEncodingStyle xiccesStyle;
+ int iConvertDataLen = 0;
+ char *pszConvertData = NULL;
+ char *pszTextList[2] = { NULL };
+ int iCount;
+ char **ppszTextList = NULL;
+ wchar_t *pwszUnicodeStr = NULL;
+ int iUnicodeLen = 0;
+ int iReturnDataLen = 0;
+ int i;
+ Bool fAbort = FALSE;
+ Bool fCloseClipboard = FALSE;
+ Bool fSetClipboardData = TRUE;
+
+ /* Get the next event - will not block because one is ready */
+ XNextEvent(pDisplay, &event);
winDebug ("Received event type %d\n",event.type);
- /* Branch on the event type */
- switch (event.type)
- {
- /*
- * SelectionRequest
- */
+ /* Branch on the event type */
+ switch (event.type) {
+ /*
+ * SelectionRequest
+ */
- case SelectionRequest:
+ case SelectionRequest:
#ifdef _DEBUG
- {
- char *pszAtomName = NULL;
- winDebug("SelectionRequest - target %d\n",
+ {
+ char *pszAtomName = NULL;
+
+ winDebug("SelectionRequest - target %d\n",
event.xselectionrequest.target);
- pszAtomName = XGetAtomName (pDisplay,
- event.xselectionrequest.target);
- winDebug("SelectionRequest - Target atom name %s\n", pszAtomName);
- XFree (pszAtomName);
- pszAtomName = NULL;
+ pszAtomName = XGetAtomName(pDisplay,
+ event.xselectionrequest.target);
+ winDebug("SelectionRequest - Target atom name %s\n", pszAtomName);
+ XFree(pszAtomName);
+ pszAtomName = NULL;
winDebug ("SelectionRequest - owner %d\n", event.xselectionrequest.owner);
winDebug ("SelectionRequest - requestor %d\n", event.xselectionrequest.requestor);
- }
+ }
#endif
- /* Abort if invalid target type */
- if (event.xselectionrequest.target != XA_STRING
- && event.xselectionrequest.target != atomUTF8String
- && event.xselectionrequest.target != atomCompoundText
- && event.xselectionrequest.target != atomTargets)
- {
- /* Abort */
- fAbort = TRUE;
- goto winClipboardFlushXEvents_SelectionRequest_Done;
- }
-
- /* Handle targets type of request */
- if (event.xselectionrequest.target == atomTargets)
- {
- Atom atomTargetArr[] = {atomTargets,
- atomCompoundText,
- atomUTF8String,
- XA_STRING};
-
- /* Try to change the property */
- iReturn = XChangeProperty (pDisplay,
- event.xselectionrequest.requestor,
- event.xselectionrequest.property,
- XA_ATOM,
- 32,
- PropModeReplace,
- (unsigned char *) atomTargetArr,
- (sizeof (atomTargetArr)
- / sizeof (atomTargetArr[0])));
- if (iReturn == BadAlloc
- || iReturn == BadAtom
- || iReturn == BadMatch
- || iReturn == BadValue
- || iReturn == BadWindow)
- {
- ErrorF ("winClipboardFlushXEvents - SelectionRequest - "
- "XChangeProperty failed: %d\n",
- iReturn);
- }
-
- /* Setup selection notify xevent */
- eventSelection.type = SelectionNotify;
- eventSelection.send_event = True;
- eventSelection.display = pDisplay;
- eventSelection.requestor = event.xselectionrequest.requestor;
- eventSelection.selection = event.xselectionrequest.selection;
- eventSelection.target = event.xselectionrequest.target;
- eventSelection.property = event.xselectionrequest.property;
- eventSelection.time = event.xselectionrequest.time;
-
- /*
- * Notify the requesting window that
- * the operation has completed
- */
- iReturn = XSendEvent (pDisplay,
- eventSelection.requestor,
- False,
- 0L,
- (XEvent *) &eventSelection);
- if (iReturn == BadValue || iReturn == BadWindow)
- {
- ErrorF ("winClipboardFlushXEvents - SelectionRequest - "
- "XSendEvent () failed\n");
- }
- break;
- }
-
- /* Check that clipboard format is available */
- if (fUseUnicode
- && !IsClipboardFormatAvailable (CF_UNICODETEXT))
- {
- static int count; /* Hack to stop acroread spamming the log */
- static HWND lasthwnd; /* I've not seen any other client get here repeatedly? */
- if (hwnd != lasthwnd) count = 0;
- count++;
- if (count < 6) ErrorF ("winClipboardFlushXEvents - CF_UNICODETEXT is not "
- "available from Win32 clipboard. Aborting %d.\n", count);
- lasthwnd = hwnd;
-
- /* Abort */
- fAbort = TRUE;
- goto winClipboardFlushXEvents_SelectionRequest_Done;
- }
- else if (!fUseUnicode
- && !IsClipboardFormatAvailable (CF_TEXT))
- {
- ErrorF ("winClipboardFlushXEvents - CF_TEXT is not "
- "available from Win32 clipboard. Aborting.\n");
-
- /* Abort */
- fAbort = TRUE;
- goto winClipboardFlushXEvents_SelectionRequest_Done;
- }
-
- /* Access the clipboard */
+ /* Abort if invalid target type */
+ if (event.xselectionrequest.target != XA_STRING
+ && event.xselectionrequest.target != atomUTF8String
+ && event.xselectionrequest.target != atomCompoundText
+ && event.xselectionrequest.target != atomTargets) {
+ /* Abort */
+ fAbort = TRUE;
+ goto winClipboardFlushXEvents_SelectionRequest_Done;
+ }
+
+ /* Handle targets type of request */
+ if (event.xselectionrequest.target == atomTargets) {
+ Atom atomTargetArr[] = { atomTargets,
+ atomCompoundText,
+ atomUTF8String,
+ XA_STRING
+ };
+
+ /* Try to change the property */
+ iReturn = XChangeProperty(pDisplay,
+ event.xselectionrequest.requestor,
+ event.xselectionrequest.property,
+ XA_ATOM,
+ 32,
+ PropModeReplace,
+ (unsigned char *) atomTargetArr,
+ (sizeof(atomTargetArr)
+ / sizeof(atomTargetArr[0])));
+ if (iReturn == BadAlloc
+ || iReturn == BadAtom
+ || iReturn == BadMatch
+ || iReturn == BadValue || iReturn == BadWindow) {
+ ErrorF("winClipboardFlushXEvents - SelectionRequest - "
+ "XChangeProperty failed: %d\n", iReturn);
+ }
+
+ /* Setup selection notify xevent */
+ eventSelection.type = SelectionNotify;
+ eventSelection.send_event = True;
+ eventSelection.display = pDisplay;
+ eventSelection.requestor = event.xselectionrequest.requestor;
+ eventSelection.selection = event.xselectionrequest.selection;
+ eventSelection.target = event.xselectionrequest.target;
+ eventSelection.property = event.xselectionrequest.property;
+ eventSelection.time = event.xselectionrequest.time;
+
+ /*
+ * Notify the requesting window that
+ * the operation has completed
+ */
+ iReturn = XSendEvent(pDisplay,
+ eventSelection.requestor,
+ False, 0L, (XEvent *) & eventSelection);
+ if (iReturn == BadValue || iReturn == BadWindow) {
+ ErrorF("winClipboardFlushXEvents - SelectionRequest - "
+ "XSendEvent () failed\n");
+ }
+ break;
+ }
+
+ /* Check that clipboard format is available */
+ if (fUseUnicode && !IsClipboardFormatAvailable(CF_UNICODETEXT)) {
+ static int count; /* Hack to stop acroread spamming the log */
+ static HWND lasthwnd; /* I've not seen any other client get here repeatedly? */
+
+ if (hwnd != lasthwnd)
+ count = 0;
+ count++;
+ if (count < 6)
+ ErrorF("winClipboardFlushXEvents - CF_UNICODETEXT is not "
+ "available from Win32 clipboard. Aborting %d.\n",
+ count);
+ lasthwnd = hwnd;
+
+ /* Abort */
+ fAbort = TRUE;
+ goto winClipboardFlushXEvents_SelectionRequest_Done;
+ }
+ else if (!fUseUnicode && !IsClipboardFormatAvailable(CF_TEXT)) {
+ ErrorF("winClipboardFlushXEvents - CF_TEXT is not "
+ "available from Win32 clipboard. Aborting.\n");
+
+ /* Abort */
+ fAbort = TRUE;
+ goto winClipboardFlushXEvents_SelectionRequest_Done;
+ }
+
+ /* Access the clipboard */
if (!ClipboardOpened)
{
if (!OpenClipboard (hwnd))
@@ -237,35 +223,32 @@ winClipboardFlushXEvents (HWND hwnd,
/* Indicate that clipboard was opened */
fCloseClipboard = TRUE;
}
- /* Setup the string style */
- if (event.xselectionrequest.target == XA_STRING)
- xiccesStyle = XStringStyle;
+ /* Setup the string style */
+ if (event.xselectionrequest.target == XA_STRING)
+ xiccesStyle = XStringStyle;
#ifdef X_HAVE_UTF8_STRING
- else if (event.xselectionrequest.target == atomUTF8String)
- xiccesStyle = XUTF8StringStyle;
+ else if (event.xselectionrequest.target == atomUTF8String)
+ xiccesStyle = XUTF8StringStyle;
#endif
- else if (event.xselectionrequest.target == atomCompoundText)
- xiccesStyle = XCompoundTextStyle;
- else
- xiccesStyle = XStringStyle;
-
- /*
- * FIXME: Can't pass CF_UNICODETEXT on Windows 95/98/Me
- */
-
- /* Get a pointer to the clipboard text, in desired format */
- if (fUseUnicode)
- {
- /* Retrieve clipboard data */
- hGlobal = GetClipboardData (CF_UNICODETEXT);
- }
- else
- {
- /* Retrieve clipboard data */
- hGlobal = GetClipboardData (CF_TEXT);
- }
- if (!hGlobal)
- {
+ else if (event.xselectionrequest.target == atomCompoundText)
+ xiccesStyle = XCompoundTextStyle;
+ else
+ xiccesStyle = XStringStyle;
+
+ /*
+ * FIXME: Can't pass CF_UNICODETEXT on Windows 95/98/Me
+ */
+
+ /* Get a pointer to the clipboard text, in desired format */
+ if (fUseUnicode) {
+ /* Retrieve clipboard data */
+ hGlobal = GetClipboardData(CF_UNICODETEXT);
+ }
+ else {
+ /* Retrieve clipboard data */
+ hGlobal = GetClipboardData(CF_TEXT);
+ }
+ if (!hGlobal) {
if (GetLastError()==ERROR_CLIPBOARD_NOT_OPEN && ClipboardOpened)
{
ErrorF("We should not have received a SelectionRequest????\n"
@@ -276,541 +259,468 @@ winClipboardFlushXEvents (HWND hwnd,
XSetSelectionOwner (pDisplay, XInternAtom (pDisplay, "CLIPBOARD", False), None, CurrentTime);
}
ErrorF ("winClipboardFlushXEvents - SelectionRequest - "
- "GetClipboardData () failed: %08lx\n",
- GetLastError ());
-
- /* Abort */
- fAbort = TRUE;
- goto winClipboardFlushXEvents_SelectionRequest_Done;
- }
- pszGlobalData = (char *) GlobalLock (hGlobal);
-
- /* Convert the Unicode string to UTF8 (MBCS) */
- if (fUseUnicode)
- {
- iConvertDataLen = WideCharToMultiByte (CP_UTF8,
- 0,
- (LPCWSTR)pszGlobalData,
- -1,
- NULL,
- 0,
- NULL,
- NULL);
- /* NOTE: iConvertDataLen includes space for null terminator */
- pszConvertData = (char *) malloc (iConvertDataLen);
- WideCharToMultiByte (CP_UTF8,
- 0,
- (LPCWSTR)pszGlobalData,
- -1,
- pszConvertData,
- iConvertDataLen,
- NULL,
- NULL);
- }
- else
- {
- pszConvertData = strdup (pszGlobalData);
- iConvertDataLen = strlen (pszConvertData) + 1;
- }
-
- /* Convert DOS string to UNIX string */
- winClipboardDOStoUNIX (pszConvertData, strlen (pszConvertData));
-
- /* Setup our text list */
- pszTextList[0] = pszConvertData;
- pszTextList[1] = NULL;
-
- /* Initialize the text property */
- xtpText.value = NULL;
- xtpText.nitems = 0;
-
- /* Create the text property from the text list */
- if (fUseUnicode)
- {
+ "GetClipboardData () failed: %08lx\n", GetLastError());
+
+ /* Abort */
+ fAbort = TRUE;
+ goto winClipboardFlushXEvents_SelectionRequest_Done;
+ }
+ pszGlobalData = (char *) GlobalLock(hGlobal);
+
+ /* Convert the Unicode string to UTF8 (MBCS) */
+ if (fUseUnicode) {
+ iConvertDataLen = WideCharToMultiByte(CP_UTF8,
+ 0,
+ (LPCWSTR) pszGlobalData,
+ -1, NULL, 0, NULL, NULL);
+ /* NOTE: iConvertDataLen includes space for null terminator */
+ pszConvertData = (char *) malloc(iConvertDataLen);
+ WideCharToMultiByte(CP_UTF8,
+ 0,
+ (LPCWSTR) pszGlobalData,
+ -1,
+ pszConvertData,
+ iConvertDataLen, NULL, NULL);
+ }
+ else {
+ pszConvertData = strdup(pszGlobalData);
+ iConvertDataLen = strlen(pszConvertData) + 1;
+ }
+
+ /* Convert DOS string to UNIX string */
+ winClipboardDOStoUNIX(pszConvertData, strlen(pszConvertData));
+
+ /* Setup our text list */
+ pszTextList[0] = pszConvertData;
+ pszTextList[1] = NULL;
+
+ /* Initialize the text property */
+ xtpText.value = NULL;
+ xtpText.nitems = 0;
+
+ /* Create the text property from the text list */
+ if (fUseUnicode) {
#ifdef X_HAVE_UTF8_STRING
- iReturn = Xutf8TextListToTextProperty (pDisplay,
- pszTextList,
- 1,
- xiccesStyle,
- &xtpText);
+ iReturn = Xutf8TextListToTextProperty(pDisplay,
+ pszTextList,
+ 1, xiccesStyle, &xtpText);
#endif
- }
- else
- {
- iReturn = XmbTextListToTextProperty (pDisplay,
- pszTextList,
- 1,
- xiccesStyle,
- &xtpText);
- }
- if (iReturn == XNoMemory || iReturn == XLocaleNotSupported)
- {
- ErrorF ("winClipboardFlushXEvents - SelectionRequest - "
- "X*TextListToTextProperty failed: %d\n",
- iReturn);
-
- /* Abort */
- fAbort = TRUE;
- goto winClipboardFlushXEvents_SelectionRequest_Done;
- }
-
- /* Free the converted string */
- free (pszConvertData);
- pszConvertData = NULL;
-
- /* Copy the clipboard text to the requesting window */
- iReturn = XChangeProperty (pDisplay,
- event.xselectionrequest.requestor,
- event.xselectionrequest.property,
- event.xselectionrequest.target,
- 8,
- PropModeReplace,
- xtpText.value,
- xtpText.nitems);
- if (iReturn == BadAlloc || iReturn == BadAtom
- || iReturn == BadMatch || iReturn == BadValue
- || iReturn == BadWindow)
- {
- ErrorF ("winClipboardFlushXEvents - SelectionRequest - "
- "XChangeProperty failed: %d\n",
- iReturn);
-
- /* Abort */
- fAbort = TRUE;
- goto winClipboardFlushXEvents_SelectionRequest_Done;
- }
-
- /* Release the clipboard data */
- GlobalUnlock (hGlobal);
- pszGlobalData = NULL;
+ }
+ else {
+ iReturn = XmbTextListToTextProperty(pDisplay,
+ pszTextList,
+ 1, xiccesStyle, &xtpText);
+ }
+ if (iReturn == XNoMemory || iReturn == XLocaleNotSupported) {
+ ErrorF("winClipboardFlushXEvents - SelectionRequest - "
+ "X*TextListToTextProperty failed: %d\n", iReturn);
+
+ /* Abort */
+ fAbort = TRUE;
+ goto winClipboardFlushXEvents_SelectionRequest_Done;
+ }
+
+ /* Free the converted string */
+ free(pszConvertData);
+ pszConvertData = NULL;
+
+ /* Copy the clipboard text to the requesting window */
+ iReturn = XChangeProperty(pDisplay,
+ event.xselectionrequest.requestor,
+ event.xselectionrequest.property,
+ event.xselectionrequest.target,
+ 8,
+ PropModeReplace,
+ xtpText.value, xtpText.nitems);
+ if (iReturn == BadAlloc || iReturn == BadAtom
+ || iReturn == BadMatch || iReturn == BadValue
+ || iReturn == BadWindow) {
+ ErrorF("winClipboardFlushXEvents - SelectionRequest - "
+ "XChangeProperty failed: %d\n", iReturn);
+
+ /* Abort */
+ fAbort = TRUE;
+ goto winClipboardFlushXEvents_SelectionRequest_Done;
+ }
+
+ /* Release the clipboard data */
+ GlobalUnlock(hGlobal);
+ pszGlobalData = NULL;
if (fCloseClipboard)
{
fCloseClipboard = FALSE;
CloseClipboard ();
}
- /* Clean up */
- XFree (xtpText.value);
- xtpText.value = NULL;
- xtpText.nitems = 0;
-
- /* Setup selection notify event */
- eventSelection.type = SelectionNotify;
- eventSelection.send_event = True;
- eventSelection.display = pDisplay;
- eventSelection.requestor = event.xselectionrequest.requestor;
- eventSelection.selection = event.xselectionrequest.selection;
- eventSelection.target = event.xselectionrequest.target;
- eventSelection.property = event.xselectionrequest.property;
- eventSelection.time = event.xselectionrequest.time;
-
- /* Notify the requesting window that the operation has completed */
- iReturn = XSendEvent (pDisplay,
- eventSelection.requestor,
- False,
- 0L,
- (XEvent *) &eventSelection);
- if (iReturn == BadValue || iReturn == BadWindow)
- {
- ErrorF ("winClipboardFlushXEvents - SelectionRequest - "
- "XSendEvent () failed\n");
-
- /* Abort */
- fAbort = TRUE;
- goto winClipboardFlushXEvents_SelectionRequest_Done;
- }
-
- winClipboardFlushXEvents_SelectionRequest_Done:
- /* Free allocated resources */
- if (xtpText.value)
- {
- XFree (xtpText.value);
- xtpText.value = NULL;
- xtpText.nitems = 0;
- }
- free(pszConvertData);
- if (hGlobal && pszGlobalData)
- GlobalUnlock (hGlobal);
-
- /*
- * Send a SelectionNotify event to the requesting
- * client when we abort.
- */
- if (fAbort)
- {
- /* Setup selection notify event */
- eventSelection.type = SelectionNotify;
- eventSelection.send_event = True;
- eventSelection.display = pDisplay;
- eventSelection.requestor = event.xselectionrequest.requestor;
- eventSelection.selection = event.xselectionrequest.selection;
- eventSelection.target = event.xselectionrequest.target;
- eventSelection.property = None;
- eventSelection.time = event.xselectionrequest.time;
-
- /* Notify the requesting window that the operation is complete */
- iReturn = XSendEvent (pDisplay,
- eventSelection.requestor,
- False,
- 0L,
- (XEvent *) &eventSelection);
- if (iReturn == BadValue || iReturn == BadWindow)
- {
- /*
- * Should not be a problem if XSendEvent fails because
- * the client may simply have exited.
- */
- ErrorF ("winClipboardFlushXEvents - SelectionRequest - "
- "XSendEvent () failed for abort event.\n");
- }
- }
-
- /* Close clipboard if it was opened */
- if (fCloseClipboard)
- {
- fCloseClipboard = FALSE;
- CloseClipboard ();
- }
- break;
-
-
- /*
- * SelectionNotify
- */
- case SelectionNotify:
+ /* Clean up */
+ XFree(xtpText.value);
+ xtpText.value = NULL;
+ xtpText.nitems = 0;
+
+ /* Setup selection notify event */
+ eventSelection.type = SelectionNotify;
+ eventSelection.send_event = True;
+ eventSelection.display = pDisplay;
+ eventSelection.requestor = event.xselectionrequest.requestor;
+ eventSelection.selection = event.xselectionrequest.selection;
+ eventSelection.target = event.xselectionrequest.target;
+ eventSelection.property = event.xselectionrequest.property;
+ eventSelection.time = event.xselectionrequest.time;
+
+ /* Notify the requesting window that the operation has completed */
+ iReturn = XSendEvent(pDisplay,
+ eventSelection.requestor,
+ False, 0L, (XEvent *) & eventSelection);
+ if (iReturn == BadValue || iReturn == BadWindow) {
+ ErrorF("winClipboardFlushXEvents - SelectionRequest - "
+ "XSendEvent () failed\n");
+
+ /* Abort */
+ fAbort = TRUE;
+ goto winClipboardFlushXEvents_SelectionRequest_Done;
+ }
+
+ winClipboardFlushXEvents_SelectionRequest_Done:
+ /* Free allocated resources */
+ if (xtpText.value) {
+ XFree(xtpText.value);
+ xtpText.value = NULL;
+ xtpText.nitems = 0;
+ }
+ free(pszConvertData);
+ if (hGlobal && pszGlobalData)
+ GlobalUnlock(hGlobal);
+
+ /*
+ * Send a SelectionNotify event to the requesting
+ * client when we abort.
+ */
+ if (fAbort) {
+ /* Setup selection notify event */
+ eventSelection.type = SelectionNotify;
+ eventSelection.send_event = True;
+ eventSelection.display = pDisplay;
+ eventSelection.requestor = event.xselectionrequest.requestor;
+ eventSelection.selection = event.xselectionrequest.selection;
+ eventSelection.target = event.xselectionrequest.target;
+ eventSelection.property = None;
+ eventSelection.time = event.xselectionrequest.time;
+
+ /* Notify the requesting window that the operation is complete */
+ iReturn = XSendEvent(pDisplay,
+ eventSelection.requestor,
+ False, 0L, (XEvent *) & eventSelection);
+ if (iReturn == BadValue || iReturn == BadWindow) {
+ /*
+ * Should not be a problem if XSendEvent fails because
+ * the client may simply have exited.
+ */
+ ErrorF("winClipboardFlushXEvents - SelectionRequest - "
+ "XSendEvent () failed for abort event.\n");
+ }
+ }
+
+ /* Close clipboard if it was opened */
+ if (fCloseClipboard) {
+ fCloseClipboard = FALSE;
+ CloseClipboard();
+ }
+ break;
+
+ /*
+ * SelectionNotify
+ */
+ case SelectionNotify:
#ifdef _DEBUG
- winDebug ("winClipboardFlushXEvents - SelectionNotify\n");
- {
- char *pszAtomName;
- pszAtomName = XGetAtomName (pDisplay,
- event.xselection.selection);
+ winDebug("winClipboardFlushXEvents - SelectionNotify\n");
+ {
+ char *pszAtomName;
+
+ pszAtomName = XGetAtomName(pDisplay,
+ event.xselection.selection);
- winDebug("winClipboardFlushXEvents - SelectionNotify - ATOM: %s\n",
+ winDebug
+ ("winClipboardFlushXEvents - SelectionNotify - ATOM: %s\n",
pszAtomName);
winDebug ("SelectionNotify - requestor %d\n", event.xselectionrequest.requestor);
- XFree (pszAtomName);
- }
+ XFree(pszAtomName);
+ }
#endif
- /*
- * Request conversion of UTF8 and CompoundText targets.
- */
- if (event.xselection.property == None)
- {
- if (event.xselection.target == XA_STRING)
- {
- winDebug ("winClipboardFlushXEvents - SelectionNotify - "
- "XA_STRING\n");
-
- return WIN_XEVENTS_CONVERT;
- }
- else if (event.xselection.target == atomUTF8String)
- {
- winDebug("winClipboardFlushXEvents - SelectionNotify - "
- "Requesting conversion of UTF8 target.\n");
-
- XConvertSelection (pDisplay,
- event.xselection.selection,
- XA_STRING,
- atomLocalProperty,
- iWindow,
- CurrentTime);
-
- /* Process the ConvertSelection event */
- XFlush (pDisplay);
- return WIN_XEVENTS_CONVERT;
- }
+ /*
+ * Request conversion of UTF8 and CompoundText targets.
+ */
+ if (event.xselection.property == None) {
+ if (event.xselection.target == XA_STRING) {
+ winDebug("winClipboardFlushXEvents - SelectionNotify - "
+ "XA_STRING\n");
+
+ return WIN_XEVENTS_CONVERT;
+ }
+ else if (event.xselection.target == atomUTF8String) {
+ winDebug("winClipboardFlushXEvents - SelectionNotify - "
+ "Requesting conversion of UTF8 target.\n");
+
+ XConvertSelection(pDisplay,
+ event.xselection.selection,
+ XA_STRING,
+ atomLocalProperty, iWindow, CurrentTime);
+
+ /* Process the ConvertSelection event */
+ XFlush(pDisplay);
+ return WIN_XEVENTS_CONVERT;
+ }
#ifdef X_HAVE_UTF8_STRING
- else if (event.xselection.target == atomCompoundText)
- {
- winDebug("winClipboardFlushXEvents - SelectionNotify - "
- "Requesting conversion of CompoundText target.\n");
-
- XConvertSelection (pDisplay,
- event.xselection.selection,
- atomUTF8String,
- atomLocalProperty,
- iWindow,
- CurrentTime);
-
- /* Process the ConvertSelection event */
- XFlush (pDisplay);
- return WIN_XEVENTS_CONVERT;
- }
+ else if (event.xselection.target == atomCompoundText) {
+ winDebug("winClipboardFlushXEvents - SelectionNotify - "
+ "Requesting conversion of CompoundText target.\n");
+
+ XConvertSelection(pDisplay,
+ event.xselection.selection,
+ atomUTF8String,
+ atomLocalProperty, iWindow, CurrentTime);
+
+ /* Process the ConvertSelection event */
+ XFlush(pDisplay);
+ return WIN_XEVENTS_CONVERT;
+ }
#endif
- else
- {
- ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
- "Unknown format. Cannot request conversion, "
- "aborting.\n");
- break;
- }
- }
-
- /* Retrieve the size of the stored data */
- iReturn = XGetWindowProperty (pDisplay,
- iWindow,
- atomLocalProperty,
- 0,
- 0, /* Don't get data, just size */
- False,
- AnyPropertyType,
- &xtpText.encoding,
- &xtpText.format,
- &xtpText.nitems,
- &ulReturnBytesLeft,
- &xtpText.value);
- if (iReturn != Success)
- {
- ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
- "XGetWindowProperty () failed, aborting: %d\n",
- iReturn);
- break;
- }
-
- winDebug("SelectionNotify - returned data %d left %d\n",
- xtpText.nitems, ulReturnBytesLeft);
-
- /* Request the selection data */
- iReturn = XGetWindowProperty (pDisplay,
- iWindow,
- atomLocalProperty,
- 0,
- ulReturnBytesLeft,
- False,
- AnyPropertyType,
- &xtpText.encoding,
- &xtpText.format,
- &xtpText.nitems,
- &ulReturnBytesLeft,
- &xtpText.value);
- if (iReturn != Success)
- {
- ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
- "XGetWindowProperty () failed, aborting: %d\n",
- iReturn);
- break;
- }
+ else {
+ ErrorF("winClipboardFlushXEvents - SelectionNotify - "
+ "Unknown format. Cannot request conversion, "
+ "aborting.\n");
+ break;
+ }
+ }
+
+ /* Retrieve the size of the stored data */
+ iReturn = XGetWindowProperty(pDisplay, iWindow, atomLocalProperty, 0, 0, /* Don't get data, just size */
+ False,
+ AnyPropertyType,
+ &xtpText.encoding,
+ &xtpText.format,
+ &xtpText.nitems,
+ &ulReturnBytesLeft, &xtpText.value);
+ if (iReturn != Success) {
+ ErrorF("winClipboardFlushXEvents - SelectionNotify - "
+ "XGetWindowProperty () failed, aborting: %d\n", iReturn);
+ break;
+ }
+
+ winDebug("SelectionNotify - returned data %d left %d\n",
+ xtpText.nitems, ulReturnBytesLeft);
+
+ /* Request the selection data */
+ iReturn = XGetWindowProperty(pDisplay,
+ iWindow,
+ atomLocalProperty,
+ 0,
+ ulReturnBytesLeft,
+ False,
+ AnyPropertyType,
+ &xtpText.encoding,
+ &xtpText.format,
+ &xtpText.nitems,
+ &ulReturnBytesLeft, &xtpText.value);
+ if (iReturn != Success) {
+ ErrorF("winClipboardFlushXEvents - SelectionNotify - "
+ "XGetWindowProperty () failed, aborting: %d\n", iReturn);
+ break;
+ }
#ifdef WINDBG
- {
- char *pszAtomName = NULL;
-
- winDebug("SelectionNotify - returned data %d left %d\n",
- xtpText.nitems, ulReturnBytesLeft);
- pszAtomName = XGetAtomName(pDisplay, xtpText.encoding);
- winDebug("Notify atom name %s\n", pszAtomName);
- XFree (pszAtomName);
- pszAtomName = NULL;
- }
+ {
+ char *pszAtomName = NULL;
+
+ winDebug("SelectionNotify - returned data %d left %d\n",
+ xtpText.nitems, ulReturnBytesLeft);
+ pszAtomName = XGetAtomName(pDisplay, xtpText.encoding);
+ winDebug("Notify atom name %s\n", pszAtomName);
+ XFree(pszAtomName);
+ pszAtomName = NULL;
+ }
#endif
- if (fUseUnicode)
- {
+ if (fUseUnicode) {
#ifdef X_HAVE_UTF8_STRING
- /* Convert the text property to a text list */
- iReturn = Xutf8TextPropertyToTextList (pDisplay,
- &xtpText,
- &ppszTextList,
- &iCount);
+ /* Convert the text property to a text list */
+ iReturn = Xutf8TextPropertyToTextList(pDisplay,
+ &xtpText,
+ &ppszTextList, &iCount);
#endif
- }
- else
- {
- iReturn = XmbTextPropertyToTextList (pDisplay,
- &xtpText,
- &ppszTextList,
- &iCount);
- }
- if (iReturn == Success || iReturn > 0)
- {
- /* Conversion succeeded or some unconvertible characters */
- if (ppszTextList != NULL)
- {
- iReturnDataLen = 0;
- for (i = 0; i < iCount; i++)
- {
- iReturnDataLen += strlen(ppszTextList[i]);
- }
- pszReturnData = (char *) malloc (iReturnDataLen + 1);
- pszReturnData[0] = '\0';
- for (i = 0; i < iCount; i++)
- {
- strcat (pszReturnData, ppszTextList[i]);
- }
- }
- else
- {
- ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
- "X*TextPropertyToTextList list_return is NULL.\n");
- pszReturnData = (char *) malloc (1);
- pszReturnData[0] = '\0';
- }
- }
- else
- {
- ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
- "X*TextPropertyToTextList returned: ");
- switch (iReturn)
- {
- case XNoMemory:
- ErrorF ("XNoMemory\n");
- break;
- case XLocaleNotSupported:
- ErrorF ("XLocaleNotSupported\n");
- break;
- case XConverterNotFound:
- ErrorF ("XConverterNotFound\n");
- break;
- default:
- ErrorF ("%d\n", iReturn);
- break;
- }
- pszReturnData = (char *) malloc (1);
- pszReturnData[0] = '\0';
- }
-
- /* Free the data returned from XGetWindowProperty */
- if (ppszTextList)
- XFreeStringList (ppszTextList);
- ppszTextList = NULL;
- XFree (xtpText.value);
- xtpText.value = NULL;
- xtpText.nitems = 0;
-
- /* Convert the X clipboard string to DOS format */
- winClipboardUNIXtoDOS ((unsigned char **)&pszReturnData, strlen (pszReturnData));
-
- if (fUseUnicode)
- {
- /* Find out how much space needed to convert MBCS to Unicode */
- iUnicodeLen = MultiByteToWideChar (CP_UTF8,
- 0,
- pszReturnData,
- -1,
- NULL,
- 0);
-
- /* Allocate memory for the Unicode string */
- pwszUnicodeStr
- = (wchar_t*) malloc (sizeof (wchar_t) * (iUnicodeLen + 1));
- if (!pwszUnicodeStr)
- {
- ErrorF ("winClipboardFlushXEvents - SelectionNotify "
- "malloc failed for pwszUnicodeStr, aborting.\n");
-
- /* Abort */
- fAbort = TRUE;
- goto winClipboardFlushXEvents_SelectionNotify_Done;
- }
-
- /* Do the actual conversion */
- MultiByteToWideChar (CP_UTF8,
- 0,
- pszReturnData,
- -1,
- pwszUnicodeStr,
- iUnicodeLen);
-
- /* Allocate global memory for the X clipboard data */
- hGlobal = GlobalAlloc (GMEM_MOVEABLE,
- sizeof (wchar_t) * (iUnicodeLen + 1));
- }
- else
- {
- pszConvertData = strdup (pszReturnData);
- iConvertDataLen = strlen (pszConvertData) + 1;
-
- /* Allocate global memory for the X clipboard data */
- hGlobal = GlobalAlloc (GMEM_MOVEABLE, iConvertDataLen);
- }
-
- free (pszReturnData);
-
- /* Check that global memory was allocated */
- if (!hGlobal)
- {
- ErrorF ("winClipboardFlushXEvents - SelectionNotify "
- "GlobalAlloc failed, aborting: %ld\n",
- GetLastError ());
-
- /* Abort */
- fAbort = TRUE;
- goto winClipboardFlushXEvents_SelectionNotify_Done;
- }
-
- /* Obtain a pointer to the global memory */
- pszGlobalData = GlobalLock (hGlobal);
- if (pszGlobalData == NULL)
- {
- ErrorF ("winClipboardFlushXEvents - Could not lock global "
- "memory for clipboard transfer\n");
-
- /* Abort */
- fAbort = TRUE;
- goto winClipboardFlushXEvents_SelectionNotify_Done;
- }
-
- /* Copy the returned string into the global memory */
- if (fUseUnicode)
- {
- memcpy (pszGlobalData,
- pwszUnicodeStr,
- sizeof (wchar_t) * (iUnicodeLen + 1));
- free (pwszUnicodeStr);
- pwszUnicodeStr = NULL;
- }
- else
- {
- strcpy (pszGlobalData, pszConvertData);
- free (pszConvertData);
- pszConvertData = NULL;
- }
-
- /* Release the pointer to the global memory */
- GlobalUnlock (hGlobal);
- pszGlobalData = NULL;
-
- /* Push the selection data to the Windows clipboard */
- if (fUseUnicode)
- SetClipboardData (CF_UNICODETEXT, hGlobal);
- else
- SetClipboardData (CF_TEXT, hGlobal);
-
- /* Flag that SetClipboardData has been called */
- fSetClipboardData = FALSE;
-
- /*
- * NOTE: Do not try to free pszGlobalData, it is owned by
- * Windows after the call to SetClipboardData ().
- */
-
- winClipboardFlushXEvents_SelectionNotify_Done:
- /* Free allocated resources */
- if (ppszTextList)
- XFreeStringList (ppszTextList);
- if (xtpText.value)
- {
- XFree (xtpText.value);
- xtpText.value = NULL;
- xtpText.nitems = 0;
- }
- free(pszConvertData);
- free(pwszUnicodeStr);
- if (hGlobal && pszGlobalData)
- GlobalUnlock (hGlobal);
- if (fSetClipboardData && g_fUnicodeSupport)
- SetClipboardData (CF_UNICODETEXT, NULL);
- if (fSetClipboardData)
- SetClipboardData (CF_TEXT, NULL);
- return WIN_XEVENTS_NOTIFY;
+ }
+ else {
+ iReturn = XmbTextPropertyToTextList(pDisplay,
+ &xtpText,
+ &ppszTextList, &iCount);
+ }
+ if (iReturn == Success || iReturn > 0) {
+ /* Conversion succeeded or some unconvertible characters */
+ if (ppszTextList != NULL) {
+ iReturnDataLen = 0;
+ for (i = 0; i < iCount; i++) {
+ iReturnDataLen += strlen(ppszTextList[i]);
+ }
+ pszReturnData = (char *) malloc(iReturnDataLen + 1);
+ pszReturnData[0] = '\0';
+ for (i = 0; i < iCount; i++) {
+ strcat(pszReturnData, ppszTextList[i]);
+ }
+ }
+ else {
+ ErrorF("winClipboardFlushXEvents - SelectionNotify - "
+ "X*TextPropertyToTextList list_return is NULL.\n");
+ pszReturnData = (char *) malloc(1);
+ pszReturnData[0] = '\0';
+ }
+ }
+ else {
+ ErrorF("winClipboardFlushXEvents - SelectionNotify - "
+ "X*TextPropertyToTextList returned: ");
+ switch (iReturn) {
+ case XNoMemory:
+ ErrorF("XNoMemory\n");
+ break;
+ case XLocaleNotSupported:
+ ErrorF("XLocaleNotSupported\n");
+ break;
+ case XConverterNotFound:
+ ErrorF("XConverterNotFound\n");
+ break;
+ default:
+ ErrorF("%d\n", iReturn);
+ break;
+ }
+ pszReturnData = (char *) malloc(1);
+ pszReturnData[0] = '\0';
+ }
+
+ /* Free the data returned from XGetWindowProperty */
+ if (ppszTextList)
+ XFreeStringList(ppszTextList);
+ ppszTextList = NULL;
+ XFree(xtpText.value);
+ xtpText.value = NULL;
+ xtpText.nitems = 0;
+
+ /* Convert the X clipboard string to DOS format */
+ winClipboardUNIXtoDOS((unsigned char **)&pszReturnData, strlen(pszReturnData));
+
+ if (fUseUnicode) {
+ /* Find out how much space needed to convert MBCS to Unicode */
+ iUnicodeLen = MultiByteToWideChar(CP_UTF8,
+ 0,
+ pszReturnData, -1, NULL, 0);
+
+ /* Allocate memory for the Unicode string */
+ pwszUnicodeStr
+ = (wchar_t *) malloc(sizeof(wchar_t) * (iUnicodeLen + 1));
+ if (!pwszUnicodeStr) {
+ ErrorF("winClipboardFlushXEvents - SelectionNotify "
+ "malloc failed for pwszUnicodeStr, aborting.\n");
+
+ /* Abort */
+ fAbort = TRUE;
+ goto winClipboardFlushXEvents_SelectionNotify_Done;
+ }
+
+ /* Do the actual conversion */
+ MultiByteToWideChar(CP_UTF8,
+ 0,
+ pszReturnData,
+ -1, pwszUnicodeStr, iUnicodeLen);
+
+ /* Allocate global memory for the X clipboard data */
+ hGlobal = GlobalAlloc(GMEM_MOVEABLE,
+ sizeof(wchar_t) * (iUnicodeLen + 1));
+ }
+ else {
+ pszConvertData = strdup(pszReturnData);
+ iConvertDataLen = strlen(pszConvertData) + 1;
+
+ /* Allocate global memory for the X clipboard data */
+ hGlobal = GlobalAlloc(GMEM_MOVEABLE, iConvertDataLen);
+ }
+
+ free(pszReturnData);
+
+ /* Check that global memory was allocated */
+ if (!hGlobal) {
+ ErrorF("winClipboardFlushXEvents - SelectionNotify "
+ "GlobalAlloc failed, aborting: %ld\n", GetLastError());
+
+ /* Abort */
+ fAbort = TRUE;
+ goto winClipboardFlushXEvents_SelectionNotify_Done;
+ }
+
+ /* Obtain a pointer to the global memory */
+ pszGlobalData = GlobalLock(hGlobal);
+ if (pszGlobalData == NULL) {
+ ErrorF("winClipboardFlushXEvents - Could not lock global "
+ "memory for clipboard transfer\n");
+
+ /* Abort */
+ fAbort = TRUE;
+ goto winClipboardFlushXEvents_SelectionNotify_Done;
+ }
+
+ /* Copy the returned string into the global memory */
+ if (fUseUnicode) {
+ memcpy(pszGlobalData,
+ pwszUnicodeStr, sizeof(wchar_t) * (iUnicodeLen + 1));
+ free(pwszUnicodeStr);
+ pwszUnicodeStr = NULL;
+ }
+ else {
+ strcpy(pszGlobalData, pszConvertData);
+ free(pszConvertData);
+ pszConvertData = NULL;
+ }
+
+ /* Release the pointer to the global memory */
+ GlobalUnlock(hGlobal);
+ pszGlobalData = NULL;
+
+ /* Push the selection data to the Windows clipboard */
+ if (fUseUnicode)
+ SetClipboardData(CF_UNICODETEXT, hGlobal);
+ else
+ SetClipboardData(CF_TEXT, hGlobal);
+
+ /* Flag that SetClipboardData has been called */
+ fSetClipboardData = FALSE;
+
+ /*
+ * NOTE: Do not try to free pszGlobalData, it is owned by
+ * Windows after the call to SetClipboardData ().
+ */
+
+ winClipboardFlushXEvents_SelectionNotify_Done:
+ /* Free allocated resources */
+ if (ppszTextList)
+ XFreeStringList(ppszTextList);
+ if (xtpText.value) {
+ XFree(xtpText.value);
+ xtpText.value = NULL;
+ xtpText.nitems = 0;
+ }
+ free(pszConvertData);
+ free(pwszUnicodeStr);
+ if (hGlobal && pszGlobalData)
+ GlobalUnlock(hGlobal);
+ if (fSetClipboardData && g_fUnicodeSupport)
+ SetClipboardData(CF_UNICODETEXT, NULL);
+ if (fSetClipboardData)
+ SetClipboardData(CF_TEXT, NULL);
+ return WIN_XEVENTS_NOTIFY;
/*
* SelectionClear
*/
case SelectionClear:
#ifdef _DEBUG
- winDebug ("SelectionClear - doing nothing\n");
+ winDebug("SelectionClear - doing nothing\n");
{
char *pszAtomName;
@@ -824,20 +734,21 @@ winClipboardFlushXEvents (HWND hwnd,
XFree (pszAtomName);
}
#endif
- break;
+ break;
- case PropertyNotify:
- break;
+ case PropertyNotify:
+ break;
- case MappingNotify:
- XRefreshKeyboardMapping((XMappingEvent *)&event);
- break;
-
- default:
- ErrorF ("winClipboardFlushXEvents - unexpected event type %d\n", event.type);
- break;
- }
+ case MappingNotify:
+ XRefreshKeyboardMapping((XMappingEvent *)&event);
+ break;
+
+ default:
+ ErrorF("winClipboardFlushXEvents - unexpected event type %d\n",
+ event.type);
+ break;
+ }
}
- return WIN_XEVENTS_SUCCESS;
+ return WIN_XEVENTS_SUCCESS;
}
diff --git a/xorg-server/hw/xwin/wincmap.c b/xorg-server/hw/xwin/wincmap.c
index 83279fd84..283372a9f 100644
--- a/xorg-server/hw/xwin/wincmap.c
+++ b/xorg-server/hw/xwin/wincmap.c
@@ -1,619 +1,550 @@
-/*
- *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, sublicense, and/or sell copies of the Software, and to
- *permit persons to whom the Software is furnished to do so, subject to
- *the following conditions:
- *
- *The above copyright notice and this permission notice shall be
- *included in all copies or substantial portions of the Software.
- *
- *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
- *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *Except as contained in this notice, the name of the XFree86 Project
- *shall not be used in advertising or otherwise to promote the sale, use
- *or other dealings in this Software without prior written authorization
- *from the XFree86 Project.
- *
- * Authors: Dakshinamurthy Karra
- * Suhaib M Siddiqi
- * Peter Busch
- * Harold L Hunt II
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-
-
-/*
- * Local prototypes
- */
-
-static int
-winListInstalledColormaps (ScreenPtr pScreen, Colormap *pmaps);
-
-static void
-winStoreColors (ColormapPtr pmap, int ndef, xColorItem *pdefs);
-
-static void
-winInstallColormap (ColormapPtr pmap);
-
-static void
-winUninstallColormap (ColormapPtr pmap);
-
-static void
-winResolveColor (unsigned short *pred,
- unsigned short *pgreen,
- unsigned short *pblue,
- VisualPtr pVisual);
-
-static Bool
-winCreateColormap (ColormapPtr pmap);
-
-static void
-winDestroyColormap (ColormapPtr pmap);
-
-static Bool
-winGetPaletteDIB (ScreenPtr pScreen, ColormapPtr pcmap);
-
-static Bool
-winGetPaletteDD (ScreenPtr pScreen, ColormapPtr pcmap);
-
-
-/*
- * Set screen functions for colormaps
- */
-
-void
-winSetColormapFunctions (ScreenPtr pScreen)
-{
- pScreen->CreateColormap = winCreateColormap;
- pScreen->DestroyColormap = winDestroyColormap;
- pScreen->InstallColormap = winInstallColormap;
- pScreen->UninstallColormap = winUninstallColormap;
- pScreen->ListInstalledColormaps = winListInstalledColormaps;
- pScreen->StoreColors = winStoreColors;
- pScreen->ResolveColor = winResolveColor;
-}
-
-
-/* See Porting Layer Definition - p. 30 */
-/*
- * Walk the list of installed colormaps, filling the pmaps list
- * with the resource ids of the installed maps, and return
- * a count of the total number of installed maps.
- */
-static int
-winListInstalledColormaps (ScreenPtr pScreen, Colormap *pmaps)
-{
- winScreenPriv(pScreen);
-
- /*
- * There will only be one installed colormap, so we only need
- * to return one id, and the count of installed maps will always
- * be one.
- */
- *pmaps = pScreenPriv->pcmapInstalled->mid;
- return 1;
-}
-
-
-/* See Porting Layer Definition - p. 30 */
-/* See Programming Windows - p. 663 */
-static void
-winInstallColormap (ColormapPtr pColormap)
-{
- ScreenPtr pScreen = pColormap->pScreen;
- winScreenPriv(pScreen);
- ColormapPtr oldpmap = pScreenPriv->pcmapInstalled;
-
- winDebug ("winInstallColormap\n");
-
- /* Did the colormap actually change? */
- if (pColormap != oldpmap)
- {
- winDebug ("winInstallColormap - Colormap has changed, attempt "
- "to install.\n");
-
- /* Was there a previous colormap? */
- if (oldpmap != (ColormapPtr) None)
- {
- /* There was a previous colormap; tell clients it is gone */
- WalkTree (pColormap->pScreen, TellLostMap, (char *)&oldpmap->mid);
- }
-
- /* Install new colormap */
- pScreenPriv->pcmapInstalled = pColormap;
- WalkTree (pColormap->pScreen, TellGainedMap, (char *)&pColormap->mid);
-
- /* Call the engine specific colormap install procedure */
- if (!((*pScreenPriv->pwinInstallColormap) (pColormap)))
- {
- ErrorF ("winInstallColormap - Screen specific colormap install "
- "procedure failed. Continuing, but colors may be "
- "messed up from now on.\n");
- }
- }
-
- /* Save a pointer to the newly installed colormap */
- pScreenPriv->pcmapInstalled = pColormap;
-}
-
-
-/* See Porting Layer Definition - p. 30 */
-static void
-winUninstallColormap (ColormapPtr pmap)
-{
- winScreenPriv(pmap->pScreen);
- ColormapPtr curpmap = pScreenPriv->pcmapInstalled;
-
- winDebug ("winUninstallColormap\n");
-
- /* Is the colormap currently installed? */
- if (pmap != curpmap)
- {
- /* Colormap not installed, nothing to do */
- return;
- }
-
- /* Clear the installed colormap flag */
- pScreenPriv->pcmapInstalled = NULL;
-
- /*
- * NOTE: The default colormap does not get "uninstalled" before
- * it is destroyed.
- */
-
- /* Install the default cmap in place of the cmap to be uninstalled */
- if (pmap->mid != pmap->pScreen->defColormap)
- {
- dixLookupResourceByType((pointer) &curpmap, pmap->pScreen->defColormap,
- RT_COLORMAP, NullClient, DixUnknownAccess);
- (*pmap->pScreen->InstallColormap) (curpmap);
- }
-}
-
-
-/* See Porting Layer Definition - p. 30 */
-static void
-winStoreColors (ColormapPtr pmap,
- int ndef,
- xColorItem *pdefs)
-{
- ScreenPtr pScreen = pmap->pScreen;
- winScreenPriv(pScreen);
- winCmapPriv(pmap);
- int i;
- unsigned short nRed, nGreen, nBlue;
-
-#ifdef WINDBG
- if (ndef != 1)
- winDebug ("winStoreColors - ndef: %d\n",
- ndef);
-#endif
-
- /* Save the new colors in the colormap privates */
- for (i = 0; i < ndef; ++i)
- {
- /* Adjust the colors from the X color spec to the Windows color spec */
- nRed = pdefs[i].red >> 8;
- nGreen = pdefs[i].green >> 8;
- nBlue = pdefs[i].blue >> 8;
-
- /* Copy the colors to a palette entry table */
- pCmapPriv->peColors[pdefs[0].pixel + i].peRed = nRed;
- pCmapPriv->peColors[pdefs[0].pixel + i].peGreen = nGreen;
- pCmapPriv->peColors[pdefs[0].pixel + i].peBlue = nBlue;
-
- /* Copy the colors to a RGBQUAD table */
- pCmapPriv->rgbColors[pdefs[0].pixel + i].rgbRed = nRed;
- pCmapPriv->rgbColors[pdefs[0].pixel + i].rgbGreen = nGreen;
- pCmapPriv->rgbColors[pdefs[0].pixel + i].rgbBlue = nBlue;
-
- winDebug ("winStoreColors - nRed %d nGreen %d nBlue %d\n",
- nRed, nGreen, nBlue);
- }
-
- /* Call the engine specific store colors procedure */
- if (!((pScreenPriv->pwinStoreColors) (pmap, ndef, pdefs)))
- {
- ErrorF ("winStoreColors - Engine cpecific color storage procedure "
- "failed. Continuing, but colors may be messed up from now "
- "on.\n");
- }
-}
-
-
-/* See Porting Layer Definition - p. 30 */
-static void
-winResolveColor (unsigned short *pred,
- unsigned short *pgreen,
- unsigned short *pblue,
- VisualPtr pVisual)
-{
- winDebug ("winResolveColor ()\n");
-
- miResolveColor (pred, pgreen, pblue, pVisual);
-}
-
-
-/* See Porting Layer Definition - p. 29 */
-static Bool
-winCreateColormap (ColormapPtr pmap)
-{
- winPrivCmapPtr pCmapPriv = NULL;
- ScreenPtr pScreen = pmap->pScreen;
- winScreenPriv(pScreen);
-
- winDebug ("winCreateColormap\n");
-
- /* Allocate colormap privates */
- if (!winAllocateCmapPrivates (pmap))
- {
- ErrorF ("winCreateColorma - Couldn't allocate cmap privates\n");
- return FALSE;
- }
-
- /* Get a pointer to the newly allocated privates */
- pCmapPriv = winGetCmapPriv (pmap);
-
- /*
- * FIXME: This is some evil hackery to help in handling some X clients
- * that expect the top pixel to be white. This "help" only lasts until
- * some client overwrites the top colormap entry.
- *
- * We don't want to actually allocate the top entry, as that causes
- * problems with X clients that need 7 planes (128 colors) in the default
- * colormap, such as Magic 7.1.
- */
- pCmapPriv->rgbColors[WIN_NUM_PALETTE_ENTRIES - 1].rgbRed = 255;
- pCmapPriv->rgbColors[WIN_NUM_PALETTE_ENTRIES - 1].rgbGreen = 255;
- pCmapPriv->rgbColors[WIN_NUM_PALETTE_ENTRIES - 1].rgbBlue = 255;
- pCmapPriv->peColors[WIN_NUM_PALETTE_ENTRIES - 1].peRed = 255;
- pCmapPriv->peColors[WIN_NUM_PALETTE_ENTRIES - 1].peGreen = 255;
- pCmapPriv->peColors[WIN_NUM_PALETTE_ENTRIES - 1].peBlue = 255;
-
- /* Call the engine specific colormap initialization procedure */
- if (!((*pScreenPriv->pwinCreateColormap) (pmap)))
- {
- ErrorF ("winCreateColormap - Engine specific colormap creation "
- "procedure failed. Aborting.\n");
- return FALSE;
- }
-
- return TRUE;
-}
-
-
-/* See Porting Layer Definition - p. 29, 30 */
-static void
-winDestroyColormap (ColormapPtr pColormap)
-{
- winScreenPriv(pColormap->pScreen);
- winCmapPriv(pColormap);
-
- /* Call the engine specific colormap destruction procedure */
- if (!((*pScreenPriv->pwinDestroyColormap) (pColormap)))
- {
- ErrorF ("winDestroyColormap - Engine specific colormap destruction "
- "procedure failed. Continuing, but it is possible that memory "
- "was leaked, or that colors will be messed up from now on.\n");
- }
-
- /* Free the colormap privates */
- free (pCmapPriv);
- winSetCmapPriv (pColormap, NULL);
-
- winDebug ("winDestroyColormap - Returning\n");
-}
-
-
-/*
- * Internal function to load the palette used by the Shadow DIB
- */
-
-static Bool
-winGetPaletteDIB (ScreenPtr pScreen, ColormapPtr pcmap)
-{
- winScreenPriv(pScreen);
- int i;
- Pixel pixel; /* Pixel == CARD32 */
- CARD16 nRed, nGreen, nBlue; /* CARD16 == unsigned short */
- UINT uiColorsRetrieved = 0;
- RGBQUAD rgbColors[WIN_NUM_PALETTE_ENTRIES];
-
- /* Get the color table for the screen */
- uiColorsRetrieved = GetDIBColorTable (pScreenPriv->hdcScreen,
- 0,
- WIN_NUM_PALETTE_ENTRIES,
- rgbColors);
- if (uiColorsRetrieved == 0)
- {
- ErrorF ("winGetPaletteDIB - Could not retrieve screen color table\n");
- return FALSE;
- }
-
- winDebug ("winGetPaletteDIB - Retrieved %d colors from DIB\n",
- uiColorsRetrieved);
-
- /* Set the DIB color table to the default screen palette */
- if (SetDIBColorTable (pScreenPriv->hdcShadow,
- 0,
- uiColorsRetrieved,
- rgbColors) == 0)
- {
- ErrorF ("winGetPaletteDIB - SetDIBColorTable () failed\n");
- return FALSE;
- }
-
- /* Alloc each color in the DIB color table */
- for (i = 0; i < uiColorsRetrieved; ++i)
- {
- pixel = i;
-
- /* Extract the color values for current palette entry */
- nRed = rgbColors[i].rgbRed << 8;
- nGreen = rgbColors[i].rgbGreen << 8;
- nBlue = rgbColors[i].rgbBlue << 8;
-
- winDebug ("winGetPaletteDIB - Allocating a color: %d; "
- "%d %d %d\n",
- pixel, nRed, nGreen, nBlue);
-
- /* Allocate a entry in the X colormap */
- if (AllocColor (pcmap,
- &nRed,
- &nGreen,
- &nBlue,
- &pixel,
- 0) != Success)
- {
- ErrorF ("winGetPaletteDIB - AllocColor () failed, pixel %d\n",
- i);
- return FALSE;
- }
-
- if (i != pixel
- || nRed != rgbColors[i].rgbRed
- || nGreen != rgbColors[i].rgbGreen
- || nBlue != rgbColors[i].rgbBlue)
- {
- winDebug ("winGetPaletteDIB - Got: %d; "
- "%d %d %d\n",
- (int) pixel, nRed, nGreen, nBlue);
- }
-
- /* FIXME: Not sure that this bit is needed at all */
- pcmap->red[i].co.local.red = nRed;
- pcmap->red[i].co.local.green = nGreen;
- pcmap->red[i].co.local.blue = nBlue;
- }
-
- /* System is using a colormap */
- /* Set the black and white pixel indices */
- pScreen->whitePixel = uiColorsRetrieved - 1;
- pScreen->blackPixel = 0;
-
- return TRUE;
-}
-
-
-/*
- * Internal function to load the standard system palette being used by DD
- */
-
-static Bool
-winGetPaletteDD (ScreenPtr pScreen, ColormapPtr pcmap)
-{
- int i;
- Pixel pixel; /* Pixel == CARD32 */
- CARD16 nRed, nGreen, nBlue; /* CARD16 == unsigned short */
- UINT uiSystemPaletteEntries;
- LPPALETTEENTRY ppeColors = NULL;
- HDC hdc = NULL;
-
- /* Get a DC to obtain the default palette */
- hdc = GetDC (NULL);
- if (hdc == NULL)
- {
- ErrorF ("winGetPaletteDD - Couldn't get a DC\n");
- return FALSE;
- }
-
- /* Get the number of entries in the system palette */
- uiSystemPaletteEntries = GetSystemPaletteEntries (hdc,
- 0, 0, NULL);
- if (uiSystemPaletteEntries == 0)
- {
- ErrorF ("winGetPaletteDD - Unable to determine number of "
- "system palette entries\n");
- return FALSE;
- }
-
- winDebug ("winGetPaletteDD - uiSystemPaletteEntries %d\n",
- uiSystemPaletteEntries);
-
- /* Allocate palette entries structure */
- ppeColors = malloc (uiSystemPaletteEntries * sizeof (PALETTEENTRY));
- if (ppeColors == NULL)
- {
- ErrorF ("winGetPaletteDD - malloc () for colormap failed\n");
- return FALSE;
- }
-
- /* Get system palette entries */
- GetSystemPaletteEntries (hdc,
- 0, uiSystemPaletteEntries, ppeColors);
-
- /* Allocate an X colormap entry for every system palette entry */
- for (i = 0; i < uiSystemPaletteEntries; ++i)
- {
- pixel = i;
-
- /* Extract the color values for current palette entry */
- nRed = ppeColors[i].peRed << 8;
- nGreen = ppeColors[i].peGreen << 8;
- nBlue = ppeColors[i].peBlue << 8;
- winDebug ("winGetPaletteDD - Allocating a color: %d; "
- "%d %d %d\n",
- pixel, nRed, nGreen, nBlue);
- if (AllocColor (pcmap,
- &nRed,
- &nGreen,
- &nBlue,
- &pixel,
- 0) != Success)
- {
- ErrorF ("winGetPaletteDD - AllocColor () failed, pixel %d\n",
- i);
- free (ppeColors);
- ppeColors = NULL;
- return FALSE;
- }
-
- pcmap->red[i].co.local.red = nRed;
- pcmap->red[i].co.local.green = nGreen;
- pcmap->red[i].co.local.blue = nBlue;
- }
-
- /* System is using a colormap */
- /* Set the black and white pixel indices */
- pScreen->whitePixel = uiSystemPaletteEntries - 1;
- pScreen->blackPixel = 0;
-
- /* Free colormap */
- free(ppeColors);
- ppeColors = NULL;
-
- /* Free the DC */
- if (hdc != NULL)
- {
- ReleaseDC (NULL, hdc);
- hdc = NULL;
- }
-
- return TRUE;
-}
-
-
-/*
- * Install the standard fb colormap, or the GDI colormap,
- * depending on the current screen depth.
- */
-
-Bool
-winCreateDefColormap (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- unsigned short zero = 0, ones = 0xFFFF;
- VisualPtr pVisual = pScreenPriv->pRootVisual;
- ColormapPtr pcmap = NULL;
- Pixel wp, bp;
-
- winDebug ("winCreateDefColormap\n");
-
- /* Use standard fb colormaps for non palettized color modes */
- if (pScreenInfo->dwBPP > 8)
- {
- winDebug ("winCreateDefColormap - Deferring to " \
- "fbCreateDefColormap ()\n");
- return fbCreateDefColormap (pScreen);
- }
-
- /*
- * AllocAll for non-Dynamic visual classes,
- * AllocNone for Dynamic visual classes.
- */
-
- /*
- * Dynamic visual classes allow the colors of the color map
- * to be changed by clients.
- */
-
- winDebug ("winCreateDefColormap - defColormap: %d\n",
- pScreen->defColormap);
-
- /* Allocate an X colormap, owned by client 0 */
- if (CreateColormap (pScreen->defColormap,
- pScreen,
- pVisual,
- &pcmap,
- (pVisual->class & DynamicClass) ? AllocNone : AllocAll,
- 0) != Success)
- {
- ErrorF ("winCreateDefColormap - CreateColormap failed\n");
- return FALSE;
- }
- if (pcmap == NULL)
- {
- ErrorF ("winCreateDefColormap - Colormap could not be created\n");
- return FALSE;
- }
-
- winDebug ("winCreateDefColormap - Created a colormap\n");
-
- /* Branch on the visual class */
- if (!(pVisual->class & DynamicClass))
- {
- /* Branch on engine type */
- if (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_GDI)
- {
- /* Load the colors being used by the Shadow DIB */
- if (!winGetPaletteDIB (pScreen, pcmap))
- {
- ErrorF ("winCreateDefColormap - Couldn't get DIB colors\n");
- return FALSE;
- }
- }
- else
- {
- /* Load the colors from the default system palette */
- if (!winGetPaletteDD (pScreen, pcmap))
- {
- ErrorF ("winCreateDefColormap - Couldn't get colors "
- "for DD\n");
- return FALSE;
- }
- }
- }
- else
- {
- wp = pScreen->whitePixel;
- bp = pScreen->blackPixel;
-
- /* Allocate a black and white pixel */
- if ((AllocColor (pcmap, &ones, &ones, &ones, &wp, 0) !=
- Success)
- ||
- (AllocColor (pcmap, &zero, &zero, &zero, &bp, 0) !=
- Success))
- {
- ErrorF ("winCreateDefColormap - Couldn't allocate bp or wp\n");
- return FALSE;
- }
-
- pScreen->whitePixel = wp;
- pScreen->blackPixel = bp;
-
- }
-
- /* Install the created colormap */
- (*pScreen->InstallColormap)(pcmap);
-
- winDebug ("winCreateDefColormap - Returning\n");
-
- return TRUE;
-}
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Dakshinamurthy Karra
+ * Suhaib M Siddiqi
+ * Peter Busch
+ * Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+/*
+ * Local prototypes
+ */
+
+static int
+ winListInstalledColormaps(ScreenPtr pScreen, Colormap * pmaps);
+
+static void
+ winStoreColors(ColormapPtr pmap, int ndef, xColorItem * pdefs);
+
+static void
+ winInstallColormap(ColormapPtr pmap);
+
+static void
+ winUninstallColormap(ColormapPtr pmap);
+
+static void
+
+winResolveColor(unsigned short *pred,
+ unsigned short *pgreen,
+ unsigned short *pblue, VisualPtr pVisual);
+
+static Bool
+ winCreateColormap(ColormapPtr pmap);
+
+static void
+ winDestroyColormap(ColormapPtr pmap);
+
+static Bool
+ winGetPaletteDIB(ScreenPtr pScreen, ColormapPtr pcmap);
+
+static Bool
+ winGetPaletteDD(ScreenPtr pScreen, ColormapPtr pcmap);
+
+/*
+ * Set screen functions for colormaps
+ */
+
+void
+winSetColormapFunctions(ScreenPtr pScreen)
+{
+ pScreen->CreateColormap = winCreateColormap;
+ pScreen->DestroyColormap = winDestroyColormap;
+ pScreen->InstallColormap = winInstallColormap;
+ pScreen->UninstallColormap = winUninstallColormap;
+ pScreen->ListInstalledColormaps = winListInstalledColormaps;
+ pScreen->StoreColors = winStoreColors;
+ pScreen->ResolveColor = winResolveColor;
+}
+
+/* See Porting Layer Definition - p. 30 */
+/*
+ * Walk the list of installed colormaps, filling the pmaps list
+ * with the resource ids of the installed maps, and return
+ * a count of the total number of installed maps.
+ */
+static int
+winListInstalledColormaps(ScreenPtr pScreen, Colormap * pmaps)
+{
+ winScreenPriv(pScreen);
+
+ /*
+ * There will only be one installed colormap, so we only need
+ * to return one id, and the count of installed maps will always
+ * be one.
+ */
+ *pmaps = pScreenPriv->pcmapInstalled->mid;
+ return 1;
+}
+
+/* See Porting Layer Definition - p. 30 */
+/* See Programming Windows - p. 663 */
+static void
+winInstallColormap(ColormapPtr pColormap)
+{
+ ScreenPtr pScreen = pColormap->pScreen;
+
+ winScreenPriv(pScreen);
+ ColormapPtr oldpmap = pScreenPriv->pcmapInstalled;
+
+ winDebug("winInstallColormap\n");
+
+ /* Did the colormap actually change? */
+ if (pColormap != oldpmap) {
+ winDebug("winInstallColormap - Colormap has changed, attempt "
+ "to install.\n");
+
+ /* Was there a previous colormap? */
+ if (oldpmap != (ColormapPtr) None) {
+ /* There was a previous colormap; tell clients it is gone */
+ WalkTree(pColormap->pScreen, TellLostMap, (char *) &oldpmap->mid);
+ }
+
+ /* Install new colormap */
+ pScreenPriv->pcmapInstalled = pColormap;
+ WalkTree(pColormap->pScreen, TellGainedMap, (char *) &pColormap->mid);
+
+ /* Call the engine specific colormap install procedure */
+ if (!((*pScreenPriv->pwinInstallColormap) (pColormap))) {
+ ErrorF ("winInstallColormap - Screen specific colormap install "
+ "procedure failed. Continuing, but colors may be "
+ "messed up from now on.\n");
+ }
+ }
+
+ /* Save a pointer to the newly installed colormap */
+ pScreenPriv->pcmapInstalled = pColormap;
+}
+
+/* See Porting Layer Definition - p. 30 */
+static void
+winUninstallColormap(ColormapPtr pmap)
+{
+ winScreenPriv(pmap->pScreen);
+ ColormapPtr curpmap = pScreenPriv->pcmapInstalled;
+
+ winDebug("winUninstallColormap\n");
+
+ /* Is the colormap currently installed? */
+ if (pmap != curpmap) {
+ /* Colormap not installed, nothing to do */
+ return;
+ }
+
+ /* Clear the installed colormap flag */
+ pScreenPriv->pcmapInstalled = NULL;
+
+ /*
+ * NOTE: The default colormap does not get "uninstalled" before
+ * it is destroyed.
+ */
+
+ /* Install the default cmap in place of the cmap to be uninstalled */
+ if (pmap->mid != pmap->pScreen->defColormap) {
+ dixLookupResourceByType((pointer) &curpmap, pmap->pScreen->defColormap,
+ RT_COLORMAP, NullClient, DixUnknownAccess);
+ (*pmap->pScreen->InstallColormap) (curpmap);
+ }
+}
+
+/* See Porting Layer Definition - p. 30 */
+static void
+winStoreColors(ColormapPtr pmap, int ndef, xColorItem * pdefs)
+{
+ ScreenPtr pScreen = pmap->pScreen;
+
+ winScreenPriv(pScreen);
+ winCmapPriv(pmap);
+ int i;
+ unsigned short nRed, nGreen, nBlue;
+
+#ifdef WINDBG
+ if (ndef != 1)
+ winDebug("winStoreColors - ndef: %d\n", ndef);
+#endif
+
+ /* Save the new colors in the colormap privates */
+ for (i = 0; i < ndef; ++i) {
+ /* Adjust the colors from the X color spec to the Windows color spec */
+ nRed = pdefs[i].red >> 8;
+ nGreen = pdefs[i].green >> 8;
+ nBlue = pdefs[i].blue >> 8;
+
+ /* Copy the colors to a palette entry table */
+ pCmapPriv->peColors[pdefs[0].pixel + i].peRed = nRed;
+ pCmapPriv->peColors[pdefs[0].pixel + i].peGreen = nGreen;
+ pCmapPriv->peColors[pdefs[0].pixel + i].peBlue = nBlue;
+
+ /* Copy the colors to a RGBQUAD table */
+ pCmapPriv->rgbColors[pdefs[0].pixel + i].rgbRed = nRed;
+ pCmapPriv->rgbColors[pdefs[0].pixel + i].rgbGreen = nGreen;
+ pCmapPriv->rgbColors[pdefs[0].pixel + i].rgbBlue = nBlue;
+
+ winDebug("winStoreColors - nRed %d nGreen %d nBlue %d\n",
+ nRed, nGreen, nBlue);
+ }
+
+ /* Call the engine specific store colors procedure */
+ if (!((pScreenPriv->pwinStoreColors) (pmap, ndef, pdefs))) {
+ ErrorF ("winStoreColors - Engine cpecific color storage procedure "
+ "failed. Continuing, but colors may be messed up from now "
+ "on.\n");
+ }
+}
+
+/* See Porting Layer Definition - p. 30 */
+static void
+winResolveColor(unsigned short *pred,
+ unsigned short *pgreen,
+ unsigned short *pblue, VisualPtr pVisual)
+{
+ winDebug("winResolveColor ()\n");
+
+ miResolveColor(pred, pgreen, pblue, pVisual);
+}
+
+/* See Porting Layer Definition - p. 29 */
+static Bool
+winCreateColormap(ColormapPtr pmap)
+{
+ winPrivCmapPtr pCmapPriv = NULL;
+ ScreenPtr pScreen = pmap->pScreen;
+
+ winScreenPriv(pScreen);
+
+ winDebug("winCreateColormap\n");
+
+ /* Allocate colormap privates */
+ if (!winAllocateCmapPrivates(pmap)) {
+ ErrorF("winCreateColorma - Couldn't allocate cmap privates\n");
+ return FALSE;
+ }
+
+ /* Get a pointer to the newly allocated privates */
+ pCmapPriv = winGetCmapPriv(pmap);
+
+ /*
+ * FIXME: This is some evil hackery to help in handling some X clients
+ * that expect the top pixel to be white. This "help" only lasts until
+ * some client overwrites the top colormap entry.
+ *
+ * We don't want to actually allocate the top entry, as that causes
+ * problems with X clients that need 7 planes (128 colors) in the default
+ * colormap, such as Magic 7.1.
+ */
+ pCmapPriv->rgbColors[WIN_NUM_PALETTE_ENTRIES - 1].rgbRed = 255;
+ pCmapPriv->rgbColors[WIN_NUM_PALETTE_ENTRIES - 1].rgbGreen = 255;
+ pCmapPriv->rgbColors[WIN_NUM_PALETTE_ENTRIES - 1].rgbBlue = 255;
+ pCmapPriv->peColors[WIN_NUM_PALETTE_ENTRIES - 1].peRed = 255;
+ pCmapPriv->peColors[WIN_NUM_PALETTE_ENTRIES - 1].peGreen = 255;
+ pCmapPriv->peColors[WIN_NUM_PALETTE_ENTRIES - 1].peBlue = 255;
+
+ /* Call the engine specific colormap initialization procedure */
+ if (!((*pScreenPriv->pwinCreateColormap) (pmap))) {
+ ErrorF("winCreateColormap - Engine specific colormap creation "
+ "procedure failed. Aborting.\n");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/* See Porting Layer Definition - p. 29, 30 */
+static void
+winDestroyColormap(ColormapPtr pColormap)
+{
+ winScreenPriv(pColormap->pScreen);
+ winCmapPriv(pColormap);
+
+ /* Call the engine specific colormap destruction procedure */
+ if (!((*pScreenPriv->pwinDestroyColormap) (pColormap))) {
+ ErrorF ("winDestroyColormap - Engine specific colormap destruction "
+ "procedure failed. Continuing, but it is possible that memory "
+ "was leaked, or that colors will be messed up from now on.\n");
+ }
+
+ /* Free the colormap privates */
+ free(pCmapPriv);
+ winSetCmapPriv(pColormap, NULL);
+
+ winDebug("winDestroyColormap - Returning\n");
+}
+
+/*
+ * Internal function to load the palette used by the Shadow DIB
+ */
+
+static Bool
+winGetPaletteDIB(ScreenPtr pScreen, ColormapPtr pcmap)
+{
+ winScreenPriv(pScreen);
+ int i;
+ Pixel pixel; /* Pixel == CARD32 */
+ CARD16 nRed, nGreen, nBlue; /* CARD16 == unsigned short */
+ UINT uiColorsRetrieved = 0;
+ RGBQUAD rgbColors[WIN_NUM_PALETTE_ENTRIES];
+
+ /* Get the color table for the screen */
+ uiColorsRetrieved = GetDIBColorTable(pScreenPriv->hdcScreen,
+ 0, WIN_NUM_PALETTE_ENTRIES, rgbColors);
+ if (uiColorsRetrieved == 0) {
+ ErrorF("winGetPaletteDIB - Could not retrieve screen color table\n");
+ return FALSE;
+ }
+
+ winDebug("winGetPaletteDIB - Retrieved %d colors from DIB\n",
+ uiColorsRetrieved);
+
+ /* Set the DIB color table to the default screen palette */
+ if (SetDIBColorTable(pScreenPriv->hdcShadow,
+ 0, uiColorsRetrieved, rgbColors) == 0) {
+ ErrorF("winGetPaletteDIB - SetDIBColorTable () failed\n");
+ return FALSE;
+ }
+
+ /* Alloc each color in the DIB color table */
+ for (i = 0; i < uiColorsRetrieved; ++i) {
+ pixel = i;
+
+ /* Extract the color values for current palette entry */
+ nRed = rgbColors[i].rgbRed << 8;
+ nGreen = rgbColors[i].rgbGreen << 8;
+ nBlue = rgbColors[i].rgbBlue << 8;
+
+ winDebug("winGetPaletteDIB - Allocating a color: %d; "
+ "%d %d %d\n", pixel, nRed, nGreen, nBlue);
+
+ /* Allocate a entry in the X colormap */
+ if (AllocColor(pcmap, &nRed, &nGreen, &nBlue, &pixel, 0) != Success) {
+ ErrorF("winGetPaletteDIB - AllocColor () failed, pixel %d\n", i);
+ return FALSE;
+ }
+
+ if (i != pixel
+ || nRed != rgbColors[i].rgbRed
+ || nGreen != rgbColors[i].rgbGreen
+ || nBlue != rgbColors[i].rgbBlue) {
+ winDebug("winGetPaletteDIB - Got: %d; "
+ "%d %d %d\n", (int) pixel, nRed, nGreen, nBlue);
+ }
+
+ /* FIXME: Not sure that this bit is needed at all */
+ pcmap->red[i].co.local.red = nRed;
+ pcmap->red[i].co.local.green = nGreen;
+ pcmap->red[i].co.local.blue = nBlue;
+ }
+
+ /* System is using a colormap */
+ /* Set the black and white pixel indices */
+ pScreen->whitePixel = uiColorsRetrieved - 1;
+ pScreen->blackPixel = 0;
+
+ return TRUE;
+}
+
+/*
+ * Internal function to load the standard system palette being used by DD
+ */
+
+static Bool
+winGetPaletteDD(ScreenPtr pScreen, ColormapPtr pcmap)
+{
+ int i;
+ Pixel pixel; /* Pixel == CARD32 */
+ CARD16 nRed, nGreen, nBlue; /* CARD16 == unsigned short */
+ UINT uiSystemPaletteEntries;
+ LPPALETTEENTRY ppeColors = NULL;
+ HDC hdc = NULL;
+
+ /* Get a DC to obtain the default palette */
+ hdc = GetDC(NULL);
+ if (hdc == NULL) {
+ ErrorF("winGetPaletteDD - Couldn't get a DC\n");
+ return FALSE;
+ }
+
+ /* Get the number of entries in the system palette */
+ uiSystemPaletteEntries = GetSystemPaletteEntries(hdc, 0, 0, NULL);
+ if (uiSystemPaletteEntries == 0) {
+ ErrorF("winGetPaletteDD - Unable to determine number of "
+ "system palette entries\n");
+ return FALSE;
+ }
+
+ winDebug("winGetPaletteDD - uiSystemPaletteEntries %d\n",
+ uiSystemPaletteEntries);
+
+ /* Allocate palette entries structure */
+ ppeColors = malloc(uiSystemPaletteEntries * sizeof(PALETTEENTRY));
+ if (ppeColors == NULL) {
+ ErrorF("winGetPaletteDD - malloc () for colormap failed\n");
+ return FALSE;
+ }
+
+ /* Get system palette entries */
+ GetSystemPaletteEntries(hdc, 0, uiSystemPaletteEntries, ppeColors);
+
+ /* Allocate an X colormap entry for every system palette entry */
+ for (i = 0; i < uiSystemPaletteEntries; ++i) {
+ pixel = i;
+
+ /* Extract the color values for current palette entry */
+ nRed = ppeColors[i].peRed << 8;
+ nGreen = ppeColors[i].peGreen << 8;
+ nBlue = ppeColors[i].peBlue << 8;
+ winDebug("winGetPaletteDD - Allocating a color: %d; "
+ "%d %d %d\n", pixel, nRed, nGreen, nBlue);
+ if (AllocColor(pcmap, &nRed, &nGreen, &nBlue, &pixel, 0) != Success) {
+ ErrorF("winGetPaletteDD - AllocColor () failed, pixel %d\n", i);
+ free(ppeColors);
+ ppeColors = NULL;
+ return FALSE;
+ }
+
+ pcmap->red[i].co.local.red = nRed;
+ pcmap->red[i].co.local.green = nGreen;
+ pcmap->red[i].co.local.blue = nBlue;
+ }
+
+ /* System is using a colormap */
+ /* Set the black and white pixel indices */
+ pScreen->whitePixel = uiSystemPaletteEntries - 1;
+ pScreen->blackPixel = 0;
+
+ /* Free colormap */
+ free(ppeColors);
+ ppeColors = NULL;
+
+ /* Free the DC */
+ if (hdc != NULL) {
+ ReleaseDC(NULL, hdc);
+ hdc = NULL;
+ }
+
+ return TRUE;
+}
+
+/*
+ * Install the standard fb colormap, or the GDI colormap,
+ * depending on the current screen depth.
+ */
+
+Bool
+winCreateDefColormap(ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ unsigned short zero = 0, ones = 0xFFFF;
+ VisualPtr pVisual = pScreenPriv->pRootVisual;
+ ColormapPtr pcmap = NULL;
+ Pixel wp, bp;
+
+ winDebug("winCreateDefColormap\n");
+
+ /* Use standard fb colormaps for non palettized color modes */
+ if (pScreenInfo->dwBPP > 8) {
+ winDebug("winCreateDefColormap - Deferring to "
+ "fbCreateDefColormap ()\n");
+ return fbCreateDefColormap(pScreen);
+ }
+
+ /*
+ * AllocAll for non-Dynamic visual classes,
+ * AllocNone for Dynamic visual classes.
+ */
+
+ /*
+ * Dynamic visual classes allow the colors of the color map
+ * to be changed by clients.
+ */
+
+ winDebug("winCreateDefColormap - defColormap: %d\n", pScreen->defColormap);
+
+ /* Allocate an X colormap, owned by client 0 */
+ if (CreateColormap(pScreen->defColormap,
+ pScreen,
+ pVisual,
+ &pcmap,
+ (pVisual->class & DynamicClass) ? AllocNone : AllocAll,
+ 0) != Success) {
+ ErrorF("winCreateDefColormap - CreateColormap failed\n");
+ return FALSE;
+ }
+ if (pcmap == NULL) {
+ ErrorF("winCreateDefColormap - Colormap could not be created\n");
+ return FALSE;
+ }
+
+ winDebug("winCreateDefColormap - Created a colormap\n");
+
+ /* Branch on the visual class */
+ if (!(pVisual->class & DynamicClass)) {
+ /* Branch on engine type */
+ if (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_GDI) {
+ /* Load the colors being used by the Shadow DIB */
+ if (!winGetPaletteDIB(pScreen, pcmap)) {
+ ErrorF("winCreateDefColormap - Couldn't get DIB colors\n");
+ return FALSE;
+ }
+ }
+ else {
+ /* Load the colors from the default system palette */
+ if (!winGetPaletteDD(pScreen, pcmap)) {
+ ErrorF("winCreateDefColormap - Couldn't get colors "
+ "for DD\n");
+ return FALSE;
+ }
+ }
+ }
+ else {
+ wp = pScreen->whitePixel;
+ bp = pScreen->blackPixel;
+
+ /* Allocate a black and white pixel */
+ if ((AllocColor(pcmap, &ones, &ones, &ones, &wp, 0) != Success)
+ || (AllocColor(pcmap, &zero, &zero, &zero, &bp, 0) != Success)) {
+ ErrorF("winCreateDefColormap - Couldn't allocate bp or wp\n");
+ return FALSE;
+ }
+
+ pScreen->whitePixel = wp;
+ pScreen->blackPixel = bp;
+
+ }
+
+ /* Install the created colormap */
+ (*pScreen->InstallColormap) (pcmap);
+
+ winDebug("winCreateDefColormap - Returning\n");
+
+ return TRUE;
+}
diff --git a/xorg-server/hw/xwin/winconfig.c b/xorg-server/hw/xwin/winconfig.c
index 4441550b0..57825af72 100644
--- a/xorg-server/hw/xwin/winconfig.c
+++ b/xorg-server/hw/xwin/winconfig.c
@@ -63,42 +63,42 @@ XF86ConfigPtr g_xf86configptr = NULL;
WinCmdlineRec g_cmdline = {
#ifdef XWIN_XF86CONFIG
- NULL, /* configFile */
- NULL, /* configDir */
+ NULL, /* configFile */
+ NULL, /* configDir */
#endif
- NULL, /* fontPath */
+ NULL, /* fontPath */
#ifdef XWIN_XF86CONFIG
- NULL, /* keyboard */
+ NULL, /* keyboard */
#endif
- NULL, /* xkbRules */
- NULL, /* xkbModel */
- NULL, /* xkbLayout */
- NULL, /* xkbVariant */
- NULL, /* xkbOptions */
- NULL, /* screenname */
- NULL, /* mousename */
- FALSE, /* emulate3Buttons */
- 0 /* emulate3Timeout */
+ NULL, /* xkbRules */
+ NULL, /* xkbModel */
+ NULL, /* xkbLayout */
+ NULL, /* xkbVariant */
+ NULL, /* xkbOptions */
+ NULL, /* screenname */
+ NULL, /* mousename */
+ FALSE, /* emulate3Buttons */
+ 0 /* emulate3Timeout */
};
winInfoRec g_winInfo = {
- { /* keyboard */
- 0, /* leds */
- 500, /* delay */
- 30 /* rate */
- }
- ,
- { /* xkb */
- NULL, /* rules */
- NULL, /* model */
- NULL, /* layout */
- NULL, /* variant */
- NULL, /* options */
- }
- ,
- {
- FALSE,
- 50}
+ { /* keyboard */
+ 0, /* leds */
+ 500, /* delay */
+ 30 /* rate */
+ }
+ ,
+ { /* xkb */
+ NULL, /* rules */
+ NULL, /* model */
+ NULL, /* layout */
+ NULL, /* variant */
+ NULL, /* options */
+ }
+ ,
+ {
+ FALSE,
+ 50}
};
#define NULL_IF_EMPTY(x) (winNameCompare(x,"")?x:NULL)
@@ -106,130 +106,111 @@ winInfoRec g_winInfo = {
#ifdef XWIN_XF86CONFIG
serverLayoutRec g_winConfigLayout;
-static Bool ParseOptionValue (int scrnIndex, pointer options,
- OptionInfoPtr p);
-static Bool configLayout (serverLayoutPtr, XF86ConfLayoutPtr, char *);
-static Bool configImpliedLayout (serverLayoutPtr, XF86ConfScreenPtr);
-static Bool GetBoolValue (OptionInfoPtr p, const char *s);
-
+static Bool ParseOptionValue(int scrnIndex, pointer options, OptionInfoPtr p);
+static Bool configLayout(serverLayoutPtr, XF86ConfLayoutPtr, char *);
+static Bool configImpliedLayout(serverLayoutPtr, XF86ConfScreenPtr);
+static Bool GetBoolValue(OptionInfoPtr p, const char *s);
Bool
-winReadConfigfile ()
+winReadConfigfile()
{
- Bool retval = TRUE;
- char *filename, *dirname;
- MessageType filefrom = X_DEFAULT;
- MessageType dirfrom = X_DEFAULT;
- char *xf86ConfigFile = NULL;
- char *xf86ConfigDir = NULL;
-
- if (g_cmdline.configFile)
- {
- filefrom = X_CMDLINE;
- xf86ConfigFile = g_cmdline.configFile;
+ Bool retval = TRUE;
+ char *filename, *dirname;
+ MessageType filefrom = X_DEFAULT;
+ MessageType dirfrom = X_DEFAULT;
+ char *xf86ConfigFile = NULL;
+ char *xf86ConfigDir = NULL;
+
+ if (g_cmdline.configFile) {
+ filefrom = X_CMDLINE;
+ xf86ConfigFile = g_cmdline.configFile;
}
- if (g_cmdline.configDir)
- {
- dirfrom = X_CMDLINE;
- xf86ConfigDir = g_cmdline.configDir;
+ if (g_cmdline.configDir) {
+ dirfrom = X_CMDLINE;
+ xf86ConfigDir = g_cmdline.configDir;
}
- /* Parse config file into data structure */
- xf86initConfigFiles();
- dirname = xf86openConfigDirFiles (CONFIGDIRPATH, xf86ConfigDir, PROJECTROOT);
- filename = xf86openConfigFile (CONFIGPATH, xf86ConfigFile, PROJECTROOT);
+ /* Parse config file into data structure */
+ xf86initConfigFiles();
+ dirname = xf86openConfigDirFiles(CONFIGDIRPATH, xf86ConfigDir, PROJECTROOT);
+ filename = xf86openConfigFile(CONFIGPATH, xf86ConfigFile, PROJECTROOT);
- /* Hack for backward compatibility */
- if (!filename && from == X_DEFAULT)
- filename = xf86openConfigFile (CONFIGPATH, "XF86Config", PROJECTROOT);
+ /* Hack for backward compatibility */
+ if (!filename && from == X_DEFAULT)
+ filename = xf86openConfigFile(CONFIGPATH, "XF86Config", PROJECTROOT);
- if (filename)
- {
- winDebug ("Using config file: \"%s\"\n", filename);
+ if (filename) {
+ winDebug ("Using config file: \"%s\"\n", filename);
}
- else
- {
- ErrorF ("Unable to locate/open config file");
- if (xf86ConfigFile)
- ErrorF (": \"%s\"", xf86ConfigFile);
- ErrorF ("\n");
+ else {
+ ErrorF ("Unable to locate/open config file");
+ if (xf86ConfigFile)
+ ErrorF(": \"%s\"", xf86ConfigFile);
+ ErrorF("\n");
}
- if (dirname)
- {
- winMsg (from, "Using config directory: \"%s\"\n", dirname);
+ if (dirname) {
+ winMsg(from, "Using config directory: \"%s\"\n", dirname);
}
- else
- {
- winMsg (X_ERROR, "Unable to locate/open config directory");
- if (xf86ConfigDir)
- ErrorF (": \"%s\"", xf86ConfigDir);
- ErrorF ("\n");
+ else {
+ winMsg(X_ERROR, "Unable to locate/open config directory");
+ if (xf86ConfigDir)
+ ErrorF(": \"%s\"", xf86ConfigDir);
+ ErrorF("\n");
}
- if (!filename && !dirname)
- {
- return FALSE;
+ if (!filename && !dirname) {
+ return FALSE;
}
- free(filename);
- free(dirname);
- if ((g_xf86configptr = xf86readConfigFile ()) == NULL)
- {
- ErrorF ("Problem parsing the config file\n");
- return FALSE;
+ free(filename);
+ free(dirname);
+ if ((g_xf86configptr = xf86readConfigFile()) == NULL) {
+ ErrorF ("Problem parsing the config file\n");
+ return FALSE;
}
- xf86closeConfigFile ();
+ xf86closeConfigFile();
- LogPrintMarkers();
+ LogPrintMarkers();
- /* set options from data structure */
+ /* set options from data structure */
- if (g_xf86configptr->conf_layout_lst == NULL || g_cmdline.screenname != NULL)
- {
- if (g_cmdline.screenname == NULL)
- {
- winDebug ("No Layout section. Using the first Screen section.\n");
- }
- if (!configImpliedLayout (&g_winConfigLayout,
- g_xf86configptr->conf_screen_lst))
- {
- ErrorF ("Unable to determine the screen layout\n");
- return FALSE;
- }
+ if (g_xf86configptr->conf_layout_lst == NULL ||
+ g_cmdline.screenname != NULL) {
+ if (g_cmdline.screenname == NULL) {
+ winDebug ("No Layout section. Using the first Screen section.\n");
+ }
+ if (!configImpliedLayout(&g_winConfigLayout,
+ g_xf86configptr->conf_screen_lst)) {
+ ErrorF ("Unable to determine the screen layout\n");
+ return FALSE;
+ }
}
- else
- {
- /* Check if layout is given in the config file */
- if (g_xf86configptr->conf_flags != NULL)
- {
- char *dfltlayout = NULL;
- pointer optlist = g_xf86configptr->conf_flags->flg_option_lst;
-
- if (optlist && winFindOption (optlist, "defaultserverlayout"))
- dfltlayout =
- winSetStrOption (optlist, "defaultserverlayout", NULL);
-
- if (!configLayout (&g_winConfigLayout,
- g_xf86configptr->conf_layout_lst,
- dfltlayout))
- {
- ErrorF ("Unable to determine the screen layout\n");
- return FALSE;
- }
- }
- else
- {
- if (!configLayout (&g_winConfigLayout,
- g_xf86configptr->conf_layout_lst,
- NULL))
- {
- ErrorF ("Unable to determine the screen layout\n");
- return FALSE;
- }
- }
+ else {
+ /* Check if layout is given in the config file */
+ if (g_xf86configptr->conf_flags != NULL) {
+ char *dfltlayout = NULL;
+ pointer optlist = g_xf86configptr->conf_flags->flg_option_lst;
+
+ if (optlist && winFindOption(optlist, "defaultserverlayout"))
+ dfltlayout =
+ winSetStrOption(optlist, "defaultserverlayout", NULL);
+
+ if (!configLayout(&g_winConfigLayout,
+ g_xf86configptr->conf_layout_lst, dfltlayout)) {
+ ErrorF ("Unable to determine the screen layout\n");
+ return FALSE;
+ }
+ }
+ else {
+ if (!configLayout(&g_winConfigLayout,
+ g_xf86configptr->conf_layout_lst, NULL)) {
+ ErrorF ("Unable to determine the screen layout\n");
+ return FALSE;
+ }
+ }
}
- /* setup special config files */
- winConfigFiles ();
- return retval;
+ /* setup special config files */
+ winConfigFiles();
+ return retval;
}
#endif
@@ -238,270 +219,256 @@ winReadConfigfile ()
/* Set the keyboard configuration */
Bool
-winConfigKeyboard (DeviceIntPtr pDevice)
+winConfigKeyboard(DeviceIntPtr pDevice)
{
- char layoutName[KL_NAMELENGTH];
- unsigned char layoutFriendlyName[256];
- static unsigned int layoutNum = 0;
- int keyboardType;
+ char layoutName[KL_NAMELENGTH];
+ unsigned char layoutFriendlyName[256];
+ static unsigned int layoutNum = 0;
+ int keyboardType;
+
#ifdef XWIN_XF86CONFIG
- XF86ConfInputPtr kbd = NULL;
- XF86ConfInputPtr input_list = NULL;
- MessageType kbdfrom = X_CONFIG;
+ XF86ConfInputPtr kbd = NULL;
+ XF86ConfInputPtr input_list = NULL;
+ MessageType kbdfrom = X_CONFIG;
#endif
- MessageType from = X_DEFAULT;
- char *s = NULL;
-
- /* Setup defaults */
- XkbGetRulesDflts(&g_winInfo.xkb);
-
- /*
- * Query the windows autorepeat settings and change the xserver defaults.
- */
- {
- int kbd_delay;
- DWORD kbd_speed;
- if (SystemParametersInfo(SPI_GETKEYBOARDDELAY, 0, &kbd_delay, 0) &&
- SystemParametersInfo(SPI_GETKEYBOARDSPEED, 0, &kbd_speed, 0))
- {
- switch (kbd_delay)
- {
- case 0: g_winInfo.keyboard.delay = 250; break;
- case 1: g_winInfo.keyboard.delay = 500; break;
- case 2: g_winInfo.keyboard.delay = 750; break;
- default:
- case 3: g_winInfo.keyboard.delay = 1000; break;
- }
- g_winInfo.keyboard.rate = (kbd_speed>0)?kbd_speed:1;
- winDebug("Setting autorepeat to delay=%d, rate=%d\n",
- g_winInfo.keyboard.delay, g_winInfo.keyboard.rate);
- }
- }
-
-
- keyboardType = GetKeyboardType (0);
- if (keyboardType > 0 && GetKeyboardLayoutName (layoutName))
- {
- WinKBLayoutPtr pLayout;
- Bool bfound = FALSE;
-
- if (! layoutNum)
- layoutNum = strtoul (layoutName, (char **)NULL, 16);
- if ((layoutNum & 0xffff) == 0x411) {
- /* The japanese layouts know a lot of different IMEs which all have
- different layout numbers set. Map them to a single entry.
- Same might apply for chinese, korean and other symbol languages
- too */
- layoutNum = (layoutNum & 0xffff);
- if (keyboardType == 7)
- {
- /* Japanese layouts have problems with key event messages
- such as the lack of WM_KEYUP for Caps Lock key.
- Loading US layout fixes this problem. */
- if (LoadKeyboardLayout("00000409", KLF_ACTIVATE) != NULL)
- winDebug("Loading US keyboard layout.\n");
- else
- ErrorF ("LoadKeyboardLayout failed.\n");
- }
- }
+ MessageType from = X_DEFAULT;
+ char *s = NULL;
- /* Discover the friendly name of the current layout */
+ /* Setup defaults */
+ XkbGetRulesDflts(&g_winInfo.xkb);
+
+ /*
+ * Query the windows autorepeat settings and change the xserver defaults.
+ */
{
- HKEY regkey = NULL;
- const char regtempl[] = "SYSTEM\\CurrentControlSet\\Control\\Keyboard Layouts\\";
- char *regpath;
- DWORD namesize = sizeof(layoutFriendlyName);
-
- regpath = malloc(sizeof(regtempl) + KL_NAMELENGTH + 1);
- strcpy(regpath, regtempl);
- strcat(regpath, layoutName);
-
- if (!RegOpenKey(HKEY_LOCAL_MACHINE, regpath, &regkey))
- RegQueryValueEx(regkey, "Layout Text", 0, NULL, layoutFriendlyName, &namesize);
-
- /* Close registry key */
- if (regkey)
- RegCloseKey (regkey);
- free(regpath);
+ int kbd_delay;
+ DWORD kbd_speed;
+
+ if (SystemParametersInfo(SPI_GETKEYBOARDDELAY, 0, &kbd_delay, 0) &&
+ SystemParametersInfo(SPI_GETKEYBOARDSPEED, 0, &kbd_speed, 0)) {
+ switch (kbd_delay) {
+ case 0:
+ g_winInfo.keyboard.delay = 250;
+ break;
+ case 1:
+ g_winInfo.keyboard.delay = 500;
+ break;
+ case 2:
+ g_winInfo.keyboard.delay = 750;
+ break;
+ default:
+ case 3:
+ g_winInfo.keyboard.delay = 1000;
+ break;
+ }
+ g_winInfo.keyboard.rate = (kbd_speed > 0) ? kbd_speed : 1;
+ winDebug("Setting autorepeat to delay=%d, rate=%d\n",
+ g_winInfo.keyboard.delay, g_winInfo.keyboard.rate);
+ }
}
- winDebug ("Windows keyboard layout: \"%s\" (%08x) \"%s\", type %d\n",
- layoutName, layoutNum, layoutFriendlyName, keyboardType);
-
- for (pLayout = winKBLayouts; pLayout->winlayout != -1; pLayout++)
- {
- if (pLayout->winlayout != layoutNum)
- continue;
- if (pLayout->winkbtype > 0 && pLayout->winkbtype != keyboardType)
- continue;
-
- bfound = TRUE;
- winDebug (
- "Found matching XKB configuration \"%s\"\n",
- pLayout->layoutname);
-
- winDebug(
- "Model = \"%s\" Layout = \"%s\""
- " Variant = \"%s\" Options = \"%s\"\n",
- pLayout->xkbmodel ? pLayout->xkbmodel : "none",
- pLayout->xkblayout ? pLayout->xkblayout : "none",
- pLayout->xkbvariant ? pLayout->xkbvariant : "none",
- pLayout->xkboptions ? pLayout->xkboptions : "none");
-
- g_winInfo.xkb.model = pLayout->xkbmodel;
- g_winInfo.xkb.layout = pLayout->xkblayout;
- g_winInfo.xkb.variant = pLayout->xkbvariant;
- g_winInfo.xkb.options = pLayout->xkboptions;
-
-
- break;
- }
-
- if (!bfound)
- {
- ErrorF ("Keyboardlayout \"%s\" (%s) is unknown, using X server default layout\n", layoutFriendlyName, layoutName);
- }
- }
-
- /* parse the configuration */
-#ifdef XWIN_XF86CONFIG
- if (g_cmdline.keyboard)
- kbdfrom = X_CMDLINE;
+ keyboardType = GetKeyboardType(0);
+ if (keyboardType > 0 && GetKeyboardLayoutName(layoutName)) {
+ WinKBLayoutPtr pLayout;
+ Bool bfound = FALSE;
+
+ if (!layoutNum)
+ layoutNum = strtoul(layoutName, (char **) NULL, 16);
+ if ((layoutNum & 0xffff) == 0x411) {
+ /* The japanese layouts know a lot of different IMEs which all have
+ different layout numbers set. Map them to a single entry.
+ Same might apply for chinese, korean and other symbol languages
+ too */
+ layoutNum = (layoutNum & 0xffff);
+ if (keyboardType == 7) {
+ /* Japanese layouts have problems with key event messages
+ such as the lack of WM_KEYUP for Caps Lock key.
+ Loading US layout fixes this problem. */
+ if (LoadKeyboardLayout("00000409", KLF_ACTIVATE) != NULL)
+ winDebug("Loading US keyboard layout.\n");
+ else
+ ErrorF ("LoadKeyboardLayout failed.\n");
+ }
+ }
- /*
- * Until the layout code is finished, I search for the keyboard
- * device and configure the server with it.
- */
+ /* Discover the friendly name of the current layout */
+ {
+ HKEY regkey = NULL;
+ const char regtempl[] =
+ "SYSTEM\\CurrentControlSet\\Control\\Keyboard Layouts\\";
+ char *regpath;
+ DWORD namesize = sizeof(layoutFriendlyName);
+
+ regpath = malloc(sizeof(regtempl) + KL_NAMELENGTH + 1);
+ strcpy(regpath, regtempl);
+ strcat(regpath, layoutName);
+
+ if (!RegOpenKey(HKEY_LOCAL_MACHINE, regpath, &regkey))
+ RegQueryValueEx(regkey, "Layout Text", 0, NULL,
+ layoutFriendlyName, &namesize);
+
+ /* Close registry key */
+ if (regkey)
+ RegCloseKey(regkey);
+ free(regpath);
+ }
- if (g_xf86configptr != NULL)
- input_list = g_xf86configptr->conf_input_lst;
+ winDebug ("Windows keyboard layout: \"%s\" (%08x) \"%s\", type %d\n",
+ layoutName, layoutNum, layoutFriendlyName, keyboardType);
+
+ for (pLayout = winKBLayouts; pLayout->winlayout != -1; pLayout++) {
+ if (pLayout->winlayout != layoutNum)
+ continue;
+ if (pLayout->winkbtype > 0 && pLayout->winkbtype != keyboardType)
+ continue;
+
+ bfound = TRUE;
+ winDebug (
+ "Found matching XKB configuration \"%s\"\n",
+ pLayout->layoutname);
+
+ winDebug(
+ "Model = \"%s\" Layout = \"%s\""
+ " Variant = \"%s\" Options = \"%s\"\n",
+ pLayout->xkbmodel ? pLayout->xkbmodel : "none",
+ pLayout->xkblayout ? pLayout->xkblayout : "none",
+ pLayout->xkbvariant ? pLayout->xkbvariant : "none",
+ pLayout->xkboptions ? pLayout->xkboptions : "none");
+
+ g_winInfo.xkb.model = pLayout->xkbmodel;
+ g_winInfo.xkb.layout = pLayout->xkblayout;
+ g_winInfo.xkb.variant = pLayout->xkbvariant;
+ g_winInfo.xkb.options = pLayout->xkboptions;
+
+ break;
+ }
- while (input_list != NULL)
- {
- if (winNameCompare (input_list->inp_driver, "keyboard") == 0)
- {
- /* Check if device name matches requested name */
- if (g_cmdline.keyboard && winNameCompare (input_list->inp_identifier,
- g_cmdline.keyboard))
- continue;
- kbd = input_list;
- }
- input_list = input_list->list.next;
+ if (!bfound) {
+ ErrorF ("Keyboardlayout \"%s\" (%s) is unknown, using X server default layout\n",
+ layoutFriendlyName, layoutName);
+ }
}
- if (kbd != NULL)
- {
-
- if (kbd->inp_identifier)
- winDebug ("Using keyboard \"%s\" as primary keyboard\n",
- kbd->inp_identifier);
+ /* parse the configuration */
+#ifdef XWIN_XF86CONFIG
+ if (g_cmdline.keyboard)
+ kbdfrom = X_CMDLINE;
+
+ /*
+ * Until the layout code is finished, I search for the keyboard
+ * device and configure the server with it.
+ */
+
+ if (g_xf86configptr != NULL)
+ input_list = g_xf86configptr->conf_input_lst;
+
+ while (input_list != NULL) {
+ if (winNameCompare(input_list->inp_driver, "keyboard") == 0) {
+ /* Check if device name matches requested name */
+ if (g_cmdline.keyboard && winNameCompare(input_list->inp_identifier,
+ g_cmdline.keyboard))
+ continue;
+ kbd = input_list;
+ }
+ input_list = input_list->list.next;
+ }
- if ((s = winSetStrOption(kbd->inp_option_lst, "AutoRepeat", NULL)))
- {
- if ((sscanf(s, "%ld %ld", &g_winInfo.keyboard.delay,
- &g_winInfo.keyboard.rate) != 2) ||
- (g_winInfo.keyboard.delay < 1) ||
- (g_winInfo.keyboard.rate == 0) ||
- (1000 / g_winInfo.keyboard.rate) < 1)
- {
- ErrorF ("\"%s\" is not a valid AutoRepeat value", s);
- free(s);
- return FALSE;
+ if (kbd != NULL) {
+
+ if (kbd->inp_identifier)
+ winDebug ("Using keyboard \"%s\" as primary keyboard\n",
+ kbd->inp_identifier);
+
+ if ((s = winSetStrOption(kbd->inp_option_lst, "AutoRepeat", NULL))) {
+ if ((sscanf(s, "%ld %ld", &g_winInfo.keyboard.delay,
+ &g_winInfo.keyboard.rate) != 2) ||
+ (g_winInfo.keyboard.delay < 1) ||
+ (g_winInfo.keyboard.rate == 0) ||
+ (1000 / g_winInfo.keyboard.rate) < 1) {
+ ErrorF ("\"%s\" is not a valid AutoRepeat value", s);
+ free(s);
+ return FALSE;
}
- free(s);
- winDebug ("AutoRepeat: %ld %ld\n",
- g_winInfo.keyboard.delay, g_winInfo.keyboard.rate);
+ free(s);
+ winDebug ("AutoRepeat: %ld %ld\n",
+ g_winInfo.keyboard.delay, g_winInfo.keyboard.rate);
}
#endif
-
+
s = NULL;
- if (g_cmdline.xkbRules)
- {
+ if (g_cmdline.xkbRules) {
s = g_cmdline.xkbRules;
from = X_CMDLINE;
- }
+ }
#ifdef XWIN_XF86CONFIG
- else
- {
- s = winSetStrOption (kbd->inp_option_lst, "XkbRules", NULL);
+ else {
+ s = winSetStrOption(kbd->inp_option_lst, "XkbRules", NULL);
from = X_CONFIG;
- }
+ }
#endif
- if (s)
- {
- g_winInfo.xkb.rules = NULL_IF_EMPTY (s);
+ if (s) {
+ g_winInfo.xkb.rules = NULL_IF_EMPTY(s);
winDebug ("XKB: rules: \"%s\"\n", s);
- }
-
+ }
+
s = NULL;
- if (g_cmdline.xkbModel)
- {
+ if (g_cmdline.xkbModel) {
s = g_cmdline.xkbModel;
from = X_CMDLINE;
- }
+ }
#ifdef XWIN_XF86CONFIG
- else
- {
- s = winSetStrOption (kbd->inp_option_lst, "XkbModel", NULL);
+ else {
+ s = winSetStrOption(kbd->inp_option_lst, "XkbModel", NULL);
from = X_CONFIG;
- }
+ }
#endif
- if (s)
- {
- g_winInfo.xkb.model = NULL_IF_EMPTY (s);
- winDebug ("XKB: model: \"%s\"\n", s);
- }
+ if (s) {
+ g_winInfo.xkb.model = NULL_IF_EMPTY(s);
+ winDebug ("XKB: model: \"%s\"\n", s);
+ }
s = NULL;
- if (g_cmdline.xkbLayout)
- {
+ if (g_cmdline.xkbLayout) {
s = g_cmdline.xkbLayout;
from = X_CMDLINE;
- }
+ }
#ifdef XWIN_XF86CONFIG
- else
- {
- s = winSetStrOption (kbd->inp_option_lst, "XkbLayout", NULL);
+ else {
+ s = winSetStrOption(kbd->inp_option_lst, "XkbLayout", NULL);
from = X_CONFIG;
- }
+ }
#endif
- if (s)
- {
- g_winInfo.xkb.layout = NULL_IF_EMPTY (s);
- winDebug ("XKB: layout: \"%s\"\n", s);
- }
+ if (s) {
+ g_winInfo.xkb.layout = NULL_IF_EMPTY(s);
+ winDebug ("XKB: layout: \"%s\"\n", s);
+ }
s = NULL;
- if (g_cmdline.xkbVariant)
- {
+ if (g_cmdline.xkbVariant) {
s = g_cmdline.xkbVariant;
from = X_CMDLINE;
- }
+ }
#ifdef XWIN_XF86CONFIG
- else
- {
- s = winSetStrOption (kbd->inp_option_lst, "XkbVariant", NULL);
+ else {
+ s = winSetStrOption(kbd->inp_option_lst, "XkbVariant", NULL);
from = X_CONFIG;
- }
+ }
#endif
- if (s)
- {
- g_winInfo.xkb.variant = NULL_IF_EMPTY (s);
- winDebug ("XKB: variant: \"%s\"\n", s);
- }
+ if (s) {
+ g_winInfo.xkb.variant = NULL_IF_EMPTY(s);
+ winDebug ("XKB: variant: \"%s\"\n", s);
+ }
s = NULL;
- if (g_cmdline.xkbOptions)
- {
+ if (g_cmdline.xkbOptions) {
s = g_cmdline.xkbOptions;
from = X_CMDLINE;
- }
+ }
#ifdef XWIN_XF86CONFIG
- else
- {
- s = winSetStrOption (kbd->inp_option_lst, "XkbOptions", NULL);
+ else {
+ s = winSetStrOption(kbd->inp_option_lst, "XkbOptions", NULL);
from = X_CONFIG;
- }
+ }
#else
else
{
@@ -509,203 +476,184 @@ winConfigKeyboard (DeviceIntPtr pDevice)
s="grab:break_actions"; /* Currently attach default CTRL+ALT+NKP/ and CTRL+ALT+NKP* mappings to release grab functions */
}
#endif
- if (s)
- {
- g_winInfo.xkb.options = NULL_IF_EMPTY (s);
- winDebug ("XKB: options: \"%s\"\n", s);
- }
+ if (s) {
+ g_winInfo.xkb.options = NULL_IF_EMPTY(s);
+ winDebug ("XKB: options: \"%s\"\n", s);
+ }
#ifdef XWIN_XF86CONFIG
}
#endif
- return TRUE;
+ return TRUE;
}
-
#ifdef XWIN_XF86CONFIG
Bool
-winConfigMouse (DeviceIntPtr pDevice)
+winConfigMouse(DeviceIntPtr pDevice)
{
- MessageType mousefrom = X_CONFIG;
+ MessageType mousefrom = X_CONFIG;
- XF86ConfInputPtr mouse = NULL;
- XF86ConfInputPtr input_list = NULL;
+ XF86ConfInputPtr mouse = NULL;
+ XF86ConfInputPtr input_list = NULL;
- if (g_cmdline.mouse)
- mousefrom = X_CMDLINE;
+ if (g_cmdline.mouse)
+ mousefrom = X_CMDLINE;
- if (g_xf86configptr != NULL)
- input_list = g_xf86configptr->conf_input_lst;
+ if (g_xf86configptr != NULL)
+ input_list = g_xf86configptr->conf_input_lst;
- while (input_list != NULL)
- {
- if (winNameCompare (input_list->inp_driver, "mouse") == 0)
- {
- /* Check if device name matches requested name */
- if (g_cmdline.mouse && winNameCompare (input_list->inp_identifier,
- g_cmdline.mouse))
- continue;
- mouse = input_list;
- }
- input_list = input_list->list.next;
+ while (input_list != NULL) {
+ if (winNameCompare(input_list->inp_driver, "mouse") == 0) {
+ /* Check if device name matches requested name */
+ if (g_cmdline.mouse && winNameCompare(input_list->inp_identifier,
+ g_cmdline.mouse))
+ continue;
+ mouse = input_list;
+ }
+ input_list = input_list->list.next;
}
- if (mouse != NULL)
- {
- if (mouse->inp_identifier)
- winDebug ("Using pointer \"%s\" as primary pointer\n",
- mouse->inp_identifier);
-
- g_winInfo.pointer.emulate3Buttons =
- winSetBoolOption (mouse->inp_option_lst, "Emulate3Buttons", FALSE);
- if (g_cmdline.emulate3buttons)
- g_winInfo.pointer.emulate3Buttons = g_cmdline.emulate3buttons;
-
- g_winInfo.pointer.emulate3Timeout =
- winSetIntOption (mouse->inp_option_lst, "Emulate3Timeout", 50);
- if (g_cmdline.emulate3timeout)
- g_winInfo.pointer.emulate3Timeout = g_cmdline.emulate3timeout;
+ if (mouse != NULL) {
+ if (mouse->inp_identifier)
+ winDebug ("Using pointer \"%s\" as primary pointer\n",
+ mouse->inp_identifier);
+
+ g_winInfo.pointer.emulate3Buttons =
+ winSetBoolOption(mouse->inp_option_lst, "Emulate3Buttons", FALSE);
+ if (g_cmdline.emulate3buttons)
+ g_winInfo.pointer.emulate3Buttons = g_cmdline.emulate3buttons;
+
+ g_winInfo.pointer.emulate3Timeout =
+ winSetIntOption(mouse->inp_option_lst, "Emulate3Timeout", 50);
+ if (g_cmdline.emulate3timeout)
+ g_winInfo.pointer.emulate3Timeout = g_cmdline.emulate3timeout;
}
- else
- {
+ else {
winDebug ("No primary pointer configured\n");
winDebug ("Using compiletime defaults for pointer\n");
}
- return TRUE;
+ return TRUE;
}
-
Bool
-winConfigFiles ()
+winConfigFiles()
{
- MessageType from;
- XF86ConfFilesPtr filesptr = NULL;
+ MessageType from;
+ XF86ConfFilesPtr filesptr = NULL;
- /* set some shortcuts */
- if (g_xf86configptr != NULL)
- {
- filesptr = g_xf86configptr->conf_files;
+ /* set some shortcuts */
+ if (g_xf86configptr != NULL) {
+ filesptr = g_xf86configptr->conf_files;
}
+ /* Fontpath */
+ from = X_DEFAULT;
- /* Fontpath */
- from = X_DEFAULT;
-
- if (g_cmdline.fontPath)
- {
- from = X_CMDLINE;
- defaultFontPath = g_cmdline.fontPath;
+ if (g_cmdline.fontPath) {
+ from = X_CMDLINE;
+ defaultFontPath = g_cmdline.fontPath;
}
- else if (filesptr != NULL && filesptr->file_fontpath)
- {
- from = X_CONFIG;
- defaultFontPath = strdup (filesptr->file_fontpath);
+ else if (filesptr != NULL && filesptr->file_fontpath) {
+ from = X_CONFIG;
+ defaultFontPath = strdup(filesptr->file_fontpath);
}
- winDebug ("FontPath set to \"%s\"\n", defaultFontPath);
+ winDebug ("FontPath set to \"%s\"\n", defaultFontPath);
- return TRUE;
+ return TRUE;
}
#else
Bool
-winConfigFiles (void)
+winConfigFiles(void)
{
- /* Fontpath */
- if (g_cmdline.fontPath)
- {
- defaultFontPath = g_cmdline.fontPath;
- winDebug("FontPath set to \"%s\"\n", defaultFontPath);
+ /* Fontpath */
+ if (g_cmdline.fontPath) {
+ defaultFontPath = g_cmdline.fontPath;
+ winDebug("FontPath set to \"%s\"\n", defaultFontPath);
}
- return TRUE;
+ return TRUE;
}
#endif
-
Bool
-winConfigOptions (void)
+winConfigOptions(void)
{
- return TRUE;
+ return TRUE;
}
-
Bool
-winConfigScreens (void)
+winConfigScreens(void)
{
- return TRUE;
+ return TRUE;
}
-
#ifdef XWIN_XF86CONFIG
char *
-winSetStrOption (pointer optlist, const char *name, char *deflt)
+winSetStrOption(pointer optlist, const char *name, char *deflt)
{
- OptionInfoRec o;
-
- o.name = name;
- o.type = OPTV_STRING;
- if (ParseOptionValue (-1, optlist, &o))
- deflt = o.value.str;
- if (deflt)
- return strdup (deflt);
- else
- return NULL;
+ OptionInfoRec o;
+
+ o.name = name;
+ o.type = OPTV_STRING;
+ if (ParseOptionValue(-1, optlist, &o))
+ deflt = o.value.str;
+ if (deflt)
+ return strdup(deflt);
+ else
+ return NULL;
}
-
int
-winSetBoolOption (pointer optlist, const char *name, int deflt)
+winSetBoolOption(pointer optlist, const char *name, int deflt)
{
- OptionInfoRec o;
+ OptionInfoRec o;
- o.name = name;
- o.type = OPTV_BOOLEAN;
- if (ParseOptionValue (-1, optlist, &o))
- deflt = o.value.bool;
- return deflt;
+ o.name = name;
+ o.type = OPTV_BOOLEAN;
+ if (ParseOptionValue(-1, optlist, &o))
+ deflt = o.value.bool;
+ return deflt;
}
-
int
-winSetIntOption (pointer optlist, const char *name, int deflt)
+winSetIntOption(pointer optlist, const char *name, int deflt)
{
- OptionInfoRec o;
+ OptionInfoRec o;
- o.name = name;
- o.type = OPTV_INTEGER;
- if (ParseOptionValue (-1, optlist, &o))
- deflt = o.value.num;
- return deflt;
+ o.name = name;
+ o.type = OPTV_INTEGER;
+ if (ParseOptionValue(-1, optlist, &o))
+ deflt = o.value.num;
+ return deflt;
}
-
double
-winSetRealOption (pointer optlist, const char *name, double deflt)
+winSetRealOption(pointer optlist, const char *name, double deflt)
{
- OptionInfoRec o;
+ OptionInfoRec o;
- o.name = name;
- o.type = OPTV_REAL;
- if (ParseOptionValue (-1, optlist, &o))
- deflt = o.value.realnum;
- return deflt;
+ o.name = name;
+ o.type = OPTV_REAL;
+ if (ParseOptionValue(-1, optlist, &o))
+ deflt = o.value.realnum;
+ return deflt;
}
double
-winSetPercentOption (pointer optlist, const char *name, double deflt)
+winSetPercentOption(pointer optlist, const char *name, double deflt)
{
- OptionInfoRec o;
+ OptionInfoRec o;
- o.name = name;
- o.type = OPTV_PERCENT;
- if (ParseOptionValue (-1, optlist, &o))
- deflt = o.value.realnum;
- return deflt;
+ o.name = name;
+ o.type = OPTV_PERCENT;
+ if (ParseOptionValue(-1, optlist, &o))
+ deflt = o.value.realnum;
+ return deflt;
}
#endif
-
/*
* Compare two strings for equality. This is caseinsensitive and
* The characters '_', ' ' (space) and '\t' (tab) are treated as
@@ -713,45 +661,42 @@ winSetPercentOption (pointer optlist, const char *name, double deflt)
*/
int
-winNameCompare (const char *s1, const char *s2)
+winNameCompare(const char *s1, const char *s2)
{
- char c1, c2;
+ char c1, c2;
- if (!s1 || *s1 == 0)
- {
- if (!s2 || *s2 == 0)
- return 0;
- else
- return 1;
+ if (!s1 || *s1 == 0) {
+ if (!s2 || *s2 == 0)
+ return 0;
+ else
+ return 1;
}
- while (*s1 == '_' || *s1 == ' ' || *s1 == '\t')
- s1++;
- while (*s2 == '_' || *s2 == ' ' || *s2 == '\t')
- s2++;
+ while (*s1 == '_' || *s1 == ' ' || *s1 == '\t')
+ s1++;
+ while (*s2 == '_' || *s2 == ' ' || *s2 == '\t')
+ s2++;
- c1 = (isupper ((int)*s1) ? tolower ((int)*s1) : *s1);
- c2 = (isupper ((int)*s2) ? tolower ((int)*s2) : *s2);
+ c1 = (isupper((int) *s1) ? tolower((int) *s1) : *s1);
+ c2 = (isupper((int) *s2) ? tolower((int) *s2) : *s2);
- while (c1 == c2)
- {
- if (c1 == 0)
- return 0;
- s1++;
- s2++;
-
- while (*s1 == '_' || *s1 == ' ' || *s1 == '\t')
- s1++;
- while (*s2 == '_' || *s2 == ' ' || *s2 == '\t')
- s2++;
-
- c1 = (isupper ((int)*s1) ? tolower ((int)*s1) : *s1);
- c2 = (isupper ((int)*s2) ? tolower ((int)*s2) : *s2);
+ while (c1 == c2) {
+ if (c1 == 0)
+ return 0;
+ s1++;
+ s2++;
+
+ while (*s1 == '_' || *s1 == ' ' || *s1 == '\t')
+ s1++;
+ while (*s2 == '_' || *s2 == ' ' || *s2 == '\t')
+ s2++;
+
+ c1 = (isupper((int) *s1) ? tolower((int) *s1) : *s1);
+ c2 = (isupper((int) *s2) ? tolower((int) *s2) : *s2);
}
- return c1 - c2;
+ return c1 - c2;
}
-
#ifdef XWIN_XF86CONFIG
/*
* Find the named option in the list.
@@ -759,351 +704,297 @@ winNameCompare (const char *s1, const char *s2)
*/
XF86OptionPtr
-winFindOption (XF86OptionPtr list, const char *name)
+winFindOption(XF86OptionPtr list, const char *name)
{
- while (list)
- {
- if (winNameCompare (list->opt_name, name) == 0)
- return list;
- list = list->list.next;
+ while (list) {
+ if (winNameCompare(list->opt_name, name) == 0)
+ return list;
+ list = list->list.next;
}
- return NULL;
+ return NULL;
}
-
/*
* Find the Value of an named option.
* @return The option value or NULL if not found.
*/
char *
-winFindOptionValue (XF86OptionPtr list, const char *name)
+winFindOptionValue(XF86OptionPtr list, const char *name)
{
- list = winFindOption (list, name);
- if (list)
- {
- if (list->opt_val)
- return list->opt_val;
- else
- return "";
+ list = winFindOption(list, name);
+ if (list) {
+ if (list->opt_val)
+ return list->opt_val;
+ else
+ return "";
}
- return NULL;
+ return NULL;
}
-
/*
* Parse the option.
*/
static Bool
-ParseOptionValue (int scrnIndex, pointer options, OptionInfoPtr p)
+ParseOptionValue(int scrnIndex, pointer options, OptionInfoPtr p)
{
- char *s, *end;
+ char *s, *end;
- if ((s = winFindOptionValue (options, p->name)) != NULL)
- {
- switch (p->type)
- {
- case OPTV_INTEGER:
- if (*s == '\0')
- {
+ if ((s = winFindOptionValue(options, p->name)) != NULL) {
+ switch (p->type) {
+ case OPTV_INTEGER:
+ if (*s == '\0') {
winDebug ( "Option \"%s\" requires an integer value\n",
- p->name);
- p->found = FALSE;
- }
- else
- {
- p->value.num = strtoul (s, &end, 0);
- if (*end == '\0')
- {
- p->found = TRUE;
- }
- else
- {
- winDebug ( "Option \"%s\" requires an integer value\n",
- p->name);
- p->found = FALSE;
- }
- }
- break;
- case OPTV_STRING:
- if (*s == '\0')
- {
- winDebug ( "Option \"%s\" requires an string value\n", p->name);
- p->found = FALSE;
- }
- else
- {
- p->value.str = s;
- p->found = TRUE;
- }
- break;
- case OPTV_ANYSTR:
- p->value.str = s;
- p->found = TRUE;
- break;
- case OPTV_REAL:
- if (*s == '\0')
- {
- winDebug ( "Option \"%s\" requires a floating point value\n",
- p->name);
- p->found = FALSE;
- }
- else
- {
- p->value.realnum = strtod (s, &end);
- if (*end == '\0')
- {
- p->found = TRUE;
- }
- else
- {
- winDebug ( "Option \"%s\" requires a floating point value\n",
- p->name);
- p->found = FALSE;
- }
- }
- break;
- case OPTV_BOOLEAN:
- if (GetBoolValue (p, s))
- {
- p->found = TRUE;
- }
- else
- {
- winDebug ( "Option \"%s\" requires a boolean value\n", p->name);
- p->found = FALSE;
- }
- break;
- case OPTV_PERCENT:
- if (*s == '\0')
- {
- winDrvMsg (scrnIndex, X_WARNING,
- "Option \"%s\" requires a percent value\n",
- p->name);
- p->found = FALSE;
- }
- else
- {
- double percent = strtod (s, &end);
-
- if (end != s && winNameCompare (end, "%"))
- {
- p->found = TRUE;
- p->value.realnum = percent;
- }
- else
- {
- winDrvMsg (scrnIndex, X_WARNING,
- "Option \"%s\" requires a frequency value\n",
- p->name);
- p->found = FALSE;
- }
- }
- case OPTV_FREQ:
- if (*s == '\0')
- {
- winDebug ( "Option \"%s\" requires a frequency value\n",
- p->name);
- p->found = FALSE;
- }
- else
- {
- double freq = strtod (s, &end);
- int units = 0;
-
- if (end != s)
- {
- p->found = TRUE;
- if (!winNameCompare (end, "Hz"))
- units = 1;
- else if (!winNameCompare (end, "kHz") ||
- !winNameCompare (end, "k"))
- units = 1000;
- else if (!winNameCompare (end, "MHz") ||
- !winNameCompare (end, "M"))
- units = 1000000;
- else
- {
- winDebug ( "Option \"%s\" requires a frequency value\n",
- p->name);
- p->found = FALSE;
- }
- if (p->found)
- freq *= (double) units;
- }
- else
- {
- winDebug ( "Option \"%s\" requires a frequency value\n",
- p->name);
- p->found = FALSE;
- }
- if (p->found)
- {
- p->value.freq.freq = freq;
- p->value.freq.units = units;
- }
- }
- break;
- case OPTV_NONE:
- /* Should never get here */
- p->found = FALSE;
- break;
- }
- if (p->found)
- {
- winDebug ("Option \"%s\"", p->name);
- if (!(p->type == OPTV_BOOLEAN && *s == 0))
- {
- winDebug (" \"%s\"", s);
- }
- winDebug ("\n");
- }
+ p->found = FALSE;
+ }
+ else {
+ p->value.num = strtoul(s, &end, 0);
+ if (*end == '\0') {
+ p->found = TRUE;
+ }
+ else {
+ winDebug ( "Option \"%s\" requires an integer value\n",
+ p->name);
+ p->found = FALSE;
+ }
+ }
+ break;
+ case OPTV_STRING:
+ if (*s == '\0') {
+ winDebug ( "Option \"%s\" requires an string value\n", p->name);
+ p->found = FALSE;
+ }
+ else {
+ p->value.str = s;
+ p->found = TRUE;
+ }
+ break;
+ case OPTV_ANYSTR:
+ p->value.str = s;
+ p->found = TRUE;
+ break;
+ case OPTV_REAL:
+ if (*s == '\0') {
+ winDebug ( "Option \"%s\" requires a floating point value\n",
+ p->name);
+ p->found = FALSE;
+ }
+ else {
+ p->value.realnum = strtod(s, &end);
+ if (*end == '\0') {
+ p->found = TRUE;
+ }
+ else {
+ winDebug ( "Option \"%s\" requires a floating point value\n",
+ p->name);
+ p->found = FALSE;
+ }
+ }
+ break;
+ case OPTV_BOOLEAN:
+ if (GetBoolValue(p, s)) {
+ p->found = TRUE;
+ }
+ else {
+ winDebug ( "Option \"%s\" requires a boolean value\n", p->name);
+ p->found = FALSE;
+ }
+ break;
+ case OPTV_PERCENT:
+ if (*s == '\0') {
+ winDrvMsg(scrnIndex, X_WARNING,
+ "Option \"%s\" requires a percent value\n", p->name);
+ p->found = FALSE;
+ }
+ else {
+ double percent = strtod(s, &end);
+
+ if (end != s && winNameCompare(end, "%")) {
+ p->found = TRUE;
+ p->value.realnum = percent;
+ }
+ else {
+ winDrvMsg(scrnIndex, X_WARNING,
+ "Option \"%s\" requires a frequency value\n",
+ p->name);
+ p->found = FALSE;
+ }
+ }
+ case OPTV_FREQ:
+ if (*s == '\0') {
+ winDebug ( "Option \"%s\" requires a frequency value\n",
+ p->name);
+ p->found = FALSE;
+ }
+ else {
+ double freq = strtod(s, &end);
+ int units = 0;
+
+ if (end != s) {
+ p->found = TRUE;
+ if (!winNameCompare(end, "Hz"))
+ units = 1;
+ else if (!winNameCompare(end, "kHz") ||
+ !winNameCompare(end, "k"))
+ units = 1000;
+ else if (!winNameCompare(end, "MHz") ||
+ !winNameCompare(end, "M"))
+ units = 1000000;
+ else {
+ winDebug ( "Option \"%s\" requires a frequency value\n",
+ p->name);
+ p->found = FALSE;
+ }
+ if (p->found)
+ freq *= (double) units;
+ }
+ else {
+ winDebug ( "Option \"%s\" requires a frequency value\n",
+ p->name);
+ p->found = FALSE;
+ }
+ if (p->found) {
+ p->value.freq.freq = freq;
+ p->value.freq.units = units;
+ }
+ }
+ break;
+ case OPTV_NONE:
+ /* Should never get here */
+ p->found = FALSE;
+ break;
+ }
+ if (p->found) {
+ winDebug ("Option \"%s\"", p->name);
+ if (!(p->type == OPTV_BOOLEAN && *s == 0)) {
+ winDebug (" \"%s\"", s);
+ }
+ winDebug ("\n");
+ }
}
- else if (p->type == OPTV_BOOLEAN)
- {
- /* Look for matches with options with or without a "No" prefix. */
- char *n, *newn;
- OptionInfoRec opt;
-
- n = winNormalizeName (p->name);
- if (!n)
- {
- p->found = FALSE;
- return FALSE;
- }
- if (strncmp (n, "no", 2) == 0)
- {
- newn = n + 2;
- }
- else
- {
- free (n);
- n = malloc (strlen (p->name) + 2 + 1);
- if (!n)
- {
- p->found = FALSE;
- return FALSE;
- }
- strcpy (n, "No");
- strcat (n, p->name);
- newn = n;
- }
- if ((s = winFindOptionValue (options, newn)) != NULL)
- {
- if (GetBoolValue (&opt, s))
- {
- p->value.bool = !opt.value.bool;
- p->found = TRUE;
- }
- else
- {
- winDebug ( "Option \"%s\" requires a boolean value\n", newn);
- p->found = FALSE;
- }
- }
- else
- {
- p->found = FALSE;
- }
- if (p->found)
- {
- winDebug ("Option \"%s\"", newn);
- if (*s != 0)
- {
- winDebug (" \"%s\"", s);
- }
- winDebug ("\n");
- }
- free (n);
+ else if (p->type == OPTV_BOOLEAN) {
+ /* Look for matches with options with or without a "No" prefix. */
+ char *n, *newn;
+ OptionInfoRec opt;
+
+ n = winNormalizeName(p->name);
+ if (!n) {
+ p->found = FALSE;
+ return FALSE;
+ }
+ if (strncmp(n, "no", 2) == 0) {
+ newn = n + 2;
+ }
+ else {
+ free(n);
+ n = malloc(strlen(p->name) + 2 + 1);
+ if (!n) {
+ p->found = FALSE;
+ return FALSE;
+ }
+ strcpy(n, "No");
+ strcat(n, p->name);
+ newn = n;
+ }
+ if ((s = winFindOptionValue(options, newn)) != NULL) {
+ if (GetBoolValue(&opt, s)) {
+ p->value.bool = !opt.value.bool;
+ p->found = TRUE;
+ }
+ else {
+ winDebug ( "Option \"%s\" requires a boolean value\n", newn);
+ p->found = FALSE;
+ }
+ }
+ else {
+ p->found = FALSE;
+ }
+ if (p->found) {
+ winDebug ("Option \"%s\"", newn);
+ if (*s != 0) {
+ winDebug (" \"%s\"", s);
+ }
+ winDebug ("\n");
+ }
+ free(n);
}
- else
- {
- p->found = FALSE;
+ else {
+ p->found = FALSE;
}
- return p->found;
+ return p->found;
}
-
static Bool
-configLayout (serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
- char *default_layout)
+configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
+ char *default_layout)
{
#if 0
#pragma warn UNIMPLEMENTED
#endif
- return TRUE;
+ return TRUE;
}
-
static Bool
-configImpliedLayout (serverLayoutPtr servlayoutp,
- XF86ConfScreenPtr conf_screen)
+configImpliedLayout(serverLayoutPtr servlayoutp, XF86ConfScreenPtr conf_screen)
{
#if 0
#pragma warn UNIMPLEMENTED
#endif
- return TRUE;
+ return TRUE;
}
-
static Bool
-GetBoolValue (OptionInfoPtr p, const char *s)
+GetBoolValue(OptionInfoPtr p, const char *s)
{
- if (*s == 0)
- {
- p->value.bool = TRUE;
+ if (*s == 0) {
+ p->value.bool = TRUE;
}
- else
- {
- if (winNameCompare (s, "1") == 0)
- p->value.bool = TRUE;
- else if (winNameCompare (s, "on") == 0)
- p->value.bool = TRUE;
- else if (winNameCompare (s, "true") == 0)
- p->value.bool = TRUE;
- else if (winNameCompare (s, "yes") == 0)
- p->value.bool = TRUE;
- else if (winNameCompare (s, "0") == 0)
- p->value.bool = FALSE;
- else if (winNameCompare (s, "off") == 0)
- p->value.bool = FALSE;
- else if (winNameCompare (s, "false") == 0)
- p->value.bool = FALSE;
- else if (winNameCompare (s, "no") == 0)
- p->value.bool = FALSE;
+ else {
+ if (winNameCompare(s, "1") == 0)
+ p->value.bool = TRUE;
+ else if (winNameCompare(s, "on") == 0)
+ p->value.bool = TRUE;
+ else if (winNameCompare(s, "true") == 0)
+ p->value.bool = TRUE;
+ else if (winNameCompare(s, "yes") == 0)
+ p->value.bool = TRUE;
+ else if (winNameCompare(s, "0") == 0)
+ p->value.bool = FALSE;
+ else if (winNameCompare(s, "off") == 0)
+ p->value.bool = FALSE;
+ else if (winNameCompare(s, "false") == 0)
+ p->value.bool = FALSE;
+ else if (winNameCompare(s, "no") == 0)
+ p->value.bool = FALSE;
}
- return TRUE;
+ return TRUE;
}
#endif
-
char *
-winNormalizeName (const char *s)
+winNormalizeName(const char *s)
{
- char *ret, *q;
- const char *p;
-
- if (s == NULL)
- return NULL;
-
- ret = malloc (strlen (s) + 1);
- for (p = s, q = ret; *p != 0; p++)
- {
- switch (*p)
- {
- case '_':
- case ' ':
- case '\t':
- continue;
- default:
- if (isupper ((int)*p))
- *q++ = tolower ((int)*p);
- else
- *q++ = *p;
- }
+ char *ret, *q;
+ const char *p;
+
+ if (s == NULL)
+ return NULL;
+
+ ret = malloc(strlen(s) + 1);
+ for (p = s, q = ret; *p != 0; p++) {
+ switch (*p) {
+ case '_':
+ case ' ':
+ case '\t':
+ continue;
+ default:
+ if (isupper((int) *p))
+ *q++ = tolower((int) *p);
+ else
+ *q++ = *p;
+ }
}
- *q = '\0';
- return ret;
+ *q = '\0';
+ return ret;
}
-
diff --git a/xorg-server/hw/xwin/winconfig.h b/xorg-server/hw/xwin/winconfig.h
index 7f533cff0..94571ff71 100644
--- a/xorg-server/hw/xwin/winconfig.h
+++ b/xorg-server/hw/xwin/winconfig.h
@@ -1,324 +1,264 @@
-#ifndef __WIN_CONFIG_H__
-#define __WIN_CONFIG_H__
-/*
- *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, sublicense, and/or sell copies of the Software, and to
- *permit persons to whom the Software is furnished to do so, subject to
- *the following conditions:
- *
- *The above copyright notice and this permission notice shall be
- *included in all copies or substantial portions of the Software.
- *
- *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
- *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *Except as contained in this notice, the name of the XFree86 Project
- *shall not be used in advertising or otherwise to promote the sale, use
- *or other dealings in this Software without prior written authorization
- *from the XFree86 Project.
- *
- * Authors: Alexander Gottwald
- */
-
-#include "win.h"
-#ifdef XWIN_XF86CONFIG
-#include "../xfree86/parser/xf86Parser.h"
-#endif
-
-
-/* These are taken from hw/xfree86/common/xf86str.h */
-
-typedef struct
-{
- CARD32 red, green, blue;
-}
-rgb;
-
-
-typedef struct
-{
- float red, green, blue;
-}
-Gamma;
-
-
-typedef struct
-{
- char *identifier;
- char *vendor;
- char *board;
- char *chipset;
- char *ramdac;
- char *driver;
- struct _confscreenrec *myScreenSection;
- Bool claimed;
- Bool active;
- Bool inUse;
- int videoRam;
- int textClockFreq;
- pointer options;
- int screen; /* For multi-CRTC cards */
-}
-GDevRec, *GDevPtr;
-
-
-typedef struct
-{
- char *identifier;
- char *driver;
- pointer commonOptions;
- pointer extraOptions;
-}
-IDevRec, *IDevPtr;
-
-
-typedef struct
-{
- int frameX0;
- int frameY0;
- int virtualX;
- int virtualY;
- int depth;
- int fbbpp;
- rgb weight;
- rgb blackColour;
- rgb whiteColour;
- int defaultVisual;
- char **modes;
- pointer options;
-}
-DispRec, *DispPtr;
-
-
-typedef struct _confxvportrec
-{
- char *identifier;
- pointer options;
-}
-confXvPortRec, *confXvPortPtr;
-
-
-typedef struct _confxvadaptrec
-{
- char *identifier;
- int numports;
- confXvPortPtr ports;
- pointer options;
-}
-confXvAdaptorRec, *confXvAdaptorPtr;
-
-
-typedef struct _confscreenrec
-{
- char *id;
- int screennum;
- int defaultdepth;
- int defaultbpp;
- int defaultfbbpp;
- GDevPtr device;
- int numdisplays;
- DispPtr displays;
- int numxvadaptors;
- confXvAdaptorPtr xvadaptors;
- pointer options;
-}
-confScreenRec, *confScreenPtr;
-
-
-typedef enum
-{
- PosObsolete = -1,
- PosAbsolute = 0,
- PosRightOf,
- PosLeftOf,
- PosAbove,
- PosBelow,
- PosRelative
-}
-PositionType;
-
-
-typedef struct _screenlayoutrec
-{
- confScreenPtr screen;
- char *topname;
- confScreenPtr top;
- char *bottomname;
- confScreenPtr bottom;
- char *leftname;
- confScreenPtr left;
- char *rightname;
- confScreenPtr right;
- PositionType where;
- int x;
- int y;
- char *refname;
- confScreenPtr refscreen;
-}
-screenLayoutRec, *screenLayoutPtr;
-
-
-typedef struct _serverlayoutrec
-{
- char *id;
- screenLayoutPtr screens;
- GDevPtr inactives;
- IDevPtr inputs;
- pointer options;
-}
-serverLayoutRec, *serverLayoutPtr;
-
-
-/*
- * winconfig.c
- */
-
-typedef struct
-{
- /* Files */
-#ifdef XWIN_XF86CONFIG
- char *configFile;
- char *configDir;
-#endif
- char *fontPath;
- /* input devices - keyboard */
-#ifdef XWIN_XF86CONFIG
- char *keyboard;
-#endif
- char *xkbRules;
- char *xkbModel;
- char *xkbLayout;
- char *xkbVariant;
- char *xkbOptions;
- /* layout */
- char *screenname;
- /* mouse settings */
- char *mouse;
- Bool emulate3buttons;
- long emulate3timeout;
-}
-WinCmdlineRec, *WinCmdlinePtr;
-
-
-extern WinCmdlineRec g_cmdline;
-#ifdef XWIN_XF86CONFIG
-extern XF86ConfigPtr g_xf86configptr;
-#endif
-extern serverLayoutRec g_winConfigLayout;
-
-
-/*
- * Function prototypes
- */
-
-Bool winReadConfigfile (void);
-Bool winConfigFiles (void);
-Bool winConfigOptions (void);
-Bool winConfigScreens (void);
-Bool winConfigKeyboard (DeviceIntPtr pDevice);
-Bool winConfigMouse (DeviceIntPtr pDevice);
-
-
-typedef struct
-{
- double freq;
- int units;
-}
-OptFrequency;
-
-
-typedef union
-{
- unsigned long num;
- char *str;
- double realnum;
- Bool bool;
- OptFrequency freq;
-}
-ValueUnion;
-
-
-typedef enum
-{
- OPTV_NONE = 0,
- OPTV_INTEGER,
- OPTV_STRING, /* a non-empty string */
- OPTV_ANYSTR, /* Any string, including an empty one */
- OPTV_REAL,
- OPTV_BOOLEAN,
- OPTV_PERCENT,
- OPTV_FREQ
-}
-OptionValueType;
-
-
-typedef enum
-{
- OPTUNITS_HZ = 1,
- OPTUNITS_KHZ,
- OPTUNITS_MHZ
-}
-OptFreqUnits;
-
-
-typedef struct
-{
- int token;
- const char *name;
- OptionValueType type;
- ValueUnion value;
- Bool found;
-}
-OptionInfoRec, *OptionInfoPtr;
-
-
-/*
- * Function prototypes
- */
-
-char *winSetStrOption (pointer optlist, const char *name, char *deflt);
-int winSetBoolOption (pointer optlist, const char *name, int deflt);
-int winSetIntOption (pointer optlist, const char *name, int deflt);
-double winSetRealOption (pointer optlist, const char *name, double deflt);
-double winSetPercentOption (pointer optlist, const char *name, double deflt);
-#ifdef XWIN_XF86CONFIG
-XF86OptionPtr winFindOption (XF86OptionPtr list, const char *name);
-char *winFindOptionValue (XF86OptionPtr list, const char *name);
-#endif
-int winNameCompare (const char *s1, const char *s2);
-char *winNormalizeName (const char *s);
-
-
-typedef struct
-{
- struct
- {
- long leds;
- long delay;
- long rate;
- }
- keyboard;
- XkbRMLVOSet xkb;
- struct
- {
- Bool emulate3Buttons;
- long emulate3Timeout;
- }
- pointer;
-}
-winInfoRec, *winInfoPtr;
-
-
-extern winInfoRec g_winInfo;
-
-#endif
+#ifndef __WIN_CONFIG_H__
+#define __WIN_CONFIG_H__
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Alexander Gottwald
+ */
+
+#include "win.h"
+#ifdef XWIN_XF86CONFIG
+#include "../xfree86/parser/xf86Parser.h"
+#endif
+
+/* These are taken from hw/xfree86/common/xf86str.h */
+
+typedef struct {
+ CARD32 red, green, blue;
+} rgb;
+
+typedef struct {
+ float red, green, blue;
+} Gamma;
+
+typedef struct {
+ char *identifier;
+ char *vendor;
+ char *board;
+ char *chipset;
+ char *ramdac;
+ char *driver;
+ struct _confscreenrec *myScreenSection;
+ Bool claimed;
+ Bool active;
+ Bool inUse;
+ int videoRam;
+ int textClockFreq;
+ pointer options;
+ int screen; /* For multi-CRTC cards */
+} GDevRec, *GDevPtr;
+
+typedef struct {
+ char *identifier;
+ char *driver;
+ pointer commonOptions;
+ pointer extraOptions;
+} IDevRec, *IDevPtr;
+
+typedef struct {
+ int frameX0;
+ int frameY0;
+ int virtualX;
+ int virtualY;
+ int depth;
+ int fbbpp;
+ rgb weight;
+ rgb blackColour;
+ rgb whiteColour;
+ int defaultVisual;
+ char **modes;
+ pointer options;
+} DispRec, *DispPtr;
+
+typedef struct _confxvportrec {
+ char *identifier;
+ pointer options;
+} confXvPortRec, *confXvPortPtr;
+
+typedef struct _confxvadaptrec {
+ char *identifier;
+ int numports;
+ confXvPortPtr ports;
+ pointer options;
+} confXvAdaptorRec, *confXvAdaptorPtr;
+
+typedef struct _confscreenrec {
+ char *id;
+ int screennum;
+ int defaultdepth;
+ int defaultbpp;
+ int defaultfbbpp;
+ GDevPtr device;
+ int numdisplays;
+ DispPtr displays;
+ int numxvadaptors;
+ confXvAdaptorPtr xvadaptors;
+ pointer options;
+} confScreenRec, *confScreenPtr;
+
+typedef enum {
+ PosObsolete = -1,
+ PosAbsolute = 0,
+ PosRightOf,
+ PosLeftOf,
+ PosAbove,
+ PosBelow,
+ PosRelative
+} PositionType;
+
+typedef struct _screenlayoutrec {
+ confScreenPtr screen;
+ char *topname;
+ confScreenPtr top;
+ char *bottomname;
+ confScreenPtr bottom;
+ char *leftname;
+ confScreenPtr left;
+ char *rightname;
+ confScreenPtr right;
+ PositionType where;
+ int x;
+ int y;
+ char *refname;
+ confScreenPtr refscreen;
+} screenLayoutRec, *screenLayoutPtr;
+
+typedef struct _serverlayoutrec {
+ char *id;
+ screenLayoutPtr screens;
+ GDevPtr inactives;
+ IDevPtr inputs;
+ pointer options;
+} serverLayoutRec, *serverLayoutPtr;
+
+/*
+ * winconfig.c
+ */
+
+typedef struct {
+ /* Files */
+#ifdef XWIN_XF86CONFIG
+ char *configFile;
+ char *configDir;
+#endif
+ char *fontPath;
+ /* input devices - keyboard */
+#ifdef XWIN_XF86CONFIG
+ char *keyboard;
+#endif
+ char *xkbRules;
+ char *xkbModel;
+ char *xkbLayout;
+ char *xkbVariant;
+ char *xkbOptions;
+ /* layout */
+ char *screenname;
+ /* mouse settings */
+ char *mouse;
+ Bool emulate3buttons;
+ long emulate3timeout;
+} WinCmdlineRec, *WinCmdlinePtr;
+
+extern WinCmdlineRec g_cmdline;
+
+#ifdef XWIN_XF86CONFIG
+extern XF86ConfigPtr g_xf86configptr;
+#endif
+extern serverLayoutRec g_winConfigLayout;
+
+/*
+ * Function prototypes
+ */
+
+Bool winReadConfigfile(void);
+Bool winConfigFiles(void);
+Bool winConfigOptions(void);
+Bool winConfigScreens(void);
+Bool winConfigKeyboard(DeviceIntPtr pDevice);
+Bool winConfigMouse(DeviceIntPtr pDevice);
+
+typedef struct {
+ double freq;
+ int units;
+} OptFrequency;
+
+typedef union {
+ unsigned long num;
+ char *str;
+ double realnum;
+ Bool bool;
+ OptFrequency freq;
+} ValueUnion;
+
+typedef enum {
+ OPTV_NONE = 0,
+ OPTV_INTEGER,
+ OPTV_STRING, /* a non-empty string */
+ OPTV_ANYSTR, /* Any string, including an empty one */
+ OPTV_REAL,
+ OPTV_BOOLEAN,
+ OPTV_PERCENT,
+ OPTV_FREQ
+} OptionValueType;
+
+typedef enum {
+ OPTUNITS_HZ = 1,
+ OPTUNITS_KHZ,
+ OPTUNITS_MHZ
+} OptFreqUnits;
+
+typedef struct {
+ int token;
+ const char *name;
+ OptionValueType type;
+ ValueUnion value;
+ Bool found;
+} OptionInfoRec, *OptionInfoPtr;
+
+/*
+ * Function prototypes
+ */
+
+char *winSetStrOption(pointer optlist, const char *name, char *deflt);
+int winSetBoolOption(pointer optlist, const char *name, int deflt);
+int winSetIntOption(pointer optlist, const char *name, int deflt);
+double winSetRealOption(pointer optlist, const char *name, double deflt);
+double winSetPercentOption(pointer optlist, const char *name, double deflt);
+
+#ifdef XWIN_XF86CONFIG
+XF86OptionPtr winFindOption(XF86OptionPtr list, const char *name);
+char *winFindOptionValue(XF86OptionPtr list, const char *name);
+#endif
+int winNameCompare(const char *s1, const char *s2);
+char *winNormalizeName(const char *s);
+
+typedef struct {
+ struct {
+ long leds;
+ long delay;
+ long rate;
+ } keyboard;
+ XkbRMLVOSet xkb;
+ struct {
+ Bool emulate3Buttons;
+ long emulate3Timeout;
+ } pointer;
+} winInfoRec, *winInfoPtr;
+
+extern winInfoRec g_winInfo;
+
+#endif
diff --git a/xorg-server/hw/xwin/wincreatewnd.c b/xorg-server/hw/xwin/wincreatewnd.c
index 9b5b2f78f..0580421ae 100644
--- a/xorg-server/hw/xwin/wincreatewnd.c
+++ b/xorg-server/hw/xwin/wincreatewnd.c
@@ -39,481 +39,455 @@
*/
static Bool
-winGetWorkArea (RECT *prcWorkArea, winScreenInfo *pScreenInfo);
+ winGetWorkArea(RECT * prcWorkArea, winScreenInfo * pScreenInfo);
static Bool
-winAdjustForAutoHide (RECT *prcWorkArea, winScreenInfo *pScreenInfo);
-
+ winAdjustForAutoHide (RECT *prcWorkArea, winScreenInfo *pScreenInfo);
/*
* Create a full screen window
*/
Bool
-winCreateBoundingWindowFullScreen (ScreenPtr pScreen)
+winCreateBoundingWindowFullScreen(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- int iX = pScreenInfo->dwInitialX;
- int iY = pScreenInfo->dwInitialY;
- int iWidth = pScreenInfo->dwWidth;
- int iHeight = pScreenInfo->dwHeight;
- HWND *phwnd = &pScreenPriv->hwndScreen;
- WNDCLASSEX wc;
- char szTitle[256];
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ int iX = pScreenInfo->dwInitialX;
+ int iY = pScreenInfo->dwInitialY;
+ int iWidth = pScreenInfo->dwWidth;
+ int iHeight = pScreenInfo->dwHeight;
+ HWND *phwnd = &pScreenPriv->hwndScreen;
+ WNDCLASSEX wc;
+ char szTitle[256];
char HostName[256];
gethostname(HostName,256);
- winDebug ("winCreateBoundingWindowFullScreen\n");
-
- /* Setup our window class */
- wc.cbSize=sizeof(WNDCLASSEX);
- wc.style = CS_HREDRAW | CS_VREDRAW;
- wc.lpfnWndProc = winWindowProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = g_hInstance;
- wc.hIcon = (HICON)LoadImage (g_hInstance, MAKEINTRESOURCE(IDI_XWIN), IMAGE_ICON,
- GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), 0);
- wc.hCursor = 0;
- wc.hbrBackground = 0;
- wc.lpszMenuName = NULL;
- wc.lpszClassName = WINDOW_CLASS;
- wc.hIconSm = (HICON)LoadImage (g_hInstance, MAKEINTRESOURCE(IDI_XWIN), IMAGE_ICON,
- GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTSIZE);
- RegisterClassEx (&wc);
-
- /* Set display and screen-specific tooltip text */
- if (g_pszQueryHost != NULL)
- snprintf (szTitle,
- sizeof (szTitle),
- WINDOW_TITLE_XDMCP,
- g_pszQueryHost,
- HostName,
- display,
- (int) pScreenInfo->dwScreen);
- else
+ winDebug("winCreateBoundingWindowFullScreen\n");
+
+ /* Setup our window class */
+ wc.cbSize = sizeof(WNDCLASSEX);
+ wc.style = CS_HREDRAW | CS_VREDRAW;
+ wc.lpfnWndProc = winWindowProc;
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 0;
+ wc.hInstance = g_hInstance;
+ wc.hIcon =
+ (HICON) LoadImage(g_hInstance, MAKEINTRESOURCE(IDI_XWIN), IMAGE_ICON,
+ GetSystemMetrics(SM_CXICON),
+ GetSystemMetrics(SM_CYICON), 0);
+ wc.hCursor = 0;
+ wc.hbrBackground = 0;
+ wc.lpszMenuName = NULL;
+ wc.lpszClassName = WINDOW_CLASS;
+ wc.hIconSm =
+ (HICON) LoadImage(g_hInstance, MAKEINTRESOURCE(IDI_XWIN), IMAGE_ICON,
+ GetSystemMetrics(SM_CXSMICON),
+ GetSystemMetrics(SM_CYSMICON), LR_DEFAULTSIZE);
+ RegisterClassEx(&wc);
+
+ /* Set display and screen-specific tooltip text */
+ if (g_pszQueryHost != NULL)
+ snprintf(szTitle,
+ sizeof(szTitle),
+ WINDOW_TITLE_XDMCP,
+ g_pszQueryHost, HostName, display, (int) pScreenInfo->dwScreen);
+ else
{
- snprintf (szTitle,
- sizeof (szTitle),
- WINDOW_TITLE,
- HostName,
- display,
- (int) pScreenInfo->dwScreen);
+ snprintf(szTitle,
+ sizeof(szTitle),
+ WINDOW_TITLE, HostName, display, (int) pScreenInfo->dwScreen);
}
- /* Create the window */
- *phwnd = CreateWindowExA (0, /* Extended styles */
- WINDOW_CLASS, /* Class name */
- szTitle, /* Window name */
- WS_POPUP,
- iX, /* Horizontal position */
- iY, /* 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)
- {
+ /* Create the window */
+ *phwnd = CreateWindowExA(0, /* Extended styles */
+ WINDOW_CLASS, /* Class name */
+ szTitle, /* Window name */
+ WS_POPUP, iX, /* Horizontal position */
+ iY, /* 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) {
#ifdef XWIN_NATIVEGDI
case WIN_SERVER_SHADOW_GDI:
- /* Show the window */
- ShowWindow (*phwnd, SW_SHOWMAXIMIZED);
- break;
+ /* Show the window */
+ ShowWindow(*phwnd, SW_SHOWMAXIMIZED);
+ break;
#endif
default:
- /* Hide the window */
- ShowWindow (*phwnd, SW_SHOWNORMAL);
- break;
+ /* Hide the window */
+ ShowWindow(*phwnd, SW_SHOWNORMAL);
+ break;
}
- /* Send first paint message */
- UpdateWindow (*phwnd);
+ /* Send first paint message */
+ UpdateWindow(*phwnd);
- /* Attempt to bring our window to the top of the display */
- BringWindowToTop (*phwnd);
+ /* Attempt to bring our window to the top of the display */
+ BringWindowToTop(*phwnd);
- return TRUE;
+ return TRUE;
}
-
/*
* Create our primary Windows display window
*/
Bool
-winCreateBoundingWindowWindowed (ScreenPtr pScreen)
+winCreateBoundingWindowWindowed(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- int iWidth = pScreenInfo->dwUserWidth;
- int iHeight = pScreenInfo->dwUserHeight;
- int iPosX;
- int iPosY;
- HWND *phwnd = &pScreenPriv->hwndScreen;
- WNDCLASSEX wc;
- RECT rcClient, rcWorkArea;
- DWORD dwWindowStyle;
- BOOL fForceShowWindow = FALSE;
- char szTitle[256];
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ int iWidth = pScreenInfo->dwUserWidth;
+ int iHeight = pScreenInfo->dwUserHeight;
+ int iPosX;
+ int iPosY;
+ HWND *phwnd = &pScreenPriv->hwndScreen;
+ WNDCLASSEX wc;
+ RECT rcClient, rcWorkArea;
+ DWORD dwWindowStyle;
+ BOOL fForceShowWindow = FALSE;
+ char szTitle[256];
char HostName[256];
gethostname(HostName,256);
-
- winDebug ("winCreateBoundingWindowWindowed - User w: %d h: %d\n",
- (int) pScreenInfo->dwUserWidth, (int) pScreenInfo->dwUserHeight);
- winDebug ("winCreateBoundingWindowWindowed - Current w: %d h: %d\n",
- (int) pScreenInfo->dwWidth, (int) pScreenInfo->dwHeight);
- /* Set the common window style flags */
- dwWindowStyle = WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX;
-
- /* Decorated or undecorated window */
- if (pScreenInfo->fDecoration
+ winDebug("winCreateBoundingWindowWindowed - User w: %d h: %d\n",
+ (int) pScreenInfo->dwUserWidth, (int) pScreenInfo->dwUserHeight);
+ winDebug("winCreateBoundingWindowWindowed - Current w: %d h: %d\n",
+ (int) pScreenInfo->dwWidth, (int) pScreenInfo->dwHeight);
+
+ /* Set the common window style flags */
+ dwWindowStyle = WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX;
+
+ /* Decorated or undecorated window */
+ if (pScreenInfo->fDecoration
#ifdef XWIN_MULTIWINDOWEXTWM
- && !pScreenInfo->fMWExtWM
+ && !pScreenInfo->fMWExtWM
#endif
- && !pScreenInfo->fRootless
+ && !pScreenInfo->fRootless
#ifdef XWIN_MULTIWINDOW
- && !pScreenInfo->fMultiWindow
+ && !pScreenInfo->fMultiWindow
#endif
- )
- {
+ ) {
/* Try to handle startup via run.exe. run.exe instructs Windows to
* hide all created windows. Detect this case and make sure the
* window is shown nevertheless */
- STARTUPINFO startupInfo;
+ STARTUPINFO startupInfo;
+
GetStartupInfo(&startupInfo);
- if (startupInfo.dwFlags & STARTF_USESHOWWINDOW &&
- startupInfo.wShowWindow == SW_HIDE)
- {
- fForceShowWindow = TRUE;
- }
+ if (startupInfo.dwFlags & STARTF_USESHOWWINDOW &&
+ startupInfo.wShowWindow == SW_HIDE) {
+ fForceShowWindow = TRUE;
+ }
dwWindowStyle |= WS_CAPTION;
if (pScreenInfo->iResizeMode != notAllowed)
dwWindowStyle |= WS_THICKFRAME | WS_MAXIMIZEBOX;
}
- else
- dwWindowStyle |= WS_POPUP;
-
- /* Setup our window class */
- wc.cbSize=sizeof(WNDCLASSEX);
- wc.style = CS_HREDRAW | CS_VREDRAW;
- wc.lpfnWndProc = winWindowProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = g_hInstance;
- wc.hIcon = (HICON)LoadImage (g_hInstance, MAKEINTRESOURCE(IDI_XWIN), IMAGE_ICON,
- GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), 0);
- wc.hCursor = 0;
- wc.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
- wc.lpszMenuName = NULL;
- wc.lpszClassName = WINDOW_CLASS;
- wc.hIconSm = (HICON)LoadImage (g_hInstance, MAKEINTRESOURCE(IDI_XWIN), IMAGE_ICON,
- GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTSIZE);
- RegisterClassEx (&wc);
-
- /* Get size of work area */
- winGetWorkArea (&rcWorkArea, pScreenInfo);
-
- /* Adjust for auto-hide taskbars */
- winAdjustForAutoHide (&rcWorkArea, pScreenInfo);
-
- /* Did the user specify a position? */
- if (pScreenInfo->fUserGavePosition)
- {
- iPosX = pScreenInfo->dwInitialX;
- iPosY = pScreenInfo->dwInitialY;
+ else
+ dwWindowStyle |= WS_POPUP;
+
+ /* Setup our window class */
+ wc.cbSize = sizeof(WNDCLASSEX);
+ wc.style = CS_HREDRAW | CS_VREDRAW;
+ wc.lpfnWndProc = winWindowProc;
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 0;
+ wc.hInstance = g_hInstance;
+ wc.hIcon =
+ (HICON) LoadImage(g_hInstance, MAKEINTRESOURCE(IDI_XWIN), IMAGE_ICON,
+ GetSystemMetrics(SM_CXICON),
+ GetSystemMetrics(SM_CYICON), 0);
+ wc.hCursor = 0;
+ wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
+ wc.lpszMenuName = NULL;
+ wc.lpszClassName = WINDOW_CLASS;
+ wc.hIconSm =
+ (HICON) LoadImage(g_hInstance, MAKEINTRESOURCE(IDI_XWIN), IMAGE_ICON,
+ GetSystemMetrics(SM_CXSMICON),
+ GetSystemMetrics(SM_CYSMICON), LR_DEFAULTSIZE);
+ RegisterClassEx(&wc);
+
+ /* Get size of work area */
+ winGetWorkArea(&rcWorkArea, pScreenInfo);
+
+ /* Adjust for auto-hide taskbars */
+ winAdjustForAutoHide (&rcWorkArea, pScreenInfo);
+
+ /* Did the user specify a position? */
+ if (pScreenInfo->fUserGavePosition) {
+ iPosX = pScreenInfo->dwInitialX;
+ iPosY = pScreenInfo->dwInitialY;
}
- else
- {
- iPosX = rcWorkArea.left;
- iPosY = rcWorkArea.top;
+ else {
+ iPosX = rcWorkArea.left;
+ iPosY = rcWorkArea.top;
}
- /* Clean up the scrollbars flag, if necessary */
- if ((!pScreenInfo->fDecoration
+ /* Clean up the scrollbars flag, if necessary */
+ if ((!pScreenInfo->fDecoration
#ifdef XWIN_MULTIWINDOWEXTWM
- || pScreenInfo->fMWExtWM
+ || pScreenInfo->fMWExtWM
#endif
- || pScreenInfo->fRootless
+ || pScreenInfo->fRootless
#ifdef XWIN_MULTIWINDOW
- || pScreenInfo->fMultiWindow
+ || pScreenInfo->fMultiWindow
#endif
- )
- && (pScreenInfo->iResizeMode == resizeWithScrollbars))
- {
- /* We cannot have scrollbars if we do not have a window border */
- pScreenInfo->iResizeMode = notAllowed;
+ )
+ && (pScreenInfo->iResizeMode == resizeWithScrollbars)) {
+ /* We cannot have scrollbars if we do not have a window border */
+ pScreenInfo->iResizeMode = notAllowed;
}
- /* Did the user specify a height and width? */
- if (pScreenInfo->fUserGaveHeightAndWidth)
- {
- /* User gave a desired height and width, try to accomodate */
- winDebug ("winCreateBoundingWindowWindowed - User gave height "
- "and width\n");
-
- /* Adjust the window width and height for borders and title bar */
- if (pScreenInfo->fDecoration
+ /* Did the user specify a height and width? */
+ if (pScreenInfo->fUserGaveHeightAndWidth) {
+ /* User gave a desired height and width, try to accomodate */
+ winDebug("winCreateBoundingWindowWindowed - User gave height "
+ "and width\n");
+
+ /* Adjust the window width and height for borders and title bar */
+ if (pScreenInfo->fDecoration
#ifdef XWIN_MULTIWINDOWEXTWM
- && !pScreenInfo->fMWExtWM
+ && !pScreenInfo->fMWExtWM
#endif
- && !pScreenInfo->fRootless
+ && !pScreenInfo->fRootless
#ifdef XWIN_MULTIWINDOW
- && !pScreenInfo->fMultiWindow
+ && !pScreenInfo->fMultiWindow
#endif
- )
- {
- winDebug ("winCreateBoundingWindowWindowed - Window has decoration\n");
-
- /* Are we resizable */
- if (pScreenInfo->iResizeMode != notAllowed)
- {
- winDebug ("winCreateBoundingWindowWindowed - Window is resizable\n");
-
- iWidth += 2 * GetSystemMetrics (SM_CXSIZEFRAME);
- iHeight += 2 * GetSystemMetrics (SM_CYSIZEFRAME)
- + GetSystemMetrics (SM_CYCAPTION);
- }
- else
- {
- winDebug ("winCreateBoundingWindowWindowed - Window is not resizable\n");
-
- iWidth += 2 * GetSystemMetrics (SM_CXFIXEDFRAME);
- iHeight += 2 * GetSystemMetrics (SM_CYFIXEDFRAME)
- + GetSystemMetrics (SM_CYCAPTION);
- }
- }
+ ) {
+ winDebug
+ ("winCreateBoundingWindowWindowed - Window has decoration\n");
+
+ /* Are we resizable */
+ if (pScreenInfo->iResizeMode != notAllowed) {
+ winDebug
+ ("winCreateBoundingWindowWindowed - Window is resizable\n");
+
+ iWidth += 2 * GetSystemMetrics(SM_CXSIZEFRAME);
+ iHeight += 2 * GetSystemMetrics(SM_CYSIZEFRAME)
+ + GetSystemMetrics(SM_CYCAPTION);
+ }
+ else {
+ winDebug
+ ("winCreateBoundingWindowWindowed - Window is not resizable\n");
+
+ iWidth += 2 * GetSystemMetrics(SM_CXFIXEDFRAME);
+ iHeight += 2 * GetSystemMetrics(SM_CYFIXEDFRAME)
+ + GetSystemMetrics(SM_CYCAPTION);
+ }
+ }
}
- else
- {
- /* By default, we are creating a window that is as large as possible */
- winDebug ("winCreateBoundingWindowWindowed - User did not give "
- "height and width\n");
- /* Defaults are wrong if we have multiple monitors */
- if (pScreenInfo->fMultipleMonitors)
- {
- iWidth = GetSystemMetrics (SM_CXVIRTUALSCREEN);
- iHeight = GetSystemMetrics (SM_CYVIRTUALSCREEN);
- }
+ else {
+ /* By default, we are creating a window that is as large as possible */
+ winDebug("winCreateBoundingWindowWindowed - User did not give "
+ "height and width\n");
+ /* Defaults are wrong if we have multiple monitors */
+ if (pScreenInfo->fMultipleMonitors) {
+ iWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN);
+ iHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN);
+ }
}
- /* Make sure window is no bigger than work area */
- if (TRUE
+ /* Make sure window is no bigger than work area */
+ if (TRUE
#ifdef XWIN_MULTIWINDOWEXTWM
- && !pScreenInfo->fMWExtWM
+ && !pScreenInfo->fMWExtWM
#endif
#ifdef XWIN_MULTIWINDOW
- && !pScreenInfo->fMultiWindow
+ && !pScreenInfo->fMultiWindow
#endif
- )
- {
- /* Trim window width to fit work area */
- if (iWidth > (rcWorkArea.right - rcWorkArea.left))
- iWidth = rcWorkArea.right - rcWorkArea.left;
-
- /* Trim window height to fit work area */
- if (iHeight >= (rcWorkArea.bottom - rcWorkArea.top))
- iHeight = rcWorkArea.bottom - rcWorkArea.top;
-
- winDebug ("winCreateBoundingWindowWindowed - Adjusted width: %d "\
- "height: %d\n",
- iWidth, iHeight);
+ ) {
+ /* Trim window width to fit work area */
+ if (iWidth > (rcWorkArea.right - rcWorkArea.left))
+ iWidth = rcWorkArea.right - rcWorkArea.left;
+
+ /* Trim window height to fit work area */
+ if (iHeight >= (rcWorkArea.bottom - rcWorkArea.top))
+ iHeight = rcWorkArea.bottom - rcWorkArea.top;
+
+ winDebug("winCreateBoundingWindowWindowed - Adjusted width: %d "
+ "height: %d\n", iWidth, iHeight);
}
- /* Set display and screen-specific tooltip text */
- if (g_pszQueryHost != NULL)
- snprintf (szTitle,
- sizeof (szTitle),
- WINDOW_TITLE_XDMCP,
- g_pszQueryHost,
- HostName,
- display,
- (int) pScreenInfo->dwScreen);
- else
+ /* Set display and screen-specific tooltip text */
+ if (g_pszQueryHost != NULL)
+ snprintf(szTitle,
+ sizeof(szTitle),
+ WINDOW_TITLE_XDMCP,
+ g_pszQueryHost, HostName, display, (int) pScreenInfo->dwScreen);
+ else
{
- snprintf (szTitle,
- sizeof (szTitle),
- WINDOW_TITLE,
- HostName,
- display,
- (int) pScreenInfo->dwScreen);
+ snprintf(szTitle,
+ sizeof(szTitle),
+ WINDOW_TITLE, HostName, display, (int) pScreenInfo->dwScreen);
}
- /* Create the window */
- *phwnd = CreateWindowExA (0, /* Extended styles */
- WINDOW_CLASS, /* Class name */
- szTitle, /* Window name */
- dwWindowStyle,
- iPosX, /* Horizontal position */
- iPosY, /* 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 */
- if (*phwnd == NULL)
- {
- ErrorF ("winCreateBoundingWindowWindowed - CreateWindowEx () failed\n");
- return FALSE;
+ /* Create the window */
+ *phwnd = CreateWindowExA(0, /* Extended styles */
+ WINDOW_CLASS, /* Class name */
+ szTitle, /* Window name */
+ dwWindowStyle, iPosX, /* Horizontal position */
+ iPosY, /* 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 */
+ if (*phwnd == NULL) {
+ ErrorF("winCreateBoundingWindowWindowed - CreateWindowEx () failed\n");
+ return FALSE;
}
- winDebug ("winCreateBoundingWindowWindowed - CreateWindowEx () returned\n");
+ winDebug("winCreateBoundingWindowWindowed - CreateWindowEx () returned\n");
- if (fForceShowWindow)
- {
- ErrorF("winCreateBoundingWindowWindowed - Setting normal windowstyle\n");
- ShowWindow(*phwnd, SW_SHOW);
- }
+ if (fForceShowWindow) {
+ ErrorF
+ ("winCreateBoundingWindowWindowed - Setting normal windowstyle\n");
+ ShowWindow(*phwnd, SW_SHOW);
+ }
- /* Get the client area coordinates */
- if (!GetClientRect (*phwnd, &rcClient))
- {
- ErrorF ("winCreateBoundingWindowWindowed - GetClientRect () "
- "failed\n");
- return FALSE;
+ /* Get the client area coordinates */
+ if (!GetClientRect(*phwnd, &rcClient)) {
+ ErrorF("winCreateBoundingWindowWindowed - GetClientRect () "
+ "failed\n");
+ return FALSE;
}
- winDebug ("winCreateBoundingWindowWindowed - WindowClient "
- "w %ld h %ld r %ld l %ld b %ld t %ld\n",
- rcClient.right - rcClient.left,
- rcClient.bottom - rcClient.top,
- rcClient.right, rcClient.left,
- rcClient.bottom, rcClient.top);
-
- /* We adjust the visual size if the user did not specify it */
- if (!((pScreenInfo->iResizeMode == resizeWithScrollbars) && pScreenInfo->fUserGaveHeightAndWidth))
- {
- /*
- * User did not give a height and width with scrollbars enabled,
- * so we will resize the underlying visual to be as large as
- * the initial view port (page size). This way scrollbars will
- * not appear until the user shrinks the window, if they ever do.
- *
- * NOTE: We have to store the viewport size here because
- * the user may have an autohide taskbar, which would
- * cause the viewport size to be one less in one dimension
- * than the viewport size that we calculated by subtracting
- * the size of the borders and caption.
- */
- pScreenInfo->dwWidth = rcClient.right - rcClient.left;
- pScreenInfo->dwHeight = rcClient.bottom - rcClient.top;
+ winDebug("winCreateBoundingWindowWindowed - WindowClient "
+ "w %ld h %ld r %ld l %ld b %ld t %ld\n",
+ rcClient.right - rcClient.left,
+ rcClient.bottom - rcClient.top,
+ rcClient.right, rcClient.left, rcClient.bottom, rcClient.top);
+
+ /* We adjust the visual size if the user did not specify it */
+ if (!
+ ((pScreenInfo->iResizeMode == resizeWithScrollbars) &&
+ pScreenInfo->fUserGaveHeightAndWidth)) {
+ /*
+ * User did not give a height and width with scrollbars enabled,
+ * so we will resize the underlying visual to be as large as
+ * the initial view port (page size). This way scrollbars will
+ * not appear until the user shrinks the window, if they ever do.
+ *
+ * NOTE: We have to store the viewport size here because
+ * the user may have an autohide taskbar, which would
+ * cause the viewport size to be one less in one dimension
+ * than the viewport size that we calculated by subtracting
+ * the size of the borders and caption.
+ */
+ pScreenInfo->dwWidth = rcClient.right - rcClient.left;
+ pScreenInfo->dwHeight = rcClient.bottom - rcClient.top;
}
#if 0
- /*
- * NOTE: For the uninitiated, the page size is the number of pixels
- * that we can display in the x or y direction at a time and the
- * range is the total number of pixels in the x or y direction that we
- * have available to display. In other words, the page size is the
- * size of the window area minus the space the caption, borders, and
- * scrollbars (if any) occupy, and the range is the size of the
- * underlying X visual. Notice that, contrary to what some of the
- * MSDN Library arcticles lead you to believe, the windows
- * ``client area'' size does not include the scrollbars. In other words,
- * the whole client area size that is reported to you is drawable by
- * you; you do not have to subtract the size of the scrollbars from
- * the client area size, and if you did it would result in the size
- * of the scrollbars being double counted.
- */
-
- /* Setup scrollbar page and range, if scrollbars are enabled */
- if (pScreenInfo->fScrollbars)
- {
- SCROLLINFO si;
-
- /* Initialize the scrollbar info structure */
- si.cbSize = sizeof (si);
- si.fMask = SIF_RANGE | SIF_PAGE;
- si.nMin = 0;
-
- /* Setup the width range and page size */
- si.nMax = pScreenInfo->dwWidth - 1;
- si.nPage = rcClient.right - rcClient.left;
- winDebug ("winCreateBoundingWindowWindowed - HORZ nMax: %d nPage :%d\n",
- si.nMax, si.nPage);
- SetScrollInfo (*phwnd, SB_HORZ, &si, TRUE);
-
- /* Setup the height range and page size */
- si.nMax = pScreenInfo->dwHeight - 1;
- si.nPage = rcClient.bottom - rcClient.top;
- winDebug ("winCreateBoundingWindowWindowed - VERT nMax: %d nPage :%d\n",
- si.nMax, si.nPage);
- SetScrollInfo (*phwnd, SB_VERT, &si, TRUE);
+ /*
+ * NOTE: For the uninitiated, the page size is the number of pixels
+ * that we can display in the x or y direction at a time and the
+ * range is the total number of pixels in the x or y direction that we
+ * have available to display. In other words, the page size is the
+ * size of the window area minus the space the caption, borders, and
+ * scrollbars (if any) occupy, and the range is the size of the
+ * underlying X visual. Notice that, contrary to what some of the
+ * MSDN Library arcticles lead you to believe, the windows
+ * ``client area'' size does not include the scrollbars. In other words,
+ * the whole client area size that is reported to you is drawable by
+ * you; you do not have to subtract the size of the scrollbars from
+ * the client area size, and if you did it would result in the size
+ * of the scrollbars being double counted.
+ */
+
+ /* Setup scrollbar page and range, if scrollbars are enabled */
+ if (pScreenInfo->fScrollbars) {
+ SCROLLINFO si;
+
+ /* Initialize the scrollbar info structure */
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_RANGE | SIF_PAGE;
+ si.nMin = 0;
+
+ /* Setup the width range and page size */
+ si.nMax = pScreenInfo->dwWidth - 1;
+ si.nPage = rcClient.right - rcClient.left;
+ winDebug("winCreateBoundingWindowWindowed - HORZ nMax: %d nPage :%d\n",
+ si.nMax, si.nPage);
+ SetScrollInfo(*phwnd, SB_HORZ, &si, TRUE);
+
+ /* Setup the height range and page size */
+ si.nMax = pScreenInfo->dwHeight - 1;
+ si.nPage = rcClient.bottom - rcClient.top;
+ winDebug("winCreateBoundingWindowWindowed - VERT nMax: %d nPage :%d\n",
+ si.nMax, si.nPage);
+ SetScrollInfo(*phwnd, SB_VERT, &si, TRUE);
}
#endif
- /* Show the window */
- if (FALSE
+ /* Show the window */
+ if (FALSE
#ifdef XWIN_MULTIWINDOWEXTWM
- || pScreenInfo->fMWExtWM
+ || pScreenInfo->fMWExtWM
#endif
#ifdef XWIN_MULTIWINDOW
- || pScreenInfo->fMultiWindow
+ || pScreenInfo->fMultiWindow
#endif
- )
- {
+ ) {
#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
- pScreenPriv->fRootWindowShown = FALSE;
+ pScreenPriv->fRootWindowShown = FALSE;
#endif
- ShowWindow (*phwnd, SW_HIDE);
+ ShowWindow(*phwnd, SW_HIDE);
}
- else
- ShowWindow (*phwnd, SW_SHOWNORMAL);
- if (!UpdateWindow (*phwnd))
- {
- ErrorF ("winCreateBoundingWindowWindowed - UpdateWindow () failed\n");
- return FALSE;
+ else
+ ShowWindow(*phwnd, SW_SHOWNORMAL);
+ if (!UpdateWindow(*phwnd)) {
+ ErrorF("winCreateBoundingWindowWindowed - UpdateWindow () failed\n");
+ return FALSE;
}
-
- /* Attempt to bring our window to the top of the display */
- if (TRUE
+
+ /* Attempt to bring our window to the top of the display */
+ if (TRUE
#ifdef XWIN_MULTIWINDOWEXTWM
- && !pScreenInfo->fMWExtWM
+ && !pScreenInfo->fMWExtWM
#endif
- && !pScreenInfo->fRootless
+ && !pScreenInfo->fRootless
#ifdef XWIN_MULTIWINDOW
- && !pScreenInfo->fMultiWindow
+ && !pScreenInfo->fMultiWindow
#endif
- )
- {
- if (!BringWindowToTop (*phwnd))
- {
- ErrorF ("winCreateBoundingWindowWindowed - BringWindowToTop () "
- "failed\n");
- return FALSE;
- }
+ ) {
+ if (!BringWindowToTop(*phwnd)) {
+ ErrorF("winCreateBoundingWindowWindowed - BringWindowToTop () "
+ "failed\n");
+ return FALSE;
+ }
}
#ifdef XWIN_NATIVEGDI
- /* Paint window background blue */
- if (pScreenInfo->dwEngine == WIN_SERVER_NATIVE_GDI)
- winPaintBackground (*phwnd, RGB (0x00, 0x00, 0xFF));
+ /* Paint window background blue */
+ if (pScreenInfo->dwEngine == WIN_SERVER_NATIVE_GDI)
+ winPaintBackground(*phwnd, RGB(0x00, 0x00, 0xFF));
#endif
- winDebug ("winCreateBoundingWindowWindowed - Returning\n");
+ winDebug("winCreateBoundingWindowWindowed - Returning\n");
- return TRUE;
+ return TRUE;
}
-
/*
* Find the work area of all attached monitors
*/
static Bool
-winGetWorkArea (RECT *prcWorkArea, winScreenInfo *pScreenInfo)
+winGetWorkArea(RECT * prcWorkArea, winScreenInfo * pScreenInfo)
{
- int iPrimaryWidth, iPrimaryHeight;
- int iWidth, iHeight;
- int iLeft, iTop;
- int iPrimaryNonWorkAreaWidth, iPrimaryNonWorkAreaHeight;
+ int iPrimaryWidth, iPrimaryHeight;
+ int iWidth, iHeight;
+ int iLeft, iTop;
+ int iPrimaryNonWorkAreaWidth, iPrimaryNonWorkAreaHeight;
/* Use GetMonitorInfo to get work area for monitor */
if (!pScreenInfo->fMultipleMonitors)
@@ -534,62 +508,59 @@ winGetWorkArea (RECT *prcWorkArea, winScreenInfo *pScreenInfo)
ErrorF ("winGetWorkArea - GetMonitorInfo() failed for monitor %d\n", pScreenInfo->iMonitor);
}
- /* Bail out here if we aren't using multiple monitors */
- return TRUE;
+ /* Bail out here if we aren't using multiple monitors */
+ return TRUE;
}
/* SPI_GETWORKAREA only gets the work area of the primary screen. */
SystemParametersInfo (SPI_GETWORKAREA, 0, prcWorkArea, 0);
winDebug ("winGetWorkArea - Primary Monitor WorkArea: %d %d %d %d\n",
- (int) prcWorkArea->top, (int) prcWorkArea->left,
- (int) prcWorkArea->bottom, (int) prcWorkArea->right);
+ (int) prcWorkArea->top, (int) prcWorkArea->left,
+ (int) prcWorkArea->bottom, (int) prcWorkArea->right);
- /* Get size of full virtual screen */
- iWidth = GetSystemMetrics (SM_CXVIRTUALSCREEN);
- iHeight = GetSystemMetrics (SM_CYVIRTUALSCREEN);
+ /* Get size of full virtual screen */
+ iWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN);
+ iHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN);
- winDebug ("winGetWorkArea - Virtual screen is %d x %d\n", iWidth, iHeight);
+ winDebug("winGetWorkArea - Virtual screen is %d x %d\n", iWidth, iHeight);
- /* Get origin of full virtual screen */
- iLeft = GetSystemMetrics (SM_XVIRTUALSCREEN);
- iTop = GetSystemMetrics (SM_YVIRTUALSCREEN);
+ /* Get origin of full virtual screen */
+ iLeft = GetSystemMetrics(SM_XVIRTUALSCREEN);
+ iTop = GetSystemMetrics(SM_YVIRTUALSCREEN);
- winDebug ("winGetWorkArea - Virtual screen origin is %d, %d\n", iLeft, iTop);
-
- /* Get size of primary screen */
- iPrimaryWidth = GetSystemMetrics (SM_CXSCREEN);
- iPrimaryHeight = GetSystemMetrics (SM_CYSCREEN);
+ winDebug("winGetWorkArea - Virtual screen origin is %d, %d\n", iLeft, iTop);
- winDebug ("winGetWorkArea - Primary screen is %d x %d\n",
- iPrimaryWidth, iPrimaryHeight);
-
- /* Work out how much of the primary screen we aren't using */
- iPrimaryNonWorkAreaWidth = iPrimaryWidth - (prcWorkArea->right -
- prcWorkArea->left);
- iPrimaryNonWorkAreaHeight = iPrimaryHeight - (prcWorkArea->bottom
- - prcWorkArea->top);
-
- /* Update the rectangle to include all monitors */
- if (iLeft < 0)
- {
- prcWorkArea->left = iLeft;
+ /* Get size of primary screen */
+ iPrimaryWidth = GetSystemMetrics(SM_CXSCREEN);
+ iPrimaryHeight = GetSystemMetrics(SM_CYSCREEN);
+
+ winDebug("winGetWorkArea - Primary screen is %d x %d\n",
+ iPrimaryWidth, iPrimaryHeight);
+
+ /* Work out how much of the primary screen we aren't using */
+ iPrimaryNonWorkAreaWidth = iPrimaryWidth - (prcWorkArea->right -
+ prcWorkArea->left);
+ iPrimaryNonWorkAreaHeight = iPrimaryHeight - (prcWorkArea->bottom
+ - prcWorkArea->top);
+
+ /* Update the rectangle to include all monitors */
+ if (iLeft < 0) {
+ prcWorkArea->left = iLeft;
}
- if (iTop < 0)
- {
- prcWorkArea->top = iTop;
+ if (iTop < 0) {
+ prcWorkArea->top = iTop;
}
- prcWorkArea->right = prcWorkArea->left + iWidth -
- iPrimaryNonWorkAreaWidth;
- prcWorkArea->bottom = prcWorkArea->top + iHeight -
- iPrimaryNonWorkAreaHeight;
-
- winDebug ("winGetWorkArea - Adjusted WorkArea for multiple "
- "monitors: %d %d %d %d\n",
- (int) prcWorkArea->top, (int) prcWorkArea->left,
- (int) prcWorkArea->bottom, (int) prcWorkArea->right);
-
- return TRUE;
+ prcWorkArea->right = prcWorkArea->left + iWidth - iPrimaryNonWorkAreaWidth;
+ prcWorkArea->bottom = prcWorkArea->top + iHeight -
+ iPrimaryNonWorkAreaHeight;
+
+ winDebug("winGetWorkArea - Adjusted WorkArea for multiple "
+ "monitors: %d %d %d %d\n",
+ (int) prcWorkArea->top, (int) prcWorkArea->left,
+ (int) prcWorkArea->bottom, (int) prcWorkArea->right);
+
+ return TRUE;
}
static Bool
@@ -614,7 +585,6 @@ winTaskbarOnScreenEdge(unsigned int uEdge, winScreenInfo *pScreenInfo)
}
return FALSE;
}
-
/*
* Adjust the client area so that any auto-hide toolbars
* will work correctly.
@@ -623,54 +593,50 @@ winTaskbarOnScreenEdge(unsigned int uEdge, winScreenInfo *pScreenInfo)
static Bool
winAdjustForAutoHide (RECT *prcWorkArea, winScreenInfo *pScreenInfo)
{
- APPBARDATA abd;
+ APPBARDATA abd;
- winDebug ("winAdjustForAutoHide - Original WorkArea: %d %d %d %d\n",
- (int) prcWorkArea->top, (int) prcWorkArea->left,
- (int) prcWorkArea->bottom, (int) prcWorkArea->right);
+ winDebug("winAdjustForAutoHide - Original WorkArea: %d %d %d %d\n",
+ (int) prcWorkArea->top, (int) prcWorkArea->left,
+ (int) prcWorkArea->bottom, (int) prcWorkArea->right);
- /* Find out if the Windows taskbar is set to auto-hide */
- ZeroMemory (&abd, sizeof (abd));
- abd.cbSize = sizeof (abd);
- if (SHAppBarMessage (ABM_GETSTATE, &abd) & ABS_AUTOHIDE)
- winDebug ("winAdjustForAutoHide - Taskbar is auto hide\n");
+ /* Find out if the Windows taskbar is set to auto-hide */
+ ZeroMemory(&abd, sizeof(abd));
+ abd.cbSize = sizeof(abd);
+ if (SHAppBarMessage(ABM_GETSTATE, &abd) & ABS_AUTOHIDE)
+ winDebug("winAdjustForAutoHide - Taskbar is auto hide\n");
/*
Despite the forgoing, we are checking for any AppBar
hiding along a monitor edge, not just the Windows TaskBar.
*/
- /* Look for a TOP auto-hide taskbar */
- if (winTaskbarOnScreenEdge(ABE_TOP, pScreenInfo))
- {
- winDebug ("winAdjustForAutoHide - Found TOP auto-hide taskbar\n");
- prcWorkArea->top += 1;
+ /* Look for a TOP auto-hide taskbar */
+ if (winTaskbarOnScreenEdge(ABE_TOP, pScreenInfo)) {
+ winDebug("winAdjustForAutoHide - Found TOP auto-hide taskbar\n");
+ prcWorkArea->top += 1;
}
- /* Look for a LEFT auto-hide taskbar */
- if (winTaskbarOnScreenEdge(ABE_LEFT, pScreenInfo))
- {
- winDebug ("winAdjustForAutoHide - Found LEFT auto-hide taskbar\n");
- prcWorkArea->left += 1;
+ /* Look for a LEFT auto-hide taskbar */
+ if (winTaskbarOnScreenEdge(ABE_LEFT, pScreenInfo)) {
+ winDebug("winAdjustForAutoHide - Found LEFT auto-hide taskbar\n");
+ prcWorkArea->left += 1;
}
- /* Look for a BOTTOM auto-hide taskbar */
- if (winTaskbarOnScreenEdge(ABE_BOTTOM, pScreenInfo))
- {
- winDebug ("winAdjustForAutoHide - Found BOTTOM auto-hide taskbar\n");
- prcWorkArea->bottom -= 1;
+ /* Look for a BOTTOM auto-hide taskbar */
+ if (winTaskbarOnScreenEdge(ABE_BOTTOM, pScreenInfo)) {
+ winDebug("winAdjustForAutoHide - Found BOTTOM auto-hide taskbar\n");
+ prcWorkArea->bottom -= 1;
}
- /* Look for a RIGHT auto-hide taskbar */
- if (winTaskbarOnScreenEdge(ABE_RIGHT, pScreenInfo))
- {
- winDebug ("winAdjustForAutoHide - Found RIGHT auto-hide taskbar\n");
- prcWorkArea->right -= 1;
+ /* Look for a RIGHT auto-hide taskbar */
+ if (winTaskbarOnScreenEdge(ABE_RIGHT, pScreenInfo)) {
+ winDebug("winAdjustForAutoHide - Found RIGHT auto-hide taskbar\n");
+ prcWorkArea->right -= 1;
}
- winDebug ("winAdjustForAutoHide - Adjusted WorkArea: %d %d %d %d\n",
- (int) prcWorkArea->top, (int) prcWorkArea->left,
- (int) prcWorkArea->bottom, (int) prcWorkArea->right);
+ winDebug("winAdjustForAutoHide - Adjusted WorkArea: %d %d %d %d\n",
+ (int) prcWorkArea->top, (int) prcWorkArea->left,
+ (int) prcWorkArea->bottom, (int) prcWorkArea->right);
- return TRUE;
+ return TRUE;
}
diff --git a/xorg-server/hw/xwin/wincursor.c b/xorg-server/hw/xwin/wincursor.c
index 3cae2361b..8f4130207 100644
--- a/xorg-server/hw/xwin/wincursor.c
+++ b/xorg-server/hw/xwin/wincursor.c
@@ -1,628 +1,613 @@
-/*
- *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, sublicense, and/or sell copies of the Software, and to
- *permit persons to whom the Software is furnished to do so, subject to
- *the following conditions:
- *
- *The above copyright notice and this permission notice shall be
- *included in all copies or substantial portions of the Software.
- *
- *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
- *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *Except as contained in this notice, the name of the XFree86 Project
- *shall not be used in advertising or otherwise to promote the sale, use
- *or other dealings in this Software without prior written authorization
- *from the XFree86 Project.
- *
- * Authors: Dakshinamurthy Karra
- * Suhaib M Siddiqi
- * Peter Busch
- * Harold L Hunt II
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-#include "winmsg.h"
-#include <cursorstr.h>
-#include <mipointrst.h>
-#include <servermd.h>
-#include "misc.h"
-
-#define BRIGHTNESS(x) (x##Red * 0.299 + x##Green * 0.587 + x##Blue * 0.114)
-
-#ifdef _MSC_VER
-#define min(a,b) (((a) < (b)) ? (a) : (b))
-#define max(a,b) (((a) > (b)) ? (a) : (b))
-#endif
-
-/*
- * Local function prototypes
- */
-
-static void
-winPointerWarpCursor (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y);
-
-static Bool
-winCursorOffScreen (ScreenPtr *ppScreen, int *x, int *y);
-
-static void
-winCrossScreen (ScreenPtr pScreen, Bool fEntering);
-
-miPointerScreenFuncRec g_winPointerCursorFuncs =
-{
- winCursorOffScreen,
- winCrossScreen,
- winPointerWarpCursor
-};
-
-
-static void
-winPointerWarpCursor (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
-{
- winScreenPriv(pScreen);
- RECT rcClient;
- static Bool s_fInitialWarp = TRUE;
-
- /* Discard first warp call */
- if (s_fInitialWarp)
- {
- /* First warp moves mouse to center of window, just ignore it */
-
- /* Don't ignore subsequent warps */
- s_fInitialWarp = FALSE;
-
- winDebug ("winPointerWarpCursor - Discarding first warp: %d %d\n",
- x, y);
-
- return;
- }
-
- /*
- Only update the Windows cursor position if root window is active,
- or we are in a rootless mode
- */
- if ((pScreenPriv->hwndScreen == GetForegroundWindow ())
- || pScreenPriv->pScreenInfo->fRootless
-#ifdef XWIN_MULTIWINDOW
- || pScreenPriv->pScreenInfo->fMultiWindow
-#endif
- )
- {
- /* Get the client area coordinates */
- GetClientRect (pScreenPriv->hwndScreen, &rcClient);
-
- /* Translate the client area coords to screen coords */
- MapWindowPoints (pScreenPriv->hwndScreen,
- HWND_DESKTOP,
- (LPPOINT)&rcClient,
- 2);
-
- /*
- * Update the Windows cursor position so that we don't
- * immediately warp back to the current position.
- */
- SetCursorPos (rcClient.left + x, rcClient.top + y);
- }
-
- /* Call the mi warp procedure to do the actual warping in X. */
- miPointerWarpCursor (pDev, pScreen, x, y);
-}
-
-static Bool
-winCursorOffScreen (ScreenPtr *ppScreen, int *x, int *y)
-{
- return FALSE;
-}
-
-static void
-winCrossScreen (ScreenPtr pScreen, Bool fEntering)
-{
-}
-
-static unsigned char
-reverse(unsigned char c)
-{
- int i;
- unsigned char ret = 0;
- for (i = 0; i < 8; ++i)
- {
- ret |= ((c >> i)&1) << (7 - i);
- }
- return ret;
-}
-
-/*
- * Convert X cursor to Windows cursor
- * FIXME: Perhaps there are more smart code
- */
-static HCURSOR
-winLoadCursor (ScreenPtr pScreen, CursorPtr pCursor, int screen)
-{
- winScreenPriv(pScreen);
- HCURSOR hCursor = NULL;
- unsigned char *pAnd;
- unsigned char *pXor;
- int nCX, nCY;
- int nBytes;
- double dForeY, dBackY;
- BOOL fReverse;
- HBITMAP hAnd, hXor;
- ICONINFO ii;
- unsigned char *pCur;
- int x, y;
- unsigned char bit;
- HDC hDC;
- BITMAPV4HEADER bi;
- BITMAPINFO *pbmi;
- unsigned long *lpBits;
-
- winDebug("winLoadCursor: Win32: %dx%d X11: %dx%d hotspot: %d,%d\n",
- pScreenPriv->cursor.sm_cx, pScreenPriv->cursor.sm_cy,
- pCursor->bits->width, pCursor->bits->height,
- pCursor->bits->xhot, pCursor->bits->yhot
- );
-
- /* We can use only White and Black, so calc brightness of color
- * Also check if the cursor is inverted */
- dForeY = BRIGHTNESS(pCursor->fore);
- dBackY = BRIGHTNESS(pCursor->back);
- fReverse = dForeY < dBackY;
-
- /* Check wether the X11 cursor is bigger than the win32 cursor */
- if (pScreenPriv->cursor.sm_cx < pCursor->bits->width ||
- pScreenPriv->cursor.sm_cy < pCursor->bits->height)
- {
- ErrorF ("winLoadCursor - Windows requires %dx%d cursor but X requires %dx%d\n",
- pScreenPriv->cursor.sm_cx, pScreenPriv->cursor.sm_cy,
- pCursor->bits->width, pCursor->bits->height);
- }
-
- /* Get the number of bytes required to store the whole cursor image
- * This is roughly (sm_cx * sm_cy) / 8
- * round up to 8 pixel boundary so we can convert whole bytes */
- nBytes = bits_to_bytes(pScreenPriv->cursor.sm_cx) * pScreenPriv->cursor.sm_cy;
-
- /* Get the effective width and height */
- nCX = min(pScreenPriv->cursor.sm_cx, pCursor->bits->width);
- nCY = min(pScreenPriv->cursor.sm_cy, pCursor->bits->height);
-
- /* Allocate memory for the bitmaps */
- pAnd = malloc (nBytes);
- memset (pAnd, 0xFF, nBytes);
- pXor = calloc (1, nBytes);
-
- /* Convert the X11 bitmap to a win32 bitmap
- * The first is for an empty mask */
- if (pCursor->bits->emptyMask)
- {
- int x, y, xmax = bits_to_bytes(nCX);
- for (y = 0; y < nCY; ++y)
- for (x = 0; x < xmax; ++x)
- {
- int nWinPix = bits_to_bytes(pScreenPriv->cursor.sm_cx) * y + x;
- int nXPix = BitmapBytePad(pCursor->bits->width) * y + x;
-
- pAnd[nWinPix] = 0;
- if (fReverse)
- pXor[nWinPix] = reverse (~pCursor->bits->source[nXPix]);
- else
- pXor[nWinPix] = reverse (pCursor->bits->source[nXPix]);
- }
- }
- else
- {
- int x, y, xmax = bits_to_bytes(nCX);
- for (y = 0; y < nCY; ++y)
- for (x = 0; x < xmax; ++x)
- {
- int nWinPix = bits_to_bytes(pScreenPriv->cursor.sm_cx) * y + x;
- int nXPix = BitmapBytePad(pCursor->bits->width) * y + x;
-
- unsigned char mask = pCursor->bits->mask[nXPix];
- pAnd[nWinPix] = reverse (~mask);
- if (fReverse)
- pXor[nWinPix] = reverse (~pCursor->bits->source[nXPix] & mask);
- else
- pXor[nWinPix] = reverse (pCursor->bits->source[nXPix] & mask);
- }
- }
-
- /* prepare the pointers */
- hCursor = NULL;
- lpBits = NULL;
-
- /* We have a truecolor alpha-blended cursor and can use it! */
- if (pCursor->bits->argb)
- {
- winDebug("winLoadCursor: Trying truecolor alphablended cursor\n");
- memset (&bi, 0, sizeof (BITMAPV4HEADER));
- bi.bV4Size = sizeof(BITMAPV4HEADER);
- bi.bV4Width = pScreenPriv->cursor.sm_cx;
- bi.bV4Height = -(pScreenPriv->cursor.sm_cy); /* right-side up */
- bi.bV4Planes = 1;
- bi.bV4BitCount = 32;
- bi.bV4V4Compression = BI_BITFIELDS;
- bi.bV4RedMask = 0x00FF0000;
- bi.bV4GreenMask = 0x0000FF00;
- bi.bV4BlueMask = 0x000000FF;
- bi.bV4AlphaMask = 0xFF000000;
-
- lpBits = (unsigned long *) calloc (pScreenPriv->cursor.sm_cx*pScreenPriv->cursor.sm_cy,
- sizeof (unsigned long));
-
- if (lpBits)
- {
- for (y=0; y<nCY; y++)
- {
- unsigned long *src, *dst;
- src = &(pCursor->bits->argb[y * pCursor->bits->width]);
- dst = &(lpBits[y * pScreenPriv->cursor.sm_cx]);
- memcpy (dst, src, 4*nCX);
- }
- }
- } /* End if-truecolor-icon */
-
- if (!lpBits)
- {
- /* Bicolor, use a palettized DIB */
- winDebug("winLoadCursor: Trying two color cursor\n");
- pbmi = (BITMAPINFO*)&bi;
- memset (pbmi, 0, sizeof (BITMAPINFOHEADER));
- pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- pbmi->bmiHeader.biWidth = pScreenPriv->cursor.sm_cx;
- pbmi->bmiHeader.biHeight = -abs(pScreenPriv->cursor.sm_cy); /* right-side up */
- pbmi->bmiHeader.biPlanes = 1;
- pbmi->bmiHeader.biBitCount = 8;
- pbmi->bmiHeader.biCompression = BI_RGB;
- pbmi->bmiHeader.biSizeImage = 0;
- pbmi->bmiHeader.biClrUsed = 3;
- pbmi->bmiHeader.biClrImportant = 3;
- pbmi->bmiColors[0].rgbRed = 0; /* Empty */
- pbmi->bmiColors[0].rgbGreen = 0;
- pbmi->bmiColors[0].rgbBlue = 0;
- pbmi->bmiColors[0].rgbReserved = 0;
- pbmi->bmiColors[1].rgbRed = pCursor->backRed>>8; /* Background */
- pbmi->bmiColors[1].rgbGreen = pCursor->backGreen>>8;
- pbmi->bmiColors[1].rgbBlue = pCursor->backBlue>>8;
- pbmi->bmiColors[1].rgbReserved = 0;
- pbmi->bmiColors[2].rgbRed = pCursor->foreRed>>8; /* Foreground */
- pbmi->bmiColors[2].rgbGreen = pCursor->foreGreen>>8;
- pbmi->bmiColors[2].rgbBlue = pCursor->foreBlue>>8;
- pbmi->bmiColors[2].rgbReserved = 0;
-
- lpBits = (unsigned long *) calloc (pScreenPriv->cursor.sm_cx*pScreenPriv->cursor.sm_cy,
- sizeof (char));
-
- pCur = (unsigned char *)lpBits;
- if (lpBits)
- {
- for (y=0; y<pScreenPriv->cursor.sm_cy; y++)
- {
- for (x=0; x<pScreenPriv->cursor.sm_cx; x++)
- {
- if (x>=nCX || y>=nCY) /* Outside of X11 icon bounds */
- (*pCur++) = 0;
- else /* Within X11 icon bounds */
- {
- int nWinPix = bits_to_bytes(pScreenPriv->cursor.sm_cx) * y + (x/8);
-
- bit = pAnd[nWinPix];
- bit = bit & (1<<(7-(x&7)));
- if (!bit) /* Within the cursor mask? */
- {
- int nXPix = BitmapBytePad(pCursor->bits->width) * y + (x/8);
- bit = ~reverse(~pCursor->bits->source[nXPix] & pCursor->bits->mask[nXPix]);
- bit = bit & (1<<(7-(x&7)));
- if (bit) /* Draw foreground */
- (*pCur++) = 2;
- else /* Draw background */
- (*pCur++) = 1;
- }
- else /* Outside the cursor mask */
- (*pCur++) = 0;
- }
- } /* end for (x) */
- } /* end for (y) */
- } /* end if (lpbits) */
- }
-
- /* If one of the previous two methods gave us the bitmap we need, make a cursor */
- if (lpBits)
- {
- winDebug("winLoadCursor: Creating bitmap cursor: hotspot %d,%d\n",
- pCursor->bits->xhot, pCursor->bits->yhot);
-
- hAnd = NULL;
- hXor = NULL;
-
- hAnd = CreateBitmap (pScreenPriv->cursor.sm_cx, pScreenPriv->cursor.sm_cy, 1, 1, pAnd);
-
- hDC = GetDC (NULL);
- if (hDC)
- {
- hXor = CreateCompatibleBitmap (hDC, pScreenPriv->cursor.sm_cx, pScreenPriv->cursor.sm_cy);
- SetDIBits (hDC, hXor, 0, pScreenPriv->cursor.sm_cy, lpBits, (BITMAPINFO*)&bi, DIB_RGB_COLORS);
- ReleaseDC (NULL, hDC);
- }
- free (lpBits);
-
-
- if (hAnd && hXor)
- {
- ii.fIcon = FALSE;
- ii.xHotspot = pCursor->bits->xhot;
- ii.yHotspot = pCursor->bits->yhot;
- ii.hbmMask = hAnd;
- ii.hbmColor = hXor;
- hCursor = (HCURSOR) CreateIconIndirect( &ii );
-
- if (hCursor == NULL)
- winW32Error("winLoadCursor - CreateIconIndirect failed:");
- else
- {
- if (GetIconInfo(hCursor, &ii))
- {
- if (ii.fIcon)
- {
- winDebug("winLoadCursor: CreateIconIndirect returned no cursor. Trying again.\n");
-
- DestroyCursor(hCursor);
-
- ii.fIcon = FALSE;
- ii.xHotspot = pCursor->bits->xhot;
- ii.yHotspot = pCursor->bits->yhot;
- hCursor = (HCURSOR) CreateIconIndirect( &ii );
-
- if (hCursor == NULL)
- winW32Error("winLoadCursor - CreateIconIndirect failed:");
- }
- /* GetIconInfo creates new bitmaps. Destroy them again */
- if (ii.hbmMask)
- DeleteObject(ii.hbmMask);
- if (ii.hbmColor)
- DeleteObject(ii.hbmColor);
- }
- }
- }
-
- if (hAnd)
- DeleteObject (hAnd);
- if (hXor)
- DeleteObject (hXor);
- }
-
- if (!hCursor)
- {
- /* We couldn't make a color cursor for this screen, use
- black and white instead */
- hCursor = CreateCursor (g_hInstance,
- pCursor->bits->xhot, pCursor->bits->yhot,
- pScreenPriv->cursor.sm_cx, pScreenPriv->cursor.sm_cy,
- pAnd, pXor);
- if (hCursor == NULL)
- winW32Error("winLoadCursor - CreateCursor failed:");
- }
- free (pAnd);
- free (pXor);
-
- return hCursor;
-}
-
-/*
-===========================================================================
-
- Pointer sprite functions
-
-===========================================================================
-*/
-
-/*
- * winRealizeCursor
- * Convert the X cursor representation to native format if possible.
- */
-static Bool
-winRealizeCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
-{
- if(pCursor == NULL || pCursor->bits == NULL)
- return FALSE;
-
- /* FIXME: cache ARGB8888 representation? */
-
- return TRUE;
-}
-
-
-/*
- * winUnrealizeCursor
- * Free the storage space associated with a realized cursor.
- */
-static Bool
-winUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
-{
- return TRUE;
-}
-
-
-/*
- * winSetCursor
- * Set the cursor sprite and position.
- */
-static void
-winSetCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, int x, int y)
-{
- POINT ptCurPos, ptTemp;
- HWND hwnd;
- RECT rcClient;
- BOOL bInhibit;
- winScreenPriv(pScreen);
- winDebug("winSetCursor: cursor=%p\n", pCursor);
-
- /* Inhibit changing the cursor if the mouse is not in a client area */
- bInhibit = FALSE;
- if (GetCursorPos (&ptCurPos))
- {
- hwnd = WindowFromPoint (ptCurPos);
- if (hwnd)
- {
- if (GetClientRect (hwnd, &rcClient))
- {
- ptTemp.x = rcClient.left;
- ptTemp.y = rcClient.top;
- if (ClientToScreen (hwnd, &ptTemp))
- {
- rcClient.left = ptTemp.x;
- rcClient.top = ptTemp.y;
- ptTemp.x = rcClient.right;
- ptTemp.y = rcClient.bottom;
- if (ClientToScreen (hwnd, &ptTemp))
- {
- rcClient.right = ptTemp.x;
- rcClient.bottom = ptTemp.y;
- if (!PtInRect (&rcClient, ptCurPos))
- bInhibit = TRUE;
- }
- }
- }
- }
- }
-
- if (pCursor == NULL)
- {
- if (pScreenPriv->cursor.visible)
- {
- if (!bInhibit && g_fSoftwareCursor)
- ShowCursor (FALSE);
- pScreenPriv->cursor.visible = FALSE;
- }
- }
- else
- {
- if (pScreenPriv->cursor.handle)
- {
- if (!bInhibit)
- SetCursor (NULL);
- DestroyCursor (pScreenPriv->cursor.handle);
- pScreenPriv->cursor.handle = NULL;
- }
- pScreenPriv->cursor.handle =
- winLoadCursor (pScreen, pCursor, pScreen->myNum);
- winDebug("winSetCursor: handle=%p\n", pScreenPriv->cursor.handle);
-
- if (!bInhibit)
- SetCursor (pScreenPriv->cursor.handle);
-
- if (!pScreenPriv->cursor.visible)
- {
- if (!bInhibit && g_fSoftwareCursor)
- ShowCursor (TRUE);
- pScreenPriv->cursor.visible = TRUE;
- }
- }
-}
-
-
-/*
- * winMoveCursor
- * Move the cursor. This is a noop for us.
- */
-static void
-winMoveCursor (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
-{
-}
-
-static Bool
-winDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScr)
-{
- winScreenPriv(pScr);
- return pScreenPriv->cursor.spriteFuncs->DeviceCursorInitialize(pDev, pScr);
-}
-
-static void
-winDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScr)
-{
- winScreenPriv(pScr);
- pScreenPriv->cursor.spriteFuncs->DeviceCursorCleanup(pDev, pScr);
-}
-
-static miPointerSpriteFuncRec winSpriteFuncsRec = {
- winRealizeCursor,
- winUnrealizeCursor,
- winSetCursor,
- winMoveCursor,
- winDeviceCursorInitialize,
- winDeviceCursorCleanup
-};
-
-
-/*
-===========================================================================
-
- Other screen functions
-
-===========================================================================
-*/
-
-/*
- * winCursorQueryBestSize
- * Handle queries for best cursor size
- */
-static void
-winCursorQueryBestSize (int class, unsigned short *width,
- unsigned short *height, ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
-
- if (class == CursorShape)
- {
- *width = pScreenPriv->cursor.sm_cx;
- *height = pScreenPriv->cursor.sm_cy;
- }
- else
- {
- if (pScreenPriv->cursor.QueryBestSize)
- (*pScreenPriv->cursor.QueryBestSize)(class, width, height, pScreen);
- }
-}
-
-/*
- * winInitCursor
- * Initialize cursor support
- */
-Bool
-winInitCursor (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- miPointerScreenPtr pPointPriv;
- /* override some screen procedures */
- pScreenPriv->cursor.QueryBestSize = pScreen->QueryBestSize;
- pScreen->QueryBestSize = winCursorQueryBestSize;
-
- pPointPriv = (miPointerScreenPtr)
- dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey);
-
- if (pPointPriv)
- {
- pScreenPriv->cursor.spriteFuncs = pPointPriv->spriteFuncs;
- pPointPriv->spriteFuncs = &winSpriteFuncsRec;
- }
- pScreenPriv->cursor.handle = NULL;
- pScreenPriv->cursor.visible = FALSE;
-
- pScreenPriv->cursor.sm_cx = GetSystemMetrics (SM_CXCURSOR);
- pScreenPriv->cursor.sm_cy = GetSystemMetrics (SM_CYCURSOR);
-
- return TRUE;
-}
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Dakshinamurthy Karra
+ * Suhaib M Siddiqi
+ * Peter Busch
+ * Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+#include "winmsg.h"
+#include <cursorstr.h>
+#include <mipointrst.h>
+#include <servermd.h>
+#include "misc.h"
+
+#define BRIGHTNESS(x) (x##Red * 0.299 + x##Green * 0.587 + x##Blue * 0.114)
+
+#ifdef _MSC_VER
+#define min(a,b) (((a) < (b)) ? (a) : (b))
+#define max(a,b) (((a) > (b)) ? (a) : (b))
+#endif
+
+/*
+ * Local function prototypes
+ */
+
+static void
+ winPointerWarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y);
+
+static Bool
+ winCursorOffScreen(ScreenPtr *ppScreen, int *x, int *y);
+
+static void
+ winCrossScreen(ScreenPtr pScreen, Bool fEntering);
+
+miPointerScreenFuncRec g_winPointerCursorFuncs = {
+ winCursorOffScreen,
+ winCrossScreen,
+ winPointerWarpCursor
+};
+
+static void
+winPointerWarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
+{
+ winScreenPriv(pScreen);
+ RECT rcClient;
+ static Bool s_fInitialWarp = TRUE;
+
+ /* Discard first warp call */
+ if (s_fInitialWarp) {
+ /* First warp moves mouse to center of window, just ignore it */
+
+ /* Don't ignore subsequent warps */
+ s_fInitialWarp = FALSE;
+
+ winDebug (
+ "winPointerWarpCursor - Discarding first warp: %d %d\n",
+ x, y);
+
+ return;
+ }
+
+ /*
+ Only update the Windows cursor position if root window is active,
+ or we are in a rootless mode
+ */
+ if ((pScreenPriv->hwndScreen == GetForegroundWindow())
+ || pScreenPriv->pScreenInfo->fRootless
+#ifdef XWIN_MULTIWINDOW
+ || pScreenPriv->pScreenInfo->fMultiWindow
+#endif
+ ) {
+ /* Get the client area coordinates */
+ GetClientRect(pScreenPriv->hwndScreen, &rcClient);
+
+ /* Translate the client area coords to screen coords */
+ MapWindowPoints(pScreenPriv->hwndScreen,
+ HWND_DESKTOP, (LPPOINT) & rcClient, 2);
+
+ /*
+ * Update the Windows cursor position so that we don't
+ * immediately warp back to the current position.
+ */
+ SetCursorPos(rcClient.left + x, rcClient.top + y);
+ }
+
+ /* Call the mi warp procedure to do the actual warping in X. */
+ miPointerWarpCursor(pDev, pScreen, x, y);
+}
+
+static Bool
+winCursorOffScreen(ScreenPtr *ppScreen, int *x, int *y)
+{
+ return FALSE;
+}
+
+static void
+winCrossScreen(ScreenPtr pScreen, Bool fEntering)
+{
+}
+
+static unsigned char
+reverse(unsigned char c)
+{
+ int i;
+ unsigned char ret = 0;
+
+ for (i = 0; i < 8; ++i) {
+ ret |= ((c >> i) & 1) << (7 - i);
+ }
+ return ret;
+}
+
+/*
+ * Convert X cursor to Windows cursor
+ * FIXME: Perhaps there are more smart code
+ */
+static HCURSOR
+winLoadCursor(ScreenPtr pScreen, CursorPtr pCursor, int screen)
+{
+ winScreenPriv(pScreen);
+ HCURSOR hCursor = NULL;
+ unsigned char *pAnd;
+ unsigned char *pXor;
+ int nCX, nCY;
+ int nBytes;
+ double dForeY, dBackY;
+ BOOL fReverse;
+ HBITMAP hAnd, hXor;
+ ICONINFO ii;
+ unsigned char *pCur;
+ int x, y;
+ unsigned char bit;
+ HDC hDC;
+ BITMAPV4HEADER bi;
+ BITMAPINFO *pbmi;
+ unsigned long *lpBits;
+
+ winDebug("winLoadCursor: Win32: %dx%d X11: %dx%d hotspot: %d,%d\n",
+ pScreenPriv->cursor.sm_cx, pScreenPriv->cursor.sm_cy,
+ pCursor->bits->width, pCursor->bits->height,
+ pCursor->bits->xhot, pCursor->bits->yhot);
+
+ /* We can use only White and Black, so calc brightness of color
+ * Also check if the cursor is inverted */
+ dForeY = BRIGHTNESS(pCursor->fore);
+ dBackY = BRIGHTNESS(pCursor->back);
+ fReverse = dForeY < dBackY;
+
+ /* Check wether the X11 cursor is bigger than the win32 cursor */
+ if (pScreenPriv->cursor.sm_cx < pCursor->bits->width ||
+ pScreenPriv->cursor.sm_cy < pCursor->bits->height) {
+ ErrorF (
+ "winLoadCursor - Windows requires %dx%d cursor but X requires %dx%d\n",
+ pScreenPriv->cursor.sm_cx, pScreenPriv->cursor.sm_cy,
+ pCursor->bits->width, pCursor->bits->height);
+ }
+
+ /* Get the number of bytes required to store the whole cursor image
+ * This is roughly (sm_cx * sm_cy) / 8
+ * round up to 8 pixel boundary so we can convert whole bytes */
+ nBytes =
+ bits_to_bytes(pScreenPriv->cursor.sm_cx) * pScreenPriv->cursor.sm_cy;
+
+ /* Get the effective width and height */
+ nCX = min(pScreenPriv->cursor.sm_cx, pCursor->bits->width);
+ nCY = min(pScreenPriv->cursor.sm_cy, pCursor->bits->height);
+
+ /* Allocate memory for the bitmaps */
+ pAnd = malloc(nBytes);
+ memset(pAnd, 0xFF, nBytes);
+ pXor = calloc(1, nBytes);
+
+ /* Convert the X11 bitmap to a win32 bitmap
+ * The first is for an empty mask */
+ if (pCursor->bits->emptyMask) {
+ int x, y, xmax = bits_to_bytes(nCX);
+
+ for (y = 0; y < nCY; ++y)
+ for (x = 0; x < xmax; ++x) {
+ int nWinPix = bits_to_bytes(pScreenPriv->cursor.sm_cx) * y + x;
+ int nXPix = BitmapBytePad(pCursor->bits->width) * y + x;
+
+ pAnd[nWinPix] = 0;
+ if (fReverse)
+ pXor[nWinPix] = reverse(~pCursor->bits->source[nXPix]);
+ else
+ pXor[nWinPix] = reverse(pCursor->bits->source[nXPix]);
+ }
+ }
+ else {
+ int x, y, xmax = bits_to_bytes(nCX);
+
+ for (y = 0; y < nCY; ++y)
+ for (x = 0; x < xmax; ++x) {
+ int nWinPix = bits_to_bytes(pScreenPriv->cursor.sm_cx) * y + x;
+ int nXPix = BitmapBytePad(pCursor->bits->width) * y + x;
+
+ unsigned char mask = pCursor->bits->mask[nXPix];
+
+ pAnd[nWinPix] = reverse(~mask);
+ if (fReverse)
+ pXor[nWinPix] =
+ reverse(~pCursor->bits->source[nXPix] & mask);
+ else
+ pXor[nWinPix] =
+ reverse(pCursor->bits->source[nXPix] & mask);
+ }
+ }
+
+ /* prepare the pointers */
+ hCursor = NULL;
+ lpBits = NULL;
+
+ /* We have a truecolor alpha-blended cursor and can use it! */
+ if (pCursor->bits->argb) {
+ winDebug("winLoadCursor: Trying truecolor alphablended cursor\n");
+ memset(&bi, 0, sizeof(BITMAPV4HEADER));
+ bi.bV4Size = sizeof(BITMAPV4HEADER);
+ bi.bV4Width = pScreenPriv->cursor.sm_cx;
+ bi.bV4Height = -(pScreenPriv->cursor.sm_cy); /* right-side up */
+ bi.bV4Planes = 1;
+ bi.bV4BitCount = 32;
+ bi.bV4V4Compression = BI_BITFIELDS;
+ bi.bV4RedMask = 0x00FF0000;
+ bi.bV4GreenMask = 0x0000FF00;
+ bi.bV4BlueMask = 0x000000FF;
+ bi.bV4AlphaMask = 0xFF000000;
+
+ lpBits =
+ (unsigned long *) calloc(pScreenPriv->cursor.sm_cx *
+ pScreenPriv->cursor.sm_cy,
+ sizeof(unsigned long));
+
+ if (lpBits) {
+ for (y = 0; y < nCY; y++) {
+ unsigned long *src, *dst;
+
+ src = &(pCursor->bits->argb[y * pCursor->bits->width]);
+ dst = &(lpBits[y * pScreenPriv->cursor.sm_cx]);
+ memcpy(dst, src, 4 * nCX);
+ }
+ }
+ } /* End if-truecolor-icon */
+
+ if (!lpBits) {
+ /* Bicolor, use a palettized DIB */
+ winDebug("winLoadCursor: Trying two color cursor\n");
+ pbmi = (BITMAPINFO *) & bi;
+ memset(pbmi, 0, sizeof(BITMAPINFOHEADER));
+ pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+ pbmi->bmiHeader.biWidth = pScreenPriv->cursor.sm_cx;
+ pbmi->bmiHeader.biHeight = -abs(pScreenPriv->cursor.sm_cy); /* right-side up */
+ pbmi->bmiHeader.biPlanes = 1;
+ pbmi->bmiHeader.biBitCount = 8;
+ pbmi->bmiHeader.biCompression = BI_RGB;
+ pbmi->bmiHeader.biSizeImage = 0;
+ pbmi->bmiHeader.biClrUsed = 3;
+ pbmi->bmiHeader.biClrImportant = 3;
+ pbmi->bmiColors[0].rgbRed = 0; /* Empty */
+ pbmi->bmiColors[0].rgbGreen = 0;
+ pbmi->bmiColors[0].rgbBlue = 0;
+ pbmi->bmiColors[0].rgbReserved = 0;
+ pbmi->bmiColors[1].rgbRed = pCursor->backRed >> 8; /* Background */
+ pbmi->bmiColors[1].rgbGreen = pCursor->backGreen >> 8;
+ pbmi->bmiColors[1].rgbBlue = pCursor->backBlue >> 8;
+ pbmi->bmiColors[1].rgbReserved = 0;
+ pbmi->bmiColors[2].rgbRed = pCursor->foreRed >> 8; /* Foreground */
+ pbmi->bmiColors[2].rgbGreen = pCursor->foreGreen >> 8;
+ pbmi->bmiColors[2].rgbBlue = pCursor->foreBlue >> 8;
+ pbmi->bmiColors[2].rgbReserved = 0;
+
+ lpBits =
+ (unsigned long *) calloc(pScreenPriv->cursor.sm_cx *
+ pScreenPriv->cursor.sm_cy, sizeof(char));
+
+ pCur = (unsigned char *) lpBits;
+ if (lpBits) {
+ for (y = 0; y < pScreenPriv->cursor.sm_cy; y++) {
+ for (x = 0; x < pScreenPriv->cursor.sm_cx; x++) {
+ if (x >= nCX || y >= nCY) /* Outside of X11 icon bounds */
+ (*pCur++) = 0;
+ else { /* Within X11 icon bounds */
+
+ int nWinPix =
+ bits_to_bytes(pScreenPriv->cursor.sm_cx) * y +
+ (x / 8);
+
+ bit = pAnd[nWinPix];
+ bit = bit & (1 << (7 - (x & 7)));
+ if (!bit) { /* Within the cursor mask? */
+ int nXPix =
+ BitmapBytePad(pCursor->bits->width) * y +
+ (x / 8);
+ bit =
+ ~reverse(~pCursor->bits->
+ source[nXPix] & pCursor->bits->
+ mask[nXPix]);
+ bit = bit & (1 << (7 - (x & 7)));
+ if (bit) /* Draw foreground */
+ (*pCur++) = 2;
+ else /* Draw background */
+ (*pCur++) = 1;
+ }
+ else /* Outside the cursor mask */
+ (*pCur++) = 0;
+ }
+ } /* end for (x) */
+ } /* end for (y) */
+ } /* end if (lpbits) */
+ }
+
+ /* If one of the previous two methods gave us the bitmap we need, make a cursor */
+ if (lpBits) {
+ winDebug("winLoadCursor: Creating bitmap cursor: hotspot %d,%d\n",
+ pCursor->bits->xhot, pCursor->bits->yhot);
+
+ hAnd = NULL;
+ hXor = NULL;
+
+ hAnd =
+ CreateBitmap(pScreenPriv->cursor.sm_cx, pScreenPriv->cursor.sm_cy,
+ 1, 1, pAnd);
+
+ hDC = GetDC(NULL);
+ if (hDC) {
+ hXor =
+ CreateCompatibleBitmap(hDC, pScreenPriv->cursor.sm_cx,
+ pScreenPriv->cursor.sm_cy);
+ SetDIBits(hDC, hXor, 0, pScreenPriv->cursor.sm_cy, lpBits,
+ (BITMAPINFO *) & bi, DIB_RGB_COLORS);
+ ReleaseDC(NULL, hDC);
+ }
+ free(lpBits);
+
+ if (hAnd && hXor) {
+ ii.fIcon = FALSE;
+ ii.xHotspot = pCursor->bits->xhot;
+ ii.yHotspot = pCursor->bits->yhot;
+ ii.hbmMask = hAnd;
+ ii.hbmColor = hXor;
+ hCursor = (HCURSOR) CreateIconIndirect(&ii);
+
+ if (hCursor == NULL)
+ winW32Error("winLoadCursor - CreateIconIndirect failed:");
+ else {
+ if (GetIconInfo(hCursor, &ii)) {
+ if (ii.fIcon) {
+ winDebug
+ ("winLoadCursor: CreateIconIndirect returned no cursor. Trying again.\n");
+ DestroyCursor(hCursor);
+
+ ii.fIcon = FALSE;
+ ii.xHotspot = pCursor->bits->xhot;
+ ii.yHotspot = pCursor->bits->yhot;
+ hCursor = (HCURSOR) CreateIconIndirect(&ii);
+
+ if (hCursor == NULL)
+ winW32Error(
+ "winLoadCursor - CreateIconIndirect failed:");
+ }
+ /* GetIconInfo creates new bitmaps. Destroy them again */
+ if (ii.hbmMask)
+ DeleteObject(ii.hbmMask);
+ if (ii.hbmColor)
+ DeleteObject(ii.hbmColor);
+ }
+ }
+ }
+
+ if (hAnd)
+ DeleteObject(hAnd);
+ if (hXor)
+ DeleteObject(hXor);
+ }
+
+ if (!hCursor) {
+ /* We couldn't make a color cursor for this screen, use
+ black and white instead */
+ hCursor = CreateCursor(g_hInstance,
+ pCursor->bits->xhot, pCursor->bits->yhot,
+ pScreenPriv->cursor.sm_cx,
+ pScreenPriv->cursor.sm_cy, pAnd, pXor);
+ if (hCursor == NULL)
+ winW32Error("winLoadCursor - CreateCursor failed:");
+ }
+ free(pAnd);
+ free(pXor);
+
+ return hCursor;
+}
+
+/*
+===========================================================================
+
+ Pointer sprite functions
+
+===========================================================================
+*/
+
+/*
+ * winRealizeCursor
+ * Convert the X cursor representation to native format if possible.
+ */
+static Bool
+winRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
+{
+ if (pCursor == NULL || pCursor->bits == NULL)
+ return FALSE;
+
+ /* FIXME: cache ARGB8888 representation? */
+
+ return TRUE;
+}
+
+/*
+ * winUnrealizeCursor
+ * Free the storage space associated with a realized cursor.
+ */
+static Bool
+winUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
+{
+ return TRUE;
+}
+
+/*
+ * winSetCursor
+ * Set the cursor sprite and position.
+ */
+static void
+winSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, int x,
+ int y)
+{
+ POINT ptCurPos, ptTemp;
+ HWND hwnd;
+ RECT rcClient;
+ BOOL bInhibit;
+
+ winScreenPriv(pScreen);
+ winDebug("winSetCursor: cursor=%p\n", pCursor);
+
+ /* Inhibit changing the cursor if the mouse is not in a client area */
+ bInhibit = FALSE;
+ if (GetCursorPos(&ptCurPos)) {
+ hwnd = WindowFromPoint(ptCurPos);
+ if (hwnd) {
+ if (GetClientRect(hwnd, &rcClient)) {
+ ptTemp.x = rcClient.left;
+ ptTemp.y = rcClient.top;
+ if (ClientToScreen(hwnd, &ptTemp)) {
+ rcClient.left = ptTemp.x;
+ rcClient.top = ptTemp.y;
+ ptTemp.x = rcClient.right;
+ ptTemp.y = rcClient.bottom;
+ if (ClientToScreen(hwnd, &ptTemp)) {
+ rcClient.right = ptTemp.x;
+ rcClient.bottom = ptTemp.y;
+ if (!PtInRect(&rcClient, ptCurPos))
+ bInhibit = TRUE;
+ }
+ }
+ }
+ }
+ }
+
+ if (pCursor == NULL) {
+ if (pScreenPriv->cursor.visible) {
+ if (!bInhibit && g_fSoftwareCursor)
+ ShowCursor(FALSE);
+ pScreenPriv->cursor.visible = FALSE;
+ }
+ }
+ else {
+ if (pScreenPriv->cursor.handle) {
+ if (!bInhibit)
+ SetCursor(NULL);
+ DestroyCursor(pScreenPriv->cursor.handle);
+ pScreenPriv->cursor.handle = NULL;
+ }
+ pScreenPriv->cursor.handle =
+ winLoadCursor(pScreen, pCursor, pScreen->myNum);
+ winDebug("winSetCursor: handle=%p\n", pScreenPriv->cursor.handle);
+
+ if (!bInhibit)
+ SetCursor(pScreenPriv->cursor.handle);
+
+ if (!pScreenPriv->cursor.visible) {
+ if (!bInhibit && g_fSoftwareCursor)
+ ShowCursor(TRUE);
+ pScreenPriv->cursor.visible = TRUE;
+ }
+ }
+}
+
+/*
+ * winMoveCursor
+ * Move the cursor. This is a noop for us.
+ */
+static void
+winMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
+{
+}
+
+static Bool
+winDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScr)
+{
+ winScreenPriv(pScr);
+ return pScreenPriv->cursor.spriteFuncs->DeviceCursorInitialize(pDev, pScr);
+}
+
+static void
+winDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScr)
+{
+ winScreenPriv(pScr);
+ pScreenPriv->cursor.spriteFuncs->DeviceCursorCleanup(pDev, pScr);
+}
+
+static miPointerSpriteFuncRec winSpriteFuncsRec = {
+ winRealizeCursor,
+ winUnrealizeCursor,
+ winSetCursor,
+ winMoveCursor,
+ winDeviceCursorInitialize,
+ winDeviceCursorCleanup
+};
+
+/*
+===========================================================================
+
+ Other screen functions
+
+===========================================================================
+*/
+
+/*
+ * winCursorQueryBestSize
+ * Handle queries for best cursor size
+ */
+static void
+winCursorQueryBestSize(int class, unsigned short *width,
+ unsigned short *height, ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+
+ if (class == CursorShape) {
+ *width = pScreenPriv->cursor.sm_cx;
+ *height = pScreenPriv->cursor.sm_cy;
+ }
+ else {
+ if (pScreenPriv->cursor.QueryBestSize)
+ (*pScreenPriv->cursor.QueryBestSize) (class, width, height,
+ pScreen);
+ }
+}
+
+/*
+ * winInitCursor
+ * Initialize cursor support
+ */
+Bool
+winInitCursor(ScreenPtr pScreen)
+{
+ winScreenPriv(pScreen);
+ miPointerScreenPtr pPointPriv;
+
+ /* override some screen procedures */
+ pScreenPriv->cursor.QueryBestSize = pScreen->QueryBestSize;
+ pScreen->QueryBestSize = winCursorQueryBestSize;
+
+ pPointPriv = (miPointerScreenPtr)
+ dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey);
+
+ if (pPointPriv)
+ {
+ pScreenPriv->cursor.spriteFuncs = pPointPriv->spriteFuncs;
+ pPointPriv->spriteFuncs = &winSpriteFuncsRec;
+ }
+ pScreenPriv->cursor.handle = NULL;
+ pScreenPriv->cursor.visible = FALSE;
+
+ pScreenPriv->cursor.sm_cx = GetSystemMetrics(SM_CXCURSOR);
+ pScreenPriv->cursor.sm_cy = GetSystemMetrics(SM_CYCURSOR);
+
+ return TRUE;
+}
diff --git a/xorg-server/hw/xwin/windialogs.c b/xorg-server/hw/xwin/windialogs.c
index 0d5d7c641..bc6715066 100644
--- a/xorg-server/hw/xwin/windialogs.c
+++ b/xorg-server/hw/xwin/windialogs.c
@@ -39,88 +39,80 @@
#include <shellapi.h>
#include "winprefs.h"
-
/*
* References to external globals
*/
#ifdef XWIN_CLIPBOARD
-extern Bool g_fClipboardStarted;
+extern Bool g_fClipboardStarted;
#endif
/*
* Local function prototypes
*/
static wBOOL CALLBACK
-winExitDlgProc (HWND hDialog, UINT message,
- WPARAM wParam, LPARAM lParam);
+winExitDlgProc(HWND hDialog, UINT message, WPARAM wParam, LPARAM lParam);
static wBOOL CALLBACK
-winChangeDepthDlgProc (HWND hDialog, UINT message,
- WPARAM wParam, LPARAM lParam);
+winChangeDepthDlgProc(HWND hDialog, UINT message, WPARAM wParam, LPARAM lParam);
static wBOOL CALLBACK
-winAboutDlgProc (HWND hDialog, UINT message,
- WPARAM wParam, LPARAM lParam);
-
+winAboutDlgProc(HWND hDialog, UINT message, WPARAM wParam, LPARAM lParam);
static void
-winDrawURLWindow (LPARAM lParam);
+ winDrawURLWindow(LPARAM lParam);
static LRESULT CALLBACK
-winURLWndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
+winURLWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
static void
-winOverrideURLButton (HWND hdlg, int id);
+ winOverrideURLButton(HWND hdlg, int id);
static void
-winUnoverrideURLButton (HWND hdlg, int id);
-
+ winUnoverrideURLButton(HWND hdlg, int id);
/*
* Owner-draw a button as a URL
*/
static void
-winDrawURLWindow (LPARAM lParam)
+winDrawURLWindow(LPARAM lParam)
{
- DRAWITEMSTRUCT *draw;
- char str[256];
- RECT rect;
- HFONT font;
- COLORREF crText;
-
- draw = (DRAWITEMSTRUCT *) lParam;
- GetWindowText (draw->hwndItem, str, sizeof(str));
- str[255] = 0;
- GetClientRect (draw->hwndItem, &rect);
-
- /* Color the button depending upon its state */
- if (draw->itemState & ODS_SELECTED)
- crText = RGB(128+64,0,0);
- else if (draw->itemState & ODS_FOCUS)
- crText = RGB(0,128+64,0);
- else
- crText = RGB(0,0,128+64);
- SetTextColor (draw->hDC, crText);
-
- /* Create font 8 high, standard dialog font */
- font = CreateFont (-8, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE,
- 0, 0, 0, 0, 0, "MS Sans Serif");
- if (!font)
- {
- ErrorF ("winDrawURLWindow: Unable to create URL font, bailing.\n");
- return;
+ DRAWITEMSTRUCT *draw;
+ char str[256];
+ RECT rect;
+ HFONT font;
+ COLORREF crText;
+
+ draw = (DRAWITEMSTRUCT *) lParam;
+ GetWindowText(draw->hwndItem, str, sizeof(str));
+ str[255] = 0;
+ GetClientRect(draw->hwndItem, &rect);
+
+ /* Color the button depending upon its state */
+ if (draw->itemState & ODS_SELECTED)
+ crText = RGB(128 + 64, 0, 0);
+ else if (draw->itemState & ODS_FOCUS)
+ crText = RGB(0, 128 + 64, 0);
+ else
+ crText = RGB(0, 0, 128 + 64);
+ SetTextColor(draw->hDC, crText);
+
+ /* Create font 8 high, standard dialog font */
+ font = CreateFont(-8, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE,
+ 0, 0, 0, 0, 0, "MS Sans Serif");
+ if (!font) {
+ ErrorF("winDrawURLWindow: Unable to create URL font, bailing.\n");
+ return;
}
- /* Draw it */
- SetBkMode (draw->hDC, OPAQUE);
- SelectObject (draw->hDC, font);
- DrawText (draw->hDC, str, strlen (str),&rect,DT_LEFT | DT_VCENTER);
- /* Delete the created font, replace it with stock font */
- DeleteObject (SelectObject (draw->hDC, GetStockObject (ANSI_VAR_FONT)));
+ /* Draw it */
+ SetBkMode(draw->hDC, OPAQUE);
+ SelectObject(draw->hDC, font);
+ DrawText(draw->hDC, str, strlen(str), &rect, DT_LEFT | DT_VCENTER);
+ /* Delete the created font, replace it with stock font */
+ DeleteObject(SelectObject(draw->hDC, GetStockObject(ANSI_VAR_FONT)));
}
-
/*
* WndProc for overridden buttons
*/
@@ -128,48 +120,47 @@ winDrawURLWindow (LPARAM lParam)
static LRESULT CALLBACK
winURLWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- WNDPROC origCB = NULL;
- HCURSOR cursor;
-
- /* If it's a SetCursor message, tell it to the hand */
- if (msg==WM_SETCURSOR) {
- cursor = LoadCursor (NULL, IDC_HAND);
- if (cursor)
- SetCursor (cursor);
- return TRUE;
- }
- origCB = (WNDPROC)GetWindowLongPtr(hwnd, GWLP_USERDATA);
- /* Otherwise fall through to original WndProc */
- if (origCB)
- return CallWindowProc (origCB, hwnd, msg, wParam, lParam);
- else
- return FALSE;
+ WNDPROC origCB = NULL;
+ HCURSOR cursor;
+
+ /* If it's a SetCursor message, tell it to the hand */
+ if (msg == WM_SETCURSOR) {
+ cursor = LoadCursor(NULL, IDC_HAND);
+ if (cursor)
+ SetCursor(cursor);
+ return TRUE;
+ }
+ origCB = (WNDPROC) GetWindowLongPtr(hwnd, GWLP_USERDATA);
+ /* Otherwise fall through to original WndProc */
+ if (origCB)
+ return CallWindowProc(origCB, hwnd, msg, wParam, lParam);
+ else
+ return FALSE;
}
-
/*
* Register and unregister the custom WndProc
*/
static void
-winOverrideURLButton (HWND hwnd, int id)
+winOverrideURLButton(HWND hwnd, int id)
{
- WNDPROC origCB;
- origCB = (WNDPROC)SetWindowLongPtr(GetDlgItem (hwnd, id),
- GWLP_WNDPROC, (LONG_PTR)winURLWndProc);
- SetWindowLongPtr(GetDlgItem (hwnd, id), GWLP_USERDATA, (LONG_PTR)origCB);
+ WNDPROC origCB;
+
+ origCB = (WNDPROC) SetWindowLongPtr(GetDlgItem(hwnd, id),
+ GWLP_WNDPROC, (LONG_PTR) winURLWndProc);
+ SetWindowLongPtr(GetDlgItem(hwnd, id), GWLP_USERDATA, (LONG_PTR) origCB);
}
static void
-winUnoverrideURLButton (HWND hwnd, int id)
+winUnoverrideURLButton(HWND hwnd, int id)
{
- WNDPROC origCB;
- origCB = (WNDPROC)SetWindowLongPtr(GetDlgItem (hwnd, id),
- GWLP_USERDATA, 0);
- if (origCB)
- SetWindowLongPtr(GetDlgItem (hwnd, id), GWLP_WNDPROC, (LONG_PTR)origCB);
-}
+ WNDPROC origCB;
+ origCB = (WNDPROC) SetWindowLongPtr(GetDlgItem(hwnd, id), GWLP_USERDATA, 0);
+ if (origCB)
+ SetWindowLongPtr(GetDlgItem(hwnd, id), GWLP_WNDPROC, (LONG_PTR) origCB);
+}
/*
* Center a dialog window in the desktop window
@@ -177,94 +168,93 @@ winUnoverrideURLButton (HWND hwnd, int id)
*/
static void
-winInitDialog (HWND hwndDlg)
+winInitDialog(HWND hwndDlg)
{
- HWND hwndDesk;
- RECT rc, rcDlg, rcDesk;
- HICON hIcon, hIconSmall;
-
- hwndDesk = GetParent (hwndDlg);
- if (!hwndDesk || IsIconic (hwndDesk))
- hwndDesk = GetDesktopWindow ();
-
- /* Remove minimize and maximize buttons */
- SetWindowLongPtr(hwndDlg, GWL_STYLE,
- GetWindowLongPtr(hwndDlg, GWL_STYLE)
- & ~(WS_MAXIMIZEBOX | WS_MINIMIZEBOX));
-
- /* Set Window not to show in the task bar */
- SetWindowLongPtr(hwndDlg, GWL_EXSTYLE,
- GetWindowLongPtr(hwndDlg, GWL_EXSTYLE) & ~WS_EX_APPWINDOW );
-
- /* Center dialog window in the screen. Not done for multi-monitor systems, where
- * it is likely to end up split across the screens. In that case, it appears
- * near the Tray icon.
- */
- if (GetSystemMetrics(SM_CMONITORS)>1) {
- /* Still need to refresh the frame change. */
+ HWND hwndDesk;
+ RECT rc, rcDlg, rcDesk;
+ HICON hIcon, hIconSmall;
+
+ hwndDesk = GetParent(hwndDlg);
+ if (!hwndDesk || IsIconic(hwndDesk))
+ hwndDesk = GetDesktopWindow();
+
+ /* Remove minimize and maximize buttons */
+ SetWindowLongPtr(hwndDlg, GWL_STYLE, GetWindowLongPtr(hwndDlg, GWL_STYLE)
+ & ~(WS_MAXIMIZEBOX | WS_MINIMIZEBOX));
+
+ /* Set Window not to show in the task bar */
+ SetWindowLongPtr(hwndDlg, GWL_EXSTYLE,
+ GetWindowLongPtr(hwndDlg, GWL_EXSTYLE) & ~WS_EX_APPWINDOW);
+
+ /* Center dialog window in the screen. Not done for multi-monitor systems, where
+ * it is likely to end up split across the screens. In that case, it appears
+ * near the Tray icon.
+ */
+ if (GetSystemMetrics(SM_CMONITORS) > 1) {
+ /* Still need to refresh the frame change. */
SetWindowPos (hwndDlg, HWND_TOP, 0,0,0,0,
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
- } else {
- GetWindowRect (hwndDesk, &rcDesk);
- GetWindowRect (hwndDlg, &rcDlg);
- CopyRect (&rc, &rcDesk);
-
- OffsetRect (&rcDlg, -rcDlg.left, -rcDlg.top);
- OffsetRect (&rc, -rc.left, -rc.top);
- OffsetRect (&rc, -rcDlg.right, -rcDlg.bottom);
-
- SetWindowPos (hwndDlg,
- HWND_TOPMOST,
- rcDesk.left + (rc.right / 2),
- rcDesk.top + (rc.bottom / 2),
- 0, 0,
- SWP_NOSIZE | SWP_FRAMECHANGED);
- }
+ }
+ else {
+ GetWindowRect(hwndDesk, &rcDesk);
+ GetWindowRect(hwndDlg, &rcDlg);
+ CopyRect(&rc, &rcDesk);
+
+ OffsetRect(&rcDlg, -rcDlg.left, -rcDlg.top);
+ OffsetRect(&rc, -rc.left, -rc.top);
+ OffsetRect(&rc, -rcDlg.right, -rcDlg.bottom);
+
+ SetWindowPos(hwndDlg,
+ HWND_TOPMOST,
+ rcDesk.left + (rc.right / 2),
+ rcDesk.top + (rc.bottom / 2),
+ 0, 0, SWP_NOSIZE | SWP_FRAMECHANGED);
+ }
#ifdef XWIN_MULTIWINDOW
- if (g_hIconX) hIcon=g_hIconX;
- else
+ if (g_hIconX)
+ hIcon = g_hIconX;
+ else
#endif
- hIcon = LoadIcon (g_hInstance, MAKEINTRESOURCE(IDI_XWIN));
+ hIcon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_XWIN));
#ifdef XWIN_MULTIWINDOW
- if (g_hSmallIconX) hIconSmall=g_hSmallIconX;
- else
+ if (g_hSmallIconX)
+ hIconSmall = g_hSmallIconX;
+ else
#endif
- hIconSmall = LoadImage (g_hInstance,
- MAKEINTRESOURCE(IDI_XWIN), IMAGE_ICON,
- GetSystemMetrics(SM_CXSMICON),
- GetSystemMetrics(SM_CYSMICON),
- LR_SHARED);
-
- PostMessage (hwndDlg, WM_SETICON, ICON_BIG, (LPARAM) hIcon);
- PostMessage (hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM) hIconSmall);
-}
+ hIconSmall = LoadImage(g_hInstance,
+ MAKEINTRESOURCE(IDI_XWIN), IMAGE_ICON,
+ GetSystemMetrics(SM_CXSMICON),
+ GetSystemMetrics(SM_CYSMICON), LR_SHARED);
+ PostMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM) hIcon);
+ PostMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM) hIconSmall);
+}
int
GetLiveClients (winPrivScreenPtr pScreenPriv)
{
- int i;
- int liveClients = 0;
+ int i;
+ int liveClients = 0;
- /* Count up running clients (clients[0] is serverClient) */
- for (i = 1; i < currentMaxClients; i++)
- if (clients[i] != NullClient)
- liveClients++;
+ /* Count up running clients (clients[0] is serverClient) */
+ for (i = 1; i < currentMaxClients; i++)
+ if (clients[i] != NullClient)
+ liveClients++;
#if defined(XWIN_MULTIWINDOW)
- /* Count down server internal clients */
- if (pScreenPriv->pScreenInfo->fMultiWindow)
- liveClients -= 2; /* multiwindow window manager & XMsgProc */
+ /* Count down server internal clients */
+ if (pScreenPriv->pScreenInfo->fMultiWindow)
+ liveClients -= 2; /* multiwindow window manager & XMsgProc */
#endif
#if defined(XWIN_CLIPBOARD)
- if (g_fClipboardStarted)
- liveClients--; /* clipboard manager */
+ if (g_fClipboardStarted)
+ liveClients--; /* clipboard manager */
#endif
- /* A user reported that this sometimes drops below zero. just eye-candy. */
- if (liveClients < 0)
- liveClients = 0;
+ /* A user reported that this sometimes drops below zero. just eye-candy. */
+ if (liveClients < 0)
+ liveClients = 0;
pScreenPriv->iConnectedClients = liveClients;
@@ -280,488 +270,445 @@ winDisplayExitDialog (winPrivScreenPtr pScreenPriv)
{
int liveClients = GetLiveClients(pScreenPriv);
- /* Don't show the exit confirmation dialog if SilentExit & no clients,
- or ForceExit, is enabled */
- if ((pref.fSilentExit && liveClients <= 0) || pref.fForceExit)
- {
- if (g_hDlgExit != NULL)
- {
- DestroyWindow (g_hDlgExit);
- g_hDlgExit = NULL;
- }
- PostMessage (pScreenPriv->hwndScreen, WM_GIVEUP, 0, 0);
- return;
+ /* Don't show the exit confirmation dialog if SilentExit & no clients,
+ or ForceExit, is enabled */
+ if ((pref.fSilentExit && liveClients <= 0) || pref.fForceExit) {
+ if (g_hDlgExit != NULL) {
+ DestroyWindow(g_hDlgExit);
+ g_hDlgExit = NULL;
+ }
+ PostMessage(pScreenPriv->hwndScreen, WM_GIVEUP, 0, 0);
+ return;
}
- /* Check if dialog already exists */
- if (g_hDlgExit != NULL)
- {
- /* Dialog box already exists, display it */
- ShowWindow (g_hDlgExit, SW_SHOWDEFAULT);
+ /* Check if dialog already exists */
+ if (g_hDlgExit != NULL) {
+ /* Dialog box already exists, display it */
+ ShowWindow(g_hDlgExit, SW_SHOWDEFAULT);
- /* User has lost the dialog. Show them where it is. */
- SetForegroundWindow (g_hDlgExit);
+ /* User has lost the dialog. Show them where it is. */
+ SetForegroundWindow(g_hDlgExit);
- return;
+ return;
}
- /* Create dialog box */
- g_hDlgExit = CreateDialogParam (g_hInstance,
- "EXIT_DIALOG",
- pScreenPriv->hwndScreen,
- winExitDlgProc,
- (int) pScreenPriv);
-
- /* Show the dialog box */
- ShowWindow (g_hDlgExit, SW_SHOW);
-
- /* Needed to get keyboard controls (tab, arrows, enter, esc) to work */
- SetForegroundWindow (g_hDlgExit);
-
- /* Set focus to the Cancel button */
- PostMessage (g_hDlgExit, WM_NEXTDLGCTL,
- (WPARAM)GetDlgItem (g_hDlgExit, IDCANCEL), TRUE);
+ /* Create dialog box */
+ g_hDlgExit = CreateDialogParam(g_hInstance,
+ "EXIT_DIALOG",
+ pScreenPriv->hwndScreen,
+ winExitDlgProc, (int) pScreenPriv);
+
+ /* Show the dialog box */
+ ShowWindow(g_hDlgExit, SW_SHOW);
+
+ /* Needed to get keyboard controls (tab, arrows, enter, esc) to work */
+ SetForegroundWindow(g_hDlgExit);
+
+ /* Set focus to the Cancel button */
+ PostMessage(g_hDlgExit, WM_NEXTDLGCTL,
+ (WPARAM) GetDlgItem(g_hDlgExit, IDCANCEL), TRUE);
}
#define CONNECTED_CLIENTS_FORMAT "There %s currently %d client%s connected."
-
/*
* Exit dialog window procedure
*/
static wBOOL CALLBACK
-winExitDlgProc (HWND hDialog, UINT message,
- WPARAM wParam, LPARAM lParam)
+winExitDlgProc(HWND hDialog, UINT message, WPARAM wParam, LPARAM lParam)
{
- static winPrivScreenPtr s_pScreenPriv = NULL;
+ static winPrivScreenPtr s_pScreenPriv = NULL;
- /* Branch on message type */
- switch (message)
- {
+ /* Branch on message type */
+ switch (message) {
case WM_INITDIALOG:
- {
- char *pszConnectedClients;
-
- /* Store pointers to private structures for future use */
- s_pScreenPriv = (winPrivScreenPtr) lParam;
-
- winInitDialog (hDialog);
-
- /* Format the connected clients string */
- if (asprintf (&pszConnectedClients, CONNECTED_CLIENTS_FORMAT,
- (s_pScreenPriv->iConnectedClients == 1) ? "is" : "are",
- s_pScreenPriv->iConnectedClients,
- (s_pScreenPriv->iConnectedClients == 1) ? "" : "s") == -1)
- return TRUE;
-
-
-
- /* Set the number of connected clients */
- SetWindowText (GetDlgItem (hDialog, IDC_CLIENTS_CONNECTED),
- pszConnectedClients);
- free(pszConnectedClients);
- }
- return TRUE;
+ {
+ char *pszConnectedClients;
+
+ /* Store pointers to private structures for future use */
+ s_pScreenPriv = (winPrivScreenPtr) lParam;
+
+ winInitDialog(hDialog);
+
+ /* Format the connected clients string */
+ if (asprintf(&pszConnectedClients, CONNECTED_CLIENTS_FORMAT,
+ (s_pScreenPriv->iConnectedClients == 1) ? "is" : "are",
+ s_pScreenPriv->iConnectedClients,
+ (s_pScreenPriv->iConnectedClients == 1) ? "" : "s") == -1)
+ return TRUE;
+
+ /* Set the number of connected clients */
+ SetWindowText(GetDlgItem(hDialog, IDC_CLIENTS_CONNECTED),
+ pszConnectedClients);
+ free(pszConnectedClients);
+ }
+ return TRUE;
case WM_COMMAND:
- switch (LOWORD (wParam))
- {
- case IDOK:
- /* Send message to call the GiveUp function */
- PostMessage (s_pScreenPriv->hwndScreen, WM_GIVEUP, 0, 0);
- DestroyWindow (g_hDlgExit);
- g_hDlgExit = NULL;
-
- /* Fix to make sure keyboard focus isn't trapped */
- PostMessage (s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
- return TRUE;
-
- case IDCANCEL:
- DestroyWindow (g_hDlgExit);
- g_hDlgExit = NULL;
-
- /* Fix to make sure keyboard focus isn't trapped */
- PostMessage (s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
- return TRUE;
- }
- break;
+ switch (LOWORD(wParam)) {
+ case IDOK:
+ /* Send message to call the GiveUp function */
+ PostMessage(s_pScreenPriv->hwndScreen, WM_GIVEUP, 0, 0);
+ DestroyWindow(g_hDlgExit);
+ g_hDlgExit = NULL;
+
+ /* Fix to make sure keyboard focus isn't trapped */
+ PostMessage(s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
+ return TRUE;
+
+ case IDCANCEL:
+ DestroyWindow(g_hDlgExit);
+ g_hDlgExit = NULL;
+
+ /* Fix to make sure keyboard focus isn't trapped */
+ PostMessage(s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
+ return TRUE;
+ }
+ break;
case WM_MOUSEMOVE:
case WM_NCMOUSEMOVE:
- /* Show the cursor if it is hidden */
- if (g_fSoftwareCursor && !g_fCursor)
- {
- g_fCursor = TRUE;
- ShowCursor (TRUE);
- }
- return TRUE;
+ /* Show the cursor if it is hidden */
+ if (g_fSoftwareCursor && !g_fCursor) {
+ g_fCursor = TRUE;
+ ShowCursor(TRUE);
+ }
+ return TRUE;
case WM_CLOSE:
- DestroyWindow (g_hDlgExit);
- g_hDlgExit = NULL;
+ DestroyWindow(g_hDlgExit);
+ g_hDlgExit = NULL;
- /* Fix to make sure keyboard focus isn't trapped */
- PostMessage (s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
- return TRUE;
+ /* Fix to make sure keyboard focus isn't trapped */
+ PostMessage(s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
+ return TRUE;
}
- return FALSE;
+ return FALSE;
}
-
/*
* Display the Depth Change dialog box
*/
void
-winDisplayDepthChangeDialog (winPrivScreenPtr pScreenPriv)
+winDisplayDepthChangeDialog(winPrivScreenPtr pScreenPriv)
{
- /* Check if dialog already exists */
- if (g_hDlgDepthChange != NULL)
- {
- /* Dialog box already exists, display it */
- ShowWindow (g_hDlgDepthChange, SW_SHOWDEFAULT);
+ /* Check if dialog already exists */
+ if (g_hDlgDepthChange != NULL) {
+ /* Dialog box already exists, display it */
+ ShowWindow(g_hDlgDepthChange, SW_SHOWDEFAULT);
- /* User has lost the dialog. Show them where it is. */
- SetForegroundWindow (g_hDlgDepthChange);
+ /* User has lost the dialog. Show them where it is. */
+ SetForegroundWindow(g_hDlgDepthChange);
- return;
+ return;
}
- /*
- * Display a notification to the user that the visual
- * will not be displayed until the Windows display depth
- * is restored to the original value.
- */
- g_hDlgDepthChange = CreateDialogParam (g_hInstance,
- "DEPTH_CHANGE_BOX",
- pScreenPriv->hwndScreen,
- winChangeDepthDlgProc,
- (int) pScreenPriv);
- /* Show the dialog box */
- ShowWindow (g_hDlgDepthChange, SW_SHOW);
-
- winDebug ("winDisplayDepthChangeDialog - DialogBox returned: %d\n",
- (int) g_hDlgDepthChange);
- winDebug ("winDisplayDepthChangeDialog - GetLastError: %d\n",
- (int) GetLastError ());
-
- /* Minimize the display window */
- ShowWindow (pScreenPriv->hwndScreen, SW_MINIMIZE);
+ /*
+ * Display a notification to the user that the visual
+ * will not be displayed until the Windows display depth
+ * is restored to the original value.
+ */
+ g_hDlgDepthChange = CreateDialogParam(g_hInstance,
+ "DEPTH_CHANGE_BOX",
+ pScreenPriv->hwndScreen,
+ winChangeDepthDlgProc,
+ (int) pScreenPriv);
+ /* Show the dialog box */
+ ShowWindow(g_hDlgDepthChange, SW_SHOW);
+
+ winDebug ("winDisplayDepthChangeDialog - DialogBox returned: %d\n",
+ (int) g_hDlgDepthChange);
+ winDebug ("winDisplayDepthChangeDialog - GetLastError: %d\n",
+ (int) GetLastError());
+
+ /* Minimize the display window */
+ ShowWindow(pScreenPriv->hwndScreen, SW_MINIMIZE);
}
-
/*
* Process messages for the dialog that is displayed for
* disruptive screen depth changes.
*/
static wBOOL CALLBACK
-winChangeDepthDlgProc (HWND hwndDialog, UINT message,
- WPARAM wParam, LPARAM lParam)
+winChangeDepthDlgProc(HWND hwndDialog, UINT message,
+ WPARAM wParam, LPARAM lParam)
{
- static winPrivScreenPtr s_pScreenPriv = NULL;
- static winScreenInfo *s_pScreenInfo = NULL;
- static ScreenPtr s_pScreen = NULL;
+ static winPrivScreenPtr s_pScreenPriv = NULL;
+ static winScreenInfo *s_pScreenInfo = NULL;
+ static ScreenPtr s_pScreen = NULL;
- winDebug ("winChangeDepthDlgProc\n");
+ winDebug("winChangeDepthDlgProc\n");
- /* Branch on message type */
- switch (message)
- {
+ /* Branch on message type */
+ switch (message) {
case WM_INITDIALOG:
- winDebug ("winChangeDepthDlgProc - WM_INITDIALOG\n");
+ winDebug("winChangeDepthDlgProc - WM_INITDIALOG\n");
- /* Store pointers to private structures for future use */
- s_pScreenPriv = (winPrivScreenPtr) lParam;
- s_pScreenInfo = s_pScreenPriv->pScreenInfo;
- s_pScreen = s_pScreenInfo->pScreen;
+ /* Store pointers to private structures for future use */
+ s_pScreenPriv = (winPrivScreenPtr) lParam;
+ s_pScreenInfo = s_pScreenPriv->pScreenInfo;
+ s_pScreen = s_pScreenInfo->pScreen;
- winDebug ("winChangeDepthDlgProc - WM_INITDIALOG - s_pScreenPriv: %08x, "
- "s_pScreenInfo: %08x, s_pScreen: %08x\n",
- s_pScreenPriv, s_pScreenInfo, s_pScreen);
+ winDebug("winChangeDepthDlgProc - WM_INITDIALOG - s_pScreenPriv: %08x, "
+ "s_pScreenInfo: %08x, s_pScreen: %08x\n",
+ s_pScreenPriv, s_pScreenInfo, s_pScreen);
- winDebug ("winChangeDepthDlgProc - WM_INITDIALOG - orig bpp: %d, "
- "current bpp: %d\n",
- s_pScreenInfo->dwBPP,
- GetDeviceCaps(s_pScreenPriv->hdcScreen, BITSPIXEL));
+ winDebug("winChangeDepthDlgProc - WM_INITDIALOG - orig bpp: %d, "
+ "current bpp: %d\n",
+ s_pScreenInfo->dwBPP,
+ GetDeviceCaps(s_pScreenPriv->hdcScreen, BITSPIXEL));
- winInitDialog( hwndDialog );
+ winInitDialog(hwndDialog);
- return TRUE;
+ return TRUE;
case WM_DISPLAYCHANGE:
- winDebug ("winChangeDepthDlgProc - WM_DISPLAYCHANGE - orig bpp: %d, "
- "new bpp: %d\n",
- s_pScreenInfo->dwBPP,
- GetDeviceCaps(s_pScreenPriv->hdcScreen, BITSPIXEL));
+ winDebug("winChangeDepthDlgProc - WM_DISPLAYCHANGE - orig bpp: %d, "
+ "new bpp: %d\n",
+ s_pScreenInfo->dwBPP,
+ GetDeviceCaps(s_pScreenPriv->hdcScreen, BITSPIXEL));
- /* Dismiss the dialog if the display returns to the original depth */
- if (GetDeviceCaps(s_pScreenPriv->hdcScreen, BITSPIXEL) == s_pScreenInfo->dwBPP)
- {
- winDebug ("winChangeDelthDlgProc - wParam == s_pScreenInfo->dwBPP\n");
+ /* Dismiss the dialog if the display returns to the original depth */
+ if (GetDeviceCaps(s_pScreenPriv->hdcScreen, BITSPIXEL) ==
+ s_pScreenInfo->dwBPP) {
+ winDebug ("winChangeDelthDlgProc - wParam == s_pScreenInfo->dwBPP\n");
- /* Depth has been restored, dismiss dialog */
- DestroyWindow (g_hDlgDepthChange);
- g_hDlgDepthChange = NULL;
+ /* Depth has been restored, dismiss dialog */
+ DestroyWindow(g_hDlgDepthChange);
+ g_hDlgDepthChange = NULL;
- /* Flag that we have a valid screen depth */
- s_pScreenPriv->fBadDepth = FALSE;
- }
- return TRUE;
+ /* Flag that we have a valid screen depth */
+ s_pScreenPriv->fBadDepth = FALSE;
+ }
+ return TRUE;
case WM_COMMAND:
- switch (LOWORD (wParam))
- {
- case IDOK:
- case IDCANCEL:
- ErrorF ("winChangeDepthDlgProc - WM_COMMAND - IDOK or IDCANCEL\n");
-
- /*
- * User dismissed the dialog, hide it until the
- * display mode is restored.
- */
- ShowWindow (g_hDlgDepthChange, SW_HIDE);
- return TRUE;
- }
- break;
+ switch (LOWORD(wParam)) {
+ case IDOK:
+ case IDCANCEL:
+ ErrorF("winChangeDepthDlgProc - WM_COMMAND - IDOK or IDCANCEL\n");
+
+ /*
+ * User dismissed the dialog, hide it until the
+ * display mode is restored.
+ */
+ ShowWindow(g_hDlgDepthChange, SW_HIDE);
+ return TRUE;
+ }
+ break;
case WM_CLOSE:
- winDebug ("winChangeDepthDlgProc - WM_CLOSE\n");
+ winDebug ("winChangeDepthDlgProc - WM_CLOSE\n");
- DestroyWindow (g_hDlgAbout);
- g_hDlgAbout = NULL;
+ DestroyWindow(g_hDlgAbout);
+ g_hDlgAbout = NULL;
- /* Fix to make sure keyboard focus isn't trapped */
- PostMessage (s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
- return TRUE;
+ /* Fix to make sure keyboard focus isn't trapped */
+ PostMessage(s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
+ return TRUE;
}
- return FALSE;
+ return FALSE;
}
-
/*
* Display the About dialog box
*/
void
-winDisplayAboutDialog (winPrivScreenPtr pScreenPriv)
+winDisplayAboutDialog(winPrivScreenPtr pScreenPriv)
{
- /* Check if dialog already exists */
- if (g_hDlgAbout != NULL)
- {
- /* Dialog box already exists, display it */
- ShowWindow (g_hDlgAbout, SW_SHOWDEFAULT);
+ /* Check if dialog already exists */
+ if (g_hDlgAbout != NULL) {
+ /* Dialog box already exists, display it */
+ ShowWindow(g_hDlgAbout, SW_SHOWDEFAULT);
- /* User has lost the dialog. Show them where it is. */
- SetForegroundWindow (g_hDlgAbout);
+ /* User has lost the dialog. Show them where it is. */
+ SetForegroundWindow(g_hDlgAbout);
- return;
+ return;
}
- /*
- * Display the about box
- */
- g_hDlgAbout = CreateDialogParam (g_hInstance,
- "ABOUT_BOX",
- pScreenPriv->hwndScreen,
- winAboutDlgProc,
- (int) pScreenPriv);
-
- /* Show the dialog box */
- ShowWindow (g_hDlgAbout, SW_SHOW);
-
- /* Needed to get keyboard controls (tab, arrows, enter, esc) to work */
- SetForegroundWindow (g_hDlgAbout);
-
- /* Set focus to the OK button */
- PostMessage (g_hDlgAbout, WM_NEXTDLGCTL,
- (WPARAM)GetDlgItem (g_hDlgAbout, IDOK), TRUE);
-}
+ /*
+ * Display the about box
+ */
+ g_hDlgAbout = CreateDialogParam(g_hInstance,
+ "ABOUT_BOX",
+ pScreenPriv->hwndScreen,
+ winAboutDlgProc, (int) pScreenPriv);
+
+ /* Show the dialog box */
+ ShowWindow(g_hDlgAbout, SW_SHOW);
+ /* Needed to get keyboard controls (tab, arrows, enter, esc) to work */
+ SetForegroundWindow(g_hDlgAbout);
+
+ /* Set focus to the OK button */
+ PostMessage(g_hDlgAbout, WM_NEXTDLGCTL,
+ (WPARAM) GetDlgItem(g_hDlgAbout, IDOK), TRUE);
+}
/*
* Process messages for the about dialog.
*/
static wBOOL CALLBACK
-winAboutDlgProc (HWND hwndDialog, UINT message,
- WPARAM wParam, LPARAM lParam)
+winAboutDlgProc(HWND hwndDialog, UINT message, WPARAM wParam, LPARAM lParam)
{
- static winPrivScreenPtr s_pScreenPriv = NULL;
- static winScreenInfo *s_pScreenInfo = NULL;
- static ScreenPtr s_pScreen = NULL;
+ static winPrivScreenPtr s_pScreenPriv = NULL;
+ static winScreenInfo *s_pScreenInfo = NULL;
+ static ScreenPtr s_pScreen = NULL;
- winDebug ("winAboutDlgProc\n");
+ winDebug("winAboutDlgProc\n");
- /* Branch on message type */
- switch (message)
- {
+ /* Branch on message type */
+ switch (message) {
case WM_INITDIALOG:
- winDebug ("winAboutDlgProc - WM_INITDIALOG\n");
+ winDebug("winAboutDlgProc - WM_INITDIALOG\n");
- /* Store pointers to private structures for future use */
- s_pScreenPriv = (winPrivScreenPtr) lParam;
- s_pScreenInfo = s_pScreenPriv->pScreenInfo;
- s_pScreen = s_pScreenInfo->pScreen;
+ /* Store pointers to private structures for future use */
+ s_pScreenPriv = (winPrivScreenPtr) lParam;
+ s_pScreenInfo = s_pScreenPriv->pScreenInfo;
+ s_pScreen = s_pScreenInfo->pScreen;
- winInitDialog (hwndDialog);
+ winInitDialog(hwndDialog);
- /* Override the URL buttons */
- winOverrideURLButton (hwndDialog, ID_ABOUT_CHANGELOG);
- winOverrideURLButton (hwndDialog, ID_ABOUT_WEBSITE);
- winOverrideURLButton (hwndDialog, ID_ABOUT_UG);
- winOverrideURLButton (hwndDialog, ID_ABOUT_FAQ);
+ /* Override the URL buttons */
+ winOverrideURLButton(hwndDialog, ID_ABOUT_CHANGELOG);
+ winOverrideURLButton(hwndDialog, ID_ABOUT_WEBSITE);
+ winOverrideURLButton(hwndDialog, ID_ABOUT_UG);
+ winOverrideURLButton(hwndDialog, ID_ABOUT_FAQ);
- return TRUE;
+ return TRUE;
case WM_DRAWITEM:
- /* Draw the URL buttons as needed */
- winDrawURLWindow (lParam);
- return TRUE;
+ /* Draw the URL buttons as needed */
+ winDrawURLWindow(lParam);
+ return TRUE;
case WM_MOUSEMOVE:
case WM_NCMOUSEMOVE:
- /* Show the cursor if it is hidden */
- if (g_fSoftwareCursor && !g_fCursor)
- {
- g_fCursor = TRUE;
- ShowCursor (TRUE);
- }
- return TRUE;
+ /* Show the cursor if it is hidden */
+ if (g_fSoftwareCursor && !g_fCursor) {
+ g_fCursor = TRUE;
+ ShowCursor(TRUE);
+ }
+ return TRUE;
case WM_COMMAND:
- switch (LOWORD (wParam))
- {
- case IDOK:
- case IDCANCEL:
- winDebug ("winAboutDlgProc - WM_COMMAND - IDOK or IDCANCEL\n");
+ switch (LOWORD(wParam)) {
+ case IDOK:
+ case IDCANCEL:
+ winDebug ("winAboutDlgProc - WM_COMMAND - IDOK or IDCANCEL\n");
+
+ DestroyWindow(g_hDlgAbout);
+ g_hDlgAbout = NULL;
- DestroyWindow (g_hDlgAbout);
- g_hDlgAbout = NULL;
+ /* Fix to make sure keyboard focus isn't trapped */
+ PostMessage(s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
- /* Fix to make sure keyboard focus isn't trapped */
- PostMessage (s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
+ /* Restore window procedures for URL buttons */
+ winUnoverrideURLButton(hwndDialog, ID_ABOUT_CHANGELOG);
+ winUnoverrideURLButton(hwndDialog, ID_ABOUT_WEBSITE);
+ winUnoverrideURLButton(hwndDialog, ID_ABOUT_UG);
+ winUnoverrideURLButton(hwndDialog, ID_ABOUT_FAQ);
- /* Restore window procedures for URL buttons */
- winUnoverrideURLButton (hwndDialog, ID_ABOUT_CHANGELOG);
- winUnoverrideURLButton (hwndDialog, ID_ABOUT_WEBSITE);
- winUnoverrideURLButton (hwndDialog, ID_ABOUT_UG);
- winUnoverrideURLButton (hwndDialog, ID_ABOUT_FAQ);
+ return TRUE;
- return TRUE;
+ case ID_ABOUT_CHANGELOG:
+ {
+ int iReturn;
- case ID_ABOUT_CHANGELOG:
- {
- int iReturn;
#ifdef __CYGWIN__
- const char * pszCygPath = "/usr/X11R6/share/doc/"
- "xorg-x11-xwin/changelog.html";
- char pszWinPath[MAX_PATH + 1];
+ const char *pszCygPath = "/usr/X11R6/share/doc/"
+ "xorg-x11-xwin/changelog.html";
+ char pszWinPath[MAX_PATH + 1];
- /* Convert the POSIX path to a Win32 path */
- cygwin_conv_to_win32_path (pszCygPath, pszWinPath);
+ /* Convert the POSIX path to a Win32 path */
+ cygwin_conv_to_win32_path(pszCygPath, pszWinPath);
#else
- const char * pszWinPath = "http://x.cygwin.com/"
- "devel/server/changelog.html";
+ const char *pszWinPath = "http://x.cygwin.com/"
+ "devel/server/changelog.html";
#endif
-
- iReturn = (int)ShellExecute (NULL,
- "open",
- pszWinPath,
- NULL,
- NULL,
- SW_MAXIMIZE);
- if (iReturn < 32)
- {
- ErrorF ("winAboutDlgProc - WM_COMMAND - ID_ABOUT_CHANGELOG - "
- "ShellExecute failed: %d\n",
- iReturn);
- }
- }
- return TRUE;
-
- case ID_ABOUT_WEBSITE:
- {
- const char * pszPath = __VENDORDWEBSUPPORT__;
- int iReturn;
-
- iReturn = (int)ShellExecute (NULL,
- "open",
- pszPath,
- NULL,
- NULL,
- SW_MAXIMIZE);
- if (iReturn < 32)
- {
- ErrorF ("winAboutDlgProc - WM_COMMAND - ID_ABOUT_WEBSITE - "
- "ShellExecute failed: %d\n",
- iReturn);
- }
- }
- return TRUE;
-
- case ID_ABOUT_UG:
- {
- const char * pszPath = "http://x.cygwin.com/docs/ug/";
- int iReturn;
-
- iReturn = (int)ShellExecute (NULL,
- "open",
- pszPath,
- NULL,
- NULL,
- SW_MAXIMIZE);
- if (iReturn < 32)
- {
- ErrorF ("winAboutDlgProc - WM_COMMAND - ID_ABOUT_UG - "
- "ShellExecute failed: %d\n",
- iReturn);
- }
- }
- return TRUE;
-
- case ID_ABOUT_FAQ:
- {
- const char * pszPath = "http://x.cygwin.com/docs/faq/";
- int iReturn;
-
- iReturn = (int)ShellExecute (NULL,
- "open",
- pszPath,
- NULL,
- NULL,
- SW_MAXIMIZE);
- if (iReturn < 32)
- {
- ErrorF ("winAboutDlgProc - WM_COMMAND - ID_ABOUT_FAQ - "
- "ShellExecute failed: %d\n",
- iReturn);
- }
- }
- return TRUE;
- }
- break;
+
+ iReturn = (int) ShellExecute(NULL,
+ "open",
+ pszWinPath, NULL, NULL, SW_MAXIMIZE);
+ if (iReturn < 32) {
+ ErrorF("winAboutDlgProc - WM_COMMAND - ID_ABOUT_CHANGELOG - "
+ "ShellExecute failed: %d\n", iReturn);
+ }
+ }
+ return TRUE;
+
+ case ID_ABOUT_WEBSITE:
+ {
+ const char *pszPath = __VENDORDWEBSUPPORT__;
+ int iReturn;
+
+ iReturn = (int) ShellExecute(NULL,
+ "open",
+ pszPath, NULL, NULL, SW_MAXIMIZE);
+ if (iReturn < 32) {
+ ErrorF("winAboutDlgProc - WM_COMMAND - ID_ABOUT_WEBSITE - "
+ "ShellExecute failed: %d\n", iReturn);
+ }
+ }
+ return TRUE;
+
+ case ID_ABOUT_UG:
+ {
+ const char *pszPath = "http://x.cygwin.com/docs/ug/";
+ int iReturn;
+
+ iReturn = (int) ShellExecute(NULL,
+ "open",
+ pszPath, NULL, NULL, SW_MAXIMIZE);
+ if (iReturn < 32) {
+ ErrorF("winAboutDlgProc - WM_COMMAND - ID_ABOUT_UG - "
+ "ShellExecute failed: %d\n", iReturn);
+ }
+ }
+ return TRUE;
+
+ case ID_ABOUT_FAQ:
+ {
+ const char *pszPath = "http://x.cygwin.com/docs/faq/";
+ int iReturn;
+
+ iReturn = (int) ShellExecute(NULL,
+ "open",
+ pszPath, NULL, NULL, SW_MAXIMIZE);
+ if (iReturn < 32) {
+ ErrorF("winAboutDlgProc - WM_COMMAND - ID_ABOUT_FAQ - "
+ "ShellExecute failed: %d\n", iReturn);
+ }
+ }
+ return TRUE;
+ }
+ break;
case WM_CLOSE:
- ErrorF ("winAboutDlgProc - WM_CLOSE\n");
+ ErrorF("winAboutDlgProc - WM_CLOSE\n");
- DestroyWindow (g_hDlgAbout);
- g_hDlgAbout = NULL;
+ DestroyWindow(g_hDlgAbout);
+ g_hDlgAbout = NULL;
- /* Fix to make sure keyboard focus isn't trapped */
- PostMessage (s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
+ /* Fix to make sure keyboard focus isn't trapped */
+ PostMessage(s_pScreenPriv->hwndScreen, WM_NULL, 0, 0);
- /* Restore window procedures for URL buttons */
- winUnoverrideURLButton (hwndDialog, ID_ABOUT_CHANGELOG);
- winUnoverrideURLButton (hwndDialog, ID_ABOUT_WEBSITE);
- winUnoverrideURLButton (hwndDialog, ID_ABOUT_UG);
- winUnoverrideURLButton (hwndDialog, ID_ABOUT_FAQ);
+ /* Restore window procedures for URL buttons */
+ winUnoverrideURLButton(hwndDialog, ID_ABOUT_CHANGELOG);
+ winUnoverrideURLButton(hwndDialog, ID_ABOUT_WEBSITE);
+ winUnoverrideURLButton(hwndDialog, ID_ABOUT_UG);
+ winUnoverrideURLButton(hwndDialog, ID_ABOUT_FAQ);
- return TRUE;
+ return TRUE;
}
- return FALSE;
+ return FALSE;
}
diff --git a/xorg-server/hw/xwin/winengine.c b/xorg-server/hw/xwin/winengine.c
index 3f5048dcd..b118864bb 100644
--- a/xorg-server/hw/xwin/winengine.c
+++ b/xorg-server/hw/xwin/winengine.c
@@ -38,8 +38,8 @@
* Global variables for function pointers into
* dynamically loaded libraries
*/
-FARPROC g_fpDirectDrawCreate = NULL;
-FARPROC g_fpDirectDrawCreateClipper = NULL;
+FARPROC g_fpDirectDrawCreate = NULL;
+FARPROC g_fpDirectDrawCreateClipper = NULL;
/*
module handle for dynamically loaded directdraw library
@@ -52,86 +52,82 @@ static HMODULE g_hmodDirectDraw = NULL;
*/
void
-winDetectSupportedEngines (void)
+winDetectSupportedEngines(void)
{
- OSVERSIONINFO osvi;
+ OSVERSIONINFO osvi;
- /* Initialize the engine support flags */
- g_dwEnginesSupported = WIN_SERVER_SHADOW_GDI;
+ /* Initialize the engine support flags */
+ g_dwEnginesSupported = WIN_SERVER_SHADOW_GDI;
#ifdef XWIN_NATIVEGDI
- g_dwEnginesSupported |= WIN_SERVER_NATIVE_GDI;
+ g_dwEnginesSupported |= WIN_SERVER_NATIVE_GDI;
#endif
- /* Get operating system version information */
- ZeroMemory (&osvi, sizeof (osvi));
- osvi.dwOSVersionInfoSize = sizeof (osvi);
- GetVersionEx (&osvi);
-
- /* Do we have DirectDraw? */
- if (g_hmodDirectDraw != NULL)
- {
- LPDIRECTDRAW lpdd = NULL;
- LPDIRECTDRAW4 lpdd4 = NULL;
- HRESULT ddrval;
-
- /* Was the DirectDrawCreate function found? */
- if (g_fpDirectDrawCreate == NULL)
- {
- /* No DirectDraw support */
- return;
- }
-
- /* DirectDrawCreate exists, try to call it */
- /* Create a DirectDraw object, store the address at lpdd */
- ddrval = (*g_fpDirectDrawCreate) (NULL,
- (void**) &lpdd,
- NULL);
- if (FAILED (ddrval))
- {
- /* No DirectDraw support */
- winDebug ("winDetectSupportedEngines - DirectDraw not installed\n");
- return;
- }
- else
- {
- /* We have DirectDraw */
- winDebug ("winDetectSupportedEngines - DirectDraw installed\n");
- g_dwEnginesSupported |= WIN_SERVER_SHADOW_DD;
+ /* Get operating system version information */
+ ZeroMemory(&osvi, sizeof(osvi));
+ osvi.dwOSVersionInfoSize = sizeof(osvi);
+ GetVersionEx(&osvi);
+
+ /* Do we have DirectDraw? */
+ if (g_hmodDirectDraw != NULL) {
+ LPDIRECTDRAW lpdd = NULL;
+ LPDIRECTDRAW4 lpdd4 = NULL;
+ HRESULT ddrval;
+
+ /* Was the DirectDrawCreate function found? */
+ if (g_fpDirectDrawCreate == NULL) {
+ /* No DirectDraw support */
+ return;
+ }
+
+ /* DirectDrawCreate exists, try to call it */
+ /* Create a DirectDraw object, store the address at lpdd */
+ ddrval = (*g_fpDirectDrawCreate) (NULL, (void **) &lpdd, NULL);
+ if (FAILED(ddrval)) {
+ /* No DirectDraw support */
+ winDebug (
+ "winDetectSupportedEngines - DirectDraw not installed\n");
+ return;
+ }
+ else {
+ /* We have DirectDraw */
+ winDebug (
+ "winDetectSupportedEngines - DirectDraw installed\n");
+ g_dwEnginesSupported |= WIN_SERVER_SHADOW_DD;
#ifdef XWIN_PRIMARYFB
- /* Allow PrimaryDD engine if NT */
- if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT)
- {
- g_dwEnginesSupported |= WIN_SERVER_PRIMARY_DD;
- winDebug ("winDetectSupportedEngines - Allowing PrimaryDD\n");
- }
+ /* Allow PrimaryDD engine if NT */
+ if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT) {
+ g_dwEnginesSupported |= WIN_SERVER_PRIMARY_DD;
+ winDebug (
+ "winDetectSupportedEngines - Allowing PrimaryDD\n");
+ }
#endif
- }
-
- /* Try to query for DirectDraw4 interface */
- ddrval = IDirectDraw_QueryInterface (lpdd,
- &IID_IDirectDraw4,
- (LPVOID*) &lpdd4);
- if (SUCCEEDED (ddrval))
- {
- /* We have DirectDraw4 */
- winDebug ("winDetectSupportedEngines - DirectDraw4 installed\n");
- g_dwEnginesSupported |= WIN_SERVER_SHADOW_DDNL;
- }
-
- /* Cleanup DirectDraw interfaces */
- if (lpdd4 != NULL)
- IDirectDraw_Release (lpdd4);
- if (lpdd != NULL)
- IDirectDraw_Release (lpdd);
+ }
+
+ /* Try to query for DirectDraw4 interface */
+ ddrval = IDirectDraw_QueryInterface(lpdd,
+ &IID_IDirectDraw4,
+ (LPVOID *) & lpdd4);
+ if (SUCCEEDED(ddrval)) {
+ /* We have DirectDraw4 */
+ winDebug (
+ "winDetectSupportedEngines - DirectDraw4 installed\n");
+ g_dwEnginesSupported |= WIN_SERVER_SHADOW_DDNL;
+ }
+
+ /* Cleanup DirectDraw interfaces */
+ if (lpdd4 != NULL)
+ IDirectDraw_Release(lpdd4);
+ if (lpdd != NULL)
+ IDirectDraw_Release(lpdd);
}
- winDebug ("winDetectSupportedEngines - Returning, supported engines %08x\n",
- (unsigned int) g_dwEnginesSupported);
+ winDebug (
+ "winDetectSupportedEngines - Returning, supported engines %08x\n",
+ (unsigned int) g_dwEnginesSupported);
}
-
/*
* Set the engine type, depending on the engines
* supported for this screen, and whether the user
@@ -139,197 +135,183 @@ winDetectSupportedEngines (void)
*/
Bool
-winSetEngine (ScreenPtr pScreen)
+winSetEngine(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- HDC hdc;
- DWORD dwBPP;
-
- /* Get a DC */
- hdc = GetDC (NULL);
- if (hdc == NULL)
- {
- ErrorF ("winSetEngine - Couldn't get an HDC\n");
- return FALSE;
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ HDC hdc;
+ DWORD dwBPP;
+
+ /* Get a DC */
+ hdc = GetDC(NULL);
+ if (hdc == NULL) {
+ ErrorF("winSetEngine - Couldn't get an HDC\n");
+ return FALSE;
}
- /*
- * pScreenInfo->dwBPP may be 0 to indicate that the current screen
- * depth is to be used. Thus, we must query for the current display
- * depth here.
- */
- dwBPP = GetDeviceCaps (hdc, BITSPIXEL);
-
- /* Release the DC */
- ReleaseDC (NULL, hdc);
- hdc = NULL;
-
- /* ShadowGDI is the only engine that supports windowed PseudoColor */
- if (dwBPP == 8 && !pScreenInfo->fFullScreen)
- {
- winDebug ("winSetEngine - Windowed && PseudoColor => ShadowGDI\n");
- pScreenInfo->dwEngine = WIN_SERVER_SHADOW_GDI;
-
- /* Set engine function pointers */
- winSetEngineFunctionsShadowGDI (pScreen);
- return TRUE;
+ /*
+ * pScreenInfo->dwBPP may be 0 to indicate that the current screen
+ * depth is to be used. Thus, we must query for the current display
+ * depth here.
+ */
+ dwBPP = GetDeviceCaps(hdc, BITSPIXEL);
+
+ /* Release the DC */
+ ReleaseDC(NULL, hdc);
+ hdc = NULL;
+
+ /* ShadowGDI is the only engine that supports windowed PseudoColor */
+ if (dwBPP == 8 && !pScreenInfo->fFullScreen) {
+ winDebug (
+ "winSetEngine - Windowed && PseudoColor => ShadowGDI\n");
+ pScreenInfo->dwEngine = WIN_SERVER_SHADOW_GDI;
+
+ /* Set engine function pointers */
+ winSetEngineFunctionsShadowGDI(pScreen);
+ return TRUE;
}
- /* ShadowGDI is the only engine that supports Multi Window Mode */
- if (
- FALSE
+ /* ShadowGDI is the only engine that supports Multi Window Mode */
+ if (FALSE
#ifdef XWIN_MULTIWINDOWEXTWM
- || pScreenInfo->fMWExtWM
+ || pScreenInfo->fMWExtWM
#endif
#ifdef XWIN_MULTIWINDOW
- || pScreenInfo->fMultiWindow
+ || pScreenInfo->fMultiWindow
#endif
- )
- {
- winDebug ("winSetEngine - Multi Window or Rootless => ShadowGDI\n");
- pScreenInfo->dwEngine = WIN_SERVER_SHADOW_GDI;
-
- /* Set engine function pointers */
- winSetEngineFunctionsShadowGDI (pScreen);
- return TRUE;
+ ) {
+ winDebug (
+ "winSetEngine - Multi Window or Rootless => ShadowGDI\n");
+ pScreenInfo->dwEngine = WIN_SERVER_SHADOW_GDI;
+
+ /* Set engine function pointers */
+ winSetEngineFunctionsShadowGDI(pScreen);
+ return TRUE;
}
/* If there is a user's choice, we'll use that */
- if (pScreenInfo->dwEnginePreferred)
- {
- winDebug ("winSetEngine - Using user's preference: %d\n",
- (int) pScreenInfo->dwEnginePreferred);
- pScreenInfo->dwEngine = pScreenInfo->dwEnginePreferred;
-
- /* Setup engine function pointers */
- switch (pScreenInfo->dwEngine)
- {
- case WIN_SERVER_SHADOW_GDI:
- winSetEngineFunctionsShadowGDI (pScreen);
- break;
- case WIN_SERVER_SHADOW_DD:
- winSetEngineFunctionsShadowDD (pScreen);
- break;
- case WIN_SERVER_SHADOW_DDNL:
- winSetEngineFunctionsShadowDDNL (pScreen);
- break;
+ if (pScreenInfo->dwEnginePreferred) {
+ winDebug ("winSetEngine - Using user's preference: %d\n",
+ (int) pScreenInfo->dwEnginePreferred);
+ pScreenInfo->dwEngine = pScreenInfo->dwEnginePreferred;
+
+ /* Setup engine function pointers */
+ switch (pScreenInfo->dwEngine) {
+ case WIN_SERVER_SHADOW_GDI:
+ winSetEngineFunctionsShadowGDI(pScreen);
+ break;
+ case WIN_SERVER_SHADOW_DD:
+ winSetEngineFunctionsShadowDD(pScreen);
+ break;
+ case WIN_SERVER_SHADOW_DDNL:
+ winSetEngineFunctionsShadowDDNL(pScreen);
+ break;
#ifdef XWIN_PRIMARYFB
- case WIN_SERVER_PRIMARY_DD:
- winSetEngineFunctionsPrimaryDD (pScreen);
- break;
+ case WIN_SERVER_PRIMARY_DD:
+ winSetEngineFunctionsPrimaryDD(pScreen);
+ break;
#endif
#ifdef XWIN_NATIVEGDI
- case WIN_SERVER_NATIVE_GDI:
- winSetEngineFunctionsNativeGDI (pScreen);
- break;
+ case WIN_SERVER_NATIVE_GDI:
+ winSetEngineFunctionsNativeGDI(pScreen);
+ break;
#endif
- default:
- FatalError ("winSetEngine - Invalid engine type %d\n",pScreenInfo->dwEngine);
- }
- return TRUE;
+ default:
+ FatalError ("winSetEngine - Invalid engine type %d\n",pScreenInfo->dwEngine);
+ }
+ return TRUE;
}
- /* ShadowDDNL has good performance, so why not */
- if (g_dwEnginesSupported & WIN_SERVER_SHADOW_DDNL)
- {
- winDebug ("winSetEngine - Using Shadow DirectDraw NonLocking\n");
- pScreenInfo->dwEngine = WIN_SERVER_SHADOW_DDNL;
+ /* ShadowDDNL has good performance, so why not */
+ if (g_dwEnginesSupported & WIN_SERVER_SHADOW_DDNL) {
+ winDebug ("winSetEngine - Using Shadow DirectDraw NonLocking\n");
+ pScreenInfo->dwEngine = WIN_SERVER_SHADOW_DDNL;
- /* Set engine function pointers */
- winSetEngineFunctionsShadowDDNL (pScreen);
- return TRUE;
+ /* Set engine function pointers */
+ winSetEngineFunctionsShadowDDNL(pScreen);
+ return TRUE;
}
- /* ShadowDD is next in line */
- if (g_dwEnginesSupported & WIN_SERVER_SHADOW_DD)
- {
- winDebug ("winSetEngine - Using Shadow DirectDraw\n");
- pScreenInfo->dwEngine = WIN_SERVER_SHADOW_DD;
+ /* ShadowDD is next in line */
+ if (g_dwEnginesSupported & WIN_SERVER_SHADOW_DD) {
+ winDebug ("winSetEngine - Using Shadow DirectDraw\n");
+ pScreenInfo->dwEngine = WIN_SERVER_SHADOW_DD;
- /* Set engine function pointers */
- winSetEngineFunctionsShadowDD (pScreen);
- return TRUE;
+ /* Set engine function pointers */
+ winSetEngineFunctionsShadowDD(pScreen);
+ return TRUE;
}
- /* ShadowGDI is next in line */
- if (g_dwEnginesSupported & WIN_SERVER_SHADOW_GDI)
- {
- winDebug ("winSetEngine - Using Shadow GDI DIB\n");
- pScreenInfo->dwEngine = WIN_SERVER_SHADOW_GDI;
+ /* ShadowGDI is next in line */
+ if (g_dwEnginesSupported & WIN_SERVER_SHADOW_GDI) {
+ winDebug ("winSetEngine - Using Shadow GDI DIB\n");
+ pScreenInfo->dwEngine = WIN_SERVER_SHADOW_GDI;
- /* Set engine function pointers */
- winSetEngineFunctionsShadowGDI (pScreen);
- return TRUE;
+ /* Set engine function pointers */
+ winSetEngineFunctionsShadowGDI(pScreen);
+ return TRUE;
}
- return TRUE;
+ return TRUE;
}
-
/*
* Get procedure addresses for DirectDrawCreate and DirectDrawCreateClipper
*/
Bool
-winGetDDProcAddresses (void)
+winGetDDProcAddresses(void)
{
- Bool fReturn = TRUE;
-
- /* Load the DirectDraw library */
- g_hmodDirectDraw = LoadLibraryEx ("ddraw.dll", NULL, 0);
- if (g_hmodDirectDraw == NULL)
- {
- ErrorF ("winGetDDProcAddresses - Could not load ddraw.dll\n");
- fReturn = TRUE;
- goto winGetDDProcAddresses_Exit;
+ Bool fReturn = TRUE;
+
+ /* Load the DirectDraw library */
+ g_hmodDirectDraw = LoadLibraryEx("ddraw.dll", NULL, 0);
+ if (g_hmodDirectDraw == NULL) {
+ ErrorF("winGetDDProcAddresses - Could not load ddraw.dll\n");
+ fReturn = TRUE;
+ goto winGetDDProcAddresses_Exit;
}
- /* Try to get the DirectDrawCreate address */
- g_fpDirectDrawCreate = GetProcAddress (g_hmodDirectDraw,
- "DirectDrawCreate");
- if (g_fpDirectDrawCreate == NULL)
- {
- ErrorF ("winGetDDProcAddresses - Could not get DirectDrawCreate "
- "address\n");
- fReturn = TRUE;
- goto winGetDDProcAddresses_Exit;
+ /* Try to get the DirectDrawCreate address */
+ g_fpDirectDrawCreate = GetProcAddress(g_hmodDirectDraw, "DirectDrawCreate");
+ if (g_fpDirectDrawCreate == NULL) {
+ ErrorF("winGetDDProcAddresses - Could not get DirectDrawCreate "
+ "address\n");
+ fReturn = TRUE;
+ goto winGetDDProcAddresses_Exit;
}
- /* Try to get the DirectDrawCreateClipper address */
- g_fpDirectDrawCreateClipper = GetProcAddress (g_hmodDirectDraw,
- "DirectDrawCreateClipper");
- if (g_fpDirectDrawCreateClipper == NULL)
- {
- ErrorF ("winGetDDProcAddresses - Could not get "
- "DirectDrawCreateClipper address\n");
- fReturn = FALSE;
- goto winGetDDProcAddresses_Exit;
+ /* Try to get the DirectDrawCreateClipper address */
+ g_fpDirectDrawCreateClipper = GetProcAddress(g_hmodDirectDraw,
+ "DirectDrawCreateClipper");
+ if (g_fpDirectDrawCreateClipper == NULL) {
+ ErrorF("winGetDDProcAddresses - Could not get "
+ "DirectDrawCreateClipper address\n");
+ fReturn = FALSE;
+ goto winGetDDProcAddresses_Exit;
}
- /*
- * Note: Do not unload ddraw.dll here. Do it in GiveUp
- */
+ /*
+ * Note: Do not unload ddraw.dll here. Do it in GiveUp
+ */
winGetDDProcAddresses_Exit:
- /* Unload the DirectDraw library if we failed to initialize */
- if (!fReturn && g_hmodDirectDraw != NULL)
- {
- FreeLibrary (g_hmodDirectDraw);
- g_hmodDirectDraw = NULL;
+ /* Unload the DirectDraw library if we failed to initialize */
+ if (!fReturn && g_hmodDirectDraw != NULL) {
+ FreeLibrary(g_hmodDirectDraw);
+ g_hmodDirectDraw = NULL;
}
-
- return fReturn;
+
+ return fReturn;
}
void
winReleaseDDProcAddresses(void)
{
- if (g_hmodDirectDraw != NULL)
- {
- FreeLibrary (g_hmodDirectDraw);
- g_hmodDirectDraw = NULL;
- g_fpDirectDrawCreate = NULL;
- g_fpDirectDrawCreateClipper = NULL;
+ if (g_hmodDirectDraw != NULL) {
+ FreeLibrary(g_hmodDirectDraw);
+ g_hmodDirectDraw = NULL;
+ g_fpDirectDrawCreate = NULL;
+ g_fpDirectDrawCreateClipper = NULL;
}
}
diff --git a/xorg-server/hw/xwin/winerror.c b/xorg-server/hw/xwin/winerror.c
index e95be3f4c..48c963d62 100644
--- a/xorg-server/hw/xwin/winerror.c
+++ b/xorg-server/hw/xwin/winerror.c
@@ -39,18 +39,18 @@ extern Bool g_fSilentDupError;
#ifdef DDXOSVERRORF
/* Prototype */
void
-OsVendorVErrorF (const char *pszFormat, va_list va_args);
+ OsVendorVErrorF(const char *pszFormat, va_list va_args);
void
-OsVendorVErrorF (const char *pszFormat, va_list va_args)
+OsVendorVErrorF(const char *pszFormat, va_list va_args)
{
#if defined(XWIN_CLIPBOARD) || defined (XWIN_MULTIWINDOW)
- /* make sure the clipboard and multiwindow threads do not interfere the
- * main thread */
- static pthread_mutex_t s_pmPrinting = PTHREAD_MUTEX_INITIALIZER;
+ /* make sure the clipboard and multiwindow threads do not interfere the
+ * main thread */
+ static pthread_mutex_t s_pmPrinting = PTHREAD_MUTEX_INITIALIZER;
- /* Lock the printing mutex */
- pthread_mutex_lock (&s_pmPrinting);
+ /* Lock the printing mutex */
+ pthread_mutex_lock(&s_pmPrinting);
#endif
/*
@@ -71,17 +71,16 @@ OsVendorVErrorF (const char *pszFormat, va_list va_args)
}
}
- /* Print the error message to a log file, could be stderr */
- LogVWrite (0, pszFormat, va_args);
+ /* Print the error message to a log file, could be stderr */
+ LogVWrite(0, pszFormat, va_args);
#if defined(XWIN_CLIPBOARD) || defined (XWIN_MULTIWINDOW)
- /* Unlock the printing mutex */
- pthread_mutex_unlock (&s_pmPrinting);
+ /* Unlock the printing mutex */
+ pthread_mutex_unlock(&s_pmPrinting);
#endif
}
#endif
-
/*
* os/util.c/FatalError () calls our vendor ErrorF, so the message
* from a FatalError will be logged. Thus, the message for the
@@ -91,17 +90,17 @@ OsVendorVErrorF (const char *pszFormat, va_list va_args)
*/
char g_FatalErrorMessage[1024];
void
-OsVendorFatalError (void)
+OsVendorFatalError(void)
{
- /* Don't give duplicate warning if UseMsg was called */
- if (g_fSilentFatalError)
- return;
+ /* Don't give duplicate warning if UseMsg was called */
+ if (g_fSilentFatalError)
+ return;
- if (!g_fLogInited) {
- g_fLogInited = TRUE;
- g_pszLogFile = LogInit (g_pszLogFile, NULL);
- }
- LogClose (EXIT_ERR_ABORT);
+ if (!g_fLogInited) {
+ g_fLogInited = TRUE;
+ g_pszLogFile = LogInit(g_pszLogFile, NULL);
+ }
+ LogClose(EXIT_ERR_ABORT);
winMessageBoxF (
"A fatal error has occurred and " PROJECT_NAME " will now exit.\n" \
@@ -110,27 +109,26 @@ OsVendorFatalError (void)
MB_ICONERROR, g_FatalErrorMessage, (g_pszLogFile?g_pszLogFile:"the logfile"));
}
-
/*
* winMessageBoxF - Print a formatted error message in a useful
* message box.
*/
void
-winMessageBoxF (const char *pszError, UINT uType, ...)
+winMessageBoxF(const char *pszError, UINT uType, ...)
{
- char * pszErrorF = NULL;
- char * pszMsgBox = NULL;
- va_list args;
- int size;
-
- va_start(args, uType);
- size = vasprintf (&pszErrorF, pszError, args);
- va_end(args);
- if (size == -1) {
- pszErrorF = NULL;
- goto winMessageBoxF_Cleanup;
- }
+ char *pszErrorF = NULL;
+ char *pszMsgBox = NULL;
+ va_list args;
+ int size;
+
+ va_start(args, uType);
+ size = vasprintf(&pszErrorF, pszError, args);
+ va_end(args);
+ if (size == -1) {
+ pszErrorF = NULL;
+ goto winMessageBoxF_Cleanup;
+ }
#define MESSAGEBOXF \
"%s\n" \
@@ -141,27 +139,22 @@ winMessageBoxF (const char *pszError, UINT uType, ...)
"XWin was started with the following command-line:\n\n" \
"%s\n"
- size = asprintf (&pszMsgBox, MESSAGEBOXF,
- pszErrorF, XVENDORNAME,
- XORG_VERSION_MAJOR, XORG_VERSION_MINOR, XORG_VERSION_PATCH,
+ size = asprintf(&pszMsgBox, MESSAGEBOXF,
+ pszErrorF, XVENDORNAME,
+ XORG_VERSION_MAJOR, XORG_VERSION_MINOR, XORG_VERSION_PATCH,
XORG_VERSION_SNAP,
- BUILDERADDR,
- BUILDERSTRING,
- g_pszCommandLine);
+ BUILDERADDR, BUILDERSTRING, g_pszCommandLine);
- if (size == -1) {
- pszMsgBox = NULL;
- goto winMessageBoxF_Cleanup;
- }
+ if (size == -1) {
+ pszMsgBox = NULL;
+ goto winMessageBoxF_Cleanup;
+ }
- /* Display the message box string */
- MessageBox (NULL,
- pszMsgBox,
- PROJECT_NAME,
- MB_OK | uType);
+ /* Display the message box string */
+ MessageBox(NULL, pszMsgBox, PROJECT_NAME, MB_OK | uType);
winMessageBoxF_Cleanup:
- free(pszErrorF);
- free(pszMsgBox);
+ free(pszErrorF);
+ free(pszMsgBox);
#undef MESSAGEBOXF
}
diff --git a/xorg-server/hw/xwin/winfillsp.c b/xorg-server/hw/xwin/winfillsp.c
index 1cc91e62a..f2432ed23 100644
--- a/xorg-server/hw/xwin/winfillsp.c
+++ b/xorg-server/hw/xwin/winfillsp.c
@@ -1,831 +1,842 @@
-/*
- *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, sublicense, and/or sell copies of the Software, and to
- *permit persons to whom the Software is furnished to do so, subject to
- *the following conditions:
- *
- *The above copyright notice and this permission notice shall be
- *included in all copies or substantial portions of the Software.
- *
- *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
- *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *Except as contained in this notice, the name of the XFree86 Project
- *shall not be used in advertising or otherwise to promote the sale, use
- *or other dealings in this Software without prior written authorization
- *from the XFree86 Project.
- *
- * Authors: Harold L Hunt II
- * Alan Hourihane <alanh@fairlite.demon.co.uk>
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-
-
-extern void ROP16(HDC hdc, int rop);
-
-#define TRANSLATE_COLOR(color) \
-{ \
- if (pDrawable->depth == 15) \
- color = ((color & 0x1F) << 19) | ((color & 0x03E0) << 6) | \
- ((color & 0xF800) >> 8); \
- else if (pDrawable->depth == 16) \
- color = ((color & 0x1F) << 19) | ((color & 0x07E0) << 5) | \
- ((color & 0xF800) >> 8); \
- else if (pDrawable->depth == 24 || pDrawable->depth == 32) \
- color = ((color & 0xFF) << 16) | (color & 0xFF00) | \
- ((color & 0xFF0000) >> 16); \
-}
-
-/* See Porting Layer Definition - p. 54 */
-void
-winFillSpansNativeGDI (DrawablePtr pDrawable,
- GCPtr pGC,
- int iSpans,
- DDXPointPtr pPoints,
- int *piWidths,
- int fSorted)
-{
- winGCPriv(pGC);
- HBITMAP hbmpOrig = NULL, hbmpOrigStipple = NULL;
- HBITMAP hPenOrig = NULL;
- HBITMAP hBitmap = NULL;
- PixmapPtr pPixmap = NULL;
- winPrivPixmapPtr pPixmapPriv = NULL;
- PixmapPtr pStipple = NULL;
- winPrivPixmapPtr pStipplePriv = NULL;
- PixmapPtr pTile = NULL;
- winPrivPixmapPtr pTilePriv = NULL;
- HDC hdcStipple = NULL, hdcTile = NULL;
- HPEN hPen = NULL;
- int iX;
- int fg, bg;
- RegionPtr pClip = pGC->pCompositeClip;
- BoxPtr pextent, pbox;
- int nbox;
- int extentX1, extentX2, extentY1, extentY2;
- int fullX1, fullX2, fullY1;
- HRGN hrgn = NULL, combined = NULL;
-
- nbox = RegionNumRects (pClip);
- pbox = RegionRects (pClip);
-
- if (!nbox) return;
-
- combined = CreateRectRgn (pbox->x1, pbox->y1, pbox->x2, pbox->y2);
- nbox--; pbox++;
-
- while (nbox--)
- {
- hrgn = CreateRectRgn (pbox->x1, pbox->y1, pbox->x2, pbox->y2);
- CombineRgn (combined, combined, hrgn, RGN_OR);
- DeleteObject (hrgn);
- hrgn = NULL;
- pbox++;
- }
-
- pextent = RegionExtents(pClip);
- extentX1 = pextent->x1;
- extentY1 = pextent->y1;
- extentX2 = pextent->x2;
- extentY2 = pextent->y2;
-
- /* Branch on the type of drawable we have */
- switch (pDrawable->type)
- {
- case DRAWABLE_PIXMAP:
-
- SelectClipRgn (pGCPriv->hdcMem, combined);
- DeleteObject (combined);
- combined = NULL;
-
- /* Get a pixmap pointer from the drawable pointer, and fetch privates */
- pPixmap = (PixmapPtr) pDrawable;
- pPixmapPriv = winGetPixmapPriv (pPixmap);
-
- /* Select the drawable pixmap into memory hdc */
- hbmpOrig = SelectObject (pGCPriv->hdcMem, pPixmapPriv->hBitmap);
- if (hbmpOrig == NULL)
- FatalError ("winFillSpans - DRAWABLE_PIXMAP - "
- "SelectObject () failed on\n\tpPixmapPriv->hBitmap: "
- "%08x\n", (unsigned int) pPixmapPriv->hBitmap);
-
- /* Branch on the fill type */
- switch (pGC->fillStyle)
- {
- case FillSolid:
-
- ROP16 (pGCPriv->hdcMem, pGC->alu);
-
- if (pDrawable->depth == 1)
- {
- if (pGC->fgPixel == 0)
- hPenOrig = SelectObject (pGCPriv->hdcMem,
- GetStockObject (BLACK_PEN));
- else
- hPenOrig = SelectObject (pGCPriv->hdcMem,
- GetStockObject (WHITE_PEN));
- }
- else
- {
- fg = pGC->fgPixel;
- TRANSLATE_COLOR (fg);
- hPen = CreatePen (PS_SOLID, 0, fg);
- hPenOrig = SelectObject (pGCPriv->hdcMem, hPen);
- }
-
- while (iSpans--)
- {
- fullX1 = pPoints->x;
- fullY1 = pPoints->y;
- fullX2 = fullX1 + (int) *piWidths;
- pPoints++;
- piWidths++;
-
- if (fullY1 < extentY1 || extentY2 <= fullY1)
- continue;
-
- if (fullX1 < extentX1)
- fullX1 = extentX1;
- if (fullX2 > extentX2)
- fullX2 = extentX2;
-
- if (fullX1 >= fullX2)
- continue;
-
- MoveToEx (pGCPriv->hdcMem, fullX1, fullY1, NULL);
- LineTo (pGCPriv->hdcMem, fullX2, fullY1);
- }
-
- SetROP2 (pGCPriv->hdcMem, R2_COPYPEN);
-
- /* Give back the Pen */
- SelectObject (pGCPriv->hdcMem, hPenOrig);
-
- if (pDrawable->depth != 1)
- DeleteObject (hPen);
- break;
-
- case FillOpaqueStippled:
-
- pStipple = pGC->stipple;
- pStipplePriv = winGetPixmapPriv (pStipple);
-
- /* Create a device-dependent bitmap for the stipple */
- hBitmap = CreateDIBitmap (pGCPriv->hdcMem,
- (BITMAPINFOHEADER *)pStipplePriv->pbmih,
- CBM_INIT,
- pStipplePriv->pbBits,
- (BITMAPINFO *)pStipplePriv->pbmih,
- DIB_RGB_COLORS);
-
- /* Create a memory DC to hold the stipple */
- hdcStipple = CreateCompatibleDC (pGCPriv->hdcMem);
-
- /* Select the stipple bitmap into the stipple DC */
- hbmpOrigStipple = SelectObject (hdcStipple, hBitmap);
- if (hbmpOrigStipple == NULL)
- FatalError ("winFillSpans () - DRAWABLE_PIXMAP - FillStippled - "
- "SelectObject () failed on hbmpOrigStipple\n");
-
- /* Make a temporary copy of the foreground and background colors */
- bg = pGC->bgPixel;
- fg = pGC->fgPixel;
-
- /* Translate the depth-dependent colors to Win32 COLORREFs */
- TRANSLATE_COLOR (fg);
- TRANSLATE_COLOR (bg);
- SetTextColor (pGCPriv->hdcMem, fg);
- SetBkColor (pGCPriv->hdcMem, bg);
-
- while (iSpans--)
- {
- int width = pStipple->drawable.width;
- fullX1 = pPoints->x;
- fullY1 = pPoints->y;
- fullX2 = fullX1 + (int) *piWidths;
- pPoints++;
- piWidths++;
-
- if (fullY1 < extentY1 || extentY2 <= fullY1)
- continue;
-
- if (fullX1 < extentX1)
- fullX1 = extentX1;
- if (fullX2 > extentX2)
- fullX2 = extentX2;
-
- if (fullX1 >= fullX2)
- continue;
-
- for (iX = fullX1; iX < fullX2; iX += width)
- {
- int xoffset;
-
- if ((iX + pStipple->drawable.width) > fullX2)
- width = fullX2 - iX;
- else
- width = pStipple->drawable.width;
-
- if (iX == fullX1)
- xoffset = (fullX1 - (pDrawable->x + (pGC->patOrg.x % pStipple->drawable.width) - pStipple->drawable.width)) % pStipple->drawable.width;
- else
- xoffset = 0;
-
- if (xoffset + width > pStipple->drawable.width)
- width = pStipple->drawable.width - xoffset;
-
- BitBlt (pGCPriv->hdcMem,
- iX, fullY1,
- width, 1,
- hdcStipple,
- xoffset,
- (fullY1 - (pDrawable->y + (pGC->patOrg.y % pStipple->drawable.height) - pStipple->drawable.height)) % pStipple->drawable.height,
- g_copyROP[pGC->alu]);
- }
- }
-
- /* Clear the stipple HDC */
- SelectObject (hdcStipple, hbmpOrigStipple);
- DeleteDC (hdcStipple);
-
- /* Delete the device dependent stipple bitmap */
- DeleteObject (hBitmap);
-
- break;
- case FillStippled:
-
- pStipple = pGC->stipple;
- pStipplePriv = winGetPixmapPriv (pStipple);
-
- /* Create a device-dependent bitmap for the stipple */
- hBitmap = CreateDIBitmap (pGCPriv->hdcMem,
- (BITMAPINFOHEADER *)pStipplePriv->pbmih,
- CBM_INIT,
- pStipplePriv->pbBits,
- (BITMAPINFO *)pStipplePriv->pbmih,
- DIB_RGB_COLORS);
-
- /* Create a memory DC to hold the stipple */
- hdcStipple = CreateCompatibleDC (pGCPriv->hdcMem);
-
- /* Select the stipple bitmap into the stipple DC */
- hbmpOrigStipple = SelectObject (hdcStipple, hBitmap);
- if (hbmpOrigStipple == NULL)
- FatalError ("winFillSpans () - DRAWABLE_PIXMAP - FillStippled - "
- "SelectObject () failed on hbmpOrigStipple\n");
-
- /* Make a temporary copy of the foreground and background colors */
- bg = pGC->bgPixel;
- fg = pGC->fgPixel;
-
- /* Translate the depth-dependent colors to Win32 COLORREFs */
- TRANSLATE_COLOR (fg);
- TRANSLATE_COLOR (bg);
-
- /* this is fudgy, we should only invert on the last one
- * We need to get the black/white pixels right in the
- * colormap. But yeah ! it's working..
- */
- if (pGC->bgPixel != -1 && pGC->fgPixel != -1)
- {
- SetTextColor (pGCPriv->hdcMem, fg);
- SetBkColor (pGCPriv->hdcMem, bg);
- BitBlt (hdcStipple,
- 0, 0,
- pStipple->drawable.width, pStipple->drawable.height,
- hdcStipple,
- 0, 0,
- 0x330008);
- }
- else if (pGC->bgPixel == -1)
- {
- SetTextColor (pGCPriv->hdcMem, fg);
- SetBkMode (pGCPriv->hdcMem, TRANSPARENT);
- BitBlt (hdcStipple,
- 0, 0,
- pStipple->drawable.width, pStipple->drawable.height,
- hdcStipple,
- 0, 0,
- 0x330008);
- }
- else if (pGC->fgPixel == -1)
- {
- SetTextColor (pGCPriv->hdcMem, bg);
- SetBkMode (pGCPriv->hdcMem, TRANSPARENT);
-#if 0
- BitBlt (hdcStipple,
- 0, 0,
- pStipple->drawable.width, pStipple->drawable.height,
- hdcStipple,
- 0, 0,
- 0x330008);
-#endif
- }
-
- while (iSpans--)
- {
- int width = pStipple->drawable.width;
- fullX1 = pPoints->x;
- fullY1 = pPoints->y;
- fullX2 = fullX1 + (int) *piWidths;
- pPoints++;
- piWidths++;
-
- if (fullY1 < extentY1 || extentY2 <= fullY1)
- continue;
-
- if (fullX1 < extentX1)
- fullX1 = extentX1;
- if (fullX2 > extentX2)
- fullX2 = extentX2;
-
- if (fullX1 >= fullX2)
- continue;
-
- for (iX = fullX1; iX < fullX2; iX += width)
- {
- int xoffset;
-
- if ((iX + pStipple->drawable.width) > fullX2)
- width = fullX2 - iX;
- else
- width = pStipple->drawable.width;
-
- if (iX == fullX1)
- xoffset = (fullX1 - (pDrawable->x + (pGC->patOrg.x % pStipple->drawable.width) - pStipple->drawable.width)) % pStipple->drawable.width;
- else
- xoffset = 0;
-
- if (xoffset + width > pStipple->drawable.width)
- width = pStipple->drawable.width - xoffset;
-
- BitBlt (pGCPriv->hdcMem,
- iX, fullY1,
- width, 1,
- hdcStipple,
- xoffset,
- (fullY1 - (pDrawable->y + (pGC->patOrg.y % pStipple->drawable.height) - pStipple->drawable.height)) % pStipple->drawable.height,
- g_copyROP[pGC->alu]);
- }
- }
-
- /* Clear the stipple HDC */
- SelectObject (hdcStipple, hbmpOrigStipple);
- DeleteDC (hdcStipple);
-
- /* Delete the device dependent stipple bitmap */
- DeleteObject (hBitmap);
-
- /* Restore the background mode */
- SetBkMode (pGCPriv->hdcMem, OPAQUE);
- break;
-
- case FillTiled:
-
- /* Get a pixmap pointer from the tile pointer, and fetch privates */
- pTile = (PixmapPtr) pGC->tile.pixmap;
- pTilePriv = winGetPixmapPriv (pTile);
-
- /* Create a memory DC to hold the tile */
- hdcTile = CreateCompatibleDC (pGCPriv->hdcMem);
-
- /* Select the tile into a DC */
- hbmpOrig = SelectObject (hdcTile, pTilePriv->hBitmap);
- if (hbmpOrig == NULL)
- FatalError ("winFillSpans - DRAWABLE_PIXMAP - FillTiled - "
- "SelectObject () failed on pTilePriv->hBitmap\n");
-
- while (iSpans--)
- {
- int width = pTile->drawable.width;
- fullX1 = pPoints->x;
- fullY1 = pPoints->y;
- fullX2 = fullX1 + (int) *piWidths;
- pPoints++;
- piWidths++;
-
- if (fullY1 < extentY1 || extentY2 <= fullY1)
- continue;
-
- if (fullX1 < extentX1)
- fullX1 = extentX1;
- if (fullX2 > extentX2)
- fullX2 = extentX2;
-
- if (fullX1 >= fullX2)
- continue;
-
- for (iX = fullX1; iX < fullX2; iX += width)
- {
- int xoffset;
-
- if ((iX + pTile->drawable.width) > fullX2)
- width = fullX2 - iX;
- else
- width = pTile->drawable.width;
-
- if (iX == fullX1)
- xoffset = (fullX1 - (pDrawable->x + (pGC->patOrg.x % pTile->drawable.width) - pTile->drawable.width)) % pTile->drawable.width;
- else
- xoffset = 0;
-
- if (xoffset + width > pTile->drawable.width)
- width = pTile->drawable.width - xoffset;
-
- BitBlt (pGCPriv->hdcMem,
- iX, fullY1,
- width, 1,
- hdcTile,
- xoffset,
- (fullY1 - (pDrawable->y + (pGC->patOrg.y % pTile->drawable.height) - pTile->drawable.height)) % pTile->drawable.height,
- g_copyROP[pGC->alu]);
- }
- }
-
- /* Push the tile pixmap out of the memory HDC */
- SelectObject (hdcTile, hbmpOrig);
-
- /* Delete the tile */
- DeleteDC (hdcTile);
- break;
-
- default:
- ErrorF ("winFillSpans - DRAWABLE_PIXMAP - Unknown fillStyle\n");
- break;
- }
-
- /* Reset clip region */
- SelectClipRgn (pGCPriv->hdcMem, NULL);
-
- /* Push the drawable pixmap out of the GC HDC */
- SelectObject (pGCPriv->hdcMem, hbmpOrig);
- break;
-
- case DRAWABLE_WINDOW:
-
- SelectClipRgn (pGCPriv->hdc, combined);
- DeleteObject (combined);
- combined = NULL;
-
- /* Branch on fill style */
- switch (pGC->fillStyle)
- {
- case FillSolid:
-
- ROP16 (pGCPriv->hdc, pGC->alu);
-
- if (pDrawable->depth == 1)
- {
- if (pGC->fgPixel == 0)
- hPenOrig = SelectObject (pGCPriv->hdc,
- GetStockObject (BLACK_PEN));
- else
- hPenOrig = SelectObject (pGCPriv->hdc,
- GetStockObject (WHITE_PEN));
- }
- else
- {
- fg = pGC->fgPixel;
- TRANSLATE_COLOR (fg);
- hPen = CreatePen (PS_SOLID, 0, fg);
- hPenOrig = SelectObject (pGCPriv->hdc, hPen);
- }
-
- while (iSpans--)
- {
- fullX1 = pPoints->x;
- fullY1 = pPoints->y;
- fullX2 = fullX1 + (int) *piWidths;
- pPoints++;
- piWidths++;
-
- if (fullY1 < extentY1 || extentY2 <= fullY1)
- continue;
-
- if (fullX1 < extentX1)
- fullX1 = extentX1;
- if (fullX2 > extentX2)
- fullX2 = extentX2;
-
- if (fullX1 >= fullX2)
- continue;
-
- MoveToEx (pGCPriv->hdc, fullX1, fullY1, NULL);
- LineTo (pGCPriv->hdc, fullX2, fullY1);
- }
-
- SetROP2 (pGCPriv->hdc, R2_COPYPEN);
-
- /* Give back the Brush */
- SelectObject (pGCPriv->hdc, hPenOrig);
-
- if (pDrawable->depth != 1)
- DeleteObject (hPen);
- break;
-
- case FillOpaqueStippled:
-
- pStipple = pGC->stipple;
- pStipplePriv = winGetPixmapPriv (pStipple);
-
- /* Create a device-dependent bitmap for the stipple */
- hBitmap = CreateDIBitmap (pGCPriv->hdc,
- (BITMAPINFOHEADER *)pStipplePriv->pbmih,
- CBM_INIT,
- pStipplePriv->pbBits,
- (BITMAPINFO *)pStipplePriv->pbmih,
- DIB_RGB_COLORS);
-
- /* Create a memory DC to hold the stipple */
- hdcStipple = CreateCompatibleDC (pGCPriv->hdc);
-
- /* Select the stipple bitmap into the stipple DC */
- hbmpOrigStipple = SelectObject (hdcStipple, hBitmap);
- if (hbmpOrigStipple == NULL)
- FatalError ("winFillSpans () - DRAWABLE_PIXMAP - FillStippled - "
- "SelectObject () failed on hbmpOrigStipple\n");
-
- /* Make a temporary copy of the foreground and background colors */
- bg = pGC->bgPixel;
- fg = pGC->fgPixel;
-
- /* Translate the depth-dependent colors to Win32 COLORREFs */
- TRANSLATE_COLOR (fg);
- TRANSLATE_COLOR (bg);
- SetTextColor (pGCPriv->hdc, fg);
- SetBkColor (pGCPriv->hdc, bg);
-
- while (iSpans--)
- {
- int width = pStipple->drawable.width;
- fullX1 = pPoints->x;
- fullY1 = pPoints->y;
- fullX2 = fullX1 + (int) *piWidths;
- pPoints++;
- piWidths++;
-
- if (fullY1 < extentY1 || extentY2 <= fullY1)
- continue;
-
- if (fullX1 < extentX1)
- fullX1 = extentX1;
- if (fullX2 > extentX2)
- fullX2 = extentX2;
-
- if (fullX1 >= fullX2)
- continue;
-
- for (iX = fullX1; iX < fullX2; iX += width)
- {
- int xoffset;
-
- if ((iX + pStipple->drawable.width) > fullX2)
- width = fullX2 - iX;
- else
- width = pStipple->drawable.width;
-
- if (iX == fullX1)
- xoffset = (fullX1 - (pDrawable->x + (pGC->patOrg.x % pStipple->drawable.width) - pStipple->drawable.width)) % pStipple->drawable.width;
- else
- xoffset = 0;
-
- if (xoffset + width > pStipple->drawable.width)
- width = pStipple->drawable.width - xoffset;
-
- BitBlt (pGCPriv->hdc,
- iX, fullY1,
- width, 1,
- hdcStipple,
- xoffset,
- (fullY1 - (pDrawable->y + (pGC->patOrg.y % pStipple->drawable.height) - pStipple->drawable.height)) % pStipple->drawable.height,
- g_copyROP[pGC->alu]);
- }
- }
-
- /* Clear the stipple HDC */
- SelectObject (hdcStipple, hbmpOrigStipple);
- DeleteDC (hdcStipple);
-
- /* Delete the device dependent stipple bitmap */
- DeleteObject (hBitmap);
-
- break;
-
- case FillStippled:
- pStipple = pGC->stipple;
- pStipplePriv = winGetPixmapPriv (pStipple);
-
- /* Create a device-dependent bitmap for the stipple */
- hBitmap = CreateDIBitmap (pGCPriv->hdcMem,
- (BITMAPINFOHEADER *)pStipplePriv->pbmih,
- CBM_INIT,
- pStipplePriv->pbBits,
- (BITMAPINFO *)pStipplePriv->pbmih,
- DIB_RGB_COLORS);
-
- /* Create a memory DC to hold the stipple */
- hdcStipple = CreateCompatibleDC (pGCPriv->hdc);
-
- /* Select the stipple bitmap into the stipple DC */
- hbmpOrigStipple = SelectObject (hdcStipple, hBitmap);
- if (hbmpOrigStipple == NULL)
- FatalError ("winFillSpans () - DRAWABLE_PIXMAP - FillStippled - "
- "SelectObject () failed on hbmpOrigStipple\n");
-
- /* Make a temporary copy of the foreground and background colors */
- bg = pGC->bgPixel;
- fg = pGC->fgPixel;
-
- /* Translate the depth-dependent colors to Win32 COLORREFs */
- TRANSLATE_COLOR (fg);
- TRANSLATE_COLOR (bg);
-
- /* this is fudgy, we should only invert on the last one
- * We need to get the black/white pixels right in the
- * colormap. But yeah ! it's working..
- */
- if (pGC->bgPixel != -1 && pGC->fgPixel != -1)
- {
- SetTextColor (pGCPriv->hdc, fg);
- SetBkColor (pGCPriv->hdc, bg);
- BitBlt (hdcStipple,
- 0, 0,
- pStipple->drawable.width, pStipple->drawable.height,
- hdcStipple,
- 0,0,
- 0x330008);
- }
- else if (pGC->bgPixel == -1)
- {
- SetTextColor (pGCPriv->hdc, fg);
- SetBkMode (pGCPriv->hdc, TRANSPARENT);
- BitBlt (hdcStipple,
- 0, 0,
- pStipple->drawable.width, pStipple->drawable.height,
- hdcStipple,
- 0,0,
- 0x330008);
- }
- else if (pGC->fgPixel == -1)
- {
- SetTextColor (pGCPriv->hdc, bg);
- SetBkMode (pGCPriv->hdc, TRANSPARENT);
-#if 0
- BitBlt (hdcStipple,
- 0, 0,
- pStipple->drawable.width, pStipple->drawable.height,
- hdcStipple,
- 0, 0,
- 0x330008);
-#endif
- }
-
- while (iSpans--)
- {
- int width = pStipple->drawable.width;
- fullX1 = pPoints->x;
- fullY1 = pPoints->y;
- fullX2 = fullX1 + (int) *piWidths;
- pPoints++;
- piWidths++;
-
- if (fullY1 < extentY1 || extentY2 <= fullY1)
- continue;
-
- if (fullX1 < extentX1)
- fullX1 = extentX1;
- if (fullX2 > extentX2)
- fullX2 = extentX2;
-
- if (fullX1 >= fullX2)
- continue;
-
- for (iX = fullX1; iX < fullX2; iX += width)
- {
- int xoffset;
-
- if ((iX + pStipple->drawable.width) > fullX2)
- width = fullX2 - iX;
- else
- width = pStipple->drawable.width;
-
- if (iX == fullX1)
- xoffset = (fullX1 - (pDrawable->x + (pGC->patOrg.x % pStipple->drawable.width) - pStipple->drawable.width)) % pStipple->drawable.width;
- else
- xoffset = 0;
-
- if (xoffset + width > pStipple->drawable.width)
- width = pStipple->drawable.width - xoffset;
-
- BitBlt (pGCPriv->hdc,
- iX, fullY1,
- width, 1,
- hdcStipple,
- xoffset,
- (fullY1 - (pDrawable->y + (pGC->patOrg.y % pStipple->drawable.height) - pStipple->drawable.height)) % pStipple->drawable.height,
- g_copyROP[pGC->alu]);
- }
- }
-
- /* Clear the stipple HDC */
- SelectObject (hdcStipple, hbmpOrigStipple);
- DeleteDC (hdcStipple);
-
- /* Delete the device dependent stipple bitmap */
- DeleteObject (hBitmap);
-
- /* Restore the background mode */
- SetBkMode (pGCPriv->hdc, OPAQUE);
- break;
-
- case FillTiled:
-
- /* Get a pixmap pointer from the tile pointer, and fetch privates */
- pTile = (PixmapPtr) pGC->tile.pixmap;
- pTilePriv = winGetPixmapPriv (pTile);
-
- /* Select the tile into a DC */
- hbmpOrig = SelectObject (pGCPriv->hdcMem, pTilePriv->hBitmap);
- if (hbmpOrig == NULL)
- FatalError ("winFillSpans - DRAWABLE_WINDOW - FillTiled - "
- "SelectObject () failed on pTilePriv->hBitmap\n");
-
- while (iSpans--)
- {
- int width = pTile->drawable.width;
- fullX1 = pPoints->x;
- fullY1 = pPoints->y;
- fullX2 = fullX1 + (int) *piWidths;
- pPoints++;
- piWidths++;
-
- if (fullY1 < extentY1 || extentY2 <= fullY1)
- continue;
-
- if (fullX1 < extentX1)
- fullX1 = extentX1;
- if (fullX2 > extentX2)
- fullX2 = extentX2;
-
- if (fullX1 >= fullX2)
- continue;
-
- for (iX = fullX1; iX < fullX2; iX += width)
- {
- int xoffset;
-
- if ((iX + pTile->drawable.width) > fullX2)
- width = fullX2 - iX;
- else
- width = pTile->drawable.width;
-
- if (iX == fullX1)
- xoffset = (fullX1 - (pDrawable->x + (pGC->patOrg.x % pTile->drawable.width) - pTile->drawable.width)) % pTile->drawable.width;
- else
- xoffset = 0;
-
- if (xoffset + width > pTile->drawable.width)
- width = pTile->drawable.width - xoffset;
-
- BitBlt (pGCPriv->hdc,
- iX, fullY1,
- width, 1,
- pGCPriv->hdcMem,
- xoffset,
- (fullY1 - (pDrawable->y + (pGC->patOrg.y % pTile->drawable.height) - pTile->drawable.height)) % pTile->drawable.height,
- g_copyROP[pGC->alu]);
- }
- }
-
- /* Push the tile pixmap out of the memory HDC */
- SelectObject (pGCPriv->hdcMem, hbmpOrig);
- break;
-
- default:
- ErrorF ("winFillSpans - DRAWABLE_WINDOW - Unknown fillStyle\n");
- break;
- }
-
- /* Reset clip region */
- SelectClipRgn (pGCPriv->hdc, NULL);
- break;
-
- default:
- ErrorF ("winFillSpans - Unknown drawable type\n");
- break;
- }
-}
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Harold L Hunt II
+ * Alan Hourihane <alanh@fairlite.demon.co.uk>
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+extern void ROP16(HDC hdc, int rop);
+
+#define TRANSLATE_COLOR(color) \
+{ \
+ if (pDrawable->depth == 15) \
+ color = ((color & 0x1F) << 19) | ((color & 0x03E0) << 6) | \
+ ((color & 0xF800) >> 8); \
+ else if (pDrawable->depth == 16) \
+ color = ((color & 0x1F) << 19) | ((color & 0x07E0) << 5) | \
+ ((color & 0xF800) >> 8); \
+ else if (pDrawable->depth == 24 || pDrawable->depth == 32) \
+ color = ((color & 0xFF) << 16) | (color & 0xFF00) | \
+ ((color & 0xFF0000) >> 16); \
+}
+
+/* See Porting Layer Definition - p. 54 */
+void
+winFillSpansNativeGDI(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int iSpans,
+ DDXPointPtr pPoints, int *piWidths, int fSorted)
+{
+ winGCPriv(pGC);
+ HBITMAP hbmpOrig = NULL, hbmpOrigStipple = NULL;
+ HBITMAP hPenOrig = NULL;
+ HBITMAP hBitmap = NULL;
+ PixmapPtr pPixmap = NULL;
+ winPrivPixmapPtr pPixmapPriv = NULL;
+ PixmapPtr pStipple = NULL;
+ winPrivPixmapPtr pStipplePriv = NULL;
+ PixmapPtr pTile = NULL;
+ winPrivPixmapPtr pTilePriv = NULL;
+ HDC hdcStipple = NULL, hdcTile = NULL;
+ HPEN hPen = NULL;
+ int iX;
+ int fg, bg;
+ RegionPtr pClip = pGC->pCompositeClip;
+ BoxPtr pextent, pbox;
+ int nbox;
+ int extentX1, extentX2, extentY1, extentY2;
+ int fullX1, fullX2, fullY1;
+ HRGN hrgn = NULL, combined = NULL;
+
+ nbox = RegionNumRects(pClip);
+ pbox = RegionRects(pClip);
+
+ if (!nbox)
+ return;
+
+ combined = CreateRectRgn(pbox->x1, pbox->y1, pbox->x2, pbox->y2);
+ nbox--;
+ pbox++;
+
+ while (nbox--) {
+ hrgn = CreateRectRgn(pbox->x1, pbox->y1, pbox->x2, pbox->y2);
+ CombineRgn(combined, combined, hrgn, RGN_OR);
+ DeleteObject(hrgn);
+ hrgn = NULL;
+ pbox++;
+ }
+
+ pextent = RegionExtents(pClip);
+ extentX1 = pextent->x1;
+ extentY1 = pextent->y1;
+ extentX2 = pextent->x2;
+ extentY2 = pextent->y2;
+
+ /* Branch on the type of drawable we have */
+ switch (pDrawable->type) {
+ case DRAWABLE_PIXMAP:
+
+ SelectClipRgn(pGCPriv->hdcMem, combined);
+ DeleteObject(combined);
+ combined = NULL;
+
+ /* Get a pixmap pointer from the drawable pointer, and fetch privates */
+ pPixmap = (PixmapPtr) pDrawable;
+ pPixmapPriv = winGetPixmapPriv(pPixmap);
+
+ /* Select the drawable pixmap into memory hdc */
+ hbmpOrig = SelectObject(pGCPriv->hdcMem, pPixmapPriv->hBitmap);
+ if (hbmpOrig == NULL)
+ FatalError("winFillSpans - DRAWABLE_PIXMAP - "
+ "SelectObject () failed on\n\tpPixmapPriv->hBitmap: "
+ "%08x\n", (unsigned int) pPixmapPriv->hBitmap);
+
+ /* Branch on the fill type */
+ switch (pGC->fillStyle) {
+ case FillSolid:
+
+ ROP16(pGCPriv->hdcMem, pGC->alu);
+
+ if (pDrawable->depth == 1) {
+ if (pGC->fgPixel == 0)
+ hPenOrig = SelectObject(pGCPriv->hdcMem,
+ GetStockObject(BLACK_PEN));
+ else
+ hPenOrig = SelectObject(pGCPriv->hdcMem,
+ GetStockObject(WHITE_PEN));
+ }
+ else {
+ fg = pGC->fgPixel;
+ TRANSLATE_COLOR(fg);
+ hPen = CreatePen(PS_SOLID, 0, fg);
+ hPenOrig = SelectObject(pGCPriv->hdcMem, hPen);
+ }
+
+ while (iSpans--) {
+ fullX1 = pPoints->x;
+ fullY1 = pPoints->y;
+ fullX2 = fullX1 + (int) *piWidths;
+ pPoints++;
+ piWidths++;
+
+ if (fullY1 < extentY1 || extentY2 <= fullY1)
+ continue;
+
+ if (fullX1 < extentX1)
+ fullX1 = extentX1;
+ if (fullX2 > extentX2)
+ fullX2 = extentX2;
+
+ if (fullX1 >= fullX2)
+ continue;
+
+ MoveToEx(pGCPriv->hdcMem, fullX1, fullY1, NULL);
+ LineTo(pGCPriv->hdcMem, fullX2, fullY1);
+ }
+
+ SetROP2(pGCPriv->hdcMem, R2_COPYPEN);
+
+ /* Give back the Pen */
+ SelectObject(pGCPriv->hdcMem, hPenOrig);
+
+ if (pDrawable->depth != 1)
+ DeleteObject(hPen);
+ break;
+
+ case FillOpaqueStippled:
+
+ pStipple = pGC->stipple;
+ pStipplePriv = winGetPixmapPriv(pStipple);
+
+ /* Create a device-dependent bitmap for the stipple */
+ hBitmap = CreateDIBitmap(pGCPriv->hdcMem,
+ (BITMAPINFOHEADER *) pStipplePriv->pbmih,
+ CBM_INIT,
+ pStipplePriv->pbBits,
+ (BITMAPINFO *) pStipplePriv->pbmih,
+ DIB_RGB_COLORS);
+
+ /* Create a memory DC to hold the stipple */
+ hdcStipple = CreateCompatibleDC(pGCPriv->hdcMem);
+
+ /* Select the stipple bitmap into the stipple DC */
+ hbmpOrigStipple = SelectObject(hdcStipple, hBitmap);
+ if (hbmpOrigStipple == NULL)
+ FatalError("winFillSpans () - DRAWABLE_PIXMAP - FillStippled - "
+ "SelectObject () failed on hbmpOrigStipple\n");
+
+ /* Make a temporary copy of the foreground and background colors */
+ bg = pGC->bgPixel;
+ fg = pGC->fgPixel;
+
+ /* Translate the depth-dependent colors to Win32 COLORREFs */
+ TRANSLATE_COLOR(fg);
+ TRANSLATE_COLOR(bg);
+ SetTextColor(pGCPriv->hdcMem, fg);
+ SetBkColor(pGCPriv->hdcMem, bg);
+
+ while (iSpans--) {
+ int width = pStipple->drawable.width;
+
+ fullX1 = pPoints->x;
+ fullY1 = pPoints->y;
+ fullX2 = fullX1 + (int) *piWidths;
+ pPoints++;
+ piWidths++;
+
+ if (fullY1 < extentY1 || extentY2 <= fullY1)
+ continue;
+
+ if (fullX1 < extentX1)
+ fullX1 = extentX1;
+ if (fullX2 > extentX2)
+ fullX2 = extentX2;
+
+ if (fullX1 >= fullX2)
+ continue;
+
+ for (iX = fullX1; iX < fullX2; iX += width) {
+ int xoffset;
+
+ if ((iX + pStipple->drawable.width) > fullX2)
+ width = fullX2 - iX;
+ else
+ width = pStipple->drawable.width;
+
+ if (iX == fullX1)
+ xoffset =
+ (fullX1 -
+ (pDrawable->x +
+ (pGC->patOrg.x % pStipple->drawable.width) -
+ pStipple->drawable.width)) %
+ pStipple->drawable.width;
+ else
+ xoffset = 0;
+
+ if (xoffset + width > pStipple->drawable.width)
+ width = pStipple->drawable.width - xoffset;
+
+ BitBlt(pGCPriv->hdcMem,
+ iX, fullY1,
+ width, 1,
+ hdcStipple,
+ xoffset,
+ (fullY1 -
+ (pDrawable->y +
+ (pGC->patOrg.y % pStipple->drawable.height) -
+ pStipple->drawable.height)) %
+ pStipple->drawable.height, g_copyROP[pGC->alu]);
+ }
+ }
+
+ /* Clear the stipple HDC */
+ SelectObject(hdcStipple, hbmpOrigStipple);
+ DeleteDC(hdcStipple);
+
+ /* Delete the device dependent stipple bitmap */
+ DeleteObject(hBitmap);
+
+ break;
+ case FillStippled:
+
+ pStipple = pGC->stipple;
+ pStipplePriv = winGetPixmapPriv(pStipple);
+
+ /* Create a device-dependent bitmap for the stipple */
+ hBitmap = CreateDIBitmap(pGCPriv->hdcMem,
+ (BITMAPINFOHEADER *) pStipplePriv->pbmih,
+ CBM_INIT,
+ pStipplePriv->pbBits,
+ (BITMAPINFO *) pStipplePriv->pbmih,
+ DIB_RGB_COLORS);
+
+ /* Create a memory DC to hold the stipple */
+ hdcStipple = CreateCompatibleDC(pGCPriv->hdcMem);
+
+ /* Select the stipple bitmap into the stipple DC */
+ hbmpOrigStipple = SelectObject(hdcStipple, hBitmap);
+ if (hbmpOrigStipple == NULL)
+ FatalError("winFillSpans () - DRAWABLE_PIXMAP - FillStippled - "
+ "SelectObject () failed on hbmpOrigStipple\n");
+
+ /* Make a temporary copy of the foreground and background colors */
+ bg = pGC->bgPixel;
+ fg = pGC->fgPixel;
+
+ /* Translate the depth-dependent colors to Win32 COLORREFs */
+ TRANSLATE_COLOR(fg);
+ TRANSLATE_COLOR(bg);
+
+ /* this is fudgy, we should only invert on the last one
+ * We need to get the black/white pixels right in the
+ * colormap. But yeah ! it's working..
+ */
+ if (pGC->bgPixel != -1 && pGC->fgPixel != -1) {
+ SetTextColor(pGCPriv->hdcMem, fg);
+ SetBkColor(pGCPriv->hdcMem, bg);
+ BitBlt(hdcStipple,
+ 0, 0,
+ pStipple->drawable.width, pStipple->drawable.height,
+ hdcStipple, 0, 0, 0x330008);
+ }
+ else if (pGC->bgPixel == -1) {
+ SetTextColor(pGCPriv->hdcMem, fg);
+ SetBkMode(pGCPriv->hdcMem, TRANSPARENT);
+ BitBlt(hdcStipple,
+ 0, 0,
+ pStipple->drawable.width, pStipple->drawable.height,
+ hdcStipple, 0, 0, 0x330008);
+ }
+ else if (pGC->fgPixel == -1) {
+ SetTextColor(pGCPriv->hdcMem, bg);
+ SetBkMode(pGCPriv->hdcMem, TRANSPARENT);
+#if 0
+ BitBlt(hdcStipple,
+ 0, 0,
+ pStipple->drawable.width, pStipple->drawable.height,
+ hdcStipple, 0, 0, 0x330008);
+#endif
+ }
+
+ while (iSpans--) {
+ int width = pStipple->drawable.width;
+
+ fullX1 = pPoints->x;
+ fullY1 = pPoints->y;
+ fullX2 = fullX1 + (int) *piWidths;
+ pPoints++;
+ piWidths++;
+
+ if (fullY1 < extentY1 || extentY2 <= fullY1)
+ continue;
+
+ if (fullX1 < extentX1)
+ fullX1 = extentX1;
+ if (fullX2 > extentX2)
+ fullX2 = extentX2;
+
+ if (fullX1 >= fullX2)
+ continue;
+
+ for (iX = fullX1; iX < fullX2; iX += width) {
+ int xoffset;
+
+ if ((iX + pStipple->drawable.width) > fullX2)
+ width = fullX2 - iX;
+ else
+ width = pStipple->drawable.width;
+
+ if (iX == fullX1)
+ xoffset =
+ (fullX1 -
+ (pDrawable->x +
+ (pGC->patOrg.x % pStipple->drawable.width) -
+ pStipple->drawable.width)) %
+ pStipple->drawable.width;
+ else
+ xoffset = 0;
+
+ if (xoffset + width > pStipple->drawable.width)
+ width = pStipple->drawable.width - xoffset;
+
+ BitBlt(pGCPriv->hdcMem,
+ iX, fullY1,
+ width, 1,
+ hdcStipple,
+ xoffset,
+ (fullY1 -
+ (pDrawable->y +
+ (pGC->patOrg.y % pStipple->drawable.height) -
+ pStipple->drawable.height)) %
+ pStipple->drawable.height, g_copyROP[pGC->alu]);
+ }
+ }
+
+ /* Clear the stipple HDC */
+ SelectObject(hdcStipple, hbmpOrigStipple);
+ DeleteDC(hdcStipple);
+
+ /* Delete the device dependent stipple bitmap */
+ DeleteObject(hBitmap);
+
+ /* Restore the background mode */
+ SetBkMode(pGCPriv->hdcMem, OPAQUE);
+ break;
+
+ case FillTiled:
+
+ /* Get a pixmap pointer from the tile pointer, and fetch privates */
+ pTile = (PixmapPtr) pGC->tile.pixmap;
+ pTilePriv = winGetPixmapPriv(pTile);
+
+ /* Create a memory DC to hold the tile */
+ hdcTile = CreateCompatibleDC(pGCPriv->hdcMem);
+
+ /* Select the tile into a DC */
+ hbmpOrig = SelectObject(hdcTile, pTilePriv->hBitmap);
+ if (hbmpOrig == NULL)
+ FatalError("winFillSpans - DRAWABLE_PIXMAP - FillTiled - "
+ "SelectObject () failed on pTilePriv->hBitmap\n");
+
+ while (iSpans--) {
+ int width = pTile->drawable.width;
+
+ fullX1 = pPoints->x;
+ fullY1 = pPoints->y;
+ fullX2 = fullX1 + (int) *piWidths;
+ pPoints++;
+ piWidths++;
+
+ if (fullY1 < extentY1 || extentY2 <= fullY1)
+ continue;
+
+ if (fullX1 < extentX1)
+ fullX1 = extentX1;
+ if (fullX2 > extentX2)
+ fullX2 = extentX2;
+
+ if (fullX1 >= fullX2)
+ continue;
+
+ for (iX = fullX1; iX < fullX2; iX += width) {
+ int xoffset;
+
+ if ((iX + pTile->drawable.width) > fullX2)
+ width = fullX2 - iX;
+ else
+ width = pTile->drawable.width;
+
+ if (iX == fullX1)
+ xoffset =
+ (fullX1 -
+ (pDrawable->x +
+ (pGC->patOrg.x % pTile->drawable.width) -
+ pTile->drawable.width)) % pTile->drawable.width;
+ else
+ xoffset = 0;
+
+ if (xoffset + width > pTile->drawable.width)
+ width = pTile->drawable.width - xoffset;
+
+ BitBlt(pGCPriv->hdcMem,
+ iX, fullY1,
+ width, 1,
+ hdcTile,
+ xoffset,
+ (fullY1 -
+ (pDrawable->y +
+ (pGC->patOrg.y % pTile->drawable.height) -
+ pTile->drawable.height)) % pTile->drawable.height,
+ g_copyROP[pGC->alu]);
+ }
+ }
+
+ /* Push the tile pixmap out of the memory HDC */
+ SelectObject(hdcTile, hbmpOrig);
+
+ /* Delete the tile */
+ DeleteDC(hdcTile);
+ break;
+
+ default:
+ ErrorF("winFillSpans - DRAWABLE_PIXMAP - Unknown fillStyle\n");
+ break;
+ }
+
+ /* Reset clip region */
+ SelectClipRgn(pGCPriv->hdcMem, NULL);
+
+ /* Push the drawable pixmap out of the GC HDC */
+ SelectObject(pGCPriv->hdcMem, hbmpOrig);
+ break;
+
+ case DRAWABLE_WINDOW:
+
+ SelectClipRgn(pGCPriv->hdc, combined);
+ DeleteObject(combined);
+ combined = NULL;
+
+ /* Branch on fill style */
+ switch (pGC->fillStyle) {
+ case FillSolid:
+
+ ROP16(pGCPriv->hdc, pGC->alu);
+
+ if (pDrawable->depth == 1) {
+ if (pGC->fgPixel == 0)
+ hPenOrig = SelectObject(pGCPriv->hdc,
+ GetStockObject(BLACK_PEN));
+ else
+ hPenOrig = SelectObject(pGCPriv->hdc,
+ GetStockObject(WHITE_PEN));
+ }
+ else {
+ fg = pGC->fgPixel;
+ TRANSLATE_COLOR(fg);
+ hPen = CreatePen(PS_SOLID, 0, fg);
+ hPenOrig = SelectObject(pGCPriv->hdc, hPen);
+ }
+
+ while (iSpans--) {
+ fullX1 = pPoints->x;
+ fullY1 = pPoints->y;
+ fullX2 = fullX1 + (int) *piWidths;
+ pPoints++;
+ piWidths++;
+
+ if (fullY1 < extentY1 || extentY2 <= fullY1)
+ continue;
+
+ if (fullX1 < extentX1)
+ fullX1 = extentX1;
+ if (fullX2 > extentX2)
+ fullX2 = extentX2;
+
+ if (fullX1 >= fullX2)
+ continue;
+
+ MoveToEx(pGCPriv->hdc, fullX1, fullY1, NULL);
+ LineTo(pGCPriv->hdc, fullX2, fullY1);
+ }
+
+ SetROP2(pGCPriv->hdc, R2_COPYPEN);
+
+ /* Give back the Brush */
+ SelectObject(pGCPriv->hdc, hPenOrig);
+
+ if (pDrawable->depth != 1)
+ DeleteObject(hPen);
+ break;
+
+ case FillOpaqueStippled:
+
+ pStipple = pGC->stipple;
+ pStipplePriv = winGetPixmapPriv(pStipple);
+
+ /* Create a device-dependent bitmap for the stipple */
+ hBitmap = CreateDIBitmap(pGCPriv->hdc,
+ (BITMAPINFOHEADER *) pStipplePriv->pbmih,
+ CBM_INIT,
+ pStipplePriv->pbBits,
+ (BITMAPINFO *) pStipplePriv->pbmih,
+ DIB_RGB_COLORS);
+
+ /* Create a memory DC to hold the stipple */
+ hdcStipple = CreateCompatibleDC(pGCPriv->hdc);
+
+ /* Select the stipple bitmap into the stipple DC */
+ hbmpOrigStipple = SelectObject(hdcStipple, hBitmap);
+ if (hbmpOrigStipple == NULL)
+ FatalError("winFillSpans () - DRAWABLE_PIXMAP - FillStippled - "
+ "SelectObject () failed on hbmpOrigStipple\n");
+
+ /* Make a temporary copy of the foreground and background colors */
+ bg = pGC->bgPixel;
+ fg = pGC->fgPixel;
+
+ /* Translate the depth-dependent colors to Win32 COLORREFs */
+ TRANSLATE_COLOR(fg);
+ TRANSLATE_COLOR(bg);
+ SetTextColor(pGCPriv->hdc, fg);
+ SetBkColor(pGCPriv->hdc, bg);
+
+ while (iSpans--) {
+ int width = pStipple->drawable.width;
+
+ fullX1 = pPoints->x;
+ fullY1 = pPoints->y;
+ fullX2 = fullX1 + (int) *piWidths;
+ pPoints++;
+ piWidths++;
+
+ if (fullY1 < extentY1 || extentY2 <= fullY1)
+ continue;
+
+ if (fullX1 < extentX1)
+ fullX1 = extentX1;
+ if (fullX2 > extentX2)
+ fullX2 = extentX2;
+
+ if (fullX1 >= fullX2)
+ continue;
+
+ for (iX = fullX1; iX < fullX2; iX += width) {
+ int xoffset;
+
+ if ((iX + pStipple->drawable.width) > fullX2)
+ width = fullX2 - iX;
+ else
+ width = pStipple->drawable.width;
+
+ if (iX == fullX1)
+ xoffset =
+ (fullX1 -
+ (pDrawable->x +
+ (pGC->patOrg.x % pStipple->drawable.width) -
+ pStipple->drawable.width)) %
+ pStipple->drawable.width;
+ else
+ xoffset = 0;
+
+ if (xoffset + width > pStipple->drawable.width)
+ width = pStipple->drawable.width - xoffset;
+
+ BitBlt(pGCPriv->hdc,
+ iX, fullY1,
+ width, 1,
+ hdcStipple,
+ xoffset,
+ (fullY1 -
+ (pDrawable->y +
+ (pGC->patOrg.y % pStipple->drawable.height) -
+ pStipple->drawable.height)) %
+ pStipple->drawable.height, g_copyROP[pGC->alu]);
+ }
+ }
+
+ /* Clear the stipple HDC */
+ SelectObject(hdcStipple, hbmpOrigStipple);
+ DeleteDC(hdcStipple);
+
+ /* Delete the device dependent stipple bitmap */
+ DeleteObject(hBitmap);
+
+ break;
+
+ case FillStippled:
+ pStipple = pGC->stipple;
+ pStipplePriv = winGetPixmapPriv(pStipple);
+
+ /* Create a device-dependent bitmap for the stipple */
+ hBitmap = CreateDIBitmap(pGCPriv->hdcMem,
+ (BITMAPINFOHEADER *) pStipplePriv->pbmih,
+ CBM_INIT,
+ pStipplePriv->pbBits,
+ (BITMAPINFO *) pStipplePriv->pbmih,
+ DIB_RGB_COLORS);
+
+ /* Create a memory DC to hold the stipple */
+ hdcStipple = CreateCompatibleDC(pGCPriv->hdc);
+
+ /* Select the stipple bitmap into the stipple DC */
+ hbmpOrigStipple = SelectObject(hdcStipple, hBitmap);
+ if (hbmpOrigStipple == NULL)
+ FatalError("winFillSpans () - DRAWABLE_PIXMAP - FillStippled - "
+ "SelectObject () failed on hbmpOrigStipple\n");
+
+ /* Make a temporary copy of the foreground and background colors */
+ bg = pGC->bgPixel;
+ fg = pGC->fgPixel;
+
+ /* Translate the depth-dependent colors to Win32 COLORREFs */
+ TRANSLATE_COLOR(fg);
+ TRANSLATE_COLOR(bg);
+
+ /* this is fudgy, we should only invert on the last one
+ * We need to get the black/white pixels right in the
+ * colormap. But yeah ! it's working..
+ */
+ if (pGC->bgPixel != -1 && pGC->fgPixel != -1) {
+ SetTextColor(pGCPriv->hdc, fg);
+ SetBkColor(pGCPriv->hdc, bg);
+ BitBlt(hdcStipple,
+ 0, 0,
+ pStipple->drawable.width, pStipple->drawable.height,
+ hdcStipple, 0, 0, 0x330008);
+ }
+ else if (pGC->bgPixel == -1) {
+ SetTextColor(pGCPriv->hdc, fg);
+ SetBkMode(pGCPriv->hdc, TRANSPARENT);
+ BitBlt(hdcStipple,
+ 0, 0,
+ pStipple->drawable.width, pStipple->drawable.height,
+ hdcStipple, 0, 0, 0x330008);
+ }
+ else if (pGC->fgPixel == -1) {
+ SetTextColor(pGCPriv->hdc, bg);
+ SetBkMode(pGCPriv->hdc, TRANSPARENT);
+#if 0
+ BitBlt(hdcStipple,
+ 0, 0,
+ pStipple->drawable.width, pStipple->drawable.height,
+ hdcStipple, 0, 0, 0x330008);
+#endif
+ }
+
+ while (iSpans--) {
+ int width = pStipple->drawable.width;
+
+ fullX1 = pPoints->x;
+ fullY1 = pPoints->y;
+ fullX2 = fullX1 + (int) *piWidths;
+ pPoints++;
+ piWidths++;
+
+ if (fullY1 < extentY1 || extentY2 <= fullY1)
+ continue;
+
+ if (fullX1 < extentX1)
+ fullX1 = extentX1;
+ if (fullX2 > extentX2)
+ fullX2 = extentX2;
+
+ if (fullX1 >= fullX2)
+ continue;
+
+ for (iX = fullX1; iX < fullX2; iX += width) {
+ int xoffset;
+
+ if ((iX + pStipple->drawable.width) > fullX2)
+ width = fullX2 - iX;
+ else
+ width = pStipple->drawable.width;
+
+ if (iX == fullX1)
+ xoffset =
+ (fullX1 -
+ (pDrawable->x +
+ (pGC->patOrg.x % pStipple->drawable.width) -
+ pStipple->drawable.width)) %
+ pStipple->drawable.width;
+ else
+ xoffset = 0;
+
+ if (xoffset + width > pStipple->drawable.width)
+ width = pStipple->drawable.width - xoffset;
+
+ BitBlt(pGCPriv->hdc,
+ iX, fullY1,
+ width, 1,
+ hdcStipple,
+ xoffset,
+ (fullY1 -
+ (pDrawable->y +
+ (pGC->patOrg.y % pStipple->drawable.height) -
+ pStipple->drawable.height)) %
+ pStipple->drawable.height, g_copyROP[pGC->alu]);
+ }
+ }
+
+ /* Clear the stipple HDC */
+ SelectObject(hdcStipple, hbmpOrigStipple);
+ DeleteDC(hdcStipple);
+
+ /* Delete the device dependent stipple bitmap */
+ DeleteObject(hBitmap);
+
+ /* Restore the background mode */
+ SetBkMode(pGCPriv->hdc, OPAQUE);
+ break;
+
+ case FillTiled:
+
+ /* Get a pixmap pointer from the tile pointer, and fetch privates */
+ pTile = (PixmapPtr) pGC->tile.pixmap;
+ pTilePriv = winGetPixmapPriv(pTile);
+
+ /* Select the tile into a DC */
+ hbmpOrig = SelectObject(pGCPriv->hdcMem, pTilePriv->hBitmap);
+ if (hbmpOrig == NULL)
+ FatalError("winFillSpans - DRAWABLE_WINDOW - FillTiled - "
+ "SelectObject () failed on pTilePriv->hBitmap\n");
+
+ while (iSpans--) {
+ int width = pTile->drawable.width;
+
+ fullX1 = pPoints->x;
+ fullY1 = pPoints->y;
+ fullX2 = fullX1 + (int) *piWidths;
+ pPoints++;
+ piWidths++;
+
+ if (fullY1 < extentY1 || extentY2 <= fullY1)
+ continue;
+
+ if (fullX1 < extentX1)
+ fullX1 = extentX1;
+ if (fullX2 > extentX2)
+ fullX2 = extentX2;
+
+ if (fullX1 >= fullX2)
+ continue;
+
+ for (iX = fullX1; iX < fullX2; iX += width) {
+ int xoffset;
+
+ if ((iX + pTile->drawable.width) > fullX2)
+ width = fullX2 - iX;
+ else
+ width = pTile->drawable.width;
+
+ if (iX == fullX1)
+ xoffset =
+ (fullX1 -
+ (pDrawable->x +
+ (pGC->patOrg.x % pTile->drawable.width) -
+ pTile->drawable.width)) % pTile->drawable.width;
+ else
+ xoffset = 0;
+
+ if (xoffset + width > pTile->drawable.width)
+ width = pTile->drawable.width - xoffset;
+
+ BitBlt(pGCPriv->hdc,
+ iX, fullY1,
+ width, 1,
+ pGCPriv->hdcMem,
+ xoffset,
+ (fullY1 -
+ (pDrawable->y +
+ (pGC->patOrg.y % pTile->drawable.height) -
+ pTile->drawable.height)) % pTile->drawable.height,
+ g_copyROP[pGC->alu]);
+ }
+ }
+
+ /* Push the tile pixmap out of the memory HDC */
+ SelectObject(pGCPriv->hdcMem, hbmpOrig);
+ break;
+
+ default:
+ ErrorF("winFillSpans - DRAWABLE_WINDOW - Unknown fillStyle\n");
+ break;
+ }
+
+ /* Reset clip region */
+ SelectClipRgn(pGCPriv->hdc, NULL);
+ break;
+
+ default:
+ ErrorF("winFillSpans - Unknown drawable type\n");
+ break;
+ }
+}
diff --git a/xorg-server/hw/xwin/wingc.c b/xorg-server/hw/xwin/wingc.c
index bf307a44c..0ad64676d 100644
--- a/xorg-server/hw/xwin/wingc.c
+++ b/xorg-server/hw/xwin/wingc.c
@@ -1,162 +1,156 @@
-/*
- *Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved.
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, sublicense, and/or sell copies of the Software, and to
- *permit persons to whom the Software is furnished to do so, subject to
- *the following conditions:
- *
- *The above copyright notice and this permission notice shall be
- *included in all copies or substantial portions of the Software.
- *
- *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
- *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *Except as contained in this notice, the name of Harold L Hunt II
- *shall not be used in advertising or otherwise to promote the sale, use
- *or other dealings in this Software without prior written authorization
- *from Harold L Hunt II.
- *
- * Authors: Harold L Hunt II
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-
-void
-winPushPixels (GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDrawable, int dx, int dy, int xOrg, int yOrg);
-
-
-/*
- * Local prototypes
- */
-
-static void
-winValidateGCNativeGDI (GCPtr pGC,
- unsigned long changes,
- DrawablePtr pDrawable);
-
-static void
-winDestroyGCNativeGDI (GCPtr pGC);
-
-const GCFuncs winGCFuncs = {
- winValidateGCNativeGDI,
- miChangeGC,
- miCopyGC,
- winDestroyGCNativeGDI,
- miChangeClip,
- miDestroyClip,
- miCopyClip,
-};
-
-/* Drawing Primitives */
-const GCOps winGCOps = {
- winFillSpansNativeGDI,
- winSetSpansNativeGDI,
- miPutImage,
- miCopyArea,
- miCopyPlane,
- miPolyPoint,
- winPolyLineNativeGDI,
- miPolySegment,
- miPolyRectangle,
- miPolyArc,
- miFillPolygon,
- miPolyFillRect,
- miPolyFillArc,
- miPolyText8,
- miPolyText16,
- miImageText8,
- miImageText16,
- miImageGlyphBlt,
- miPolyGlyphBlt,
- miPushPixels,
-};
-
-
-/* See Porting Layer Definition - p. 45 */
-/* See mfb/mfbgc.c - mfbCreateGC() */
-/* See Strategies for Porting - pp. 15, 16 */
-Bool
-winCreateGCNativeGDI (GCPtr pGC)
-{
- winPrivGCPtr pGCPriv = NULL;
- winPrivScreenPtr pScreenPriv = NULL;
-
- winDebug ("winCreateGCNativeGDI - depth: %d\n",
- pGC->depth);
-
- pGC->ops = (GCOps *) &winGCOps;
- pGC->funcs = (GCFuncs *) &winGCFuncs;
-
- /* We want all coordinates passed to spans functions to be screen relative */
- pGC->miTranslate = TRUE;
-
- /* Allocate privates for this GC */
- pGCPriv = winGetGCPriv (pGC);
- if (pGCPriv == NULL)
- {
- ErrorF ("winCreateGCNativeGDI () - Privates pointer was NULL\n");
- return FALSE;
- }
-
- /* Create a new screen DC for the display window */
- pScreenPriv = winGetScreenPriv (pGC->pScreen);
- pGCPriv->hdc = GetDC (pScreenPriv->hwndScreen);
-
- /* Allocate a memory DC for the GC */
- pGCPriv->hdcMem = CreateCompatibleDC (pGCPriv->hdc);
-
- return TRUE;
-}
-
-static void
-winValidateGCNativeGDI (GCPtr pGC,
- unsigned long ulChanges,
- DrawablePtr pDrawable)
-{
- if ((ulChanges & (GCClipXOrigin | GCClipYOrigin | GCClipMask | GCSubwindowMode))
- || (pDrawable->serialNumber != (pGC->serialNumber & DRAWABLE_SERIAL_BITS)))
- {
- miComputeCompositeClip (pGC, pDrawable);
- }
-}
-
-
-/* See Porting Layer Definition - p. 46 */
-static void
-winDestroyGCNativeGDI (GCPtr pGC)
-{
- winGCPriv(pGC);
- winScreenPriv(pGC->pScreen);
-
- if (pGC->freeCompClip)
- RegionDestroy(pGC->pCompositeClip);
-
- /* Free the memory DC */
- if (pGCPriv->hdcMem != NULL)
- {
- DeleteDC (pGCPriv->hdcMem);
- pGCPriv->hdcMem = NULL;
- }
-
- /* Release the screen DC for the display window */
- if (pGCPriv->hdc != NULL)
- {
- ReleaseDC (pScreenPriv->hwndScreen, pGCPriv->hdc);
- pGCPriv->hdc = NULL;
- }
-
- /* Invalidate the GC privates pointer */
- winSetGCPriv (pGC, NULL);
-}
+/*
+ *Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of Harold L Hunt II
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from Harold L Hunt II.
+ *
+ * Authors: Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+void
+
+winPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDrawable, int dx,
+ int dy, int xOrg, int yOrg);
+
+/*
+ * Local prototypes
+ */
+
+static void
+
+winValidateGCNativeGDI(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable);
+
+static void
+ winDestroyGCNativeGDI(GCPtr pGC);
+
+const GCFuncs winGCFuncs = {
+ winValidateGCNativeGDI,
+ miChangeGC,
+ miCopyGC,
+ winDestroyGCNativeGDI,
+ miChangeClip,
+ miDestroyClip,
+ miCopyClip,
+};
+
+/* Drawing Primitives */
+const GCOps winGCOps = {
+ winFillSpansNativeGDI,
+ winSetSpansNativeGDI,
+ miPutImage,
+ miCopyArea,
+ miCopyPlane,
+ miPolyPoint,
+ winPolyLineNativeGDI,
+ miPolySegment,
+ miPolyRectangle,
+ miPolyArc,
+ miFillPolygon,
+ miPolyFillRect,
+ miPolyFillArc,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ miImageGlyphBlt,
+ miPolyGlyphBlt,
+ miPushPixels,
+};
+
+/* See Porting Layer Definition - p. 45 */
+/* See mfb/mfbgc.c - mfbCreateGC() */
+/* See Strategies for Porting - pp. 15, 16 */
+Bool
+winCreateGCNativeGDI(GCPtr pGC)
+{
+ winPrivGCPtr pGCPriv = NULL;
+ winPrivScreenPtr pScreenPriv = NULL;
+
+ winDebug ("winCreateGCNativeGDI - depth: %d\n", pGC->depth);
+
+ pGC->ops = (GCOps *) & winGCOps;
+ pGC->funcs = (GCFuncs *) & winGCFuncs;
+
+ /* We want all coordinates passed to spans functions to be screen relative */
+ pGC->miTranslate = TRUE;
+
+ /* Allocate privates for this GC */
+ pGCPriv = winGetGCPriv(pGC);
+ if (pGCPriv == NULL) {
+ ErrorF("winCreateGCNativeGDI () - Privates pointer was NULL\n");
+ return FALSE;
+ }
+
+ /* Create a new screen DC for the display window */
+ pScreenPriv = winGetScreenPriv(pGC->pScreen);
+ pGCPriv->hdc = GetDC(pScreenPriv->hwndScreen);
+
+ /* Allocate a memory DC for the GC */
+ pGCPriv->hdcMem = CreateCompatibleDC(pGCPriv->hdc);
+
+ return TRUE;
+}
+
+static void
+winValidateGCNativeGDI(GCPtr pGC,
+ unsigned long ulChanges, DrawablePtr pDrawable)
+{
+ if ((ulChanges &
+ (GCClipXOrigin | GCClipYOrigin | GCClipMask | GCSubwindowMode))
+ || (pDrawable->serialNumber !=
+ (pGC->serialNumber & DRAWABLE_SERIAL_BITS))) {
+ miComputeCompositeClip(pGC, pDrawable);
+ }
+}
+
+/* See Porting Layer Definition - p. 46 */
+static void
+winDestroyGCNativeGDI(GCPtr pGC)
+{
+ winGCPriv(pGC);
+ winScreenPriv(pGC->pScreen);
+
+ if (pGC->freeCompClip)
+ RegionDestroy(pGC->pCompositeClip);
+
+ /* Free the memory DC */
+ if (pGCPriv->hdcMem != NULL) {
+ DeleteDC(pGCPriv->hdcMem);
+ pGCPriv->hdcMem = NULL;
+ }
+
+ /* Release the screen DC for the display window */
+ if (pGCPriv->hdc != NULL) {
+ ReleaseDC(pScreenPriv->hwndScreen, pGCPriv->hdc);
+ pGCPriv->hdc = NULL;
+ }
+
+ /* Invalidate the GC privates pointer */
+ winSetGCPriv(pGC, NULL);
+}
diff --git a/xorg-server/hw/xwin/wingetsp.c b/xorg-server/hw/xwin/wingetsp.c
index 0fd0ebce9..1076b5cc5 100644
--- a/xorg-server/hw/xwin/wingetsp.c
+++ b/xorg-server/hw/xwin/wingetsp.c
@@ -1,167 +1,154 @@
-/*
- *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, sublicense, and/or sell copies of the Software, and to
- *permit persons to whom the Software is furnished to do so, subject to
- *the following conditions:
- *
- *The above copyright notice and this permission notice shall be
- *included in all copies or substantial portions of the Software.
- *
- *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
- *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *Except as contained in this notice, the name of the XFree86 Project
- *shall not be used in advertising or otherwise to promote the sale, use
- *or other dealings in this Software without prior written authorization
- *from the XFree86 Project.
- *
- * Authors: Harold L Hunt II
- * Alan Hourihane <alanh@fairlite.demon.co.uk>
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-
-/* See Porting Layer Definition - p. 55 */
-void
-winGetSpansNativeGDI (DrawablePtr pDrawable,
- int nMax,
- DDXPointPtr pPoints,
- int *piWidths,
- int iSpans,
- char *pDsts)
-{
- PixmapPtr pPixmap = NULL;
- winPrivPixmapPtr pPixmapPriv = NULL;
- int iSpan;
- DDXPointPtr pPoint = NULL;
- int *piWidth = NULL;
- char *pDst = pDsts;
- HBITMAP hbmpWindow, hbmpOrig, hbmpOrig1;
- BYTE *pbWindow = NULL;
- HDC hdcMem, hdcMem1;
- ScreenPtr pScreen = pDrawable->pScreen;
- winScreenPriv(pScreen);
-
- /* Branch on the drawable type */
- switch (pDrawable->type)
- {
- case DRAWABLE_PIXMAP:
- winDebug ("winGetSpans - DRAWABLE_PIXMAP %08x\n",
- pDrawable);
-
- pPixmap = (PixmapPtr) pDrawable;
- pPixmapPriv = winGetPixmapPriv (pPixmap);
-
- /* Open a memory HDC */
- hdcMem1 = CreateCompatibleDC (NULL);
- hdcMem = CreateCompatibleDC (NULL);
-
- /* Select the drawable pixmap into a DC */
- hbmpOrig1 = SelectObject (hdcMem1, pPixmapPriv->hBitmap);
-
- if (hbmpOrig1 == NULL)
- FatalError ("winGetSpans - DRAWABLE_PIXMAP - SelectObject () "
- "failed on pPixmapPriv->hBitmap\n");
-
- /* Loop through spans */
- for (iSpan = 0; iSpan < iSpans; ++iSpan)
- {
- pPoint = pPoints + iSpan;
- piWidth = piWidths + iSpan;
-
- hbmpWindow = winCreateDIBNativeGDI (*piWidth, 1,
- pDrawable->depth,
- &pbWindow,
- NULL);
-
- hbmpOrig = SelectObject (hdcMem, hbmpWindow);
-
- /* Transfer the window bits to the window bitmap */
- BitBlt (hdcMem,
- 0, 0,
- *piWidth, 1,
- hdcMem1,
- pPoint->x, pPoint->y,
- SRCCOPY);
-
- memcpy (pDst,
- (char*) pbWindow,
- PixmapBytePad (*piWidth, pDrawable->depth));
-
- /* Pop the window bitmap out of the HDC and delete the bitmap */
- SelectObject (hdcMem, hbmpOrig);
- DeleteObject (hbmpWindow);
-
- /* Calculate offset of next bit destination */
- pDst += PixmapBytePad (*piWidth, pDrawable->depth);
- }
-
- /* Pop the pixmap's bitmap out of the HDC */
- SelectObject (hdcMem1, hbmpOrig1);
-
- /* Delete the HDCs */
- DeleteDC (hdcMem1);
- DeleteDC (hdcMem);
- break;
-
- case DRAWABLE_WINDOW:
-
- /* Open a memory HDC */
- hdcMem = CreateCompatibleDC (NULL);
-
- /* Loop through spans */
- for (iSpan = 0; iSpan < iSpans; ++iSpan)
- {
- pPoint = pPoints + iSpan;
- piWidth = piWidths + iSpan;
-
- hbmpWindow = winCreateDIBNativeGDI (*piWidth, 1,
- pDrawable->depth,
- &pbWindow,
- NULL);
-
- hbmpOrig = SelectObject (hdcMem, hbmpWindow);
-
- /* Transfer the window bits to the window bitmap */
- BitBlt (hdcMem,
- 0, 0,
- *piWidth, 1,
- pScreenPriv->hdcScreen,
- pPoint->x, pPoint->y,
- SRCCOPY);
-
- memcpy (pDst,
- (char*) pbWindow,
- PixmapBytePad (*piWidth, pDrawable->depth));
-
- /* Pop the window bitmap out of the HDC */
- SelectObject (hdcMem, hbmpOrig);
-
- DeleteObject (hbmpWindow);
-
- /* Calculate offset of next bit destination */
- pDst += PixmapBytePad (*piWidth, pDrawable->depth);
- }
-
- /* Delete the window bitmap */
- DeleteDC (hdcMem);
- break;
-
- default:
- FatalError ("winGetSpans - Unknown drawable type\n");
- break;
- }
-}
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Harold L Hunt II
+ * Alan Hourihane <alanh@fairlite.demon.co.uk>
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+/* See Porting Layer Definition - p. 55 */
+void
+winGetSpansNativeGDI(DrawablePtr pDrawable,
+ int nMax,
+ DDXPointPtr pPoints,
+ int *piWidths, int iSpans, char *pDsts)
+{
+ PixmapPtr pPixmap = NULL;
+ winPrivPixmapPtr pPixmapPriv = NULL;
+ int iSpan;
+ DDXPointPtr pPoint = NULL;
+ int *piWidth = NULL;
+ char *pDst = pDsts;
+ HBITMAP hbmpWindow, hbmpOrig, hbmpOrig1;
+ BYTE *pbWindow = NULL;
+ HDC hdcMem, hdcMem1;
+ ScreenPtr pScreen = pDrawable->pScreen;
+
+ winScreenPriv(pScreen);
+
+ /* Branch on the drawable type */
+ switch (pDrawable->type) {
+ case DRAWABLE_PIXMAP:
+ winDebug ("winGetSpans - DRAWABLE_PIXMAP %08x\n", pDrawable);
+
+ pPixmap = (PixmapPtr) pDrawable;
+ pPixmapPriv = winGetPixmapPriv(pPixmap);
+
+ /* Open a memory HDC */
+ hdcMem1 = CreateCompatibleDC(NULL);
+ hdcMem = CreateCompatibleDC(NULL);
+
+ /* Select the drawable pixmap into a DC */
+ hbmpOrig1 = SelectObject(hdcMem1, pPixmapPriv->hBitmap);
+
+ if (hbmpOrig1 == NULL)
+ FatalError("winGetSpans - DRAWABLE_PIXMAP - SelectObject () "
+ "failed on pPixmapPriv->hBitmap\n");
+
+ /* Loop through spans */
+ for (iSpan = 0; iSpan < iSpans; ++iSpan) {
+ pPoint = pPoints + iSpan;
+ piWidth = piWidths + iSpan;
+
+ hbmpWindow = winCreateDIBNativeGDI(*piWidth, 1,
+ pDrawable->depth,
+ &pbWindow, NULL);
+
+ hbmpOrig = SelectObject(hdcMem, hbmpWindow);
+
+ /* Transfer the window bits to the window bitmap */
+ BitBlt(hdcMem,
+ 0, 0, *piWidth, 1, hdcMem1, pPoint->x, pPoint->y, SRCCOPY);
+
+ memcpy(pDst,
+ (char *) pbWindow,
+ PixmapBytePad(*piWidth, pDrawable->depth));
+
+ /* Pop the window bitmap out of the HDC and delete the bitmap */
+ SelectObject(hdcMem, hbmpOrig);
+ DeleteObject(hbmpWindow);
+
+ /* Calculate offset of next bit destination */
+ pDst += PixmapBytePad(*piWidth, pDrawable->depth);
+ }
+
+ /* Pop the pixmap's bitmap out of the HDC */
+ SelectObject(hdcMem1, hbmpOrig1);
+
+ /* Delete the HDCs */
+ DeleteDC(hdcMem1);
+ DeleteDC(hdcMem);
+ break;
+
+ case DRAWABLE_WINDOW:
+
+ /* Open a memory HDC */
+ hdcMem = CreateCompatibleDC(NULL);
+
+ /* Loop through spans */
+ for (iSpan = 0; iSpan < iSpans; ++iSpan) {
+ pPoint = pPoints + iSpan;
+ piWidth = piWidths + iSpan;
+
+ hbmpWindow = winCreateDIBNativeGDI(*piWidth, 1,
+ pDrawable->depth,
+ &pbWindow, NULL);
+
+ hbmpOrig = SelectObject(hdcMem, hbmpWindow);
+
+ /* Transfer the window bits to the window bitmap */
+ BitBlt(hdcMem,
+ 0, 0,
+ *piWidth, 1,
+ pScreenPriv->hdcScreen, pPoint->x, pPoint->y, SRCCOPY);
+
+ memcpy(pDst,
+ (char *) pbWindow,
+ PixmapBytePad(*piWidth, pDrawable->depth));
+
+ /* Pop the window bitmap out of the HDC */
+ SelectObject(hdcMem, hbmpOrig);
+
+ DeleteObject(hbmpWindow);
+
+ /* Calculate offset of next bit destination */
+ pDst += PixmapBytePad(*piWidth, pDrawable->depth);
+ }
+
+ /* Delete the window bitmap */
+ DeleteDC(hdcMem);
+ break;
+
+ default:
+ FatalError("winGetSpans - Unknown drawable type\n");
+ break;
+ }
+}
diff --git a/xorg-server/hw/xwin/winkeybd.c b/xorg-server/hw/xwin/winkeybd.c
index e11a71248..5da959cae 100644
--- a/xorg-server/hw/xwin/winkeybd.c
+++ b/xorg-server/hw/xwin/winkeybd.c
@@ -31,7 +31,6 @@
* Harold L Hunt II
*/
-
#ifdef HAVE_XWIN_CONFIG_H
#include <xwin-config.h>
#endif
@@ -49,12 +48,10 @@ static Bool g_winKeyState[NUM_KEYCODES];
*/
static void
-winKeybdBell (int iPercent, DeviceIntPtr pDeviceInt,
- pointer pCtrl, int iClass);
+ winKeybdBell(int iPercent, DeviceIntPtr pDeviceInt, pointer pCtrl, int iClass);
static void
-winKeybdCtrl (DeviceIntPtr pDevice, KeybdCtrl *pCtrl);
-
+ winKeybdCtrl(DeviceIntPtr pDevice, KeybdCtrl * pCtrl);
/*
* Translate a Windows WM_[SYS]KEY(UP/DOWN) message
@@ -66,14 +63,14 @@ winKeybdCtrl (DeviceIntPtr pDevice, KeybdCtrl *pCtrl);
*/
void
-winTranslateKey (WPARAM wParam, LPARAM lParam, int *piScanCode)
+winTranslateKey(WPARAM wParam, LPARAM lParam, int *piScanCode)
{
- int iKeyFixup = g_iKeyMap[wParam * WIN_KEYMAP_COLS + 1];
- int iKeyFixupEx = g_iKeyMap[wParam * WIN_KEYMAP_COLS + 2];
- int iParam = HIWORD (lParam);
- int iParamScanCode = LOBYTE (iParam);
+ int iKeyFixup = g_iKeyMap[wParam * WIN_KEYMAP_COLS + 1];
+ int iKeyFixupEx = g_iKeyMap[wParam * WIN_KEYMAP_COLS + 2];
+ int iParam = HIWORD(lParam);
+ int iParamScanCode = LOBYTE(iParam);
- winDebug("winTranslateKey: wParam %08x lParam %08x\n", wParam, lParam);
+ winDebug("winTranslateKey: wParam %08x lParam %08x\n", wParam, lParam);
/* WM_ key messages faked by Vista speech recognition (WSR) don't have a
* scan code.
@@ -82,129 +79,117 @@ winTranslateKey (WPARAM wParam, LPARAM lParam, int *piScanCode)
* System.Windows.Forms.SendKeys.SendWait(), which appears always to give a
* scan code of 1
*/
- if (iParamScanCode <= 1)
- {
- if (VK_PRIOR <= wParam && wParam <= VK_DOWN)
- /* Trigger special case table to translate to extended
- * keycode, otherwise if num_lock is on, we can get keypad
- * numbers instead of navigation keys. */
- iParam |= KF_EXTENDED;
- else
- iParamScanCode = MapVirtualKeyEx(wParam,
- /*MAPVK_VK_TO_VSC*/0,
- GetKeyboardLayout(0));
+ if (iParamScanCode <= 1) {
+ if (VK_PRIOR <= wParam && wParam <= VK_DOWN)
+ /* Trigger special case table to translate to extended
+ * keycode, otherwise if num_lock is on, we can get keypad
+ * numbers instead of navigation keys. */
+ iParam |= KF_EXTENDED;
+ else
+ iParamScanCode = MapVirtualKeyEx(wParam,
+ /*MAPVK_VK_TO_VSC */ 0,
+ GetKeyboardLayout(0));
}
- /* Branch on special extended, special non-extended, or normal key */
- if ((iParam & KF_EXTENDED) && iKeyFixupEx)
- *piScanCode = iKeyFixupEx;
- else if (iKeyFixup)
- *piScanCode = iKeyFixup;
- else if (wParam == 0 && iParamScanCode == 0x70)
- *piScanCode = KEY_HKTG;
- else
- switch (iParamScanCode)
- {
- case 0x70:
+ /* Branch on special extended, special non-extended, or normal key */
+ if ((iParam & KF_EXTENDED) && iKeyFixupEx)
+ *piScanCode = iKeyFixupEx;
+ else if (iKeyFixup)
+ *piScanCode = iKeyFixup;
+ else if (wParam == 0 && iParamScanCode == 0x70)
*piScanCode = KEY_HKTG;
- break;
- case 0x73:
- *piScanCode = KEY_BSlash2;
- break;
- default:
- *piScanCode = iParamScanCode;
- break;
- }
+ else
+ switch (iParamScanCode) {
+ case 0x70:
+ *piScanCode = KEY_HKTG;
+ break;
+ case 0x73:
+ *piScanCode = KEY_BSlash2;
+ break;
+ default:
+ *piScanCode = iParamScanCode;
+ break;
+ }
}
-
/* Ring the keyboard bell (system speaker on PCs) */
static void
-winKeybdBell (int iPercent, DeviceIntPtr pDeviceInt,
- pointer pCtrl, int iClass)
+winKeybdBell(int iPercent, DeviceIntPtr pDeviceInt, pointer pCtrl, int iClass)
{
- /*
- * We can't use Beep () here because it uses the PC speaker
- * on NT/2000. MessageBeep (MB_OK) will play the default system
- * sound on systems with a sound card or it will beep the PC speaker
- * on systems that do not have a sound card.
- */
- MessageBeep (MB_OK);
+ /*
+ * We can't use Beep () here because it uses the PC speaker
+ * on NT/2000. MessageBeep (MB_OK) will play the default system
+ * sound on systems with a sound card or it will beep the PC speaker
+ * on systems that do not have a sound card.
+ */
+ MessageBeep(MB_OK);
}
-
/* Change some keyboard configuration parameters */
static void
-winKeybdCtrl (DeviceIntPtr pDevice, KeybdCtrl *pCtrl)
+winKeybdCtrl(DeviceIntPtr pDevice, KeybdCtrl * pCtrl)
{
}
-
/*
* See Porting Layer Definition - p. 18
* winKeybdProc is known as a DeviceProc.
*/
int
-winKeybdProc (DeviceIntPtr pDeviceInt, int iState)
+winKeybdProc(DeviceIntPtr pDeviceInt, int iState)
{
- DevicePtr pDevice = (DevicePtr) pDeviceInt;
- XkbSrvInfoPtr xkbi;
- XkbControlsPtr ctrl;
+ DevicePtr pDevice = (DevicePtr) pDeviceInt;
+ XkbSrvInfoPtr xkbi;
+ XkbControlsPtr ctrl;
- switch (iState)
- {
+ switch (iState) {
case DEVICE_INIT:
- winConfigKeyboard (pDeviceInt);
-
- /* FIXME: Maybe we should use winGetKbdLeds () here? */
- defaultKeyboardControl.leds = g_winInfo.keyboard.leds;
-
- winDebug("Rules = \"%s\" Model = \"%s\" Layout = \"%s\""
- " Variant = \"%s\" Options = \"%s\"\n",
- g_winInfo.xkb.rules ? g_winInfo.xkb.rules : "none",
- g_winInfo.xkb.model ? g_winInfo.xkb.model : "none",
- g_winInfo.xkb.layout ? g_winInfo.xkb.layout : "none",
- g_winInfo.xkb.variant ? g_winInfo.xkb.variant : "none",
- g_winInfo.xkb.options ? g_winInfo.xkb.options : "none");
-
- InitKeyboardDeviceStruct (pDeviceInt,
- &g_winInfo.xkb,
- winKeybdBell,
- winKeybdCtrl);
-
- xkbi = pDeviceInt->key->xkbInfo;
- if ((xkbi != NULL) && (xkbi->desc != NULL))
- {
- ctrl = xkbi->desc->ctrls;
- ctrl->repeat_delay = g_winInfo.keyboard.delay;
- ctrl->repeat_interval = 1000/g_winInfo.keyboard.rate;
+ winConfigKeyboard(pDeviceInt);
+
+ /* FIXME: Maybe we should use winGetKbdLeds () here? */
+ defaultKeyboardControl.leds = g_winInfo.keyboard.leds;
+
+ winDebug("Rules = \"%s\" Model = \"%s\" Layout = \"%s\""
+ " Variant = \"%s\" Options = \"%s\"\n",
+ g_winInfo.xkb.rules ? g_winInfo.xkb.rules : "none",
+ g_winInfo.xkb.model ? g_winInfo.xkb.model : "none",
+ g_winInfo.xkb.layout ? g_winInfo.xkb.layout : "none",
+ g_winInfo.xkb.variant ? g_winInfo.xkb.variant : "none",
+ g_winInfo.xkb.options ? g_winInfo.xkb.options : "none");
+
+ InitKeyboardDeviceStruct(pDeviceInt,
+ &g_winInfo.xkb, winKeybdBell, winKeybdCtrl);
+
+ xkbi = pDeviceInt->key->xkbInfo;
+ if ((xkbi != NULL) && (xkbi->desc != NULL)) {
+ ctrl = xkbi->desc->ctrls;
+ ctrl->repeat_delay = g_winInfo.keyboard.delay;
+ ctrl->repeat_interval = 1000 / g_winInfo.keyboard.rate;
}
- else
- {
- winDebug ("winKeybdProc - Error initializing keyboard AutoRepeat\n");
+ else {
+ winDebug ("winKeybdProc - Error initializing keyboard AutoRepeat\n");
}
- break;
-
- case DEVICE_ON:
- pDevice->on = TRUE;
+ break;
- // immediately copy the state of this keyboard device to the VCK
- // (which otherwise happens lazily after the first keypress)
- CopyKeyClass(pDeviceInt, inputInfo.keyboard);
- break;
+ case DEVICE_ON:
+ pDevice->on = TRUE;
+
+ // immediately copy the state of this keyboard device to the VCK
+ // (which otherwise happens lazily after the first keypress)
+ CopyKeyClass(pDeviceInt, inputInfo.keyboard);
+ break;
case DEVICE_CLOSE:
- case DEVICE_OFF:
- pDevice->on = FALSE;
- break;
+ case DEVICE_OFF:
+ pDevice->on = FALSE;
+ break;
}
- return Success;
+ return Success;
}
-
/*
* Detect current mode key states upon server startup.
*
@@ -213,38 +198,33 @@ winKeybdProc (DeviceIntPtr pDeviceInt, int iState)
*/
void
-winInitializeModeKeyStates (void)
+winInitializeModeKeyStates(void)
{
- /* Restore NumLock */
- if (GetKeyState (VK_NUMLOCK) & 0x0001)
- {
- winSendKeyEvent (KEY_NumLock, TRUE);
- winSendKeyEvent (KEY_NumLock, FALSE);
+ /* Restore NumLock */
+ if (GetKeyState(VK_NUMLOCK) & 0x0001) {
+ winSendKeyEvent(KEY_NumLock, TRUE);
+ winSendKeyEvent(KEY_NumLock, FALSE);
}
- /* Restore CapsLock */
- if (GetKeyState (VK_CAPITAL) & 0x0001)
- {
- winSendKeyEvent (KEY_CapsLock, TRUE);
- winSendKeyEvent (KEY_CapsLock, FALSE);
+ /* Restore CapsLock */
+ if (GetKeyState(VK_CAPITAL) & 0x0001) {
+ winSendKeyEvent(KEY_CapsLock, TRUE);
+ winSendKeyEvent(KEY_CapsLock, FALSE);
}
- /* Restore ScrollLock */
- if (GetKeyState (VK_SCROLL) & 0x0001)
- {
- winSendKeyEvent (KEY_ScrollLock, TRUE);
- winSendKeyEvent (KEY_ScrollLock, FALSE);
+ /* Restore ScrollLock */
+ if (GetKeyState(VK_SCROLL) & 0x0001) {
+ winSendKeyEvent(KEY_ScrollLock, TRUE);
+ winSendKeyEvent(KEY_ScrollLock, FALSE);
}
- /* Restore KanaLock */
- if (GetKeyState (VK_KANA) & 0x0001)
- {
- winSendKeyEvent (KEY_HKTG, TRUE);
- winSendKeyEvent (KEY_HKTG, FALSE);
+ /* Restore KanaLock */
+ if (GetKeyState(VK_KANA) & 0x0001) {
+ winSendKeyEvent(KEY_HKTG, TRUE);
+ winSendKeyEvent(KEY_HKTG, FALSE);
}
}
-
/*
* Upon regaining the keyboard focus we must
* resynchronize our internal mode key states
@@ -252,29 +232,31 @@ winInitializeModeKeyStates (void)
*/
void
-winRestoreModeKeyStates (void)
+winRestoreModeKeyStates(void)
{
- DWORD dwKeyState;
- BOOL processEvents = TRUE;
- unsigned short internalKeyStates;
-
- /* X server is being initialized */
- if (!inputInfo.keyboard)
- return;
-
- /* Only process events if the rootwindow is mapped. The keyboard events
- * will cause segfaults otherwise */
- if (screenInfo.screens[0]->root && screenInfo.screens[0]->root->mapped == FALSE)
- processEvents = FALSE;
-
- /* Force to process all pending events in the mi event queue */
- if (processEvents)
- mieqProcessInputEvents ();
-
- /* Read the mode key states of our X server */
- /* (stored in the virtual core keyboard) */
- internalKeyStates = XkbStateFieldFromRec(&inputInfo.keyboard->key->xkbInfo->state);
- winDebug("winRestoreModeKeyStates: state %d\n", internalKeyStates);
+ DWORD dwKeyState;
+ BOOL processEvents = TRUE;
+ unsigned short internalKeyStates;
+
+ /* X server is being initialized */
+ if (!inputInfo.keyboard)
+ return;
+
+ /* Only process events if the rootwindow is mapped. The keyboard events
+ * will cause segfaults otherwise */
+ if (screenInfo.screens[0]->root &&
+ screenInfo.screens[0]->root->mapped == FALSE)
+ processEvents = FALSE;
+
+ /* Force to process all pending events in the mi event queue */
+ if (processEvents)
+ mieqProcessInputEvents();
+
+ /* Read the mode key states of our X server */
+ /* (stored in the virtual core keyboard) */
+ internalKeyStates =
+ XkbStateFieldFromRec(&inputInfo.keyboard->key->xkbInfo->state);
+ winDebug("winRestoreModeKeyStates: state %d\n", internalKeyStates);
{
/* Make sure the message queue is empty, otherwise the GetKeyState will not always
@@ -291,11 +273,11 @@ winRestoreModeKeyStates (void)
}
}
- /*
- * NOTE: The C XOR operator, ^, will not work here because it is
- * a bitwise operator, not a logical operator. C does not
- * have a logical XOR operator, so we use a macro instead.
- */
+ /*
+ * NOTE: The C XOR operator, ^, will not work here because it is
+ * a bitwise operator, not a logical operator. C does not
+ * have a logical XOR operator, so we use a macro instead.
+ */
{
/* consider modifer keys */
@@ -320,204 +302,182 @@ winRestoreModeKeyStates (void)
winSendKeyEvent (KEY_AltLang, altgr);
}
- /* Has the key state changed? */
- dwKeyState = GetKeyState (VK_NUMLOCK) & 0x0001;
- if (WIN_XOR (internalKeyStates & NumLockMask, dwKeyState))
- {
- winSendKeyEvent (KEY_NumLock, TRUE);
- winSendKeyEvent (KEY_NumLock, FALSE);
+ /* Has the key state changed? */
+ dwKeyState = GetKeyState(VK_NUMLOCK) & 0x0001;
+ if (WIN_XOR(internalKeyStates & NumLockMask, dwKeyState)) {
+ winSendKeyEvent(KEY_NumLock, TRUE);
+ winSendKeyEvent(KEY_NumLock, FALSE);
}
- /* Has the key state changed? */
- dwKeyState = GetKeyState (VK_CAPITAL) & 0x0001;
- if (WIN_XOR (internalKeyStates & LockMask, dwKeyState))
- {
- winSendKeyEvent (KEY_CapsLock, TRUE);
- winSendKeyEvent (KEY_CapsLock, FALSE);
+ /* Has the key state changed? */
+ dwKeyState = GetKeyState(VK_CAPITAL) & 0x0001;
+ if (WIN_XOR(internalKeyStates & LockMask, dwKeyState)) {
+ winSendKeyEvent(KEY_CapsLock, TRUE);
+ winSendKeyEvent(KEY_CapsLock, FALSE);
}
- /* Has the key state changed? */
- dwKeyState = GetKeyState (VK_SCROLL) & 0x0001;
- if (WIN_XOR (internalKeyStates & ScrollLockMask, dwKeyState))
- {
- winSendKeyEvent (KEY_ScrollLock, TRUE);
- winSendKeyEvent (KEY_ScrollLock, FALSE);
+ /* Has the key state changed? */
+ dwKeyState = GetKeyState(VK_SCROLL) & 0x0001;
+ if (WIN_XOR(internalKeyStates & ScrollLockMask, dwKeyState)) {
+ winSendKeyEvent(KEY_ScrollLock, TRUE);
+ winSendKeyEvent(KEY_ScrollLock, FALSE);
}
- /* Has the key state changed? */
- dwKeyState = GetKeyState (VK_KANA) & 0x0001;
- if (WIN_XOR (internalKeyStates & KanaMask, dwKeyState))
- {
- winSendKeyEvent (KEY_HKTG, TRUE);
- winSendKeyEvent (KEY_HKTG, FALSE);
+ /* Has the key state changed? */
+ dwKeyState = GetKeyState(VK_KANA) & 0x0001;
+ if (WIN_XOR(internalKeyStates & KanaMask, dwKeyState)) {
+ winSendKeyEvent(KEY_HKTG, TRUE);
+ winSendKeyEvent(KEY_HKTG, FALSE);
}
}
-
/*
* Look for the lovely fake Control_L press/release generated by Windows
* when AltGr is pressed/released on a non-U.S. keyboard.
*/
Bool
-winIsFakeCtrl_L (UINT message, WPARAM wParam, LPARAM lParam)
+winIsFakeCtrl_L(UINT message, WPARAM wParam, LPARAM lParam)
{
- MSG msgNext;
- LONG lTime;
- Bool fReturn;
-
- static Bool lastWasControlL = FALSE;
- static UINT lastMessage;
- static LONG lastTime;
-
- /*
- * Fake Ctrl_L presses will be followed by an Alt_R press
- * with the same timestamp as the Ctrl_L press.
- */
- if ((message == WM_KEYDOWN || message == WM_SYSKEYDOWN)
- && wParam == VK_CONTROL
- && (HIWORD (lParam) & KF_EXTENDED) == 0)
- {
- /* Got a Ctrl_L press */
-
- /* Get time of current message */
- lTime = GetMessageTime ();
-
- /* Look for next press message */
- fReturn = PeekMessage (&msgNext, NULL,
- WM_KEYDOWN, WM_SYSKEYDOWN,
- PM_NOREMOVE);
-
- if (fReturn && msgNext.message != WM_KEYDOWN && msgNext.message != WM_SYSKEYDOWN)
- fReturn = 0;
-
- if (!fReturn)
- {
- lastWasControlL = TRUE;
- lastMessage = message;
- lastTime = lTime;
+ MSG msgNext;
+ LONG lTime;
+ Bool fReturn;
+
+ static Bool lastWasControlL = FALSE;
+ static UINT lastMessage;
+ static LONG lastTime;
+
+ /*
+ * Fake Ctrl_L presses will be followed by an Alt_R press
+ * with the same timestamp as the Ctrl_L press.
+ */
+ if ((message == WM_KEYDOWN || message == WM_SYSKEYDOWN)
+ && wParam == VK_CONTROL && (HIWORD(lParam) & KF_EXTENDED) == 0) {
+ /* Got a Ctrl_L press */
+
+ /* Get time of current message */
+ lTime = GetMessageTime();
+
+ /* Look for next press message */
+ fReturn = PeekMessage(&msgNext, NULL,
+ WM_KEYDOWN, WM_SYSKEYDOWN, PM_NOREMOVE);
+
+ if (fReturn && msgNext.message != WM_KEYDOWN &&
+ msgNext.message != WM_SYSKEYDOWN)
+ fReturn = 0;
+
+ if (!fReturn) {
+ lastWasControlL = TRUE;
+ lastMessage = message;
+ lastTime = lTime;
}
- else
- {
- lastWasControlL = FALSE;
+ else {
+ lastWasControlL = FALSE;
}
- /* 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;
- }
+ /* 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;
+ }
}
- /*
- * Sometimes, the Alt_R press message is not yet posted when the
- * fake Ctrl_L press message arrives (even though it has the
- * same timestamp), so check for an Alt_R press message that has
- * arrived since the last Ctrl_L message.
- */
- else if ((message == WM_KEYDOWN || message == WM_SYSKEYDOWN)
- && wParam == VK_MENU
- && (HIWORD (lParam) & KF_EXTENDED))
- {
- /* Got a Alt_R press */
-
- if (lastWasControlL)
- {
- lTime = GetMessageTime ();
-
- if (lastTime == lTime)
- {
+ /*
+ * Sometimes, the Alt_R press message is not yet posted when the
+ * fake Ctrl_L press message arrives (even though it has the
+ * same timestamp), so check for an Alt_R press message that has
+ * arrived since the last Ctrl_L message.
+ */
+ else if ((message == WM_KEYDOWN || message == WM_SYSKEYDOWN)
+ && wParam == VK_MENU && (HIWORD(lParam) & KF_EXTENDED)) {
+ /* Got a Alt_R press */
+
+ if (lastWasControlL) {
+ lTime = GetMessageTime();
+
+ if (lastTime == lTime) {
/* Undo the fake Ctrl_L press by sending a fake Ctrl_L release */
- winSendKeyEvent (KEY_LCtrl, FALSE);
+ winSendKeyEvent(KEY_LCtrl, FALSE);
}
- lastWasControlL = FALSE;
+ lastWasControlL = FALSE;
}
}
- /*
- * Fake Ctrl_L releases will be followed by an Alt_R release
- * with the same timestamp as the Ctrl_L release.
- */
- else 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 next release message */
- fReturn = PeekMessage (&msgNext, NULL,
- WM_KEYUP, WM_SYSKEYUP,
- PM_NOREMOVE);
-
- if (fReturn && msgNext.message != WM_KEYUP && msgNext.message != WM_SYSKEYUP)
- fReturn = 0;
-
- lastWasControlL = FALSE;
-
- /* 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;
- }
+ /*
+ * Fake Ctrl_L releases will be followed by an Alt_R release
+ * with the same timestamp as the Ctrl_L release.
+ */
+ else 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 next release message */
+ fReturn = PeekMessage(&msgNext, NULL,
+ WM_KEYUP, WM_SYSKEYUP, PM_NOREMOVE);
+
+ if (fReturn && msgNext.message != WM_KEYUP &&
+ msgNext.message != WM_SYSKEYUP)
+ fReturn = 0;
+
+ lastWasControlL = FALSE;
+
+ /* 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;
+ }
}
- else
- {
- /* On any other press or release message, we don't have a
- potentially fake Ctrl_L to worry about anymore... */
- lastWasControlL = FALSE;
+ else {
+ /* On any other press or release message, we don't have a
+ potentially fake Ctrl_L to worry about anymore... */
+ lastWasControlL = FALSE;
}
- /* Not a fake control left press/release */
- return FALSE;
+ /* Not a fake control left press/release */
+ return FALSE;
}
-
/*
* Lift any modifier keys that are pressed
*/
void
-winKeybdReleaseKeys (void)
+winKeybdReleaseKeys(void)
{
- int i;
+ int i;
#ifdef HAS_DEVWINDOWS
- /* Verify that the mi input system has been initialized */
- if (g_fdMessageQueue == WIN_FD_INVALID)
- return;
+ /* Verify that the mi input system has been initialized */
+ if (g_fdMessageQueue == WIN_FD_INVALID)
+ return;
#endif
- /* Loop through all keys */
- for (i = 0; i < NUM_KEYCODES; ++i)
- {
- /* Pop key if pressed */
- if (g_winKeyState[i])
- winSendKeyEvent (i, FALSE);
+ /* Loop through all keys */
+ for (i = 0; i < NUM_KEYCODES; ++i) {
+ /* Pop key if pressed */
+ if (g_winKeyState[i])
+ winSendKeyEvent(i, FALSE);
- /* Reset pressed flag for keys */
- g_winKeyState[i] = FALSE;
+ /* Reset pressed flag for keys */
+ g_winKeyState[i] = FALSE;
}
}
-
/*
* Take a raw X key code and send an up or down event for it.
*
@@ -525,55 +485,57 @@ winKeybdReleaseKeys (void)
*/
void
-winSendKeyEvent (DWORD dwKey, Bool fDown)
+winSendKeyEvent(DWORD dwKey, Bool fDown)
{
- /*
- * When alt-tabing between screens we can get phantom key up messages
- * Here we only pass them through it we think we should!
- */
- if (g_winKeyState[dwKey] == FALSE && fDown == FALSE) return;
+ /*
+ * When alt-tabing between screens we can get phantom key up messages
+ * Here we only pass them through it we think we should!
+ */
+ if (g_winKeyState[dwKey] == FALSE && fDown == FALSE)
+ return;
- /* Update the keyState map */
- g_winKeyState[dwKey] = fDown;
+ /* Update the keyState map */
+ g_winKeyState[dwKey] = fDown;
- QueueKeyboardEvents(g_pwinKeyboard, fDown ? KeyPress : KeyRelease, dwKey + MIN_KEYCODE, NULL);
+ QueueKeyboardEvents(g_pwinKeyboard, fDown ? KeyPress : KeyRelease,
+ dwKey + MIN_KEYCODE, NULL);
- winDebug("winSendKeyEvent: dwKey: %d, fDown: %d\n",
- dwKey, fDown);
+ winDebug("winSendKeyEvent: dwKey: %d, fDown: %d\n", dwKey, fDown);
}
-BOOL winCheckKeyPressed(WPARAM wParam, LPARAM lParam)
+BOOL
+winCheckKeyPressed(WPARAM wParam, LPARAM lParam)
{
- switch (wParam)
- {
+ switch (wParam) {
case VK_CONTROL:
- if ((lParam & 0x1ff0000) == 0x11d0000 && g_winKeyState[KEY_RCtrl])
- return TRUE;
- if ((lParam & 0x1ff0000) == 0x01d0000 && g_winKeyState[KEY_LCtrl])
- return TRUE;
- break;
+ if ((lParam & 0x1ff0000) == 0x11d0000 && g_winKeyState[KEY_RCtrl])
+ return TRUE;
+ if ((lParam & 0x1ff0000) == 0x01d0000 && g_winKeyState[KEY_LCtrl])
+ return TRUE;
+ break;
case VK_SHIFT:
- if ((lParam & 0x1ff0000) == 0x0360000 && g_winKeyState[KEY_ShiftR])
- return TRUE;
- if ((lParam & 0x1ff0000) == 0x02a0000 && g_winKeyState[KEY_ShiftL])
- return TRUE;
- break;
+ if ((lParam & 0x1ff0000) == 0x0360000 && g_winKeyState[KEY_ShiftR])
+ return TRUE;
+ if ((lParam & 0x1ff0000) == 0x02a0000 && g_winKeyState[KEY_ShiftL])
+ return TRUE;
+ break;
default:
- return TRUE;
- }
- return FALSE;
+ return TRUE;
+ }
+ return FALSE;
}
/* Only on shift release message is sent even if both are pressed.
* Fix this here
*/
-void winFixShiftKeys (int iScanCode)
+void
+winFixShiftKeys(int iScanCode)
{
- if (GetKeyState (VK_SHIFT) & 0x8000)
- return;
+ if (GetKeyState(VK_SHIFT) & 0x8000)
+ return;
- if (iScanCode == KEY_ShiftL && g_winKeyState[KEY_ShiftR])
- winSendKeyEvent (KEY_ShiftR, FALSE);
- if (iScanCode == KEY_ShiftR && g_winKeyState[KEY_ShiftL])
- winSendKeyEvent (KEY_ShiftL, FALSE);
+ if (iScanCode == KEY_ShiftL && g_winKeyState[KEY_ShiftR])
+ winSendKeyEvent(KEY_ShiftR, FALSE);
+ if (iScanCode == KEY_ShiftR && g_winKeyState[KEY_ShiftL])
+ winSendKeyEvent(KEY_ShiftL, FALSE);
}
diff --git a/xorg-server/hw/xwin/winkeybd.h b/xorg-server/hw/xwin/winkeybd.h
index 292d05cb6..545aef751 100644
--- a/xorg-server/hw/xwin/winkeybd.h
+++ b/xorg-server/hw/xwin/winkeybd.h
@@ -45,264 +45,266 @@
* may not be associated with the appropriate scan code/extended bit
*/
const int
-g_iKeyMap [] = {
- /* count Windows VK, ASCII, ASCII when extended VK */
- /* 0 */ 0, 0, 0,
- /* 1 */ 0, 0, 0,
- /* 2 */ 0, 0, 0,
- /* 3 */ VK_CANCEL, 0, KEY_Break,
- /* 4 */ 0, 0, 0,
- /* 5 */ 0, 0, 0,
- /* 6 */ 0, 0, 0,
- /* 7 */ 0, 0, 0,
- /* 8 */ 0, 0, 0,
- /* 9 */ 0, 0, 0,
- /* 10 */ 0, 0, 0,
- /* 11 */ 0, 0, 0,
- /* 12 */ 0, 0, 0,
- /* 13 */ VK_RETURN, 0, KEY_KP_Enter,
- /* 14 */ 0, 0, 0,
- /* 15 */ 0, 0, 0,
- /* 16 */ VK_SHIFT, 0, 0,
- /* 17 */ VK_CONTROL, 0, KEY_RCtrl,
- /* 18 */ VK_MENU, 0, KEY_AltLang,
- /* 19 */ VK_PAUSE, KEY_Pause, 0,
- /* 20 */ 0, 0, 0,
- /* 21 */ 0, 0, 0,
- /* 22 */ 0, 0, 0,
- /* 23 */ 0, 0, 0,
- /* 24 */ 0, 0, 0,
- /* 25 */ 0, 0, 0,
- /* 26 */ 0, 0, 0,
- /* 27 */ 0, 0, 0,
- /* 28 */ 0, 0, 0,
- /* 29 */ 0, 0, 0,
- /* 30 */ 0, 0, 0,
- /* 31 */ 0, 0, 0,
- /* 32 */ 0, 0, 0,
- /* 33 */ VK_PRIOR, KEY_PgUp, KEY_PgUp,
- /* 34 */ VK_NEXT, KEY_PgDown, KEY_PgDown,
- /* 35 */ VK_END, KEY_End, KEY_End,
- /* 36 */ VK_HOME, KEY_Home, KEY_Home,
- /* 37 */ VK_LEFT, KEY_Left, KEY_Left,
- /* 38 */ VK_UP, KEY_Up, KEY_Up,
- /* 39 */ VK_RIGHT, KEY_Right, KEY_Right,
- /* 40 */ VK_DOWN, KEY_Down, KEY_Down,
- /* 41 */ 0, 0, 0,
- /* 42 */ 0, 0, 0,
- /* 43 */ 0, 0, 0,
- /* 44 */ VK_SNAPSHOT, 0, KEY_Print,
- /* 45 */ VK_INSERT, 0, KEY_Insert,
- /* 46 */ VK_DELETE, 0, KEY_Delete,
- /* 47 */ 0, 0, 0,
- /* 48 */ 0, 0, 0,
- /* 49 */ 0, 0, 0,
- /* 50 */ 0, 0, 0,
- /* 51 */ 0, 0, 0,
- /* 52 */ 0, 0, 0,
- /* 53 */ 0, 0, 0,
- /* 54 */ 0, 0, 0,
- /* 55 */ 0, 0, 0,
- /* 56 */ 0, 0, 0,
- /* 57 */ 0, 0, 0,
- /* 58 */ 0, 0, 0,
- /* 59 */ 0, 0, 0,
- /* 60 */ 0, 0, 0,
- /* 61 */ 0, 0, 0,
- /* 62 */ 0, 0, 0,
- /* 63 */ 0, 0, 0,
- /* 64 */ 0, 0, 0,
- /* 65 */ 0, 0, 0,
- /* 66 */ 0, 0, 0,
- /* 67 */ 0, 0, 0,
- /* 68 */ 0, 0, 0,
- /* 69 */ 0, 0, 0,
- /* 70 */ 0, 0, 0,
- /* 71 */ 0, 0, 0,
- /* 72 */ 0, 0, 0,
- /* 73 */ 0, 0, 0,
- /* 74 */ 0, 0, 0,
- /* 75 */ 0, 0, 0,
- /* 76 */ 0, 0, 0,
- /* 77 */ 0, 0, 0,
- /* 78 */ 0, 0, 0,
- /* 79 */ 0, 0, 0,
- /* 80 */ 0, 0, 0,
- /* 81 */ 0, 0, 0,
- /* 82 */ 0, 0, 0,
- /* 83 */ 0, 0, 0,
- /* 84 */ 0, 0, 0,
- /* 85 */ 0, 0, 0,
- /* 86 */ 0, 0, 0,
- /* 87 */ 0, 0, 0,
- /* 88 */ 0, 0, 0,
- /* 89 */ 0, 0, 0,
- /* 90 */ 0, 0, 0,
- /* 91 */ VK_LWIN, KEY_LMeta, 0,
- /* 92 */ VK_RWIN, KEY_RMeta, 0,
- /* 93 */ VK_APPS, KEY_Menu, 0,
- /* 94 */ 0, 0, 0,
- /* 95 */ 0, 0, 0,
- /* 96 */ 0, 0, 0,
- /* 97 */ 0, 0, 0,
- /* 98 */ 0, 0, 0,
- /* 99 */ 0, 0, 0,
- /* 100 */ 0, 0, 0,
- /* 101 */ 0, 0, 0,
- /* 102 */ 0, 0, 0,
- /* 103 */ 0, 0, 0,
- /* 104 */ 0, 0, 0,
- /* 105 */ 0, 0, 0,
- /* 106 */ 0, 0, 0,
- /* 107 */ 0, 0, 0,
- /* 108 */ 0, 0, 0,
- /* 109 */ 0, 0, 0,
- /* 110 */ 0, 0, 0,
- /* 111 */ VK_DIVIDE, 0, KEY_KP_Divide,
- /* 112 */ 0, 0, 0,
- /* 113 */ 0, 0, 0,
- /* 114 */ 0, 0, 0,
- /* 115 */ 0, 0, 0,
- /* 116 */ 0, 0, 0,
- /* 117 */ 0, 0, 0,
- /* 118 */ 0, 0, 0,
- /* 119 */ 0, 0, 0,
- /* 120 */ 0, 0, 0,
- /* 121 */ 0, 0, 0,
- /* 122 */ 0, 0, 0,
- /* 123 */ 0, 0, 0,
- /* 124 */ 0, 0, 0,
- /* 125 */ 0, 0, 0,
- /* 126 */ 0, 0, 0,
- /* 127 */ 0, 0, 0,
- /* 128 */ 0, 0, 0,
- /* 129 */ 0, 0, 0,
- /* 130 */ 0, 0, 0,
- /* 131 */ 0, 0, 0,
- /* 132 */ 0, 0, 0,
- /* 133 */ 0, 0, 0,
- /* 134 */ 0, 0, 0,
- /* 135 */ 0, 0, 0,
- /* 136 */ 0, 0, 0,
- /* 137 */ 0, 0, 0,
- /* 138 */ 0, 0, 0,
- /* 139 */ 0, 0, 0,
- /* 140 */ 0, 0, 0,
- /* 141 */ 0, 0, 0,
- /* 142 */ 0, 0, 0,
- /* 143 */ 0, 0, 0,
- /* 144 */ 0, 0, 0,
- /* 145 */ 0, 0, 0,
- /* 146 */ 0, 0, 0,
- /* 147 */ 0, 0, 0,
- /* 148 */ 0, 0, 0,
- /* 149 */ 0, 0, 0,
- /* 150 */ 0, 0, 0,
- /* 151 */ 0, 0, 0,
- /* 152 */ 0, 0, 0,
- /* 153 */ 0, 0, 0,
- /* 154 */ 0, 0, 0,
- /* 155 */ 0, 0, 0,
- /* 156 */ 0, 0, 0,
- /* 157 */ 0, 0, 0,
- /* 158 */ 0, 0, 0,
- /* 159 */ 0, 0, 0,
- /* 160 */ VK_LSHIFT, KEY_ShiftL, KEY_ShiftL,
- /* 161 */ VK_RSHIFT, KEY_ShiftR, KEY_ShiftR,
- /* 162 */ VK_LCONTROL, KEY_LCtrl, KEY_LCtrl,
- /* 163 */ VK_RCONTROL, KEY_RCtrl, KEY_RCtrl,
- /* 164 */ VK_LMENU, KEY_Alt, KEY_Alt,
- /* 165 */ VK_RMENU, KEY_AltLang, KEY_AltLang,
- /* 166 */ 0, 0, 0,
- /* 167 */ 0, 0, 0,
- /* 168 */ 0, 0, 0,
- /* 169 */ 0, 0, 0,
- /* 170 */ 0, 0, 0,
- /* 171 */ 0, 0, 0,
- /* 172 */ 0, 0, 0,
- /* 173 */ VK_VOLUME_MUTE, 0, KEY_Mute,
- /* 174 */ VK_VOLUME_DOWN, 0, KEY_AudioLower,
- /* 175 */ VK_VOLUME_UP, 0, KEY_AudioRaise,
- /* 176 */ VK_MEDIA_NEXT_TRACK, 0, KEY_NEXTSONG,
- /* 177 */ VK_MEDIA_PREV_TRACK, 0, KEY_PREVIOUSSONG,
- /* 178 */ VK_MEDIA_STOP, 0, KEY_STOPCD,
- /* 179 */ VK_MEDIA_PLAY_PAUSE, 0, KEY_PLAYPAUSE,
- /* 180 */ 0, 0, 0,
- /* 181 */ 0, 0, 0,
- /* 182 */ 0, 0, 0,
- /* 183 */ 0, 0, 0,
- /* 184 */ 0, 0, 0,
- /* 185 */ 0, 0, 0,
- /* 186 */ 0, 0, 0,
- /* 187 */ 0, 0, 0,
- /* 188 */ 0, 0, 0,
- /* 189 */ 0, 0, 0,
- /* 190 */ 0, 0, 0,
- /* 191 */ 0, 0, 0,
- /* 192 */ 0, 0, 0,
- /* 193 */ 0, 0, 0,
- /* 194 */ 0, 0, 0,
- /* 195 */ 0, 0, 0,
- /* 196 */ 0, 0, 0,
- /* 197 */ 0, 0, 0,
- /* 198 */ 0, 0, 0,
- /* 199 */ 0, 0, 0,
- /* 200 */ 0, 0, 0,
- /* 201 */ 0, 0, 0,
- /* 202 */ 0, 0, 0,
- /* 203 */ 0, 0, 0,
- /* 204 */ 0, 0, 0,
- /* 205 */ 0, 0, 0,
- /* 206 */ 0, 0, 0,
- /* 207 */ 0, 0, 0,
- /* 208 */ 0, 0, 0,
- /* 209 */ 0, 0, 0,
- /* 210 */ 0, 0, 0,
- /* 211 */ 0, 0, 0,
- /* 212 */ 0, 0, 0,
- /* 213 */ 0, 0, 0,
- /* 214 */ 0, 0, 0,
- /* 215 */ 0, 0, 0,
- /* 216 */ 0, 0, 0,
- /* 217 */ 0, 0, 0,
- /* 218 */ 0, 0, 0,
- /* 219 */ 0, 0, 0,
- /* 220 */ 0, 0, 0,
- /* 221 */ 0, 0, 0,
- /* 222 */ 0, 0, 0,
- /* 223 */ VK_OEM_8, 0, KEY_RCtrl, /* at least on Canadian Multilingual Standard layout */
- /* 224 */ 0, 0, 0,
- /* 225 */ 0, 0, 0,
- /* 226 */ 0, 0, 0,
- /* 227 */ 0, 0, 0,
- /* 228 */ 0, 0, 0,
- /* 229 */ 0, 0, 0,
- /* 230 */ 0, 0, 0,
- /* 231 */ 0, 0, 0,
- /* 232 */ 0, 0, 0,
- /* 233 */ 0, 0, 0,
- /* 234 */ 0, 0, 0,
- /* 235 */ 0, 0, 0,
- /* 236 */ 0, 0, 0,
- /* 237 */ 0, 0, 0,
- /* 238 */ 0, 0, 0,
- /* 239 */ 0, 0, 0,
- /* 240 */ 0, 0, 0,
- /* 241 */ 0, 0, 0,
- /* 242 */ 0, 0, 0,
- /* 243 */ 0, 0, 0,
- /* 244 */ 0, 0, 0,
- /* 245 */ 0, 0, 0,
- /* 246 */ 0, 0, 0,
- /* 247 */ 0, 0, 0,
- /* 248 */ 0, 0, 0,
- /* 249 */ 0, 0, 0,
- /* 250 */ 0, 0, 0,
- /* 251 */ 0, 0, 0,
- /* 252 */ 0, 0, 0,
- /* 253 */ 0, 0, 0,
- /* 254 */ 0, 0, 0,
- /* 255 */ VK_FN, 0, KEY_Fn /* Most keyboards don't generate a scancode for Fn, but a few do... */
+ g_iKeyMap[] = {
+ /* count Windows VK, ASCII, ASCII when extended VK */
+ /* 0 */ 0, 0, 0,
+ /* 1 */ 0, 0, 0,
+ /* 2 */ 0, 0, 0,
+ /* 3 */ VK_CANCEL, 0, KEY_Break,
+ /* 4 */ 0, 0, 0,
+ /* 5 */ 0, 0, 0,
+ /* 6 */ 0, 0, 0,
+ /* 7 */ 0, 0, 0,
+ /* 8 */ 0, 0, 0,
+ /* 9 */ 0, 0, 0,
+ /* 10 */ 0, 0, 0,
+ /* 11 */ 0, 0, 0,
+ /* 12 */ 0, 0, 0,
+ /* 13 */ VK_RETURN, 0, KEY_KP_Enter,
+ /* 14 */ 0, 0, 0,
+ /* 15 */ 0, 0, 0,
+ /* 16 */ VK_SHIFT, 0, 0,
+ /* 17 */ VK_CONTROL, 0, KEY_RCtrl,
+ /* 18 */ VK_MENU, 0, KEY_AltLang,
+ /* 19 */ VK_PAUSE, KEY_Pause, 0,
+ /* 20 */ 0, 0, 0,
+ /* 21 */ 0, 0, 0,
+ /* 22 */ 0, 0, 0,
+ /* 23 */ 0, 0, 0,
+ /* 24 */ 0, 0, 0,
+ /* 25 */ 0, 0, 0,
+ /* 26 */ 0, 0, 0,
+ /* 27 */ 0, 0, 0,
+ /* 28 */ 0, 0, 0,
+ /* 29 */ 0, 0, 0,
+ /* 30 */ 0, 0, 0,
+ /* 31 */ 0, 0, 0,
+ /* 32 */ 0, 0, 0,
+ /* 33 */ VK_PRIOR, KEY_PgUp, KEY_PgUp,
+ /* 34 */ VK_NEXT, KEY_PgDown, KEY_PgDown,
+ /* 35 */ VK_END, KEY_End, KEY_End,
+ /* 36 */ VK_HOME, KEY_Home, KEY_Home,
+ /* 37 */ VK_LEFT, KEY_Left, KEY_Left,
+ /* 38 */ VK_UP, KEY_Up, KEY_Up,
+ /* 39 */ VK_RIGHT, KEY_Right, KEY_Right,
+ /* 40 */ VK_DOWN, KEY_Down, KEY_Down,
+ /* 41 */ 0, 0, 0,
+ /* 42 */ 0, 0, 0,
+ /* 43 */ 0, 0, 0,
+ /* 44 */ VK_SNAPSHOT, 0, KEY_Print,
+ /* 45 */ VK_INSERT, 0, KEY_Insert,
+ /* 46 */ VK_DELETE, 0, KEY_Delete,
+ /* 47 */ 0, 0, 0,
+ /* 48 */ 0, 0, 0,
+ /* 49 */ 0, 0, 0,
+ /* 50 */ 0, 0, 0,
+ /* 51 */ 0, 0, 0,
+ /* 52 */ 0, 0, 0,
+ /* 53 */ 0, 0, 0,
+ /* 54 */ 0, 0, 0,
+ /* 55 */ 0, 0, 0,
+ /* 56 */ 0, 0, 0,
+ /* 57 */ 0, 0, 0,
+ /* 58 */ 0, 0, 0,
+ /* 59 */ 0, 0, 0,
+ /* 60 */ 0, 0, 0,
+ /* 61 */ 0, 0, 0,
+ /* 62 */ 0, 0, 0,
+ /* 63 */ 0, 0, 0,
+ /* 64 */ 0, 0, 0,
+ /* 65 */ 0, 0, 0,
+ /* 66 */ 0, 0, 0,
+ /* 67 */ 0, 0, 0,
+ /* 68 */ 0, 0, 0,
+ /* 69 */ 0, 0, 0,
+ /* 70 */ 0, 0, 0,
+ /* 71 */ 0, 0, 0,
+ /* 72 */ 0, 0, 0,
+ /* 73 */ 0, 0, 0,
+ /* 74 */ 0, 0, 0,
+ /* 75 */ 0, 0, 0,
+ /* 76 */ 0, 0, 0,
+ /* 77 */ 0, 0, 0,
+ /* 78 */ 0, 0, 0,
+ /* 79 */ 0, 0, 0,
+ /* 80 */ 0, 0, 0,
+ /* 81 */ 0, 0, 0,
+ /* 82 */ 0, 0, 0,
+ /* 83 */ 0, 0, 0,
+ /* 84 */ 0, 0, 0,
+ /* 85 */ 0, 0, 0,
+ /* 86 */ 0, 0, 0,
+ /* 87 */ 0, 0, 0,
+ /* 88 */ 0, 0, 0,
+ /* 89 */ 0, 0, 0,
+ /* 90 */ 0, 0, 0,
+ /* 91 */ VK_LWIN, KEY_LMeta, 0,
+ /* 92 */ VK_RWIN, KEY_RMeta, 0,
+ /* 93 */ VK_APPS, KEY_Menu, 0,
+ /* 94 */ 0, 0, 0,
+ /* 95 */ 0, 0, 0,
+ /* 96 */ 0, 0, 0,
+ /* 97 */ 0, 0, 0,
+ /* 98 */ 0, 0, 0,
+ /* 99 */ 0, 0, 0,
+ /* 100 */ 0, 0, 0,
+ /* 101 */ 0, 0, 0,
+ /* 102 */ 0, 0, 0,
+ /* 103 */ 0, 0, 0,
+ /* 104 */ 0, 0, 0,
+ /* 105 */ 0, 0, 0,
+ /* 106 */ 0, 0, 0,
+ /* 107 */ 0, 0, 0,
+ /* 108 */ 0, 0, 0,
+ /* 109 */ 0, 0, 0,
+ /* 110 */ 0, 0, 0,
+ /* 111 */ VK_DIVIDE, 0, KEY_KP_Divide,
+ /* 112 */ 0, 0, 0,
+ /* 113 */ 0, 0, 0,
+ /* 114 */ 0, 0, 0,
+ /* 115 */ 0, 0, 0,
+ /* 116 */ 0, 0, 0,
+ /* 117 */ 0, 0, 0,
+ /* 118 */ 0, 0, 0,
+ /* 119 */ 0, 0, 0,
+ /* 120 */ 0, 0, 0,
+ /* 121 */ 0, 0, 0,
+ /* 122 */ 0, 0, 0,
+ /* 123 */ 0, 0, 0,
+ /* 124 */ 0, 0, 0,
+ /* 125 */ 0, 0, 0,
+ /* 126 */ 0, 0, 0,
+ /* 127 */ 0, 0, 0,
+ /* 128 */ 0, 0, 0,
+ /* 129 */ 0, 0, 0,
+ /* 130 */ 0, 0, 0,
+ /* 131 */ 0, 0, 0,
+ /* 132 */ 0, 0, 0,
+ /* 133 */ 0, 0, 0,
+ /* 134 */ 0, 0, 0,
+ /* 135 */ 0, 0, 0,
+ /* 136 */ 0, 0, 0,
+ /* 137 */ 0, 0, 0,
+ /* 138 */ 0, 0, 0,
+ /* 139 */ 0, 0, 0,
+ /* 140 */ 0, 0, 0,
+ /* 141 */ 0, 0, 0,
+ /* 142 */ 0, 0, 0,
+ /* 143 */ 0, 0, 0,
+ /* 144 */ 0, 0, 0,
+ /* 145 */ 0, 0, 0,
+ /* 146 */ 0, 0, 0,
+ /* 147 */ 0, 0, 0,
+ /* 148 */ 0, 0, 0,
+ /* 149 */ 0, 0, 0,
+ /* 150 */ 0, 0, 0,
+ /* 151 */ 0, 0, 0,
+ /* 152 */ 0, 0, 0,
+ /* 153 */ 0, 0, 0,
+ /* 154 */ 0, 0, 0,
+ /* 155 */ 0, 0, 0,
+ /* 156 */ 0, 0, 0,
+ /* 157 */ 0, 0, 0,
+ /* 158 */ 0, 0, 0,
+ /* 159 */ 0, 0, 0,
+ /* 160 */ VK_LSHIFT, KEY_ShiftL, KEY_ShiftL,
+ /* 161 */ VK_RSHIFT, KEY_ShiftR, KEY_ShiftR,
+ /* 162 */ VK_LCONTROL, KEY_LCtrl, KEY_LCtrl,
+ /* 163 */ VK_RCONTROL, KEY_RCtrl, KEY_RCtrl,
+ /* 164 */ VK_LMENU, KEY_Alt, KEY_Alt,
+ /* 165 */ VK_RMENU, KEY_AltLang, KEY_AltLang,
+ /* 166 */ 0, 0, 0,
+ /* 167 */ 0, 0, 0,
+ /* 168 */ 0, 0, 0,
+ /* 169 */ 0, 0, 0,
+ /* 170 */ 0, 0, 0,
+ /* 171 */ 0, 0, 0,
+ /* 172 */ 0, 0, 0,
+ /* 173 */ VK_VOLUME_MUTE, 0, KEY_Mute,
+ /* 174 */ VK_VOLUME_DOWN, 0, KEY_AudioLower,
+ /* 175 */ VK_VOLUME_UP, 0, KEY_AudioRaise,
+ /* 176 */ VK_MEDIA_NEXT_TRACK, 0, KEY_NEXTSONG,
+ /* 177 */ VK_MEDIA_PREV_TRACK, 0, KEY_PREVIOUSSONG,
+ /* 178 */ VK_MEDIA_STOP, 0, KEY_STOPCD,
+ /* 179 */ VK_MEDIA_PLAY_PAUSE, 0, KEY_PLAYPAUSE,
+ /* 180 */ 0, 0, 0,
+ /* 181 */ 0, 0, 0,
+ /* 182 */ 0, 0, 0,
+ /* 183 */ 0, 0, 0,
+ /* 184 */ 0, 0, 0,
+ /* 185 */ 0, 0, 0,
+ /* 186 */ 0, 0, 0,
+ /* 187 */ 0, 0, 0,
+ /* 188 */ 0, 0, 0,
+ /* 189 */ 0, 0, 0,
+ /* 190 */ 0, 0, 0,
+ /* 191 */ 0, 0, 0,
+ /* 192 */ 0, 0, 0,
+ /* 193 */ 0, 0, 0,
+ /* 194 */ 0, 0, 0,
+ /* 195 */ 0, 0, 0,
+ /* 196 */ 0, 0, 0,
+ /* 197 */ 0, 0, 0,
+ /* 198 */ 0, 0, 0,
+ /* 199 */ 0, 0, 0,
+ /* 200 */ 0, 0, 0,
+ /* 201 */ 0, 0, 0,
+ /* 202 */ 0, 0, 0,
+ /* 203 */ 0, 0, 0,
+ /* 204 */ 0, 0, 0,
+ /* 205 */ 0, 0, 0,
+ /* 206 */ 0, 0, 0,
+ /* 207 */ 0, 0, 0,
+ /* 208 */ 0, 0, 0,
+ /* 209 */ 0, 0, 0,
+ /* 210 */ 0, 0, 0,
+ /* 211 */ 0, 0, 0,
+ /* 212 */ 0, 0, 0,
+ /* 213 */ 0, 0, 0,
+ /* 214 */ 0, 0, 0,
+ /* 215 */ 0, 0, 0,
+ /* 216 */ 0, 0, 0,
+ /* 217 */ 0, 0, 0,
+ /* 218 */ 0, 0, 0,
+ /* 219 */ 0, 0, 0,
+ /* 220 */ 0, 0, 0,
+ /* 221 */ 0, 0, 0,
+ /* 222 */ 0, 0, 0,
+ /* 223 */ VK_OEM_8, 0, KEY_RCtrl,
+ /* at least on Canadian Multilingual Standard layout */
+ /* 224 */ 0, 0, 0,
+ /* 225 */ 0, 0, 0,
+ /* 226 */ 0, 0, 0,
+ /* 227 */ 0, 0, 0,
+ /* 228 */ 0, 0, 0,
+ /* 229 */ 0, 0, 0,
+ /* 230 */ 0, 0, 0,
+ /* 231 */ 0, 0, 0,
+ /* 232 */ 0, 0, 0,
+ /* 233 */ 0, 0, 0,
+ /* 234 */ 0, 0, 0,
+ /* 235 */ 0, 0, 0,
+ /* 236 */ 0, 0, 0,
+ /* 237 */ 0, 0, 0,
+ /* 238 */ 0, 0, 0,
+ /* 239 */ 0, 0, 0,
+ /* 240 */ 0, 0, 0,
+ /* 241 */ 0, 0, 0,
+ /* 242 */ 0, 0, 0,
+ /* 243 */ 0, 0, 0,
+ /* 244 */ 0, 0, 0,
+ /* 245 */ 0, 0, 0,
+ /* 246 */ 0, 0, 0,
+ /* 247 */ 0, 0, 0,
+ /* 248 */ 0, 0, 0,
+ /* 249 */ 0, 0, 0,
+ /* 250 */ 0, 0, 0,
+ /* 251 */ 0, 0, 0,
+ /* 252 */ 0, 0, 0,
+ /* 253 */ 0, 0, 0,
+ /* 254 */ 0, 0, 0,
+ /* 255 */ VK_FN, 0, KEY_Fn
+ /* Most keyboards don't generate a scancode for Fn, but a few do... */
};
-#endif /* WINKEYBD_H */
+#endif /* WINKEYBD_H */
diff --git a/xorg-server/hw/xwin/winkeyhook.c b/xorg-server/hw/xwin/winkeyhook.c
index e452fa5f7..124150850 100644
--- a/xorg-server/hw/xwin/winkeyhook.c
+++ b/xorg-server/hw/xwin/winkeyhook.c
@@ -1,186 +1,173 @@
-/*
- *Copyright (C) 2004 Harold L Hunt II All Rights Reserved.
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, sublicense, and/or sell copies of the Software, and to
- *permit persons to whom the Software is furnished to do so, subject to
- *the following conditions:
- *
- *The above copyright notice and this permission notice shall be
- *included in all copies or substantial portions of the Software.
- *
- *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
- *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *Except as contained in this notice, the name of Harold L Hunt II
- *shall not be used in advertising or otherwise to promote the sale, use
- *or other dealings in this Software without prior written authorization
- *from Harold L Hunt II.
- *
- * Authors: Harold L Hunt II
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-
-
-static HHOOK g_hhookKeyboardLL = NULL;
-
-
-/*
- * Function prototypes
- */
-
-static LRESULT CALLBACK
-winKeyboardMessageHookLL (int iCode, WPARAM wParam, LPARAM lParam);
-
-
-#ifndef LLKHF_EXTENDED
-# define LLKHF_EXTENDED 0x00000001
-#endif
-#ifndef LLKHF_UP
-# define LLKHF_UP 0x00000080
-#endif
-
-
-/*
- * KeyboardMessageHook
- */
-
-static LRESULT CALLBACK
-winKeyboardMessageHookLL (int iCode, WPARAM wParam, LPARAM lParam)
-{
- BOOL fPassKeystroke = FALSE;
- BOOL fPassAltTab = TRUE;
- PKBDLLHOOKSTRUCT p = (PKBDLLHOOKSTRUCT) lParam;
- HWND hwnd = GetActiveWindow();
-#ifdef XWIN_MULTIWINDOW
- WindowPtr pWin = NULL;
- winPrivWinPtr pWinPriv = NULL;
- winPrivScreenPtr pScreenPriv = NULL;
- winScreenInfo *pScreenInfo = NULL;
-
- /* Check if the Windows window property for our X window pointer is valid */
- if ((pWin = GetProp (hwnd, WIN_WINDOW_PROP)) != NULL)
- {
- /* Get a pointer to our window privates */
- pWinPriv = winGetWindowPriv(pWin);
-
- /* Get pointers to our screen privates and screen info */
- pScreenPriv = pWinPriv->pScreenPriv;
- pScreenInfo = pScreenPriv->pScreenInfo;
-
- if (pScreenInfo->fMultiWindow)
- fPassAltTab = FALSE;
- }
-#endif
-
- /* Pass keystrokes on to our main message loop */
- if (iCode == HC_ACTION)
- {
- winDebug("winKeyboardMessageHook: vkCode: %08x scanCode: %08x\n", p->vkCode, p->scanCode);
-
- switch (wParam)
- {
- case WM_KEYDOWN: case WM_SYSKEYDOWN:
- case WM_KEYUP: case WM_SYSKEYUP:
- fPassKeystroke =
- (fPassAltTab &&
- (p->vkCode == VK_TAB) && ((p->flags & LLKHF_ALTDOWN) != 0))
- || (p->vkCode == VK_LWIN) || (p->vkCode == VK_RWIN)
- ;
- break;
- }
- }
-
- /*
- * Pass message on to our main message loop.
- * We process this immediately with SendMessage so that the keystroke
- * appears in, hopefully, the correct order.
- */
- if (fPassKeystroke)
- {
- LPARAM lParamKey = 0x0;
-
- /* Construct the lParam from KBDLLHOOKSTRUCT */
- lParamKey = lParamKey | (0x0000FFFF & 0x00000001); /* Repeat count */
- lParamKey = lParamKey | (0x00FF0000 & (p->scanCode << 16));
- lParamKey = lParamKey
- | (0x01000000 & ((p->flags & LLKHF_EXTENDED) << 23));
- lParamKey = lParamKey
- | (0x20000000
- & ((p->flags & LLKHF_ALTDOWN) << 24));
- lParamKey = lParamKey | (0x80000000 & ((p->flags & LLKHF_UP) << 24));
-
- /* Send message to our main window that has the keyboard focus */
- PostMessage (hwnd,
- (UINT) wParam,
- (WPARAM) p->vkCode,
- lParamKey);
-
- return 1;
- }
-
- /* Call next hook */
- return CallNextHookEx (NULL, iCode, wParam, lParam);
-}
-
-
-/*
- * Attempt to install the keyboard hook, return FALSE if it was not installed
- */
-
-Bool
-winInstallKeyboardHookLL (void)
-{
- OSVERSIONINFO osvi = {0};
-
- /* Get operating system version information */
- osvi.dwOSVersionInfoSize = sizeof (osvi);
- GetVersionEx (&osvi);
-
- /* Branch on platform ID */
- switch (osvi.dwPlatformId)
- {
- case VER_PLATFORM_WIN32_NT:
- /* Low-level is supported on NT 4.0 SP3+ only */
- /* TODO: Return FALSE on NT 4.0 with no SP, SP1, or SP2 */
- break;
-
- case VER_PLATFORM_WIN32_WINDOWS:
- /* Low-level hook is not supported on non-NT */
- return FALSE;
- }
-
- /* Install the hook only once */
- if (!g_hhookKeyboardLL)
- g_hhookKeyboardLL = SetWindowsHookEx (WH_KEYBOARD_LL,
- winKeyboardMessageHookLL,
- g_hInstance,
- 0);
-
- return TRUE;
-}
-
-
-/*
- * Remove the keyboard hook if it is installed
- */
-
-void
-winRemoveKeyboardHookLL (void)
-{
- if (g_hhookKeyboardLL)
- UnhookWindowsHookEx (g_hhookKeyboardLL);
- g_hhookKeyboardLL = NULL;
-}
+/*
+ *Copyright (C) 2004 Harold L Hunt II All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of Harold L Hunt II
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from Harold L Hunt II.
+ *
+ * Authors: Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+static HHOOK g_hhookKeyboardLL = NULL;
+
+/*
+ * Function prototypes
+ */
+
+static LRESULT CALLBACK
+winKeyboardMessageHookLL(int iCode, WPARAM wParam, LPARAM lParam);
+
+#ifndef LLKHF_EXTENDED
+#define LLKHF_EXTENDED 0x00000001
+#endif
+#ifndef LLKHF_UP
+#define LLKHF_UP 0x00000080
+#endif
+
+/*
+ * KeyboardMessageHook
+ */
+
+static LRESULT CALLBACK
+winKeyboardMessageHookLL(int iCode, WPARAM wParam, LPARAM lParam)
+{
+ BOOL fPassKeystroke = FALSE;
+ BOOL fPassAltTab = TRUE;
+ PKBDLLHOOKSTRUCT p = (PKBDLLHOOKSTRUCT) lParam;
+ HWND hwnd = GetActiveWindow();
+
+#ifdef XWIN_MULTIWINDOW
+ WindowPtr pWin = NULL;
+ winPrivWinPtr pWinPriv = NULL;
+ winPrivScreenPtr pScreenPriv = NULL;
+ winScreenInfo *pScreenInfo = NULL;
+
+ /* Check if the Windows window property for our X window pointer is valid */
+ if ((pWin = GetProp(hwnd, WIN_WINDOW_PROP)) != NULL) {
+ /* Get a pointer to our window privates */
+ pWinPriv = winGetWindowPriv(pWin);
+
+ /* Get pointers to our screen privates and screen info */
+ pScreenPriv = pWinPriv->pScreenPriv;
+ pScreenInfo = pScreenPriv->pScreenInfo;
+
+ if (pScreenInfo->fMultiWindow)
+ fPassAltTab = FALSE;
+ }
+#endif
+
+ /* Pass keystrokes on to our main message loop */
+ if (iCode == HC_ACTION) {
+ winDebug("winKeyboardMessageHook: vkCode: %08x scanCode: %08x\n",
+ p->vkCode, p->scanCode);
+
+ switch (wParam) {
+ case WM_KEYDOWN:
+ case WM_SYSKEYDOWN:
+ case WM_KEYUP:
+ case WM_SYSKEYUP:
+ fPassKeystroke =
+ (fPassAltTab &&
+ (p->vkCode == VK_TAB) && ((p->flags & LLKHF_ALTDOWN) != 0))
+ || (p->vkCode == VK_LWIN) || (p->vkCode == VK_RWIN);
+ break;
+ }
+ }
+
+ /*
+ * Pass message on to our main message loop.
+ * We process this immediately with SendMessage so that the keystroke
+ * appears in, hopefully, the correct order.
+ */
+ if (fPassKeystroke) {
+ LPARAM lParamKey = 0x0;
+
+ /* Construct the lParam from KBDLLHOOKSTRUCT */
+ lParamKey = lParamKey | (0x0000FFFF & 0x00000001); /* Repeat count */
+ lParamKey = lParamKey | (0x00FF0000 & (p->scanCode << 16));
+ lParamKey = lParamKey
+ | (0x01000000 & ((p->flags & LLKHF_EXTENDED) << 23));
+ lParamKey = lParamKey
+ | (0x20000000 & ((p->flags & LLKHF_ALTDOWN) << 24));
+ lParamKey = lParamKey | (0x80000000 & ((p->flags & LLKHF_UP) << 24));
+
+ /* Send message to our main window that has the keyboard focus */
+ PostMessage(hwnd, (UINT) wParam, (WPARAM) p->vkCode, lParamKey);
+
+ return 1;
+ }
+
+ /* Call next hook */
+ return CallNextHookEx(NULL, iCode, wParam, lParam);
+}
+
+/*
+ * Attempt to install the keyboard hook, return FALSE if it was not installed
+ */
+
+Bool
+winInstallKeyboardHookLL(void)
+{
+ OSVERSIONINFO osvi = { 0 };
+
+ /* Get operating system version information */
+ osvi.dwOSVersionInfoSize = sizeof(osvi);
+ GetVersionEx(&osvi);
+
+ /* Branch on platform ID */
+ switch (osvi.dwPlatformId) {
+ case VER_PLATFORM_WIN32_NT:
+ /* Low-level is supported on NT 4.0 SP3+ only */
+ /* TODO: Return FALSE on NT 4.0 with no SP, SP1, or SP2 */
+ break;
+
+ case VER_PLATFORM_WIN32_WINDOWS:
+ /* Low-level hook is not supported on non-NT */
+ return FALSE;
+ }
+
+ /* Install the hook only once */
+ if (!g_hhookKeyboardLL)
+ g_hhookKeyboardLL = SetWindowsHookEx(WH_KEYBOARD_LL,
+ winKeyboardMessageHookLL,
+ g_hInstance, 0);
+
+ return TRUE;
+}
+
+/*
+ * Remove the keyboard hook if it is installed
+ */
+
+void
+winRemoveKeyboardHookLL(void)
+{
+ if (g_hhookKeyboardLL)
+ UnhookWindowsHookEx(g_hhookKeyboardLL);
+ g_hhookKeyboardLL = NULL;
+}
diff --git a/xorg-server/hw/xwin/winlayouts.h b/xorg-server/hw/xwin/winlayouts.h
index c53f0e054..82da2da63 100644
--- a/xorg-server/hw/xwin/winlayouts.h
+++ b/xorg-server/hw/xwin/winlayouts.h
@@ -1,96 +1,98 @@
-/*
- * Copyright (c) 2005 Alexander Gottwald
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name(s) of the above copyright
- * holders shall not be used in advertising or otherwise to promote the sale,
- * use or other dealings in this Software without prior written authorization.
- */
-/* Definitions for various keyboard layouts from windows and their
- * XKB settings.
- */
-
-typedef struct
-{
- unsigned int winlayout;
- int winkbtype;
- char *xkbmodel;
- char *xkblayout;
- char *xkbvariant;
- char *xkboptions;
- char *layoutname;
-} WinKBLayoutRec, *WinKBLayoutPtr;
-
-/*
- This table is sorted by low byte of winlayout, then by next byte, etc.
-*/
-
-WinKBLayoutRec winKBLayouts[] =
-{
- { 0x00000404, -1, "pc105", "zh_TW", NULL, NULL, "Chinese (Taiwan)"},
- { 0x00000405, -1, "pc105", "cz", NULL, NULL, "Czech"},
- { 0x00010405, -1, "pc105", "cz_qwerty", NULL, NULL, "Czech (QWERTY)"},
- { 0x00000406, -1, "pc105", "dk", NULL, NULL, "Danish"},
- { 0x00000407, -1, "pc105", "de", NULL, NULL, "German (Germany)"},
- { 0x00010407, -1, "pc105", "de", NULL, NULL, "German (Germany,IBM)"},
- { 0x00000807, -1, "pc105", "ch", "de", NULL, "German (Switzerland)"},
- { 0x00000409, -1, "pc105", "us", NULL, NULL, "English (USA)"},
- { 0x00010409, -1, "pc105", "dvorak", NULL, NULL, "English (USA,Dvorak)"},
- { 0x00020409, -1, "pc105", "us_intl", NULL, NULL, "English (USA,International)"},
- { 0x00000809, -1, "pc105", "gb", NULL, NULL, "English (United Kingdom)"},
- { 0x00001009, -1, "pc105", "ca", "fr", NULL, "French (Canada)"},
- { 0x00011009, -1, "pc105", "ca", "multix", NULL, "Canadian Multilingual Standard"},
- { 0x00001809, -1, "pc105", "ie", NULL, NULL, "Irish"},
- { 0x0000040a, -1, "pc105", "es", NULL, NULL, "Spanish (Spain,Traditional Sort)"},
- { 0x0000080a, -1, "pc105", "latam", NULL, NULL, "Latin American"},
- { 0x0000040b, -1, "pc105", "fi", NULL, NULL, "Finnish"},
- { 0x0000040c, -1, "pc105", "fr", NULL, NULL, "French (Standard)"},
- { 0x0000080c, -1, "pc105", "be", NULL, NULL, "French (Belgian)"},
- { 0x0001080c, -1, "pc105", "be", NULL, NULL, "Belgian (Comma)"},
- { 0x00000c0c, -1, "pc105", "ca", "fr-legacy", NULL, "French (Canada, Legacy)"},
- { 0x0000100c, -1, "pc105", "ch", "fr", NULL, "French (Switzerland)"},
- { 0x0000040d, -1, "pc105", "il", NULL, NULL, "Hebrew"},
- { 0x0000040e, -1, "pc105", "hu", NULL, NULL, "Hungarian"},
- { 0x0000040f, -1, "pc105", "is", NULL, NULL, "Icelandic"},
- { 0x00000410, -1, "pc105", "it", NULL, NULL, "Italian"},
- { 0x00010410, -1, "pc105", "it", NULL, NULL, "Italian (142)"},
- { 0xa0000410, -1, "macbook79", "it", "mac", NULL, "Italiano (Apple)"},
- { 0x00000411, 7, "jp106", "jp", NULL, NULL, "Japanese"},
- { 0x00000413, -1, "pc105", "nl", NULL, NULL, "Dutch"},
- { 0x00000813, -1, "pc105", "be", NULL, NULL, "Dutch (Belgian)"},
- { 0x00000414, -1, "pc105", "no", NULL, NULL, "Norwegian"},
- { 0x00000415, -1, "pc105", "pl", NULL, NULL, "Polish (Programmers)"},
- { 0x00000416, -1, "pc105", "br", NULL, NULL, "Portuguese (Brazil,ABNT)"},
- { 0x00010416, -1, "abnt2", "br", NULL, NULL, "Portuguese (Brazil,ABNT2)"},
- { 0x00000816, -1, "pc105", "pt", NULL, NULL, "Portuguese (Portugal)"},
- { 0x0000041a, -1, "pc105", "hr", NULL, NULL, "Croatian"},
- { 0x0000041d, -1, "pc105", "se", NULL, NULL, "Swedish (Sweden)"},
- { 0x0000041f, -1, "pc105", "tr", NULL, NULL, "Turkish (Q)"},
- { 0x0001041f, -1, "pc105", "tr", "f", NULL, "Turkish (F)"},
- { 0x00000424, -1, "pc105", "si", NULL, NULL, "Slovenian"},
- { 0x00000425, -1, "pc105", "ee", NULL, NULL, "Estonian"},
- { 0x00000452, -1, "pc105", "gb", "intl", NULL, "United Kingdom (Extended)"},
- { -1, -1, NULL, NULL, NULL, NULL, NULL}
-};
-
-/*
- See http://technet.microsoft.com/en-us/library/cc766503%28WS.10%29.aspx
- for a listing of input locale (keyboard layout) codes
-*/
+/*
+ * Copyright (c) 2005 Alexander Gottwald
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name(s) of the above copyright
+ * holders shall not be used in advertising or otherwise to promote the sale,
+ * use or other dealings in this Software without prior written authorization.
+ */
+/* Definitions for various keyboard layouts from windows and their
+ * XKB settings.
+ */
+
+typedef struct {
+ unsigned int winlayout;
+ int winkbtype;
+ char *xkbmodel;
+ char *xkblayout;
+ char *xkbvariant;
+ char *xkboptions;
+ char *layoutname;
+} WinKBLayoutRec, *WinKBLayoutPtr;
+
+/*
+ This table is sorted by low byte of winlayout, then by next byte, etc.
+*/
+
+WinKBLayoutRec winKBLayouts[] = {
+ {0x00000404, -1, "pc105", "zh_TW", NULL, NULL, "Chinese (Taiwan)"},
+ {0x00000405, -1, "pc105", "cz", NULL, NULL, "Czech"},
+ {0x00010405, -1, "pc105", "cz_qwerty", NULL, NULL, "Czech (QWERTY)"},
+ {0x00000406, -1, "pc105", "dk", NULL, NULL, "Danish"},
+ {0x00000407, -1, "pc105", "de", NULL, NULL, "German (Germany)"},
+ {0x00010407, -1, "pc105", "de", NULL, NULL, "German (Germany,IBM)"},
+ {0x00000807, -1, "pc105", "ch", "de", NULL, "German (Switzerland)"},
+ {0x00000409, -1, "pc105", "us", NULL, NULL, "English (USA)"},
+ {0x00010409, -1, "pc105", "dvorak", NULL, NULL, "English (USA,Dvorak)"},
+ {0x00020409, -1, "pc105", "us_intl", NULL, NULL,
+ "English (USA,International)"},
+ {0x00000809, -1, "pc105", "gb", NULL, NULL, "English (United Kingdom)"},
+ {0x00001009, -1, "pc105", "ca", "fr", NULL, "French (Canada)"},
+ {0x00011009, -1, "pc105", "ca", "multix", NULL,
+ "Canadian Multilingual Standard"},
+ {0x00001809, -1, "pc105", "ie", NULL, NULL, "Irish"},
+ {0x0000040a, -1, "pc105", "es", NULL, NULL,
+ "Spanish (Spain,Traditional Sort)"},
+ {0x0000080a, -1, "pc105", "latam", NULL, NULL, "Latin American"},
+ {0x0000040b, -1, "pc105", "fi", NULL, NULL, "Finnish"},
+ {0x0000040c, -1, "pc105", "fr", NULL, NULL, "French (Standard)"},
+ {0x0000080c, -1, "pc105", "be", NULL, NULL, "French (Belgian)"},
+ {0x0001080c, -1, "pc105", "be", NULL, NULL, "Belgian (Comma)"},
+ {0x00000c0c, -1, "pc105", "ca", "fr-legacy", NULL,
+ "French (Canada, Legacy)"},
+ {0x0000100c, -1, "pc105", "ch", "fr", NULL, "French (Switzerland)"},
+ {0x0000040d, -1, "pc105", "il", NULL, NULL, "Hebrew"},
+ {0x0000040e, -1, "pc105", "hu", NULL, NULL, "Hungarian"},
+ {0x0000040f, -1, "pc105", "is", NULL, NULL, "Icelandic"},
+ {0x00000410, -1, "pc105", "it", NULL, NULL, "Italian"},
+ {0x00010410, -1, "pc105", "it", NULL, NULL, "Italian (142)"},
+ {0xa0000410, -1, "macbook79", "it", "mac", NULL, "Italiano (Apple)"},
+ {0x00000411, 7, "jp106", "jp", NULL, NULL, "Japanese"},
+ {0x00000413, -1, "pc105", "nl", NULL, NULL, "Dutch"},
+ {0x00000813, -1, "pc105", "be", NULL, NULL, "Dutch (Belgian)"},
+ {0x00000414, -1, "pc105", "no", NULL, NULL, "Norwegian"},
+ {0x00000415, -1, "pc105", "pl", NULL, NULL, "Polish (Programmers)"},
+ {0x00000416, -1, "pc105", "br", NULL, NULL, "Portuguese (Brazil,ABNT)"},
+ {0x00010416, -1, "abnt2", "br", NULL, NULL, "Portuguese (Brazil,ABNT2)"},
+ {0x00000816, -1, "pc105", "pt", NULL, NULL, "Portuguese (Portugal)"},
+ {0x0000041a, -1, "pc105", "hr", NULL, NULL, "Croatian"},
+ {0x0000041d, -1, "pc105", "se", NULL, NULL, "Swedish (Sweden)"},
+ {0x0000041f, -1, "pc105", "tr", NULL, NULL, "Turkish (Q)"},
+ {0x0001041f, -1, "pc105", "tr", "f", NULL, "Turkish (F)"},
+ {0x00000424, -1, "pc105", "si", NULL, NULL, "Slovenian"},
+ {0x00000425, -1, "pc105", "ee", NULL, NULL, "Estonian"},
+ {0x00000452, -1, "pc105", "gb", "intl", NULL, "United Kingdom (Extended)"},
+ {-1, -1, NULL, NULL, NULL, NULL, NULL}
+};
+
+/*
+ See http://technet.microsoft.com/en-us/library/cc766503%28WS.10%29.aspx
+ for a listing of input locale (keyboard layout) codes
+*/
diff --git a/xorg-server/hw/xwin/winmisc.c b/xorg-server/hw/xwin/winmisc.c
index a5a2d3d1c..f810ed073 100644
--- a/xorg-server/hw/xwin/winmisc.c
+++ b/xorg-server/hw/xwin/winmisc.c
@@ -41,112 +41,103 @@
*/
void
-winQueryBestSizeNativeGDI (int class, unsigned short *pWidth,
- unsigned short *pHeight, ScreenPtr pScreen)
+winQueryBestSizeNativeGDI(int class, unsigned short *pWidth,
+ unsigned short *pHeight, ScreenPtr pScreen)
{
winDebug ("winQueryBestSizeNativeGDI\n");
}
#endif
-
/*
* Count the number of one bits in a color mask.
*/
CARD8
-winCountBits (DWORD dw)
+winCountBits(DWORD dw)
{
- DWORD dwBits = 0;
+ DWORD dwBits = 0;
- while (dw)
- {
- dwBits += (dw & 1);
- dw >>= 1;
+ while (dw) {
+ dwBits += (dw & 1);
+ dw >>= 1;
}
- return dwBits;
+ return dwBits;
}
-
/*
* Modify the screen pixmap to point to the new framebuffer address
*/
Bool
-winUpdateFBPointer (ScreenPtr pScreen, void *pbits)
+winUpdateFBPointer(ScreenPtr pScreen, void *pbits)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-
- /* Location of shadow framebuffer has changed */
- pScreenInfo->pfb = pbits;
-
- /* Update the screen pixmap */
- if (!(*pScreen->ModifyPixmapHeader) (pScreen->devPrivate,
- pScreen->width,
- pScreen->height,
- pScreen->rootDepth,
- BitsPerPixel (pScreen->rootDepth),
- PixmapBytePad (pScreenInfo->dwStride,
- pScreenInfo->dwBPP),
- pScreenInfo->pfb))
- {
- FatalError ("winUpdateFramebufferPointer - Failed modifying "\
- "screen pixmap\n");
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /* Location of shadow framebuffer has changed */
+ pScreenInfo->pfb = pbits;
+
+ /* Update the screen pixmap */
+ if (!(*pScreen->ModifyPixmapHeader) (pScreen->devPrivate,
+ pScreen->width,
+ pScreen->height,
+ pScreen->rootDepth,
+ BitsPerPixel(pScreen->rootDepth),
+ PixmapBytePad(pScreenInfo->dwStride,
+ pScreenInfo->dwBPP),
+ pScreenInfo->pfb)) {
+ FatalError("winUpdateFramebufferPointer - Failed modifying "
+ "screen pixmap\n");
}
- return TRUE;
+ return TRUE;
}
-
#ifdef XWIN_NATIVEGDI
/*
* Paint the window background with the specified color
*/
BOOL
-winPaintBackground (HWND hwnd, COLORREF colorref)
+winPaintBackground(HWND hwnd, COLORREF colorref)
{
- HDC hdc;
- HBRUSH hbrush;
- RECT rect;
-
- /* Create an hdc */
- hdc = GetDC (hwnd);
- if (hdc == NULL)
- {
- printf ("gdiWindowProc - GetDC failed\n");
- exit (1);
+ HDC hdc;
+ HBRUSH hbrush;
+ RECT rect;
+
+ /* Create an hdc */
+ hdc = GetDC(hwnd);
+ if (hdc == NULL) {
+ printf("gdiWindowProc - GetDC failed\n");
+ exit(1);
}
- /* Create and select blue brush */
- hbrush = CreateSolidBrush (colorref);
- if (hbrush == NULL)
- {
- printf ("gdiWindowProc - CreateSolidBrush failed\n");
- exit (1);
+ /* Create and select blue brush */
+ hbrush = CreateSolidBrush(colorref);
+ if (hbrush == NULL) {
+ printf("gdiWindowProc - CreateSolidBrush failed\n");
+ exit(1);
}
- /* Get window extents */
- if (GetClientRect (hwnd, &rect) == FALSE)
- {
- printf ("gdiWindowProc - GetClientRect failed\n");
- exit (1);
+ /* Get window extents */
+ if (GetClientRect(hwnd, &rect) == FALSE) {
+ printf("gdiWindowProc - GetClientRect failed\n");
+ exit(1);
}
- /* Fill window with blue brush */
- if (FillRect (hdc, &rect, hbrush) == 0)
- {
- printf ("gdiWindowProc - FillRect failed\n");
- exit (1);
+ /* Fill window with blue brush */
+ if (FillRect(hdc, &rect, hbrush) == 0) {
+ printf("gdiWindowProc - FillRect failed\n");
+ exit(1);
}
- /* Delete blue brush */
- DeleteObject (hbrush);
+ /* Delete blue brush */
+ DeleteObject(hbrush);
- /* Release the hdc */
- ReleaseDC (hwnd, hdc);
+ /* Release the hdc */
+ ReleaseDC(hwnd, hdc);
- return TRUE;
+ return TRUE;
}
#endif
diff --git a/xorg-server/hw/xwin/winmonitors.c b/xorg-server/hw/xwin/winmonitors.c
index a253afc61..31c7aeab0 100644
--- a/xorg-server/hw/xwin/winmonitors.c
+++ b/xorg-server/hw/xwin/winmonitors.c
@@ -30,7 +30,6 @@ from The Open Group.
#ifdef HAVE_XWIN_CONFIG_H
#include <xwin-config.h>
#endif
-
#include "win.h"
#define COMPILE_MULTIMON_STUBS
#include <multimon.h>
@@ -41,25 +40,27 @@ from The Open Group.
*/
static
-wBOOL CALLBACK getMonitorInfo(HMONITOR hMonitor, HDC hdc, LPRECT rect, LPARAM _data)
+ wBOOL CALLBACK
+getMonitorInfo(HMONITOR hMonitor, HDC hdc, LPRECT rect, LPARAM _data)
{
- struct GetMonitorInfoData* data = (struct GetMonitorInfoData*)_data;
- // only get data for monitor number specified in <data>
- data->monitorNum++;
- if (data->monitorNum == data->requestedMonitor)
- {
- data->bMonitorSpecifiedExists = TRUE;
- data->monitorOffsetX = rect->left;
- data->monitorOffsetY = rect->top;
- data->monitorHeight = rect->bottom - rect->top;
- data->monitorWidth = rect->right - rect->left;
+ struct GetMonitorInfoData *data = (struct GetMonitorInfoData *) _data;
+
+ // only get data for monitor number specified in <data>
+ data->monitorNum++;
+ if (data->monitorNum == data->requestedMonitor) {
+ data->bMonitorSpecifiedExists = TRUE;
+ data->monitorOffsetX = rect->left;
+ data->monitorOffsetY = rect->top;
+ data->monitorHeight = rect->bottom - rect->top;
+ data->monitorWidth = rect->right - rect->left;
data->monitorHandle = hMonitor;
- return FALSE;
- }
- return TRUE;
+ return FALSE;
+ }
+ return TRUE;
}
-Bool QueryMonitor(int index, struct GetMonitorInfoData *data)
+Bool
+QueryMonitor(int index, struct GetMonitorInfoData *data)
{
/* prepare data */
if (data == NULL)
diff --git a/xorg-server/hw/xwin/winmouse.c b/xorg-server/hw/xwin/winmouse.c
index e7cb1ccb7..63081d62c 100644
--- a/xorg-server/hw/xwin/winmouse.c
+++ b/xorg-server/hw/xwin/winmouse.c
@@ -44,7 +44,7 @@
#endif
#include "inputstr.h"
-#include "exevents.h" /* for button/axes labels */
+#include "exevents.h" /* for button/axes labels */
#include "xserver-properties.h"
#include "inpututils.h"
@@ -57,308 +57,283 @@ static CARD8 const *g_winMouseButtonMap = NULL;
*/
int
-winMouseProc (DeviceIntPtr pDeviceInt, int iState)
+winMouseProc(DeviceIntPtr pDeviceInt, int iState)
{
- int lngMouseButtons, i;
- int lngWheelEvents = 4;
- CARD8 *map;
- DevicePtr pDevice = (DevicePtr) pDeviceInt;
- Atom *btn_labels;
- Atom axes_labels[2];
-
- switch (iState)
- {
+ int lngMouseButtons, i;
+ int lngWheelEvents = 4;
+ CARD8 *map;
+ DevicePtr pDevice = (DevicePtr) pDeviceInt;
+ Atom *btn_labels;
+ Atom axes_labels[2];
+
+ switch (iState) {
case DEVICE_INIT:
- /* Get number of mouse buttons */
- lngMouseButtons = GetSystemMetrics(SM_CMOUSEBUTTONS);
- winDebug("%d mouse buttons found\n", lngMouseButtons);
-
- /* Mapping of windows events to X events:
- * LEFT:1 MIDDLE:2 RIGHT:3
- * SCROLL_UP:4 SCROLL_DOWN:5
- * XBUTTON 1:6 XBUTTON 2:7 ...
- *
- * To map scroll wheel correctly we need at least the 3 normal buttons
- */
- if (lngMouseButtons < 3)
- lngMouseButtons = 3;
-
- /* allocate memory:
- * number of buttons + 2x mouse wheel event + 1 extra (offset for map)
- */
- map = malloc(sizeof(CARD8) * (lngMouseButtons + lngWheelEvents + 1));
-
- /* initalize button map */
- map[0] = 0;
- for (i=1; i <= lngMouseButtons + lngWheelEvents; i++)
- map[i] = i;
-
- btn_labels = calloc((lngMouseButtons + lngWheelEvents), sizeof(Atom));
- btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
- btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
- btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
- btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
- btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN);
+ /* Get number of mouse buttons */
+ lngMouseButtons = GetSystemMetrics(SM_CMOUSEBUTTONS);
+ winDebug("%d mouse buttons found\n", lngMouseButtons);
+
+ /* Mapping of windows events to X events:
+ * LEFT:1 MIDDLE:2 RIGHT:3
+ * SCROLL_UP:4 SCROLL_DOWN:5
+ * XBUTTON 1:6 XBUTTON 2:7 ...
+ *
+ * To map scroll wheel correctly we need at least the 3 normal buttons
+ */
+ if (lngMouseButtons < 3)
+ lngMouseButtons = 3;
+
+ /* allocate memory:
+ * number of buttons + 2x mouse wheel event + 1 extra (offset for map)
+ */
+ map = malloc(sizeof(CARD8) * (lngMouseButtons + lngWheelEvents + 1));
+
+ /* initalize button map */
+ map[0] = 0;
+ for (i = 1; i <= lngMouseButtons + lngWheelEvents; i++)
+ map[i] = i;
+
+ btn_labels = calloc((lngMouseButtons + lngWheelEvents), sizeof(Atom));
+ btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
+ btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
+ btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
+ btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
+ btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN);
btn_labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT);
btn_labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT);
- axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
- axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
+ axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
+ axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
- InitPointerDeviceStruct (pDevice,
- map,
- lngMouseButtons + lngWheelEvents,
- btn_labels,
- (PtrCtrlProcPtr)NoopDDA,
- GetMotionHistorySize(),
- 2,
- axes_labels);
- free(map);
- free(btn_labels);
+ InitPointerDeviceStruct(pDevice,
+ map,
+ lngMouseButtons + lngWheelEvents,
+ btn_labels,
+ (PtrCtrlProcPtr)NoopDDA,
+ GetMotionHistorySize(), 2, axes_labels);
+ free(map);
+ free(btn_labels);
- g_winMouseButtonMap = pDeviceInt->button->map;
- break;
+ g_winMouseButtonMap = pDeviceInt->button->map;
+ break;
case DEVICE_ON:
- pDevice->on = TRUE;
- break;
+ pDevice->on = TRUE;
+ break;
case DEVICE_CLOSE:
- g_winMouseButtonMap = NULL;
+ g_winMouseButtonMap = NULL;
case DEVICE_OFF:
- pDevice->on = FALSE;
- break;
+ pDevice->on = FALSE;
+ break;
}
- return Success;
+ return Success;
}
-
/* Handle the mouse wheel */
int
-winMouseWheel (ScreenPtr pScreen, int iDeltaZ)
+winMouseWheel(ScreenPtr pScreen, int iDeltaZ)
{
- winScreenPriv(pScreen);
- int button; /* Button4 or Button5 */
-
- /* Button4 = WheelUp */
- /* Button5 = WheelDown */
-
- /* Do we have any previous delta stored? */
- if ((pScreenPriv->iDeltaZ > 0
- && iDeltaZ > 0)
- || (pScreenPriv->iDeltaZ < 0
- && iDeltaZ < 0))
- {
- /* Previous delta and of same sign as current delta */
- iDeltaZ += pScreenPriv->iDeltaZ;
- pScreenPriv->iDeltaZ = 0;
+ winScreenPriv(pScreen);
+ int button; /* Button4 or Button5 */
+
+ /* Button4 = WheelUp */
+ /* Button5 = WheelDown */
+
+ /* Do we have any previous delta stored? */
+ if ((pScreenPriv->iDeltaZ > 0 && iDeltaZ > 0)
+ || (pScreenPriv->iDeltaZ < 0 && iDeltaZ < 0)) {
+ /* Previous delta and of same sign as current delta */
+ iDeltaZ += pScreenPriv->iDeltaZ;
+ pScreenPriv->iDeltaZ = 0;
}
- else
- {
- /*
- * Previous delta of different sign, or zero.
- * We will set it to zero for either case,
- * as blindly setting takes just as much time
- * as checking, then setting if necessary :)
- */
- pScreenPriv->iDeltaZ = 0;
+ 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;
+ /*
+ * 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;
+ else {
+ /*
+ * Wheel has not moved past WHEEL_DELTA threshold;
+ * we will store the wheel delta until the threshold
+ * has been reached.
+ */
+ pScreenPriv->iDeltaZ = iDeltaZ;
+ return 0;
}
- /* Set the button to indicate up or down wheel delta */
- if (iDeltaZ > 0)
- {
- button = Button4;
+ /* Set the button to indicate up or down wheel delta */
+ if (iDeltaZ > 0) {
+ button = Button4;
}
- else
- {
- button = Button5;
+ else {
+ button = Button5;
}
- /*
- * Flip iDeltaZ to positive, if negative,
- * because always need to generate a *positive* number of
- * button clicks for the Z axis.
- */
- if (iDeltaZ < 0)
- {
- iDeltaZ *= -1;
+ /*
+ * Flip iDeltaZ to positive, if negative,
+ * because always need to generate a *positive* number of
+ * button clicks for the Z axis.
+ */
+ if (iDeltaZ < 0) {
+ iDeltaZ *= -1;
}
- /* Generate X input messages for each wheel delta we have seen */
- while (iDeltaZ--)
- {
- /* Push the wheel button */
- winMouseButtonsSendEvent (ButtonPress, button);
+ /* Generate X input messages for each wheel delta we have seen */
+ while (iDeltaZ--) {
+ /* Push the wheel button */
+ winMouseButtonsSendEvent(ButtonPress, button);
- /* Release the wheel button */
- winMouseButtonsSendEvent (ButtonRelease, button);
+ /* Release the wheel button */
+ winMouseButtonsSendEvent(ButtonRelease, button);
}
- return 0;
+ return 0;
}
-
/*
* Enqueue a mouse button event
*/
void
-winMouseButtonsSendEvent (int iEventType, int iButton)
+winMouseButtonsSendEvent(int iEventType, int iButton)
{
- ValuatorMask mask;
+ ValuatorMask mask;
- if (g_winMouseButtonMap)
- iButton = g_winMouseButtonMap[iButton];
+ if (g_winMouseButtonMap)
+ iButton = g_winMouseButtonMap[iButton];
- valuator_mask_zero(&mask);
- QueuePointerEvents(g_pwinPointer, iEventType, iButton,
- POINTER_RELATIVE, &mask);
+ valuator_mask_zero(&mask);
+ QueuePointerEvents(g_pwinPointer, iEventType, iButton,
+ POINTER_RELATIVE, &mask);
winDebug("winMouseButtonsSendEvent: iEventType: %d, iButton: %d\n",
- iEventType, iButton);
+ iEventType, iButton);
}
-
/*
* Decide what to do with a Windows mouse message
*/
int
-winMouseButtonsHandle (ScreenPtr pScreen,
- int iEventType, int iButton,
- WPARAM wParam)
+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;
+ 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);
+ /* 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 == 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->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->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);
+ 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;
+ return 0;
}
/**
* Enqueue a motion event.
*
*/
-void winEnqueueMotion(int x, int y)
+void
+winEnqueueMotion(int x, int y)
{
- int valuators[2];
- ValuatorMask mask;
+ int valuators[2];
+ ValuatorMask mask;
- valuators[0] = x;
- valuators[1] = y;
+ valuators[0] = x;
+ valuators[1] = y;
- valuator_mask_set_range(&mask, 0, 2, valuators);
- QueuePointerEvents(g_pwinPointer, MotionNotify, 0,
- POINTER_ABSOLUTE | POINTER_SCREEN, &mask);
+ valuator_mask_set_range(&mask, 0, 2, valuators);
+ QueuePointerEvents(g_pwinPointer, MotionNotify, 0,
+ POINTER_ABSOLUTE | POINTER_SCREEN, &mask);
}
diff --git a/xorg-server/hw/xwin/winmsg.c b/xorg-server/hw/xwin/winmsg.c
index e3d68915f..3b08d4fde 100644
--- a/xorg-server/hw/xwin/winmsg.c
+++ b/xorg-server/hw/xwin/winmsg.c
@@ -39,22 +39,29 @@
#include <stdarg.h>
#ifdef WINDBG
+
+
+
+
+
void
-winDebug (const char *format, ...)
+winDebug(const char *format, ...)
{
- va_list ap;
- va_start (ap, format);
- LogVMessageVerb(X_NONE, 3, format, ap);
- va_end (ap);
+ va_list ap;
+
+ va_start(ap, format);
+ LogVMessageVerb(X_NONE, 3, format, ap);
+ va_end(ap);
}
void
winDebug4 (const char *format, ...)
{
- va_list ap;
- va_start (ap, format);
+ va_list ap;
+
+ va_start(ap, format);
LogVMessageVerb(X_NONE, 4, format, ap);
- va_end (ap);
+ va_end(ap);
}
#endif
@@ -68,51 +75,50 @@ void
winW32ErrorEx(const char *msg, DWORD errorcode)
{
LPVOID buffer;
- if (!FormatMessage(
- FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
- errorcode,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPTSTR) &buffer,
- 0,
- NULL ))
- {
+
+ if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ errorcode,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPTSTR) & buffer, 0, NULL)) {
ErrorF(msg);
ErrorF("Unknown error in FormatMessage!\n");
}
- else
- {
+ else {
ErrorF("%s %s", msg, (char *)buffer);
LocalFree(buffer);
}
}
#ifdef WINDBG
-void winDebugWin32Message(const char* function, HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
+void
+winDebugWin32Message(const char *function, HWND hwnd, UINT message,
+ WPARAM wParam, LPARAM lParam)
{
- static int force = 0;
-
- if (message >= WM_USER)
- {
- if (force || getenv("WIN_DEBUG_MESSAGES") || getenv("WIN_DEBUG_WM_USER"))
- {
- winDebug("%s - Message WM_USER + %d\n", function, message - WM_USER);
- winDebug("\thwnd 0x%x wParam 0x%x lParam 0x%x\n", hwnd, wParam, lParam);
- }
+ static int force = 0;
+
+ if (message >= WM_USER) {
+ if (force || getenv("WIN_DEBUG_MESSAGES") ||
+ getenv("WIN_DEBUG_WM_USER")) {
+ winDebug("%s - Message WM_USER + %d\n", function,
+ message - WM_USER);
+ winDebug("\thwnd 0x%x wParam 0x%x lParam 0x%x\n", hwnd, wParam,
+ lParam);
+ }
}
- else if (message < MESSAGE_NAMES_LEN && MESSAGE_NAMES[message])
- {
- const char *msgname = MESSAGE_NAMES[message];
- char buffer[64];
- snprintf(buffer, sizeof(buffer), "WIN_DEBUG_%s", msgname);
- buffer[63] = 0;
- if (force || getenv("WIN_DEBUG_MESSAGES") || getenv(buffer))
- {
- winDebug("%s - Message %s\n", function, MESSAGE_NAMES[message]);
- winDebug("\thwnd 0x%x wParam 0x%x lParam 0x%x\n", hwnd, wParam, lParam);
- }
+ else if (message < MESSAGE_NAMES_LEN && MESSAGE_NAMES[message]) {
+ const char *msgname = MESSAGE_NAMES[message];
+ char buffer[64];
+
+ snprintf(buffer, sizeof(buffer), "WIN_DEBUG_%s", msgname);
+ buffer[63] = 0;
+ if (force || getenv("WIN_DEBUG_MESSAGES") || getenv(buffer)) {
+ winDebug("%s - Message %s\n", function, MESSAGE_NAMES[message]);
+ winDebug("\thwnd 0x%x wParam 0x%x lParam 0x%x\n", hwnd, wParam,
+ lParam);
+ }
}
}
#endif
diff --git a/xorg-server/hw/xwin/winmultiwindowclass.c b/xorg-server/hw/xwin/winmultiwindowclass.c
index ca08ae483..cc7628d5c 100644
--- a/xorg-server/hw/xwin/winmultiwindowclass.c
+++ b/xorg-server/hw/xwin/winmultiwindowclass.c
@@ -43,287 +43,255 @@
DEFINE_ATOM_HELPER(AtmWmWindowRole, "WM_WINDOW_ROLE")
-
int
-winMultiWindowGetClassHint (WindowPtr pWin, char **res_name, char **res_class)
+winMultiWindowGetClassHint(WindowPtr pWin, char **res_name, char **res_class)
{
- struct _Window *pwin;
- struct _Property *prop;
- int len_name, len_class;
-
- if (!pWin || !res_name || !res_class)
- {
- ErrorF ("winMultiWindowGetClassHint - pWin, res_name, or res_class was "
- "NULL\n");
- return 0;
+ struct _Window *pwin;
+ struct _Property *prop;
+ int len_name, len_class;
+
+ if (!pWin || !res_name || !res_class) {
+ ErrorF("winMultiWindowGetClassHint - pWin, res_name, or res_class was "
+ "NULL\n");
+ return 0;
}
-
- pwin = (struct _Window*) pWin;
-
- if (pwin->optional)
- prop = (struct _Property *) pwin->optional->userProps;
- else
- prop = NULL;
-
- *res_name = *res_class = NULL;
-
- while (prop)
- {
- if (prop->propertyName == XA_WM_CLASS
- && prop->type == XA_STRING
- && prop->format == 8
- && prop->data)
- {
- len_name = strlen ((char *) prop->data);
-
- (*res_name) = malloc (len_name + 1);
-
- if (!*res_name)
- {
- ErrorF ("winMultiWindowGetClassHint - *res_name was NULL\n");
- return 0;
- }
-
- /* Add one to len_name to allow copying of trailing 0 */
- strncpy ((*res_name), prop->data, len_name + 1);
-
- if (len_name == prop->size)
- len_name--;
-
- len_class = strlen (((char *)prop->data) + 1 + len_name);
-
- (*res_class) = malloc (len_class + 1);
-
- if (!*res_class)
- {
- ErrorF ("winMultiWindowGetClassHint - *res_class was NULL\n");
-
- /* Free the previously allocated res_name */
- free (*res_name);
- return 0;
- }
-
- strcpy ((*res_class), ((char *)prop->data) + 1 + len_name);
-
- return 1;
- }
- else
- prop = prop->next;
+
+ pwin = (struct _Window *) pWin;
+
+ if (pwin->optional)
+ prop = (struct _Property *) pwin->optional->userProps;
+ else
+ prop = NULL;
+
+ *res_name = *res_class = NULL;
+
+ while (prop) {
+ if (prop->propertyName == XA_WM_CLASS
+ && prop->type == XA_STRING && prop->format == 8 && prop->data) {
+ len_name = strlen((char *) prop->data);
+
+ (*res_name) = malloc(len_name + 1);
+
+ if (!*res_name) {
+ ErrorF("winMultiWindowGetClassHint - *res_name was NULL\n");
+ return 0;
+ }
+
+ /* Add one to len_name to allow copying of trailing 0 */
+ strncpy((*res_name), prop->data, len_name + 1);
+
+ if (len_name == prop->size)
+ len_name--;
+
+ len_class = strlen(((char *) prop->data) + 1 + len_name);
+
+ (*res_class) = malloc(len_class + 1);
+
+ if (!*res_class) {
+ ErrorF("winMultiWindowGetClassHint - *res_class was NULL\n");
+
+ /* Free the previously allocated res_name */
+ free(*res_name);
+ return 0;
+ }
+
+ strcpy((*res_class), ((char *) prop->data) + 1 + len_name);
+
+ return 1;
+ }
+ else
+ prop = prop->next;
}
-
- return 0;
-}
+ return 0;
+}
int
-winMultiWindowGetWMHints (WindowPtr pWin, WinXWMHints *hints)
+winMultiWindowGetWMHints(WindowPtr pWin, WinXWMHints * hints)
{
- struct _Window *pwin;
- struct _Property *prop;
+ struct _Window *pwin;
+ struct _Property *prop;
- if (!pWin || !hints)
- {
- ErrorF ("winMultiWindowGetWMHints - pWin or hints was NULL\n");
- return 0;
+ if (!pWin || !hints) {
+ ErrorF("winMultiWindowGetWMHints - pWin or hints was NULL\n");
+ return 0;
}
- pwin = (struct _Window*) pWin;
-
- if (pwin->optional)
- prop = (struct _Property *) pwin->optional->userProps;
- else
- prop = NULL;
-
- memset (hints, 0, sizeof (WinXWMHints));
-
- while (prop)
- {
- if (prop->propertyName == XA_WM_HINTS
- && prop->format == 32
- && prop->data)
- {
- memcpy (hints, prop->data, 4*(int)prop->size); /* format/8 = 4 */
- return 1;
- }
- else
- prop = prop->next;
+ pwin = (struct _Window *) pWin;
+
+ if (pwin->optional)
+ prop = (struct _Property *) pwin->optional->userProps;
+ else
+ prop = NULL;
+
+ memset(hints, 0, sizeof(WinXWMHints));
+
+ while (prop) {
+ if (prop->propertyName == XA_WM_HINTS && prop->data
+ && prop->format == 32) {
+ memcpy (hints, prop->data, 4*(int)prop->size); /* format/8 = 4 */
+ return 1;
+ }
+ else
+ prop = prop->next;
}
-
- return 0;
-}
+ return 0;
+}
int
-winMultiWindowGetWindowRole (WindowPtr pWin, char **res_role)
+winMultiWindowGetWindowRole(WindowPtr pWin, char **res_role)
{
- struct _Window *pwin;
- struct _Property *prop;
- int len_role;
-
- if (!pWin || !res_role)
- return 0;
-
- pwin = (struct _Window*) pWin;
-
- if (pwin->optional)
- prop = (struct _Property *) pwin->optional->userProps;
- else
- prop = NULL;
-
- *res_role = NULL;
- while (prop)
- {
- if (prop->propertyName == AtmWmWindowRole ()
- && prop->type == XA_STRING
- && prop->format == 8
- && prop->data)
- {
- len_role= prop->size;
-
- (*res_role) = malloc (len_role + 1);
-
- if (!*res_role)
- {
- ErrorF ("winMultiWindowGetWindowRole - *res_role was NULL\n");
- return 0;
- }
-
- strncpy ((*res_role), prop->data, len_role);
- (*res_role)[len_role] = 0;
-
- return 1;
- }
- else
- prop = prop->next;
+ struct _Window *pwin;
+ struct _Property *prop;
+ int len_role;
+
+ if (!pWin || !res_role)
+ return 0;
+
+ pwin = (struct _Window *) pWin;
+
+ if (pwin->optional)
+ prop = (struct _Property *) pwin->optional->userProps;
+ else
+ prop = NULL;
+
+ *res_role = NULL;
+ while (prop) {
+ if (prop->propertyName == AtmWmWindowRole()
+ && prop->type == XA_STRING && prop->format == 8 && prop->data) {
+ len_role = prop->size;
+
+ (*res_role) = malloc(len_role + 1);
+
+ if (!*res_role) {
+ ErrorF("winMultiWindowGetWindowRole - *res_role was NULL\n");
+ return 0;
+ }
+
+ strncpy((*res_role), prop->data, len_role);
+ (*res_role)[len_role] = 0;
+
+ return 1;
+ }
+ else
+ prop = prop->next;
}
-
- return 0;
-}
+ return 0;
+}
int
-winMultiWindowGetWMNormalHints (WindowPtr pWin, WinXSizeHints *hints)
+winMultiWindowGetWMNormalHints(WindowPtr pWin, WinXSizeHints * hints)
{
- struct _Window *pwin;
- struct _Property *prop;
+ struct _Window *pwin;
+ struct _Property *prop;
- if (!pWin || !hints)
- {
- ErrorF ("winMultiWindowGetWMNormalHints - pWin or hints was NULL\n");
- return 0;
+ if (!pWin || !hints) {
+ ErrorF("winMultiWindowGetWMNormalHints - pWin or hints was NULL\n");
+ return 0;
}
- pwin = (struct _Window*) pWin;
-
- if (pwin->optional)
- prop = (struct _Property *) pwin->optional->userProps;
- else
- prop = NULL;
-
- memset (hints, 0, sizeof (WinXSizeHints));
-
- while (prop)
- {
- if (prop->propertyName == XA_WM_NORMAL_HINTS
- && prop->format == 32
- && prop->data)
- {
- memcpy (hints, prop->data, 4*(int)prop->size); /* format/8 = 4 */
- return 1;
- }
- else
- prop = prop->next;
+ pwin = (struct _Window *) pWin;
+
+ if (pwin->optional)
+ prop = (struct _Property *) pwin->optional->userProps;
+ else
+ prop = NULL;
+
+ memset(hints, 0, sizeof(WinXSizeHints));
+
+ while (prop) {
+ if (prop->propertyName == XA_WM_NORMAL_HINTS && prop->data
+ && prop->format == 32) {
+ memcpy (hints, prop->data, 4*(int)prop->size); /* format/8 = 4 */
+ return 1;
+ }
+ else
+ prop = prop->next;
}
- return 0;
+ return 0;
}
int
-winMultiWindowGetTransientFor (WindowPtr pWin, WindowPtr *ppDaddy)
+winMultiWindowGetTransientFor(WindowPtr pWin, WindowPtr *ppDaddy)
{
- struct _Window *pwin;
- struct _Property *prop;
+ struct _Window *pwin;
+ struct _Property *prop;
- if (!pWin)
- {
- ErrorF ("winMultiWindowGetTransientFor - pWin was NULL\n");
- return 0;
+ if (!pWin) {
+ ErrorF("winMultiWindowGetTransientFor - pWin was NULL\n");
+ return 0;
}
- pwin = (struct _Window*) pWin;
-
- if (pwin->optional)
- prop = (struct _Property *) pwin->optional->userProps;
- else
- prop = NULL;
-
- if (ppDaddy)
- *ppDaddy = NULL;
-
- while (prop)
- {
- if (prop->propertyName == XA_WM_TRANSIENT_FOR
- && prop->format == 32
- && prop->data)
- {
- if (ppDaddy)
- memcpy (ppDaddy, prop->data, 4*(int)prop->size); /* format/8 = 4 */
- return 1;
+ pwin = (struct _Window *) pWin;
+
+ if (pwin->optional)
+ prop = (struct _Property *) pwin->optional->userProps;
+ else
+ prop = NULL;
+
+ if (ppDaddy)
+ *ppDaddy = NULL;
+
+ while (prop) {
+ if (prop->propertyName == XA_WM_TRANSIENT_FOR
+ && prop->format == 32
+ && prop->data) {
+ if (ppDaddy)
+ memcpy (ppDaddy, prop->data, 4*(int)prop->size); /* format/8 = 4 */
+ return 1;
}
- else
- prop = prop->next;
+ else
+ prop = prop->next;
}
- return 0;
+ return 0;
}
int
-winMultiWindowGetWMName (WindowPtr pWin, char **wmName)
+winMultiWindowGetWMName(WindowPtr pWin, char **wmName)
{
- struct _Window *pwin;
- struct _Property *prop;
- int len_name;
-
- if (!pWin || !wmName)
- {
- ErrorF ("winMultiWindowGetClassHint - pWin, res_name, or res_class was "
- "NULL\n");
- return 0;
+ struct _Window *pwin;
+ struct _Property *prop;
+ int len_name;
+
+ if (!pWin || !wmName) {
+ ErrorF("winMultiWindowGetClassHint - pWin, res_name, or res_class was "
+ "NULL\n");
+ return 0;
}
-
- pwin = (struct _Window*) pWin;
-
- if (pwin->optional)
- prop = (struct _Property *) pwin->optional->userProps;
- else
- prop = NULL;
-
- *wmName = NULL;
-
- while (prop)
- {
- if (prop->propertyName == XA_WM_NAME
- && prop->type == XA_STRING
- && prop->data)
- {
- len_name = prop->size;
-
- (*wmName) = malloc (len_name + 1);
-
- if (!*wmName)
- {
- ErrorF ("winMultiWindowGetWMName - *wmName was NULL\n");
- return 0;
- }
-
- strncpy ((*wmName), prop->data, len_name);
- (*wmName)[len_name] = 0;
-
- return 1;
- }
- else
- prop = prop->next;
+
+ pwin = (struct _Window *) pWin;
+
+ if (pwin->optional)
+ prop = (struct _Property *) pwin->optional->userProps;
+ else
+ prop = NULL;
+
+ *wmName = NULL;
+
+ while (prop) {
+ if (prop->propertyName == XA_WM_NAME
+ && prop->type == XA_STRING && prop->data) {
+ len_name = prop->size;
+
+ (*wmName) = malloc(len_name + 1);
+
+ if (!*wmName) {
+ ErrorF("winMultiWindowGetWMName - *wmName was NULL\n");
+ return 0;
+ }
+
+ strncpy((*wmName), prop->data, len_name);
+ (*wmName)[len_name] = 0;
+
+ return 1;
+ }
+ else
+ prop = prop->next;
}
-
- return 0;
+
+ return 0;
}
diff --git a/xorg-server/hw/xwin/winmultiwindowicons.c b/xorg-server/hw/xwin/winmultiwindowicons.c
index d534cf0b7..42bdb5f9c 100644
--- a/xorg-server/hw/xwin/winmultiwindowicons.c
+++ b/xorg-server/hw/xwin/winmultiwindowicons.c
@@ -39,235 +39,221 @@
#include "propertyst.h"
#include "windowstr.h"
-
/*
* Prototypes for local functions
*/
static void
-winScaleXBitmapToWindows (int iconSize, int effBPP,
- PixmapPtr pixmap, unsigned char *image);
+winScaleXBitmapToWindows(int iconSize, int effBPP,
+ PixmapPtr pixmap, unsigned char *image);
/*
* Scale an X icon bitmap into a Windoze icon bitmap
*/
static void
-winScaleXBitmapToWindows (int iconSize,
- int effBPP,
- PixmapPtr pixmap,
- unsigned char *image)
+winScaleXBitmapToWindows(int iconSize,
+ int effBPP, PixmapPtr pixmap, unsigned char *image)
{
- int row, column, effXBPP, effXDepth;
- unsigned char *outPtr;
- char *iconData = 0;
- int stride, xStride;
- float factX, factY;
- int posX, posY;
- unsigned char *ptr;
- unsigned int zero;
- unsigned int color;
-
- effXBPP = BitsPerPixel(pixmap->drawable.depth);
- effXDepth = pixmap->drawable.depth;
-
- if (pixmap->drawable.bitsPerPixel == 15)
- effXBPP = 16;
-
- if (pixmap->drawable.depth == 15)
- effXDepth = 16;
-
- /* Need 16-bit aligned rows for DDBitmaps */
- stride = ((iconSize * effBPP + 15) & (~15)) / 8;
- xStride = PixmapBytePad (pixmap->drawable.width, pixmap->drawable.depth);
- if (stride == 0 || xStride == 0)
- {
- ErrorF ("winScaleXBitmapToWindows - stride or xStride is zero. "
- "Bailing.\n");
- return;
+ int row, column, effXBPP, effXDepth;
+ unsigned char *outPtr;
+ char *iconData = 0;
+ int stride, xStride;
+ float factX, factY;
+ int posX, posY;
+ unsigned char *ptr;
+ unsigned int zero;
+ unsigned int color;
+
+ effXBPP = BitsPerPixel(pixmap->drawable.depth);
+ effXDepth = pixmap->drawable.depth;
+
+ if (pixmap->drawable.bitsPerPixel == 15)
+ effXBPP = 16;
+
+ if (pixmap->drawable.depth == 15)
+ effXDepth = 16;
+
+ /* Need 16-bit aligned rows for DDBitmaps */
+ stride = ((iconSize * effBPP + 15) & (~15)) / 8;
+ xStride = PixmapBytePad(pixmap->drawable.width, pixmap->drawable.depth);
+ if (stride == 0 || xStride == 0) {
+ ErrorF("winScaleXBitmapToWindows - stride or xStride is zero. "
+ "Bailing.\n");
+ return;
}
- /* Allocate memory for icon data */
- iconData = malloc (xStride * pixmap->drawable.height);
- if (!iconData)
- {
- ErrorF ("winScaleXBitmapToWindows - malloc failed for iconData. "
- "Bailing.\n");
- return;
+ /* Allocate memory for icon data */
+ iconData = malloc(xStride * pixmap->drawable.height);
+ if (!iconData) {
+ ErrorF("winScaleXBitmapToWindows - malloc failed for iconData. "
+ "Bailing.\n");
+ return;
}
- /* Get icon data */
- miGetImage ((DrawablePtr) &(pixmap->drawable), 0, 0,
- pixmap->drawable.width, pixmap->drawable.height,
- ZPixmap, 0xffffffff, iconData);
-
- /* Keep aspect ratio */
- factX = ((float)pixmap->drawable.width) / ((float)iconSize);
- factY = ((float)pixmap->drawable.height) / ((float)iconSize);
- if (factX > factY)
- factY = factX;
- else
- factX = factY;
-
- /* Out-of-bounds, fill icon with zero */
- zero = 0;
-
- for (row = 0; row < iconSize; row++)
- {
- outPtr = image + stride * row;
- for (column = 0; column < iconSize; column++)
- {
- posX = factX * column;
- posY = factY * row;
-
- ptr = (unsigned char*) iconData + posY*xStride;
- if (effXBPP == 1)
- {
- ptr += posX / 8;
-
- /* Out of X icon bounds, leave space blank */
- if (posX >= pixmap->drawable.width
- || posY >= pixmap->drawable.height)
- ptr = (unsigned char *) &zero;
-
- if ((*ptr) & (1 << (posX & 7)))
- switch (effBPP)
- {
- case 32:
- *(outPtr++) = 0;
- case 24:
- *(outPtr++) = 0;
- case 16:
- *(outPtr++) = 0;
- case 8:
- *(outPtr++) = 0;
- break;
- case 1:
- outPtr[column / 8] &= ~(1 << (7 - (column & 7)));
- break;
- }
- else
- switch (effBPP)
- {
- case 32:
- *(outPtr++) = 255;
- *(outPtr++) = 255;
- *(outPtr++) = 255;
- *(outPtr++) = 0;
- break;
- case 24:
- *(outPtr++) = 255;
- case 16:
- *(outPtr++) = 255;
- case 8:
- *(outPtr++) = 255;
- break;
- case 1:
- outPtr[column / 8] |= (1 << (7 - (column & 7)));
- break;
- }
- }
- else if (effXDepth == 24 || effXDepth == 32)
- {
- ptr += posX * (effXBPP / 8);
-
- /* Out of X icon bounds, leave space blank */
- if (posX >= pixmap->drawable.width
- || posY >= pixmap->drawable.height)
- ptr = (unsigned char *) &zero;
- color = (((*ptr) << 16)
- + ((*(ptr + 1)) << 8)
- + ((*(ptr + 2)) << 0));
- switch (effBPP)
- {
- case 32:
- *(outPtr++) = *(ptr++); /* b */
- *(outPtr++) = *(ptr++); /* g */
- *(outPtr++) = *(ptr++); /* r */
- *(outPtr++) = (effXDepth == 32) ? *(ptr++) : 0x0; /* alpha */
- break;
- case 24:
- *(outPtr++) = *(ptr++);
- *(outPtr++) = *(ptr++);
- *(outPtr++) = *(ptr++);
- break;
- case 16:
- color = ((((*ptr) >> 2) << 10)
- + (((*(ptr + 1)) >> 2) << 5)
- + (((*(ptr + 2)) >> 2)));
- *(outPtr++) = (color >> 8);
- *(outPtr++) = (color & 255);
- break;
- case 8:
- color = (((*ptr))) + (((*(ptr + 1)))) + (((*(ptr + 2))));
- color /= 3;
- *(outPtr++) = color;
- break;
- case 1:
- if (color)
- outPtr[column / 8] |= (1 << (7 - (column & 7)));
- else
- outPtr[column / 8] &= ~(1 << (7 - (column & 7)));
- }
- }
- else if (effXDepth == 16)
- {
- ptr += posX * (effXBPP / 8);
-
- /* Out of X icon bounds, leave space blank */
- if (posX >= pixmap->drawable.width
- || posY >= pixmap->drawable.height)
- ptr = (unsigned char *) &zero;
- color = ((*ptr) << 8) + (*(ptr + 1));
- switch (effBPP)
- {
- case 32:
- *(outPtr++) = (color & 31) << 2;
- *(outPtr++) = ((color >> 5) & 31) << 2;
- *(outPtr++) = ((color >> 10) & 31) << 2;
- *(outPtr++) = 0; /* resvd */
- break;
- case 24:
- *(outPtr++) = (color & 31) << 2;
- *(outPtr++) = ((color >> 5) & 31) << 2;
- *(outPtr++) = ((color >> 10) & 31) << 2;
- break;
- case 16:
- *(outPtr++) = *(ptr++);
- *(outPtr++) = *(ptr++);
- break;
- case 8:
- *(outPtr++) = (((color & 31)
- + ((color >> 5) & 31)
- + ((color >> 10) & 31)) / 3) << 2;
- break;
- case 1:
- if (color)
- outPtr[column / 8] |= (1 << (7 - (column & 7)));
- else
- outPtr[column / 8] &= ~(1 << (7 - (column & 7)));
- break;
- } /* end switch(effbpp) */
- } /* end if effxbpp==16) */
- } /* end for column */
- } /* end for row */
- free (iconData);
+ /* Get icon data */
+ miGetImage((DrawablePtr) &(pixmap->drawable), 0, 0,
+ pixmap->drawable.width, pixmap->drawable.height,
+ ZPixmap, 0xffffffff, iconData);
+
+ /* Keep aspect ratio */
+ factX = ((float) pixmap->drawable.width) / ((float) iconSize);
+ factY = ((float) pixmap->drawable.height) / ((float) iconSize);
+ if (factX > factY)
+ factY = factX;
+ else
+ factX = factY;
+
+ /* Out-of-bounds, fill icon with zero */
+ zero = 0;
+
+ for (row = 0; row < iconSize; row++) {
+ outPtr = image + stride * row;
+ for (column = 0; column < iconSize; column++) {
+ posX = factX * column;
+ posY = factY * row;
+
+ ptr = (unsigned char *) iconData + posY * xStride;
+ if (effXBPP == 1) {
+ ptr += posX / 8;
+
+ /* Out of X icon bounds, leave space blank */
+ if (posX >= pixmap->drawable.width
+ || posY >= pixmap->drawable.height)
+ ptr = (unsigned char *) &zero;
+
+ if ((*ptr) & (1 << (posX & 7)))
+ switch (effBPP) {
+ case 32:
+ *(outPtr++) = 0;
+ case 24:
+ *(outPtr++) = 0;
+ case 16:
+ *(outPtr++) = 0;
+ case 8:
+ *(outPtr++) = 0;
+ break;
+ case 1:
+ outPtr[column / 8] &= ~(1 << (7 - (column & 7)));
+ break;
+ }
+ else
+ switch (effBPP) {
+ case 32:
+ *(outPtr++) = 255;
+ *(outPtr++) = 255;
+ *(outPtr++) = 255;
+ *(outPtr++) = 0;
+ break;
+ case 24:
+ *(outPtr++) = 255;
+ case 16:
+ *(outPtr++) = 255;
+ case 8:
+ *(outPtr++) = 255;
+ break;
+ case 1:
+ outPtr[column / 8] |= (1 << (7 - (column & 7)));
+ break;
+ }
+ }
+ else if (effXDepth == 24 || effXDepth == 32) {
+ ptr += posX * (effXBPP / 8);
+
+ /* Out of X icon bounds, leave space blank */
+ if (posX >= pixmap->drawable.width
+ || posY >= pixmap->drawable.height)
+ ptr = (unsigned char *) &zero;
+ color = (((*ptr) << 16)
+ + ((*(ptr + 1)) << 8)
+ + ((*(ptr + 2)) << 0));
+ switch (effBPP) {
+ case 32:
+ *(outPtr++) = *(ptr++); /* b */
+ *(outPtr++) = *(ptr++); /* g */
+ *(outPtr++) = *(ptr++); /* r */
+ *(outPtr++) = (effXDepth == 32) ? *(ptr++) : 0x0; /* alpha */
+ break;
+ case 24:
+ *(outPtr++) = *(ptr++);
+ *(outPtr++) = *(ptr++);
+ *(outPtr++) = *(ptr++);
+ break;
+ case 16:
+ color = ((((*ptr) >> 2) << 10)
+ + (((*(ptr + 1)) >> 2) << 5)
+ + (((*(ptr + 2)) >> 2)));
+ *(outPtr++) = (color >> 8);
+ *(outPtr++) = (color & 255);
+ break;
+ case 8:
+ color = (((*ptr))) + (((*(ptr + 1)))) + (((*(ptr + 2))));
+ color /= 3;
+ *(outPtr++) = color;
+ break;
+ case 1:
+ if (color)
+ outPtr[column / 8] |= (1 << (7 - (column & 7)));
+ else
+ outPtr[column / 8] &= ~(1 << (7 - (column & 7)));
+ }
+ }
+ else if (effXDepth == 16) {
+ ptr += posX * (effXBPP / 8);
+
+ /* Out of X icon bounds, leave space blank */
+ if (posX >= pixmap->drawable.width
+ || posY >= pixmap->drawable.height)
+ ptr = (unsigned char *) &zero;
+ color = ((*ptr) << 8) + (*(ptr + 1));
+ switch (effBPP) {
+ case 32:
+ *(outPtr++) = (color & 31) << 2;
+ *(outPtr++) = ((color >> 5) & 31) << 2;
+ *(outPtr++) = ((color >> 10) & 31) << 2;
+ *(outPtr++) = 0; /* resvd */
+ break;
+ case 24:
+ *(outPtr++) = (color & 31) << 2;
+ *(outPtr++) = ((color >> 5) & 31) << 2;
+ *(outPtr++) = ((color >> 10) & 31) << 2;
+ break;
+ case 16:
+ *(outPtr++) = *(ptr++);
+ *(outPtr++) = *(ptr++);
+ break;
+ case 8:
+ *(outPtr++) = (((color & 31)
+ + ((color >> 5) & 31)
+ + ((color >> 10) & 31)) / 3) << 2;
+ break;
+ case 1:
+ if (color)
+ outPtr[column / 8] |= (1 << (7 - (column & 7)));
+ else
+ outPtr[column / 8] &= ~(1 << (7 - (column & 7)));
+ break;
+ } /* end switch(effbpp) */
+ } /* end if effxbpp==16) */
+ } /* end for column */
+ } /* end for row */
+ free(iconData);
}
static HICON
-NetWMToWinIconAlpha(uint32_t *icon)
+NetWMToWinIconAlpha(uint32_t * icon)
{
- int width = icon[0];
- int height = icon[1];
- uint32_t *pixels = &icon[2];
- HICON result;
- HDC hdc = GetDC(NULL);
- uint32_t *DIB_pixels;
+ int width = icon[0];
+ int height = icon[1];
+ uint32_t *pixels = &icon[2];
+ HICON result;
+ HDC hdc = GetDC(NULL);
+ uint32_t *DIB_pixels;
ICONINFO ii;
BITMAPV5HEADER bmh;
- /* Define an ARGB pixel format used for Color+Alpha icons */
+ /* Define an ARGB pixel format used for Color+Alpha icons */
ZeroMemory(&bmh,sizeof(bmh));
bmh.bV5Size = sizeof(bmh);
bmh.bV5Width = width;
@@ -280,126 +266,134 @@ NetWMToWinIconAlpha(uint32_t *icon)
bmh.bV5GreenMask = 0x0000FF00;
bmh.bV5BlueMask = 0x000000FF;
- ii.hbmColor = CreateDIBSection(hdc, (BITMAPINFO*)&bmh,
- DIB_RGB_COLORS, (void**)&DIB_pixels, NULL, 0);
- ReleaseDC(NULL, hdc);
- ii.hbmMask = CreateBitmap(width, height, 1, 1, NULL);
- memcpy(DIB_pixels, pixels, height*width*4);
+ ii.hbmColor = CreateDIBSection(hdc, (BITMAPINFO *) & bmh,
+ DIB_RGB_COLORS, (void **) &DIB_pixels, NULL,
+ 0);
+ ReleaseDC(NULL, hdc);
+ ii.hbmMask = CreateBitmap(width, height, 1, 1, NULL);
+ memcpy(DIB_pixels, pixels, height * width * 4);
- /* CreateIconIndirect() traditionally required DDBitmaps */
- /* Systems from WinXP accept 32-bit ARGB DIBitmaps with full 8-bit alpha support */
- /* The icon is created with a DIB + empty DDB mask (an MS example does the same) */
+ /* CreateIconIndirect() traditionally required DDBitmaps */
+ /* Systems from WinXP accept 32-bit ARGB DIBitmaps with full 8-bit alpha support */
+ /* The icon is created with a DIB + empty DDB mask (an MS example does the same) */
ii.fIcon = TRUE;
ii.xHotspot = 0;
ii.yHotspot = 0;
- result = CreateIconIndirect(&ii);
+ result = CreateIconIndirect(&ii);
- DeleteObject(ii.hbmColor);
- DeleteObject(ii.hbmMask);
+ DeleteObject(ii.hbmColor);
+ DeleteObject(ii.hbmMask);
- winDebug("NetWMToWinIconAlpha - %d x %d = %p\n", icon[0], icon[1], result);
- return result;
+ winDebug("NetWMToWinIconAlpha - %d x %d = %p\n", icon[0], icon[1], result);
+ return result;
}
static HICON
-NetWMToWinIconThreshold(uint32_t *icon)
+NetWMToWinIconThreshold(uint32_t * icon)
{
- int width = icon[0];
- int height = icon[1];
- uint32_t *pixels = &icon[2];
- int row, col;
- HICON result;
- ICONINFO ii;
-
- HDC hdc = GetDC(NULL);
- HDC xorDC = CreateCompatibleDC(hdc);
- HDC andDC = CreateCompatibleDC(hdc);
- ii.hbmColor = CreateCompatibleBitmap(hdc, width, height);
- ii.hbmMask = CreateCompatibleBitmap(hdc, width, height);
- ReleaseDC(NULL, hdc);
- SelectObject(xorDC, ii.hbmColor);
- SelectObject(andDC, ii.hbmMask);
-
- for (row = 0; row < height; row++) {
- for (col = 0; col < width; col++) {
- if ((*pixels & 0xFF000000) > 31<<24) { /* 31 alpha threshold, i.e. opaque above, transparent below */
- SetPixelV(xorDC, col, row, RGB(((char*)pixels)[2], ((char*)pixels)[1],
- ((char*)pixels)[0]));
- SetPixelV(andDC, col, row, RGB(0, 0, 0)); /* black mask */
- }
- else {
- SetPixelV(xorDC, col, row, RGB(0, 0, 0));
- SetPixelV(andDC, col, row, RGB(255, 255, 255)); /* white mask */
- }
- pixels++;
+ int width = icon[0];
+ int height = icon[1];
+ uint32_t *pixels = &icon[2];
+ int row, col;
+ HICON result;
+ ICONINFO ii;
+
+ HDC hdc = GetDC(NULL);
+ HDC xorDC = CreateCompatibleDC(hdc);
+ HDC andDC = CreateCompatibleDC(hdc);
+
+ ii.hbmColor = CreateCompatibleBitmap(hdc, width, height);
+ ii.hbmMask = CreateCompatibleBitmap(hdc, width, height);
+ ReleaseDC(NULL, hdc);
+ SelectObject(xorDC, ii.hbmColor);
+ SelectObject(andDC, ii.hbmMask);
+
+ for (row = 0; row < height; row++) {
+ for (col = 0; col < width; col++) {
+ if ((*pixels & 0xFF000000) > 31 << 24) { /* 31 alpha threshold, i.e. opaque above, transparent below */
+ SetPixelV(xorDC, col, row,
+ RGB(((char *) pixels)[2], ((char *) pixels)[1],
+ ((char *) pixels)[0]));
+ SetPixelV(andDC, col, row, RGB(0, 0, 0)); /* black mask */
+ }
+ else {
+ SetPixelV(xorDC, col, row, RGB(0, 0, 0));
+ SetPixelV(andDC, col, row, RGB(255, 255, 255)); /* white mask */
+ }
+ pixels++;
+ }
}
- }
- DeleteDC(xorDC);
- DeleteDC(andDC);
+ DeleteDC(xorDC);
+ DeleteDC(andDC);
ii.fIcon = TRUE;
ii.xHotspot = 0;
ii.yHotspot = 0;
- result = CreateIconIndirect(&ii);
+ result = CreateIconIndirect(&ii);
- DeleteObject(ii.hbmColor);
- DeleteObject(ii.hbmMask );
+ DeleteObject(ii.hbmColor);
+ DeleteObject(ii.hbmMask);
- winDebug("NetWMToWinIconThreshold - %d x %d = %p\n", icon[0], icon[1], result);
- return result;
+ winDebug("NetWMToWinIconThreshold - %d x %d = %p\n", icon[0], icon[1],
+ result);
+ return result;
}
static HICON
-NetWMToWinIcon(int bpp, uint32_t *icon)
+NetWMToWinIcon(int bpp, uint32_t * icon)
{
- static Bool hasIconAlphaChannel = FALSE;
- static BOOL versionChecked = FALSE;
-
- if (!versionChecked)
- {
- OSVERSIONINFOEX osvi = {0};
- ULONGLONG dwlConditionMask = 0;
-
- osvi.dwOSVersionInfoSize = sizeof (osvi);
- osvi.dwMajorVersion = 5;
- osvi.dwMinorVersion = 1;
-
- /* Windows versions later than XP have icon alpha channel suport, 2000 does not */
- VER_SET_CONDITION(dwlConditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL);
- VER_SET_CONDITION(dwlConditionMask, VER_MINORVERSION, VER_GREATER_EQUAL);
- hasIconAlphaChannel = VerifyVersionInfo(&osvi, VER_MAJORVERSION | VER_MINORVERSION, dwlConditionMask);
- versionChecked = TRUE;
-
- winDebug("OS has icon alpha channel support: %s\n", hasIconAlphaChannel ? "yes" : "no");
+ static Bool hasIconAlphaChannel = FALSE;
+ static BOOL versionChecked = FALSE;
+
+ if (!versionChecked) {
+ OSVERSIONINFOEX osvi = { 0 };
+ ULONGLONG dwlConditionMask = 0;
+
+ osvi.dwOSVersionInfoSize = sizeof(osvi);
+ osvi.dwMajorVersion = 5;
+ osvi.dwMinorVersion = 1;
+
+ /* Windows versions later than XP have icon alpha channel suport, 2000 does not */
+ VER_SET_CONDITION(dwlConditionMask, VER_MAJORVERSION,
+ VER_GREATER_EQUAL);
+ VER_SET_CONDITION(dwlConditionMask, VER_MINORVERSION,
+ VER_GREATER_EQUAL);
+ hasIconAlphaChannel =
+ VerifyVersionInfo(&osvi, VER_MAJORVERSION | VER_MINORVERSION,
+ dwlConditionMask);
+ versionChecked = TRUE;
+
+ winDebug("OS has icon alpha channel support: %s\n",
+ hasIconAlphaChannel ? "yes" : "no");
}
- if (hasIconAlphaChannel && (bpp==32))
- return NetWMToWinIconAlpha(icon);
- else
- return NetWMToWinIconThreshold(icon);
+ if (hasIconAlphaChannel && (bpp == 32))
+ return NetWMToWinIconAlpha(icon);
+ else
+ return NetWMToWinIconThreshold(icon);
}
static pointer
GetWindowProp(WindowPtr pWin, Atom name, long int *size_return)
{
- struct _Window *pwin;
- struct _Property *prop;
-
- if (!pWin || !name) {
- ErrorF ("GetWindowProp - pWin or name was NULL\n");
- return 0;
- }
- pwin = (struct _Window*) pWin;
- if (!pwin->optional) return NULL;
- for (prop = (struct _Property *) pwin->optional->userProps;
- prop;
- prop=prop->next){
- if (prop->propertyName == name) {
- *size_return=prop->size;
- return prop->data;
+ struct _Window *pwin;
+ struct _Property *prop;
+
+ if (!pWin || !name) {
+ ErrorF("GetWindowProp - pWin or name was NULL\n");
+ return 0;
+ }
+ pwin = (struct _Window *) pWin;
+ if (!pwin->optional)
+ return NULL;
+ for (prop = (struct _Property *) pwin->optional->userProps;
+ prop; prop = prop->next) {
+ if (prop->propertyName == name) {
+ *size_return = prop->size;
+ return prop->data;
+ }
}
- }
- return NULL;
+ return NULL;
}
/*
@@ -407,130 +401,128 @@ GetWindowProp(WindowPtr pWin, Atom name, long int *size_return)
*/
HICON
-winXIconToHICON (WindowPtr pWin, int iconSize)
+winXIconToHICON(WindowPtr pWin, int iconSize)
{
- unsigned char *mask, *image, *imageMask;
- unsigned char *dst, *src;
- PixmapPtr iconPtr;
- PixmapPtr maskPtr;
- int planes, bpp, effBPP, stride, maskStride, i;
- int biggest_size = 0;
- HDC hDC;
- ICONINFO ii;
- WinXWMHints hints;
- HICON hIcon = NULL;
- uint32_t *biggest_icon = NULL;
-
- /* Try to get _NET_WM_ICON icons first */
- static Atom _XA_NET_WM_ICON;
- static int generation;
- uint32_t *icon, *icon_data = NULL;
- long int size=0;
-
- hDC = GetDC (GetDesktopWindow ());
- planes = GetDeviceCaps (hDC, PLANES);
- bpp = GetDeviceCaps (hDC, BITSPIXEL);
- ReleaseDC (GetDesktopWindow (), hDC);
-
- if (generation != serverGeneration) {
- generation = serverGeneration;
- _XA_NET_WM_ICON = MakeAtom("_NET_WM_ICON", 12, TRUE);
- }
-
- if (_XA_NET_WM_ICON) icon_data = GetWindowProp(pWin, _XA_NET_WM_ICON, &size);
- if (icon_data)
- {
- for(icon = icon_data;
- icon < &icon_data[size] && *icon;
- icon = &icon[icon[0]*icon[1]+2])
- {
- if (icon[0]==iconSize && icon[1]==iconSize)
- return NetWMToWinIcon(bpp, icon);
- /* Find the biggest icon and let Windows scale the size */
- else if (biggest_size < icon[0])
- {
- biggest_icon = icon;
- biggest_size = icon[0];
- }
- }
- if (biggest_icon)
- return NetWMToWinIcon(bpp, biggest_icon);
+ unsigned char *mask, *image, *imageMask;
+ unsigned char *dst, *src;
+ PixmapPtr iconPtr;
+ PixmapPtr maskPtr;
+ int planes, bpp, effBPP, stride, maskStride, i;
+ int biggest_size = 0;
+ HDC hDC;
+ ICONINFO ii;
+ WinXWMHints hints;
+ HICON hIcon = NULL;
+ uint32_t *biggest_icon = NULL;
+
+ /* Try to get _NET_WM_ICON icons first */
+ static Atom _XA_NET_WM_ICON;
+ static int generation;
+ uint32_t *icon, *icon_data = NULL;
+ long int size = 0;
+
+ hDC = GetDC(GetDesktopWindow());
+ planes = GetDeviceCaps(hDC, PLANES);
+ bpp = GetDeviceCaps(hDC, BITSPIXEL);
+ ReleaseDC(GetDesktopWindow(), hDC);
+
+ if (generation != serverGeneration) {
+ generation = serverGeneration;
+ _XA_NET_WM_ICON = MakeAtom("_NET_WM_ICON", 12, TRUE);
}
- winDebug("winXIconToHICON - pWin %x: no suitable NetIcon\n",(int)pWin, iconSize);
-
- winMultiWindowGetWMHints (pWin, &hints);
- if (!hints.icon_pixmap) return NULL;
-
- dixLookupResourceByType((pointer) &iconPtr, hints.icon_pixmap, RT_PIXMAP,
- NullClient, DixUnknownAccess);
-
- if (!iconPtr) return NULL;
-
- /* 15 BPP is really 16BPP as far as we care */
- if (bpp == 15)
- effBPP = 16;
- else
- effBPP = bpp;
-
- /* Need 16-bit aligned rows for DDBitmaps */
- stride = ((iconSize * effBPP + 15) & (~15)) / 8;
-
- /* Mask is 1-bit deep */
- maskStride = ((iconSize * 1 + 15) & (~15)) / 8;
-
- image = malloc (stride * iconSize);
- imageMask = malloc (stride * iconSize);
- /* Default to a completely black mask */
- mask = calloc (maskStride, iconSize);
-
- winScaleXBitmapToWindows (iconSize, effBPP, iconPtr, image);
- dixLookupResourceByType((pointer) &maskPtr, hints.icon_mask, RT_PIXMAP,
- NullClient, DixUnknownAccess);
-
- if (maskPtr)
- {
- winScaleXBitmapToWindows (iconSize, 1, maskPtr, mask);
-
- winScaleXBitmapToWindows (iconSize, effBPP, maskPtr, imageMask);
-
- /* Now we need to set all bits of the icon which are not masked */
- /* on to 0 because Color is really an XOR, not an OR function */
- dst = image;
- src = imageMask;
-
- for (i = 0; i < (stride * iconSize); i++)
- if ((*(src++)))
- *(dst++) = 0;
- else
- dst++;
+
+ if (_XA_NET_WM_ICON)
+ icon_data = GetWindowProp(pWin, _XA_NET_WM_ICON, &size);
+ if (icon_data) {
+ for (icon = icon_data;
+ icon < &icon_data[size] && *icon;
+ icon = &icon[icon[0] * icon[1] + 2]) {
+ if (icon[0] == iconSize && icon[1] == iconSize)
+ return NetWMToWinIcon(bpp, icon);
+ /* Find the biggest icon and let Windows scale the size */
+ else if (biggest_size < icon[0]) {
+ biggest_icon = icon;
+ biggest_size = icon[0];
+ }
+ }
+ if (biggest_icon)
+ return NetWMToWinIcon(bpp, biggest_icon);
}
-
- ii.fIcon = TRUE;
- ii.xHotspot = 0; /* ignored */
- ii.yHotspot = 0; /* ignored */
-
- /* Create Win32 mask from pixmap shape */
- ii.hbmMask = CreateBitmap (iconSize, iconSize, planes, 1, mask);
+ winDebug("winXIconToHICON - pWin %x: no suitable NetIcon\n", (int) pWin,
+ iconSize);
- /* Create Win32 bitmap from pixmap */
- ii.hbmColor = CreateBitmap (iconSize, iconSize, planes, bpp, image);
+ winMultiWindowGetWMHints(pWin, &hints);
+ if (!hints.icon_pixmap)
+ return NULL;
- /* Merge Win32 mask and bitmap into icon */
- hIcon = CreateIconIndirect (&ii);
+ dixLookupResourceByType((pointer) &iconPtr, hints.icon_pixmap, RT_PIXMAP,
+ NullClient, DixUnknownAccess);
- /* Release Win32 mask and bitmap */
- DeleteObject (ii.hbmMask);
- DeleteObject (ii.hbmColor);
+ if (!iconPtr)
+ return NULL;
- /* Free X mask and bitmap */
- free (mask);
- free (image);
- free (imageMask);
+ /* 15 BPP is really 16BPP as far as we care */
+ if (bpp == 15)
+ effBPP = 16;
+ else
+ effBPP = bpp;
- return hIcon;
-}
+ /* Need 16-bit aligned rows for DDBitmaps */
+ stride = ((iconSize * effBPP + 15) & (~15)) / 8;
+
+ /* Mask is 1-bit deep */
+ maskStride = ((iconSize * 1 + 15) & (~15)) / 8;
+
+ image = malloc(stride * iconSize);
+ imageMask = malloc(stride * iconSize);
+ /* Default to a completely black mask */
+ mask = calloc(maskStride, iconSize);
+
+ winScaleXBitmapToWindows(iconSize, effBPP, iconPtr, image);
+ dixLookupResourceByType((pointer) &maskPtr, hints.icon_mask, RT_PIXMAP,
+ NullClient, DixUnknownAccess);
+
+ if (maskPtr) {
+ winScaleXBitmapToWindows(iconSize, 1, maskPtr, mask);
+
+ winScaleXBitmapToWindows(iconSize, effBPP, maskPtr, imageMask);
+
+ /* Now we need to set all bits of the icon which are not masked */
+ /* on to 0 because Color is really an XOR, not an OR function */
+ dst = image;
+ src = imageMask;
+
+ for (i = 0; i < (stride * iconSize); i++)
+ if ((*(src++)))
+ *(dst++) = 0;
+ else
+ dst++;
+ }
+
+ ii.fIcon = TRUE;
+ ii.xHotspot = 0; /* ignored */
+ ii.yHotspot = 0; /* ignored */
+
+ /* Create Win32 mask from pixmap shape */
+ ii.hbmMask = CreateBitmap(iconSize, iconSize, planes, 1, mask);
+ /* Create Win32 bitmap from pixmap */
+ ii.hbmColor = CreateBitmap(iconSize, iconSize, planes, bpp, image);
+ /* Merge Win32 mask and bitmap into icon */
+ hIcon = CreateIconIndirect(&ii);
+
+ /* Release Win32 mask and bitmap */
+ DeleteObject(ii.hbmMask);
+ DeleteObject(ii.hbmColor);
+
+ /* Free X mask and bitmap */
+ free(mask);
+ free(image);
+ free(imageMask);
+
+ return hIcon;
+}
/*
* Change the Windows window icon
@@ -538,112 +530,115 @@ winXIconToHICON (WindowPtr pWin, int iconSize)
#ifdef XWIN_MULTIWINDOW
void
-winUpdateIcon (Window id)
+winUpdateIcon(Window id)
{
- WindowPtr pWin;
- HICON hIcon, hIconSmall=NULL, hIconOld;
-
- dixLookupResourceByType((pointer) &pWin, id, RT_WINDOW, NullClient, DixUnknownAccess);
- if (pWin)
- {
- winWindowPriv(pWin);
- if (pWinPriv->hWnd) {
- hIcon = winOverrideIcon ((unsigned long)pWin);
- if (!hIcon) {
- hIcon = winXIconToHICON (pWin, GetSystemMetrics(SM_CXICON));
- if (!hIcon) {
- hIcon = g_hIconX;
- hIconSmall = g_hSmallIconX;
- } else {
- /* Leave undefined if not found */
- hIconSmall = winXIconToHICON (pWin, GetSystemMetrics(SM_CXSMICON));
- }
+ WindowPtr pWin;
+ HICON hIcon, hIconSmall = NULL, hIconOld;
+
+ dixLookupResourceByType((pointer) &pWin, id, RT_WINDOW, NullClient,
+ DixUnknownAccess);
+ if (pWin) {
+ winWindowPriv(pWin);
+ if (pWinPriv->hWnd) {
+ hIcon = winOverrideIcon((unsigned long) pWin);
+ if (!hIcon) {
+ hIcon = winXIconToHICON(pWin, GetSystemMetrics(SM_CXICON));
+ if (!hIcon) {
+ hIcon = g_hIconX;
+ hIconSmall = g_hSmallIconX;
+ }
+ else {
+ /* Leave undefined if not found */
+ hIconSmall =
+ winXIconToHICON(pWin, GetSystemMetrics(SM_CXSMICON));
+ }
+ }
+
+ /* Set the large icon */
+ hIconOld = (HICON) SendMessage(pWinPriv->hWnd,
+ WM_SETICON, ICON_BIG,
+ (LPARAM) hIcon);
+
+ /* Delete the icon if its not the default */
+ winDestroyIcon(hIconOld);
+
+ /* Same for the small icon */
+ hIconOld = (HICON) SendMessage(pWinPriv->hWnd,
+ WM_SETICON, ICON_SMALL,
+ (LPARAM) hIconSmall);
+ winDestroyIcon(hIconOld);
}
+ }
+}
- /* Set the large icon */
- hIconOld = (HICON) SendMessage (pWinPriv->hWnd,
- WM_SETICON, ICON_BIG, (LPARAM) hIcon);
+void
+winInitGlobalIcons(void)
+{
+ int sm_cx = GetSystemMetrics(SM_CXICON);
+ int sm_cxsm = GetSystemMetrics(SM_CXSMICON);
- /* Delete the icon if its not the default */
- winDestroyIcon(hIconOld);
+ /* Load default X icon in case it's not ready yet */
+ if (!g_hIconX) {
+ g_hIconX = winOverrideDefaultIcon(sm_cx);
+ g_hSmallIconX = winOverrideDefaultIcon(sm_cxsm);
+ }
- /* Same for the small icon */
- hIconOld = (HICON) SendMessage (pWinPriv->hWnd,
- WM_SETICON, ICON_SMALL, (LPARAM) hIconSmall);
- winDestroyIcon(hIconOld);
- }
- }
+ if (!g_hIconX) {
+ g_hIconX = (HICON) LoadImage(g_hInstance,
+ MAKEINTRESOURCE(IDI_XWIN),
+ IMAGE_ICON,
+ GetSystemMetrics(SM_CXICON),
+ GetSystemMetrics(SM_CYICON), 0);
+ g_hSmallIconX = (HICON) LoadImage(g_hInstance,
+ MAKEINTRESOURCE(IDI_XWIN),
+ IMAGE_ICON,
+ GetSystemMetrics(SM_CXSMICON),
+ GetSystemMetrics(SM_CYSMICON),
+ LR_DEFAULTSIZE);
+ }
}
-void winInitGlobalIcons (void)
+void
+winSelectIcons(WindowPtr pWin, HICON * pIcon, HICON * pSmallIcon)
{
- int sm_cx = GetSystemMetrics(SM_CXICON);
- int sm_cxsm = GetSystemMetrics(SM_CXSMICON);
- /* Load default X icon in case it's not ready yet */
- if (!g_hIconX)
- {
- g_hIconX = winOverrideDefaultIcon(sm_cx);
- g_hSmallIconX = winOverrideDefaultIcon(sm_cxsm);
+ HICON hIcon, hSmallIcon;
+
+ winInitGlobalIcons();
+
+ /* Try and get the icon from WM_HINTS */
+ hIcon = winXIconToHICON(pWin, GetSystemMetrics(SM_CXICON));
+ hSmallIcon = winXIconToHICON(pWin, GetSystemMetrics(SM_CXSMICON));
+
+ /* If we got the small, but not the large one swap them */
+ if (!hIcon && hSmallIcon) {
+ hIcon = hSmallIcon;
+ hSmallIcon = NULL;
}
-
- if (!g_hIconX)
- {
- g_hIconX = (HICON)LoadImage (g_hInstance,
- MAKEINTRESOURCE(IDI_XWIN),
- IMAGE_ICON,
- GetSystemMetrics(SM_CXICON),
- GetSystemMetrics(SM_CYICON),
- 0);
- g_hSmallIconX = (HICON)LoadImage (g_hInstance,
- MAKEINTRESOURCE(IDI_XWIN),
- IMAGE_ICON,
- GetSystemMetrics(SM_CXSMICON),
- GetSystemMetrics(SM_CYSMICON),
- LR_DEFAULTSIZE);
+
+ /* Use default X icon if no icon loaded from WM_HINTS */
+ if (!hIcon) {
+ hIcon = g_hIconX;
+ hSmallIcon = g_hSmallIconX;
}
-}
-void winSelectIcons(WindowPtr pWin, HICON *pIcon, HICON *pSmallIcon)
-{
- HICON hIcon, hSmallIcon;
-
- winInitGlobalIcons();
-
- /* Try and get the icon from WM_HINTS */
- hIcon = winXIconToHICON (pWin, GetSystemMetrics(SM_CXICON));
- hSmallIcon = winXIconToHICON (pWin, GetSystemMetrics(SM_CXSMICON));
-
- /* If we got the small, but not the large one swap them */
- if (!hIcon && hSmallIcon)
- {
- hIcon = hSmallIcon;
- hSmallIcon = NULL;
- }
-
- /* Use default X icon if no icon loaded from WM_HINTS */
- if (!hIcon) {
- hIcon = g_hIconX;
- hSmallIcon = g_hSmallIconX;
- }
-
- if (pIcon)
- *pIcon = hIcon;
- else
- winDestroyIcon(hIcon);
-
- if (pSmallIcon)
- *pSmallIcon = hSmallIcon;
- else
- winDestroyIcon(hSmallIcon);
+ if (pIcon)
+ *pIcon = hIcon;
+ else
+ winDestroyIcon(hIcon);
+
+ if (pSmallIcon)
+ *pSmallIcon = hSmallIcon;
+ else
+ winDestroyIcon(hSmallIcon);
}
-void winDestroyIcon(HICON hIcon)
+void
+winDestroyIcon(HICON hIcon)
{
- /* Delete the icon if its not one of the application defaults or an override */
- if (hIcon &&
- hIcon != g_hIconX &&
- hIcon != g_hSmallIconX &&
- !winIconIsOverride((unsigned long)hIcon))
- DestroyIcon (hIcon);
+ /* Delete the icon if its not one of the application defaults or an override */
+ if (hIcon &&
+ hIcon != g_hIconX &&
+ hIcon != g_hSmallIconX && !winIconIsOverride((unsigned long) hIcon))
+ DestroyIcon(hIcon);
}
#endif
diff --git a/xorg-server/hw/xwin/winmultiwindowshape.c b/xorg-server/hw/xwin/winmultiwindowshape.c
index 9219bb708..26cd715bc 100644
--- a/xorg-server/hw/xwin/winmultiwindowshape.c
+++ b/xorg-server/hw/xwin/winmultiwindowshape.c
@@ -1,215 +1,206 @@
-/*
- *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, sublicense, and/or sell copies of the Software, and to
- *permit persons to whom the Software is furnished to do so, subject to
- *the following conditions:
- *
- *The above copyright notice and this permission notice shall be
- *included in all copies or substantial portions of the Software.
- *
- *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
- *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *Except as contained in this notice, the name of the XFree86 Project
- *shall not be used in advertising or otherwise to promote the sale, use
- *or other dealings in this Software without prior written authorization
- *from the XFree86 Project.
- *
- * Authors: Kensuke Matsuzaki
- * Harold L Hunt II
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-
-#include "win.h"
-
-
-/*
- * winSetShapeMultiWindow - See Porting Layer Definition - p. 42
- */
-
-void
-winSetShapeMultiWindow (WindowPtr pWin, int kind)
-{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- winScreenPriv(pScreen);
-
- winDebug ("winSetShapeMultiWindow - pWin: %08x kind: %i\n", pWin, kind);
-
- WIN_UNWRAP(SetShape);
- (*pScreen->SetShape)(pWin, kind);
- WIN_WRAP(SetShape, winSetShapeMultiWindow);
-
- /* Update the Windows window's shape */
- winReshapeMultiWindow (pWin);
- winUpdateRgnMultiWindow (pWin);
-
- return;
-}
-
-
-/*
- * winUpdateRgnMultiWindow - Local function to update a Windows window region
- */
-
-void
-winUpdateRgnMultiWindow (WindowPtr pWin)
-{
- SetWindowRgn (winGetWindowPriv(pWin)->hWnd,
- winGetWindowPriv(pWin)->hRgn, TRUE);
-
- /* The system now owns the region specified by the region handle and will delete it when it is no longer needed. */
- winGetWindowPriv(pWin)->hRgn = NULL;
-}
-
-
-/*
- * winReshapeMultiWindow - Computes the composite clipping region for a window
- */
-
-void
-winReshapeMultiWindow (WindowPtr pWin)
-{
- int nRects;
- RegionRec rrNewShape;
- BoxPtr pShape, pRects, pEnd;
- HRGN hRgn, hRgnRect;
- winWindowPriv(pWin);
-
- winDebug ("winReshape ()\n");
-
- /* Bail if the window is the root window */
- if (pWin->parent == NULL)
- return;
-
- /* Bail if the window is not top level */
- if (pWin->parent->parent != NULL)
- return;
-
- /* Bail if Windows window handle is invalid */
- if (pWinPriv->hWnd == NULL)
- return;
-
- /* Free any existing window region stored in the window privates */
- if (pWinPriv->hRgn != NULL)
- {
- DeleteObject (pWinPriv->hRgn);
- pWinPriv->hRgn = NULL;
- }
-
- /* Bail if the window has no bounding region defined */
- if (!wBoundingShape (pWin))
- return;
-
- RegionNull(&rrNewShape);
- RegionCopy(&rrNewShape, wBoundingShape(pWin));
- RegionTranslate(&rrNewShape, pWin->borderWidth, pWin->borderWidth);
-
- nRects = RegionNumRects(&rrNewShape);
- pShape = RegionRects(&rrNewShape);
-
- /* Don't do anything if there are no rectangles in the region */
- if (nRects > 0)
- {
- RECT rcClient;
- RECT rcWindow;
- int iOffsetX, iOffsetY;
-
- /* Get client rectangle */
- if (!GetClientRect (pWinPriv->hWnd, &rcClient))
- {
- ErrorF ("winReshape - GetClientRect failed, bailing: %d\n",
- (int) GetLastError ());
- return;
- }
-
- /* Translate client rectangle coords to screen coords */
- /* NOTE: Only transforms top and left members */
- ClientToScreen (pWinPriv->hWnd, (LPPOINT) &rcClient);
-
- /* Get window rectangle */
- if (!GetWindowRect (pWinPriv->hWnd, &rcWindow))
- {
- ErrorF ("winReshape - GetWindowRect failed, bailing: %d\n",
- (int) GetLastError ());
- return;
- }
-
- /* Calculate offset from window upper-left to client upper-left */
- iOffsetX = rcClient.left - rcWindow.left;
- iOffsetY = rcClient.top - rcWindow.top;
-
- /* Create initial Windows region for title bar */
- /* FIXME: Mean, nasty, ugly hack!!! */
- hRgn = CreateRectRgn (0, 0, rcWindow.right, iOffsetY);
- if (hRgn == NULL)
- {
- ErrorF ("winReshape - Initial CreateRectRgn (%d, %d, %d, %d) "
- "failed: %d\n",
- 0, 0, (int) rcWindow.right, iOffsetY, (int) GetLastError ());
- }
-
- /* Loop through all rectangles in the X region */
- for (pRects = pShape, pEnd = pShape + nRects; pRects < pEnd; pRects++)
- {
- /* Create a Windows region for the X rectangle */
- hRgnRect = CreateRectRgn (pRects->x1 + iOffsetX,
- pRects->y1 + iOffsetY,
- pRects->x2 + iOffsetX,
- pRects->y2 + iOffsetY);
- if (hRgnRect == NULL)
- {
- ErrorF ("winReshape - Loop CreateRectRgn (%d, %d, %d, %d) "
- "failed: %d\n"
- "\tx1: %d x2: %d xOff: %d y1: %d y2: %d yOff: %d\n",
- pRects->x1 + iOffsetX,
- pRects->y1 + iOffsetY,
- pRects->x2 + iOffsetX,
- pRects->y2 + iOffsetY,
- (int) GetLastError (),
- pRects->x1, pRects->x2, iOffsetX,
- pRects->y1, pRects->y2, iOffsetY);
- }
-
- /* Merge the Windows region with the accumulated region */
- if (CombineRgn (hRgn, hRgn, hRgnRect, RGN_OR) == ERROR)
- {
- ErrorF ("winReshape - CombineRgn () failed: %d\n",
- (int) GetLastError ());
- }
-
- /* Delete the temporary Windows region */
- DeleteObject (hRgnRect);
- }
-
- /* Save a handle to the composite region in the window privates */
- pWinPriv->hRgn = hRgn;
- }
-
- RegionUninit(&rrNewShape);
-
- return;
-}
-
-void
-winShapeRgnUpdateMultiwindow(HWND hwnd)
-{
- WindowPtr pWin = GetProp (hwnd, WIN_WINDOW_PROP);
- if (pWin)
- {
- winReshapeMultiWindow(pWin);
- winUpdateRgnMultiWindow(pWin);
- }
-}
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Kensuke Matsuzaki
+ * Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+
+#include "win.h"
+
+/*
+ * winSetShapeMultiWindow - See Porting Layer Definition - p. 42
+ */
+
+void
+winSetShapeMultiWindow(WindowPtr pWin, int kind)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ winScreenPriv(pScreen);
+
+ winDebug ("winSetShapeMultiWindow - pWin: %08x kind: %i\n", pWin, kind);
+
+ WIN_UNWRAP(SetShape);
+ (*pScreen->SetShape) (pWin, kind);
+ WIN_WRAP(SetShape, winSetShapeMultiWindow);
+
+ /* Update the Windows window's shape */
+ winReshapeMultiWindow(pWin);
+ winUpdateRgnMultiWindow(pWin);
+
+ return;
+}
+
+/*
+ * winUpdateRgnMultiWindow - Local function to update a Windows window region
+ */
+
+void
+winUpdateRgnMultiWindow(WindowPtr pWin)
+{
+ SetWindowRgn(winGetWindowPriv(pWin)->hWnd,
+ winGetWindowPriv(pWin)->hRgn, TRUE);
+
+ /* The system now owns the region specified by the region handle and will delete it when it is no longer needed. */
+ winGetWindowPriv(pWin)->hRgn = NULL;
+}
+
+/*
+ * winReshapeMultiWindow - Computes the composite clipping region for a window
+ */
+
+void
+winReshapeMultiWindow(WindowPtr pWin)
+{
+ int nRects;
+ RegionRec rrNewShape;
+ BoxPtr pShape, pRects, pEnd;
+ HRGN hRgn, hRgnRect;
+
+ winWindowPriv(pWin);
+
+ winDebug("winReshape ()\n");
+
+ /* Bail if the window is the root window */
+ if (pWin->parent == NULL)
+ return;
+
+ /* Bail if the window is not top level */
+ if (pWin->parent->parent != NULL)
+ return;
+
+ /* Bail if Windows window handle is invalid */
+ if (pWinPriv->hWnd == NULL)
+ return;
+
+ /* Free any existing window region stored in the window privates */
+ if (pWinPriv->hRgn != NULL) {
+ DeleteObject(pWinPriv->hRgn);
+ pWinPriv->hRgn = NULL;
+ }
+
+ /* Bail if the window has no bounding region defined */
+ if (!wBoundingShape(pWin))
+ return;
+
+ RegionNull(&rrNewShape);
+ RegionCopy(&rrNewShape, wBoundingShape(pWin));
+ RegionTranslate(&rrNewShape, pWin->borderWidth, pWin->borderWidth);
+
+ nRects = RegionNumRects(&rrNewShape);
+ pShape = RegionRects(&rrNewShape);
+
+ /* Don't do anything if there are no rectangles in the region */
+ if (nRects > 0) {
+ RECT rcClient;
+ RECT rcWindow;
+ int iOffsetX, iOffsetY;
+
+ /* Get client rectangle */
+ if (!GetClientRect(pWinPriv->hWnd, &rcClient)) {
+ ErrorF("winReshape - GetClientRect failed, bailing: %d\n",
+ (int) GetLastError());
+ return;
+ }
+
+ /* Translate client rectangle coords to screen coords */
+ /* NOTE: Only transforms top and left members */
+ ClientToScreen(pWinPriv->hWnd, (LPPOINT) & rcClient);
+
+ /* Get window rectangle */
+ if (!GetWindowRect(pWinPriv->hWnd, &rcWindow)) {
+ ErrorF("winReshape - GetWindowRect failed, bailing: %d\n",
+ (int) GetLastError());
+ return;
+ }
+
+ /* Calculate offset from window upper-left to client upper-left */
+ iOffsetX = rcClient.left - rcWindow.left;
+ iOffsetY = rcClient.top - rcWindow.top;
+
+ /* Create initial Windows region for title bar */
+ /* FIXME: Mean, nasty, ugly hack!!! */
+ hRgn = CreateRectRgn(0, 0, rcWindow.right, iOffsetY);
+ if (hRgn == NULL) {
+ ErrorF("winReshape - Initial CreateRectRgn (%d, %d, %d, %d) "
+ "failed: %d\n",
+ 0, 0, (int) rcWindow.right, iOffsetY, (int) GetLastError());
+ }
+
+ /* Loop through all rectangles in the X region */
+ for (pRects = pShape, pEnd = pShape + nRects; pRects < pEnd; pRects++) {
+ /* Create a Windows region for the X rectangle */
+ hRgnRect = CreateRectRgn(pRects->x1 + iOffsetX,
+ pRects->y1 + iOffsetY,
+ pRects->x2 + iOffsetX,
+ pRects->y2 + iOffsetY);
+ if (hRgnRect == NULL) {
+ ErrorF("winReshape - Loop CreateRectRgn (%d, %d, %d, %d) "
+ "failed: %d\n"
+ "\tx1: %d x2: %d xOff: %d y1: %d y2: %d yOff: %d\n",
+ pRects->x1 + iOffsetX,
+ pRects->y1 + iOffsetY,
+ pRects->x2 + iOffsetX,
+ pRects->y2 + iOffsetY,
+ (int) GetLastError(),
+ pRects->x1, pRects->x2, iOffsetX,
+ pRects->y1, pRects->y2, iOffsetY);
+ }
+
+ /* Merge the Windows region with the accumulated region */
+ if (CombineRgn(hRgn, hRgn, hRgnRect, RGN_OR) == ERROR) {
+ ErrorF("winReshape - CombineRgn () failed: %d\n",
+ (int) GetLastError());
+ }
+
+ /* Delete the temporary Windows region */
+ DeleteObject(hRgnRect);
+ }
+
+ /* Save a handle to the composite region in the window privates */
+ pWinPriv->hRgn = hRgn;
+ }
+
+ RegionUninit(&rrNewShape);
+
+ return;
+}
+
+void
+winShapeRgnUpdateMultiwindow(HWND hwnd)
+{
+ WindowPtr pWin = GetProp (hwnd, WIN_WINDOW_PROP);
+ if (pWin)
+ {
+ winReshapeMultiWindow(pWin);
+ winUpdateRgnMultiWindow(pWin);
+ }
+}
diff --git a/xorg-server/hw/xwin/winmultiwindowwindow.c b/xorg-server/hw/xwin/winmultiwindowwindow.c
index 836587f74..3bdc2138d 100644
--- a/xorg-server/hw/xwin/winmultiwindowwindow.c
+++ b/xorg-server/hw/xwin/winmultiwindowwindow.c
@@ -44,45 +44,45 @@
*/
void
-winCreateWindowsWindow (WindowPtr pWin);
+ winCreateWindowsWindow(WindowPtr pWin);
static void
-winDestroyWindowsWindow (WindowPtr pWin);
+ winDestroyWindowsWindow(WindowPtr pWin);
static void
-winUpdateWindowsWindow (WindowPtr pWin);
+ winUpdateWindowsWindow(WindowPtr pWin);
static void
-winFindWindow (pointer value, XID id, pointer cdata);
+ winFindWindow(pointer value, XID id, pointer cdata);
static
-void winInitMultiWindowClass(void)
+ void
+winInitMultiWindowClass(void)
{
- static wATOM atomXWinClass=0;
- WNDCLASSEX wcx;
-
- if (atomXWinClass==0)
- {
- /* Setup our window class */
- wcx.cbSize=sizeof(WNDCLASSEX);
- wcx.style = CS_HREDRAW | CS_VREDRAW | (g_fNativeGl ? CS_OWNDC : 0);
- wcx.lpfnWndProc = winTopLevelWindowProc;
- wcx.cbClsExtra = 0;
- wcx.cbWndExtra = 0;
- wcx.hInstance = g_hInstance;
- wcx.hIcon = g_hIconX;
- wcx.hCursor = 0;
- wcx.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
- wcx.lpszMenuName = NULL;
- wcx.lpszClassName = WINDOW_CLASS_X;
- wcx.hIconSm = g_hSmallIconX;
+ static wATOM atomXWinClass = 0;
+ WNDCLASSEX wcx;
+
+ if (atomXWinClass == 0) {
+ /* Setup our window class */
+ wcx.cbSize = sizeof(WNDCLASSEX);
+ wcx.style = CS_HREDRAW | CS_VREDRAW | (g_fNativeGl ? CS_OWNDC : 0);
+ wcx.lpfnWndProc = winTopLevelWindowProc;
+ wcx.cbClsExtra = 0;
+ wcx.cbWndExtra = 0;
+ wcx.hInstance = g_hInstance;
+ wcx.hIcon = g_hIconX;
+ wcx.hCursor = 0;
+ wcx.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
+ wcx.lpszMenuName = NULL;
+ wcx.lpszClassName = WINDOW_CLASS_X;
+ wcx.hIconSm = g_hSmallIconX;
#if CYGMULTIWINDOW_DEBUG
winDebug ("winCreateWindowsWindow - Creating class: %s\n", WINDOW_CLASS_X);
#endif
- atomXWinClass = RegisterClassEx (&wcx);
- }
+ atomXWinClass = RegisterClassEx(&wcx);
+ }
}
/*
@@ -90,63 +90,63 @@ void winInitMultiWindowClass(void)
*/
Bool
-winCreateWindowMultiWindow (WindowPtr pWin)
+winCreateWindowMultiWindow(WindowPtr pWin)
{
- Bool fResult = TRUE;
- ScreenPtr pScreen = pWin->drawable.pScreen;
- winWindowPriv(pWin);
- winScreenPriv(pScreen);
+ Bool fResult = TRUE;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ winWindowPriv(pWin);
+ winScreenPriv(pScreen);
#if CYGMULTIWINDOW_DEBUG
winDebug ("winCreateWindowMultiWindow - pWin: %p\n", pWin);
#endif
-
- WIN_UNWRAP(CreateWindow);
- fResult = (*pScreen->CreateWindow) (pWin);
- WIN_WRAP(CreateWindow, winCreateWindowMultiWindow);
-
- /* Initialize some privates values */
- pWinPriv->hRgn = NULL;
- pWinPriv->hWnd = NULL;
- pWinPriv->pScreenPriv = winGetScreenPriv(pWin->drawable.pScreen);
- pWinPriv->fXKilled = FALSE;
+
+ WIN_UNWRAP(CreateWindow);
+ fResult = (*pScreen->CreateWindow) (pWin);
+ WIN_WRAP(CreateWindow, winCreateWindowMultiWindow);
+
+ /* Initialize some privates values */
+ pWinPriv->hRgn = NULL;
+ pWinPriv->hWnd = NULL;
+ pWinPriv->pScreenPriv = winGetScreenPriv(pWin->drawable.pScreen);
+ pWinPriv->fXKilled = FALSE;
#ifdef XWIN_GLX_WINDOWS
- pWinPriv->fWglUsed = FALSE;
+ pWinPriv->fWglUsed = FALSE;
#endif
- return fResult;
+ return fResult;
}
-
/*
* DestroyWindow - See Porting Layer Definition - p. 37
*/
Bool
-winDestroyWindowMultiWindow (WindowPtr pWin)
+winDestroyWindowMultiWindow(WindowPtr pWin)
{
- Bool fResult = TRUE;
- ScreenPtr pScreen = pWin->drawable.pScreen;
- winWindowPriv(pWin);
- winScreenPriv(pScreen);
+ Bool fResult = TRUE;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ winWindowPriv(pWin);
+ winScreenPriv(pScreen);
#if CYGMULTIWINDOW_DEBUG
winDebug ("winDestroyWindowMultiWindow - pWin: %p\n", pWin);
#endif
-
- WIN_UNWRAP(DestroyWindow);
- fResult = (*pScreen->DestroyWindow)(pWin);
- WIN_WRAP(DestroyWindow, winDestroyWindowMultiWindow);
-
- /* Flag that the window has been destroyed */
- pWinPriv->fXKilled = TRUE;
-
- /* Kill the MS Windows window associated with this window */
- winDestroyWindowsWindow (pWin);
- return fResult;
-}
+ WIN_UNWRAP(DestroyWindow);
+ fResult = (*pScreen->DestroyWindow) (pWin);
+ WIN_WRAP(DestroyWindow, winDestroyWindowMultiWindow);
+
+ /* Flag that the window has been destroyed */
+ pWinPriv->fXKilled = TRUE;
+ /* Kill the MS Windows window associated with this window */
+ winDestroyWindowsWindow(pWin);
+
+ return fResult;
+}
/*
* PositionWindow - See Porting Layer Definition - p. 37
@@ -157,98 +157,97 @@ winDestroyWindowMultiWindow (WindowPtr pWin)
*/
Bool
-winPositionWindowMultiWindow (WindowPtr pWin, int x, int y)
+winPositionWindowMultiWindow(WindowPtr pWin, int x, int y)
{
- Bool fResult = TRUE;
- int iX, iY, iWidth, iHeight;
- ScreenPtr pScreen = pWin->drawable.pScreen;
- winWindowPriv(pWin);
- winScreenPriv(pScreen);
-
- HWND hWnd = pWinPriv->hWnd;
- RECT rcNew;
- RECT rcOld;
+ Bool fResult = TRUE;
+ int iX, iY, iWidth, iHeight;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ winWindowPriv(pWin);
+ winScreenPriv(pScreen);
+
+ HWND hWnd = pWinPriv->hWnd;
+ RECT rcNew;
+ RECT rcOld;
#ifdef WINDBG
- RECT rcClient;
- RECT *lpRc;
+ RECT rcClient;
+ RECT *lpRc;
#endif
- DWORD dwExStyle;
- DWORD dwStyle;
+ DWORD dwExStyle;
+ DWORD dwStyle;
winDebug ("winPositionWindowMultiWindow - pWin: %p\n", pWin);
-
- WIN_UNWRAP(PositionWindow);
- fResult = (*pScreen->PositionWindow)(pWin, x, y);
- WIN_WRAP(PositionWindow, winPositionWindowMultiWindow);
-
- winDebug ("winPositionWindowMultiWindow: (x, y) = (%d, %d)\n",
- x, y);
- /* Bail out if the Windows window handle is bad */
- if (!hWnd)
- {
+ WIN_UNWRAP(PositionWindow);
+ fResult = (*pScreen->PositionWindow) (pWin, x, y);
+ WIN_WRAP(PositionWindow, winPositionWindowMultiWindow);
+
+ winDebug ("winPositionWindowMultiWindow: (x, y) = (%d, %d)\n",
+ x, y);
+
+ /* Bail out if the Windows window handle is bad */
+ if (!hWnd) {
winDebug ("\timmediately return since hWnd is NULL\n");
if (pWin->redirectDraw != RedirectDrawNone)
{
winDebug("winPositionWindowMultiWindow: Calling compReallocPixmap to make sure the pixmap buffer is valid.\n");
compReallocPixmap(pWin, x, y, pWin->drawable.width, pWin->drawable.height, pWin->borderWidth);
}
- return fResult;
+ return fResult;
}
- /* Get the Windows window style and extended style */
- dwExStyle = GetWindowLongPtr (hWnd, GWL_EXSTYLE);
- dwStyle = GetWindowLongPtr (hWnd, GWL_STYLE);
+ /* Get the Windows window style and extended style */
+ dwExStyle = GetWindowLongPtr(hWnd, GWL_EXSTYLE);
+ dwStyle = GetWindowLongPtr(hWnd, GWL_STYLE);
- /* Get the X and Y location of the X window */
- iX = pWin->drawable.x + GetSystemMetrics (SM_XVIRTUALSCREEN);
- iY = pWin->drawable.y + GetSystemMetrics (SM_YVIRTUALSCREEN);
+ /* Get the X and Y location of the X window */
+ iX = pWin->drawable.x + GetSystemMetrics(SM_XVIRTUALSCREEN);
+ iY = pWin->drawable.y + GetSystemMetrics(SM_YVIRTUALSCREEN);
- /* Get the height and width of the X window */
- iWidth = pWin->drawable.width;
- iHeight = pWin->drawable.height;
+ /* Get the height and width of the X window */
+ iWidth = pWin->drawable.width;
+ iHeight = pWin->drawable.height;
- /* Store the origin, height, and width in a rectangle structure */
- SetRect (&rcNew, iX, iY, iX + iWidth, iY + iHeight);
+ /* Store the origin, height, and width in a rectangle structure */
+ SetRect(&rcNew, iX, iY, iX + iWidth, iY + iHeight);
#if CYGMULTIWINDOW_DEBUG
- lpRc = &rcNew;
+ lpRc = &rcNew;
winDebug ("winPositionWindowMultiWindow - (%d ms)drawable (%d, %d)-(%d, %d)\n",
- GetTickCount (), lpRc->left, lpRc->top, lpRc->right, lpRc->bottom);
+ GetTickCount(), lpRc->left, lpRc->top, lpRc->right, lpRc->bottom);
#endif
- /*
- * Calculate the required size of the Windows window rectangle,
- * given the size of the Windows window client area.
- */
- AdjustWindowRectEx (&rcNew, dwStyle, FALSE, dwExStyle);
+ /*
+ * Calculate the required size of the Windows window rectangle,
+ * given the size of the Windows window client area.
+ */
+ AdjustWindowRectEx(&rcNew, dwStyle, FALSE, dwExStyle);
- /* Get a rectangle describing the old Windows window */
- GetWindowRect (hWnd, &rcOld);
+ /* Get a rectangle describing the old Windows window */
+ GetWindowRect(hWnd, &rcOld);
#if CYGMULTIWINDOW_DEBUG
- /* Get a rectangle describing the Windows window client area */
- GetClientRect (hWnd, &rcClient);
-
- lpRc = &rcNew;
- winDebug ("winPositionWindowMultiWindow - (%d ms)rcNew (%d, %d)-(%d, %d)\n",
- GetTickCount (), lpRc->left, lpRc->top, lpRc->right, lpRc->bottom);
-
- lpRc = &rcOld;
- winDebug ("winPositionWindowMultiWindow - (%d ms)rcOld (%d, %d)-(%d, %d)\n",
- GetTickCount (), lpRc->left, lpRc->top, lpRc->right, lpRc->bottom);
-
- lpRc = &rcClient;
- winDebug ("(%d ms)rcClient (%d, %d)-(%d, %d)\n",
- GetTickCount (), lpRc->left, lpRc->top, lpRc->right, lpRc->bottom);
+ /* Get a rectangle describing the Windows window client area */
+ GetClientRect(hWnd, &rcClient);
+
+ lpRc = &rcNew;
+ winDebug ("winPositionWindowMultiWindow - (%d ms)rcNew (%d, %d)-(%d, %d)\n",
+ GetTickCount(), lpRc->left, lpRc->top, lpRc->right, lpRc->bottom);
+
+ lpRc = &rcOld;
+ winDebug ("winPositionWindowMultiWindow - (%d ms)rcOld (%d, %d)-(%d, %d)\n",
+ GetTickCount(), lpRc->left, lpRc->top, lpRc->right, lpRc->bottom);
+
+ lpRc = &rcClient;
+ winDebug ("(%d ms)rcClient (%d, %d)-(%d, %d)\n",
+ GetTickCount(), lpRc->left, lpRc->top, lpRc->right, lpRc->bottom);
#endif
- /* Check if the old rectangle and new rectangle are the same */
- if (!EqualRect (&rcNew, &rcOld))
- {
+ /* Check if the old rectangle and new rectangle are the same */
+ if (!EqualRect(&rcNew, &rcOld)) {
winDebug ("winPositionWindowMultiWindow - Need to move\n");
winDebug ("\tMoveWindow to (%ld, %ld) - %ldx%ld\n", rcNew.left, rcNew.top,
- rcNew.right - rcNew.left, rcNew.bottom - rcNew.top);
+ rcNew.right - rcNew.left, rcNew.bottom - rcNew.top);
/* Change the position and dimensions of the Windows window */
if (pWinPriv->fWglUsed)
@@ -267,39 +266,37 @@ winPositionWindowMultiWindow (WindowPtr pWin, int x, int y)
rcNew.right - rcNew.left, rcNew.bottom - rcNew.top,
TRUE);
}
- else
- {
+ else {
winDebug ("winPositionWindowMultiWindow - Not need to move\n");
}
- return fResult;
+ return fResult;
}
-
/*
* ChangeWindowAttributes - See Porting Layer Definition - p. 37
*/
Bool
-winChangeWindowAttributesMultiWindow (WindowPtr pWin, unsigned long mask)
+winChangeWindowAttributesMultiWindow(WindowPtr pWin, unsigned long mask)
{
- Bool fResult = TRUE;
- ScreenPtr pScreen = pWin->drawable.pScreen;
- winScreenPriv(pScreen);
+ Bool fResult = TRUE;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
- winDebug ("winChangeWindowAttributesMultiWindow - pWin: %08x\n", pWin);
-
- WIN_UNWRAP(ChangeWindowAttributes);
- fResult = (*pScreen->ChangeWindowAttributes)(pWin, mask);
- WIN_WRAP(ChangeWindowAttributes, winChangeWindowAttributesMultiWindow);
-
- /*
- * NOTE: We do not currently need to do anything here.
- */
+ winScreenPriv(pScreen);
- return fResult;
-}
+ winDebug ("winChangeWindowAttributesMultiWindow - pWin: %08x\n", pWin);
+
+ WIN_UNWRAP(ChangeWindowAttributes);
+ fResult = (*pScreen->ChangeWindowAttributes) (pWin, mask);
+ WIN_WRAP(ChangeWindowAttributes, winChangeWindowAttributesMultiWindow);
+
+ /*
+ * NOTE: We do not currently need to do anything here.
+ */
+ return fResult;
+}
/*
* UnmapWindow - See Porting Layer Definition - p. 37
@@ -307,30 +304,30 @@ winChangeWindowAttributesMultiWindow (WindowPtr pWin, unsigned long mask)
*/
Bool
-winUnmapWindowMultiWindow (WindowPtr pWin)
+winUnmapWindowMultiWindow(WindowPtr pWin)
{
- Bool fResult = TRUE;
- ScreenPtr pScreen = pWin->drawable.pScreen;
- winWindowPriv(pWin);
- winScreenPriv(pScreen);
+ Bool fResult = TRUE;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ winWindowPriv(pWin);
+ winScreenPriv(pScreen);
#if CYGMULTIWINDOW_DEBUG
- winDebug ("winUnmapWindowMultiWindow - pWin: %08x\n", pWin);
+ winDebug ("winUnmapWindowMultiWindow - pWin: %08x\n", pWin);
#endif
-
- WIN_UNWRAP(UnrealizeWindow);
- fResult = (*pScreen->UnrealizeWindow)(pWin);
- WIN_WRAP(UnrealizeWindow, winUnmapWindowMultiWindow);
-
- /* Flag that the window has been killed */
- pWinPriv->fXKilled = TRUE;
-
- /* Destroy the Windows window associated with this X window */
- winDestroyWindowsWindow (pWin);
- return fResult;
-}
+ WIN_UNWRAP(UnrealizeWindow);
+ fResult = (*pScreen->UnrealizeWindow) (pWin);
+ WIN_WRAP(UnrealizeWindow, winUnmapWindowMultiWindow);
+
+ /* Flag that the window has been killed */
+ pWinPriv->fXKilled = TRUE;
+
+ /* Destroy the Windows window associated with this X window */
+ winDestroyWindowsWindow(pWin);
+ return fResult;
+}
/*
* MapWindow - See Porting Layer Definition - p. 37
@@ -338,116 +335,120 @@ winUnmapWindowMultiWindow (WindowPtr pWin)
*/
Bool
-winMapWindowMultiWindow (WindowPtr pWin)
+winMapWindowMultiWindow(WindowPtr pWin)
{
- Bool fResult = TRUE;
- ScreenPtr pScreen = pWin->drawable.pScreen;
- winWindowPriv(pWin);
- winScreenPriv(pScreen);
+ Bool fResult = TRUE;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ winWindowPriv(pWin);
+ winScreenPriv(pScreen);
#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMapWindowMultiWindow - pWin: %08x\n", pWin);
+ winDebug ("winMapWindowMultiWindow - pWin: %08x\n", pWin);
#endif
-
- WIN_UNWRAP(RealizeWindow);
- fResult = (*pScreen->RealizeWindow)(pWin);
- WIN_WRAP(RealizeWindow, winMapWindowMultiWindow);
-
- /* Flag that this window has not been destroyed */
- pWinPriv->fXKilled = FALSE;
- /* Refresh/redisplay the Windows window associated with this X window */
- winUpdateWindowsWindow (pWin);
+ WIN_UNWRAP(RealizeWindow);
+ fResult = (*pScreen->RealizeWindow) (pWin);
+ WIN_WRAP(RealizeWindow, winMapWindowMultiWindow);
- /* Update the Windows window's shape */
- winReshapeMultiWindow (pWin);
- winUpdateRgnMultiWindow (pWin);
+ /* Flag that this window has not been destroyed */
+ pWinPriv->fXKilled = FALSE;
- return fResult;
-}
+ /* Refresh/redisplay the Windows window associated with this X window */
+ winUpdateWindowsWindow(pWin);
+
+ /* Update the Windows window's shape */
+ winReshapeMultiWindow(pWin);
+ winUpdateRgnMultiWindow(pWin);
+ return fResult;
+}
/*
* ReparentWindow - See Porting Layer Definition - p. 42
*/
void
-winReparentWindowMultiWindow (WindowPtr pWin, WindowPtr pPriorParent)
+winReparentWindowMultiWindow(WindowPtr pWin, WindowPtr pPriorParent)
{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- winScreenPriv(pScreen);
+ ScreenPtr pScreen = pWin->drawable.pScreen;
- winDebug("winReparentMultiWindow - pWin:%08x XID:0x%x, reparent from pWin:%08x XID:0x%x to pWin:%08x XID:0x%x\n",
- pWin, pWin->drawable.id, pPriorParent, pPriorParent->drawable.id, pWin->parent, pWin->parent->drawable.id);
+ winScreenPriv(pScreen);
- WIN_UNWRAP(ReparentWindow);
- if (pScreen->ReparentWindow)
- (*pScreen->ReparentWindow)(pWin, pPriorParent);
- WIN_WRAP(ReparentWindow, winReparentWindowMultiWindow);
-
- /* Update the Windows window associated with this X window */
- winUpdateWindowsWindow (pWin);
-}
+ winDebug
+ ("winReparentMultiWindow - pWin:%08x XID:0x%x, reparent from pWin:%08x XID:0x%x to pWin:%08x XID:0x%x\n",
+ pWin, pWin->drawable.id, pPriorParent, pPriorParent->drawable.id,
+ pWin->parent, pWin->parent->drawable.id);
+
+ WIN_UNWRAP(ReparentWindow);
+ if (pScreen->ReparentWindow)
+ (*pScreen->ReparentWindow) (pWin, pPriorParent);
+ WIN_WRAP(ReparentWindow, winReparentWindowMultiWindow);
+ /* Update the Windows window associated with this X window */
+ winUpdateWindowsWindow(pWin);
+}
/*
* RestackWindow - Shuffle the z-order of a window
*/
void
-winRestackWindowMultiWindow (WindowPtr pWin, WindowPtr pOldNextSib)
+winRestackWindowMultiWindow(WindowPtr pWin, WindowPtr pOldNextSib)
{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- winScreenPriv(pScreen);
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ winScreenPriv(pScreen);
winDebug ("winRestackMultiWindow - %08x\n", pWin);
-
- WIN_UNWRAP(RestackWindow);
- if (pScreen->RestackWindow)
- (*pScreen->RestackWindow)(pWin, pOldNextSib);
- WIN_WRAP(RestackWindow, winRestackWindowMultiWindow);
-
- /*
- * Calling winReorderWindowsMultiWindow here means our window manager
- * (i.e. Windows Explorer) has initiative to determine Z order.
- */
- if (pWin->nextSib != pOldNextSib)
- winReorderWindowsMultiWindow ();
-}
+ WIN_UNWRAP(RestackWindow);
+ if (pScreen->RestackWindow)
+ (*pScreen->RestackWindow) (pWin, pOldNextSib);
+ WIN_WRAP(RestackWindow, winRestackWindowMultiWindow);
+
+ /*
+ * Calling winReorderWindowsMultiWindow here means our window manager
+ * (i.e. Windows Explorer) has initiative to determine Z order.
+ */
+ if (pWin->nextSib != pOldNextSib)
+ winReorderWindowsMultiWindow();
+}
/*
* winCreateWindowsWindow - Create a Windows window associated with an X window
*/
void
-winCreateWindowsWindow (WindowPtr pWin)
+winCreateWindowsWindow(WindowPtr pWin)
{
- int iX, iY;
- int iWidth;
- int iHeight;
- HWND hWnd;
- HWND hFore = NULL;
- winWindowPriv(pWin);
- HICON hIcon;
- HICON hIconSmall;
- winPrivScreenPtr pScreenPriv = pWinPriv->pScreenPriv;
- WinXSizeHints hints;
- WindowPtr pDaddy;
- DWORD dwStyle, dwExStyle;
- RECT rc;
-
- winInitMultiWindowClass();
-
- winDebug("winCreateWindowsTopLevelWindow - pWin:%08x XID:0x%x \n", pWin, pWin->drawable.id);
-
- iX = pWin->drawable.x + GetSystemMetrics (SM_XVIRTUALSCREEN);
- iY = pWin->drawable.y + GetSystemMetrics (SM_YVIRTUALSCREEN);
-
- iWidth = pWin->drawable.width;
- iHeight = pWin->drawable.height;
-
- /* If it's an InputOutput window, and so is going to end up being made visible,
+ int iX, iY;
+ int iWidth;
+ int iHeight;
+ HWND hWnd;
+ HWND hFore = NULL;
+
+ winWindowPriv(pWin);
+ HICON hIcon;
+ HICON hIconSmall;
+ winPrivScreenPtr pScreenPriv = pWinPriv->pScreenPriv;
+ WinXSizeHints hints;
+ WindowPtr pDaddy;
+ DWORD dwStyle, dwExStyle;
+ RECT rc;
+
+ winInitMultiWindowClass();
+
+ winDebug("winCreateWindowsTopLevelWindow - pWin:%08x XID:0x%x \n", pWin,
+ pWin->drawable.id);
+
+ iX = pWin->drawable.x + GetSystemMetrics(SM_XVIRTUALSCREEN);
+ iY = pWin->drawable.y + GetSystemMetrics(SM_YVIRTUALSCREEN);
+
+ iWidth = pWin->drawable.width;
+ iHeight = pWin->drawable.height;
+
+ /* If it's an InputOutput window, and so is going to end up being made visible,
make sure the window actually ends up somewhere where it will be visible
Dont't do it by making just one of the two iX and iY CW_USEDEFAULT since
this will create a window at place CW_USEDEFAULT which is 0x80000000 */
@@ -486,75 +487,77 @@ winCreateWindowsWindow (WindowPtr pWin)
}
}
- winDebug("winCreateWindowsWindow - %dx%d @ %dx%d\n", iWidth, iHeight, iX, iY);
+ winDebug("winCreateWindowsWindow - %dx%d @ %dx%d\n", iWidth, iHeight, iX,
+ iY);
- if (winMultiWindowGetTransientFor (pWin, &pDaddy))
- {
- if (pDaddy)
- {
- hFore = GetForegroundWindow();
- if (hFore && (pDaddy != (WindowPtr)GetProp(hFore, WIN_WID_PROP))) hFore = NULL;
- }
+ if (winMultiWindowGetTransientFor(pWin, &pDaddy)) {
+ if (pDaddy) {
+ hFore = GetForegroundWindow();
+ if (hFore && (pDaddy != (WindowPtr) GetProp(hFore, WIN_WID_PROP)))
+ hFore = NULL;
+ }
}
- else
- {
- /* Default positions if none specified */
- if (!winMultiWindowGetWMNormalHints(pWin, &hints))
- hints.flags = 0;
- if (!(hints.flags & (USPosition|PPosition)) &&
- !pWin->overrideRedirect)
- {
- iX = CW_USEDEFAULT;
- iY = CW_USEDEFAULT;
- }
+ else {
+ /* Default positions if none specified */
+ if (!winMultiWindowGetWMNormalHints(pWin, &hints))
+ hints.flags = 0;
+ if (!(hints.flags & (USPosition | PPosition)) &&
+ !pWin->overrideRedirect) {
+ iX = CW_USEDEFAULT;
+ iY = CW_USEDEFAULT;
+ }
}
- /* Make it WS_OVERLAPPED in create call since WS_POPUP doesn't support */
- /* CW_USEDEFAULT, change back to popup after creation */
- dwStyle = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
- dwExStyle = WS_EX_TOOLWINDOW;
-
- /*
- Calculate the window coordinates containing the requested client area,
- being careful to preseve CW_USEDEFAULT
- */
- rc.top = (iY != CW_USEDEFAULT) ? iY : 0;
- rc.left = (iX != CW_USEDEFAULT) ? iX : 0;
- rc.bottom = rc.top + iHeight;
- rc.right = rc.left + iWidth;
- AdjustWindowRectEx(&rc, dwStyle, FALSE, dwExStyle);
- if (iY != CW_USEDEFAULT) iY = rc.top;
- if (iX != CW_USEDEFAULT) iX = rc.left;
- iHeight = rc.bottom - rc.top;
- iWidth = rc.right - rc.left;
-
- winDebug("winCreateWindowsWindow - %dx%d @ %dx%d\n", iWidth, iHeight, iX, iY);
-
- /* Create the window */
- hWnd = CreateWindowExA (dwExStyle, /* Extended styles */
- WINDOW_CLASS_X, /* Class name */
- WINDOW_TITLE_X, /* Window name */
- dwStyle, /* Styles */
- iX, /* Horizontal position */
- iY, /* Vertical position */
- iWidth, /* Right edge */
- iHeight, /* Bottom edge */
- hFore, /* Null or Parent window if transient*/
- (HMENU) NULL, /* No menu */
- GetModuleHandle (NULL), /* Instance handle */
- pWin); /* ScreenPrivates */
- if (hWnd == NULL)
- {
- ErrorF ("winCreateWindowsWindow - CreateWindowExA () failed: %d\n",
- (int) GetLastError ());
+ /* Make it WS_OVERLAPPED in create call since WS_POPUP doesn't support */
+ /* CW_USEDEFAULT, change back to popup after creation */
+ dwStyle = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
+ dwExStyle = WS_EX_TOOLWINDOW;
+
+ /*
+ Calculate the window coordinates containing the requested client area,
+ being careful to preseve CW_USEDEFAULT
+ */
+ rc.top = (iY != CW_USEDEFAULT) ? iY : 0;
+ rc.left = (iX != CW_USEDEFAULT) ? iX : 0;
+ rc.bottom = rc.top + iHeight;
+ rc.right = rc.left + iWidth;
+ AdjustWindowRectEx(&rc, dwStyle, FALSE, dwExStyle);
+ if (iY != CW_USEDEFAULT)
+ iY = rc.top;
+ if (iX != CW_USEDEFAULT)
+ iX = rc.left;
+ iHeight = rc.bottom - rc.top;
+ iWidth = rc.right - rc.left;
+
+ winDebug("winCreateWindowsWindow - %dx%d @ %dx%d\n", iWidth, iHeight, iX,
+ iY);
+
+ /* Create the window */
+ hWnd = CreateWindowExA(dwExStyle, /* Extended styles */
+ WINDOW_CLASS_X, /* Class name */
+ WINDOW_TITLE_X, /* Window name */
+ dwStyle, /* Styles */
+ iX, /* Horizontal position */
+ iY, /* Vertical position */
+ iWidth, /* Right edge */
+ iHeight, /* Bottom edge */
+ hFore, /* Null or Parent window if transient */
+ (HMENU) NULL, /* No menu */
+ GetModuleHandle(NULL), /* Instance handle */
+ pWin); /* ScreenPrivates */
+ if (hWnd == NULL) {
+ ErrorF("winCreateWindowsWindow - CreateWindowExA () failed: %d\n",
+ (int) GetLastError());
}
- pWinPriv->hWnd = hWnd;
+ pWinPriv->hWnd = hWnd;
+
+ /* Set application or .XWinrc defined Icons */
+ winSelectIcons(pWin, &hIcon, &hIconSmall);
+ if (hIcon)
+ SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM) hIcon);
+ if (hIconSmall)
+ SendMessage(hWnd, WM_SETICON, ICON_SMALL, (LPARAM) hIconSmall);
- /* Set application or .XWinrc defined Icons */
- winSelectIcons(pWin, &hIcon, &hIconSmall);
- if (hIcon) SendMessage (hWnd, WM_SETICON, ICON_BIG, (LPARAM) hIcon);
- if (hIconSmall) SendMessage (hWnd, WM_SETICON, ICON_SMALL, (LPARAM) hIconSmall);
-
/* If we asked the native WM to place the window, synchronize the X window position.
Do this before the next SetWindowPos because this one is generating a WM_STYLECHANGED
message which is causing a window move, which is wrong if the Xwindow does not
@@ -564,119 +567,115 @@ winCreateWindowsWindow (WindowPtr pWin)
winAdjustXWindow(pWin, hWnd);
}
- /* Change style back to popup, already placed... */
- SetWindowLongPtr(hWnd, GWL_STYLE, WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
- SetWindowPos (hWnd, 0, 0, 0, 0, 0,
- SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
+ /* Change style back to popup, already placed... */
+ SetWindowLongPtr(hWnd, GWL_STYLE,
+ WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
+ SetWindowPos(hWnd, 0, 0, 0, 0, 0,
+ SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE |
+ SWP_NOACTIVATE);
- /* Make sure it gets the proper system menu for a WS_POPUP, too */
- GetSystemMenu (hWnd, TRUE);
+ /* Make sure it gets the proper system menu for a WS_POPUP, too */
+ GetSystemMenu(hWnd, TRUE);
- /* Cause any .XWinrc menus to be added in main WNDPROC */
- PostMessage (hWnd, WM_INIT_SYS_MENU, 0, 0);
-
- SetProp (hWnd, WIN_WID_PROP, (HANDLE) winGetWindowID(pWin));
+ /* Cause any .XWinrc menus to be added in main WNDPROC */
+ PostMessage(hWnd, WM_INIT_SYS_MENU, 0, 0);
- /* Flag that this Windows window handles its own activation */
- SetProp (hWnd, WIN_NEEDMANAGE_PROP, (HANDLE) 0);
+ SetProp(hWnd, WIN_WID_PROP, (HANDLE) winGetWindowID(pWin));
- /* Call engine-specific create window procedure */
- (*pScreenPriv->pwinFinishCreateWindowsWindow) (pWin);
-}
+ /* Flag that this Windows window handles its own activation */
+ SetProp(hWnd, WIN_NEEDMANAGE_PROP, (HANDLE) 0);
+ /* Call engine-specific create window procedure */
+ (*pScreenPriv->pwinFinishCreateWindowsWindow) (pWin);
+}
Bool winInDestroyWindowsWindow = FALSE;
+
/*
* winDestroyWindowsWindow - Destroy a Windows window associated
* with an X window
*/
static void
-winDestroyWindowsWindow (WindowPtr pWin)
+winDestroyWindowsWindow(WindowPtr pWin)
{
- MSG msg;
- winWindowPriv(pWin);
- BOOL oldstate = winInDestroyWindowsWindow;
- HICON hIcon;
- HICON hIconSm;
+ MSG msg;
- winDebug("winDestroyWindowsWindow - pWin:%08x XID:0x%x \n", pWin, pWin->drawable.id);
+ winWindowPriv(pWin);
+ BOOL oldstate = winInDestroyWindowsWindow;
+ HICON hIcon;
+ HICON hIconSm;
- /* Bail out if the Windows window handle is invalid */
- if (pWinPriv->hWnd == NULL)
- return;
+ winDebug("winDestroyWindowsWindow - pWin:%08x XID:0x%x \n", pWin,
+ pWin->drawable.id);
- winInDestroyWindowsWindow = TRUE;
+ /* Bail out if the Windows window handle is invalid */
+ if (pWinPriv->hWnd == NULL)
+ return;
- /* Store the info we need to destroy after this window is gone */
- hIcon = (HICON)SendMessage(pWinPriv->hWnd, WM_GETICON, ICON_BIG, 0);
- hIconSm = (HICON)SendMessage(pWinPriv->hWnd, WM_GETICON, ICON_SMALL, 0);
+ winInDestroyWindowsWindow = TRUE;
- /* Destroy the Windows window */
- DestroyWindow (pWinPriv->hWnd);
+ /* Store the info we need to destroy after this window is gone */
+ hIcon = (HICON) SendMessage(pWinPriv->hWnd, WM_GETICON, ICON_BIG, 0);
+ hIconSm = (HICON) SendMessage(pWinPriv->hWnd, WM_GETICON, ICON_SMALL, 0);
- /* Null our handle to the Window so referencing it will cause an error */
- pWinPriv->hWnd = NULL;
+ /* Destroy the Windows window */
+ DestroyWindow(pWinPriv->hWnd);
- /* Destroy any icons we created for this window */
- winDestroyIcon(hIcon);
- winDestroyIcon(hIconSm);
+ /* Null our handle to the Window so referencing it will cause an error */
+ pWinPriv->hWnd = NULL;
+
+ /* Destroy any icons we created for this window */
+ winDestroyIcon(hIcon);
+ winDestroyIcon(hIconSm);
#ifdef XWIN_GLX_WINDOWS
- /* No longer note WGL used on this window */
- pWinPriv->fWglUsed = FALSE;
+ /* No longer note WGL used on this window */
+ pWinPriv->fWglUsed = FALSE;
#endif
- /* Process all messages on our queue */
- while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
- {
- if (g_hDlgDepthChange == 0 || !IsDialogMessage (g_hDlgDepthChange, &msg))
- {
- DispatchMessage (&msg);
- }
+ /* Process all messages on our queue */
+ while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
+ if (g_hDlgDepthChange == 0 || !IsDialogMessage(g_hDlgDepthChange, &msg)) {
+ DispatchMessage(&msg);
+ }
}
- winInDestroyWindowsWindow = oldstate;
+ winInDestroyWindowsWindow = oldstate;
- winDebug("winDestroyWindowsWindow - done\n");
+ winDebug("winDestroyWindowsWindow - done\n");
}
-
/*
* winUpdateWindowsWindow - Redisplay/redraw a Windows window
* associated with an X window
*/
static void
-winUpdateWindowsWindow (WindowPtr pWin)
+winUpdateWindowsWindow(WindowPtr pWin)
{
- winWindowPriv(pWin);
- HWND hWnd = pWinPriv->hWnd;
+ winWindowPriv(pWin);
+ HWND hWnd = pWinPriv->hWnd;
#if CYGMULTIWINDOW_DEBUG
- winDebug ("winUpdateWindowsWindow\n");
+ winDebug ("winUpdateWindowsWindow\n");
#endif
- /* Check if the Windows window's parents have been destroyed */
- if (pWin->parent != NULL
- && pWin->parent->parent == NULL
- && pWin->mapped)
- {
- /* Create the Windows window if it has been destroyed */
- if (hWnd == NULL)
- {
- winCreateWindowsWindow (pWin);
- assert (pWinPriv->hWnd != NULL);
- }
-
- /* Display the window without activating it */
- if (pWin->drawable.class != InputOnly)
- ShowWindow (pWinPriv->hWnd, SW_SHOWNOACTIVATE);
-
- /* Send first paint message */
- UpdateWindow (pWinPriv->hWnd);
+ /* Check if the Windows window's parents have been destroyed */
+ if (pWin->parent != NULL && pWin->parent->parent == NULL && pWin->mapped) {
+ /* Create the Windows window if it has been destroyed */
+ if (hWnd == NULL) {
+ winCreateWindowsWindow(pWin);
+ assert(pWinPriv->hWnd != NULL);
+ }
+
+ /* Display the window without activating it */
+ if (pWin->drawable.class != InputOnly)
+ ShowWindow(pWinPriv->hWnd, SW_SHOWNOACTIVATE);
+
+ /* Send first paint message */
+ UpdateWindow(pWinPriv->hWnd);
}
- else if (hWnd != NULL)
- {
+ else if (hWnd != NULL) {
if (pWinPriv->fWglUsed)
{
/* We do not need to destroy the window but to reparent it and move it to the
@@ -723,209 +722,199 @@ winUpdateWindowsWindow (WindowPtr pWin)
#endif
}
-
/*
* winGetWindowID -
*/
XID
-winGetWindowID (WindowPtr pWin)
+winGetWindowID(WindowPtr pWin)
{
- WindowIDPairRec wi = {pWin, 0};
- ClientPtr c = wClient(pWin);
-
- /* */
- FindClientResourcesByType (c, RT_WINDOW, winFindWindow, &wi);
+ WindowIDPairRec wi = { pWin, 0 };
+ ClientPtr c = wClient(pWin);
+
+ /* */
+ FindClientResourcesByType(c, RT_WINDOW, winFindWindow, &wi);
#if CYGMULTIWINDOW_DEBUG
winDebug ("winGetWindowID - Window ID: %d\n", wi.id);
#endif
- return wi.id;
+ return wi.id;
}
-
/*
* winFindWindow -
*/
static void
-winFindWindow (pointer value, XID id, pointer cdata)
+winFindWindow(pointer value, XID id, pointer cdata)
{
- WindowIDPairPtr wi = (WindowIDPairPtr)cdata;
+ WindowIDPairPtr wi = (WindowIDPairPtr) cdata;
- if (value == wi->value)
- {
- wi->id = id;
+ if (value == wi->value) {
+ wi->id = id;
}
}
-
/*
* winReorderWindowsMultiWindow -
*/
void
-winReorderWindowsMultiWindow (void)
+winReorderWindowsMultiWindow(void)
{
- HWND hwnd = NULL;
- WindowPtr pWin = NULL;
- WindowPtr pWinSib = NULL;
- XID vlist[2];
- static Bool fRestacking = FALSE; /* Avoid recusive calls to this function */
- DWORD dwCurrentProcessID = GetCurrentProcessId ();
- DWORD dwWindowProcessID = 0;
-
- winDebug ("winReorderWindowsMultiWindow\n");
-
- if (fRestacking)
- {
- /* It is a recusive call so immediately exit */
+ HWND hwnd = NULL;
+ WindowPtr pWin = NULL;
+ WindowPtr pWinSib = NULL;
+ XID vlist[2];
+ static Bool fRestacking = FALSE; /* Avoid recusive calls to this function */
+ DWORD dwCurrentProcessID = GetCurrentProcessId();
+ DWORD dwWindowProcessID = 0;
+
+ winDebug ("winReorderWindowsMultiWindow\n");
+
+ if (fRestacking) {
+ /* It is a recusive call so immediately exit */
winDebug ("winReorderWindowsMultiWindow - "
- "exit because fRestacking == TRUE\n");
- return;
+ "exit because fRestacking == TRUE\n");
+ return;
}
- fRestacking = TRUE;
-
- /* Loop through top level Window windows, descending in Z order */
- for ( hwnd = GetTopWindow (NULL);
- hwnd;
- hwnd = GetNextWindow (hwnd, GW_HWNDNEXT) )
- {
- /* Don't take care of other Cygwin/X process's windows */
- GetWindowThreadProcessId (hwnd, &dwWindowProcessID);
-
- if ( GetProp (hwnd, WIN_WINDOW_PROP)
- && (dwWindowProcessID == dwCurrentProcessID)
- && !IsIconic (hwnd) ) /* ignore minimized windows */
- {
- pWinSib = pWin;
- pWin = GetProp (hwnd, WIN_WINDOW_PROP);
-
- if (!pWinSib)
- { /* 1st window - raise to the top */
- vlist[0] = Above;
-
- ConfigureWindow (pWin, CWStackMode, vlist, wClient(pWin));
- }
- else
- { /* 2nd or deeper windows - just below the previous one */
- vlist[0] = winGetWindowID (pWinSib);
- vlist[1] = Below;
-
- ConfigureWindow (pWin, CWSibling | CWStackMode,
- vlist, wClient(pWin));
- }
- }
+ fRestacking = TRUE;
+
+ /* Loop through top level Window windows, descending in Z order */
+ for (hwnd = GetTopWindow(NULL);
+ hwnd; hwnd = GetNextWindow(hwnd, GW_HWNDNEXT)) {
+ /* Don't take care of other Cygwin/X process's windows */
+ GetWindowThreadProcessId(hwnd, &dwWindowProcessID);
+
+ if (GetProp(hwnd, WIN_WINDOW_PROP)
+ && (dwWindowProcessID == dwCurrentProcessID)
+ && !IsIconic(hwnd)) { /* ignore minimized windows */
+ pWinSib = pWin;
+ pWin = GetProp(hwnd, WIN_WINDOW_PROP);
+
+ if (!pWinSib) { /* 1st window - raise to the top */
+ vlist[0] = Above;
+
+ ConfigureWindow(pWin, CWStackMode, vlist, wClient(pWin));
+ }
+ else { /* 2nd or deeper windows - just below the previous one */
+ vlist[0] = winGetWindowID(pWinSib);
+ vlist[1] = Below;
+
+ ConfigureWindow(pWin, CWSibling | CWStackMode,
+ vlist, wClient(pWin));
+ }
+ }
}
- fRestacking = FALSE;
+ fRestacking = FALSE;
}
-
/*
* winMinimizeWindow - Minimize in response to WM_CHANGE_STATE
*/
void
-winMinimizeWindow (Window id)
+winMinimizeWindow(Window id)
{
- WindowPtr pWin;
- winPrivWinPtr pWinPriv;
+ WindowPtr pWin;
+ winPrivWinPtr pWinPriv;
+
#ifdef XWIN_MULTIWINDOWEXTWM
- win32RootlessWindowPtr pRLWinPriv;
+ win32RootlessWindowPtr pRLWinPriv;
#endif
- HWND hWnd;
- ScreenPtr pScreen = NULL;
- winPrivScreenPtr pScreenPriv = NULL;
- winScreenInfo *pScreenInfo = NULL;
-
- winDebug ("winMinimizeWindow\n");
-
- dixLookupResourceByType((pointer) &pWin, id, RT_WINDOW, NullClient, DixUnknownAccess);
- if (!pWin)
- {
- ErrorF("%s: NULL pWin. Leaving\n", __FUNCTION__);
- return;
- }
+ HWND hWnd;
+ ScreenPtr pScreen = NULL;
+ winPrivScreenPtr pScreenPriv = NULL;
+ winScreenInfo *pScreenInfo = NULL;
+
+ winDebug ("winMinimizeWindow\n");
+
+ dixLookupResourceByType((pointer) &pWin, id, RT_WINDOW, NullClient,
+ DixUnknownAccess);
+ if (!pWin) {
+ ErrorF("%s: NULL pWin. Leaving\n", __FUNCTION__);
+ return;
+ }
- pScreen = pWin->drawable.pScreen;
- if (pScreen) pScreenPriv = winGetScreenPriv(pScreen);
- if (pScreenPriv) pScreenInfo = pScreenPriv->pScreenInfo;
+ pScreen = pWin->drawable.pScreen;
+ if (pScreen)
+ pScreenPriv = winGetScreenPriv(pScreen);
+ if (pScreenPriv)
+ pScreenInfo = pScreenPriv->pScreenInfo;
#ifdef XWIN_MULTIWINDOWINTWM
- if (pScreenPriv && pScreenInfo->fInternalWM)
- {
- pRLWinPriv = (win32RootlessWindowPtr) RootlessFrameForWindow (pWin, FALSE);
- hWnd = pRLWinPriv->hWnd;
+ if (pScreenPriv && pScreenInfo->fInternalWM) {
+ pRLWinPriv =
+ (win32RootlessWindowPtr) RootlessFrameForWindow(pWin, FALSE);
+ hWnd = pRLWinPriv->hWnd;
}
- else
+ else
#else
- if (pScreenPriv)
+ if (pScreenPriv)
#endif
{
- pWinPriv = winGetWindowPriv (pWin);
- hWnd = pWinPriv->hWnd;
+ pWinPriv = winGetWindowPriv(pWin);
+ hWnd = pWinPriv->hWnd;
}
- ShowWindow (hWnd, SW_MINIMIZE);
+ ShowWindow(hWnd, SW_MINIMIZE);
}
-
/*
* CopyWindow - See Porting Layer Definition - p. 39
*/
void
-winCopyWindowMultiWindow (WindowPtr pWin, DDXPointRec oldpt,
- RegionPtr oldRegion)
+winCopyWindowMultiWindow(WindowPtr pWin, DDXPointRec oldpt, RegionPtr oldRegion)
{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- winScreenPriv(pScreen);
+ ScreenPtr pScreen = pWin->drawable.pScreen;
- winDebug ("CopyWindowMultiWindow\n");
+ winScreenPriv(pScreen);
- WIN_UNWRAP(CopyWindow);
- (*pScreen->CopyWindow)(pWin, oldpt, oldRegion);
- WIN_WRAP(CopyWindow, winCopyWindowMultiWindow);
-}
+ winDebug ("CopyWindowMultiWindow\n");
+ WIN_UNWRAP(CopyWindow);
+ (*pScreen->CopyWindow) (pWin, oldpt, oldRegion);
+ WIN_WRAP(CopyWindow, winCopyWindowMultiWindow);
+}
/*
* MoveWindow - See Porting Layer Definition - p. 42
*/
void
-winMoveWindowMultiWindow (WindowPtr pWin, int x, int y,
- WindowPtr pSib, VTKind kind)
+winMoveWindowMultiWindow(WindowPtr pWin, int x, int y,
+ WindowPtr pSib, VTKind kind)
{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- winScreenPriv(pScreen);
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ winScreenPriv(pScreen);
winDebug ("MoveWindowMultiWindow to (%d, %d)\n", x, y);
- WIN_UNWRAP(MoveWindow);
- (*pScreen->MoveWindow)(pWin, x, y, pSib, kind);
- WIN_WRAP(MoveWindow, winMoveWindowMultiWindow);
+ WIN_UNWRAP(MoveWindow);
+ (*pScreen->MoveWindow) (pWin, x, y, pSib, kind);
+ WIN_WRAP(MoveWindow, winMoveWindowMultiWindow);
}
-
/*
* ResizeWindow - See Porting Layer Definition - p. 42
*/
void
-winResizeWindowMultiWindow (WindowPtr pWin, int x, int y, unsigned int w,
- unsigned int h, WindowPtr pSib)
+winResizeWindowMultiWindow(WindowPtr pWin, int x, int y, unsigned int w,
+ unsigned int h, WindowPtr pSib)
{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- winScreenPriv(pScreen);
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ winScreenPriv(pScreen);
winDebug ("ResizeWindowMultiWindow to (%d, %d) - %dx%d\n", x, y, w, h);
- WIN_UNWRAP(ResizeWindow);
- (*pScreen->ResizeWindow)(pWin, x, y, w, h, pSib);
- WIN_WRAP(ResizeWindow, winResizeWindowMultiWindow);
+ WIN_UNWRAP(ResizeWindow);
+ (*pScreen->ResizeWindow) (pWin, x, y, w, h, pSib);
+ WIN_WRAP(ResizeWindow, winResizeWindowMultiWindow);
}
-
/*
* winAdjustXWindow
*
@@ -937,83 +926,81 @@ winResizeWindowMultiWindow (WindowPtr pWin, int x, int y, unsigned int w,
* adjusts Windows window with respect to X window.
*/
int
-winAdjustXWindow (WindowPtr pWin, HWND hwnd)
+winAdjustXWindow(WindowPtr pWin, HWND hwnd)
{
- RECT rcDraw; /* Rect made from pWin->drawable to be adjusted */
- RECT rcWin; /* The source: WindowRect from hwnd */
- DrawablePtr pDraw;
- XID vlist[4];
- LONG dX, dY, dW, dH, x, y;
- DWORD dwStyle, dwExStyle;
+ RECT rcDraw; /* Rect made from pWin->drawable to be adjusted */
+ RECT rcWin; /* The source: WindowRect from hwnd */
+ DrawablePtr pDraw;
+ XID vlist[4];
+ LONG dX, dY, dW, dH, x, y;
+ DWORD dwStyle, dwExStyle;
#define WIDTH(rc) (rc.right - rc.left)
#define HEIGHT(rc) (rc.bottom - rc.top)
-
- winDebug ("winAdjustXWindow\n");
- if (IsIconic (hwnd))
- {
+ winDebug ("winAdjustXWindow\n");
+
+ if (IsIconic(hwnd)) {
winDebug ("\timmediately return because the window is iconized\n");
- /*
- * If the Windows window is minimized, its WindowRect has
- * meaningless values so we don't adjust X window to it.
- */
- vlist[0] = 0;
- vlist[1] = 0;
- return ConfigureWindow (pWin, CWX | CWY, vlist, wClient(pWin));
+ /*
+ * If the Windows window is minimized, its WindowRect has
+ * meaningless values so we don't adjust X window to it.
+ */
+ vlist[0] = 0;
+ vlist[1] = 0;
+ return ConfigureWindow(pWin, CWX | CWY, vlist, wClient(pWin));
}
-
- pDraw = &pWin->drawable;
-
- /* Calculate the window rect from the drawable */
- x = pDraw->x + GetSystemMetrics (SM_XVIRTUALSCREEN);
- y = pDraw->y + GetSystemMetrics (SM_YVIRTUALSCREEN);
- SetRect (&rcDraw, x, y, x + pDraw->width, y + pDraw->height);
- winDebug("\tDrawable extend {%d, %d, %d, %d}, {%d, %d}\n",
- rcDraw.left, rcDraw.top, rcDraw.right, rcDraw.bottom,
- rcDraw.right - rcDraw.left, rcDraw.bottom - rcDraw.top);
- dwExStyle = GetWindowLongPtr (hwnd, GWL_EXSTYLE);
- dwStyle = GetWindowLongPtr (hwnd, GWL_STYLE);
- winDebug("\tWindowStyle: %08x %08x\n", dwStyle, dwExStyle);
- AdjustWindowRectEx (&rcDraw, dwStyle, FALSE, dwExStyle);
-
- /* The source of adjust */
- GetWindowRect (hwnd, &rcWin);
- winDebug("\tWindow extend {%d, %d, %d, %d}, {%d, %d}\n",
- rcWin.left, rcWin.top, rcWin.right, rcWin.bottom,
- rcWin.right - rcWin.left, rcWin.bottom - rcWin.top);
- winDebug("\tDraw extend {%d, %d, %d, %d}, {%d, %d}\n",
- rcDraw.left, rcDraw.top, rcDraw.right, rcDraw.bottom,
- rcDraw.right - rcDraw.left, rcDraw.bottom - rcDraw.top);
-
- if (EqualRect (&rcDraw, &rcWin)) {
- /* Bail if no adjust is needed */
+
+ pDraw = &pWin->drawable;
+
+ /* Calculate the window rect from the drawable */
+ x = pDraw->x + GetSystemMetrics(SM_XVIRTUALSCREEN);
+ y = pDraw->y + GetSystemMetrics(SM_YVIRTUALSCREEN);
+ SetRect(&rcDraw, x, y, x + pDraw->width, y + pDraw->height);
+ winDebug("\tDrawable extend {%d, %d, %d, %d}, {%d, %d}\n",
+ rcDraw.left, rcDraw.top, rcDraw.right, rcDraw.bottom,
+ rcDraw.right - rcDraw.left, rcDraw.bottom - rcDraw.top);
+ dwExStyle = GetWindowLongPtr(hwnd, GWL_EXSTYLE);
+ dwStyle = GetWindowLongPtr(hwnd, GWL_STYLE);
+ winDebug("\tWindowStyle: %08x %08x\n", dwStyle, dwExStyle);
+ AdjustWindowRectEx(&rcDraw, dwStyle, FALSE, dwExStyle);
+
+ /* The source of adjust */
+ GetWindowRect(hwnd, &rcWin);
+ winDebug("\tWindow extend {%d, %d, %d, %d}, {%d, %d}\n",
+ rcWin.left, rcWin.top, rcWin.right, rcWin.bottom,
+ rcWin.right - rcWin.left, rcWin.bottom - rcWin.top);
+ winDebug("\tDraw extend {%d, %d, %d, %d}, {%d, %d}\n",
+ rcDraw.left, rcDraw.top, rcDraw.right, rcDraw.bottom,
+ rcDraw.right - rcDraw.left, rcDraw.bottom - rcDraw.top);
+
+ if (EqualRect(&rcDraw, &rcWin)) {
+ /* Bail if no adjust is needed */
winDebug ("\treturn because already adjusted\n");
- return 0;
- }
-
- /* Calculate delta values */
- dX = rcWin.left - rcDraw.left;
- dY = rcWin.top - rcDraw.top;
- dW = WIDTH(rcWin) - WIDTH(rcDraw);
- dH = HEIGHT(rcWin) - HEIGHT(rcDraw);
-
- /*
- * Adjust.
- * We may only need to move (vlist[0] and [1]), or only resize
- * ([2] and [3]) but currently we set all the parameters and leave
- * the decision to ConfigureWindow. The reason is code simplicity.
- */
- vlist[0] = pDraw->x + dX - wBorderWidth(pWin);
- vlist[1] = pDraw->y + dY - wBorderWidth(pWin);
- vlist[2] = pDraw->width + dW;
- vlist[3] = pDraw->height + dH;
- winDebug ("\tConfigureWindow to (%ld, %ld) - %ldx%ld\n", vlist[0], vlist[1],
- vlist[2], vlist[3]);
- return ConfigureWindow (pWin, CWX | CWY | CWWidth | CWHeight,
- vlist, wClient(pWin));
-
+ return 0;
+ }
+
+ /* Calculate delta values */
+ dX = rcWin.left - rcDraw.left;
+ dY = rcWin.top - rcDraw.top;
+ dW = WIDTH(rcWin) - WIDTH(rcDraw);
+ dH = HEIGHT(rcWin) - HEIGHT(rcDraw);
+
+ /*
+ * Adjust.
+ * We may only need to move (vlist[0] and [1]), or only resize
+ * ([2] and [3]) but currently we set all the parameters and leave
+ * the decision to ConfigureWindow. The reason is code simplicity.
+ */
+ vlist[0] = pDraw->x + dX - wBorderWidth(pWin);
+ vlist[1] = pDraw->y + dY - wBorderWidth(pWin);
+ vlist[2] = pDraw->width + dW;
+ vlist[3] = pDraw->height + dH;
+ winDebug ("\tConfigureWindow to (%ld, %ld) - %ldx%ld\n", vlist[0], vlist[1],
+ vlist[2], vlist[3]);
+ return ConfigureWindow(pWin, CWX | CWY | CWWidth | CWHeight,
+ vlist, wClient(pWin));
+
#undef WIDTH
#undef HEIGHT
}
-
diff --git a/xorg-server/hw/xwin/winmultiwindowwm.c b/xorg-server/hw/xwin/winmultiwindowwm.c
index 5a8a38ac4..c93d3efe9 100644
--- a/xorg-server/hw/xwin/winmultiwindowwm.c
+++ b/xorg-server/hw/xwin/winmultiwindowwm.c
@@ -90,7 +90,7 @@ extern void winUpdateRgnMultiWindow(WindowPtr pWin);
#define WIN_CONNECT_RETRIES 5
#define WIN_CONNECT_DELAY 5
#ifdef HAS_DEVWINDOWS
-# define WIN_MSG_QUEUE_FNAME "/dev/windows"
+#define WIN_MSG_QUEUE_FNAME "/dev/windows"
#endif
#define WIN_JMP_OKAY 0
#define WIN_JMP_ERROR_IO 2
@@ -100,124 +100,122 @@ extern void winUpdateRgnMultiWindow(WindowPtr pWin);
*/
typedef struct _WMMsgNodeRec {
- winWMMessageRec msg;
- struct _WMMsgNodeRec *pNext;
+ winWMMessageRec msg;
+ struct _WMMsgNodeRec *pNext;
} WMMsgNodeRec, *WMMsgNodePtr;
typedef struct _WMMsgQueueRec {
- struct _WMMsgNodeRec *pHead;
- struct _WMMsgNodeRec *pTail;
- pthread_mutex_t pmMutex;
- pthread_cond_t pcNotEmpty;
+ struct _WMMsgNodeRec *pHead;
+ struct _WMMsgNodeRec *pTail;
+ pthread_mutex_t pmMutex;
+ pthread_cond_t pcNotEmpty;
#ifdef _DEBUG
- int nQueueSize;
+ int nQueueSize;
#endif
} WMMsgQueueRec, *WMMsgQueuePtr;
typedef struct _WMInfo {
- Display *pDisplay;
- WMMsgQueueRec wmMsgQueue;
- Atom atmWmProtos;
- Atom atmWmDelete;
- Atom atmPrivMap;
+ Display *pDisplay;
+ WMMsgQueueRec wmMsgQueue;
+ Atom atmWmProtos;
+ Atom atmWmDelete;
+ Atom atmPrivMap;
#ifdef XWIN_MULTIWINDOWINTWM
- Bool fAllowOtherWM;
+ Bool fAllowOtherWM;
#endif
} WMInfoRec, *WMInfoPtr;
typedef struct _WMProcArgRec {
- DWORD dwScreen;
- WMInfoPtr pWMInfo;
- pthread_mutex_t *ppmServerStarted;
+ DWORD dwScreen;
+ WMInfoPtr pWMInfo;
+ pthread_mutex_t *ppmServerStarted;
} WMProcArgRec, *WMProcArgPtr;
typedef struct _XMsgProcArgRec {
- Display *pDisplay;
- DWORD dwScreen;
- WMInfoPtr pWMInfo;
- pthread_mutex_t *ppmServerStarted;
- HWND hwndScreen;
+ Display *pDisplay;
+ DWORD dwScreen;
+ WMInfoPtr pWMInfo;
+ pthread_mutex_t *ppmServerStarted;
+ HWND hwndScreen;
} XMsgProcArgRec, *XMsgProcArgPtr;
-
/*
* References to external symbols
*/
extern char *display;
-extern void ErrorF (const char* /*f*/, ...);
+extern void ErrorF(const char * /*f */ , ...);
/*
* Prototypes for local functions
*/
static void
-PushMessage (WMMsgQueuePtr pQueue, WMMsgNodePtr pNode);
+ PushMessage(WMMsgQueuePtr pQueue, WMMsgNodePtr pNode);
-static WMMsgNodePtr
-PopMessage (WMMsgQueuePtr pQueue, WMInfoPtr pWMInfo);
+static WMMsgNodePtr PopMessage(WMMsgQueuePtr pQueue, WMInfoPtr pWMInfo);
static Bool
-InitQueue (WMMsgQueuePtr pQueue);
+ InitQueue(WMMsgQueuePtr pQueue);
static void
-GetWindowName (Display * pDpy, Window iWin, wchar_t **ppName);
+ GetWindowName(Display * pDpy, Window iWin, wchar_t ** ppName);
static int
-SendXMessage (Display *pDisplay, Window iWin, Atom atmType, long nData);
+ SendXMessage(Display * pDisplay, Window iWin, Atom atmType, long nData);
static void
-UpdateName (WMInfoPtr pWMInfo, Window iWindow);
+ UpdateName(WMInfoPtr pWMInfo, Window iWindow);
-static void*
-winMultiWindowWMProc (void* pArg);
+static void *winMultiWindowWMProc(void *pArg);
static int
-winMultiWindowWMErrorHandler (Display *pDisplay, XErrorEvent *pErr);
+ winMultiWindowWMErrorHandler(Display * pDisplay, XErrorEvent * pErr);
static int
-winMultiWindowWMIOErrorHandler (Display *pDisplay);
+ winMultiWindowWMIOErrorHandler(Display * pDisplay);
-static void *
-winMultiWindowXMsgProc (void *pArg);
+static void *winMultiWindowXMsgProc(void *pArg);
static int
-winMultiWindowXMsgProcErrorHandler (Display *pDisplay, XErrorEvent *pErr);
+ winMultiWindowXMsgProcErrorHandler(Display * pDisplay, XErrorEvent * pErr);
static int
-winMultiWindowXMsgProcIOErrorHandler (Display *pDisplay);
+ winMultiWindowXMsgProcIOErrorHandler(Display * pDisplay);
static void
winMultiWindowThreadExit(void *arg);
static int
-winRedirectErrorHandler (Display *pDisplay, XErrorEvent *pErr);
+ winRedirectErrorHandler(Display * pDisplay, XErrorEvent * pErr);
static void
-winInitMultiWindowWM (WMInfoPtr pWMInfo, WMProcArgPtr pProcArg);
+ winInitMultiWindowWM(WMInfoPtr pWMInfo, WMProcArgPtr pProcArg);
static Bool
-CheckAnotherWindowManager (Display *pDisplay, DWORD dwScreen, Bool fAllowOtherWM);
+
+CheckAnotherWindowManager(Display * pDisplay, DWORD dwScreen,
+ Bool fAllowOtherWM);
static void
-winApplyHints (Display *pDisplay, Window iWindow, HWND hWnd, HWND *zstyle);
+ winApplyHints(Display * pDisplay, Window iWindow, HWND hWnd, HWND * zstyle);
void
-winUpdateWindowPosition (HWND hWnd, Bool reshape, HWND *zstyle);
+ winUpdateWindowPosition(HWND hWnd, Bool reshape, HWND * zstyle);
/*
* Local globals
*/
-static jmp_buf g_jmpWMEntry;
+static jmp_buf g_jmpWMEntry;
static XIOErrorHandler g_winMultiWindowWMOldIOErrorHandler;
static pthread_t g_winMultiWindowWMThread;
-static jmp_buf g_jmpXMsgProcEntry;
+static jmp_buf g_jmpXMsgProcEntry;
static XIOErrorHandler g_winMultiWindowXMsgProcOldIOErrorHandler;
static pthread_t g_winMultiWindowXMsgProcThread;
-static Bool g_shutdown = FALSE;
-static Bool redirectError = FALSE;
-static Bool g_fAnotherWMRunning = FALSE;
+static Bool g_shutdown = FALSE;
+static Bool redirectError = FALSE;
+static Bool g_fAnotherWMRunning = FALSE;
static HMODULE g_hmodShell32Dll = NULL;
static HMODULE g_hmodOle32Dll = NULL;
static SHGETPROPERTYSTOREFORWINDOWPROC g_pSHGetPropertyStoreForWindow = NULL;
@@ -228,100 +226,92 @@ static PROPVARIANTCLEARPROC g_pPropVariantClear = NULL;
*/
static void
-PushMessage (WMMsgQueuePtr pQueue, WMMsgNodePtr pNode)
+PushMessage(WMMsgQueuePtr pQueue, WMMsgNodePtr pNode)
{
- /* Lock the queue mutex */
- pthread_mutex_lock (&pQueue->pmMutex);
+ /* Lock the queue mutex */
+ pthread_mutex_lock(&pQueue->pmMutex);
- pNode->pNext = NULL;
-
- if (pQueue->pTail != NULL)
- {
- pQueue->pTail->pNext = pNode;
+ pNode->pNext = NULL;
+
+ if (pQueue->pTail != NULL) {
+ pQueue->pTail->pNext = pNode;
}
- pQueue->pTail = pNode;
-
- if (pQueue->pHead == NULL)
- {
- pQueue->pHead = pNode;
+ pQueue->pTail = pNode;
+
+ if (pQueue->pHead == NULL) {
+ pQueue->pHead = pNode;
}
#ifdef _DEBUG
/* Increase the count of elements in the queue by one */
- ++(pQueue->nQueueSize);
+ ++(pQueue->nQueueSize);
#endif
- /* Release the queue mutex */
- pthread_mutex_unlock (&pQueue->pmMutex);
+ /* Release the queue mutex */
+ pthread_mutex_unlock(&pQueue->pmMutex);
- /* Signal that the queue is not empty */
- pthread_cond_signal (&pQueue->pcNotEmpty);
+ /* Signal that the queue is not empty */
+ pthread_cond_signal(&pQueue->pcNotEmpty);
}
-
#ifdef WINDBG
/*
* QueueSize - Return the size of the queue
*/
static int
-QueueSize (WMMsgQueuePtr pQueue)
+QueueSize(WMMsgQueuePtr pQueue)
{
- WMMsgNodePtr pNode;
- int nSize = 0;
-
- /* Loop through all elements in the queue */
- for (pNode = pQueue->pHead; pNode != NULL; pNode = pNode->pNext)
- ++nSize;
+ WMMsgNodePtr pNode;
+ int nSize = 0;
- return nSize;
+ /* Loop through all elements in the queue */
+ for (pNode = pQueue->pHead; pNode != NULL; pNode = pNode->pNext)
+ ++nSize;
+
+ return nSize;
}
#endif
-
/*
* PopMessage - Pop a message from the queue
*/
static WMMsgNodePtr
-PopMessage (WMMsgQueuePtr pQueue, WMInfoPtr pWMInfo)
+PopMessage(WMMsgQueuePtr pQueue, WMInfoPtr pWMInfo)
{
- WMMsgNodePtr pNode;
+ WMMsgNodePtr pNode;
- /* Lock the queue mutex */
- pthread_mutex_lock (&pQueue->pmMutex);
+ /* Lock the queue mutex */
+ pthread_mutex_lock(&pQueue->pmMutex);
- /* Wait for --- */
- while (pQueue->pHead == NULL)
- {
- pthread_cond_wait (&pQueue->pcNotEmpty, &pQueue->pmMutex);
+ /* Wait for --- */
+ while (pQueue->pHead == NULL) {
+ pthread_cond_wait(&pQueue->pcNotEmpty, &pQueue->pmMutex);
}
-
- pNode = pQueue->pHead;
- if (pQueue->pHead != NULL)
- {
- pQueue->pHead = pQueue->pHead->pNext;
+
+ pNode = pQueue->pHead;
+ if (pQueue->pHead != NULL) {
+ pQueue->pHead = pQueue->pHead->pNext;
}
- if (pQueue->pTail == pNode)
- {
- pQueue->pTail = NULL;
+ if (pQueue->pTail == pNode) {
+ pQueue->pTail = NULL;
}
#ifdef _DEBUG
/* Drop the number of elements in the queue by one */
- --(pQueue->nQueueSize);
+ --(pQueue->nQueueSize);
winDebug ("Queue Size %d %d\n", pQueue->nQueueSize, QueueSize(pQueue));
#endif
-
- /* Release the queue mutex */
- pthread_mutex_unlock (&pQueue->pmMutex);
- return pNode;
-}
+ /* Release the queue mutex */
+ pthread_mutex_unlock(&pQueue->pmMutex);
+ return pNode;
+}
#if 0
/*
@@ -329,195 +319,178 @@ PopMessage (WMMsgQueuePtr pQueue, WMInfoPtr pWMInfo)
*/
static Bool
-HaveMessage (WMMsgQueuePtr pQueue, UINT msg, Window iWindow)
+HaveMessage(WMMsgQueuePtr pQueue, UINT msg, Window iWindow)
{
- WMMsgNodePtr pNode;
-
- for (pNode = pQueue->pHead; pNode != NULL; pNode = pNode->pNext)
- {
- if (pNode->msg.msg==msg && pNode->msg.iWindow==iWindow)
- return True;
+ WMMsgNodePtr pNode;
+
+ for (pNode = pQueue->pHead; pNode != NULL; pNode = pNode->pNext) {
+ if (pNode->msg.msg == msg && pNode->msg.iWindow == iWindow)
+ return True;
}
-
- return False;
+
+ return False;
}
#endif
-
/*
* InitQueue - Initialize the Window Manager message queue
*/
static
-Bool
-InitQueue (WMMsgQueuePtr pQueue)
+ Bool
+InitQueue(WMMsgQueuePtr pQueue)
{
- /* Check if the pQueue pointer is NULL */
- if (pQueue == NULL)
- {
- ErrorF ("InitQueue - pQueue is NULL. Exiting.\n");
- return FALSE;
+ /* Check if the pQueue pointer is NULL */
+ if (pQueue == NULL) {
+ ErrorF("InitQueue - pQueue is NULL. Exiting.\n");
+ return FALSE;
}
- /* Set the head and tail to NULL */
- pQueue->pHead = NULL;
- pQueue->pTail = NULL;
+ /* Set the head and tail to NULL */
+ pQueue->pHead = NULL;
+ pQueue->pTail = NULL;
- /* There are no elements initially */
+ /* There are no elements initially */
#ifdef _DEBUG
- pQueue->nQueueSize = 0;
+ pQueue->nQueueSize = 0;
- winDebug ("InitQueue - Queue Size %d %d\n", pQueue->nQueueSize,
- QueueSize(pQueue));
+ winDebug ("InitQueue - Queue Size %d %d\n", pQueue->nQueueSize,
+ QueueSize(pQueue));
#endif
- winDebug ("InitQueue - Calling pthread_mutex_init\n");
+ winDebug ("InitQueue - Calling pthread_mutex_init\n");
- /* Create synchronization objects */
- pthread_mutex_init (&pQueue->pmMutex, NULL);
+ /* Create synchronization objects */
+ pthread_mutex_init(&pQueue->pmMutex, NULL);
- winDebug ("InitQueue - pthread_mutex_init returned\n");
- winDebug ("InitQueue - Calling pthread_cond_init\n");
+ winDebug ("InitQueue - pthread_mutex_init returned\n");
+ winDebug ("InitQueue - Calling pthread_cond_init\n");
- pthread_cond_init (&pQueue->pcNotEmpty, NULL);
+ pthread_cond_init(&pQueue->pcNotEmpty, NULL);
- winDebug ("InitQueue - pthread_cond_init returned\n");
+ winDebug ("InitQueue - pthread_cond_init returned\n");
- return TRUE;
+ return TRUE;
}
-
/*
* GetWindowName - Retrieve the title of an X Window
*/
static void
-GetWindowName (Display *pDisplay, Window iWin, wchar_t **ppName)
+GetWindowName(Display * pDisplay, Window iWin, wchar_t ** ppName)
{
- int nResult, nNum;
- char **ppList;
- char *pszReturnData;
- int iLen, i;
- XTextProperty xtpName;
-
- winDebug ("GetWindowName\n");
-
- /* Intialize ppName to NULL */
- *ppName = NULL;
-
- /* Try to get --- */
- nResult = XGetWMName (pDisplay, iWin, &xtpName);
- if (!nResult || !xtpName.value || !xtpName.nitems)
- {
- ErrorF ("GetWindowName - XGetWMName failed. No name.\n");
- return;
+ int nResult, nNum;
+ char **ppList;
+ char *pszReturnData;
+ int iLen, i;
+ XTextProperty xtpName;
+
+ winDebug ("GetWindowName\n");
+
+ /* Intialize ppName to NULL */
+ *ppName = NULL;
+
+ /* Try to get --- */
+ nResult = XGetWMName(pDisplay, iWin, &xtpName);
+ if (!nResult || !xtpName.value || !xtpName.nitems) {
+ ErrorF("GetWindowName - XGetWMName failed. No name.\n");
+ return;
}
- if (Xutf8TextPropertyToTextList (pDisplay, &xtpName, &ppList, &nNum) >= Success && nNum > 0 && *ppList)
- {
- iLen = 0;
- for (i = 0; i < nNum; i++) iLen += strlen(ppList[i]);
- pszReturnData = (char *) malloc (iLen + 1);
- pszReturnData[0] = '\0';
- for (i = 0; i < nNum; i++) strcat (pszReturnData, ppList[i]);
- if (ppList) XFreeStringList (ppList);
- }
- else
- {
- pszReturnData = (char *) malloc (1);
- pszReturnData[0] = '\0';
- }
- iLen = MultiByteToWideChar (CP_UTF8, 0, pszReturnData, -1, NULL, 0);
- *ppName = (wchar_t*)malloc(sizeof(wchar_t)*(iLen + 1));
- MultiByteToWideChar (CP_UTF8, 0, pszReturnData, -1, *ppName, iLen);
- XFree (xtpName.value);
- free (pszReturnData);
- winDebug ("GetWindowName - Returning\n");
+ if (Xutf8TextPropertyToTextList(pDisplay, &xtpName, &ppList, &nNum) >=
+ Success && nNum > 0 && *ppList) {
+ iLen = 0;
+ for (i = 0; i < nNum; i++)
+ iLen += strlen(ppList[i]);
+ pszReturnData = (char *) malloc(iLen + 1);
+ pszReturnData[0] = '\0';
+ for (i = 0; i < nNum; i++)
+ strcat(pszReturnData, ppList[i]);
+ if (ppList)
+ XFreeStringList(ppList);
+ }
+ else {
+ pszReturnData = (char *) malloc(1);
+ pszReturnData[0] = '\0';
+ }
+ iLen = MultiByteToWideChar(CP_UTF8, 0, pszReturnData, -1, NULL, 0);
+ *ppName = (wchar_t *) malloc(sizeof(wchar_t) * (iLen + 1));
+ MultiByteToWideChar(CP_UTF8, 0, pszReturnData, -1, *ppName, iLen);
+ XFree(xtpName.value);
+ free(pszReturnData);
+ winDebug ("GetWindowName - Returning\n");
}
-
/*
* Send a message to the X server from the WM thread
*/
static int
-SendXMessage (Display *pDisplay, Window iWin, Atom atmType, long nData)
+SendXMessage(Display * pDisplay, Window iWin, Atom atmType, long nData)
{
- XEvent e;
-
- /* Prepare the X event structure */
- e.type = ClientMessage;
- e.xclient.window = iWin;
- e.xclient.message_type = atmType;
- e.xclient.format = 32;
- e.xclient.data.l[0] = nData;
- e.xclient.data.l[1] = CurrentTime;
-
- /* Send the event to X */
- return XSendEvent (pDisplay, iWin, False, NoEventMask, &e);
+ XEvent e;
+
+ /* Prepare the X event structure */
+ e.type = ClientMessage;
+ e.xclient.window = iWin;
+ e.xclient.message_type = atmType;
+ e.xclient.format = 32;
+ e.xclient.data.l[0] = nData;
+ e.xclient.data.l[1] = CurrentTime;
+
+ /* Send the event to X */
+ return XSendEvent(pDisplay, iWin, False, NoEventMask, &e);
}
-
/*
* Updates the name of a HWND according to its X WM_NAME property
*/
static void
-UpdateName (WMInfoPtr pWMInfo, Window iWindow)
+UpdateName(WMInfoPtr pWMInfo, Window iWindow)
{
- wchar_t *pszName;
- Atom atmType;
- int fmtRet;
- unsigned long items, remain;
- HWND *retHwnd, hWnd;
- XWindowAttributes attr;
-
- hWnd = 0;
-
- /* See if we can get the cached HWND for this window... */
- if (XGetWindowProperty (pWMInfo->pDisplay,
- iWindow,
- pWMInfo->atmPrivMap,
- 0,
- 1,
- False,
- XA_INTEGER,//pWMInfo->atmPrivMap,
- &atmType,
- &fmtRet,
- &items,
- &remain,
- (unsigned char **) &retHwnd) == Success)
- {
- if (retHwnd)
- {
- hWnd = *retHwnd;
- XFree (retHwnd);
- }
+ wchar_t *pszName;
+ Atom atmType;
+ int fmtRet;
+ unsigned long items, remain;
+ HWND *retHwnd, hWnd;
+ XWindowAttributes attr;
+
+ hWnd = 0;
+
+ /* See if we can get the cached HWND for this window... */
+ if (XGetWindowProperty(pWMInfo->pDisplay, iWindow, pWMInfo->atmPrivMap, 0, 1, False, XA_INTEGER, //pWMInfo->atmPrivMap,
+ &atmType,
+ &fmtRet,
+ &items,
+ &remain, (unsigned char **) &retHwnd) == Success) {
+ if (retHwnd) {
+ hWnd = *retHwnd;
+ XFree(retHwnd);
+ }
}
-
- /* Some sanity checks */
- if (!hWnd) return;
- if (!IsWindow (hWnd)) return;
- /* Set the Windows window name */
- GetWindowName (pWMInfo->pDisplay, iWindow, &pszName);
- if (pszName)
- {
- /* Get the window attributes */
- XGetWindowAttributes (pWMInfo->pDisplay,
- iWindow,
- &attr);
- if (!attr.override_redirect)
- {
- SetWindowTextW (hWnd, pszName);
- winUpdateIcon (iWindow);
- }
-
- free (pszName);
+ /* Some sanity checks */
+ if (!hWnd)
+ return;
+ if (!IsWindow(hWnd))
+ return;
+
+ /* Set the Windows window name */
+ GetWindowName(pWMInfo->pDisplay, iWindow, &pszName);
+ if (pszName) {
+ /* Get the window attributes */
+ XGetWindowAttributes(pWMInfo->pDisplay, iWindow, &attr);
+ if (!attr.override_redirect) {
+ SetWindowTextW(hWnd, pszName);
+ winUpdateIcon(iWindow);
+ }
+
+ free(pszName);
}
}
-
#if 0
/*
* Fix up any differences between the X11 and Win32 window stacks
@@ -526,609 +499,546 @@ UpdateName (WMInfoPtr pWMInfo, Window iWindow)
static void
PreserveWin32Stack(WMInfoPtr pWMInfo, Window iWindow, UINT direction)
{
- Atom atmType;
- int fmtRet;
- unsigned long items, remain;
- HWND hWnd, *retHwnd;
- DWORD myWinProcID, winProcID;
- Window xWindow;
- WINDOWPLACEMENT wndPlace;
-
- hWnd = NULL;
- /* See if we can get the cached HWND for this window... */
- if (XGetWindowProperty (pWMInfo->pDisplay,
- iWindow,
- pWMInfo->atmPrivMap,
- 0,
- 1,
- False,
- XA_INTEGER,//pWMInfo->atmPrivMap,
- &atmType,
- &fmtRet,
- &items,
- &remain,
- (unsigned char **) &retHwnd) == Success)
- {
- if (retHwnd)
- {
- hWnd = *retHwnd;
- XFree (retHwnd);
- }
+ Atom atmType;
+ int fmtRet;
+ unsigned long items, remain;
+ HWND hWnd, *retHwnd;
+ DWORD myWinProcID, winProcID;
+ Window xWindow;
+ WINDOWPLACEMENT wndPlace;
+
+ hWnd = NULL;
+ /* See if we can get the cached HWND for this window... */
+ if (XGetWindowProperty(pWMInfo->pDisplay, iWindow, pWMInfo->atmPrivMap, 0, 1, False, XA_INTEGER, //pWMInfo->atmPrivMap,
+ &atmType,
+ &fmtRet,
+ &items,
+ &remain, (unsigned char **) &retHwnd) == Success) {
+ if (retHwnd) {
+ hWnd = *retHwnd;
+ XFree(retHwnd);
+ }
}
-
- if (!hWnd) return;
-
- GetWindowThreadProcessId (hWnd, &myWinProcID);
- hWnd = GetNextWindow (hWnd, direction);
-
- while (hWnd) {
- GetWindowThreadProcessId (hWnd, &winProcID);
- if (winProcID == myWinProcID)
- {
- wndPlace.length = sizeof(WINDOWPLACEMENT);
- GetWindowPlacement (hWnd, &wndPlace);
- if ( !(wndPlace.showCmd==SW_HIDE ||
- wndPlace.showCmd==SW_MINIMIZE) )
- {
- xWindow = (Window)GetProp (hWnd, WIN_WID_PROP);
- if (xWindow)
- {
- if (direction==GW_HWNDPREV)
- XRaiseWindow (pWMInfo->pDisplay, xWindow);
- else
- XLowerWindow (pWMInfo->pDisplay, xWindow);
- }
- }
- }
+
+ if (!hWnd)
+ return;
+
+ GetWindowThreadProcessId(hWnd, &myWinProcID);
hWnd = GetNextWindow(hWnd, direction);
- }
-}
-#endif /* PreserveWin32Stack */
+ while (hWnd) {
+ GetWindowThreadProcessId(hWnd, &winProcID);
+ if (winProcID == myWinProcID) {
+ wndPlace.length = sizeof(WINDOWPLACEMENT);
+ GetWindowPlacement(hWnd, &wndPlace);
+ if (!(wndPlace.showCmd == SW_HIDE ||
+ wndPlace.showCmd == SW_MINIMIZE)) {
+ xWindow = (Window) GetProp(hWnd, WIN_WID_PROP);
+ if (xWindow) {
+ if (direction == GW_HWNDPREV)
+ XRaiseWindow(pWMInfo->pDisplay, xWindow);
+ else
+ XLowerWindow(pWMInfo->pDisplay, xWindow);
+ }
+ }
+ }
+ hWnd = GetNextWindow(hWnd, direction);
+ }
+}
+#endif /* PreserveWin32Stack */
/*
* winMultiWindowWMProc
*/
static void *
-winMultiWindowWMProc (void *pArg)
+winMultiWindowWMProc(void *pArg)
{
- WMProcArgPtr pProcArg = (WMProcArgPtr)pArg;
- WMInfoPtr pWMInfo = pProcArg->pWMInfo;
+ WMProcArgPtr pProcArg = (WMProcArgPtr) pArg;
+ WMInfoPtr pWMInfo = pProcArg->pWMInfo;
- pthread_cleanup_push(&winMultiWindowThreadExit, NULL);
-
- /* Initialize the Window Manager */
- winInitMultiWindowWM (pWMInfo, pProcArg);
+ pthread_cleanup_push(&winMultiWindowThreadExit, NULL);
- winDebug ("winMultiWindowWMProc ()\n");
+ /* Initialize the Window Manager */
+ winInitMultiWindowWM(pWMInfo, pProcArg);
- /* Loop until we explicitly break out */
- for (;;)
- {
- WMMsgNodePtr pNode;
+ winDebug ("winMultiWindowWMProc ()\n");
+
+ /* Loop until we explicitly break out */
+ for (;;) {
+ WMMsgNodePtr pNode;
#ifdef XWIN_MULTIWINDOWINTWM
- if(g_fAnotherWMRunning)/* Another Window manager exists. */
- {
- Sleep (1000);
- continue;
- }
+ if (g_fAnotherWMRunning) { /* Another Window manager exists. */
+ Sleep(1000);
+ continue;
+ }
#endif
- /* Pop a message off of our queue */
- pNode = PopMessage (&pWMInfo->wmMsgQueue, pWMInfo);
- if (pNode == NULL)
- {
- /* Bail if PopMessage returns without a message */
- /* NOTE: Remember that PopMessage is a blocking function. */
- ErrorF ("winMultiWindowWMProc - Queue is Empty? Exiting.\n");
- pthread_exit (NULL);
- }
-
- winDebug ("winMultiWindowWMProc - %d ms MSG: %d ID: %d\n",
- GetTickCount (), (int)pNode->msg.msg, (int)pNode->msg.dwID);
-
- /* Branch on the message type */
- switch (pNode->msg.msg)
- {
- case WM_WM_RAISE:
- winDebug ("\tWM_WM_RAISE\n");
- /* Raise the window */
- XRaiseWindow (pWMInfo->pDisplay, pNode->msg.iWindow);
- break;
-
- case WM_WM_LOWER:
- winDebug ("\tWM_WM_LOWER\n");
-
- /* Lower the window */
- XLowerWindow (pWMInfo->pDisplay, pNode->msg.iWindow);
- break;
-
- case WM_WM_MAP:
- winDebug ("\tWM_WM_MAP\n");
- /* Put a note as to the HWND associated with this Window */
- XChangeProperty (pWMInfo->pDisplay,
- pNode->msg.iWindow,
- pWMInfo->atmPrivMap,
- XA_INTEGER,//pWMInfo->atmPrivMap,
- 32,
- PropModeReplace,
- (unsigned char *) &(pNode->msg.hwndWindow),
- 1);
- UpdateName (pWMInfo, pNode->msg.iWindow);
- winUpdateIcon (pNode->msg.iWindow);
- {
- HWND zstyle = HWND_NOTOPMOST;
- winApplyHints (pWMInfo->pDisplay, pNode->msg.iWindow, pNode->msg.hwndWindow, &zstyle);
- winUpdateWindowPosition (pNode->msg.hwndWindow, TRUE, &zstyle);
- }
- break;
-
- case WM_WM_MAP2:
- winDebug ("\tWM_WM_MAP2\n");
-
- XChangeProperty (pWMInfo->pDisplay,
- pNode->msg.iWindow,
- pWMInfo->atmPrivMap,
- XA_INTEGER,//pWMInfo->atmPrivMap,
- 32,
- PropModeReplace,
- (unsigned char *) &(pNode->msg.hwndWindow),
- 1);
- break;
-
- case WM_WM_MAP3:
- winDebug ("\tWM_WM_MAP3\n");
-
- /* Put a note as to the HWND associated with this Window */
- XChangeProperty (pWMInfo->pDisplay,
- pNode->msg.iWindow,
- pWMInfo->atmPrivMap,
- XA_INTEGER,//pWMInfo->atmPrivMap,
- 32,
- PropModeReplace,
- (unsigned char *) &(pNode->msg.hwndWindow),
- 1);
- UpdateName (pWMInfo, pNode->msg.iWindow);
- winUpdateIcon (pNode->msg.iWindow);
- {
- HWND zstyle = HWND_NOTOPMOST;
- winApplyHints (pWMInfo->pDisplay, pNode->msg.iWindow, pNode->msg.hwndWindow, &zstyle);
- winUpdateWindowPosition (pNode->msg.hwndWindow, TRUE, &zstyle);
- }
- break;
-
- case WM_WM_UNMAP:
- winDebug ("\tWM_WM_UNMAP\n");
-
- /* Unmap the window */
- XUnmapWindow (pWMInfo->pDisplay, pNode->msg.iWindow);
- break;
-
- case WM_WM_KILL:
- winDebug ("\tWM_WM_KILL\n");
- {
- int i, n, found = 0;
- Atom *protocols;
-
- /* --- */
- if (XGetWMProtocols (pWMInfo->pDisplay,
- pNode->msg.iWindow,
- &protocols,
- &n))
- {
- for (i = 0; i < n; ++i)
- if (protocols[i] == pWMInfo->atmWmDelete)
- ++found;
-
- XFree (protocols);
- }
-
- /* --- */
- if (found)
- SendXMessage (pWMInfo->pDisplay,
- pNode->msg.iWindow,
- pWMInfo->atmWmProtos,
- pWMInfo->atmWmDelete);
- else
- XKillClient (pWMInfo->pDisplay,
- pNode->msg.iWindow);
- }
- break;
-
- case WM_WM_ACTIVATE:
- winDebug ("\tWM_WM_ACTIVATE\n");
-
- /* Set the input focus */
- XSetInputFocus (pWMInfo->pDisplay,
- pNode->msg.iWindow,
- RevertToPointerRoot,
- CurrentTime);
- break;
-
- case WM_WM_NAME_EVENT:
- UpdateName (pWMInfo, pNode->msg.iWindow);
- break;
-
- case WM_WM_HINTS_EVENT:
- winUpdateIcon (pNode->msg.iWindow);
- break;
-
- case WM_WM_CHANGE_STATE:
- /* Minimize the window in Windows */
- winMinimizeWindow (pNode->msg.iWindow);
- break;
-
- default:
- ErrorF ("winMultiWindowWMProc - Unknown Message. Exiting.\n");
- pthread_exit (NULL);
- break;
- }
-
- /* Free the retrieved message */
- free (pNode);
-
- /* Flush any pending events on our display */
- XFlush (pWMInfo->pDisplay);
+ /* Pop a message off of our queue */
+ pNode = PopMessage(&pWMInfo->wmMsgQueue, pWMInfo);
+ if (pNode == NULL) {
+ /* Bail if PopMessage returns without a message */
+ /* NOTE: Remember that PopMessage is a blocking function. */
+ ErrorF("winMultiWindowWMProc - Queue is Empty? Exiting.\n");
+ pthread_exit(NULL);
+ }
+
+ winDebug ("winMultiWindowWMProc - %d ms MSG: %d ID: %d\n",
+ GetTickCount(), (int) pNode->msg.msg, (int) pNode->msg.dwID);
+
+ /* Branch on the message type */
+ switch (pNode->msg.msg) {
+ case WM_WM_RAISE:
+ winDebug ("\tWM_WM_RAISE\n");
+ /* Raise the window */
+ XRaiseWindow(pWMInfo->pDisplay, pNode->msg.iWindow);
+ break;
+
+ case WM_WM_LOWER:
+ winDebug ("\tWM_WM_LOWER\n");
+
+ /* Lower the window */
+ XLowerWindow(pWMInfo->pDisplay, pNode->msg.iWindow);
+ break;
+
+ case WM_WM_MAP:
+ winDebug ("\tWM_WM_MAP\n");
+ /* Put a note as to the HWND associated with this Window */
+ XChangeProperty(pWMInfo->pDisplay, pNode->msg.iWindow, pWMInfo->atmPrivMap, XA_INTEGER, //pWMInfo->atmPrivMap,
+ 32,
+ PropModeReplace,
+ (unsigned char *) &(pNode->msg.hwndWindow), 1);
+ UpdateName(pWMInfo, pNode->msg.iWindow);
+ winUpdateIcon(pNode->msg.iWindow);
+ {
+ HWND zstyle = HWND_NOTOPMOST;
+ winApplyHints (pWMInfo->pDisplay, pNode->msg.iWindow, pNode->msg.hwndWindow, &zstyle);
+ winUpdateWindowPosition (pNode->msg.hwndWindow, TRUE, &zstyle);
+ }
+ break;
+
+ case WM_WM_MAP2:
+ winDebug ("\tWM_WM_MAP2\n");
+
+ XChangeProperty(pWMInfo->pDisplay, pNode->msg.iWindow, pWMInfo->atmPrivMap, XA_INTEGER, //pWMInfo->atmPrivMap,
+ 32,
+ PropModeReplace,
+ (unsigned char *) &(pNode->msg.hwndWindow), 1);
+ break;
+
+ case WM_WM_MAP3:
+ winDebug ("\tWM_WM_MAP3\n");
+
+ /* Put a note as to the HWND associated with this Window */
+ XChangeProperty(pWMInfo->pDisplay, pNode->msg.iWindow, pWMInfo->atmPrivMap, XA_INTEGER, //pWMInfo->atmPrivMap,
+ 32,
+ PropModeReplace,
+ (unsigned char *) &(pNode->msg.hwndWindow), 1);
+ UpdateName(pWMInfo, pNode->msg.iWindow);
+ winUpdateIcon(pNode->msg.iWindow);
+ {
+ HWND zstyle = HWND_NOTOPMOST;
+
+ winApplyHints(pWMInfo->pDisplay, pNode->msg.iWindow,
+ pNode->msg.hwndWindow, &zstyle);
+ winUpdateWindowPosition(pNode->msg.hwndWindow, TRUE, &zstyle);
+ }
+ break;
+
+ case WM_WM_UNMAP:
+ winDebug ("\tWM_WM_UNMAP\n");
+
+ /* Unmap the window */
+ XUnmapWindow(pWMInfo->pDisplay, pNode->msg.iWindow);
+ break;
+
+ case WM_WM_KILL:
+ winDebug ("\tWM_WM_KILL\n");
+ {
+ int i, n, found = 0;
+ Atom *protocols;
+
+ /* --- */
+ if (XGetWMProtocols(pWMInfo->pDisplay,
+ pNode->msg.iWindow, &protocols, &n)) {
+ for (i = 0; i < n; ++i)
+ if (protocols[i] == pWMInfo->atmWmDelete)
+ ++found;
+
+ XFree(protocols);
+ }
+
+ /* --- */
+ if (found)
+ SendXMessage(pWMInfo->pDisplay,
+ pNode->msg.iWindow,
+ pWMInfo->atmWmProtos, pWMInfo->atmWmDelete);
+ else
+ XKillClient(pWMInfo->pDisplay, pNode->msg.iWindow);
+ }
+ break;
+
+ case WM_WM_ACTIVATE:
+ winDebug ("\tWM_WM_ACTIVATE\n");
+
+ /* Set the input focus */
+ XSetInputFocus(pWMInfo->pDisplay,
+ pNode->msg.iWindow,
+ RevertToPointerRoot, CurrentTime);
+ break;
+
+ case WM_WM_NAME_EVENT:
+ UpdateName(pWMInfo, pNode->msg.iWindow);
+ break;
+
+ case WM_WM_HINTS_EVENT:
+ winUpdateIcon(pNode->msg.iWindow);
+ break;
+
+ case WM_WM_CHANGE_STATE:
+ /* Minimize the window in Windows */
+ winMinimizeWindow(pNode->msg.iWindow);
+ break;
+
+ default:
+ ErrorF("winMultiWindowWMProc - Unknown Message. Exiting.\n");
+ pthread_exit(NULL);
+ break;
+ }
+
+ /* Free the retrieved message */
+ free(pNode);
+
+ /* Flush any pending events on our display */
+ XFlush(pWMInfo->pDisplay);
}
- /* Free the condition variable */
- pthread_cond_destroy (&pWMInfo->wmMsgQueue.pcNotEmpty);
-
- /* Free the mutex variable */
- pthread_mutex_destroy (&pWMInfo->wmMsgQueue.pmMutex);
-
- /* Free the passed-in argument */
- free (pProcArg);
-
- winDebug("-winMultiWindowWMProc ()\n");
+ /* Free the condition variable */
+ pthread_cond_destroy(&pWMInfo->wmMsgQueue.pcNotEmpty);
- pthread_cleanup_pop(0);
+ /* Free the mutex variable */
+ pthread_mutex_destroy(&pWMInfo->wmMsgQueue.pmMutex);
- return NULL;
-}
+ /* Free the passed-in argument */
+ free(pProcArg);
+ winDebug("-winMultiWindowWMProc ()\n");
+
+ pthread_cleanup_pop(0);
+
+ return NULL;
+}
/*
* X message procedure
*/
static void *
-winMultiWindowXMsgProc (void *pArg)
+winMultiWindowXMsgProc(void *pArg)
{
- winWMMessageRec msg;
- XMsgProcArgPtr pProcArg = (XMsgProcArgPtr) pArg;
- char pszDisplay[512];
- int iRetries;
- XEvent event;
- Atom atmWmName;
- Atom atmWmHints;
- Atom atmWmChange;
- int iReturn;
- XIconSize *xis;
-
- pthread_cleanup_push(&winMultiWindowThreadExit, NULL);
-
- winDebug ("winMultiWindowXMsgProc - Hello\n");
-
- /* Check that argument pointer is not invalid */
- if (pProcArg == NULL)
- {
- ErrorF ("winMultiWindowXMsgProc - pProcArg is NULL. Exiting.\n");
- pthread_exit (NULL);
+ winWMMessageRec msg;
+ XMsgProcArgPtr pProcArg = (XMsgProcArgPtr) pArg;
+ char pszDisplay[512];
+ int iRetries;
+ XEvent event;
+ Atom atmWmName;
+ Atom atmWmHints;
+ Atom atmWmChange;
+ int iReturn;
+ XIconSize *xis;
+
+ pthread_cleanup_push(&winMultiWindowThreadExit, NULL);
+
+ winDebug ("winMultiWindowXMsgProc - Hello\n");
+
+ /* Check that argument pointer is not invalid */
+ if (pProcArg == NULL) {
+ ErrorF("winMultiWindowXMsgProc - pProcArg is NULL. Exiting.\n");
+ pthread_exit(NULL);
}
- winDebug ("winMultiWindowXMsgProc - Calling pthread_mutex_lock ()\n");
+ winDebug ("winMultiWindowXMsgProc - Calling pthread_mutex_lock ()\n");
- /* Grab the server started mutex - pause until we get it */
- iReturn = pthread_mutex_lock (pProcArg->ppmServerStarted);
- if (iReturn != 0)
- {
- ErrorF ("winMultiWindowXMsgProc - pthread_mutex_lock () failed: %d. "
- "Exiting.\n",
- iReturn);
- pthread_exit (NULL);
+ /* Grab the server started mutex - pause until we get it */
+ iReturn = pthread_mutex_lock(pProcArg->ppmServerStarted);
+ if (iReturn != 0) {
+ ErrorF("winMultiWindowXMsgProc - pthread_mutex_lock () failed: %d. "
+ "Exiting.\n", iReturn);
+ pthread_exit(NULL);
}
- winDebug ("winMultiWindowXMsgProc - pthread_mutex_lock () returned.\n");
+ winDebug ("winMultiWindowXMsgProc - pthread_mutex_lock () returned.\n");
- /* Release the server started mutex */
- pthread_mutex_unlock (pProcArg->ppmServerStarted);
+ /* Release the server started mutex */
+ pthread_mutex_unlock(pProcArg->ppmServerStarted);
- winDebug ("winMultiWindowXMsgProc - pthread_mutex_unlock () returned.\n");
+ winDebug ("winMultiWindowXMsgProc - pthread_mutex_unlock () returned.\n");
- /* Install our error handler */
- XSetErrorHandler (winMultiWindowXMsgProcErrorHandler);
- g_winMultiWindowXMsgProcThread = pthread_self();
- g_winMultiWindowXMsgProcOldIOErrorHandler = XSetIOErrorHandler (winMultiWindowXMsgProcIOErrorHandler);
+ /* Install our error handler */
+ XSetErrorHandler(winMultiWindowXMsgProcErrorHandler);
+ g_winMultiWindowXMsgProcThread = pthread_self();
+ g_winMultiWindowXMsgProcOldIOErrorHandler =
+ XSetIOErrorHandler(winMultiWindowXMsgProcIOErrorHandler);
- /* Set jump point for IO Error exits */
- iReturn = setjmp (g_jmpXMsgProcEntry);
+ /* Set jump point for IO Error exits */
+ iReturn = setjmp(g_jmpXMsgProcEntry);
- /* Check if we should continue operations */
- if (iReturn != WIN_JMP_ERROR_IO
- && iReturn != WIN_JMP_OKAY)
- {
- /* setjmp returned an unknown value, exit */
- ErrorF ("winInitMultiWindowXMsgProc - setjmp returned: %d. Exiting.\n",
- iReturn);
- pthread_exit (NULL);
+ /* Check if we should continue operations */
+ if (iReturn != WIN_JMP_ERROR_IO && iReturn != WIN_JMP_OKAY) {
+ /* setjmp returned an unknown value, exit */
+ ErrorF("winInitMultiWindowXMsgProc - setjmp returned: %d. Exiting.\n",
+ iReturn);
+ pthread_exit(NULL);
}
- else if (iReturn == WIN_JMP_ERROR_IO)
- {
- ErrorF ("winInitMultiWindowXMsgProc - Caught IO Error. Exiting.\n");
- pthread_exit (NULL);
+ else if (iReturn == WIN_JMP_ERROR_IO) {
+ ErrorF("winInitMultiWindowXMsgProc - Caught IO Error. Exiting.\n");
+ pthread_exit(NULL);
}
- /* Setup the display connection string x */
- winGetDisplayName(pszDisplay, (int)pProcArg->dwScreen);
+ /* Setup the display connection string x */
+ winGetDisplayName(pszDisplay, (int)pProcArg->dwScreen);
- /* Print the display connection string */
- winDebug ("winMultiWindowXMsgProc - DISPLAY=%s\n", pszDisplay);
+ /* Print the display connection string */
+ winDebug ("winMultiWindowXMsgProc - DISPLAY=%s\n", pszDisplay);
- /* Use our generated cookie for authentication */
- winSetAuthorization();
-
- /* Initialize retry count */
- iRetries = 0;
+ /* Use our generated cookie for authentication */
+ winSetAuthorization();
- /* Open the X display */
- do
- {
- /* Try to open the display */
- pProcArg->pDisplay = XOpenDisplay (pszDisplay);
- if (pProcArg->pDisplay == NULL)
- {
- winDebug ("winMultiWindowXMsgProc - Could not open display, try: %d, "
- "sleeping: %d\n",
- iRetries + 1, WIN_CONNECT_DELAY);
- ++iRetries;
- sleep (WIN_CONNECT_DELAY);
- continue;
- }
- else
- break;
+ /* Initialize retry count */
+ iRetries = 0;
+
+ /* Open the X display */
+ do {
+ /* Try to open the display */
+ pProcArg->pDisplay = XOpenDisplay(pszDisplay);
+ if (pProcArg->pDisplay == NULL) {
+ winDebug ("winMultiWindowXMsgProc - Could not open display, try: %d, "
+ "sleeping: %d\n", iRetries + 1, WIN_CONNECT_DELAY);
+ ++iRetries;
+ sleep(WIN_CONNECT_DELAY);
+ continue;
+ }
+ else
+ break;
}
- while (pProcArg->pDisplay == NULL && iRetries < WIN_CONNECT_RETRIES);
-
- /* Make sure that the display opened */
- if (pProcArg->pDisplay == NULL)
- {
- ErrorF ("winMultiWindowXMsgProc - Failed opening the display. "
- "Exiting.\n");
- pthread_exit (NULL);
+ while (pProcArg->pDisplay == NULL && iRetries < WIN_CONNECT_RETRIES);
+
+ /* Make sure that the display opened */
+ if (pProcArg->pDisplay == NULL) {
+ ErrorF("winMultiWindowXMsgProc - Failed opening the display. "
+ "Exiting.\n");
+ pthread_exit(NULL);
}
- winDebug ("winMultiWindowXMsgProc - XOpenDisplay () returned and "
- "successfully opened the display.\n");
+ winDebug ("winMultiWindowXMsgProc - XOpenDisplay () returned and "
+ "successfully opened the display.\n");
- /* Check if another window manager is already running */
+ /* Check if another window manager is already running */
#ifdef XWIN_MULTIWINDOWINTWM
- g_fAnotherWMRunning = CheckAnotherWindowManager (pProcArg->pDisplay, pProcArg->dwScreen, pProcArg->pWMInfo->fAllowOtherWM);
+ g_fAnotherWMRunning =
+ CheckAnotherWindowManager(pProcArg->pDisplay, pProcArg->dwScreen,
+ pProcArg->pWMInfo->fAllowOtherWM);
#else
- g_fAnotherWMRunning = CheckAnotherWindowManager (pProcArg->pDisplay, pProcArg->dwScreen, FALSE);
+ g_fAnotherWMRunning =
+ CheckAnotherWindowManager(pProcArg->pDisplay, pProcArg->dwScreen,
+ FALSE);
#endif
- if (g_fAnotherWMRunning
+ if (g_fAnotherWMRunning
#ifdef XWIN_MULTIWINDOWINTWM
- && !pProcArg->pWMInfo->fAllowOtherWM
+ && !pProcArg->pWMInfo->fAllowOtherWM
#endif
- )
- {
- ErrorF ("winMultiWindowXMsgProc - "
- "another window manager is running. Exiting.\n");
- pthread_exit (NULL);
+ ) {
+ ErrorF("winMultiWindowXMsgProc - "
+ "another window manager is running. Exiting.\n");
+ pthread_exit(NULL);
}
- /* Set up the supported icon sizes */
- xis = XAllocIconSize ();
- if (xis)
- {
- xis->min_width = xis->min_height = 16;
- xis->max_width = xis->max_height = 48;
- xis->width_inc = xis->height_inc = 16;
- XSetIconSizes (pProcArg->pDisplay,
- RootWindow (pProcArg->pDisplay, pProcArg->dwScreen),
- xis,
- 1);
- XFree (xis);
+ /* Set up the supported icon sizes */
+ xis = XAllocIconSize();
+ if (xis) {
+ xis->min_width = xis->min_height = 16;
+ xis->max_width = xis->max_height = 48;
+ xis->width_inc = xis->height_inc = 16;
+ XSetIconSizes(pProcArg->pDisplay,
+ RootWindow(pProcArg->pDisplay, pProcArg->dwScreen),
+ xis, 1);
+ XFree(xis);
}
- atmWmName = XInternAtom (pProcArg->pDisplay,
- "WM_NAME",
- False);
- atmWmHints = XInternAtom (pProcArg->pDisplay,
- "WM_HINTS",
- False);
- atmWmChange = XInternAtom (pProcArg->pDisplay,
- "WM_CHANGE_STATE",
- False);
+ atmWmName = XInternAtom(pProcArg->pDisplay, "WM_NAME", False);
+ atmWmHints = XInternAtom(pProcArg->pDisplay, "WM_HINTS", False);
+ atmWmChange = XInternAtom(pProcArg->pDisplay, "WM_CHANGE_STATE", False);
- /*
- iiimxcf had a bug until 2009-04-27, assuming that the
- WM_STATE atom exists, causing clients to fail with
- a BadAtom X error if it doesn't.
+ /*
+ iiimxcf had a bug until 2009-04-27, assuming that the
+ WM_STATE atom exists, causing clients to fail with
+ a BadAtom X error if it doesn't.
- Since this is on in the default Solaris 10 install,
- workaround this by making sure it does exist...
- */
- XInternAtom(pProcArg->pDisplay, "WM_STATE", 0);
+ Since this is on in the default Solaris 10 install,
+ workaround this by making sure it does exist...
+ */
+ XInternAtom(pProcArg->pDisplay, "WM_STATE", 0);
- /* Loop until we explicitly break out */
- while (1)
- {
- if (g_shutdown)
- break;
+ /* Loop until we explicitly break out */
+ while (1) {
+ if (g_shutdown)
+ break;
#ifdef XWIN_MULTIWINDOWINTWM
- if (pProcArg->pWMInfo->fAllowOtherWM && !XPending (pProcArg->pDisplay))
- {
- if (CheckAnotherWindowManager (pProcArg->pDisplay, pProcArg->dwScreen, TRUE))
- {
- if (!g_fAnotherWMRunning)
- {
- g_fAnotherWMRunning = TRUE;
- SendMessage(*(HWND*)pProcArg->hwndScreen, WM_UNMANAGE, 0, 0);
- }
- }
- else
- {
- if (g_fAnotherWMRunning)
- {
- g_fAnotherWMRunning = FALSE;
- SendMessage(*(HWND*)pProcArg->hwndScreen, WM_MANAGE, 0, 0);
- }
- }
- Sleep (500);
- continue;
- }
+ if (pProcArg->pWMInfo->fAllowOtherWM && !XPending(pProcArg->pDisplay)) {
+ if (CheckAnotherWindowManager
+ (pProcArg->pDisplay, pProcArg->dwScreen, TRUE)) {
+ if (!g_fAnotherWMRunning) {
+ g_fAnotherWMRunning = TRUE;
+ SendMessage(*(HWND *) pProcArg->hwndScreen, WM_UNMANAGE, 0,
+ 0);
+ }
+ }
+ else {
+ if (g_fAnotherWMRunning) {
+ g_fAnotherWMRunning = FALSE;
+ SendMessage(*(HWND *) pProcArg->hwndScreen, WM_MANAGE, 0,
+ 0);
+ }
+ }
+ Sleep(500);
+ continue;
+ }
#endif
- /* Fetch next event */
- XNextEvent (pProcArg->pDisplay, &event);
-
- /* Branch on event type */
- if (event.type == MapNotify /* CreateNotify */)
- {
- XWindowAttributes attr;
-
- XSelectInput (pProcArg->pDisplay,
- event.xcreatewindow.window,
- PropertyChangeMask);
-
- /* Get the window attributes */
- XGetWindowAttributes (pProcArg->pDisplay,
- event.xcreatewindow.window,
- &attr);
-
- if (!attr.override_redirect && attr.class != InputOnly)
- XSetWindowBorderWidth(pProcArg->pDisplay,
- event.xcreatewindow.window,
- 0);
- }
- else if (event.type == MapNotify)
- {
- /* Fake a reparentNotify event as SWT/Motif expects a
- Window Manager to reparent a top-level window when
- it is mapped and waits until they do.
-
- We don't actually need to reparent, as the frame is
- a native window, not an X window
-
- We do this on MapNotify, not MapRequest like a real
- Window Manager would, so we don't have do get involved
- in actually mapping the window via it's (non-existent)
- parent...
-
- See sourceware bugzilla #9848
- */
-
- XWindowAttributes attr;
- Window root;
- Window parent;
- Window *children;
- unsigned int nchildren;
-
- if (XGetWindowAttributes(event.xmap.display,
- event.xmap.window,
- &attr) &&
- XQueryTree(event.xmap.display,
- event.xmap.window,
- &root, &parent, &children, &nchildren))
- {
- if (children) XFree(children);
-
- /*
- It's a top-level window if the parent window is a root window
- Only non-override_redirect windows can get reparented
- */
- if ((attr.root == parent) && !event.xmap.override_redirect)
- {
- XEvent event_send;
-
- event_send.type = ReparentNotify;
- event_send.xreparent.event = event.xmap.window;
- event_send.xreparent.window = event.xmap.window;
- event_send.xreparent.parent = parent;
- event_send.xreparent.x = attr.x;
- event_send.xreparent.y = attr.y;
- event_send.xreparent.override_redirect = False;
-
- XSendEvent(event.xmap.display,
- event.xmap.window,
- True, StructureNotifyMask,
- &event_send);
+ /* Fetch next event */
+ XNextEvent(pProcArg->pDisplay, &event);
+
+ /* Branch on event type */
+ if (event.type == MapNotify /* CreateNotify */) {
+ XWindowAttributes attr;
+
+ XSelectInput(pProcArg->pDisplay,
+ event.xcreatewindow.window, PropertyChangeMask);
+
+ /* Get the window attributes */
+ XGetWindowAttributes(pProcArg->pDisplay,
+ event.xcreatewindow.window, &attr);
+
+ if (!attr.override_redirect && attr.class != InputOnly)
+ XSetWindowBorderWidth(pProcArg->pDisplay,
+ event.xcreatewindow.window, 0);
+ }
+ else if (event.type == MapNotify) {
+ /* Fake a reparentNotify event as SWT/Motif expects a
+ Window Manager to reparent a top-level window when
+ it is mapped and waits until they do.
+
+ We don't actually need to reparent, as the frame is
+ a native window, not an X window
+
+ We do this on MapNotify, not MapRequest like a real
+ Window Manager would, so we don't have do get involved
+ in actually mapping the window via it's (non-existent)
+ parent...
+
+ See sourceware bugzilla #9848
+ */
+
+ XWindowAttributes attr;
+ Window root;
+ Window parent;
+ Window *children;
+ unsigned int nchildren;
+
+ if (XGetWindowAttributes(event.xmap.display,
+ event.xmap.window,
+ &attr) &&
+ XQueryTree(event.xmap.display,
+ event.xmap.window,
+ &root, &parent, &children, &nchildren)) {
+ if (children)
+ XFree(children);
+
+ /*
+ It's a top-level window if the parent window is a root window
+ Only non-override_redirect windows can get reparented
+ */
+ if ((attr.root == parent) && !event.xmap.override_redirect) {
+ XEvent event_send;
+
+ event_send.type = ReparentNotify;
+ event_send.xreparent.event = event.xmap.window;
+ event_send.xreparent.window = event.xmap.window;
+ event_send.xreparent.parent = parent;
+ event_send.xreparent.x = attr.x;
+ event_send.xreparent.y = attr.y;
+ event_send.xreparent.override_redirect = False;
+
+ XSendEvent(event.xmap.display,
+ event.xmap.window,
+ True, StructureNotifyMask, &event_send);
}
}
}
- else if (event.type == ConfigureNotify)
- {
- if (!event.xconfigure.send_event)
- {
- /*
- Java applications using AWT on JRE 1.6.0 break with non-reparenting WMs AWT
- doesn't explicitly know about (See sun bug #6434227)
-
- XDecoratedPeer.handleConfigureNotifyEvent() only processes non-synthetic
- ConfigureNotify events to update window location if it's identified the
- WM as a non-reparenting WM it knows about (compiz or lookingglass)
-
- Rather than tell all sorts of lies to get XWM to recognize us as one of
- those, simply send a synthetic ConfigureNotify for every non-synthetic one
- */
- XEvent event_send = event;
- event_send.xconfigure.send_event = TRUE;
- event_send.xconfigure.event = event.xconfigure.window;
- XSendEvent(event.xconfigure.display,
- event.xconfigure.window,
- True, StructureNotifyMask,
- &event_send);
+ else if (event.type == ConfigureNotify) {
+ if (!event.xconfigure.send_event) {
+ /*
+ Java applications using AWT on JRE 1.6.0 break with non-reparenting WMs AWT
+ doesn't explicitly know about (See sun bug #6434227)
+
+ XDecoratedPeer.handleConfigureNotifyEvent() only processes non-synthetic
+ ConfigureNotify events to update window location if it's identified the
+ WM as a non-reparenting WM it knows about (compiz or lookingglass)
+
+ Rather than tell all sorts of lies to get XWM to recognize us as one of
+ those, simply send a synthetic ConfigureNotify for every non-synthetic one
+ */
+ XEvent event_send = event;
+
+ event_send.xconfigure.send_event = TRUE;
+ event_send.xconfigure.event = event.xconfigure.window;
+ XSendEvent(event.xconfigure.display,
+ event.xconfigure.window,
+ True, StructureNotifyMask, &event_send);
}
}
- else if (event.type == PropertyNotify
- && event.xproperty.atom == atmWmName)
- {
- memset (&msg, 0, sizeof (msg));
-
- msg.msg = WM_WM_NAME_EVENT;
- msg.iWindow = event.xproperty.window;
-
- /* Other fields ignored */
- winSendMessageToWM (pProcArg->pWMInfo, &msg);
- }
- else if (event.type == PropertyNotify
- && event.xproperty.atom == atmWmHints)
- {
- memset (&msg, 0, sizeof (msg));
-
- msg.msg = WM_WM_HINTS_EVENT;
- msg.iWindow = event.xproperty.window;
-
- /* Other fields ignored */
- winSendMessageToWM (pProcArg->pWMInfo, &msg);
- }
- else if (event.type == ClientMessage
- && event.xclient.message_type == atmWmChange
- && event.xclient.data.l[0] == IconicState)
- {
- winDebug ("winMultiWindowXMsgProc - WM_CHANGE_STATE - IconicState\n");
-
- memset (&msg, 0, sizeof (msg));
-
- msg.msg = WM_WM_CHANGE_STATE;
- msg.iWindow = event.xclient.window;
-
- winSendMessageToWM (pProcArg->pWMInfo, &msg);
- }
+ else if (event.type == PropertyNotify
+ && event.xproperty.atom == atmWmName) {
+ memset(&msg, 0, sizeof(msg));
+
+ msg.msg = WM_WM_NAME_EVENT;
+ msg.iWindow = event.xproperty.window;
+
+ /* Other fields ignored */
+ winSendMessageToWM(pProcArg->pWMInfo, &msg);
+ }
+ else if (event.type == PropertyNotify
+ && event.xproperty.atom == atmWmHints) {
+ memset(&msg, 0, sizeof(msg));
+
+ msg.msg = WM_WM_HINTS_EVENT;
+ msg.iWindow = event.xproperty.window;
+
+ /* Other fields ignored */
+ winSendMessageToWM(pProcArg->pWMInfo, &msg);
+ }
+ else if (event.type == ClientMessage
+ && event.xclient.message_type == atmWmChange
+ && event.xclient.data.l[0] == IconicState) {
+ winDebug ("winMultiWindowXMsgProc - WM_CHANGE_STATE - IconicState\n");
+
+ memset(&msg, 0, sizeof(msg));
+
+ msg.msg = WM_WM_CHANGE_STATE;
+ msg.iWindow = event.xclient.window;
+
+ winSendMessageToWM(pProcArg->pWMInfo, &msg);
+ }
}
- XCloseDisplay (pProcArg->pDisplay);
- pthread_cleanup_pop(0);
- return NULL;
+ XCloseDisplay(pProcArg->pDisplay);
+ pthread_cleanup_pop(0);
+ return NULL;
}
-
/*
* winInitWM - Entry point for the X server to spawn
* the Window Manager thread. Called from
@@ -1136,334 +1046,300 @@ winMultiWindowXMsgProc (void *pArg)
*/
Bool
-winInitWM (void **ppWMInfo,
- pthread_t *ptWMProc,
- pthread_t *ptXMsgProc,
- pthread_mutex_t *ppmServerStarted,
- int dwScreen,
- HWND hwndScreen,
- BOOL allowOtherWM)
+winInitWM(void **ppWMInfo,
+ pthread_t * ptWMProc,
+ pthread_t * ptXMsgProc,
+ pthread_mutex_t * ppmServerStarted,
+ int dwScreen, HWND hwndScreen, BOOL allowOtherWM)
{
- WMProcArgPtr pArg = (WMProcArgPtr) malloc (sizeof(WMProcArgRec));
- WMInfoPtr pWMInfo = (WMInfoPtr) malloc (sizeof(WMInfoRec));
- XMsgProcArgPtr pXMsgArg = (XMsgProcArgPtr) malloc (sizeof(XMsgProcArgRec));
-
- /* Bail if the input parameters are bad */
- if (pArg == NULL || pWMInfo == NULL || pXMsgArg == NULL) {
- ErrorF ("winInitWM - malloc failed.\n");
- free(pArg);
- free(pWMInfo);
- free(pXMsgArg);
- return FALSE;
- }
-
- /* Zero the allocated memory */
- ZeroMemory (pArg, sizeof (WMProcArgRec));
- ZeroMemory (pWMInfo, sizeof (WMInfoRec));
- ZeroMemory (pXMsgArg, sizeof (XMsgProcArgRec));
+ WMProcArgPtr pArg = (WMProcArgPtr) malloc(sizeof(WMProcArgRec));
+ WMInfoPtr pWMInfo = (WMInfoPtr) malloc(sizeof(WMInfoRec));
+ XMsgProcArgPtr pXMsgArg = (XMsgProcArgPtr) malloc(sizeof(XMsgProcArgRec));
+
+ /* Bail if the input parameters are bad */
+ if (pArg == NULL || pWMInfo == NULL || pXMsgArg == NULL) {
+ ErrorF("winInitWM - malloc failed.\n");
+ free(pArg);
+ free(pWMInfo);
+ free(pXMsgArg);
+ return FALSE;
+ }
+
+ /* Zero the allocated memory */
+ ZeroMemory(pArg, sizeof(WMProcArgRec));
+ ZeroMemory(pWMInfo, sizeof(WMInfoRec));
+ ZeroMemory(pXMsgArg, sizeof(XMsgProcArgRec));
- /* Set a return pointer to the Window Manager info structure */
- *ppWMInfo = pWMInfo;
+ /* Set a return pointer to the Window Manager info structure */
+ *ppWMInfo = pWMInfo;
#ifdef XWIN_MULTIWINDOWINTWM
- pWMInfo->fAllowOtherWM = allowOtherWM;
+ pWMInfo->fAllowOtherWM = allowOtherWM;
#endif
- /* Setup the argument structure for the thread function */
- pArg->dwScreen = dwScreen;
- pArg->pWMInfo = pWMInfo;
- pArg->ppmServerStarted = ppmServerStarted;
-
- /* Intialize the message queue */
- if (!InitQueue (&pWMInfo->wmMsgQueue))
- {
- ErrorF ("winInitWM - InitQueue () failed.\n");
- return FALSE;
+ /* Setup the argument structure for the thread function */
+ pArg->dwScreen = dwScreen;
+ pArg->pWMInfo = pWMInfo;
+ pArg->ppmServerStarted = ppmServerStarted;
+
+ /* Intialize the message queue */
+ if (!InitQueue(&pWMInfo->wmMsgQueue)) {
+ ErrorF("winInitWM - InitQueue () failed.\n");
+ return FALSE;
}
-
- /* Spawn a thread for the Window Manager */
- if (pthread_create (ptWMProc, NULL, winMultiWindowWMProc, pArg))
- {
- /* Bail if thread creation failed */
- ErrorF ("winInitWM - pthread_create failed for Window Manager.\n");
- return FALSE;
+
+ /* Spawn a thread for the Window Manager */
+ if (pthread_create(ptWMProc, NULL, winMultiWindowWMProc, pArg)) {
+ /* Bail if thread creation failed */
+ ErrorF("winInitWM - pthread_create failed for Window Manager.\n");
+ return FALSE;
}
- /* Spawn the XNextEvent thread, will send messages to WM */
- pXMsgArg->dwScreen = dwScreen;
- pXMsgArg->pWMInfo = pWMInfo;
- pXMsgArg->ppmServerStarted = ppmServerStarted;
- pXMsgArg->hwndScreen = hwndScreen;
- if (pthread_create (ptXMsgProc, NULL, winMultiWindowXMsgProc, pXMsgArg))
- {
- /* Bail if thread creation failed */
- ErrorF ("winInitWM - pthread_create failed on XMSG.\n");
- return FALSE;
+ /* Spawn the XNextEvent thread, will send messages to WM */
+ pXMsgArg->dwScreen = dwScreen;
+ pXMsgArg->pWMInfo = pWMInfo;
+ pXMsgArg->ppmServerStarted = ppmServerStarted;
+ pXMsgArg->hwndScreen = hwndScreen;
+ if (pthread_create(ptXMsgProc, NULL, winMultiWindowXMsgProc, pXMsgArg)) {
+ /* Bail if thread creation failed */
+ ErrorF("winInitWM - pthread_create failed on XMSG.\n");
+ return FALSE;
}
- winDebug ("winInitWM - Returning.\n");
+ winDebug("winInitWM - Returning.\n");
- return TRUE;
+ return TRUE;
}
-
/*
* Window manager thread - setup
*/
static void
-winInitMultiWindowWM (WMInfoPtr pWMInfo, WMProcArgPtr pProcArg)
+winInitMultiWindowWM(WMInfoPtr pWMInfo, WMProcArgPtr pProcArg)
{
- int iRetries = 0;
- char pszDisplay[512];
- int iReturn;
+ int iRetries = 0;
+ char pszDisplay[512];
+ int iReturn;
- winDebug ("winInitMultiWindowWM - Hello\n");
+ winDebug ("winInitMultiWindowWM - Hello\n");
- /* Check that argument pointer is not invalid */
- if (pProcArg == NULL)
- {
- ErrorF ("winInitMultiWindowWM - pProcArg is NULL. Exiting.\n");
- pthread_exit (NULL);
+ /* Check that argument pointer is not invalid */
+ if (pProcArg == NULL) {
+ ErrorF("winInitMultiWindowWM - pProcArg is NULL. Exiting.\n");
+ pthread_exit(NULL);
}
- winDebug ("winInitMultiWindowWM - Calling pthread_mutex_lock ()\n");
+ winDebug ("winInitMultiWindowWM - Calling pthread_mutex_lock ()\n");
- /* Grab our garbage mutex to satisfy pthread_cond_wait */
- iReturn = pthread_mutex_lock (pProcArg->ppmServerStarted);
- if (iReturn != 0)
- {
- ErrorF ("winInitMultiWindowWM - pthread_mutex_lock () failed: %d. "
- "Exiting.\n",
- iReturn);
- pthread_exit (NULL);
+ /* Grab our garbage mutex to satisfy pthread_cond_wait */
+ iReturn = pthread_mutex_lock(pProcArg->ppmServerStarted);
+ if (iReturn != 0) {
+ ErrorF("winInitMultiWindowWM - pthread_mutex_lock () failed: %d. "
+ "Exiting.\n", iReturn);
+ pthread_exit(NULL);
}
- winDebug ("winInitMultiWindowWM - pthread_mutex_lock () returned.\n");
+ winDebug ("winInitMultiWindowWM - pthread_mutex_lock () returned.\n");
- /* Release the server started mutex */
- pthread_mutex_unlock (pProcArg->ppmServerStarted);
+ /* Release the server started mutex */
+ pthread_mutex_unlock(pProcArg->ppmServerStarted);
- winDebug ("winInitMultiWindowWM - pthread_mutex_unlock () returned.\n");
+ winDebug ("winInitMultiWindowWM - pthread_mutex_unlock () returned.\n");
- /* Install our error handler */
- XSetErrorHandler (winMultiWindowWMErrorHandler);
- g_winMultiWindowWMThread = pthread_self();
- g_winMultiWindowWMOldIOErrorHandler = XSetIOErrorHandler (winMultiWindowWMIOErrorHandler);
+ /* Install our error handler */
+ XSetErrorHandler(winMultiWindowWMErrorHandler);
+ g_winMultiWindowWMThread = pthread_self();
+ g_winMultiWindowWMOldIOErrorHandler =
+ XSetIOErrorHandler(winMultiWindowWMIOErrorHandler);
- /* Set jump point for IO Error exits */
- iReturn = setjmp (g_jmpWMEntry);
+ /* Set jump point for IO Error exits */
+ iReturn = setjmp(g_jmpWMEntry);
- /* Check if we should continue operations */
- if (iReturn != WIN_JMP_ERROR_IO
- && iReturn != WIN_JMP_OKAY)
- {
- /* setjmp returned an unknown value, exit */
- ErrorF ("winInitMultiWindowWM - setjmp returned: %d. Exiting.\n",
- iReturn);
- pthread_exit (NULL);
+ /* Check if we should continue operations */
+ if (iReturn != WIN_JMP_ERROR_IO && iReturn != WIN_JMP_OKAY) {
+ /* setjmp returned an unknown value, exit */
+ ErrorF("winInitMultiWindowWM - setjmp returned: %d. Exiting.\n",
+ iReturn);
+ pthread_exit(NULL);
}
- else if (iReturn == WIN_JMP_ERROR_IO)
- {
- ErrorF ("winInitMultiWindowWM - Caught IO Error. Exiting.\n");
- pthread_exit (NULL);
+ else if (iReturn == WIN_JMP_ERROR_IO) {
+ ErrorF("winInitMultiWindowWM - Caught IO Error. Exiting.\n");
+ pthread_exit(NULL);
}
- /* Setup the display connection string x */
- winGetDisplayName(pszDisplay, (int)pProcArg->dwScreen);
-
- /* Print the display connection string */
- winDebug ("winInitMultiWindowWM - DISPLAY=%s\n", pszDisplay);
-
- /* Use our generated cookie for authentication */
- winSetAuthorization();
-
- /* Open the X display */
- do
- {
- /* Try to open the display */
- pWMInfo->pDisplay = XOpenDisplay (pszDisplay);
- if (pWMInfo->pDisplay == NULL)
- {
- ErrorF ("winInitMultiWindowWM - Could not open display, try: %d, "
- "sleeping: %d\n",
- iRetries + 1, WIN_CONNECT_DELAY);
- ++iRetries;
- sleep (WIN_CONNECT_DELAY);
- continue;
- }
- else
- break;
+ /* Setup the display connection string x */
+ winGetDisplayName(pszDisplay, (int)pProcArg->dwScreen);
+
+ /* Print the display connection string */
+ winDebug ("winInitMultiWindowWM - DISPLAY=%s\n", pszDisplay);
+
+ /* Use our generated cookie for authentication */
+ winSetAuthorization();
+
+ /* Open the X display */
+ do {
+ /* Try to open the display */
+ pWMInfo->pDisplay = XOpenDisplay(pszDisplay);
+ if (pWMInfo->pDisplay == NULL) {
+ ErrorF("winInitMultiWindowWM - Could not open display, try: %d, "
+ "sleeping: %d\n", iRetries + 1, WIN_CONNECT_DELAY);
+ ++iRetries;
+ sleep(WIN_CONNECT_DELAY);
+ continue;
+ }
+ else
+ break;
}
- while (pWMInfo->pDisplay == NULL && iRetries < WIN_CONNECT_RETRIES);
-
- /* Make sure that the display opened */
- if (pWMInfo->pDisplay == NULL)
- {
- ErrorF ("winInitMultiWindowWM - Failed opening the display. "
- "Exiting.\n");
- pthread_exit (NULL);
+ while (pWMInfo->pDisplay == NULL && iRetries < WIN_CONNECT_RETRIES);
+
+ /* Make sure that the display opened */
+ if (pWMInfo->pDisplay == NULL) {
+ ErrorF("winInitMultiWindowWM - Failed opening the display. "
+ "Exiting.\n");
+ pthread_exit(NULL);
}
- winDebug ("winInitMultiWindowWM - XOpenDisplay () returned and "
- "successfully opened the display.\n");
-
+ winDebug ("winInitMultiWindowWM - XOpenDisplay () returned and "
+ "successfully opened the display.\n");
- /* Create some atoms */
- pWMInfo->atmWmProtos = XInternAtom (pWMInfo->pDisplay,
- "WM_PROTOCOLS",
- False);
- pWMInfo->atmWmDelete = XInternAtom (pWMInfo->pDisplay,
- "WM_DELETE_WINDOW",
- False);
+ /* Create some atoms */
+ pWMInfo->atmWmProtos = XInternAtom(pWMInfo->pDisplay,
+ "WM_PROTOCOLS", False);
+ pWMInfo->atmWmDelete = XInternAtom(pWMInfo->pDisplay,
+ "WM_DELETE_WINDOW", False);
- pWMInfo->atmPrivMap = XInternAtom (pWMInfo->pDisplay,
- WINDOWSWM_NATIVE_HWND,
- False);
+ pWMInfo->atmPrivMap = XInternAtom(pWMInfo->pDisplay,
+ WINDOWSWM_NATIVE_HWND, False);
+ if (1) {
+ Cursor cursor = XCreateFontCursor(pWMInfo->pDisplay, XC_left_ptr);
- if (1) {
- Cursor cursor = XCreateFontCursor (pWMInfo->pDisplay, XC_left_ptr);
- if (cursor)
- {
- XDefineCursor (pWMInfo->pDisplay, DefaultRootWindow(pWMInfo->pDisplay), cursor);
- XFreeCursor (pWMInfo->pDisplay, cursor);
+ if (cursor) {
+ XDefineCursor(pWMInfo->pDisplay,
+ DefaultRootWindow(pWMInfo->pDisplay), cursor);
+ XFreeCursor(pWMInfo->pDisplay, cursor);
+ }
}
- }
}
-
/*
* winSendMessageToWM - Send a message from the X thread to the WM thread
*/
void
-winSendMessageToWM (void *pWMInfo, winWMMessagePtr pMsg)
+winSendMessageToWM(void *pWMInfo, winWMMessagePtr pMsg)
{
- WMMsgNodePtr pNode;
-
- winDebug ("winSendMessageToWM ()\n");
-
- pNode = (WMMsgNodePtr)malloc(sizeof(WMMsgNodeRec));
- if (pNode != NULL)
- {
- memcpy (&pNode->msg, pMsg, sizeof(winWMMessageRec));
- PushMessage (&((WMInfoPtr)pWMInfo)->wmMsgQueue, pNode);
+ WMMsgNodePtr pNode;
+
+ winDebug ("winSendMessageToWM ()\n");
+
+ pNode = (WMMsgNodePtr) malloc(sizeof(WMMsgNodeRec));
+ if (pNode != NULL) {
+ memcpy(&pNode->msg, pMsg, sizeof(winWMMessageRec));
+ PushMessage(&((WMInfoPtr) pWMInfo)->wmMsgQueue, pNode);
}
}
-
/*
* Window manager error handler
*/
static int
-winMultiWindowWMErrorHandler (Display *pDisplay, XErrorEvent *pErr)
+winMultiWindowWMErrorHandler(Display * pDisplay, XErrorEvent * pErr)
{
- char pszErrorMsg[100];
+ char pszErrorMsg[100];
- if (pErr->request_code == X_ChangeWindowAttributes
- && pErr->error_code == BadAccess)
- {
- ErrorF ("winMultiWindowWMErrorHandler - ChangeWindowAttributes "
- "BadAccess.\n");
- return 0;
+ if (pErr->request_code == X_ChangeWindowAttributes
+ && pErr->error_code == BadAccess) {
+ ErrorF("winMultiWindowWMErrorHandler - ChangeWindowAttributes "
+ "BadAccess.\n");
+ return 0;
}
-
- XGetErrorText (pDisplay,
- pErr->error_code,
- pszErrorMsg,
- sizeof (pszErrorMsg));
- ErrorF ("winMultiWindowWMErrorHandler - ERROR: %s\n"
- " errorCode %d\n"
- " serial %d\n"
- " resourceID 0x%x\n"
- " majorCode %d\n"
- " minorCode %d\n"
- , pszErrorMsg
- , pErr->error_code
- , pErr->serial
- , pErr->resourceid
- , pErr->request_code
- , pErr->minor_code);
-
- return 0;
-}
+ XGetErrorText(pDisplay, pErr->error_code, pszErrorMsg, sizeof(pszErrorMsg));
+ ErrorF ("winMultiWindowWMErrorHandler - ERROR: %s\n"
+ " errorCode %d\n"
+ " serial %d\n"
+ " resourceID 0x%x\n"
+ " majorCode %d\n"
+ " minorCode %d\n"
+ , pszErrorMsg
+ , pErr->error_code
+ , pErr->serial
+ , pErr->resourceid
+ , pErr->request_code
+ , pErr->minor_code);
+
+ return 0;
+}
/*
* Window manager IO error handler
*/
static int
-winMultiWindowWMIOErrorHandler (Display *pDisplay)
+winMultiWindowWMIOErrorHandler(Display * pDisplay)
{
- ErrorF ("winMultiWindowWMIOErrorHandler!\n\n");
+ ErrorF("winMultiWindowWMIOErrorHandler!\n\n");
- if (pthread_equal(pthread_self(),g_winMultiWindowWMThread))
- {
- if (g_shutdown)
- pthread_exit(NULL);
+ if (pthread_equal(pthread_self(), g_winMultiWindowWMThread)) {
+ if (g_shutdown)
+ pthread_exit(NULL);
- /* Restart at the main entry point */
- longjmp (g_jmpWMEntry, WIN_JMP_ERROR_IO);
+ /* Restart at the main entry point */
+ longjmp(g_jmpWMEntry, WIN_JMP_ERROR_IO);
}
- if (g_winMultiWindowWMOldIOErrorHandler)
- g_winMultiWindowWMOldIOErrorHandler(pDisplay);
+ if (g_winMultiWindowWMOldIOErrorHandler)
+ g_winMultiWindowWMOldIOErrorHandler(pDisplay);
- return 0;
+ return 0;
}
-
/*
* X message procedure error handler
*/
static int
-winMultiWindowXMsgProcErrorHandler (Display *pDisplay, XErrorEvent *pErr)
+winMultiWindowXMsgProcErrorHandler(Display * pDisplay, XErrorEvent * pErr)
{
- char pszErrorMsg[100];
-
- XGetErrorText (pDisplay,
- pErr->error_code,
- pszErrorMsg,
- sizeof (pszErrorMsg));
- ErrorF ("winMultiWindowXMsgProcErrorHandler - ERROR: %s\n"
- " errorCode %d\n"
- " serial %d\n"
- " resourceID 0x%x\n"
- " majorCode %d\n"
- " minorCode %d\n"
- , pszErrorMsg
- , pErr->error_code
- , pErr->serial
- , pErr->resourceid
- , pErr->request_code
- , pErr->minor_code);
-
- return 0;
+ char pszErrorMsg[100];
+
+ XGetErrorText(pDisplay, pErr->error_code, pszErrorMsg, sizeof(pszErrorMsg));
+ ErrorF ("winMultiWindowXMsgProcErrorHandler - ERROR: %s\n"
+ " errorCode %d\n"
+ " serial %d\n"
+ " resourceID 0x%x\n"
+ " majorCode %d\n"
+ " minorCode %d\n"
+ , pszErrorMsg
+ , pErr->error_code
+ , pErr->serial
+ , pErr->resourceid
+ , pErr->request_code
+ , pErr->minor_code);
+
+ return 0;
}
-
/*
* X message procedure IO error handler
*/
static int
-winMultiWindowXMsgProcIOErrorHandler (Display *pDisplay)
+winMultiWindowXMsgProcIOErrorHandler(Display * pDisplay)
{
- ErrorF ("winMultiWindowXMsgProcIOErrorHandler!\n\n");
+ ErrorF("winMultiWindowXMsgProcIOErrorHandler!\n\n");
- if (pthread_equal(pthread_self(),g_winMultiWindowXMsgProcThread))
- {
- /* Restart at the main entry point */
- longjmp (g_jmpXMsgProcEntry, WIN_JMP_ERROR_IO);
+ if (pthread_equal(pthread_self(), g_winMultiWindowXMsgProcThread)) {
+ /* Restart at the main entry point */
+ longjmp(g_jmpXMsgProcEntry, WIN_JMP_ERROR_IO);
}
- if (g_winMultiWindowXMsgProcOldIOErrorHandler)
- g_winMultiWindowXMsgProcOldIOErrorHandler(pDisplay);
+ if (g_winMultiWindowXMsgProcOldIOErrorHandler)
+ g_winMultiWindowXMsgProcOldIOErrorHandler(pDisplay);
- return 0;
+ return 0;
}
/*
@@ -1478,47 +1354,48 @@ winMultiWindowThreadExit(void *arg)
/* multiwindow client thread has exited, stop server as well */
TerminateProcess(GetCurrentProcess(),1);
}
-
/*
* Catch RedirectError to detect other window manager running
*/
static int
-winRedirectErrorHandler (Display *pDisplay, XErrorEvent *pErr)
+winRedirectErrorHandler(Display * pDisplay, XErrorEvent * pErr)
{
- redirectError = TRUE;
- return 0;
+ redirectError = TRUE;
+ return 0;
}
-
/*
* Check if another window manager is running
*/
static Bool
-CheckAnotherWindowManager (Display *pDisplay, DWORD dwScreen, Bool fAllowOtherWM)
+CheckAnotherWindowManager(Display * pDisplay, DWORD dwScreen,
+ Bool fAllowOtherWM)
{
- /*
- Try to select the events which only one client at a time is allowed to select.
- If this causes an error, another window manager is already running...
- */
- redirectError = FALSE;
- XSetErrorHandler (winRedirectErrorHandler);
- XSelectInput(pDisplay, RootWindow (pDisplay, dwScreen),
- ResizeRedirectMask | SubstructureRedirectMask | ButtonPressMask);
- XSync (pDisplay, 0);
- XSetErrorHandler (winMultiWindowXMsgProcErrorHandler);
-
- /*
- Side effect: select the events we are actually interested in...
-
- If other WMs are not allowed, also select one of the events which only one client
- at a time is allowed to select, so other window managers won't start...
- */
- XSelectInput(pDisplay, RootWindow (pDisplay, dwScreen),
- SubstructureNotifyMask | ( !fAllowOtherWM ? ButtonPressMask : 0));
- XSync (pDisplay, 0);
- return redirectError;
+ /*
+ Try to select the events which only one client at a time is allowed to select.
+ If this causes an error, another window manager is already running...
+ */
+ redirectError = FALSE;
+ XSetErrorHandler(winRedirectErrorHandler);
+ XSelectInput(pDisplay, RootWindow(pDisplay, dwScreen),
+ ResizeRedirectMask | SubstructureRedirectMask |
+ ButtonPressMask);
+ XSync(pDisplay, 0);
+ XSetErrorHandler(winMultiWindowXMsgProcErrorHandler);
+
+ /*
+ Side effect: select the events we are actually interested in...
+
+ If other WMs are not allowed, also select one of the events which only one client
+ at a time is allowed to select, so other window managers won't start...
+ */
+ XSelectInput(pDisplay, RootWindow(pDisplay, dwScreen),
+ SubstructureNotifyMask | (!fAllowOtherWM ? ButtonPressMask :
+ 0));
+ XSync(pDisplay, 0);
+ return redirectError;
}
/*
@@ -1526,10 +1403,10 @@ CheckAnotherWindowManager (Display *pDisplay, DWORD dwScreen, Bool fAllowOtherWM
*/
void
-winDeinitMultiWindowWM (void)
+winDeinitMultiWindowWM(void)
{
- winDebug ("winDeinitMultiWindowWM - Noting shutdown in progress\n");
- g_shutdown = TRUE;
+ winDebug ("winDeinitMultiWindowWM - Noting shutdown in progress\n");
+ g_shutdown = TRUE;
}
/* Windows window styles */
@@ -1545,254 +1422,276 @@ winDeinitMultiWindowWM (void)
#define HINT_MIN (1L<<1)
static void
-winApplyHints (Display *pDisplay, Window iWindow, HWND hWnd, HWND *zstyle)
+winApplyHints(Display * pDisplay, Window iWindow, HWND hWnd, HWND * zstyle)
{
- static Atom windowState, motif_wm_hints, windowType;
- static Atom hiddenState, fullscreenState, belowState, aboveState;
- static Atom dockWindow;
- static int generation;
- Atom type, *pAtom = NULL;
- int format;
- unsigned long hint = 0, maxmin = 0, style, nitems = 0 , left = 0;
+ static Atom windowState, motif_wm_hints, windowType;
+ static Atom hiddenState, fullscreenState, belowState, aboveState;
+ static Atom dockWindow;
+ static int generation;
+ Atom type, *pAtom = NULL;
+ int format;
+ unsigned long hint = 0, maxmin = 0, style, nitems = 0, left = 0;
WindowPtr pWin = GetProp (hWnd, WIN_WINDOW_PROP);
- MwmHints *mwm_hint = NULL;
+ MwmHints *mwm_hint = NULL;
WinXSizeHints SizeHints;
- if (!hWnd) return;
- if (!IsWindow (hWnd)) return;
-
- if (generation != serverGeneration) {
- generation = serverGeneration;
- windowState = XInternAtom(pDisplay, "_NET_WM_STATE", False);
- motif_wm_hints = XInternAtom(pDisplay, "_MOTIF_WM_HINTS", False);
- windowType = XInternAtom(pDisplay, "_NET_WM_WINDOW_TYPE", False);
- hiddenState = XInternAtom(pDisplay, "_NET_WM_STATE_HIDDEN", False);
- fullscreenState = XInternAtom(pDisplay, "_NET_WM_STATE_FULLSCREEN", False);
- belowState = XInternAtom(pDisplay, "_NET_WM_STATE_BELOW", False);
- aboveState = XInternAtom(pDisplay, "_NET_WM_STATE_ABOVE", False);
- dockWindow = XInternAtom(pDisplay, "_NET_WM_WINDOW_TYPE_DOCK", False);
- }
-
- if (XGetWindowProperty(pDisplay, iWindow, windowState, 0L,
- 1L, False, XA_ATOM, &type, &format,
- &nitems, &left, (unsigned char **)&pAtom) == Success)
- {
- if (pAtom && nitems == 1)
- {
- if (*pAtom == hiddenState) maxmin |= HINT_MIN;
- else if (*pAtom == fullscreenState) maxmin |= HINT_MAX;
- if (*pAtom == belowState) *zstyle = HWND_BOTTOM;
- else if (*pAtom == aboveState) *zstyle = HWND_TOPMOST;
+ if (!hWnd)
+ return;
+ if (!IsWindow(hWnd))
+ return;
+
+ if (generation != serverGeneration) {
+ generation = serverGeneration;
+ windowState = XInternAtom(pDisplay, "_NET_WM_STATE", False);
+ motif_wm_hints = XInternAtom(pDisplay, "_MOTIF_WM_HINTS", False);
+ windowType = XInternAtom(pDisplay, "_NET_WM_WINDOW_TYPE", False);
+ hiddenState = XInternAtom(pDisplay, "_NET_WM_STATE_HIDDEN", False);
+ fullscreenState =
+ XInternAtom(pDisplay, "_NET_WM_STATE_FULLSCREEN", False);
+ belowState = XInternAtom(pDisplay, "_NET_WM_STATE_BELOW", False);
+ aboveState = XInternAtom(pDisplay, "_NET_WM_STATE_ABOVE", False);
+ dockWindow = XInternAtom(pDisplay, "_NET_WM_WINDOW_TYPE_DOCK", False);
}
- if (pAtom) XFree(pAtom);
- }
-
- nitems = left = 0;
- if (XGetWindowProperty(pDisplay, iWindow, motif_wm_hints, 0L,
- PropMwmHintsElements, False, motif_wm_hints, &type, &format,
- &nitems, &left, (unsigned char **)&mwm_hint) == Success)
- {
- if (mwm_hint && nitems == PropMwmHintsElements && (mwm_hint->flags & MwmHintsDecorations))
- {
- if (!mwm_hint->decorations) hint |= HINT_NOFRAME;
- else if (!(mwm_hint->decorations & MwmDecorAll))
- {
- if (mwm_hint->decorations & MwmDecorBorder) hint |= HINT_BORDER;
- if (mwm_hint->decorations & MwmDecorHandle) hint |= HINT_SIZEBOX;
- if (mwm_hint->decorations & MwmDecorTitle) hint |= HINT_CAPTION;
- if (!(mwm_hint->decorations & MwmDecorMenu)) hint |= HINT_NOSYSMENU;
- if (!(mwm_hint->decorations & MwmDecorMinimize)) hint |= HINT_NOMINIMIZE;
- if (!(mwm_hint->decorations & MwmDecorMaximize)) hint |= HINT_NOMAXIMIZE;
- }
- else
- {
- /*
- MwmDecorAll means all decorations *except* those specified by other flag
- bits that are set. Not yet implemented.
- */
- }
+
+ if (XGetWindowProperty(pDisplay, iWindow, windowState, 0L,
+ 1L, False, XA_ATOM, &type, &format,
+ &nitems, &left,
+ (unsigned char **) &pAtom) == Success) {
+ if (pAtom && nitems == 1) {
+ if (*pAtom == hiddenState)
+ maxmin |= HINT_MIN;
+ else if (*pAtom == fullscreenState)
+ maxmin |= HINT_MAX;
+ if (*pAtom == belowState)
+ *zstyle = HWND_BOTTOM;
+ else if (*pAtom == aboveState)
+ *zstyle = HWND_TOPMOST;
+ }
+ if (pAtom)
+ XFree(pAtom);
}
- if (mwm_hint) XFree(mwm_hint);
- }
-
- nitems = left = 0;
- pAtom = NULL;
- if (XGetWindowProperty(pDisplay, iWindow, windowType, 0L,
- 1L, False, XA_ATOM, &type, &format,
- &nitems, &left, (unsigned char **)&pAtom) == Success)
- {
- if (pAtom && nitems == 1)
+
+ nitems = left = 0;
+ if (XGetWindowProperty(pDisplay, iWindow, motif_wm_hints, 0L,
+ PropMwmHintsElements, False, motif_wm_hints, &type,
+ &format, &nitems, &left,
+ (unsigned char **) &mwm_hint) == Success) {
+ if (mwm_hint && nitems == PropMwmHintsElements &&
+ (mwm_hint->flags & MwmHintsDecorations)) {
+ if (!mwm_hint->decorations)
+ hint |= HINT_NOFRAME;
+ else if (!(mwm_hint->decorations & MwmDecorAll)) {
+ if (mwm_hint->decorations & MwmDecorBorder)
+ hint |= HINT_BORDER;
+ if (mwm_hint->decorations & MwmDecorHandle)
+ hint |= HINT_SIZEBOX;
+ if (mwm_hint->decorations & MwmDecorTitle)
+ hint |= HINT_CAPTION;
+ if (!(mwm_hint->decorations & MwmDecorMenu))
+ hint |= HINT_NOSYSMENU;
+ if (!(mwm_hint->decorations & MwmDecorMinimize))
+ hint |= HINT_NOMINIMIZE;
+ if (!(mwm_hint->decorations & MwmDecorMaximize))
+ hint |= HINT_NOMAXIMIZE;
+ }
+ else {
+ /*
+ MwmDecorAll means all decorations *except* those specified by other flag
+ bits that are set. Not yet implemented.
+ */
+ }
+ }
+ if (mwm_hint)
+ XFree(mwm_hint);
+ }
+
+ nitems = left = 0;
+ pAtom = NULL;
+ if (XGetWindowProperty(pDisplay, iWindow, windowType, 0L,
+ 1L, False, XA_ATOM, &type, &format,
+ &nitems, &left,
+ (unsigned char **) &pAtom) == Success) {
+ if (pAtom && nitems == 1) {
+ if (*pAtom == dockWindow) {
+ hint = (hint & ~HINT_NOFRAME) | HINT_SIZEBOX; /* Xming puts a sizebox on dock windows */
+ *zstyle = HWND_TOPMOST;
+ }
+ }
+ if (pAtom)
+ XFree(pAtom);
+ }
+
{
- if (*pAtom == dockWindow)
- {
- hint = (hint & ~HINT_NOFRAME) | HINT_SIZEBOX; /* Xming puts a sizebox on dock windows */
- *zstyle = HWND_TOPMOST;
- }
+ XSizeHints *normal_hint = XAllocSizeHints();
+ long supplied;
+
+ if (normal_hint &&
+ (XGetWMNormalHints(pDisplay, iWindow, normal_hint, &supplied) ==
+ Success)) {
+ if (normal_hint->flags & PMaxSize) {
+ /* Not maximizable if a maximum size is specified */
+ hint |= HINT_NOMAXIMIZE;
+
+ if (normal_hint->flags & PMinSize) {
+ /*
+ If both minimum size and maximum size are specified and are the same,
+ don't bother with a resizing frame
+ */
+ if ((normal_hint->min_width == normal_hint->max_width)
+ && (normal_hint->min_height == normal_hint->max_height))
+ hint = (hint & ~HINT_SIZEBOX);
+ }
+ }
+ }
+ XFree(normal_hint);
}
- if (pAtom) XFree(pAtom);
- }
-
- {
- XSizeHints *normal_hint = XAllocSizeHints();
- long supplied;
- if (normal_hint && (XGetWMNormalHints(pDisplay, iWindow, normal_hint, &supplied) == Success))
- {
- if (normal_hint->flags & PMaxSize)
- {
- /* Not maximizable if a maximum size is specified */
- hint |= HINT_NOMAXIMIZE;
-
- if (normal_hint->flags & PMinSize)
- {
- /*
- If both minimum size and maximum size are specified and are the same,
- don't bother with a resizing frame
- */
- if ((normal_hint->min_width == normal_hint->max_width)
- && (normal_hint->min_height == normal_hint->max_height))
- hint = (hint & ~HINT_SIZEBOX);
- }
- }
- }
- XFree(normal_hint);
- }
-
- /* Override hint settings from above with settings from config file */
- {
- XClassHint class_hint = {0,0};
-
- if (XGetClassHint(pDisplay, iWindow, &class_hint))
- {
- char *window_name = 0;
- char *application_id = 0;
- XFetchName(pDisplay, iWindow, &window_name);
-
- style = winOverrideStyle(class_hint.res_name, class_hint.res_class, window_name);
+
+ /* Override hint settings from above with settings from config file */
+ {
+ XClassHint class_hint = { 0, 0 };
+
+ if (XGetClassHint(pDisplay, iWindow, &class_hint)) {
+ char *window_name = 0;
+ char *application_id = 0;
+ XFetchName(pDisplay, iWindow, &window_name);
+
+ style =
+ winOverrideStyle(class_hint.res_name, class_hint.res_class,
+ window_name);
#define APPLICATION_ID_FORMAT "%s.vcxsrv.%s"
#define APPLICATION_ID_UNKNOWN "unknown"
- if (class_hint.res_class)
- {
- asprintf (&application_id, APPLICATION_ID_FORMAT, XVENDORNAME, class_hint.res_class);
- }
- else
- {
- asprintf (&application_id, APPLICATION_ID_FORMAT, XVENDORNAME, APPLICATION_ID_UNKNOWN);
- }
- winSetAppID (hWnd, application_id);
-
- if (class_hint.res_name) XFree(class_hint.res_name);
- if (class_hint.res_class) XFree(class_hint.res_class);
- if (application_id) free(application_id);
- if (window_name) XFree(window_name);
- }
- else
- {
- style = STYLE_NONE;
- }
- }
-
- if (style & STYLE_TOPMOST) *zstyle = HWND_TOPMOST;
- else if (style & STYLE_MAXIMIZE) maxmin = (hint & ~HINT_MIN) | HINT_MAX;
- else if (style & STYLE_MINIMIZE) maxmin = (hint & ~HINT_MAX) | HINT_MIN;
- else if (style & STYLE_BOTTOM) *zstyle = HWND_BOTTOM;
-
- if (maxmin & HINT_MAX) SendMessage(hWnd, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
- else if (maxmin & HINT_MIN) SendMessage(hWnd, WM_SYSCOMMAND, SC_MINIMIZE, 0);
-
- if (style & STYLE_NOTITLE)
- hint = (hint & ~HINT_NOFRAME & ~HINT_BORDER & ~HINT_CAPTION) | HINT_SIZEBOX;
- else if (style & STYLE_OUTLINE)
- hint = (hint & ~HINT_NOFRAME & ~HINT_CAPTION) | HINT_BORDER;
- else if (style & STYLE_NOFRAME)
- hint = (hint & ~HINT_BORDER & ~HINT_CAPTION) | HINT_NOFRAME;
-
- /* Now apply styles to window */
- style = GetWindowLongPtr(hWnd, GWL_STYLE) & ~WS_CAPTION & ~WS_SIZEBOX; /* Just in case */
- if (!hint) /* All on, but no resize of children is allowed */
- style = style | WS_CAPTION;
- else if (hint & HINT_NOFRAME) /* All off */
- style = style & ~WS_CAPTION & ~WS_SIZEBOX;
- else style = style | ((hint & HINT_BORDER) ? WS_BORDER : 0) |
- ((hint & HINT_SIZEBOX) ? WS_SIZEBOX : 0) |
- ((hint & HINT_CAPTION) ? WS_CAPTION : 0);
-
- if (hint & HINT_NOMAXIMIZE)
- style = style & ~WS_MAXIMIZEBOX;
-
- if (hint & HINT_NOMINIMIZE)
- style = style & ~WS_MINIMIZEBOX;
-
- if (hint & HINT_NOSYSMENU)
- style = style & ~WS_SYSMENU;
-
- if (!IsWindow (hWnd))
- {
- ErrorF("Windows window 0x%x has become invalid, so returning without applying hints\n",hWnd);
- return;
- }
-
- if (winMultiWindowGetWMNormalHints(pWin, &SizeHints))
- {
- if (!(SizeHints.max_width&&SizeHints.max_height&&(SizeHints.min_width == SizeHints.max_width)&&(SizeHints.min_height == SizeHints.max_height) ))
- style|=WS_SIZEBOX;
- }
- else
- style|=WS_SIZEBOX;
- SetWindowLongPtr (hWnd, GWL_STYLE, style);
-}
-
-void
-winUpdateWindowPosition (HWND hWnd, Bool reshape, HWND *zstyle)
-{
- int iX, iY, iWidth, iHeight;
- int iDx, iDy;
- RECT rcNew;
- WindowPtr pWin = GetProp (hWnd, WIN_WINDOW_PROP);
- DrawablePtr pDraw = NULL;
+ if (class_hint.res_class)
+ {
+ asprintf (&application_id, APPLICATION_ID_FORMAT, XVENDORNAME, class_hint.res_class);
+ }
+ else
+ {
+ asprintf (&application_id, APPLICATION_ID_FORMAT, XVENDORNAME, APPLICATION_ID_UNKNOWN);
+ }
+ winSetAppID (hWnd, application_id);
- if (!pWin) return;
- pDraw = &pWin->drawable;
- if (!pDraw) return;
+ if (class_hint.res_name) XFree(class_hint.res_name);
+ if (class_hint.res_class) XFree(class_hint.res_class);
+ if (application_id) free(application_id);
+ if (window_name) XFree(window_name);
+ }
+ else {
+ style = STYLE_NONE;
+ }
+ }
- /* Get the X and Y location of the X window */
- iX = pWin->drawable.x + GetSystemMetrics (SM_XVIRTUALSCREEN);
- iY = pWin->drawable.y + GetSystemMetrics (SM_YVIRTUALSCREEN);
+ if (style & STYLE_TOPMOST)
+ *zstyle = HWND_TOPMOST;
+ else if (style & STYLE_MAXIMIZE)
+ maxmin = (hint & ~HINT_MIN) | HINT_MAX;
+ else if (style & STYLE_MINIMIZE)
+ maxmin = (hint & ~HINT_MAX) | HINT_MIN;
+ else if (style & STYLE_BOTTOM)
+ *zstyle = HWND_BOTTOM;
+
+ if (maxmin & HINT_MAX)
+ SendMessage(hWnd, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
+ else if (maxmin & HINT_MIN)
+ SendMessage(hWnd, WM_SYSCOMMAND, SC_MINIMIZE, 0);
+
+ if (style & STYLE_NOTITLE)
+ hint =
+ (hint & ~HINT_NOFRAME & ~HINT_BORDER & ~HINT_CAPTION) |
+ HINT_SIZEBOX;
+ else if (style & STYLE_OUTLINE)
+ hint =
+ (hint & ~HINT_NOFRAME & ~HINT_CAPTION) | HINT_BORDER;
+ else if (style & STYLE_NOFRAME)
+ hint =
+ (hint & ~HINT_BORDER & ~HINT_CAPTION) | HINT_NOFRAME;
+
+ /* Now apply styles to window */
+ style = GetWindowLongPtr(hWnd, GWL_STYLE) & ~WS_CAPTION & ~WS_SIZEBOX; /* Just in case */
+ if (!hint) /* All on, but no resize of children is allowed */
+ style = style | WS_CAPTION;
+ else if (hint & HINT_NOFRAME) /* All off */
+ style = style & ~WS_CAPTION & ~WS_SIZEBOX;
+ else
+ style = style | ((hint & HINT_BORDER) ? WS_BORDER : 0) |
+ ((hint & HINT_SIZEBOX) ? WS_SIZEBOX : 0) |
+ ((hint & HINT_CAPTION) ? WS_CAPTION : 0);
- /* Get the height and width of the X window */
- iWidth = pWin->drawable.width;
- iHeight = pWin->drawable.height;
+ if (hint & HINT_NOMAXIMIZE)
+ style = style & ~WS_MAXIMIZEBOX;
- /* Setup a rectangle with the X window position and size */
- SetRect (&rcNew, iX, iY, iX + iWidth, iY + iHeight);
+ if (hint & HINT_NOMINIMIZE)
+ style = style & ~WS_MINIMIZEBOX;
- AdjustWindowRectEx (&rcNew, GetWindowLongPtr (hWnd, GWL_STYLE), FALSE, WS_EX_APPWINDOW);
+ if (hint & HINT_NOSYSMENU)
+ style = style & ~WS_SYSMENU;
- /* Don't allow window decoration to disappear off to top-left as a result of this adjustment */
- if (rcNew.left < GetSystemMetrics(SM_XVIRTUALSCREEN))
+ if (!IsWindow (hWnd))
{
- iDx = GetSystemMetrics(SM_XVIRTUALSCREEN) - rcNew.left;
- rcNew.left += iDx;
- rcNew.right += iDx;
+ ErrorF("Windows window 0x%x has become invalid, so returning without applying hints\n",hWnd);
+ return;
}
-
- if (rcNew.top < GetSystemMetrics(SM_YVIRTUALSCREEN))
+
+ if (winMultiWindowGetWMNormalHints(pWin, &SizeHints))
{
- iDy = GetSystemMetrics(SM_YVIRTUALSCREEN) - rcNew.top;
- rcNew.top += iDy;
- rcNew.bottom += iDy;
+ if (!(SizeHints.max_width&&SizeHints.max_height&&(SizeHints.min_width == SizeHints.max_width)&&(SizeHints.min_height == SizeHints.max_height) ))
+ style|=WS_SIZEBOX;
}
+ else
+ style|=WS_SIZEBOX;
+ SetWindowLongPtr(hWnd, GWL_STYLE, style);
+}
- /* Position the Windows window */
- SetWindowPos (hWnd, *zstyle, rcNew.left, rcNew.top,
- rcNew.right - rcNew.left, rcNew.bottom - rcNew.top,
- 0);
+void
+winUpdateWindowPosition(HWND hWnd, Bool reshape, HWND * zstyle)
+{
+ int iX, iY, iWidth, iHeight;
+ int iDx, iDy;
+ RECT rcNew;
+ WindowPtr pWin = GetProp(hWnd, WIN_WINDOW_PROP);
+ DrawablePtr pDraw = NULL;
+
+ if (!pWin)
+ return;
+ pDraw = &pWin->drawable;
+ if (!pDraw)
+ return;
+
+ /* Get the X and Y location of the X window */
+ iX = pWin->drawable.x + GetSystemMetrics(SM_XVIRTUALSCREEN);
+ iY = pWin->drawable.y + GetSystemMetrics(SM_YVIRTUALSCREEN);
+
+ /* Get the height and width of the X window */
+ iWidth = pWin->drawable.width;
+ iHeight = pWin->drawable.height;
+
+ /* Setup a rectangle with the X window position and size */
+ SetRect(&rcNew, iX, iY, iX + iWidth, iY + iHeight);
+
+ AdjustWindowRectEx(&rcNew, GetWindowLongPtr(hWnd, GWL_STYLE), FALSE,
+ WS_EX_APPWINDOW);
+
+ /* Don't allow window decoration to disappear off to top-left as a result of this adjustment */
+ if (rcNew.left < GetSystemMetrics(SM_XVIRTUALSCREEN)) {
+ iDx = GetSystemMetrics(SM_XVIRTUALSCREEN) - rcNew.left;
+ rcNew.left += iDx;
+ rcNew.right += iDx;
+ }
- if (reshape)
- {
- winReshapeMultiWindow(pWin);
- winUpdateRgnMultiWindow(pWin);
- }
+ if (rcNew.top < GetSystemMetrics(SM_YVIRTUALSCREEN)) {
+ iDy = GetSystemMetrics(SM_YVIRTUALSCREEN) - rcNew.top;
+ rcNew.top += iDy;
+ rcNew.bottom += iDy;
+ }
+
+ /* Position the Windows window */
+ SetWindowPos(hWnd, *zstyle, rcNew.left, rcNew.top,
+ rcNew.right - rcNew.left, rcNew.bottom - rcNew.top, 0);
+
+ if (reshape) {
+ winReshapeMultiWindow(pWin);
+ winUpdateRgnMultiWindow(pWin);
+ }
}
void
diff --git a/xorg-server/hw/xwin/winmultiwindowwndproc.c b/xorg-server/hw/xwin/winmultiwindowwndproc.c
index ff66b602f..c124f86ba 100644
--- a/xorg-server/hw/xwin/winmultiwindowwndproc.c
+++ b/xorg-server/hw/xwin/winmultiwindowwndproc.c
@@ -53,15 +53,13 @@
#include <xkbsrv.h>
#endif
-extern void winUpdateWindowPosition (HWND hWnd, Bool reshape, HWND *zstyle);
-
+extern void winUpdateWindowPosition(HWND hWnd, Bool reshape, HWND * zstyle);
/*
* Local globals
*/
-static UINT_PTR g_uipMousePollingTimerID = 0;
-
+static UINT_PTR g_uipMousePollingTimerID = 0;
/*
* Constant defines
@@ -69,244 +67,242 @@ static UINT_PTR g_uipMousePollingTimerID = 0;
#define WIN_MULTIWINDOW_SHAPE YES
-
/*
* ConstrainSize - Taken from TWM sources - Respects hints for sizing
*/
#define makemult(a,b) ((b==1) ? (a) : (((int)((a)/(b))) * (b)) )
static void
-ConstrainSize (WinXSizeHints hints, int *widthp, int *heightp)
+ConstrainSize(WinXSizeHints hints, int *widthp, int *heightp)
{
- int minWidth, minHeight, maxWidth, maxHeight, xinc, yinc, delta;
- int baseWidth, baseHeight;
- int dwidth = *widthp, dheight = *heightp;
-
- if (hints.flags & PMinSize)
- {
- minWidth = hints.min_width;
- minHeight = hints.min_height;
+ int minWidth, minHeight, maxWidth, maxHeight, xinc, yinc, delta;
+ int baseWidth, baseHeight;
+ int dwidth = *widthp, dheight = *heightp;
+
+ if (hints.flags & PMinSize) {
+ minWidth = hints.min_width;
+ minHeight = hints.min_height;
}
- else if (hints.flags & PBaseSize)
- {
- minWidth = hints.base_width;
- minHeight = hints.base_height;
+ else if (hints.flags & PBaseSize) {
+ minWidth = hints.base_width;
+ minHeight = hints.base_height;
}
- else
- minWidth = minHeight = 1;
-
- if (hints.flags & PBaseSize)
- {
- baseWidth = hints.base_width;
- baseHeight = hints.base_height;
- }
- else if (hints.flags & PMinSize)
- {
- baseWidth = hints.min_width;
- baseHeight = hints.min_height;
+ else
+ minWidth = minHeight = 1;
+
+ if (hints.flags & PBaseSize) {
+ baseWidth = hints.base_width;
+ baseHeight = hints.base_height;
}
- else
- baseWidth = baseHeight = 0;
+ else if (hints.flags & PMinSize) {
+ baseWidth = hints.min_width;
+ baseHeight = hints.min_height;
+ }
+ else
+ baseWidth = baseHeight = 0;
- if (hints.flags & PMaxSize)
- {
- maxWidth = hints.max_width;
- maxHeight = hints.max_height;
+ if (hints.flags & PMaxSize) {
+ maxWidth = hints.max_width;
+ maxHeight = hints.max_height;
}
- else
- {
- maxWidth = MAXINT;
- maxHeight = MAXINT;
+ else {
+ maxWidth = MAXINT;
+ maxHeight = MAXINT;
}
- if (hints.flags & PResizeInc)
- {
- xinc = hints.width_inc;
- yinc = hints.height_inc;
+ if (hints.flags & PResizeInc) {
+ xinc = hints.width_inc;
+ yinc = hints.height_inc;
}
- else
- xinc = yinc = 1;
-
- /*
- * First, clamp to min and max values
- */
- if (dwidth < minWidth)
- dwidth = minWidth;
- if (dheight < minHeight)
- dheight = minHeight;
-
- if (dwidth > maxWidth)
- dwidth = maxWidth;
- if (dheight > maxHeight)
- dheight = maxHeight;
-
- /*
- * Second, fit to base + N * inc
- */
- dwidth = ((dwidth - baseWidth) / xinc * xinc) + baseWidth;
- dheight = ((dheight - baseHeight) / yinc * yinc) + baseHeight;
-
- /*
- * Third, adjust for aspect ratio
- */
-
- /*
- * The math looks like this:
- *
- * minAspectX dwidth maxAspectX
- * ---------- <= ------- <= ----------
- * minAspectY dheight maxAspectY
- *
- * If that is multiplied out, then the width and height are
- * invalid in the following situations:
- *
- * minAspectX * dheight > minAspectY * dwidth
- * maxAspectX * dheight < maxAspectY * dwidth
- *
- */
-
- if (hints.flags & PAspect)
- {
- if (hints.min_aspect.x * dheight > hints.min_aspect.y * dwidth)
- {
- delta = makemult(hints.min_aspect.x * dheight / hints.min_aspect.y - dwidth, xinc);
- if (dwidth + delta <= maxWidth)
- dwidth += delta;
- else
- {
- delta = makemult(dheight - dwidth*hints.min_aspect.y/hints.min_aspect.x, yinc);
- if (dheight - delta >= minHeight)
- dheight -= delta;
+ else
+ xinc = yinc = 1;
+
+ /*
+ * First, clamp to min and max values
+ */
+ if (dwidth < minWidth)
+ dwidth = minWidth;
+ if (dheight < minHeight)
+ dheight = minHeight;
+
+ if (dwidth > maxWidth)
+ dwidth = maxWidth;
+ if (dheight > maxHeight)
+ dheight = maxHeight;
+
+ /*
+ * Second, fit to base + N * inc
+ */
+ dwidth = ((dwidth - baseWidth) / xinc * xinc) + baseWidth;
+ dheight = ((dheight - baseHeight) / yinc * yinc) + baseHeight;
+
+ /*
+ * Third, adjust for aspect ratio
+ */
+
+ /*
+ * The math looks like this:
+ *
+ * minAspectX dwidth maxAspectX
+ * ---------- <= ------- <= ----------
+ * minAspectY dheight maxAspectY
+ *
+ * If that is multiplied out, then the width and height are
+ * invalid in the following situations:
+ *
+ * minAspectX * dheight > minAspectY * dwidth
+ * maxAspectX * dheight < maxAspectY * dwidth
+ *
+ */
+
+ if (hints.flags & PAspect) {
+ if (hints.min_aspect.x * dheight > hints.min_aspect.y * dwidth) {
+ delta =
+ makemult(hints.min_aspect.x * dheight / hints.min_aspect.y -
+ dwidth, xinc);
+ if (dwidth + delta <= maxWidth)
+ dwidth += delta;
+ else {
+ delta =
+ makemult(dheight -
+ dwidth * hints.min_aspect.y / hints.min_aspect.x,
+ yinc);
+ if (dheight - delta >= minHeight)
+ dheight -= delta;
}
}
-
- if (hints.max_aspect.x * dheight < hints.max_aspect.y * dwidth)
- {
- delta = makemult(dwidth * hints.max_aspect.y / hints.max_aspect.x - dheight, yinc);
- if (dheight + delta <= maxHeight)
- dheight += delta;
- else
- {
- delta = makemult(dwidth - hints.max_aspect.x*dheight/hints.max_aspect.y, xinc);
- if (dwidth - delta >= minWidth)
- dwidth -= delta;
+
+ if (hints.max_aspect.x * dheight < hints.max_aspect.y * dwidth) {
+ delta =
+ makemult(dwidth * hints.max_aspect.y / hints.max_aspect.x -
+ dheight, yinc);
+ if (dheight + delta <= maxHeight)
+ dheight += delta;
+ else {
+ delta =
+ makemult(dwidth -
+ hints.max_aspect.x * dheight / hints.max_aspect.y,
+ xinc);
+ if (dwidth - delta >= minWidth)
+ dwidth -= delta;
}
}
}
-
- /* Return computed values */
- *widthp = dwidth;
- *heightp = dheight;
-}
-#undef makemult
+ /* Return computed values */
+ *widthp = dwidth;
+ *heightp = dheight;
+}
+#undef makemult
/*
* ValidateSizing - Ensures size request respects hints
*/
static int
-ValidateSizing (HWND hwnd, WindowPtr pWin,
- WPARAM wParam, LPARAM lParam)
+ValidateSizing(HWND hwnd, WindowPtr pWin, WPARAM wParam, LPARAM lParam)
{
- WinXSizeHints sizeHints;
- RECT *rect;
- int iWidth, iHeight;
- RECT rcClient, rcWindow;
- int iBorderWidthX, iBorderWidthY;
-
- /* Invalid input checking */
- if (pWin==NULL || lParam==0)
- return FALSE;
-
- /* No size hints, no checking */
- if (!winMultiWindowGetWMNormalHints (pWin, &sizeHints))
- return FALSE;
-
- /* Avoid divide-by-zero */
- if (sizeHints.flags & PResizeInc)
- {
- if (sizeHints.width_inc == 0) sizeHints.width_inc = 1;
- if (sizeHints.height_inc == 0) sizeHints.height_inc = 1;
+ WinXSizeHints sizeHints;
+ RECT *rect;
+ int iWidth, iHeight;
+ RECT rcClient, rcWindow;
+ int iBorderWidthX, iBorderWidthY;
+
+ /* Invalid input checking */
+ if (pWin == NULL || lParam == 0)
+ return FALSE;
+
+ /* No size hints, no checking */
+ if (!winMultiWindowGetWMNormalHints(pWin, &sizeHints))
+ return FALSE;
+
+ /* Avoid divide-by-zero */
+ if (sizeHints.flags & PResizeInc) {
+ if (sizeHints.width_inc == 0)
+ sizeHints.width_inc = 1;
+ if (sizeHints.height_inc == 0)
+ sizeHints.height_inc = 1;
+ }
+
+ rect = (RECT *) lParam;
+
+ iWidth = rect->right - rect->left;
+ iHeight = rect->bottom - rect->top;
+
+ /* Now remove size of any borders and title bar */
+ GetClientRect(hwnd, &rcClient);
+ GetWindowRect(hwnd, &rcWindow);
+ iBorderWidthX =
+ (rcWindow.right - rcWindow.left) - (rcClient.right - rcClient.left);
+ iBorderWidthY =
+ (rcWindow.bottom - rcWindow.top) - (rcClient.bottom - rcClient.top);
+ iWidth -= iBorderWidthX;
+ iHeight -= iBorderWidthY;
+
+ /* Constrain the size to legal values */
+ ConstrainSize(sizeHints, &iWidth, &iHeight);
+
+ /* Add back the size of borders and title bar */
+ iWidth += iBorderWidthX;
+ iHeight += iBorderWidthY;
+
+ /* Adjust size according to where we're dragging from */
+ switch (wParam) {
+ case WMSZ_TOP:
+ case WMSZ_TOPRIGHT:
+ case WMSZ_BOTTOM:
+ case WMSZ_BOTTOMRIGHT:
+ case WMSZ_RIGHT:
+ rect->right = rect->left + iWidth;
+ break;
+ default:
+ rect->left = rect->right - iWidth;
+ break;
+ }
+ switch (wParam) {
+ case WMSZ_BOTTOM:
+ case WMSZ_BOTTOMRIGHT:
+ case WMSZ_BOTTOMLEFT:
+ case WMSZ_RIGHT:
+ case WMSZ_LEFT:
+ rect->bottom = rect->top + iHeight;
+ break;
+ default:
+ rect->top = rect->bottom - iHeight;
+ break;
}
-
- rect = (RECT*)lParam;
-
- iWidth = rect->right - rect->left;
- iHeight = rect->bottom - rect->top;
-
- /* Now remove size of any borders and title bar */
- GetClientRect(hwnd, &rcClient);
- GetWindowRect(hwnd, &rcWindow);
- iBorderWidthX = (rcWindow.right - rcWindow.left) - (rcClient.right - rcClient.left);
- iBorderWidthY = (rcWindow.bottom - rcWindow.top) - (rcClient.bottom - rcClient.top);
- iWidth -= iBorderWidthX;
- iHeight -= iBorderWidthY;
-
- /* Constrain the size to legal values */
- ConstrainSize (sizeHints, &iWidth, &iHeight);
-
- /* Add back the size of borders and title bar */
- iWidth += iBorderWidthX;
- iHeight += iBorderWidthY;
-
- /* Adjust size according to where we're dragging from */
- switch(wParam) {
- case WMSZ_TOP:
- case WMSZ_TOPRIGHT:
- case WMSZ_BOTTOM:
- case WMSZ_BOTTOMRIGHT:
- case WMSZ_RIGHT:
- rect->right = rect->left + iWidth;
- break;
- default:
- rect->left = rect->right - iWidth;
- break;
- }
- switch(wParam) {
- case WMSZ_BOTTOM:
- case WMSZ_BOTTOMRIGHT:
- case WMSZ_BOTTOMLEFT:
- case WMSZ_RIGHT:
- case WMSZ_LEFT:
- rect->bottom = rect->top + iHeight;
- break;
- default:
- rect->top = rect->bottom - iHeight;
- break;
- }
- return TRUE;
+ return TRUE;
}
extern Bool winInDestroyWindowsWindow;
static Bool winInRaiseWindow = FALSE;
-static void winRaiseWindow(WindowPtr pWin)
+static void
+winRaiseWindow(WindowPtr pWin)
{
- if (!winInDestroyWindowsWindow && !winInRaiseWindow)
- {
- BOOL oldstate = winInRaiseWindow;
- XID vlist[1] = { 0 };
- winInRaiseWindow = TRUE;
- /* Call configure window directly to make sure it gets processed
- * in time
- */
- ConfigureWindow(pWin, CWStackMode, vlist, serverClient);
- winInRaiseWindow = oldstate;
- }
+ if (!winInDestroyWindowsWindow && !winInRaiseWindow) {
+ BOOL oldstate = winInRaiseWindow;
+ XID vlist[1] = { 0 };
+ winInRaiseWindow = TRUE;
+ /* Call configure window directly to make sure it gets processed
+ * in time
+ */
+ ConfigureWindow(pWin, CWStackMode, vlist, serverClient);
+ winInRaiseWindow = oldstate;
+ }
}
static
-void winStartMousePolling(winPrivScreenPtr s_pScreenPriv)
+ void
+winStartMousePolling(winPrivScreenPtr s_pScreenPriv)
{
- /*
- * Timer to poll mouse position. This is needed to make
- * programs like xeyes follow the mouse properly when the
- * mouse pointer is outside of any X window.
- */
- if (g_uipMousePollingTimerID == 0)
- g_uipMousePollingTimerID = SetTimer (s_pScreenPriv->hwndScreen,
- WIN_POLLING_MOUSE_TIMER_ID,
- MOUSE_POLLING_INTERVAL,
- NULL);
+ /*
+ * Timer to poll mouse position. This is needed to make
+ * programs like xeyes follow the mouse properly when the
+ * mouse pointer is outside of any X window.
+ */
+ if (g_uipMousePollingTimerID == 0)
+ g_uipMousePollingTimerID = SetTimer(s_pScreenPriv->hwndScreen,
+ WIN_POLLING_MOUSE_TIMER_ID,
+ MOUSE_POLLING_INTERVAL, NULL);
}
/*
@@ -314,636 +310,630 @@ void winStartMousePolling(winPrivScreenPtr s_pScreenPriv)
*/
LRESULT CALLBACK
-winTopLevelWindowProc (HWND hwnd, UINT message,
- WPARAM wParam, LPARAM lParam)
+winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- POINT ptMouse;
- HDC hdcUpdate;
- PAINTSTRUCT ps;
- WindowPtr pWin = NULL;
- winPrivWinPtr pWinPriv = NULL;
- ScreenPtr s_pScreen = NULL;
- winPrivScreenPtr s_pScreenPriv = NULL;
- winScreenInfo *s_pScreenInfo = NULL;
- HWND hwndScreen = NULL;
- DrawablePtr pDraw = NULL;
- winWMMessageRec wmMsg;
- Bool fWMMsgInitialized = FALSE;
- static Bool s_fTracking = FALSE;
- Bool needRestack = FALSE;
- LRESULT ret;
+ POINT ptMouse;
+ HDC hdcUpdate;
+ PAINTSTRUCT ps;
+ WindowPtr pWin = NULL;
+ winPrivWinPtr pWinPriv = NULL;
+ ScreenPtr s_pScreen = NULL;
+ winPrivScreenPtr s_pScreenPriv = NULL;
+ winScreenInfo *s_pScreenInfo = NULL;
+ HWND hwndScreen = NULL;
+ DrawablePtr pDraw = NULL;
+ winWMMessageRec wmMsg;
+ Bool fWMMsgInitialized = FALSE;
+ static Bool s_fTracking = FALSE;
+ Bool needRestack = FALSE;
+ LRESULT ret;
static Bool hasEnteredSizeMove = FALSE;
- winDebugWin32Message("winTopLevelWindowProc", hwnd, message, wParam, lParam);
-
- /* Check if the Windows window property for our X window pointer is valid */
- if ((pWin = GetProp (hwnd, WIN_WINDOW_PROP)) != NULL)
- {
- /* Our X window pointer is valid */
+ winDebugWin32Message("winTopLevelWindowProc", hwnd, message, wParam,
+ lParam);
+
+ /* Check if the Windows window property for our X window pointer is valid */
+ if ((pWin = GetProp(hwnd, WIN_WINDOW_PROP)) != NULL) {
+ /* Our X window pointer is valid */
- /* Get pointers to the drawable and the screen */
- pDraw = &pWin->drawable;
- s_pScreen = pWin->drawable.pScreen;
+ /* Get pointers to the drawable and the screen */
+ pDraw = &pWin->drawable;
+ s_pScreen = pWin->drawable.pScreen;
- /* Get a pointer to our window privates */
- pWinPriv = winGetWindowPriv(pWin);
+ /* Get a pointer to our window privates */
+ pWinPriv = winGetWindowPriv(pWin);
- /* Get pointers to our screen privates and screen info */
- s_pScreenPriv = pWinPriv->pScreenPriv;
- s_pScreenInfo = s_pScreenPriv->pScreenInfo;
+ /* Get pointers to our screen privates and screen info */
+ s_pScreenPriv = pWinPriv->pScreenPriv;
+ s_pScreenInfo = s_pScreenPriv->pScreenInfo;
- /* Get the handle for our screen-sized window */
- hwndScreen = s_pScreenPriv->hwndScreen;
+ /* Get the handle for our screen-sized window */
+ hwndScreen = s_pScreenPriv->hwndScreen;
- /* */
- wmMsg.msg = 0;
- wmMsg.hwndWindow = hwnd;
- wmMsg.iWindow = (Window)GetProp (hwnd, WIN_WID_PROP);
+ /* */
+ wmMsg.msg = 0;
+ wmMsg.hwndWindow = hwnd;
+ wmMsg.iWindow = (Window) GetProp(hwnd, WIN_WID_PROP);
- wmMsg.iX = pDraw->x;
- wmMsg.iY = pDraw->y;
- wmMsg.iWidth = pDraw->width;
- wmMsg.iHeight = pDraw->height;
+ wmMsg.iX = pDraw->x;
+ wmMsg.iY = pDraw->y;
+ wmMsg.iWidth = pDraw->width;
+ wmMsg.iHeight = pDraw->height;
- fWMMsgInitialized = TRUE;
+ fWMMsgInitialized = TRUE;
}
- #ifdef _DEBUG
- else if (message!=WM_CREATE)
+ #ifdef _DEBUG
+ else if (message!=WM_CREATE)
{
- winDebug("Warning: message 0x%x received when WIN_WINDOW_PROP NULL\n",message);
+ winDebug("Warning: message 0x%x received when WIN_WINDOW_PROP NULL\n",message);
}
#endif
- /* Branch on message type */
- switch (message)
- {
+ /* Branch on message type */
+ switch (message) {
case WM_CREATE:
- /* */
- SetProp (hwnd,
- WIN_WINDOW_PROP,
- (HANDLE)((LPCREATESTRUCT) lParam)->lpCreateParams);
-
- /* */
- SetProp (hwnd,
- WIN_WID_PROP,
- (HANDLE)winGetWindowID (((LPCREATESTRUCT) lParam)->lpCreateParams));
-
- /*
- * Make X windows' Z orders sync with Windows windows because
- * there can be AlwaysOnTop windows overlapped on the window
- * currently being created.
- */
- winReorderWindowsMultiWindow ();
-
- /* Fix a 'round title bar corner background should be transparent not black' problem when first painted */
- {
- RECT rWindow;
- HRGN hRgnWindow;
- GetWindowRect(hwnd, &rWindow);
- hRgnWindow = CreateRectRgnIndirect(&rWindow);
- SetWindowRgn (hwnd, hRgnWindow, TRUE);
- }
+ /* */
+ SetProp(hwnd,
+ WIN_WINDOW_PROP,
+ (HANDLE) ((LPCREATESTRUCT) lParam)->lpCreateParams);
- SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)VCXSRV_SIGNATURE);
+ /* */
+ SetProp(hwnd,
+ WIN_WID_PROP,
+ (HANDLE) winGetWindowID(((LPCREATESTRUCT) lParam)->
+ lpCreateParams));
- return 0;
+ /*
+ * Make X windows' Z orders sync with Windows windows because
+ * there can be AlwaysOnTop windows overlapped on the window
+ * currently being created.
+ */
+ winReorderWindowsMultiWindow();
+
+ /* Fix a 'round title bar corner background should be transparent not black' problem when first painted */
+ {
+ RECT rWindow;
+ HRGN hRgnWindow;
+
+ GetWindowRect(hwnd, &rWindow);
+ hRgnWindow = CreateRectRgnIndirect(&rWindow);
+ SetWindowRgn(hwnd, hRgnWindow, TRUE);
+ }
+
+ SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)VCXSRV_SIGNATURE);
+
+ return 0;
case WM_INIT_SYS_MENU:
- /*
- * Add whatever the setup file wants to for this window
- */
- SetupSysMenu ((unsigned long)hwnd);
- return 0;
+ /*
+ * Add whatever the setup file wants to for this window
+ */
+ SetupSysMenu((unsigned long) hwnd);
+ return 0;
case WM_SYSCOMMAND:
- /*
- * Any window menu items go through here
- */
- if (HandleCustomWM_COMMAND ((unsigned long)hwnd, LOWORD(wParam)))
- {
- /* Don't pass customized menus to DefWindowProc */
- return 0;
- }
- if (wParam == SC_RESTORE || wParam == SC_MAXIMIZE)
- {
- WINDOWPLACEMENT wndpl;
- wndpl.length = sizeof(wndpl);
- if (GetWindowPlacement(hwnd, &wndpl) && wndpl.showCmd == SW_SHOWMINIMIZED)
- needRestack = TRUE;
- }
- break;
+ /*
+ * Any window menu items go through here
+ */
+ if (HandleCustomWM_COMMAND((unsigned long) hwnd, LOWORD(wParam))) {
+ /* Don't pass customized menus to DefWindowProc */
+ return 0;
+ }
+ if (wParam == SC_RESTORE || wParam == SC_MAXIMIZE) {
+ WINDOWPLACEMENT wndpl;
+
+ wndpl.length = sizeof(wndpl);
+ if (GetWindowPlacement(hwnd, &wndpl) &&
+ wndpl.showCmd == SW_SHOWMINIMIZED)
+ needRestack = TRUE;
+ }
+ break;
case WM_INITMENU:
- /* Checks/Unchecks any menu items before they are displayed */
- HandleCustomWM_INITMENU ((unsigned long)hwnd, wParam);
- break;
+ /* Checks/Unchecks any menu items before they are displayed */
+ HandleCustomWM_INITMENU((unsigned long) hwnd, wParam);
+ break;
case WM_ERASEBKGND:
- /*
- * Pretend that we did erase the background but we don't care,
- * since we repaint the entire region anyhow
- * This avoids some flickering when resizing.
- */
- return TRUE;
+ /*
+ * Pretend that we did erase the background but we don't care,
+ * since we repaint the entire region anyhow
+ * This avoids some flickering when resizing.
+ */
+ return TRUE;
case WM_PAINT:
- /* Only paint if our window handle is valid */
- if (hwndScreen == NULL)
- break;
-
- /* BeginPaint gives us an hdc that clips to the invalidated region */
- hdcUpdate = BeginPaint (hwnd, &ps);
- /* Avoid the BitBlt's if the PAINTSTRUCT is bogus */
- if (ps.rcPaint.right==0 && ps.rcPaint.bottom==0 && ps.rcPaint.left==0 && ps.rcPaint.top==0)
- {
- EndPaint (hwnd, &ps);
- return 0;
- }
+ /* Only paint if our window handle is valid */
+ if (hwndScreen == NULL)
+ break;
+
+ /* BeginPaint gives us an hdc that clips to the invalidated region */
+ hdcUpdate = BeginPaint(hwnd, &ps);
+ /* Avoid the BitBlt's if the PAINTSTRUCT is bogus */
+ if (ps.rcPaint.right == 0 && ps.rcPaint.bottom == 0 &&
+ ps.rcPaint.left == 0 && ps.rcPaint.top == 0) {
+ EndPaint(hwnd, &ps);
+ return 0;
+ }
#ifdef XWIN_GLX_WINDOWS
- if (pWinPriv->fWglUsed)
- {
- /*
- For regions which are being drawn by GL, the shadow framebuffer doesn't have the
- correct bits, so don't bitblt from the shadow framebuffer
-
- XXX: For now, just leave it alone, but ideally we want to send an expose event to
- the window so it really redraws the affected region...
- */
- ValidateRect(hwnd, &(ps.rcPaint));
+ if (pWinPriv->fWglUsed) {
+ /*
+ For regions which are being drawn by GL, the shadow framebuffer doesn't have the
+ correct bits, so don't bitblt from the shadow framebuffer
+
+ XXX: For now, just leave it alone, but ideally we want to send an expose event to
+ the window so it really redraws the affected region...
+ */
+ ValidateRect(hwnd, &(ps.rcPaint));
}
- else
+ else
#endif
- /* Try to copy from the shadow buffer */
- if (!BitBlt (hdcUpdate,
- ps.rcPaint.left, ps.rcPaint.top,
- ps.rcPaint.right - ps.rcPaint.left, ps.rcPaint.bottom - ps.rcPaint.top,
- s_pScreenPriv->hdcShadow,
- ps.rcPaint.left + pWin->drawable.x, ps.rcPaint.top + pWin->drawable.y,
- SRCCOPY))
- {
- LPVOID lpMsgBuf;
-
- /* Display a fancy error message */
- FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
- GetLastError (),
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPTSTR) &lpMsgBuf,
- 0, NULL);
-
- ErrorF ("winTopLevelWindowProc - BitBlt failed: %s\n",
- (LPSTR)lpMsgBuf);
- LocalFree (lpMsgBuf);
- }
-
- /* EndPaint frees the DC */
- EndPaint (hwnd, &ps);
- return 0;
+ /* Try to copy from the shadow buffer */
+ if (!BitBlt(hdcUpdate,
+ ps.rcPaint.left, ps.rcPaint.top,
+ ps.rcPaint.right - ps.rcPaint.left,
+ ps.rcPaint.bottom - ps.rcPaint.top,
+ s_pScreenPriv->hdcShadow,
+ ps.rcPaint.left + pWin->drawable.x,
+ ps.rcPaint.top + pWin->drawable.y, SRCCOPY)) {
+ LPVOID lpMsgBuf;
+
+ /* Display a fancy error message */
+ FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ GetLastError(),
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPTSTR) & lpMsgBuf, 0, NULL);
+
+ ErrorF("winTopLevelWindowProc - BitBlt failed: %s\n",
+ (LPSTR) lpMsgBuf);
+ LocalFree(lpMsgBuf);
+ }
+
+ /* EndPaint frees the DC */
+ EndPaint(hwnd, &ps);
+ return 0;
case WM_MOUSEMOVE:
- /* Unpack the client area mouse coordinates */
- ptMouse.x = GET_X_LPARAM(lParam);
- ptMouse.y = GET_Y_LPARAM(lParam);
-
- /* Translate the client area mouse coordinates to screen coordinates */
- ClientToScreen (hwnd, &ptMouse);
-
- /* Screen Coords from (-X, -Y) -> Root Window (0, 0) */
- ptMouse.x -= GetSystemMetrics (SM_XVIRTUALSCREEN);
- ptMouse.y -= GetSystemMetrics (SM_YVIRTUALSCREEN);
-
- /* We can't do anything without privates */
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
-
- /* Has the mouse pointer crossed screens? */
- if (s_pScreen != miPointerGetScreen(g_pwinPointer))
- miPointerSetScreen (g_pwinPointer, s_pScreenInfo->dwScreen,
- ptMouse.x - s_pScreenInfo->dwXOffset,
- ptMouse.y - s_pScreenInfo->dwYOffset);
-
- /* Are we tracking yet? */
- if (!s_fTracking)
- {
- TRACKMOUSEEVENT tme;
-
- /* Setup data structure */
- ZeroMemory (&tme, sizeof (tme));
- tme.cbSize = sizeof (tme);
- tme.dwFlags = TME_LEAVE;
- tme.hwndTrack = hwnd;
-
- /* Call the tracking function */
- if (!TrackMouseEvent(&tme))
- ErrorF ("winTopLevelWindowProc - TrackMouseEvent failed\n");
-
- /* Flag that we are tracking now */
- s_fTracking = TRUE;
- }
-
- /* Hide or show the Windows mouse cursor */
- if (g_fSoftwareCursor && g_fCursor)
- {
- /* Hide Windows cursor */
- g_fCursor = FALSE;
- ShowCursor (FALSE);
- }
-
- /* Kill the timer used to poll mouse events */
- if (g_uipMousePollingTimerID != 0)
- {
- KillTimer (s_pScreenPriv->hwndScreen, WIN_POLLING_MOUSE_TIMER_ID);
- g_uipMousePollingTimerID = 0;
- }
-
- /* Deliver absolute cursor position to X Server */
- winEnqueueMotion(ptMouse.x - s_pScreenInfo->dwXOffset,
- ptMouse.y - s_pScreenInfo->dwYOffset);
+ /* Unpack the client area mouse coordinates */
+ ptMouse.x = GET_X_LPARAM(lParam);
+ ptMouse.y = GET_Y_LPARAM(lParam);
+
+ /* Translate the client area mouse coordinates to screen coordinates */
+ ClientToScreen(hwnd, &ptMouse);
+
+ /* Screen Coords from (-X, -Y) -> Root Window (0, 0) */
+ ptMouse.x -= GetSystemMetrics(SM_XVIRTUALSCREEN);
+ ptMouse.y -= GetSystemMetrics(SM_YVIRTUALSCREEN);
+
+ /* We can't do anything without privates */
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+
+ /* Has the mouse pointer crossed screens? */
+ if (s_pScreen != miPointerGetScreen(g_pwinPointer))
+ miPointerSetScreen(g_pwinPointer, s_pScreenInfo->dwScreen,
+ ptMouse.x - s_pScreenInfo->dwXOffset,
+ ptMouse.y - s_pScreenInfo->dwYOffset);
+
+ /* Are we tracking yet? */
+ if (!s_fTracking) {
+ TRACKMOUSEEVENT tme;
+
+ /* Setup data structure */
+ ZeroMemory(&tme, sizeof(tme));
+ tme.cbSize = sizeof(tme);
+ tme.dwFlags = TME_LEAVE;
+ tme.hwndTrack = hwnd;
+
+ /* Call the tracking function */
+ if (!TrackMouseEvent(&tme))
+ ErrorF("winTopLevelWindowProc - TrackMouseEvent failed\n");
+
+ /* Flag that we are tracking now */
+ s_fTracking = TRUE;
+ }
+
+ /* Hide or show the Windows mouse cursor */
+ if (g_fSoftwareCursor && g_fCursor) {
+ /* Hide Windows cursor */
+ g_fCursor = FALSE;
+ ShowCursor(FALSE);
+ }
+
+ /* Kill the timer used to poll mouse events */
+ if (g_uipMousePollingTimerID != 0) {
+ KillTimer(s_pScreenPriv->hwndScreen, WIN_POLLING_MOUSE_TIMER_ID);
+ g_uipMousePollingTimerID = 0;
+ }
+
+ /* Deliver absolute cursor position to X Server */
+ winEnqueueMotion(ptMouse.x - s_pScreenInfo->dwXOffset,
+ ptMouse.y - s_pScreenInfo->dwYOffset);
+
+ return 0;
- return 0;
-
case WM_NCMOUSEMOVE:
- /*
- * We break instead of returning 0 since we need to call
- * DefWindowProc to get the mouse cursor changes
- * and min/max/close button highlighting in Windows XP.
- * The Platform SDK says that you should return 0 if you
- * process this message, but it fails to mention that you
- * will give up any default functionality if you do return 0.
- */
-
- /* We can't do anything without privates */
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
-
- /* Non-client mouse movement, show Windows cursor */
- if (g_fSoftwareCursor && !g_fCursor)
- {
- g_fCursor = TRUE;
- ShowCursor (TRUE);
- }
-
- winStartMousePolling(s_pScreenPriv);
+ /*
+ * We break instead of returning 0 since we need to call
+ * DefWindowProc to get the mouse cursor changes
+ * and min/max/close button highlighting in Windows XP.
+ * The Platform SDK says that you should return 0 if you
+ * process this message, but it fails to mention that you
+ * will give up any default functionality if you do return 0.
+ */
- break;
+ /* We can't do anything without privates */
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+
+ /* Non-client mouse movement, show Windows cursor */
+ if (g_fSoftwareCursor && !g_fCursor) {
+ g_fCursor = TRUE;
+ ShowCursor(TRUE);
+ }
+
+ winStartMousePolling(s_pScreenPriv);
+
+ break;
case WM_MOUSELEAVE:
/* We can't do anything without privates */
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
- /* Mouse has left our client area */
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ /* Mouse has left our client area */
- /* Flag that we are no longer tracking */
- s_fTracking = FALSE;
+ /* Flag that we are no longer tracking */
+ s_fTracking = FALSE;
- /* Show the mouse cursor, if necessary */
- if (g_fSoftwareCursor && !g_fCursor)
- {
- g_fCursor = TRUE;
- ShowCursor (TRUE);
- }
+ /* Show the mouse cursor, if necessary */
+ if (g_fSoftwareCursor && !g_fCursor) {
+ g_fCursor = TRUE;
+ ShowCursor(TRUE);
+ }
- winStartMousePolling(s_pScreenPriv);
+ winStartMousePolling(s_pScreenPriv);
- return 0;
+ return 0;
case WM_LBUTTONDBLCLK:
case WM_LBUTTONDOWN:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
- g_fButton[0] = TRUE;
- SetCapture(hwnd);
- return winMouseButtonsHandle (s_pScreen, ButtonPress, Button1, wParam);
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ g_fButton[0] = TRUE;
+ SetCapture(hwnd);
+ return winMouseButtonsHandle(s_pScreen, ButtonPress, Button1, wParam);
case WM_LBUTTONUP:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
- g_fButton[0] = FALSE;
- ReleaseCapture();
- winStartMousePolling(s_pScreenPriv);
- return winMouseButtonsHandle (s_pScreen, ButtonRelease, Button1, wParam);
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ g_fButton[0] = FALSE;
+ ReleaseCapture();
+ winStartMousePolling(s_pScreenPriv);
+ return winMouseButtonsHandle(s_pScreen, ButtonRelease, Button1, wParam);
case WM_MBUTTONDBLCLK:
case WM_MBUTTONDOWN:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
- g_fButton[1] = TRUE;
- SetCapture(hwnd);
- return winMouseButtonsHandle (s_pScreen, ButtonPress, Button2, wParam);
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ g_fButton[1] = TRUE;
+ SetCapture(hwnd);
+ return winMouseButtonsHandle(s_pScreen, ButtonPress, Button2, wParam);
case WM_MBUTTONUP:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
- g_fButton[1] = FALSE;
- ReleaseCapture();
- winStartMousePolling(s_pScreenPriv);
- return winMouseButtonsHandle (s_pScreen, ButtonRelease, Button2, wParam);
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ g_fButton[1] = FALSE;
+ ReleaseCapture();
+ winStartMousePolling(s_pScreenPriv);
+ return winMouseButtonsHandle(s_pScreen, ButtonRelease, Button2, wParam);
case WM_RBUTTONDBLCLK:
case WM_RBUTTONDOWN:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
- g_fButton[2] = TRUE;
- SetCapture(hwnd);
- return winMouseButtonsHandle (s_pScreen, ButtonPress, Button3, wParam);
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ g_fButton[2] = TRUE;
+ SetCapture(hwnd);
+ return winMouseButtonsHandle(s_pScreen, ButtonPress, Button3, wParam);
case WM_RBUTTONUP:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
- g_fButton[2] = FALSE;
- ReleaseCapture();
- winStartMousePolling(s_pScreenPriv);
- return winMouseButtonsHandle (s_pScreen, ButtonRelease, Button3, wParam);
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ g_fButton[2] = FALSE;
+ ReleaseCapture();
+ winStartMousePolling(s_pScreenPriv);
+ return winMouseButtonsHandle(s_pScreen, ButtonRelease, Button3, wParam);
case WM_XBUTTONDBLCLK:
case WM_XBUTTONDOWN:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
- SetCapture(hwnd);
- return winMouseButtonsHandle (s_pScreen, ButtonPress, HIWORD(wParam) + 5, wParam);
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ SetCapture(hwnd);
+ return winMouseButtonsHandle(s_pScreen, ButtonPress, HIWORD(wParam) + 5,
+ wParam);
case WM_XBUTTONUP:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
- ReleaseCapture();
- winStartMousePolling(s_pScreenPriv);
- return winMouseButtonsHandle (s_pScreen, ButtonRelease, HIWORD(wParam) + 5, wParam);
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ ReleaseCapture();
+ winStartMousePolling(s_pScreenPriv);
+ return winMouseButtonsHandle(s_pScreen, ButtonRelease,
+ HIWORD(wParam) + 5, wParam);
case WM_MOUSEWHEEL:
- if (SendMessage(hwnd, WM_NCHITTEST, 0, MAKELONG(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))) == HTCLIENT)
- {
- /* Pass the message to the root window */
- SendMessage (hwndScreen, message, wParam, lParam);
- return 0;
- }
- else break;
+ if (SendMessage
+ (hwnd, WM_NCHITTEST, 0,
+ MAKELONG(GET_X_LPARAM(lParam),
+ GET_Y_LPARAM(lParam))) == HTCLIENT) {
+ /* Pass the message to the root window */
+ SendMessage(hwndScreen, message, wParam, lParam);
+ return 0;
+ }
+ else
+ break;
case WM_SETFOCUS:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
- {
- /* Get the parent window for transient handling */
- HWND hParent = GetParent(hwnd);
- if (hParent && IsIconic(hParent)) ShowWindow (hParent, SW_RESTORE);
- }
+ {
+ /* Get the parent window for transient handling */
+ HWND hParent = GetParent(hwnd);
+
+ if (hParent && IsIconic(hParent))
+ ShowWindow(hParent, SW_RESTORE);
+ }
- winRestoreModeKeyStates ();
+ winRestoreModeKeyStates();
+
+ /* Add the keyboard hook if possible */
+ if (g_fKeyboardHookLL)
+ g_fKeyboardHookLL = winInstallKeyboardHookLL();
+ return 0;
- /* Add the keyboard hook if possible */
- if (g_fKeyboardHookLL)
- g_fKeyboardHookLL = winInstallKeyboardHookLL ();
- return 0;
-
case WM_KILLFOCUS:
- /* Pop any pressed keys since we are losing keyboard focus */
- winKeybdReleaseKeys ();
+ /* Pop any pressed keys since we are losing keyboard focus */
+ winKeybdReleaseKeys();
- /* Remove our keyboard hook if it is installed */
- winRemoveKeyboardHookLL ();
+ /* Remove our keyboard hook if it is installed */
+ winRemoveKeyboardHookLL();
- /* Revert the X focus as well, but only if the Windows focus is going to another window */
- if (!wParam && pWin)
- DeleteWindowFromAnyEvents(pWin, FALSE);
+ /* Revert the X focus as well, but only if the Windows focus is going to another window */
+ if (!wParam && pWin)
+ DeleteWindowFromAnyEvents(pWin, FALSE);
- return 0;
+ return 0;
- case WM_SYSDEADCHAR:
+ case WM_SYSDEADCHAR:
case WM_DEADCHAR:
- /*
- * NOTE: We do nothing with WM_*CHAR messages,
- * nor does the root window, so we can just toss these messages.
- */
- return 0;
+ /*
+ * NOTE: We do nothing with WM_*CHAR messages,
+ * nor does the root window, so we can just toss these messages.
+ */
+ return 0;
case WM_SYSKEYDOWN:
case WM_KEYDOWN:
- /*
- * Don't pass Alt-F4 key combo to root window,
- * let Windows translate to WM_CLOSE and close this top-level window.
- *
- * NOTE: We purposely don't check the fUseWinKillKey setting because
- * it should only apply to the key handling for the root window,
- * not for top-level window-manager windows.
- *
- * ALSO NOTE: We do pass Ctrl-Alt-Backspace to the root window
- * because that is a key combo that no X app should be expecting to
- * receive, since it has historically been used to shutdown the X server.
- * Passing Ctrl-Alt-Backspace to the root window preserves that
- * behavior, assuming that -unixkill has been passed as a parameter.
- */
- if (wParam == VK_F4 && (GetKeyState (VK_MENU) & 0x8000))
- break;
+ /*
+ * Don't pass Alt-F4 key combo to root window,
+ * let Windows translate to WM_CLOSE and close this top-level window.
+ *
+ * NOTE: We purposely don't check the fUseWinKillKey setting because
+ * it should only apply to the key handling for the root window,
+ * not for top-level window-manager windows.
+ *
+ * ALSO NOTE: We do pass Ctrl-Alt-Backspace to the root window
+ * because that is a key combo that no X app should be expecting to
+ * receive, since it has historically been used to shutdown the X server.
+ * Passing Ctrl-Alt-Backspace to the root window preserves that
+ * behavior, assuming that -unixkill has been passed as a parameter.
+ */
+ if (wParam == VK_F4 && (GetKeyState(VK_MENU) & 0x8000))
+ break;
#ifdef WINDBG
- if (wParam == VK_ESCAPE)
- {
- /* Place for debug: put any tests and dumps here */
- WINDOWPLACEMENT windPlace;
- RECT rc;
- LPRECT pRect;
-
- windPlace.length = sizeof (WINDOWPLACEMENT);
- GetWindowPlacement (hwnd, &windPlace);
- pRect = &windPlace.rcNormalPosition;
- winDebug ("\nCYGWINDOWING Dump:\n"
- "\tdrawable: (%hd, %hd) - %hdx%hd\n", pDraw->x,
- pDraw->y, pDraw->width, pDraw->height);
- winDebug ("\twindPlace: (%ld, %ld) - %ldx%ld\n", pRect->left,
- pRect->top, pRect->right - pRect->left,
- pRect->bottom - pRect->top);
- if (GetClientRect (hwnd, &rc))
- {
- pRect = &rc;
- winDebug ("\tClientRect: (%ld, %ld) - %ldx%ld\n", pRect->left,
- pRect->top, pRect->right - pRect->left,
- pRect->bottom - pRect->top);
- }
- if (GetWindowRect (hwnd, &rc))
- {
- pRect = &rc;
- winDebug ("\tWindowRect: (%ld, %ld) - %ldx%ld\n", pRect->left,
- pRect->top, pRect->right - pRect->left,
- pRect->bottom - pRect->top);
- }
- winDebug ("\n");
- }
+ if (wParam == VK_ESCAPE) {
+ /* Place for debug: put any tests and dumps here */
+ WINDOWPLACEMENT windPlace;
+ RECT rc;
+ LPRECT pRect;
+
+ windPlace.length = sizeof(WINDOWPLACEMENT);
+ GetWindowPlacement(hwnd, &windPlace);
+ pRect = &windPlace.rcNormalPosition;
+ winDebug ("\nCYGWINDOWING Dump:\n"
+ "\tdrawable: (%hd, %hd) - %hdx%hd\n", pDraw->x,
+ pDraw->y, pDraw->width, pDraw->height);
+ winDebug ("\twindPlace: (%ld, %ld) - %ldx%ld\n", pRect->left,
+ pRect->top, pRect->right - pRect->left,
+ pRect->bottom - pRect->top);
+ if (GetClientRect(hwnd, &rc)) {
+ pRect = &rc;
+ winDebug ("\tClientRect: (%ld, %ld) - %ldx%ld\n", pRect->left,
+ pRect->top, pRect->right - pRect->left,
+ pRect->bottom - pRect->top);
+ }
+ if (GetWindowRect(hwnd, &rc)) {
+ pRect = &rc;
+ winDebug ("\tWindowRect: (%ld, %ld) - %ldx%ld\n", pRect->left,
+ pRect->top, pRect->right - pRect->left,
+ pRect->bottom - pRect->top);
+ }
+ winDebug ("\n");
+ }
#endif
-
- /* Pass the message to the root window */
- return winWindowProc(hwndScreen, message, wParam, lParam);
+
+ /* Pass the message to the root window */
+ return winWindowProc(hwndScreen, message, wParam, lParam);
case WM_SYSKEYUP:
case WM_KEYUP:
-
- /* Pass the message to the root window */
- return winWindowProc(hwndScreen, message, wParam, lParam);
+ /* Pass the message to the root window */
+ return winWindowProc(hwndScreen, message, wParam, lParam);
case WM_HOTKEY:
- /* Pass the message to the root window */
- SendMessage (hwndScreen, message, wParam, lParam);
- return 0;
+ /* Pass the message to the root window */
+ SendMessage(hwndScreen, message, wParam, lParam);
+ return 0;
case WM_ACTIVATE:
- /* Pass the message to the root window */
- SendMessage (hwndScreen, message, wParam, lParam);
-
- if (LOWORD(wParam) != WA_INACTIVE)
- {
- /* Raise the window to the top in Z order */
- /* ago: Activate does not mean putting it to front! */
- /*
- wmMsg.msg = WM_WM_RAISE;
- if (fWMMsgInitialized)
- winSendMessageToWM (s_pScreenPriv->pWMInfo, &wmMsg);
- */
-
- /* Tell our Window Manager thread to activate the window */
- wmMsg.msg = WM_WM_ACTIVATE;
- if (fWMMsgInitialized && pWin->realized && !pWin->overrideRedirect /* for OOo menus */)
- winSendMessageToWM (s_pScreenPriv->pWMInfo, &wmMsg);
- }
- /* Prevent the mouse wheel from stalling when another window is minimized */
- if (HIWORD(wParam) == 0 && LOWORD(wParam) == WA_ACTIVE &&
- (HWND)lParam != NULL && (HWND)lParam != (HWND)GetParent(hwnd))
- SetFocus(hwnd);
- return 0;
+ /* Pass the message to the root window */
+ SendMessage(hwndScreen, message, wParam, lParam);
+
+ if (LOWORD(wParam) != WA_INACTIVE) {
+ /* Raise the window to the top in Z order */
+ /* ago: Activate does not mean putting it to front! */
+ /*
+ wmMsg.msg = WM_WM_RAISE;
+ if (fWMMsgInitialized)
+ winSendMessageToWM (s_pScreenPriv->pWMInfo, &wmMsg);
+ */
+
+ /* Tell our Window Manager thread to activate the window */
+ wmMsg.msg = WM_WM_ACTIVATE;
+ if (fWMMsgInitialized && pWin->realized && !pWin->overrideRedirect /* for OOo menus */)
+ winSendMessageToWM (s_pScreenPriv->pWMInfo, &wmMsg);
+ }
+ /* Prevent the mouse wheel from stalling when another window is minimized */
+ if (HIWORD(wParam) == 0 && LOWORD(wParam) == WA_ACTIVE &&
+ (HWND) lParam != NULL && (HWND) lParam != (HWND) GetParent(hwnd))
+ SetFocus(hwnd);
+ return 0;
case WM_ACTIVATEAPP:
- /*
- * This message is also sent to the root window
- * so we do nothing for individual multiwindow windows
- */
- break;
+ /*
+ * This message is also sent to the root window
+ * so we do nothing for individual multiwindow windows
+ */
+ break;
case WM_CLOSE:
/* Remove property AppUserModelID */
winSetAppID (hwnd, NULL);
- /* Branch on if the window was killed in X already */
- if (pWinPriv->fXKilled)
- {
- /* Window was killed, go ahead and destroy the window */
- DestroyWindow (hwnd);
- }
- else
- {
- /* Tell our Window Manager thread to kill the window */
- wmMsg.msg = WM_WM_KILL;
- if (fWMMsgInitialized)
- winSendMessageToWM (s_pScreenPriv->pWMInfo, &wmMsg);
- }
- return 0;
+ /* Branch on if the window was killed in X already */
+ if (pWinPriv->fXKilled) {
+ /* Window was killed, go ahead and destroy the window */
+ DestroyWindow(hwnd);
+ }
+ else {
+ /* Tell our Window Manager thread to kill the window */
+ wmMsg.msg = WM_WM_KILL;
+ if (fWMMsgInitialized)
+ winSendMessageToWM(s_pScreenPriv->pWMInfo, &wmMsg);
+ }
+ return 0;
case WM_DESTROY:
- /* Branch on if the window was killed in X already */
- if (pWinPriv && !pWinPriv->fXKilled)
- {
- winDebug ("winTopLevelWindowProc - WM_DESTROY - WM_WM_KILL\n");
-
- /* Tell our Window Manager thread to kill the window */
- wmMsg.msg = WM_WM_KILL;
- if (fWMMsgInitialized)
- winSendMessageToWM (s_pScreenPriv->pWMInfo, &wmMsg);
- }
-
- RemoveProp (hwnd, WIN_WINDOW_PROP);
- RemoveProp (hwnd, WIN_WID_PROP);
- RemoveProp (hwnd, WIN_NEEDMANAGE_PROP);
+ /* Branch on if the window was killed in X already */
+ if (pWinPriv && !pWinPriv->fXKilled) {
+ winDebug ("winTopLevelWindowProc - WM_DESTROY - WM_WM_KILL\n");
- break;
+ /* Tell our Window Manager thread to kill the window */
+ wmMsg.msg = WM_WM_KILL;
+ if (fWMMsgInitialized)
+ winSendMessageToWM(s_pScreenPriv->pWMInfo, &wmMsg);
+ }
+
+ RemoveProp(hwnd, WIN_WINDOW_PROP);
+ RemoveProp(hwnd, WIN_WID_PROP);
+ RemoveProp(hwnd, WIN_NEEDMANAGE_PROP);
+
+ break;
case WM_MOVE:
- /* Adjust the X Window to the moved Windows window */
- if (!hasEnteredSizeMove) winAdjustXWindow (pWin, hwnd);
- /* else: Wait for WM_EXITSIZEMOVE */
- return 0;
+ /* Adjust the X Window to the moved Windows window */
+ if (!hasEnteredSizeMove) winAdjustXWindow (pWin, hwnd);
+ /* else: Wait for WM_EXITSIZEMOVE */
+ return 0;
case WM_SHOWWINDOW:
- /* Bail out if the window is being hidden */
- if (!wParam)
- return 0;
-
- /* */
- if (!pWin->overrideRedirect)
- {
- /* Flag that this window needs to be made active when clicked */
- SetProp (hwnd, WIN_NEEDMANAGE_PROP, (HANDLE) 1);
-
- if (!(GetWindowLongPtr (hwnd, GWL_EXSTYLE) & WS_EX_APPWINDOW))
- {
- HWND zstyle = HWND_NOTOPMOST;
-
- /* Set the window extended style flags */
- SetWindowLongPtr (hwnd, GWL_EXSTYLE, WS_EX_APPWINDOW);
-
- /* Set the transient style flags */
- if (GetParent(hwnd)) SetWindowLongPtr (hwnd, GWL_STYLE,
- WS_POPUP | WS_OVERLAPPED | WS_SYSMENU | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
- /* Set the window standard style flags */
- else SetWindowLongPtr (hwnd, GWL_STYLE,
- (WS_POPUP | WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS)
- & ~WS_CAPTION & ~WS_SIZEBOX);
-
- winUpdateWindowPosition (hwnd, FALSE, &zstyle);
-
- {
- WinXWMHints hints;
- if (winMultiWindowGetWMHints(pWin, &hints))
- {
- /*
- Give the window focus, unless it has an InputHint
- which is FALSE (this is used by e.g. glean to
- avoid every test window grabbing the focus)
- */
- if (!((hints.flags & InputHint) && (!hints.input)))
- {
- SetForegroundWindow (hwnd);
- }
- }
- }
- }
- wmMsg.msg = WM_WM_MAP3;
- }
- else /* It is an overridden window so make it top of Z stack */
- {
- HWND forHwnd = GetForegroundWindow();
- winDebug ("overridden window is shown\n");
- if (forHwnd != NULL)
- {
- if (GetWindowLongPtr(forHwnd, GWLP_USERDATA) & (LONG_PTR)VCXSRV_SIGNATURE)
- {
- if (GetWindowLongPtr(forHwnd, GWL_EXSTYLE) & WS_EX_TOPMOST)
- SetWindowPos (hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
- else
- SetWindowPos (hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
- }
- }
- wmMsg.msg = WM_WM_MAP2;
- }
-
- /* Tell our Window Manager thread to map the window */
- if (fWMMsgInitialized)
- winSendMessageToWM (s_pScreenPriv->pWMInfo, &wmMsg);
-
- winStartMousePolling(s_pScreenPriv);
+ /* Bail out if the window is being hidden */
+ if (!wParam)
+ return 0;
+
+ /* */
+ if (!pWin->overrideRedirect) {
+ /* Flag that this window needs to be made active when clicked */
+ SetProp(hwnd, WIN_NEEDMANAGE_PROP, (HANDLE) 1);
+
+ if (!(GetWindowLongPtr(hwnd, GWL_EXSTYLE) & WS_EX_APPWINDOW)) {
+ HWND zstyle = HWND_NOTOPMOST;
+
+ /* Set the window extended style flags */
+ SetWindowLongPtr(hwnd, GWL_EXSTYLE, WS_EX_APPWINDOW);
+
+ /* Set the transient style flags */
+ if (GetParent(hwnd))
+ SetWindowLongPtr(hwnd, GWL_STYLE,
+ WS_POPUP | WS_OVERLAPPED | WS_SYSMENU |
+ WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
+ /* Set the window standard style flags */
+ else
+ SetWindowLongPtr(hwnd, GWL_STYLE,
+ (WS_POPUP | WS_OVERLAPPEDWINDOW |
+ WS_CLIPCHILDREN | WS_CLIPSIBLINGS)
+ & ~WS_CAPTION & ~WS_SIZEBOX);
+
+ winUpdateWindowPosition(hwnd, FALSE, &zstyle);
+
+ {
+ WinXWMHints hints;
+
+ if (winMultiWindowGetWMHints(pWin, &hints)) {
+ /*
+ Give the window focus, unless it has an InputHint
+ which is FALSE (this is used by e.g. glean to
+ avoid every test window grabbing the focus)
+ */
+ if (!((hints.flags & InputHint) && (!hints.input))) {
+ SetForegroundWindow(hwnd);
+ }
+ }
+ }
+ }
+ wmMsg.msg = WM_WM_MAP3;
+ }
+ else { /* It is an overridden window so make it top of Z stack */
+
+ HWND forHwnd = GetForegroundWindow();
+ winDebug ("overridden window is shown\n");
+ if (forHwnd != NULL) {
+ if (GetWindowLongPtr(forHwnd, GWLP_USERDATA) & (LONG_PTR)
+ VCXSRV_SIGNATURE) {
+ if (GetWindowLongPtr(forHwnd, GWL_EXSTYLE) & WS_EX_TOPMOST)
+ SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0,
+ SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
+ else
+ SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0,
+ SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
+ }
+ }
+ wmMsg.msg = WM_WM_MAP2;
+ }
- return 0;
+ /* Tell our Window Manager thread to map the window */
+ if (fWMMsgInitialized)
+ winSendMessageToWM(s_pScreenPriv->pWMInfo, &wmMsg);
+
+ winStartMousePolling(s_pScreenPriv);
+
+ return 0;
case WM_SIZING:
- /* Need to legalize the size according to WM_NORMAL_HINTS */
- /* for applications like xterm */
- return ValidateSizing (hwnd, pWin, wParam, lParam);
+ /* Need to legalize the size according to WM_NORMAL_HINTS */
+ /* for applications like xterm */
+ return ValidateSizing(hwnd, pWin, wParam, lParam);
case WM_WINDOWPOSCHANGING:
{
@@ -966,64 +956,58 @@ winTopLevelWindowProc (HWND hwnd, UINT message,
break;
case WM_WINDOWPOSCHANGED:
- {
- LPWINDOWPOS pWinPos = (LPWINDOWPOS) lParam;
+ {
+ LPWINDOWPOS pWinPos = (LPWINDOWPOS) lParam;
- if (!(pWinPos->flags & SWP_NOZORDER))
- {
+ if (!(pWinPos->flags & SWP_NOZORDER)) {
#if CYGWINDOWING_DEBUG
- winDebug ("\twindow z order was changed\n");
+ winDebug("\twindow z order was changed\n");
#endif
- if (pWinPos->hwndInsertAfter == HWND_TOP
- ||pWinPos->hwndInsertAfter == HWND_TOPMOST
- ||pWinPos->hwndInsertAfter == HWND_NOTOPMOST)
- {
+ if (pWinPos->hwndInsertAfter == HWND_TOP
+ || pWinPos->hwndInsertAfter == HWND_TOPMOST
+ || pWinPos->hwndInsertAfter == HWND_NOTOPMOST) {
#if CYGWINDOWING_DEBUG
- winDebug ("\traise to top\n");
+ winDebug("\traise to top\n");
#endif
- /* Raise the window to the top in Z order */
- winRaiseWindow(pWin);
- }
- else if (pWinPos->hwndInsertAfter == HWND_BOTTOM)
- {
- }
- else
- {
- /* Check if this window is top of X windows. */
- HWND hWndAbove = NULL;
- DWORD dwCurrentProcessID = GetCurrentProcessId ();
- DWORD dwWindowProcessID = 0;
-
- for (hWndAbove = pWinPos->hwndInsertAfter;
- hWndAbove != NULL;
- hWndAbove = GetNextWindow (hWndAbove, GW_HWNDPREV))
- {
- /* Ignore other XWin process's window */
- GetWindowThreadProcessId (hWndAbove, &dwWindowProcessID);
-
- if ((dwWindowProcessID == dwCurrentProcessID)
- && GetProp (hWndAbove, WIN_WINDOW_PROP)
- && !IsWindowVisible (hWndAbove)
- && !IsIconic (hWndAbove) ) /* ignore minimized windows */
- break;
- }
- /* If this is top of X windows in Windows stack,
- raise it in X stack. */
- if (hWndAbove == NULL)
- {
+ /* Raise the window to the top in Z order */
+ winRaiseWindow(pWin);
+ }
+ else if (pWinPos->hwndInsertAfter == HWND_BOTTOM) {
+ }
+ else {
+ /* Check if this window is top of X windows. */
+ HWND hWndAbove = NULL;
+ DWORD dwCurrentProcessID = GetCurrentProcessId();
+ DWORD dwWindowProcessID = 0;
+
+ for (hWndAbove = pWinPos->hwndInsertAfter;
+ hWndAbove != NULL;
+ hWndAbove = GetNextWindow(hWndAbove, GW_HWNDPREV)) {
+ /* Ignore other XWin process's window */
+ GetWindowThreadProcessId(hWndAbove, &dwWindowProcessID);
+
+ if ((dwWindowProcessID == dwCurrentProcessID)
+ && GetProp(hWndAbove, WIN_WINDOW_PROP)
+ && !IsWindowVisible(hWndAbove)
+ && !IsIconic(hWndAbove)) /* ignore minimized windows */
+ break;
+ }
+ /* If this is top of X windows in Windows stack,
+ raise it in X stack. */
+ if (hWndAbove == NULL) {
#if CYGWINDOWING_DEBUG
- winDebug ("\traise to top\n");
+ winDebug("\traise to top\n");
#endif
- winRaiseWindow(pWin);
- }
- }
- }
- }
- /*
- * Pass the message to DefWindowProc to let the function
- * break down WM_WINDOWPOSCHANGED to WM_MOVE and WM_SIZE.
- */
- break;
+ winRaiseWindow(pWin);
+ }
+ }
+ }
+ }
+ /*
+ * Pass the message to DefWindowProc to let the function
+ * break down WM_WINDOWPOSCHANGED to WM_MOVE and WM_SIZE.
+ */
+ break;
case WM_ENTERSIZEMOVE:
hasEnteredSizeMove = TRUE;
@@ -1036,80 +1020,79 @@ winTopLevelWindowProc (HWND hwnd, UINT message,
return 0;
case WM_SIZE:
- /* see dix/window.c */
+ /* see dix/window.c */
#ifdef WINDBG
- {
- char buf[64];
- switch (wParam)
- {
- case SIZE_MINIMIZED:
- strcpy(buf, "SIZE_MINIMIZED");
- break;
- case SIZE_MAXIMIZED:
- strcpy(buf, "SIZE_MAXIMIZED");
- break;
- case SIZE_RESTORED:
- strcpy(buf, "SIZE_RESTORED");
- break;
- default:
- strcpy(buf, "UNKNOWN_FLAG");
- }
- winDebug ("winTopLevelWindowProc - WM_SIZE to %dx%d (%s) - %d ms\n",
- (int)LOWORD(lParam), (int)HIWORD(lParam), buf,
- (int)(GetTickCount ()));
- }
+ {
+ char buf[64];
+
+ switch (wParam) {
+ case SIZE_MINIMIZED:
+ strcpy(buf, "SIZE_MINIMIZED");
+ break;
+ case SIZE_MAXIMIZED:
+ strcpy(buf, "SIZE_MAXIMIZED");
+ break;
+ case SIZE_RESTORED:
+ strcpy(buf, "SIZE_RESTORED");
+ break;
+ default:
+ strcpy(buf, "UNKNOWN_FLAG");
+ }
+ winDebug ("winTopLevelWindowProc - WM_SIZE to %dx%d (%s) - %d ms\n",
+ (int) LOWORD(lParam), (int) HIWORD(lParam), buf,
+ (int) (GetTickCount()));
+ }
#endif
- if (!hasEnteredSizeMove)
+ if (!hasEnteredSizeMove)
{
- /* Adjust the X Window to the moved Windows window */
- winAdjustXWindow (pWin, hwnd);
- if (wParam == SIZE_MINIMIZED) winReorderWindowsMultiWindow();
- }
- /* else: wait for WM_EXITSIZEMOVE */
- return 0; /* end of WM_SIZE handler */
+ /* Adjust the X Window to the moved Windows window */
+ winAdjustXWindow (pWin, hwnd);
+ if (wParam == SIZE_MINIMIZED) winReorderWindowsMultiWindow();
+ }
+ /* else: wait for WM_EXITSIZEMOVE */
+ return 0; /* end of WM_SIZE handler */
case WM_STYLECHANGED:
/* when the style changes, adjust the window size so the client area remains the same */
- {
- LONG x,y;
- DrawablePtr pDraw = &pWin->drawable;
- x = pDraw->x - wBorderWidth(pWin);
- y = pDraw->y - wBorderWidth(pWin);
- winPositionWindowMultiWindow(pWin, x, y);
- }
- return 0;
+ {
+ LONG x,y;
+ DrawablePtr pDraw = &pWin->drawable;
+ x = pDraw->x - wBorderWidth(pWin);
+ y = pDraw->y - wBorderWidth(pWin);
+ winPositionWindowMultiWindow(pWin, x, y);
+ }
+ return 0;
case WM_MOUSEACTIVATE:
- /* Check if this window needs to be made active when clicked */
- if (!GetProp (pWinPriv->hWnd, WIN_NEEDMANAGE_PROP))
- {
- winDebug ("winTopLevelWindowProc - WM_MOUSEACTIVATE - "
- "MA_NOACTIVATE\n");
+ /* Check if this window needs to be made active when clicked */
+ if (!GetProp(pWinPriv->hWnd, WIN_NEEDMANAGE_PROP)) {
+ winDebug ("winTopLevelWindowProc - WM_MOUSEACTIVATE - "
+ "MA_NOACTIVATE\n");
- /* */
- return MA_NOACTIVATE;
- }
- break;
+ /* */
+ return MA_NOACTIVATE;
+ }
+ break;
case WM_SETCURSOR:
- if (LOWORD(lParam) == HTCLIENT)
- {
- if (!g_fSoftwareCursor) SetCursor (s_pScreenPriv->cursor.handle);
- return TRUE;
- }
- break;
+ if (LOWORD(lParam) == HTCLIENT) {
+ if (!g_fSoftwareCursor)
+ SetCursor(s_pScreenPriv->cursor.handle);
+ return TRUE;
+ }
+ break;
default:
- break;
+ break;
}
- ret = DefWindowProc (hwnd, message, wParam, lParam);
- /*
- * If the window was minized we get the stack change before the window is restored
- * and so it gets lost. Ensure there stacking order is correct.
- */
- if (needRestack)
- winReorderWindowsMultiWindow();
- return ret;
+ ret = DefWindowProc(hwnd, message, wParam, lParam);
+ /*
+ * If the window was minized we get the stack change before the window is restored
+ * and so it gets lost. Ensure there stacking order is correct.
+ */
+ if (needRestack)
+ winReorderWindowsMultiWindow();
+ return ret;
}
diff --git a/xorg-server/hw/xwin/winnativegdi.c b/xorg-server/hw/xwin/winnativegdi.c
index c6238d43b..88cc52976 100644
--- a/xorg-server/hw/xwin/winnativegdi.c
+++ b/xorg-server/hw/xwin/winnativegdi.c
@@ -33,76 +33,69 @@
#endif
#include "win.h"
-
/*
* Local function prototypes
*/
static Bool
-winAllocateFBNativeGDI (ScreenPtr pScreen);
+ winAllocateFBNativeGDI(ScreenPtr pScreen);
static void
-winShadowUpdateNativeGDI (ScreenPtr pScreen,
- shadowBufPtr pBuf);
+ winShadowUpdateNativeGDI(ScreenPtr pScreen, shadowBufPtr pBuf);
static Bool
-winCloseScreenNativeGDI (int nIndex, ScreenPtr pScreen);
+ winCloseScreenNativeGDI(int nIndex, ScreenPtr pScreen);
static Bool
-winInitVisualsNativeGDI (ScreenPtr pScreen);
+ winInitVisualsNativeGDI(ScreenPtr pScreen);
static Bool
-winAdjustVideoModeNativeGDI (ScreenPtr pScreen);
+ winAdjustVideoModeNativeGDI(ScreenPtr pScreen);
#if 0
static Bool
-winBltExposedRegionsNativeGDI (ScreenPtr pScreen);
+ winBltExposedRegionsNativeGDI(ScreenPtr pScreen);
#endif
static Bool
-winActivateAppNativeGDI (ScreenPtr pScreen);
+ winActivateAppNativeGDI(ScreenPtr pScreen);
static Bool
-winRedrawScreenNativeGDI (ScreenPtr pScreen);
+ winRedrawScreenNativeGDI(ScreenPtr pScreen);
static Bool
-winRealizeInstalledPaletteNativeGDI (ScreenPtr pScreen);
+ winRealizeInstalledPaletteNativeGDI(ScreenPtr pScreen);
static Bool
-winInstallColormapNativeGDI (ColormapPtr pColormap);
+ winInstallColormapNativeGDI(ColormapPtr pColormap);
static Bool
-winStoreColorsNativeGDI (ColormapPtr pmap,
- int ndef,
- xColorItem *pdefs);
+ winStoreColorsNativeGDI(ColormapPtr pmap, int ndef, xColorItem * pdefs);
static Bool
-winCreateColormapNativeGDI (ColormapPtr pColormap);
+ winCreateColormapNativeGDI(ColormapPtr pColormap);
static Bool
-winDestroyColormapNativeGDI (ColormapPtr pColormap);
-
-
+ winDestroyColormapNativeGDI(ColormapPtr pColormap);
static Bool
-winAllocateFBNativeGDI (ScreenPtr pScreen)
+winAllocateFBNativeGDI(ScreenPtr pScreen)
{
- FatalError ("winAllocateFBNativeGDI\n");
+ FatalError("winAllocateFBNativeGDI\n");
- return TRUE;
+ return TRUE;
}
static void
-winFreeFBNativeGDI (ScreenPtr pScreen)
+winFreeFBNativeGDI(ScreenPtr pScreen)
{
- FatalError ("winFreeFBNativeGDI\n");
+ FatalError("winFreeFBNativeGDI\n");
}
-
static Bool
winInitScreenNativeGDI(ScreenPtr pScreen)
{
- FatalError ("winInitScreenNativeGDI\n");
+ FatalError("winInitScreenNativeGDI\n");
}
/*
@@ -111,425 +104,389 @@ winInitScreenNativeGDI(ScreenPtr pScreen)
*/
static Bool
-winCloseScreenNativeGDI (int nIndex, ScreenPtr pScreen)
+winCloseScreenNativeGDI(int nIndex, ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-
- winDebug ("winCloseScreenNativeGDI - Freeing screen resources\n");
-
- /* Flag that the screen is closed */
- pScreenPriv->fClosed = TRUE;
- pScreenPriv->fActive = FALSE;
-
- /*
- * NOTE: mi doesn't use a CloseScreen procedure, so we do not
- * need to call a wrapped procedure here.
- */
-
- /* Delete the window property */
- RemoveProp (pScreenPriv->hwndScreen, WIN_SCR_PROP);
-
- winDebug ("winCloseScreenNativeGDI - Destroying window\n");
-
- /* Delete tray icon, if we have one */
- if (!pScreenInfo->fNoTrayIcon)
- winDeleteNotifyIcon (pScreenPriv);
-
- /* Free the exit confirmation dialog box, if it exists */
- if (g_hDlgExit != NULL)
- {
- DestroyWindow (g_hDlgExit);
- g_hDlgExit = NULL;
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ winDebug ("winCloseScreenNativeGDI - Freeing screen resources\n");
+
+ /* Flag that the screen is closed */
+ pScreenPriv->fClosed = TRUE;
+ pScreenPriv->fActive = FALSE;
+
+ /*
+ * NOTE: mi doesn't use a CloseScreen procedure, so we do not
+ * need to call a wrapped procedure here.
+ */
+
+ /* Delete the window property */
+ RemoveProp(pScreenPriv->hwndScreen, WIN_SCR_PROP);
+
+ winDebug ("winCloseScreenNativeGDI - Destroying window\n");
+
+ /* Delete tray icon, if we have one */
+ if (!pScreenInfo->fNoTrayIcon)
+ winDeleteNotifyIcon(pScreenPriv);
+
+ /* Free the exit confirmation dialog box, if it exists */
+ if (g_hDlgExit != NULL) {
+ DestroyWindow(g_hDlgExit);
+ g_hDlgExit = NULL;
}
- /* Kill our window */
- if (pScreenPriv->hwndScreen)
- {
- DestroyWindow (pScreenPriv->hwndScreen);
- pScreenPriv->hwndScreen = NULL;
+ /* Kill our window */
+ if (pScreenPriv->hwndScreen) {
+ DestroyWindow(pScreenPriv->hwndScreen);
+ pScreenPriv->hwndScreen = NULL;
}
- /* Invalidate our screeninfo's pointer to the screen */
- pScreenInfo->pScreen = NULL;
+ /* Invalidate our screeninfo's pointer to the screen */
+ pScreenInfo->pScreen = NULL;
- /* Free the screen privates for this screen */
- free (pScreenPriv);
+ /* Free the screen privates for this screen */
+ free(pScreenPriv);
- winDebug ("winCloseScreenNativeGDI - Returning\n");
+ winDebug ("winCloseScreenNativeGDI - Returning\n");
- return TRUE;
+ return TRUE;
}
-
static void
-winShadowUpdateNativeGDI (ScreenPtr pScreen,
- shadowBufPtr pBuf)
+winShadowUpdateNativeGDI(ScreenPtr pScreen, shadowBufPtr pBuf)
{
- FatalError ("winShadowUpdateNativeGDI\n");
- return;
+ FatalError("winShadowUpdateNativeGDI\n");
+ return;
}
-
static Bool
-winInitVisualsNativeGDI (ScreenPtr pScreen)
+winInitVisualsNativeGDI(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- /* Set the bitsPerRGB and bit masks */
- switch (pScreenInfo->dwDepth)
- {
+ /* Set the bitsPerRGB and bit masks */
+ switch (pScreenInfo->dwDepth) {
case 24:
- pScreenPriv->dwBitsPerRGB = 8;
- pScreenPriv->dwRedMask = 0x00FF0000;
- pScreenPriv->dwGreenMask = 0x0000FF00;
- pScreenPriv->dwBlueMask = 0x000000FF;
- break;
-
+ pScreenPriv->dwBitsPerRGB = 8;
+ pScreenPriv->dwRedMask = 0x00FF0000;
+ pScreenPriv->dwGreenMask = 0x0000FF00;
+ pScreenPriv->dwBlueMask = 0x000000FF;
+ break;
+
case 16:
- pScreenPriv->dwBitsPerRGB = 6;
- pScreenPriv->dwRedMask = 0xF800;
- pScreenPriv->dwGreenMask = 0x07E0;
- pScreenPriv->dwBlueMask = 0x001F;
- break;
-
+ pScreenPriv->dwBitsPerRGB = 6;
+ pScreenPriv->dwRedMask = 0xF800;
+ pScreenPriv->dwGreenMask = 0x07E0;
+ pScreenPriv->dwBlueMask = 0x001F;
+ break;
+
case 15:
- pScreenPriv->dwBitsPerRGB = 5;
- pScreenPriv->dwRedMask = 0x7C00;
- pScreenPriv->dwGreenMask = 0x03E0;
- pScreenPriv->dwBlueMask = 0x001F;
- break;
-
+ pScreenPriv->dwBitsPerRGB = 5;
+ pScreenPriv->dwRedMask = 0x7C00;
+ pScreenPriv->dwGreenMask = 0x03E0;
+ pScreenPriv->dwBlueMask = 0x001F;
+ break;
+
case 8:
- pScreenPriv->dwBitsPerRGB = 8;
- pScreenPriv->dwRedMask = 0;
- pScreenPriv->dwGreenMask = 0;
- pScreenPriv->dwBlueMask = 0;
- break;
+ pScreenPriv->dwBitsPerRGB = 8;
+ pScreenPriv->dwRedMask = 0;
+ pScreenPriv->dwGreenMask = 0;
+ pScreenPriv->dwBlueMask = 0;
+ break;
default:
- ErrorF ("winInitVisualsNativeGDI - Unknown screen depth\n");
- return FALSE;
- break;
+ ErrorF("winInitVisualsNativeGDI - Unknown screen depth\n");
+ return FALSE;
+ break;
}
- /* Tell the user how many bits per RGB we are using */
- winDebug ("winInitVisualsNativeGDI - Using dwBitsPerRGB: %d\n",
- (int) pScreenPriv->dwBitsPerRGB);
+ /* Tell the user how many bits per RGB we are using */
+ winDebug ("winInitVisualsNativeGDI - Using dwBitsPerRGB: %d\n",
+ (int) pScreenPriv->dwBitsPerRGB);
- /* Create a single visual according to the Windows screen depth */
- switch (pScreenInfo->dwDepth)
- {
+ /* Create a single visual according to the Windows screen depth */
+ switch (pScreenInfo->dwDepth) {
case 24:
case 16:
case 15:
- if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
- TrueColorMask,
- pScreenPriv->dwBitsPerRGB,
- TrueColor,
- pScreenPriv->dwRedMask,
- pScreenPriv->dwGreenMask,
- pScreenPriv->dwBlueMask))
- {
- ErrorF ("winInitVisuals - miSetVisualTypesAndMasks failed\n");
- return FALSE;
- }
- break;
+ if (!miSetVisualTypesAndMasks(pScreenInfo->dwDepth,
+ TrueColorMask,
+ pScreenPriv->dwBitsPerRGB,
+ TrueColor,
+ pScreenPriv->dwRedMask,
+ pScreenPriv->dwGreenMask,
+ pScreenPriv->dwBlueMask)) {
+ ErrorF("winInitVisuals - miSetVisualTypesAndMasks failed\n");
+ return FALSE;
+ }
+ break;
case 8:
- winDebug ("winInitVisuals - Calling miSetVisualTypesAndMasks\n");
- if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
- StaticColorMask,
- pScreenPriv->dwBitsPerRGB,
- StaticColor,
- pScreenPriv->dwRedMask,
- pScreenPriv->dwGreenMask,
- pScreenPriv->dwBlueMask))
- {
- ErrorF ("winInitVisuals - miSetVisualTypesAndMasks failed\n");
- return FALSE;
- }
- break;
+ winDebug ("winInitVisuals - Calling miSetVisualTypesAndMasks\n");
+ if (!miSetVisualTypesAndMasks(pScreenInfo->dwDepth,
+ StaticColorMask,
+ pScreenPriv->dwBitsPerRGB,
+ StaticColor,
+ pScreenPriv->dwRedMask,
+ pScreenPriv->dwGreenMask,
+ pScreenPriv->dwBlueMask)) {
+ ErrorF("winInitVisuals - miSetVisualTypesAndMasks failed\n");
+ return FALSE;
+ }
+ break;
default:
- ErrorF ("winInitVisualsNativeGDI - Unknown screen depth\n");
- return FALSE;
+ ErrorF("winInitVisualsNativeGDI - Unknown screen depth\n");
+ return FALSE;
}
- winDebug ("winInitVisualsNativeGDI - Returning\n");
+ winDebug ("winInitVisualsNativeGDI - Returning\n");
- return TRUE;
+ return TRUE;
}
-
/* Adjust the video mode */
static Bool
-winAdjustVideoModeNativeGDI (ScreenPtr pScreen)
+winAdjustVideoModeNativeGDI(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- HDC hdc = NULL;
- DWORD dwBPP;
-
- hdc = GetDC (NULL);
-
- /* We're in serious trouble if we can't get a DC */
- if (hdc == NULL)
- {
- ErrorF ("winAdjustVideoModeNativeGDI - GetDC () failed\n");
- return FALSE;
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ HDC hdc = NULL;
+ DWORD dwBPP;
+
+ hdc = GetDC(NULL);
+
+ /* We're in serious trouble if we can't get a DC */
+ if (hdc == NULL) {
+ ErrorF("winAdjustVideoModeNativeGDI - GetDC () failed\n");
+ return FALSE;
}
- /* Query GDI for current display depth */
- dwBPP = GetDeviceCaps (hdc, BITSPIXEL);
- pScreenInfo->dwDepth = GetDeviceCaps (hdc, PLANES);
+ /* Query GDI for current display depth */
+ dwBPP = GetDeviceCaps(hdc, BITSPIXEL);
+ pScreenInfo->dwDepth = GetDeviceCaps(hdc, PLANES);
- switch (pScreenInfo->dwDepth) {
+ switch (pScreenInfo->dwDepth) {
case 24:
case 16:
case 15:
case 8:
- break;
+ break;
default:
- if (dwBPP == 32)
- pScreenInfo->dwDepth = 24;
- else
- pScreenInfo->dwDepth = dwBPP;
- break;
- }
+ if (dwBPP == 32)
+ pScreenInfo->dwDepth = 24;
+ else
+ pScreenInfo->dwDepth = dwBPP;
+ break;
+ }
- /* GDI cannot change the screen depth, so we'll use GDI's depth */
- pScreenInfo->dwBPP = dwBPP;
+ /* GDI cannot change the screen depth, so we'll use GDI's depth */
+ pScreenInfo->dwBPP = dwBPP;
- /* Release our DC */
- ReleaseDC (NULL, hdc);
+ /* Release our DC */
+ ReleaseDC(NULL, hdc);
- return TRUE;
+ return TRUE;
}
-
static Bool
-winActivateAppNativeGDI (ScreenPtr pScreen)
+winActivateAppNativeGDI(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
-
- /*
- * Are we active?
- * Are we fullscreen?
- */
- if (pScreenPriv != NULL
- && pScreenPriv->fActive
- && pScreenPriv->pScreenInfo
- && pScreenPriv->pScreenInfo->fFullScreen)
- {
- /*
- * Activating, attempt to bring our window
- * to the top of the display
- */
- ShowWindow (pScreenPriv->hwndScreen, SW_RESTORE);
+ winScreenPriv(pScreen);
+
+ /*
+ * Are we active?
+ * Are we fullscreen?
+ */
+ if (pScreenPriv != NULL
+ && pScreenPriv->fActive
+ && pScreenPriv->pScreenInfo && pScreenPriv->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
- && pScreenPriv->pScreenInfo
- && pScreenPriv->pScreenInfo->fFullScreen)
- {
- /*
- * Deactivating, stuff our window onto the
- * task bar.
- */
- ShowWindow (pScreenPriv->hwndScreen, SW_MINIMIZE);
+ /*
+ * Are we inactive?
+ * Are we fullscreen?
+ */
+ if (pScreenPriv != NULL
+ && !pScreenPriv->fActive
+ && pScreenPriv->pScreenInfo && pScreenPriv->pScreenInfo->fFullScreen) {
+ /*
+ * Deactivating, stuff our window onto the
+ * task bar.
+ */
+ ShowWindow(pScreenPriv->hwndScreen, SW_MINIMIZE);
}
- return TRUE;
+ return TRUE;
}
-
HBITMAP
-winCreateDIBNativeGDI (int iWidth, int iHeight, int iDepth,
- BYTE **ppbBits, BITMAPINFO **ppbmi)
+winCreateDIBNativeGDI(int iWidth, int iHeight, int iDepth,
+ BYTE ** ppbBits, BITMAPINFO ** ppbmi)
{
- BITMAPINFOHEADER *pbmih = NULL;
- HBITMAP hBitmap = NULL;
- BITMAPINFO *pbmi = NULL;
-
- /* Don't create an invalid bitmap */
- if (iWidth == 0
- || iHeight == 0
- || iDepth == 0)
- {
- ErrorF ("\nwinCreateDIBNativeGDI - Invalid specs w %d h %d d %d\n\n",
- iWidth, iHeight, iDepth);
- return NULL;
+ BITMAPINFOHEADER *pbmih = NULL;
+ HBITMAP hBitmap = NULL;
+ BITMAPINFO *pbmi = NULL;
+
+ /* Don't create an invalid bitmap */
+ if (iWidth == 0 || iHeight == 0 || iDepth == 0) {
+ ErrorF("\nwinCreateDIBNativeGDI - Invalid specs w %d h %d d %d\n\n",
+ iWidth, iHeight, iDepth);
+ return NULL;
}
- /* Allocate bitmap info header */
- pbmih = (BITMAPINFOHEADER*) malloc (sizeof (BITMAPINFOHEADER)
- + 256 * sizeof (RGBQUAD));
- if (pbmih == NULL)
- {
- ErrorF ("winCreateDIBNativeGDI - malloc () failed\n");
- return FALSE;
+ /* Allocate bitmap info header */
+ pbmih = (BITMAPINFOHEADER *) malloc(sizeof(BITMAPINFOHEADER)
+ + 256 * sizeof(RGBQUAD));
+ if (pbmih == NULL) {
+ ErrorF("winCreateDIBNativeGDI - malloc () failed\n");
+ return FALSE;
}
- ZeroMemory (pbmih, sizeof(BITMAPINFOHEADER) + 256 * sizeof (RGBQUAD));
-
- /* Describe bitmap to be created */
- pbmih->biSize = sizeof (BITMAPINFOHEADER);
- pbmih->biWidth = iWidth;
- pbmih->biHeight = -iHeight;
- pbmih->biPlanes = 1;
- pbmih->biBitCount = iDepth;
- pbmih->biCompression = BI_RGB;
+ ZeroMemory(pbmih, sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
+
+ /* Describe bitmap to be created */
+ pbmih->biSize = sizeof(BITMAPINFOHEADER);
+ pbmih->biWidth = iWidth;
+ pbmih->biHeight = -iHeight;
+ pbmih->biPlanes = 1;
+ pbmih->biBitCount = iDepth;
+ pbmih->biCompression = BI_RGB;
/*
- pbmih->biSizeImage = 0;
- pbmih->biXPelsPerMeter = 0;
- pbmih->biYPelsPerMeter = 0;
- pbmih->biClrUsed = 0;
- pbmih->biClrImportant = 0;
+ pbmih->biSizeImage = 0;
+ pbmih->biXPelsPerMeter = 0;
+ pbmih->biYPelsPerMeter = 0;
+ pbmih->biClrUsed = 0;
+ pbmih->biClrImportant = 0;
*/
- /* Setup color table for mono DIBs */
- if (iDepth == 1)
- {
- pbmi = (BITMAPINFO*) pbmih;
- pbmi->bmiColors[1].rgbBlue = 255;
- pbmi->bmiColors[1].rgbGreen = 255;
- pbmi->bmiColors[1].rgbRed = 255;
+ /* Setup color table for mono DIBs */
+ if (iDepth == 1) {
+ pbmi = (BITMAPINFO *) pbmih;
+ pbmi->bmiColors[1].rgbBlue = 255;
+ pbmi->bmiColors[1].rgbGreen = 255;
+ pbmi->bmiColors[1].rgbRed = 255;
}
- /* Create a DIB with a bit pointer */
- hBitmap = CreateDIBSection (NULL,
- (BITMAPINFO *) pbmih,
- DIB_RGB_COLORS,
- (void **) ppbBits,
- NULL,
- 0);
- if (hBitmap == NULL)
- {
- ErrorF ("winCreateDIBNativeGDI - CreateDIBSection () failed\n");
- return NULL;
+ /* Create a DIB with a bit pointer */
+ hBitmap = CreateDIBSection(NULL,
+ (BITMAPINFO *) pbmih,
+ DIB_RGB_COLORS, (void **) ppbBits, NULL, 0);
+ if (hBitmap == NULL) {
+ ErrorF("winCreateDIBNativeGDI - CreateDIBSection () failed\n");
+ return NULL;
}
- /* Free the bitmap info header memory */
- if (ppbmi != NULL)
- {
- /* Store the address of the BMIH in the ppbmih parameter */
- *ppbmi = (BITMAPINFO *) pbmih;
+ /* Free the bitmap info header memory */
+ if (ppbmi != NULL) {
+ /* Store the address of the BMIH in the ppbmih parameter */
+ *ppbmi = (BITMAPINFO *) pbmih;
}
- else
- {
- free (pbmih);
- pbmih = NULL;
+ else {
+ free(pbmih);
+ pbmih = NULL;
}
- return hBitmap;
+ return hBitmap;
}
-
#if 0
static Bool
-winBltExposedRegionsNativeGDI (ScreenPtr pScreen)
+winBltExposedRegionsNativeGDI(ScreenPtr pScreen)
{
-
- return TRUE;
+
+ return TRUE;
}
#endif
-
static Bool
-winRedrawScreenNativeGDI (ScreenPtr pScreen)
+winRedrawScreenNativeGDI(ScreenPtr pScreen)
{
- FatalError ("winRedrawScreenNativeGDI\n");
- return TRUE;
+ FatalError("winRedrawScreenNativeGDI\n");
+ return TRUE;
}
-
static Bool
-winRealizeInstalledPaletteNativeGDI (ScreenPtr pScreen)
+winRealizeInstalledPaletteNativeGDI(ScreenPtr pScreen)
{
- FatalError ("winRealizeInstalledPaletteNativeGDI\n");
- return TRUE;
+ FatalError("winRealizeInstalledPaletteNativeGDI\n");
+ return TRUE;
}
-
static Bool
-winInstallColormapNativeGDI (ColormapPtr pColormap)
+winInstallColormapNativeGDI(ColormapPtr pColormap)
{
- FatalError ("winInstallColormapNativeGDI\n");
- return TRUE;
+ FatalError("winInstallColormapNativeGDI\n");
+ return TRUE;
}
-
static Bool
-winStoreColorsNativeGDI (ColormapPtr pmap,
- int ndef,
- xColorItem *pdefs)
+winStoreColorsNativeGDI(ColormapPtr pmap, int ndef, xColorItem * pdefs)
{
- FatalError ("winStoreColorsNativeGDI\n");
- return TRUE;
+ FatalError("winStoreColorsNativeGDI\n");
+ return TRUE;
}
-
static Bool
-winCreateColormapNativeGDI (ColormapPtr pColormap)
+winCreateColormapNativeGDI(ColormapPtr pColormap)
{
- FatalError ("winCreateColormapNativeGDI\n");
- return TRUE;
+ FatalError("winCreateColormapNativeGDI\n");
+ return TRUE;
}
-
static Bool
-winDestroyColormapNativeGDI (ColormapPtr pColormap)
+winDestroyColormapNativeGDI(ColormapPtr pColormap)
{
- FatalError ("winDestroyColormapNativeGDI\n");
- return TRUE;
+ FatalError("winDestroyColormapNativeGDI\n");
+ return TRUE;
}
-
/* Set engine specific funtions */
Bool
-winSetEngineFunctionsNativeGDI (ScreenPtr pScreen)
+winSetEngineFunctionsNativeGDI(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-
- /* Set our pointers */
- pScreenPriv->pwinAllocateFB = winAllocateFBNativeGDI;
- pScreenPriv->pwinFreeFB = winFreeFBNativeGDI;
- pScreenPriv->pwinShadowUpdate = winShadowUpdateNativeGDI;
- pScreenPriv->pwinInitScreen = winInitScreenNativeGDI;
- pScreenPriv->pwinCloseScreen = winCloseScreenNativeGDI;
- pScreenPriv->pwinInitVisuals = winInitVisualsNativeGDI;
- pScreenPriv->pwinAdjustVideoMode = winAdjustVideoModeNativeGDI;
- if (pScreenInfo->fFullScreen)
- pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowFullScreen;
- else
- pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowWindowed;
- pScreenPriv->pwinFinishScreenInit = winFinishScreenInitNativeGDI;
- /*
- * WARNING: Do not set the BltExposedRegions procedure pointer to anything
- * other than NULL until a working painting procedure is in place.
- * Else, winWindowProc will get stuck in an infinite loop because
- * Windows expects the BeginPaint and EndPaint functions to be called
- * before a WM_PAINT message can be removed from the queue. We are
- * using NULL here as a signal for winWindowProc that it should
- * not signal that the WM_PAINT message has been processed.
- */
- pScreenPriv->pwinBltExposedRegions = NULL;
- pScreenPriv->pwinActivateApp = winActivateAppNativeGDI;
- pScreenPriv->pwinRedrawScreen = winRedrawScreenNativeGDI;
- pScreenPriv->pwinRealizeInstalledPalette =
- winRealizeInstalledPaletteNativeGDI;
- pScreenPriv->pwinInstallColormap = winInstallColormapNativeGDI;
- pScreenPriv->pwinStoreColors = winStoreColorsNativeGDI;
- pScreenPriv->pwinCreateColormap = winCreateColormapNativeGDI;
- pScreenPriv->pwinDestroyColormap = winDestroyColormapNativeGDI;
- pScreenPriv->pwinHotKeyAltTab = (winHotKeyAltTabProcPtr) (void (*)(void))NoopDDA;
-
- return TRUE;
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /* Set our pointers */
+ pScreenPriv->pwinAllocateFB = winAllocateFBNativeGDI;
+ pScreenPriv->pwinFreeFB = winFreeFBNativeGDI;
+ pScreenPriv->pwinShadowUpdate = winShadowUpdateNativeGDI;
+ pScreenPriv->pwinInitScreen = winInitScreenNativeGDI;
+ pScreenPriv->pwinCloseScreen = winCloseScreenNativeGDI;
+ pScreenPriv->pwinInitVisuals = winInitVisualsNativeGDI;
+ pScreenPriv->pwinAdjustVideoMode = winAdjustVideoModeNativeGDI;
+ if (pScreenInfo->fFullScreen)
+ pScreenPriv->pwinCreateBoundingWindow =
+ winCreateBoundingWindowFullScreen;
+ else
+ pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowWindowed;
+ pScreenPriv->pwinFinishScreenInit = winFinishScreenInitNativeGDI;
+ /*
+ * WARNING: Do not set the BltExposedRegions procedure pointer to anything
+ * other than NULL until a working painting procedure is in place.
+ * Else, winWindowProc will get stuck in an infinite loop because
+ * Windows expects the BeginPaint and EndPaint functions to be called
+ * before a WM_PAINT message can be removed from the queue. We are
+ * using NULL here as a signal for winWindowProc that it should
+ * not signal that the WM_PAINT message has been processed.
+ */
+ pScreenPriv->pwinBltExposedRegions = NULL;
+ pScreenPriv->pwinActivateApp = winActivateAppNativeGDI;
+ pScreenPriv->pwinRedrawScreen = winRedrawScreenNativeGDI;
+ pScreenPriv->pwinRealizeInstalledPalette =
+ winRealizeInstalledPaletteNativeGDI;
+ pScreenPriv->pwinInstallColormap = winInstallColormapNativeGDI;
+ pScreenPriv->pwinStoreColors = winStoreColorsNativeGDI;
+ pScreenPriv->pwinCreateColormap = winCreateColormapNativeGDI;
+ pScreenPriv->pwinDestroyColormap = winDestroyColormapNativeGDI;
+ pScreenPriv->pwinHotKeyAltTab =
+ (winHotKeyAltTabProcPtr) (void (*)(void)) NoopDDA;
+
+ return TRUE;
}
diff --git a/xorg-server/hw/xwin/winpfbdd.c b/xorg-server/hw/xwin/winpfbdd.c
index 3ea61ade2..d9b095f3a 100644
--- a/xorg-server/hw/xwin/winpfbdd.c
+++ b/xorg-server/hw/xwin/winpfbdd.c
@@ -36,241 +36,225 @@
#endif
#include "win.h"
-
/*
* Local function prototypes
*/
static Bool
-winAllocateFBPrimaryDD (ScreenPtr pScreen);
+ winAllocateFBPrimaryDD(ScreenPtr pScreen);
static Bool
-winCloseScreenPrimaryDD (int nIndex, ScreenPtr pScreen);
+ winCloseScreenPrimaryDD(int nIndex, ScreenPtr pScreen);
static Bool
-winInitVisualsPrimaryDD (ScreenPtr pScreen);
+ winInitVisualsPrimaryDD(ScreenPtr pScreen);
static Bool
-winAdjustVideoModePrimaryDD (ScreenPtr pScreen);
+ winAdjustVideoModePrimaryDD(ScreenPtr pScreen);
static Bool
-winActivateAppPrimaryDD (ScreenPtr pScreen);
+ winActivateAppPrimaryDD(ScreenPtr pScreen);
static Bool
-winHotKeyAltTabPrimaryDD (ScreenPtr pScreen);
-
+ winHotKeyAltTabPrimaryDD(ScreenPtr pScreen);
/*
* Create a DirectDraw primary surface
*/
static Bool
-winAllocateFBPrimaryDD (ScreenPtr pScreen)
+winAllocateFBPrimaryDD(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- HRESULT ddrval = DD_OK;
- DDSURFACEDESC ddsd;
- DDSURFACEDESC *pddsdPrimary = NULL;
- DDSURFACEDESC *pddsdOffscreen = NULL;
- RECT rcClient;
-
- winDebug ("winAllocateFBPrimaryDD\n");
-
- /* Get client area location in screen coords */
- GetClientRect (pScreenPriv->hwndScreen, &rcClient);
- MapWindowPoints (pScreenPriv->hwndScreen,
- HWND_DESKTOP,
- (LPPOINT)&rcClient, 2);
-
- /* Create a DirectDraw object, store the address at lpdd */
- ddrval = (*g_fpDirectDrawCreate) (NULL, &pScreenPriv->pdd, NULL);
- if (ddrval != DD_OK)
- FatalError ("winAllocateFBPrimaryDD - Could not start DirectDraw\n");
-
- /* Get a DirectDraw2 interface pointer */
- ddrval = IDirectDraw_QueryInterface (pScreenPriv->pdd,
- &IID_IDirectDraw2,
- (LPVOID*) &pScreenPriv->pdd2);
- if (FAILED (ddrval))
- {
- ErrorF ("winAllocateFBShadowDD - Failed DD2 query: %08x\n",
- (unsigned int) ddrval);
- return FALSE;
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ HRESULT ddrval = DD_OK;
+ DDSURFACEDESC ddsd;
+ DDSURFACEDESC *pddsdPrimary = NULL;
+ DDSURFACEDESC *pddsdOffscreen = NULL;
+ RECT rcClient;
+
+ winDebug ("winAllocateFBPrimaryDD\n");
+
+ /* Get client area location in screen coords */
+ GetClientRect(pScreenPriv->hwndScreen, &rcClient);
+ MapWindowPoints(pScreenPriv->hwndScreen,
+ HWND_DESKTOP, (LPPOINT) & rcClient, 2);
+
+ /* Create a DirectDraw object, store the address at lpdd */
+ ddrval = (*g_fpDirectDrawCreate) (NULL, &pScreenPriv->pdd, NULL);
+ if (ddrval != DD_OK)
+ FatalError("winAllocateFBPrimaryDD - Could not start DirectDraw\n");
+
+ /* Get a DirectDraw2 interface pointer */
+ ddrval = IDirectDraw_QueryInterface(pScreenPriv->pdd,
+ &IID_IDirectDraw2,
+ (LPVOID *) & pScreenPriv->pdd2);
+ if (FAILED(ddrval)) {
+ ErrorF("winAllocateFBShadowDD - Failed DD2 query: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
}
-
- winDebug ("winAllocateFBPrimaryDD - Created and initialized DD\n");
-
- /* Are we windowed or fullscreen? */
- if (pScreenInfo->fFullScreen)
- {
- /* Full screen mode */
- ddrval = IDirectDraw2_SetCooperativeLevel (pScreenPriv->pdd2,
- pScreenPriv->hwndScreen,
- DDSCL_FULLSCREEN
- | DDSCL_EXCLUSIVE);
- if (FAILED (ddrval))
- FatalError ("winAllocateFBPrimaryDD - Could not set "
- "cooperative level\n");
-
- /* Change the video mode to the mode requested */
- ddrval = IDirectDraw2_SetDisplayMode (pScreenPriv->pdd2,
- pScreenInfo->dwWidth,
- pScreenInfo->dwHeight,
- pScreenInfo->dwBPP,
- pScreenInfo->dwRefreshRate,
- 0);
- if (FAILED (ddrval))
- FatalError ("winAllocateFBPrimaryDD - Could not set "
- "full screen display mode\n");
+ winDebug ("winAllocateFBPrimaryDD - Created and initialized DD\n");
+
+ /* Are we windowed or fullscreen? */
+ if (pScreenInfo->fFullScreen) {
+ /* Full screen mode */
+ ddrval = IDirectDraw2_SetCooperativeLevel(pScreenPriv->pdd2,
+ pScreenPriv->hwndScreen,
+ DDSCL_FULLSCREEN
+ | DDSCL_EXCLUSIVE);
+ if (FAILED(ddrval))
+ FatalError("winAllocateFBPrimaryDD - Could not set "
+ "cooperative level\n");
+
+ /* Change the video mode to the mode requested */
+ ddrval = IDirectDraw2_SetDisplayMode(pScreenPriv->pdd2,
+ pScreenInfo->dwWidth,
+ pScreenInfo->dwHeight,
+ pScreenInfo->dwBPP,
+ pScreenInfo->dwRefreshRate, 0);
+ if (FAILED(ddrval))
+ FatalError("winAllocateFBPrimaryDD - Could not set "
+ "full screen display mode\n");
}
- else
- {
- /* Windowed mode */
- ddrval = IDirectDraw2_SetCooperativeLevel (pScreenPriv->pdd2,
- pScreenPriv->hwndScreen,
- DDSCL_NORMAL);
- if (FAILED (ddrval))
- FatalError ("winAllocateFBPrimaryDD - Could not set "
- "cooperative level\n");
+ else {
+ /* Windowed mode */
+ ddrval = IDirectDraw2_SetCooperativeLevel(pScreenPriv->pdd2,
+ pScreenPriv->hwndScreen,
+ DDSCL_NORMAL);
+ if (FAILED(ddrval))
+ FatalError("winAllocateFBPrimaryDD - Could not set "
+ "cooperative level\n");
}
- /* Describe the primary surface */
- ZeroMemory (&ddsd, sizeof (ddsd));
- ddsd.dwSize = sizeof (ddsd);
- ddsd.dwFlags = DDSD_CAPS;
- ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
-
- /* Create the primary surface */
- ddrval = IDirectDraw2_CreateSurface (pScreenPriv->pdd2,
- &ddsd,
- &pScreenPriv->pddsPrimary,
- NULL);
- if (FAILED (ddrval))
- FatalError ("winAllocateFBPrimaryDD - Could not create primary "
- "surface %08x\n", (unsigned int) ddrval);
-
- winDebug ("winAllocateFBPrimaryDD - Created primary\n");
-
- /* Allocate a DD surface description for our screen privates */
- pddsdPrimary = pScreenPriv->pddsdPrimary
- = malloc (sizeof (DDSURFACEDESC));
- if (pddsdPrimary == NULL)
- FatalError ("winAllocateFBPrimaryDD - Could not allocate surface "
- "description memory\n");
- ZeroMemory (pddsdPrimary, sizeof (*pddsdPrimary));
- pddsdPrimary->dwSize = sizeof (*pddsdPrimary);
-
- /* Describe the offscreen surface to be created */
- /*
- * NOTE: Do not use a DDSCAPS_VIDEOMEMORY surface,
- * as drawing, locking, and unlocking take forever
- * with video memory surfaces. In addition,
- * video memory is a somewhat scarce resource,
- * so you shouldn't be allocating video memory when
- * you have the option of using system memory instead.
- */
- ZeroMemory (&ddsd, sizeof (ddsd));
- ddsd.dwSize = sizeof (ddsd);
- ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
- ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
- ddsd.dwHeight = pScreenInfo->dwHeight;
- ddsd.dwWidth = pScreenInfo->dwWidth;
-
- /* Create the shadow surface */
- ddrval = IDirectDraw2_CreateSurface (pScreenPriv->pdd2,
- &ddsd,
- &pScreenPriv->pddsOffscreen,
- NULL);
- if (ddrval != DD_OK)
- FatalError ("winAllocateFBPrimaryDD - Could not create shadow "
- "surface\n");
-
- winDebug ("winAllocateFBPrimaryDD - Created offscreen\n");
-
- /* Allocate a DD surface description for our screen privates */
- pddsdOffscreen = pScreenPriv->pddsdOffscreen
- = malloc (sizeof (DDSURFACEDESC));
- if (pddsdOffscreen == NULL)
- FatalError ("winAllocateFBPrimaryDD - Could not allocate surface "
- "description memory\n");
- ZeroMemory (pddsdOffscreen, sizeof (*pddsdOffscreen));
- pddsdOffscreen->dwSize = sizeof (*pddsdOffscreen);
-
- winDebug ("winAllocateFBPrimaryDD - Locking primary\n");
-
- /* Lock the primary surface */
- ddrval = IDirectDrawSurface2_Lock (pScreenPriv->pddsPrimary,
- pScreenInfo->fFullScreen ? NULL:&rcClient,
- pddsdPrimary,
- DDLOCK_WAIT,
- NULL);
- if (ddrval != DD_OK || pddsdPrimary->lpSurface == NULL)
- FatalError ("winAllocateFBPrimaryDD - Could not lock "
- "primary surface\n");
-
- winDebug ("winAllocateFBPrimaryDD - Locked primary\n");
-
- /* We don't know how to deal with anything other than RGB */
- if (!(pddsdPrimary->ddpfPixelFormat.dwFlags & DDPF_RGB))
- FatalError ("winAllocateFBPrimaryDD - Color format other than RGB\n");
-
- /* Grab the pitch from the surface desc */
- pScreenInfo->dwStride = (pddsdPrimary->u1.lPitch * 8)
- / pScreenInfo->dwBPP;
-
- /* Save the pointer to our surface memory */
- pScreenInfo->pfb = pddsdPrimary->lpSurface;
-
- /* Grab the color depth and masks from the surface description */
- pScreenPriv->dwRedMask = pddsdPrimary->ddpfPixelFormat.u2.dwRBitMask;
- pScreenPriv->dwGreenMask = pddsdPrimary->ddpfPixelFormat.u3.dwGBitMask;
- pScreenPriv->dwBlueMask = pddsdPrimary->ddpfPixelFormat.u4.dwBBitMask;
-
- winDebug ("winAllocateFBPrimaryDD - Returning\n");
-
- return TRUE;
+ /* Describe the primary surface */
+ ZeroMemory(&ddsd, sizeof(ddsd));
+ ddsd.dwSize = sizeof(ddsd);
+ ddsd.dwFlags = DDSD_CAPS;
+ ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
+
+ /* Create the primary surface */
+ ddrval = IDirectDraw2_CreateSurface(pScreenPriv->pdd2,
+ &ddsd, &pScreenPriv->pddsPrimary, NULL);
+ if (FAILED(ddrval))
+ FatalError("winAllocateFBPrimaryDD - Could not create primary "
+ "surface %08x\n", (unsigned int) ddrval);
+
+ winDebug ("winAllocateFBPrimaryDD - Created primary\n");
+
+ /* Allocate a DD surface description for our screen privates */
+ pddsdPrimary = pScreenPriv->pddsdPrimary = malloc(sizeof(DDSURFACEDESC));
+ if (pddsdPrimary == NULL)
+ FatalError("winAllocateFBPrimaryDD - Could not allocate surface "
+ "description memory\n");
+ ZeroMemory(pddsdPrimary, sizeof(*pddsdPrimary));
+ pddsdPrimary->dwSize = sizeof(*pddsdPrimary);
+
+ /* Describe the offscreen surface to be created */
+ /*
+ * NOTE: Do not use a DDSCAPS_VIDEOMEMORY surface,
+ * as drawing, locking, and unlocking take forever
+ * with video memory surfaces. In addition,
+ * video memory is a somewhat scarce resource,
+ * so you shouldn't be allocating video memory when
+ * you have the option of using system memory instead.
+ */
+ ZeroMemory(&ddsd, sizeof(ddsd));
+ ddsd.dwSize = sizeof(ddsd);
+ ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
+ ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
+ ddsd.dwHeight = pScreenInfo->dwHeight;
+ ddsd.dwWidth = pScreenInfo->dwWidth;
+
+ /* Create the shadow surface */
+ ddrval = IDirectDraw2_CreateSurface(pScreenPriv->pdd2,
+ &ddsd,
+ &pScreenPriv->pddsOffscreen, NULL);
+ if (ddrval != DD_OK)
+ FatalError("winAllocateFBPrimaryDD - Could not create shadow "
+ "surface\n");
+
+ winDebug ("winAllocateFBPrimaryDD - Created offscreen\n");
+
+ /* Allocate a DD surface description for our screen privates */
+ pddsdOffscreen = pScreenPriv->pddsdOffscreen
+ = malloc(sizeof(DDSURFACEDESC));
+ if (pddsdOffscreen == NULL)
+ FatalError("winAllocateFBPrimaryDD - Could not allocate surface "
+ "description memory\n");
+ ZeroMemory(pddsdOffscreen, sizeof(*pddsdOffscreen));
+ pddsdOffscreen->dwSize = sizeof(*pddsdOffscreen);
+
+ winDebug ("winAllocateFBPrimaryDD - Locking primary\n");
+
+ /* Lock the primary surface */
+ ddrval = IDirectDrawSurface2_Lock(pScreenPriv->pddsPrimary,
+ pScreenInfo->
+ fFullScreen ? NULL : &rcClient,
+ pddsdPrimary, DDLOCK_WAIT, NULL);
+ if (ddrval != DD_OK || pddsdPrimary->lpSurface == NULL)
+ FatalError("winAllocateFBPrimaryDD - Could not lock "
+ "primary surface\n");
+
+ winDebug ("winAllocateFBPrimaryDD - Locked primary\n");
+
+ /* We don't know how to deal with anything other than RGB */
+ if (!(pddsdPrimary->ddpfPixelFormat.dwFlags & DDPF_RGB))
+ FatalError("winAllocateFBPrimaryDD - Color format other than RGB\n");
+
+ /* Grab the pitch from the surface desc */
+ pScreenInfo->dwStride = (pddsdPrimary->u1.lPitch * 8)
+ / pScreenInfo->dwBPP;
+
+ /* Save the pointer to our surface memory */
+ pScreenInfo->pfb = pddsdPrimary->lpSurface;
+
+ /* Grab the color depth and masks from the surface description */
+ pScreenPriv->dwRedMask = pddsdPrimary->ddpfPixelFormat.u2.dwRBitMask;
+ pScreenPriv->dwGreenMask = pddsdPrimary->ddpfPixelFormat.u3.dwGBitMask;
+ pScreenPriv->dwBlueMask = pddsdPrimary->ddpfPixelFormat.u4.dwBBitMask;
+
+ winDebug ("winAllocateFBPrimaryDD - Returning\n");
+
+ return TRUE;
}
static void
-winFreeFBPrimaryDD (ScreenPtr pScreen)
+winFreeFBPrimaryDD(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-
- /* Free the offscreen surface, if there is one */
- if (pScreenPriv->pddsOffscreen)
- {
- IDirectDrawSurface2_Unlock (pScreenPriv->pddsOffscreen, NULL);
- IDirectDrawSurface2_Release (pScreenPriv->pddsOffscreen);
- pScreenPriv->pddsOffscreen = NULL;
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /* Free the offscreen surface, if there is one */
+ if (pScreenPriv->pddsOffscreen) {
+ IDirectDrawSurface2_Unlock(pScreenPriv->pddsOffscreen, NULL);
+ IDirectDrawSurface2_Release(pScreenPriv->pddsOffscreen);
+ pScreenPriv->pddsOffscreen = NULL;
}
- /* Release the primary surface, if there is one */
- if (pScreenPriv->pddsPrimary)
- {
- IDirectDrawSurface2_Unlock (pScreenPriv->pddsPrimary, NULL);
- IDirectDrawSurface2_Release (pScreenPriv->pddsPrimary);
- pScreenPriv->pddsPrimary = NULL;
+ /* Release the primary surface, if there is one */
+ if (pScreenPriv->pddsPrimary) {
+ IDirectDrawSurface2_Unlock(pScreenPriv->pddsPrimary, NULL);
+ IDirectDrawSurface2_Release(pScreenPriv->pddsPrimary);
+ pScreenPriv->pddsPrimary = NULL;
}
- /* Free the DirectDraw object, if there is one */
- if (pScreenPriv->pdd)
- {
- IDirectDraw2_RestoreDisplayMode (pScreenPriv->pdd);
- IDirectDraw2_Release (pScreenPriv->pdd);
- pScreenPriv->pdd = NULL;
+ /* Free the DirectDraw object, if there is one */
+ if (pScreenPriv->pdd) {
+ IDirectDraw2_RestoreDisplayMode(pScreenPriv->pdd);
+ IDirectDraw2_Release(pScreenPriv->pdd);
+ pScreenPriv->pdd = NULL;
}
- /* Invalidate the ScreenInfo's fb pointer */
- pScreenInfo->pfb = NULL;
+ /* Invalidate the ScreenInfo's fb pointer */
+ pScreenInfo->pfb = NULL;
}
static Bool
winInitScreenPrimaryDD(ScreenPtr pScreen)
{
- return winAllocateFBPrimaryDD(pScreen);
+ return winAllocateFBPrimaryDD(pScreen);
}
/*
@@ -280,56 +264,53 @@ winInitScreenPrimaryDD(ScreenPtr pScreen)
*/
static Bool
-winCloseScreenPrimaryDD (int nIndex, ScreenPtr pScreen)
+winCloseScreenPrimaryDD(int nIndex, ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- Bool fReturn;
-
- ErrorF ("winCloseScreenPrimaryDD - Freeing screen resources\n");
-
- /* Flag that the screen is closed */
- pScreenPriv->fClosed = TRUE;
- pScreenPriv->fActive = FALSE;
-
- /* Call the wrapped CloseScreen procedure */
- WIN_UNWRAP(CloseScreen);
- if (pScreen->CloseScreen)
- fReturn = (*pScreen->CloseScreen) (nIndex, pScreen);
-
- /* Delete the window property */
- RemoveProp (pScreenPriv->hwndScreen, WIN_SCR_PROP);
-
- winFreeFBPrimaryDD(pScreen);
-
- /* Delete tray icon, if we have one */
- if (!pScreenInfo->fNoTrayIcon)
- winDeleteNotifyIcon (pScreenPriv);
-
- /* Free the exit confirmation dialog box, if it exists */
- if (g_hDlgExit != NULL)
- {
- DestroyWindow (g_hDlgExit);
- g_hDlgExit = NULL;
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ Bool fReturn;
+
+ ErrorF("winCloseScreenPrimaryDD - Freeing screen resources\n");
+
+ /* Flag that the screen is closed */
+ pScreenPriv->fClosed = TRUE;
+ pScreenPriv->fActive = FALSE;
+
+ /* Call the wrapped CloseScreen procedure */
+ WIN_UNWRAP(CloseScreen);
+ if (pScreen->CloseScreen)
+ fReturn = (*pScreen->CloseScreen) (nIndex, pScreen);
+
+ /* Delete the window property */
+ RemoveProp(pScreenPriv->hwndScreen, WIN_SCR_PROP);
+
+ winFreeFBPrimaryDD(pScreen);
+
+ /* Delete tray icon, if we have one */
+ if (!pScreenInfo->fNoTrayIcon)
+ winDeleteNotifyIcon(pScreenPriv);
+
+ /* Free the exit confirmation dialog box, if it exists */
+ if (g_hDlgExit != NULL) {
+ DestroyWindow(g_hDlgExit);
+ g_hDlgExit = NULL;
}
- /* Kill our window */
- if (pScreenPriv->hwndScreen)
- {
- DestroyWindow (pScreenPriv->hwndScreen);
- pScreenPriv->hwndScreen = NULL;
+ /* Kill our window */
+ if (pScreenPriv->hwndScreen) {
+ DestroyWindow(pScreenPriv->hwndScreen);
+ pScreenPriv->hwndScreen = NULL;
}
- /* Kill our screeninfo's pointer to the screen */
- pScreenInfo->pScreen = NULL;
+ /* Kill our screeninfo's pointer to the screen */
+ pScreenInfo->pScreen = NULL;
- /* Free the screen privates for this screen */
- free ((pointer) pScreenPriv);
+ /* Free the screen privates for this screen */
+ free((pointer) pScreenPriv);
- return fReturn;
+ return fReturn;
}
-
/*
* Tell mi what sort of visuals we need.
*
@@ -339,114 +320,106 @@ winCloseScreenPrimaryDD (int nIndex, ScreenPtr pScreen)
*/
static Bool
-winInitVisualsPrimaryDD (ScreenPtr pScreen)
+winInitVisualsPrimaryDD(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- DWORD dwRedBits, dwGreenBits, dwBlueBits;
-
- /* Count the number of ones in each color mask */
- dwRedBits = winCountBits (pScreenPriv->dwRedMask);
- dwGreenBits = winCountBits (pScreenPriv->dwGreenMask);
- dwBlueBits = winCountBits (pScreenPriv->dwBlueMask);
-
- /* Store the maximum number of ones in a color mask as the bitsPerRGB */
- if (dwRedBits > dwGreenBits && dwRedBits > dwBlueBits)
- pScreenPriv->dwBitsPerRGB = dwRedBits;
- else if (dwGreenBits > dwRedBits && dwGreenBits > dwBlueBits)
- pScreenPriv->dwBitsPerRGB = dwGreenBits;
- else
- pScreenPriv->dwBitsPerRGB = dwBlueBits;
-
- winDebug ("winInitVisualsPrimaryDD - Masks: %08x %08x %08x bpRGB: %d\n",
- (unsigned int) pScreenPriv->dwRedMask,
- (unsigned int) pScreenPriv->dwGreenMask,
- (unsigned int) pScreenPriv->dwBlueMask,
- (int) pScreenPriv->dwBitsPerRGB);
-
- /* Create a single visual according to the Windows screen depth */
- switch (pScreenInfo->dwDepth)
- {
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ DWORD dwRedBits, dwGreenBits, dwBlueBits;
+
+ /* Count the number of ones in each color mask */
+ dwRedBits = winCountBits(pScreenPriv->dwRedMask);
+ dwGreenBits = winCountBits(pScreenPriv->dwGreenMask);
+ dwBlueBits = winCountBits(pScreenPriv->dwBlueMask);
+
+ /* Store the maximum number of ones in a color mask as the bitsPerRGB */
+ if (dwRedBits > dwGreenBits && dwRedBits > dwBlueBits)
+ pScreenPriv->dwBitsPerRGB = dwRedBits;
+ else if (dwGreenBits > dwRedBits && dwGreenBits > dwBlueBits)
+ pScreenPriv->dwBitsPerRGB = dwGreenBits;
+ else
+ pScreenPriv->dwBitsPerRGB = dwBlueBits;
+
+ winDebug ("winInitVisualsPrimaryDD - Masks: %08x %08x %08x bpRGB: %d\n",
+ (unsigned int) pScreenPriv->dwRedMask,
+ (unsigned int) pScreenPriv->dwGreenMask,
+ (unsigned int) pScreenPriv->dwBlueMask,
+ (int) pScreenPriv->dwBitsPerRGB);
+
+ /* Create a single visual according to the Windows screen depth */
+ switch (pScreenInfo->dwDepth) {
case 24:
case 16:
case 15:
- if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
- TrueColorMask,
- pScreenPriv->dwBitsPerRGB,
- TrueColor,
- pScreenPriv->dwRedMask,
- pScreenPriv->dwGreenMask,
- pScreenPriv->dwBlueMask))
- {
- ErrorF ("winInitVisualsPrimaryDD - "
- "miSetVisualTypesAndMasks failed\n");
- return FALSE;
- }
- break;
+ if (!miSetVisualTypesAndMasks(pScreenInfo->dwDepth,
+ TrueColorMask,
+ pScreenPriv->dwBitsPerRGB,
+ TrueColor,
+ pScreenPriv->dwRedMask,
+ pScreenPriv->dwGreenMask,
+ pScreenPriv->dwBlueMask)) {
+ ErrorF("winInitVisualsPrimaryDD - "
+ "miSetVisualTypesAndMasks failed\n");
+ return FALSE;
+ }
+ break;
case 8:
- winDebug ("winInitVisuals - Calling miSetVisualTypesAndMasks\n");
- if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
- PseudoColorMask,
- pScreenPriv->dwBitsPerRGB,
- PseudoColor,
- pScreenPriv->dwRedMask,
- pScreenPriv->dwGreenMask,
- pScreenPriv->dwBlueMask))
- {
- ErrorF ("winInitVisualsPrimaryDD - "
- "miSetVisualTypesAndMasks failed\n");
- return FALSE;
- }
- winDebug ("winInitVisualsPrimaryDD - Returned from "
- "miSetVisualTypesAndMasks\n");
- break;
+ winDebug("winInitVisuals - Calling miSetVisualTypesAndMasks\n");
+ if (!miSetVisualTypesAndMasks(pScreenInfo->dwDepth,
+ PseudoColorMask,
+ pScreenPriv->dwBitsPerRGB,
+ PseudoColor,
+ pScreenPriv->dwRedMask,
+ pScreenPriv->dwGreenMask,
+ pScreenPriv->dwBlueMask)) {
+ ErrorF("winInitVisualsPrimaryDD - "
+ "miSetVisualTypesAndMasks failed\n");
+ return FALSE;
+ }
+ winDebug("winInitVisualsPrimaryDD - Returned from "
+ "miSetVisualTypesAndMasks\n");
+ break;
default:
- ErrorF ("winInitVisualsPrimaryDD - Unknown screen depth\n");
- return FALSE;
+ ErrorF("winInitVisualsPrimaryDD - Unknown screen depth\n");
+ return FALSE;
}
- winDebug ("winInitVisualsPrimaryDD - Returning\n");
+ winDebug ("winInitVisualsPrimaryDD - Returning\n");
- return TRUE;
+ return TRUE;
}
-
static Bool
-winAdjustVideoModePrimaryDD (ScreenPtr pScreen)
+winAdjustVideoModePrimaryDD(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- HDC hdc = NULL;
- DWORD dwBPP;
-
- /* We're in serious trouble if we can't get a DC */
- hdc = GetDC (NULL);
- if (hdc == NULL)
- {
- ErrorF ("winAdjustVideoModePrimaryDD - GetDC failed\n");
- return FALSE;
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ HDC hdc = NULL;
+ DWORD dwBPP;
+
+ /* We're in serious trouble if we can't get a DC */
+ hdc = GetDC(NULL);
+ if (hdc == NULL) {
+ ErrorF("winAdjustVideoModePrimaryDD - GetDC failed\n");
+ return FALSE;
}
- /* Query GDI for current display depth */
- dwBPP = GetDeviceCaps (hdc, BITSPIXEL);
+ /* Query GDI for current display depth */
+ dwBPP = GetDeviceCaps(hdc, BITSPIXEL);
- /* DirectDraw can only change the depth in fullscreen mode */
- if (!(pScreenInfo->fFullScreen &&
- (pScreenInfo->dwBPP != WIN_DEFAULT_BPP)))
- {
- /* Otherwise, We'll use GDI's depth */
- pScreenInfo->dwBPP = dwBPP;
+ /* DirectDraw can only change the depth in fullscreen mode */
+ if (!(pScreenInfo->fFullScreen && (pScreenInfo->dwBPP != WIN_DEFAULT_BPP))) {
+ /* Otherwise, We'll use GDI's depth */
+ pScreenInfo->dwBPP = dwBPP;
}
- /* Release our DC */
- ReleaseDC (NULL, hdc);
+ /* Release our DC */
+ ReleaseDC(NULL, hdc);
- return TRUE;
+ return TRUE;
}
-
/*
* We need to blit our offscreen fb to
* the screen when we are activated, and we need to point
@@ -454,85 +427,76 @@ winAdjustVideoModePrimaryDD (ScreenPtr pScreen)
*/
static Bool
-winActivateAppPrimaryDD (ScreenPtr pScreen)
+winActivateAppPrimaryDD(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- RECT rcSrc, rcClient;
- HRESULT ddrval = DD_OK;
-
- /* Check for errors */
- if (pScreenPriv == NULL
- || pScreenPriv->pScreenInfo == NULL
- || pScreenPriv->pddsPrimary == NULL
- || pScreenPriv->pddsOffscreen == NULL)
- return FALSE;
-
- /* Check for do-nothing */
- if (!pScreenPriv->fActive)
- return TRUE;
-
- /* We are activating */
- ddrval = IDirectDrawSurface2_IsLost (pScreenPriv->pddsOffscreen);
- if (ddrval == DD_OK)
- {
- IDirectDrawSurface2_Unlock (pScreenPriv->pddsOffscreen,
- NULL);
- /*
- * We don't check for an error from Unlock, because it
- * doesn't matter if the Unlock failed.
- */
+ winScreenPriv(pScreen);
+ RECT rcSrc, rcClient;
+ HRESULT ddrval = DD_OK;
+
+ /* Check for errors */
+ if (pScreenPriv == NULL
+ || pScreenPriv->pScreenInfo == NULL
+ || pScreenPriv->pddsPrimary == NULL
+ || pScreenPriv->pddsOffscreen == NULL)
+ return FALSE;
+
+ /* Check for do-nothing */
+ if (!pScreenPriv->fActive)
+ return TRUE;
+
+ /* We are activating */
+ ddrval = IDirectDrawSurface2_IsLost(pScreenPriv->pddsOffscreen);
+ if (ddrval == DD_OK) {
+ IDirectDrawSurface2_Unlock(pScreenPriv->pddsOffscreen, NULL);
+ /*
+ * We don't check for an error from Unlock, because it
+ * doesn't matter if the Unlock failed.
+ */
}
- /* Restore both surfaces, just cause I like it that way */
- IDirectDrawSurface2_Restore (pScreenPriv->pddsOffscreen);
- IDirectDrawSurface2_Restore (pScreenPriv->pddsPrimary);
-
- /* Get client area in screen coords */
- GetClientRect (pScreenPriv->hwndScreen, &rcClient);
- MapWindowPoints (pScreenPriv->hwndScreen,
- HWND_DESKTOP,
- (LPPOINT)&rcClient, 2);
-
- /* Setup a source rectangle */
- rcSrc.left = 0;
- rcSrc.top = 0;
- rcSrc.right = pScreenPriv->pScreenInfo->dwWidth;
- rcSrc.bottom = pScreenPriv->pScreenInfo->dwHeight;
-
- ddrval = IDirectDrawSurface2_Blt (pScreenPriv->pddsPrimary,
- &rcClient,
- pScreenPriv->pddsOffscreen,
- &rcSrc,
- DDBLT_WAIT,
- NULL);
- if (ddrval != DD_OK)
- FatalError ("winActivateAppPrimaryDD () - Failed blitting offscreen "
- "surface to primary surface %08x\n", (unsigned int) ddrval);
-
- /* Lock the primary surface */
- ddrval = IDirectDrawSurface2_Lock (pScreenPriv->pddsPrimary,
- &rcClient,
- pScreenPriv->pddsdPrimary,
- DDLOCK_WAIT,
- NULL);
- if (ddrval != DD_OK
- || pScreenPriv->pddsdPrimary->lpSurface == NULL)
- FatalError ("winActivateAppPrimaryDD () - Could not lock "
- "primary surface\n");
-
- /* Notify FB of the new memory pointer */
- winUpdateFBPointer (pScreen,
- pScreenPriv->pddsdPrimary->lpSurface);
-
- /*
- * Register the Alt-Tab combo as a hotkey so we can copy
- * the primary framebuffer before the display mode changes
- */
- RegisterHotKey (pScreenPriv->hwndScreen, 1, MOD_ALT, 9);
-
- return TRUE;
-}
+ /* Restore both surfaces, just cause I like it that way */
+ IDirectDrawSurface2_Restore(pScreenPriv->pddsOffscreen);
+ IDirectDrawSurface2_Restore(pScreenPriv->pddsPrimary);
+
+ /* Get client area in screen coords */
+ GetClientRect(pScreenPriv->hwndScreen, &rcClient);
+ MapWindowPoints(pScreenPriv->hwndScreen,
+ HWND_DESKTOP, (LPPOINT) & rcClient, 2);
+
+ /* Setup a source rectangle */
+ rcSrc.left = 0;
+ rcSrc.top = 0;
+ rcSrc.right = pScreenPriv->pScreenInfo->dwWidth;
+ rcSrc.bottom = pScreenPriv->pScreenInfo->dwHeight;
+
+ ddrval = IDirectDrawSurface2_Blt(pScreenPriv->pddsPrimary,
+ &rcClient,
+ pScreenPriv->pddsOffscreen,
+ &rcSrc, DDBLT_WAIT, NULL);
+ if (ddrval != DD_OK)
+ FatalError("winActivateAppPrimaryDD () - Failed blitting offscreen "
+ "surface to primary surface %08x\n", (unsigned int) ddrval);
+
+ /* Lock the primary surface */
+ ddrval = IDirectDrawSurface2_Lock(pScreenPriv->pddsPrimary,
+ &rcClient,
+ pScreenPriv->pddsdPrimary,
+ DDLOCK_WAIT, NULL);
+ if (ddrval != DD_OK || pScreenPriv->pddsdPrimary->lpSurface == NULL)
+ FatalError("winActivateAppPrimaryDD () - Could not lock "
+ "primary surface\n");
+
+ /* Notify FB of the new memory pointer */
+ winUpdateFBPointer(pScreen, pScreenPriv->pddsdPrimary->lpSurface);
+
+ /*
+ * Register the Alt-Tab combo as a hotkey so we can copy
+ * the primary framebuffer before the display mode changes
+ */
+ RegisterHotKey(pScreenPriv->hwndScreen, 1, MOD_ALT, 9);
+ return TRUE;
+}
/*
* Handle the Alt+Tab hotkey.
@@ -543,133 +507,123 @@ winActivateAppPrimaryDD (ScreenPtr pScreen)
*/
static Bool
-winHotKeyAltTabPrimaryDD (ScreenPtr pScreen)
+winHotKeyAltTabPrimaryDD(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- RECT rcClient, rcSrc;
- HRESULT ddrval = DD_OK;
-
- winDebug ("\nwinHotKeyAltTabPrimaryDD\n\n");
-
- /* Alt+Tab was pressed, we will lose focus very soon */
- pScreenPriv->fActive = FALSE;
-
- /* Check for error conditions */
- if (pScreenPriv->pddsPrimary == NULL
- || pScreenPriv->pddsOffscreen == NULL)
- return FALSE;
-
- /* Get client area in screen coords */
- GetClientRect (pScreenPriv->hwndScreen, &rcClient);
- MapWindowPoints (pScreenPriv->hwndScreen,
- HWND_DESKTOP,
- (LPPOINT)&rcClient, 2);
-
- /* Did we loose the primary surface? */
- ddrval = IDirectDrawSurface2_IsLost (pScreenPriv->pddsPrimary);
- if (ddrval == DD_OK)
- {
- ddrval = IDirectDrawSurface2_Unlock (pScreenPriv->pddsPrimary,
- NULL);
- if (FAILED (ddrval))
- FatalError ("winHotKeyAltTabPrimaryDD - Failed unlocking primary "
- "surface\n");
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ RECT rcClient, rcSrc;
+ HRESULT ddrval = DD_OK;
+
+ winDebug ("\nwinHotKeyAltTabPrimaryDD\n\n");
+
+ /* Alt+Tab was pressed, we will lose focus very soon */
+ pScreenPriv->fActive = FALSE;
+
+ /* Check for error conditions */
+ if (pScreenPriv->pddsPrimary == NULL || pScreenPriv->pddsOffscreen == NULL)
+ return FALSE;
+
+ /* Get client area in screen coords */
+ GetClientRect(pScreenPriv->hwndScreen, &rcClient);
+ MapWindowPoints(pScreenPriv->hwndScreen,
+ HWND_DESKTOP, (LPPOINT) & rcClient, 2);
+
+ /* Did we loose the primary surface? */
+ ddrval = IDirectDrawSurface2_IsLost(pScreenPriv->pddsPrimary);
+ if (ddrval == DD_OK) {
+ ddrval = IDirectDrawSurface2_Unlock(pScreenPriv->pddsPrimary, NULL);
+ if (FAILED(ddrval))
+ FatalError("winHotKeyAltTabPrimaryDD - Failed unlocking primary "
+ "surface\n");
}
- /* Setup a source rectangle */
- rcSrc.left = 0;
- rcSrc.top = 0;
- rcSrc.right = pScreenInfo->dwWidth;
- rcSrc.bottom = pScreenInfo->dwHeight;
-
- /* Blit the primary surface to the offscreen surface */
- ddrval = IDirectDrawSurface2_Blt (pScreenPriv->pddsOffscreen,
- NULL, /* should be rcDest */
- pScreenPriv->pddsPrimary,
- NULL,
- DDBLT_WAIT,
- NULL);
- if (ddrval == DDERR_SURFACELOST)
- {
- IDirectDrawSurface2_Restore (pScreenPriv->pddsOffscreen);
- IDirectDrawSurface2_Restore (pScreenPriv->pddsPrimary);
-
- /* Blit the primary surface to the offscreen surface */
- ddrval = IDirectDrawSurface2_Blt (pScreenPriv->pddsOffscreen,
- NULL,
- pScreenPriv->pddsPrimary,
- NULL,
- DDBLT_WAIT,
- NULL);
- if (FAILED (ddrval))
- FatalError ("winHotKeyAltTabPrimaryDD - Failed blitting primary "
- "surface to offscreen surface: %08x\n",
- (unsigned int) ddrval);
+ /* Setup a source rectangle */
+ rcSrc.left = 0;
+ rcSrc.top = 0;
+ rcSrc.right = pScreenInfo->dwWidth;
+ rcSrc.bottom = pScreenInfo->dwHeight;
+
+ /* Blit the primary surface to the offscreen surface */
+ ddrval = IDirectDrawSurface2_Blt(pScreenPriv->pddsOffscreen, NULL, /* should be rcDest */
+ pScreenPriv->pddsPrimary,
+ NULL, DDBLT_WAIT, NULL);
+ if (ddrval == DDERR_SURFACELOST) {
+ IDirectDrawSurface2_Restore(pScreenPriv->pddsOffscreen);
+ IDirectDrawSurface2_Restore(pScreenPriv->pddsPrimary);
+
+ /* Blit the primary surface to the offscreen surface */
+ ddrval = IDirectDrawSurface2_Blt(pScreenPriv->pddsOffscreen,
+ NULL,
+ pScreenPriv->pddsPrimary,
+ NULL, DDBLT_WAIT, NULL);
+ if (FAILED(ddrval))
+ FatalError("winHotKeyAltTabPrimaryDD - Failed blitting primary "
+ "surface to offscreen surface: %08x\n",
+ (unsigned int) ddrval);
}
- else
- {
- FatalError ("winHotKeyAltTabPrimaryDD - Unknown error from "
- "Blt: %08dx\n", (unsigned int) ddrval);
+ else {
+ FatalError("winHotKeyAltTabPrimaryDD - Unknown error from "
+ "Blt: %08dx\n", (unsigned int) ddrval);
}
- /* Lock the offscreen surface */
- ddrval = IDirectDrawSurface2_Lock (pScreenPriv->pddsOffscreen,
- NULL,
- pScreenPriv->pddsdOffscreen,
- DDLOCK_WAIT,
- NULL);
- if (ddrval != DD_OK
- || pScreenPriv->pddsdPrimary->lpSurface == NULL)
- FatalError ("winHotKeyAltTabPrimaryDD - Could not lock "
- "offscreen surface\n");
-
- /* Notify FB of the new memory pointer */
- winUpdateFBPointer (pScreen,
- pScreenPriv->pddsdOffscreen->lpSurface);
-
- /* Unregister our hotkey */
- UnregisterHotKey (pScreenPriv->hwndScreen, 1);
-
- return TRUE;
-}
+ /* Lock the offscreen surface */
+ ddrval = IDirectDrawSurface2_Lock(pScreenPriv->pddsOffscreen,
+ NULL,
+ pScreenPriv->pddsdOffscreen,
+ DDLOCK_WAIT, NULL);
+ if (ddrval != DD_OK || pScreenPriv->pddsdPrimary->lpSurface == NULL)
+ FatalError("winHotKeyAltTabPrimaryDD - Could not lock "
+ "offscreen surface\n");
+
+ /* Notify FB of the new memory pointer */
+ winUpdateFBPointer(pScreen, pScreenPriv->pddsdOffscreen->lpSurface);
+
+ /* Unregister our hotkey */
+ UnregisterHotKey(pScreenPriv->hwndScreen, 1);
+ return TRUE;
+}
/* Set engine specific functions */
Bool
-winSetEngineFunctionsPrimaryDD (ScreenPtr pScreen)
+winSetEngineFunctionsPrimaryDD(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-
- /* Set our pointers */
- pScreenPriv->pwinAllocateFB = winAllocateFBPrimaryDD;
- pScreenPriv->pwinFreeFB = winFreeFBPrimaryDD;
- pScreenPriv->pwinShadowUpdate = (winShadowUpdateProcPtr) (void (*)(void))NoopDDA;
- pScreenPriv->pwinInitScreen = winInitScreenPrimaryDD;
- pScreenPriv->pwinCloseScreen = winCloseScreenPrimaryDD;
- pScreenPriv->pwinInitVisuals = winInitVisualsPrimaryDD;
- pScreenPriv->pwinAdjustVideoMode = winAdjustVideoModePrimaryDD;
- if (pScreenInfo->fFullScreen)
- pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowFullScreen;
- else
- pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowWindowed;
- pScreenPriv->pwinFinishScreenInit = winFinishScreenInitFB;
- pScreenPriv->pwinBltExposedRegions = (winBltExposedRegionsProcPtr) (void (*)(void))NoopDDA;
- pScreenPriv->pwinActivateApp = winActivateAppPrimaryDD;
- pScreenPriv->pwinRedrawScreen = NULL;
- pScreenPriv->pwinRealizeInstalledPalette = NULL;
- pScreenPriv->pwinInstallColormap = NULL;
- pScreenPriv->pwinStoreColors = NULL;
- pScreenPriv->pwinCreateColormap = NULL;
- pScreenPriv->pwinDestroyColormap = NULL;
- pScreenPriv->pwinHotKeyAltTab = winHotKeyAltTabPrimaryDD;
- pScreenPriv->pwinCreatePrimarySurface = (winCreatePrimarySurfaceProcPtr) (void (*)(void))NoopDDA;
- pScreenPriv->pwinReleasePrimarySurface = (winReleasePrimarySurfaceProcPtr) (void (*)(void))NoopDDA;
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /* Set our pointers */
+ pScreenPriv->pwinAllocateFB = winAllocateFBPrimaryDD;
+ pScreenPriv->pwinFreeFB = winFreeFBPrimaryDD;
+ pScreenPriv->pwinShadowUpdate =
+ (winShadowUpdateProcPtr) (void (*)(void)) NoopDDA;
+ pScreenPriv->pwinInitScreen = winInitScreenPrimaryDD;
+ pScreenPriv->pwinCloseScreen = winCloseScreenPrimaryDD;
+ pScreenPriv->pwinInitVisuals = winInitVisualsPrimaryDD;
+ pScreenPriv->pwinAdjustVideoMode = winAdjustVideoModePrimaryDD;
+ if (pScreenInfo->fFullScreen)
+ pScreenPriv->pwinCreateBoundingWindow =
+ winCreateBoundingWindowFullScreen;
+ else
+ pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowWindowed;
+ pScreenPriv->pwinFinishScreenInit = winFinishScreenInitFB;
+ pScreenPriv->pwinBltExposedRegions =
+ (winBltExposedRegionsProcPtr) (void (*)(void)) NoopDDA;
+ pScreenPriv->pwinActivateApp = winActivateAppPrimaryDD;
+ pScreenPriv->pwinRedrawScreen = NULL;
+ pScreenPriv->pwinRealizeInstalledPalette = NULL;
+ pScreenPriv->pwinInstallColormap = NULL;
+ pScreenPriv->pwinStoreColors = NULL;
+ pScreenPriv->pwinCreateColormap = NULL;
+ pScreenPriv->pwinDestroyColormap = NULL;
+ pScreenPriv->pwinHotKeyAltTab = winHotKeyAltTabPrimaryDD;
+ pScreenPriv->pwinCreatePrimarySurface =
+ (winCreatePrimarySurfaceProcPtr) (void (*)(void)) NoopDDA;
+ pScreenPriv->pwinReleasePrimarySurface =
+ (winReleasePrimarySurfaceProcPtr) (void (*)(void)) NoopDDA;
#ifdef XWIN_MULTIWINDOW
- pScreenPriv->pwinFinishCreateWindowsWindow =
- (winFinishCreateWindowsWindowProcPtr) (void (*)(void))NoopDDA;
+ pScreenPriv->pwinFinishCreateWindowsWindow =
+ (winFinishCreateWindowsWindowProcPtr) (void (*)(void)) NoopDDA;
#endif
- return TRUE;
+ return TRUE;
}
diff --git a/xorg-server/hw/xwin/winpixmap.c b/xorg-server/hw/xwin/winpixmap.c
index 2af95f225..ac883a84c 100644
--- a/xorg-server/hw/xwin/winpixmap.c
+++ b/xorg-server/hw/xwin/winpixmap.c
@@ -1,184 +1,178 @@
-/*
- *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: drewry, september 1986
- * Harold L Hunt II
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-
-
-/*
- * Local prototypes
- */
-
-#if 0
-static void
-winXRotatePixmapNativeGDI (PixmapPtr pPix, int rw);
-
-static void
-winYRotatePixmapNativeGDI (PixmapPtr pPix, int rh);
-
-static void
-winCopyRotatePixmapNativeGDI (PixmapPtr psrcPix, PixmapPtr *ppdstPix,
- int xrot, int yrot);
-#endif
-
-
-/* See Porting Layer Definition - p. 34 */
-/* See mfb/mfbpixmap.c - mfbCreatePixmap() */
-PixmapPtr
-winCreatePixmapNativeGDI (ScreenPtr pScreen,
- int iWidth, int iHeight,
- int iDepth, unsigned usage_hint)
-{
- winPrivPixmapPtr pPixmapPriv = NULL;
- PixmapPtr pPixmap = NULL;
-
- /* Allocate pixmap memory */
- pPixmap = AllocatePixmap (pScreen, 0);
- if (!pPixmap)
- {
- ErrorF ("winCreatePixmapNativeGDI () - Couldn't allocate a pixmap\n");
- return NullPixmap;
- }
-
- winDebug ("winCreatePixmap () - w %d h %d d %d uh %d bw %d\n",
- iWidth, iHeight, iDepth, usage_hint,
- PixmapBytePad (iWidth, iDepth));
-
- /* Setup pixmap values */
- pPixmap->drawable.type = DRAWABLE_PIXMAP;
- pPixmap->drawable.class = 0;
- pPixmap->drawable.pScreen = pScreen;
- pPixmap->drawable.depth = iDepth;
- pPixmap->drawable.bitsPerPixel = BitsPerPixel (iDepth);
- pPixmap->drawable.id = 0;
- pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
- pPixmap->drawable.x = 0;
- pPixmap->drawable.y = 0;
- pPixmap->drawable.width = iWidth;
- pPixmap->drawable.height = iHeight;
- pPixmap->devKind = 0;
- pPixmap->refcnt = 1;
- pPixmap->devPrivate.ptr = NULL;
- pPixmap->usage_hint = usage_hint;
-
- /* Pixmap privates are allocated by AllocatePixmap */
- pPixmapPriv = winGetPixmapPriv (pPixmap);
-
- /* Initialize pixmap privates */
- pPixmapPriv->hBitmap = NULL;
- pPixmapPriv->hdcSelected = NULL;
- pPixmapPriv->pbBits = NULL;
- pPixmapPriv->dwScanlineBytes = PixmapBytePad (iWidth, iDepth);
-
- /* Check for zero width or height pixmaps */
- if (iWidth == 0 || iHeight == 0)
- {
- /* Don't allocate a real pixmap, just set fields and return */
- return pPixmap;
- }
-
- /* Create a DIB for the pixmap */
- pPixmapPriv->hBitmap = winCreateDIBNativeGDI (iWidth, iHeight, iDepth,
- &pPixmapPriv->pbBits,
- (BITMAPINFO **) &pPixmapPriv->pbmih);
-
- winDebug ("winCreatePixmap () - Created a pixmap %08x, %dx%dx%d, for " \
- "screen: %08x\n",
- pPixmapPriv->hBitmap, iWidth, iHeight, iDepth, pScreen);
-
- return pPixmap;
-}
-
-
-/*
- * See Porting Layer Definition - p. 35
- *
- * See mfb/mfbpixmap.c - mfbDestroyPixmap()
- */
-
-Bool
-winDestroyPixmapNativeGDI (PixmapPtr pPixmap)
-{
- winPrivPixmapPtr pPixmapPriv = NULL;
-
- winDebug ("winDestroyPixmapNativeGDI ()\n");
-
- /* Bail early if there is not a pixmap to destroy */
- if (pPixmap == NULL)
- {
- ErrorF ("winDestroyPixmapNativeGDI () - No pixmap to destroy\n");
- return TRUE;
- }
-
- /* Get a handle to the pixmap privates */
- pPixmapPriv = winGetPixmapPriv (pPixmap);
-
- winDebug ("winDestroyPixmapNativeGDI - pPixmapPriv->hBitmap: %08x\n",
- pPixmapPriv->hBitmap);
-
- /* Decrement reference count, return if nonzero */
- --pPixmap->refcnt;
- if (pPixmap->refcnt != 0)
- return TRUE;
-
- /* Free GDI bitmap */
- if (pPixmapPriv->hBitmap) DeleteObject (pPixmapPriv->hBitmap);
-
- /* Free the bitmap info header memory */
- free(pPixmapPriv->pbmih);
- pPixmapPriv->pbmih = NULL;
-
- /* Free the pixmap memory */
- free (pPixmap);
- pPixmap = NULL;
-
- return TRUE;
-}
-
-
-/*
- * Not used yet
- */
-
-Bool
-winModifyPixmapHeaderNativeGDI (PixmapPtr pPixmap,
- int iWidth, int iHeight,
- int iDepth,
- int iBitsPerPixel,
- int devKind,
- pointer pPixData)
-{
- FatalError ("winModifyPixmapHeaderNativeGDI ()\n");
- return TRUE;
-}
-
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: drewry, september 1986
+ * Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+/*
+ * Local prototypes
+ */
+
+#if 0
+static void
+ winXRotatePixmapNativeGDI(PixmapPtr pPix, int rw);
+
+static void
+ winYRotatePixmapNativeGDI(PixmapPtr pPix, int rh);
+
+static void
+
+winCopyRotatePixmapNativeGDI(PixmapPtr psrcPix, PixmapPtr *ppdstPix,
+ int xrot, int yrot);
+#endif
+
+/* See Porting Layer Definition - p. 34 */
+/* See mfb/mfbpixmap.c - mfbCreatePixmap() */
+PixmapPtr
+winCreatePixmapNativeGDI(ScreenPtr pScreen,
+ int iWidth, int iHeight,
+ int iDepth, unsigned usage_hint)
+{
+ winPrivPixmapPtr pPixmapPriv = NULL;
+ PixmapPtr pPixmap = NULL;
+
+ /* Allocate pixmap memory */
+ pPixmap = AllocatePixmap(pScreen, 0);
+ if (!pPixmap) {
+ ErrorF("winCreatePixmapNativeGDI () - Couldn't allocate a pixmap\n");
+ return NullPixmap;
+ }
+
+ winDebug("winCreatePixmap () - w %d h %d d %d uh %d bw %d\n",
+ iWidth, iHeight, iDepth, usage_hint,
+ PixmapBytePad(iWidth, iDepth));
+
+ /* Setup pixmap values */
+ pPixmap->drawable.type = DRAWABLE_PIXMAP;
+ pPixmap->drawable.class = 0;
+ pPixmap->drawable.pScreen = pScreen;
+ pPixmap->drawable.depth = iDepth;
+ pPixmap->drawable.bitsPerPixel = BitsPerPixel(iDepth);
+ pPixmap->drawable.id = 0;
+ pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ pPixmap->drawable.x = 0;
+ pPixmap->drawable.y = 0;
+ pPixmap->drawable.width = iWidth;
+ pPixmap->drawable.height = iHeight;
+ pPixmap->devKind = 0;
+ pPixmap->refcnt = 1;
+ pPixmap->devPrivate.ptr = NULL;
+ pPixmap->usage_hint = usage_hint;
+
+ /* Pixmap privates are allocated by AllocatePixmap */
+ pPixmapPriv = winGetPixmapPriv(pPixmap);
+
+ /* Initialize pixmap privates */
+ pPixmapPriv->hBitmap = NULL;
+ pPixmapPriv->hdcSelected = NULL;
+ pPixmapPriv->pbBits = NULL;
+ pPixmapPriv->dwScanlineBytes = PixmapBytePad(iWidth, iDepth);
+
+ /* Check for zero width or height pixmaps */
+ if (iWidth == 0 || iHeight == 0) {
+ /* Don't allocate a real pixmap, just set fields and return */
+ return pPixmap;
+ }
+
+ /* Create a DIB for the pixmap */
+ pPixmapPriv->hBitmap = winCreateDIBNativeGDI(iWidth, iHeight, iDepth,
+ &pPixmapPriv->pbBits,
+ (BITMAPINFO **) & pPixmapPriv->
+ pbmih);
+
+ winDebug("winCreatePixmap () - Created a pixmap %08x, %dx%dx%d, for "
+ "screen: %08x\n",
+ pPixmapPriv->hBitmap, iWidth, iHeight, iDepth, pScreen);
+
+ return pPixmap;
+}
+
+/*
+ * See Porting Layer Definition - p. 35
+ *
+ * See mfb/mfbpixmap.c - mfbDestroyPixmap()
+ */
+
+Bool
+winDestroyPixmapNativeGDI(PixmapPtr pPixmap)
+{
+ winPrivPixmapPtr pPixmapPriv = NULL;
+
+ winDebug("winDestroyPixmapNativeGDI ()\n");
+
+ /* Bail early if there is not a pixmap to destroy */
+ if (pPixmap == NULL) {
+ ErrorF("winDestroyPixmapNativeGDI () - No pixmap to destroy\n");
+ return TRUE;
+ }
+
+ /* Get a handle to the pixmap privates */
+ pPixmapPriv = winGetPixmapPriv(pPixmap);
+
+ winDebug("winDestroyPixmapNativeGDI - pPixmapPriv->hBitmap: %08x\n",
+ pPixmapPriv->hBitmap);
+
+ /* Decrement reference count, return if nonzero */
+ --pPixmap->refcnt;
+ if (pPixmap->refcnt != 0)
+ return TRUE;
+
+ /* Free GDI bitmap */
+ if (pPixmapPriv->hBitmap)
+ DeleteObject(pPixmapPriv->hBitmap);
+
+ /* Free the bitmap info header memory */
+ free(pPixmapPriv->pbmih);
+ pPixmapPriv->pbmih = NULL;
+
+ /* Free the pixmap memory */
+ free(pPixmap);
+ pPixmap = NULL;
+
+ return TRUE;
+}
+
+/*
+ * Not used yet
+ */
+
+Bool
+winModifyPixmapHeaderNativeGDI(PixmapPtr pPixmap,
+ int iWidth, int iHeight,
+ int iDepth,
+ int iBitsPerPixel, int devKind, pointer pPixData)
+{
+ FatalError("winModifyPixmapHeaderNativeGDI ()\n");
+ return TRUE;
+}
+
diff --git a/xorg-server/hw/xwin/winpolyline.c b/xorg-server/hw/xwin/winpolyline.c
index bf98d73ec..ce7c8de28 100644
--- a/xorg-server/hw/xwin/winpolyline.c
+++ b/xorg-server/hw/xwin/winpolyline.c
@@ -35,23 +35,19 @@
/* See Porting Layer Definition - p. 50 */
void
-winPolyLineNativeGDI (DrawablePtr pDrawable,
- GCPtr pGC,
- int mode,
- int npt,
- DDXPointPtr ppt)
+winPolyLineNativeGDI(DrawablePtr pDrawable,
+ GCPtr pGC, int mode, int npt, DDXPointPtr ppt)
{
- switch (pGC->lineStyle)
- {
+ switch (pGC->lineStyle) {
case LineSolid:
- if (pGC->lineWidth == 0)
- miZeroLine (pDrawable, pGC, mode, npt, ppt);
- else
- miWideLine (pDrawable, pGC, mode, npt, ppt);
- break;
+ if (pGC->lineWidth == 0)
+ miZeroLine (pDrawable, pGC, mode, npt, ppt);
+ else
+ miWideLine(pDrawable, pGC, mode, npt, ppt);
+ break;
case LineOnOffDash:
case LineDoubleDash:
- miWideDash (pDrawable, pGC, mode, npt, ppt);
- break;
+ miWideDash(pDrawable, pGC, mode, npt, ppt);
+ break;
}
}
diff --git a/xorg-server/hw/xwin/winprefs.c b/xorg-server/hw/xwin/winprefs.c
index 8c738e515..8f403cec3 100644
--- a/xorg-server/hw/xwin/winprefs.c
+++ b/xorg-server/hw/xwin/winprefs.c
@@ -54,165 +54,142 @@ extern const char *winGetBaseDir(void);
extern const char *g_pszLogFile;
/* From winprefslex.l, the real parser */
-extern int parse_file (FILE *fp);
-
+extern int parse_file(FILE * fp);
/* Currently in use command ID, incremented each new menu item created */
static int g_cmdid = STARTMENUID;
-
/* Defined in DIX */
extern char *display;
/* Local function to handle comma-ified icon names */
-static HICON
-LoadImageComma (char *fname, int sx, int sy, int flags);
-
+static HICON LoadImageComma(char *fname, int sx, int sy, int flags);
/*
* Creates or appends a menu from a MENUPARSED structure
*/
static HMENU
-MakeMenu (char *name,
- HMENU editMenu,
- int editItem)
+MakeMenu(char *name, HMENU editMenu, int editItem)
{
- int i;
- int item;
- MENUPARSED *m;
- HMENU hmenu, hsub;
-
- for (i=0; i<pref.menuItems; i++)
- {
- if (!strcmp(name, pref.menu[i].menuName))
- break;
+ int i;
+ int item;
+ MENUPARSED *m;
+ HMENU hmenu, hsub;
+
+ for (i = 0; i < pref.menuItems; i++) {
+ if (!strcmp(name, pref.menu[i].menuName))
+ break;
}
-
- /* Didn't find a match, bummer */
- if (i==pref.menuItems)
- {
- ErrorF("MakeMenu: Can't find menu %s\n", name);
- return NULL;
+
+ /* Didn't find a match, bummer */
+ if (i == pref.menuItems) {
+ ErrorF("MakeMenu: Can't find menu %s\n", name);
+ return NULL;
}
-
- m = &(pref.menu[i]);
- if (editMenu)
- {
- hmenu = editMenu;
- item = editItem;
+ m = &(pref.menu[i]);
+
+ if (editMenu) {
+ hmenu = editMenu;
+ item = editItem;
}
- else
- {
- hmenu = CreatePopupMenu();
- if (!hmenu)
- {
- ErrorF("MakeMenu: Unable to CreatePopupMenu() %s\n", name);
- return NULL;
- }
- item = 0;
+ else {
+ hmenu = CreatePopupMenu();
+ if (!hmenu) {
+ ErrorF("MakeMenu: Unable to CreatePopupMenu() %s\n", name);
+ return NULL;
+ }
+ item = 0;
}
- /* Add the menu items */
- for (i=0; i<m->menuItems; i++)
- {
- /* Only assign IDs one time... */
- if ( m->menuItem[i].commandID == 0 )
- m->menuItem[i].commandID = g_cmdid++;
-
- switch (m->menuItem[i].cmd)
- {
- case CMD_EXEC:
- case CMD_ALWAYSONTOP:
- case CMD_RELOAD:
- InsertMenu (hmenu,
- item,
- MF_BYPOSITION|MF_ENABLED|MF_STRING,
- m->menuItem[i].commandID,
- m->menuItem[i].text);
- break;
-
- case CMD_SEPARATOR:
- InsertMenu (hmenu,
- item,
- MF_BYPOSITION|MF_SEPARATOR,
- 0,
- NULL);
- break;
-
- case CMD_MENU:
- /* Recursive! */
- hsub = MakeMenu (m->menuItem[i].param, 0, 0);
- if (hsub)
- InsertMenu (hmenu,
- item,
- MF_BYPOSITION|MF_POPUP|MF_ENABLED|MF_STRING,
- (UINT_PTR)hsub,
- m->menuItem[i].text);
- break;
- }
-
- /* If item==-1 (means to add at end of menu) don't increment) */
- if (item>=0)
- item++;
+ /* Add the menu items */
+ for (i = 0; i < m->menuItems; i++) {
+ /* Only assign IDs one time... */
+ if (m->menuItem[i].commandID == 0)
+ m->menuItem[i].commandID = g_cmdid++;
+
+ switch (m->menuItem[i].cmd) {
+ case CMD_EXEC:
+ case CMD_ALWAYSONTOP:
+ case CMD_RELOAD:
+ InsertMenu(hmenu,
+ item,
+ MF_BYPOSITION | MF_ENABLED | MF_STRING,
+ m->menuItem[i].commandID, m->menuItem[i].text);
+ break;
+
+ case CMD_SEPARATOR:
+ InsertMenu(hmenu, item, MF_BYPOSITION | MF_SEPARATOR, 0, NULL);
+ break;
+
+ case CMD_MENU:
+ /* Recursive! */
+ hsub = MakeMenu(m->menuItem[i].param, 0, 0);
+ if (hsub)
+ InsertMenu(hmenu,
+ item,
+ MF_BYPOSITION | MF_POPUP | MF_ENABLED | MF_STRING,
+ (UINT_PTR) hsub, m->menuItem[i].text);
+ break;
+ }
+
+ /* If item==-1 (means to add at end of menu) don't increment) */
+ if (item >= 0)
+ item++;
}
- return hmenu;
+ return hmenu;
}
-
#ifdef XWIN_MULTIWINDOW
/*
* Callback routine that is executed once per window class.
* Removes or creates custom window settings depending on LPARAM
*/
static wBOOL CALLBACK
-ReloadEnumWindowsProc (HWND hwnd, LPARAM lParam)
+ReloadEnumWindowsProc(HWND hwnd, LPARAM lParam)
{
- HICON hicon;
- Window wid;
+ HICON hicon;
+ Window wid;
- if (!hwnd) {
- ErrorF("ReloadEnumWindowsProc: hwnd==NULL!\n");
- return FALSE;
- }
+ if (!hwnd) {
+ ErrorF("ReloadEnumWindowsProc: hwnd==NULL!\n");
+ return FALSE;
+ }
- /* It's our baby, either clean or dirty it */
- if (lParam==FALSE)
- {
- /* Reset the window's icon to undefined. */
- hicon = (HICON)SendMessage(hwnd, WM_SETICON, ICON_BIG, 0);
+ /* It's our baby, either clean or dirty it */
+ if (lParam == FALSE) {
+ /* Reset the window's icon to undefined. */
+ hicon = (HICON) SendMessage(hwnd, WM_SETICON, ICON_BIG, 0);
- /* If the old icon is generated on-the-fly, get rid of it, will regen */
- winDestroyIcon (hicon);
+ /* If the old icon is generated on-the-fly, get rid of it, will regen */
+ winDestroyIcon(hicon);
- /* Same for the small icon */
- hicon = (HICON)SendMessage(hwnd, WM_SETICON, ICON_SMALL, 0);
- winDestroyIcon (hicon);
+ /* Same for the small icon */
+ hicon = (HICON) SendMessage(hwnd, WM_SETICON, ICON_SMALL, 0);
+ winDestroyIcon(hicon);
- /* Remove any menu additions; bRevert=TRUE destroys any modified menus */
- GetSystemMenu (hwnd, TRUE);
-
- /* This window is now clean of our taint (but with undefined icons) */
+ /* Remove any menu additions; bRevert=TRUE destroys any modified menus */
+ GetSystemMenu(hwnd, TRUE);
+
+ /* This window is now clean of our taint (but with undefined icons) */
}
- else
- {
- /* winUpdateIcon() will set the icon default, dynamic, or from xwinrc */
- wid = (Window)GetProp (hwnd, WIN_WID_PROP);
- if (wid)
- winUpdateIcon (wid);
+ else {
+ /* winUpdateIcon() will set the icon default, dynamic, or from xwinrc */
+ wid = (Window) GetProp(hwnd, WIN_WID_PROP);
+ if (wid)
+ winUpdateIcon(wid);
- /* Update the system menu for this window */
- SetupSysMenu ((unsigned long)hwnd);
+ /* Update the system menu for this window */
+ SetupSysMenu((unsigned long) hwnd);
- /* That was easy... */
+ /* That was easy... */
}
- return TRUE;
+ return TRUE;
}
#endif
-
/*
* Removes any custom icons in classes, custom menus, etc.
* Frees all members in pref structure.
@@ -220,353 +197,327 @@ ReloadEnumWindowsProc (HWND hwnd, LPARAM lParam)
* Set custom icons and menus again.
*/
static void
-ReloadPrefs (void)
+ReloadPrefs(void)
{
- int i;
+ int i;
#ifdef XWIN_MULTIWINDOW
- /* First, iterate over all windows, deleting their icons and custom menus.
- * This is really only needed because winDestroyIcon() will try to
- * destroy the old global icons, which will have changed.
- * It is probably better to set a windows USER_DATA to flag locally defined
- * icons, and use that to accurately know when to destroy old icons.
- */
- EnumThreadWindows (g_dwCurrentThreadID, ReloadEnumWindowsProc, FALSE);
+ /* First, iterate over all windows, deleting their icons and custom menus.
+ * This is really only needed because winDestroyIcon() will try to
+ * destroy the old global icons, which will have changed.
+ * It is probably better to set a windows USER_DATA to flag locally defined
+ * icons, and use that to accurately know when to destroy old icons.
+ */
+ EnumThreadWindows(g_dwCurrentThreadID, ReloadEnumWindowsProc, FALSE);
#endif
-
- /* Now, free/clear all info from our prefs structure */
- for (i=0; i<pref.menuItems; i++)
- free (pref.menu[i].menuItem);
- free (pref.menu);
- pref.menu = NULL;
- pref.menuItems = 0;
-
- pref.rootMenuName[0] = 0;
-
- free (pref.sysMenu);
- pref.sysMenuItems = 0;
-
- pref.defaultSysMenuName[0] = 0;
- pref.defaultSysMenuPos = 0;
-
- pref.iconDirectory[0] = 0;
- pref.defaultIconName[0] = 0;
- pref.trayIconName[0] = 0;
-
- for (i=0; i<pref.iconItems; i++)
- if (pref.icon[i].hicon)
- DestroyIcon ((HICON)pref.icon[i].hicon);
- free (pref.icon);
- pref.icon = NULL;
- pref.iconItems = 0;
-
- /* Free global default X icon */
- if (g_hIconX)
- DestroyIcon (g_hIconX);
- if (g_hSmallIconX)
- DestroyIcon (g_hSmallIconX);
-
- /* Reset the custom command IDs */
- g_cmdid = STARTMENUID;
-
- /* Load the updated resource file */
- LoadPreferences();
-
- g_hIconX = NULL;
- g_hSmallIconX = NULL;
+
+ /* Now, free/clear all info from our prefs structure */
+ for (i = 0; i < pref.menuItems; i++)
+ free(pref.menu[i].menuItem);
+ free(pref.menu);
+ pref.menu = NULL;
+ pref.menuItems = 0;
+
+ pref.rootMenuName[0] = 0;
+
+ free(pref.sysMenu);
+ pref.sysMenuItems = 0;
+
+ pref.defaultSysMenuName[0] = 0;
+ pref.defaultSysMenuPos = 0;
+
+ pref.iconDirectory[0] = 0;
+ pref.defaultIconName[0] = 0;
+ pref.trayIconName[0] = 0;
+
+ for (i = 0; i < pref.iconItems; i++)
+ if (pref.icon[i].hicon)
+ DestroyIcon((HICON) pref.icon[i].hicon);
+ free(pref.icon);
+ pref.icon = NULL;
+ pref.iconItems = 0;
+
+ /* Free global default X icon */
+ if (g_hIconX)
+ DestroyIcon(g_hIconX);
+ if (g_hSmallIconX)
+ DestroyIcon(g_hSmallIconX);
+
+ /* Reset the custom command IDs */
+ g_cmdid = STARTMENUID;
+
+ /* Load the updated resource file */
+ LoadPreferences();
+
+ g_hIconX = NULL;
+ g_hSmallIconX = NULL;
#ifdef XWIN_MULTIWINDOW
- winInitGlobalIcons();
+ winInitGlobalIcons();
#endif
-
+
#ifdef XWIN_MULTIWINDOW
- /* Rebuild the icons and menus */
- EnumThreadWindows (g_dwCurrentThreadID, ReloadEnumWindowsProc, TRUE);
+ /* Rebuild the icons and menus */
+ EnumThreadWindows(g_dwCurrentThreadID, ReloadEnumWindowsProc, TRUE);
#endif
- /* Whew, done */
+ /* Whew, done */
}
/*
* Check/uncheck the ALWAYSONTOP items in this menu
*/
void
-HandleCustomWM_INITMENU(unsigned long hwndIn,
- unsigned long hmenuIn)
+HandleCustomWM_INITMENU(unsigned long hwndIn, unsigned long hmenuIn)
{
- HWND hwnd;
- HMENU hmenu;
- DWORD dwExStyle;
- int i, j;
-
- hwnd = (HWND)hwndIn;
- hmenu = (HMENU)hmenuIn;
- if (!hwnd || !hmenu)
- return;
-
- if (GetWindowLongPtr(hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST)
- dwExStyle = MF_BYCOMMAND | MF_CHECKED;
- else
- dwExStyle = MF_BYCOMMAND | MF_UNCHECKED;
-
- for (i=0; i<pref.menuItems; i++)
- for (j=0; j<pref.menu[i].menuItems; j++)
- if (pref.menu[i].menuItem[j].cmd==CMD_ALWAYSONTOP)
- CheckMenuItem (hmenu, pref.menu[i].menuItem[j].commandID, dwExStyle );
-
+ HWND hwnd;
+ HMENU hmenu;
+ DWORD dwExStyle;
+ int i, j;
+
+ hwnd = (HWND) hwndIn;
+ hmenu = (HMENU) hmenuIn;
+ if (!hwnd || !hmenu)
+ return;
+
+ if (GetWindowLongPtr(hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST)
+ dwExStyle = MF_BYCOMMAND | MF_CHECKED;
+ else
+ dwExStyle = MF_BYCOMMAND | MF_UNCHECKED;
+
+ for (i = 0; i < pref.menuItems; i++)
+ for (j = 0; j < pref.menu[i].menuItems; j++)
+ if (pref.menu[i].menuItem[j].cmd == CMD_ALWAYSONTOP)
+ CheckMenuItem(hmenu, pref.menu[i].menuItem[j].commandID,
+ dwExStyle);
+
}
-
+
/*
* Searches for the custom WM_COMMAND command ID and performs action.
* Return TRUE if command is proccessed, FALSE otherwise.
*/
Bool
-HandleCustomWM_COMMAND (unsigned long hwndIn,
- int command)
+HandleCustomWM_COMMAND(unsigned long hwndIn, int command)
{
- HWND hwnd;
- int i, j;
- MENUPARSED *m;
- DWORD dwExStyle;
-
- hwnd = (HWND)hwndIn;
-
- if (!command)
- return FALSE;
-
- for (i=0; i<pref.menuItems; i++)
- {
- m = &(pref.menu[i]);
- for (j=0; j<m->menuItems; j++)
- {
- if (command==m->menuItem[j].commandID)
- {
- /* Match! */
- switch(m->menuItem[j].cmd)
- {
+ HWND hwnd;
+ int i, j;
+ MENUPARSED *m;
+ DWORD dwExStyle;
+
+ hwnd = (HWND) hwndIn;
+
+ if (!command)
+ return FALSE;
+
+ for (i = 0; i < pref.menuItems; i++) {
+ m = &(pref.menu[i]);
+ for (j = 0; j < m->menuItems; j++) {
+ if (command == m->menuItem[j].commandID) {
+ /* Match! */
+ switch (m->menuItem[j].cmd) {
#ifdef __CYGWIN__
- case CMD_EXEC:
- if (fork()==0)
- {
- struct rlimit rl;
- unsigned long i;
-
- /* Close any open descriptors except for STD* */
- getrlimit (RLIMIT_NOFILE, &rl);
- for (i = STDERR_FILENO+1; i < rl.rlim_cur; i++)
- close(i);
-
- /* Disassociate any TTYs */
- setsid();
-
- execl ("/bin/sh",
- "/bin/sh",
- "-c",
- m->menuItem[j].param,
- NULL);
- exit (0);
- }
- else
- return TRUE;
- break;
+ case CMD_EXEC:
+ if (fork() == 0) {
+ struct rlimit rl;
+ unsigned long i;
+
+ /* Close any open descriptors except for STD* */
+ getrlimit(RLIMIT_NOFILE, &rl);
+ for (i = STDERR_FILENO + 1; i < rl.rlim_cur; i++)
+ close(i);
+
+ /* Disassociate any TTYs */
+ setsid();
+
+ execl("/bin/sh",
+ "/bin/sh", "-c", m->menuItem[j].param, NULL);
+ exit(0);
+ }
+ else
+ return TRUE;
+ break;
#else
- case CMD_EXEC:
- {
- /* Start process without console window */
- STARTUPINFO start;
- PROCESS_INFORMATION child;
-
- memset (&start, 0, sizeof (start));
- start.cb = sizeof (start);
- //start.dwFlags = STARTF_USESHOWWINDOW;
- //start.wShowWindow = SW_HIDE;
-
- memset (&child, 0, sizeof (child));
-
- if (CreateProcess (NULL, m->menuItem[j].param, NULL, NULL, FALSE, 0,
- NULL, NULL, &start, &child))
- {
- CloseHandle (child.hThread);
- CloseHandle (child.hProcess);
- }
- else
- MessageBox(NULL, m->menuItem[j].param, "VcXsrv Exec Command Error!", MB_OK | MB_ICONEXCLAMATION);
- }
- return TRUE;
+ case CMD_EXEC:
+ {
+ /* Start process without console window */
+ STARTUPINFO start;
+ PROCESS_INFORMATION child;
+
+ memset(&start, 0, sizeof(start));
+ start.cb = sizeof(start);
+ //start.dwFlags = STARTF_USESHOWWINDOW;
+ //start.wShowWindow = SW_HIDE;
+
+ memset(&child, 0, sizeof(child));
+
+ if (CreateProcess
+ (NULL, m->menuItem[j].param, NULL, NULL, FALSE, 0, NULL,
+ NULL, &start, &child)) {
+ CloseHandle(child.hThread);
+ CloseHandle(child.hProcess);
+ }
+ else
+ MessageBox(NULL, m->menuItem[j].param,
+ "VcXsrv Exec Command Error!",
+ MB_OK | MB_ICONEXCLAMATION);
+ }
+ return TRUE;
#endif
- case CMD_ALWAYSONTOP:
- if (!hwnd)
- return FALSE;
-
- /* Get extended window style */
- dwExStyle = GetWindowLongPtr(hwnd, GWL_EXSTYLE);
-
- /* Handle topmost windows */
- if (dwExStyle & WS_EX_TOPMOST)
- SetWindowPos (hwnd,
- HWND_NOTOPMOST,
- 0, 0,
- 0, 0,
- SWP_NOSIZE | SWP_NOMOVE);
- else
- SetWindowPos (hwnd,
- HWND_TOPMOST,
- 0, 0,
- 0, 0,
- SWP_NOSIZE | SWP_NOMOVE);
+ case CMD_ALWAYSONTOP:
+ if (!hwnd)
+ return FALSE;
+
+ /* Get extended window style */
+ dwExStyle = GetWindowLongPtr(hwnd, GWL_EXSTYLE);
+
+ /* Handle topmost windows */
+ if (dwExStyle & WS_EX_TOPMOST)
+ SetWindowPos(hwnd,
+ HWND_NOTOPMOST,
+ 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
+ else
+ SetWindowPos(hwnd,
+ HWND_TOPMOST,
+ 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
#if XWIN_MULTIWINDOW
- /* Reflect the changed Z order */
- winReorderWindowsMultiWindow ();
+ /* Reflect the changed Z order */
+ winReorderWindowsMultiWindow();
#endif
- return TRUE;
-
- case CMD_RELOAD:
- ReloadPrefs();
- return TRUE;
-
- default:
- return FALSE;
- }
- } /* match */
- } /* for j */
- } /* for i */
-
- return FALSE;
-}
+ return TRUE;
+ case CMD_RELOAD:
+ ReloadPrefs();
+ return TRUE;
+
+ default:
+ return FALSE;
+ }
+ } /* match */
+ } /* for j */
+ } /* for i */
+
+ return FALSE;
+}
#ifdef XWIN_MULTIWINDOW
/*
* Add the default or a custom menu depending on the class match
*/
void
-SetupSysMenu (unsigned long hwndIn)
+SetupSysMenu(unsigned long hwndIn)
{
- HWND hwnd;
- HMENU sys;
- int i;
- WindowPtr pWin;
- char *res_name, *res_class;
-
- hwnd = (HWND)hwndIn;
- if (!hwnd)
- return;
-
- pWin = GetProp (hwnd, WIN_WINDOW_PROP);
-
- sys = GetSystemMenu (hwnd, FALSE);
- if (!sys)
- return;
-
- if (pWin)
- {
- /* First see if there's a class match... */
- if (winMultiWindowGetClassHint (pWin, &res_name, &res_class))
- {
- for (i=0; i<pref.sysMenuItems; i++)
- {
- if (!strcmp(pref.sysMenu[i].match, res_name) ||
- !strcmp(pref.sysMenu[i].match, res_class) )
- {
- free(res_name);
- free(res_class);
-
- MakeMenu (pref.sysMenu[i].menuName, sys,
- pref.sysMenu[i].menuPos==AT_START?0:-1);
- return;
- }
- }
-
- /* No match, just free alloc'd strings */
- free(res_name);
- free(res_class);
- } /* Found wm_class */
- } /* if pwin */
-
- /* Fallback to system default */
- if (pref.defaultSysMenuName[0])
- {
- if (pref.defaultSysMenuPos==AT_START)
- MakeMenu (pref.defaultSysMenuName, sys, 0);
- else
- MakeMenu (pref.defaultSysMenuName, sys, -1);
+ HWND hwnd;
+ HMENU sys;
+ int i;
+ WindowPtr pWin;
+ char *res_name, *res_class;
+
+ hwnd = (HWND) hwndIn;
+ if (!hwnd)
+ return;
+
+ pWin = GetProp(hwnd, WIN_WINDOW_PROP);
+
+ sys = GetSystemMenu(hwnd, FALSE);
+ if (!sys)
+ return;
+
+ if (pWin) {
+ /* First see if there's a class match... */
+ if (winMultiWindowGetClassHint(pWin, &res_name, &res_class)) {
+ for (i = 0; i < pref.sysMenuItems; i++) {
+ if (!strcmp(pref.sysMenu[i].match, res_name) ||
+ !strcmp(pref.sysMenu[i].match, res_class)) {
+ free(res_name);
+ free(res_class);
+
+ MakeMenu(pref.sysMenu[i].menuName, sys,
+ pref.sysMenu[i].menuPos == AT_START ? 0 : -1);
+ return;
+ }
+ }
+
+ /* No match, just free alloc'd strings */
+ free(res_name);
+ free(res_class);
+ } /* Found wm_class */
+ } /* if pwin */
+
+ /* Fallback to system default */
+ if (pref.defaultSysMenuName[0]) {
+ if (pref.defaultSysMenuPos == AT_START)
+ MakeMenu(pref.defaultSysMenuName, sys, 0);
+ else
+ MakeMenu(pref.defaultSysMenuName, sys, -1);
}
}
#endif
-
/*
* Possibly add a menu to the toolbar icon
*/
void
-SetupRootMenu (unsigned long hmenuRoot)
+SetupRootMenu(unsigned long hmenuRoot)
{
- HMENU root;
+ HMENU root;
- root = (HMENU)hmenuRoot;
- if (!root)
- return;
+ root = (HMENU) hmenuRoot;
+ if (!root)
+ return;
- if (pref.rootMenuName[0])
- {
- MakeMenu(pref.rootMenuName, root, 0);
+ if (pref.rootMenuName[0]) {
+ MakeMenu(pref.rootMenuName, root, 0);
}
}
-
/*
* Check for and return an overridden default ICON specified in the prefs
*/
HICON
winOverrideDefaultIcon(int size)
{
- HICON hicon;
-
- if (pref.defaultIconName[0])
- {
- hicon = LoadImageComma (pref.defaultIconName, size, size, 0);
- if (hicon==NULL)
- ErrorF ("winOverrideDefaultIcon: LoadImageComma(%s) failed\n",
- pref.defaultIconName);
-
- return hicon;
+ HICON hicon;
+
+ if (pref.defaultIconName[0]) {
+ hicon = LoadImageComma(pref.defaultIconName, size, size, 0);
+ if (hicon == NULL)
+ ErrorF("winOverrideDefaultIcon: LoadImageComma(%s) failed\n",
+ pref.defaultIconName);
+
+ return hicon;
}
- return 0;
+ return 0;
}
-
/*
* Return the HICON to use in the taskbar notification area
*/
HICON
winTaskbarIcon(void)
{
- HICON hicon;
-
- hicon = 0;
- /* First try and load an overridden, if success then return it */
- if (pref.trayIconName[0])
- {
- hicon = LoadImageComma (pref.trayIconName,
- GetSystemMetrics (SM_CXSMICON),
- GetSystemMetrics (SM_CYSMICON),
- 0 );
+ HICON hicon;
+
+ hicon = 0;
+ /* First try and load an overridden, if success then return it */
+ if (pref.trayIconName[0]) {
+ hicon = LoadImageComma(pref.trayIconName,
+ GetSystemMetrics(SM_CXSMICON),
+ GetSystemMetrics(SM_CYSMICON), 0);
}
- /* Otherwise return the default */
- if (!hicon)
- hicon = (HICON) LoadImage (g_hInstance,
- MAKEINTRESOURCE(IDI_XWIN),
- IMAGE_ICON,
- GetSystemMetrics (SM_CXSMICON),
- GetSystemMetrics (SM_CYSMICON),
- 0);
+ /* Otherwise return the default */
+ if (!hicon)
+ hicon = (HICON) LoadImage(g_hInstance,
+ MAKEINTRESOURCE(IDI_XWIN),
+ IMAGE_ICON,
+ GetSystemMetrics(SM_CXSMICON),
+ GetSystemMetrics(SM_CYSMICON), 0);
- return hicon;
+ return hicon;
}
-
/*
* Parse a filename to extract an icon:
* If fname is exactly ",nnn" then extract icon from our resource
@@ -574,64 +525,53 @@ winTaskbarIcon(void)
* else try to load it as an .ico file and if that fails return NULL
*/
static HICON
-LoadImageComma (char *fname, int sx, int sy, int flags)
+LoadImageComma(char *fname, int sx, int sy, int flags)
{
- HICON hicon;
- int index;
- char file[PATH_MAX+NAME_MAX+2];
-
- /* Some input error checking */
- if (!fname || !fname[0])
- return NULL;
-
- index = 0;
- hicon = NULL;
-
- if (fname[0]==',')
- {
- /* It's the XWIN.EXE resource they want */
- index = atoi (fname+1);
- hicon = LoadImage (g_hInstance,
- MAKEINTRESOURCE(index),
- IMAGE_ICON,
- sx,
- sy,
- flags);
+ HICON hicon;
+ int index;
+ char file[PATH_MAX + NAME_MAX + 2];
+
+ /* Some input error checking */
+ if (!fname || !fname[0])
+ return NULL;
+
+ index = 0;
+ hicon = NULL;
+
+ if (fname[0] == ',') {
+ /* It's the XWIN.EXE resource they want */
+ index = atoi(fname + 1);
+ hicon = LoadImage(g_hInstance,
+ MAKEINTRESOURCE(index), IMAGE_ICON, sx, sy, flags);
}
- else
- {
- file[0] = 0;
- /* Prepend path if not given a "X:\" filename */
- if ( !(fname[0] && fname[1]==':' && fname[2]=='\\') )
- {
- strcpy (file, pref.iconDirectory);
- if (pref.iconDirectory[0])
- if (fname[strlen(fname)-1]!='\\')
- strcat (file, "\\");
+ else {
+ file[0] = 0;
+ /* Prepend path if not given a "X:\" filename */
+ if (!(fname[0] && fname[1] == ':' && fname[2] == '\\')) {
+ strcpy(file, pref.iconDirectory);
+ if (pref.iconDirectory[0])
+ if (fname[strlen(fname) - 1] != '\\')
+ strcat(file, "\\");
+ }
+ strcat(file, fname);
+
+ if (strrchr(file, ',')) {
+ /* Specified as <fname>,<index> */
+
+ *(strrchr(file, ',')) = 0; /* End string at comma */
+ index = atoi(strrchr(fname, ',') + 1);
+ hicon = ExtractIcon(g_hInstance, file, index);
+ }
+ else {
+ /* Just an .ico file... */
+
+ hicon = (HICON) LoadImage(NULL,
+ file,
+ IMAGE_ICON,
+ sx, sy, LR_LOADFROMFILE | flags);
}
- strcat (file, fname);
-
- if (strrchr (file, ','))
- {
- /* Specified as <fname>,<index> */
-
- *(strrchr (file, ',')) = 0; /* End string at comma */
- index = atoi (strrchr (fname, ',') + 1);
- hicon = ExtractIcon (g_hInstance, file, index);
- }
- else
- {
- /* Just an .ico file... */
-
- hicon = (HICON)LoadImage (NULL,
- file,
- IMAGE_ICON,
- sx,
- sy,
- LR_LOADFROMFILE|flags);
- }
}
- return hicon;
+ return hicon;
}
/*
@@ -639,54 +579,52 @@ LoadImageComma (char *fname, int sx, int sy, int flags)
* ICONS{} section in the prefs file, and load the icon from a file
*/
HICON
-winOverrideIcon (unsigned long longWin)
+winOverrideIcon(unsigned long longWin)
{
- WindowPtr pWin = (WindowPtr) longWin;
- char *res_name, *res_class;
- int i;
- HICON hicon;
- char *wmName;
+ WindowPtr pWin = (WindowPtr) longWin;
+ char *res_name, *res_class;
+ int i;
+ HICON hicon;
+ char *wmName;
+
+ if (pWin == NULL)
+ return 0;
+
+ /* If we can't find the class, we can't override from default! */
+ if (!winMultiWindowGetClassHint(pWin, &res_name, &res_class))
+ return 0;
+
+ winMultiWindowGetWMName(pWin, &wmName);
+
+ for (i = 0; i < pref.iconItems; i++) {
+ if (!strcmp(pref.icon[i].match, res_name) ||
+ !strcmp(pref.icon[i].match, res_class) ||
+ (wmName && strstr(wmName, pref.icon[i].match))) {
+ free(res_name);
+ free(res_class);
+ free(wmName);
+
+ if (pref.icon[i].hicon)
+ return pref.icon[i].hicon;
+
+ hicon = LoadImageComma(pref.icon[i].iconFile, 0, 0, LR_DEFAULTSIZE);
+ if (hicon == NULL)
+ ErrorF("winOverrideIcon: LoadImageComma(%s) failed\n",
+ pref.icon[i].iconFile);
+
+ pref.icon[i].hicon = hicon;
+ return hicon;
+ }
+ }
- if (pWin==NULL)
- return 0;
+ /* Didn't find the icon, fail gracefully */
+ free(res_name);
+ free(res_class);
+ free(wmName);
- /* If we can't find the class, we can't override from default! */
- if (!winMultiWindowGetClassHint (pWin, &res_name, &res_class))
return 0;
-
- winMultiWindowGetWMName (pWin, &wmName);
-
- for (i=0; i<pref.iconItems; i++) {
- if (!strcmp(pref.icon[i].match, res_name) ||
- !strcmp(pref.icon[i].match, res_class) ||
- (wmName && strstr(wmName, pref.icon[i].match)))
- {
- free (res_name);
- free (res_class);
- free(wmName);
-
- if (pref.icon[i].hicon)
- return pref.icon[i].hicon;
-
- hicon = LoadImageComma (pref.icon[i].iconFile, 0, 0, LR_DEFAULTSIZE);
- if (hicon==NULL)
- ErrorF ("winOverrideIcon: LoadImageComma(%s) failed\n",
- pref.icon[i].iconFile);
-
- pref.icon[i].hicon = hicon;
- return hicon;
- }
- }
-
- /* Didn't find the icon, fail gracefully */
- free (res_name);
- free (res_class);
- free(wmName);
-
- return 0;
}
-
/*
* Should we free this icon or leave it in memory (is it part of our
* ICONS{} overrides)?
@@ -694,187 +632,168 @@ winOverrideIcon (unsigned long longWin)
int
winIconIsOverride(unsigned hiconIn)
{
- HICON hicon;
- int i;
+ HICON hicon;
+ int i;
- hicon = (HICON)hiconIn;
+ hicon = (HICON) hiconIn;
- if (!hicon)
- return 0;
-
- for (i=0; i<pref.iconItems; i++)
- if ((HICON)pref.icon[i].hicon == hicon)
- return 1;
-
- return 0;
-}
+ if (!hicon)
+ return 0;
+ for (i = 0; i < pref.iconItems; i++)
+ if ((HICON) pref.icon[i].hicon == hicon)
+ return 1;
+ return 0;
+}
/*
* Open and parse the XWinrc config file @path.
* If @path is NULL, use the built-in default.
*/
static int
-winPrefsLoadPreferences (char *path)
+winPrefsLoadPreferences(char *path)
{
- FILE *prefFile = NULL;
+ FILE *prefFile = NULL;
- if (path)
- prefFile = fopen (path, "r");
+ if (path)
+ prefFile = fopen(path, "r");
#ifndef _MSC_VER
- else
- {
- char defaultPrefs[] =
- "MENU rmenu {\n"
- " \"How to customize this menu\" EXEC \"xterm +tb -e man XWinrc\"\n"
- " \"Launch xterm\" EXEC xterm\n"
- " \"Load .XWinrc\" RELOAD\n"
- " SEPARATOR\n"
- "}\n"
- "\n"
- "ROOTMENU rmenu\n";
-
- path = "built-in default";
- prefFile = fmemopen(defaultPrefs, strlen(defaultPrefs), "r");
+ else {
+ char defaultPrefs[] =
+ "MENU rmenu {\n"
+ " \"How to customize this menu\" EXEC \"xterm +tb -e man XWinrc\"\n"
+ " \"Launch xterm\" EXEC xterm\n"
+ " \"Load .XWinrc\" RELOAD\n"
+ " SEPARATOR\n" "}\n" "\n" "ROOTMENU rmenu\n";
+
+ path = "built-in default";
+ prefFile = fmemopen(defaultPrefs, strlen(defaultPrefs), "r");
}
#endif
- if (!prefFile)
- {
- ErrorF ("LoadPreferences: %s not found\n", path);
- return FALSE;
+ if (!prefFile) {
+ ErrorF("LoadPreferences: %s not found\n", path);
+ return FALSE;
}
- ErrorF ("LoadPreferences: Loading %s\n", path);
+ ErrorF("LoadPreferences: Loading %s\n", path);
- if((parse_file (prefFile)) != 0)
- {
- ErrorF ("LoadPreferences: %s is badly formed!\n", path);
- fclose (prefFile);
- return FALSE;
+ if ((parse_file(prefFile)) != 0) {
+ ErrorF("LoadPreferences: %s is badly formed!\n", path);
+ fclose(prefFile);
+ return FALSE;
}
- fclose (prefFile);
- return TRUE;
+ fclose(prefFile);
+ return TRUE;
}
-
-
/*
* Try and open ~/.XWinrc and system.XWinrc
* Load it into prefs structure for use by other functions
*/
void
-LoadPreferences (void)
+LoadPreferences(void)
{
- char *home;
- char fname[PATH_MAX+NAME_MAX+2];
- char szDisplay[512];
- char *szEnvDisplay;
- int i, j;
- char param[PARAM_MAX+1];
- char *srcParam, *dstParam;
- int parsed = FALSE;
-
- /* First, clear all preference settings */
- memset (&pref, 0, sizeof(pref));
-
- /* Now try and find a ~/.xwinrc file */
- home = getenv ("HOME");
- if (home)
- {
- strcpy (fname, home);
- if (fname[strlen(fname)-1]!='/')
- strcat (fname, "/");
- strcat (fname, ".XWinrc");
- parsed = winPrefsLoadPreferences(fname);
+ char *home;
+ char fname[PATH_MAX + NAME_MAX + 2];
+ char szDisplay[512];
+ char *szEnvDisplay;
+ int i, j;
+ char param[PARAM_MAX + 1];
+ char *srcParam, *dstParam;
+ int parsed = FALSE;
+
+ /* First, clear all preference settings */
+ memset(&pref, 0, sizeof(pref));
+
+ /* Now try and find a ~/.xwinrc file */
+ home = getenv("HOME");
+ if (home) {
+ strcpy(fname, home);
+ if (fname[strlen(fname) - 1] != '/')
+ strcat(fname, "/");
+ strcat(fname, ".XWinrc");
+ parsed = winPrefsLoadPreferences(fname);
}
- /* No home file found, check system default */
- if (!parsed)
- {
- char buffer[MAX_PATH];
+ /* No home file found, check system default */
+ if (!parsed) {
+ char buffer[MAX_PATH];
+
#ifdef RELOCATE_PROJECTROOT
- snprintf(buffer, sizeof(buffer), "%s\\system.XWinrc", winGetBaseDir());
+ snprintf(buffer, sizeof(buffer), "%s\\system.XWinrc", winGetBaseDir());
#else
- strncpy(buffer, SYSCONFDIR"/X11/system.XWinrc", sizeof(buffer));
+ strncpy(buffer, SYSCONFDIR "/X11/system.XWinrc", sizeof(buffer));
#endif
- buffer[sizeof(buffer)-1] = 0;
- parsed = winPrefsLoadPreferences(buffer);
+ buffer[sizeof(buffer) - 1] = 0;
+ parsed = winPrefsLoadPreferences(buffer);
}
- /* Neither user nor system configuration found, or were badly formed */
- if (!parsed)
- {
- ErrorF ("LoadPreferences: See \"man XWinrc\" to customize the XWin menu.\n");
- parsed = winPrefsLoadPreferences(NULL);
+ /* Neither user nor system configuration found, or were badly formed */
+ if (!parsed) {
+ ErrorF
+ ("LoadPreferences: See \"man XWinrc\" to customize the XWin menu.\n");
+ parsed = winPrefsLoadPreferences(NULL);
}
- /* Setup a DISPLAY environment variable, need to allocate on heap */
- /* because putenv doesn't copy the argument... Always use screen 0 */
- winGetDisplayName(szDisplay, 0);
- szEnvDisplay = (char *)(malloc(strlen(szDisplay)+9/*strlen("DISPLAY=")+1*/));
- snprintf(szEnvDisplay, 512, "DISPLAY=%s", szDisplay);
- putenv (szEnvDisplay);
-
- /* Replace any "%display%" in menu commands with display string */
- for (i=0; i<pref.menuItems; i++)
- {
- for (j=0; j<pref.menu[i].menuItems; j++)
- {
- if (pref.menu[i].menuItem[j].cmd==CMD_EXEC)
- {
- srcParam = pref.menu[i].menuItem[j].param;
- dstParam = param;
- while (*srcParam) {
- if (!strncmp(srcParam, "%display%", 9))
- {
- memcpy (dstParam, szDisplay, strlen(szDisplay));
- dstParam += strlen(szDisplay);
- srcParam += 9;
- }
- else if (!strncmp(srcParam, "%logfile%", 9))
- {
- memcpy (dstParam, g_pszLogFile, strlen(g_pszLogFile));
- dstParam += strlen(g_pszLogFile);
- srcParam += 9;
- }
- else
- {
- *dstParam = *srcParam;
- dstParam++;
- srcParam++;
- }
- }
- *dstParam = 0;
- strcpy (pref.menu[i].menuItem[j].param, param);
- } /* cmd==cmd_exec */
- } /* for all menuitems */
- } /* for all menus */
+ /* Setup a DISPLAY environment variable, need to allocate on heap */
+ /* because putenv doesn't copy the argument... Always use screen 0 */
+ winGetDisplayName(szDisplay, 0);
+ szEnvDisplay = (char *)(malloc(strlen(szDisplay)+9/*strlen("DISPLAY=")+1*/));
+ snprintf(szEnvDisplay, 512, "DISPLAY=%s", szDisplay);
+ putenv (szEnvDisplay);
+
+ /* Replace any "%display%" in menu commands with display string */
+ for (i = 0; i < pref.menuItems; i++) {
+ for (j = 0; j < pref.menu[i].menuItems; j++) {
+ if (pref.menu[i].menuItem[j].cmd == CMD_EXEC) {
+ srcParam = pref.menu[i].menuItem[j].param;
+ dstParam = param;
+ while (*srcParam) {
+ if (!strncmp(srcParam, "%display%", 9)) {
+ memcpy(dstParam, szDisplay, strlen(szDisplay));
+ dstParam += strlen(szDisplay);
+ srcParam += 9;
+ }
+ else if (!strncmp(srcParam, "%logfile%", 9)) {
+ memcpy (dstParam, g_pszLogFile, strlen(g_pszLogFile));
+ dstParam += strlen(g_pszLogFile);
+ srcParam += 9;
+ }
+ else {
+ *dstParam = *srcParam;
+ dstParam++;
+ srcParam++;
+ }
+ }
+ *dstParam = 0;
+ strcpy(pref.menu[i].menuItem[j].param, param);
+ } /* cmd==cmd_exec */
+ } /* for all menuitems */
+ } /* for all menus */
}
-
/*
* Check for a match of the window class to one specified in the
* STYLES{} section in the prefs file, and return the style type
*/
unsigned long
-winOverrideStyle (char *res_name, char *res_class, char *wmName)
+winOverrideStyle(char *res_name, char *res_class, char *wmName)
{
- int i;
-
- for (i=0; i<pref.styleItems; i++) {
- if ((res_name && !strcmp(pref.style[i].match, res_name)) ||
- (res_class && !strcmp(pref.style[i].match, res_class)) ||
- (wmName && strstr(wmName, pref.style[i].match)))
- {
- if (pref.style[i].type)
- return pref.style[i].type;
- }
- }
-
- /* Didn't find the style, fail gracefully */
- return STYLE_NONE;
+ int i;
+
+ for (i = 0; i < pref.styleItems; i++) {
+ if ((res_name && !strcmp(pref.style[i].match, res_name)) ||
+ (res_class && !strcmp(pref.style[i].match, res_class)) ||
+ (wmName && strstr(wmName, pref.style[i].match))) {
+ if (pref.style[i].type)
+ return pref.style[i].type;
+ }
+ }
+
+ /* Didn't find the style, fail gracefully */
+ return STYLE_NONE;
}
diff --git a/xorg-server/hw/xwin/winprefs.h b/xorg-server/hw/xwin/winprefs.h
index ecd0a3fbd..fcce8d840 100644
--- a/xorg-server/hw/xwin/winprefs.h
+++ b/xorg-server/hw/xwin/winprefs.h
@@ -45,146 +45,131 @@
#ifndef NAME_MAX
#define NAME_MAX PATH_MAX
#endif
-#define MENU_MAX 128 /* Maximum string length of a menu name or item */
+#define MENU_MAX 128 /* Maximum string length of a menu name or item */
#define PARAM_MAX (4*PATH_MAX) /* Maximum length of a parameter to a MENU */
-
/* Supported commands in a MENU {} statement */
-typedef enum MENUCOMMANDTYPE
-{
- CMD_EXEC, /* /bin/sh -c the parameter */
- CMD_MENU, /* Display a popup menu named param */
- CMD_SEPARATOR, /* Menu separator */
- CMD_ALWAYSONTOP, /* Toggle always-on-top mode */
- CMD_RELOAD /* Reparse the .XWINRC file */
+typedef enum MENUCOMMANDTYPE {
+ CMD_EXEC, /* /bin/sh -c the parameter */
+ CMD_MENU, /* Display a popup menu named param */
+ CMD_SEPARATOR, /* Menu separator */
+ CMD_ALWAYSONTOP, /* Toggle always-on-top mode */
+ CMD_RELOAD /* Reparse the .XWINRC file */
} MENUCOMMANDTYPE;
-#define STYLE_NONE (0L) /* Dummy the first entry */
-#define STYLE_NOTITLE (1L) /* Force window style no titlebar */
-#define STYLE_OUTLINE (1L<<1) /* Force window style just thin-line border */
-#define STYLE_NOFRAME (1L<<2) /* Force window style no frame */
-#define STYLE_TOPMOST (1L<<3) /* Open a window always-on-top */
-#define STYLE_MAXIMIZE (1L<<4) /* Open a window maximized */
-#define STYLE_MINIMIZE (1L<<5) /* Open a window minimized */
-#define STYLE_BOTTOM (1L<<6) /* Open a window at the bottom of the Z order */
+#define STYLE_NONE (0L) /* Dummy the first entry */
+#define STYLE_NOTITLE (1L) /* Force window style no titlebar */
+#define STYLE_OUTLINE (1L<<1) /* Force window style just thin-line border */
+#define STYLE_NOFRAME (1L<<2) /* Force window style no frame */
+#define STYLE_TOPMOST (1L<<3) /* Open a window always-on-top */
+#define STYLE_MAXIMIZE (1L<<4) /* Open a window maximized */
+#define STYLE_MINIMIZE (1L<<5) /* Open a window minimized */
+#define STYLE_BOTTOM (1L<<6) /* Open a window at the bottom of the Z order */
/* Where to place a system menu */
-typedef enum MENUPOSITION
-{
- AT_START, /* Place menu at the top of the system menu */
- AT_END /* Put it at the bottom of the menu (default) */
+typedef enum MENUPOSITION {
+ AT_START, /* Place menu at the top of the system menu */
+ AT_END /* Put it at the bottom of the menu (default) */
} MENUPOSITION;
/* Menu item definitions */
-typedef struct MENUITEM
-{
- char text[MENU_MAX+1]; /* To be displayed in menu */
- MENUCOMMANDTYPE cmd; /* What should it do? */
- char param[PARAM_MAX+1]; /* Any parameters? */
- unsigned long commandID; /* Windows WM_COMMAND ID assigned at runtime */
+typedef struct MENUITEM {
+ char text[MENU_MAX + 1]; /* To be displayed in menu */
+ MENUCOMMANDTYPE cmd; /* What should it do? */
+ char param[PARAM_MAX + 1]; /* Any parameters? */
+ unsigned long commandID; /* Windows WM_COMMAND ID assigned at runtime */
} MENUITEM;
/* A completely read in menu... */
-typedef struct MENUPARSED
-{
- char menuName[MENU_MAX+1]; /* What's it called in the text? */
- MENUITEM *menuItem; /* Array of items */
- int menuItems; /* How big's the array? */
+typedef struct MENUPARSED {
+ char menuName[MENU_MAX + 1]; /* What's it called in the text? */
+ MENUITEM *menuItem; /* Array of items */
+ int menuItems; /* How big's the array? */
} MENUPARSED;
/* To map between a window and a system menu to add for it */
-typedef struct SYSMENUITEM
-{
- char match[MENU_MAX+1]; /* String to look for to apply this sysmenu */
- char menuName[MENU_MAX+1]; /* Which menu to show? Used to set *menu */
- MENUPOSITION menuPos; /* Where to place it (ignored in root) */
+typedef struct SYSMENUITEM {
+ char match[MENU_MAX + 1]; /* String to look for to apply this sysmenu */
+ char menuName[MENU_MAX + 1]; /* Which menu to show? Used to set *menu */
+ MENUPOSITION menuPos; /* Where to place it (ignored in root) */
} SYSMENUITEM;
/* To redefine icons for certain window types */
-typedef struct ICONITEM
-{
- char match[MENU_MAX+1]; /* What string to search for? */
- char iconFile[PATH_MAX+NAME_MAX+2]; /* Icon location, WIN32 path */
- HICON hicon; /* LoadImage() result */
+typedef struct ICONITEM {
+ char match[MENU_MAX + 1]; /* What string to search for? */
+ char iconFile[PATH_MAX + NAME_MAX + 2]; /* Icon location, WIN32 path */
+ HICON hicon; /* LoadImage() result */
} ICONITEM;
/* To redefine styles for certain window types */
-typedef struct STYLEITEM
-{
- char match[MENU_MAX+1]; /* What string to search for? */
- unsigned long type; /* What should it do? */
+typedef struct STYLEITEM {
+ char match[MENU_MAX + 1]; /* What string to search for? */
+ unsigned long type; /* What should it do? */
} STYLEITEM;
-typedef struct WINPREFS
-{
- /* Menu information */
- MENUPARSED *menu; /* Array of created menus */
- int menuItems; /* How big? */
+typedef struct WINPREFS {
+ /* Menu information */
+ MENUPARSED *menu; /* Array of created menus */
+ int menuItems; /* How big? */
- /* Taskbar menu settings */
- char rootMenuName[MENU_MAX+1]; /* Menu for taskbar icon */
+ /* Taskbar menu settings */
+ char rootMenuName[MENU_MAX + 1]; /* Menu for taskbar icon */
- /* System menu addition menus */
- SYSMENUITEM *sysMenu;
- int sysMenuItems;
+ /* System menu addition menus */
+ SYSMENUITEM *sysMenu;
+ int sysMenuItems;
- /* Which menu to add to unmatched windows? */
- char defaultSysMenuName[MENU_MAX+1];
- MENUPOSITION defaultSysMenuPos; /* Where to place it */
+ /* Which menu to add to unmatched windows? */
+ char defaultSysMenuName[MENU_MAX + 1];
+ MENUPOSITION defaultSysMenuPos; /* Where to place it */
- /* Icon information */
- char iconDirectory[PATH_MAX+1]; /* Where do the .icos lie? (Win32 path) */
- char defaultIconName[NAME_MAX+1]; /* Replacement for x.ico */
- char trayIconName[NAME_MAX+1]; /* Replacement for tray icon */
+ /* Icon information */
+ char iconDirectory[PATH_MAX + 1]; /* Where do the .icos lie? (Win32 path) */
+ char defaultIconName[NAME_MAX + 1]; /* Replacement for x.ico */
+ char trayIconName[NAME_MAX + 1]; /* Replacement for tray icon */
- ICONITEM *icon;
- int iconItems;
+ ICONITEM *icon;
+ int iconItems;
- STYLEITEM *style;
- int styleItems;
+ STYLEITEM *style;
+ int styleItems;
- /* Force exit flag */
- Bool fForceExit;
+ /* Force exit flag */
+ Bool fForceExit;
- /* Silent exit flag */
- Bool fSilentExit;
+ /* Silent exit flag */
+ Bool fSilentExit;
} WINPREFS;
/* The global pref settings structure loaded by the winprefyacc.y parser */
extern WINPREFS pref;
-
/* Functions */
void
-LoadPreferences(void);
+ LoadPreferences(void);
void
-SetupRootMenu (unsigned long hmenuRoot);
+ SetupRootMenu(unsigned long hmenuRoot);
void
-SetupSysMenu (unsigned long hwndIn);
+ SetupSysMenu(unsigned long hwndIn);
void
-HandleCustomWM_INITMENU(unsigned long hwndIn,
- unsigned long hmenuIn);
+ HandleCustomWM_INITMENU(unsigned long hwndIn, unsigned long hmenuIn);
Bool
-HandleCustomWM_COMMAND (unsigned long hwndIn,
- int command);
+ HandleCustomWM_COMMAND(unsigned long hwndIn, int command);
int
-winIconIsOverride (unsigned hiconIn);
+ winIconIsOverride(unsigned hiconIn);
-HICON
-winOverrideIcon (unsigned long longpWin);
+HICON winOverrideIcon(unsigned long longpWin);
unsigned long
-winOverrideStyle (char *res_name, char *res_class, char *wmName);
+ winOverrideStyle(char *res_name, char *res_class, char *wmName);
-HICON
-winTaskbarIcon(void);
+HICON winTaskbarIcon(void);
-HICON
-winOverrideDefaultIcon(int size);
+HICON winOverrideDefaultIcon(int size);
#endif
diff --git a/xorg-server/hw/xwin/winprocarg.c b/xorg-server/hw/xwin/winprocarg.c
index 1418f78bc..bb7f2fd94 100644
--- a/xorg-server/hw/xwin/winprocarg.c
+++ b/xorg-server/hw/xwin/winprocarg.c
@@ -42,9 +42,9 @@ from The Open Group.
*/
#ifdef XWIN_CLIPBOARD
-extern Bool g_fUnicodeClipboard;
-extern Bool g_fClipboard;
-extern Bool g_fClipboardPrimary;
+extern Bool g_fUnicodeClipboard;
+extern Bool g_fClipboard;
+extern Bool g_fClipboardPrimary;
#endif
/*
@@ -52,13 +52,13 @@ extern Bool g_fClipboardPrimary;
*/
void
-winLogCommandLine (int argc, char *argv[]);
+ winLogCommandLine(int argc, char *argv[]);
void
-winLogVersionInfo (void);
+ winLogVersionInfo(void);
#ifdef DDXOSVERRORF
-void OsVendorVErrorF (const char *pszFormat, va_list va_args);
+void OsVendorVErrorF(const char *pszFormat, va_list va_args);
#endif
/*
@@ -71,122 +71,128 @@ static winScreenInfo defaultScreenInfo;
static void
winInitializeScreenDefaults(void)
{
- DWORD dwWidth, dwHeight;
- static Bool fInitializedScreenDefaults = FALSE;
-
- /* Bail out early if default screen has already been initialized */
- if (fInitializedScreenDefaults)
- return;
-
- /* Zero the memory used for storing the screen info */
- memset(&defaultScreenInfo, 0, sizeof(winScreenInfo));
-
- /* Get default width and height */
- /*
- * NOTE: These defaults will cause the window to cover only
- * the primary monitor in the case that we have multiple monitors.
- */
- dwWidth = GetSystemMetrics (SM_CXSCREEN);
- dwHeight = GetSystemMetrics (SM_CYSCREEN);
-
- winDebug ("winInitializeScreenDefaults - primary monitor w %d h %d\n", (int) dwWidth, (int) dwHeight);
-
- /* Set a default DPI, if no '-dpi' option was used */
- if (monitorResolution == 0)
- {
- HDC hdc = GetDC(NULL);
- if (hdc)
- {
- int dpiX = GetDeviceCaps(hdc, LOGPIXELSX);
- int dpiY = GetDeviceCaps(hdc, LOGPIXELSY);
-
- winDebug("winInitializeDefaultScreens - native DPI x %d y %d\n", dpiX, dpiY);
- monitorResolution = dpiY;
- ReleaseDC(NULL, hdc);
+ DWORD dwWidth, dwHeight;
+ static Bool fInitializedScreenDefaults = FALSE;
+
+ /* Bail out early if default screen has already been initialized */
+ if (fInitializedScreenDefaults)
+ return;
+
+ /* Zero the memory used for storing the screen info */
+ memset(&defaultScreenInfo, 0, sizeof(winScreenInfo));
+
+ /* Get default width and height */
+ /*
+ * NOTE: These defaults will cause the window to cover only
+ * the primary monitor in the case that we have multiple monitors.
+ */
+ dwWidth = GetSystemMetrics(SM_CXSCREEN);
+ dwHeight = GetSystemMetrics(SM_CYSCREEN);
+
+ winDebug (
+ "winInitializeScreenDefaults - primary monitor w %d h %d\n",
+ (int) dwWidth, (int) dwHeight);
+
+ /* Set a default DPI, if no '-dpi' option was used */
+ if (monitorResolution == 0) {
+ HDC hdc = GetDC(NULL);
+
+ if (hdc) {
+ int dpiX = GetDeviceCaps(hdc, LOGPIXELSX);
+ int dpiY = GetDeviceCaps(hdc, LOGPIXELSY);
+
+ winDebug(
+ "winInitializeDefaultScreens - native DPI x %d y %d\n",
+ dpiX, dpiY);
+ monitorResolution = dpiY;
+ ReleaseDC(NULL, hdc);
}
- else
- {
- winDebug("winInitializeDefaultScreens - Failed to retrieve native DPI, falling back to default of %d DPI\n", WIN_DEFAULT_DPI);
- monitorResolution = WIN_DEFAULT_DPI;
+ else {
+ winDebug(
+ "winInitializeDefaultScreens - Failed to retrieve native DPI, falling back to default of %d DPI\n",
+ WIN_DEFAULT_DPI);
+ monitorResolution = WIN_DEFAULT_DPI;
}
}
- defaultScreenInfo.iMonitor = 1;
- defaultScreenInfo.hMonitor = MonitorFromWindow(NULL, MONITOR_DEFAULTTOPRIMARY);
- defaultScreenInfo.dwWidth = dwWidth;
- defaultScreenInfo.dwHeight = dwHeight;
- defaultScreenInfo.dwUserWidth = dwWidth;
- defaultScreenInfo.dwUserHeight = dwHeight;
- defaultScreenInfo.fUserGaveHeightAndWidth = WIN_DEFAULT_USER_GAVE_HEIGHT_AND_WIDTH;
- defaultScreenInfo.fUserGavePosition = FALSE;
- defaultScreenInfo.dwBPP = WIN_DEFAULT_BPP;
- defaultScreenInfo.dwClipUpdatesNBoxes = WIN_DEFAULT_CLIP_UPDATES_NBOXES;
+ defaultScreenInfo.iMonitor = 1;
+ defaultScreenInfo.hMonitor = MonitorFromWindow(NULL, MONITOR_DEFAULTTOPRIMARY);
+ defaultScreenInfo.dwWidth = dwWidth;
+ defaultScreenInfo.dwHeight = dwHeight;
+ defaultScreenInfo.dwUserWidth = dwWidth;
+ defaultScreenInfo.dwUserHeight = dwHeight;
+ defaultScreenInfo.fUserGaveHeightAndWidth =
+ WIN_DEFAULT_USER_GAVE_HEIGHT_AND_WIDTH;
+ defaultScreenInfo.fUserGavePosition = FALSE;
+ defaultScreenInfo.dwBPP = WIN_DEFAULT_BPP;
+ defaultScreenInfo.dwClipUpdatesNBoxes = WIN_DEFAULT_CLIP_UPDATES_NBOXES;
#ifdef XWIN_EMULATEPSEUDO
- defaultScreenInfo.fEmulatePseudo = WIN_DEFAULT_EMULATE_PSEUDO;
+ defaultScreenInfo.fEmulatePseudo = WIN_DEFAULT_EMULATE_PSEUDO;
#endif
- defaultScreenInfo.dwRefreshRate = WIN_DEFAULT_REFRESH;
- defaultScreenInfo.pfb = NULL;
- defaultScreenInfo.fFullScreen = FALSE;
- defaultScreenInfo.fDecoration = TRUE;
+ defaultScreenInfo.dwRefreshRate = WIN_DEFAULT_REFRESH;
+ defaultScreenInfo.pfb = NULL;
+ defaultScreenInfo.fFullScreen = FALSE;
+ defaultScreenInfo.fDecoration = TRUE;
#ifdef XWIN_MULTIWINDOWEXTWM
- defaultScreenInfo.fMWExtWM = FALSE;
+ defaultScreenInfo.fMWExtWM = FALSE;
#endif
#ifdef XWIN_MULTIWINDOWINTWM
- defaultScreenInfo.fInternalWM = FALSE;
+ defaultScreenInfo.fInternalWM = FALSE;
#endif
- defaultScreenInfo.fRootless = FALSE;
+ defaultScreenInfo.fRootless = FALSE;
#ifdef XWIN_MULTIWINDOW
- defaultScreenInfo.fMultiWindow = FALSE;
+ defaultScreenInfo.fMultiWindow = FALSE;
#endif
#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
- defaultScreenInfo.fMultiMonitorOverride = FALSE;
+ defaultScreenInfo.fMultiMonitorOverride = FALSE;
#endif
- defaultScreenInfo.fMultipleMonitors = FALSE;
- defaultScreenInfo.fLessPointer = FALSE;
- defaultScreenInfo.iResizeMode = resizeWithRandr;
- defaultScreenInfo.fNoTrayIcon = FALSE;
- defaultScreenInfo.iE3BTimeout = WIN_E3B_DEFAULT;
- defaultScreenInfo.fUseWinKillKey = WIN_DEFAULT_WIN_KILL;
- defaultScreenInfo.fUseUnixKillKey = WIN_DEFAULT_UNIX_KILL;
- defaultScreenInfo.fIgnoreInput = FALSE;
- defaultScreenInfo.fExplicitScreen = FALSE;
-
- /* Note that the default screen has been initialized */
- fInitializedScreenDefaults = TRUE;
+ defaultScreenInfo.fMultipleMonitors = FALSE;
+ defaultScreenInfo.fLessPointer = FALSE;
+ defaultScreenInfo.iResizeMode = resizeWithRandr;
+ defaultScreenInfo.fNoTrayIcon = FALSE;
+ defaultScreenInfo.iE3BTimeout = WIN_E3B_DEFAULT;
+ defaultScreenInfo.fUseWinKillKey = WIN_DEFAULT_WIN_KILL;
+ defaultScreenInfo.fUseUnixKillKey = WIN_DEFAULT_UNIX_KILL;
+ defaultScreenInfo.fIgnoreInput = FALSE;
+ defaultScreenInfo.fExplicitScreen = FALSE;
+
+ /* Note that the default screen has been initialized */
+ fInitializedScreenDefaults = TRUE;
}
static void
winInitializeScreen(int i)
{
- winDebug ("winInitializeScreen - %d\n",i);
+ winDebug ("winInitializeScreen - %d\n",i);
- /* Initialize default screen values, if needed */
- winInitializeScreenDefaults();
+ /* Initialize default screen values, if needed */
+ winInitializeScreenDefaults();
- /* Copy the default screen info */
- g_ScreenInfo[i] = defaultScreenInfo;
+ /* Copy the default screen info */
+ g_ScreenInfo[i] = defaultScreenInfo;
- /* Set the screen number */
- g_ScreenInfo[i].dwScreen = i;
+ /* Set the screen number */
+ g_ScreenInfo[i].dwScreen = i;
}
void
winInitializeScreens(int maxscreens)
{
- int i;
- winDebug ("winInitializeScreens - %i\n", maxscreens);
+ int i;
- if (maxscreens > g_iNumScreens)
- {
- /* Reallocate the memory for DDX-specific screen info */
- g_ScreenInfo = realloc(g_ScreenInfo, maxscreens * sizeof (winScreenInfo));
+ winDebug ("winInitializeScreens - %i\n", maxscreens);
+
+ if (maxscreens > g_iNumScreens) {
+ /* Reallocate the memory for DDX-specific screen info */
+ g_ScreenInfo =
+ realloc(g_ScreenInfo, maxscreens * sizeof(winScreenInfo));
- /* Set default values for any new screens */
- for (i = g_iNumScreens; i < maxscreens ; i++)
- winInitializeScreen(i);
+ /* Set default values for any new screens */
+ for (i = g_iNumScreens; i < maxscreens; i++)
+ winInitializeScreen(i);
- /* Keep a count of the number of screens */
- g_iNumScreens = maxscreens;
+ /* Keep a count of the number of screens */
+ g_iNumScreens = maxscreens;
}
}
@@ -212,539 +218,507 @@ winInitializeScreens(int maxscreens)
/* Check if enough arguments are given for the option */
#define CHECK_ARGS(count) if (i + count >= argc) { UseMsg (); return 0; }
-/* Compare the current option with the string. */
+/* Compare the current option with the string. */
#define IS_OPTION(name) (strcmp (argv[i], name) == 0)
int
-ddxProcessArgument (int argc, char *argv[], int i)
+ddxProcessArgument(int argc, char *argv[], int i)
{
- static Bool s_fBeenHere = FALSE;
- winScreenInfo *screenInfoPtr = NULL;
+ static Bool s_fBeenHere = FALSE;
+ winScreenInfo *screenInfoPtr = NULL;
- /* Initialize once */
- if (!s_fBeenHere)
- {
+ /* Initialize once */
+ if (!s_fBeenHere) {
#ifdef DDXOSVERRORF
- /*
- * This initialises our hook into VErrorF () for catching log messages
- * that are generated before OsInit () is called.
- */
- OsVendorVErrorFProc = OsVendorVErrorF;
+ /*
+ * This initialises our hook into VErrorF () for catching log messages
+ * that are generated before OsInit () is called.
+ */
+ OsVendorVErrorFProc = OsVendorVErrorF;
#endif
- s_fBeenHere = TRUE;
+ s_fBeenHere = TRUE;
- /* Initialize only if option is not -help */
- if (!IS_OPTION("-help") && !IS_OPTION("-h") && !IS_OPTION("--help") &&
- !IS_OPTION("-version") && !IS_OPTION("--version"))
- {
+ /* Initialize only if option is not -help */
+ if (!IS_OPTION("-help") && !IS_OPTION("-h") && !IS_OPTION("--help") &&
+ !IS_OPTION("-version") && !IS_OPTION("--version")) {
- /* Log the version information */
- winLogVersionInfo ();
+ /* Log the version information */
+ winLogVersionInfo();
- /* Log the command line */
- winLogCommandLine (argc, argv);
+ /* Log the command line */
+ winLogCommandLine(argc, argv);
- /*
- * Initialize default screen settings. We have to do this before
- * OsVendorInit () gets called, otherwise we will overwrite
- * settings changed by parameters such as -fullscreen, etc.
- */
- winDebug ("ddxProcessArgument - Initializing default "
- "screens\n");
- winInitializeScreenDefaults();
- }
+ /*
+ * Initialize default screen settings. We have to do this before
+ * OsVendorInit () gets called, otherwise we will overwrite
+ * settings changed by parameters such as -fullscreen, etc.
+ */
+ winDebug ("ddxProcessArgument - Initializing default "
+ "screens\n");
+ winInitializeScreenDefaults();
+ }
}
- winDebug ("ddxProcessArgument - arg: %s\n", argv[i]);
-
- /*
- * Look for the '-help' and similar options
- */
- if (IS_OPTION ("-help") || IS_OPTION("-h") || IS_OPTION("--help"))
- {
- /* Reset logfile. We don't need that helpmessage in the logfile */
- g_pszLogFile = NULL;
- g_fNoHelpMessageBox = TRUE;
- UseMsg();
- exit (0);
- return 1;
+ winDebug("ddxProcessArgument - arg: %s\n", argv[i]);
+
+ /*
+ * Look for the '-help' and similar options
+ */
+ if (IS_OPTION("-help") || IS_OPTION("-h") || IS_OPTION("--help")) {
+ /* Reset logfile. We don't need that helpmessage in the logfile */
+ g_pszLogFile = NULL;
+ g_fNoHelpMessageBox = TRUE;
+ UseMsg();
+ exit(0);
+ return 1;
}
- if (IS_OPTION ("-version") || IS_OPTION("--version"))
- {
- /* Reset logfile. We don't need that versioninfo in the logfile */
- g_pszLogFile = NULL;
- winLogVersionInfo ();
- exit (0);
- return 1;
+ if (IS_OPTION("-version") || IS_OPTION("--version")) {
+ /* Reset logfile. We don't need that versioninfo in the logfile */
+ g_pszLogFile = NULL;
+ winLogVersionInfo();
+ exit(0);
+ return 1;
}
- /*
- * Look for the '-screen scr_num [width height]' argument
- */
- if (IS_OPTION ("-screen"))
- {
- int iArgsProcessed = 1;
- int nScreenNum;
- int iWidth, iHeight, iX, iY;
- int iMonitor;
-
- winDebug ("ddxProcessArgument - screen - argc: %d i: %d\n",
- argc, i);
-
- /* Display the usage message if the argument is malformed */
- if (i + 1 >= argc)
- {
- return 0;
- }
-
- /* Grab screen number */
- nScreenNum = atoi (argv[i + 1]);
-
- /* Validate the specified screen number */
- if (nScreenNum < 0)
- {
- ErrorF ("ddxProcessArgument - screen - Invalid screen number %d\n",
- nScreenNum);
- UseMsg ();
- return 0;
+ /*
+ * Look for the '-screen scr_num [width height]' argument
+ */
+ if (IS_OPTION("-screen")) {
+ int iArgsProcessed = 1;
+ int nScreenNum;
+ int iWidth, iHeight, iX, iY;
+ int iMonitor;
+
+ winDebug("ddxProcessArgument - screen - argc: %d i: %d\n", argc, i);
+
+ /* Display the usage message if the argument is malformed */
+ if (i + 1 >= argc) {
+ return 0;
+ }
+
+ /* Grab screen number */
+ nScreenNum = atoi(argv[i + 1]);
+
+ /* Validate the specified screen number */
+ if (nScreenNum < 0) {
+ ErrorF("ddxProcessArgument - screen - Invalid screen number %d\n",
+ nScreenNum);
+ UseMsg();
+ return 0;
}
- /*
- Initialize default values for any new screens
+ /*
+ Initialize default values for any new screens
- Note that default values can't change after a -screen option is
- seen, so it's safe to do this for each screen as it is introduced
- */
- winInitializeScreens(nScreenNum+1);
+ Note that default values can't change after a -screen option is
+ seen, so it's safe to do this for each screen as it is introduced
+ */
+ winInitializeScreens(nScreenNum + 1);
- /* look for @m where m is monitor number */
- if (i + 2 < argc
- && 1 == sscanf(argv[i + 2], "@%d", (int *) &iMonitor))
- {
- struct GetMonitorInfoData data;
- if (!QueryMonitor(iMonitor, &data))
- {
- ErrorF ("ddxProcessArgument - screen - Querying monitors failed\n");
- } else if (data.bMonitorSpecifiedExists == TRUE)
- {
- winDebug("ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n", iMonitor);
- iArgsProcessed = 3;
- g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = FALSE;
- g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE;
- g_ScreenInfo[nScreenNum].iMonitor = iMonitor;
- g_ScreenInfo[nScreenNum].hMonitor = data.monitorHandle;
- g_ScreenInfo[nScreenNum].dwWidth = data.monitorWidth;
- g_ScreenInfo[nScreenNum].dwHeight = data.monitorHeight;
- g_ScreenInfo[nScreenNum].dwUserWidth = data.monitorWidth;
- g_ScreenInfo[nScreenNum].dwUserHeight = data.monitorHeight;
- g_ScreenInfo[nScreenNum].dwInitialX = data.monitorOffsetX;
- g_ScreenInfo[nScreenNum].dwInitialY = data.monitorOffsetY;
- }
- else
- {
- /* monitor does not exist, error out */
- ErrorF ("ddxProcessArgument - screen - Invalid monitor number %d\n",
- iMonitor);
- UseMsg ();
- exit (0);
- return 0;
- }
- }
-
- /* Look for 'WxD' or 'W D' */
- else if (i + 2 < argc
- && 2 == sscanf (argv[i + 2], "%dx%d",
- (int *) &iWidth,
- (int *) &iHeight))
- {
- winDebug ("ddxProcessArgument - screen - Found ``WxD'' arg\n");
- iArgsProcessed = 3;
- g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = TRUE;
- g_ScreenInfo[nScreenNum].dwWidth = iWidth;
- g_ScreenInfo[nScreenNum].dwHeight = iHeight;
- g_ScreenInfo[nScreenNum].dwUserWidth = iWidth;
- g_ScreenInfo[nScreenNum].dwUserHeight = iHeight;
- /* Look for WxD+X+Y */
- if (2 == sscanf (argv[i + 2], "%*dx%*d+%d+%d",
- (int *) &iX,
- (int *) &iY))
- {
- winDebug("ddxProcessArgument - screen - Found ``X+Y'' arg\n");
- g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE;
- g_ScreenInfo[nScreenNum].dwInitialX = iX;
- g_ScreenInfo[nScreenNum].dwInitialY = iY;
-
- /* look for WxD+X+Y@m where m is monitor number. take X,Y to be offsets from monitor's root position */
- if (1 == sscanf (argv[i + 2], "%*dx%*d+%*d+%*d@%d",
- (int *) &iMonitor))
- {
- struct GetMonitorInfoData data;
- if (!QueryMonitor(iMonitor, &data))
- {
- ErrorF ("ddxProcessArgument - screen - Querying monitors failed\n");
- } else if (data.bMonitorSpecifiedExists == TRUE)
- {
- g_ScreenInfo[nScreenNum].iMonitor = iMonitor;
+ /* look for @m where m is monitor number */
+ if (i + 2 < argc && 1 == sscanf(argv[i + 2], "@%d", (int *) &iMonitor)) {
+ struct GetMonitorInfoData data;
+
+ if (!QueryMonitor(iMonitor, &data)) {
+ ErrorF
+ ("ddxProcessArgument - screen - Querying monitors failed\n");
+ }
+ else if (data.bMonitorSpecifiedExists == TRUE) {
+ winDebug(
+ "ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n",
+ iMonitor);
+ iArgsProcessed = 3;
+ g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = FALSE;
+ g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE;
+ g_ScreenInfo[nScreenNum].iMonitor = iMonitor;
+ g_ScreenInfo[nScreenNum].hMonitor = data.monitorHandle;
+ g_ScreenInfo[nScreenNum].dwWidth = data.monitorWidth;
+ g_ScreenInfo[nScreenNum].dwHeight = data.monitorHeight;
+ g_ScreenInfo[nScreenNum].dwUserWidth = data.monitorWidth;
+ g_ScreenInfo[nScreenNum].dwUserHeight = data.monitorHeight;
+ g_ScreenInfo[nScreenNum].dwInitialX = data.monitorOffsetX;
+ g_ScreenInfo[nScreenNum].dwInitialY = data.monitorOffsetY;
+ }
+ else {
+ /* monitor does not exist, error out */
+ ErrorF
+ ("ddxProcessArgument - screen - Invalid monitor number %d\n",
+ iMonitor);
+ UseMsg();
+ exit(0);
+ return 0;
+ }
+ }
+
+ /* Look for 'WxD' or 'W D' */
+ else if (i + 2 < argc
+ && 2 == sscanf(argv[i + 2], "%dx%d",
+ (int *) &iWidth, (int *) &iHeight)) {
+ winDebug (
+ "ddxProcessArgument - screen - Found ``WxD'' arg\n");
+ iArgsProcessed = 3;
+ g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = TRUE;
+ g_ScreenInfo[nScreenNum].dwWidth = iWidth;
+ g_ScreenInfo[nScreenNum].dwHeight = iHeight;
+ g_ScreenInfo[nScreenNum].dwUserWidth = iWidth;
+ g_ScreenInfo[nScreenNum].dwUserHeight = iHeight;
+ /* Look for WxD+X+Y */
+ if (2 == sscanf(argv[i + 2], "%*dx%*d+%d+%d",
+ (int *) &iX, (int *) &iY)) {
+ winDebug (
+ "ddxProcessArgument - screen - Found ``X+Y'' arg\n");
+ g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE;
+ g_ScreenInfo[nScreenNum].dwInitialX = iX;
+ g_ScreenInfo[nScreenNum].dwInitialY = iY;
+
+ /* look for WxD+X+Y@m where m is monitor number. take X,Y to be offsets from monitor's root position */
+ if (1 == sscanf(argv[i + 2], "%*dx%*d+%*d+%*d@%d",
+ (int *) &iMonitor)) {
+ struct GetMonitorInfoData data;
+
+ if (!QueryMonitor(iMonitor, &data)) {
+ ErrorF
+ ("ddxProcessArgument - screen - Querying monitors failed\n");
+ }
+ else if (data.bMonitorSpecifiedExists == TRUE) {
+ g_ScreenInfo[nScreenNum].iMonitor = iMonitor;
g_ScreenInfo[nScreenNum].hMonitor = data.monitorHandle;
- g_ScreenInfo[nScreenNum].dwInitialX += data.monitorOffsetX;
- g_ScreenInfo[nScreenNum].dwInitialY += data.monitorOffsetY;
- }
- else
- {
- /* monitor does not exist, error out */
- ErrorF ("ddxProcessArgument - screen - Invalid monitor number %d\n",
- iMonitor);
- UseMsg ();
- exit (0);
- return 0;
- }
-
- }
- }
-
- /* look for WxD@m where m is monitor number */
- else if (1 == sscanf(argv[i + 2], "%*dx%*d@%d",
- (int *) &iMonitor))
- {
- struct GetMonitorInfoData data;
- if (!QueryMonitor(iMonitor, &data))
- {
- ErrorF ("ddxProcessArgument - screen - Querying monitors failed\n");
- } else if (data.bMonitorSpecifiedExists == TRUE)
- {
- winDebug ("ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n", iMonitor);
- g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE;
- g_ScreenInfo[nScreenNum].iMonitor = iMonitor;
- g_ScreenInfo[nScreenNum].hMonitor = data.monitorHandle;
- g_ScreenInfo[nScreenNum].dwInitialX = data.monitorOffsetX;
- g_ScreenInfo[nScreenNum].dwInitialY = data.monitorOffsetY;
- }
- else
- {
- /* monitor does not exist, error out */
- ErrorF ("ddxProcessArgument - screen - Invalid monitor number %d\n",
- iMonitor);
- UseMsg ();
- exit (0);
- return 0;
- }
-
- }
- }
- else if (i + 3 < argc
- && 1 == sscanf (argv[i + 2], "%d",
- (int *) &iWidth)
- && 1 == sscanf (argv[i + 3], "%d",
- (int *) &iHeight))
- {
- winDebug ("ddxProcessArgument - screen - Found ``W D'' arg\n");
- iArgsProcessed = 4;
- g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = TRUE;
- g_ScreenInfo[nScreenNum].dwWidth = iWidth;
- g_ScreenInfo[nScreenNum].dwHeight = iHeight;
- g_ScreenInfo[nScreenNum].dwUserWidth = iWidth;
- g_ScreenInfo[nScreenNum].dwUserHeight = iHeight;
- if (i + 5 < argc
- && 1 == sscanf (argv[i + 4], "%d",
- (int *) &iX)
- && 1 == sscanf (argv[i + 5], "%d",
- (int *) &iY))
- {
- winDebug ("ddxProcessArgument - screen - Found ``X Y'' arg\n");
- iArgsProcessed = 6;
- g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE;
- g_ScreenInfo[nScreenNum].dwInitialX = iX;
- g_ScreenInfo[nScreenNum].dwInitialY = iY;
- }
- }
- else
- {
- ErrorF ("ddxProcessArgument - screen - Did not find size arg. "
- "dwWidth: %d dwHeight: %d\n",
- (int) g_ScreenInfo[nScreenNum].dwWidth,
- (int) g_ScreenInfo[nScreenNum].dwHeight);
- iArgsProcessed = 2;
- g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = FALSE;
- }
-
- /* Flag that this screen was explicity specified by the user */
- g_ScreenInfo[nScreenNum].fExplicitScreen = TRUE;
-
- /*
- * Keep track of the last screen number seen, as parameters seen
- * before a screen number apply to all screens, whereas parameters
- * seen after a screen number apply to that screen number only.
- */
- iLastScreen = nScreenNum;
-
- return iArgsProcessed;
- }
+ g_ScreenInfo[nScreenNum].dwInitialX +=
+ data.monitorOffsetX;
+ g_ScreenInfo[nScreenNum].dwInitialY +=
+ data.monitorOffsetY;
+ }
+ else {
+ /* monitor does not exist, error out */
+ ErrorF
+ ("ddxProcessArgument - screen - Invalid monitor number %d\n",
+ iMonitor);
+ UseMsg();
+ exit(0);
+ return 0;
+ }
+
+ }
+ }
+ /* look for WxD@m where m is monitor number */
+ else if (1 == sscanf(argv[i + 2], "%*dx%*d@%d", (int *) &iMonitor)) {
+ struct GetMonitorInfoData data;
+
+ if (!QueryMonitor(iMonitor, &data)) {
+ ErrorF
+ ("ddxProcessArgument - screen - Querying monitors failed\n");
+ }
+ else if (data.bMonitorSpecifiedExists == TRUE) {
+ winDebug (
+ "ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n",
+ iMonitor);
+ g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE;
+ g_ScreenInfo[nScreenNum].iMonitor = iMonitor;
+ g_ScreenInfo[nScreenNum].hMonitor = data.monitorHandle;
+ g_ScreenInfo[nScreenNum].dwInitialX = data.monitorOffsetX;
+ g_ScreenInfo[nScreenNum].dwInitialY = data.monitorOffsetY;
+ }
+ else {
+ /* monitor does not exist, error out */
+ ErrorF
+ ("ddxProcessArgument - screen - Invalid monitor number %d\n",
+ iMonitor);
+ UseMsg();
+ exit(0);
+ return 0;
+ }
- /*
- * Is this parameter attached to a screen or global?
- *
- * If the parameter is for all screens (appears before
- * any -screen option), store it in the default screen
- * info
- *
- * If the parameter is for a single screen (appears
- * after a -screen option), store it in the screen info
- * for that screen
- *
- */
- if (iLastScreen == -1)
- {
- screenInfoPtr = &defaultScreenInfo;
+ }
+ }
+ else if (i + 3 < argc && 1 == sscanf(argv[i + 2], "%d", (int *) &iWidth)
+ && 1 == sscanf(argv[i + 3], "%d", (int *) &iHeight)) {
+ winDebug (
+ "ddxProcessArgument - screen - Found ``W D'' arg\n");
+ iArgsProcessed = 4;
+ g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = TRUE;
+ g_ScreenInfo[nScreenNum].dwWidth = iWidth;
+ g_ScreenInfo[nScreenNum].dwHeight = iHeight;
+ g_ScreenInfo[nScreenNum].dwUserWidth = iWidth;
+ g_ScreenInfo[nScreenNum].dwUserHeight = iHeight;
+ if (i + 5 < argc && 1 == sscanf(argv[i + 4], "%d", (int *) &iX)
+ && 1 == sscanf(argv[i + 5], "%d", (int *) &iY)) {
+ winDebug (
+ "ddxProcessArgument - screen - Found ``X Y'' arg\n");
+ iArgsProcessed = 6;
+ g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE;
+ g_ScreenInfo[nScreenNum].dwInitialX = iX;
+ g_ScreenInfo[nScreenNum].dwInitialY = iY;
+ }
+ }
+ else {
+ ErrorF (
+ "ddxProcessArgument - screen - Did not find size arg. "
+ "dwWidth: %d dwHeight: %d\n",
+ (int) g_ScreenInfo[nScreenNum].dwWidth,
+ (int) g_ScreenInfo[nScreenNum].dwHeight);
+ iArgsProcessed = 2;
+ g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = FALSE;
+ }
+
+ /* Flag that this screen was explicity specified by the user */
+ g_ScreenInfo[nScreenNum].fExplicitScreen = TRUE;
+
+ /*
+ * Keep track of the last screen number seen, as parameters seen
+ * before a screen number apply to all screens, whereas parameters
+ * seen after a screen number apply to that screen number only.
+ */
+ iLastScreen = nScreenNum;
+
+ return iArgsProcessed;
}
- else
- {
- screenInfoPtr = &(g_ScreenInfo[iLastScreen]);
+
+ /*
+ * Is this parameter attached to a screen or global?
+ *
+ * If the parameter is for all screens (appears before
+ * any -screen option), store it in the default screen
+ * info
+ *
+ * If the parameter is for a single screen (appears
+ * after a -screen option), store it in the screen info
+ * for that screen
+ *
+ */
+ if (iLastScreen == -1) {
+ screenInfoPtr = &defaultScreenInfo;
+ }
+ else {
+ screenInfoPtr = &(g_ScreenInfo[iLastScreen]);
}
- /*
- * Look for the '-engine n' argument
- */
- if (IS_OPTION ("-engine"))
- {
- DWORD dwEngine = 0;
- CARD8 c8OnBits = 0;
-
- /* Display the usage message if the argument is malformed */
- if (++i >= argc)
- {
- UseMsg ();
- return 0;
- }
-
- /* Grab the argument */
- dwEngine = atoi (argv[i]);
-
- /* Count the one bits in the engine argument */
- c8OnBits = winCountBits (dwEngine);
-
- /* Argument should only have a single bit on */
- if (c8OnBits != 1)
- {
- UseMsg ();
- return 0;
- }
-
- screenInfoPtr->dwEnginePreferred = dwEngine;
-
- /* Indicate that we have processed the argument */
- return 2;
+ /*
+ * Look for the '-engine n' argument
+ */
+ if (IS_OPTION("-engine")) {
+ DWORD dwEngine = 0;
+ CARD8 c8OnBits = 0;
+
+ /* Display the usage message if the argument is malformed */
+ if (++i >= argc) {
+ UseMsg();
+ return 0;
+ }
+
+ /* Grab the argument */
+ dwEngine = atoi(argv[i]);
+
+ /* Count the one bits in the engine argument */
+ c8OnBits = winCountBits(dwEngine);
+
+ /* Argument should only have a single bit on */
+ if (c8OnBits != 1) {
+ UseMsg();
+ return 0;
+ }
+
+ screenInfoPtr->dwEnginePreferred = dwEngine;
+
+ /* Indicate that we have processed the argument */
+ return 2;
}
- /*
- * Look for the '-fullscreen' argument
- */
- if (IS_OPTION ("-fullscreen"))
- {
+ /*
+ * Look for the '-fullscreen' argument
+ */
+ if (IS_OPTION("-fullscreen")) {
#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
- if (!screenInfoPtr->fMultiMonitorOverride)
+ if (!screenInfoPtr->fMultiMonitorOverride)
screenInfoPtr->fMultipleMonitors = FALSE;
#endif
- screenInfoPtr->fFullScreen = TRUE;
+ screenInfoPtr->fFullScreen = TRUE;
- /* Indicate that we have processed this argument */
- return 1;
+ /* Indicate that we have processed this argument */
+ return 1;
}
- /*
- * Look for the '-lesspointer' argument
- */
- if (IS_OPTION ("-lesspointer"))
- {
- screenInfoPtr->fLessPointer = TRUE;
+ /*
+ * Look for the '-lesspointer' argument
+ */
+ if (IS_OPTION("-lesspointer")) {
+ screenInfoPtr->fLessPointer = TRUE;
- /* Indicate that we have processed this argument */
- return 1;
+ /* Indicate that we have processed this argument */
+ return 1;
}
- /*
- * Look for the '-nodecoration' argument
- */
- if (IS_OPTION ("-nodecoration"))
- {
+ /*
+ * Look for the '-nodecoration' argument
+ */
+ if (IS_OPTION("-nodecoration")) {
#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
- if (!screenInfoPtr->fMultiMonitorOverride)
- screenInfoPtr->fMultipleMonitors = FALSE;
+ if (!screenInfoPtr->fMultiMonitorOverride)
+ screenInfoPtr->fMultipleMonitors = FALSE;
#endif
- screenInfoPtr->fDecoration = FALSE;
+ screenInfoPtr->fDecoration = FALSE;
- /* Indicate that we have processed this argument */
- return 1;
+ /* Indicate that we have processed this argument */
+ return 1;
}
#ifdef XWIN_MULTIWINDOWEXTWM
- /*
- * Look for the '-mwextwm' argument
- */
- if (IS_OPTION ("-mwextwm"))
- {
- if (!screenInfoPtr->fMultiMonitorOverride)
- screenInfoPtr->fMultipleMonitors = TRUE;
- screenInfoPtr->fMWExtWM = TRUE;
-
- /* Indicate that we have processed this argument */
- return 1;
+ /*
+ * Look for the '-mwextwm' argument
+ */
+ if (IS_OPTION("-mwextwm")) {
+ if (!screenInfoPtr->fMultiMonitorOverride)
+ screenInfoPtr->fMultipleMonitors = TRUE;
+ screenInfoPtr->fMWExtWM = TRUE;
+
+ /* Indicate that we have processed this argument */
+ return 1;
}
#endif
#ifdef XWIN_MULTIWINDOWINTWM
- /*
- * Look for the '-internalwm' argument
- */
- if (IS_OPTION ("-internalwm"))
- {
- if (!screenInfoPtr->fMultiMonitorOverride)
- screenInfoPtr->fMultipleMonitors = TRUE;
- screenInfoPtr->fMWExtWM = TRUE;
- screenInfoPtr->fInternalWM = TRUE;
-
- /* Indicate that we have processed this argument */
- return 1;
+ /*
+ * Look for the '-internalwm' argument
+ */
+ if (IS_OPTION("-internalwm")) {
+ if (!screenInfoPtr->fMultiMonitorOverride)
+ screenInfoPtr->fMultipleMonitors = TRUE;
+ screenInfoPtr->fMWExtWM = TRUE;
+ screenInfoPtr->fInternalWM = TRUE;
+
+ /* Indicate that we have processed this argument */
+ return 1;
}
#endif
- /*
- * Look for the '-rootless' argument
- */
- if (IS_OPTION ("-rootless"))
- {
+ /*
+ * Look for the '-rootless' argument
+ */
+ if (IS_OPTION("-rootless")) {
#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
- if (!screenInfoPtr->fMultiMonitorOverride)
- screenInfoPtr->fMultipleMonitors = FALSE;
+ if (!screenInfoPtr->fMultiMonitorOverride)
+ screenInfoPtr->fMultipleMonitors = FALSE;
#endif
- screenInfoPtr->fRootless = TRUE;
+ screenInfoPtr->fRootless = TRUE;
- /* Indicate that we have processed this argument */
- return 1;
+ /* Indicate that we have processed this argument */
+ return 1;
}
#ifdef XWIN_MULTIWINDOW
- /*
- * Look for the '-multiwindow' argument
- */
- if (IS_OPTION ("-multiwindow"))
- {
+ /*
+ * Look for the '-multiwindow' argument
+ */
+ if (IS_OPTION("-multiwindow")) {
#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
- if (!screenInfoPtr->fMultiMonitorOverride)
- screenInfoPtr->fMultipleMonitors = TRUE;
+ if (!screenInfoPtr->fMultiMonitorOverride)
+ screenInfoPtr->fMultipleMonitors = TRUE;
#endif
- screenInfoPtr->fMultiWindow = TRUE;
+ screenInfoPtr->fMultiWindow = TRUE;
- /* Indicate that we have processed this argument */
- return 1;
+ /* Indicate that we have processed this argument */
+ return 1;
}
#endif
- /*
- * Look for the '-multiplemonitors' argument
- */
- if (IS_OPTION ("-multiplemonitors")
- || IS_OPTION ("-multimonitors"))
- {
+ /*
+ * Look for the '-multiplemonitors' argument
+ */
+ if (IS_OPTION("-multiplemonitors")
+ || IS_OPTION("-multimonitors")) {
#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
- screenInfoPtr->fMultiMonitorOverride = TRUE;
+ screenInfoPtr->fMultiMonitorOverride = TRUE;
#endif
- screenInfoPtr->fMultipleMonitors = TRUE;
+ screenInfoPtr->fMultipleMonitors = TRUE;
- /* Indicate that we have processed this argument */
- return 1;
+ /* Indicate that we have processed this argument */
+ return 1;
}
- /*
- * Look for the '-nomultiplemonitors' argument
- */
- if (IS_OPTION ("-nomultiplemonitors")
- || IS_OPTION ("-nomultimonitors"))
- {
+ /*
+ * Look for the '-nomultiplemonitors' argument
+ */
+ if (IS_OPTION("-nomultiplemonitors")
+ || IS_OPTION("-nomultimonitors")) {
#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
- screenInfoPtr->fMultiMonitorOverride = TRUE;
+ screenInfoPtr->fMultiMonitorOverride = TRUE;
#endif
- screenInfoPtr->fMultipleMonitors = FALSE;
+ screenInfoPtr->fMultipleMonitors = FALSE;
- /* Indicate that we have processed this argument */
- return 1;
+ /* Indicate that we have processed this argument */
+ return 1;
}
+ /*
+ * Look for the '-scrollbars' argument
+ */
+ if (IS_OPTION("-scrollbars")) {
- /*
- * Look for the '-scrollbars' argument
- */
- if (IS_OPTION ("-scrollbars"))
- {
-
- screenInfoPtr->iResizeMode = resizeWithScrollbars;
+ screenInfoPtr->iResizeMode = resizeWithScrollbars;
- /* Indicate that we have processed this argument */
- return 1;
+ /* Indicate that we have processed this argument */
+ return 1;
}
- /*
- * Look for the '-resize' argument
- */
- if (IS_OPTION ("-resize") || IS_OPTION ("-noresize") ||
- (strncmp(argv[i], "-resize=",strlen("-resize=")) == 0))
- {
- winResizeMode mode;
+ /*
+ * Look for the '-resize' argument
+ */
+ if (IS_OPTION("-resize") || IS_OPTION("-noresize") ||
+ (strncmp(argv[i], "-resize=", strlen("-resize=")) == 0)) {
+ winResizeMode mode;
- if (IS_OPTION ("-resize"))
- mode = resizeWithRandr;
- else if (IS_OPTION ("-noresize"))
- mode = notAllowed;
- else if (strncmp(argv[i], "-resize=",strlen("-resize=")) == 0)
- {
- char *option = argv[i] + strlen("-resize=");
- if (strcmp(option, "randr") == 0)
+ if (IS_OPTION("-resize"))
mode = resizeWithRandr;
- else if (strcmp(option, "scrollbars") == 0)
- mode = resizeWithScrollbars;
- else if (strcmp(option, "none") == 0)
+ else if (IS_OPTION("-noresize"))
mode = notAllowed;
- else
- {
- ErrorF ("ddxProcessArgument - resize - Invalid resize mode %s\n", option);
- return 0;
+ else if (strncmp(argv[i], "-resize=", strlen("-resize=")) == 0) {
+ char *option = argv[i] + strlen("-resize=");
+
+ if (strcmp(option, "randr") == 0)
+ mode = resizeWithRandr;
+ else if (strcmp(option, "scrollbars") == 0)
+ mode = resizeWithScrollbars;
+ else if (strcmp(option, "none") == 0)
+ mode = notAllowed;
+ else {
+ ErrorF("ddxProcessArgument - resize - Invalid resize mode %s\n",
+ option);
+ return 0;
}
}
- else
- {
- ErrorF ("ddxProcessArgument - resize - Invalid resize option %s\n", argv[i]);
- return 0;
+ else {
+ ErrorF("ddxProcessArgument - resize - Invalid resize option %s\n",
+ argv[i]);
+ return 0;
}
- screenInfoPtr->iResizeMode = mode;
+ screenInfoPtr->iResizeMode = mode;
- /* Indicate that we have processed this argument */
- return 1;
+ /* Indicate that we have processed this argument */
+ return 1;
}
#ifdef XWIN_CLIPBOARD
- /*
- * Look for the '-clipboard' argument
- */
- if (IS_OPTION ("-clipboard"))
- {
- /* Now the default, we still accept the arg for backwards compatibility */
- g_fClipboard = TRUE;
-
- /* Indicate that we have processed this argument */
- return 1;
+ /*
+ * Look for the '-clipboard' argument
+ */
+ if (IS_OPTION("-clipboard")) {
+ /* Now the default, we still accept the arg for backwards compatibility */
+ g_fClipboard = TRUE;
+
+ /* Indicate that we have processed this argument */
+ return 1;
}
- /*
- * Look for the '-noclipboard' argument
- */
- if (IS_OPTION ("-noclipboard"))
- {
- g_fClipboard = FALSE;
+ /*
+ * Look for the '-noclipboard' argument
+ */
+ if (IS_OPTION("-noclipboard")) {
+ g_fClipboard = FALSE;
- /* Indicate that we have processed this argument */
- return 1;
+ /* Indicate that we have processed this argument */
+ return 1;
}
/*
@@ -772,516 +746,468 @@ ddxProcessArgument (int argc, char *argv[], int i)
#endif
+ /*
+ * Look for the '-ignoreinput' argument
+ */
+ if (IS_OPTION("-ignoreinput")) {
+ screenInfoPtr->fIgnoreInput = TRUE;
- /*
- * Look for the '-ignoreinput' argument
- */
- if (IS_OPTION ("-ignoreinput"))
- {
- screenInfoPtr->fIgnoreInput = TRUE;
-
- /* Indicate that we have processed this argument */
- return 1;
+ /* Indicate that we have processed this argument */
+ return 1;
}
- /*
- * Look for the '-emulate3buttons' argument
- */
- if (IS_OPTION ("-emulate3buttons"))
- {
- int iArgsProcessed = 1;
- int iE3BTimeout = WIN_DEFAULT_E3B_TIME;
-
- /* Grab the optional timeout value */
- if (i + 1 < argc
- && 1 == sscanf (argv[i + 1], "%d",
- &iE3BTimeout))
- {
- /* Indicate that we have processed the next argument */
- iArgsProcessed++;
+ /*
+ * Look for the '-emulate3buttons' argument
+ */
+ if (IS_OPTION("-emulate3buttons")) {
+ int iArgsProcessed = 1;
+ int iE3BTimeout = WIN_DEFAULT_E3B_TIME;
+
+ /* Grab the optional timeout value */
+ if (i + 1 < argc && 1 == sscanf(argv[i + 1], "%d", &iE3BTimeout)) {
+ /* Indicate that we have processed the next argument */
+ iArgsProcessed++;
+ }
+ else {
+ /*
+ * sscanf () won't modify iE3BTimeout if it doesn't find
+ * the specified format; however, I want to be explicit
+ * about setting the default timeout in such cases to
+ * prevent some programs (me) from getting confused.
+ */
+ iE3BTimeout = WIN_DEFAULT_E3B_TIME;
}
- else
- {
- /*
- * sscanf () won't modify iE3BTimeout if it doesn't find
- * the specified format; however, I want to be explicit
- * about setting the default timeout in such cases to
- * prevent some programs (me) from getting confused.
- */
- iE3BTimeout = WIN_DEFAULT_E3B_TIME;
- }
-
- screenInfoPtr->iE3BTimeout = iE3BTimeout;
- /* Indicate that we have processed this argument */
- return iArgsProcessed;
+ screenInfoPtr->iE3BTimeout = iE3BTimeout;
+
+ /* Indicate that we have processed this argument */
+ return iArgsProcessed;
}
- /*
- * Look for the '-noemulate3buttons' argument
- */
- if (IS_OPTION ("-noemulate3buttons"))
- {
- screenInfoPtr->iE3BTimeout = WIN_E3B_OFF;
+ /*
+ * Look for the '-noemulate3buttons' argument
+ */
+ if (IS_OPTION("-noemulate3buttons")) {
+ screenInfoPtr->iE3BTimeout = WIN_E3B_OFF;
- /* Indicate that we have processed this argument */
- return 1;
+ /* Indicate that we have processed this argument */
+ return 1;
}
- /*
- * Look for the '-depth n' argument
- */
- if (IS_OPTION ("-depth"))
- {
- DWORD dwBPP = 0;
-
- /* Display the usage message if the argument is malformed */
- if (++i >= argc)
- {
- UseMsg ();
- return 0;
- }
-
- /* Grab the argument */
- dwBPP = atoi (argv[i]);
-
- screenInfoPtr->dwBPP = dwBPP;
-
- /* Indicate that we have processed the argument */
- return 2;
+ /*
+ * Look for the '-depth n' argument
+ */
+ if (IS_OPTION("-depth")) {
+ DWORD dwBPP = 0;
+
+ /* Display the usage message if the argument is malformed */
+ if (++i >= argc) {
+ UseMsg();
+ return 0;
+ }
+
+ /* Grab the argument */
+ dwBPP = atoi(argv[i]);
+
+ screenInfoPtr->dwBPP = dwBPP;
+
+ /* Indicate that we have processed the argument */
+ return 2;
}
- /*
- * Look for the '-refresh n' argument
- */
- if (IS_OPTION ("-refresh"))
- {
- DWORD dwRefreshRate = 0;
-
- /* Display the usage message if the argument is malformed */
- if (++i >= argc)
- {
- UseMsg ();
- return 0;
- }
-
- /* Grab the argument */
- dwRefreshRate = atoi (argv[i]);
-
- screenInfoPtr->dwRefreshRate = dwRefreshRate;
-
- /* Indicate that we have processed the argument */
- return 2;
+ /*
+ * Look for the '-refresh n' argument
+ */
+ if (IS_OPTION("-refresh")) {
+ DWORD dwRefreshRate = 0;
+
+ /* Display the usage message if the argument is malformed */
+ if (++i >= argc) {
+ UseMsg();
+ return 0;
+ }
+
+ /* Grab the argument */
+ dwRefreshRate = atoi(argv[i]);
+
+ screenInfoPtr->dwRefreshRate = dwRefreshRate;
+
+ /* Indicate that we have processed the argument */
+ return 2;
}
- /*
- * Look for the '-clipupdates num_boxes' argument
- */
- if (IS_OPTION ("-clipupdates"))
- {
- DWORD dwNumBoxes = 0;
-
- /* Display the usage message if the argument is malformed */
- if (++i >= argc)
- {
- UseMsg ();
- return 0;
- }
-
- /* Grab the argument */
- dwNumBoxes = atoi (argv[i]);
-
- screenInfoPtr->dwClipUpdatesNBoxes = dwNumBoxes;
-
- /* Indicate that we have processed the argument */
- return 2;
+ /*
+ * Look for the '-clipupdates num_boxes' argument
+ */
+ if (IS_OPTION("-clipupdates")) {
+ DWORD dwNumBoxes = 0;
+
+ /* Display the usage message if the argument is malformed */
+ if (++i >= argc) {
+ UseMsg();
+ return 0;
+ }
+
+ /* Grab the argument */
+ dwNumBoxes = atoi(argv[i]);
+
+ screenInfoPtr->dwClipUpdatesNBoxes = dwNumBoxes;
+
+ /* Indicate that we have processed the argument */
+ return 2;
}
#ifdef XWIN_EMULATEPSEUDO
- /*
- * Look for the '-emulatepseudo' argument
- */
- if (IS_OPTION ("-emulatepseudo"))
- {
- screenInfoPtr->fEmulatePseudo = TRUE;
-
- /* Indicate that we have processed this argument */
- return 1;
+ /*
+ * Look for the '-emulatepseudo' argument
+ */
+ if (IS_OPTION("-emulatepseudo")) {
+ screenInfoPtr->fEmulatePseudo = TRUE;
+
+ /* Indicate that we have processed this argument */
+ return 1;
}
#endif
- /*
- * Look for the '-nowinkill' argument
- */
- if (IS_OPTION ("-nowinkill"))
- {
- screenInfoPtr->fUseWinKillKey = FALSE;
+ /*
+ * Look for the '-nowinkill' argument
+ */
+ if (IS_OPTION("-nowinkill")) {
+ screenInfoPtr->fUseWinKillKey = FALSE;
- /* Indicate that we have processed this argument */
- return 1;
+ /* Indicate that we have processed this argument */
+ return 1;
}
- /*
- * Look for the '-winkill' argument
- */
- if (IS_OPTION ("-winkill"))
- {
- screenInfoPtr->fUseWinKillKey = TRUE;
+ /*
+ * Look for the '-winkill' argument
+ */
+ if (IS_OPTION("-winkill")) {
+ screenInfoPtr->fUseWinKillKey = TRUE;
- /* Indicate that we have processed this argument */
- return 1;
+ /* Indicate that we have processed this argument */
+ return 1;
}
- /*
- * Look for the '-nounixkill' argument
- */
- if (IS_OPTION ("-nounixkill"))
- {
- screenInfoPtr->fUseUnixKillKey = FALSE;
+ /*
+ * Look for the '-nounixkill' argument
+ */
+ if (IS_OPTION("-nounixkill")) {
+ screenInfoPtr->fUseUnixKillKey = FALSE;
- /* Indicate that we have processed this argument */
- return 1;
+ /* Indicate that we have processed this argument */
+ return 1;
}
- /*
- * Look for the '-unixkill' argument
- */
- if (IS_OPTION ("-unixkill"))
- {
- screenInfoPtr->fUseUnixKillKey = TRUE;
+ /*
+ * Look for the '-unixkill' argument
+ */
+ if (IS_OPTION("-unixkill")) {
+ screenInfoPtr->fUseUnixKillKey = TRUE;
- /* Indicate that we have processed this argument */
- return 1;
+ /* Indicate that we have processed this argument */
+ return 1;
}
- /*
- * Look for the '-notrayicon' argument
- */
- if (IS_OPTION ("-notrayicon"))
- {
- screenInfoPtr->fNoTrayIcon = TRUE;
+ /*
+ * Look for the '-notrayicon' argument
+ */
+ if (IS_OPTION("-notrayicon")) {
+ screenInfoPtr->fNoTrayIcon = TRUE;
- /* Indicate that we have processed this argument */
- return 1;
+ /* Indicate that we have processed this argument */
+ return 1;
}
- /*
- * Look for the '-trayicon' argument
- */
- if (IS_OPTION ("-trayicon"))
- {
- screenInfoPtr->fNoTrayIcon = FALSE;
+ /*
+ * Look for the '-trayicon' argument
+ */
+ if (IS_OPTION("-trayicon")) {
+ screenInfoPtr->fNoTrayIcon = FALSE;
- /* Indicate that we have processed this argument */
- return 1;
+ /* Indicate that we have processed this argument */
+ return 1;
}
- /*
- * Look for the '-fp' argument
- */
- if (IS_OPTION ("-fp"))
- {
- CHECK_ARGS (1);
- g_cmdline.fontPath = argv[++i];
- return 0; /* Let DIX parse this again */
+ /*
+ * Look for the '-fp' argument
+ */
+ if (IS_OPTION("-fp")) {
+ CHECK_ARGS(1);
+ g_cmdline.fontPath = argv[++i];
+ return 0; /* Let DIX parse this again */
}
- /*
- * Look for the '-query' argument
- */
- if (IS_OPTION ("-query"))
- {
- CHECK_ARGS (1);
- g_fXdmcpEnabled = TRUE;
- g_pszQueryHost = argv[++i];
- return 0; /* Let DIX parse this again */
+ /*
+ * Look for the '-query' argument
+ */
+ if (IS_OPTION("-query")) {
+ CHECK_ARGS(1);
+ g_fXdmcpEnabled = TRUE;
+ g_pszQueryHost = argv[++i];
+ return 0; /* Let DIX parse this again */
}
- /*
- * Look for the '-auth' argument
- */
- if (IS_OPTION ("-auth"))
- {
- g_fAuthEnabled = TRUE;
- return 0; /* Let DIX parse this again */
+ /*
+ * Look for the '-auth' argument
+ */
+ if (IS_OPTION("-auth")) {
+ g_fAuthEnabled = TRUE;
+ return 0; /* Let DIX parse this again */
}
- /*
- * Look for the '-indirect' or '-broadcast' arguments
- */
- if (IS_OPTION ("-indirect")
- || IS_OPTION ("-broadcast"))
- {
- g_fXdmcpEnabled = TRUE;
- return 0; /* Let DIX parse this again */
+ /*
+ * Look for the '-indirect' or '-broadcast' arguments
+ */
+ if (IS_OPTION("-indirect")
+ || IS_OPTION("-broadcast")) {
+ g_fXdmcpEnabled = TRUE;
+ return 0; /* Let DIX parse this again */
}
- /*
- * Look for the '-config' argument
- */
- if (IS_OPTION ("-config")
- || IS_OPTION ("-xf86config"))
- {
- CHECK_ARGS (1);
+ /*
+ * Look for the '-config' argument
+ */
+ if (IS_OPTION("-config")
+ || IS_OPTION("-xf86config")) {
+ CHECK_ARGS(1);
#ifdef XWIN_XF86CONFIG
- g_cmdline.configFile = argv[++i];
+ g_cmdline.configFile = argv[++i];
#else
- winMessageBoxF ("The %s option is not supported in this "
- "release.\n"
- "Ignoring this option and continuing.\n",
- MB_ICONINFORMATION,
- argv[i]);
+ winMessageBoxF("The %s option is not supported in this "
+ "release.\n"
+ "Ignoring this option and continuing.\n",
+ MB_ICONINFORMATION, argv[i]);
#endif
- return 2;
+ return 2;
}
- /*
- * Look for the '-configdir' argument
- */
- if (IS_OPTION ("-configdir"))
- {
- CHECK_ARGS (1);
+ /*
+ * Look for the '-configdir' argument
+ */
+ if (IS_OPTION("-configdir")) {
+ CHECK_ARGS(1);
#ifdef XWIN_XF86CONFIG
- g_cmdline.configDir = argv[++i];
+ g_cmdline.configDir = argv[++i];
#else
- winMessageBoxF ("The %s option is not supported in this "
- "release.\n"
- "Ignoring this option and continuing.\n",
- MB_ICONINFORMATION,
- argv[i]);
+ winMessageBoxF("The %s option is not supported in this "
+ "release.\n"
+ "Ignoring this option and continuing.\n",
+ MB_ICONINFORMATION, argv[i]);
#endif
- return 2;
+ return 2;
}
- /*
- * Look for the '-keyboard' argument
- */
- if (IS_OPTION ("-keyboard"))
- {
+ /*
+ * Look for the '-keyboard' argument
+ */
+ if (IS_OPTION("-keyboard")) {
#ifdef XWIN_XF86CONFIG
- CHECK_ARGS (1);
- g_cmdline.keyboard = argv[++i];
+ CHECK_ARGS(1);
+ g_cmdline.keyboard = argv[++i];
#else
- winMessageBoxF ("The -keyboard option is not supported in this "
- "release.\n"
- "Ignoring this option and continuing.\n",
- MB_ICONINFORMATION);
+ winMessageBoxF("The -keyboard option is not supported in this "
+ "release.\n"
+ "Ignoring this option and continuing.\n",
+ MB_ICONINFORMATION);
#endif
- return 2;
+ return 2;
}
- /*
- * Look for the '-logfile' argument
- */
- if (IS_OPTION ("-logfile"))
- {
- CHECK_ARGS (1);
- g_pszLogFile = argv[++i];
+ /*
+ * Look for the '-logfile' argument
+ */
+ if (IS_OPTION("-logfile")) {
+ CHECK_ARGS(1);
+ g_pszLogFile = argv[++i];
#ifdef RELOCATE_PROJECTROOT
- g_fLogFileChanged = TRUE;
+ g_fLogFileChanged = TRUE;
#endif
- return 2;
+ return 2;
}
- /*
- * Look for the '-logverbose' argument
- */
- if (IS_OPTION ("-logverbose"))
- {
- CHECK_ARGS (1);
- g_iLogVerbose = atoi(argv[++i]);
- return 2;
+ /*
+ * Look for the '-logverbose' argument
+ */
+ if (IS_OPTION("-logverbose")) {
+ CHECK_ARGS(1);
+ g_iLogVerbose = atoi(argv[++i]);
+ return 2;
}
#ifdef XWIN_CLIPBOARD
- /*
- * Look for the '-nounicodeclipboard' argument
- */
- if (IS_OPTION ("-nounicodeclipboard"))
- {
- g_fUnicodeClipboard = FALSE;
- /* Indicate that we have processed the argument */
- return 1;
+ /*
+ * Look for the '-nounicodeclipboard' argument
+ */
+ if (IS_OPTION("-nounicodeclipboard")) {
+ g_fUnicodeClipboard = FALSE;
+ /* Indicate that we have processed the argument */
+ return 1;
}
#endif
- if (IS_OPTION ("-xkbrules"))
- {
- CHECK_ARGS (1);
- g_cmdline.xkbRules = argv[++i];
- return 2;
+ if (IS_OPTION("-xkbrules")) {
+ CHECK_ARGS(1);
+ g_cmdline.xkbRules = argv[++i];
+ return 2;
}
- if (IS_OPTION ("-xkbmodel"))
- {
- CHECK_ARGS (1);
- g_cmdline.xkbModel = argv[++i];
- return 2;
+ if (IS_OPTION("-xkbmodel")) {
+ CHECK_ARGS(1);
+ g_cmdline.xkbModel = argv[++i];
+ return 2;
}
- if (IS_OPTION ("-xkblayout"))
- {
- CHECK_ARGS (1);
- g_cmdline.xkbLayout = argv[++i];
- return 2;
+ if (IS_OPTION("-xkblayout")) {
+ CHECK_ARGS(1);
+ g_cmdline.xkbLayout = argv[++i];
+ return 2;
}
- if (IS_OPTION ("-xkbvariant"))
- {
- CHECK_ARGS (1);
- g_cmdline.xkbVariant = argv[++i];
- return 2;
+ if (IS_OPTION("-xkbvariant")) {
+ CHECK_ARGS(1);
+ g_cmdline.xkbVariant = argv[++i];
+ return 2;
}
- if (IS_OPTION ("-xkboptions"))
- {
- CHECK_ARGS (1);
- g_cmdline.xkbOptions = argv[++i];
- return 2;
+ if (IS_OPTION("-xkboptions")) {
+ CHECK_ARGS(1);
+ g_cmdline.xkbOptions = argv[++i];
+ return 2;
}
- if (IS_OPTION ("-keyhook"))
- {
- g_fKeyboardHookLL = TRUE;
- return 1;
+ if (IS_OPTION("-keyhook")) {
+ g_fKeyboardHookLL = TRUE;
+ return 1;
}
-
- if (IS_OPTION ("-nokeyhook"))
- {
- g_fKeyboardHookLL = FALSE;
- return 1;
+
+ if (IS_OPTION("-nokeyhook")) {
+ g_fKeyboardHookLL = FALSE;
+ return 1;
}
-
- if (IS_OPTION ("-swcursor"))
- {
- g_fSoftwareCursor = TRUE;
- return 1;
+
+ if (IS_OPTION("-swcursor")) {
+ g_fSoftwareCursor = TRUE;
+ return 1;
}
-
- if (IS_OPTION ("-silent-dup-error"))
- {
- g_fSilentDupError = TRUE;
- return 1;
+
+ if (IS_OPTION("-silent-dup-error")) {
+ g_fSilentDupError = TRUE;
+ return 1;
}
- if (IS_OPTION("-wgl"))
- {
- g_fNativeGl = TRUE;
- return 1;
+ if (IS_OPTION("-wgl")) {
+ g_fNativeGl = TRUE;
+ return 1;
}
- else if (IS_OPTION("-nowgl"))
- {
- g_fNativeGl = FALSE;
- return 1;
+
+ else if (IS_OPTION("-nowgl")) {
+ g_fNativeGl = FALSE;
+ return 1;
}
- else if (IS_OPTION("-swrastwgl"))
+ else if (IS_OPTION("-swrastwgl"))
{
- g_fswrastwgl = TRUE;
- return 1;
+ g_fswrastwgl = TRUE;
+ return 1;
}
- else if (IS_OPTION("-parentprocessid"))
+ else if (IS_OPTION("-parentprocessid"))
{
- DWORD dwProcessId;
- CHECK_ARGS (1);
- dwProcessId = atoi(argv[++i]);
- if (!AllowSetForegroundWindow(dwProcessId))
+ DWORD dwProcessId;
+ CHECK_ARGS (1);
+ dwProcessId = atoi(argv[++i]);
+ if (!AllowSetForegroundWindow(dwProcessId))
{
- winMessageBoxF ("Error calling AllowSetForegroundWindow.", MB_ICONINFORMATION);
- return 0;
- }
- return 2;
+ winMessageBoxF ("Error calling AllowSetForegroundWindow.", MB_ICONINFORMATION);
+ return 0;
+ }
+ return 2;
}
- return 0;
+ return 0;
}
-
/*
* winLogCommandLine - Write entire command line to the log file
*/
void
-winLogCommandLine (int argc, char *argv[])
+winLogCommandLine(int argc, char *argv[])
{
- int i;
- int iSize = 0;
- int iCurrLen = 0;
+ int i;
+ int iSize = 0;
+ int iCurrLen = 0;
#define CHARS_PER_LINE 60
- /* Bail if command line has already been logged */
- if (g_pszCommandLine)
- return;
-
- /* Count how much memory is needed for concatenated command line */
- for (i = 0, iCurrLen = 0; i < argc; ++i)
- if (argv[i])
- {
- /* Adds two characters for lines that overflow */
- if ((strlen (argv[i]) < CHARS_PER_LINE
- && iCurrLen + strlen (argv[i]) > CHARS_PER_LINE)
- || strlen (argv[i]) > CHARS_PER_LINE)
- {
- iCurrLen = 0;
- iSize += 2;
- }
-
- /* Add space for item and trailing space */
- iSize += strlen (argv[i]) + 1;
-
- /* Update current line length */
- iCurrLen += strlen (argv[i]);
- }
-
- /* Allocate memory for concatenated command line */
- g_pszCommandLine = malloc (iSize + 1);
- if (!g_pszCommandLine)
- FatalError ("winLogCommandLine - Could not allocate memory for "
- "command line string. Exiting.\n");
-
- /* Set first character to concatenated command line to null */
- g_pszCommandLine[0] = '\0';
-
- /* Loop through all args */
- for (i = 0, iCurrLen = 0; i < argc; ++i)
- {
- /* Add a character for lines that overflow */
- if ((strlen (argv[i]) < CHARS_PER_LINE
- && iCurrLen + strlen (argv[i]) > CHARS_PER_LINE)
- || strlen (argv[i]) > CHARS_PER_LINE)
- {
- iCurrLen = 0;
-
- /* Add line break if it fits */
- strncat (g_pszCommandLine, "\n ", iSize - strlen (g_pszCommandLine));
- }
-
- strncat (g_pszCommandLine, argv[i], iSize - strlen (g_pszCommandLine));
- strncat (g_pszCommandLine, " ", iSize - strlen (g_pszCommandLine));
-
- /* Save new line length */
- iCurrLen += strlen (argv[i]);
+ /* Bail if command line has already been logged */
+ if (g_pszCommandLine)
+ return;
+
+ /* Count how much memory is needed for concatenated command line */
+ for (i = 0, iCurrLen = 0; i < argc; ++i)
+ if (argv[i]) {
+ /* Adds two characters for lines that overflow */
+ if ((strlen(argv[i]) < CHARS_PER_LINE
+ && iCurrLen + strlen(argv[i]) > CHARS_PER_LINE)
+ || strlen(argv[i]) > CHARS_PER_LINE) {
+ iCurrLen = 0;
+ iSize += 2;
+ }
+
+ /* Add space for item and trailing space */
+ iSize += strlen(argv[i]) + 1;
+
+ /* Update current line length */
+ iCurrLen += strlen(argv[i]);
+ }
+
+ /* Allocate memory for concatenated command line */
+ g_pszCommandLine = malloc(iSize + 1);
+ if (!g_pszCommandLine)
+ FatalError("winLogCommandLine - Could not allocate memory for "
+ "command line string. Exiting.\n");
+
+ /* Set first character to concatenated command line to null */
+ g_pszCommandLine[0] = '\0';
+
+ /* Loop through all args */
+ for (i = 0, iCurrLen = 0; i < argc; ++i) {
+ /* Add a character for lines that overflow */
+ if ((strlen(argv[i]) < CHARS_PER_LINE
+ && iCurrLen + strlen(argv[i]) > CHARS_PER_LINE)
+ || strlen(argv[i]) > CHARS_PER_LINE) {
+ iCurrLen = 0;
+
+ /* Add line break if it fits */
+ strncat(g_pszCommandLine, "\n ", iSize - strlen(g_pszCommandLine));
+ }
+
+ strncat(g_pszCommandLine, argv[i], iSize - strlen(g_pszCommandLine));
+ strncat(g_pszCommandLine, " ", iSize - strlen(g_pszCommandLine));
+
+ /* Save new line length */
+ iCurrLen += strlen(argv[i]);
}
- winDebug ("XWin was started with the following command line:\n\n"
- "%s\n\n", g_pszCommandLine);
+ winDebug ("XWin was started with the following command line:\n\n"
+ "%s\n\n", g_pszCommandLine);
}
-
/*
* winLogVersionInfo - Log version information
*/
void
-winLogVersionInfo (void)
+winLogVersionInfo(void)
{
#ifdef WINDBG
- static Bool s_fBeenHere = FALSE;
-
- if (s_fBeenHere)
- return;
- s_fBeenHere = TRUE;
-
- winDebug ("Welcome to the VcXsrv X Server\n");
- winDebug ("Vendor: %s\n", XVENDORNAME);
- winDebug ("Release: %d.%d.%d.%d\n\n", XORG_VERSION_MAJOR, XORG_VERSION_MINOR, XORG_VERSION_PATCH, XORG_VERSION_SNAP);
- winDebug ("%s\n\n", BUILDERSTRING);
- winDebug ("Contact: %s\n\n", BUILDERADDR);
+ static Bool s_fBeenHere = FALSE;
+
+ if (s_fBeenHere)
+ return;
+ s_fBeenHere = TRUE;
+
+ winDebug ("Welcome to the VcXsrv X Server\n");
+ winDebug ("Vendor: %s\n", XVENDORNAME);
+ winDebug ("Release: %d.%d.%d.%d\n\n", XORG_VERSION_MAJOR,
+ XORG_VERSION_MINOR, XORG_VERSION_PATCH, XORG_VERSION_SNAP);
+ winDebug ("%s\n\n", BUILDERSTRING);
+ winDebug ("Contact: %s\n\n", BUILDERADDR);
#endif
}
diff --git a/xorg-server/hw/xwin/winrandr.c b/xorg-server/hw/xwin/winrandr.c
index 596c1ab9d..1b340850c 100644
--- a/xorg-server/hw/xwin/winrandr.c
+++ b/xorg-server/hw/xwin/winrandr.c
@@ -34,163 +34,159 @@
#include <xwin-config.h>
#endif
#include "win.h"
-#include "mivalidate.h" // for union _Validate used by windowstr.h
+#include "mivalidate.h" // for union _Validate used by windowstr.h
#ifndef RANDR_12_INTERFACE
#error X server must have RandR 1.2 interface
#endif
-
/*
* Answer queries about the RandR features supported.
*/
static Bool
-winRandRGetInfo (ScreenPtr pScreen, Rotation *pRotations)
+winRandRGetInfo(ScreenPtr pScreen, Rotation * pRotations)
{
- winDebug ("winRandRGetInfo ()\n");
+ winDebug("winRandRGetInfo ()\n");
- /* Don't support rotations */
- *pRotations = RR_Rotate_0;
+ /* Don't support rotations */
+ *pRotations = RR_Rotate_0;
- /*
- The screen doesn't have to be limited to the actual
- monitor size (we can have scrollbars :-), so what is
- the upper limit?
- */
- RRScreenSetSizeRange(pScreen, 0, 0, 4096, 4096);
+ /*
+ The screen doesn't have to be limited to the actual
+ monitor size (we can have scrollbars :-), so what is
+ the upper limit?
+ */
+ RRScreenSetSizeRange(pScreen, 0, 0, 4096, 4096);
- return TRUE;
+ return TRUE;
}
/*
*/
void
-winDoRandRScreenSetSize (ScreenPtr pScreen,
- CARD16 width,
- CARD16 height,
- CARD32 mmWidth,
- CARD32 mmHeight)
+winDoRandRScreenSetSize(ScreenPtr pScreen,
+ CARD16 width,
+ CARD16 height, CARD32 mmWidth, CARD32 mmHeight)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- WindowPtr pRoot = pScreen->root;
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ WindowPtr pRoot = pScreen->root;
- // Prevent screen updates while we change things around
- SetRootClip(pScreen, FALSE);
+ // Prevent screen updates while we change things around
+ SetRootClip(pScreen, FALSE);
- /* Update the screen size as requested */
- pScreenInfo->dwWidth = width;
- pScreenInfo->dwHeight = height;
+ /* Update the screen size as requested */
+ pScreenInfo->dwWidth = width;
+ pScreenInfo->dwHeight = height;
- /* Reallocate the framebuffer used by the drawing engine */
- (*pScreenPriv->pwinFreeFB)(pScreen);
- if (!(*pScreenPriv->pwinAllocateFB)(pScreen))
- {
- ErrorF ("winDoRandRScreenSetSize - Could not reallocate framebuffer\n");
+ /* Reallocate the framebuffer used by the drawing engine */
+ (*pScreenPriv->pwinFreeFB) (pScreen);
+ if (!(*pScreenPriv->pwinAllocateFB) (pScreen)) {
+ ErrorF("winDoRandRScreenSetSize - Could not reallocate framebuffer\n");
}
- pScreen->width = width;
- pScreen->height = height;
- pScreen->mmWidth = mmWidth;
- pScreen->mmHeight = mmHeight;
+ pScreen->width = width;
+ pScreen->height = height;
+ pScreen->mmWidth = mmWidth;
+ pScreen->mmHeight = mmHeight;
- /* Update the screen pixmap to point to the new framebuffer */
- winUpdateFBPointer(pScreen, pScreenInfo->pfb);
+ /* Update the screen pixmap to point to the new framebuffer */
+ winUpdateFBPointer(pScreen, pScreenInfo->pfb);
- // pScreen->devPrivate == pScreen->GetScreenPixmap(screen) ?
- // resize the root window
- //pScreen->ResizeWindow(pRoot, 0, 0, width, height, NULL);
- // does this emit a ConfigureNotify??
+ // pScreen->devPrivate == pScreen->GetScreenPixmap(screen) ?
+ // resize the root window
+ //pScreen->ResizeWindow(pRoot, 0, 0, width, height, NULL);
+ // does this emit a ConfigureNotify??
- // Restore the ability to update screen, now with new dimensions
- SetRootClip(pScreen, TRUE);
+ // Restore the ability to update screen, now with new dimensions
+ SetRootClip(pScreen, TRUE);
- // and arrange for it to be repainted
- miPaintWindow(pRoot, &pRoot->borderClip, PW_BACKGROUND);
+ // and arrange for it to be repainted
+ miPaintWindow(pRoot, &pRoot->borderClip, PW_BACKGROUND);
- /* Indicate that a screen size change took place */
- RRScreenSizeNotify(pScreen);
+ /* Indicate that a screen size change took place */
+ RRScreenSizeNotify(pScreen);
}
/*
* Respond to resize request
*/
static
-Bool
-winRandRScreenSetSize (ScreenPtr pScreen,
- CARD16 width,
- CARD16 height,
- CARD32 mmWidth,
- CARD32 mmHeight)
+ Bool
+winRandRScreenSetSize(ScreenPtr pScreen,
+ CARD16 width,
+ CARD16 height, CARD32 mmWidth, CARD32 mmHeight)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- winDebug ("winRandRScreenSetSize ()\n");
+ winDebug("winRandRScreenSetSize ()\n");
- /*
- It doesn't currently make sense to allow resize in fullscreen mode
- (we'd actually have to list the supported resolutions)
- */
- if (pScreenInfo->fFullScreen)
- {
- ErrorF ("winRandRScreenSetSize - resize not supported in fullscreen mode\n");
- return FALSE;
+ /*
+ It doesn't currently make sense to allow resize in fullscreen mode
+ (we'd actually have to list the supported resolutions)
+ */
+ if (pScreenInfo->fFullScreen) {
+ ErrorF
+ ("winRandRScreenSetSize - resize not supported in fullscreen mode\n");
+ return FALSE;
}
- /*
- Client resize requests aren't allowed in rootless modes, even if
- the X screen is monitor or virtual desktop size, we'd need to
- resize the native display size
- */
- if (FALSE
+ /*
+ Client resize requests aren't allowed in rootless modes, even if
+ the X screen is monitor or virtual desktop size, we'd need to
+ resize the native display size
+ */
+ if (FALSE
#ifdef XWIN_MULTIWINDOWEXTWM
- || pScreenInfo->fMWExtWM
+ || pScreenInfo->fMWExtWM
#endif
- || pScreenInfo->fRootless
+ || pScreenInfo->fRootless
#ifdef XWIN_MULTIWINDOW
- || pScreenInfo->fMultiWindow
+ || pScreenInfo->fMultiWindow
#endif
- )
- {
- ErrorF ("winRandRScreenSetSize - resize not supported in rootless modes\n");
- return FALSE;
+ ) {
+ ErrorF
+ ("winRandRScreenSetSize - resize not supported in rootless modes\n");
+ return FALSE;
}
- winDoRandRScreenSetSize(pScreen, width, height, mmWidth, mmHeight);
+ winDoRandRScreenSetSize(pScreen, width, height, mmWidth, mmHeight);
- /* Cause the native window for the screen to resize itself */
- {
- DWORD dwStyle, dwExStyle;
- RECT rcClient;
+ /* Cause the native window for the screen to resize itself */
+ {
+ DWORD dwStyle, dwExStyle;
+ RECT rcClient;
- rcClient.left = 0;
- rcClient.top = 0;
- rcClient.right = width;
- rcClient.bottom = height;
+ rcClient.left = 0;
+ rcClient.top = 0;
+ rcClient.right = width;
+ rcClient.bottom = height;
- ErrorF ("winRandRScreenSetSize new client area w: %d h: %d\n", width, height);
+ ErrorF("winRandRScreenSetSize new client area w: %d h: %d\n", width,
+ height);
- /* Get the Windows window style and extended style */
- dwExStyle = GetWindowLongPtr(pScreenPriv->hwndScreen, GWL_EXSTYLE);
- dwStyle = GetWindowLongPtr(pScreenPriv->hwndScreen, GWL_STYLE);
+ /* Get the Windows window style and extended style */
+ dwExStyle = GetWindowLongPtr(pScreenPriv->hwndScreen, GWL_EXSTYLE);
+ dwStyle = GetWindowLongPtr(pScreenPriv->hwndScreen, GWL_STYLE);
- /*
- * Calculate the window size needed for the given client area
- * adjusting for any decorations it will have
- */
- AdjustWindowRectEx(&rcClient, dwStyle, FALSE, dwExStyle);
+ /*
+ * Calculate the window size needed for the given client area
+ * adjusting for any decorations it will have
+ */
+ AdjustWindowRectEx(&rcClient, dwStyle, FALSE, dwExStyle);
- ErrorF ("winRandRScreenSetSize new window area w: %ld h: %ld\n", rcClient.right-rcClient.left, rcClient.bottom-rcClient.top);
+ ErrorF("winRandRScreenSetSize new window area w: %ld h: %ld\n",
+ rcClient.right - rcClient.left, rcClient.bottom - rcClient.top);
- SetWindowPos(pScreenPriv->hwndScreen, NULL,
- 0, 0, rcClient.right-rcClient.left, rcClient.bottom-rcClient.top,
- SWP_NOZORDER | SWP_NOMOVE);
- }
+ SetWindowPos(pScreenPriv->hwndScreen, NULL,
+ 0, 0, rcClient.right - rcClient.left,
+ rcClient.bottom - rcClient.top, SWP_NOZORDER | SWP_NOMOVE);
+ }
- return TRUE;
+ return TRUE;
}
/*
@@ -198,24 +194,24 @@ winRandRScreenSetSize (ScreenPtr pScreen,
*/
Bool
-winRandRInit (ScreenPtr pScreen)
+winRandRInit(ScreenPtr pScreen)
{
- rrScrPrivPtr pRRScrPriv;
- winDebug ("winRandRInit ()\n");
+ rrScrPrivPtr pRRScrPriv;
- if (!RRScreenInit (pScreen))
- {
- ErrorF ("winRandRInit () - RRScreenInit () failed\n");
- return FALSE;
+ winDebug("winRandRInit ()\n");
+
+ if (!RRScreenInit(pScreen)) {
+ ErrorF("winRandRInit () - RRScreenInit () failed\n");
+ return FALSE;
}
- /* Set some RandR function pointers */
- pRRScrPriv = rrGetScrPriv (pScreen);
- pRRScrPriv->rrGetInfo = winRandRGetInfo;
- pRRScrPriv->rrSetConfig = NULL;
- pRRScrPriv->rrScreenSetSize = winRandRScreenSetSize;
- pRRScrPriv->rrCrtcSet = NULL;
- pRRScrPriv->rrCrtcSetGamma = NULL;
+ /* Set some RandR function pointers */
+ pRRScrPriv = rrGetScrPriv(pScreen);
+ pRRScrPriv->rrGetInfo = winRandRGetInfo;
+ pRRScrPriv->rrSetConfig = NULL;
+ pRRScrPriv->rrScreenSetSize = winRandRScreenSetSize;
+ pRRScrPriv->rrCrtcSet = NULL;
+ pRRScrPriv->rrCrtcSetGamma = NULL;
- return TRUE;
+ return TRUE;
}
diff --git a/xorg-server/hw/xwin/winregistry.c b/xorg-server/hw/xwin/winregistry.c
index 898ed978b..0535c879d 100644
--- a/xorg-server/hw/xwin/winregistry.c
+++ b/xorg-server/hw/xwin/winregistry.c
@@ -34,38 +34,32 @@
#include "win.h"
/* Prototypes */
-DWORD
-winGetRegistryDWORD (HKEY hkey, char *pszRegistryKey);
+DWORD winGetRegistryDWORD(HKEY hkey, char *pszRegistryKey);
DWORD
-winGetRegistryDWORD (HKEY hkey, char *pszRegistryKey)
+winGetRegistryDWORD(HKEY hkey, char *pszRegistryKey)
{
- HKEY hkResult;
- DWORD dwDisposition;
+ HKEY hkResult;
+ DWORD dwDisposition;
- RegCreateKeyEx (hkey,
- pszRegistryKey,
- 0,
- '\0',
- REG_OPTION_NON_VOLATILE,
- KEY_READ,
- NULL,
- &hkResult,
- &dwDisposition);
+ RegCreateKeyEx(hkey,
+ pszRegistryKey,
+ 0,
+ '\0',
+ REG_OPTION_NON_VOLATILE,
+ KEY_READ, NULL, &hkResult, &dwDisposition);
- if (dwDisposition == REG_CREATED_NEW_KEY)
- {
- winDebug ("winGetRegistryDWORD - Created new key: %s\n", pszRegistryKey);
+ if (dwDisposition == REG_CREATED_NEW_KEY) {
+ winDebug ("winGetRegistryDWORD - Created new key: %s\n", pszRegistryKey);
}
- else if (dwDisposition == REG_OPENED_EXISTING_KEY)
- {
- winDebug ("winGetRegistryDWORD - Opened existing key: %s\n",
- pszRegistryKey);
+ else if (dwDisposition == REG_OPENED_EXISTING_KEY) {
+ winDebug ("winGetRegistryDWORD - Opened existing key: %s\n",
+ pszRegistryKey);
}
- /* Free the registry key handle */
- RegCloseKey (hkResult);
- hkResult = NULL;
+ /* Free the registry key handle */
+ RegCloseKey(hkResult);
+ hkResult = NULL;
- return 0;
+ return 0;
}
diff --git a/xorg-server/hw/xwin/winrop.c b/xorg-server/hw/xwin/winrop.c
index f4818920a..1f9ff7320 100644
--- a/xorg-server/hw/xwin/winrop.c
+++ b/xorg-server/hw/xwin/winrop.c
@@ -37,108 +37,106 @@
#include "win.h"
void
-ROP16 (HDC hdc, int rop);
-
-int g_copyROP[16] = { 0xFF0062, /* GXclear - 0 */
- 0x8800C6, /* GXand - S & D */
- 0x440328, /* GXandReverse - S & !D */
- 0xCC0020, /* GXcopy - S */
- 0x220326, /* GXandInverted - !S & D */
- 0xAA0029, /* GXnoop - D */
- 0x660046, /* GXxor - S ^ D */
- 0xEE0086, /* GXor - S | D */
- 0x1100A6, /* GXnor - !S & !D */
- 0x990126, /* GXequiv - !S ^ D */
- 0x550009, /* GXinvert - !D */
- 0xDD0228, /* GXorReverse - S | !D */
- 0x330008, /* GXcopyInverted - !S */
- 0xBB0226, /* GXorInverted - !S | D */
- 0x7700C6, /* GXnand - !S | !D */
- 0x000042 /* GXset - 1 */
+ ROP16(HDC hdc, int rop);
+
+int g_copyROP[16] = { 0xFF0062, /* GXclear - 0 */
+ 0x8800C6, /* GXand - S & D */
+ 0x440328, /* GXandReverse - S & !D */
+ 0xCC0020, /* GXcopy - S */
+ 0x220326, /* GXandInverted - !S & D */
+ 0xAA0029, /* GXnoop - D */
+ 0x660046, /* GXxor - S ^ D */
+ 0xEE0086, /* GXor - S | D */
+ 0x1100A6, /* GXnor - !S & !D */
+ 0x990126, /* GXequiv - !S ^ D */
+ 0x550009, /* GXinvert - !D */
+ 0xDD0228, /* GXorReverse - S | !D */
+ 0x330008, /* GXcopyInverted - !S */
+ 0xBB0226, /* GXorInverted - !S | D */
+ 0x7700C6, /* GXnand - !S | !D */
+ 0x000042 /* GXset - 1 */
};
-int g_patternROP[16] = {0xFF0062, /* GXclear - 0 */
- 0xA000C9, /* GXand - P & D */
- 0xF50225, /* GXandReverse - P & !D */
- 0xF00021, /* GXcopy - P */
- 0x5F00E9, /* GXandInverted - !P & D */
- 0xAA0029, /* GXnoop - D */
- 0xA50065, /* GXxor - P ^ D */
- 0xA000C9, /* GXor - P | D */
- 0x5F00E9, /* GXnor - !P & !D */
- 0x5A0049, /* GXequiv - !P ^ D */
- 0x550009, /* GXinvert - !D */
- 0x500325, /* GXorReverse - P | !D */
- 0x0F0001, /* GXcopyInverted - !P */
- 0x0A0329, /* GXorInverted - !P | D */
- 0x0500A9, /* GXnand - !P | !D */
- 0x000042 /* GXset - 1 */
+int g_patternROP[16] = { 0xFF0062, /* GXclear - 0 */
+ 0xA000C9, /* GXand - P & D */
+ 0xF50225, /* GXandReverse - P & !D */
+ 0xF00021, /* GXcopy - P */
+ 0x5F00E9, /* GXandInverted - !P & D */
+ 0xAA0029, /* GXnoop - D */
+ 0xA50065, /* GXxor - P ^ D */
+ 0xA000C9, /* GXor - P | D */
+ 0x5F00E9, /* GXnor - !P & !D */
+ 0x5A0049, /* GXequiv - !P ^ D */
+ 0x550009, /* GXinvert - !D */
+ 0x500325, /* GXorReverse - P | !D */
+ 0x0F0001, /* GXcopyInverted - !P */
+ 0x0A0329, /* GXorInverted - !P | D */
+ 0x0500A9, /* GXnand - !P | !D */
+ 0x000042 /* GXset - 1 */
};
-
void
-ROP16 (HDC hdc, int rop)
+ROP16(HDC hdc, int rop)
{
- switch (rop)
- {
+ switch (rop) {
case GXclear:
- SetROP2 (hdc, R2_BLACK);
- break;
+ SetROP2(hdc, R2_BLACK);
+ break;
case GXand:
- SetROP2 (hdc, R2_MASKPEN);
- break;
+ SetROP2(hdc, R2_MASKPEN);
+ break;
case GXandReverse:
- SetROP2 (hdc, R2_MASKPENNOT);
- break;
+ SetROP2(hdc, R2_MASKPENNOT);
+ break;
case GXcopy:
- SetROP2 (hdc, R2_COPYPEN);
- break;
+ SetROP2(hdc, R2_COPYPEN);
+ break;
case GXnoop:
- SetROP2 (hdc, R2_NOP);
- break;
+ SetROP2(hdc, R2_NOP);
+ break;
case GXxor:
- SetROP2 (hdc, R2_XORPEN);
- break;
+ SetROP2(hdc, R2_XORPEN);
+ break;
case GXor:
- SetROP2 (hdc, R2_MERGEPEN);
- break;
+ SetROP2(hdc, R2_MERGEPEN);
+ break;
case GXnor:
- SetROP2 (hdc, R2_NOTMERGEPEN);
- break;
+ SetROP2(hdc, R2_NOTMERGEPEN);
+ break;
case GXequiv:
- SetROP2 (hdc, R2_NOTXORPEN);
- break;
+ SetROP2(hdc, R2_NOTXORPEN);
+ break;
case GXinvert:
- SetROP2 (hdc, R2_NOT);
- break;
+ SetROP2(hdc, R2_NOT);
+ break;
case GXorReverse:
- SetROP2 (hdc, R2_MERGEPENNOT);
- break;
+ SetROP2(hdc, R2_MERGEPENNOT);
+ break;
case GXcopyInverted:
- SetROP2 (hdc, R2_NOTCOPYPEN);
- break;
+ SetROP2(hdc, R2_NOTCOPYPEN);
+ break;
case GXorInverted:
- SetROP2 (hdc, R2_MERGENOTPEN);
- break;
+ SetROP2(hdc, R2_MERGENOTPEN);
+ break;
case GXnand:
- SetROP2 (hdc, R2_NOTMASKPEN);
- break;
+ SetROP2(hdc, R2_NOTMASKPEN);
+ break;
case GXset:
- SetROP2 (hdc, R2_WHITE);
- break;
+ SetROP2(hdc, R2_WHITE);
+ break;
}
}
diff --git a/xorg-server/hw/xwin/winscrinit.c b/xorg-server/hw/xwin/winscrinit.c
index 3cf74cdcc..2b699a84e 100644
--- a/xorg-server/hw/xwin/winscrinit.c
+++ b/xorg-server/hw/xwin/winscrinit.c
@@ -38,30 +38,28 @@
#include "win.h"
#include "winmsg.h"
-
#ifdef XWIN_MULTIWINDOWEXTWM
-static RootlessFrameProcsRec
-winMWExtWMProcs = {
- winMWExtWMCreateFrame,
- winMWExtWMDestroyFrame,
-
- winMWExtWMMoveFrame,
- winMWExtWMResizeFrame,
- winMWExtWMRestackFrame,
- winMWExtWMReshapeFrame,
- winMWExtWMUnmapFrame,
-
- winMWExtWMStartDrawing,
- winMWExtWMStopDrawing,
- winMWExtWMUpdateRegion,
- winMWExtWMDamageRects,
- winMWExtWMRootlessSwitchWindow,
- NULL,//winMWExtWMDoReorderWindow,
- NULL,//winMWExtWMHideWindow,
- NULL,//winMWExtWMUpdateColorMap,
-
- NULL,//winMWExtWMCopyBytes,
- winMWExtWMCopyWindow
+static RootlessFrameProcsRec winMWExtWMProcs = {
+ winMWExtWMCreateFrame,
+ winMWExtWMDestroyFrame,
+
+ winMWExtWMMoveFrame,
+ winMWExtWMResizeFrame,
+ winMWExtWMRestackFrame,
+ winMWExtWMReshapeFrame,
+ winMWExtWMUnmapFrame,
+
+ winMWExtWMStartDrawing,
+ winMWExtWMStopDrawing,
+ winMWExtWMUpdateRegion,
+ winMWExtWMDamageRects,
+ winMWExtWMRootlessSwitchWindow,
+ NULL, //winMWExtWMDoReorderWindow,
+ NULL, //winMWExtWMHideWindow,
+ NULL, //winMWExtWMUpdateColorMap,
+
+ NULL, //winMWExtWMCopyBytes,
+ winMWExtWMCopyWindow
};
#endif
@@ -74,8 +72,7 @@ winMWExtWMProcs = {
*/
static Bool
-winSaveScreen (ScreenPtr pScreen, int on);
-
+ winSaveScreen(ScreenPtr pScreen, int on);
/*
* Determine what type of screen we are initializing
@@ -84,376 +81,346 @@ winSaveScreen (ScreenPtr pScreen, int on);
*/
Bool
-winScreenInit (int index,
- ScreenPtr pScreen,
- int argc, char **argv)
+winScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
{
- winScreenInfoPtr pScreenInfo = &g_ScreenInfo[index];
- winPrivScreenPtr pScreenPriv;
- HDC hdc;
- DWORD dwInitialBPP;
+ winScreenInfoPtr pScreenInfo = &g_ScreenInfo[index];
+ winPrivScreenPtr pScreenPriv;
+ HDC hdc;
+ DWORD dwInitialBPP;
- winDebug ("winScreenInit - dwWidth: %ld dwHeight: %ld\n",
- pScreenInfo->dwWidth, pScreenInfo->dwHeight);
+ winDebug("winScreenInit - dwWidth: %ld dwHeight: %ld\n",
+ pScreenInfo->dwWidth, pScreenInfo->dwHeight);
- /* Allocate privates for this screen */
- if (!winAllocatePrivates (pScreen))
- {
- ErrorF ("winScreenInit - Couldn't allocate screen privates\n");
- return FALSE;
+ /* Allocate privates for this screen */
+ if (!winAllocatePrivates(pScreen)) {
+ ErrorF("winScreenInit - Couldn't allocate screen privates\n");
+ return FALSE;
}
- /* Get a pointer to the privates structure that was allocated */
- pScreenPriv = winGetScreenPriv (pScreen);
+ /* Get a pointer to the privates structure that was allocated */
+ pScreenPriv = winGetScreenPriv(pScreen);
- /* Save a pointer to this screen in the screen info structure */
- pScreenInfo->pScreen = pScreen;
+ /* Save a pointer to this screen in the screen info structure */
+ pScreenInfo->pScreen = pScreen;
- /* Save a pointer to the screen info in the screen privates structure */
- /* This allows us to get back to the screen info from a screen pointer */
- pScreenPriv->pScreenInfo = pScreenInfo;
+ /* Save a pointer to the screen info in the screen privates structure */
+ /* This allows us to get back to the screen info from a screen pointer */
+ pScreenPriv->pScreenInfo = pScreenInfo;
- /*
- * Determine which engine to use.
- *
- * NOTE: This is done once per screen because each screen possibly has
- * a preferred engine specified on the command line.
- */
- if (!winSetEngine (pScreen))
- {
- ErrorF ("winScreenInit - winSetEngine () failed\n");
- return FALSE;
+ /*
+ * Determine which engine to use.
+ *
+ * NOTE: This is done once per screen because each screen possibly has
+ * a preferred engine specified on the command line.
+ */
+ if (!winSetEngine(pScreen)) {
+ ErrorF("winScreenInit - winSetEngine () failed\n");
+ return FALSE;
}
- /* Horribly misnamed function: Allow engine to adjust BPP for screen */
- dwInitialBPP = pScreenInfo->dwBPP;
+ /* Horribly misnamed function: Allow engine to adjust BPP for screen */
+ dwInitialBPP = pScreenInfo->dwBPP;
- if (pScreenPriv->pwinAdjustVideoMode && !(*pScreenPriv->pwinAdjustVideoMode) (pScreen))
- {
- ErrorF ("winScreenInit - winAdjustVideoMode () failed\n");
- return FALSE;
- }
-
- if (dwInitialBPP == WIN_DEFAULT_BPP)
- {
- /* No -depth parameter was passed, let the user know the depth being used */
- winDebug ("winScreenInit - Using Windows display depth of %d bits per pixel\n", (int) pScreenInfo->dwBPP);
- }
- else if (dwInitialBPP != pScreenInfo->dwBPP)
- {
- /* Warn user if engine forced a depth different to -depth parameter */
- winDebug ("winScreenInit - Command line depth of %d bpp overidden by engine, using %d bpp\n", (int) dwInitialBPP, (int) pScreenInfo->dwBPP);
- }
- else
- {
- winDebug ("winScreenInit - Using command line depth of %d bpp\n", (int) pScreenInfo->dwBPP);
- }
-
- /* Check for supported display depth */
- if (!(WIN_SUPPORTED_BPPS & (1 << (pScreenInfo->dwBPP - 1))))
- {
- ErrorF ("winScreenInit - Unsupported display depth: %d\n" \
- "Change your Windows display depth to 15, 16, 24, or 32 bits "
- "per pixel.\n",
- (int) pScreenInfo->dwBPP);
- ErrorF ("winScreenInit - Supported depths: %08x\n",
- WIN_SUPPORTED_BPPS);
+ if (pScreenPriv->pwinAdjustVideoMode && !(*pScreenPriv->pwinAdjustVideoMode) (pScreen)) {
+ ErrorF("winScreenInit - winAdjustVideoMode () failed\n");
+ return FALSE;
+ }
+
+ if (dwInitialBPP == WIN_DEFAULT_BPP) {
+ /* No -depth parameter was passed, let the user know the depth being used */
+ winDebug
+ ("winScreenInit - Using Windows display depth of %d bits per pixel\n",
+ (int) pScreenInfo->dwBPP);
+ }
+ else if (dwInitialBPP != pScreenInfo->dwBPP) {
+ /* Warn user if engine forced a depth different to -depth parameter */
+ winDebug
+ ("winScreenInit - Command line depth of %d bpp overidden by engine, using %d bpp\n",
+ (int) dwInitialBPP, (int) pScreenInfo->dwBPP);
+ }
+ else {
+ winDebug("winScreenInit - Using command line depth of %d bpp\n",
+ (int) pScreenInfo->dwBPP);
+ }
+
+ /* Check for supported display depth */
+ if (!(WIN_SUPPORTED_BPPS & (1 << (pScreenInfo->dwBPP - 1)))) {
+ ErrorF("winScreenInit - Unsupported display depth: %d\n"
+ "Change your Windows display depth to 15, 16, 24, or 32 bits "
+ "per pixel.\n", (int) pScreenInfo->dwBPP);
+ ErrorF("winScreenInit - Supported depths: %08x\n", WIN_SUPPORTED_BPPS);
#if WIN_CHECK_DEPTH
- return FALSE;
+ return FALSE;
#endif
}
- /*
- * Check that all monitors have the same display depth if we are using
- * multiple monitors
- */
- if (pScreenInfo->fMultipleMonitors
- && !GetSystemMetrics (SM_SAMEDISPLAYFORMAT))
- {
- ErrorF ("winScreenInit - Monitors do not all have same pixel format / "
- "display depth.\n");
- if (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_GDI)
- {
- ErrorF ("winScreenInit - Performance may suffer off primary display.\n");
+ /*
+ * Check that all monitors have the same display depth if we are using
+ * multiple monitors
+ */
+ if (pScreenInfo->fMultipleMonitors
+ && !GetSystemMetrics(SM_SAMEDISPLAYFORMAT)) {
+ ErrorF("winScreenInit - Monitors do not all have same pixel format / "
+ "display depth.\n");
+ if (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_GDI) {
+ ErrorF
+ ("winScreenInit - Performance may suffer off primary display.\n");
}
- else
- {
- ErrorF ("winScreenInit - Using primary display only.\n");
- pScreenInfo->fMultipleMonitors = FALSE;
+ else {
+ ErrorF("winScreenInit - Using primary display only.\n");
+ pScreenInfo->fMultipleMonitors = FALSE;
}
}
- /* Create display window */
- if (pScreenPriv->pwinCreateBoundingWindow && !(*pScreenPriv->pwinCreateBoundingWindow) (pScreen))
- {
- ErrorF ("winScreenInit - pwinCreateBoundingWindow () "
- "failed\n");
- return FALSE;
+ /* Create display window */
+ if (pScreenPriv->pwinCreateBoundingWindow && !(*pScreenPriv->pwinCreateBoundingWindow) (pScreen)) {
+ ErrorF("winScreenInit - pwinCreateBoundingWindow () " "failed\n");
+ return FALSE;
}
- /* Get a device context */
- hdc = GetDC (pScreenPriv->hwndScreen);
+ /* Get a device context */
+ hdc = GetDC(pScreenPriv->hwndScreen);
- /* Are we using multiple monitors? */
- if (pScreenInfo->fMultipleMonitors)
- {
- /*
- * In this case, some of the defaults set in
- * winInitializeScreenDefaults() are not correct ...
- */
- if (!pScreenInfo->fUserGaveHeightAndWidth)
- {
- pScreenInfo->dwWidth = GetSystemMetrics (SM_CXVIRTUALSCREEN);
- pScreenInfo->dwHeight = GetSystemMetrics (SM_CYVIRTUALSCREEN);
- }
+ /* Are we using multiple monitors? */
+ if (pScreenInfo->fMultipleMonitors) {
+ /*
+ * In this case, some of the defaults set in
+ * winInitializeScreenDefaults() are not correct ...
+ */
+ if (!pScreenInfo->fUserGaveHeightAndWidth) {
+ pScreenInfo->dwWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN);
+ pScreenInfo->dwHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN);
+ }
}
- /* Release the device context */
- ReleaseDC (pScreenPriv->hwndScreen, hdc);
-
- /* Clear the visuals list */
- miClearVisualTypes ();
+ /* Release the device context */
+ ReleaseDC(pScreenPriv->hwndScreen, hdc);
+
+ /* Clear the visuals list */
+ miClearVisualTypes();
- /* Call the engine dependent screen initialization procedure */
- if (pScreenPriv->pwinFinishScreenInit && !((*pScreenPriv->pwinFinishScreenInit) (index, pScreen, argc, argv)))
- {
- ErrorF ("winScreenInit - winFinishScreenInit () failed\n");
+ /* Call the engine dependent screen initialization procedure */
+ if (pScreenPriv->pwinFinishScreenInit && !((*pScreenPriv->pwinFinishScreenInit) (index, pScreen, argc, argv))) {
+ ErrorF("winScreenInit - winFinishScreenInit () failed\n");
- /* call the engine dependent screen close procedure to clean up from a failure */
- pScreenPriv->pwinCloseScreen(index, pScreen);
+ /* call the engine dependent screen close procedure to clean up from a failure */
+ pScreenPriv->pwinCloseScreen(index, pScreen);
- return FALSE;
+ return FALSE;
}
- if (!g_fSoftwareCursor)
- winInitCursor(pScreen);
+ if (!g_fSoftwareCursor)
+ winInitCursor(pScreen);
#ifdef WINDBG
- else
- winDebug("winScreenInit - Using software cursor\n");
+ else
+ winDebug("winScreenInit - Using software cursor\n");
#endif
- /*
- Note the screen origin in a normalized coordinate space where (0,0) is at the top left
- of the native virtual desktop area
- */
- pScreen->x = pScreenInfo->dwInitialX - GetSystemMetrics(SM_XVIRTUALSCREEN);
- pScreen->y = pScreenInfo->dwInitialY - GetSystemMetrics(SM_YVIRTUALSCREEN);
+ /*
+ Note the screen origin in a normalized coordinate space where (0,0) is at the top left
+ of the native virtual desktop area
+ */
+ pScreen->x = pScreenInfo->dwInitialX - GetSystemMetrics(SM_XVIRTUALSCREEN);
+ pScreen->y = pScreenInfo->dwInitialY - GetSystemMetrics(SM_YVIRTUALSCREEN);
- winDebug("Screen %d added at virtual desktop coordinate (%d,%d).\n",
- index, pScreen->x, pScreen->y);
- winDebug ("winScreenInit - returning\n");
+ winDebug("Screen %d added at virtual desktop coordinate (%d,%d).\n",
+ index, pScreen->x, pScreen->y);
+ winDebug("winScreenInit - returning\n");
- return TRUE;
+ return TRUE;
}
static Bool
winCreateScreenResources(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- Bool result;
+ winScreenPriv(pScreen);
+ Bool result;
- result = pScreenPriv->pwinCreateScreenResources(pScreen);
+ result = pScreenPriv->pwinCreateScreenResources(pScreen);
- /* Now the screen bitmap has been wrapped in a pixmap,
- add that to the Shadow framebuffer */
- if (!shadowAdd(pScreen, pScreen->devPrivate,
- pScreenPriv->pwinShadowUpdate, NULL, 0, 0))
- {
- ErrorF ("winCreateScreenResources - shadowAdd () failed\n");
- return FALSE;
+ /* Now the screen bitmap has been wrapped in a pixmap,
+ add that to the Shadow framebuffer */
+ if (!shadowAdd(pScreen, pScreen->devPrivate,
+ pScreenPriv->pwinShadowUpdate, NULL, 0, 0)) {
+ ErrorF("winCreateScreenResources - shadowAdd () failed\n");
+ return FALSE;
}
- return result;
+ return result;
}
/* See Porting Layer Definition - p. 20 */
Bool
-winFinishScreenInitFB (int index,
- ScreenPtr pScreen,
- int argc, char **argv)
+winFinishScreenInitFB(int index, ScreenPtr pScreen, int argc, char **argv)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- VisualPtr pVisual = NULL;
- char *pbits = NULL;
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ VisualPtr pVisual = NULL;
+ char *pbits = NULL;
+
#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
- int iReturn;
+ int iReturn;
#endif
- /* Create framebuffer */
- if (!(*pScreenPriv->pwinInitScreen) (pScreen))
- {
- ErrorF ("winFinishScreenInitFB - Could not allocate framebuffer\n");
- return FALSE;
- }
-
- /*
- * Calculate the number of bits that are used to represent color in each pixel,
- * the color depth for the screen
- */
- if (pScreenInfo->dwBPP == 8)
- pScreenInfo->dwDepth = 8;
- else
- pScreenInfo->dwDepth = winCountBits (pScreenPriv->dwRedMask)
- + winCountBits (pScreenPriv->dwGreenMask)
- + winCountBits (pScreenPriv->dwBlueMask);
-
- winDebug ("winFinishScreenInitFB - Masks: %08x %08x %08x\n",
- (unsigned int) pScreenPriv->dwRedMask,
- (unsigned int) pScreenPriv->dwGreenMask,
- (unsigned int) pScreenPriv->dwBlueMask);
-
- /* Init visuals */
- if (!(*pScreenPriv->pwinInitVisuals) (pScreen))
- {
- ErrorF ("winFinishScreenInitFB - winInitVisuals failed\n");
- return FALSE;
- }
-
- /* Setup a local variable to point to the framebuffer */
- pbits = pScreenInfo->pfb;
-
- /* Apparently we need this for the render extension */
- miSetPixmapDepths ();
-
- /* Start fb initialization */
- if (!fbSetupScreen (pScreen,
- pScreenInfo->pfb,
- pScreenInfo->dwWidth, pScreenInfo->dwHeight,
- monitorResolution, monitorResolution,
- pScreenInfo->dwStride,
- pScreenInfo->dwBPP))
- {
- ErrorF ("winFinishScreenInitFB - fbSetupScreen failed\n");
- return FALSE;
- }
-
- /* Override default colormap routines if visual class is dynamic */
- if (pScreenInfo->dwDepth == 8
- && (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_GDI
- || (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL
- && pScreenInfo->fFullScreen)
- || (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DD
- && pScreenInfo->fFullScreen)))
- {
- winSetColormapFunctions (pScreen);
-
- /*
- * NOTE: Setting whitePixel to 255 causes Magic 7.1 to allocate its
- * own colormap, as it cannot allocate 7 planes in the default
- * colormap. Setting whitePixel to 1 allows Magic to get 7
- * planes in the default colormap, so it doesn't create its
- * own colormap. This latter situation is highly desireable,
- * as it keeps the Magic window viewable when switching to
- * other X clients that use the default colormap.
- */
- pScreen->blackPixel = 0;
- pScreen->whitePixel = 1;
- }
-
- /* Place our save screen function */
- pScreen->SaveScreen = winSaveScreen;
-
- /* Finish fb initialization */
- if (!fbFinishScreenInit (pScreen,
- pScreenInfo->pfb,
- pScreenInfo->dwWidth, pScreenInfo->dwHeight,
- monitorResolution, monitorResolution,
- pScreenInfo->dwStride,
- pScreenInfo->dwBPP))
- {
- ErrorF ("winFinishScreenInitFB - fbFinishScreenInit failed\n");
- return FALSE;
- }
-
- /* Save a pointer to the root visual */
- for (pVisual = pScreen->visuals;
- pVisual->vid != pScreen->rootVisual;
- pVisual++);
- pScreenPriv->pRootVisual = pVisual;
-
- /*
- * Setup points to the block and wakeup handlers. Pass a pointer
- * to the current screen as pWakeupdata.
- */
- pScreen->BlockHandler = winBlockHandler;
- pScreen->WakeupHandler = winWakeupHandler;
- pScreen->blockData = pScreen;
- pScreen->wakeupData = pScreen;
-
- /* Render extension initialization, calls miPictureInit */
- if (!fbPictureInit (pScreen, NULL, 0))
- {
- ErrorF ("winFinishScreenInitFB - fbPictureInit () failed\n");
- return FALSE;
+ /* Create framebuffer */
+ if (!(*pScreenPriv->pwinInitScreen) (pScreen)) {
+ ErrorF("winFinishScreenInitFB - Could not allocate framebuffer\n");
+ return FALSE;
+ }
+
+ /*
+ * Calculate the number of bits that are used to represent color in each pixel,
+ * the color depth for the screen
+ */
+ if (pScreenInfo->dwBPP == 8)
+ pScreenInfo->dwDepth = 8;
+ else
+ pScreenInfo->dwDepth = winCountBits(pScreenPriv->dwRedMask)
+ + winCountBits(pScreenPriv->dwGreenMask)
+ + winCountBits(pScreenPriv->dwBlueMask);
+
+ winDebug ("winFinishScreenInitFB - Masks: %08x %08x %08x\n",
+ (unsigned int) pScreenPriv->dwRedMask,
+ (unsigned int) pScreenPriv->dwGreenMask,
+ (unsigned int) pScreenPriv->dwBlueMask);
+
+ /* Init visuals */
+ if (!(*pScreenPriv->pwinInitVisuals) (pScreen)) {
+ ErrorF("winFinishScreenInitFB - winInitVisuals failed\n");
+ return FALSE;
+ }
+
+ /* Setup a local variable to point to the framebuffer */
+ pbits = pScreenInfo->pfb;
+
+ /* Apparently we need this for the render extension */
+ miSetPixmapDepths();
+
+ /* Start fb initialization */
+ if (!fbSetupScreen(pScreen,
+ pScreenInfo->pfb,
+ pScreenInfo->dwWidth, pScreenInfo->dwHeight,
+ monitorResolution, monitorResolution,
+ pScreenInfo->dwStride, pScreenInfo->dwBPP)) {
+ ErrorF("winFinishScreenInitFB - fbSetupScreen failed\n");
+ return FALSE;
+ }
+
+ /* Override default colormap routines if visual class is dynamic */
+ if (pScreenInfo->dwDepth == 8
+ && (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_GDI
+ || (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL
+ && pScreenInfo->fFullScreen)
+ || (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DD
+ && pScreenInfo->fFullScreen))) {
+ winSetColormapFunctions(pScreen);
+
+ /*
+ * NOTE: Setting whitePixel to 255 causes Magic 7.1 to allocate its
+ * own colormap, as it cannot allocate 7 planes in the default
+ * colormap. Setting whitePixel to 1 allows Magic to get 7
+ * planes in the default colormap, so it doesn't create its
+ * own colormap. This latter situation is highly desireable,
+ * as it keeps the Magic window viewable when switching to
+ * other X clients that use the default colormap.
+ */
+ pScreen->blackPixel = 0;
+ pScreen->whitePixel = 1;
+ }
+
+ /* Place our save screen function */
+ pScreen->SaveScreen = winSaveScreen;
+
+ /* Finish fb initialization */
+ if (!fbFinishScreenInit(pScreen,
+ pScreenInfo->pfb,
+ pScreenInfo->dwWidth, pScreenInfo->dwHeight,
+ monitorResolution, monitorResolution,
+ pScreenInfo->dwStride, pScreenInfo->dwBPP)) {
+ ErrorF("winFinishScreenInitFB - fbFinishScreenInit failed\n");
+ return FALSE;
+ }
+
+ /* Save a pointer to the root visual */
+ for (pVisual = pScreen->visuals;
+ pVisual->vid != pScreen->rootVisual; pVisual++);
+ pScreenPriv->pRootVisual = pVisual;
+
+ /*
+ * Setup points to the block and wakeup handlers. Pass a pointer
+ * to the current screen as pWakeupdata.
+ */
+ pScreen->BlockHandler = winBlockHandler;
+ pScreen->WakeupHandler = winWakeupHandler;
+ pScreen->blockData = pScreen;
+ pScreen->wakeupData = pScreen;
+
+ /* Render extension initialization, calls miPictureInit */
+ if (!fbPictureInit(pScreen, NULL, 0)) {
+ ErrorF("winFinishScreenInitFB - fbPictureInit () failed\n");
+ return FALSE;
}
#ifdef RANDR
- /* Initialize resize and rotate support */
- if (!winRandRInit (pScreen))
- {
- ErrorF ("winFinishScreenInitFB - winRandRInit () failed\n");
- return FALSE;
+ /* Initialize resize and rotate support */
+ if (!winRandRInit(pScreen)) {
+ ErrorF("winFinishScreenInitFB - winRandRInit () failed\n");
+ return FALSE;
}
#endif
- /* Setup the cursor routines */
- winDebug ("winFinishScreenInitFB - Calling miDCInitialize ()\n");
- miDCInitialize (pScreen, &g_winPointerCursorFuncs);
+ /* Setup the cursor routines */
+ winDebug("winFinishScreenInitFB - Calling miDCInitialize ()\n");
+ miDCInitialize(pScreen, &g_winPointerCursorFuncs);
- /* KDrive does winCreateDefColormap right after miDCInitialize */
- /* Create a default colormap */
- winDebug ("winFinishScreenInitFB - Calling winCreateDefColormap ()\n");
- if (!winCreateDefColormap (pScreen))
- {
- ErrorF ("winFinishScreenInitFB - Could not create colormap\n");
- return FALSE;
+ /* KDrive does winCreateDefColormap right after miDCInitialize */
+ /* Create a default colormap */
+ winDebug("winFinishScreenInitFB - Calling winCreateDefColormap ()\n");
+ if (!winCreateDefColormap(pScreen)) {
+ ErrorF("winFinishScreenInitFB - Could not create colormap\n");
+ return FALSE;
}
- /* Initialize the shadow framebuffer layer */
- if ((pScreenInfo->dwEngine == WIN_SERVER_SHADOW_GDI
- || pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DD
- || pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL)
+ /* Initialize the shadow framebuffer layer */
+ if ((pScreenInfo->dwEngine == WIN_SERVER_SHADOW_GDI
+ || pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DD
+ || pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL)
#ifdef XWIN_MULTIWINDOWEXTWM
- && !pScreenInfo->fMWExtWM
+ && !pScreenInfo->fMWExtWM
#endif
- )
- {
- winDebug ("winFinishScreenInitFB - Calling shadowSetup ()\n");
- if (!shadowSetup(pScreen))
- {
- ErrorF ("winFinishScreenInitFB - shadowSetup () failed\n");
- return FALSE;
- }
+ ) {
+ winDebug("winFinishScreenInitFB - Calling shadowSetup ()\n");
+ if (!shadowSetup(pScreen)) {
+ ErrorF("winFinishScreenInitFB - shadowSetup () failed\n");
+ return FALSE;
+ }
- /* Wrap CreateScreenResources so we can add the screen pixmap
- to the Shadow framebuffer after it's been created */
- pScreenPriv->pwinCreateScreenResources = pScreen->CreateScreenResources;
- pScreen->CreateScreenResources = winCreateScreenResources;
+ /* Wrap CreateScreenResources so we can add the screen pixmap
+ to the Shadow framebuffer after it's been created */
+ pScreenPriv->pwinCreateScreenResources = pScreen->CreateScreenResources;
+ pScreen->CreateScreenResources = winCreateScreenResources;
}
#ifdef XWIN_MULTIWINDOWEXTWM
- /* Handle multi-window external window manager mode */
- if (pScreenInfo->fMWExtWM)
- {
- winDebug ("winScreenInit - MultiWindowExtWM - Calling RootlessInit\n");
-
- RootlessInit(pScreen, &winMWExtWMProcs);
-
- winDebug ("winScreenInit - MultiWindowExtWM - RootlessInit returned\n");
-
- rootless_CopyBytes_threshold = 0;
- /* FIXME: How many? Profiling needed? */
- rootless_CopyWindow_threshold = 1;
-
- winWindowsWMExtensionInit ();
+ /* Handle multi-window external window manager mode */
+ if (pScreenInfo->fMWExtWM) {
+ winDebug("winScreenInit - MultiWindowExtWM - Calling RootlessInit\n");
+
+ RootlessInit(pScreen, &winMWExtWMProcs);
+
+ winDebug("winScreenInit - MultiWindowExtWM - RootlessInit returned\n");
+
+ rootless_CopyBytes_threshold = 0;
+ /* FIXME: How many? Profiling needed? */
+ rootless_CopyWindow_threshold = 1;
+
+ winWindowsWMExtensionInit();
}
#endif
- /* Handle rootless mode */
- if (pScreenInfo->fRootless)
- {
- /* Define the WRAP macro temporarily for local use */
+ /* Handle rootless mode */
+ if (pScreenInfo->fRootless) {
+ /* Define the WRAP macro temporarily for local use */
#define WRAP(a) \
if (pScreen->a) { \
pScreenPriv->a = pScreen->a; \
@@ -462,34 +429,32 @@ winFinishScreenInitFB (int index,
pScreenPriv->a = NULL; \
}
- /* Save a pointer to each lower-level window procedure */
- WRAP(CreateWindow);
- WRAP(DestroyWindow);
- WRAP(RealizeWindow);
- WRAP(UnrealizeWindow);
- WRAP(PositionWindow);
- WRAP(ChangeWindowAttributes);
- WRAP(SetShape);
-
- /* Assign rootless window procedures to be top level procedures */
- pScreen->CreateWindow = winCreateWindowRootless;
- pScreen->DestroyWindow = winDestroyWindowRootless;
- pScreen->PositionWindow = winPositionWindowRootless;
- /*pScreen->ChangeWindowAttributes = winChangeWindowAttributesRootless;*/
- pScreen->RealizeWindow = winMapWindowRootless;
- pScreen->UnrealizeWindow = winUnmapWindowRootless;
- pScreen->SetShape = winSetShapeRootless;
-
- /* Undefine the WRAP macro, as it is not needed elsewhere */
+ /* Save a pointer to each lower-level window procedure */
+ WRAP(CreateWindow);
+ WRAP(DestroyWindow);
+ WRAP(RealizeWindow);
+ WRAP(UnrealizeWindow);
+ WRAP(PositionWindow);
+ WRAP(ChangeWindowAttributes);
+ WRAP(SetShape);
+
+ /* Assign rootless window procedures to be top level procedures */
+ pScreen->CreateWindow = winCreateWindowRootless;
+ pScreen->DestroyWindow = winDestroyWindowRootless;
+ pScreen->PositionWindow = winPositionWindowRootless;
+ /*pScreen->ChangeWindowAttributes = winChangeWindowAttributesRootless; */
+ pScreen->RealizeWindow = winMapWindowRootless;
+ pScreen->UnrealizeWindow = winUnmapWindowRootless;
+ pScreen->SetShape = winSetShapeRootless;
+
+ /* Undefine the WRAP macro, as it is not needed elsewhere */
#undef WRAP
}
-
#ifdef XWIN_MULTIWINDOW
- /* Handle multi window mode */
- else if (pScreenInfo->fMultiWindow)
- {
- /* Define the WRAP macro temporarily for local use */
+ /* Handle multi window mode */
+ else if (pScreenInfo->fMultiWindow) {
+ /* Define the WRAP macro temporarily for local use */
#define WRAP(a) \
if (pScreen->a) { \
pScreenPriv->a = pScreen->a; \
@@ -498,263 +463,250 @@ winFinishScreenInitFB (int index,
pScreenPriv->a = NULL; \
}
- /* Save a pointer to each lower-level window procedure */
- WRAP(CreateWindow);
- WRAP(DestroyWindow);
- WRAP(RealizeWindow);
- WRAP(UnrealizeWindow);
- WRAP(PositionWindow);
- WRAP(ChangeWindowAttributes);
- WRAP(ReparentWindow);
- WRAP(RestackWindow);
- WRAP(ResizeWindow);
- WRAP(MoveWindow);
- WRAP(CopyWindow);
- WRAP(SetShape);
-
- /* Assign multi-window window procedures to be top level procedures */
- pScreen->CreateWindow = winCreateWindowMultiWindow;
- pScreen->DestroyWindow = winDestroyWindowMultiWindow;
- pScreen->PositionWindow = winPositionWindowMultiWindow;
- /*pScreen->ChangeWindowAttributes = winChangeWindowAttributesMultiWindow;*/
- pScreen->RealizeWindow = winMapWindowMultiWindow;
- pScreen->UnrealizeWindow = winUnmapWindowMultiWindow;
- pScreen->ReparentWindow = winReparentWindowMultiWindow;
- pScreen->RestackWindow = winRestackWindowMultiWindow;
- pScreen->ResizeWindow = winResizeWindowMultiWindow;
- pScreen->MoveWindow = winMoveWindowMultiWindow;
- pScreen->CopyWindow = winCopyWindowMultiWindow;
- pScreen->SetShape = winSetShapeMultiWindow;
-
- /* Undefine the WRAP macro, as it is not needed elsewhere */
+ /* Save a pointer to each lower-level window procedure */
+ WRAP(CreateWindow);
+ WRAP(DestroyWindow);
+ WRAP(RealizeWindow);
+ WRAP(UnrealizeWindow);
+ WRAP(PositionWindow);
+ WRAP(ChangeWindowAttributes);
+ WRAP(ReparentWindow);
+ WRAP(RestackWindow);
+ WRAP(ResizeWindow);
+ WRAP(MoveWindow);
+ WRAP(CopyWindow);
+ WRAP(SetShape);
+
+ /* Assign multi-window window procedures to be top level procedures */
+ pScreen->CreateWindow = winCreateWindowMultiWindow;
+ pScreen->DestroyWindow = winDestroyWindowMultiWindow;
+ pScreen->PositionWindow = winPositionWindowMultiWindow;
+ /*pScreen->ChangeWindowAttributes = winChangeWindowAttributesMultiWindow; */
+ pScreen->RealizeWindow = winMapWindowMultiWindow;
+ pScreen->UnrealizeWindow = winUnmapWindowMultiWindow;
+ pScreen->ReparentWindow = winReparentWindowMultiWindow;
+ pScreen->RestackWindow = winRestackWindowMultiWindow;
+ pScreen->ResizeWindow = winResizeWindowMultiWindow;
+ pScreen->MoveWindow = winMoveWindowMultiWindow;
+ pScreen->CopyWindow = winCopyWindowMultiWindow;
+ pScreen->SetShape = winSetShapeMultiWindow;
+
+ /* Undefine the WRAP macro, as it is not needed elsewhere */
#undef WRAP
}
#endif
- /* Wrap either fb's or shadow's CloseScreen with our CloseScreen */
- pScreenPriv->CloseScreen = pScreen->CloseScreen;
- pScreen->CloseScreen = pScreenPriv->pwinCloseScreen;
+ /* Wrap either fb's or shadow's CloseScreen with our CloseScreen */
+ pScreenPriv->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = pScreenPriv->pwinCloseScreen;
#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
- /* Create a mutex for modules in separate threads to wait for */
- iReturn = pthread_mutex_init (&pScreenPriv->pmServerStarted, NULL);
- if (iReturn != 0)
- {
- ErrorF ("winFinishScreenInitFB - pthread_mutex_init () failed: %d\n",
- iReturn);
- return FALSE;
- }
-
- /* Own the mutex for modules in separate threads */
- iReturn = pthread_mutex_lock (&pScreenPriv->pmServerStarted);
- if (iReturn != 0)
- {
- ErrorF ("winFinishScreenInitFB - pthread_mutex_lock () failed: %d\n",
- iReturn);
- return FALSE;
- }
-
- /* Set the ServerStarted flag to false */
- pScreenPriv->fServerStarted = FALSE;
+ /* Create a mutex for modules in separate threads to wait for */
+ iReturn = pthread_mutex_init(&pScreenPriv->pmServerStarted, NULL);
+ if (iReturn != 0) {
+ ErrorF("winFinishScreenInitFB - pthread_mutex_init () failed: %d\n",
+ iReturn);
+ return FALSE;
+ }
+
+ /* Own the mutex for modules in separate threads */
+ iReturn = pthread_mutex_lock(&pScreenPriv->pmServerStarted);
+ if (iReturn != 0) {
+ ErrorF("winFinishScreenInitFB - pthread_mutex_lock () failed: %d\n",
+ iReturn);
+ return FALSE;
+ }
+
+ /* Set the ServerStarted flag to false */
+ pScreenPriv->fServerStarted = FALSE;
#endif
#ifdef XWIN_MULTIWINDOWEXTWM
- pScreenPriv->fRestacking = FALSE;
+ pScreenPriv->fRestacking = FALSE;
#endif
#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
- if (FALSE
+ if (FALSE
#ifdef XWIN_MULTIWINDOW
- || pScreenInfo->fMultiWindow
+ || pScreenInfo->fMultiWindow
#endif
#ifdef XWIN_MULTIWINDOWINTWM
- || pScreenInfo->fInternalWM
+ || pScreenInfo->fInternalWM
#endif
- )
- {
- winDebug ("winFinishScreenInitFB - Calling winInitWM.\n");
-
- /* Initialize multi window mode */
- if (!winInitWM (&pScreenPriv->pWMInfo,
- &pScreenPriv->ptWMProc,
- &pScreenPriv->ptXMsgProc,
- &pScreenPriv->pmServerStarted,
- pScreenInfo->dwScreen,
- (HWND)&pScreenPriv->hwndScreen,
+ ) {
+ winDebug("winFinishScreenInitFB - Calling winInitWM.\n");
+
+ /* Initialize multi window mode */
+ if (!winInitWM(&pScreenPriv->pWMInfo,
+ &pScreenPriv->ptWMProc,
+ &pScreenPriv->ptXMsgProc,
+ &pScreenPriv->pmServerStarted,
+ pScreenInfo->dwScreen, (HWND) & pScreenPriv->hwndScreen,
#ifdef XWIN_MULTIWINDOWINTWM
- pScreenInfo->fInternalWM ||
+ pScreenInfo->fInternalWM ||
#endif
- FALSE))
- {
- ErrorF ("winFinishScreenInitFB - winInitWM () failed.\n");
- return FALSE;
+ FALSE)) {
+ ErrorF("winFinishScreenInitFB - winInitWM () failed.\n");
+ return FALSE;
}
- }
+ }
#endif
- /* Tell the server that we are enabled */
- pScreenPriv->fEnabled = TRUE;
+ /* Tell the server that we are enabled */
+ pScreenPriv->fEnabled = TRUE;
- /* Tell the server that we have a valid depth */
- pScreenPriv->fBadDepth = FALSE;
+ /* Tell the server that we have a valid depth */
+ pScreenPriv->fBadDepth = FALSE;
- winDebug ("winFinishScreenInitFB - returning\n");
+ winDebug("winFinishScreenInitFB - returning\n");
- return TRUE;
+ return TRUE;
}
#ifdef XWIN_NATIVEGDI
/* See Porting Layer Definition - p. 20 */
Bool
-winFinishScreenInitNativeGDI (int index,
- ScreenPtr pScreen,
- int argc, char **argv)
+winFinishScreenInitNativeGDI(int index,
+ ScreenPtr pScreen, int argc, char **argv)
{
- winScreenPriv(pScreen);
- winScreenInfoPtr pScreenInfo = &g_ScreenInfo[index];
- VisualPtr pVisuals = NULL;
- DepthPtr pDepths = NULL;
- VisualID rootVisual = 0;
- int nVisuals = 0, nDepths = 0, nRootDepth = 0;
-
- /* Ignore user input (mouse, keyboard) */
- pScreenInfo->fIgnoreInput = FALSE;
-
- /* Get device contexts for the screen and shadow bitmap */
- pScreenPriv->hdcScreen = GetDC (pScreenPriv->hwndScreen);
- if (pScreenPriv->hdcScreen == NULL)
- FatalError ("winFinishScreenInitNativeGDI - Couldn't get a DC\n");
-
- /* Init visuals */
- if (!(*pScreenPriv->pwinInitVisuals) (pScreen))
- {
- ErrorF ("winFinishScreenInitNativeGDI - pwinInitVisuals failed\n");
- return FALSE;
- }
-
- /* Initialize the mi visuals */
- if (!miInitVisuals (&pVisuals, &pDepths, &nVisuals, &nDepths, &nRootDepth,
- &rootVisual,
- ((unsigned long)1 << (pScreenInfo->dwDepth - 1)), 8,
- TrueColor))
- {
- ErrorF ("winFinishScreenInitNativeGDI - miInitVisuals () failed\n");
- return FALSE;
- }
-
- /* Initialize the CloseScreen procedure pointer */
- pScreen->CloseScreen = NULL;
-
- /* Initialize the mi code */
- if (!miScreenInit (pScreen,
- NULL, /* No framebuffer */
- pScreenInfo->dwWidth, pScreenInfo->dwHeight,
- monitorResolution, monitorResolution,
- pScreenInfo->dwStride,
- nRootDepth, nDepths, pDepths, rootVisual,
- nVisuals, pVisuals))
- {
- ErrorF ("winFinishScreenInitNativeGDI - miScreenInit failed\n");
- return FALSE;
- }
-
- pScreen->defColormap = FakeClientID(0);
-
- /*
- * Register our block and wakeup handlers; these procedures
- * process messages in our Windows message queue; specifically,
- * they process mouse and keyboard input.
- */
- pScreen->BlockHandler = winBlockHandler;
- pScreen->WakeupHandler = winWakeupHandler;
- pScreen->blockData = pScreen;
- pScreen->wakeupData = pScreen;
-
- /* Place our save screen function */
- pScreen->SaveScreen = winSaveScreen;
-
- /* Pixmaps */
- pScreen->CreatePixmap = winCreatePixmapNativeGDI;
- pScreen->DestroyPixmap = winDestroyPixmapNativeGDI;
-
- /* Other Screen Routines */
- pScreen->QueryBestSize = winQueryBestSizeNativeGDI;
- pScreen->SaveScreen = winSaveScreen;
- pScreen->GetImage = miGetImage;
- pScreen->GetSpans = winGetSpansNativeGDI;
-
- /* Window Procedures */
- pScreen->CreateWindow = winCreateWindowNativeGDI;
- pScreen->DestroyWindow = winDestroyWindowNativeGDI;
- pScreen->PositionWindow = winPositionWindowNativeGDI;
- /*pScreen->ChangeWindowAttributes = winChangeWindowAttributesNativeGDI;*/
- pScreen->RealizeWindow = winMapWindowNativeGDI;
- pScreen->UnrealizeWindow = winUnmapWindowNativeGDI;
-
- /* Paint window */
- pScreen->CopyWindow = winCopyWindowNativeGDI;
-
- /* Fonts */
- pScreen->RealizeFont = winRealizeFontNativeGDI;
- pScreen->UnrealizeFont = winUnrealizeFontNativeGDI;
-
- /* GC */
- pScreen->CreateGC = winCreateGCNativeGDI;
-
- /* Colormap Routines */
- pScreen->CreateColormap = miInitializeColormap;
- pScreen->DestroyColormap = (DestroyColormapProcPtr) (void (*)(void)) NoopDDA;
- pScreen->InstallColormap = miInstallColormap;
- pScreen->UninstallColormap = miUninstallColormap;
- pScreen->ListInstalledColormaps = miListInstalledColormaps;
- pScreen->StoreColors = (StoreColorsProcPtr) (void (*)(void)) NoopDDA;
- pScreen->ResolveColor = miResolveColor;
-
- /* Bitmap */
- pScreen->BitmapToRegion = winPixmapToRegionNativeGDI;
-
- winDebug ("winFinishScreenInitNativeGDI - calling miDCInitialize\n");
-
- /* Set the default white and black pixel positions */
- pScreen->whitePixel = pScreen->blackPixel = (Pixel) 0;
-
- /* Initialize the cursor */
- if (!miDCInitialize (pScreen, &g_winPointerCursorFuncs))
- {
- ErrorF ("winFinishScreenInitNativeGDI - miDCInitialize failed\n");
- return FALSE;
+ winScreenPriv(pScreen);
+ winScreenInfoPtr pScreenInfo = &g_ScreenInfo[index];
+ VisualPtr pVisuals = NULL;
+ DepthPtr pDepths = NULL;
+ VisualID rootVisual = 0;
+ int nVisuals = 0, nDepths = 0, nRootDepth = 0;
+
+ /* Ignore user input (mouse, keyboard) */
+ pScreenInfo->fIgnoreInput = FALSE;
+
+ /* Get device contexts for the screen and shadow bitmap */
+ pScreenPriv->hdcScreen = GetDC(pScreenPriv->hwndScreen);
+ if (pScreenPriv->hdcScreen == NULL)
+ FatalError("winFinishScreenInitNativeGDI - Couldn't get a DC\n");
+
+ /* Init visuals */
+ if (!(*pScreenPriv->pwinInitVisuals) (pScreen)) {
+ ErrorF("winFinishScreenInitNativeGDI - pwinInitVisuals failed\n");
+ return FALSE;
+ }
+
+ /* Initialize the mi visuals */
+ if (!miInitVisuals(&pVisuals, &pDepths, &nVisuals, &nDepths, &nRootDepth,
+ &rootVisual,
+ ((unsigned long) 1 << (pScreenInfo->dwDepth - 1)), 8,
+ TrueColor)) {
+ ErrorF("winFinishScreenInitNativeGDI - miInitVisuals () failed\n");
+ return FALSE;
+ }
+
+ /* Initialize the CloseScreen procedure pointer */
+ pScreen->CloseScreen = NULL;
+
+ /* Initialize the mi code */
+ if (!miScreenInit(pScreen, NULL, /* No framebuffer */
+ pScreenInfo->dwWidth, pScreenInfo->dwHeight,
+ monitorResolution, monitorResolution,
+ pScreenInfo->dwStride,
+ nRootDepth, nDepths, pDepths, rootVisual,
+ nVisuals, pVisuals)) {
+ ErrorF("winFinishScreenInitNativeGDI - miScreenInit failed\n");
+ return FALSE;
+ }
+
+ pScreen->defColormap = FakeClientID(0);
+
+ /*
+ * Register our block and wakeup handlers; these procedures
+ * process messages in our Windows message queue; specifically,
+ * they process mouse and keyboard input.
+ */
+ pScreen->BlockHandler = winBlockHandler;
+ pScreen->WakeupHandler = winWakeupHandler;
+ pScreen->blockData = pScreen;
+ pScreen->wakeupData = pScreen;
+
+ /* Place our save screen function */
+ pScreen->SaveScreen = winSaveScreen;
+
+ /* Pixmaps */
+ pScreen->CreatePixmap = winCreatePixmapNativeGDI;
+ pScreen->DestroyPixmap = winDestroyPixmapNativeGDI;
+
+ /* Other Screen Routines */
+ pScreen->QueryBestSize = winQueryBestSizeNativeGDI;
+ pScreen->SaveScreen = winSaveScreen;
+ pScreen->GetImage = miGetImage;
+ pScreen->GetSpans = winGetSpansNativeGDI;
+
+ /* Window Procedures */
+ pScreen->CreateWindow = winCreateWindowNativeGDI;
+ pScreen->DestroyWindow = winDestroyWindowNativeGDI;
+ pScreen->PositionWindow = winPositionWindowNativeGDI;
+ /*pScreen->ChangeWindowAttributes = winChangeWindowAttributesNativeGDI; */
+ pScreen->RealizeWindow = winMapWindowNativeGDI;
+ pScreen->UnrealizeWindow = winUnmapWindowNativeGDI;
+
+ /* Paint window */
+ pScreen->CopyWindow = winCopyWindowNativeGDI;
+
+ /* Fonts */
+ pScreen->RealizeFont = winRealizeFontNativeGDI;
+ pScreen->UnrealizeFont = winUnrealizeFontNativeGDI;
+
+ /* GC */
+ pScreen->CreateGC = winCreateGCNativeGDI;
+
+ /* Colormap Routines */
+ pScreen->CreateColormap = miInitializeColormap;
+ pScreen->DestroyColormap =
+ (DestroyColormapProcPtr) (void (*)(void)) NoopDDA;
+ pScreen->InstallColormap = miInstallColormap;
+ pScreen->UninstallColormap = miUninstallColormap;
+ pScreen->ListInstalledColormaps = miListInstalledColormaps;
+ pScreen->StoreColors = (StoreColorsProcPtr) (void (*)(void)) NoopDDA;
+ pScreen->ResolveColor = miResolveColor;
+
+ /* Bitmap */
+ pScreen->BitmapToRegion = winPixmapToRegionNativeGDI;
+
+ winDebug ("winFinishScreenInitNativeGDI - calling miDCInitialize\n");
+
+ /* Set the default white and black pixel positions */
+ pScreen->whitePixel = pScreen->blackPixel = (Pixel) 0;
+
+ /* Initialize the cursor */
+ if (!miDCInitialize(pScreen, &g_winPointerCursorFuncs)) {
+ ErrorF("winFinishScreenInitNativeGDI - miDCInitialize failed\n");
+ return FALSE;
}
-
- /* Create a default colormap */
- if (!miCreateDefColormap (pScreen))
- {
- ErrorF ("winFinishScreenInitNativeGDI - miCreateDefColormap () "
- "failed\n");
- return FALSE;
+
+ /* Create a default colormap */
+ if (!miCreateDefColormap(pScreen)) {
+ ErrorF("winFinishScreenInitNativeGDI - miCreateDefColormap () "
+ "failed\n");
+ return FALSE;
}
- winDebug ("winFinishScreenInitNativeGDI - miCreateDefColormap () "
- "returned\n");
-
- /* mi doesn't use a CloseScreen procedure, so no need to wrap */
- pScreen->CloseScreen = pScreenPriv->pwinCloseScreen;
+ winDebug ("winFinishScreenInitNativeGDI - miCreateDefColormap () "
+ "returned\n");
- /* Tell the server that we are enabled */
- pScreenPriv->fEnabled = TRUE;
+ /* mi doesn't use a CloseScreen procedure, so no need to wrap */
+ pScreen->CloseScreen = pScreenPriv->pwinCloseScreen;
+
+ /* Tell the server that we are enabled */
+ pScreenPriv->fEnabled = TRUE;
- winDebug ("winFinishScreenInitNativeGDI - Successful addition of "
- "screen %08x\n",
- (unsigned int) pScreen);
+ winDebug ("winFinishScreenInitNativeGDI - Successful addition of "
+ "screen %08x\n", (unsigned int) pScreen);
- return TRUE;
+ return TRUE;
}
#endif
-
/* See Porting Layer Definition - p. 33 */
static Bool
-winSaveScreen (ScreenPtr pScreen, int on)
+winSaveScreen(ScreenPtr pScreen, int on)
{
- return TRUE;
+ return TRUE;
}
diff --git a/xorg-server/hw/xwin/winsetsp.c b/xorg-server/hw/xwin/winsetsp.c
index 6150a9182..fb9105132 100644
--- a/xorg-server/hw/xwin/winsetsp.c
+++ b/xorg-server/hw/xwin/winsetsp.c
@@ -1,183 +1,174 @@
-/*
- *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, sublicense, and/or sell copies of the Software, and to
- *permit persons to whom the Software is furnished to do so, subject to
- *the following conditions:
- *
- *The above copyright notice and this permission notice shall be
- *included in all copies or substantial portions of the Software.
- *
- *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
- *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *Except as contained in this notice, the name of the XFree86 Project
- *shall not be used in advertising or otherwise to promote the sale, use
- *or other dealings in this Software without prior written authorization
- *from the XFree86 Project.
- *
- * Authors: Harold L Hunt II
- * Alan Hourihane <alanh@fairlite.demon.co.uk>
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-
-typedef struct mybitmap
-{
- BITMAPINFOHEADER bmiHeader;
- RGBQUAD bmiColors[256]; /* Maximum palette used in case of 8-bit per pixel */
-} mybitmap_t;
-
-/* See Porting Layer Definition - p. 55 */
-void
-winSetSpansNativeGDI (DrawablePtr pDrawable,
- GCPtr pGC,
- char *pSrcs,
- DDXPointPtr pPoints,
- int *piWidths,
- int iSpans,
- int fSorted)
-{
- winGCPriv(pGC);
- PixmapPtr pPixmap = NULL;
- winPrivPixmapPtr pPixmapPriv = NULL;
- HBITMAP hbmpOrig = NULL;
- mybitmap_t bmi;
- HRGN hrgn = NULL, combined = NULL;
- int nbox;
- BoxPtr pbox;
-
- nbox = RegionNumRects (pGC->pCompositeClip);
- pbox = RegionRects (pGC->pCompositeClip);
-
- if (!nbox) return;
-
- combined = CreateRectRgn (pbox->x1, pbox->y1, pbox->x2, pbox->y2);
- nbox--; pbox++;
- while (nbox--)
- {
- hrgn = CreateRectRgn (pbox->x1, pbox->y1, pbox->x2, pbox->y2);
- CombineRgn (combined, combined, hrgn, RGN_OR);
- DeleteObject (hrgn);
- hrgn = NULL;
- pbox++;
- }
-
- /* Branch on the drawable type */
- switch (pDrawable->type)
- {
- case DRAWABLE_PIXMAP:
-
- SelectClipRgn (pGCPriv->hdcMem, combined);
- DeleteObject (combined);
- combined = NULL;
-
- pPixmap = (PixmapPtr) pDrawable;
- pPixmapPriv = winGetPixmapPriv (pPixmap);
-
- /* Select the drawable pixmap into a DC */
- hbmpOrig = SelectObject (pGCPriv->hdcMem, pPixmapPriv->hBitmap);
- if (hbmpOrig == NULL)
- FatalError ("winSetSpans - DRAWABLE_PIXMAP - SelectObject () "
- "failed on pPixmapPriv->hBitmap\n");
-
- while (iSpans--)
- {
- ZeroMemory (&bmi, sizeof (mybitmap_t));
- bmi.bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
- bmi.bmiHeader.biWidth = *piWidths;
- bmi.bmiHeader.biHeight = 1;
- bmi.bmiHeader.biPlanes = 1;
- bmi.bmiHeader.biBitCount = pDrawable->depth;
- bmi.bmiHeader.biCompression = BI_RGB;
-
- /* Setup color table for mono DIBs */
- if (pDrawable->depth == 1)
- {
- bmi.bmiColors[1].rgbBlue = 255;
- bmi.bmiColors[1].rgbGreen = 255;
- bmi.bmiColors[1].rgbRed = 255;
- }
-
- StretchDIBits (pGCPriv->hdcMem,
- pPoints->x, pPoints->y,
- *piWidths, 1,
- 0, 0,
- *piWidths, 1,
- pSrcs,
- (BITMAPINFO*)&bmi,
- DIB_RGB_COLORS,
- g_copyROP[pGC->alu]);
-
- pSrcs += PixmapBytePad (*piWidths, pDrawable->depth);
- pPoints++;
- piWidths++;
- }
-
- /* Reset the clip region */
- SelectClipRgn (pGCPriv->hdcMem, NULL);
-
- /* Push the drawable pixmap out of the GC HDC */
- SelectObject (pGCPriv->hdcMem, hbmpOrig);
- break;
-
- case DRAWABLE_WINDOW:
-
- SelectClipRgn (pGCPriv->hdc, combined);
- DeleteObject (combined);
- combined = NULL;
-
- while (iSpans--)
- {
- ZeroMemory (&bmi, sizeof (mybitmap_t));
- bmi.bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
- bmi.bmiHeader.biWidth = *piWidths;
- bmi.bmiHeader.biHeight = 1;
- bmi.bmiHeader.biPlanes = 1;
- bmi.bmiHeader.biBitCount = pDrawable->depth;
- bmi.bmiHeader.biCompression = BI_RGB;
-
- /* Setup color table for mono DIBs */
- if (pDrawable->depth == 1)
- {
- bmi.bmiColors[1].rgbBlue = 255;
- bmi.bmiColors[1].rgbGreen = 255;
- bmi.bmiColors[1].rgbRed = 255;
- }
-
- StretchDIBits (pGCPriv->hdc,
- pPoints->x, pPoints->y,
- *piWidths, 1,
- 0, 0,
- *piWidths, 1,
- pSrcs,
- (BITMAPINFO *) &bmi,
- DIB_RGB_COLORS,
- g_copyROP[pGC->alu]);
-
- pSrcs += PixmapBytePad (*piWidths, pDrawable->depth);
- pPoints++;
- piWidths++;
- }
-
- /* Reset the clip region */
- SelectClipRgn (pGCPriv->hdc, NULL);
- break;
-
- default:
- FatalError ("\nwinSetSpansNativeGDI - Unknown drawable type\n\n");
- break;
- }
-}
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Harold L Hunt II
+ * Alan Hourihane <alanh@fairlite.demon.co.uk>
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+typedef struct mybitmap
+{
+ BITMAPINFOHEADER bmiHeader;
+ RGBQUAD bmiColors[256]; /* Maximum palette used in case of 8-bit per pixel */
+} mybitmap_t;
+/* See Porting Layer Definition - p. 55 */
+void
+winSetSpansNativeGDI(DrawablePtr pDrawable,
+ GCPtr pGC,
+ char *pSrcs,
+ DDXPointPtr pPoints,
+ int *piWidths, int iSpans, int fSorted)
+{
+ winGCPriv(pGC);
+ PixmapPtr pPixmap = NULL;
+ winPrivPixmapPtr pPixmapPriv = NULL;
+ HBITMAP hbmpOrig = NULL;
+ mybitmap_t bmi;
+ HRGN hrgn = NULL, combined = NULL;
+ int nbox;
+ BoxPtr pbox;
+
+ nbox = RegionNumRects(pGC->pCompositeClip);
+ pbox = RegionRects(pGC->pCompositeClip);
+
+ if (!nbox)
+ return;
+
+ combined = CreateRectRgn(pbox->x1, pbox->y1, pbox->x2, pbox->y2);
+ nbox--;
+ pbox++;
+ while (nbox--) {
+ hrgn = CreateRectRgn(pbox->x1, pbox->y1, pbox->x2, pbox->y2);
+ CombineRgn(combined, combined, hrgn, RGN_OR);
+ DeleteObject(hrgn);
+ hrgn = NULL;
+ pbox++;
+ }
+
+ /* Branch on the drawable type */
+ switch (pDrawable->type) {
+ case DRAWABLE_PIXMAP:
+
+ SelectClipRgn(pGCPriv->hdcMem, combined);
+ DeleteObject(combined);
+ combined = NULL;
+
+ pPixmap = (PixmapPtr) pDrawable;
+ pPixmapPriv = winGetPixmapPriv(pPixmap);
+
+ /* Select the drawable pixmap into a DC */
+ hbmpOrig = SelectObject(pGCPriv->hdcMem, pPixmapPriv->hBitmap);
+ if (hbmpOrig == NULL)
+ FatalError("winSetSpans - DRAWABLE_PIXMAP - SelectObject () "
+ "failed on pPixmapPriv->hBitmap\n");
+
+ while (iSpans--) {
+ ZeroMemory (&bmi, sizeof (mybitmap_t));
+ bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+ bmi.bmiHeader.biWidth = *piWidths;
+ bmi.bmiHeader.biHeight = 1;
+ bmi.bmiHeader.biPlanes = 1;
+ bmi.bmiHeader.biBitCount = pDrawable->depth;
+ bmi.bmiHeader.biCompression = BI_RGB;
+
+ /* Setup color table for mono DIBs */
+ if (pDrawable->depth == 1) {
+ bmi.bmiColors[1].rgbBlue = 255;
+ bmi.bmiColors[1].rgbGreen = 255;
+ bmi.bmiColors[1].rgbRed = 255;
+ }
+
+ StretchDIBits(pGCPriv->hdcMem,
+ pPoints->x, pPoints->y,
+ *piWidths, 1,
+ 0, 0,
+ *piWidths, 1,
+ pSrcs,
+ (BITMAPINFO*)&bmi,
+ DIB_RGB_COLORS, g_copyROP[pGC->alu]);
+
+ pSrcs += PixmapBytePad(*piWidths, pDrawable->depth);
+ pPoints++;
+ piWidths++;
+ }
+
+ /* Reset the clip region */
+ SelectClipRgn(pGCPriv->hdcMem, NULL);
+
+ /* Push the drawable pixmap out of the GC HDC */
+ SelectObject(pGCPriv->hdcMem, hbmpOrig);
+ break;
+
+ case DRAWABLE_WINDOW:
+
+ SelectClipRgn(pGCPriv->hdc, combined);
+ DeleteObject(combined);
+ combined = NULL;
+
+ while (iSpans--) {
+ ZeroMemory (&bmi, sizeof (mybitmap_t));
+ bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+ bmi.bmiHeader.biWidth = *piWidths;
+ bmi.bmiHeader.biHeight = 1;
+ bmi.bmiHeader.biPlanes = 1;
+ bmi.bmiHeader.biBitCount = pDrawable->depth;
+ bmi.bmiHeader.biCompression = BI_RGB;
+
+ /* Setup color table for mono DIBs */
+ if (pDrawable->depth == 1) {
+ bmi.bmiColors[1].rgbBlue = 255;
+ bmi.bmiColors[1].rgbGreen = 255;
+ bmi.bmiColors[1].rgbRed = 255;
+ }
+
+ StretchDIBits(pGCPriv->hdc,
+ pPoints->x, pPoints->y,
+ *piWidths, 1,
+ 0, 0,
+ *piWidths, 1,
+ pSrcs,
+ (BITMAPINFO *) & bmi,
+ DIB_RGB_COLORS, g_copyROP[pGC->alu]);
+
+ pSrcs += PixmapBytePad(*piWidths, pDrawable->depth);
+ pPoints++;
+ piWidths++;
+ }
+
+ /* Reset the clip region */
+ SelectClipRgn(pGCPriv->hdc, NULL);
+ break;
+
+ default:
+ FatalError("\nwinSetSpansNativeGDI - Unknown drawable type\n\n");
+ break;
+ }
+}
diff --git a/xorg-server/hw/xwin/winshaddd.c b/xorg-server/hw/xwin/winshaddd.c
index cf4dd62f1..4b0eba1cb 100644
--- a/xorg-server/hw/xwin/winshaddd.c
+++ b/xorg-server/hw/xwin/winshaddd.c
@@ -37,61 +37,55 @@
#include "win.h"
-/*
-
/*
* Local prototypes
*/
static Bool
-winAllocateFBShadowDD (ScreenPtr pScreen);
+ winAllocateFBShadowDD(ScreenPtr pScreen);
static void
-winShadowUpdateDD (ScreenPtr pScreen,
- shadowBufPtr pBuf);
+ winShadowUpdateDD(ScreenPtr pScreen, shadowBufPtr pBuf);
static Bool
-winCloseScreenShadowDD (int nIndex, ScreenPtr pScreen);
+ winCloseScreenShadowDD(int nIndex, ScreenPtr pScreen);
static Bool
-winInitVisualsShadowDD (ScreenPtr pScreen);
+ winInitVisualsShadowDD(ScreenPtr pScreen);
static Bool
-winAdjustVideoModeShadowDD (ScreenPtr pScreen);
+ winAdjustVideoModeShadowDD(ScreenPtr pScreen);
static Bool
-winBltExposedRegionsShadowDD (ScreenPtr pScreen);
+ winBltExposedRegionsShadowDD(ScreenPtr pScreen);
static Bool
-winActivateAppShadowDD (ScreenPtr pScreen);
+ winActivateAppShadowDD(ScreenPtr pScreen);
static Bool
-winRedrawScreenShadowDD (ScreenPtr pScreen);
+ winRedrawScreenShadowDD(ScreenPtr pScreen);
static Bool
-winRealizeInstalledPaletteShadowDD (ScreenPtr pScreen);
+ winRealizeInstalledPaletteShadowDD(ScreenPtr pScreen);
static Bool
-winInstallColormapShadowDD (ColormapPtr pColormap);
+ winInstallColormapShadowDD(ColormapPtr pColormap);
static Bool
-winStoreColorsShadowDD (ColormapPtr pmap,
- int ndef,
- xColorItem *pdefs);
+ winStoreColorsShadowDD(ColormapPtr pmap, int ndef, xColorItem * pdefs);
static Bool
-winCreateColormapShadowDD (ColormapPtr pColormap);
+ winCreateColormapShadowDD(ColormapPtr pColormap);
static Bool
-winDestroyColormapShadowDD (ColormapPtr pColormap);
+ winDestroyColormapShadowDD(ColormapPtr pColormap);
static Bool
-winCreatePrimarySurfaceShadowDD (ScreenPtr pScreen);
+ winCreatePrimarySurfaceShadowDD(ScreenPtr pScreen);
static Bool
-winReleasePrimarySurfaceShadowDD (ScreenPtr pScreen);
-
+ winReleasePrimarySurfaceShadowDD(ScreenPtr pScreen);
/*
* Create the primary surface and attach the clipper.
@@ -100,89 +94,80 @@ winReleasePrimarySurfaceShadowDD (ScreenPtr pScreen);
*/
static Bool
-winCreatePrimarySurfaceShadowDD (ScreenPtr pScreen)
+winCreatePrimarySurfaceShadowDD(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- HRESULT ddrval = DD_OK;
- DDSURFACEDESC ddsd;
-
- /* Describe the primary surface */
- ZeroMemory (&ddsd, sizeof (ddsd));
- ddsd.dwSize = sizeof (ddsd);
- ddsd.dwFlags = DDSD_CAPS;
- ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
-
- /* Create the primary surface */
- ddrval = IDirectDraw2_CreateSurface (pScreenPriv->pdd2,
- &ddsd,
- &pScreenPriv->pddsPrimary,
- NULL);
- if (FAILED (ddrval))
- {
- ErrorF ("winCreatePrimarySurfaceShadowDD - Could not create primary "
- "surface: %08x\n", (unsigned int) ddrval);
- return FALSE;
+ winScreenPriv(pScreen);
+ HRESULT ddrval = DD_OK;
+ DDSURFACEDESC ddsd;
+
+ /* Describe the primary surface */
+ ZeroMemory(&ddsd, sizeof(ddsd));
+ ddsd.dwSize = sizeof(ddsd);
+ ddsd.dwFlags = DDSD_CAPS;
+ ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
+
+ /* Create the primary surface */
+ ddrval = IDirectDraw2_CreateSurface(pScreenPriv->pdd2,
+ &ddsd, &pScreenPriv->pddsPrimary, NULL);
+ if (FAILED(ddrval)) {
+ ErrorF("winCreatePrimarySurfaceShadowDD - Could not create primary "
+ "surface: %08x\n", (unsigned int) ddrval);
+ return FALSE;
}
-
- winDebug ("winCreatePrimarySurfaceShadowDD - Created primary surface\n");
-
- /*
- * Attach a clipper to the primary surface that will clip our blits to our
- * display window.
- */
- ddrval = IDirectDrawSurface2_SetClipper (pScreenPriv->pddsPrimary,
- pScreenPriv->pddcPrimary);
- if (FAILED (ddrval))
- {
- ErrorF ("winCreatePrimarySurfaceShadowDD - Primary attach clipper "
- "failed: %08x\n",
- (unsigned int) ddrval);
- return FALSE;
+
+ winDebug("winCreatePrimarySurfaceShadowDD - Created primary surface\n");
+
+ /*
+ * Attach a clipper to the primary surface that will clip our blits to our
+ * display window.
+ */
+ ddrval = IDirectDrawSurface2_SetClipper(pScreenPriv->pddsPrimary,
+ pScreenPriv->pddcPrimary);
+ if (FAILED(ddrval)) {
+ ErrorF("winCreatePrimarySurfaceShadowDD - Primary attach clipper "
+ "failed: %08x\n", (unsigned int) ddrval);
+ return FALSE;
}
- winDebug ("winCreatePrimarySurfaceShadowDD - Attached clipper to "
- "primary surface\n");
+ winDebug("winCreatePrimarySurfaceShadowDD - Attached clipper to "
+ "primary surface\n");
- /* Everything was correct */
- return TRUE;
+ /* Everything was correct */
+ return TRUE;
}
-
/*
* Detach the clipper and release the primary surface.
* Called from WM_DISPLAYCHANGE.
*/
static Bool
-winReleasePrimarySurfaceShadowDD (ScreenPtr pScreen)
+winReleasePrimarySurfaceShadowDD(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
+ winScreenPriv(pScreen);
- winDebug ("winReleasePrimarySurfaceShadowDD - Hello\n");
+ winDebug ("winReleasePrimarySurfaceShadowDD - Hello\n");
- /* Release the primary surface and clipper, if they exist */
- if (pScreenPriv->pddsPrimary)
- {
- /*
- * Detach the clipper from the primary surface.
- * NOTE: We do this explicity for clarity. The Clipper is not released.
- */
- IDirectDrawSurface2_SetClipper (pScreenPriv->pddsPrimary,
- NULL);
+ /* Release the primary surface and clipper, if they exist */
+ if (pScreenPriv->pddsPrimary) {
+ /*
+ * Detach the clipper from the primary surface.
+ * NOTE: We do this explicity for clarity. The Clipper is not released.
+ */
+ IDirectDrawSurface2_SetClipper(pScreenPriv->pddsPrimary, NULL);
- winDebug ("winReleasePrimarySurfaceShadowDD - Detached clipper\n");
+ winDebug ("winReleasePrimarySurfaceShadowDD - Detached clipper\n");
- /* Release the primary surface */
- IDirectDrawSurface2_Release (pScreenPriv->pddsPrimary);
- pScreenPriv->pddsPrimary = NULL;
+ /* Release the primary surface */
+ IDirectDrawSurface2_Release(pScreenPriv->pddsPrimary);
+ pScreenPriv->pddsPrimary = NULL;
}
- winDebug ("winReleasePrimarySurfaceShadowDD - Released primary surface\n");
+ winDebug ("winReleasePrimarySurfaceShadowDD - Released primary surface\n");
- return TRUE;
+ return TRUE;
}
-
/*
* Create a DirectDraw surface for the shadow framebuffer; also create
* a primary surface object so we can blit to the display.
@@ -192,319 +177,283 @@ winReleasePrimarySurfaceShadowDD (ScreenPtr pScreen)
*/
static Bool
-winAllocateFBShadowDD (ScreenPtr pScreen)
+winAllocateFBShadowDD(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- HRESULT ddrval = DD_OK;
- DDSURFACEDESC ddsd;
- DDSURFACEDESC *pddsdShadow = NULL;
-
- winDebug ("winAllocateFBShadowDD\n");
-
- /* Create a clipper */
- ddrval = (*g_fpDirectDrawCreateClipper) (0,
- &pScreenPriv->pddcPrimary,
- NULL);
- if (FAILED (ddrval))
- {
- ErrorF ("winAllocateFBShadowDD - Could not create clipper: %08x\n",
- (unsigned int) ddrval);
- return FALSE;
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ HRESULT ddrval = DD_OK;
+ DDSURFACEDESC ddsd;
+ DDSURFACEDESC *pddsdShadow = NULL;
+
+ winDebug("winAllocateFBShadowDD\n");
+
+ /* Create a clipper */
+ ddrval = (*g_fpDirectDrawCreateClipper) (0,
+ &pScreenPriv->pddcPrimary, NULL);
+ if (FAILED(ddrval)) {
+ ErrorF("winAllocateFBShadowDD - Could not create clipper: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
}
- winDebug ("winAllocateFBShadowDD - Created a clipper\n");
-
- /* Attach the clipper to our display window */
- ddrval = IDirectDrawClipper_SetHWnd (pScreenPriv->pddcPrimary,
- 0,
- pScreenPriv->hwndScreen);
- if (FAILED (ddrval))
- {
- ErrorF ("winAllocateFBShadowDD - Clipper not attached to "
- "window: %08x\n",
- (unsigned int) ddrval);
- return FALSE;
+ winDebug("winAllocateFBShadowDD - Created a clipper\n");
+
+ /* Attach the clipper to our display window */
+ ddrval = IDirectDrawClipper_SetHWnd(pScreenPriv->pddcPrimary,
+ 0, pScreenPriv->hwndScreen);
+ if (FAILED(ddrval)) {
+ ErrorF("winAllocateFBShadowDD - Clipper not attached to "
+ "window: %08x\n", (unsigned int) ddrval);
+ return FALSE;
}
- winDebug ("winAllocateFBShadowDD - Attached clipper to window\n");
+ winDebug("winAllocateFBShadowDD - Attached clipper to window\n");
- /* Create a DirectDraw object, store the address at lpdd */
- ddrval = (*g_fpDirectDrawCreate) (NULL, &pScreenPriv->pdd, NULL);
- if (FAILED (ddrval))
- {
- ErrorF ("winAllocateFBShadowDD - Could not start DirectDraw: %08x\n",
- (unsigned int) ddrval);
- return FALSE;
+ /* Create a DirectDraw object, store the address at lpdd */
+ ddrval = (*g_fpDirectDrawCreate) (NULL, &pScreenPriv->pdd, NULL);
+ if (FAILED(ddrval)) {
+ ErrorF("winAllocateFBShadowDD - Could not start DirectDraw: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
}
- winDebug ("winAllocateFBShadowDD () - Created and initialized DD\n");
-
- /* Get a DirectDraw2 interface pointer */
- ddrval = IDirectDraw_QueryInterface (pScreenPriv->pdd,
- &IID_IDirectDraw2,
- (LPVOID*) &pScreenPriv->pdd2);
- if (FAILED (ddrval))
- {
- ErrorF ("winAllocateFBShadowDD - Failed DD2 query: %08x\n",
- (unsigned int) ddrval);
- return FALSE;
+ winDebug("winAllocateFBShadowDD () - Created and initialized DD\n");
+
+ /* Get a DirectDraw2 interface pointer */
+ ddrval = IDirectDraw_QueryInterface(pScreenPriv->pdd,
+ &IID_IDirectDraw2,
+ (LPVOID *) & pScreenPriv->pdd2);
+ if (FAILED(ddrval)) {
+ ErrorF("winAllocateFBShadowDD - Failed DD2 query: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
}
- /* Are we full screen? */
- if (pScreenInfo->fFullScreen)
- {
- DDSURFACEDESC ddsdCurrent;
- DWORD dwRefreshRateCurrent = 0;
- HDC hdc = NULL;
-
- /* Set the cooperative level to full screen */
- ddrval = IDirectDraw2_SetCooperativeLevel (pScreenPriv->pdd2,
- pScreenPriv->hwndScreen,
- DDSCL_EXCLUSIVE
- | DDSCL_FULLSCREEN);
- if (FAILED (ddrval))
- {
- ErrorF ("winAllocateFBShadowDD - Could not set "
- "cooperative level: %08x\n",
- (unsigned int) ddrval);
- return FALSE;
- }
-
- /*
- * We only need to get the current refresh rate for comparison
- * if a refresh rate has been passed on the command line.
- */
- if (pScreenInfo->dwRefreshRate != 0)
- {
- ZeroMemory (&ddsdCurrent, sizeof (ddsdCurrent));
- ddsdCurrent.dwSize = sizeof (ddsdCurrent);
-
- /* Get information about current display settings */
- ddrval = IDirectDraw2_GetDisplayMode (pScreenPriv->pdd2,
- &ddsdCurrent);
- if (FAILED (ddrval))
- {
- ErrorF ("winAllocateFBShadowDD - Could not get current "
- "refresh rate: %08x. Continuing.\n",
- (unsigned int) ddrval);
- dwRefreshRateCurrent = 0;
- }
- else
- {
- /* Grab the current refresh rate */
- dwRefreshRateCurrent = ddsdCurrent.u2.dwRefreshRate;
- }
- }
-
- /* Clean up the refresh rate */
- if (dwRefreshRateCurrent == pScreenInfo->dwRefreshRate)
- {
- /*
- * Refresh rate is non-specified or equal to current.
- */
- pScreenInfo->dwRefreshRate = 0;
- }
-
- /* Grab a device context for the screen */
- hdc = GetDC (NULL);
- if (hdc == NULL)
- {
- ErrorF ("winAllocateFBShadowDD - GetDC () failed\n");
- return FALSE;
- }
-
- /* Only change the video mode when different than current mode */
- if (!pScreenInfo->fMultipleMonitors
- && (pScreenInfo->dwWidth != GetSystemMetrics (SM_CXSCREEN)
- || pScreenInfo->dwHeight != GetSystemMetrics (SM_CYSCREEN)
- || pScreenInfo->dwBPP != GetDeviceCaps (hdc, BITSPIXEL)
- || pScreenInfo->dwRefreshRate != 0))
- {
- winDebug ("winAllocateFBShadowDD - Changing video mode\n");
-
- /* Change the video mode to the mode requested, and use the driver default refresh rate on failure */
- ddrval = IDirectDraw2_SetDisplayMode (pScreenPriv->pdd2,
- pScreenInfo->dwWidth,
- pScreenInfo->dwHeight,
- pScreenInfo->dwBPP,
- pScreenInfo->dwRefreshRate,
- 0);
- if (FAILED (ddrval))
- {
- ErrorF ("winAllocateFBShadowDD - Could not set "\
- "full screen display mode: %08x\n",
- (unsigned int) ddrval);
- ErrorF ("winAllocateFBShadowDD - Using default driver refresh rate\n");
- ddrval = IDirectDraw2_SetDisplayMode (pScreenPriv->pdd2,
- pScreenInfo->dwWidth,
- pScreenInfo->dwHeight,
- pScreenInfo->dwBPP,
- 0,
- 0);
- if (FAILED(ddrval))
- {
- ErrorF ("winAllocateFBShadowDD - Could not set default refresh rate "
- "full screen display mode: %08x\n",
- (unsigned int) ddrval);
- return FALSE;
- }
- }
- }
- else
- {
- winDebug ("winAllocateFBShadowDD - Not changing video mode\n");
- }
-
- /* Release our DC */
- ReleaseDC (NULL, hdc);
- hdc = NULL;
+ /* Are we full screen? */
+ if (pScreenInfo->fFullScreen) {
+ DDSURFACEDESC ddsdCurrent;
+ DWORD dwRefreshRateCurrent = 0;
+ HDC hdc = NULL;
+
+ /* Set the cooperative level to full screen */
+ ddrval = IDirectDraw2_SetCooperativeLevel(pScreenPriv->pdd2,
+ pScreenPriv->hwndScreen,
+ DDSCL_EXCLUSIVE
+ | DDSCL_FULLSCREEN);
+ if (FAILED(ddrval)) {
+ ErrorF("winAllocateFBShadowDD - Could not set "
+ "cooperative level: %08x\n", (unsigned int) ddrval);
+ return FALSE;
+ }
+
+ /*
+ * We only need to get the current refresh rate for comparison
+ * if a refresh rate has been passed on the command line.
+ */
+ if (pScreenInfo->dwRefreshRate != 0) {
+ ZeroMemory(&ddsdCurrent, sizeof(ddsdCurrent));
+ ddsdCurrent.dwSize = sizeof(ddsdCurrent);
+
+ /* Get information about current display settings */
+ ddrval = IDirectDraw2_GetDisplayMode(pScreenPriv->pdd2,
+ &ddsdCurrent);
+ if (FAILED(ddrval)) {
+ ErrorF("winAllocateFBShadowDD - Could not get current "
+ "refresh rate: %08x. Continuing.\n",
+ (unsigned int) ddrval);
+ dwRefreshRateCurrent = 0;
+ }
+ else {
+ /* Grab the current refresh rate */
+ dwRefreshRateCurrent = ddsdCurrent.u2.dwRefreshRate;
+ }
+ }
+
+ /* Clean up the refresh rate */
+ if (dwRefreshRateCurrent == pScreenInfo->dwRefreshRate) {
+ /*
+ * Refresh rate is non-specified or equal to current.
+ */
+ pScreenInfo->dwRefreshRate = 0;
+ }
+
+ /* Grab a device context for the screen */
+ hdc = GetDC(NULL);
+ if (hdc == NULL) {
+ ErrorF("winAllocateFBShadowDD - GetDC () failed\n");
+ return FALSE;
+ }
+
+ /* Only change the video mode when different than current mode */
+ if (!pScreenInfo->fMultipleMonitors
+ && (pScreenInfo->dwWidth != GetSystemMetrics(SM_CXSCREEN)
+ || pScreenInfo->dwHeight != GetSystemMetrics(SM_CYSCREEN)
+ || pScreenInfo->dwBPP != GetDeviceCaps(hdc, BITSPIXEL)
+ || pScreenInfo->dwRefreshRate != 0)) {
+ winDebug ("winAllocateFBShadowDD - Changing video mode\n");
+
+ /* Change the video mode to the mode requested, and use the driver default refresh rate on failure */
+ ddrval = IDirectDraw2_SetDisplayMode(pScreenPriv->pdd2,
+ pScreenInfo->dwWidth,
+ pScreenInfo->dwHeight,
+ pScreenInfo->dwBPP,
+ pScreenInfo->dwRefreshRate, 0);
+ if (FAILED(ddrval)) {
+ ErrorF("winAllocateFBShadowDD - Could not set "
+ "full screen display mode: %08x\n",
+ (unsigned int) ddrval);
+ ErrorF
+ ("winAllocateFBShadowDD - Using default driver refresh rate\n");
+ ddrval =
+ IDirectDraw2_SetDisplayMode(pScreenPriv->pdd2,
+ pScreenInfo->dwWidth,
+ pScreenInfo->dwHeight,
+ pScreenInfo->dwBPP, 0, 0);
+ if (FAILED(ddrval)) {
+ ErrorF
+ ("winAllocateFBShadowDD - Could not set default refresh rate "
+ "full screen display mode: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+ }
+ }
+ else {
+ winDebug ("winAllocateFBShadowDD - Not changing video mode\n");
+ }
+
+ /* Release our DC */
+ ReleaseDC(NULL, hdc);
+ hdc = NULL;
}
- else
- {
- /* Set the cooperative level for windowed mode */
- ddrval = IDirectDraw2_SetCooperativeLevel (pScreenPriv->pdd2,
- pScreenPriv->hwndScreen,
- DDSCL_NORMAL);
- if (FAILED (ddrval))
- {
- ErrorF ("winAllocateFBShadowDD - Could not set "\
- "cooperative level: %08x\n",
- (unsigned int) ddrval);
- return FALSE;
- }
+ else {
+ /* Set the cooperative level for windowed mode */
+ ddrval = IDirectDraw2_SetCooperativeLevel(pScreenPriv->pdd2,
+ pScreenPriv->hwndScreen,
+ DDSCL_NORMAL);
+ if (FAILED(ddrval)) {
+ ErrorF("winAllocateFBShadowDD - Could not set "
+ "cooperative level: %08x\n", (unsigned int) ddrval);
+ return FALSE;
+ }
}
- /* Create the primary surface */
- if (!winCreatePrimarySurfaceShadowDD (pScreen))
- {
- ErrorF ("winAllocateFBShadowDD - winCreatePrimarySurfaceShadowDD "
- "failed\n");
- return FALSE;
+ /* Create the primary surface */
+ if (!winCreatePrimarySurfaceShadowDD(pScreen)) {
+ ErrorF("winAllocateFBShadowDD - winCreatePrimarySurfaceShadowDD "
+ "failed\n");
+ return FALSE;
}
- /* Describe the shadow surface to be created */
- /* NOTE: Do not use a DDSCAPS_VIDEOMEMORY surface,
- * as drawing, locking, and unlocking take forever
- * with video memory surfaces. In addition,
- * video memory is a somewhat scarce resource,
- * so you shouldn't be allocating video memory when
- * you have the option of using system memory instead.
- */
- ZeroMemory (&ddsd, sizeof (ddsd));
- ddsd.dwSize = sizeof (ddsd);
- ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
- ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
- ddsd.dwHeight = pScreenInfo->dwHeight;
- ddsd.dwWidth = pScreenInfo->dwWidth;
-
- /* Create the shadow surface */
- ddrval = IDirectDraw2_CreateSurface (pScreenPriv->pdd2,
- &ddsd,
- &pScreenPriv->pddsShadow,
- NULL);
- if (FAILED (ddrval))
- {
- ErrorF ("winAllocateFBShadowDD - Could not create shadow "\
- "surface: %08x\n", (unsigned int) ddrval);
- return FALSE;
+ /* Describe the shadow surface to be created */
+ /* NOTE: Do not use a DDSCAPS_VIDEOMEMORY surface,
+ * as drawing, locking, and unlocking take forever
+ * with video memory surfaces. In addition,
+ * video memory is a somewhat scarce resource,
+ * so you shouldn't be allocating video memory when
+ * you have the option of using system memory instead.
+ */
+ ZeroMemory(&ddsd, sizeof(ddsd));
+ ddsd.dwSize = sizeof(ddsd);
+ ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
+ ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
+ ddsd.dwHeight = pScreenInfo->dwHeight;
+ ddsd.dwWidth = pScreenInfo->dwWidth;
+
+ /* Create the shadow surface */
+ ddrval = IDirectDraw2_CreateSurface(pScreenPriv->pdd2,
+ &ddsd, &pScreenPriv->pddsShadow, NULL);
+ if (FAILED(ddrval)) {
+ ErrorF("winAllocateFBShadowDD - Could not create shadow "
+ "surface: %08x\n", (unsigned int) ddrval);
+ return FALSE;
}
-
- winDebug ("winAllocateFBShadowDD - Created shadow\n");
-
- /* Allocate a DD surface description for our screen privates */
- pddsdShadow = pScreenPriv->pddsdShadow = malloc (sizeof (DDSURFACEDESC));
- if (pddsdShadow == NULL)
- {
- ErrorF ("winAllocateFBShadowDD - Could not allocate surface "\
- "description memory\n");
- return FALSE;
+
+ winDebug("winAllocateFBShadowDD - Created shadow\n");
+
+ /* Allocate a DD surface description for our screen privates */
+ pddsdShadow = pScreenPriv->pddsdShadow = malloc(sizeof(DDSURFACEDESC));
+ if (pddsdShadow == NULL) {
+ ErrorF("winAllocateFBShadowDD - Could not allocate surface "
+ "description memory\n");
+ return FALSE;
}
- ZeroMemory (pddsdShadow, sizeof (*pddsdShadow));
- pddsdShadow->dwSize = sizeof (*pddsdShadow);
-
- winDebug ("winAllocateFBShadowDD - Locking shadow\n");
-
- /* Lock the shadow surface */
- ddrval = IDirectDrawSurface2_Lock (pScreenPriv->pddsShadow,
- NULL,
- pddsdShadow,
- DDLOCK_WAIT,
- NULL);
- if (FAILED (ddrval) || pddsdShadow->lpSurface == NULL)
- {
- ErrorF ("winAllocateFBShadowDD - Could not lock shadow "\
- "surface: %08x\n", (unsigned int) ddrval);
- return FALSE;
+ ZeroMemory(pddsdShadow, sizeof(*pddsdShadow));
+ pddsdShadow->dwSize = sizeof(*pddsdShadow);
+
+ winDebug("winAllocateFBShadowDD - Locking shadow\n");
+
+ /* Lock the shadow surface */
+ ddrval = IDirectDrawSurface2_Lock(pScreenPriv->pddsShadow,
+ NULL, pddsdShadow, DDLOCK_WAIT, NULL);
+ if (FAILED(ddrval) || pddsdShadow->lpSurface == NULL) {
+ ErrorF("winAllocateFBShadowDD - Could not lock shadow "
+ "surface: %08x\n", (unsigned int) ddrval);
+ return FALSE;
}
- winDebug ("winAllocateFBShadowDD - Locked shadow\n");
+ winDebug("winAllocateFBShadowDD - Locked shadow\n");
- /* We don't know how to deal with anything other than RGB */
- if (!(pddsdShadow->ddpfPixelFormat.dwFlags & DDPF_RGB))
- {
- ErrorF ("winAllocateFBShadowDD - Color format other than RGB\n");
- return FALSE;
+ /* We don't know how to deal with anything other than RGB */
+ if (!(pddsdShadow->ddpfPixelFormat.dwFlags & DDPF_RGB)) {
+ ErrorF("winAllocateFBShadowDD - Color format other than RGB\n");
+ return FALSE;
}
- /* Grab the pitch from the surface desc */
- pScreenInfo->dwStride = (pddsdShadow->u1.lPitch * 8)
- / pScreenInfo->dwBPP;
+ /* Grab the pitch from the surface desc */
+ pScreenInfo->dwStride = (pddsdShadow->u1.lPitch * 8)
+ / pScreenInfo->dwBPP;
+
+ /* Save the pointer to our surface memory */
+ pScreenInfo->pfb = pddsdShadow->lpSurface;
- /* Save the pointer to our surface memory */
- pScreenInfo->pfb = pddsdShadow->lpSurface;
-
- /* Grab the color depth and masks from the surface description */
- pScreenPriv->dwRedMask = pddsdShadow->ddpfPixelFormat.u2.dwRBitMask;
- pScreenPriv->dwGreenMask = pddsdShadow->ddpfPixelFormat.u3.dwGBitMask;
- pScreenPriv->dwBlueMask = pddsdShadow->ddpfPixelFormat.u4.dwBBitMask;
+ /* Grab the color depth and masks from the surface description */
+ pScreenPriv->dwRedMask = pddsdShadow->ddpfPixelFormat.u2.dwRBitMask;
+ pScreenPriv->dwGreenMask = pddsdShadow->ddpfPixelFormat.u3.dwGBitMask;
+ pScreenPriv->dwBlueMask = pddsdShadow->ddpfPixelFormat.u4.dwBBitMask;
- winDebug ("winAllocateFBShadowDD - Returning\n");
+ winDebug("winAllocateFBShadowDD - Returning\n");
- return TRUE;
+ return TRUE;
}
static void
-winFreeFBShadowDD (ScreenPtr pScreen)
+winFreeFBShadowDD(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-
- /* Free the shadow surface, if there is one */
- if (pScreenPriv->pddsShadow)
- {
- IDirectDrawSurface2_Unlock (pScreenPriv->pddsShadow, NULL);
- IDirectDrawSurface2_Release (pScreenPriv->pddsShadow);
- pScreenPriv->pddsShadow = NULL;
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /* Free the shadow surface, if there is one */
+ if (pScreenPriv->pddsShadow) {
+ IDirectDrawSurface2_Unlock(pScreenPriv->pddsShadow, NULL);
+ IDirectDrawSurface2_Release(pScreenPriv->pddsShadow);
+ pScreenPriv->pddsShadow = NULL;
}
- /* Detach the clipper from the primary surface and release the primary surface, if there is one */
- winReleasePrimarySurfaceShadowDD(pScreen);
+ /* Detach the clipper from the primary surface and release the primary surface, if there is one */
+ winReleasePrimarySurfaceShadowDD(pScreen);
- /* Release the clipper object */
- if (pScreenPriv->pddcPrimary)
- {
- IDirectDrawClipper_Release (pScreenPriv->pddcPrimary);
- pScreenPriv->pddcPrimary = NULL;
+ /* Release the clipper object */
+ if (pScreenPriv->pddcPrimary) {
+ IDirectDrawClipper_Release(pScreenPriv->pddcPrimary);
+ pScreenPriv->pddcPrimary = NULL;
}
- /* Free the DirectDraw2 object, if there is one */
- if (pScreenPriv->pdd2)
- {
- IDirectDraw2_RestoreDisplayMode (pScreenPriv->pdd2);
- IDirectDraw2_Release (pScreenPriv->pdd2);
- pScreenPriv->pdd2 = NULL;
+ /* Free the DirectDraw2 object, if there is one */
+ if (pScreenPriv->pdd2) {
+ IDirectDraw2_RestoreDisplayMode(pScreenPriv->pdd2);
+ IDirectDraw2_Release(pScreenPriv->pdd2);
+ pScreenPriv->pdd2 = NULL;
}
- /* Free the DirectDraw object, if there is one */
- if (pScreenPriv->pdd)
- {
- IDirectDraw_Release (pScreenPriv->pdd);
- pScreenPriv->pdd = NULL;
+ /* Free the DirectDraw object, if there is one */
+ if (pScreenPriv->pdd) {
+ IDirectDraw_Release(pScreenPriv->pdd);
+ pScreenPriv->pdd = NULL;
}
- /* Invalidate the ScreenInfo's fb pointer */
- pScreenInfo->pfb = NULL;
+ /* Invalidate the ScreenInfo's fb pointer */
+ pScreenInfo->pfb = NULL;
}
/*
@@ -512,162 +461,149 @@ winFreeFBShadowDD (ScreenPtr pScreen)
*/
static void
-winShadowUpdateDD (ScreenPtr pScreen,
- shadowBufPtr pBuf)
+winShadowUpdateDD(ScreenPtr pScreen, shadowBufPtr pBuf)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- RegionPtr damage = shadowDamage(pBuf);
- HRESULT ddrval = DD_OK;
- RECT rcDest, rcSrc;
- POINT ptOrigin;
- DWORD dwBox = RegionNumRects (damage);
- BoxPtr pBox = RegionRects (damage);
- HRGN hrgnTemp = NULL, hrgnCombined = NULL;
-
- /*
- * Return immediately if the app is not active
- * and we are fullscreen, or if we have a bad display depth
- */
- if ((!pScreenPriv->fActive && pScreenInfo->fFullScreen)
- || pScreenPriv->fBadDepth) return;
-
- /* Return immediately if we didn't get needed surfaces */
- if (!pScreenPriv->pddsPrimary || !pScreenPriv->pddsShadow)
- return;
-
- /* Get the origin of the window in the screen coords */
- ptOrigin.x = pScreenInfo->dwXOffset;
- ptOrigin.y = pScreenInfo->dwYOffset;
- MapWindowPoints (pScreenPriv->hwndScreen,
- HWND_DESKTOP,
- (LPPOINT)&ptOrigin, 1);
-
- /* Unlock the shadow surface, so we can blit */
- ddrval = IDirectDrawSurface2_Unlock (pScreenPriv->pddsShadow, NULL);
- if (FAILED (ddrval))
- {
- ErrorF ("winShadowUpdateDD - Unlock failed\n");
- return;
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ RegionPtr damage = shadowDamage(pBuf);
+ HRESULT ddrval = DD_OK;
+ RECT rcDest, rcSrc;
+ POINT ptOrigin;
+ DWORD dwBox = RegionNumRects(damage);
+ BoxPtr pBox = RegionRects(damage);
+ HRGN hrgnTemp = NULL, hrgnCombined = NULL;
+
+ /*
+ * Return immediately if the app is not active
+ * and we are fullscreen, or if we have a bad display depth
+ */
+ if ((!pScreenPriv->fActive && pScreenInfo->fFullScreen)
+ || pScreenPriv->fBadDepth)
+ return;
+
+ /* Return immediately if we didn't get needed surfaces */
+ if (!pScreenPriv->pddsPrimary || !pScreenPriv->pddsShadow)
+ return;
+
+ /* Get the origin of the window in the screen coords */
+ ptOrigin.x = pScreenInfo->dwXOffset;
+ ptOrigin.y = pScreenInfo->dwYOffset;
+ MapWindowPoints(pScreenPriv->hwndScreen,
+ HWND_DESKTOP, (LPPOINT) & ptOrigin, 1);
+
+ /* Unlock the shadow surface, so we can blit */
+ ddrval = IDirectDrawSurface2_Unlock(pScreenPriv->pddsShadow, NULL);
+ if (FAILED(ddrval)) {
+ ErrorF("winShadowUpdateDD - Unlock failed\n");
+ return;
}
- /*
- * Handle small regions with multiple blits,
- * handle large regions by creating a clipping region and
- * doing a single blit constrained to that clipping region.
- */
- if (pScreenInfo->dwClipUpdatesNBoxes == 0
- || dwBox < pScreenInfo->dwClipUpdatesNBoxes)
- {
- /* Loop through all boxes in the damaged region */
- while (dwBox--)
- {
- /* Assign damage box to source rectangle */
- rcSrc.left = pBox->x1;
- rcSrc.top = pBox->y1;
- rcSrc.right = pBox->x2;
- rcSrc.bottom = pBox->y2;
-
- /* Calculate destination rectange */
- rcDest.left = ptOrigin.x + rcSrc.left;
- rcDest.top = ptOrigin.y + rcSrc.top;
- rcDest.right = ptOrigin.x + rcSrc.right;
- rcDest.bottom = ptOrigin.y + rcSrc.bottom;
-
- /* Blit the damaged areas */
- ddrval = IDirectDrawSurface2_Blt (pScreenPriv->pddsPrimary,
- &rcDest,
- pScreenPriv->pddsShadow,
- &rcSrc,
- DDBLT_WAIT,
- NULL);
-
- /* Get a pointer to the next box */
- ++pBox;
- }
+ /*
+ * Handle small regions with multiple blits,
+ * handle large regions by creating a clipping region and
+ * doing a single blit constrained to that clipping region.
+ */
+ if (pScreenInfo->dwClipUpdatesNBoxes == 0
+ || dwBox < pScreenInfo->dwClipUpdatesNBoxes) {
+ /* Loop through all boxes in the damaged region */
+ while (dwBox--) {
+ /* Assign damage box to source rectangle */
+ rcSrc.left = pBox->x1;
+ rcSrc.top = pBox->y1;
+ rcSrc.right = pBox->x2;
+ rcSrc.bottom = pBox->y2;
+
+ /* Calculate destination rectange */
+ rcDest.left = ptOrigin.x + rcSrc.left;
+ rcDest.top = ptOrigin.y + rcSrc.top;
+ rcDest.right = ptOrigin.x + rcSrc.right;
+ rcDest.bottom = ptOrigin.y + rcSrc.bottom;
+
+ /* Blit the damaged areas */
+ ddrval = IDirectDrawSurface2_Blt(pScreenPriv->pddsPrimary,
+ &rcDest,
+ pScreenPriv->pddsShadow,
+ &rcSrc, DDBLT_WAIT, NULL);
+
+ /* Get a pointer to the next box */
+ ++pBox;
+ }
}
- else
- {
- BoxPtr pBoxExtents = RegionExtents(damage);
-
- /* Compute a GDI region from the damaged region */
- hrgnCombined = CreateRectRgn (pBox->x1, pBox->y1, pBox->x2, pBox->y2);
- dwBox--;
- pBox++;
- while (dwBox--)
- {
- hrgnTemp = CreateRectRgn (pBox->x1, pBox->y1, pBox->x2, pBox->y2);
- CombineRgn (hrgnCombined, hrgnCombined, hrgnTemp, RGN_OR);
- DeleteObject (hrgnTemp);
- pBox++;
- }
-
- /* Install the GDI region as a clipping region */
- SelectClipRgn (pScreenPriv->hdcScreen, hrgnCombined);
- DeleteObject (hrgnCombined);
- hrgnCombined = NULL;
-
- /* Calculating a bounding box for the source is easy */
- rcSrc.left = pBoxExtents->x1;
- rcSrc.top = pBoxExtents->y1;
- rcSrc.right = pBoxExtents->x2;
- rcSrc.bottom = pBoxExtents->y2;
-
- /* Calculating a bounding box for the destination is trickier */
- rcDest.left = ptOrigin.x + rcSrc.left;
- rcDest.top = ptOrigin.y + rcSrc.top;
- rcDest.right = ptOrigin.x + rcSrc.right;
- rcDest.bottom = ptOrigin.y + rcSrc.bottom;
-
- /* Our Blt should be clipped to the invalidated region */
- ddrval = IDirectDrawSurface2_Blt (pScreenPriv->pddsPrimary,
- &rcDest,
- pScreenPriv->pddsShadow,
- &rcSrc,
- DDBLT_WAIT,
- NULL);
-
- /* Reset the clip region */
- SelectClipRgn (pScreenPriv->hdcScreen, NULL);
+ else {
+ BoxPtr pBoxExtents = RegionExtents(damage);
+
+ /* Compute a GDI region from the damaged region */
+ hrgnCombined = CreateRectRgn(pBox->x1, pBox->y1, pBox->x2, pBox->y2);
+ dwBox--;
+ pBox++;
+ while (dwBox--) {
+ hrgnTemp = CreateRectRgn(pBox->x1, pBox->y1, pBox->x2, pBox->y2);
+ CombineRgn(hrgnCombined, hrgnCombined, hrgnTemp, RGN_OR);
+ DeleteObject(hrgnTemp);
+ pBox++;
+ }
+
+ /* Install the GDI region as a clipping region */
+ SelectClipRgn(pScreenPriv->hdcScreen, hrgnCombined);
+ DeleteObject(hrgnCombined);
+ hrgnCombined = NULL;
+
+ /* Calculating a bounding box for the source is easy */
+ rcSrc.left = pBoxExtents->x1;
+ rcSrc.top = pBoxExtents->y1;
+ rcSrc.right = pBoxExtents->x2;
+ rcSrc.bottom = pBoxExtents->y2;
+
+ /* Calculating a bounding box for the destination is trickier */
+ rcDest.left = ptOrigin.x + rcSrc.left;
+ rcDest.top = ptOrigin.y + rcSrc.top;
+ rcDest.right = ptOrigin.x + rcSrc.right;
+ rcDest.bottom = ptOrigin.y + rcSrc.bottom;
+
+ /* Our Blt should be clipped to the invalidated region */
+ ddrval = IDirectDrawSurface2_Blt(pScreenPriv->pddsPrimary,
+ &rcDest,
+ pScreenPriv->pddsShadow,
+ &rcSrc, DDBLT_WAIT, NULL);
+
+ /* Reset the clip region */
+ SelectClipRgn(pScreenPriv->hdcScreen, NULL);
}
- /* Relock the shadow surface */
- ddrval = IDirectDrawSurface2_Lock (pScreenPriv->pddsShadow,
- NULL,
- pScreenPriv->pddsdShadow,
- DDLOCK_WAIT,
- NULL);
- if (FAILED (ddrval))
- {
- ErrorF ("winShadowUpdateDD - Lock failed\n");
- return;
+ /* Relock the shadow surface */
+ ddrval = IDirectDrawSurface2_Lock(pScreenPriv->pddsShadow,
+ NULL,
+ pScreenPriv->pddsdShadow,
+ DDLOCK_WAIT, NULL);
+ if (FAILED(ddrval)) {
+ ErrorF("winShadowUpdateDD - Lock failed\n");
+ return;
}
- /* Has our memory pointer changed? */
- if (pScreenInfo->pfb != pScreenPriv->pddsdShadow->lpSurface)
- {
+ /* Has our memory pointer changed? */
+ if (pScreenInfo->pfb != pScreenPriv->pddsdShadow->lpSurface) {
extern const char *g_pszLogFile;
- ErrorF ("winShadowUpdateDD - Memory location of the shadow "
- "surface has changed, trying to update the root window "
- "pixmap header to point to the new address. If you get "
- "this message and "PROJECT_NAME" freezes or crashes "
- "after this message then send a problem report and your "
- "%s file to " BUILDERADDR "\n", g_pszLogFile);
-
- /* Location of shadow framebuffer has changed */
- winUpdateFBPointer(pScreen, pScreenPriv->pddsdShadow->lpSurface);
+ ErrorF("winShadowUpdateDD - Memory location of the shadow "
+ "surface has changed, trying to update the root window "
+ "pixmap header to point to the new address. If you get "
+ "this message and " PROJECT_NAME " freezes or crashes "
+ "after this message then send a problem report and your "
+ "%s file to " BUILDERADDR "\n", g_pszLogFile);
+
+ /* Location of shadow framebuffer has changed */
+ winUpdateFBPointer(pScreen, pScreenPriv->pddsdShadow->lpSurface);
}
}
static Bool
-winInitScreenShadowDD (ScreenPtr pScreen)
+winInitScreenShadowDD(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
+ winScreenPriv(pScreen);
- /* Get a device context for the screen */
- pScreenPriv->hdcScreen = GetDC (pScreenPriv->hwndScreen);
+ /* Get a device context for the screen */
+ pScreenPriv->hdcScreen = GetDC(pScreenPriv->hwndScreen);
- return winAllocateFBShadowDD(pScreen);
+ return winAllocateFBShadowDD(pScreen);
}
/*
@@ -677,64 +613,61 @@ winInitScreenShadowDD (ScreenPtr pScreen)
*/
static Bool
-winCloseScreenShadowDD (int nIndex, ScreenPtr pScreen)
+winCloseScreenShadowDD(int nIndex, ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- Bool fReturn;
-
- winDebug ("winCloseScreenShadowDD - Freeing screen resources\n");
-
- /* Flag that the screen is closed */
- pScreenPriv->fClosed = TRUE;
- pScreenPriv->fActive = FALSE;
-
- /* Call the wrapped CloseScreen procedure */
- WIN_UNWRAP(CloseScreen);
- if (pScreen->CloseScreen)
- fReturn = (*pScreen->CloseScreen) (nIndex, pScreen);
-
- winFreeFBShadowDD(pScreen);
-
- /* Free the screen DC */
- ReleaseDC (pScreenPriv->hwndScreen, pScreenPriv->hdcScreen);
-
- /* Delete the window property */
- RemoveProp (pScreenPriv->hwndScreen, WIN_SCR_PROP);
-
- /* Delete tray icon, if we have one */
- if (!pScreenInfo->fNoTrayIcon)
- winDeleteNotifyIcon (pScreenPriv);
-
- /* Free the exit confirmation dialog box, if it exists */
- if (g_hDlgExit != NULL)
- {
- DestroyWindow (g_hDlgExit);
- g_hDlgExit = NULL;
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ Bool fReturn;
+
+ winDebug("winCloseScreenShadowDD - Freeing screen resources\n");
+
+ /* Flag that the screen is closed */
+ pScreenPriv->fClosed = TRUE;
+ pScreenPriv->fActive = FALSE;
+
+ /* Call the wrapped CloseScreen procedure */
+ WIN_UNWRAP(CloseScreen);
+ if (pScreen->CloseScreen)
+ fReturn = (*pScreen->CloseScreen) (nIndex, pScreen);
+
+ winFreeFBShadowDD(pScreen);
+
+ /* Free the screen DC */
+ ReleaseDC(pScreenPriv->hwndScreen, pScreenPriv->hdcScreen);
+
+ /* Delete the window property */
+ RemoveProp(pScreenPriv->hwndScreen, WIN_SCR_PROP);
+
+ /* Delete tray icon, if we have one */
+ if (!pScreenInfo->fNoTrayIcon)
+ winDeleteNotifyIcon(pScreenPriv);
+
+ /* Free the exit confirmation dialog box, if it exists */
+ if (g_hDlgExit != NULL) {
+ DestroyWindow(g_hDlgExit);
+ g_hDlgExit = NULL;
}
- /* Kill our window */
- if (pScreenPriv->hwndScreen)
- {
- DestroyWindow (pScreenPriv->hwndScreen);
- pScreenPriv->hwndScreen = NULL;
+ /* Kill our window */
+ if (pScreenPriv->hwndScreen) {
+ DestroyWindow(pScreenPriv->hwndScreen);
+ pScreenPriv->hwndScreen = NULL;
}
#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
- /* Destroy the thread startup mutex */
- if (pScreenPriv->pmServerStarted) pthread_mutex_destroy (&pScreenPriv->pmServerStarted);
+ /* Destroy the thread startup mutex */
+ if (pScreenPriv->pmServerStarted) pthread_mutex_destroy (&pScreenPriv->pmServerStarted);
#endif
- /* Kill our screeninfo's pointer to the screen */
- pScreenInfo->pScreen = NULL;
+ /* Kill our screeninfo's pointer to the screen */
+ pScreenInfo->pScreen = NULL;
- /* Free the screen privates for this screen */
- free ((pointer) pScreenPriv);
+ /* Free the screen privates for this screen */
+ free((pointer) pScreenPriv);
- return fReturn;
+ return fReturn;
}
-
/*
* Tell mi what sort of visuals we need.
*
@@ -744,583 +677,528 @@ winCloseScreenShadowDD (int nIndex, ScreenPtr pScreen)
*/
static Bool
-winInitVisualsShadowDD (ScreenPtr pScreen)
+winInitVisualsShadowDD(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- DWORD dwRedBits, dwGreenBits, dwBlueBits;
-
- /* Count the number of ones in each color mask */
- dwRedBits = winCountBits (pScreenPriv->dwRedMask);
- dwGreenBits = winCountBits (pScreenPriv->dwGreenMask);
- dwBlueBits = winCountBits (pScreenPriv->dwBlueMask);
-
- /* Store the maximum number of ones in a color mask as the bitsPerRGB */
- if (dwRedBits == 0 || dwGreenBits == 0 || dwBlueBits == 0)
- pScreenPriv->dwBitsPerRGB = 8;
- else if (dwRedBits > dwGreenBits && dwRedBits > dwBlueBits)
- pScreenPriv->dwBitsPerRGB = dwRedBits;
- else if (dwGreenBits > dwRedBits && dwGreenBits > dwBlueBits)
- pScreenPriv->dwBitsPerRGB = dwGreenBits;
- else
- pScreenPriv->dwBitsPerRGB = dwBlueBits;
-
- winDebug ("winInitVisualsShadowDD - Masks %08x %08x %08x BPRGB %d d %d "
- "bpp %d\n",
- (unsigned int) pScreenPriv->dwRedMask,
- (unsigned int) pScreenPriv->dwGreenMask,
- (unsigned int) pScreenPriv->dwBlueMask,
- (int) pScreenPriv->dwBitsPerRGB,
- (int) pScreenInfo->dwDepth,
- (int) pScreenInfo->dwBPP);
-
- /* Create a single visual according to the Windows screen depth */
- switch (pScreenInfo->dwDepth)
- {
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ DWORD dwRedBits, dwGreenBits, dwBlueBits;
+
+ /* Count the number of ones in each color mask */
+ dwRedBits = winCountBits(pScreenPriv->dwRedMask);
+ dwGreenBits = winCountBits(pScreenPriv->dwGreenMask);
+ dwBlueBits = winCountBits(pScreenPriv->dwBlueMask);
+
+ /* Store the maximum number of ones in a color mask as the bitsPerRGB */
+ if (dwRedBits == 0 || dwGreenBits == 0 || dwBlueBits == 0)
+ pScreenPriv->dwBitsPerRGB = 8;
+ else if (dwRedBits > dwGreenBits && dwRedBits > dwBlueBits)
+ pScreenPriv->dwBitsPerRGB = dwRedBits;
+ else if (dwGreenBits > dwRedBits && dwGreenBits > dwBlueBits)
+ pScreenPriv->dwBitsPerRGB = dwGreenBits;
+ else
+ pScreenPriv->dwBitsPerRGB = dwBlueBits;
+
+ winDebug ("winInitVisualsShadowDD - Masks %08x %08x %08x BPRGB %d d %d "
+ "bpp %d\n",
+ (unsigned int) pScreenPriv->dwRedMask,
+ (unsigned int) pScreenPriv->dwGreenMask,
+ (unsigned int) pScreenPriv->dwBlueMask,
+ (int) pScreenPriv->dwBitsPerRGB,
+ (int) pScreenInfo->dwDepth, (int) pScreenInfo->dwBPP);
+
+ /* Create a single visual according to the Windows screen depth */
+ switch (pScreenInfo->dwDepth) {
case 24:
case 16:
case 15:
- /* Create the real visual */
- if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
- TrueColorMask,
- pScreenPriv->dwBitsPerRGB,
- TrueColor,
- pScreenPriv->dwRedMask,
- pScreenPriv->dwGreenMask,
- pScreenPriv->dwBlueMask))
- {
- ErrorF ("winInitVisualsShadowDD - miSetVisualTypesAndMasks "
- "failed for TrueColor\n");
- return FALSE;
- }
+ /* Create the real visual */
+ if (!miSetVisualTypesAndMasks(pScreenInfo->dwDepth,
+ TrueColorMask,
+ pScreenPriv->dwBitsPerRGB,
+ TrueColor,
+ pScreenPriv->dwRedMask,
+ pScreenPriv->dwGreenMask,
+ pScreenPriv->dwBlueMask)) {
+ ErrorF("winInitVisualsShadowDD - miSetVisualTypesAndMasks "
+ "failed for TrueColor\n");
+ return FALSE;
+ }
#ifdef XWIN_EMULATEPSEUDO
- if (!pScreenInfo->fEmulatePseudo)
- break;
-
- /* Setup a pseudocolor visual */
- if (!miSetVisualTypesAndMasks (8,
- PseudoColorMask,
- 8,
- -1,
- 0,
- 0,
- 0))
- {
- ErrorF ("winInitVisualsShadowDD - miSetVisualTypesAndMasks "
- "failed for PseudoColor\n");
- return FALSE;
- }
+ if (!pScreenInfo->fEmulatePseudo)
+ break;
+
+ /* Setup a pseudocolor visual */
+ if (!miSetVisualTypesAndMasks(8, PseudoColorMask, 8, -1, 0, 0, 0)) {
+ ErrorF("winInitVisualsShadowDD - miSetVisualTypesAndMasks "
+ "failed for PseudoColor\n");
+ return FALSE;
+ }
#endif
- break;
+ break;
case 8:
- if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
- pScreenInfo->fFullScreen
- ? PseudoColorMask : StaticColorMask,
- pScreenPriv->dwBitsPerRGB,
- pScreenInfo->fFullScreen
- ? PseudoColor : StaticColor,
- pScreenPriv->dwRedMask,
- pScreenPriv->dwGreenMask,
- pScreenPriv->dwBlueMask))
- {
- ErrorF ("winInitVisualsShadowDD - miSetVisualTypesAndMasks "
- "failed\n");
- return FALSE;
- }
- break;
+ if (!miSetVisualTypesAndMasks(pScreenInfo->dwDepth,
+ pScreenInfo->fFullScreen
+ ? PseudoColorMask : StaticColorMask,
+ pScreenPriv->dwBitsPerRGB,
+ pScreenInfo->fFullScreen
+ ? PseudoColor : StaticColor,
+ pScreenPriv->dwRedMask,
+ pScreenPriv->dwGreenMask,
+ pScreenPriv->dwBlueMask)) {
+ ErrorF("winInitVisualsShadowDD - miSetVisualTypesAndMasks "
+ "failed\n");
+ return FALSE;
+ }
+ break;
default:
- ErrorF ("winInitVisualsShadowDD - Unknown screen depth\n");
- return FALSE;
+ ErrorF("winInitVisualsShadowDD - Unknown screen depth\n");
+ return FALSE;
}
- winDebug ("winInitVisualsShadowDD - Returning\n");
+ winDebug("winInitVisualsShadowDD - Returning\n");
- return TRUE;
+ return TRUE;
}
-
/*
* Adjust the user proposed video mode
*/
static Bool
-winAdjustVideoModeShadowDD (ScreenPtr pScreen)
+winAdjustVideoModeShadowDD(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- HDC hdc = NULL;
- DWORD dwBPP;
-
- /* We're in serious trouble if we can't get a DC */
- hdc = GetDC (NULL);
- if (hdc == NULL)
- {
- ErrorF ("winAdjustVideoModeShadowDD - GetDC () failed\n");
- return FALSE;
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ HDC hdc = NULL;
+ DWORD dwBPP;
+
+ /* We're in serious trouble if we can't get a DC */
+ hdc = GetDC(NULL);
+ if (hdc == NULL) {
+ ErrorF("winAdjustVideoModeShadowDD - GetDC () failed\n");
+ return FALSE;
}
- /* Query GDI for current display depth */
- dwBPP = GetDeviceCaps (hdc, BITSPIXEL);
+ /* Query GDI for current display depth */
+ dwBPP = GetDeviceCaps(hdc, BITSPIXEL);
- /* DirectDraw can only change the depth in fullscreen mode */
- if (!(pScreenInfo->fFullScreen &&
- (pScreenInfo->dwBPP != WIN_DEFAULT_BPP)))
- {
- /* Otherwise, We'll use GDI's depth */
- pScreenInfo->dwBPP = dwBPP;
+ /* DirectDraw can only change the depth in fullscreen mode */
+ if (!(pScreenInfo->fFullScreen && (pScreenInfo->dwBPP != WIN_DEFAULT_BPP))) {
+ /* Otherwise, We'll use GDI's depth */
+ pScreenInfo->dwBPP = dwBPP;
}
- /* Release our DC */
- ReleaseDC (NULL, hdc);
- return TRUE;
+ /* Release our DC */
+ ReleaseDC(NULL, hdc);
+ return TRUE;
}
-
/*
* Blt exposed regions to the screen
*/
static Bool
-winBltExposedRegionsShadowDD (ScreenPtr pScreen)
+winBltExposedRegionsShadowDD(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- RECT rcSrc, rcDest;
- POINT ptOrigin;
- HDC hdcUpdate = NULL;
- PAINTSTRUCT ps;
- HRESULT ddrval = DD_OK;
- Bool fReturn = TRUE;
- Bool fLocked = TRUE;
- int i;
-
- /* BeginPaint gives us an hdc that clips to the invalidated region */
- hdcUpdate = BeginPaint (pScreenPriv->hwndScreen, &ps);
- if (hdcUpdate == NULL)
- {
- ErrorF ("winBltExposedRegionsShadowDD - BeginPaint () returned "
- "a NULL device context handle. Aborting blit attempt.\n");
- return FALSE;
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ RECT rcSrc, rcDest;
+ POINT ptOrigin;
+ HDC hdcUpdate = NULL;
+ PAINTSTRUCT ps;
+ HRESULT ddrval = DD_OK;
+ Bool fReturn = TRUE;
+ Bool fLocked = TRUE;
+ int i;
+
+ /* BeginPaint gives us an hdc that clips to the invalidated region */
+ hdcUpdate = BeginPaint(pScreenPriv->hwndScreen, &ps);
+ if (hdcUpdate == NULL) {
+ ErrorF("winBltExposedRegionsShadowDD - BeginPaint () returned "
+ "a NULL device context handle. Aborting blit attempt.\n");
+ return FALSE;
}
-
- /* Unlock the shadow surface, so we can blit */
- ddrval = IDirectDrawSurface2_Unlock (pScreenPriv->pddsShadow, NULL);
- if (FAILED (ddrval))
- {
- fReturn = FALSE;
- goto winBltExposedRegionsShadowDD_Exit;
+
+ /* Unlock the shadow surface, so we can blit */
+ ddrval = IDirectDrawSurface2_Unlock(pScreenPriv->pddsShadow, NULL);
+ if (FAILED(ddrval)) {
+ fReturn = FALSE;
+ goto winBltExposedRegionsShadowDD_Exit;
}
- else
- {
- /* Flag that we have unlocked the shadow surface */
- fLocked = FALSE;
+ else {
+ /* Flag that we have unlocked the shadow surface */
+ fLocked = FALSE;
}
- /* Get the origin of the window in the screen coords */
- ptOrigin.x = pScreenInfo->dwXOffset;
- ptOrigin.y = pScreenInfo->dwYOffset;
-
- MapWindowPoints (pScreenPriv->hwndScreen,
- HWND_DESKTOP,
- (LPPOINT)&ptOrigin, 1);
- rcDest.left = ptOrigin.x;
- rcDest.right = ptOrigin.x + pScreenInfo->dwWidth;
- rcDest.top = ptOrigin.y;
- rcDest.bottom = ptOrigin.y + pScreenInfo->dwHeight;
-
- /* Source can be enter shadow surface, as Blt should clip */
- rcSrc.left = 0;
- rcSrc.top = 0;
- rcSrc.right = pScreenInfo->dwWidth;
- rcSrc.bottom = pScreenInfo->dwHeight;
-
- /* Try to regain the primary surface and blit again if we've lost it */
- for (i = 0; i <= WIN_REGAIN_SURFACE_RETRIES; ++i)
- {
- /* Our Blt should be clipped to the invalidated region */
- ddrval = IDirectDrawSurface2_Blt (pScreenPriv->pddsPrimary,
- &rcDest,
- pScreenPriv->pddsShadow,
- &rcSrc,
- DDBLT_WAIT,
- NULL);
- if (ddrval == DDERR_SURFACELOST)
- {
- /* Surface was lost */
- ErrorF ("winBltExposedRegionsShadowDD - IDirectDrawSurface2_Blt "
- "reported that the primary surface was lost, "
- "trying to restore, retry: %d\n", i + 1);
-
- /* Try to restore the surface, once */
- ddrval = IDirectDrawSurface2_Restore (pScreenPriv->pddsPrimary);
- ErrorF ("winBltExposedRegionsShadowDD - "
- "IDirectDrawSurface2_Restore returned: ");
- if (ddrval == DD_OK)
- ErrorF ("DD_OK\n");
- else if (ddrval == DDERR_WRONGMODE)
- ErrorF ("DDERR_WRONGMODE\n");
- else if (ddrval == DDERR_INCOMPATIBLEPRIMARY)
- ErrorF ("DDERR_INCOMPATIBLEPRIMARY\n");
- else if (ddrval == DDERR_UNSUPPORTED)
- ErrorF ("DDERR_UNSUPPORTED\n");
- else if (ddrval == DDERR_INVALIDPARAMS)
- ErrorF ("DDERR_INVALIDPARAMS\n");
- else if (ddrval == DDERR_INVALIDOBJECT)
- ErrorF ("DDERR_INVALIDOBJECT\n");
- else
- ErrorF ("unknown error: %08x\n", (unsigned int) ddrval);
-
- /* Loop around to try the blit one more time */
- continue;
- }
- else if (FAILED (ddrval))
- {
- fReturn = FALSE;
- ErrorF ("winBltExposedRegionsShadowDD - IDirectDrawSurface2_Blt "
- "failed, but surface not lost: %08x %d\n",
- (unsigned int) ddrval, (int) ddrval);
- goto winBltExposedRegionsShadowDD_Exit;
- }
- else
- {
- /* Success, stop looping */
- break;
- }
+ /* Get the origin of the window in the screen coords */
+ ptOrigin.x = pScreenInfo->dwXOffset;
+ ptOrigin.y = pScreenInfo->dwYOffset;
+
+ MapWindowPoints(pScreenPriv->hwndScreen,
+ HWND_DESKTOP, (LPPOINT) & ptOrigin, 1);
+ rcDest.left = ptOrigin.x;
+ rcDest.right = ptOrigin.x + pScreenInfo->dwWidth;
+ rcDest.top = ptOrigin.y;
+ rcDest.bottom = ptOrigin.y + pScreenInfo->dwHeight;
+
+ /* Source can be enter shadow surface, as Blt should clip */
+ rcSrc.left = 0;
+ rcSrc.top = 0;
+ rcSrc.right = pScreenInfo->dwWidth;
+ rcSrc.bottom = pScreenInfo->dwHeight;
+
+ /* Try to regain the primary surface and blit again if we've lost it */
+ for (i = 0; i <= WIN_REGAIN_SURFACE_RETRIES; ++i) {
+ /* Our Blt should be clipped to the invalidated region */
+ ddrval = IDirectDrawSurface2_Blt(pScreenPriv->pddsPrimary,
+ &rcDest,
+ pScreenPriv->pddsShadow,
+ &rcSrc, DDBLT_WAIT, NULL);
+ if (ddrval == DDERR_SURFACELOST) {
+ /* Surface was lost */
+ ErrorF("winBltExposedRegionsShadowDD - IDirectDrawSurface2_Blt "
+ "reported that the primary surface was lost, "
+ "trying to restore, retry: %d\n", i + 1);
+
+ /* Try to restore the surface, once */
+ ddrval = IDirectDrawSurface2_Restore(pScreenPriv->pddsPrimary);
+ ErrorF("winBltExposedRegionsShadowDD - "
+ "IDirectDrawSurface2_Restore returned: ");
+ if (ddrval == DD_OK)
+ ErrorF("DD_OK\n");
+ else if (ddrval == DDERR_WRONGMODE)
+ ErrorF("DDERR_WRONGMODE\n");
+ else if (ddrval == DDERR_INCOMPATIBLEPRIMARY)
+ ErrorF("DDERR_INCOMPATIBLEPRIMARY\n");
+ else if (ddrval == DDERR_UNSUPPORTED)
+ ErrorF("DDERR_UNSUPPORTED\n");
+ else if (ddrval == DDERR_INVALIDPARAMS)
+ ErrorF("DDERR_INVALIDPARAMS\n");
+ else if (ddrval == DDERR_INVALIDOBJECT)
+ ErrorF("DDERR_INVALIDOBJECT\n");
+ else
+ ErrorF("unknown error: %08x\n", (unsigned int) ddrval);
+
+ /* Loop around to try the blit one more time */
+ continue;
+ }
+ else if (FAILED(ddrval)) {
+ fReturn = FALSE;
+ ErrorF("winBltExposedRegionsShadowDD - IDirectDrawSurface2_Blt "
+ "failed, but surface not lost: %08x %d\n",
+ (unsigned int) ddrval, (int) ddrval);
+ goto winBltExposedRegionsShadowDD_Exit;
+ }
+ else {
+ /* Success, stop looping */
+ break;
+ }
}
- /* Relock the shadow surface */
- ddrval = IDirectDrawSurface2_Lock (pScreenPriv->pddsShadow,
- NULL,
- pScreenPriv->pddsdShadow,
- DDLOCK_WAIT,
- NULL);
- if (FAILED (ddrval))
- {
- fReturn = FALSE;
- ErrorF ("winBltExposedRegionsShadowDD - IDirectDrawSurface2_Lock "
- "failed\n");
- goto winBltExposedRegionsShadowDD_Exit;
+ /* Relock the shadow surface */
+ ddrval = IDirectDrawSurface2_Lock(pScreenPriv->pddsShadow,
+ NULL,
+ pScreenPriv->pddsdShadow,
+ DDLOCK_WAIT, NULL);
+ if (FAILED(ddrval)) {
+ fReturn = FALSE;
+ ErrorF("winBltExposedRegionsShadowDD - IDirectDrawSurface2_Lock "
+ "failed\n");
+ goto winBltExposedRegionsShadowDD_Exit;
}
- else
- {
- /* Indicate that we have relocked the shadow surface */
- fLocked = TRUE;
+ else {
+ /* Indicate that we have relocked the shadow surface */
+ fLocked = TRUE;
}
- /* Has our memory pointer changed? */
- if (pScreenInfo->pfb != pScreenPriv->pddsdShadow->lpSurface)
- winUpdateFBPointer (pScreen,
- pScreenPriv->pddsdShadow->lpSurface);
+ /* Has our memory pointer changed? */
+ if (pScreenInfo->pfb != pScreenPriv->pddsdShadow->lpSurface)
+ winUpdateFBPointer(pScreen, pScreenPriv->pddsdShadow->lpSurface);
winBltExposedRegionsShadowDD_Exit:
- /* EndPaint frees the DC */
- if (hdcUpdate != NULL)
- EndPaint (pScreenPriv->hwndScreen, &ps);
-
- /*
- * Relock the surface if it is not locked. We don't care if locking fails,
- * as it will cause the server to shutdown within a few more operations.
- */
- if (!fLocked)
- {
- IDirectDrawSurface2_Lock (pScreenPriv->pddsShadow,
- NULL,
- pScreenPriv->pddsdShadow,
- DDLOCK_WAIT,
- NULL);
-
- /* Has our memory pointer changed? */
- if (pScreenInfo->pfb != pScreenPriv->pddsdShadow->lpSurface)
- winUpdateFBPointer (pScreen,
- pScreenPriv->pddsdShadow->lpSurface);
-
- fLocked = TRUE;
+ /* EndPaint frees the DC */
+ if (hdcUpdate != NULL)
+ EndPaint(pScreenPriv->hwndScreen, &ps);
+
+ /*
+ * Relock the surface if it is not locked. We don't care if locking fails,
+ * as it will cause the server to shutdown within a few more operations.
+ */
+ if (!fLocked) {
+ IDirectDrawSurface2_Lock(pScreenPriv->pddsShadow,
+ NULL,
+ pScreenPriv->pddsdShadow, DDLOCK_WAIT, NULL);
+
+ /* Has our memory pointer changed? */
+ if (pScreenInfo->pfb != pScreenPriv->pddsdShadow->lpSurface)
+ winUpdateFBPointer(pScreen, pScreenPriv->pddsdShadow->lpSurface);
+
+ fLocked = TRUE;
}
- return fReturn;
+ return fReturn;
}
-
/*
* Do any engine-specific appliation-activation processing
*/
static Bool
-winActivateAppShadowDD (ScreenPtr pScreen)
+winActivateAppShadowDD(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
-
- /*
- * Do we have a surface?
- * Are we active?
- * Are we fullscreen?
- */
- if (pScreenPriv != NULL
- && pScreenPriv->pddsPrimary != NULL
- && pScreenPriv->fActive)
- {
- /* Primary surface was lost, restore it */
- IDirectDrawSurface2_Restore (pScreenPriv->pddsPrimary);
+ winScreenPriv(pScreen);
+
+ /*
+ * Do we have a surface?
+ * Are we active?
+ * Are we fullscreen?
+ */
+ if (pScreenPriv != NULL
+ && pScreenPriv->pddsPrimary != NULL && pScreenPriv->fActive) {
+ /* Primary surface was lost, restore it */
+ IDirectDrawSurface2_Restore(pScreenPriv->pddsPrimary);
}
- return TRUE;
+ return TRUE;
}
-
/*
* Reblit the shadow framebuffer to the screen.
*/
static Bool
-winRedrawScreenShadowDD (ScreenPtr pScreen)
+winRedrawScreenShadowDD(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- HRESULT ddrval = DD_OK;
- RECT rcSrc, rcDest;
- POINT ptOrigin;
-
- /* Get the origin of the window in the screen coords */
- ptOrigin.x = pScreenInfo->dwXOffset;
- ptOrigin.y = pScreenInfo->dwYOffset;
- MapWindowPoints (pScreenPriv->hwndScreen,
- HWND_DESKTOP,
- (LPPOINT)&ptOrigin, 1);
- rcDest.left = ptOrigin.x;
- rcDest.right = ptOrigin.x + pScreenInfo->dwWidth;
- rcDest.top = ptOrigin.y;
- rcDest.bottom = ptOrigin.y + pScreenInfo->dwHeight;
-
- /* Source can be entire shadow surface, as Blt should clip for us */
- rcSrc.left = 0;
- rcSrc.top = 0;
- rcSrc.right = pScreenInfo->dwWidth;
- rcSrc.bottom = pScreenInfo->dwHeight;
-
- /* Redraw the whole window, to take account for the new colors */
- ddrval = IDirectDrawSurface2_Blt (pScreenPriv->pddsPrimary,
- &rcDest,
- pScreenPriv->pddsShadow,
- &rcSrc,
- DDBLT_WAIT,
- NULL);
- if (FAILED (ddrval))
- {
- ErrorF ("winRedrawScreenShadowDD - IDirectDrawSurface_Blt () "
- "failed: %08x\n",
- (unsigned int) ddrval);
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ HRESULT ddrval = DD_OK;
+ RECT rcSrc, rcDest;
+ POINT ptOrigin;
+
+ /* Get the origin of the window in the screen coords */
+ ptOrigin.x = pScreenInfo->dwXOffset;
+ ptOrigin.y = pScreenInfo->dwYOffset;
+ MapWindowPoints(pScreenPriv->hwndScreen,
+ HWND_DESKTOP, (LPPOINT) & ptOrigin, 1);
+ rcDest.left = ptOrigin.x;
+ rcDest.right = ptOrigin.x + pScreenInfo->dwWidth;
+ rcDest.top = ptOrigin.y;
+ rcDest.bottom = ptOrigin.y + pScreenInfo->dwHeight;
+
+ /* Source can be entire shadow surface, as Blt should clip for us */
+ rcSrc.left = 0;
+ rcSrc.top = 0;
+ rcSrc.right = pScreenInfo->dwWidth;
+ rcSrc.bottom = pScreenInfo->dwHeight;
+
+ /* Redraw the whole window, to take account for the new colors */
+ ddrval = IDirectDrawSurface2_Blt(pScreenPriv->pddsPrimary,
+ &rcDest,
+ pScreenPriv->pddsShadow,
+ &rcSrc, DDBLT_WAIT, NULL);
+ if (FAILED(ddrval)) {
+ ErrorF("winRedrawScreenShadowDD - IDirectDrawSurface_Blt () "
+ "failed: %08x\n", (unsigned int) ddrval);
}
- return TRUE;
+ return TRUE;
}
-
/*
* Realize the currently installed colormap
*/
static Bool
-winRealizeInstalledPaletteShadowDD (ScreenPtr pScreen)
+winRealizeInstalledPaletteShadowDD(ScreenPtr pScreen)
{
- return TRUE;
+ return TRUE;
}
-
/*
* Install the specified colormap
*/
static Bool
-winInstallColormapShadowDD (ColormapPtr pColormap)
+winInstallColormapShadowDD(ColormapPtr pColormap)
{
- ScreenPtr pScreen = pColormap->pScreen;
- winScreenPriv(pScreen);
- winCmapPriv(pColormap);
- HRESULT ddrval = DD_OK;
-
- /* Install the DirectDraw palette on the primary surface */
- ddrval = IDirectDrawSurface2_SetPalette (pScreenPriv->pddsPrimary,
- pCmapPriv->lpDDPalette);
- if (FAILED (ddrval))
- {
- ErrorF ("winInstallColormapShadowDD - Failed installing the "
- "DirectDraw palette.\n");
- return FALSE;
+ ScreenPtr pScreen = pColormap->pScreen;
+
+ winScreenPriv(pScreen);
+ winCmapPriv(pColormap);
+ HRESULT ddrval = DD_OK;
+
+ /* Install the DirectDraw palette on the primary surface */
+ ddrval = IDirectDrawSurface2_SetPalette(pScreenPriv->pddsPrimary,
+ pCmapPriv->lpDDPalette);
+ if (FAILED(ddrval)) {
+ ErrorF("winInstallColormapShadowDD - Failed installing the "
+ "DirectDraw palette.\n");
+ return FALSE;
}
- /* Save a pointer to the newly installed colormap */
- pScreenPriv->pcmapInstalled = pColormap;
+ /* Save a pointer to the newly installed colormap */
+ pScreenPriv->pcmapInstalled = pColormap;
- return TRUE;
+ return TRUE;
}
-
/*
* Store the specified colors in the specified colormap
*/
static Bool
-winStoreColorsShadowDD (ColormapPtr pColormap,
- int ndef,
- xColorItem *pdefs)
+winStoreColorsShadowDD(ColormapPtr pColormap, int ndef, xColorItem * pdefs)
{
- ScreenPtr pScreen = pColormap->pScreen;
- winScreenPriv(pScreen);
- winCmapPriv(pColormap);
- ColormapPtr curpmap = pScreenPriv->pcmapInstalled;
- HRESULT ddrval = DD_OK;
-
- /* Put the X colormap entries into the Windows logical palette */
- ddrval = IDirectDrawPalette_SetEntries (pCmapPriv->lpDDPalette,
- 0,
- pdefs[0].pixel,
- ndef,
- pCmapPriv->peColors
- + pdefs[0].pixel);
- if (FAILED (ddrval))
- {
- ErrorF ("winStoreColorsShadowDD - SetEntries () failed\n");
- return FALSE;
+ ScreenPtr pScreen = pColormap->pScreen;
+
+ winScreenPriv(pScreen);
+ winCmapPriv(pColormap);
+ ColormapPtr curpmap = pScreenPriv->pcmapInstalled;
+ HRESULT ddrval = DD_OK;
+
+ /* Put the X colormap entries into the Windows logical palette */
+ ddrval = IDirectDrawPalette_SetEntries(pCmapPriv->lpDDPalette,
+ 0,
+ pdefs[0].pixel,
+ ndef,
+ pCmapPriv->peColors
+ + pdefs[0].pixel);
+ if (FAILED(ddrval)) {
+ ErrorF("winStoreColorsShadowDD - SetEntries () failed\n");
+ return FALSE;
}
- /* Don't install the DirectDraw palette if the colormap is not installed */
- if (pColormap != curpmap)
- {
- return TRUE;
+ /* Don't install the DirectDraw palette if the colormap is not installed */
+ if (pColormap != curpmap) {
+ return TRUE;
}
- if (!winInstallColormapShadowDD (pColormap))
- {
- ErrorF ("winStoreColorsShadowDD - Failed installing colormap\n");
- return FALSE;
+ if (!winInstallColormapShadowDD(pColormap)) {
+ ErrorF("winStoreColorsShadowDD - Failed installing colormap\n");
+ return FALSE;
}
- return TRUE;
+ return TRUE;
}
-
/*
* Colormap initialization procedure
*/
static Bool
-winCreateColormapShadowDD (ColormapPtr pColormap)
+winCreateColormapShadowDD(ColormapPtr pColormap)
{
- HRESULT ddrval = DD_OK;
- ScreenPtr pScreen = pColormap->pScreen;
- winScreenPriv(pScreen);
- winCmapPriv(pColormap);
-
- /* Create a DirectDraw palette */
- ddrval = IDirectDraw2_CreatePalette (pScreenPriv->pdd,
- DDPCAPS_8BIT | DDPCAPS_ALLOW256,
- pCmapPriv->peColors,
- &pCmapPriv->lpDDPalette,
- NULL);
- if (FAILED (ddrval))
- {
- ErrorF ("winCreateColormapShadowDD - CreatePalette failed\n");
- return FALSE;
+ HRESULT ddrval = DD_OK;
+ ScreenPtr pScreen = pColormap->pScreen;
+
+ winScreenPriv(pScreen);
+ winCmapPriv(pColormap);
+
+ /* Create a DirectDraw palette */
+ ddrval = IDirectDraw2_CreatePalette(pScreenPriv->pdd,
+ DDPCAPS_8BIT | DDPCAPS_ALLOW256,
+ pCmapPriv->peColors,
+ &pCmapPriv->lpDDPalette, NULL);
+ if (FAILED(ddrval)) {
+ ErrorF("winCreateColormapShadowDD - CreatePalette failed\n");
+ return FALSE;
}
- return TRUE;
+ return TRUE;
}
-
/*
* Colormap destruction procedure
*/
static Bool
-winDestroyColormapShadowDD (ColormapPtr pColormap)
+winDestroyColormapShadowDD(ColormapPtr pColormap)
{
- winScreenPriv(pColormap->pScreen);
- winCmapPriv(pColormap);
- HRESULT ddrval = DD_OK;
-
- /*
- * Is colormap to be destroyed the default?
- *
- * Non-default colormaps should have had winUninstallColormap
- * called on them before we get here. The default colormap
- * will not have had winUninstallColormap called on it. Thus,
- * we need to handle the default colormap in a special way.
- */
- if (pColormap->flags & IsDefault)
- {
- winDebug ("winDestroyColormapShadowDD - Destroying default "
- "colormap\n");
-
- /*
- * FIXME: Walk the list of all screens, popping the default
- * palette out of each screen device context.
- */
-
- /* Pop the palette out of the primary surface */
- ddrval = IDirectDrawSurface2_SetPalette (pScreenPriv->pddsPrimary,
- NULL);
- if (FAILED (ddrval))
- {
- ErrorF ("winDestroyColormapShadowDD - Failed freeing the "
- "default colormap DirectDraw palette.\n");
- return FALSE;
- }
-
- /* Clear our private installed colormap pointer */
- pScreenPriv->pcmapInstalled = NULL;
+ winScreenPriv(pColormap->pScreen);
+ winCmapPriv(pColormap);
+ HRESULT ddrval = DD_OK;
+
+ /*
+ * Is colormap to be destroyed the default?
+ *
+ * Non-default colormaps should have had winUninstallColormap
+ * called on them before we get here. The default colormap
+ * will not have had winUninstallColormap called on it. Thus,
+ * we need to handle the default colormap in a special way.
+ */
+ if (pColormap->flags & IsDefault) {
+ winDebug("winDestroyColormapShadowDD - Destroying default "
+ "colormap\n");
+
+ /*
+ * FIXME: Walk the list of all screens, popping the default
+ * palette out of each screen device context.
+ */
+
+ /* Pop the palette out of the primary surface */
+ ddrval = IDirectDrawSurface2_SetPalette(pScreenPriv->pddsPrimary, NULL);
+ if (FAILED(ddrval)) {
+ ErrorF("winDestroyColormapShadowDD - Failed freeing the "
+ "default colormap DirectDraw palette.\n");
+ return FALSE;
+ }
+
+ /* Clear our private installed colormap pointer */
+ pScreenPriv->pcmapInstalled = NULL;
}
-
- /* Release the palette */
- IDirectDrawPalette_Release (pCmapPriv->lpDDPalette);
-
- /* Invalidate the colormap privates */
- pCmapPriv->lpDDPalette = NULL;
-
- return TRUE;
-}
+ /* Release the palette */
+ IDirectDrawPalette_Release(pCmapPriv->lpDDPalette);
+
+ /* Invalidate the colormap privates */
+ pCmapPriv->lpDDPalette = NULL;
+
+ return TRUE;
+}
/*
* Set engine specific functions
*/
Bool
-winSetEngineFunctionsShadowDD (ScreenPtr pScreen)
+winSetEngineFunctionsShadowDD(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-
- /* Set our pointers */
- pScreenPriv->pwinAllocateFB = winAllocateFBShadowDD;
- pScreenPriv->pwinFreeFB = winFreeFBShadowDD;
- pScreenPriv->pwinShadowUpdate = winShadowUpdateDD;
- pScreenPriv->pwinInitScreen = winInitScreenShadowDD;
- pScreenPriv->pwinCloseScreen = winCloseScreenShadowDD;
- pScreenPriv->pwinInitVisuals = winInitVisualsShadowDD;
- pScreenPriv->pwinAdjustVideoMode = winAdjustVideoModeShadowDD;
- if (pScreenInfo->fFullScreen)
- pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowFullScreen;
- else
- pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowWindowed;
- pScreenPriv->pwinFinishScreenInit = winFinishScreenInitFB;
- pScreenPriv->pwinBltExposedRegions = winBltExposedRegionsShadowDD;
- pScreenPriv->pwinActivateApp = winActivateAppShadowDD;
- pScreenPriv->pwinRedrawScreen = winRedrawScreenShadowDD;
- pScreenPriv->pwinRealizeInstalledPalette
- = winRealizeInstalledPaletteShadowDD;
- pScreenPriv->pwinInstallColormap = winInstallColormapShadowDD;
- pScreenPriv->pwinStoreColors = winStoreColorsShadowDD;
- pScreenPriv->pwinCreateColormap = winCreateColormapShadowDD;
- pScreenPriv->pwinDestroyColormap = winDestroyColormapShadowDD;
- pScreenPriv->pwinHotKeyAltTab = (winHotKeyAltTabProcPtr) (void (*)(void))NoopDDA;
- pScreenPriv->pwinCreatePrimarySurface = winCreatePrimarySurfaceShadowDD;
- pScreenPriv->pwinReleasePrimarySurface = winReleasePrimarySurfaceShadowDD;
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /* Set our pointers */
+ pScreenPriv->pwinAllocateFB = winAllocateFBShadowDD;
+ pScreenPriv->pwinFreeFB = winFreeFBShadowDD;
+ pScreenPriv->pwinShadowUpdate = winShadowUpdateDD;
+ pScreenPriv->pwinInitScreen = winInitScreenShadowDD;
+ pScreenPriv->pwinCloseScreen = winCloseScreenShadowDD;
+ pScreenPriv->pwinInitVisuals = winInitVisualsShadowDD;
+ pScreenPriv->pwinAdjustVideoMode = winAdjustVideoModeShadowDD;
+ if (pScreenInfo->fFullScreen)
+ pScreenPriv->pwinCreateBoundingWindow =
+ winCreateBoundingWindowFullScreen;
+ else
+ pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowWindowed;
+ pScreenPriv->pwinFinishScreenInit = winFinishScreenInitFB;
+ pScreenPriv->pwinBltExposedRegions = winBltExposedRegionsShadowDD;
+ pScreenPriv->pwinActivateApp = winActivateAppShadowDD;
+ pScreenPriv->pwinRedrawScreen = winRedrawScreenShadowDD;
+ pScreenPriv->pwinRealizeInstalledPalette
+ = winRealizeInstalledPaletteShadowDD;
+ pScreenPriv->pwinInstallColormap = winInstallColormapShadowDD;
+ pScreenPriv->pwinStoreColors = winStoreColorsShadowDD;
+ pScreenPriv->pwinCreateColormap = winCreateColormapShadowDD;
+ pScreenPriv->pwinDestroyColormap = winDestroyColormapShadowDD;
+ pScreenPriv->pwinHotKeyAltTab =
+ (winHotKeyAltTabProcPtr) (void (*)(void)) NoopDDA;
+ pScreenPriv->pwinCreatePrimarySurface = winCreatePrimarySurfaceShadowDD;
+ pScreenPriv->pwinReleasePrimarySurface = winReleasePrimarySurfaceShadowDD;
#ifdef XWIN_MULTIWINDOW
- pScreenPriv->pwinFinishCreateWindowsWindow =
- (winFinishCreateWindowsWindowProcPtr) (void (*)(void))NoopDDA;
+ pScreenPriv->pwinFinishCreateWindowsWindow =
+ (winFinishCreateWindowsWindowProcPtr) (void (*)(void)) NoopDDA;
#endif
- return TRUE;
+ return TRUE;
}
diff --git a/xorg-server/hw/xwin/winshadddnl.c b/xorg-server/hw/xwin/winshadddnl.c
index 2f7e34243..17fe23e5a 100644
--- a/xorg-server/hw/xwin/winshadddnl.c
+++ b/xorg-server/hw/xwin/winshadddnl.c
@@ -36,7 +36,6 @@
#endif
#include "win.h"
-
/*
* FIXME: Headers are broken, DEFINE_GUID doesn't work correctly,
* so we have to redefine it here.
@@ -45,7 +44,7 @@
#ifdef DEFINE_GUID
#undef DEFINE_GUID
#define DEFINE_GUID(n,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) const GUID n GUID_SECT = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}}
-#endif /* DEFINE_GUID */
+#endif /* DEFINE_GUID */
#endif
/*
@@ -53,63 +52,60 @@
* here manually. Should be handled by ddraw.h
*/
#ifndef IID_IDirectDraw4
-DEFINE_GUID( IID_IDirectDraw4, 0x9c59509a,0x39bd,0x11d1,0x8c,0x4a,0x00,0xc0,0x4f,0xd9,0x30,0xc5 );
-#endif /* IID_IDirectDraw4 */
+DEFINE_GUID(IID_IDirectDraw4, 0x9c59509a, 0x39bd, 0x11d1, 0x8c, 0x4a, 0x00,
+ 0xc0, 0x4f, 0xd9, 0x30, 0xc5);
+#endif /* IID_IDirectDraw4 */
#define FAIL_MSG_MAX_BLT 10
-
/*
* Local prototypes
*/
static Bool
-winAllocateFBShadowDDNL (ScreenPtr pScreen);
+ winAllocateFBShadowDDNL(ScreenPtr pScreen);
static void
-winShadowUpdateDDNL (ScreenPtr pScreen,
- shadowBufPtr pBuf);
+ winShadowUpdateDDNL(ScreenPtr pScreen, shadowBufPtr pBuf);
static Bool
-winCloseScreenShadowDDNL (int nIndex, ScreenPtr pScreen);
+ winCloseScreenShadowDDNL(int nIndex, ScreenPtr pScreen);
static Bool
-winInitVisualsShadowDDNL (ScreenPtr pScreen);
+ winInitVisualsShadowDDNL(ScreenPtr pScreen);
static Bool
-winAdjustVideoModeShadowDDNL (ScreenPtr pScreen);
+ winAdjustVideoModeShadowDDNL(ScreenPtr pScreen);
static Bool
-winBltExposedRegionsShadowDDNL (ScreenPtr pScreen);
+ winBltExposedRegionsShadowDDNL(ScreenPtr pScreen);
static Bool
-winActivateAppShadowDDNL (ScreenPtr pScreen);
+ winActivateAppShadowDDNL(ScreenPtr pScreen);
static Bool
-winRedrawScreenShadowDDNL (ScreenPtr pScreen);
+ winRedrawScreenShadowDDNL(ScreenPtr pScreen);
static Bool
-winRealizeInstalledPaletteShadowDDNL (ScreenPtr pScreen);
+ winRealizeInstalledPaletteShadowDDNL(ScreenPtr pScreen);
static Bool
-winInstallColormapShadowDDNL (ColormapPtr pColormap);
+ winInstallColormapShadowDDNL(ColormapPtr pColormap);
static Bool
-winStoreColorsShadowDDNL (ColormapPtr pmap,
- int ndef,
- xColorItem *pdefs);
+ winStoreColorsShadowDDNL(ColormapPtr pmap, int ndef, xColorItem * pdefs);
static Bool
-winCreateColormapShadowDDNL (ColormapPtr pColormap);
+ winCreateColormapShadowDDNL(ColormapPtr pColormap);
static Bool
-winDestroyColormapShadowDDNL (ColormapPtr pColormap);
+ winDestroyColormapShadowDDNL(ColormapPtr pColormap);
static Bool
-winCreatePrimarySurfaceShadowDDNL (ScreenPtr pScreen);
+ winCreatePrimarySurfaceShadowDDNL(ScreenPtr pScreen);
static Bool
-winReleasePrimarySurfaceShadowDDNL (ScreenPtr pScreen);
+ winReleasePrimarySurfaceShadowDDNL(ScreenPtr pScreen);
static HRESULT myIDirectDrawSurface4_Blt( ScreenPtr pScreen, RECT *pRect, RECT *prcSrc)
{
@@ -170,7 +166,6 @@ static HRESULT myIDirectDrawSurface4_Blt( ScreenPtr pScreen, RECT *pRect, RECT *
return ddrval;
}
-
/*
* Create the primary surface and attach the clipper.
* Used for both the initial surface creation and during
@@ -178,80 +173,72 @@ static HRESULT myIDirectDrawSurface4_Blt( ScreenPtr pScreen, RECT *pRect, RECT *
*/
static Bool
-winCreatePrimarySurfaceShadowDDNL (ScreenPtr pScreen)
+winCreatePrimarySurfaceShadowDDNL(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- HRESULT ddrval = DD_OK;
- DDSURFACEDESC2 ddsd;
-
- winDebug ("winCreatePrimarySurfaceShadowDDNL - Creating primary surface\n");
-
- /* Describe the primary surface */
- ZeroMemory (&ddsd, sizeof (ddsd));
- ddsd.dwSize = sizeof (ddsd);
- ddsd.dwFlags = DDSD_CAPS;
- ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
-
- /* Create the primary surface */
- ddrval = IDirectDraw4_CreateSurface (pScreenPriv->pdd4,
- &ddsd,
- &pScreenPriv->pddsPrimary4,
- NULL);
- pScreenPriv->fRetryCreateSurface = FALSE;
- if (FAILED (ddrval))
- {
- if (ddrval == DDERR_NOEXCLUSIVEMODE)
- {
- /* Recreating the surface failed. Mark screen to retry later */
- pScreenPriv->fRetryCreateSurface = TRUE;
- winDebug ("winCreatePrimarySurfaceShadowDDNL - Could not create "
- "primary surface: DDERR_NOEXCLUSIVEMODE\n");
+ winScreenPriv(pScreen);
+ HRESULT ddrval = DD_OK;
+ DDSURFACEDESC2 ddsd;
+
+ winDebug("winCreatePrimarySurfaceShadowDDNL - Creating primary surface\n");
+
+ /* Describe the primary surface */
+ ZeroMemory(&ddsd, sizeof(ddsd));
+ ddsd.dwSize = sizeof(ddsd);
+ ddsd.dwFlags = DDSD_CAPS;
+ ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
+
+ /* Create the primary surface */
+ ddrval = IDirectDraw4_CreateSurface(pScreenPriv->pdd4,
+ &ddsd,
+ &pScreenPriv->pddsPrimary4, NULL);
+ pScreenPriv->fRetryCreateSurface = FALSE;
+ if (FAILED(ddrval)) {
+ if (ddrval == DDERR_NOEXCLUSIVEMODE) {
+ /* Recreating the surface failed. Mark screen to retry later */
+ pScreenPriv->fRetryCreateSurface = TRUE;
+ winDebug("winCreatePrimarySurfaceShadowDDNL - Could not create "
+ "primary surface: DDERR_NOEXCLUSIVEMODE\n");
}
- else
- {
- ErrorF ("winCreatePrimarySurfaceShadowDDNL - Could not create "
- "primary surface: %08x\n", (unsigned int) ddrval);
+ else {
+ ErrorF("winCreatePrimarySurfaceShadowDDNL - Could not create "
+ "primary surface: %08x\n", (unsigned int) ddrval);
}
- return FALSE;
+ return FALSE;
}
-
- winDebug ("winCreatePrimarySurfaceShadowDDNL - Created primary surface\n");
- /* Attach our clipper to our primary surface handle */
- ddrval = IDirectDrawSurface4_SetClipper (pScreenPriv->pddsPrimary4,
- pScreenPriv->pddcPrimary);
- if (FAILED (ddrval))
- {
- ErrorF ("winCreatePrimarySurfaceShadowDDNL - Primary attach clipper "
- "failed: %08x\n",
- (unsigned int) ddrval);
- return FALSE;
+ winDebug("winCreatePrimarySurfaceShadowDDNL - Created primary surface\n");
+
+ /* Attach our clipper to our primary surface handle */
+ ddrval = IDirectDrawSurface4_SetClipper(pScreenPriv->pddsPrimary4,
+ pScreenPriv->pddcPrimary);
+ if (FAILED(ddrval)) {
+ ErrorF("winCreatePrimarySurfaceShadowDDNL - Primary attach clipper "
+ "failed: %08x\n", (unsigned int) ddrval);
+ return FALSE;
}
- winDebug ("winCreatePrimarySurfaceShadowDDNL - Attached clipper to primary "
- "surface\n");
+ winDebug("winCreatePrimarySurfaceShadowDDNL - Attached clipper to primary "
+ "surface\n");
- /* Everything was correct */
- return TRUE;
+ /* Everything was correct */
+ return TRUE;
}
-
static void ClosePrimarySurfaceShadowDDNL (winPrivScreenPtr pScreenPriv)
{
- /* Release the primary surface and clipper, if they exist */
- if (pScreenPriv->pddsPrimary4)
- {
- /*
- * Detach the clipper from the primary surface.
- * NOTE: We do this explicity for clarity. The Clipper is not released.
- */
- IDirectDrawSurface4_SetClipper (pScreenPriv->pddsPrimary4, NULL);
-
- winDebug ("winReleasePrimarySurfaceShadowDDNL - Detached clipper\n");
-
- /* Release the primary surface */
- IDirectDrawSurface4_Release (pScreenPriv->pddsPrimary4);
- pScreenPriv->pddsPrimary4 = NULL;
+ /* Release the primary surface and clipper, if they exist */
+ if (pScreenPriv->pddsPrimary4) {
+ /*
+ * Detach the clipper from the primary surface.
+ * NOTE: We do this explicity for clarity. The Clipper is not released.
+ */
+ IDirectDrawSurface4_SetClipper (pScreenPriv->pddsPrimary4, NULL);
+
+ winDebug("winReleasePrimarySurfaceShadowDDNL - Detached clipper\n");
+
+ /* Release the primary surface */
+ IDirectDrawSurface4_Release(pScreenPriv->pddsPrimary4);
+ pScreenPriv->pddsPrimary4 = NULL;
}
}
@@ -295,11 +282,10 @@ winReleasePrimarySurfaceShadowDDNL (ScreenPtr pScreen)
ClosePrimarySurfaceShadowDDNL(pScreenPriv);
- winDebug ("winReleasePrimarySurfaceShadowDDNL - Released primary surface\n");
-
- return TRUE;
-}
+ winDebug("winReleasePrimarySurfaceShadowDDNL - Released primary surface\n");
+ return TRUE;
+}
/*
* Create a DirectDraw surface for the shadow framebuffer; also create
@@ -310,335 +296,304 @@ winReleasePrimarySurfaceShadowDDNL (ScreenPtr pScreen)
*/
Bool
-winAllocateFBShadowDDNL (ScreenPtr pScreen)
+winAllocateFBShadowDDNL(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- HRESULT ddrval = DD_OK;
- DDSURFACEDESC2 ddsdShadow;
- char *lpSurface = NULL;
- DDPIXELFORMAT ddpfPrimary;
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ HRESULT ddrval = DD_OK;
+ DDSURFACEDESC2 ddsdShadow;
+ char *lpSurface = NULL;
+ DDPIXELFORMAT ddpfPrimary;
- winDebug ("winAllocateFBShadowDDNL - w %d h %d d %d\n",
- pScreenInfo->dwWidth, pScreenInfo->dwHeight, pScreenInfo->dwDepth);
+ winDebug("winAllocateFBShadowDDNL - w %d h %d d %d\n",
+ pScreenInfo->dwWidth, pScreenInfo->dwHeight, pScreenInfo->dwDepth);
- /* Set the padded screen width */
- pScreenInfo->dwPaddedWidth = PixmapBytePad (pScreenInfo->dwWidth,
- pScreenInfo->dwBPP);
+ /* Set the padded screen width */
+ pScreenInfo->dwPaddedWidth = PixmapBytePad(pScreenInfo->dwWidth,
+ pScreenInfo->dwBPP);
- if ( pScreenInfo->pfb)
- {
- ErrorF("winAllocateFBShadowDDNL calling for the second time, reallocating\n");
- lpSurface=pScreenInfo->pfb;
+ if ( pScreenInfo->pfb)
+ {
+ ErrorF("winAllocateFBShadowDDNL calling for the second time, reallocating\n");
+ lpSurface=pScreenInfo->pfb;
- if (pScreenPriv->pddsShadow4)
+ if (pScreenPriv->pddsShadow4)
+ {
+ IDirectDrawSurface4_Release (pScreenPriv->pddsShadow4);
+ pScreenPriv->pddsShadow4 = NULL;
+ }
+ ClosePrimarySurfaceShadowDDNL(pScreenPriv);
+ ReleaseDDNL(pScreenPriv);
+ }
+ else
{
- IDirectDrawSurface4_Release (pScreenPriv->pddsShadow4);
- pScreenPriv->pddsShadow4 = NULL;
+ /* Allocate memory for our shadow surface */
+ lpSurface = malloc (pScreenInfo->dwPaddedWidth * pScreenInfo->dwHeight);
+ if (lpSurface == NULL) {
+ ErrorF ("winAllocateFBShadowDDNL - Could not allocate bits\n");
+ return FALSE;
+ }
+
+ /*
+ * Initialize the framebuffer memory so we don't get a
+ * strange display at startup
+ */
+ ZeroMemory (lpSurface, pScreenInfo->dwPaddedWidth * pScreenInfo->dwHeight);
}
- ClosePrimarySurfaceShadowDDNL(pScreenPriv);
- ReleaseDDNL(pScreenPriv);
- }
- else
- {
- /* Allocate memory for our shadow surface */
- lpSurface = malloc (pScreenInfo->dwPaddedWidth * pScreenInfo->dwHeight);
- if (lpSurface == NULL)
- {
- ErrorF ("winAllocateFBShadowDDNL - Could not allocate bits\n");
+ /* Create a clipper */
+ ddrval = (*g_fpDirectDrawCreateClipper) (0,
+ &pScreenPriv->pddcPrimary, NULL);
+ if (FAILED(ddrval)) {
+ ErrorF("winAllocateFBShadowDDNL - Could not attach clipper: %08x\n",
+ (unsigned int) ddrval);
return FALSE;
- }
-
- /*
- * Initialize the framebuffer memory so we don't get a
- * strange display at startup
- */
- ZeroMemory (lpSurface, pScreenInfo->dwPaddedWidth * pScreenInfo->dwHeight);
- }
- /* Create a clipper */
- ddrval = (*g_fpDirectDrawCreateClipper) (0,
- &pScreenPriv->pddcPrimary,
- NULL);
- if (FAILED (ddrval))
- {
- ErrorF ("winAllocateFBShadowDDNL - Could not attach clipper: %08x\n",
- (unsigned int) ddrval);
- return FALSE;
}
- winDebug ("winAllocateFBShadowDDNL - Created a clipper\n");
+ winDebug("winAllocateFBShadowDDNL - Created a clipper\n");
- /* Attach the clipper to our display window */
- ddrval = IDirectDrawClipper_SetHWnd (pScreenPriv->pddcPrimary,
- 0,
- pScreenPriv->hwndScreen);
- if (FAILED (ddrval))
- {
- ErrorF ("winAllocateFBShadowDDNL - Clipper not attached "
- "to window: %08x\n",
- (unsigned int) ddrval);
- return FALSE;
+ /* Attach the clipper to our display window */
+ ddrval = IDirectDrawClipper_SetHWnd(pScreenPriv->pddcPrimary,
+ 0, pScreenPriv->hwndScreen);
+ if (FAILED(ddrval)) {
+ ErrorF("winAllocateFBShadowDDNL - Clipper not attached "
+ "to window: %08x\n", (unsigned int) ddrval);
+ return FALSE;
}
- winDebug ("winAllocateFBShadowDDNL - Attached clipper to window\n");
+ winDebug("winAllocateFBShadowDDNL - Attached clipper to window\n");
- /* Create a DirectDraw object, store the address at lpdd */
- ddrval = (*g_fpDirectDrawCreate) (NULL,
- (LPDIRECTDRAW*) &pScreenPriv->pdd,
- NULL);
- if (FAILED (ddrval))
- {
- ErrorF ("winAllocateFBShadowDDNL - Could not start "
- "DirectDraw: %08x\n",
- (unsigned int) ddrval);
- return FALSE;
+ /* Create a DirectDraw object, store the address at lpdd */
+ ddrval = (*g_fpDirectDrawCreate) (NULL,
+ (LPDIRECTDRAW *) & pScreenPriv->pdd,
+ NULL);
+ if (FAILED(ddrval)) {
+ ErrorF("winAllocateFBShadowDDNL - Could not start "
+ "DirectDraw: %08x\n", (unsigned int) ddrval);
+ return FALSE;
}
- winDebug ("winAllocateFBShadowDDNL - Created and initialized DD\n");
+ winDebug("winAllocateFBShadowDDNL - Created and initialized DD\n");
- /* Get a DirectDraw4 interface pointer */
- ddrval = IDirectDraw_QueryInterface (pScreenPriv->pdd,
- &IID_IDirectDraw4,
- (LPVOID*) &pScreenPriv->pdd4);
- if (FAILED (ddrval))
- {
- ErrorF ("winAllocateFBShadowDDNL - Failed DD4 query: %08x\n",
- (unsigned int) ddrval);
- return FALSE;
+ /* Get a DirectDraw4 interface pointer */
+ ddrval = IDirectDraw_QueryInterface(pScreenPriv->pdd,
+ &IID_IDirectDraw4,
+ (LPVOID *) & pScreenPriv->pdd4);
+ if (FAILED(ddrval)) {
+ ErrorF("winAllocateFBShadowDDNL - Failed DD4 query: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
}
- /* Are we full screen? */
- if (pScreenInfo->fFullScreen)
- {
- DDSURFACEDESC2 ddsdCurrent;
- DWORD dwRefreshRateCurrent = 0;
- HDC hdc = NULL;
-
- /* Set the cooperative level to full screen */
- ddrval = IDirectDraw4_SetCooperativeLevel (pScreenPriv->pdd4,
- pScreenPriv->hwndScreen,
- DDSCL_EXCLUSIVE
- | DDSCL_FULLSCREEN);
- if (FAILED (ddrval))
- {
- ErrorF ("winAllocateFBShadowDDNL - Could not set "
- "cooperative level: %08x\n",
- (unsigned int) ddrval);
- return FALSE;
- }
-
- /*
- * We only need to get the current refresh rate for comparison
- * if a refresh rate has been passed on the command line.
- */
- if (pScreenInfo->dwRefreshRate != 0)
- {
- ZeroMemory (&ddsdCurrent, sizeof (ddsdCurrent));
- ddsdCurrent.dwSize = sizeof (ddsdCurrent);
-
- /* Get information about current display settings */
- ddrval = IDirectDraw4_GetDisplayMode (pScreenPriv->pdd4,
- &ddsdCurrent);
- if (FAILED (ddrval))
- {
- ErrorF ("winAllocateFBShadowDDNL - Could not get current "
- "refresh rate: %08x. Continuing.\n",
- (unsigned int) ddrval);
- dwRefreshRateCurrent = 0;
- }
- else
- {
- /* Grab the current refresh rate */
- dwRefreshRateCurrent = ddsdCurrent.u2.dwRefreshRate;
- }
- }
-
- /* Clean up the refresh rate */
- if (dwRefreshRateCurrent == pScreenInfo->dwRefreshRate)
- {
- /*
- * Refresh rate is non-specified or equal to current.
- */
- pScreenInfo->dwRefreshRate = 0;
- }
-
- /* Grab a device context for the screen */
- hdc = GetDC (NULL);
- if (hdc == NULL)
- {
- ErrorF ("winAllocateFBShadowDDNL - GetDC () failed\n");
- return FALSE;
- }
-
- /* Only change the video mode when different than current mode */
- if (!pScreenInfo->fMultipleMonitors
- && (pScreenInfo->dwWidth != GetSystemMetrics (SM_CXSCREEN)
- || pScreenInfo->dwHeight != GetSystemMetrics (SM_CYSCREEN)
- || pScreenInfo->dwBPP != GetDeviceCaps (hdc, BITSPIXEL)
- || pScreenInfo->dwRefreshRate != 0))
- {
- winDebug ("winAllocateFBShadowDDNL - Changing video mode\n");
-
- /* Change the video mode to the mode requested, and use the driver default refresh rate on failure */
- ddrval = IDirectDraw4_SetDisplayMode (pScreenPriv->pdd4,
- pScreenInfo->dwWidth,
- pScreenInfo->dwHeight,
- pScreenInfo->dwBPP,
- pScreenInfo->dwRefreshRate,
- 0);
- if (FAILED (ddrval))
- {
- ErrorF ("winAllocateFBShadowDDNL - Could not set "
- "full screen display mode: %08x\n",
- (unsigned int) ddrval);
- ErrorF ("winAllocateFBShadowDDNL - Using default driver refresh rate\n");
- ddrval = IDirectDraw4_SetDisplayMode (pScreenPriv->pdd4,
- pScreenInfo->dwWidth,
- pScreenInfo->dwHeight,
- pScreenInfo->dwBPP,
- 0,
- 0);
- if (FAILED(ddrval))
- {
- ErrorF ("winAllocateFBShadowDDNL - Could not set default refresh rate "
- "full screen display mode: %08x\n",
- (unsigned int) ddrval);
- return FALSE;
- }
- }
- }
- else
- {
- winDebug ("winAllocateFBShadowDDNL - Not changing video mode\n");
- }
+ /* Are we full screen? */
+ if (pScreenInfo->fFullScreen) {
+ DDSURFACEDESC2 ddsdCurrent;
+ DWORD dwRefreshRateCurrent = 0;
+ HDC hdc = NULL;
+
+ /* Set the cooperative level to full screen */
+ ddrval = IDirectDraw4_SetCooperativeLevel(pScreenPriv->pdd4,
+ pScreenPriv->hwndScreen,
+ DDSCL_EXCLUSIVE
+ | DDSCL_FULLSCREEN);
+ if (FAILED(ddrval)) {
+ ErrorF("winAllocateFBShadowDDNL - Could not set "
+ "cooperative level: %08x\n", (unsigned int) ddrval);
+ return FALSE;
+ }
+
+ /*
+ * We only need to get the current refresh rate for comparison
+ * if a refresh rate has been passed on the command line.
+ */
+ if (pScreenInfo->dwRefreshRate != 0) {
+ ZeroMemory(&ddsdCurrent, sizeof(ddsdCurrent));
+ ddsdCurrent.dwSize = sizeof(ddsdCurrent);
+
+ /* Get information about current display settings */
+ ddrval = IDirectDraw4_GetDisplayMode(pScreenPriv->pdd4,
+ &ddsdCurrent);
+ if (FAILED(ddrval)) {
+ ErrorF("winAllocateFBShadowDDNL - Could not get current "
+ "refresh rate: %08x. Continuing.\n",
+ (unsigned int) ddrval);
+ dwRefreshRateCurrent = 0;
+ }
+ else {
+ /* Grab the current refresh rate */
+ dwRefreshRateCurrent = ddsdCurrent.u2.dwRefreshRate;
+ }
+ }
+
+ /* Clean up the refresh rate */
+ if (dwRefreshRateCurrent == pScreenInfo->dwRefreshRate) {
+ /*
+ * Refresh rate is non-specified or equal to current.
+ */
+ pScreenInfo->dwRefreshRate = 0;
+ }
+
+ /* Grab a device context for the screen */
+ hdc = GetDC(NULL);
+ if (hdc == NULL) {
+ ErrorF("winAllocateFBShadowDDNL - GetDC () failed\n");
+ return FALSE;
+ }
+
+ /* Only change the video mode when different than current mode */
+ if (!pScreenInfo->fMultipleMonitors
+ && (pScreenInfo->dwWidth != GetSystemMetrics(SM_CXSCREEN)
+ || pScreenInfo->dwHeight != GetSystemMetrics(SM_CYSCREEN)
+ || pScreenInfo->dwBPP != GetDeviceCaps(hdc, BITSPIXEL)
+ || pScreenInfo->dwRefreshRate != 0)) {
+ winDebug("winAllocateFBShadowDDNL - Changing video mode\n");
+
+ /* Change the video mode to the mode requested, and use the driver default refresh rate on failure */
+ ddrval = IDirectDraw4_SetDisplayMode(pScreenPriv->pdd4,
+ pScreenInfo->dwWidth,
+ pScreenInfo->dwHeight,
+ pScreenInfo->dwBPP,
+ pScreenInfo->dwRefreshRate, 0);
+ if (FAILED(ddrval)) {
+ ErrorF("winAllocateFBShadowDDNL - Could not set "
+ "full screen display mode: %08x\n",
+ (unsigned int) ddrval);
+ ErrorF
+ ("winAllocateFBShadowDDNL - Using default driver refresh rate\n");
+ ddrval =
+ IDirectDraw4_SetDisplayMode(pScreenPriv->pdd4,
+ pScreenInfo->dwWidth,
+ pScreenInfo->dwHeight,
+ pScreenInfo->dwBPP, 0, 0);
+ if (FAILED(ddrval)) {
+ ErrorF
+ ("winAllocateFBShadowDDNL - Could not set default refresh rate "
+ "full screen display mode: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
+ }
+ }
+ }
+ else {
+ winDebug("winAllocateFBShadowDDNL - Not changing video mode\n");
+ }
- /* Release our DC */
- ReleaseDC (NULL, hdc);
- hdc = NULL;
+ /* Release our DC */
+ ReleaseDC(NULL, hdc);
+ hdc = NULL;
}
- else
- {
- /* Set the cooperative level for windowed mode */
- ddrval = IDirectDraw4_SetCooperativeLevel (pScreenPriv->pdd4,
- pScreenPriv->hwndScreen,
- DDSCL_NORMAL);
- if (FAILED (ddrval))
- {
- ErrorF ("winAllocateFBShadowDDNL - Could not set "
- "cooperative level: %08x\n",
- (unsigned int) ddrval);
- return FALSE;
- }
+ else {
+ /* Set the cooperative level for windowed mode */
+ ddrval = IDirectDraw4_SetCooperativeLevel(pScreenPriv->pdd4,
+ pScreenPriv->hwndScreen,
+ DDSCL_NORMAL);
+ if (FAILED(ddrval)) {
+ ErrorF("winAllocateFBShadowDDNL - Could not set "
+ "cooperative level: %08x\n", (unsigned int) ddrval);
+ return FALSE;
+ }
}
- /* Create the primary surface */
- if (!winCreatePrimarySurfaceShadowDDNL (pScreen))
- {
- ErrorF ("winAllocateFBShadowDDNL - winCreatePrimarySurfaceShadowDDNL "
- "failed\n");
- return FALSE;
+ /* Create the primary surface */
+ if (!winCreatePrimarySurfaceShadowDDNL(pScreen)) {
+ ErrorF("winAllocateFBShadowDDNL - winCreatePrimarySurfaceShadowDDNL "
+ "failed\n");
+ return FALSE;
}
- /* Get primary surface's pixel format */
- ZeroMemory (&ddpfPrimary, sizeof (ddpfPrimary));
- ddpfPrimary.dwSize = sizeof (ddpfPrimary);
- ddrval = IDirectDrawSurface4_GetPixelFormat (pScreenPriv->pddsPrimary4,
- &ddpfPrimary);
- if (FAILED (ddrval))
- {
- ErrorF ("winAllocateFBShadowDDNL - Could not get primary "
- "pixformat: %08x\n",
- (unsigned int) ddrval);
- return FALSE;
+ /* Get primary surface's pixel format */
+ ZeroMemory(&ddpfPrimary, sizeof(ddpfPrimary));
+ ddpfPrimary.dwSize = sizeof(ddpfPrimary);
+ ddrval = IDirectDrawSurface4_GetPixelFormat(pScreenPriv->pddsPrimary4,
+ &ddpfPrimary);
+ if (FAILED(ddrval)) {
+ ErrorF("winAllocateFBShadowDDNL - Could not get primary "
+ "pixformat: %08x\n", (unsigned int) ddrval);
+ return FALSE;
}
- winDebug ("winAllocateFBShadowDDNL - Primary masks: %08x %08x %08x "
- "dwRGBBitCount: %d\n",
- ddpfPrimary.u2.dwRBitMask,
- ddpfPrimary.u3.dwGBitMask,
- ddpfPrimary.u4.dwBBitMask,
- ddpfPrimary.u1.dwRGBBitCount);
-
- /* Describe the shadow surface to be created */
- /*
- * NOTE: Do not use a DDSCAPS_VIDEOMEMORY surface,
- * as drawing, locking, and unlocking take forever
- * with video memory surfaces. In addition,
- * video memory is a somewhat scarce resource,
- * so you shouldn't be allocating video memory when
- * you have the option of using system memory instead.
- */
- ZeroMemory (&ddsdShadow, sizeof (ddsdShadow));
- ddsdShadow.dwSize = sizeof (ddsdShadow);
- ddsdShadow.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH
- | DDSD_LPSURFACE | DDSD_PITCH | DDSD_PIXELFORMAT;
- ddsdShadow.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
- ddsdShadow.dwHeight = pScreenInfo->dwHeight;
- ddsdShadow.dwWidth = pScreenInfo->dwWidth;
- ddsdShadow.u1.lPitch = pScreenInfo->dwPaddedWidth;
- ddsdShadow.lpSurface = lpSurface;
- ddsdShadow.u4.ddpfPixelFormat = ddpfPrimary;
-
- winDebug ("winAllocateFBShadowDDNL - lPitch: %d\n",
- (int) pScreenInfo->dwPaddedWidth);
-
- /* Create the shadow surface */
- ddrval = IDirectDraw4_CreateSurface (pScreenPriv->pdd4,
- &ddsdShadow,
- &pScreenPriv->pddsShadow4,
- NULL);
- if (FAILED (ddrval))
- {
- ErrorF ("winAllocateFBShadowDDNL - Could not create shadow "
- "surface: %08x\n", (unsigned int) ddrval);
- return FALSE;
+ winDebug("winAllocateFBShadowDDNL - Primary masks: %08x %08x %08x "
+ "dwRGBBitCount: %d\n",
+ ddpfPrimary.u2.dwRBitMask,
+ ddpfPrimary.u3.dwGBitMask,
+ ddpfPrimary.u4.dwBBitMask, ddpfPrimary.u1.dwRGBBitCount);
+
+ /* Describe the shadow surface to be created */
+ /*
+ * NOTE: Do not use a DDSCAPS_VIDEOMEMORY surface,
+ * as drawing, locking, and unlocking take forever
+ * with video memory surfaces. In addition,
+ * video memory is a somewhat scarce resource,
+ * so you shouldn't be allocating video memory when
+ * you have the option of using system memory instead.
+ */
+ ZeroMemory(&ddsdShadow, sizeof(ddsdShadow));
+ ddsdShadow.dwSize = sizeof(ddsdShadow);
+ ddsdShadow.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH
+ | DDSD_LPSURFACE | DDSD_PITCH | DDSD_PIXELFORMAT;
+ ddsdShadow.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
+ ddsdShadow.dwHeight = pScreenInfo->dwHeight;
+ ddsdShadow.dwWidth = pScreenInfo->dwWidth;
+ ddsdShadow.u1.lPitch = pScreenInfo->dwPaddedWidth;
+ ddsdShadow.lpSurface = lpSurface;
+ ddsdShadow.u4.ddpfPixelFormat = ddpfPrimary;
+
+ winDebug("winAllocateFBShadowDDNL - lPitch: %d\n",
+ (int) pScreenInfo->dwPaddedWidth);
+
+ /* Create the shadow surface */
+ ddrval = IDirectDraw4_CreateSurface(pScreenPriv->pdd4,
+ &ddsdShadow,
+ &pScreenPriv->pddsShadow4, NULL);
+ if (FAILED(ddrval)) {
+ ErrorF("winAllocateFBShadowDDNL - Could not create shadow "
+ "surface: %08x\n", (unsigned int) ddrval);
+ return FALSE;
}
-
- winDebug ("winAllocateFBShadowDDNL - Created shadow pitch: %d\n",
- (int) ddsdShadow.u1.lPitch);
- /* Grab the pitch from the surface desc */
- pScreenInfo->dwStride = (ddsdShadow.u1.lPitch * 8)
- / pScreenInfo->dwBPP;
+ winDebug("winAllocateFBShadowDDNL - Created shadow pitch: %d\n",
+ (int) ddsdShadow.u1.lPitch);
- winDebug ("winAllocateFBShadowDDNL - Created shadow stride: %d\n",
- (int) pScreenInfo->dwStride);
+ /* Grab the pitch from the surface desc */
+ pScreenInfo->dwStride = (ddsdShadow.u1.lPitch * 8)
+ / pScreenInfo->dwBPP;
- /* Save the pointer to our surface memory */
- pScreenInfo->pfb = lpSurface;
-
- /* Grab the masks from the surface description */
- pScreenPriv->dwRedMask = ddsdShadow.u4.ddpfPixelFormat.u2.dwRBitMask;
- pScreenPriv->dwGreenMask = ddsdShadow.u4.ddpfPixelFormat.u3.dwGBitMask;
- pScreenPriv->dwBlueMask = ddsdShadow.u4.ddpfPixelFormat.u4.dwBBitMask;
+ winDebug("winAllocateFBShadowDDNL - Created shadow stride: %d\n",
+ (int) pScreenInfo->dwStride);
+
+ /* Save the pointer to our surface memory */
+ pScreenInfo->pfb = lpSurface;
+
+ /* Grab the masks from the surface description */
+ pScreenPriv->dwRedMask = ddsdShadow.u4.ddpfPixelFormat.u2.dwRBitMask;
+ pScreenPriv->dwGreenMask = ddsdShadow.u4.ddpfPixelFormat.u3.dwGBitMask;
+ pScreenPriv->dwBlueMask = ddsdShadow.u4.ddpfPixelFormat.u4.dwBBitMask;
- winDebug ("winAllocateFBShadowDDNL - Returning\n");
+ winDebug("winAllocateFBShadowDDNL - Returning\n");
- return TRUE;
+ return TRUE;
}
static void
winFreeFBShadowDDNL(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-
- /* Free the shadow surface, if there is one */
- if (pScreenPriv->pddsShadow4)
- {
- IDirectDrawSurface4_Release (pScreenPriv->pddsShadow4);
- free (pScreenInfo->pfb);
- pScreenInfo->pfb = NULL;
- pScreenPriv->pddsShadow4 = NULL;
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /* Free the shadow surface, if there is one */
+ if (pScreenPriv->pddsShadow4) {
+ IDirectDrawSurface4_Release(pScreenPriv->pddsShadow4);
+ free(pScreenInfo->pfb);
+ pScreenInfo->pfb = NULL;
+ pScreenPriv->pddsShadow4 = NULL;
}
- /* Detach the clipper from the primary surface and release the primary surface, if there is one */
- winReleasePrimarySurfaceShadowDDNL(pScreen);
+ /* Detach the clipper from the primary surface and release the primary surface, if there is one */
+ winReleasePrimarySurfaceShadowDDNL(pScreen);
- ReleaseDDNL(pScreenPriv);
+ ReleaseDDNL(pScreenPriv);
- /* Invalidate the ScreenInfo's fb pointer */
- pScreenInfo->pfb = NULL;
+ /* Invalidate the ScreenInfo's fb pointer */
+ pScreenInfo->pfb = NULL;
}
#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
@@ -647,171 +602,161 @@ winFreeFBShadowDDNL(ScreenPtr pScreen)
*/
static
-Bool
-winFinishCreateWindowsWindowDDNL (WindowPtr pWin)
+ Bool
+winFinishCreateWindowsWindowDDNL(WindowPtr pWin)
{
- winWindowPriv(pWin);
- winPrivScreenPtr pScreenPriv = pWinPriv->pScreenPriv;
- HRESULT ddrval = DD_OK;
- DDSURFACEDESC2 ddsd;
- int iWidth, iHeight;
- int iX, iY;
-
- winDebug ("winFinishCreateWindowsWindowDDNL!\n\n");
-
- iX = pWin->drawable.x + GetSystemMetrics (SM_XVIRTUALSCREEN);
- iY = pWin->drawable.y + GetSystemMetrics (SM_YVIRTUALSCREEN);
-
- iWidth = pWin->drawable.width;
- iHeight = pWin->drawable.height;
-
- /* Describe the primary surface */
- ZeroMemory (&ddsd, sizeof (ddsd));
- ddsd.dwSize = sizeof (ddsd);
- ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
- ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
- ddsd.dwHeight = iHeight;
- ddsd.dwWidth = iWidth;
-
- /* Create the primary surface */
- ddrval = IDirectDraw4_CreateSurface (pScreenPriv->pdd4,
- &ddsd,
- &pWinPriv->pddsPrimary4,
- NULL);
- if (FAILED (ddrval))
- {
- ErrorF ("winFinishCreateWindowsWindowDDNL - Could not create primary "
- "surface: %08x\n",
- (unsigned int)ddrval);
- return FALSE;
+ winWindowPriv(pWin);
+ winPrivScreenPtr pScreenPriv = pWinPriv->pScreenPriv;
+ HRESULT ddrval = DD_OK;
+ DDSURFACEDESC2 ddsd;
+ int iWidth, iHeight;
+ int iX, iY;
+
+ winDebug("winFinishCreateWindowsWindowDDNL!\n\n");
+
+ iX = pWin->drawable.x + GetSystemMetrics(SM_XVIRTUALSCREEN);
+ iY = pWin->drawable.y + GetSystemMetrics(SM_YVIRTUALSCREEN);
+
+ iWidth = pWin->drawable.width;
+ iHeight = pWin->drawable.height;
+
+ /* Describe the primary surface */
+ ZeroMemory(&ddsd, sizeof(ddsd));
+ ddsd.dwSize = sizeof(ddsd);
+ ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
+ ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
+ ddsd.dwHeight = iHeight;
+ ddsd.dwWidth = iWidth;
+
+ /* Create the primary surface */
+ ddrval = IDirectDraw4_CreateSurface(pScreenPriv->pdd4,
+ &ddsd, &pWinPriv->pddsPrimary4, NULL);
+ if (FAILED(ddrval)) {
+ ErrorF("winFinishCreateWindowsWindowDDNL - Could not create primary "
+ "surface: %08x\n", (unsigned int) ddrval);
+ return FALSE;
}
- return TRUE;
+ return TRUE;
}
#endif
-
/*
* Transfer the damaged regions of the shadow framebuffer to the display.
*/
static void
-winShadowUpdateDDNL (ScreenPtr pScreen,
- shadowBufPtr pBuf)
+winShadowUpdateDDNL(ScreenPtr pScreen, shadowBufPtr pBuf)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- RegionPtr damage = shadowDamage(pBuf);
- RECT rcDest, rcSrc;
- POINT ptOrigin;
- DWORD dwBox = RegionNumRects (damage);
- BoxPtr pBox = RegionRects (damage);
- HRGN hrgnTemp = NULL, hrgnCombined = NULL;
-
- /*
- * Return immediately if the app is not active
- * and we are fullscreen, or if we have a bad display depth
- */
- if ((!pScreenPriv->fActive && pScreenInfo->fFullScreen)
- || pScreenPriv->fBadDepth) return;
-
- /* Return immediately if we didn't get needed surfaces */
- if (!pScreenPriv->pddsPrimary4 || !pScreenPriv->pddsShadow4)
- return;
-
- /* Get the origin of the window in the screen coords */
- ptOrigin.x = pScreenInfo->dwXOffset;
- ptOrigin.y = pScreenInfo->dwYOffset;
- MapWindowPoints (pScreenPriv->hwndScreen,
- HWND_DESKTOP,
- (LPPOINT)&ptOrigin, 1);
-
- /*
- * Handle small regions with multiple blits,
- * handle large regions by creating a clipping region and
- * doing a single blit constrained to that clipping region.
- */
- if (pScreenInfo->dwClipUpdatesNBoxes == 0
- || dwBox < pScreenInfo->dwClipUpdatesNBoxes)
- {
- /* Loop through all boxes in the damaged region */
- while (dwBox--)
- {
- /* Assign damage box to source rectangle */
- rcSrc.left = pBox->x1;
- rcSrc.top = pBox->y1;
- rcSrc.right = pBox->x2;
- rcSrc.bottom = pBox->y2;
-
- /* Calculate destination rectangle */
- rcDest.left = ptOrigin.x + rcSrc.left;
- rcDest.top = ptOrigin.y + rcSrc.top;
- rcDest.right = ptOrigin.x + rcSrc.right;
- rcDest.bottom = ptOrigin.y + rcSrc.bottom;
-
- /* Blit the damaged areas */
- if (pScreenPriv->pddsPrimary4)
- myIDirectDrawSurface4_Blt (pScreen,
- &rcDest,
- &rcSrc);
-
- /* Get a pointer to the next box */
- ++pBox;
- }
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ RegionPtr damage = shadowDamage(pBuf);
+ RECT rcDest, rcSrc;
+ POINT ptOrigin;
+ DWORD dwBox = RegionNumRects(damage);
+ BoxPtr pBox = RegionRects(damage);
+ HRGN hrgnTemp = NULL, hrgnCombined = NULL;
+
+ /*
+ * Return immediately if the app is not active
+ * and we are fullscreen, or if we have a bad display depth
+ */
+ if ((!pScreenPriv->fActive && pScreenInfo->fFullScreen)
+ || pScreenPriv->fBadDepth)
+ return;
+
+ /* Return immediately if we didn't get needed surfaces */
+ if (!pScreenPriv->pddsPrimary4 || !pScreenPriv->pddsShadow4)
+ return;
+
+ /* Get the origin of the window in the screen coords */
+ ptOrigin.x = pScreenInfo->dwXOffset;
+ ptOrigin.y = pScreenInfo->dwYOffset;
+ MapWindowPoints(pScreenPriv->hwndScreen,
+ HWND_DESKTOP, (LPPOINT) & ptOrigin, 1);
+
+ /*
+ * Handle small regions with multiple blits,
+ * handle large regions by creating a clipping region and
+ * doing a single blit constrained to that clipping region.
+ */
+ if (pScreenInfo->dwClipUpdatesNBoxes == 0
+ || dwBox < pScreenInfo->dwClipUpdatesNBoxes) {
+ /* Loop through all boxes in the damaged region */
+ while (dwBox--) {
+ /* Assign damage box to source rectangle */
+ rcSrc.left = pBox->x1;
+ rcSrc.top = pBox->y1;
+ rcSrc.right = pBox->x2;
+ rcSrc.bottom = pBox->y2;
+
+ /* Calculate destination rectangle */
+ rcDest.left = ptOrigin.x + rcSrc.left;
+ rcDest.top = ptOrigin.y + rcSrc.top;
+ rcDest.right = ptOrigin.x + rcSrc.right;
+ rcDest.bottom = ptOrigin.y + rcSrc.bottom;
+
+ /* Blit the damaged areas */
+ if (pScreenPriv->pddsPrimary4)
+ myIDirectDrawSurface4_Blt (pScreen,
+ &rcDest,
+ &rcSrc);
+
+ /* Get a pointer to the next box */
+ ++pBox;
+ }
}
- else
- {
- BoxPtr pBoxExtents = RegionExtents(damage);
-
- /* Compute a GDI region from the damaged region */
- hrgnCombined = CreateRectRgn (pBox->x1, pBox->y1, pBox->x2, pBox->y2);
- dwBox--;
- pBox++;
- while (dwBox--)
- {
- hrgnTemp = CreateRectRgn (pBox->x1, pBox->y1, pBox->x2, pBox->y2);
- CombineRgn (hrgnCombined, hrgnCombined, hrgnTemp, RGN_OR);
- DeleteObject (hrgnTemp);
- pBox++;
- }
-
- /* Install the GDI region as a clipping region */
- SelectClipRgn (pScreenPriv->hdcScreen, hrgnCombined);
- DeleteObject (hrgnCombined);
- hrgnCombined = NULL;
-
- winDebug ("winShadowUpdateDDNL - be x1 %d y1 %d x2 %d y2 %d\n",
- pBoxExtents->x1, pBoxExtents->y1,
- pBoxExtents->x2, pBoxExtents->y2);
-
- /* Calculating a bounding box for the source is easy */
- rcSrc.left = pBoxExtents->x1;
- rcSrc.top = pBoxExtents->y1;
- rcSrc.right = pBoxExtents->x2;
- rcSrc.bottom = pBoxExtents->y2;
-
- /* Calculating a bounding box for the destination is trickier */
- rcDest.left = ptOrigin.x + rcSrc.left;
- rcDest.top = ptOrigin.y + rcSrc.top;
- rcDest.right = ptOrigin.x + rcSrc.right;
- rcDest.bottom = ptOrigin.y + rcSrc.bottom;
-
- /* Our Blt should be clipped to the invalidated region */
- myIDirectDrawSurface4_Blt (pScreen, &rcDest, &rcSrc);
-
- /* Reset the clip region */
- SelectClipRgn (pScreenPriv->hdcScreen, NULL);
+ else {
+ BoxPtr pBoxExtents = RegionExtents(damage);
+
+ /* Compute a GDI region from the damaged region */
+ hrgnCombined = CreateRectRgn(pBox->x1, pBox->y1, pBox->x2, pBox->y2);
+ dwBox--;
+ pBox++;
+ while (dwBox--) {
+ hrgnTemp = CreateRectRgn(pBox->x1, pBox->y1, pBox->x2, pBox->y2);
+ CombineRgn(hrgnCombined, hrgnCombined, hrgnTemp, RGN_OR);
+ DeleteObject(hrgnTemp);
+ pBox++;
+ }
+
+ /* Install the GDI region as a clipping region */
+ SelectClipRgn(pScreenPriv->hdcScreen, hrgnCombined);
+ DeleteObject(hrgnCombined);
+ hrgnCombined = NULL;
+
+ winDebug("winShadowUpdateDDNL - be x1 %d y1 %d x2 %d y2 %d\n",
+ pBoxExtents->x1, pBoxExtents->y1,
+ pBoxExtents->x2, pBoxExtents->y2);
+
+ /* Calculating a bounding box for the source is easy */
+ rcSrc.left = pBoxExtents->x1;
+ rcSrc.top = pBoxExtents->y1;
+ rcSrc.right = pBoxExtents->x2;
+ rcSrc.bottom = pBoxExtents->y2;
+
+ /* Calculating a bounding box for the destination is trickier */
+ rcDest.left = ptOrigin.x + rcSrc.left;
+ rcDest.top = ptOrigin.y + rcSrc.top;
+ rcDest.right = ptOrigin.x + rcSrc.right;
+ rcDest.bottom = ptOrigin.y + rcSrc.bottom;
+
+ /* Our Blt should be clipped to the invalidated region */
+ myIDirectDrawSurface4_Blt (pScreen, &rcDest, &rcSrc);
+
+ /* Reset the clip region */
+ SelectClipRgn(pScreenPriv->hdcScreen, NULL);
}
}
static Bool
winInitScreenShadowDDNL(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
+ winScreenPriv(pScreen);
- /* Get a device context for the screen */
- pScreenPriv->hdcScreen = GetDC (pScreenPriv->hwndScreen);
+ /* Get a device context for the screen */
+ pScreenPriv->hdcScreen = GetDC(pScreenPriv->hwndScreen);
- return winAllocateFBShadowDDNL(pScreen);
+ return winAllocateFBShadowDDNL(pScreen);
}
/*
@@ -821,64 +766,61 @@ winInitScreenShadowDDNL(ScreenPtr pScreen)
*/
static Bool
-winCloseScreenShadowDDNL (int nIndex, ScreenPtr pScreen)
+winCloseScreenShadowDDNL(int nIndex, ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- Bool fReturn=FALSE;
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ Bool fReturn=FALSE;
- winDebug ("winCloseScreenShadowDDNL - Freeing screen resources\n");
+ winDebug("winCloseScreenShadowDDNL - Freeing screen resources\n");
- /* Flag that the screen is closed */
- pScreenPriv->fClosed = TRUE;
- pScreenPriv->fActive = FALSE;
+ /* Flag that the screen is closed */
+ pScreenPriv->fClosed = TRUE;
+ pScreenPriv->fActive = FALSE;
- /* Call the wrapped CloseScreen procedure */
- WIN_UNWRAP(CloseScreen);
- if (pScreen->CloseScreen)
- fReturn = (*pScreen->CloseScreen) (nIndex, pScreen);
+ /* Call the wrapped CloseScreen procedure */
+ WIN_UNWRAP(CloseScreen);
+ if (pScreen->CloseScreen)
+ fReturn = (*pScreen->CloseScreen) (nIndex, pScreen);
- winFreeFBShadowDDNL(pScreen);
+ winFreeFBShadowDDNL(pScreen);
- /* Free the screen DC */
- ReleaseDC (pScreenPriv->hwndScreen, pScreenPriv->hdcScreen);
+ /* Free the screen DC */
+ ReleaseDC(pScreenPriv->hwndScreen, pScreenPriv->hdcScreen);
- /* Delete the window property */
- RemoveProp (pScreenPriv->hwndScreen, WIN_SCR_PROP);
+ /* Delete the window property */
+ RemoveProp(pScreenPriv->hwndScreen, WIN_SCR_PROP);
- /* Delete tray icon, if we have one */
- if (!pScreenInfo->fNoTrayIcon)
- winDeleteNotifyIcon (pScreenPriv);
+ /* Delete tray icon, if we have one */
+ if (!pScreenInfo->fNoTrayIcon)
+ winDeleteNotifyIcon(pScreenPriv);
- /* Free the exit confirmation dialog box, if it exists */
- if (g_hDlgExit != NULL)
- {
- DestroyWindow (g_hDlgExit);
- g_hDlgExit = NULL;
+ /* Free the exit confirmation dialog box, if it exists */
+ if (g_hDlgExit != NULL) {
+ DestroyWindow(g_hDlgExit);
+ g_hDlgExit = NULL;
}
- /* Kill our window */
- if (pScreenPriv->hwndScreen)
- {
- DestroyWindow (pScreenPriv->hwndScreen);
- pScreenPriv->hwndScreen = NULL;
+ /* Kill our window */
+ if (pScreenPriv->hwndScreen) {
+ DestroyWindow(pScreenPriv->hwndScreen);
+ pScreenPriv->hwndScreen = NULL;
}
#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
- /* Destroy the thread startup mutex */
- if (pScreenPriv->pmServerStarted) pthread_mutex_destroy (&pScreenPriv->pmServerStarted);
+ /* Destroy the thread startup mutex */
+ if (pScreenPriv->pmServerStarted) pthread_mutex_destroy (&pScreenPriv->pmServerStarted);
#endif
- /* Kill our screeninfo's pointer to the screen */
- pScreenInfo->pScreen = NULL;
+ /* Kill our screeninfo's pointer to the screen */
+ pScreenInfo->pScreen = NULL;
- /* Free the screen privates for this screen */
- free ((pointer) pScreenPriv);
+ /* Free the screen privates for this screen */
+ free((pointer) pScreenPriv);
- return fReturn;
+ return fReturn;
}
-
/*
* Tell mi what sort of visuals we need.
*
@@ -888,477 +830,444 @@ winCloseScreenShadowDDNL (int nIndex, ScreenPtr pScreen)
*/
static Bool
-winInitVisualsShadowDDNL (ScreenPtr pScreen)
+winInitVisualsShadowDDNL(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- DWORD dwRedBits, dwGreenBits, dwBlueBits;
-
- /* Count the number of ones in each color mask */
- dwRedBits = winCountBits (pScreenPriv->dwRedMask);
- dwGreenBits = winCountBits (pScreenPriv->dwGreenMask);
- dwBlueBits = winCountBits (pScreenPriv->dwBlueMask);
-
- /* Store the maximum number of ones in a color mask as the bitsPerRGB */
- if (dwRedBits == 0 || dwGreenBits == 0 || dwBlueBits == 0)
- pScreenPriv->dwBitsPerRGB = 8;
- else if (dwRedBits > dwGreenBits && dwRedBits > dwBlueBits)
- pScreenPriv->dwBitsPerRGB = dwRedBits;
- else if (dwGreenBits > dwRedBits && dwGreenBits > dwBlueBits)
- pScreenPriv->dwBitsPerRGB = dwGreenBits;
- else
- pScreenPriv->dwBitsPerRGB = dwBlueBits;
-
- winDebug ("winInitVisualsShadowDDNL - Masks %08x %08x %08x BPRGB %d d %d "
- "bpp %d\n",
- (unsigned int) pScreenPriv->dwRedMask,
- (unsigned int) pScreenPriv->dwGreenMask,
- (unsigned int) pScreenPriv->dwBlueMask,
- (int) pScreenPriv->dwBitsPerRGB,
- (int) pScreenInfo->dwDepth,
- (int) pScreenInfo->dwBPP);
-
- /* Create a single visual according to the Windows screen depth */
- switch (pScreenInfo->dwDepth)
- {
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ DWORD dwRedBits, dwGreenBits, dwBlueBits;
+
+ /* Count the number of ones in each color mask */
+ dwRedBits = winCountBits(pScreenPriv->dwRedMask);
+ dwGreenBits = winCountBits(pScreenPriv->dwGreenMask);
+ dwBlueBits = winCountBits(pScreenPriv->dwBlueMask);
+
+ /* Store the maximum number of ones in a color mask as the bitsPerRGB */
+ if (dwRedBits == 0 || dwGreenBits == 0 || dwBlueBits == 0)
+ pScreenPriv->dwBitsPerRGB = 8;
+ else if (dwRedBits > dwGreenBits && dwRedBits > dwBlueBits)
+ pScreenPriv->dwBitsPerRGB = dwRedBits;
+ else if (dwGreenBits > dwRedBits && dwGreenBits > dwBlueBits)
+ pScreenPriv->dwBitsPerRGB = dwGreenBits;
+ else
+ pScreenPriv->dwBitsPerRGB = dwBlueBits;
+
+ winDebug("winInitVisualsShadowDDNL - Masks %08x %08x %08x BPRGB %d d %d "
+ "bpp %d\n",
+ (unsigned int) pScreenPriv->dwRedMask,
+ (unsigned int) pScreenPriv->dwGreenMask,
+ (unsigned int) pScreenPriv->dwBlueMask,
+ (int) pScreenPriv->dwBitsPerRGB,
+ (int) pScreenInfo->dwDepth, (int) pScreenInfo->dwBPP);
+
+ /* Create a single visual according to the Windows screen depth */
+ switch (pScreenInfo->dwDepth) {
case 24:
case 16:
case 15:
- /* Setup the real visual */
- if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
- TrueColorMask,
- pScreenPriv->dwBitsPerRGB,
- -1,
- pScreenPriv->dwRedMask,
- pScreenPriv->dwGreenMask,
- pScreenPriv->dwBlueMask))
- {
- ErrorF ("winInitVisualsShadowDDNL - miSetVisualTypesAndMasks "
- "failed for TrueColor\n");
- return FALSE;
- }
+ /* Setup the real visual */
+ if (!miSetVisualTypesAndMasks(pScreenInfo->dwDepth,
+ TrueColorMask,
+ pScreenPriv->dwBitsPerRGB,
+ -1,
+ pScreenPriv->dwRedMask,
+ pScreenPriv->dwGreenMask,
+ pScreenPriv->dwBlueMask)) {
+ ErrorF("winInitVisualsShadowDDNL - miSetVisualTypesAndMasks "
+ "failed for TrueColor\n");
+ return FALSE;
+ }
#ifdef XWIN_EMULATEPSEUDO
- if (!pScreenInfo->fEmulatePseudo)
- break;
-
- /* Setup a pseudocolor visual */
- if (!miSetVisualTypesAndMasks (8,
- PseudoColorMask,
- 8,
- -1,
- 0,
- 0,
- 0))
- {
- ErrorF ("winInitVisualsShadowDDNL - miSetVisualTypesAndMasks "
- "failed for PseudoColor\n");
- return FALSE;
- }
+ if (!pScreenInfo->fEmulatePseudo)
+ break;
+
+ /* Setup a pseudocolor visual */
+ if (!miSetVisualTypesAndMasks(8, PseudoColorMask, 8, -1, 0, 0, 0)) {
+ ErrorF("winInitVisualsShadowDDNL - miSetVisualTypesAndMasks "
+ "failed for PseudoColor\n");
+ return FALSE;
+ }
#endif
- break;
+ break;
case 8:
- if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
- pScreenInfo->fFullScreen
- ? PseudoColorMask : StaticColorMask,
- pScreenPriv->dwBitsPerRGB,
- pScreenInfo->fFullScreen
- ? PseudoColor : StaticColor,
- pScreenPriv->dwRedMask,
- pScreenPriv->dwGreenMask,
- pScreenPriv->dwBlueMask))
- {
- ErrorF ("winInitVisualsShadowDDNL - miSetVisualTypesAndMasks "
- "failed\n");
- return FALSE;
- }
- break;
+ if (!miSetVisualTypesAndMasks(pScreenInfo->dwDepth,
+ pScreenInfo->fFullScreen
+ ? PseudoColorMask : StaticColorMask,
+ pScreenPriv->dwBitsPerRGB,
+ pScreenInfo->fFullScreen
+ ? PseudoColor : StaticColor,
+ pScreenPriv->dwRedMask,
+ pScreenPriv->dwGreenMask,
+ pScreenPriv->dwBlueMask)) {
+ ErrorF("winInitVisualsShadowDDNL - miSetVisualTypesAndMasks "
+ "failed\n");
+ return FALSE;
+ }
+ break;
default:
- ErrorF ("winInitVisualsShadowDDNL - Unknown screen depth\n");
- return FALSE;
+ ErrorF("winInitVisualsShadowDDNL - Unknown screen depth\n");
+ return FALSE;
}
- winDebug ("winInitVisualsShadowDDNL - Returning\n");
+ winDebug("winInitVisualsShadowDDNL - Returning\n");
- return TRUE;
+ return TRUE;
}
-
/*
* Adjust the user proposed video mode
*/
static Bool
-winAdjustVideoModeShadowDDNL (ScreenPtr pScreen)
+winAdjustVideoModeShadowDDNL(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- HDC hdc = NULL;
- DWORD dwBPP;
-
- /* We're in serious trouble if we can't get a DC */
- hdc = GetDC (NULL);
- if (hdc == NULL)
- {
- ErrorF ("winAdjustVideoModeShadowDDNL - GetDC () failed\n");
- return FALSE;
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ HDC hdc = NULL;
+ DWORD dwBPP;
+
+ /* We're in serious trouble if we can't get a DC */
+ hdc = GetDC(NULL);
+ if (hdc == NULL) {
+ ErrorF("winAdjustVideoModeShadowDDNL - GetDC () failed\n");
+ return FALSE;
}
- /* Query GDI for current display depth */
- dwBPP = GetDeviceCaps (hdc, BITSPIXEL);
+ /* Query GDI for current display depth */
+ dwBPP = GetDeviceCaps(hdc, BITSPIXEL);
- /* DirectDraw can only change the depth in fullscreen mode */
- if (!(pScreenInfo->fFullScreen &&
- (pScreenInfo->dwBPP != WIN_DEFAULT_BPP)))
- {
- /* Otherwise, We'll use GDI's depth */
- pScreenInfo->dwBPP = dwBPP;
+ /* DirectDraw can only change the depth in fullscreen mode */
+ if (!(pScreenInfo->fFullScreen && (pScreenInfo->dwBPP != WIN_DEFAULT_BPP))) {
+ /* Otherwise, We'll use GDI's depth */
+ pScreenInfo->dwBPP = dwBPP;
}
- /* Release our DC */
- ReleaseDC (NULL, hdc);
+ /* Release our DC */
+ ReleaseDC(NULL, hdc);
- return TRUE;
+ return TRUE;
}
-
/*
* Blt exposed regions to the screen
*/
static Bool
-winBltExposedRegionsShadowDDNL (ScreenPtr pScreen)
+winBltExposedRegionsShadowDDNL(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- RECT rcSrc, rcDest;
- POINT ptOrigin;
- HDC hdcUpdate;
- PAINTSTRUCT ps;
- HRESULT ddrval = DD_OK;
- Bool fReturn = TRUE;
- int i;
-
- /* Quite common case. The primary surface was lost (maybe because of depth
- * change). Try to create a new primary surface. Bail out if this fails */
- if (pScreenPriv->pddsPrimary4 == NULL && pScreenPriv->fRetryCreateSurface &&
- !winCreatePrimarySurfaceShadowDDNL(pScreen))
- {
- Sleep(100);
- return FALSE;
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ RECT rcSrc, rcDest;
+ POINT ptOrigin;
+ HDC hdcUpdate;
+ PAINTSTRUCT ps;
+ HRESULT ddrval = DD_OK;
+ Bool fReturn = TRUE;
+ int i;
+
+ /* Quite common case. The primary surface was lost (maybe because of depth
+ * change). Try to create a new primary surface. Bail out if this fails */
+ if (pScreenPriv->pddsPrimary4 == NULL && pScreenPriv->fRetryCreateSurface &&
+ !winCreatePrimarySurfaceShadowDDNL(pScreen)) {
+ Sleep(100);
+ return FALSE;
}
- if (pScreenPriv->pddsPrimary4 == NULL)
- return FALSE;
-
- /* BeginPaint gives us an hdc that clips to the invalidated region */
- hdcUpdate = BeginPaint (pScreenPriv->hwndScreen, &ps);
- if (hdcUpdate == NULL)
- {
- fReturn = FALSE;
- ErrorF ("winBltExposedRegionsShadowDDNL - BeginPaint () returned "
- "a NULL device context handle. Aborting blit attempt.\n");
- goto winBltExposedRegionsShadowDDNL_Exit;
+ if (pScreenPriv->pddsPrimary4 == NULL)
+ return FALSE;
+
+ /* BeginPaint gives us an hdc that clips to the invalidated region */
+ hdcUpdate = BeginPaint(pScreenPriv->hwndScreen, &ps);
+ if (hdcUpdate == NULL) {
+ fReturn = FALSE;
+ ErrorF("winBltExposedRegionsShadowDDNL - BeginPaint () returned "
+ "a NULL device context handle. Aborting blit attempt.\n");
+ goto winBltExposedRegionsShadowDDNL_Exit;
}
- /* Get the origin of the window in the screen coords */
- ptOrigin.x = pScreenInfo->dwXOffset;
- ptOrigin.y = pScreenInfo->dwYOffset;
-
- MapWindowPoints (pScreenPriv->hwndScreen,
- HWND_DESKTOP,
- (LPPOINT)&ptOrigin, 1);
- rcDest.left = ptOrigin.x;
- rcDest.right = ptOrigin.x + pScreenInfo->dwWidth;
- rcDest.top = ptOrigin.y;
- rcDest.bottom = ptOrigin.y + pScreenInfo->dwHeight;
-
- /* Source can be entire shadow surface, as Blt should clip for us */
- rcSrc.left = 0;
- rcSrc.top = 0;
- rcSrc.right = pScreenInfo->dwWidth;
- rcSrc.bottom = pScreenInfo->dwHeight;
-
- /* Our Blt should be clipped to the invalidated region */
- ddrval = myIDirectDrawSurface4_Blt (pScreen, &rcDest, &rcSrc);
- if (FAILED (ddrval))
- {
- fReturn = FALSE;
- }
+ /* Get the origin of the window in the screen coords */
+ ptOrigin.x = pScreenInfo->dwXOffset;
+ ptOrigin.y = pScreenInfo->dwYOffset;
+
+ MapWindowPoints(pScreenPriv->hwndScreen,
+ HWND_DESKTOP, (LPPOINT) & ptOrigin, 1);
+ rcDest.left = ptOrigin.x;
+ rcDest.right = ptOrigin.x + pScreenInfo->dwWidth;
+ rcDest.top = ptOrigin.y;
+ rcDest.bottom = ptOrigin.y + pScreenInfo->dwHeight;
+
+ /* Source can be entire shadow surface, as Blt should clip for us */
+ rcSrc.left = 0;
+ rcSrc.top = 0;
+ rcSrc.right = pScreenInfo->dwWidth;
+ rcSrc.bottom = pScreenInfo->dwHeight;
+
+ /* Our Blt should be clipped to the invalidated region */
+ ddrval = myIDirectDrawSurface4_Blt (pScreen, &rcDest, &rcSrc);
+ if (FAILED (ddrval))
+ {
+ fReturn = FALSE;
+ }
winBltExposedRegionsShadowDDNL_Exit:
- /* EndPaint frees the DC */
- if (hdcUpdate != NULL)
- EndPaint (pScreenPriv->hwndScreen, &ps);
- return fReturn;
+ /* EndPaint frees the DC */
+ if (hdcUpdate != NULL)
+ EndPaint(pScreenPriv->hwndScreen, &ps);
+ return fReturn;
}
-
/*
* Do any engine-specific application-activation processing
*/
static Bool
-winActivateAppShadowDDNL (ScreenPtr pScreen)
+winActivateAppShadowDDNL(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
+ winScreenPriv(pScreen);
- /*
- * Do we have a surface?
- * Are we active?
- * Are we full screen?
- */
- if (pScreenPriv != NULL
- && pScreenPriv->pddsPrimary4 != NULL
- && pScreenPriv->fActive)
- {
- /* Primary surface was lost, restore it */
- IDirectDrawSurface4_Restore (pScreenPriv->pddsPrimary4);
+ /*
+ * Do we have a surface?
+ * Are we active?
+ * Are we full screen?
+ */
+ if (pScreenPriv != NULL
+ && pScreenPriv->pddsPrimary4 != NULL && pScreenPriv->fActive) {
+ /* Primary surface was lost, restore it */
+ IDirectDrawSurface4_Restore(pScreenPriv->pddsPrimary4);
}
- return TRUE;
+ return TRUE;
}
-
/*
* Reblit the shadow framebuffer to the screen.
*/
static Bool
-winRedrawScreenShadowDDNL (ScreenPtr pScreen)
+winRedrawScreenShadowDDNL(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- RECT rcSrc, rcDest;
- POINT ptOrigin;
-
- /* Get the origin of the window in the screen coords */
- ptOrigin.x = pScreenInfo->dwXOffset;
- ptOrigin.y = pScreenInfo->dwYOffset;
- MapWindowPoints (pScreenPriv->hwndScreen,
- HWND_DESKTOP,
- (LPPOINT)&ptOrigin, 1);
- rcDest.left = ptOrigin.x;
- rcDest.right = ptOrigin.x + pScreenInfo->dwWidth;
- rcDest.top = ptOrigin.y;
- rcDest.bottom = ptOrigin.y + pScreenInfo->dwHeight;
-
- /* Source can be entire shadow surface, as Blt should clip for us */
- rcSrc.left = 0;
- rcSrc.top = 0;
- rcSrc.right = pScreenInfo->dwWidth;
- rcSrc.bottom = pScreenInfo->dwHeight;
-
- /* Redraw the whole window, to take account for the new colors */
- myIDirectDrawSurface4_Blt (pScreen, &rcDest, &rcSrc);
- return TRUE;
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ RECT rcSrc, rcDest;
+ POINT ptOrigin;
+
+ /* Get the origin of the window in the screen coords */
+ ptOrigin.x = pScreenInfo->dwXOffset;
+ ptOrigin.y = pScreenInfo->dwYOffset;
+ MapWindowPoints(pScreenPriv->hwndScreen,
+ HWND_DESKTOP, (LPPOINT) & ptOrigin, 1);
+ rcDest.left = ptOrigin.x;
+ rcDest.right = ptOrigin.x + pScreenInfo->dwWidth;
+ rcDest.top = ptOrigin.y;
+ rcDest.bottom = ptOrigin.y + pScreenInfo->dwHeight;
+
+ /* Source can be entire shadow surface, as Blt should clip for us */
+ rcSrc.left = 0;
+ rcSrc.top = 0;
+ rcSrc.right = pScreenInfo->dwWidth;
+ rcSrc.bottom = pScreenInfo->dwHeight;
+
+ /* Redraw the whole window, to take account for the new colors */
+ myIDirectDrawSurface4_Blt (pScreen, &rcDest, &rcSrc);
+ return TRUE;
}
-
/*
* Realize the currently installed colormap
*/
static Bool
-winRealizeInstalledPaletteShadowDDNL (ScreenPtr pScreen)
+winRealizeInstalledPaletteShadowDDNL(ScreenPtr pScreen)
{
- return TRUE;
+ return TRUE;
}
-
/*
* Install the specified colormap
*/
static Bool
-winInstallColormapShadowDDNL (ColormapPtr pColormap)
+winInstallColormapShadowDDNL(ColormapPtr pColormap)
{
- ScreenPtr pScreen = pColormap->pScreen;
- winScreenPriv(pScreen);
- winCmapPriv(pColormap);
- HRESULT ddrval = DD_OK;
-
- /* Install the DirectDraw palette on the primary surface */
- ddrval = IDirectDrawSurface4_SetPalette (pScreenPriv->pddsPrimary4,
- pCmapPriv->lpDDPalette);
- if (FAILED (ddrval))
- {
- ErrorF ("winInstallColormapShadowDDNL - Failed installing the "
- "DirectDraw palette.\n");
- return FALSE;
+ ScreenPtr pScreen = pColormap->pScreen;
+
+ winScreenPriv(pScreen);
+ winCmapPriv(pColormap);
+ HRESULT ddrval = DD_OK;
+
+ /* Install the DirectDraw palette on the primary surface */
+ ddrval = IDirectDrawSurface4_SetPalette(pScreenPriv->pddsPrimary4,
+ pCmapPriv->lpDDPalette);
+ if (FAILED(ddrval)) {
+ ErrorF("winInstallColormapShadowDDNL - Failed installing the "
+ "DirectDraw palette.\n");
+ return FALSE;
}
- /* Save a pointer to the newly installed colormap */
- pScreenPriv->pcmapInstalled = pColormap;
+ /* Save a pointer to the newly installed colormap */
+ pScreenPriv->pcmapInstalled = pColormap;
- return TRUE;
+ return TRUE;
}
-
/*
* Store the specified colors in the specified colormap
*/
static Bool
-winStoreColorsShadowDDNL (ColormapPtr pColormap,
- int ndef,
- xColorItem *pdefs)
+winStoreColorsShadowDDNL(ColormapPtr pColormap, int ndef, xColorItem * pdefs)
{
- ScreenPtr pScreen = pColormap->pScreen;
- winScreenPriv(pScreen);
- winCmapPriv(pColormap);
- ColormapPtr curpmap = pScreenPriv->pcmapInstalled;
- HRESULT ddrval = DD_OK;
-
- /* Put the X colormap entries into the Windows logical palette */
- ddrval = IDirectDrawPalette_SetEntries (pCmapPriv->lpDDPalette,
- 0,
- pdefs[0].pixel,
- ndef,
- pCmapPriv->peColors
- + pdefs[0].pixel);
- if (FAILED (ddrval))
- {
- ErrorF ("winStoreColorsShadowDDNL - SetEntries () failed: %08x\n", (unsigned int) ddrval);
- return FALSE;
+ ScreenPtr pScreen = pColormap->pScreen;
+
+ winScreenPriv(pScreen);
+ winCmapPriv(pColormap);
+ ColormapPtr curpmap = pScreenPriv->pcmapInstalled;
+ HRESULT ddrval = DD_OK;
+
+ /* Put the X colormap entries into the Windows logical palette */
+ ddrval = IDirectDrawPalette_SetEntries(pCmapPriv->lpDDPalette,
+ 0,
+ pdefs[0].pixel,
+ ndef,
+ pCmapPriv->peColors
+ + pdefs[0].pixel);
+ if (FAILED(ddrval)) {
+ ErrorF("winStoreColorsShadowDDNL - SetEntries () failed: %08x\n",
+ (unsigned int) ddrval);
+ return FALSE;
}
- /* Don't install the DirectDraw palette if the colormap is not installed */
- if (pColormap != curpmap)
- {
- return TRUE;
+ /* Don't install the DirectDraw palette if the colormap is not installed */
+ if (pColormap != curpmap) {
+ return TRUE;
}
- if (!winInstallColormapShadowDDNL (pColormap))
- {
- ErrorF ("winStoreColorsShadowDDNL - Failed installing colormap\n");
- return FALSE;
+ if (!winInstallColormapShadowDDNL(pColormap)) {
+ ErrorF("winStoreColorsShadowDDNL - Failed installing colormap\n");
+ return FALSE;
}
- return TRUE;
+ return TRUE;
}
-
/*
* Colormap initialization procedure
*/
static Bool
-winCreateColormapShadowDDNL (ColormapPtr pColormap)
+winCreateColormapShadowDDNL(ColormapPtr pColormap)
{
- HRESULT ddrval = DD_OK;
- ScreenPtr pScreen = pColormap->pScreen;
- winScreenPriv(pScreen);
- winCmapPriv(pColormap);
-
- /* Create a DirectDraw palette */
- ddrval = IDirectDraw4_CreatePalette (pScreenPriv->pdd4,
- DDPCAPS_8BIT | DDPCAPS_ALLOW256,
- pCmapPriv->peColors,
- &pCmapPriv->lpDDPalette,
- NULL);
- if (FAILED (ddrval))
- {
- ErrorF ("winCreateColormapShadowDDNL - CreatePalette failed\n");
- return FALSE;
+ HRESULT ddrval = DD_OK;
+ ScreenPtr pScreen = pColormap->pScreen;
+
+ winScreenPriv(pScreen);
+ winCmapPriv(pColormap);
+
+ /* Create a DirectDraw palette */
+ ddrval = IDirectDraw4_CreatePalette(pScreenPriv->pdd4,
+ DDPCAPS_8BIT | DDPCAPS_ALLOW256,
+ pCmapPriv->peColors,
+ &pCmapPriv->lpDDPalette, NULL);
+ if (FAILED(ddrval)) {
+ ErrorF("winCreateColormapShadowDDNL - CreatePalette failed\n");
+ return FALSE;
}
- return TRUE;
+ return TRUE;
}
-
/*
* Colormap destruction procedure
*/
static Bool
-winDestroyColormapShadowDDNL (ColormapPtr pColormap)
+winDestroyColormapShadowDDNL(ColormapPtr pColormap)
{
- winScreenPriv(pColormap->pScreen);
- winCmapPriv(pColormap);
- HRESULT ddrval = DD_OK;
-
- /*
- * Is colormap to be destroyed the default?
- *
- * Non-default colormaps should have had winUninstallColormap
- * called on them before we get here. The default colormap
- * will not have had winUninstallColormap called on it. Thus,
- * we need to handle the default colormap in a special way.
- */
- if (pColormap->flags & IsDefault)
- {
- winDebug ("winDestroyColormapShadowDDNL - Destroying default colormap\n");
-
- /*
- * FIXME: Walk the list of all screens, popping the default
- * palette out of each screen device context.
- */
-
- /* Pop the palette out of the primary surface */
- ddrval = IDirectDrawSurface4_SetPalette (pScreenPriv->pddsPrimary4,
- NULL);
- if (FAILED (ddrval))
- {
- ErrorF ("winDestroyColormapShadowDDNL - Failed freeing the "
- "default colormap DirectDraw palette.\n");
- return FALSE;
- }
-
- /* Clear our private installed colormap pointer */
- pScreenPriv->pcmapInstalled = NULL;
+ winScreenPriv(pColormap->pScreen);
+ winCmapPriv(pColormap);
+ HRESULT ddrval = DD_OK;
+
+ /*
+ * Is colormap to be destroyed the default?
+ *
+ * Non-default colormaps should have had winUninstallColormap
+ * called on them before we get here. The default colormap
+ * will not have had winUninstallColormap called on it. Thus,
+ * we need to handle the default colormap in a special way.
+ */
+ if (pColormap->flags & IsDefault) {
+ winDebug
+ ("winDestroyColormapShadowDDNL - Destroying default colormap\n");
+
+ /*
+ * FIXME: Walk the list of all screens, popping the default
+ * palette out of each screen device context.
+ */
+
+ /* Pop the palette out of the primary surface */
+ ddrval = IDirectDrawSurface4_SetPalette(pScreenPriv->pddsPrimary4,
+ NULL);
+ if (FAILED(ddrval)) {
+ ErrorF("winDestroyColormapShadowDDNL - Failed freeing the "
+ "default colormap DirectDraw palette.\n");
+ return FALSE;
+ }
+
+ /* Clear our private installed colormap pointer */
+ pScreenPriv->pcmapInstalled = NULL;
}
-
- /* Release the palette */
- IDirectDrawPalette_Release (pCmapPriv->lpDDPalette);
-
- /* Invalidate the colormap privates */
- pCmapPriv->lpDDPalette = NULL;
- return TRUE;
-}
+ /* Release the palette */
+ IDirectDrawPalette_Release(pCmapPriv->lpDDPalette);
+ /* Invalidate the colormap privates */
+ pCmapPriv->lpDDPalette = NULL;
+
+ return TRUE;
+}
/*
* Set pointers to our engine specific functions
*/
Bool
-winSetEngineFunctionsShadowDDNL (ScreenPtr pScreen)
+winSetEngineFunctionsShadowDDNL(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-
- /* Set our pointers */
- pScreenPriv->pwinAllocateFB = winAllocateFBShadowDDNL;
- pScreenPriv->pwinFreeFB = winFreeFBShadowDDNL;
- pScreenPriv->pwinShadowUpdate = winShadowUpdateDDNL;
- pScreenPriv->pwinInitScreen = winInitScreenShadowDDNL;
- pScreenPriv->pwinCloseScreen = winCloseScreenShadowDDNL;
- pScreenPriv->pwinInitVisuals = winInitVisualsShadowDDNL;
- pScreenPriv->pwinAdjustVideoMode = winAdjustVideoModeShadowDDNL;
- if (pScreenInfo->fFullScreen)
- pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowFullScreen;
- else
- pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowWindowed;
- pScreenPriv->pwinFinishScreenInit = winFinishScreenInitFB;
- pScreenPriv->pwinBltExposedRegions = winBltExposedRegionsShadowDDNL;
- pScreenPriv->pwinActivateApp = winActivateAppShadowDDNL;
- pScreenPriv->pwinRedrawScreen = winRedrawScreenShadowDDNL;
- pScreenPriv->pwinRealizeInstalledPalette
- = winRealizeInstalledPaletteShadowDDNL;
- pScreenPriv->pwinInstallColormap = winInstallColormapShadowDDNL;
- pScreenPriv->pwinStoreColors = winStoreColorsShadowDDNL;
- pScreenPriv->pwinCreateColormap = winCreateColormapShadowDDNL;
- pScreenPriv->pwinDestroyColormap = winDestroyColormapShadowDDNL;
- pScreenPriv->pwinHotKeyAltTab = (winHotKeyAltTabProcPtr) (void (*)(void))NoopDDA;
- pScreenPriv->pwinCreatePrimarySurface = winCreatePrimarySurfaceShadowDDNL;
- pScreenPriv->pwinReleasePrimarySurface = winReleasePrimarySurfaceShadowDDNL;
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /* Set our pointers */
+ pScreenPriv->pwinAllocateFB = winAllocateFBShadowDDNL;
+ pScreenPriv->pwinFreeFB = winFreeFBShadowDDNL;
+ pScreenPriv->pwinShadowUpdate = winShadowUpdateDDNL;
+ pScreenPriv->pwinInitScreen = winInitScreenShadowDDNL;
+ pScreenPriv->pwinCloseScreen = winCloseScreenShadowDDNL;
+ pScreenPriv->pwinInitVisuals = winInitVisualsShadowDDNL;
+ pScreenPriv->pwinAdjustVideoMode = winAdjustVideoModeShadowDDNL;
+ if (pScreenInfo->fFullScreen)
+ pScreenPriv->pwinCreateBoundingWindow =
+ winCreateBoundingWindowFullScreen;
+ else
+ pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowWindowed;
+ pScreenPriv->pwinFinishScreenInit = winFinishScreenInitFB;
+ pScreenPriv->pwinBltExposedRegions = winBltExposedRegionsShadowDDNL;
+ pScreenPriv->pwinActivateApp = winActivateAppShadowDDNL;
+ pScreenPriv->pwinRedrawScreen = winRedrawScreenShadowDDNL;
+ pScreenPriv->pwinRealizeInstalledPalette
+ = winRealizeInstalledPaletteShadowDDNL;
+ pScreenPriv->pwinInstallColormap = winInstallColormapShadowDDNL;
+ pScreenPriv->pwinStoreColors = winStoreColorsShadowDDNL;
+ pScreenPriv->pwinCreateColormap = winCreateColormapShadowDDNL;
+ pScreenPriv->pwinDestroyColormap = winDestroyColormapShadowDDNL;
+ pScreenPriv->pwinHotKeyAltTab =
+ (winHotKeyAltTabProcPtr) (void (*)(void)) NoopDDA;
+ pScreenPriv->pwinCreatePrimarySurface = winCreatePrimarySurfaceShadowDDNL;
+ pScreenPriv->pwinReleasePrimarySurface = winReleasePrimarySurfaceShadowDDNL;
#ifdef XWIN_MULTIWINDOW
- pScreenPriv->pwinFinishCreateWindowsWindow
- = winFinishCreateWindowsWindowDDNL;
+ pScreenPriv->pwinFinishCreateWindowsWindow
+ = winFinishCreateWindowsWindowDDNL;
#endif
- return TRUE;
+ return TRUE;
}
diff --git a/xorg-server/hw/xwin/winshadgdi.c b/xorg-server/hw/xwin/winshadgdi.c
index a11ca43bd..c4d1da8d0 100644
--- a/xorg-server/hw/xwin/winshadgdi.c
+++ b/xorg-server/hw/xwin/winshadgdi.c
@@ -33,410 +33,382 @@
#endif
#include "win.h"
-
/*
* Local function prototypes
*/
#ifdef XWIN_MULTIWINDOW
-static wBOOL CALLBACK
-winRedrawAllProcShadowGDI (HWND hwnd, LPARAM lParam);
+static wBOOL CALLBACK winRedrawAllProcShadowGDI(HWND hwnd, LPARAM lParam);
-static wBOOL CALLBACK
-winRedrawDamagedWindowShadowGDI (HWND hwnd, LPARAM lParam);
+static wBOOL CALLBACK winRedrawDamagedWindowShadowGDI(HWND hwnd, LPARAM lParam);
#endif
static Bool
-winAllocateFBShadowGDI (ScreenPtr pScreen);
+ winAllocateFBShadowGDI(ScreenPtr pScreen);
static void
-winShadowUpdateGDI (ScreenPtr pScreen,
- shadowBufPtr pBuf);
+ winShadowUpdateGDI(ScreenPtr pScreen, shadowBufPtr pBuf);
static Bool
-winCloseScreenShadowGDI (int nIndex, ScreenPtr pScreen);
+ winCloseScreenShadowGDI(int nIndex, ScreenPtr pScreen);
static Bool
-winInitVisualsShadowGDI (ScreenPtr pScreen);
+ winInitVisualsShadowGDI(ScreenPtr pScreen);
static Bool
-winAdjustVideoModeShadowGDI (ScreenPtr pScreen);
+ winAdjustVideoModeShadowGDI(ScreenPtr pScreen);
static Bool
-winBltExposedRegionsShadowGDI (ScreenPtr pScreen);
+ winBltExposedRegionsShadowGDI(ScreenPtr pScreen);
static Bool
-winActivateAppShadowGDI (ScreenPtr pScreen);
+ winActivateAppShadowGDI(ScreenPtr pScreen);
static Bool
-winRedrawScreenShadowGDI (ScreenPtr pScreen);
+ winRedrawScreenShadowGDI(ScreenPtr pScreen);
static Bool
-winRealizeInstalledPaletteShadowGDI (ScreenPtr pScreen);
+ winRealizeInstalledPaletteShadowGDI(ScreenPtr pScreen);
static Bool
-winInstallColormapShadowGDI (ColormapPtr pColormap);
+ winInstallColormapShadowGDI(ColormapPtr pColormap);
static Bool
-winStoreColorsShadowGDI (ColormapPtr pmap,
- int ndef,
- xColorItem *pdefs);
+ winStoreColorsShadowGDI(ColormapPtr pmap, int ndef, xColorItem * pdefs);
static Bool
-winCreateColormapShadowGDI (ColormapPtr pColormap);
+ winCreateColormapShadowGDI(ColormapPtr pColormap);
static Bool
-winDestroyColormapShadowGDI (ColormapPtr pColormap);
-
+ winDestroyColormapShadowGDI(ColormapPtr pColormap);
/*
* Internal function to get the DIB format that is compatible with the screen
*/
static
-Bool
-winQueryScreenDIBFormat (ScreenPtr pScreen, BITMAPINFOHEADER *pbmih)
+ Bool
+winQueryScreenDIBFormat(ScreenPtr pScreen, BITMAPINFOHEADER * pbmih)
{
- winScreenPriv(pScreen);
- HBITMAP hbmp;
+ winScreenPriv(pScreen);
+ HBITMAP hbmp;
#ifdef WINDBG
- LPDWORD pdw = NULL;
+ LPDWORD pdw = NULL;
#endif
-
- /* Create a memory bitmap compatible with the screen */
- hbmp = CreateCompatibleBitmap (pScreenPriv->hdcScreen, 1, 1);
- if (hbmp == NULL)
- {
- ErrorF ("winQueryScreenDIBFormat - CreateCompatibleBitmap failed\n");
- return FALSE;
+
+ /* Create a memory bitmap compatible with the screen */
+ hbmp = CreateCompatibleBitmap(pScreenPriv->hdcScreen, 1, 1);
+ if (hbmp == NULL) {
+ ErrorF("winQueryScreenDIBFormat - CreateCompatibleBitmap failed\n");
+ return FALSE;
}
-
- /* Initialize our bitmap info header */
- ZeroMemory (pbmih, sizeof (BITMAPINFOHEADER) + 256 * sizeof (RGBQUAD));
- pbmih->biSize = sizeof (BITMAPINFOHEADER);
-
- /* Get the biBitCount */
- if (!GetDIBits (pScreenPriv->hdcScreen,
- hbmp,
- 0, 1,
- NULL,
- (BITMAPINFO*) pbmih,
- DIB_RGB_COLORS))
- {
- ErrorF ("winQueryScreenDIBFormat - First call to GetDIBits failed\n");
- DeleteObject (hbmp);
- return FALSE;
+
+ /* Initialize our bitmap info header */
+ ZeroMemory(pbmih, sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
+ pbmih->biSize = sizeof(BITMAPINFOHEADER);
+
+ /* Get the biBitCount */
+ if (!GetDIBits(pScreenPriv->hdcScreen,
+ hbmp, 0, 1, NULL, (BITMAPINFO *) pbmih, DIB_RGB_COLORS)) {
+ ErrorF("winQueryScreenDIBFormat - First call to GetDIBits failed\n");
+ DeleteObject(hbmp);
+ return FALSE;
}
#ifdef WINDBG
- /* Get a pointer to bitfields */
- pdw = (DWORD*) ((CARD8*)pbmih + sizeof (BITMAPINFOHEADER));
+ /* Get a pointer to bitfields */
+ pdw = (DWORD *) ((CARD8 *) pbmih + sizeof(BITMAPINFOHEADER));
- winDebug ("winQueryScreenDIBFormat - First call masks: %08x %08x %08x\n",
- pdw[0], pdw[1], pdw[2]);
+ winDebug("winQueryScreenDIBFormat - First call masks: %08x %08x %08x\n",
+ pdw[0], pdw[1], pdw[2]);
#endif
- /* Get optimal color table, or the optimal bitfields */
- if (!GetDIBits (pScreenPriv->hdcScreen,
- hbmp,
- 0, 1,
- NULL,
- (BITMAPINFO*)pbmih,
- DIB_RGB_COLORS))
- {
- ErrorF ("winQueryScreenDIBFormat - Second call to GetDIBits "
- "failed\n");
- DeleteObject (hbmp);
- return FALSE;
+ /* Get optimal color table, or the optimal bitfields */
+ if (!GetDIBits(pScreenPriv->hdcScreen,
+ hbmp, 0, 1, NULL, (BITMAPINFO *) pbmih, DIB_RGB_COLORS)) {
+ ErrorF("winQueryScreenDIBFormat - Second call to GetDIBits "
+ "failed\n");
+ DeleteObject(hbmp);
+ return FALSE;
}
- /* Free memory */
- DeleteObject (hbmp);
-
- return TRUE;
-}
+ /* Free memory */
+ DeleteObject(hbmp);
+ return TRUE;
+}
/*
* Internal function to determine the GDI bits per rgb and bit masks
*/
static
-Bool
-winQueryRGBBitsAndMasks (ScreenPtr pScreen)
+ Bool
+winQueryRGBBitsAndMasks(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- BITMAPINFOHEADER *pbmih = NULL;
- Bool fReturn = TRUE;
- LPDWORD pdw = NULL;
- DWORD dwRedBits, dwGreenBits, dwBlueBits;
-
- /* Color masks for 8 bpp are standardized */
- if (GetDeviceCaps (pScreenPriv->hdcScreen, RASTERCAPS) & RC_PALETTE)
- {
- /*
- * RGB BPP for 8 bit palletes is always 8
- * and the color masks are always 0.
- */
- pScreenPriv->dwBitsPerRGB = 8;
- pScreenPriv->dwRedMask = 0x0L;
- pScreenPriv->dwGreenMask = 0x0L;
- pScreenPriv->dwBlueMask = 0x0L;
- return TRUE;
+ winScreenPriv(pScreen);
+ BITMAPINFOHEADER *pbmih = NULL;
+ Bool fReturn = TRUE;
+ LPDWORD pdw = NULL;
+ DWORD dwRedBits, dwGreenBits, dwBlueBits;
+
+ /* Color masks for 8 bpp are standardized */
+ if (GetDeviceCaps(pScreenPriv->hdcScreen, RASTERCAPS) & RC_PALETTE) {
+ /*
+ * RGB BPP for 8 bit palletes is always 8
+ * and the color masks are always 0.
+ */
+ pScreenPriv->dwBitsPerRGB = 8;
+ pScreenPriv->dwRedMask = 0x0L;
+ pScreenPriv->dwGreenMask = 0x0L;
+ pScreenPriv->dwBlueMask = 0x0L;
+ return TRUE;
}
- /* Color masks for 24 bpp are standardized */
- if (GetDeviceCaps (pScreenPriv->hdcScreen, PLANES)
- * GetDeviceCaps (pScreenPriv->hdcScreen, BITSPIXEL) == 24)
- {
- winDebug ("winQueryRGBBitsAndMasks - GetDeviceCaps (BITSPIXEL) "
- "returned 24 for the screen. Using default 24bpp masks.\n");
-
- /* 8 bits per primary color */
- pScreenPriv->dwBitsPerRGB = 8;
-
- /* Set screen privates masks */
- pScreenPriv->dwRedMask = WIN_24BPP_MASK_RED;
- pScreenPriv->dwGreenMask = WIN_24BPP_MASK_GREEN;
- pScreenPriv->dwBlueMask = WIN_24BPP_MASK_BLUE;
-
- return TRUE;
+ /* Color masks for 24 bpp are standardized */
+ if (GetDeviceCaps(pScreenPriv->hdcScreen, PLANES)
+ * GetDeviceCaps(pScreenPriv->hdcScreen, BITSPIXEL) == 24) {
+ winDebug ("winQueryRGBBitsAndMasks - GetDeviceCaps (BITSPIXEL) "
+ "returned 24 for the screen. Using default 24bpp masks.\n");
+
+ /* 8 bits per primary color */
+ pScreenPriv->dwBitsPerRGB = 8;
+
+ /* Set screen privates masks */
+ pScreenPriv->dwRedMask = WIN_24BPP_MASK_RED;
+ pScreenPriv->dwGreenMask = WIN_24BPP_MASK_GREEN;
+ pScreenPriv->dwBlueMask = WIN_24BPP_MASK_BLUE;
+
+ return TRUE;
}
- /* Allocate a bitmap header and color table */
- pbmih = (BITMAPINFOHEADER*) malloc (sizeof (BITMAPINFOHEADER)
- + 256 * sizeof (RGBQUAD));
- if (pbmih == NULL)
- {
- ErrorF ("winQueryRGBBitsAndMasks - malloc failed\n");
- return FALSE;
+ /* Allocate a bitmap header and color table */
+ pbmih = (BITMAPINFOHEADER *) malloc(sizeof(BITMAPINFOHEADER)
+ + 256 * sizeof(RGBQUAD));
+ if (pbmih == NULL) {
+ ErrorF("winQueryRGBBitsAndMasks - malloc failed\n");
+ return FALSE;
}
- /* Get screen description */
- if (winQueryScreenDIBFormat (pScreen, pbmih))
- {
- /* Get a pointer to bitfields */
- pdw = (DWORD*) ((CARD8*)pbmih + sizeof (BITMAPINFOHEADER));
-
+ /* Get screen description */
+ if (winQueryScreenDIBFormat(pScreen, pbmih)) {
+ /* Get a pointer to bitfields */
+ pdw = (DWORD *) ((CARD8 *) pbmih + sizeof(BITMAPINFOHEADER));
+
#ifdef WINDBG
- winDebug ("%s - Masks: %08x %08x %08x\n", __FUNCTION__,
- pdw[0], pdw[1], pdw[2]);
- winDebug ("%s - Bitmap: %dx%d %d bpp %d planes\n", __FUNCTION__,
- pbmih->biWidth, pbmih->biHeight, pbmih->biBitCount, pbmih->biPlanes);
- winDebug ("%s - Compression: %d %s\n", __FUNCTION__,
- pbmih->biCompression,
- (pbmih->biCompression == BI_RGB?"(BI_RGB)":
- (pbmih->biCompression == BI_RLE8?"(BI_RLE8)":
- (pbmih->biCompression == BI_RLE4?"(BI_RLE4)":
- (pbmih->biCompression == BI_BITFIELDS?"(BI_BITFIELDS)":""
- )))));
+ winDebug("%s - Masks: %08x %08x %08x\n", __FUNCTION__,
+ pdw[0], pdw[1], pdw[2]);
+ winDebug("%s - Bitmap: %dx%d %d bpp %d planes\n", __FUNCTION__,
+ pbmih->biWidth, pbmih->biHeight, pbmih->biBitCount,
+ pbmih->biPlanes);
+ winDebug("%s - Compression: %d %s\n", __FUNCTION__,
+ pbmih->biCompression,
+ (pbmih->biCompression ==
+ BI_RGB ? "(BI_RGB)" : (pbmih->biCompression ==
+ BI_RLE8 ? "(BI_RLE8)" : (pbmih->
+ biCompression
+ ==
+ BI_RLE4 ?
+ "(BI_RLE4)"
+ : (pbmih->
+ biCompression
+ ==
+ BI_BITFIELDS
+ ?
+ "(BI_BITFIELDS)"
+ : "")))));
#endif
- /* Handle BI_RGB case, which is returned by Wine */
- if (pbmih->biCompression == BI_RGB)
- {
- dwRedBits = 5;
- dwGreenBits = 5;
- dwBlueBits = 5;
-
- pScreenPriv->dwBitsPerRGB = 5;
-
- /* Set screen privates masks */
- pScreenPriv->dwRedMask = 0x7c00;
- pScreenPriv->dwGreenMask = 0x03e0;
- pScreenPriv->dwBlueMask = 0x001f;
+ /* Handle BI_RGB case, which is returned by Wine */
+ if (pbmih->biCompression == BI_RGB) {
+ dwRedBits = 5;
+ dwGreenBits = 5;
+ dwBlueBits = 5;
+
+ pScreenPriv->dwBitsPerRGB = 5;
+
+ /* Set screen privates masks */
+ pScreenPriv->dwRedMask = 0x7c00;
+ pScreenPriv->dwGreenMask = 0x03e0;
+ pScreenPriv->dwBlueMask = 0x001f;
+ }
+ else {
+ /* Count the number of bits in each mask */
+ dwRedBits = winCountBits(pdw[0]);
+ dwGreenBits = winCountBits(pdw[1]);
+ dwBlueBits = winCountBits(pdw[2]);
+
+ /* Find maximum bits per red, green, blue */
+ if (dwRedBits > dwGreenBits && dwRedBits > dwBlueBits)
+ pScreenPriv->dwBitsPerRGB = dwRedBits;
+ else if (dwGreenBits > dwRedBits && dwGreenBits > dwBlueBits)
+ pScreenPriv->dwBitsPerRGB = dwGreenBits;
+ else
+ pScreenPriv->dwBitsPerRGB = dwBlueBits;
+
+ /* Set screen privates masks */
+ pScreenPriv->dwRedMask = pdw[0];
+ pScreenPriv->dwGreenMask = pdw[1];
+ pScreenPriv->dwBlueMask = pdw[2];
}
- else
- {
- /* Count the number of bits in each mask */
- dwRedBits = winCountBits (pdw[0]);
- dwGreenBits = winCountBits (pdw[1]);
- dwBlueBits = winCountBits (pdw[2]);
-
- /* Find maximum bits per red, green, blue */
- if (dwRedBits > dwGreenBits && dwRedBits > dwBlueBits)
- pScreenPriv->dwBitsPerRGB = dwRedBits;
- else if (dwGreenBits > dwRedBits && dwGreenBits > dwBlueBits)
- pScreenPriv->dwBitsPerRGB = dwGreenBits;
- else
- pScreenPriv->dwBitsPerRGB = dwBlueBits;
-
- /* Set screen privates masks */
- pScreenPriv->dwRedMask = pdw[0];
- pScreenPriv->dwGreenMask = pdw[1];
- pScreenPriv->dwBlueMask = pdw[2];
- }
}
- else
- {
- ErrorF ("winQueryRGBBitsAndMasks - winQueryScreenDIBFormat failed\n");
- fReturn = FALSE;
+ else {
+ ErrorF("winQueryRGBBitsAndMasks - winQueryScreenDIBFormat failed\n");
+ fReturn = FALSE;
}
- /* Free memory */
- free (pbmih);
+ /* Free memory */
+ free(pbmih);
- return fReturn;
+ return fReturn;
}
-
#ifdef XWIN_MULTIWINDOW
/*
* Redraw all ---?
*/
static wBOOL CALLBACK
-winRedrawAllProcShadowGDI (HWND hwnd, LPARAM lParam)
+winRedrawAllProcShadowGDI(HWND hwnd, LPARAM lParam)
{
- if (hwnd == (HWND)lParam)
- return TRUE;
- InvalidateRect (hwnd, NULL, FALSE);
- UpdateWindow (hwnd);
- return TRUE;
+ if (hwnd == (HWND) lParam)
+ return TRUE;
+ InvalidateRect(hwnd, NULL, FALSE);
+ UpdateWindow(hwnd);
+ return TRUE;
}
static wBOOL CALLBACK
-winRedrawDamagedWindowShadowGDI (HWND hwnd, LPARAM lParam)
+winRedrawDamagedWindowShadowGDI(HWND hwnd, LPARAM lParam)
{
- BoxPtr pDamage = (BoxPtr)lParam;
- RECT rcClient, rcDamage, rcRedraw;
- POINT topLeft, bottomRight;
-
- if (IsIconic (hwnd))
- return TRUE; /* Don't care minimized windows */
-
- /* Convert the damaged area from Screen coords to Client coords */
- topLeft.x = pDamage->x1; topLeft.y = pDamage->y1;
- bottomRight.x = pDamage->x2; bottomRight.y = pDamage->y2;
- topLeft.x += GetSystemMetrics (SM_XVIRTUALSCREEN);
- bottomRight.x += GetSystemMetrics (SM_XVIRTUALSCREEN);
- topLeft.y += GetSystemMetrics (SM_YVIRTUALSCREEN);
- bottomRight.y += GetSystemMetrics (SM_YVIRTUALSCREEN);
- ScreenToClient (hwnd, &topLeft);
- ScreenToClient (hwnd, &bottomRight);
- SetRect (&rcDamage, topLeft.x, topLeft.y, bottomRight.x, bottomRight.y);
-
- GetClientRect (hwnd, &rcClient);
-
- if (IntersectRect (&rcRedraw, &rcClient, &rcDamage))
- {
- InvalidateRect (hwnd, &rcRedraw, FALSE);
- UpdateWindow (hwnd);
+ BoxPtr pDamage = (BoxPtr) lParam;
+ RECT rcClient, rcDamage, rcRedraw;
+ POINT topLeft, bottomRight;
+
+ if (IsIconic(hwnd))
+ return TRUE; /* Don't care minimized windows */
+
+ /* Convert the damaged area from Screen coords to Client coords */
+ topLeft.x = pDamage->x1;
+ topLeft.y = pDamage->y1;
+ bottomRight.x = pDamage->x2;
+ bottomRight.y = pDamage->y2;
+ topLeft.x += GetSystemMetrics(SM_XVIRTUALSCREEN);
+ bottomRight.x += GetSystemMetrics(SM_XVIRTUALSCREEN);
+ topLeft.y += GetSystemMetrics(SM_YVIRTUALSCREEN);
+ bottomRight.y += GetSystemMetrics(SM_YVIRTUALSCREEN);
+ ScreenToClient(hwnd, &topLeft);
+ ScreenToClient(hwnd, &bottomRight);
+ SetRect(&rcDamage, topLeft.x, topLeft.y, bottomRight.x, bottomRight.y);
+
+ GetClientRect(hwnd, &rcClient);
+
+ if (IntersectRect(&rcRedraw, &rcClient, &rcDamage)) {
+ InvalidateRect(hwnd, &rcRedraw, FALSE);
+ UpdateWindow(hwnd);
}
- return TRUE;
+ return TRUE;
}
#endif
-
/*
* Allocate a DIB for the shadow framebuffer GDI server
*/
static Bool
-winAllocateFBShadowGDI (ScreenPtr pScreen)
+winAllocateFBShadowGDI(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- DIBSECTION dibsection;
- Bool fReturn = TRUE;
-
- /* Describe shadow bitmap to be created */
- pScreenPriv->pbmih->biWidth = pScreenInfo->dwWidth;
- pScreenPriv->pbmih->biHeight = -pScreenInfo->dwHeight;
-
- winDebug ("winAllocateFBShadowGDI - Creating DIB with width: %d height: %d "
- "depth: %d\n",
- (int) pScreenPriv->pbmih->biWidth, (int) -pScreenPriv->pbmih->biHeight, pScreenPriv->pbmih->biBitCount);
-
- /* Create a DI shadow bitmap with a bit pointer */
- pScreenPriv->hbmpShadow = CreateDIBSection (pScreenPriv->hdcScreen,
- (BITMAPINFO *) pScreenPriv->pbmih,
- DIB_RGB_COLORS,
- (VOID**) &pScreenInfo->pfb,
- NULL,
- 0);
- if (pScreenPriv->hbmpShadow == NULL || pScreenInfo->pfb == NULL)
- {
- winW32Error ("winAllocateFBShadowGDI - CreateDIBSection failed:");
- return FALSE;
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ DIBSECTION dibsection;
+ Bool fReturn = TRUE;
+
+ /* Describe shadow bitmap to be created */
+ pScreenPriv->pbmih->biWidth = pScreenInfo->dwWidth;
+ pScreenPriv->pbmih->biHeight = -pScreenInfo->dwHeight;
+
+ winDebug ("winAllocateFBShadowGDI - Creating DIB with width: %d height: %d "
+ "depth: %d\n",
+ (int) pScreenPriv->pbmih->biWidth,
+ (int) -pScreenPriv->pbmih->biHeight, pScreenPriv->pbmih->biBitCount);
+
+ /* Create a DI shadow bitmap with a bit pointer */
+ pScreenPriv->hbmpShadow = CreateDIBSection(pScreenPriv->hdcScreen,
+ (BITMAPINFO *) pScreenPriv->
+ pbmih, DIB_RGB_COLORS,
+ (VOID **) & pScreenInfo->pfb,
+ NULL, 0);
+ if (pScreenPriv->hbmpShadow == NULL || pScreenInfo->pfb == NULL) {
+ winW32Error ("winAllocateFBShadowGDI - CreateDIBSection failed:");
+ return FALSE;
}
- else
- {
- winDebug ("winAllocateFBShadowGDI - Shadow buffer allocated\n");
+ else {
+ winDebug("winAllocateFBShadowGDI - Shadow buffer allocated\n");
}
- /* Get information about the bitmap that was allocated */
- GetObject (pScreenPriv->hbmpShadow,
- sizeof (dibsection),
- &dibsection);
-
- /* Print information about bitmap allocated */
- winDebug ("winAllocateFBShadowGDI - Dibsection width: %d height: %d "
- "depth: %d size image: %d\n",
- (int) dibsection.dsBmih.biWidth, (int) dibsection.dsBmih.biHeight,
- dibsection.dsBmih.biBitCount,
- (int) dibsection.dsBmih.biSizeImage);
-
- /* Select the shadow bitmap into the shadow DC */
- SelectObject (pScreenPriv->hdcShadow,
- pScreenPriv->hbmpShadow);
-
- winDebug ("winAllocateFBShadowGDI - Attempting a shadow blit\n");
-
- /* Do a test blit from the shadow to the screen, I think */
- fReturn = BitBlt (pScreenPriv->hdcScreen,
- 0, 0,
- pScreenInfo->dwWidth, pScreenInfo->dwHeight,
- pScreenPriv->hdcShadow,
- 0, 0,
- SRCCOPY);
- if (fReturn)
- {
- winDebug ("winAllocateFBShadowGDI - Shadow blit success\n");
+ /* Get information about the bitmap that was allocated */
+ GetObject(pScreenPriv->hbmpShadow, sizeof(dibsection), &dibsection);
+
+ /* Print information about bitmap allocated */
+ winDebug("winAllocateFBShadowGDI - Dibsection width: %d height: %d "
+ "depth: %d size image: %d\n",
+ (int) dibsection.dsBmih.biWidth, (int) dibsection.dsBmih.biHeight,
+ dibsection.dsBmih.biBitCount, (int) dibsection.dsBmih.biSizeImage);
+
+ /* Select the shadow bitmap into the shadow DC */
+ SelectObject(pScreenPriv->hdcShadow, pScreenPriv->hbmpShadow);
+
+ winDebug("winAllocateFBShadowGDI - Attempting a shadow blit\n");
+
+ /* Do a test blit from the shadow to the screen, I think */
+ fReturn = BitBlt(pScreenPriv->hdcScreen,
+ 0, 0,
+ pScreenInfo->dwWidth, pScreenInfo->dwHeight,
+ pScreenPriv->hdcShadow, 0, 0, SRCCOPY);
+ if (fReturn) {
+ winDebug("winAllocateFBShadowGDI - Shadow blit success\n");
}
- else
- {
- winW32Error ("winAllocateFBShadowGDI - Shadow blit failure\n");
- /* ago: ignore this error. The blit fails with wine, but does not
- * cause any problems later. */
+ else {
+ winW32Error ("winAllocateFBShadowGDI - Shadow blit failure\n");
+ /* ago: ignore this error. The blit fails with wine, but does not
+ * cause any problems later. */
- fReturn = TRUE;
+ fReturn = TRUE;
}
- /* Look for height weirdness */
- if (dibsection.dsBmih.biHeight < 0)
- {
- dibsection.dsBmih.biHeight = -dibsection.dsBmih.biHeight;
+ /* Look for height weirdness */
+ if (dibsection.dsBmih.biHeight < 0) {
+ dibsection.dsBmih.biHeight = -dibsection.dsBmih.biHeight;
}
- /* Set screeninfo stride */
- pScreenInfo->dwStride = ((dibsection.dsBmih.biSizeImage
- / dibsection.dsBmih.biHeight)
- * 8) / pScreenInfo->dwBPP;
+ /* Set screeninfo stride */
+ pScreenInfo->dwStride = ((dibsection.dsBmih.biSizeImage
+ / dibsection.dsBmih.biHeight)
+ * 8) / pScreenInfo->dwBPP;
- winDebug ("winAllocateFBShadowGDI - Created shadow stride: %d\n",
- (int) pScreenInfo->dwStride);
+ winDebug("winAllocateFBShadowGDI - Created shadow stride: %d\n",
+ (int) pScreenInfo->dwStride);
#ifdef XWIN_MULTIWINDOW
- /* Redraw all windows */
- if (pScreenInfo->fMultiWindow)
- EnumThreadWindows (g_dwCurrentThreadID, winRedrawAllProcShadowGDI, 0);
+ /* Redraw all windows */
+ if (pScreenInfo->fMultiWindow)
+ EnumThreadWindows(g_dwCurrentThreadID, winRedrawAllProcShadowGDI, 0);
#endif
- return fReturn;
+ return fReturn;
}
static void
-winFreeFBShadowGDI (ScreenPtr pScreen)
+winFreeFBShadowGDI(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- /* Free the shadow bitmap */
- DeleteObject (pScreenPriv->hbmpShadow);
+ /* Free the shadow bitmap */
+ DeleteObject(pScreenPriv->hbmpShadow);
- /* Invalidate the ScreenInfo's fb pointer */
- pScreenInfo->pfb = NULL;
+ /* Invalidate the ScreenInfo's fb pointer */
+ pScreenInfo->pfb = NULL;
}
/*
@@ -444,160 +416,146 @@ winFreeFBShadowGDI (ScreenPtr pScreen)
*/
static void
-winShadowUpdateGDI (ScreenPtr pScreen,
- shadowBufPtr pBuf)
+winShadowUpdateGDI(ScreenPtr pScreen, shadowBufPtr pBuf)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- RegionPtr damage = shadowDamage(pBuf);
- DWORD dwBox = RegionNumRects (damage);
- BoxPtr pBox = RegionRects (damage);
- int x, y, w, h;
- HRGN hrgnTemp = NULL, hrgnCombined = NULL;
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ RegionPtr damage = shadowDamage(pBuf);
+ DWORD dwBox = RegionNumRects(damage);
+ BoxPtr pBox = RegionRects(damage);
+ int x, y, w, h;
+ HRGN hrgnTemp = NULL, hrgnCombined = NULL;
+
#ifdef XWIN_UPDATESTATS
- static DWORD s_dwNonUnitRegions = 0;
- static DWORD s_dwTotalUpdates = 0;
- static DWORD s_dwTotalBoxes = 0;
+ static DWORD s_dwNonUnitRegions = 0;
+ static DWORD s_dwTotalUpdates = 0;
+ static DWORD s_dwTotalBoxes = 0;
#endif
- BoxPtr pBoxExtents = RegionExtents(damage);
+ BoxPtr pBoxExtents = RegionExtents(damage);
- /*
- * Return immediately if the app is not active
- * and we are fullscreen, or if we have a bad display depth
- */
- if ((!pScreenPriv->fActive && pScreenInfo->fFullScreen)
- || pScreenPriv->fBadDepth) return;
+ /*
+ * Return immediately if the app is not active
+ * and we are fullscreen, or if we have a bad display depth
+ */
+ if ((!pScreenPriv->fActive && pScreenInfo->fFullScreen)
+ || pScreenPriv->fBadDepth)
+ return;
#ifdef XWIN_UPDATESTATS
- ++s_dwTotalUpdates;
- s_dwTotalBoxes += dwBox;
+ ++s_dwTotalUpdates;
+ s_dwTotalBoxes += dwBox;
- if (dwBox != 1)
- {
- ++s_dwNonUnitRegions;
- winDebug ("winShadowUpdatGDI - dwBox: %d\n", dwBox);
+ if (dwBox != 1) {
+ ++s_dwNonUnitRegions;
+ winDebug ("winShadowUpdatGDI - dwBox: %d\n", dwBox);
}
-
- if ((s_dwTotalUpdates % 100) == 0)
- {
- winDebug ("winShadowUpdateGDI - %d%% non-unity regions, avg boxes: %d "
- "nu: %d tu: %d\n",
- (s_dwNonUnitRegions * 100) / s_dwTotalUpdates,
- s_dwTotalBoxes / s_dwTotalUpdates,
- s_dwNonUnitRegions, s_dwTotalUpdates);
+
+ if ((s_dwTotalUpdates % 100) == 0)
+ winDebug ("winShadowUpdateGDI - %d%% non-unity regions, avg boxes: %d "
+ "nu: %d tu: %d\n",
+ (s_dwNonUnitRegions * 100) / s_dwTotalUpdates,
+ s_dwTotalBoxes / s_dwTotalUpdates,
+ s_dwNonUnitRegions, s_dwTotalUpdates);
}
-#endif /* XWIN_UPDATESTATS */
-
- /*
- * Handle small regions with multiple blits,
- * handle large regions by creating a clipping region and
- * doing a single blit constrained to that clipping region.
- */
- if (!pScreenInfo->fMultiWindow &&
- (pScreenInfo->dwClipUpdatesNBoxes == 0 ||
- dwBox < pScreenInfo->dwClipUpdatesNBoxes))
- {
- /* Loop through all boxes in the damaged region */
- while (dwBox--)
- {
- /*
- * Calculate x offset, y offset, width, and height for
- * current damage box
- */
- x = pBox->x1;
- y = pBox->y1;
- w = pBox->x2 - pBox->x1;
- h = pBox->y2 - pBox->y1;
-
- BitBlt (pScreenPriv->hdcScreen,
- x, y,
- w, h,
- pScreenPriv->hdcShadow,
- x, y,
- SRCCOPY);
-
- /* Get a pointer to the next box */
- ++pBox;
- }
+#endif /* XWIN_UPDATESTATS */
+
+ /*
+ * Handle small regions with multiple blits,
+ * handle large regions by creating a clipping region and
+ * doing a single blit constrained to that clipping region.
+ */
+ if (!pScreenInfo->fMultiWindow &&
+ (pScreenInfo->dwClipUpdatesNBoxes == 0 ||
+ dwBox < pScreenInfo->dwClipUpdatesNBoxes)) {
+ /* Loop through all boxes in the damaged region */
+ while (dwBox--) {
+ /*
+ * Calculate x offset, y offset, width, and height for
+ * current damage box
+ */
+ x = pBox->x1;
+ y = pBox->y1;
+ w = pBox->x2 - pBox->x1;
+ h = pBox->y2 - pBox->y1;
+
+ BitBlt(pScreenPriv->hdcScreen,
+ x, y, w, h, pScreenPriv->hdcShadow, x, y, SRCCOPY);
+
+ /* Get a pointer to the next box */
+ ++pBox;
+ }
}
- else if (!pScreenInfo->fMultiWindow)
- {
- /* Compute a GDI region from the damaged region */
- hrgnCombined = CreateRectRgn (pBox->x1, pBox->y1, pBox->x2, pBox->y2);
- dwBox--;
- pBox++;
- while (dwBox--)
- {
- hrgnTemp = CreateRectRgn (pBox->x1, pBox->y1, pBox->x2, pBox->y2);
- CombineRgn (hrgnCombined, hrgnCombined, hrgnTemp, RGN_OR);
- DeleteObject (hrgnTemp);
- pBox++;
- }
-
- /* Install the GDI region as a clipping region */
- SelectClipRgn (pScreenPriv->hdcScreen, hrgnCombined);
- DeleteObject (hrgnCombined);
- hrgnCombined = NULL;
-
- /*
- * Blit the shadow buffer to the screen,
- * constrained to the clipping region.
- */
- BitBlt (pScreenPriv->hdcScreen,
- pBoxExtents->x1, pBoxExtents->y1,
- pBoxExtents->x2 - pBoxExtents->x1,
- pBoxExtents->y2 - pBoxExtents->y1,
- pScreenPriv->hdcShadow,
- pBoxExtents->x1, pBoxExtents->y1,
- SRCCOPY);
-
- /* Reset the clip region */
- SelectClipRgn (pScreenPriv->hdcScreen, NULL);
+ else if (!pScreenInfo->fMultiWindow) {
+ /* Compute a GDI region from the damaged region */
+ hrgnCombined = CreateRectRgn(pBox->x1, pBox->y1, pBox->x2, pBox->y2);
+ dwBox--;
+ pBox++;
+ while (dwBox--) {
+ hrgnTemp = CreateRectRgn(pBox->x1, pBox->y1, pBox->x2, pBox->y2);
+ CombineRgn(hrgnCombined, hrgnCombined, hrgnTemp, RGN_OR);
+ DeleteObject(hrgnTemp);
+ pBox++;
+ }
+
+ /* Install the GDI region as a clipping region */
+ SelectClipRgn(pScreenPriv->hdcScreen, hrgnCombined);
+ DeleteObject(hrgnCombined);
+ hrgnCombined = NULL;
+
+ /*
+ * Blit the shadow buffer to the screen,
+ * constrained to the clipping region.
+ */
+ BitBlt(pScreenPriv->hdcScreen,
+ pBoxExtents->x1, pBoxExtents->y1,
+ pBoxExtents->x2 - pBoxExtents->x1,
+ pBoxExtents->y2 - pBoxExtents->y1,
+ pScreenPriv->hdcShadow,
+ pBoxExtents->x1, pBoxExtents->y1, SRCCOPY);
+
+ /* Reset the clip region */
+ SelectClipRgn(pScreenPriv->hdcScreen, NULL);
}
#ifdef XWIN_MULTIWINDOW
- /* Redraw all multiwindow windows */
- if (pScreenInfo->fMultiWindow)
- EnumThreadWindows (g_dwCurrentThreadID,
- winRedrawDamagedWindowShadowGDI,
- (LPARAM)pBoxExtents);
+ /* Redraw all multiwindow windows */
+ if (pScreenInfo->fMultiWindow)
+ EnumThreadWindows(g_dwCurrentThreadID,
+ winRedrawDamagedWindowShadowGDI,
+ (LPARAM) pBoxExtents);
#endif
}
-
static Bool
-winInitScreenShadowGDI (ScreenPtr pScreen)
+winInitScreenShadowGDI(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
-
- /* Get device contexts for the screen and shadow bitmap */
- pScreenPriv->hdcScreen = GetDC (pScreenPriv->hwndScreen);
- pScreenPriv->hdcShadow = CreateCompatibleDC (pScreenPriv->hdcScreen);
-
- /* Allocate bitmap info header */
- pScreenPriv->pbmih = (BITMAPINFOHEADER*) malloc (sizeof (BITMAPINFOHEADER)
- + 256 * sizeof (RGBQUAD));
- if (pScreenPriv->pbmih == NULL)
- {
- ErrorF ("winInitScreenShadowGDI - malloc () failed\n");
- return FALSE;
+ winScreenPriv(pScreen);
+
+ /* Get device contexts for the screen and shadow bitmap */
+ pScreenPriv->hdcScreen = GetDC(pScreenPriv->hwndScreen);
+ pScreenPriv->hdcShadow = CreateCompatibleDC(pScreenPriv->hdcScreen);
+
+ /* Allocate bitmap info header */
+ pScreenPriv->pbmih = (BITMAPINFOHEADER *) malloc(sizeof(BITMAPINFOHEADER)
+ + 256 * sizeof(RGBQUAD));
+ if (pScreenPriv->pbmih == NULL) {
+ ErrorF("winInitScreenShadowGDI - malloc () failed\n");
+ return FALSE;
}
- /* Query the screen format */
- if (!winQueryScreenDIBFormat (pScreen, pScreenPriv->pbmih))
- {
- ErrorF ("winInitScreenShadowGDI - winQueryScreenDIBFormat failed\n");
- return FALSE;
+ /* Query the screen format */
+ if (!winQueryScreenDIBFormat(pScreen, pScreenPriv->pbmih)) {
+ ErrorF("winInitScreenShadowGDI - winQueryScreenDIBFormat failed\n");
+ return FALSE;
}
- /* Determine our color masks */
- if (!winQueryRGBBitsAndMasks (pScreen))
- {
- ErrorF ("winInitScreenShadowGDI - winQueryRGBBitsAndMasks failed\n");
- return FALSE;
+ /* Determine our color masks */
+ if (!winQueryRGBBitsAndMasks(pScreen)) {
+ ErrorF("winInitScreenShadowGDI - winQueryRGBBitsAndMasks failed\n");
+ return FALSE;
}
- return winAllocateFBShadowGDI(pScreen);
+ return winAllocateFBShadowGDI(pScreen);
}
/* See Porting Layer Definition - p. 33 */
@@ -607,67 +565,64 @@ winInitScreenShadowGDI (ScreenPtr pScreen)
*/
static Bool
-winCloseScreenShadowGDI (int nIndex, ScreenPtr pScreen)
+winCloseScreenShadowGDI(int nIndex, ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- Bool fReturn;
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ Bool fReturn;
- winDebug ("winCloseScreenShadowGDI - Freeing screen resources\n");
+ winDebug("winCloseScreenShadowGDI - Freeing screen resources\n");
- /* Flag that the screen is closed */
- pScreenPriv->fClosed = TRUE;
- pScreenPriv->fActive = FALSE;
+ /* Flag that the screen is closed */
+ pScreenPriv->fClosed = TRUE;
+ pScreenPriv->fActive = FALSE;
- /* Call the wrapped CloseScreen procedure */
- WIN_UNWRAP(CloseScreen);
- if (pScreen->CloseScreen)
- fReturn = (*pScreen->CloseScreen) (nIndex, pScreen);
+ /* Call the wrapped CloseScreen procedure */
+ WIN_UNWRAP(CloseScreen);
+ if (pScreen->CloseScreen)
+ fReturn = (*pScreen->CloseScreen) (nIndex, pScreen);
- /* Delete the window property */
- RemoveProp (pScreenPriv->hwndScreen, WIN_SCR_PROP);
+ /* Delete the window property */
+ RemoveProp(pScreenPriv->hwndScreen, WIN_SCR_PROP);
- /* Free the shadow DC; which allows the bitmap to be freed */
- DeleteDC (pScreenPriv->hdcShadow);
+ /* Free the shadow DC; which allows the bitmap to be freed */
+ DeleteDC(pScreenPriv->hdcShadow);
- winFreeFBShadowGDI(pScreen);
+ winFreeFBShadowGDI(pScreen);
- /* Free the screen DC */
- ReleaseDC (pScreenPriv->hwndScreen, pScreenPriv->hdcScreen);
+ /* Free the screen DC */
+ ReleaseDC(pScreenPriv->hwndScreen, pScreenPriv->hdcScreen);
- /* Delete tray icon, if we have one */
- if (!pScreenInfo->fNoTrayIcon)
- winDeleteNotifyIcon (pScreenPriv);
+ /* Delete tray icon, if we have one */
+ if (!pScreenInfo->fNoTrayIcon)
+ winDeleteNotifyIcon(pScreenPriv);
- /* Free the exit confirmation dialog box, if it exists */
- if (g_hDlgExit != NULL)
- {
- DestroyWindow (g_hDlgExit);
- g_hDlgExit = NULL;
+ /* Free the exit confirmation dialog box, if it exists */
+ if (g_hDlgExit != NULL) {
+ DestroyWindow(g_hDlgExit);
+ g_hDlgExit = NULL;
}
- /* Kill our window */
- if (pScreenPriv->hwndScreen)
- {
- DestroyWindow (pScreenPriv->hwndScreen);
- pScreenPriv->hwndScreen = NULL;
+ /* Kill our window */
+ if (pScreenPriv->hwndScreen) {
+ DestroyWindow(pScreenPriv->hwndScreen);
+ pScreenPriv->hwndScreen = NULL;
}
#if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW)
- /* Destroy the thread startup mutex */
- if (pScreenPriv->pmServerStarted) pthread_mutex_destroy (&pScreenPriv->pmServerStarted);
+ /* Destroy the thread startup mutex */
+ if (pScreenPriv->pmServerStarted) pthread_mutex_destroy (&pScreenPriv->pmServerStarted);
#endif
- /* Invalidate our screeninfo's pointer to the screen */
- pScreenInfo->pScreen = NULL;
+ /* Invalidate our screeninfo's pointer to the screen */
+ pScreenInfo->pScreen = NULL;
- /* Free the screen privates for this screen */
- free ((pointer) pScreenPriv);
+ /* Free the screen privates for this screen */
+ free((pointer) pScreenPriv);
- return fReturn;
+ return fReturn;
}
-
/*
* Tell mi what sort of visuals we need.
*
@@ -677,561 +632,510 @@ winCloseScreenShadowGDI (int nIndex, ScreenPtr pScreen)
*/
static Bool
-winInitVisualsShadowGDI (ScreenPtr pScreen)
+winInitVisualsShadowGDI(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-
- /* Display debugging information */
- winDebug ("winInitVisualsShadowGDI - Masks %08x %08x %08x BPRGB %d d %d "
- "bpp %d\n",
- (unsigned int) pScreenPriv->dwRedMask,
- (unsigned int) pScreenPriv->dwGreenMask,
- (unsigned int) pScreenPriv->dwBlueMask,
- (int) pScreenPriv->dwBitsPerRGB,
- (int) pScreenInfo->dwDepth,
- (int) pScreenInfo->dwBPP);
-
- /* Create a single visual according to the Windows screen depth */
- switch (pScreenInfo->dwDepth)
- {
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /* Display debugging information */
+ winDebug ("winInitVisualsShadowGDI - Masks %08x %08x %08x BPRGB %d d %d "
+ "bpp %d\n",
+ (unsigned int) pScreenPriv->dwRedMask,
+ (unsigned int) pScreenPriv->dwGreenMask,
+ (unsigned int) pScreenPriv->dwBlueMask,
+ (int) pScreenPriv->dwBitsPerRGB,
+ (int) pScreenInfo->dwDepth, (int) pScreenInfo->dwBPP);
+
+ /* Create a single visual according to the Windows screen depth */
+ switch (pScreenInfo->dwDepth) {
case 24:
case 16:
case 15:
- /* Setup the real visual */
- if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
- TrueColorMask,
- pScreenPriv->dwBitsPerRGB,
- -1,
- pScreenPriv->dwRedMask,
- pScreenPriv->dwGreenMask,
- pScreenPriv->dwBlueMask))
- {
- ErrorF ("winInitVisualsShadowGDI - miSetVisualTypesAndMasks "
- "failed\n");
- return FALSE;
- }
+ /* Setup the real visual */
+ if (!miSetVisualTypesAndMasks(pScreenInfo->dwDepth,
+ TrueColorMask,
+ pScreenPriv->dwBitsPerRGB,
+ -1,
+ pScreenPriv->dwRedMask,
+ pScreenPriv->dwGreenMask,
+ pScreenPriv->dwBlueMask)) {
+ ErrorF("winInitVisualsShadowGDI - miSetVisualTypesAndMasks "
+ "failed\n");
+ return FALSE;
+ }
#ifdef XWIN_EMULATEPSEUDO
- if (!pScreenInfo->fEmulatePseudo)
- break;
-
- /* Setup a pseudocolor visual */
- if (!miSetVisualTypesAndMasks (8,
- PseudoColorMask,
- 8,
- -1,
- 0,
- 0,
- 0))
- {
- ErrorF ("winInitVisualsShadowGDI - miSetVisualTypesAndMasks "
- "failed for PseudoColor\n");
- return FALSE;
- }
+ if (!pScreenInfo->fEmulatePseudo)
+ break;
+
+ /* Setup a pseudocolor visual */
+ if (!miSetVisualTypesAndMasks(8, PseudoColorMask, 8, -1, 0, 0, 0)) {
+ ErrorF("winInitVisualsShadowGDI - miSetVisualTypesAndMasks "
+ "failed for PseudoColor\n");
+ return FALSE;
+ }
#endif
- break;
+ break;
case 8:
- if (!miSetVisualTypesAndMasks (pScreenInfo->dwDepth,
- PseudoColorMask,
- pScreenPriv->dwBitsPerRGB,
- PseudoColor,
- pScreenPriv->dwRedMask,
- pScreenPriv->dwGreenMask,
- pScreenPriv->dwBlueMask))
- {
- ErrorF ("winInitVisualsShadowGDI - miSetVisualTypesAndMasks "
- "failed\n");
- return FALSE;
- }
- break;
+ if (!miSetVisualTypesAndMasks(pScreenInfo->dwDepth,
+ PseudoColorMask,
+ pScreenPriv->dwBitsPerRGB,
+ PseudoColor,
+ pScreenPriv->dwRedMask,
+ pScreenPriv->dwGreenMask,
+ pScreenPriv->dwBlueMask)) {
+ ErrorF("winInitVisualsShadowGDI - miSetVisualTypesAndMasks "
+ "failed\n");
+ return FALSE;
+ }
+ break;
default:
- ErrorF ("winInitVisualsShadowGDI - Unknown screen depth\n");
- return FALSE;
+ ErrorF("winInitVisualsShadowGDI - Unknown screen depth\n");
+ return FALSE;
}
- winDebug ("winInitVisualsShadowGDI - Returning\n");
+ winDebug("winInitVisualsShadowGDI - Returning\n");
- return TRUE;
+ return TRUE;
}
-
/*
* Adjust the proposed video mode
*/
static Bool
-winAdjustVideoModeShadowGDI (ScreenPtr pScreen)
+winAdjustVideoModeShadowGDI(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- HDC hdc;
- DWORD dwBPP;
-
- hdc = GetDC (NULL);
-
- /* We're in serious trouble if we can't get a DC */
- if (hdc == NULL)
- {
- ErrorF ("winAdjustVideoModeShadowGDI - GetDC () failed\n");
- return FALSE;
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ HDC hdc;
+ DWORD dwBPP;
+
+ hdc = GetDC(NULL);
+
+ /* We're in serious trouble if we can't get a DC */
+ if (hdc == NULL) {
+ ErrorF("winAdjustVideoModeShadowGDI - GetDC () failed\n");
+ return FALSE;
}
- /* Query GDI for current display depth */
- dwBPP = GetDeviceCaps (hdc, BITSPIXEL);
+ /* Query GDI for current display depth */
+ dwBPP = GetDeviceCaps(hdc, BITSPIXEL);
- /* GDI cannot change the screen depth, so always use GDI's depth */
- pScreenInfo->dwBPP = dwBPP;
+ /* GDI cannot change the screen depth, so always use GDI's depth */
+ pScreenInfo->dwBPP = dwBPP;
- /* Release our DC */
- ReleaseDC (NULL, hdc);
- hdc = NULL;
+ /* Release our DC */
+ ReleaseDC(NULL, hdc);
+ hdc = NULL;
- return TRUE;
+ return TRUE;
}
-
/*
* Blt exposed regions to the screen
*/
static Bool
-winBltExposedRegionsShadowGDI (ScreenPtr pScreen)
+winBltExposedRegionsShadowGDI(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- winPrivCmapPtr pCmapPriv = NULL;
- HDC hdcUpdate;
- PAINTSTRUCT ps;
-
- /* BeginPaint gives us an hdc that clips to the invalidated region */
- hdcUpdate = BeginPaint (pScreenPriv->hwndScreen, &ps);
-
- /* Realize the palette, if we have one */
- if (pScreenPriv->pcmapInstalled != NULL)
- {
- pCmapPriv = winGetCmapPriv (pScreenPriv->pcmapInstalled);
-
- SelectPalette (hdcUpdate, pCmapPriv->hPalette, FALSE);
- RealizePalette (hdcUpdate);
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ winPrivCmapPtr pCmapPriv = NULL;
+ HDC hdcUpdate;
+ PAINTSTRUCT ps;
+
+ /* BeginPaint gives us an hdc that clips to the invalidated region */
+ hdcUpdate = BeginPaint(pScreenPriv->hwndScreen, &ps);
+
+ /* Realize the palette, if we have one */
+ if (pScreenPriv->pcmapInstalled != NULL) {
+ pCmapPriv = winGetCmapPriv(pScreenPriv->pcmapInstalled);
+
+ SelectPalette(hdcUpdate, pCmapPriv->hPalette, FALSE);
+ RealizePalette(hdcUpdate);
}
- /* Our BitBlt will be clipped to the invalidated region */
- BitBlt (hdcUpdate,
- 0, 0,
- pScreenInfo->dwWidth, pScreenInfo->dwHeight,
- pScreenPriv->hdcShadow,
- 0, 0,
- SRCCOPY);
+ /* 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);
+ /* EndPaint frees the DC */
+ EndPaint(pScreenPriv->hwndScreen, &ps);
#ifdef XWIN_MULTIWINDOW
- /* Redraw all windows */
- if (pScreenInfo->fMultiWindow)
- EnumThreadWindows(g_dwCurrentThreadID, winRedrawAllProcShadowGDI,
- (LPARAM)pScreenPriv->hwndScreen);
+ /* Redraw all windows */
+ if (pScreenInfo->fMultiWindow)
+ EnumThreadWindows(g_dwCurrentThreadID, winRedrawAllProcShadowGDI,
+ (LPARAM) pScreenPriv->hwndScreen);
#endif
- return TRUE;
+ return TRUE;
}
-
/*
* Do any engine-specific appliation-activation processing
*/
static Bool
-winActivateAppShadowGDI (ScreenPtr pScreen)
+winActivateAppShadowGDI(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-
- /*
- * 2004/04/12 - Harold - We perform the restoring or minimizing
- * manually for ShadowGDI in fullscreen modes so that this engine
- * will perform just like ShadowDD and ShadowDDNL in fullscreen mode;
- * if we do not do this then our fullscreen window will appear in the
- * z-order when it is deactivated and it can be uncovered by resizing
- * or minimizing another window that is on top of it, which is not how
- * the DirectDraw engines work. Therefore we keep this code here to
- * make sure that all engines work the same in fullscreen mode.
- */
-
- /*
- * Are we active?
- * Are we fullscreen?
- */
- if (pScreenPriv->fActive
- && pScreenInfo->fFullScreen)
- {
- /*
- * Activating, attempt to bring our window
- * to the top of the display
- */
- ShowWindow (pScreenPriv->hwndScreen, SW_RESTORE);
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /*
+ * 2004/04/12 - Harold - We perform the restoring or minimizing
+ * manually for ShadowGDI in fullscreen modes so that this engine
+ * will perform just like ShadowDD and ShadowDDNL in fullscreen mode;
+ * if we do not do this then our fullscreen window will appear in the
+ * z-order when it is deactivated and it can be uncovered by resizing
+ * or minimizing another window that is on top of it, which is not how
+ * the DirectDraw engines work. Therefore we keep this code here to
+ * make sure that all engines work the same in fullscreen mode.
+ */
+
+ /*
+ * Are we active?
+ * Are we fullscreen?
+ */
+ if (pScreenPriv->fActive && pScreenInfo->fFullScreen) {
+ /*
+ * Activating, attempt to bring our window
+ * to the top of the display
+ */
+ ShowWindow(pScreenPriv->hwndScreen, SW_RESTORE);
}
- else if (!pScreenPriv->fActive
- && pScreenInfo->fFullScreen)
- {
- /*
- * Deactivating, stuff our window onto the
- * task bar.
- */
- ShowWindow (pScreenPriv->hwndScreen, SW_MINIMIZE);
+ else if (!pScreenPriv->fActive && pScreenInfo->fFullScreen) {
+ /*
+ * Deactivating, stuff our window onto the
+ * task bar.
+ */
+ ShowWindow(pScreenPriv->hwndScreen, SW_MINIMIZE);
}
- return TRUE;
+ return TRUE;
}
-
/*
* Reblit the shadow framebuffer to the screen.
*/
static Bool
-winRedrawScreenShadowGDI (ScreenPtr pScreen)
+winRedrawScreenShadowGDI(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- /* Redraw the whole window, to take account for the new colors */
- BitBlt (pScreenPriv->hdcScreen,
- 0, 0,
- pScreenInfo->dwWidth, pScreenInfo->dwHeight,
- pScreenPriv->hdcShadow,
- 0, 0,
- SRCCOPY);
+ /* Redraw the whole window, to take account for the new colors */
+ BitBlt(pScreenPriv->hdcScreen,
+ 0, 0,
+ pScreenInfo->dwWidth, pScreenInfo->dwHeight,
+ pScreenPriv->hdcShadow, 0, 0, SRCCOPY);
#ifdef XWIN_MULTIWINDOW
- /* Redraw all windows */
- if (pScreenInfo->fMultiWindow)
- EnumThreadWindows(g_dwCurrentThreadID, winRedrawAllProcShadowGDI, 0);
+ /* Redraw all windows */
+ if (pScreenInfo->fMultiWindow)
+ EnumThreadWindows(g_dwCurrentThreadID, winRedrawAllProcShadowGDI, 0);
#endif
- return TRUE;
+ return TRUE;
}
-
-
/*
* Realize the currently installed colormap
*/
static Bool
-winRealizeInstalledPaletteShadowGDI (ScreenPtr pScreen)
+winRealizeInstalledPaletteShadowGDI(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- winPrivCmapPtr pCmapPriv = NULL;
+ winScreenPriv(pScreen);
+ winPrivCmapPtr pCmapPriv = NULL;
- winDebug ("winRealizeInstalledPaletteShadowGDI\n");
+ winDebug("winRealizeInstalledPaletteShadowGDI\n");
- /* Don't do anything if there is not a colormap */
- if (pScreenPriv->pcmapInstalled == NULL)
- {
- winDebug ("winRealizeInstalledPaletteShadowGDI - No colormap "
- "installed\n");
- return TRUE;
+ /* Don't do anything if there is not a colormap */
+ if (pScreenPriv->pcmapInstalled == NULL) {
+ winDebug("winRealizeInstalledPaletteShadowGDI - No colormap "
+ "installed\n");
+ return TRUE;
}
- pCmapPriv = winGetCmapPriv (pScreenPriv->pcmapInstalled);
-
- /* Realize our palette for the screen */
- if (RealizePalette (pScreenPriv->hdcScreen) == GDI_ERROR)
- {
- ErrorF ("winRealizeInstalledPaletteShadowGDI - RealizePalette () "
- "failed\n");
- return FALSE;
+ pCmapPriv = winGetCmapPriv(pScreenPriv->pcmapInstalled);
+
+ /* Realize our palette for the screen */
+ if (RealizePalette(pScreenPriv->hdcScreen) == GDI_ERROR) {
+ ErrorF("winRealizeInstalledPaletteShadowGDI - RealizePalette () "
+ "failed\n");
+ return FALSE;
}
-
- /* Set the DIB color table */
- if (SetDIBColorTable (pScreenPriv->hdcShadow,
- 0,
- WIN_NUM_PALETTE_ENTRIES,
- pCmapPriv->rgbColors) == 0)
- {
- ErrorF ("winRealizeInstalledPaletteShadowGDI - SetDIBColorTable () "
- "failed\n");
- return FALSE;
+
+ /* Set the DIB color table */
+ if (SetDIBColorTable(pScreenPriv->hdcShadow,
+ 0,
+ WIN_NUM_PALETTE_ENTRIES, pCmapPriv->rgbColors) == 0) {
+ ErrorF("winRealizeInstalledPaletteShadowGDI - SetDIBColorTable () "
+ "failed\n");
+ return FALSE;
}
-
- return TRUE;
-}
+ return TRUE;
+}
/*
* Install the specified colormap
*/
static Bool
-winInstallColormapShadowGDI (ColormapPtr pColormap)
+winInstallColormapShadowGDI(ColormapPtr pColormap)
{
- ScreenPtr pScreen = pColormap->pScreen;
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- winCmapPriv(pColormap);
-
- /*
- * Tell Windows to install the new colormap
- */
- if (SelectPalette (pScreenPriv->hdcScreen,
- pCmapPriv->hPalette,
- FALSE) == NULL)
- {
- ErrorF ("winInstallColormapShadowGDI - SelectPalette () failed\n");
- return FALSE;
+ ScreenPtr pScreen = pColormap->pScreen;
+
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ winCmapPriv(pColormap);
+
+ /*
+ * Tell Windows to install the new colormap
+ */
+ if (SelectPalette(pScreenPriv->hdcScreen,
+ pCmapPriv->hPalette, FALSE) == NULL) {
+ ErrorF("winInstallColormapShadowGDI - SelectPalette () failed\n");
+ return FALSE;
}
-
- /* Realize the palette */
- if (GDI_ERROR == RealizePalette (pScreenPriv->hdcScreen))
- {
- ErrorF ("winInstallColormapShadowGDI - RealizePalette () failed\n");
- return FALSE;
+
+ /* Realize the palette */
+ if (GDI_ERROR == RealizePalette(pScreenPriv->hdcScreen)) {
+ ErrorF("winInstallColormapShadowGDI - RealizePalette () failed\n");
+ return FALSE;
}
- /* Set the DIB color table */
- if (SetDIBColorTable (pScreenPriv->hdcShadow,
- 0,
- WIN_NUM_PALETTE_ENTRIES,
- pCmapPriv->rgbColors) == 0)
- {
- ErrorF ("winInstallColormapShadowGDI - SetDIBColorTable () failed\n");
- return FALSE;
+ /* Set the DIB color table */
+ if (SetDIBColorTable(pScreenPriv->hdcShadow,
+ 0,
+ WIN_NUM_PALETTE_ENTRIES, pCmapPriv->rgbColors) == 0) {
+ ErrorF("winInstallColormapShadowGDI - SetDIBColorTable () failed\n");
+ return FALSE;
}
- /* Redraw the whole window, to take account for the new colors */
- BitBlt (pScreenPriv->hdcScreen,
- 0, 0,
- pScreenInfo->dwWidth, pScreenInfo->dwHeight,
- pScreenPriv->hdcShadow,
- 0, 0,
- SRCCOPY);
+ /* Redraw the whole window, to take account for the new colors */
+ BitBlt(pScreenPriv->hdcScreen,
+ 0, 0,
+ pScreenInfo->dwWidth, pScreenInfo->dwHeight,
+ pScreenPriv->hdcShadow, 0, 0, SRCCOPY);
- /* Save a pointer to the newly installed colormap */
- pScreenPriv->pcmapInstalled = pColormap;
+ /* Save a pointer to the newly installed colormap */
+ pScreenPriv->pcmapInstalled = pColormap;
#ifdef XWIN_MULTIWINDOW
- /* Redraw all windows */
- if (pScreenInfo->fMultiWindow)
- EnumThreadWindows (g_dwCurrentThreadID, winRedrawAllProcShadowGDI, 0);
+ /* Redraw all windows */
+ if (pScreenInfo->fMultiWindow)
+ EnumThreadWindows(g_dwCurrentThreadID, winRedrawAllProcShadowGDI, 0);
#endif
- return TRUE;
+ return TRUE;
}
-
/*
* Store the specified colors in the specified colormap
*/
static Bool
-winStoreColorsShadowGDI (ColormapPtr pColormap,
- int ndef,
- xColorItem *pdefs)
+winStoreColorsShadowGDI(ColormapPtr pColormap, int ndef, xColorItem * pdefs)
{
- ScreenPtr pScreen = pColormap->pScreen;
- winScreenPriv(pScreen);
- winCmapPriv(pColormap);
- ColormapPtr curpmap = pScreenPriv->pcmapInstalled;
-
- /* Put the X colormap entries into the Windows logical palette */
- if (SetPaletteEntries (pCmapPriv->hPalette,
- pdefs[0].pixel,
- ndef,
- pCmapPriv->peColors + pdefs[0].pixel) == 0)
- {
- ErrorF ("winStoreColorsShadowGDI - SetPaletteEntries () failed\n");
- return FALSE;
+ ScreenPtr pScreen = pColormap->pScreen;
+
+ winScreenPriv(pScreen);
+ winCmapPriv(pColormap);
+ ColormapPtr curpmap = pScreenPriv->pcmapInstalled;
+
+ /* Put the X colormap entries into the Windows logical palette */
+ if (SetPaletteEntries(pCmapPriv->hPalette,
+ pdefs[0].pixel,
+ ndef, pCmapPriv->peColors + pdefs[0].pixel) == 0) {
+ ErrorF("winStoreColorsShadowGDI - SetPaletteEntries () failed\n");
+ return FALSE;
}
- /* Don't install the Windows palette if the colormap is not installed */
- if (pColormap != curpmap)
- {
- return TRUE;
+ /* Don't install the Windows palette if the colormap is not installed */
+ if (pColormap != curpmap) {
+ return TRUE;
}
- /* Try to install the newly modified colormap */
- if (!winInstallColormapShadowGDI (pColormap))
- {
- ErrorF ("winInstallColormapShadowGDI - winInstallColormapShadowGDI "
- "failed\n");
- return FALSE;
+ /* Try to install the newly modified colormap */
+ if (!winInstallColormapShadowGDI(pColormap)) {
+ ErrorF("winInstallColormapShadowGDI - winInstallColormapShadowGDI "
+ "failed\n");
+ return FALSE;
}
#if 0
- /* Tell Windows that the palette has changed */
- RealizePalette (pScreenPriv->hdcScreen);
-
- /* Set the DIB color table */
- if (SetDIBColorTable (pScreenPriv->hdcShadow,
- pdefs[0].pixel,
- ndef,
- pCmapPriv->rgbColors + pdefs[0].pixel) == 0)
- {
- ErrorF ("winInstallColormapShadowGDI - SetDIBColorTable () failed\n");
- return FALSE;
+ /* Tell Windows that the palette has changed */
+ RealizePalette(pScreenPriv->hdcScreen);
+
+ /* Set the DIB color table */
+ if (SetDIBColorTable(pScreenPriv->hdcShadow,
+ pdefs[0].pixel,
+ ndef, pCmapPriv->rgbColors + pdefs[0].pixel) == 0) {
+ ErrorF("winInstallColormapShadowGDI - SetDIBColorTable () failed\n");
+ return FALSE;
}
- /* Save a pointer to the newly installed colormap */
- pScreenPriv->pcmapInstalled = pColormap;
+ /* Save a pointer to the newly installed colormap */
+ pScreenPriv->pcmapInstalled = pColormap;
#endif
- return TRUE;
+ return TRUE;
}
-
/*
* Colormap initialization procedure
*/
static Bool
-winCreateColormapShadowGDI (ColormapPtr pColormap)
+winCreateColormapShadowGDI(ColormapPtr pColormap)
{
- LPLOGPALETTE lpPaletteNew = NULL;
- DWORD dwEntriesMax;
- VisualPtr pVisual;
- HPALETTE hpalNew = NULL;
- winCmapPriv(pColormap);
-
- /* Get a pointer to the visual that the colormap belongs to */
- pVisual = pColormap->pVisual;
-
- /* Get the maximum number of palette entries for this visual */
- dwEntriesMax = pVisual->ColormapEntries;
-
- /* Allocate a Windows logical color palette with max entries */
- lpPaletteNew = malloc (sizeof (LOGPALETTE)
- + (dwEntriesMax - 1) * sizeof (PALETTEENTRY));
- if (lpPaletteNew == NULL)
- {
- ErrorF ("winCreateColormapShadowGDI - Couldn't allocate palette "
- "with %d entries\n",
- (int) dwEntriesMax);
- return FALSE;
+ LPLOGPALETTE lpPaletteNew = NULL;
+ DWORD dwEntriesMax;
+ VisualPtr pVisual;
+ HPALETTE hpalNew = NULL;
+
+ winCmapPriv(pColormap);
+
+ /* Get a pointer to the visual that the colormap belongs to */
+ pVisual = pColormap->pVisual;
+
+ /* Get the maximum number of palette entries for this visual */
+ dwEntriesMax = pVisual->ColormapEntries;
+
+ /* Allocate a Windows logical color palette with max entries */
+ lpPaletteNew = malloc(sizeof(LOGPALETTE)
+ + (dwEntriesMax - 1) * sizeof(PALETTEENTRY));
+ if (lpPaletteNew == NULL) {
+ ErrorF("winCreateColormapShadowGDI - Couldn't allocate palette "
+ "with %d entries\n", (int) dwEntriesMax);
+ return FALSE;
}
- /* Zero out the colormap */
- ZeroMemory (lpPaletteNew, sizeof (LOGPALETTE)
- + (dwEntriesMax - 1) * sizeof (PALETTEENTRY));
-
- /* Set the logical palette structure */
- lpPaletteNew->palVersion = 0x0300;
- lpPaletteNew->palNumEntries = dwEntriesMax;
-
- /* Tell Windows to create the palette */
- hpalNew = CreatePalette (lpPaletteNew);
- if (hpalNew == NULL)
- {
- ErrorF ("winCreateColormapShadowGDI - CreatePalette () failed\n");
- free (lpPaletteNew);
- return FALSE;
+ /* Zero out the colormap */
+ ZeroMemory(lpPaletteNew, sizeof(LOGPALETTE)
+ + (dwEntriesMax - 1) * sizeof(PALETTEENTRY));
+
+ /* Set the logical palette structure */
+ lpPaletteNew->palVersion = 0x0300;
+ lpPaletteNew->palNumEntries = dwEntriesMax;
+
+ /* Tell Windows to create the palette */
+ hpalNew = CreatePalette(lpPaletteNew);
+ if (hpalNew == NULL) {
+ ErrorF("winCreateColormapShadowGDI - CreatePalette () failed\n");
+ free(lpPaletteNew);
+ return FALSE;
}
- /* Save the Windows logical palette handle in the X colormaps' privates */
- pCmapPriv->hPalette = hpalNew;
+ /* Save the Windows logical palette handle in the X colormaps' privates */
+ pCmapPriv->hPalette = hpalNew;
- /* Free the palette initialization memory */
- free (lpPaletteNew);
+ /* Free the palette initialization memory */
+ free(lpPaletteNew);
- return TRUE;
+ return TRUE;
}
-
/*
* Colormap destruction procedure
*/
static Bool
-winDestroyColormapShadowGDI (ColormapPtr pColormap)
+winDestroyColormapShadowGDI(ColormapPtr pColormap)
{
- winScreenPriv(pColormap->pScreen);
- winCmapPriv(pColormap);
-
- /*
- * Is colormap to be destroyed the default?
- *
- * Non-default colormaps should have had winUninstallColormap
- * called on them before we get here. The default colormap
- * will not have had winUninstallColormap called on it. Thus,
- * we need to handle the default colormap in a special way.
- */
- if (pColormap->flags & IsDefault)
- {
- winDebug ("winDestroyColormapShadowGDI - Destroying default "
- "colormap\n");
-
- /*
- * FIXME: Walk the list of all screens, popping the default
- * palette out of each screen device context.
- */
-
- /* Pop the palette out of the device context */
- SelectPalette (pScreenPriv->hdcScreen,
- GetStockObject (DEFAULT_PALETTE),
- FALSE);
-
- /* Clear our private installed colormap pointer */
- pScreenPriv->pcmapInstalled = NULL;
+ winScreenPriv(pColormap->pScreen);
+ winCmapPriv(pColormap);
+
+ /*
+ * Is colormap to be destroyed the default?
+ *
+ * Non-default colormaps should have had winUninstallColormap
+ * called on them before we get here. The default colormap
+ * will not have had winUninstallColormap called on it. Thus,
+ * we need to handle the default colormap in a special way.
+ */
+ if (pColormap->flags & IsDefault) {
+ winDebug("winDestroyColormapShadowGDI - Destroying default "
+ "colormap\n");
+
+ /*
+ * FIXME: Walk the list of all screens, popping the default
+ * palette out of each screen device context.
+ */
+
+ /* Pop the palette out of the device context */
+ SelectPalette(pScreenPriv->hdcScreen,
+ GetStockObject(DEFAULT_PALETTE), FALSE);
+
+ /* Clear our private installed colormap pointer */
+ pScreenPriv->pcmapInstalled = NULL;
}
-
- /* Try to delete the logical palette */
- if (DeleteObject (pCmapPriv->hPalette) == 0)
- {
- ErrorF ("winDestroyColormap - DeleteObject () failed\n");
- return FALSE;
+
+ /* Try to delete the logical palette */
+ if (DeleteObject(pCmapPriv->hPalette) == 0) {
+ ErrorF("winDestroyColormap - DeleteObject () failed\n");
+ return FALSE;
}
-
- /* Invalidate the colormap privates */
- pCmapPriv->hPalette = NULL;
- return TRUE;
-}
+ /* Invalidate the colormap privates */
+ pCmapPriv->hPalette = NULL;
+ return TRUE;
+}
/*
* Set engine specific funtions
*/
Bool
-winSetEngineFunctionsShadowGDI (ScreenPtr pScreen)
+winSetEngineFunctionsShadowGDI(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-
- /* Set our pointers */
- pScreenPriv->pwinAllocateFB = winAllocateFBShadowGDI;
- pScreenPriv->pwinFreeFB = winFreeFBShadowGDI;
- pScreenPriv->pwinShadowUpdate = winShadowUpdateGDI;
- pScreenPriv->pwinInitScreen = winInitScreenShadowGDI;
- pScreenPriv->pwinCloseScreen = winCloseScreenShadowGDI;
- pScreenPriv->pwinInitVisuals = winInitVisualsShadowGDI;
- pScreenPriv->pwinAdjustVideoMode = winAdjustVideoModeShadowGDI;
- if (pScreenInfo->fFullScreen)
- pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowFullScreen;
- else
- pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowWindowed;
- pScreenPriv->pwinFinishScreenInit = winFinishScreenInitFB;
- pScreenPriv->pwinBltExposedRegions = winBltExposedRegionsShadowGDI;
- pScreenPriv->pwinActivateApp = winActivateAppShadowGDI;
- pScreenPriv->pwinRedrawScreen = winRedrawScreenShadowGDI;
- pScreenPriv->pwinRealizeInstalledPalette =
- winRealizeInstalledPaletteShadowGDI;
- pScreenPriv->pwinInstallColormap = winInstallColormapShadowGDI;
- pScreenPriv->pwinStoreColors = winStoreColorsShadowGDI;
- pScreenPriv->pwinCreateColormap = winCreateColormapShadowGDI;
- pScreenPriv->pwinDestroyColormap = winDestroyColormapShadowGDI;
- pScreenPriv->pwinHotKeyAltTab = (winHotKeyAltTabProcPtr) (void (*)(void))NoopDDA;
- pScreenPriv->pwinCreatePrimarySurface
- = (winCreatePrimarySurfaceProcPtr) (void (*)(void))NoopDDA;
- pScreenPriv->pwinReleasePrimarySurface
- = (winReleasePrimarySurfaceProcPtr) (void (*)(void))NoopDDA;
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ /* Set our pointers */
+ pScreenPriv->pwinAllocateFB = winAllocateFBShadowGDI;
+ pScreenPriv->pwinFreeFB = winFreeFBShadowGDI;
+ pScreenPriv->pwinShadowUpdate = winShadowUpdateGDI;
+ pScreenPriv->pwinInitScreen = winInitScreenShadowGDI;
+ pScreenPriv->pwinCloseScreen = winCloseScreenShadowGDI;
+ pScreenPriv->pwinInitVisuals = winInitVisualsShadowGDI;
+ pScreenPriv->pwinAdjustVideoMode = winAdjustVideoModeShadowGDI;
+ if (pScreenInfo->fFullScreen)
+ pScreenPriv->pwinCreateBoundingWindow =
+ winCreateBoundingWindowFullScreen;
+ else
+ pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowWindowed;
+ pScreenPriv->pwinFinishScreenInit = winFinishScreenInitFB;
+ pScreenPriv->pwinBltExposedRegions = winBltExposedRegionsShadowGDI;
+ pScreenPriv->pwinActivateApp = winActivateAppShadowGDI;
+ pScreenPriv->pwinRedrawScreen = winRedrawScreenShadowGDI;
+ pScreenPriv->pwinRealizeInstalledPalette =
+ winRealizeInstalledPaletteShadowGDI;
+ pScreenPriv->pwinInstallColormap = winInstallColormapShadowGDI;
+ pScreenPriv->pwinStoreColors = winStoreColorsShadowGDI;
+ pScreenPriv->pwinCreateColormap = winCreateColormapShadowGDI;
+ pScreenPriv->pwinDestroyColormap = winDestroyColormapShadowGDI;
+ pScreenPriv->pwinHotKeyAltTab =
+ (winHotKeyAltTabProcPtr) (void (*)(void)) NoopDDA;
+ pScreenPriv->pwinCreatePrimarySurface =
+ (winCreatePrimarySurfaceProcPtr) (void (*)(void)) NoopDDA;
+ pScreenPriv->pwinReleasePrimarySurface =
+ (winReleasePrimarySurfaceProcPtr) (void (*)(void)) NoopDDA;
#ifdef XWIN_MULTIWINDOW
- pScreenPriv->pwinFinishCreateWindowsWindow =
- (winFinishCreateWindowsWindowProcPtr) (void (*)(void))NoopDDA;
+ pScreenPriv->pwinFinishCreateWindowsWindow =
+ (winFinishCreateWindowsWindowProcPtr) (void (*)(void)) NoopDDA;
#endif
- return TRUE;
+ return TRUE;
}
diff --git a/xorg-server/hw/xwin/wintrayicon.c b/xorg-server/hw/xwin/wintrayicon.c
index 01d53bc44..8a3952629 100644
--- a/xorg-server/hw/xwin/wintrayicon.c
+++ b/xorg-server/hw/xwin/wintrayicon.c
@@ -42,92 +42,88 @@ static NOTIFYICONDATA nid;
*/
void
-winInitNotifyIcon (winPrivScreenPtr pScreenPriv, Bool Modify)
+winInitNotifyIcon(winPrivScreenPtr pScreenPriv, Bool Modify)
{
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- char HostName[256];
-
- if (!Modify)
- {
- nid.cbSize = sizeof (NOTIFYICONDATA);
- nid.hWnd = pScreenPriv->hwndScreen;
- nid.uID = pScreenInfo->dwScreen;
- nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
- nid.uCallbackMessage = WM_TRAYICON;
- nid.hIcon = winTaskbarIcon ();
-
- /* Save handle to the icon so it can be freed later */
- pScreenPriv->hiconNotifyIcon = nid.hIcon;
- }
-
- gethostname(HostName,256);
-
- /* Set display and screen-specific tooltip text */
- if (g_pszQueryHost)
- {
- snprintf (nid.szTip,
- sizeof (nid.szTip),
- "%s - %s:%s.%d - %d clients",
- g_pszQueryHost,
- HostName,
- display,
- (int) pScreenInfo->dwScreen,
- pScreenPriv->iConnectedClients);
- }
- else
- {
- snprintf (nid.szTip,
- sizeof (nid.szTip),
- "%s:%s.%d - %d clients",
- HostName,
- display,
- (int) pScreenInfo->dwScreen,
- pScreenPriv->iConnectedClients);
- }
-
- /* Add the tray icon */
- if (!Shell_NotifyIcon ((Modify) ? NIM_MODIFY : NIM_ADD, &nid))
- ErrorF ("winInitNotifyIcon - Shell_NotifyIcon Failed\n");
-}
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ char HostName[256];
+
+ if (!Modify)
+ {
+ nid.cbSize = sizeof(NOTIFYICONDATA);
+ nid.hWnd = pScreenPriv->hwndScreen;
+ nid.uID = pScreenInfo->dwScreen;
+ nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
+ nid.uCallbackMessage = WM_TRAYICON;
+ nid.hIcon = winTaskbarIcon();
+
+ /* Save handle to the icon so it can be freed later */
+ pScreenPriv->hiconNotifyIcon = nid.hIcon;
+ }
+ gethostname(HostName,256);
+
+ /* Set display and screen-specific tooltip text */
+ if (g_pszQueryHost)
+ {
+ snprintf(nid.szTip,
+ sizeof(nid.szTip),
+ "%s - %s:%s.%d - %d clients",
+ g_pszQueryHost,
+ HostName,
+ display,
+ (int) pScreenInfo->dwScreen,
+ pScreenPriv->iConnectedClients);
+ }
+ else
+ {
+ snprintf (nid.szTip,
+ sizeof (nid.szTip),
+ "%s:%s.%d - %d clients",
+ HostName,
+ display,
+ (int) pScreenInfo->dwScreen,
+ pScreenPriv->iConnectedClients);
+ }
+
+ /* Add the tray icon */
+ if (!Shell_NotifyIcon ((Modify) ? NIM_MODIFY : NIM_ADD, &nid))
+ ErrorF("winInitNotifyIcon - Shell_NotifyIcon Failed\n");
+}
/*
* Delete the tray icon
*/
void
-winDeleteNotifyIcon (winPrivScreenPtr pScreenPriv)
+winDeleteNotifyIcon(winPrivScreenPtr pScreenPriv)
{
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-
- if (!pScreenPriv->hiconNotifyIcon)
- return;
-
- /* Delete the tray icon */
- Shell_NotifyIcon (NIM_DELETE, &nid);
-
- /* Free the icon that was loaded */
- DestroyIcon (pScreenPriv->hiconNotifyIcon);
-
- pScreenPriv->hiconNotifyIcon = NULL;
-}
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ if (!pScreenPriv->hiconNotifyIcon)
+ return;
+ /* Delete the tray icon */
+ Shell_NotifyIcon (NIM_DELETE, &nid);
+
+ /* Free the icon that was loaded */
+ DestroyIcon (pScreenPriv->hiconNotifyIcon);
+
+ pScreenPriv->hiconNotifyIcon = NULL;
+}
/*
* Process messages intended for the tray icon
*/
LRESULT
-winHandleIconMessage (HWND hwnd, UINT message,
- WPARAM wParam, LPARAM lParam,
- winPrivScreenPtr pScreenPriv)
+winHandleIconMessage(HWND hwnd, UINT message,
+ WPARAM wParam, LPARAM lParam, winPrivScreenPtr pScreenPriv)
{
#if defined(XWIN_MULTIWINDOWEXTWM) || defined(XWIN_MULTIWINDOW)
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
#endif
- switch (lParam)
- {
+ switch (lParam) {
case WM_MOUSEMOVE:
{
static int PrevNrClients;
@@ -140,91 +136,85 @@ winHandleIconMessage (HWND hwnd, UINT message,
}
break;
case WM_LBUTTONUP:
- /* Restack and bring all windows to top */
- SetForegroundWindow (hwnd);
+ /* Restack and bring all windows to top */
+ SetForegroundWindow(hwnd);
#ifdef XWIN_MULTIWINDOWEXTWM
- if (pScreenInfo->fMWExtWM)
- winMWExtWMRestackWindows (pScreenInfo->pScreen);
+ if (pScreenInfo->fMWExtWM)
+ winMWExtWMRestackWindows(pScreenInfo->pScreen);
#endif
- break;
+ break;
case WM_LBUTTONDBLCLK:
- /* Display Exit dialog box */
- winDisplayExitDialog (pScreenPriv);
- break;
+ /* Display Exit dialog box */
+ winDisplayExitDialog(pScreenPriv);
+ break;
case WM_RBUTTONUP:
- {
- POINT ptCursor;
- HMENU hmenuPopup;
- HMENU hmenuTray;
+ {
+ POINT ptCursor;
+ HMENU hmenuPopup;
+ HMENU hmenuTray;
- /* Get cursor position */
- GetCursorPos (&ptCursor);
+ /* Get cursor position */
+ GetCursorPos(&ptCursor);
- /* Load tray icon menu resource */
- hmenuPopup = LoadMenu (g_hInstance,
- MAKEINTRESOURCE(IDM_TRAYICON_MENU));
- if (!hmenuPopup)
- ErrorF ("winHandleIconMessage - LoadMenu failed\n");
+ /* Load tray icon menu resource */
+ hmenuPopup = LoadMenu(g_hInstance, MAKEINTRESOURCE(IDM_TRAYICON_MENU));
+ if (!hmenuPopup)
+ ErrorF("winHandleIconMessage - LoadMenu failed\n");
- /* Get actual tray icon menu */
- hmenuTray = GetSubMenu (hmenuPopup, 0);
+ /* Get actual tray icon menu */
+ hmenuTray = GetSubMenu(hmenuPopup, 0);
#ifdef XWIN_MULTIWINDOW
- /* Check for MultiWindow mode */
- if (pScreenInfo->fMultiWindow)
- {
- MENUITEMINFO mii = {0};
-
- /* Root is shown, remove the check box */
-
- /* Setup menu item info structure */
- mii.cbSize = sizeof (MENUITEMINFO);
- mii.fMask = MIIM_STATE;
- mii.fState = MFS_CHECKED;
-
- /* Unheck box if root is shown */
- if (pScreenPriv->fRootWindowShown)
- mii.fState = MFS_UNCHECKED;
-
- /* Set menu state */
- SetMenuItemInfo (hmenuTray, ID_APP_HIDE_ROOT, FALSE, &mii);
- }
- else
+ /* Check for MultiWindow mode */
+ if (pScreenInfo->fMultiWindow) {
+ MENUITEMINFO mii = { 0 };
+
+ /* Root is shown, remove the check box */
+
+ /* Setup menu item info structure */
+ mii.cbSize = sizeof(MENUITEMINFO);
+ mii.fMask = MIIM_STATE;
+ mii.fState = MFS_CHECKED;
+
+ /* Unheck box if root is shown */
+ if (pScreenPriv->fRootWindowShown)
+ mii.fState = MFS_UNCHECKED;
+
+ /* Set menu state */
+ SetMenuItemInfo(hmenuTray, ID_APP_HIDE_ROOT, FALSE, &mii);
+ }
+ else
#endif
- {
- /* Remove Hide Root Window button */
- RemoveMenu (hmenuTray,
- ID_APP_HIDE_ROOT,
- MF_BYCOMMAND);
- }
-
- SetupRootMenu ((unsigned long)hmenuTray);
-
- /*
- * NOTE: This three-step procedure is required for
- * proper popup menu operation. Without the
- * call to SetForegroundWindow the
- * popup menu will often not disappear when you click
- * outside of it. Without the PostMessage the second
- * time you display the popup menu it might immediately
- * disappear.
- */
- SetForegroundWindow (hwnd);
- TrackPopupMenuEx (hmenuTray,
- TPM_LEFTALIGN | TPM_BOTTOMALIGN | TPM_RIGHTBUTTON,
- ptCursor.x, ptCursor.y,
- hwnd,
- NULL);
- PostMessage (hwnd, WM_NULL, 0, 0);
-
- /* Free menu */
- DestroyMenu (hmenuPopup);
- }
- break;
+ {
+ /* Remove Hide Root Window button */
+ RemoveMenu(hmenuTray, ID_APP_HIDE_ROOT, MF_BYCOMMAND);
+ }
+
+ SetupRootMenu((unsigned long) hmenuTray);
+
+ /*
+ * NOTE: This three-step procedure is required for
+ * proper popup menu operation. Without the
+ * call to SetForegroundWindow the
+ * popup menu will often not disappear when you click
+ * outside of it. Without the PostMessage the second
+ * time you display the popup menu it might immediately
+ * disappear.
+ */
+ SetForegroundWindow(hwnd);
+ TrackPopupMenuEx(hmenuTray,
+ TPM_LEFTALIGN | TPM_BOTTOMALIGN | TPM_RIGHTBUTTON,
+ ptCursor.x, ptCursor.y, hwnd, NULL);
+ PostMessage(hwnd, WM_NULL, 0, 0);
+
+ /* Free menu */
+ DestroyMenu(hmenuPopup);
+ }
+ break;
}
- return 0;
+ return 0;
}
diff --git a/xorg-server/hw/xwin/winvalargs.c b/xorg-server/hw/xwin/winvalargs.c
index 04db777b0..eb6e973b8 100644
--- a/xorg-server/hw/xwin/winvalargs.c
+++ b/xorg-server/hw/xwin/winvalargs.c
@@ -34,22 +34,19 @@
#include "win.h"
#include "winmsg.h"
-
-
-
/*
* Verify all screens have been explicitly specified
*/
static BOOL
isEveryScreenExplicit(void)
{
- int i;
+ int i;
- for (i = 0; i < g_iNumScreens; i++)
- if (!g_ScreenInfo[i].fExplicitScreen)
- return FALSE;
+ for (i = 0; i < g_iNumScreens; i++)
+ if (!g_ScreenInfo[i].fExplicitScreen)
+ return FALSE;
- return TRUE;
+ return TRUE;
}
/*
@@ -57,124 +54,117 @@ isEveryScreenExplicit(void)
*/
Bool
-winValidateArgs (void)
+winValidateArgs(void)
{
- int i;
- int iMaxConsecutiveScreen = 0;
- BOOL fHasNormalScreen0 = FALSE;
- BOOL fImplicitScreenFound = FALSE;
-
- /*
- * Check for a malformed set of -screen parameters.
- * Examples of malformed parameters:
- * XWin -screen 1
- * XWin -screen 0 -screen 2
- * XWin -screen 1 -screen 2
- */
- if (!isEveryScreenExplicit())
- {
- ErrorF ("winValidateArgs - Malformed set of screen parameter(s). "
- "Screens must be specified consecutively starting with "
- "screen 0. That is, you cannot have only a screen 1, nor "
- "could you have screen 0 and screen 2. You instead must "
- "have screen 0, or screen 0 and screen 1, respectively. "
- "You can specify as many screens as you want.\n");
- return FALSE;
+ int i;
+ int iMaxConsecutiveScreen = 0;
+ BOOL fHasNormalScreen0 = FALSE;
+ BOOL fImplicitScreenFound = FALSE;
+
+ /*
+ * Check for a malformed set of -screen parameters.
+ * Examples of malformed parameters:
+ * XWin -screen 1
+ * XWin -screen 0 -screen 2
+ * XWin -screen 1 -screen 2
+ */
+ if (!isEveryScreenExplicit()) {
+ ErrorF("winValidateArgs - Malformed set of screen parameter(s). "
+ "Screens must be specified consecutively starting with "
+ "screen 0. That is, you cannot have only a screen 1, nor "
+ "could you have screen 0 and screen 2. You instead must "
+ "have screen 0, or screen 0 and screen 1, respectively. "
+ "You can specify as many screens as you want.\n");
+ return FALSE;
}
- /* Loop through all screens */
- for (i = 0; i < g_iNumScreens; ++i)
- {
- /*
- * Check for any combination of
- * -multiwindow, -mwextwm, and -rootless.
- */
- {
- int iCount = 0;
-
- /* Count conflicting options */
+ /* Loop through all screens */
+ for (i = 0; i < g_iNumScreens; ++i) {
+ /*
+ * Check for any combination of
+ * -multiwindow, -mwextwm, and -rootless.
+ */
+ {
+ int iCount = 0;
+
+ /* Count conflicting options */
#ifdef XWIN_MULTIWINDOW
- if (g_ScreenInfo[i].fMultiWindow)
- ++iCount;
+ if (g_ScreenInfo[i].fMultiWindow)
+ ++iCount;
#endif
#ifdef XWIN_MULTIWINDOWEXTWM
- if (g_ScreenInfo[i].fMWExtWM)
- ++iCount;
+ if (g_ScreenInfo[i].fMWExtWM)
+ ++iCount;
#endif
- if (g_ScreenInfo[i].fRootless)
- ++iCount;
-
- /* Check if the first screen is without rootless and multiwindow */
- if (iCount == 0 && i == 0)
- fHasNormalScreen0 = TRUE;
-
- /* Fail if two or more conflicting options */
- if (iCount > 1)
- {
- ErrorF ("winValidateArgs - Only one of -multiwindow, -mwextwm, "
- "and -rootless can be specific at a time.\n");
- return FALSE;
- }
- }
-
- /* Check for -multiwindow or -mwextwm and Xdmcp */
- /* allow xdmcp if screen 0 is normal. */
- if (g_fXdmcpEnabled && !fHasNormalScreen0
- && (FALSE
+ if (g_ScreenInfo[i].fRootless)
+ ++iCount;
+
+ /* Check if the first screen is without rootless and multiwindow */
+ if (iCount == 0 && i == 0)
+ fHasNormalScreen0 = TRUE;
+
+ /* Fail if two or more conflicting options */
+ if (iCount > 1) {
+ ErrorF("winValidateArgs - Only one of -multiwindow, -mwextwm, "
+ "and -rootless can be specific at a time.\n");
+ return FALSE;
+ }
+ }
+
+ /* Check for -multiwindow or -mwextwm and Xdmcp */
+ /* allow xdmcp if screen 0 is normal. */
+ if (g_fXdmcpEnabled && !fHasNormalScreen0 && (FALSE
#ifdef XWIN_MULTIWINDOW
- || g_ScreenInfo[i].fMultiWindow
+ || g_ScreenInfo[i].
+ fMultiWindow
#endif
#ifdef XWIN_MULTIWINDOWEXTWM
- || g_ScreenInfo[i].fMWExtWM
+ || g_ScreenInfo[i].
+ fMWExtWM
#endif
- )
- )
- {
- ErrorF ("winValidateArgs - Xdmcp (-query, -broadcast, or -indirect) "
- "is invalid with -multiwindow or -mwextwm.\n");
- return FALSE;
- }
-
- /* Check for -multiwindow, -mwextwm, or -rootless and fullscreen */
- if (g_ScreenInfo[i].fFullScreen
- && (FALSE
+ )
+ ) {
+ ErrorF("winValidateArgs - Xdmcp (-query, -broadcast, or -indirect) "
+ "is invalid with -multiwindow or -mwextwm.\n");
+ return FALSE;
+ }
+
+ /* Check for -multiwindow, -mwextwm, or -rootless and fullscreen */
+ if (g_ScreenInfo[i].fFullScreen && (FALSE
#ifdef XWIN_MULTIWINDOW
- || g_ScreenInfo[i].fMultiWindow
+ || g_ScreenInfo[i].fMultiWindow
#endif
#ifdef XWIN_MULTIWINDOWEXTWM
- || g_ScreenInfo[i].fMWExtWM
+ || g_ScreenInfo[i].fMWExtWM
#endif
- || g_ScreenInfo[i].fRootless)
- )
- {
- ErrorF ("winValidateArgs - -fullscreen is invalid with "
- "-multiwindow, -mwextwm, or -rootless.\n");
- return FALSE;
- }
-
- /* Check for !fullscreen and any fullscreen-only parameters */
- if (!g_ScreenInfo[i].fFullScreen
- && (g_ScreenInfo[i].dwRefreshRate != WIN_DEFAULT_REFRESH
- || g_ScreenInfo[i].dwBPP != WIN_DEFAULT_BPP))
- {
- ErrorF ("winValidateArgs - -refresh and -depth are only valid "
- "with -fullscreen.\n");
- return FALSE;
- }
-
- /* Check for fullscreen and any non-fullscreen parameters */
- if (g_ScreenInfo[i].fFullScreen
- && ((g_ScreenInfo[i].iResizeMode != notAllowed)
- || !g_ScreenInfo[i].fDecoration
- || g_ScreenInfo[i].fLessPointer))
- {
- ErrorF ("winValidateArgs - -fullscreen is invalid with "
- "-scrollbars, -resize, -nodecoration, or -lesspointer.\n");
- return FALSE;
- }
+ || g_ScreenInfo[i].fRootless)
+ ) {
+ ErrorF("winValidateArgs - -fullscreen is invalid with "
+ "-multiwindow, -mwextwm, or -rootless.\n");
+ return FALSE;
+ }
+
+ /* Check for !fullscreen and any fullscreen-only parameters */
+ if (!g_ScreenInfo[i].fFullScreen
+ && (g_ScreenInfo[i].dwRefreshRate != WIN_DEFAULT_REFRESH
+ || g_ScreenInfo[i].dwBPP != WIN_DEFAULT_BPP)) {
+ ErrorF("winValidateArgs - -refresh and -depth are only valid "
+ "with -fullscreen.\n");
+ return FALSE;
+ }
+
+ /* Check for fullscreen and any non-fullscreen parameters */
+ if (g_ScreenInfo[i].fFullScreen
+ && ((g_ScreenInfo[i].iResizeMode != notAllowed)
+ || !g_ScreenInfo[i].fDecoration
+ || g_ScreenInfo[i].fLessPointer)) {
+ ErrorF("winValidateArgs - -fullscreen is invalid with "
+ "-scrollbars, -resize, -nodecoration, or -lesspointer.\n");
+ return FALSE;
+ }
}
- winDebug ("winValidateArgs - Returning.\n");
+ winDebug("winValidateArgs - Returning.\n");
- return TRUE;
+ return TRUE;
}
diff --git a/xorg-server/hw/xwin/winvideo.c b/xorg-server/hw/xwin/winvideo.c
index ed205448d..151538d10 100644
--- a/xorg-server/hw/xwin/winvideo.c
+++ b/xorg-server/hw/xwin/winvideo.c
@@ -36,32 +36,24 @@
#include <X11/extensions/Xvproto.h>
void
-winInitVideo (ScreenPtr pScreen);
+ winInitVideo(ScreenPtr pScreen);
/*
* winInitVideo - Initialize support for the X Video (Xv) Extension.
*/
void
-winInitVideo (ScreenPtr pScreen)
+winInitVideo(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+
+ if (pScreenInfo->dwBPP > 8) {
- if (pScreenInfo->dwBPP > 8)
- {
-
}
-
}
-
-
-
-
-
-
#if 0
#include "../xfree86/common/xf86.h"
#include "../Xext/xvdix.h"
@@ -69,80 +61,71 @@ winInitVideo (ScreenPtr pScreen)
#include <X11/extensions/Xv.h>
#endif
-
-
#if 0
/* client libraries expect an encoding */
-static XF86VideoEncodingRec DummyEncoding[1] =
-{
- {
- 0,
- "XV_IMAGE",
- IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT,
- {1, 1}
- }
+static XF86VideoEncodingRec DummyEncoding[1] = {
+ {
+ 0,
+ "XV_IMAGE",
+ IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT,
+ {1, 1}
+ }
};
#define NUM_FORMATS 3
-static XF86VideoFormatRec Formats[NUM_FORMATS] =
-{
- {15, TrueColor}, {16, TrueColor}, {24, TrueColor}
+static XF86VideoFormatRec Formats[NUM_FORMATS] = {
+ {15, TrueColor}, {16, TrueColor}, {24, TrueColor}
};
#define NUM_ATTRIBUTES 3
-static XF86AttributeRec Attributes[NUM_ATTRIBUTES] =
-{
- {XvSettable | XvGettable, 0, (1 << 24) - 1, "XV_COLORKEY"},
- {XvSettable | XvGettable, -128, 127, "XV_BRIGHTNESS"},
- {XvSettable | XvGettable, 0, 255, "XV_CONTRAST"}
+static XF86AttributeRec Attributes[NUM_ATTRIBUTES] = {
+ {XvSettable | XvGettable, 0, (1 << 24) - 1, "XV_COLORKEY"},
+ {XvSettable | XvGettable, -128, 127, "XV_BRIGHTNESS"},
+ {XvSettable | XvGettable, 0, 255, "XV_CONTRAST"}
};
#define NUM_IMAGES 4
-static XF86ImageRec Images[NUM_IMAGES] =
-{
- XVIMAGE_YUY2,
- XVIMAGE_YV12,
- XVIMAGE_I420,
- XVIMAGE_UYVY
+static XF86ImageRec Images[NUM_IMAGES] = {
+ XVIMAGE_YUY2,
+ XVIMAGE_YV12,
+ XVIMAGE_I420,
+ XVIMAGE_UYVY
};
-
-
/*
* winInitVideo - Initialize support for the X Video (Xv) Extension.
*/
void
-winInitVideo (ScreenPtr pScreen)
+winInitVideo(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- XF86VideoAdaptorPtr newAdaptor = NULL;
+ winScreenPriv(pScreen);
+ winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
+ XF86VideoAdaptorPtr newAdaptor = NULL;
- if (pScreenInfo->dwBPP > 8)
- {
- newAdaptor = I810SetupImageVideo (pScreen);
- I810InitOffscreenImages (pScreen);
+ if (pScreenInfo->dwBPP > 8) {
+ newAdaptor = I810SetupImageVideo(pScreen);
+ I810InitOffscreenImages(pScreen);
}
-
- xf86XVScreenInit (pScreen, adaptors, 1);
-}
+ xf86XVScreenInit(pScreen, adaptors, 1);
+}
-static XF86VideoAdaptorPtr
-winSetupImageVideo (ScreenPtr pScreen)
+static XF86VideoAdaptorPtr
+winSetupImageVideo(ScreenPtr pScreen)
{
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+
#if 0
I810Ptr pI810 = I810PTR(pScrn);
#endif
XF86VideoAdaptorPtr adapt;
if (!(adapt = calloc(1, sizeof(XF86VideoAdaptorRec))))
- return NULL;
+ return NULL;
adapt->type = XvWindowMask | XvInputMask | XvImageMask;
adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT;
@@ -195,8 +178,8 @@ winSetupImageVideo (ScreenPtr pScreen)
#if 0
xvBrightness = MAKE_ATOM("XV_BRIGHTNESS");
- xvContrast = MAKE_ATOM("XV_CONTRAST");
- xvColorKey = MAKE_ATOM("XV_COLORKEY");
+ xvContrast = MAKE_ATOM("XV_CONTRAST");
+ xvColorKey = MAKE_ATOM("XV_COLORKEY");
#endif
#if 0
diff --git a/xorg-server/hw/xwin/winwakeup.c b/xorg-server/hw/xwin/winwakeup.c
index 64c202fed..1d2bfedbe 100644
--- a/xorg-server/hw/xwin/winwakeup.c
+++ b/xorg-server/hw/xwin/winwakeup.c
@@ -1,61 +1,55 @@
-/*
- *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, sublicense, and/or sell copies of the Software, and to
- *permit persons to whom the Software is furnished to do so, subject to
- *the following conditions:
- *
- *The above copyright notice and this permission notice shall be
- *included in all copies or substantial portions of the Software.
- *
- *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
- *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *Except as contained in this notice, the name of the XFree86 Project
- *shall not be used in advertising or otherwise to promote the sale, use
- *or other dealings in this Software without prior written authorization
- *from the XFree86 Project.
- *
- * Authors: Dakshinamurthy Karra
- * Suhaib M Siddiqi
- * Peter Busch
- * Harold L Hunt II
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-
-/* See Porting Layer Definition - p. 7 */
-void
-winWakeupHandler (int nScreen,
- pointer pWakeupData,
- unsigned long ulResult,
- pointer pReadmask)
-{
- MSG msg;
-
- /* Process all messages on our queue */
- while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
- {
- if ((g_hDlgDepthChange == 0
- || !IsDialogMessage (g_hDlgDepthChange, &msg))
- && (g_hDlgExit == 0
- || !IsDialogMessage (g_hDlgExit, &msg))
- && (g_hDlgAbout == 0
- || !IsDialogMessage (g_hDlgAbout, &msg)))
- {
- DispatchMessage (&msg);
- }
- }
-}
+/*
+ *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ *Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ *"Software"), to deal in the Software without restriction, including
+ *without limitation the rights to use, copy, modify, merge, publish,
+ *distribute, sublicense, and/or sell copies of the Software, and to
+ *permit persons to whom the Software is furnished to do so, subject to
+ *the following conditions:
+ *
+ *The above copyright notice and this permission notice shall be
+ *included in all copies or substantial portions of the Software.
+ *
+ *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
+ *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *Except as contained in this notice, the name of the XFree86 Project
+ *shall not be used in advertising or otherwise to promote the sale, use
+ *or other dealings in this Software without prior written authorization
+ *from the XFree86 Project.
+ *
+ * Authors: Dakshinamurthy Karra
+ * Suhaib M Siddiqi
+ * Peter Busch
+ * Harold L Hunt II
+ */
+
+#ifdef HAVE_XWIN_CONFIG_H
+#include <xwin-config.h>
+#endif
+#include "win.h"
+
+/* See Porting Layer Definition - p. 7 */
+void
+winWakeupHandler(int nScreen,
+ pointer pWakeupData, unsigned long ulResult, pointer pReadmask)
+{
+ MSG msg;
+
+ /* Process all messages on our queue */
+ while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
+ if ((g_hDlgDepthChange == 0
+ || !IsDialogMessage(g_hDlgDepthChange, &msg))
+ && (g_hDlgExit == 0 || !IsDialogMessage(g_hDlgExit, &msg))
+ && (g_hDlgAbout == 0 || !IsDialogMessage(g_hDlgAbout, &msg))) {
+ DispatchMessage(&msg);
+ }
+ }
+}
diff --git a/xorg-server/hw/xwin/winwin32rootless.c b/xorg-server/hw/xwin/winwin32rootless.c
index 9f828503f..9ec1cbdf3 100644
--- a/xorg-server/hw/xwin/winwin32rootless.c
+++ b/xorg-server/hw/xwin/winwin32rootless.c
@@ -43,7 +43,6 @@
#include "winmultiwindowclass.h"
#include <X11/Xatom.h>
-
/*
* Constant defines
*/
@@ -65,13 +64,13 @@
DEFINE_ATOM_HELPER(AtmWindowsWmNativeHwnd, WINDOWSWM_NATIVE_HWND)
static void
-winMWExtWMSetNativeProperty (RootlessWindowPtr pFrame);
+winMWExtWMSetNativeProperty(RootlessWindowPtr pFrame);
/*
* Global variables
*/
-Bool g_fNoConfigureWindow = FALSE;
+Bool g_fNoConfigureWindow = FALSE;
/*
* Internal function to get the DIB format that is compatible with the screen
@@ -80,804 +79,764 @@ Bool g_fNoConfigureWindow = FALSE;
static
Bool
-winMWExtWMQueryDIBFormat (win32RootlessWindowPtr pRLWinPriv, BITMAPINFOHEADER *pbmih)
+winMWExtWMQueryDIBFormat(win32RootlessWindowPtr pRLWinPriv,
+ BITMAPINFOHEADER * pbmih)
{
- HBITMAP hbmp;
+ HBITMAP hbmp;
#ifdef _DEBUG
- LPDWORD pdw = NULL;
+ LPDWORD pdw = NULL;
#endif
-
- /* Create a memory bitmap compatible with the screen */
- hbmp = CreateCompatibleBitmap (pRLWinPriv->hdcScreen, 1, 1);
- if (hbmp == NULL)
- {
- ErrorF ("winMWExtWMQueryDIBFormat - CreateCompatibleBitmap failed\n");
- return FALSE;
+
+ /* Create a memory bitmap compatible with the screen */
+ hbmp = CreateCompatibleBitmap(pRLWinPriv->hdcScreen, 1, 1);
+ if (hbmp == NULL) {
+ ErrorF("winMWExtWMQueryDIBFormat - CreateCompatibleBitmap failed\n");
+ return FALSE;
}
-
- /* Initialize our bitmap info header */
- ZeroMemory (pbmih, sizeof (BITMAPINFOHEADER) + 256 * sizeof (RGBQUAD));
- pbmih->biSize = sizeof (BITMAPINFOHEADER);
-
- /* Get the biBitCount */
- if (!GetDIBits (pRLWinPriv->hdcScreen,
- hbmp,
- 0, 1,
- NULL,
- (BITMAPINFO*) pbmih,
- DIB_RGB_COLORS))
- {
- ErrorF ("winMWExtWMQueryDIBFormat - First call to GetDIBits failed\n");
- DeleteObject (hbmp);
- return FALSE;
+
+ /* Initialize our bitmap info header */
+ ZeroMemory(pbmih, sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
+ pbmih->biSize = sizeof(BITMAPINFOHEADER);
+
+ /* Get the biBitCount */
+ if (!GetDIBits(pRLWinPriv->hdcScreen,
+ hbmp, 0, 1, NULL, (BITMAPINFO *) pbmih, DIB_RGB_COLORS)) {
+ ErrorF("winMWExtWMQueryDIBFormat - First call to GetDIBits failed\n");
+ DeleteObject(hbmp);
+ return FALSE;
}
#ifdef _DEBUG
- /* Get a pointer to bitfields */
- pdw = (DWORD*) ((CARD8*)pbmih + sizeof (BITMAPINFOHEADER));
+ /* Get a pointer to bitfields */
+ pdw = (DWORD *) ((CARD8 *) pbmih + sizeof(BITMAPINFOHEADER));
- winDebug ("winMWExtWMQueryDIBFormat - First call masks: %08x %08x %08x\n",
- (unsigned int)pdw[0], (unsigned int)pdw[1], (unsigned int)pdw[2]);
+ winDebug("winMWExtWMQueryDIBFormat - First call masks: %08x %08x %08x\n",
+ (unsigned int) pdw[0], (unsigned int) pdw[1],
+ (unsigned int) pdw[2]);
#endif
- /* Get optimal color table, or the optimal bitfields */
- if (!GetDIBits (pRLWinPriv->hdcScreen,
- hbmp,
- 0, 1,
- NULL,
- (BITMAPINFO*)pbmih,
- DIB_RGB_COLORS))
- {
- ErrorF ("winMWExtWMQueryDIBFormat - Second call to GetDIBits "
- "failed\n");
- DeleteObject (hbmp);
- return FALSE;
+ /* Get optimal color table, or the optimal bitfields */
+ if (!GetDIBits(pRLWinPriv->hdcScreen,
+ hbmp, 0, 1, NULL, (BITMAPINFO *) pbmih, DIB_RGB_COLORS)) {
+ ErrorF("winMWExtWMQueryDIBFormat - Second call to GetDIBits "
+ "failed\n");
+ DeleteObject(hbmp);
+ return FALSE;
}
- /* Free memory */
- DeleteObject (hbmp);
-
- return TRUE;
+ /* Free memory */
+ DeleteObject(hbmp);
+
+ return TRUE;
}
static HRGN
-winMWExtWMCreateRgnFromRegion (RegionPtr pShape)
+winMWExtWMCreateRgnFromRegion(RegionPtr pShape)
{
- int nRects;
- BoxPtr pRects, pEnd;
- HRGN hRgn, hRgnRect;
-
- if (pShape == NULL) return NULL;
-
- nRects = RegionNumRects(pShape);
- pRects = RegionRects(pShape);
-
- hRgn = CreateRectRgn (0, 0, 0, 0);
- if (hRgn == NULL)
- {
- ErrorF ("winReshape - Initial CreateRectRgn (%d, %d, %d, %d) "
- "failed: %d\n",
- 0, 0, 0, 0, (int) GetLastError ());
+ int nRects;
+ BoxPtr pRects, pEnd;
+ HRGN hRgn, hRgnRect;
+
+ if (pShape == NULL)
+ return NULL;
+
+ nRects = RegionNumRects(pShape);
+ pRects = RegionRects(pShape);
+
+ hRgn = CreateRectRgn(0, 0, 0, 0);
+ if (hRgn == NULL) {
+ ErrorF("winReshape - Initial CreateRectRgn (%d, %d, %d, %d) "
+ "failed: %d\n", 0, 0, 0, 0, (int) GetLastError());
}
- /* Loop through all rectangles in the X region */
- for (pEnd = pRects + nRects; pRects < pEnd; pRects++)
- {
- /* Create a Windows region for the X rectangle */
- hRgnRect = CreateRectRgn (pRects->x1,
- pRects->y1,
- pRects->x2,
- pRects->y2);
- if (hRgnRect == NULL)
- {
- ErrorF ("winReshape - Loop CreateRectRgn (%d, %d, %d, %d) "
- "failed: %d\n",
- pRects->x1,
- pRects->y1,
- pRects->x2,
- pRects->y2,
- (int) GetLastError ());
- }
-
- /* Merge the Windows region with the accumulated region */
- if (CombineRgn (hRgn, hRgn, hRgnRect, RGN_OR) == ERROR)
- {
- ErrorF ("winReshape - CombineRgn () failed: %d\n",
- (int) GetLastError ());
- }
-
- /* Delete the temporary Windows region */
- DeleteObject (hRgnRect);
+ /* Loop through all rectangles in the X region */
+ for (pEnd = pRects + nRects; pRects < pEnd; pRects++) {
+ /* Create a Windows region for the X rectangle */
+ hRgnRect = CreateRectRgn(pRects->x1,
+ pRects->y1, pRects->x2, pRects->y2);
+ if (hRgnRect == NULL) {
+ ErrorF("winReshape - Loop CreateRectRgn (%d, %d, %d, %d) "
+ "failed: %d\n",
+ pRects->x1,
+ pRects->y1, pRects->x2, pRects->y2, (int) GetLastError());
+ }
+
+ /* Merge the Windows region with the accumulated region */
+ if (CombineRgn(hRgn, hRgn, hRgnRect, RGN_OR) == ERROR) {
+ ErrorF("winReshape - CombineRgn () failed: %d\n",
+ (int) GetLastError());
+ }
+
+ /* Delete the temporary Windows region */
+ DeleteObject(hRgnRect);
}
-
- return hRgn;
+
+ return hRgn;
}
static void
-InitWin32RootlessEngine (win32RootlessWindowPtr pRLWinPriv)
+InitWin32RootlessEngine(win32RootlessWindowPtr pRLWinPriv)
{
- pRLWinPriv->hdcScreen = GetDC (pRLWinPriv->hWnd);
- pRLWinPriv->hdcShadow = CreateCompatibleDC (pRLWinPriv->hdcScreen);
- pRLWinPriv->hbmpShadow = NULL;
-
- /* Allocate bitmap info header */
- pRLWinPriv->pbmihShadow = (BITMAPINFOHEADER*) malloc (sizeof (BITMAPINFOHEADER)
- + 256 * sizeof (RGBQUAD));
- if (pRLWinPriv->pbmihShadow == NULL)
- {
- ErrorF ("InitWin32RootlessEngine - malloc () failed\n");
- return;
+ pRLWinPriv->hdcScreen = GetDC(pRLWinPriv->hWnd);
+ pRLWinPriv->hdcShadow = CreateCompatibleDC(pRLWinPriv->hdcScreen);
+ pRLWinPriv->hbmpShadow = NULL;
+
+ /* Allocate bitmap info header */
+ pRLWinPriv->pbmihShadow =
+ (BITMAPINFOHEADER *) malloc(sizeof(BITMAPINFOHEADER)
+ + 256 * sizeof(RGBQUAD));
+ if (pRLWinPriv->pbmihShadow == NULL) {
+ ErrorF("InitWin32RootlessEngine - malloc () failed\n");
+ return;
}
-
- /* Query the screen format */
- winMWExtWMQueryDIBFormat (pRLWinPriv,
- pRLWinPriv->pbmihShadow);
+
+ /* Query the screen format */
+ winMWExtWMQueryDIBFormat(pRLWinPriv, pRLWinPriv->pbmihShadow);
}
Bool
-winMWExtWMCreateFrame (RootlessWindowPtr pFrame, ScreenPtr pScreen,
- int newX, int newY, RegionPtr pShape)
+winMWExtWMCreateFrame(RootlessWindowPtr pFrame, ScreenPtr pScreen,
+ int newX, int newY, RegionPtr pShape)
{
#define CLASS_NAME_LENGTH 512
- Bool fResult = TRUE;
- win32RootlessWindowPtr pRLWinPriv;
- WNDCLASSEX wc;
- char pszClass[CLASS_NAME_LENGTH], pszWindowID[12];
- HICON hIcon;
- HICON hIconSmall;
- char *res_name, *res_class, *res_role;
- static int s_iWindowID = 0;
-
- winDebug ("winMWExtWMCreateFrame %d %d - %d %d\n",
- newX, newY, pFrame->width, pFrame->height);
-
- pRLWinPriv = (win32RootlessWindowPtr) malloc (sizeof (win32RootlessWindowRec));
- pRLWinPriv->pFrame = pFrame;
- pRLWinPriv->pfb = NULL;
- pRLWinPriv->hbmpShadow = NULL;
- pRLWinPriv->hdcShadow = NULL;
- pRLWinPriv->hdcScreen = NULL;
- pRLWinPriv->pbmihShadow = NULL;
- pRLWinPriv->fResized = TRUE;
- pRLWinPriv->fClose = FALSE;
- pRLWinPriv->fRestackingNow = FALSE;
- pRLWinPriv->fDestroyed = FALSE;
- pRLWinPriv->fMovingOrSizing = FALSE;
-
- // Store the implementation private frame ID
- pFrame->wid = (RootlessFrameID) pRLWinPriv;
-
- winSelectIcons(pFrame->win, &hIcon, &hIconSmall);
-
- /* Set standard class name prefix so we can identify window easily */
- strncpy (pszClass, WINDOW_CLASS_X, sizeof(pszClass));
-
- if (winMultiWindowGetClassHint (pFrame->win, &res_name, &res_class))
- {
- strncat (pszClass, "-", 1);
- strncat (pszClass, res_name, CLASS_NAME_LENGTH - strlen (pszClass));
- strncat (pszClass, "-", 1);
- strncat (pszClass, res_class, CLASS_NAME_LENGTH - strlen (pszClass));
-
- /* Check if a window class is provided by the WM_WINDOW_ROLE property,
- * if not use the WM_CLASS information.
- * For further information see:
- * http://tronche.com/gui/x/icccm/sec-5.html
- */
- if (winMultiWindowGetWindowRole (pFrame->win, &res_role) )
- {
- strcat (pszClass, "-");
- strcat (pszClass, res_role);
- free (res_role);
- }
-
- free (res_name);
- free (res_class);
+ Bool fResult = TRUE;
+ win32RootlessWindowPtr pRLWinPriv;
+ WNDCLASSEX wc;
+ char pszClass[CLASS_NAME_LENGTH], pszWindowID[12];
+ HICON hIcon;
+ HICON hIconSmall;
+ char *res_name, *res_class, *res_role;
+ static int s_iWindowID = 0;
+
+ winDebug("winMWExtWMCreateFrame %d %d - %d %d\n",
+ newX, newY, pFrame->width, pFrame->height);
+
+ pRLWinPriv =
+ (win32RootlessWindowPtr) malloc(sizeof(win32RootlessWindowRec));
+ pRLWinPriv->pFrame = pFrame;
+ pRLWinPriv->pfb = NULL;
+ pRLWinPriv->hbmpShadow = NULL;
+ pRLWinPriv->hdcShadow = NULL;
+ pRLWinPriv->hdcScreen = NULL;
+ pRLWinPriv->pbmihShadow = NULL;
+ pRLWinPriv->fResized = TRUE;
+ pRLWinPriv->fClose = FALSE;
+ pRLWinPriv->fRestackingNow = FALSE;
+ pRLWinPriv->fDestroyed = FALSE;
+ pRLWinPriv->fMovingOrSizing = FALSE;
+
+ // Store the implementation private frame ID
+ pFrame->wid = (RootlessFrameID) pRLWinPriv;
+
+ winSelectIcons(pFrame->win, &hIcon, &hIconSmall);
+
+ /* Set standard class name prefix so we can identify window easily */
+ strncpy(pszClass, WINDOW_CLASS_X, sizeof(pszClass));
+
+ if (winMultiWindowGetClassHint(pFrame->win, &res_name, &res_class)) {
+ strncat(pszClass, "-", 1);
+ strncat(pszClass, res_name, CLASS_NAME_LENGTH - strlen(pszClass));
+ strncat(pszClass, "-", 1);
+ strncat(pszClass, res_class, CLASS_NAME_LENGTH - strlen(pszClass));
+
+ /* Check if a window class is provided by the WM_WINDOW_ROLE property,
+ * if not use the WM_CLASS information.
+ * For further information see:
+ * http://tronche.com/gui/x/icccm/sec-5.html
+ */
+ if (winMultiWindowGetWindowRole(pFrame->win, &res_role)) {
+ strcat(pszClass, "-");
+ strcat(pszClass, res_role);
+ free(res_role);
+ }
+
+ free(res_name);
+ free(res_class);
}
- /* Add incrementing window ID to make unique class name */
- snprintf (pszWindowID, sizeof(pszWindowID), "-%x", s_iWindowID++);
- pszWindowID[sizeof(pszWindowID)-1] = 0;
- strcat (pszClass, pszWindowID);
-
- winDebug ("winCreateWindowsWindow - Creating class: %s\n", pszClass);
-
- /* Setup our window class */
- wc.cbSize = sizeof(wc);
- wc.style = CS_HREDRAW | CS_VREDRAW;
- wc.lpfnWndProc = winMWExtWMWindowProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = g_hInstance;
- wc.hIcon = hIcon;
- wc.hIconSm = hIconSmall;
- wc.hCursor = 0;
- wc.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
- wc.lpszMenuName = NULL;
- wc.lpszClassName = pszClass;
- RegisterClassEx (&wc);
-
- /* Create the window */
- g_fNoConfigureWindow = TRUE;
- pRLWinPriv->hWnd = CreateWindowExA (WS_EX_TOOLWINDOW, /* Extended styles */
- pszClass, /* Class name */
- WINDOW_TITLE_X, /* Window name */
- WS_POPUP | WS_CLIPCHILDREN,
- newX, /* Horizontal position */
- newY, /* Vertical position */
- pFrame->width, /* Right edge */
- pFrame->height, /* Bottom edge */
- (HWND) NULL, /* No parent or owner window */
- (HMENU) NULL, /* No menu */
- GetModuleHandle (NULL), /* Instance handle */
- pRLWinPriv); /* ScreenPrivates */
- if (pRLWinPriv->hWnd == NULL)
- {
- ErrorF ("winMWExtWMCreateFrame - CreateWindowExA () failed: %d\n",
- (int) GetLastError ());
- fResult = FALSE;
+ /* Add incrementing window ID to make unique class name */
+ snprintf(pszWindowID, sizeof(pszWindowID), "-%x", s_iWindowID++);
+ pszWindowID[sizeof(pszWindowID) - 1] = 0;
+ strcat(pszClass, pszWindowID);
+
+ winDebug("winCreateWindowsWindow - Creating class: %s\n", pszClass);
+
+ /* Setup our window class */
+ wc.cbSize = sizeof(wc);
+ wc.style = CS_HREDRAW | CS_VREDRAW;
+ wc.lpfnWndProc = winMWExtWMWindowProc;
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 0;
+ wc.hInstance = g_hInstance;
+ wc.hIcon = hIcon;
+ wc.hIconSm = hIconSmall;
+ wc.hCursor = 0;
+ wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
+ wc.lpszMenuName = NULL;
+ wc.lpszClassName = pszClass;
+ RegisterClassEx(&wc);
+
+ /* Create the window */
+ g_fNoConfigureWindow = TRUE;
+ pRLWinPriv->hWnd = CreateWindowExA(WS_EX_TOOLWINDOW, /* Extended styles */
+ pszClass, /* Class name */
+ WINDOW_TITLE_X, /* Window name */
+ WS_POPUP | WS_CLIPCHILDREN, newX, /* Horizontal position */
+ newY, /* Vertical position */
+ pFrame->width, /* Right edge */
+ pFrame->height, /* Bottom edge */
+ (HWND) NULL, /* No parent or owner window */
+ (HMENU) NULL, /* No menu */
+ GetModuleHandle(NULL), /* Instance handle */
+ pRLWinPriv); /* ScreenPrivates */
+ if (pRLWinPriv->hWnd == NULL) {
+ ErrorF("winMWExtWMCreateFrame - CreateWindowExA () failed: %d\n",
+ (int) GetLastError());
+ fResult = FALSE;
}
- winDebug ("winMWExtWMCreateFrame - ShowWindow\n");
+ winDebug("winMWExtWMCreateFrame - ShowWindow\n");
+
+ //ShowWindow (pRLWinPriv->hWnd, SW_SHOWNOACTIVATE);
+ g_fNoConfigureWindow = FALSE;
- //ShowWindow (pRLWinPriv->hWnd, SW_SHOWNOACTIVATE);
- g_fNoConfigureWindow = FALSE;
-
- if (pShape != NULL)
- {
- winMWExtWMReshapeFrame (pFrame->wid, pShape);
+ if (pShape != NULL) {
+ winMWExtWMReshapeFrame(pFrame->wid, pShape);
}
- winDebug ("winMWExtWMCreateFrame - (%08x) %08x\n",
- (int) pFrame->wid, (int) pRLWinPriv->hWnd);
+ winDebug("winMWExtWMCreateFrame - (%08x) %08x\n",
+ (int) pFrame->wid, (int) pRLWinPriv->hWnd);
- winMWExtWMSetNativeProperty (pFrame);
+ winMWExtWMSetNativeProperty(pFrame);
- return fResult;
+ return fResult;
}
void
-winMWExtWMDestroyFrame (RootlessFrameID wid)
+winMWExtWMDestroyFrame(RootlessFrameID wid)
{
- win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
- HICON hIcon;
- HICON hIconSm;
- HMODULE hInstance;
- int iReturn;
- char pszClass[CLASS_NAME_LENGTH];
-
- winDebug ("winMWExtWMDestroyFrame (%08x) %08x\n",
- (int) pRLWinPriv, (int) pRLWinPriv->hWnd);
-
- /* Store the info we need to destroy after this window is gone */
- hInstance = (HINSTANCE) GetClassLongPtr (pRLWinPriv->hWnd, GCLP_HMODULE);
- hIcon = (HICON)SendMessage(pRLWinPriv->hWnd, WM_GETICON, ICON_BIG, 0);
- hIconSm = (HICON)SendMessage(pRLWinPriv->hWnd, WM_GETICON, ICON_SMALL, 0);
- iReturn = GetClassName (pRLWinPriv->hWnd, pszClass, CLASS_NAME_LENGTH);
-
- pRLWinPriv->fClose = TRUE;
- pRLWinPriv->fDestroyed = TRUE;
-
- /* Destroy the Windows window */
- DestroyWindow (pRLWinPriv->hWnd);
-
- /* Only if we were able to get the name */
- if (iReturn)
- {
- winDebug ("winMWExtWMDestroyFrame - Unregistering %s: ", pszClass);
- iReturn = UnregisterClass (pszClass, hInstance);
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
+ HICON hIcon;
+ HICON hIconSm;
+ HMODULE hInstance;
+ int iReturn;
+ char pszClass[CLASS_NAME_LENGTH];
+
+ winDebug("winMWExtWMDestroyFrame (%08x) %08x\n",
+ (int) pRLWinPriv, (int) pRLWinPriv->hWnd);
+
+ /* Store the info we need to destroy after this window is gone */
+ hInstance = (HINSTANCE) GetClassLongPtr(pRLWinPriv->hWnd, GCLP_HMODULE);
+ hIcon = (HICON) SendMessage(pRLWinPriv->hWnd, WM_GETICON, ICON_BIG, 0);
+ hIconSm = (HICON) SendMessage(pRLWinPriv->hWnd, WM_GETICON, ICON_SMALL, 0);
+ iReturn = GetClassName(pRLWinPriv->hWnd, pszClass, CLASS_NAME_LENGTH);
+
+ pRLWinPriv->fClose = TRUE;
+ pRLWinPriv->fDestroyed = TRUE;
+
+ /* Destroy the Windows window */
+ DestroyWindow(pRLWinPriv->hWnd);
+
+ /* Only if we were able to get the name */
+ if (iReturn) {
+ winDebug("winMWExtWMDestroyFrame - Unregistering %s: ", pszClass);
+ iReturn = UnregisterClass(pszClass, hInstance);
- winDebug ("winMWExtWMDestroyFramew - Deleting Icon\n");
+ winDebug ("winMWExtWMDestroyFramew - Deleting Icon\n");
}
winDestroyIcon(hiconClass);
winDestroyIcon(hiconSmClass);
- winDebug ("winMWExtWMDestroyFrame - done\n");
+ winDebug("winMWExtWMDestroyFrame - done\n");
}
void
-winMWExtWMMoveFrame (RootlessFrameID wid, ScreenPtr pScreen, int iNewX, int iNewY)
+winMWExtWMMoveFrame(RootlessFrameID wid, ScreenPtr pScreen, int iNewX,
+ int iNewY)
{
- win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
- RECT rcNew;
- DWORD dwExStyle;
- DWORD dwStyle;
- int iX, iY, iWidth, iHeight;
-
- winDebug ("winMWExtWMMoveFrame (%08x) (%d %d)\n", (int) pRLWinPriv, iNewX, iNewY);
-
- /* Get the Windows window style and extended style */
- dwExStyle = GetWindowLongPtr (pRLWinPriv->hWnd, GWL_EXSTYLE);
- dwStyle = GetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE);
-
- /* Get the X and Y location of the X window */
- iX = iNewX + GetSystemMetrics (SM_XVIRTUALSCREEN);
- iY = iNewY + GetSystemMetrics (SM_YVIRTUALSCREEN);
-
- /* Get the height and width of the X window */
- iWidth = pRLWinPriv->pFrame->width;
- iHeight = pRLWinPriv->pFrame->height;
-
- /* Store the origin, height, and width in a rectangle structure */
- SetRect (&rcNew, iX, iY, iX + iWidth, iY + iHeight);
-
- winDebug("\tWindow {%d, %d, %d, %d}, {%d, %d}\n",
- rcNew.left, rcNew.top, rcNew.right, rcNew.bottom,
- rcNew.right - rcNew.left, rcNew.bottom - rcNew.top);
- /*
- * Calculate the required size of the Windows window rectangle,
- * given the size of the Windows window client area.
- */
- AdjustWindowRectEx (&rcNew, dwStyle, FALSE, dwExStyle);
-
- winDebug("\tAdjusted {%d, %d, %d, %d}, {%d, %d}\n",
- rcNew.left, rcNew.top, rcNew.right, rcNew.bottom,
- rcNew.right - rcNew.left, rcNew.bottom - rcNew.top);
- g_fNoConfigureWindow = TRUE;
- SetWindowPos (pRLWinPriv->hWnd, NULL, rcNew.left, rcNew.top, 0, 0,
- SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER);
- g_fNoConfigureWindow = FALSE;
- winDebug ("winMWExtWMMoveFrame (%08x) done\n", (int) pRLWinPriv);
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
+ RECT rcNew;
+ DWORD dwExStyle;
+ DWORD dwStyle;
+ int iX, iY, iWidth, iHeight;
+
+ winDebug("winMWExtWMMoveFrame (%08x) (%d %d)\n", (int) pRLWinPriv, iNewX,
+ iNewY);
+
+ /* Get the Windows window style and extended style */
+ dwExStyle = GetWindowLongPtr(pRLWinPriv->hWnd, GWL_EXSTYLE);
+ dwStyle = GetWindowLongPtr(pRLWinPriv->hWnd, GWL_STYLE);
+
+ /* Get the X and Y location of the X window */
+ iX = iNewX + GetSystemMetrics(SM_XVIRTUALSCREEN);
+ iY = iNewY + GetSystemMetrics(SM_YVIRTUALSCREEN);
+
+ /* Get the height and width of the X window */
+ iWidth = pRLWinPriv->pFrame->width;
+ iHeight = pRLWinPriv->pFrame->height;
+
+ /* Store the origin, height, and width in a rectangle structure */
+ SetRect(&rcNew, iX, iY, iX + iWidth, iY + iHeight);
+
+ winDebug("\tWindow {%d, %d, %d, %d}, {%d, %d}\n",
+ rcNew.left, rcNew.top, rcNew.right, rcNew.bottom,
+ rcNew.right - rcNew.left, rcNew.bottom - rcNew.top);
+ /*
+ * Calculate the required size of the Windows window rectangle,
+ * given the size of the Windows window client area.
+ */
+ AdjustWindowRectEx(&rcNew, dwStyle, FALSE, dwExStyle);
+
+ winDebug("\tAdjusted {%d, %d, %d, %d}, {%d, %d}\n",
+ rcNew.left, rcNew.top, rcNew.right, rcNew.bottom,
+ rcNew.right - rcNew.left, rcNew.bottom - rcNew.top);
+ g_fNoConfigureWindow = TRUE;
+ SetWindowPos(pRLWinPriv->hWnd, NULL, rcNew.left, rcNew.top, 0, 0,
+ SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER);
+ g_fNoConfigureWindow = FALSE;
+ winDebug("winMWExtWMMoveFrame (%08x) done\n", (int) pRLWinPriv);
}
void
-winMWExtWMResizeFrame (RootlessFrameID wid, ScreenPtr pScreen,
- int iNewX, int iNewY,
- unsigned int uiNewWidth, unsigned int uiNewHeight,
- unsigned int uiGravity)
+winMWExtWMResizeFrame(RootlessFrameID wid, ScreenPtr pScreen,
+ int iNewX, int iNewY,
+ unsigned int uiNewWidth, unsigned int uiNewHeight,
+ unsigned int uiGravity)
{
- win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
- RECT rcNew;
- RECT rcOld;
- DWORD dwExStyle;
- DWORD dwStyle;
- int iX, iY;
-
- winDebug ("winMWExtWMResizeFrame (%08x) (%d %d)-(%d %d)\n",
- (int) pRLWinPriv, iNewX, iNewY, uiNewWidth, uiNewHeight);
-
- pRLWinPriv->fResized = TRUE;
-
- /* Get the Windows window style and extended style */
- dwExStyle = GetWindowLongPtr (pRLWinPriv->hWnd, GWL_EXSTYLE);
- dwStyle = GetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE);
-
- /* Get the X and Y location of the X window */
- iX = iNewX + GetSystemMetrics (SM_XVIRTUALSCREEN);
- iY = iNewY + GetSystemMetrics (SM_YVIRTUALSCREEN);
-
- /* Store the origin, height, and width in a rectangle structure */
- SetRect (&rcNew, iX, iY, iX + uiNewWidth, iY + uiNewHeight);
-
- /*
- * Calculate the required size of the Windows window rectangle,
- * given the size of the Windows window client area.
- */
- AdjustWindowRectEx (&rcNew, dwStyle, FALSE, dwExStyle);
-
- /* Get a rectangle describing the old Windows window */
- GetWindowRect (pRLWinPriv->hWnd, &rcOld);
-
- /* Check if the old rectangle and new rectangle are the same */
- if (!EqualRect (&rcNew, &rcOld))
- {
-
- g_fNoConfigureWindow = TRUE;
- MoveWindow (pRLWinPriv->hWnd,
- rcNew.left, rcNew.top,
- rcNew.right - rcNew.left, rcNew.bottom - rcNew.top,
- TRUE);
- g_fNoConfigureWindow = FALSE;
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
+ RECT rcNew;
+ RECT rcOld;
+ DWORD dwExStyle;
+ DWORD dwStyle;
+ int iX, iY;
+
+ winDebug("winMWExtWMResizeFrame (%08x) (%d %d)-(%d %d)\n",
+ (int) pRLWinPriv, iNewX, iNewY, uiNewWidth, uiNewHeight);
+
+ pRLWinPriv->fResized = TRUE;
+
+ /* Get the Windows window style and extended style */
+ dwExStyle = GetWindowLongPtr(pRLWinPriv->hWnd, GWL_EXSTYLE);
+ dwStyle = GetWindowLongPtr(pRLWinPriv->hWnd, GWL_STYLE);
+
+ /* Get the X and Y location of the X window */
+ iX = iNewX + GetSystemMetrics(SM_XVIRTUALSCREEN);
+ iY = iNewY + GetSystemMetrics(SM_YVIRTUALSCREEN);
+
+ /* Store the origin, height, and width in a rectangle structure */
+ SetRect(&rcNew, iX, iY, iX + uiNewWidth, iY + uiNewHeight);
+
+ /*
+ * Calculate the required size of the Windows window rectangle,
+ * given the size of the Windows window client area.
+ */
+ AdjustWindowRectEx(&rcNew, dwStyle, FALSE, dwExStyle);
+
+ /* Get a rectangle describing the old Windows window */
+ GetWindowRect(pRLWinPriv->hWnd, &rcOld);
+
+ /* Check if the old rectangle and new rectangle are the same */
+ if (!EqualRect(&rcNew, &rcOld)) {
+
+ g_fNoConfigureWindow = TRUE;
+ MoveWindow(pRLWinPriv->hWnd,
+ rcNew.left, rcNew.top,
+ rcNew.right - rcNew.left, rcNew.bottom - rcNew.top, TRUE);
+ g_fNoConfigureWindow = FALSE;
}
}
void
-winMWExtWMRestackFrame (RootlessFrameID wid, RootlessFrameID nextWid)
+winMWExtWMRestackFrame(RootlessFrameID wid, RootlessFrameID nextWid)
{
- win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
- win32RootlessWindowPtr pRLNextWinPriv = (win32RootlessWindowPtr) nextWid;
- winScreenPriv(pRLWinPriv->pFrame->win->drawable.pScreen);
- winScreenInfo *pScreenInfo = NULL;
- DWORD dwCurrentProcessID = GetCurrentProcessId ();
- DWORD dwWindowProcessID = 0;
- HWND hWnd;
- Bool fFirst = TRUE;
- Bool fNeedRestack = TRUE;
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
+ win32RootlessWindowPtr pRLNextWinPriv = (win32RootlessWindowPtr) nextWid;
+
+ winScreenPriv(pRLWinPriv->pFrame->win->drawable.pScreen);
+ winScreenInfo *pScreenInfo = NULL;
+ DWORD dwCurrentProcessID = GetCurrentProcessId();
+ DWORD dwWindowProcessID = 0;
+ HWND hWnd;
+ Bool fFirst = TRUE;
+ Bool fNeedRestack = TRUE;
- winDebug ("winMWExtWMRestackFrame (%08x)\n", (int) pRLWinPriv);
+ winDebug("winMWExtWMRestackFrame (%08x)\n", (int) pRLWinPriv);
- if (pScreenPriv && pScreenPriv->fRestacking) return;
+ if (pScreenPriv && pScreenPriv->fRestacking)
+ return;
- if (pScreenPriv) pScreenInfo = pScreenPriv->pScreenInfo;
+ if (pScreenPriv)
+ pScreenInfo = pScreenPriv->pScreenInfo;
- pRLWinPriv->fRestackingNow = TRUE;
+ pRLWinPriv->fRestackingNow = TRUE;
- /* Show window */
- if(!IsWindowVisible (pRLWinPriv->hWnd))
- ShowWindow (pRLWinPriv->hWnd, SW_SHOWNOACTIVATE);
+ /* Show window */
+ if (!IsWindowVisible(pRLWinPriv->hWnd))
+ ShowWindow(pRLWinPriv->hWnd, SW_SHOWNOACTIVATE);
- if (pRLNextWinPriv == NULL)
- {
- winDebug ("Win %08x is top\n", pRLWinPriv);
- pScreenPriv->widTop = wid;
- SetWindowPos (pRLWinPriv->hWnd, HWND_TOP,
- 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
+ if (pRLNextWinPriv == NULL) {
+ winDebug("Win %08x is top\n", pRLWinPriv);
+ pScreenPriv->widTop = wid;
+ SetWindowPos(pRLWinPriv->hWnd, HWND_TOP,
+ 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
}
#ifdef XWIN_MULTIWINDOWINTWM
- else if (winIsInternalWMRunning(pScreenInfo))
- {
+ else if (winIsInternalWMRunning(pScreenInfo)) {
/* using mulwinidow wm */
- winDebug ("Win %08x is not top\n", pRLWinPriv);
-
- for (hWnd = GetNextWindow (pRLWinPriv->hWnd, GW_HWNDPREV);
- fNeedRestack && hWnd != NULL;
- hWnd = GetNextWindow (hWnd, GW_HWNDPREV))
- {
- GetWindowThreadProcessId (hWnd, &dwWindowProcessID);
-
- if ((dwWindowProcessID == dwCurrentProcessID)
- && GetProp (hWnd, WIN_WINDOW_PROP))
- {
- if (hWnd == pRLNextWinPriv->hWnd)
- {
- /* Enable interleave X window and Windows window */
- if (!fFirst)
- {
- winDebug ("raise: Insert after Win %08x\n", pRLNextWinPriv);
-
- SetWindowPos (pRLWinPriv->hWnd, pRLNextWinPriv->hWnd,
- 0, 0, 0, 0,
- SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
- }
- else
- {
- winDebug ("No change\n");
- }
- fNeedRestack = FALSE;
- break;
- }
- if (fFirst) fFirst = FALSE;
- }
- }
-
- for (hWnd = GetNextWindow (pRLWinPriv->hWnd, GW_HWNDNEXT);
- fNeedRestack && hWnd != NULL;
- hWnd = GetNextWindow (hWnd, GW_HWNDNEXT))
- {
- GetWindowThreadProcessId (hWnd, &dwWindowProcessID);
-
- if ((dwWindowProcessID == dwCurrentProcessID)
- && GetProp (hWnd, WIN_WINDOW_PROP))
- {
- if (hWnd == pRLNextWinPriv->hWnd)
- {
- winDebug ("lower: Insert after Win %08x\n", pRLNextWinPriv);
-
- SetWindowPos (pRLWinPriv->hWnd, pRLNextWinPriv->hWnd,
- 0, 0, 0, 0,
- SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
- fNeedRestack = FALSE;
- break;
- }
- }
- }
+ winDebug("Win %08x is not top\n", pRLWinPriv);
+
+ for (hWnd = GetNextWindow(pRLWinPriv->hWnd, GW_HWNDPREV);
+ fNeedRestack && hWnd != NULL;
+ hWnd = GetNextWindow(hWnd, GW_HWNDPREV)) {
+ GetWindowThreadProcessId(hWnd, &dwWindowProcessID);
+
+ if ((dwWindowProcessID == dwCurrentProcessID)
+ && GetProp(hWnd, WIN_WINDOW_PROP)) {
+ if (hWnd == pRLNextWinPriv->hWnd) {
+ /* Enable interleave X window and Windows window */
+ if (!fFirst) {
+ winDebug("raise: Insert after Win %08x\n",
+ pRLNextWinPriv);
+ SetWindowPos(pRLWinPriv->hWnd, pRLNextWinPriv->hWnd,
+ 0, 0, 0, 0,
+ SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
+ }
+ else {
+ winDebug("No change\n");
+ }
+ fNeedRestack = FALSE;
+ break;
+ }
+ if (fFirst)
+ fFirst = FALSE;
+ }
+ }
+
+ for (hWnd = GetNextWindow(pRLWinPriv->hWnd, GW_HWNDNEXT);
+ fNeedRestack && hWnd != NULL;
+ hWnd = GetNextWindow(hWnd, GW_HWNDNEXT)) {
+ GetWindowThreadProcessId(hWnd, &dwWindowProcessID);
+
+ if ((dwWindowProcessID == dwCurrentProcessID)
+ && GetProp(hWnd, WIN_WINDOW_PROP)) {
+ if (hWnd == pRLNextWinPriv->hWnd) {
+ winDebug("lower: Insert after Win %08x\n", pRLNextWinPriv);
+
+ SetWindowPos(pRLWinPriv->hWnd, pRLNextWinPriv->hWnd,
+ 0, 0, 0, 0,
+ SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
+ fNeedRestack = FALSE;
+ break;
+ }
+ }
+ }
}
#endif
- else
- {
- /* using general wm like twm, wmaker etc.
- Interleave X window and Windows window will cause problem. */
- SetWindowPos (pRLWinPriv->hWnd, pRLNextWinPriv->hWnd,
- 0, 0, 0, 0,
- SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
+ else {
+ /* using general wm like twm, wmaker etc.
+ Interleave X window and Windows window will cause problem. */
+ SetWindowPos(pRLWinPriv->hWnd, pRLNextWinPriv->hWnd,
+ 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
}
- winDebug ("winMWExtWMRestackFrame - done (%08x)\n", (int) pRLWinPriv);
+ winDebug("winMWExtWMRestackFrame - done (%08x)\n", (int) pRLWinPriv);
- pRLWinPriv->fRestackingNow = FALSE;
+ pRLWinPriv->fRestackingNow = FALSE;
}
void
-winMWExtWMReshapeFrame (RootlessFrameID wid, RegionPtr pShape)
+winMWExtWMReshapeFrame(RootlessFrameID wid, RegionPtr pShape)
{
- win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
- HRGN hRgn, hRgnWindow, hRgnClient;
- RECT rcWindow, rcClient;
-
- winDebug ("winMWExtWMReshapeFrame (%08x)\n", (int) pRLWinPriv);
-
- hRgn = winMWExtWMCreateRgnFromRegion (pShape);
-
- /* Create region for non-client area */
- GetWindowRect (pRLWinPriv->hWnd, &rcWindow);
- GetClientRect (pRLWinPriv->hWnd, &rcClient);
- MapWindowPoints (pRLWinPriv->hWnd, HWND_DESKTOP, (LPPOINT)&rcClient, 2);
- OffsetRgn (hRgn, rcClient.left - rcWindow.left, rcClient.top - rcWindow.top);
- OffsetRect (&rcClient, -rcWindow.left, -rcWindow.top);
- OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
- hRgnWindow = CreateRectRgnIndirect (&rcWindow);
- hRgnClient = CreateRectRgnIndirect (&rcClient);
- CombineRgn (hRgnWindow, hRgnWindow, hRgnClient, RGN_DIFF);
- CombineRgn (hRgn, hRgnWindow, hRgn, RGN_OR);
-
-
- SetWindowRgn (pRLWinPriv->hWnd, hRgn, TRUE);
-
- DeleteObject (hRgnWindow);
- DeleteObject (hRgnClient);
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
+ HRGN hRgn, hRgnWindow, hRgnClient;
+ RECT rcWindow, rcClient;
+
+ winDebug("winMWExtWMReshapeFrame (%08x)\n", (int) pRLWinPriv);
+
+ hRgn = winMWExtWMCreateRgnFromRegion(pShape);
+
+ /* Create region for non-client area */
+ GetWindowRect(pRLWinPriv->hWnd, &rcWindow);
+ GetClientRect(pRLWinPriv->hWnd, &rcClient);
+ MapWindowPoints(pRLWinPriv->hWnd, HWND_DESKTOP, (LPPOINT) & rcClient, 2);
+ OffsetRgn(hRgn, rcClient.left - rcWindow.left, rcClient.top - rcWindow.top);
+ OffsetRect(&rcClient, -rcWindow.left, -rcWindow.top);
+ OffsetRect(&rcWindow, -rcWindow.left, -rcWindow.top);
+ hRgnWindow = CreateRectRgnIndirect(&rcWindow);
+ hRgnClient = CreateRectRgnIndirect(&rcClient);
+ CombineRgn(hRgnWindow, hRgnWindow, hRgnClient, RGN_DIFF);
+ CombineRgn(hRgn, hRgnWindow, hRgn, RGN_OR);
+
+ SetWindowRgn(pRLWinPriv->hWnd, hRgn, TRUE);
+
+ DeleteObject(hRgnWindow);
+ DeleteObject(hRgnClient);
}
void
-winMWExtWMUnmapFrame (RootlessFrameID wid)
+winMWExtWMUnmapFrame(RootlessFrameID wid)
{
- win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
- winDebug ("winMWExtWMUnmapFrame (%08x)\n", (int) pRLWinPriv);
+ winDebug("winMWExtWMUnmapFrame (%08x)\n", (int) pRLWinPriv);
- g_fNoConfigureWindow = TRUE;
- //ShowWindow (pRLWinPriv->hWnd, SW_MINIMIZE);
- ShowWindow (pRLWinPriv->hWnd, SW_HIDE);
- g_fNoConfigureWindow = FALSE;
+ g_fNoConfigureWindow = TRUE;
+ //ShowWindow (pRLWinPriv->hWnd, SW_MINIMIZE);
+ ShowWindow(pRLWinPriv->hWnd, SW_HIDE);
+ g_fNoConfigureWindow = FALSE;
}
/*
* Fixme: Code sharing with winshadgdi.c and other engine support
*/
void
-winMWExtWMStartDrawing (RootlessFrameID wid, char **pixelData, int *bytesPerRow)
+winMWExtWMStartDrawing(RootlessFrameID wid, char **pixelData, int *bytesPerRow)
{
- win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
- winPrivScreenPtr pScreenPriv = NULL;
- winScreenInfo *pScreenInfo = NULL;
- ScreenPtr pScreen = NULL;
- DIBSECTION dibsection;
- Bool fReturn = TRUE;
- HDC hdcNew;
- HBITMAP hbmpNew;
-
- winDebug ("winMWExtWMStartDrawing (%08x) %08x\n", (int) pRLWinPriv, pRLWinPriv->fDestroyed);
-
- if (!pRLWinPriv->fDestroyed)
- {
- pScreen = pRLWinPriv->pFrame->win->drawable.pScreen;
- if (pScreen) pScreenPriv = winGetScreenPriv(pScreen);
- if (pScreenPriv) pScreenInfo = pScreenPriv->pScreenInfo;
-
- winDebug ("\tpScreenPriv %08X\n", (int) pScreenPriv);
- winDebug ("\tpScreenInfo %08X\n", (int) pScreenInfo);
- winDebug ("\t(%d, %d)\n", (int)pRLWinPriv->pFrame->width,
- (int) pRLWinPriv->pFrame->height);
-
- if (pRLWinPriv->hdcScreen == NULL)
- {
- InitWin32RootlessEngine (pRLWinPriv);
- }
-
- if (pRLWinPriv->fResized)
- {
- /* width * bpp must be multiple of 4 to match 32bit alignment */
- int stridesize;
- int misalignment;
-
- pRLWinPriv->pbmihShadow->biWidth = pRLWinPriv->pFrame->width;
- pRLWinPriv->pbmihShadow->biHeight = -pRLWinPriv->pFrame->height;
-
- stridesize = pRLWinPriv->pFrame->width * (pScreenInfo->dwBPP >> 3);
- misalignment = stridesize & 3;
- if (misalignment != 0)
- {
- stridesize += 4 - misalignment;
- pRLWinPriv->pbmihShadow->biWidth = stridesize / (pScreenInfo->dwBPP >> 3);
- winDebug("\tresizing to %d (was %d)\n",
- pRLWinPriv->pbmihShadow->biWidth, pRLWinPriv->pFrame->width);
- }
-
- hdcNew = CreateCompatibleDC (pRLWinPriv->hdcScreen);
- /* Create a DI shadow bitmap with a bit pointer */
- hbmpNew = CreateDIBSection (pRLWinPriv->hdcScreen,
- (BITMAPINFO *) pRLWinPriv->pbmihShadow,
- DIB_RGB_COLORS,
- (VOID**) &pRLWinPriv->pfb,
- NULL,
- 0);
- if (hbmpNew == NULL || pRLWinPriv->pfb == NULL)
- {
- ErrorF ("winMWExtWMStartDrawing - CreateDIBSection failed\n");
- //return FALSE;
- }
- else
- {
- winDebug ("winMWExtWMStartDrawing - Shadow buffer allocated\n");
- }
-
- /* Get information about the bitmap that was allocated */
- GetObject (hbmpNew, sizeof (dibsection), &dibsection);
-
- /* Print information about bitmap allocated */
- winDebug ("winMWExtWMStartDrawing - Dibsection width: %d height: %d "
- "depth: %d size image: %d\n",
- (unsigned int)dibsection.dsBmih.biWidth,
- (unsigned int)dibsection.dsBmih.biHeight,
- (unsigned int)dibsection.dsBmih.biBitCount,
- (unsigned int)dibsection.dsBmih.biSizeImage);
-
- /* Select the shadow bitmap into the shadow DC */
- SelectObject (hdcNew, hbmpNew);
-
- winDebug ("winMWExtWMStartDrawing - Attempting a shadow blit\n");
-
- /* Blit from the old shadow to the new shadow */
- fReturn = BitBlt (hdcNew,
- 0, 0,
- pRLWinPriv->pFrame->width, pRLWinPriv->pFrame->height,
- pRLWinPriv->hdcShadow,
- 0, 0,
- SRCCOPY);
- if (fReturn)
- {
- winDebug ("winMWExtWMStartDrawing - Shadow blit success\n");
- }
- else
- {
- ErrorF ("winMWExtWMStartDrawing - Shadow blit failure\n");
- }
-
- /* Look for height weirdness */
- if (dibsection.dsBmih.biHeight < 0)
- {
- /* FIXME: Figure out why biHeight is sometimes negative */
- ErrorF ("winMWExtWMStartDrawing - WEIRDNESS - "
- "biHeight still negative: %d\n",
- (int) dibsection.dsBmih.biHeight);
- ErrorF ("winMWExtWMStartDrawing - WEIRDNESS - "
- "Flipping biHeight sign\n");
- dibsection.dsBmih.biHeight = -dibsection.dsBmih.biHeight;
- }
-
- pRLWinPriv->dwWidthBytes = dibsection.dsBm.bmWidthBytes;
-
- winDebug ("winMWExtWMStartDrawing - bytesPerRow: %d\n",
- (unsigned int)dibsection.dsBm.bmWidthBytes);
-
- /* Free the old shadow bitmap */
- DeleteObject (pRLWinPriv->hdcShadow);
- DeleteObject (pRLWinPriv->hbmpShadow);
-
- pRLWinPriv->hdcShadow = hdcNew;
- pRLWinPriv->hbmpShadow = hbmpNew;
-
- pRLWinPriv->fResized = FALSE;
- winDebug ("winMWExtWMStartDrawing - 0x%08x %d\n",
- (unsigned int)pRLWinPriv->pfb,
- (unsigned int)dibsection.dsBm.bmWidthBytes);
- }
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
+ winPrivScreenPtr pScreenPriv = NULL;
+ winScreenInfo *pScreenInfo = NULL;
+ ScreenPtr pScreen = NULL;
+ DIBSECTION dibsection;
+ Bool fReturn = TRUE;
+ HDC hdcNew;
+ HBITMAP hbmpNew;
+
+ winDebug("winMWExtWMStartDrawing (%08x) %08x\n", (int) pRLWinPriv,
+ pRLWinPriv->fDestroyed);
+
+ if (!pRLWinPriv->fDestroyed) {
+ pScreen = pRLWinPriv->pFrame->win->drawable.pScreen;
+ if (pScreen)
+ pScreenPriv = winGetScreenPriv(pScreen);
+ if (pScreenPriv)
+ pScreenInfo = pScreenPriv->pScreenInfo;
+
+ winDebug("\tpScreenPriv %08X\n", (int) pScreenPriv);
+ winDebug("\tpScreenInfo %08X\n", (int) pScreenInfo);
+ winDebug("\t(%d, %d)\n", (int) pRLWinPriv->pFrame->width,
+ (int) pRLWinPriv->pFrame->height);
+
+ if (pRLWinPriv->hdcScreen == NULL) {
+ InitWin32RootlessEngine(pRLWinPriv);
+ }
+
+ if (pRLWinPriv->fResized) {
+ /* width * bpp must be multiple of 4 to match 32bit alignment */
+ int stridesize;
+ int misalignment;
+
+ pRLWinPriv->pbmihShadow->biWidth = pRLWinPriv->pFrame->width;
+ pRLWinPriv->pbmihShadow->biHeight = -pRLWinPriv->pFrame->height;
+
+ stridesize = pRLWinPriv->pFrame->width * (pScreenInfo->dwBPP >> 3);
+ misalignment = stridesize & 3;
+ if (misalignment != 0) {
+ stridesize += 4 - misalignment;
+ pRLWinPriv->pbmihShadow->biWidth =
+ stridesize / (pScreenInfo->dwBPP >> 3);
+ winDebug("\tresizing to %d (was %d)\n",
+ pRLWinPriv->pbmihShadow->biWidth,
+ pRLWinPriv->pFrame->width);
+ }
+
+ hdcNew = CreateCompatibleDC(pRLWinPriv->hdcScreen);
+ /* Create a DI shadow bitmap with a bit pointer */
+ hbmpNew = CreateDIBSection(pRLWinPriv->hdcScreen,
+ (BITMAPINFO *) pRLWinPriv->pbmihShadow,
+ DIB_RGB_COLORS,
+ (VOID **) & pRLWinPriv->pfb, NULL, 0);
+ if (hbmpNew == NULL || pRLWinPriv->pfb == NULL) {
+ ErrorF("winMWExtWMStartDrawing - CreateDIBSection failed\n");
+ //return FALSE;
+ }
+ else {
+ winDebug("winMWExtWMStartDrawing - Shadow buffer allocated\n");
+ }
+
+ /* Get information about the bitmap that was allocated */
+ GetObject(hbmpNew, sizeof(dibsection), &dibsection);
+
+ /* Print information about bitmap allocated */
+ winDebug("winMWExtWMStartDrawing - Dibsection width: %d height: %d "
+ "depth: %d size image: %d\n",
+ (unsigned int) dibsection.dsBmih.biWidth,
+ (unsigned int) dibsection.dsBmih.biHeight,
+ (unsigned int) dibsection.dsBmih.biBitCount,
+ (unsigned int) dibsection.dsBmih.biSizeImage);
+
+ /* Select the shadow bitmap into the shadow DC */
+ SelectObject(hdcNew, hbmpNew);
+
+ winDebug("winMWExtWMStartDrawing - Attempting a shadow blit\n");
+
+ /* Blit from the old shadow to the new shadow */
+ fReturn = BitBlt(hdcNew,
+ 0, 0,
+ pRLWinPriv->pFrame->width,
+ pRLWinPriv->pFrame->height, pRLWinPriv->hdcShadow,
+ 0, 0, SRCCOPY);
+ if (fReturn) {
+ winDebug("winMWExtWMStartDrawing - Shadow blit success\n");
+ }
+ else {
+ ErrorF("winMWExtWMStartDrawing - Shadow blit failure\n");
+ }
+
+ /* Look for height weirdness */
+ if (dibsection.dsBmih.biHeight < 0) {
+ /* FIXME: Figure out why biHeight is sometimes negative */
+ ErrorF("winMWExtWMStartDrawing - WEIRDNESS - "
+ "biHeight still negative: %d\n",
+ (int) dibsection.dsBmih.biHeight);
+ ErrorF("winMWExtWMStartDrawing - WEIRDNESS - "
+ "Flipping biHeight sign\n");
+ dibsection.dsBmih.biHeight = -dibsection.dsBmih.biHeight;
+ }
+
+ pRLWinPriv->dwWidthBytes = dibsection.dsBm.bmWidthBytes;
+
+ winDebug("winMWExtWMStartDrawing - bytesPerRow: %d\n",
+ (unsigned int) dibsection.dsBm.bmWidthBytes);
+
+ /* Free the old shadow bitmap */
+ DeleteObject(pRLWinPriv->hdcShadow);
+ DeleteObject(pRLWinPriv->hbmpShadow);
+
+ pRLWinPriv->hdcShadow = hdcNew;
+ pRLWinPriv->hbmpShadow = hbmpNew;
+
+ pRLWinPriv->fResized = FALSE;
+ winDebug("winMWExtWMStartDrawing - 0x%08x %d\n",
+ (unsigned int) pRLWinPriv->pfb,
+ (unsigned int) dibsection.dsBm.bmWidthBytes);
+ }
}
- else
- {
- ErrorF ("winMWExtWMStartDrawing - Already window was destroyed \n");
+ else {
+ ErrorF("winMWExtWMStartDrawing - Already window was destroyed \n");
}
- winDebug ("winMWExtWMStartDrawing - done (0x%08x) 0x%08x %d\n",
- (int) pRLWinPriv,
- (unsigned int)pRLWinPriv->pfb, (unsigned int)pRLWinPriv->dwWidthBytes);
- *pixelData = pRLWinPriv->pfb;
- *bytesPerRow = pRLWinPriv->dwWidthBytes;
+ winDebug("winMWExtWMStartDrawing - done (0x%08x) 0x%08x %d\n",
+ (int) pRLWinPriv,
+ (unsigned int) pRLWinPriv->pfb,
+ (unsigned int) pRLWinPriv->dwWidthBytes);
+ *pixelData = pRLWinPriv->pfb;
+ *bytesPerRow = pRLWinPriv->dwWidthBytes;
}
void
-winMWExtWMStopDrawing (RootlessFrameID wid, Bool fFlush)
+winMWExtWMStopDrawing(RootlessFrameID wid, Bool fFlush)
{
}
void
-winMWExtWMUpdateRegion (RootlessFrameID wid, RegionPtr pDamage)
+winMWExtWMUpdateRegion(RootlessFrameID wid, RegionPtr pDamage)
{
- win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
- if (!g_fNoConfigureWindow) UpdateWindow (pRLWinPriv->hWnd);
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
+
+ if (!g_fNoConfigureWindow)
+ UpdateWindow(pRLWinPriv->hWnd);
}
void
-winMWExtWMDamageRects (RootlessFrameID wid, int nCount, const BoxRec *pRects,
- int shift_x, int shift_y)
+winMWExtWMDamageRects(RootlessFrameID wid, int nCount, const BoxRec * pRects,
+ int shift_x, int shift_y)
{
- win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
- const BoxRec *pEnd;
- winDebug ("winMWExtWMDamageRects (%08x, %d, %08x, %d, %d)\n",
- pRLWinPriv, nCount, pRects, shift_x, shift_y);
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
+ const BoxRec *pEnd;
- for (pEnd = pRects + nCount; pRects < pEnd; pRects++) {
+ winDebug("winMWExtWMDamageRects (%08x, %d, %08x, %d, %d)\n",
+ pRLWinPriv, nCount, pRects, shift_x, shift_y);
+
+ for (pEnd = pRects + nCount; pRects < pEnd; pRects++) {
RECT rcDmg;
+
rcDmg.left = pRects->x1 + shift_x;
rcDmg.top = pRects->y1 + shift_y;
rcDmg.right = pRects->x2 + shift_x;
rcDmg.bottom = pRects->y2 + shift_y;
- InvalidateRect (pRLWinPriv->hWnd, &rcDmg, FALSE);
+ InvalidateRect(pRLWinPriv->hWnd, &rcDmg, FALSE);
}
}
void
-winMWExtWMRootlessSwitchWindow (RootlessWindowPtr pFrame, WindowPtr oldWin)
+winMWExtWMRootlessSwitchWindow(RootlessWindowPtr pFrame, WindowPtr oldWin)
{
- win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) pFrame->wid;
- winDebug ("winMWExtWMRootlessSwitchWindow (%08x) %08x\n",
- (int) pRLWinPriv, (int) pRLWinPriv->hWnd);
- pRLWinPriv->pFrame = pFrame;
- pRLWinPriv->fResized = TRUE;
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) pFrame->wid;
+
+ winDebug("winMWExtWMRootlessSwitchWindow (%08x) %08x\n",
+ (int) pRLWinPriv, (int) pRLWinPriv->hWnd);
+ pRLWinPriv->pFrame = pFrame;
+ pRLWinPriv->fResized = TRUE;
- /* Set the window extended style flags */
- SetWindowLongPtr (pRLWinPriv->hWnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
+ /* Set the window extended style flags */
+ SetWindowLongPtr(pRLWinPriv->hWnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
- /* Set the window standard style flags */
- SetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE,
- WS_POPUP | WS_CLIPCHILDREN);
+ /* Set the window standard style flags */
+ SetWindowLongPtr(pRLWinPriv->hWnd, GWL_STYLE, WS_POPUP | WS_CLIPCHILDREN);
- DeleteProperty (serverClient, oldWin, AtmWindowsWmNativeHwnd ());
- winMWExtWMSetNativeProperty (pFrame);
+ DeleteProperty(serverClient, oldWin, AtmWindowsWmNativeHwnd());
+ winMWExtWMSetNativeProperty(pFrame);
}
void
-winMWExtWMCopyBytes (unsigned int width, unsigned int height,
- const void *src, unsigned int srcRowBytes,
- void *dst, unsigned int dstRowBytes)
+winMWExtWMCopyBytes(unsigned int width, unsigned int height,
+ const void *src, unsigned int srcRowBytes,
+ void *dst, unsigned int dstRowBytes)
{
- winDebug ("winMWExtWMCopyBytes - Not implemented\n");
+ winDebug("winMWExtWMCopyBytes - Not implemented\n");
}
void
-winMWExtWMCopyWindow (RootlessFrameID wid, int nDstRects, const BoxRec *pDstRects,
- int nDx, int nDy)
+winMWExtWMCopyWindow(RootlessFrameID wid, int nDstRects,
+ const BoxRec * pDstRects, int nDx, int nDy)
{
- win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
- const BoxRec *pEnd;
- RECT rcDmg;
- winDebug ("winMWExtWMCopyWindow (%08x, %d, %08x, %d, %d)\n",
- (int) pRLWinPriv, nDstRects, (int) pDstRects, nDx, nDy);
-
- for (pEnd = pDstRects + nDstRects; pDstRects < pEnd; pDstRects++)
- {
- winDebug ("BitBlt (%d, %d, %d, %d) (%d, %d)\n",
- pDstRects->x1, pDstRects->y1,
- pDstRects->x2 - pDstRects->x1,
- pDstRects->y2 - pDstRects->y1,
- pDstRects->x1 + nDx,
- pDstRects->y1 + nDy);
-
- if (!BitBlt (pRLWinPriv->hdcShadow,
- pDstRects->x1, pDstRects->y1,
- pDstRects->x2 - pDstRects->x1,
- pDstRects->y2 - pDstRects->y1,
- pRLWinPriv->hdcShadow,
- pDstRects->x1 + nDx, pDstRects->y1 + nDy,
- SRCCOPY))
- {
- ErrorF ("winMWExtWMCopyWindow - BitBlt failed.\n");
- }
-
- rcDmg.left = pDstRects->x1;
- rcDmg.top = pDstRects->y1;
- rcDmg.right = pDstRects->x2;
- rcDmg.bottom = pDstRects->y2;
-
- InvalidateRect (pRLWinPriv->hWnd, &rcDmg, FALSE);
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
+ const BoxRec *pEnd;
+ RECT rcDmg;
+
+ winDebug("winMWExtWMCopyWindow (%08x, %d, %08x, %d, %d)\n",
+ (int) pRLWinPriv, nDstRects, (int) pDstRects, nDx, nDy);
+
+ for (pEnd = pDstRects + nDstRects; pDstRects < pEnd; pDstRects++) {
+ winDebug("BitBlt (%d, %d, %d, %d) (%d, %d)\n",
+ pDstRects->x1, pDstRects->y1,
+ pDstRects->x2 - pDstRects->x1,
+ pDstRects->y2 - pDstRects->y1,
+ pDstRects->x1 + nDx, pDstRects->y1 + nDy);
+
+ if (!BitBlt(pRLWinPriv->hdcShadow,
+ pDstRects->x1, pDstRects->y1,
+ pDstRects->x2 - pDstRects->x1,
+ pDstRects->y2 - pDstRects->y1,
+ pRLWinPriv->hdcShadow,
+ pDstRects->x1 + nDx, pDstRects->y1 + nDy, SRCCOPY)) {
+ ErrorF("winMWExtWMCopyWindow - BitBlt failed.\n");
+ }
+
+ rcDmg.left = pDstRects->x1;
+ rcDmg.top = pDstRects->y1;
+ rcDmg.right = pDstRects->x2;
+ rcDmg.bottom = pDstRects->y2;
+
+ InvalidateRect(pRLWinPriv->hWnd, &rcDmg, FALSE);
}
- winDebug ("winMWExtWMCopyWindow - done\n");
+ winDebug("winMWExtWMCopyWindow - done\n");
}
-
/*
* winMWExtWMSetNativeProperty
*/
static void
-winMWExtWMSetNativeProperty (RootlessWindowPtr pFrame)
+winMWExtWMSetNativeProperty(RootlessWindowPtr pFrame)
{
- win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) pFrame->wid;
- long lData;
+ win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) pFrame->wid;
+ long lData;
- /* FIXME: move this to WindowsWM extension */
+ /* FIXME: move this to WindowsWM extension */
- lData = (long) pRLWinPriv->hWnd;
- dixChangeWindowProperty(serverClient, pFrame->win, AtmWindowsWmNativeHwnd(),
- XA_INTEGER, 32, PropModeReplace, 1, &lData, TRUE);
+ lData = (long) pRLWinPriv->hWnd;
+ dixChangeWindowProperty(serverClient, pFrame->win, AtmWindowsWmNativeHwnd(),
+ XA_INTEGER, 32, PropModeReplace, 1, &lData, TRUE);
}
diff --git a/xorg-server/hw/xwin/winwin32rootlesswindow.c b/xorg-server/hw/xwin/winwin32rootlesswindow.c
index bcfb2798e..19478ad60 100644
--- a/xorg-server/hw/xwin/winwin32rootlesswindow.c
+++ b/xorg-server/hw/xwin/winwin32rootlesswindow.c
@@ -42,345 +42,333 @@
*/
void
-winMWExtWMReorderWindows (ScreenPtr pScreen)
+winMWExtWMReorderWindows(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- HWND hwnd = NULL;
- win32RootlessWindowPtr pRLWin = NULL;
- win32RootlessWindowPtr pRLWinSib = NULL;
- DWORD dwCurrentProcessID = GetCurrentProcessId ();
- DWORD dwWindowProcessID = 0;
- XID vlist[2];
+ winScreenPriv(pScreen);
+ HWND hwnd = NULL;
+ win32RootlessWindowPtr pRLWin = NULL;
+ win32RootlessWindowPtr pRLWinSib = NULL;
+ DWORD dwCurrentProcessID = GetCurrentProcessId();
+ DWORD dwWindowProcessID = 0;
+ XID vlist[2];
#if CYGMULTIWINDOW_DEBUG && FALSE
- winDebug ("winMWExtWMReorderWindows\n");
+ winDebug("winMWExtWMReorderWindows\n");
#endif
- pScreenPriv->fRestacking = TRUE;
+ pScreenPriv->fRestacking = TRUE;
- if (pScreenPriv->fWindowOrderChanged)
- {
+ if (pScreenPriv->fWindowOrderChanged) {
#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMReorderWindows - Need to restack\n");
+ winDebug("winMWExtWMReorderWindows - Need to restack\n");
#endif
- hwnd = GetTopWindow (NULL);
-
- while (hwnd)
- {
- GetWindowThreadProcessId (hwnd, &dwWindowProcessID);
-
- if ((dwWindowProcessID == dwCurrentProcessID)
- && GetProp (hwnd, WIN_WINDOW_PROP))
- {
- pRLWinSib = pRLWin;
- pRLWin = (win32RootlessWindowPtr)GetProp (hwnd, WIN_WINDOW_PROP);
-
- if (pRLWinSib)
- {
- vlist[0] = pRLWinSib->pFrame->win->drawable.id;
- vlist[1] = Below;
-
- ConfigureWindow (pRLWin->pFrame->win, CWSibling | CWStackMode,
- vlist, wClient(pRLWin->pFrame->win));
- }
- else
- {
- /* 1st window - raise to the top */
- vlist[0] = Above;
-
- ConfigureWindow (pRLWin->pFrame->win, CWStackMode,
- vlist, wClient(pRLWin->pFrame->win));
- }
- }
- hwnd = GetNextWindow (hwnd, GW_HWNDNEXT);
- }
+ hwnd = GetTopWindow(NULL);
+
+ while (hwnd) {
+ GetWindowThreadProcessId(hwnd, &dwWindowProcessID);
+
+ if ((dwWindowProcessID == dwCurrentProcessID)
+ && GetProp(hwnd, WIN_WINDOW_PROP)) {
+ pRLWinSib = pRLWin;
+ pRLWin =
+ (win32RootlessWindowPtr) GetProp(hwnd, WIN_WINDOW_PROP);
+
+ if (pRLWinSib) {
+ vlist[0] = pRLWinSib->pFrame->win->drawable.id;
+ vlist[1] = Below;
+
+ ConfigureWindow(pRLWin->pFrame->win,
+ CWSibling | CWStackMode, vlist,
+ wClient(pRLWin->pFrame->win));
+ }
+ else {
+ /* 1st window - raise to the top */
+ vlist[0] = Above;
+
+ ConfigureWindow(pRLWin->pFrame->win, CWStackMode,
+ vlist, wClient(pRLWin->pFrame->win));
+ }
+ }
+ hwnd = GetNextWindow(hwnd, GW_HWNDNEXT);
+ }
}
- pScreenPriv->fRestacking = FALSE;
- pScreenPriv->fWindowOrderChanged = FALSE;
+ pScreenPriv->fRestacking = FALSE;
+ pScreenPriv->fWindowOrderChanged = FALSE;
}
#endif
-
/*
* winMWExtWMMoveXWindow
*/
void
-winMWExtWMMoveXWindow (WindowPtr pWin, int x, int y)
+winMWExtWMMoveXWindow(WindowPtr pWin, int x, int y)
{
- CARD32 *vlist = malloc(sizeof(CARD32)*2);
+ CARD32 *vlist = malloc(sizeof(CARD32) * 2);
- vlist[0] = x;
- vlist[1] = y;
- ConfigureWindow (pWin, CWX | CWY, vlist, wClient(pWin));
- free(vlist);
+ vlist[0] = x;
+ vlist[1] = y;
+ ConfigureWindow(pWin, CWX | CWY, vlist, wClient(pWin));
+ free(vlist);
}
-
/*
* winMWExtWMResizeXWindow
*/
void
-winMWExtWMResizeXWindow (WindowPtr pWin, int w, int h)
+winMWExtWMResizeXWindow(WindowPtr pWin, int w, int h)
{
- CARD32 *vlist = malloc(sizeof(CARD32)*2);
+ CARD32 *vlist = malloc(sizeof(CARD32) * 2);
- vlist[0] = w;
- vlist[1] = h;
- ConfigureWindow (pWin, CWWidth | CWHeight, vlist, wClient(pWin));
- free(vlist);
+ vlist[0] = w;
+ vlist[1] = h;
+ ConfigureWindow(pWin, CWWidth | CWHeight, vlist, wClient(pWin));
+ free(vlist);
}
-
/*
* winMWExtWMMoveResizeXWindow
*/
void
-winMWExtWMMoveResizeXWindow (WindowPtr pWin, int x, int y, int w, int h)
+winMWExtWMMoveResizeXWindow(WindowPtr pWin, int x, int y, int w, int h)
{
- CARD32 *vlist = malloc(sizeof(long)*4);
+ CARD32 *vlist = malloc(sizeof(long) * 4);
- vlist[0] = x;
- vlist[1] = y;
- vlist[2] = w;
- vlist[3] = h;
+ vlist[0] = x;
+ vlist[1] = y;
+ vlist[2] = w;
+ vlist[3] = h;
- ConfigureWindow (pWin, CWX | CWY | CWWidth | CWHeight, vlist, wClient(pWin));
- free(vlist);
+ ConfigureWindow(pWin, CWX | CWY | CWWidth | CWHeight, vlist, wClient(pWin));
+ free(vlist);
}
-
/*
* winMWExtWMUpdateIcon
* Change the Windows window icon
*/
void
-winMWExtWMUpdateIcon (Window id)
+winMWExtWMUpdateIcon(Window id)
{
- WindowPtr pWin;
- HICON hIcon, hiconOld;
+ WindowPtr pWin;
+ HICON hIcon, hiconOld;
- dixLookupResourceByType((pointer) &pWin, id, RT_WINDOW, NullClient, DixUnknownAccess);
- hIcon = winOverrideIcon ((unsigned long)pWin);
+ dixLookupResourceByType((pointer) &pWin, id, RT_WINDOW, NullClient,
+ DixUnknownAccess);
+ hIcon = winOverrideIcon((unsigned long) pWin);
- if (!hIcon)
- hIcon = winXIconToHICON (pWin, GetSystemMetrics(SM_CXICON));
+ if (!hIcon)
+ hIcon = winXIconToHICON(pWin, GetSystemMetrics(SM_CXICON));
- if (hIcon)
- {
- win32RootlessWindowPtr pRLWinPriv
- = (win32RootlessWindowPtr) RootlessFrameForWindow (pWin, FALSE);
+ if (hIcon) {
+ win32RootlessWindowPtr pRLWinPriv
+ = (win32RootlessWindowPtr) RootlessFrameForWindow(pWin, FALSE);
- if (pRLWinPriv->hWnd)
- {
+ if (pRLWinPriv->hWnd) {
- hiconOld = (HICON) SendMessage (pRLWinPriv->hWnd,
- WM_SETICON, ICON_BIG, (LPARAM) hIcon);
- winDestroyIcon(hiconOld);
- }
- hIcon=NULL;
+ hiconOld = (HICON) SendMessage(pRLWinPriv->hWnd,
+ WM_SETICON, ICON_BIG,
+ (LPARAM) hIcon);
+ winDestroyIcon(hiconOld);
+ }
+ hIcon = NULL;
}
}
-
/*
* winMWExtWMDecorateWindow - Update window style. Called by EnumWindows.
*/
wBOOL CALLBACK
-winMWExtWMDecorateWindow (HWND hwnd, LPARAM lParam)
+winMWExtWMDecorateWindow(HWND hwnd, LPARAM lParam)
{
- win32RootlessWindowPtr pRLWinPriv = NULL;
- ScreenPtr pScreen = NULL;
- winPrivScreenPtr pScreenPriv = NULL;
- winScreenInfo *pScreenInfo = NULL;
-
- /* Check if the Windows window property for our X window pointer is valid */
- if ((pRLWinPriv = (win32RootlessWindowPtr)GetProp (hwnd, WIN_WINDOW_PROP)) != NULL)
- {
- if (pRLWinPriv != NULL && pRLWinPriv->pFrame != NULL && pRLWinPriv->pFrame->win != NULL)
- pScreen = pRLWinPriv->pFrame->win->drawable.pScreen;
- if (pScreen) pScreenPriv = winGetScreenPriv(pScreen);
- if (pScreenPriv) pScreenInfo = pScreenPriv->pScreenInfo;
- if (pRLWinPriv && pScreenInfo) winMWExtWMUpdateWindowDecoration (pRLWinPriv, pScreenInfo);
+ win32RootlessWindowPtr pRLWinPriv = NULL;
+ ScreenPtr pScreen = NULL;
+ winPrivScreenPtr pScreenPriv = NULL;
+ winScreenInfo *pScreenInfo = NULL;
+
+ /* Check if the Windows window property for our X window pointer is valid */
+ if ((pRLWinPriv =
+ (win32RootlessWindowPtr) GetProp(hwnd, WIN_WINDOW_PROP)) != NULL) {
+ if (pRLWinPriv != NULL && pRLWinPriv->pFrame != NULL &&
+ pRLWinPriv->pFrame->win != NULL)
+ pScreen = pRLWinPriv->pFrame->win->drawable.pScreen;
+ if (pScreen)
+ pScreenPriv = winGetScreenPriv(pScreen);
+ if (pScreenPriv)
+ pScreenInfo = pScreenPriv->pScreenInfo;
+ if (pRLWinPriv && pScreenInfo)
+ winMWExtWMUpdateWindowDecoration(pRLWinPriv, pScreenInfo);
}
- return TRUE;
+ return TRUE;
}
-
/*
* winMWExtWMUpdateWindowDecoration - Update window style.
*/
void
-winMWExtWMUpdateWindowDecoration (win32RootlessWindowPtr pRLWinPriv,
- winScreenInfoPtr pScreenInfo)
+winMWExtWMUpdateWindowDecoration(win32RootlessWindowPtr pRLWinPriv,
+ winScreenInfoPtr pScreenInfo)
{
- Bool fDecorate = FALSE;
- DWORD dwExStyle = 0;
- DWORD dwStyle = 0;
- WINDOWPLACEMENT wndPlace;
- UINT showCmd = 0;
+ Bool fDecorate = FALSE;
+ DWORD dwExStyle = 0;
+ DWORD dwStyle = 0;
+ WINDOWPLACEMENT wndPlace;
+ UINT showCmd = 0;
- wndPlace.length = sizeof (WINDOWPLACEMENT);
+ wndPlace.length = sizeof(WINDOWPLACEMENT);
- /* Get current window placement */
- GetWindowPlacement (pRLWinPriv->hWnd, &wndPlace);
+ /* Get current window placement */
+ GetWindowPlacement(pRLWinPriv->hWnd, &wndPlace);
#ifdef XWIN_MULTIWINDOWINTWM
- if (winIsInternalWMRunning(pScreenInfo))
- {
- if (!pRLWinPriv->pFrame->win->overrideRedirect)
- fDecorate = TRUE;
+ if (winIsInternalWMRunning(pScreenInfo)) {
+ if (!pRLWinPriv->pFrame->win->overrideRedirect)
+ fDecorate = TRUE;
}
#endif
- if (wndPlace.showCmd == SW_HIDE)
- return;
-
- if (IsWindowVisible (pRLWinPriv->hWnd))
- showCmd = SWP_SHOWWINDOW;
-
- showCmd |= SWP_NOMOVE | SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOZORDER;
-
- winDebug ("winMWExtWMUpdateWindowDecoration %08x %s\n",
- (int)pRLWinPriv, fDecorate?"Decorate":"Bare");
-
- /* Get the standard and extended window style information */
- dwExStyle = GetWindowLongPtr (pRLWinPriv->hWnd, GWL_EXSTYLE);
- dwStyle = GetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE);
-
- if (fDecorate)
- {
- RECT rcNew;
- int iDx, iDy;
- winWMMessageRec wmMsg;
- winScreenPriv(pScreenInfo->pScreen);
-
- /* */
- if (!(dwExStyle & WS_EX_APPWINDOW))
- {
- winDebug ("\tBare=>Decorate\n");
- /* Setup a rectangle with the X window position and size */
- SetRect (&rcNew,
- pRLWinPriv->pFrame->x,
- pRLWinPriv->pFrame->y,
- pRLWinPriv->pFrame->x + pRLWinPriv->pFrame->width,
- pRLWinPriv->pFrame->y + pRLWinPriv->pFrame->height);
+ if (wndPlace.showCmd == SW_HIDE)
+ return;
+
+ if (IsWindowVisible(pRLWinPriv->hWnd))
+ showCmd = SWP_SHOWWINDOW;
+
+ showCmd |= SWP_NOMOVE | SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOZORDER;
+
+ winDebug("winMWExtWMUpdateWindowDecoration %08x %s\n",
+ (int) pRLWinPriv, fDecorate ? "Decorate" : "Bare");
+
+ /* Get the standard and extended window style information */
+ dwExStyle = GetWindowLongPtr(pRLWinPriv->hWnd, GWL_EXSTYLE);
+ dwStyle = GetWindowLongPtr(pRLWinPriv->hWnd, GWL_STYLE);
+
+ if (fDecorate) {
+ RECT rcNew;
+ int iDx, iDy;
+ winWMMessageRec wmMsg;
+
+ winScreenPriv(pScreenInfo->pScreen);
+
+ /* */
+ if (!(dwExStyle & WS_EX_APPWINDOW)) {
+ winDebug("\tBare=>Decorate\n");
+ /* Setup a rectangle with the X window position and size */
+ SetRect(&rcNew,
+ pRLWinPriv->pFrame->x,
+ pRLWinPriv->pFrame->y,
+ pRLWinPriv->pFrame->x + pRLWinPriv->pFrame->width,
+ pRLWinPriv->pFrame->y + pRLWinPriv->pFrame->height);
#ifdef CYGMULTIWINDOW_DEBUG
- winDebug("\tWindow extend {%d, %d, %d, %d}, {%d, %d}\n",
- rcNew.left, rcNew.top, rcNew.right, rcNew.bottom,
- rcNew.right - rcNew.left, rcNew.bottom - rcNew.top);
+ winDebug("\tWindow extend {%d, %d, %d, %d}, {%d, %d}\n",
+ rcNew.left, rcNew.top, rcNew.right, rcNew.bottom,
+ rcNew.right - rcNew.left, rcNew.bottom - rcNew.top);
#endif
- /* */
- AdjustWindowRectEx (&rcNew,
- WS_POPUP | WS_SIZEBOX | WS_OVERLAPPEDWINDOW,
- FALSE,
- WS_EX_APPWINDOW);
+ /* */
+ AdjustWindowRectEx(&rcNew,
+ WS_POPUP | WS_SIZEBOX | WS_OVERLAPPEDWINDOW,
+ FALSE, WS_EX_APPWINDOW);
#ifdef CYGMULTIWINDOW_DEBUG
- winDebug("\tAdjusted {%d, %d, %d, %d}, {%d, %d}\n",
- rcNew.left, rcNew.top, rcNew.right, rcNew.bottom,
- rcNew.right - rcNew.left, rcNew.bottom - rcNew.top);
+ winDebug("\tAdjusted {%d, %d, %d, %d}, {%d, %d}\n",
+ rcNew.left, rcNew.top, rcNew.right, rcNew.bottom,
+ rcNew.right - rcNew.left, rcNew.bottom - rcNew.top);
#endif
- /* Calculate position deltas */
- iDx = pRLWinPriv->pFrame->x - rcNew.left;
- iDy = pRLWinPriv->pFrame->y - rcNew.top;
+ /* Calculate position deltas */
+ iDx = pRLWinPriv->pFrame->x - rcNew.left;
+ iDy = pRLWinPriv->pFrame->y - rcNew.top;
- /* Calculate new rectangle */
- rcNew.left += iDx;
- rcNew.right += iDx;
- rcNew.top += iDy;
- rcNew.bottom += iDy;
+ /* Calculate new rectangle */
+ rcNew.left += iDx;
+ rcNew.right += iDx;
+ rcNew.top += iDy;
+ rcNew.bottom += iDy;
- /* Set the window extended style flags */
- SetWindowLongPtr (pRLWinPriv->hWnd, GWL_EXSTYLE, WS_EX_APPWINDOW);
+ /* Set the window extended style flags */
+ SetWindowLongPtr(pRLWinPriv->hWnd, GWL_EXSTYLE, WS_EX_APPWINDOW);
- /* Set the window standard style flags */
- SetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE,
- WS_POPUP | WS_SIZEBOX | WS_OVERLAPPEDWINDOW);
+ /* Set the window standard style flags */
+ SetWindowLongPtr(pRLWinPriv->hWnd, GWL_STYLE,
+ WS_POPUP | WS_SIZEBOX | WS_OVERLAPPEDWINDOW);
#ifdef CYGMULTIWINDOW_DEBUG
- winDebug("\tWindowStyle: %08x %08x\n",
- WS_POPUP | WS_SIZEBOX | WS_OVERLAPPEDWINDOW,
- WS_EX_APPWINDOW);
+ winDebug("\tWindowStyle: %08x %08x\n",
+ WS_POPUP | WS_SIZEBOX | WS_OVERLAPPEDWINDOW,
+ WS_EX_APPWINDOW);
#endif
- /* Position the Windows window */
+ /* Position the Windows window */
#ifdef CYGMULTIWINDOW_DEBUG
- winDebug("\tMoved {%d, %d, %d, %d}, {%d, %d}\n",
- rcNew.left, rcNew.top, rcNew.right, rcNew.bottom,
- rcNew.right - rcNew.left, rcNew.bottom - rcNew.top);
+ winDebug("\tMoved {%d, %d, %d, %d}, {%d, %d}\n",
+ rcNew.left, rcNew.top, rcNew.right, rcNew.bottom,
+ rcNew.right - rcNew.left, rcNew.bottom - rcNew.top);
#endif
- SetWindowPos (pRLWinPriv->hWnd, NULL,
- rcNew.left, rcNew.top,
- rcNew.right - rcNew.left, rcNew.bottom - rcNew.top,
- showCmd);
-
-
- wmMsg.hwndWindow = pRLWinPriv->hWnd;
- wmMsg.iWindow = (Window)pRLWinPriv->pFrame->win->drawable.id;
- wmMsg.msg = WM_WM_NAME_EVENT;
- winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
-
- winMWExtWMReshapeFrame ((RootlessFrameID)pRLWinPriv ,
- wBoundingShape(pRLWinPriv->pFrame->win));
- }
+ SetWindowPos(pRLWinPriv->hWnd, NULL,
+ rcNew.left, rcNew.top,
+ rcNew.right - rcNew.left, rcNew.bottom - rcNew.top,
+ showCmd);
+
+ wmMsg.hwndWindow = pRLWinPriv->hWnd;
+ wmMsg.iWindow = (Window) pRLWinPriv->pFrame->win->drawable.id;
+ wmMsg.msg = WM_WM_NAME_EVENT;
+ winSendMessageToWM(pScreenPriv->pWMInfo, &wmMsg);
+
+ winMWExtWMReshapeFrame((RootlessFrameID) pRLWinPriv,
+ wBoundingShape(pRLWinPriv->pFrame->win));
+ }
}
- else
- {
- RECT rcNew;
-
- /* */
- if (dwExStyle & WS_EX_APPWINDOW)
- {
- winDebug ("\tDecorate=>Bare\n");
- /* Setup a rectangle with the X window position and size */
- SetRect (&rcNew,
- pRLWinPriv->pFrame->x,
- pRLWinPriv->pFrame->y,
- pRLWinPriv->pFrame->x + pRLWinPriv->pFrame->width,
- pRLWinPriv->pFrame->y + pRLWinPriv->pFrame->height);
+ else {
+ RECT rcNew;
+
+ /* */
+ if (dwExStyle & WS_EX_APPWINDOW) {
+ winDebug("\tDecorate=>Bare\n");
+ /* Setup a rectangle with the X window position and size */
+ SetRect(&rcNew,
+ pRLWinPriv->pFrame->x,
+ pRLWinPriv->pFrame->y,
+ pRLWinPriv->pFrame->x + pRLWinPriv->pFrame->width,
+ pRLWinPriv->pFrame->y + pRLWinPriv->pFrame->height);
#if 0
- /* */
- AdjustWindowRectEx (&rcNew,
- WS_POPUP | WS_CLIPCHILDREN,
- FALSE,
- WS_EX_TOOLWINDOW);
-
- /* Calculate position deltas */
- iDx = pRLWinPriv->pFrame->x - rcNew.left;
- iDy = pRLWinPriv->pFrame->y - rcNew.top;
-
- /* Calculate new rectangle */
- rcNew.left += iDx;
- rcNew.right += iDx;
- rcNew.top += iDy;
- rcNew.bottom += iDy;
+ /* */
+ AdjustWindowRectEx(&rcNew,
+ WS_POPUP | WS_CLIPCHILDREN,
+ FALSE, WS_EX_TOOLWINDOW);
+
+ /* Calculate position deltas */
+ iDx = pRLWinPriv->pFrame->x - rcNew.left;
+ iDy = pRLWinPriv->pFrame->y - rcNew.top;
+
+ /* Calculate new rectangle */
+ rcNew.left += iDx;
+ rcNew.right += iDx;
+ rcNew.top += iDy;
+ rcNew.bottom += iDy;
#endif
- /* Hide window temporary to remove from taskbar. */
- ShowWindow( pRLWinPriv->hWnd, SW_HIDE );
+ /* Hide window temporary to remove from taskbar. */
+ ShowWindow(pRLWinPriv->hWnd, SW_HIDE);
- /* Set the window extended style flags */
- SetWindowLongPtr (pRLWinPriv->hWnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
+ /* Set the window extended style flags */
+ SetWindowLongPtr(pRLWinPriv->hWnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
- /* Set the window standard style flags */
- SetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE,
- WS_POPUP | WS_CLIPCHILDREN);
+ /* Set the window standard style flags */
+ SetWindowLongPtr(pRLWinPriv->hWnd, GWL_STYLE,
+ WS_POPUP | WS_CLIPCHILDREN);
- /* Position the Windows window */
- SetWindowPos (pRLWinPriv->hWnd, NULL,
- rcNew.left, rcNew.top,
- rcNew.right - rcNew.left, rcNew.bottom - rcNew.top,
- showCmd);
+ /* Position the Windows window */
+ SetWindowPos(pRLWinPriv->hWnd, NULL,
+ rcNew.left, rcNew.top,
+ rcNew.right - rcNew.left, rcNew.bottom - rcNew.top,
+ showCmd);
- winMWExtWMReshapeFrame ((RootlessFrameID)pRLWinPriv ,
- wBoundingShape(pRLWinPriv->pFrame->win));
- }
+ winMWExtWMReshapeFrame((RootlessFrameID) pRLWinPriv,
+ wBoundingShape(pRLWinPriv->pFrame->win));
+ }
}
}
@@ -389,84 +377,86 @@ winMWExtWMUpdateWindowDecoration (win32RootlessWindowPtr pRLWinPriv,
* winIsInternalWMRunning (winScreenInfoPtr pScreenInfo)
*/
Bool
-winIsInternalWMRunning (winScreenInfoPtr pScreenInfo)
+winIsInternalWMRunning(winScreenInfoPtr pScreenInfo)
{
- return pScreenInfo->fInternalWM && !pScreenInfo->fAnotherWMRunning;
+ return pScreenInfo->fInternalWM && !pScreenInfo->fAnotherWMRunning;
}
#endif
-
/*
* winMWExtWMRestackWindows
*/
void
-winMWExtWMRestackWindows (ScreenPtr pScreen)
+winMWExtWMRestackWindows(ScreenPtr pScreen)
{
- winScreenPriv(pScreen);
- WindowPtr pRoot = pScreen->root;
- WindowPtr pWin = NULL;
- WindowPtr pWinPrev = NULL;
- win32RootlessWindowPtr pRLWin = NULL;
- win32RootlessWindowPtr pRLWinPrev = NULL;
- int nWindow = 0;
- HDWP hWinPosInfo = NULL;
+ winScreenPriv(pScreen);
+ WindowPtr pRoot = pScreen->root;
+ WindowPtr pWin = NULL;
+ WindowPtr pWinPrev = NULL;
+ win32RootlessWindowPtr pRLWin = NULL;
+ win32RootlessWindowPtr pRLWinPrev = NULL;
+ int nWindow = 0;
+ HDWP hWinPosInfo = NULL;
#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMRestackWindows\n");
+ winDebug("winMWExtWMRestackWindows\n");
#endif
- pScreenPriv->fRestacking = TRUE;
+ pScreenPriv->fRestacking = TRUE;
- if (pRoot != NULL)
- {
- for (pWin = pRoot->firstChild; pWin; pWin = pWin->nextSib)
- nWindow ++;
+ if (pRoot != NULL) {
+ for (pWin = pRoot->firstChild; pWin; pWin = pWin->nextSib)
+ nWindow++;
- hWinPosInfo = BeginDeferWindowPos(nWindow);
+ hWinPosInfo = BeginDeferWindowPos(nWindow);
- for (pWin = pRoot->firstChild; pWin; pWin = pWin->nextSib)
- {
- if (pWin->realized)
- {
- UINT uFlags;
+ for (pWin = pRoot->firstChild; pWin; pWin = pWin->nextSib) {
+ if (pWin->realized) {
+ UINT uFlags;
- pRLWin = (win32RootlessWindowPtr) RootlessFrameForWindow (pWin, FALSE);
- if (pRLWin == NULL) continue;
+ pRLWin =
+ (win32RootlessWindowPtr) RootlessFrameForWindow(pWin,
+ FALSE);
+ if (pRLWin == NULL)
+ continue;
- if (pWinPrev)
- pRLWinPrev = (win32RootlessWindowPtr) RootlessFrameForWindow (pWinPrev, FALSE);
+ if (pWinPrev)
+ pRLWinPrev =
+ (win32RootlessWindowPtr)
+ RootlessFrameForWindow(pWinPrev, FALSE);
- uFlags = SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW;
- if (pRLWinPrev != NULL) uFlags |= SWP_NOACTIVATE;
+ uFlags = SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW;
+ if (pRLWinPrev != NULL)
+ uFlags |= SWP_NOACTIVATE;
#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMRestackWindows - DeferWindowPos (%08x, %08x)\n",
- pRLWin->hWnd,
- pRLWinPrev ? pRLWinPrev->hWnd : HWND_TOP);
+ winDebug
+ ("winMWExtWMRestackWindows - DeferWindowPos (%08x, %08x)\n",
+ pRLWin->hWnd, pRLWinPrev ? pRLWinPrev->hWnd : HWND_TOP);
#endif
- hWinPosInfo = DeferWindowPos (hWinPosInfo, pRLWin->hWnd,
- pRLWinPrev ? pRLWinPrev->hWnd : HWND_TOP,
- 0, 0, 0, 0,
- uFlags);
- if (hWinPosInfo == NULL)
- {
- ErrorF ("winMWExtWMRestackWindows - DeferWindowPos () failed: %d\n",
- (int) GetLastError ());
- return;
- }
- pWinPrev = pWin;
- }
- }
- if (!EndDeferWindowPos (hWinPosInfo))
- {
- ErrorF ("winMWExtWMRestackWindows - EndDeferWindowPos () failed: %d\n",
- (int) GetLastError ());
- return;
- }
+ hWinPosInfo = DeferWindowPos(hWinPosInfo, pRLWin->hWnd,
+ pRLWinPrev ? pRLWinPrev->
+ hWnd : HWND_TOP, 0, 0, 0, 0,
+ uFlags);
+ if (hWinPosInfo == NULL) {
+ ErrorF
+ ("winMWExtWMRestackWindows - DeferWindowPos () failed: %d\n",
+ (int) GetLastError());
+ return;
+ }
+ pWinPrev = pWin;
+ }
+ }
+ if (!EndDeferWindowPos(hWinPosInfo)) {
+ ErrorF
+ ("winMWExtWMRestackWindows - EndDeferWindowPos () failed: %d\n",
+ (int) GetLastError());
+ return;
+ }
}
#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMRestackWindows - done\n");
+ winDebug("winMWExtWMRestackWindows - done\n");
#endif
- pScreenPriv->fRestacking = FALSE;
+ pScreenPriv->fRestacking = FALSE;
}
diff --git a/xorg-server/hw/xwin/winwin32rootlesswndproc.c b/xorg-server/hw/xwin/winwin32rootlesswndproc.c
index c47719701..46000efe4 100644
--- a/xorg-server/hw/xwin/winwin32rootlesswndproc.c
+++ b/xorg-server/hw/xwin/winwin32rootlesswndproc.c
@@ -43,7 +43,6 @@
#include "winmsg.h"
#include "inputstr.h"
-
/*
* Constant defines
*/
@@ -51,1275 +50,1236 @@
#define MOUSE_ACTIVATE_DEFAULT TRUE
#define RAISE_ON_CLICK_DEFAULT FALSE
-
/*
* Local globals
*/
-static UINT_PTR g_uipMousePollingTimerID = 0;
-
+static UINT_PTR g_uipMousePollingTimerID = 0;
/*
* Local function
*/
DEFINE_ATOM_HELPER(AtmWindowsWmRaiseOnClick, WINDOWSWM_RAISE_ON_CLICK)
-DEFINE_ATOM_HELPER(AtmWindowsWMMouseActivate, WINDOWSWM_MOUSE_ACTIVATE)
+ DEFINE_ATOM_HELPER(AtmWindowsWMMouseActivate, WINDOWSWM_MOUSE_ACTIVATE)
/* DEFINE_ATOM_HELPER(AtmWindowsWMClientWindow, WINDOWSWM_CLIENT_WINDOW) */
-
/*
* ConstrainSize - Taken from TWM sources - Respects hints for sizing
*/
#define makemult(a,b) ((b==1) ? (a) : (((int)((a)/(b))) * (b)) )
static void
-ConstrainSize (WinXSizeHints hints, int *widthp, int *heightp)
+ConstrainSize(WinXSizeHints hints, int *widthp, int *heightp)
{
- int minWidth, minHeight, maxWidth, maxHeight, xinc, yinc, delta;
- int baseWidth, baseHeight;
- int dwidth = *widthp, dheight = *heightp;
-
- if (hints.flags & PMinSize)
- {
- minWidth = hints.min_width;
- minHeight = hints.min_height;
+ int minWidth, minHeight, maxWidth, maxHeight, xinc, yinc, delta;
+ int baseWidth, baseHeight;
+ int dwidth = *widthp, dheight = *heightp;
+
+ if (hints.flags & PMinSize) {
+ minWidth = hints.min_width;
+ minHeight = hints.min_height;
}
- else if (hints.flags & PBaseSize)
- {
- minWidth = hints.base_width;
- minHeight = hints.base_height;
+ else if (hints.flags & PBaseSize) {
+ minWidth = hints.base_width;
+ minHeight = hints.base_height;
}
- else
- minWidth = minHeight = 1;
-
- if (hints.flags & PBaseSize)
- {
- baseWidth = hints.base_width;
- baseHeight = hints.base_height;
- }
- else if (hints.flags & PMinSize)
- {
- baseWidth = hints.min_width;
- baseHeight = hints.min_height;
+ else
+ minWidth = minHeight = 1;
+
+ if (hints.flags & PBaseSize) {
+ baseWidth = hints.base_width;
+ baseHeight = hints.base_height;
+ }
+ else if (hints.flags & PMinSize) {
+ baseWidth = hints.min_width;
+ baseHeight = hints.min_height;
}
- else
- baseWidth = baseHeight = 0;
+ else
+ baseWidth = baseHeight = 0;
- if (hints.flags & PMaxSize)
- {
- maxWidth = hints.max_width;
- maxHeight = hints.max_height;
+ if (hints.flags & PMaxSize) {
+ maxWidth = hints.max_width;
+ maxHeight = hints.max_height;
}
- else
- {
- maxWidth = MAXINT;
- maxHeight = MAXINT;
+ else {
+ maxWidth = MAXINT;
+ maxHeight = MAXINT;
}
- if (hints.flags & PResizeInc)
- {
- xinc = hints.width_inc;
- yinc = hints.height_inc;
+ if (hints.flags & PResizeInc) {
+ xinc = hints.width_inc;
+ yinc = hints.height_inc;
}
- else
- xinc = yinc = 1;
-
- /*
- * First, clamp to min and max values
- */
- if (dwidth < minWidth)
- dwidth = minWidth;
- if (dheight < minHeight)
- dheight = minHeight;
-
- if (dwidth > maxWidth)
- dwidth = maxWidth;
- if (dheight > maxHeight)
- dheight = maxHeight;
-
- /*
- * Second, fit to base + N * inc
- */
- dwidth = ((dwidth - baseWidth) / xinc * xinc) + baseWidth;
- dheight = ((dheight - baseHeight) / yinc * yinc) + baseHeight;
-
- /*
- * Third, adjust for aspect ratio
- */
-
- /*
- * The math looks like this:
- *
- * minAspectX dwidth maxAspectX
- * ---------- <= ------- <= ----------
- * minAspectY dheight maxAspectY
- *
- * If that is multiplied out, then the width and height are
- * invalid in the following situations:
- *
- * minAspectX * dheight > minAspectY * dwidth
- * maxAspectX * dheight < maxAspectY * dwidth
- *
- */
-
- if (hints.flags & PAspect)
- {
- if (hints.min_aspect.x * dheight > hints.min_aspect.y * dwidth)
- {
- delta = makemult(hints.min_aspect.x * dheight / hints.min_aspect.y - dwidth, xinc);
- if (dwidth + delta <= maxWidth)
- dwidth += delta;
- else
- {
- delta = makemult(dheight - dwidth*hints.min_aspect.y/hints.min_aspect.x, yinc);
- if (dheight - delta >= minHeight)
- dheight -= delta;
+ else
+ xinc = yinc = 1;
+
+ /*
+ * First, clamp to min and max values
+ */
+ if (dwidth < minWidth)
+ dwidth = minWidth;
+ if (dheight < minHeight)
+ dheight = minHeight;
+
+ if (dwidth > maxWidth)
+ dwidth = maxWidth;
+ if (dheight > maxHeight)
+ dheight = maxHeight;
+
+ /*
+ * Second, fit to base + N * inc
+ */
+ dwidth = ((dwidth - baseWidth) / xinc * xinc) + baseWidth;
+ dheight = ((dheight - baseHeight) / yinc * yinc) + baseHeight;
+
+ /*
+ * Third, adjust for aspect ratio
+ */
+
+ /*
+ * The math looks like this:
+ *
+ * minAspectX dwidth maxAspectX
+ * ---------- <= ------- <= ----------
+ * minAspectY dheight maxAspectY
+ *
+ * If that is multiplied out, then the width and height are
+ * invalid in the following situations:
+ *
+ * minAspectX * dheight > minAspectY * dwidth
+ * maxAspectX * dheight < maxAspectY * dwidth
+ *
+ */
+
+ if (hints.flags & PAspect) {
+ if (hints.min_aspect.x * dheight > hints.min_aspect.y * dwidth) {
+ delta =
+ makemult(hints.min_aspect.x * dheight / hints.min_aspect.y -
+ dwidth, xinc);
+ if (dwidth + delta <= maxWidth)
+ dwidth += delta;
+ else {
+ delta =
+ makemult(dheight -
+ dwidth * hints.min_aspect.y / hints.min_aspect.x,
+ yinc);
+ if (dheight - delta >= minHeight)
+ dheight -= delta;
}
}
-
- if (hints.max_aspect.x * dheight < hints.max_aspect.y * dwidth)
- {
- delta = makemult(dwidth * hints.max_aspect.y / hints.max_aspect.x - dheight, yinc);
- if (dheight + delta <= maxHeight)
- dheight += delta;
- else
- {
- delta = makemult(dwidth - hints.max_aspect.x*dheight/hints.max_aspect.y, xinc);
- if (dwidth - delta >= minWidth)
- dwidth -= delta;
+
+ if (hints.max_aspect.x * dheight < hints.max_aspect.y * dwidth) {
+ delta =
+ makemult(dwidth * hints.max_aspect.y / hints.max_aspect.x -
+ dheight, yinc);
+ if (dheight + delta <= maxHeight)
+ dheight += delta;
+ else {
+ delta =
+ makemult(dwidth -
+ hints.max_aspect.x * dheight / hints.max_aspect.y,
+ xinc);
+ if (dwidth - delta >= minWidth)
+ dwidth -= delta;
}
}
}
-
- /* Return computed values */
- *widthp = dwidth;
- *heightp = dheight;
-}
-#undef makemult
+ /* Return computed values */
+ *widthp = dwidth;
+ *heightp = dheight;
+}
+#undef makemult
/*
* ValidateSizing - Ensures size request respects hints
*/
static int
-ValidateSizing (HWND hwnd, WindowPtr pWin,
- WPARAM wParam, LPARAM lParam)
+ValidateSizing(HWND hwnd, WindowPtr pWin, WPARAM wParam, LPARAM lParam)
{
- WinXSizeHints sizeHints;
- RECT *rect;
- int iWidth, iHeight, iTopBorder;
- POINT pt;
+ WinXSizeHints sizeHints;
+ RECT *rect;
+ int iWidth, iHeight, iTopBorder;
+ POINT pt;
+
+ /* Invalid input checking */
+ if (pWin == NULL || lParam == 0) {
+ ErrorF("Invalid input checking\n");
+ return FALSE;
+ }
- /* Invalid input checking */
- if (pWin==NULL || lParam==0)
- {
- ErrorF ("Invalid input checking\n");
- return FALSE;
+ /* No size hints, no checking */
+ if (!winMultiWindowGetWMNormalHints(pWin, &sizeHints)) {
+ ErrorF("No size hints, no checking\n");
+ return FALSE;
}
- /* No size hints, no checking */
- if (!winMultiWindowGetWMNormalHints (pWin, &sizeHints))
- {
- ErrorF ("No size hints, no checking\n");
- return FALSE;
+ /* Avoid divide-by-zero */
+ if (sizeHints.flags & PResizeInc) {
+ if (sizeHints.width_inc == 0)
+ sizeHints.width_inc = 1;
+ if (sizeHints.height_inc == 0)
+ sizeHints.height_inc = 1;
}
-
- /* Avoid divide-by-zero */
- if (sizeHints.flags & PResizeInc)
- {
- if (sizeHints.width_inc == 0) sizeHints.width_inc = 1;
- if (sizeHints.height_inc == 0) sizeHints.height_inc = 1;
+
+ rect = (RECT *) lParam;
+
+ iWidth = rect->right - rect->left;
+ iHeight = rect->bottom - rect->top;
+
+ /* Get title bar height, there must be an easier way?! */
+ pt.x = pt.y = 0;
+ ClientToScreen(hwnd, &pt);
+ iTopBorder = pt.y - rect->top;
+
+ /* Now remove size of any borders */
+ iWidth -= 2 * GetSystemMetrics(SM_CXSIZEFRAME);
+ iHeight -= GetSystemMetrics(SM_CYSIZEFRAME) + iTopBorder;
+
+ /* Constrain the size to legal values */
+ ConstrainSize(sizeHints, &iWidth, &iHeight);
+
+ /* Add back the borders */
+ iWidth += 2 * GetSystemMetrics(SM_CXSIZEFRAME);
+ iHeight += GetSystemMetrics(SM_CYSIZEFRAME) + iTopBorder;
+
+ /* Adjust size according to where we're dragging from */
+ switch (wParam) {
+ case WMSZ_TOP:
+ case WMSZ_TOPRIGHT:
+ case WMSZ_BOTTOM:
+ case WMSZ_BOTTOMRIGHT:
+ case WMSZ_RIGHT:
+ rect->right = rect->left + iWidth;
+ break;
+ default:
+ rect->left = rect->right - iWidth;
+ break;
}
-
- rect = (RECT*)lParam;
-
- iWidth = rect->right - rect->left;
- iHeight = rect->bottom - rect->top;
-
- /* Get title bar height, there must be an easier way?! */
- pt.x = pt.y = 0;
- ClientToScreen(hwnd, &pt);
- iTopBorder = pt.y - rect->top;
-
- /* Now remove size of any borders */
- iWidth -= 2 * GetSystemMetrics(SM_CXSIZEFRAME);
- iHeight -= GetSystemMetrics(SM_CYSIZEFRAME) + iTopBorder;
-
- /* Constrain the size to legal values */
- ConstrainSize (sizeHints, &iWidth, &iHeight);
-
- /* Add back the borders */
- iWidth += 2 * GetSystemMetrics(SM_CXSIZEFRAME);
- iHeight += GetSystemMetrics(SM_CYSIZEFRAME) + iTopBorder;
-
- /* Adjust size according to where we're dragging from */
- switch(wParam) {
- case WMSZ_TOP:
- case WMSZ_TOPRIGHT:
- case WMSZ_BOTTOM:
- case WMSZ_BOTTOMRIGHT:
- case WMSZ_RIGHT:
- rect->right = rect->left + iWidth;
- break;
- default:
- rect->left = rect->right - iWidth;
- break;
- }
- switch(wParam) {
- case WMSZ_BOTTOM:
- case WMSZ_BOTTOMRIGHT:
- case WMSZ_BOTTOMLEFT:
- case WMSZ_RIGHT:
- case WMSZ_LEFT:
- rect->bottom = rect->top + iHeight;
- break;
- default:
- rect->top = rect->bottom - iHeight;
- break;
- }
- return TRUE;
+ switch (wParam) {
+ case WMSZ_BOTTOM:
+ case WMSZ_BOTTOMRIGHT:
+ case WMSZ_BOTTOMLEFT:
+ case WMSZ_RIGHT:
+ case WMSZ_LEFT:
+ rect->bottom = rect->top + iHeight;
+ break;
+ default:
+ rect->top = rect->bottom - iHeight;
+ break;
+ }
+ return TRUE;
}
-
/*
* IsRaiseOnClick
*/
static Bool
-IsRaiseOnClick (WindowPtr pWin)
+IsRaiseOnClick(WindowPtr pWin)
{
- struct _Window *pwin;
- struct _Property *prop;
- /* XXX We're getting inputInfo.poniter here, but this might be really wrong.
- * Which pointer's current window do we want? */
- WindowPtr pRoot = GetCurrentRootWindow (inputInfo.pointer);
+ struct _Window *pwin;
+ struct _Property *prop;
- if (!pWin)
- {
- ErrorF ("IsRaiseOnClick - no prop use default value:%d\n",
- RAISE_ON_CLICK_DEFAULT);
- return RAISE_ON_CLICK_DEFAULT;
- }
+ /* XXX We're getting inputInfo.poniter here, but this might be really wrong.
+ * Which pointer's current window do we want? */
+ WindowPtr pRoot = GetCurrentRootWindow(inputInfo.pointer);
- pwin = (struct _Window*) pWin;
+ if (!pWin) {
+ ErrorF("IsRaiseOnClick - no prop use default value:%d\n",
+ RAISE_ON_CLICK_DEFAULT);
+ return RAISE_ON_CLICK_DEFAULT;
+ }
- if (pwin->optional)
- prop = (struct _Property *) pwin->optional->userProps;
- else
- prop = NULL;
+ pwin = (struct _Window *) pWin;
- while (prop)
- {
- if (prop->propertyName == AtmWindowsWmRaiseOnClick ()
- && prop->type == XA_INTEGER
- && prop->format == 32)
- {
- return *(int*)prop->data;
- }
- else
- prop = prop->next;
+ if (pwin->optional)
+ prop = (struct _Property *) pwin->optional->userProps;
+ else
+ prop = NULL;
+
+ while (prop) {
+ if (prop->propertyName == AtmWindowsWmRaiseOnClick()
+ && prop->type == XA_INTEGER && prop->format == 32) {
+ return *(int *) prop->data;
+ }
+ else
+ prop = prop->next;
}
- if (pWin != pRoot)
- {
- return IsRaiseOnClick (pRoot);
+ if (pWin != pRoot) {
+ return IsRaiseOnClick(pRoot);
}
- else
- {
+ else {
#if CYGMULTIWINDOW_DEBUG
- winDebug ("IsRaiseOnClick - no prop use default value:%d\n",
- RAISE_ON_CLICK_DEFAULT);
+ winDebug("IsRaiseOnClick - no prop use default value:%d\n",
+ RAISE_ON_CLICK_DEFAULT);
#endif
- return RAISE_ON_CLICK_DEFAULT;
+ return RAISE_ON_CLICK_DEFAULT;
}
}
-
/*
* IsMouseActive
*/
static Bool
-IsMouseActive (WindowPtr pWin)
+IsMouseActive(WindowPtr pWin)
{
- struct _Window *pwin;
- struct _Property *prop;
- /* XXX We're getting inputInfo.poniter here, but this might be really wrong.
- * Which pointer's current window do we want? */
- WindowPtr pRoot = GetCurrentRootWindow (inputInfo.pointer);
+ struct _Window *pwin;
+ struct _Property *prop;
- if (!pWin)
- {
- ErrorF ("IsMouseActive - pWin was NULL use default value:%d\n",
- MOUSE_ACTIVATE_DEFAULT);
- return MOUSE_ACTIVATE_DEFAULT;
- }
+ /* XXX We're getting inputInfo.poniter here, but this might be really wrong.
+ * Which pointer's current window do we want? */
+ WindowPtr pRoot = GetCurrentRootWindow(inputInfo.pointer);
+
+ if (!pWin) {
+ ErrorF("IsMouseActive - pWin was NULL use default value:%d\n",
+ MOUSE_ACTIVATE_DEFAULT);
+ return MOUSE_ACTIVATE_DEFAULT;
+ }
- pwin = (struct _Window*) pWin;
+ pwin = (struct _Window *) pWin;
- if (pwin->optional)
- prop = (struct _Property *) pwin->optional->userProps;
- else
- prop = NULL;
+ if (pwin->optional)
+ prop = (struct _Property *) pwin->optional->userProps;
+ else
+ prop = NULL;
- while (prop)
- {
- if (prop->propertyName == AtmWindowsWMMouseActivate ()
- && prop->type == XA_INTEGER
- && prop->format == 32)
- {
- return *(int*)prop->data;
- }
- else
- prop = prop->next;
+ while (prop) {
+ if (prop->propertyName == AtmWindowsWMMouseActivate()
+ && prop->type == XA_INTEGER && prop->format == 32) {
+ return *(int *) prop->data;
+ }
+ else
+ prop = prop->next;
}
- if (pWin != pRoot)
- {
- return IsMouseActive (pRoot);
+ if (pWin != pRoot) {
+ return IsMouseActive(pRoot);
}
- else
- {
+ else {
#if CYGMULTIWINDOW_DEBUG
- winDebug ("IsMouseActive - no prop use default value:%d\n",
- MOUSE_ACTIVATE_DEFAULT);
+ winDebug("IsMouseActive - no prop use default value:%d\n",
+ MOUSE_ACTIVATE_DEFAULT);
#endif
- return MOUSE_ACTIVATE_DEFAULT;
+ return MOUSE_ACTIVATE_DEFAULT;
}
}
-
/*
* winMWExtWMWindowProc - Window procedure
*/
LRESULT CALLBACK
-winMWExtWMWindowProc (HWND hwnd, UINT message,
- WPARAM wParam, LPARAM lParam)
+winMWExtWMWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- WindowPtr pWin = NULL;
- win32RootlessWindowPtr pRLWinPriv = NULL;
- ScreenPtr pScreen = NULL;
- winPrivScreenPtr pScreenPriv = NULL;
- winScreenInfo *pScreenInfo = NULL;
- HWND hwndScreen = NULL;
- POINT ptMouse;
- static Bool s_fTracking = FALSE;
- HDC hdcUpdate;
- PAINTSTRUCT ps;
- LPWINDOWPOS pWinPos = NULL;
- RECT rcClient;
- winWMMessageRec wmMsg;
- Bool fWMMsgInitialized = FALSE;
-
- /* Check if the Windows window property for our X window pointer is valid */
- if ((pRLWinPriv = (win32RootlessWindowPtr)GetProp (hwnd, WIN_WINDOW_PROP)) != NULL)
- {
- pWin = pRLWinPriv->pFrame->win;
- pScreen = pWin->drawable.pScreen;
- if (pScreen) pScreenPriv = winGetScreenPriv(pScreen);
- if (pScreenPriv) pScreenInfo = pScreenPriv->pScreenInfo;
- if (pScreenPriv) hwndScreen = pScreenPriv->hwndScreen;
-
- wmMsg.msg = 0;
- wmMsg.hwndWindow = hwnd;
- wmMsg.iWindow = (Window)pWin->drawable.id;
-
- wmMsg.iX = pRLWinPriv->pFrame->x;
- wmMsg.iY = pRLWinPriv->pFrame->y;
- wmMsg.iWidth = pRLWinPriv->pFrame->width;
- wmMsg.iHeight = pRLWinPriv->pFrame->height;
-
- fWMMsgInitialized = TRUE;
- winDebugWin32Message("winMWExtWMWindowProc", hwnd, message, wParam, lParam);
-
- winDebug ("\thWnd %08X\n", hwnd);
- winDebug ("\tpScreenPriv %08X\n", pScreenPriv);
- winDebug ("\tpScreenInfo %08X\n", pScreenInfo);
- winDebug ("\thwndScreen %08X\n", hwndScreen);
- winDebug ("winMWExtWMWindowProc (%08x) %08x %08x %08x\n",
- pRLWinPriv, message, wParam, lParam);
+ WindowPtr pWin = NULL;
+ win32RootlessWindowPtr pRLWinPriv = NULL;
+ ScreenPtr pScreen = NULL;
+ winPrivScreenPtr pScreenPriv = NULL;
+ winScreenInfo *pScreenInfo = NULL;
+ HWND hwndScreen = NULL;
+ POINT ptMouse;
+ static Bool s_fTracking = FALSE;
+ HDC hdcUpdate;
+ PAINTSTRUCT ps;
+ LPWINDOWPOS pWinPos = NULL;
+ RECT rcClient;
+ winWMMessageRec wmMsg;
+ Bool fWMMsgInitialized = FALSE;
+
+ /* Check if the Windows window property for our X window pointer is valid */
+ if ((pRLWinPriv =
+ (win32RootlessWindowPtr) GetProp(hwnd, WIN_WINDOW_PROP)) != NULL) {
+ pWin = pRLWinPriv->pFrame->win;
+ pScreen = pWin->drawable.pScreen;
+ if (pScreen)
+ pScreenPriv = winGetScreenPriv(pScreen);
+ if (pScreenPriv)
+ pScreenInfo = pScreenPriv->pScreenInfo;
+ if (pScreenPriv)
+ hwndScreen = pScreenPriv->hwndScreen;
+
+ wmMsg.msg = 0;
+ wmMsg.hwndWindow = hwnd;
+ wmMsg.iWindow = (Window) pWin->drawable.id;
+
+ wmMsg.iX = pRLWinPriv->pFrame->x;
+ wmMsg.iY = pRLWinPriv->pFrame->y;
+ wmMsg.iWidth = pRLWinPriv->pFrame->width;
+ wmMsg.iHeight = pRLWinPriv->pFrame->height;
+
+ fWMMsgInitialized = TRUE;
+ winDebugWin32Message("winMWExtWMWindowProc", hwnd, message, wParam,
+ lParam);
+
+ winDebug("\thWnd %08X\n", hwnd);
+ winDebug("\tpScreenPriv %08X\n", pScreenPriv);
+ winDebug("\tpScreenInfo %08X\n", pScreenInfo);
+ winDebug("\thwndScreen %08X\n", hwndScreen);
+ winDebug("winMWExtWMWindowProc (%08x) %08x %08x %08x\n",
+ pRLWinPriv, message, wParam, lParam);
}
- /* Branch on message type */
- switch (message)
- {
+ /* Branch on message type */
+ switch (message) {
case WM_CREATE:
#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_CREATE\n");
+ winDebug("winMWExtWMWindowProc - WM_CREATE\n");
#endif
- /* */
- SetProp (hwnd,
- WIN_WINDOW_PROP,
- (HANDLE)((LPCREATESTRUCT) lParam)->lpCreateParams);
- return 0;
+ /* */
+ SetProp(hwnd,
+ WIN_WINDOW_PROP,
+ (HANDLE) ((LPCREATESTRUCT) lParam)->lpCreateParams);
+ return 0;
case WM_CLOSE:
- winDebug ("winMWExtWMWindowProc - WM_CLOSE %d\n", pRLWinPriv->fClose);
-
- /* Tell window-manager to close window */
- if (pRLWinPriv->fClose)
- {
- DestroyWindow (hwnd);
- }
- else
- {
+ winDebug("winMWExtWMWindowProc - WM_CLOSE %d\n", pRLWinPriv->fClose);
+
+ /* Tell window-manager to close window */
+ if (pRLWinPriv->fClose) {
+ DestroyWindow(hwnd);
+ }
+ else {
+ if (winIsInternalWMRunning(pScreenInfo)) {
#ifdef XWIN_MULTIWINDOWINTWM
- if (winIsInternalWMRunning(pScreenInfo))
- {
- /* Tell our Window Manager thread to kill the window */
- wmMsg.msg = WM_WM_KILL;
- if (fWMMsgInitialized)
- winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
- }
+ /* Tell our Window Manager thread to kill the window */
+ wmMsg.msg = WM_WM_KILL;
+ if (fWMMsgInitialized)
+ winSendMessageToWM(pScreenPriv->pWMInfo, &wmMsg);
+ }
#endif
- winWindowsWMSendEvent(WindowsWMControllerNotify,
- WindowsWMControllerNotifyMask,
- 1,
- WindowsWMCloseWindow,
- pWin->drawable.id,
- 0, 0, 0, 0);
- }
- return 0;
+ winWindowsWMSendEvent(WindowsWMControllerNotify,
+ WindowsWMControllerNotifyMask,
+ 1,
+ WindowsWMCloseWindow,
+ pWin->drawable.id, 0, 0, 0, 0);
+ }
+ return 0;
case WM_DESTROY:
#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_DESTROY\n");
+ winDebug("winMWExtWMWindowProc - WM_DESTROY\n");
#endif
- /* Free the shaodw DC; which allows the bitmap to be freed */
- DeleteDC (pRLWinPriv->hdcShadow);
- pRLWinPriv->hdcShadow = NULL;
-
- /* Free the shadow bitmap */
- DeleteObject (pRLWinPriv->hbmpShadow);
- pRLWinPriv->hbmpShadow = NULL;
-
- /* Free the screen DC */
- ReleaseDC (pRLWinPriv->hWnd, pRLWinPriv->hdcScreen);
- pRLWinPriv->hdcScreen = NULL;
-
- /* Free shadow buffer info header */
- free (pRLWinPriv->pbmihShadow);
- pRLWinPriv->pbmihShadow = NULL;
-
- pRLWinPriv->fResized = FALSE;
- pRLWinPriv->pfb = NULL;
- free (pRLWinPriv);
- RemoveProp (hwnd, WIN_WINDOW_PROP);
- break;
+ /* Free the shaodw DC; which allows the bitmap to be freed */
+ DeleteDC(pRLWinPriv->hdcShadow);
+ pRLWinPriv->hdcShadow = NULL;
+
+ /* Free the shadow bitmap */
+ DeleteObject(pRLWinPriv->hbmpShadow);
+ pRLWinPriv->hbmpShadow = NULL;
+
+ /* Free the screen DC */
+ ReleaseDC(pRLWinPriv->hWnd, pRLWinPriv->hdcScreen);
+ pRLWinPriv->hdcScreen = NULL;
+
+ /* Free shadow buffer info header */
+ free(pRLWinPriv->pbmihShadow);
+ pRLWinPriv->pbmihShadow = NULL;
+
+ pRLWinPriv->fResized = FALSE;
+ pRLWinPriv->pfb = NULL;
+ free(pRLWinPriv);
+ RemoveProp(hwnd, WIN_WINDOW_PROP);
+ break;
case WM_MOUSEMOVE:
#if CYGMULTIWINDOW_DEBUG && 0
- winDebug ("winMWExtWMWindowProc - WM_MOUSEMOVE\n");
+ winDebug("winMWExtWMWindowProc - WM_MOUSEMOVE\n");
#endif
- /* Unpack the client area mouse coordinates */
- ptMouse.x = GET_X_LPARAM(lParam);
- ptMouse.y = GET_Y_LPARAM(lParam);
-
- /* Translate the client area mouse coordinates to screen coordinates */
- ClientToScreen (hwnd, &ptMouse);
-
- /* Screen Coords from (-X, -Y) -> Root Window (0, 0) */
- ptMouse.x -= GetSystemMetrics (SM_XVIRTUALSCREEN);
- ptMouse.y -= GetSystemMetrics (SM_YVIRTUALSCREEN);
-
- /* We can't do anything without privates */
- if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
- break;
-
- /* Has the mouse pointer crossed screens? */
- if (pScreen != miPointerGetScreen(inputInfo.pointer))
- miPointerSetScreen (inputInfo.pointer, pScreenInfo->dwScreen,
- ptMouse.x - pScreenInfo->dwXOffset,
- ptMouse.y - pScreenInfo->dwYOffset);
-
- /* Are we tracking yet? */
- if (!s_fTracking)
- {
- TRACKMOUSEEVENT tme;
-
- /* Setup data structure */
- ZeroMemory (&tme, sizeof (tme));
- tme.cbSize = sizeof (tme);
- tme.dwFlags = TME_LEAVE;
- tme.hwndTrack = hwnd;
-
- /* Call the tracking function */
- if (!TrackMouseEvent(&tme))
- ErrorF ("winMWExtWMWindowProc - TrackMouseEvent failed\n");
-
- /* Flag that we are tracking now */
- s_fTracking = TRUE;
- }
-
- /* Kill the timer used to poll mouse events */
- if (g_uipMousePollingTimerID != 0)
- {
- KillTimer (pScreenPriv->hwndScreen, WIN_POLLING_MOUSE_TIMER_ID);
- g_uipMousePollingTimerID = 0;
- }
-
- /* Deliver absolute cursor position to X Server */
- winEnqueueMotion(ptMouse.x - pScreenInfo->dwXOffset,
- ptMouse.y - pScreenInfo->dwYOffset);
+ /* Unpack the client area mouse coordinates */
+ ptMouse.x = GET_X_LPARAM(lParam);
+ ptMouse.y = GET_Y_LPARAM(lParam);
+
+ /* Translate the client area mouse coordinates to screen coordinates */
+ ClientToScreen(hwnd, &ptMouse);
+
+ /* Screen Coords from (-X, -Y) -> Root Window (0, 0) */
+ ptMouse.x -= GetSystemMetrics(SM_XVIRTUALSCREEN);
+ ptMouse.y -= GetSystemMetrics(SM_YVIRTUALSCREEN);
+
+ /* We can't do anything without privates */
+ if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
+ break;
+
+ /* Has the mouse pointer crossed screens? */
+ if (pScreen != miPointerGetScreen(inputInfo.pointer))
+ miPointerSetScreen(inputInfo.pointer, pScreenInfo->dwScreen,
+ ptMouse.x - pScreenInfo->dwXOffset,
+ ptMouse.y - pScreenInfo->dwYOffset);
+
+ /* Are we tracking yet? */
+ if (!s_fTracking) {
+ TRACKMOUSEEVENT tme;
+
+ /* Setup data structure */
+ ZeroMemory(&tme, sizeof(tme));
+ tme.cbSize = sizeof(tme);
+ tme.dwFlags = TME_LEAVE;
+ tme.hwndTrack = hwnd;
+
+ /* Call the tracking function */
+ if (!TrackMouseEvent(&tme))
+ ErrorF("winMWExtWMWindowProc - TrackMouseEvent failed\n");
+
+ /* Flag that we are tracking now */
+ s_fTracking = TRUE;
+ }
+
+ /* Kill the timer used to poll mouse events */
+ if (g_uipMousePollingTimerID != 0) {
+ KillTimer(pScreenPriv->hwndScreen, WIN_POLLING_MOUSE_TIMER_ID);
+ g_uipMousePollingTimerID = 0;
+ }
+
+ /* Deliver absolute cursor position to X Server */
+ winEnqueueMotion(ptMouse.x - pScreenInfo->dwXOffset,
+ ptMouse.y - pScreenInfo->dwYOffset);
+
+ return 0;
- return 0;
-
case WM_NCMOUSEMOVE:
#if CYGMULTIWINDOW_DEBUG && 0
- winDebug ("winMWExtWMWindowProc - WM_NCMOUSEMOVE\n");
+ winDebug("winMWExtWMWindowProc - WM_NCMOUSEMOVE\n");
#endif
- /*
- * We break instead of returning 0 since we need to call
- * DefWindowProc to get the mouse cursor changes
- * and min/max/close button highlighting in Windows XP.
- * The Platform SDK says that you should return 0 if you
- * process this message, but it fails to mention that you
- * will give up any default functionality if you do return 0.
- */
-
- /* We can't do anything without privates */
- if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
- break;
-
- /*
- * Timer to poll mouse events. This is needed to make
- * programs like xeyes follow the mouse properly.
- */
- if (g_uipMousePollingTimerID == 0)
- g_uipMousePollingTimerID = SetTimer (pScreenPriv->hwndScreen,
- WIN_POLLING_MOUSE_TIMER_ID,
- MOUSE_POLLING_INTERVAL,
- NULL);
- break;
+ /*
+ * We break instead of returning 0 since we need to call
+ * DefWindowProc to get the mouse cursor changes
+ * and min/max/close button highlighting in Windows XP.
+ * The Platform SDK says that you should return 0 if you
+ * process this message, but it fails to mention that you
+ * will give up any default functionality if you do return 0.
+ */
+
+ /* We can't do anything without privates */
+ if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
+ break;
+
+ /*
+ * Timer to poll mouse events. This is needed to make
+ * programs like xeyes follow the mouse properly.
+ */
+ if (g_uipMousePollingTimerID == 0)
+ g_uipMousePollingTimerID = SetTimer(pScreenPriv->hwndScreen,
+ WIN_POLLING_MOUSE_TIMER_ID,
+ MOUSE_POLLING_INTERVAL, NULL);
+ break;
case WM_MOUSELEAVE:
#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_MOUSELEAVE\n");
+ winDebug("winMWExtWMWindowProc - WM_MOUSELEAVE\n");
#endif
- /* Mouse has left our client area */
-
- /* Flag that we are no longer tracking */
- s_fTracking = FALSE;
-
- /*
- * Timer to poll mouse events. This is needed to make
- * programs like xeyes follow the mouse properly.
- */
- if (g_uipMousePollingTimerID == 0)
- g_uipMousePollingTimerID = SetTimer (pScreenPriv->hwndScreen,
- WIN_POLLING_MOUSE_TIMER_ID,
- MOUSE_POLLING_INTERVAL,
- NULL);
- return 0;
+ /* Mouse has left our client area */
+
+ /* Flag that we are no longer tracking */
+ s_fTracking = FALSE;
+
+ /*
+ * Timer to poll mouse events. This is needed to make
+ * programs like xeyes follow the mouse properly.
+ */
+ if (g_uipMousePollingTimerID == 0)
+ g_uipMousePollingTimerID = SetTimer(pScreenPriv->hwndScreen,
+ WIN_POLLING_MOUSE_TIMER_ID,
+ MOUSE_POLLING_INTERVAL, NULL);
+ return 0;
case WM_LBUTTONDBLCLK:
case WM_LBUTTONDOWN:
#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_LBUTTONDBLCLK\n");
+ winDebug("winMWExtWMWindowProc - WM_LBUTTONDBLCLK\n");
#endif
- if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
- break;
- SetCapture (hwnd);
- return winMouseButtonsHandle (pScreen, ButtonPress, Button1, wParam);
-
+ if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
+ break;
+ SetCapture(hwnd);
+ return winMouseButtonsHandle(pScreen, ButtonPress, Button1, wParam);
+
case WM_LBUTTONUP:
#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_LBUTTONUP\n");
+ winDebug("winMWExtWMWindowProc - WM_LBUTTONUP\n");
#endif
- if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
- break;
- ReleaseCapture ();
- return winMouseButtonsHandle (pScreen, ButtonRelease, Button1, wParam);
+ if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
+ break;
+ ReleaseCapture();
+ return winMouseButtonsHandle(pScreen, ButtonRelease, Button1, wParam);
case WM_MBUTTONDBLCLK:
case WM_MBUTTONDOWN:
#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_MBUTTONDBLCLK\n");
+ winDebug("winMWExtWMWindowProc - WM_MBUTTONDBLCLK\n");
#endif
- if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
- break;
- SetCapture (hwnd);
- return winMouseButtonsHandle (pScreen, ButtonPress, Button2, wParam);
-
+ if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
+ break;
+ SetCapture(hwnd);
+ return winMouseButtonsHandle(pScreen, ButtonPress, Button2, wParam);
+
case WM_MBUTTONUP:
#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_MBUTTONUP\n");
+ winDebug("winMWExtWMWindowProc - WM_MBUTTONUP\n");
#endif
- if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
- break;
- ReleaseCapture ();
- return winMouseButtonsHandle (pScreen, ButtonRelease, Button2, wParam);
-
+ if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
+ break;
+ ReleaseCapture();
+ return winMouseButtonsHandle(pScreen, ButtonRelease, Button2, wParam);
+
case WM_RBUTTONDBLCLK:
case WM_RBUTTONDOWN:
#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_RBUTTONDBLCLK\n");
+ winDebug("winMWExtWMWindowProc - WM_RBUTTONDBLCLK\n");
#endif
- if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
- break;
- SetCapture (hwnd);
- return winMouseButtonsHandle (pScreen, ButtonPress, Button3, wParam);
-
+ if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
+ break;
+ SetCapture(hwnd);
+ return winMouseButtonsHandle(pScreen, ButtonPress, Button3, wParam);
+
case WM_RBUTTONUP:
#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_RBUTTONUP\n");
+ winDebug("winMWExtWMWindowProc - WM_RBUTTONUP\n");
#endif
- if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
- break;
- ReleaseCapture ();
- return winMouseButtonsHandle (pScreen, ButtonRelease, Button3, wParam);
+ if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
+ break;
+ ReleaseCapture();
+ return winMouseButtonsHandle(pScreen, ButtonRelease, Button3, wParam);
case WM_XBUTTONDBLCLK:
case WM_XBUTTONDOWN:
- if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
- break;
- SetCapture (hwnd);
- return winMouseButtonsHandle (pScreen, ButtonPress, HIWORD(wParam) + 5, wParam);
+ if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
+ break;
+ SetCapture(hwnd);
+ return winMouseButtonsHandle(pScreen, ButtonPress, HIWORD(wParam) + 5,
+ wParam);
case WM_XBUTTONUP:
- if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
- break;
- ReleaseCapture ();
- return winMouseButtonsHandle (pScreen, ButtonRelease, HIWORD(wParam) + 5, wParam);
+ if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
+ break;
+ ReleaseCapture();
+ return winMouseButtonsHandle(pScreen, ButtonRelease, HIWORD(wParam) + 5,
+ wParam);
case WM_MOUSEWHEEL:
#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_MOUSEWHEEL\n");
+ winDebug("winMWExtWMWindowProc - WM_MOUSEWHEEL\n");
#endif
-
- /* Pass the message to the root window */
- SendMessage (hwndScreen, message, wParam, lParam);
- return 0;
+
+ /* Pass the message to the root window */
+ SendMessage(hwndScreen, message, wParam, lParam);
+ return 0;
case WM_MOUSEACTIVATE:
- winDebug ("winMWExtWMWindowProc - WM_MOUSEACTIVATE\n");
+ winDebug("winMWExtWMWindowProc - WM_MOUSEACTIVATE\n");
#ifdef XWIN_MULTIWINDOWINTWM
- /* Check if this window needs to be made active when clicked */
- if (winIsInternalWMRunning(pScreenInfo) && pWin->overrideRedirect)
- {
- winDebug ("winMWExtWMWindowProc - WM_MOUSEACTIVATE - "
- "MA_NOACTIVATE\n");
-
- /* */
- return MA_NOACTIVATE;
- }
+ /* Check if this window needs to be made active when clicked */
+ if (winIsInternalWMRunning(pScreenInfo) && pWin->overrideRedirect) {
+ winDebug("winMWExtWMWindowProc - WM_MOUSEACTIVATE - "
+ "MA_NOACTIVATE\n");
+
+ /* */
+ return MA_NOACTIVATE;
+ }
#endif
- if (
+ if (
#ifdef XWIN_MULTIWINDOWINTWM
- !winIsInternalWMRunning(pScreenInfo) &&
+ !winIsInternalWMRunning(pScreenInfo) &&
#endif
- !IsMouseActive (pWin))
- return MA_NOACTIVATE;
+ !IsMouseActive (pWin))
+ return MA_NOACTIVATE;
- break;
+ break;
case WM_KILLFOCUS:
- /* Pop any pressed keys since we are losing keyboard focus */
- winKeybdReleaseKeys ();
- return 0;
+ /* Pop any pressed keys since we are losing keyboard focus */
+ winKeybdReleaseKeys();
+ return 0;
case WM_SYSDEADCHAR:
case WM_DEADCHAR:
- /*
- * NOTE: We do nothing with WM_*CHAR messages,
- * nor does the root window, so we can just toss these messages.
- */
- return 0;
+ /*
+ * NOTE: We do nothing with WM_*CHAR messages,
+ * nor does the root window, so we can just toss these messages.
+ */
+ return 0;
case WM_SYSKEYDOWN:
case WM_KEYDOWN:
#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_*KEYDOWN\n");
+ winDebug("winMWExtWMWindowProc - WM_*KEYDOWN\n");
#endif
- /*
- * Don't pass Alt-F4 key combo to root window,
- * let Windows translate to WM_CLOSE and close this top-level window.
- *
- * NOTE: We purposely don't check the fUseWinKillKey setting because
- * it should only apply to the key handling for the root window,
- * not for top-level window-manager windows.
- *
- * ALSO NOTE: We do pass Ctrl-Alt-Backspace to the root window
- * because that is a key combo that no X app should be expecting to
- * receive, since it has historically been used to shutdown the X server.
- * Passing Ctrl-Alt-Backspace to the root window preserves that
- * behavior, assuming that -unixkill has been passed as a parameter.
- */
- if (wParam == VK_F4 && (GetKeyState (VK_MENU) & 0x8000))
- break;
-
- /* Pass the message to the root window */
- SendMessage (hwndScreen, message, wParam, lParam);
- return 0;
+ /*
+ * Don't pass Alt-F4 key combo to root window,
+ * let Windows translate to WM_CLOSE and close this top-level window.
+ *
+ * NOTE: We purposely don't check the fUseWinKillKey setting because
+ * it should only apply to the key handling for the root window,
+ * not for top-level window-manager windows.
+ *
+ * ALSO NOTE: We do pass Ctrl-Alt-Backspace to the root window
+ * because that is a key combo that no X app should be expecting to
+ * receive, since it has historically been used to shutdown the X server.
+ * Passing Ctrl-Alt-Backspace to the root window preserves that
+ * behavior, assuming that -unixkill has been passed as a parameter.
+ */
+ if (wParam == VK_F4 && (GetKeyState(VK_MENU) & 0x8000))
+ break;
+
+ /* Pass the message to the root window */
+ SendMessage(hwndScreen, message, wParam, lParam);
+ return 0;
case WM_SYSKEYUP:
case WM_KEYUP:
#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_*KEYUP\n");
+ winDebug("winMWExtWMWindowProc - WM_*KEYUP\n");
#endif
- /* Pass the message to the root window */
- SendMessage (hwndScreen, message, wParam, lParam);
- return 0;
+ /* Pass the message to the root window */
+ SendMessage(hwndScreen, message, wParam, lParam);
+ return 0;
case WM_HOTKEY:
#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_HOTKEY\n");
+ winDebug("winMWExtWMWindowProc - WM_HOTKEY\n");
#endif
- /* Pass the message to the root window */
- SendMessage (hwndScreen, message, wParam, lParam);
- return 0;
+ /* Pass the message to the root window */
+ SendMessage(hwndScreen, message, wParam, lParam);
+ return 0;
case WM_ERASEBKGND:
- winDebug ("winMWExtWMWindowProc - WM_ERASEBKGND\n");
- /*
- * Pretend that we did erase the background but we don't care,
- * since we repaint the entire region anyhow
- * This avoids some flickering when resizing.
- */
- return TRUE;
+ winDebug("winMWExtWMWindowProc - WM_ERASEBKGND\n");
+ /*
+ * Pretend that we did erase the background but we don't care,
+ * since we repaint the entire region anyhow
+ * This avoids some flickering when resizing.
+ */
+ return TRUE;
case WM_PAINT:
-
- /* BeginPaint gives us an hdc that clips to the invalidated region */
- hdcUpdate = BeginPaint (hwnd, &ps);
-
- /* Try to copy from the shadow buffer */
- if (!BitBlt (hdcUpdate,
- ps.rcPaint.left, ps.rcPaint.top,
- ps.rcPaint.right - ps.rcPaint.left,
- ps.rcPaint.bottom - ps.rcPaint.top,
- pRLWinPriv->hdcShadow,
- ps.rcPaint.left, ps.rcPaint.top,
- SRCCOPY))
- {
- LPVOID lpMsgBuf;
-
- /* Display a fancy error message */
- FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
- GetLastError (),
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPTSTR) &lpMsgBuf,
- 0, NULL);
-
- ErrorF ("winMWExtWMWindowProc - BitBlt failed: %s\n",
- (LPSTR)lpMsgBuf);
- LocalFree (lpMsgBuf);
- }
-
- /* EndPaint frees the DC */
- EndPaint (hwnd, &ps);
- break;
+
+ /* BeginPaint gives us an hdc that clips to the invalidated region */
+ hdcUpdate = BeginPaint(hwnd, &ps);
+
+ /* Try to copy from the shadow buffer */
+ if (!BitBlt(hdcUpdate,
+ ps.rcPaint.left, ps.rcPaint.top,
+ ps.rcPaint.right - ps.rcPaint.left,
+ ps.rcPaint.bottom - ps.rcPaint.top,
+ pRLWinPriv->hdcShadow,
+ ps.rcPaint.left, ps.rcPaint.top, SRCCOPY)) {
+ LPVOID lpMsgBuf;
+
+ /* Display a fancy error message */
+ FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ GetLastError(),
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPTSTR) & lpMsgBuf, 0, NULL);
+
+ ErrorF("winMWExtWMWindowProc - BitBlt failed: %s\n",
+ (LPSTR) lpMsgBuf);
+ LocalFree(lpMsgBuf);
+ }
+
+ /* EndPaint frees the DC */
+ EndPaint(hwnd, &ps);
+ break;
case WM_ACTIVATE:
- winDebug ("winMWExtWMWindowProc - WM_ACTIVATE\n");
- if (LOWORD(wParam) != WA_INACTIVE)
- {
+ winDebug("winMWExtWMWindowProc - WM_ACTIVATE\n");
+ if (LOWORD(wParam) != WA_INACTIVE) {
+ if (winIsInternalWMRunning(pScreenInfo)) {
#ifdef XWIN_MULTIWINDOWINTWM
- if (winIsInternalWMRunning(pScreenInfo))
- {
#if 0
- /* Raise the window to the top in Z order */
- wmMsg.msg = WM_WM_RAISE;
- if (fWMMsgInitialized)
- winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
+ /* Raise the window to the top in Z order */
+ wmMsg.msg = WM_WM_RAISE;
+ if (fWMMsgInitialized)
+ winSendMessageToWM(pScreenPriv->pWMInfo, &wmMsg);
#endif
- /* Tell our Window Manager thread to activate the window */
- wmMsg.msg = WM_WM_ACTIVATE;
- if (fWMMsgInitialized)
- if (!pWin || !pWin->overrideRedirect) /* for OOo menus */
- winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
- }
+ /* Tell our Window Manager thread to activate the window */
+ wmMsg.msg = WM_WM_ACTIVATE;
+ if (fWMMsgInitialized)
+ if (!pWin || !pWin->overrideRedirect) /* for OOo menus */
+ winSendMessageToWM(pScreenPriv->pWMInfo, &wmMsg);
+ }
#endif
- winWindowsWMSendEvent(WindowsWMControllerNotify,
- WindowsWMControllerNotifyMask,
- 1,
- WindowsWMActivateWindow,
- pWin->drawable.id,
- 0, 0,
- 0, 0);
- }
- return 0;
+ winWindowsWMSendEvent(WindowsWMControllerNotify,
+ WindowsWMControllerNotifyMask,
+ 1,
+ WindowsWMActivateWindow,
+ pWin->drawable.id, 0, 0, 0, 0);
+ }
+ return 0;
#if 1
case WM_WINDOWPOSCHANGING:
- pWinPos = (LPWINDOWPOS)lParam;
- if (!(pWinPos->flags & SWP_NOZORDER))
- {
- if (pRLWinPriv->fRestackingNow || pScreenPriv->fRestacking)
- {
- winDebug ("Win %08x is now restacking.\n", (unsigned int)pRLWinPriv);
- break;
- }
-
- if (
+ pWinPos = (LPWINDOWPOS) lParam;
+ if (!(pWinPos->flags & SWP_NOZORDER)) {
+ if (pRLWinPriv->fRestackingNow || pScreenPriv->fRestacking) {
+ winDebug("Win %08x is now restacking.\n",
+ (unsigned int) pRLWinPriv);
+ break;
+ }
+
+ if (
#ifdef XWIN_MULTIWINDOWINTWM
- winIsInternalWMRunning(pScreenInfo) ||
+ winIsInternalWMRunning(pScreenInfo) ||
#endif
- IsRaiseOnClick (pWin))
- {
- winDebug ("Win %08x has WINDOWSWM_RAISE_ON_CLICK.\n", (unsigned int)pRLWinPriv);
- break;
- }
-
- winDebug ("Win %08x forbid to change z order (%08x).\n",
- (unsigned int)pRLWinPriv, (unsigned int)pWinPos->hwndInsertAfter);
-
- pWinPos->flags |= SWP_NOZORDER;
- }
- break;
+ IsRaiseOnClick (pWin))
+ winDebug("Win %08x has WINDOWSWM_RAISE_ON_CLICK.\n",
+ (unsigned int) pRLWinPriv);
+ break;
+ }
+
+ winDebug("Win %08x forbid to change z order (%08x).\n",
+ (unsigned int) pRLWinPriv,
+ (unsigned int) pWinPos->hwndInsertAfter);
+ pWinPos->flags |= SWP_NOZORDER;
+ }
+ break;
#endif
case WM_MOVE:
#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_MOVE - %d ms\n",
- (unsigned int)GetTickCount ());
+ winDebug("winMWExtWMWindowProc - WM_MOVE - %d ms\n",
+ (unsigned int) GetTickCount());
#endif
- if (g_fNoConfigureWindow) break;
+ if (g_fNoConfigureWindow)
+ break;
#if 0
- /* Bail if Windows window is not actually moving */
- if (pRLWinPriv->dwX == (short) LOWORD(lParam)
- && pRLWinPriv->dwY == (short) HIWORD(lParam))
- break;
-
- /* Also bail if we're maximizing, we'll do the whole thing in WM_SIZE */
- {
- WINDOWPLACEMENT windPlace;
- windPlace.length = sizeof (WINDOWPLACEMENT);
-
- /* Get current window placement */
- GetWindowPlacement (hwnd, &windPlace);
-
- /* Bail if maximizing */
- if (windPlace.showCmd == SW_MAXIMIZE
- || windPlace.showCmd == SW_SHOWMAXIMIZED)
- break;
- }
-#endif
+ /* Bail if Windows window is not actually moving */
+ if (pRLWinPriv->dwX == (short) LOWORD(lParam)
+ && pRLWinPriv->dwY == (short) HIWORD(lParam))
+ break;
+
+ /* Also bail if we're maximizing, we'll do the whole thing in WM_SIZE */
+ {
+ WINDOWPLACEMENT windPlace;
+
+ windPlace.length = sizeof(WINDOWPLACEMENT);
+
+ /* Get current window placement */
+ GetWindowPlacement(hwnd, &windPlace);
- winDebug ("\t(%d, %d)\n", (short) LOWORD(lParam), (short) HIWORD(lParam));
+ /* Bail if maximizing */
+ if (windPlace.showCmd == SW_MAXIMIZE
+ || windPlace.showCmd == SW_SHOWMAXIMIZED)
+ break;
+ }
+#endif
- if (!pRLWinPriv->fMovingOrSizing)
- {
+ winDebug("\t(%d, %d)\n", (short) LOWORD(lParam),
+ (short) HIWORD(lParam));
+ if (!pRLWinPriv->fMovingOrSizing) {
#ifdef XWIN_MULTIWINDOWINTWM
- if (winIsInternalWMRunning(pScreenInfo))
- winAdjustXWindow (pWin, hwnd);
+ if (winIsInternalWMRunning(pScreenInfo))
+ winAdjustXWindow(pWin, hwnd);
#endif
- winMWExtWMMoveXWindow (pWin,
- (LOWORD(lParam) - wBorderWidth (pWin)
- - GetSystemMetrics (SM_XVIRTUALSCREEN)),
- (HIWORD(lParam) - wBorderWidth (pWin)
- - GetSystemMetrics (SM_YVIRTUALSCREEN)));
- }
- return 0;
+ winMWExtWMMoveXWindow(pWin, (LOWORD(lParam) - wBorderWidth(pWin)
+ - GetSystemMetrics(SM_XVIRTUALSCREEN)),
+ (HIWORD(lParam) - wBorderWidth(pWin)
+ - GetSystemMetrics(SM_YVIRTUALSCREEN)));
+ }
+ return 0;
case WM_SHOWWINDOW:
- winDebug ("winMWExtWMWindowProc - WM_SHOWWINDOW - %d ms\n",
- (unsigned int)GetTickCount ());
+ winDebug("winMWExtWMWindowProc - WM_SHOWWINDOW - %d ms\n",
+ (unsigned int) GetTickCount());
- /* Bail out if the window is being hidden */
- if (!wParam)
- return 0;
+ /* Bail out if the window is being hidden */
+ if (!wParam)
+ return 0;
#ifdef XWIN_MULTIWINDOWINTWM
- if (!pScreenInfo->fInternalWM)//XXXX
- return 0;
+ if (!pScreenInfo->fInternalWM) //XXXX
+ return 0;
- winMWExtWMUpdateWindowDecoration (pRLWinPriv, pScreenInfo);
+ winMWExtWMUpdateWindowDecoration(pRLWinPriv, pScreenInfo);
- if (winIsInternalWMRunning(pScreenInfo))
- {
- winDebug ("\tMapWindow\n");
+ if (winIsInternalWMRunning(pScreenInfo)) {
+ winDebug("\tMapWindow\n");
- /* Tell X to map the window */
- MapWindow (pWin, wClient(pWin));
+ /* Tell X to map the window */
+ MapWindow(pWin, wClient(pWin));
- if (!pRLWinPriv->pFrame->win->overrideRedirect)
- /* Bring the Windows window to the foreground */
- SetForegroundWindow (hwnd);
+ if (!pRLWinPriv->pFrame->win->overrideRedirect)
+ /* Bring the Windows window to the foreground */
+ SetForegroundWindow(hwnd);
- /* Setup the Window Manager message */
- wmMsg.msg = WM_WM_MAP;
- wmMsg.iWidth = pRLWinPriv->pFrame->width;
- wmMsg.iHeight = pRLWinPriv->pFrame->height;
+ /* Setup the Window Manager message */
+ wmMsg.msg = WM_WM_MAP;
+ wmMsg.iWidth = pRLWinPriv->pFrame->width;
+ wmMsg.iHeight = pRLWinPriv->pFrame->height;
- /* Tell our Window Manager thread to map the window */
- if (fWMMsgInitialized)
- winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
- }
+ /* Tell our Window Manager thread to map the window */
+ if (fWMMsgInitialized)
+ winSendMessageToWM(pScreenPriv->pWMInfo, &wmMsg);
+ }
#else
return 0;
#endif
- break;
+ break;
case WM_SIZING:
- /* Need to legalize the size according to WM_NORMAL_HINTS */
- /* for applications like xterm */
- return ValidateSizing (hwnd, pWin, wParam, lParam);
+ /* Need to legalize the size according to WM_NORMAL_HINTS */
+ /* for applications like xterm */
+ return ValidateSizing(hwnd, pWin, wParam, lParam);
case WM_WINDOWPOSCHANGED:
- {
- pWinPos = (LPWINDOWPOS) lParam;
+ {
+ pWinPos = (LPWINDOWPOS) lParam;
#ifdef _DEBUG
winDebug("winMWExtWMWindowProc - WM_WINDOWPOSCHANGED\n");
- winDebug("\tflags: %s%s%s%s%s%s%s%s%s%s%s%s\n",
- (pWinPos->flags & SWP_DRAWFRAME)?"SWP_DRAWFRAME ":"",
- (pWinPos->flags & SWP_FRAMECHANGED)?"SWP_FRAMECHANGED ":"",
- (pWinPos->flags & SWP_HIDEWINDOW)?"SWP_HIDEWINDOW ":"",
- (pWinPos->flags & SWP_NOACTIVATE)?"SWP_NOACTIVATE ":"",
- (pWinPos->flags & SWP_NOCOPYBITS)?"SWP_NOCOPYBITS ":"",
- (pWinPos->flags & SWP_NOMOVE)?"SWP_NOMOVE ":"",
- (pWinPos->flags & SWP_NOOWNERZORDER)?"SWP_NOOWNERZORDER ":"",
- (pWinPos->flags & SWP_NOSIZE)?"SWP_NOSIZE ":"",
- (pWinPos->flags & SWP_NOREDRAW)?"SWP_NOREDRAW ":"",
- (pWinPos->flags & SWP_NOSENDCHANGING)?"SWP_NOSENDCHANGING ":"",
- (pWinPos->flags & SWP_NOZORDER)?"SWP_NOZORDER ":"",
- (pWinPos->flags & SWP_SHOWWINDOW)?"SWP_SHOWWINDOW ":"");
- winDebug("\tno_configure: %s\n", (g_fNoConfigureWindow?"Yes":"No"));
- winDebug("\textend: (%d, %d, %d, %d)\n",
- pWinPos->x, pWinPos->y, pWinPos->cx, pWinPos->cy);
+ winDebug("\tflags: %s%s%s%s%s%s%s%s%s%s%s%s\n",
+ (pWinPos->flags & SWP_DRAWFRAME) ? "SWP_DRAWFRAME " : "",
+ (pWinPos->flags & SWP_FRAMECHANGED) ? "SWP_FRAMECHANGED " : "",
+ (pWinPos->flags & SWP_HIDEWINDOW) ? "SWP_HIDEWINDOW " : "",
+ (pWinPos->flags & SWP_NOACTIVATE) ? "SWP_NOACTIVATE " : "",
+ (pWinPos->flags & SWP_NOCOPYBITS) ? "SWP_NOCOPYBITS " : "",
+ (pWinPos->flags & SWP_NOMOVE) ? "SWP_NOMOVE " : "",
+ (pWinPos->
+ flags & SWP_NOOWNERZORDER) ? "SWP_NOOWNERZORDER " : "",
+ (pWinPos->flags & SWP_NOSIZE) ? "SWP_NOSIZE " : "",
+ (pWinPos->flags & SWP_NOREDRAW) ? "SWP_NOREDRAW " : "",
+ (pWinPos->
+ flags & SWP_NOSENDCHANGING) ? "SWP_NOSENDCHANGING " : "",
+ (pWinPos->flags & SWP_NOZORDER) ? "SWP_NOZORDER " : "",
+ (pWinPos->flags & SWP_SHOWWINDOW) ? "SWP_SHOWWINDOW " : "");
+ winDebug("\tno_configure: %s\n", (g_fNoConfigureWindow ? "Yes" : "No"));
+ winDebug("\textend: (%d, %d, %d, %d)\n",
+ pWinPos->x, pWinPos->y, pWinPos->cx, pWinPos->cy);
#endif
- if (pWinPos->flags & SWP_HIDEWINDOW) break;
+ if (pWinPos->flags & SWP_HIDEWINDOW)
+ break;
#ifdef XWIN_MULTIWINDOWINTWM
- /* Reorder if window z order was changed */
- if ((pScreenPriv != NULL)
- && !(pWinPos->flags & SWP_NOZORDER)
- && !(pWinPos->flags & SWP_SHOWWINDOW)
- && winIsInternalWMRunning(pScreenInfo))
- {
- winDebug ("\twindow z order was changed\n");
-
- if (pWinPos->hwndInsertAfter == HWND_TOP
- ||pWinPos->hwndInsertAfter == HWND_TOPMOST
- ||pWinPos->hwndInsertAfter == HWND_NOTOPMOST)
- {
- winDebug ("\traise to top\n");
-
- /* Raise the window to the top in Z order */
- wmMsg.msg = WM_WM_RAISE;
- if (fWMMsgInitialized)
- winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
- }
+ /* Reorder if window z order was changed */
+ if ((pScreenPriv != NULL)
+ && !(pWinPos->flags & SWP_NOZORDER)
+ && !(pWinPos->flags & SWP_SHOWWINDOW)
+ && winIsInternalWMRunning(pScreenInfo)) {
+ winDebug("\twindow z order was changed\n");
+
+ if (pWinPos->hwndInsertAfter == HWND_TOP
+ || pWinPos->hwndInsertAfter == HWND_TOPMOST
+ || pWinPos->hwndInsertAfter == HWND_NOTOPMOST) {
+ winDebug("\traise to top\n");
+
+ /* Raise the window to the top in Z order */
+ wmMsg.msg = WM_WM_RAISE;
+ if (fWMMsgInitialized)
+ winSendMessageToWM(pScreenPriv->pWMInfo, &wmMsg);
+ }
#if 1
- else if (pWinPos->hwndInsertAfter == HWND_BOTTOM)
- {
- }
- else
- {
- /* Check if this window is top of X windows. */
- HWND hWndAbove = NULL;
- DWORD dwCurrentProcessID = GetCurrentProcessId ();
- DWORD dwWindowProcessID = 0;
-
- for (hWndAbove = pWinPos->hwndInsertAfter;
- hWndAbove != NULL;
- hWndAbove = GetNextWindow (hWndAbove, GW_HWNDPREV))
- {
- /* Ignore other XWin process's window */
- GetWindowThreadProcessId (hWndAbove, &dwWindowProcessID);
-
- if ((dwWindowProcessID == dwCurrentProcessID)
- && GetProp (hWndAbove, WIN_WINDOW_PROP)
- && !IsWindowVisible (hWndAbove)
- && !IsIconic (hWndAbove) ) /* ignore minimized windows */
- break;
- }
- /* If this is top of X windows in Windows stack,
- raise it in X stack. */
- if (hWndAbove == NULL)
- {
- winDebug ("\traise to top\n");
-
- /* Raise the window to the top in Z order */
- wmMsg.msg = WM_WM_RAISE;
- if (fWMMsgInitialized)
- winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
- }
- }
+ else if (pWinPos->hwndInsertAfter == HWND_BOTTOM) {
+ }
+ else {
+ /* Check if this window is top of X windows. */
+ HWND hWndAbove = NULL;
+ DWORD dwCurrentProcessID = GetCurrentProcessId();
+ DWORD dwWindowProcessID = 0;
+
+ for (hWndAbove = pWinPos->hwndInsertAfter;
+ hWndAbove != NULL;
+ hWndAbove = GetNextWindow(hWndAbove, GW_HWNDPREV)) {
+ /* Ignore other XWin process's window */
+ GetWindowThreadProcessId(hWndAbove, &dwWindowProcessID);
+
+ if ((dwWindowProcessID == dwCurrentProcessID)
+ && GetProp(hWndAbove, WIN_WINDOW_PROP)
+ && !IsWindowVisible(hWndAbove)
+ && !IsIconic(hWndAbove)) /* ignore minimized windows */
+ break;
+ }
+ /* If this is top of X windows in Windows stack,
+ raise it in X stack. */
+ if (hWndAbove == NULL) {
+ winDebug("\traise to top\n");
+
+ /* Raise the window to the top in Z order */
+ wmMsg.msg = WM_WM_RAISE;
+ if (fWMMsgInitialized)
+ winSendMessageToWM(pScreenPriv->pWMInfo, &wmMsg);
+ }
+ }
#endif
- }
+ }
#endif
- if (!(pWinPos->flags & SWP_NOSIZE)) {
- if (IsIconic(hwnd)){
- winDebug ("\tIconic -> MINIMIZED\n");
+ if (!(pWinPos->flags & SWP_NOSIZE)) {
+ if (IsIconic(hwnd)) {
+ winDebug("\tIconic -> MINIMIZED\n");
#ifdef XWIN_MULTIWINDOWINTWM
- if (winIsInternalWMRunning(pScreenInfo))
- {
- /* Raise the window to the top in Z order */
- wmMsg.msg = WM_WM_LOWER;
- if (fWMMsgInitialized)
- winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
- }
+ if (winIsInternalWMRunning(pScreenInfo)) {
+ /* Raise the window to the top in Z order */
+ wmMsg.msg = WM_WM_LOWER;
+ if (fWMMsgInitialized)
+ winSendMessageToWM(pScreenPriv->pWMInfo, &wmMsg);
+ }
#endif
- winWindowsWMSendEvent(WindowsWMControllerNotify,
- WindowsWMControllerNotifyMask,
- 1,
- WindowsWMMinimizeWindow,
- pWin->drawable.id,
- 0, 0, 0, 0);
- } else if (IsZoomed(hwnd)){
- winDebug ("\tZoomed -> MAXIMIZED\n");
-
- winWindowsWMSendEvent(WindowsWMControllerNotify,
- WindowsWMControllerNotifyMask,
- 1,
- WindowsWMMaximizeWindow,
- pWin->drawable.id,
- 0, 0, 0, 0);
- } else {
- winDebug ("\tnone -> RESTORED\n");
-
- winWindowsWMSendEvent(WindowsWMControllerNotify,
- WindowsWMControllerNotifyMask,
- 1,
- WindowsWMRestoreWindow,
- pWin->drawable.id,
- 0, 0, 0, 0);
- }
- }
- if (!g_fNoConfigureWindow ) {
-
- if (!pRLWinPriv->fMovingOrSizing
- /*&& (pWinPos->flags & SWP_SHOWWINDOW)*/) {
- GetClientRect (hwnd, &rcClient);
- MapWindowPoints (hwnd, HWND_DESKTOP, (LPPOINT)&rcClient, 2);
-
- if (!(pWinPos->flags & SWP_NOMOVE)
- &&!(pWinPos->flags & SWP_NOSIZE)) {
- winDebug ("\tmove & resize\n");
+ winWindowsWMSendEvent(WindowsWMControllerNotify,
+ WindowsWMControllerNotifyMask,
+ 1,
+ WindowsWMMinimizeWindow,
+ pWin->drawable.id, 0, 0, 0, 0);
+ }
+ else if (IsZoomed(hwnd)) {
+ winDebug("\tZoomed -> MAXIMIZED\n");
+
+ winWindowsWMSendEvent(WindowsWMControllerNotify,
+ WindowsWMControllerNotifyMask,
+ 1,
+ WindowsWMMaximizeWindow,
+ pWin->drawable.id, 0, 0, 0, 0);
+ }
+ else {
+ winDebug("\tnone -> RESTORED\n");
+
+ winWindowsWMSendEvent(WindowsWMControllerNotify,
+ WindowsWMControllerNotifyMask,
+ 1,
+ WindowsWMRestoreWindow,
+ pWin->drawable.id, 0, 0, 0, 0);
+ }
+ }
+ if (!g_fNoConfigureWindow) {
+
+ if (!pRLWinPriv->fMovingOrSizing
+ /*&& (pWinPos->flags & SWP_SHOWWINDOW) */ ) {
+ GetClientRect(hwnd, &rcClient);
+ MapWindowPoints(hwnd, HWND_DESKTOP, (LPPOINT) & rcClient, 2);
+
+ if (!(pWinPos->flags & SWP_NOMOVE)
+ && !(pWinPos->flags & SWP_NOSIZE)) {
+ winDebug("\tmove & resize\n");
#ifdef XWIN_MULTIWINDOWINTWM
- if (winIsInternalWMRunning(pScreenInfo))
- winAdjustXWindow (pWin, hwnd);
+ if (winIsInternalWMRunning(pScreenInfo))
+ winAdjustXWindow(pWin, hwnd);
#endif
- winMWExtWMMoveResizeXWindow (pWin,
- rcClient.left - wBorderWidth (pWin)
- - GetSystemMetrics (SM_XVIRTUALSCREEN),
- rcClient.top - wBorderWidth (pWin)
- - GetSystemMetrics (SM_YVIRTUALSCREEN),
- rcClient.right - rcClient.left
- - wBorderWidth (pWin)*2,
- rcClient.bottom - rcClient.top
- - wBorderWidth (pWin)*2);
- } else if (!(pWinPos->flags & SWP_NOMOVE)) {
- winDebug ("\tmove\n");
+ winMWExtWMMoveResizeXWindow(pWin,
+ rcClient.left -
+ wBorderWidth(pWin)
+ -
+ GetSystemMetrics
+ (SM_XVIRTUALSCREEN),
+ rcClient.top -
+ wBorderWidth(pWin)
+ -
+ GetSystemMetrics
+ (SM_YVIRTUALSCREEN),
+ rcClient.right - rcClient.left -
+ wBorderWidth(pWin) * 2,
+ rcClient.bottom - rcClient.top -
+ wBorderWidth(pWin) * 2);
+ }
+ else if (!(pWinPos->flags & SWP_NOMOVE)) {
+ winDebug("\tmove\n");
#ifdef XWIN_MULTIWINDOWINTWM
- if (winIsInternalWMRunning(pScreenInfo))
- winAdjustXWindow (pWin, hwnd);
+ if (winIsInternalWMRunning(pScreenInfo))
+ winAdjustXWindow(pWin, hwnd);
#endif
- winMWExtWMMoveResizeXWindow (pWin,
- rcClient.left - wBorderWidth (pWin)
- - GetSystemMetrics (SM_XVIRTUALSCREEN),
- rcClient.top - wBorderWidth (pWin)
- - GetSystemMetrics (SM_YVIRTUALSCREEN),
- rcClient.right - rcClient.left
- - wBorderWidth (pWin)*2,
- rcClient.bottom - rcClient.top
- - wBorderWidth (pWin)*2);
- } else if (!(pWinPos->flags & SWP_NOMOVE)) {
- winDebug ("\tmove\n");
+ winMWExtWMMoveResizeXWindow(pWin,
+ rcClient.left -
+ wBorderWidth(pWin)
+ -
+ GetSystemMetrics
+ (SM_XVIRTUALSCREEN),
+ rcClient.top -
+ wBorderWidth(pWin)
+ -
+ GetSystemMetrics
+ (SM_YVIRTUALSCREEN),
+ rcClient.right - rcClient.left -
+ wBorderWidth(pWin) * 2,
+ rcClient.bottom - rcClient.top -
+ wBorderWidth(pWin) * 2);
+ }
+ else if (!(pWinPos->flags & SWP_NOMOVE)) {
+ winDebug("\tmove\n");
#ifdef XWIN_MULTIWINDOWINTWM
- if (winIsInternalWMRunning(pScreenInfo))
- winAdjustXWindow (pWin, hwnd);
+ if (winIsInternalWMRunning(pScreenInfo))
+ winAdjustXWindow(pWin, hwnd);
#endif
- winMWExtWMMoveXWindow (pWin,
- rcClient.left - wBorderWidth (pWin)
- - GetSystemMetrics (SM_XVIRTUALSCREEN),
- rcClient.top - wBorderWidth (pWin)
- - GetSystemMetrics (SM_YVIRTUALSCREEN));
- } else if (!(pWinPos->flags & SWP_NOSIZE)) {
- winDebug ("\tresize\n");
+ winMWExtWMMoveXWindow(pWin,
+ rcClient.left - wBorderWidth(pWin)
+ - GetSystemMetrics(SM_XVIRTUALSCREEN),
+ rcClient.top - wBorderWidth(pWin)
+ -
+ GetSystemMetrics(SM_YVIRTUALSCREEN));
+ }
+ else if (!(pWinPos->flags & SWP_NOSIZE)) {
+ winDebug("\tresize\n");
#ifdef XWIN_MULTIWINDOWINTWM
- if (winIsInternalWMRunning(pScreenInfo))
- winAdjustXWindow (pWin, hwnd);
+ if (winIsInternalWMRunning(pScreenInfo))
+ winAdjustXWindow(pWin, hwnd);
#endif
- winMWExtWMResizeXWindow (pWin,
- rcClient.right - rcClient.left
- - wBorderWidth (pWin)*2,
- rcClient.bottom - rcClient.top
- - wBorderWidth (pWin)*2);
- }
- }
- }
- }
- winDebug ("winMWExtWMWindowProc - WM_WINDOWPOSCHANGED - done.\n");
+ winMWExtWMResizeXWindow(pWin,
+ rcClient.right - rcClient.left
+ - wBorderWidth(pWin) * 2,
+ rcClient.bottom - rcClient.top
+ - wBorderWidth(pWin) * 2);
+ }
+ }
+ }
+ }
+ winDebug("winMWExtWMWindowProc - WM_WINDOWPOSCHANGED - done.\n");
- return 0;
+ return 0;
case WM_SIZE:
- /* see dix/window.c */
- /* FIXME: Maximize/Restore? */
- winDebug ("winMWExtWMWindowProc - WM_SIZE - %d ms\n",
- (unsigned int)GetTickCount ());
+ /* see dix/window.c */
+ /* FIXME: Maximize/Restore? */
+ winDebug("winMWExtWMWindowProc - WM_SIZE - %d ms\n",
+ (unsigned int) GetTickCount());
- winDebug ("\t(%d, %d) %d\n", (short) LOWORD(lParam), (short) HIWORD(lParam), g_fNoConfigureWindow);
+ winDebug("\t(%d, %d) %d\n", (short) LOWORD(lParam),
+ (short) HIWORD(lParam), g_fNoConfigureWindow);
+ if (g_fNoConfigureWindow)
+ break;
- if (g_fNoConfigureWindow) break;
-
- /* Branch on type of resizing occurring */
- switch (wParam)
- {
- case SIZE_MINIMIZED:
- winDebug ("\tSIZE_MINIMIZED\n");
+ /* Branch on type of resizing occurring */
+ switch (wParam) {
+ case SIZE_MINIMIZED:
+ winDebug("\tSIZE_MINIMIZED\n");
#ifdef XWIN_MULTIWINDOWINTWM
- if (winIsInternalWMRunning(pScreenInfo))
- {
- /* Raise the window to the top in Z order */
- wmMsg.msg = WM_WM_LOWER;
- if (fWMMsgInitialized)
- winSendMessageToWM (pScreenPriv->pWMInfo, &wmMsg);
- }
+ if (winIsInternalWMRunning(pScreenInfo)) {
+ /* Raise the window to the top in Z order */
+ wmMsg.msg = WM_WM_LOWER;
+ if (fWMMsgInitialized)
+ winSendMessageToWM(pScreenPriv->pWMInfo, &wmMsg);
+ }
#endif
- winWindowsWMSendEvent(WindowsWMControllerNotify,
- WindowsWMControllerNotifyMask,
- 1,
- WindowsWMMinimizeWindow,
- pWin->drawable.id,
- 0, 0,
- LOWORD(lParam), HIWORD(lParam));
- break;
-
- case SIZE_RESTORED:
- winDebug ("\tSIZE_RESTORED\n");
-
- winWindowsWMSendEvent(WindowsWMControllerNotify,
- WindowsWMControllerNotifyMask,
- 1,
- WindowsWMRestoreWindow,
- pWin->drawable.id,
- 0, 0,
- LOWORD(lParam), HIWORD(lParam));
- break;
-
- case SIZE_MAXIMIZED:
+ winWindowsWMSendEvent(WindowsWMControllerNotify,
+ WindowsWMControllerNotifyMask,
+ 1,
+ WindowsWMMinimizeWindow,
+ pWin->drawable.id,
+ 0, 0, LOWORD(lParam), HIWORD(lParam));
+ break;
+
+ case SIZE_RESTORED:
+ winDebug("\tSIZE_RESTORED\n");
+
+ winWindowsWMSendEvent(WindowsWMControllerNotify,
+ WindowsWMControllerNotifyMask,
+ 1,
+ WindowsWMRestoreWindow,
+ pWin->drawable.id,
+ 0, 0, LOWORD(lParam), HIWORD(lParam));
+ break;
+
+ case SIZE_MAXIMIZED:
#if CYGMULTIWINDOW_DEBUG
- winDebug ("\tSIZE_MAXIMIZED\n");
+ winDebug("\tSIZE_MAXIMIZED\n");
#endif
- winWindowsWMSendEvent(WindowsWMControllerNotify,
- WindowsWMControllerNotifyMask,
- 1,
- WindowsWMMaximizeWindow,
- pWin->drawable.id,
- 0, 0,
- LOWORD(lParam), HIWORD(lParam));
- break;
- }
-
- /* Perform the resize and notify the X client */
- if (!pRLWinPriv->fMovingOrSizing)
- {
+ winWindowsWMSendEvent(WindowsWMControllerNotify,
+ WindowsWMControllerNotifyMask,
+ 1,
+ WindowsWMMaximizeWindow,
+ pWin->drawable.id,
+ 0, 0, LOWORD(lParam), HIWORD(lParam));
+ break;
+ }
+
+ /* Perform the resize and notify the X client */
+ if (!pRLWinPriv->fMovingOrSizing) {
#ifdef XWIN_MULTIWINDOWINTWM
- if (winIsInternalWMRunning(pScreenInfo))
- winAdjustXWindow (pWin, hwnd);
+ if (winIsInternalWMRunning(pScreenInfo))
+ winAdjustXWindow(pWin, hwnd);
#endif
- winMWExtWMResizeXWindow (pWin,
- (short) LOWORD(lParam)
- - wBorderWidth (pWin)*2,
- (short) HIWORD(lParam)
- - wBorderWidth (pWin)*2);
- }
- break;
+ winMWExtWMResizeXWindow(pWin, (short) LOWORD(lParam)
+ - wBorderWidth(pWin) * 2,
+ (short) HIWORD(lParam)
+ - wBorderWidth(pWin) * 2);
+ }
+ break;
case WM_ACTIVATEAPP:
#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMWindowProc - WM_ACTIVATEAPP - %d ms\n",
- (unsigned int)GetTickCount ());
+ winDebug("winMWExtWMWindowProc - WM_ACTIVATEAPP - %d ms\n",
+ (unsigned int) GetTickCount());
#endif
- if (wParam)
- {
+ if (wParam) {
+ if (winIsInternalWMRunning(pScreenInfo)) {
#ifdef XWIN_MULTIWINDOWINTWM
- if (winIsInternalWMRunning(pScreenInfo))
- {
- }
- else
- {
- }
+ }
+ else {
+ }
#endif
- winWindowsWMSendEvent(WindowsWMActivationNotify,
- WindowsWMActivationNotifyMask,
- 1,
- WindowsWMIsActive,
- pWin->drawable.id,
- 0, 0,
- 0, 0);
- }
- else
- {
- winWindowsWMSendEvent(WindowsWMActivationNotify,
- WindowsWMActivationNotifyMask,
- 1,
- WindowsWMIsInactive,
- pWin->drawable.id,
- 0, 0,
- 0, 0);
- }
- break;
+ winWindowsWMSendEvent(WindowsWMActivationNotify,
+ WindowsWMActivationNotifyMask,
+ 1,
+ WindowsWMIsActive,
+ pWin->drawable.id, 0, 0, 0, 0);
+ }
+ else {
+ winWindowsWMSendEvent(WindowsWMActivationNotify,
+ WindowsWMActivationNotifyMask,
+ 1,
+ WindowsWMIsInactive,
+ pWin->drawable.id, 0, 0, 0, 0);
+ }
+ break;
case WM_SETCURSOR:
- if (LOWORD(lParam) == HTCLIENT)
- {
- if (!g_fSoftwareCursor) SetCursor (pScreenPriv->cursor.handle);
- return TRUE;
- }
- break;
+ if (LOWORD(lParam) == HTCLIENT) {
+ if (!g_fSoftwareCursor)
+ SetCursor(pScreenPriv->cursor.handle);
+ return TRUE;
+ }
+ break;
case WM_ENTERSIZEMOVE:
- winDebug ("winMWExtWMWindowProc - WM_ENTERSIZEMOVE - %d ms\n",
- (unsigned int)GetTickCount ());
+ winDebug("winMWExtWMWindowProc - WM_ENTERSIZEMOVE - %d ms\n",
+ (unsigned int) GetTickCount());
- pRLWinPriv->fMovingOrSizing = TRUE;
- break;
+ pRLWinPriv->fMovingOrSizing = TRUE;
+ break;
case WM_EXITSIZEMOVE:
- winDebug ("winMWExtWMWindowProc - WM_EXITSIZEMOVE - %d ms\n",
- (unsigned int)GetTickCount ());
+ winDebug("winMWExtWMWindowProc - WM_EXITSIZEMOVE - %d ms\n",
+ (unsigned int) GetTickCount());
- pRLWinPriv->fMovingOrSizing = FALSE;
+ pRLWinPriv->fMovingOrSizing = FALSE;
- GetClientRect (hwnd, &rcClient);
+ GetClientRect(hwnd, &rcClient);
- MapWindowPoints (hwnd, HWND_DESKTOP, (LPPOINT)&rcClient, 2);
+ MapWindowPoints(hwnd, HWND_DESKTOP, (LPPOINT) & rcClient, 2);
#ifdef XWIN_MULTIWINDOWINTWM
- if (winIsInternalWMRunning(pScreenInfo))
- winAdjustXWindow (pWin, hwnd);
+ if (winIsInternalWMRunning(pScreenInfo))
+ winAdjustXWindow(pWin, hwnd);
#endif
- winMWExtWMMoveResizeXWindow (pWin,
- rcClient.left - wBorderWidth (pWin)
- - GetSystemMetrics (SM_XVIRTUALSCREEN),
- rcClient.top - wBorderWidth (pWin)
- - GetSystemMetrics (SM_YVIRTUALSCREEN),
- rcClient.right - rcClient.left
- - wBorderWidth (pWin)*2,
- rcClient.bottom - rcClient.top
- - wBorderWidth (pWin)*2);
- break;
+ winMWExtWMMoveResizeXWindow(pWin, rcClient.left - wBorderWidth(pWin)
+ - GetSystemMetrics(SM_XVIRTUALSCREEN),
+ rcClient.top - wBorderWidth(pWin)
+ - GetSystemMetrics(SM_YVIRTUALSCREEN),
+ rcClient.right - rcClient.left
+ - wBorderWidth(pWin) * 2,
+ rcClient.bottom - rcClient.top
+ - wBorderWidth(pWin) * 2);
+ break;
case WM_MANAGE:
- winDebug ("winMWExtWMWindowProc - WM_MANAGE\n");
- break;
+ winDebug ("winMWExtWMWindowProc - WM_MANAGE\n");
+ break;
case WM_UNMANAGE:
- winDebug ("winMWExtWMWindowProc - WM_UNMANAGE\n");
- break;
+ winDebug ("winMWExtWMWindowProc - WM_UNMANAGE\n");
+ break;
default:
- break;
+ break;
}
- return DefWindowProc (hwnd, message, wParam, lParam);
+ return DefWindowProc(hwnd, message, wParam, lParam);
}
diff --git a/xorg-server/hw/xwin/winwindow.c b/xorg-server/hw/xwin/winwindow.c
index b83ea9485..a847561f8 100644
--- a/xorg-server/hw/xwin/winwindow.c
+++ b/xorg-server/hw/xwin/winwindow.c
@@ -34,559 +34,533 @@
#endif
#include "win.h"
-
/*
* Prototypes for local functions
*/
static int
-winAddRgn (WindowPtr pWindow, pointer data);
+ winAddRgn(WindowPtr pWindow, pointer data);
static
-void
-winUpdateRgnRootless (WindowPtr pWindow);
+ void
+ winUpdateRgnRootless(WindowPtr pWindow);
static
-void
-winReshapeRootless (WindowPtr pWin);
-
+ void
+ winReshapeRootless(WindowPtr pWin);
#ifdef XWIN_NATIVEGDI
/* See Porting Layer Definition - p. 37 */
/* See mfb/mfbwindow.c - mfbCreateWindow() */
Bool
-winCreateWindowNativeGDI (WindowPtr pWin)
+winCreateWindowNativeGDI(WindowPtr pWin)
{
- Bool fResult = TRUE;
- ScreenPtr pScreen = pWin->drawable.pScreen;
- winWindowPriv(pWin);
- winScreenPriv(pScreen);
+ Bool fResult = TRUE;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
- winDebug ("winCreateWindowNativeGDI (%p)\n", pWin);
+ winWindowPriv(pWin);
+ winScreenPriv(pScreen);
- WIN_UNWRAP(CreateWindow);
- fResult = (*pScreen->CreateWindow) (pWin);
- WIN_WRAP(CreateWindow, winCreateWindowNativeGDI);
+ winDebug ("winCreateWindowNativeGDI (%p)\n", pWin);
- return fResult;
-}
+ WIN_UNWRAP(CreateWindow);
+ fResult = (*pScreen->CreateWindow) (pWin);
+ WIN_WRAP(CreateWindow, winCreateWindowNativeGDI);
+ return fResult;
+}
/* See Porting Layer Definition - p. 37 */
/* See mfb/mfbwindow.c - mfbDestroyWindow() */
Bool
-winDestroyWindowNativeGDI (WindowPtr pWin)
+winDestroyWindowNativeGDI(WindowPtr pWin)
{
- Bool fResult = TRUE;
- ScreenPtr pScreen = pWin->drawable.pScreen;
- winWindowPriv(pWin);
- winScreenPriv(pScreen);
+ Bool fResult = TRUE;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
- winDebug ("winDestroyWindowNativeGDI (%p)\n", pWin);
+ winWindowPriv(pWin);
+ winScreenPriv(pScreen);
- WIN_UNWRAP(DestroyWindow);
- fResult = (*pScreen->DestroyWindow)(pWin);
- WIN_WRAP(DestroyWindow, winDestroyWindowNativeGDI);
+ winDebug ("winDestroyWindowNativeGDI (%p)\n", pWin);
- return fResult;
-}
+ WIN_UNWRAP(DestroyWindow);
+ fResult = (*pScreen->DestroyWindow) (pWin);
+ WIN_WRAP(DestroyWindow, winDestroyWindowNativeGDI);
+ return fResult;
+}
/* See Porting Layer Definition - p. 37 */
/* See mfb/mfbwindow.c - mfbPositionWindow() */
Bool
-winPositionWindowNativeGDI (WindowPtr pWin, int x, int y)
+winPositionWindowNativeGDI(WindowPtr pWin, int x, int y)
{
- Bool fResult = TRUE;
- ScreenPtr pScreen = pWin->drawable.pScreen;
- winWindowPriv(pWin);
- winScreenPriv(pScreen);
+ Bool fResult = TRUE;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
- winDebug ("winPositionWindowNativeGDI (%p)\n", pWin);
+ winWindowPriv(pWin);
+ winScreenPriv(pScreen);
- WIN_UNWRAP(PositionWindow);
- fResult = (*pScreen->PositionWindow)(pWin, x, y);
- WIN_WRAP(PositionWindow, winPositionWindowNativeGDI);
+ winDebug ("winPositionWindowNativeGDI (%p)\n", pWin);
- return fResult;
-}
+ WIN_UNWRAP(PositionWindow);
+ fResult = (*pScreen->PositionWindow) (pWin, x, y);
+ WIN_WRAP(PositionWindow, winPositionWindowNativeGDI);
+ return fResult;
+}
/* See Porting Layer Definition - p. 39 */
/* See mfb/mfbwindow.c - mfbCopyWindow() */
-void
-winCopyWindowNativeGDI (WindowPtr pWin,
- DDXPointRec ptOldOrg,
- RegionPtr prgnSrc)
+void
+winCopyWindowNativeGDI(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
{
- DDXPointPtr pptSrc;
- DDXPointPtr ppt;
- RegionPtr prgnDst;
- BoxPtr pBox;
- int dx, dy;
- int i, nbox;
- WindowPtr pwinRoot;
- BoxPtr pBoxDst;
- ScreenPtr pScreen = pWin->drawable.pScreen;
- winScreenPriv(pScreen);
-
- /* Get a pointer to the root window */
- pwinRoot = pWin->drawable.pScreen->root;
-
- /* Create a region for the destination */
- prgnDst = RegionCreate(NULL, 1);
-
- /* Calculate the shift from the source to the destination */
- dx = ptOldOrg.x - pWin->drawable.x;
- dy = ptOldOrg.y - pWin->drawable.y;
-
- /* Translate the region from the destination to the source? */
- RegionTranslate(prgnSrc, -dx, -dy);
- RegionIntersect(prgnDst, &pWin->borderClip,
- prgnSrc);
-
- /* Get a pointer to the first box in the region to be copied */
- pBox = RegionRects(prgnDst);
-
- /* Get the number of boxes in the region */
- nbox = RegionNumRects(prgnDst);
-
- /* Allocate source points for each box */
- if(!(pptSrc = (DDXPointPtr )malloc(nbox * sizeof(DDXPointRec))))
- return;
+ DDXPointPtr pptSrc;
+ DDXPointPtr ppt;
+ RegionPtr prgnDst;
+ BoxPtr pBox;
+ int dx, dy;
+ int i, nbox;
+ WindowPtr pwinRoot;
+ BoxPtr pBoxDst;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ winScreenPriv(pScreen);
+
+ /* Get a pointer to the root window */
+ pwinRoot = pWin->drawable.pScreen->root;
+
+ /* Create a region for the destination */
+ prgnDst = RegionCreate(NULL, 1);
+
+ /* Calculate the shift from the source to the destination */
+ dx = ptOldOrg.x - pWin->drawable.x;
+ dy = ptOldOrg.y - pWin->drawable.y;
+
+ /* Translate the region from the destination to the source? */
+ RegionTranslate(prgnSrc, -dx, -dy);
+ RegionIntersect(prgnDst, &pWin->borderClip, prgnSrc);
- /* Set an iterator pointer */
- ppt = pptSrc;
+ /* Get a pointer to the first box in the region to be copied */
+ pBox = RegionRects(prgnDst);
- /* Calculate the source point of each box? */
- for (i = nbox; --i >= 0; ppt++, pBox++)
- {
- ppt->x = pBox->x1 + dx;
- ppt->y = pBox->y1 + dy;
+ /* Get the number of boxes in the region */
+ nbox = RegionNumRects(prgnDst);
+
+ /* Allocate source points for each box */
+ if (!(pptSrc = (DDXPointPtr) malloc(nbox * sizeof(DDXPointRec))))
+ return;
+
+ /* Set an iterator pointer */
+ ppt = pptSrc;
+
+ /* Calculate the source point of each box? */
+ for (i = nbox; --i >= 0; ppt++, pBox++) {
+ ppt->x = pBox->x1 + dx;
+ ppt->y = pBox->y1 + dy;
}
- /* Setup loop pointers again */
- pBoxDst = RegionRects(prgnDst);
- ppt = pptSrc;
-
- /* BitBlt each source to the destination point */
- for (i = nbox; --i >= 0; pBoxDst++, ppt++)
- {
- BitBlt (pScreenPriv->hdcScreen,
- pBoxDst->x1, pBoxDst->y1,
- pBoxDst->x2 - pBoxDst->x1, pBoxDst->y2 - pBoxDst->y1,
- pScreenPriv->hdcScreen,
- ppt->x, ppt->y,
- SRCCOPY);
+ /* Setup loop pointers again */
+ pBoxDst = RegionRects(prgnDst);
+ ppt = pptSrc;
+
+ /* BitBlt each source to the destination point */
+ for (i = nbox; --i >= 0; pBoxDst++, ppt++) {
+ BitBlt(pScreenPriv->hdcScreen,
+ pBoxDst->x1, pBoxDst->y1,
+ pBoxDst->x2 - pBoxDst->x1, pBoxDst->y2 - pBoxDst->y1,
+ pScreenPriv->hdcScreen, ppt->x, ppt->y, SRCCOPY);
}
- /* Cleanup the regions, etc. */
- free(pptSrc);
- RegionDestroy(prgnDst);
+ /* Cleanup the regions, etc. */
+ free(pptSrc);
+ RegionDestroy(prgnDst);
}
-
/* See Porting Layer Definition - p. 37 */
/* See mfb/mfbwindow.c - mfbChangeWindowAttributes() */
Bool
-winChangeWindowAttributesNativeGDI (WindowPtr pWin, unsigned long mask)
+winChangeWindowAttributesNativeGDI(WindowPtr pWin, unsigned long mask)
{
- Bool fResult = TRUE;
- ScreenPtr pScreen = pWin->drawable.pScreen;
- winWindowPriv(pWin);
- winScreenPriv(pScreen);
+ Bool fResult = TRUE;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ winWindowPriv(pWin);
+ winScreenPriv(pScreen);
winDebug ("winChangeWindowAttributesNativeGDI (%p)\n", pWin);
-
- WIN_UNWRAP(ChangeWindowAttributes);
- fResult = (*pScreen->ChangeWindowAttributes)(pWin, mask);
- WIN_WRAP(ChangeWindowAttributes, winChangeWindowAttributesNativeGDI);
-
- /*
- * NOTE: We do not currently need to do anything here.
- */
-
- return fResult;
-}
+ WIN_UNWRAP(ChangeWindowAttributes);
+ fResult = (*pScreen->ChangeWindowAttributes) (pWin, mask);
+ WIN_WRAP(ChangeWindowAttributes, winChangeWindowAttributesNativeGDI);
+
+ /*
+ * NOTE: We do not currently need to do anything here.
+ */
+
+ return fResult;
+}
/* See Porting Layer Definition - p. 37
* Also referred to as UnrealizeWindow
*/
Bool
-winUnmapWindowNativeGDI (WindowPtr pWin)
+winUnmapWindowNativeGDI(WindowPtr pWin)
{
- Bool fResult = TRUE;
- ScreenPtr pScreen = pWin->drawable.pScreen;
- winWindowPriv(pWin);
- winScreenPriv(pScreen);
+ Bool fResult = TRUE;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ winWindowPriv(pWin);
+ winScreenPriv(pScreen);
winDebug ("winUnmapWindowNativeGDI (%p)\n", pWin);
- WIN_UNWRAP(UnrealizeWindow);
- fResult = (*pScreen->UnrealizeWindow)(pWin);
- WIN_WRAP(UnrealizeWindow, winUnmapWindowNativeGDI);
-
- return fResult;
-}
+ WIN_UNWRAP(UnrealizeWindow);
+ fResult = (*pScreen->UnrealizeWindow) (pWin);
+ WIN_WRAP(UnrealizeWindow, winUnmapWindowNativeGDI);
+ return fResult;
+}
/* See Porting Layer Definition - p. 37
* Also referred to as RealizeWindow
*/
Bool
-winMapWindowNativeGDI (WindowPtr pWin)
+winMapWindowNativeGDI(WindowPtr pWin)
{
- Bool fResult = TRUE;
- ScreenPtr pScreen = pWin->drawable.pScreen;
- winWindowPriv(pWin);
- winScreenPriv(pScreen);
+ Bool fResult = TRUE;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ winWindowPriv(pWin);
+ winScreenPriv(pScreen);
winDebug ("winMapWindowNativeGDI (%p)\n", pWin);
- WIN_UNWRAP(RealizeWindow);
- fResult = (*pScreen->RealizeWindow)(pWin);
- WIN_WRAP(RealizeWindow, winMapWindowMultiWindow);
-
- return fResult;
+ WIN_UNWRAP(RealizeWindow);
+ fResult = (*pScreen->RealizeWindow) (pWin);
+ WIN_WRAP(RealizeWindow, winMapWindowMultiWindow);
+
+ return fResult;
}
#endif
-
/* See Porting Layer Definition - p. 37 */
/* See mfb/mfbwindow.c - mfbCreateWindow() */
Bool
-winCreateWindowRootless (WindowPtr pWin)
+winCreateWindowRootless(WindowPtr pWin)
{
- Bool fResult = FALSE;
- ScreenPtr pScreen = pWin->drawable.pScreen;
- winWindowPriv(pWin);
- winScreenPriv(pScreen);
+ Bool fResult = FALSE;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ winWindowPriv(pWin);
+ winScreenPriv(pScreen);
winDebug ("winCreateWindowRootless (%p)\n", pWin);
- WIN_UNWRAP(CreateWindow);
- fResult = (*pScreen->CreateWindow) (pWin);
- WIN_WRAP(CreateWindow, winCreateWindowRootless);
-
- pWinPriv->hRgn = NULL;
-
- return fResult;
-}
+ WIN_UNWRAP(CreateWindow);
+ fResult = (*pScreen->CreateWindow) (pWin);
+ WIN_WRAP(CreateWindow, winCreateWindowRootless);
+
+ pWinPriv->hRgn = NULL;
+ return fResult;
+}
/* See Porting Layer Definition - p. 37 */
/* See mfb/mfbwindow.c - mfbDestroyWindow() */
Bool
-winDestroyWindowRootless (WindowPtr pWin)
+winDestroyWindowRootless(WindowPtr pWin)
{
- Bool fResult = FALSE;
- ScreenPtr pScreen = pWin->drawable.pScreen;
- winWindowPriv(pWin);
- winScreenPriv(pScreen);
+ Bool fResult = FALSE;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ winWindowPriv(pWin);
+ winScreenPriv(pScreen);
winDebug ("winDestroyWindowRootless (%p)\n", pWin);
- WIN_UNWRAP(DestroyWindow);
- fResult = (*pScreen->DestroyWindow)(pWin);
- WIN_WRAP(DestroyWindow, winDestroyWindowRootless);
-
- if (pWinPriv->hRgn != NULL)
- {
- DeleteObject(pWinPriv->hRgn);
- pWinPriv->hRgn = NULL;
+ WIN_UNWRAP(DestroyWindow);
+ fResult = (*pScreen->DestroyWindow) (pWin);
+ WIN_WRAP(DestroyWindow, winDestroyWindowRootless);
+
+ if (pWinPriv->hRgn != NULL) {
+ DeleteObject(pWinPriv->hRgn);
+ pWinPriv->hRgn = NULL;
}
-
- winUpdateRgnRootless (pWin);
-
- return fResult;
-}
+ winUpdateRgnRootless(pWin);
+
+ return fResult;
+}
/* See Porting Layer Definition - p. 37 */
/* See mfb/mfbwindow.c - mfbPositionWindow() */
Bool
-winPositionWindowRootless (WindowPtr pWin, int x, int y)
+winPositionWindowRootless(WindowPtr pWin, int x, int y)
{
- Bool fResult = FALSE;
- ScreenPtr pScreen = pWin->drawable.pScreen;
- winScreenPriv(pScreen);
-
- winDebug ("winPositionWindowRootless (%p)\n", pWin);
-
- WIN_UNWRAP(PositionWindow);
- fResult = (*pScreen->PositionWindow)(pWin, x, y);
- WIN_WRAP(PositionWindow, winPositionWindowRootless);
-
- winUpdateRgnRootless (pWin);
-
- return fResult;
-}
+ Bool fResult = FALSE;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ winScreenPriv(pScreen);
+ winDebug ("winPositionWindowRootless (%p)\n", pWin);
+
+ WIN_UNWRAP(PositionWindow);
+ fResult = (*pScreen->PositionWindow) (pWin, x, y);
+ WIN_WRAP(PositionWindow, winPositionWindowRootless);
+
+ winUpdateRgnRootless(pWin);
+
+ return fResult;
+}
/* See Porting Layer Definition - p. 37 */
/* See mfb/mfbwindow.c - mfbChangeWindowAttributes() */
Bool
-winChangeWindowAttributesRootless (WindowPtr pWin, unsigned long mask)
+winChangeWindowAttributesRootless(WindowPtr pWin, unsigned long mask)
{
- Bool fResult = FALSE;
- ScreenPtr pScreen = pWin->drawable.pScreen;
- winScreenPriv(pScreen);
+ Bool fResult = FALSE;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ winScreenPriv(pScreen);
winDebug ("winChangeWindowAttributesRootless (%p)\n", pWin);
- WIN_UNWRAP(ChangeWindowAttributes);
- fResult = (*pScreen->ChangeWindowAttributes)(pWin, mask);
- WIN_WRAP(ChangeWindowAttributes, winChangeWindowAttributesRootless);
+ WIN_UNWRAP(ChangeWindowAttributes);
+ fResult = (*pScreen->ChangeWindowAttributes) (pWin, mask);
+ WIN_WRAP(ChangeWindowAttributes, winChangeWindowAttributesRootless);
- winUpdateRgnRootless (pWin);
-
- return fResult;
-}
+ winUpdateRgnRootless(pWin);
+ return fResult;
+}
/* See Porting Layer Definition - p. 37
* Also referred to as UnrealizeWindow
*/
Bool
-winUnmapWindowRootless (WindowPtr pWin)
+winUnmapWindowRootless(WindowPtr pWin)
{
- Bool fResult = FALSE;
- ScreenPtr pScreen = pWin->drawable.pScreen;
- winWindowPriv(pWin);
- winScreenPriv(pScreen);
+ Bool fResult = FALSE;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ winWindowPriv(pWin);
+ winScreenPriv(pScreen);
winDebug ("winUnmapWindowRootless (%p)\n", pWin);
- WIN_UNWRAP(UnrealizeWindow);
- fResult = (*pScreen->UnrealizeWindow)(pWin);
- WIN_WRAP(UnrealizeWindow, winUnmapWindowRootless);
-
- if (pWinPriv->hRgn != NULL)
- {
- DeleteObject(pWinPriv->hRgn);
- pWinPriv->hRgn = NULL;
+ WIN_UNWRAP(UnrealizeWindow);
+ fResult = (*pScreen->UnrealizeWindow) (pWin);
+ WIN_WRAP(UnrealizeWindow, winUnmapWindowRootless);
+
+ if (pWinPriv->hRgn != NULL) {
+ DeleteObject(pWinPriv->hRgn);
+ pWinPriv->hRgn = NULL;
}
-
- winUpdateRgnRootless (pWin);
-
- return fResult;
-}
+ winUpdateRgnRootless(pWin);
+
+ return fResult;
+}
/* See Porting Layer Definition - p. 37
* Also referred to as RealizeWindow
*/
Bool
-winMapWindowRootless (WindowPtr pWin)
+winMapWindowRootless(WindowPtr pWin)
{
- Bool fResult = FALSE;
- ScreenPtr pScreen = pWin->drawable.pScreen;
- winScreenPriv(pScreen);
+ Bool fResult = FALSE;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ winScreenPriv(pScreen);
winDebug ("winMapWindowRootless (%p)\n", pWin);
- WIN_UNWRAP(RealizeWindow);
- fResult = (*pScreen->RealizeWindow)(pWin);
- WIN_WRAP(RealizeWindow, winMapWindowRootless);
+ WIN_UNWRAP(RealizeWindow);
+ fResult = (*pScreen->RealizeWindow) (pWin);
+ WIN_WRAP(RealizeWindow, winMapWindowRootless);
- winReshapeRootless (pWin);
-
- winUpdateRgnRootless (pWin);
-
- return fResult;
-}
+ winReshapeRootless(pWin);
+ winUpdateRgnRootless(pWin);
+
+ return fResult;
+}
void
-winSetShapeRootless (WindowPtr pWin, int kind)
+winSetShapeRootless(WindowPtr pWin, int kind)
{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- winScreenPriv(pScreen);
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+
+ winScreenPriv(pScreen);
winDebug ("winSetShapeRootless (%p, %i)\n", pWin, kind);
- WIN_UNWRAP(SetShape);
- (*pScreen->SetShape)(pWin, kind);
- WIN_WRAP(SetShape, winSetShapeRootless);
-
- winReshapeRootless (pWin);
- winUpdateRgnRootless (pWin);
-
- return;
-}
+ WIN_UNWRAP(SetShape);
+ (*pScreen->SetShape) (pWin, kind);
+ WIN_WRAP(SetShape, winSetShapeRootless);
+ winReshapeRootless(pWin);
+ winUpdateRgnRootless(pWin);
+
+ return;
+}
/*
* Local function for adding a region to the Windows window region
*/
static
-int
-winAddRgn (WindowPtr pWin, pointer data)
+ int
+winAddRgn(WindowPtr pWin, pointer data)
{
- int iX, iY, iWidth, iHeight, iBorder;
- HRGN hRgn = *(HRGN*)data;
- HRGN hRgnWin;
- winWindowPriv(pWin);
-
- /* If pWin is not Root */
- if (pWin->parent != NULL)
- {
- winDebug ("winAddRgn ()\n");
- if (pWin->mapped)
- {
- iBorder = wBorderWidth (pWin);
-
- iX = pWin->drawable.x - iBorder;
- iY = pWin->drawable.y - iBorder;
-
- iWidth = pWin->drawable.width + iBorder * 2;
- iHeight = pWin->drawable.height + iBorder * 2;
-
- hRgnWin = CreateRectRgn (0, 0, iWidth, iHeight);
-
- if (hRgnWin == NULL)
- {
- winDebug ("winAddRgn - CreateRectRgn () failed\n");
- winDebug (" Rect %d %d %d %d\n",
- iX, iY, iX + iWidth, iY + iHeight);
- }
-
- if (pWinPriv->hRgn)
- {
- if (CombineRgn (hRgnWin, hRgnWin, pWinPriv->hRgn, RGN_AND)
- == ERROR)
- {
- ErrorF ("winAddRgn - CombineRgn () failed\n");
- }
- }
-
- OffsetRgn (hRgnWin, iX, iY);
-
- if (CombineRgn (hRgn, hRgn, hRgnWin, RGN_OR) == ERROR)
- {
- ErrorF ("winAddRgn - CombineRgn () failed\n");
- }
-
- DeleteObject (hRgnWin);
- }
- return WT_DONTWALKCHILDREN;
+ int iX, iY, iWidth, iHeight, iBorder;
+ HRGN hRgn = *(HRGN *) data;
+ HRGN hRgnWin;
+
+ winWindowPriv(pWin);
+
+ /* If pWin is not Root */
+ if (pWin->parent != NULL) {
+ winDebug("winAddRgn ()\n");
+ if (pWin->mapped) {
+ iBorder = wBorderWidth(pWin);
+
+ iX = pWin->drawable.x - iBorder;
+ iY = pWin->drawable.y - iBorder;
+
+ iWidth = pWin->drawable.width + iBorder * 2;
+ iHeight = pWin->drawable.height + iBorder * 2;
+
+ hRgnWin = CreateRectRgn(0, 0, iWidth, iHeight);
+
+ if (hRgnWin == NULL) {
+ winDebug ("winAddRgn - CreateRectRgn () failed\n");
+ winDebug (" Rect %d %d %d %d\n",
+ iX, iY, iX + iWidth, iY + iHeight);
+ }
+
+ if (pWinPriv->hRgn) {
+ if (CombineRgn(hRgnWin, hRgnWin, pWinPriv->hRgn, RGN_AND)
+ == ERROR) {
+ ErrorF("winAddRgn - CombineRgn () failed\n");
+ }
+ }
+
+ OffsetRgn(hRgnWin, iX, iY);
+
+ if (CombineRgn(hRgn, hRgn, hRgnWin, RGN_OR) == ERROR) {
+ ErrorF("winAddRgn - CombineRgn () failed\n");
+ }
+
+ DeleteObject(hRgnWin);
+ }
+ return WT_DONTWALKCHILDREN;
}
- else
- {
- return WT_WALKCHILDREN;
+ else {
+ return WT_WALKCHILDREN;
}
}
-
/*
* Local function to update the Windows window's region
*/
static
-void
-winUpdateRgnRootless (WindowPtr pWin)
+ void
+winUpdateRgnRootless(WindowPtr pWin)
{
- HRGN hRgn = CreateRectRgn (0, 0, 0, 0);
-
- if (hRgn != NULL)
- {
- WalkTree (pWin->drawable.pScreen, winAddRgn, &hRgn);
- SetWindowRgn (winGetScreenPriv(pWin->drawable.pScreen)->hwndScreen,
- hRgn, TRUE);
+ HRGN hRgn = CreateRectRgn(0, 0, 0, 0);
+
+ if (hRgn != NULL) {
+ WalkTree(pWin->drawable.pScreen, winAddRgn, &hRgn);
+ SetWindowRgn(winGetScreenPriv(pWin->drawable.pScreen)->hwndScreen,
+ hRgn, TRUE);
}
- else
- {
- ErrorF ("winUpdateRgnRootless - CreateRectRgn failed.\n");
+ else {
+ ErrorF("winUpdateRgnRootless - CreateRectRgn failed.\n");
}
}
-
static
-void
-winReshapeRootless (WindowPtr pWin)
+ void
+winReshapeRootless(WindowPtr pWin)
{
- int nRects;
- RegionRec rrNewShape;
- BoxPtr pShape, pRects, pEnd;
- HRGN hRgn, hRgnRect;
- winWindowPriv(pWin);
+ int nRects;
+ RegionRec rrNewShape;
+ BoxPtr pShape, pRects, pEnd;
+ HRGN hRgn, hRgnRect;
- winDebug ("winReshapeRootless ()\n");
+ winWindowPriv(pWin);
- /* Bail if the window is the root window */
- if (pWin->parent == NULL)
- return;
+ winDebug("winReshapeRootless ()\n");
- /* Bail if the window is not top level */
- if (pWin->parent->parent != NULL)
- return;
+ /* Bail if the window is the root window */
+ if (pWin->parent == NULL)
+ return;
- /* Free any existing window region stored in the window privates */
- if (pWinPriv->hRgn != NULL)
- {
- DeleteObject (pWinPriv->hRgn);
- pWinPriv->hRgn = NULL;
+ /* Bail if the window is not top level */
+ if (pWin->parent->parent != NULL)
+ return;
+
+ /* Free any existing window region stored in the window privates */
+ if (pWinPriv->hRgn != NULL) {
+ DeleteObject(pWinPriv->hRgn);
+ pWinPriv->hRgn = NULL;
}
-
- /* Bail if the window has no bounding region defined */
- if (!wBoundingShape (pWin))
- return;
- RegionNull(&rrNewShape);
- RegionCopy(&rrNewShape, wBoundingShape(pWin));
- RegionTranslate(&rrNewShape, pWin->borderWidth,
- pWin->borderWidth);
-
- nRects = RegionNumRects(&rrNewShape);
- pShape = RegionRects(&rrNewShape);
-
- if (nRects > 0)
- {
- /* Create initial empty Windows region */
- hRgn = CreateRectRgn (0, 0, 0, 0);
-
- /* Loop through all rectangles in the X region */
- for (pRects = pShape, pEnd = pShape + nRects; pRects < pEnd; pRects++)
- {
- /* Create a Windows region for the X rectangle */
- hRgnRect = CreateRectRgn (pRects->x1, pRects->y1,
- pRects->x2, pRects->y2);
- if (hRgnRect == NULL)
- {
- ErrorF("winReshapeRootless - CreateRectRgn() failed\n");
- }
-
- /* Merge the Windows region with the accumulated region */
- if (CombineRgn (hRgn, hRgn, hRgnRect, RGN_OR) == ERROR)
- {
- ErrorF("winReshapeRootless - CombineRgn() failed\n");
- }
-
- /* Delete the temporary Windows region */
- DeleteObject (hRgnRect);
+ /* Bail if the window has no bounding region defined */
+ if (!wBoundingShape(pWin))
+ return;
+
+ RegionNull(&rrNewShape);
+ RegionCopy(&rrNewShape, wBoundingShape(pWin));
+ RegionTranslate(&rrNewShape, pWin->borderWidth, pWin->borderWidth);
+
+ nRects = RegionNumRects(&rrNewShape);
+ pShape = RegionRects(&rrNewShape);
+
+ if (nRects > 0) {
+ /* Create initial empty Windows region */
+ hRgn = CreateRectRgn(0, 0, 0, 0);
+
+ /* Loop through all rectangles in the X region */
+ for (pRects = pShape, pEnd = pShape + nRects; pRects < pEnd; pRects++) {
+ /* Create a Windows region for the X rectangle */
+ hRgnRect = CreateRectRgn(pRects->x1, pRects->y1,
+ pRects->x2, pRects->y2);
+ if (hRgnRect == NULL) {
+ ErrorF("winReshapeRootless - CreateRectRgn() failed\n");
+ }
+
+ /* Merge the Windows region with the accumulated region */
+ if (CombineRgn(hRgn, hRgn, hRgnRect, RGN_OR) == ERROR) {
+ ErrorF("winReshapeRootless - CombineRgn() failed\n");
+ }
+
+ /* Delete the temporary Windows region */
+ DeleteObject(hRgnRect);
}
-
- /* Save a handle to the composite region in the window privates */
- pWinPriv->hRgn = hRgn;
+
+ /* Save a handle to the composite region in the window privates */
+ pWinPriv->hRgn = hRgn;
}
- RegionUninit(&rrNewShape);
-
- return;
+ RegionUninit(&rrNewShape);
+
+ return;
}
diff --git a/xorg-server/hw/xwin/winwindow.h b/xorg-server/hw/xwin/winwindow.h
index 7721f1411..ce8157d8a 100644
--- a/xorg-server/hw/xwin/winwindow.h
+++ b/xorg-server/hw/xwin/winwindow.h
@@ -41,7 +41,7 @@
/* Constant strings */
#ifndef PROJECT_NAME
-# define PROJECT_NAME "VcXsrv"
+#define PROJECT_NAME "VcXsrv"
#endif
#define EXECUTABLE_NAME "VcXsrv"
#define WINDOW_CLASS "VcXsrv/x"
@@ -52,7 +52,7 @@
#define WINDOW_TITLE_X PROJECT_NAME " X"
#define WIN_WINDOW_PROP "vcxsrv_window_prop_rl"
#ifdef HAS_DEVWINDOWS
-# define WIN_MSG_QUEUE_FNAME "/dev/windows"
+#define WIN_MSG_QUEUE_FNAME "/dev/windows"
#endif
#define WIN_WID_PROP "vcxsrv_wid_prop_rl"
#define WIN_NEEDMANAGE_PROP "vcxsrv_override_redirect_prop_rl"
@@ -61,45 +61,42 @@
typedef struct _winPrivScreenRec *winPrivScreenPtr;
-
/*
* Window privates
*/
-typedef struct
-{
- DWORD dwDummy;
- HRGN hRgn;
- HWND hWnd;
+typedef struct {
+ DWORD dwDummy;
+ HRGN hRgn;
+ HWND hWnd;
BOOL OpenGlWindow;
- winPrivScreenPtr pScreenPriv;
- Bool fXKilled;
- HDWP hDwp;
+ winPrivScreenPtr pScreenPriv;
+ Bool fXKilled;
+ HDWP hDwp;
#ifdef XWIN_GLX_WINDOWS
- Bool fWglUsed;
+ Bool fWglUsed;
#endif
- /* Privates used by primary fb DirectDraw server */
- LPDDSURFACEDESC pddsdPrimary;
+ /* Privates used by primary fb DirectDraw server */
+ LPDDSURFACEDESC pddsdPrimary;
- /* Privates used by shadow fb DirectDraw Nonlocking server */
- LPDIRECTDRAWSURFACE4 pddsPrimary4;
+ /* Privates used by shadow fb DirectDraw Nonlocking server */
+ LPDIRECTDRAWSURFACE4 pddsPrimary4;
- /* Privates used by both shadow fb DirectDraw servers */
- LPDIRECTDRAWCLIPPER pddcPrimary;
+ /* Privates used by both shadow fb DirectDraw servers */
+ LPDIRECTDRAWCLIPPER pddcPrimary;
} winPrivWinRec, *winPrivWinPtr;
#ifdef XWIN_MULTIWINDOW
-typedef struct _winWMMessageRec{
- DWORD dwID;
- DWORD msg;
- int iWindow;
- HWND hwndWindow;
- int iX, iY;
- int iWidth, iHeight;
+typedef struct _winWMMessageRec {
+ DWORD dwID;
+ DWORD msg;
+ int iWindow;
+ HWND hwndWindow;
+ int iX, iY;
+ int iWidth, iHeight;
} winWMMessageRec, *winWMMessagePtr;
-
/*
* winmultiwindowwm.c
*/
@@ -135,27 +132,27 @@ typedef struct _winWMMessageRec{
/* This structure only contains 3 elements... the Motif 2.0 structure
contains 5... we only need the first 3... so that is all we will define */
typedef struct MwmHints {
- unsigned long flags, functions, decorations;
+ unsigned long flags, functions, decorations;
} MwmHints;
+
#define PropMwmHintsElements 3
void
-winSendMessageToWM (void *pWMInfo, winWMMessagePtr msg);
+ winSendMessageToWM(void *pWMInfo, winWMMessagePtr msg);
Bool
-winInitWM (void **ppWMInfo,
- pthread_t *ptWMProc,
- pthread_t *ptXMsgProc,
- pthread_mutex_t *ppmServerStarted,
- int dwScreen,
- HWND hwndScreen,
- BOOL allowOtherWM);
+
+winInitWM(void **ppWMInfo,
+ pthread_t * ptWMProc,
+ pthread_t * ptXMsgProc,
+ pthread_mutex_t * ppmServerStarted,
+ int dwScreen, HWND hwndScreen, BOOL allowOtherWM);
void
-winDeinitMultiWindowWM (void);
+ winDeinitMultiWindowWM(void);
void
-winMinimizeWindow (Window id);
+ winMinimizeWindow(Window id);
void
winTaskbarInit (void);
@@ -165,19 +162,18 @@ winTaskbarDestroy (void);
void
winSetAppID (HWND hWnd, const char* AppID);
-
/*
* winmultiwindowicons.c
*/
void
-winUpdateIcon (Window id);
+ winUpdateIcon(Window id);
-void
-winInitGlobalIcons (void);
+void
+ winInitGlobalIcons(void);
-void
-winDestroyIcon(HICON hIcon);
+void
+ winDestroyIcon(HICON hIcon);
-#endif /* XWIN_MULTIWINDOW */
+#endif /* XWIN_MULTIWINDOW */
#endif
diff --git a/xorg-server/hw/xwin/winwindowswm.c b/xorg-server/hw/xwin/winwindowswm.c
index 05879eb9d..a14caf7a9 100644
--- a/xorg-server/hw/xwin/winwindowswm.c
+++ b/xorg-server/hw/xwin/winwindowswm.c
@@ -47,207 +47,193 @@ static int WMErrorBase;
static unsigned char WMReqCode = 0;
static int WMEventBase = 0;
-static RESTYPE ClientType, eventResourceType; /* resource types for event masks */
+static RESTYPE ClientType, eventResourceType; /* resource types for event masks */
static XID eventResource;
/* Currently selected events */
static unsigned int eventMask = 0;
-static int WMFreeClient (pointer data, XID id);
-static int WMFreeEvents (pointer data, XID id);
-static void SNotifyEvent(xWindowsWMNotifyEvent *from, xWindowsWMNotifyEvent *to);
+static int WMFreeClient(pointer data, XID id);
+static int WMFreeEvents(pointer data, XID id);
+static void SNotifyEvent(xWindowsWMNotifyEvent * from,
+ xWindowsWMNotifyEvent * to);
typedef struct _WMEvent *WMEventPtr;
typedef struct _WMEvent {
- WMEventPtr next;
- ClientPtr client;
- XID clientResource;
- unsigned int mask;
+ WMEventPtr next;
+ ClientPtr client;
+ XID clientResource;
+ unsigned int mask;
} WMEventRec;
static inline BoxRec
-make_box (int x, int y, int w, int h)
+make_box(int x, int y, int w, int h)
{
- BoxRec r;
- r.x1 = x;
- r.y1 = y;
- r.x2 = x + w;
- r.y2 = y + h;
- return r;
+ BoxRec r;
+
+ r.x1 = x;
+ r.y1 = y;
+ r.x2 = x + w;
+ r.y2 = y + h;
+ return r;
}
static int
ProcWindowsWMQueryVersion(ClientPtr client)
{
- xWindowsWMQueryVersionReply rep;
- int n;
-
- REQUEST_SIZE_MATCH(xWindowsWMQueryVersionReq);
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.majorVersion = SERVER_WINDOWSWM_MAJOR_VERSION;
- rep.minorVersion = SERVER_WINDOWSWM_MINOR_VERSION;
- rep.patchVersion = SERVER_WINDOWSWM_PATCH_VERSION;
- if (client->swapped)
- {
- swaps(&rep.sequenceNumber);
- swapl(&rep.length);
+ xWindowsWMQueryVersionReply rep;
+ int n;
+
+ REQUEST_SIZE_MATCH(xWindowsWMQueryVersionReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.majorVersion = SERVER_WINDOWSWM_MAJOR_VERSION;
+ rep.minorVersion = SERVER_WINDOWSWM_MINOR_VERSION;
+ rep.patchVersion = SERVER_WINDOWSWM_PATCH_VERSION;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber);
+ swapl(&rep.length);
}
- WriteToClient(client, sizeof(xWindowsWMQueryVersionReply), (char *)&rep);
- return Success;
+ WriteToClient(client, sizeof(xWindowsWMQueryVersionReply), (char *) &rep);
+ return Success;
}
-
/* events */
static inline void
-updateEventMask (WMEventPtr *pHead)
+updateEventMask(WMEventPtr * pHead)
{
- WMEventPtr pCur;
+ WMEventPtr pCur;
- eventMask = 0;
- for (pCur = *pHead; pCur != NULL; pCur = pCur->next)
- eventMask |= pCur->mask;
+ eventMask = 0;
+ for (pCur = *pHead; pCur != NULL; pCur = pCur->next)
+ eventMask |= pCur->mask;
}
-/*ARGSUSED*/
-static int
-WMFreeClient (pointer data, XID id)
+ /*ARGSUSED*/ static int
+WMFreeClient(pointer data, XID id)
{
- WMEventPtr pEvent;
- WMEventPtr *pHead, pCur, pPrev;
-
- pEvent = (WMEventPtr) data;
- dixLookupResourceByType((pointer) &pHead, eventResource, eventResourceType,
- NullClient, DixUnknownAccess);
- if (pHead)
- {
- pPrev = 0;
- for (pCur = *pHead; pCur && pCur != pEvent; pCur=pCur->next)
- pPrev = pCur;
- if (pCur)
- {
- if (pPrev)
- pPrev->next = pEvent->next;
- else
- *pHead = pEvent->next;
- }
- updateEventMask (pHead);
+ WMEventPtr pEvent;
+ WMEventPtr *pHead, pCur, pPrev;
+
+ pEvent = (WMEventPtr) data;
+ dixLookupResourceByType((pointer) &pHead, eventResource, eventResourceType,
+ NullClient, DixUnknownAccess);
+ if (pHead) {
+ pPrev = 0;
+ for (pCur = *pHead; pCur && pCur != pEvent; pCur = pCur->next)
+ pPrev = pCur;
+ if (pCur) {
+ if (pPrev)
+ pPrev->next = pEvent->next;
+ else
+ *pHead = pEvent->next;
+ }
+ updateEventMask(pHead);
}
- free((pointer) pEvent);
- return 1;
+ free((pointer) pEvent);
+ return 1;
}
-/*ARGSUSED*/
-static int
-WMFreeEvents (pointer data, XID id)
+ /*ARGSUSED*/ static int
+WMFreeEvents(pointer data, XID id)
{
- WMEventPtr *pHead, pCur, pNext;
-
- pHead = (WMEventPtr *) data;
- for (pCur = *pHead; pCur; pCur = pNext)
- {
- pNext = pCur->next;
- FreeResource (pCur->clientResource, ClientType);
- free((pointer) pCur);
+ WMEventPtr *pHead, pCur, pNext;
+
+ pHead = (WMEventPtr *) data;
+ for (pCur = *pHead; pCur; pCur = pNext) {
+ pNext = pCur->next;
+ FreeResource(pCur->clientResource, ClientType);
+ free((pointer) pCur);
}
- free((pointer) pHead);
- eventMask = 0;
- return 1;
+ free((pointer) pHead);
+ eventMask = 0;
+ return 1;
}
static int
-ProcWindowsWMSelectInput (ClientPtr client)
+ProcWindowsWMSelectInput(ClientPtr client)
{
- REQUEST(xWindowsWMSelectInputReq);
- WMEventPtr pEvent, pNewEvent, *pHead;
- XID clientResource;
-
- REQUEST_SIZE_MATCH (xWindowsWMSelectInputReq);
- dixLookupResourceByType((pointer) &pHead, eventResource, eventResourceType, client, DixWriteAccess);
- if (stuff->mask != 0)
- {
- if (pHead)
- {
- /* check for existing entry. */
- for (pEvent = *pHead; pEvent; pEvent = pEvent->next)
- {
- if (pEvent->client == client)
- {
- pEvent->mask = stuff->mask;
- updateEventMask (pHead);
- return Success;
- }
- }
- }
-
- /* build the entry */
- pNewEvent = (WMEventPtr) malloc(sizeof (WMEventRec));
- if (!pNewEvent)
- return BadAlloc;
- pNewEvent->next = 0;
- pNewEvent->client = client;
- pNewEvent->mask = stuff->mask;
- /*
- * add a resource that will be deleted when
- * the client goes away
- */
- clientResource = FakeClientID (client->index);
- pNewEvent->clientResource = clientResource;
- if (!AddResource (clientResource, ClientType, (pointer)pNewEvent))
- return BadAlloc;
- /*
- * create a resource to contain a pointer to the list
- * of clients selecting input. This must be indirect as
- * the list may be arbitrarily rearranged which cannot be
- * done through the resource database.
- */
- if (!pHead)
- {
- pHead = (WMEventPtr *) malloc(sizeof (WMEventPtr));
- if (!pHead ||
- !AddResource (eventResource, eventResourceType, (pointer)pHead))
- {
- FreeResource (clientResource, RT_NONE);
- return BadAlloc;
- }
- *pHead = 0;
- }
- pNewEvent->next = *pHead;
- *pHead = pNewEvent;
- updateEventMask (pHead);
+ REQUEST(xWindowsWMSelectInputReq);
+ WMEventPtr pEvent, pNewEvent, *pHead;
+ XID clientResource;
+
+ REQUEST_SIZE_MATCH(xWindowsWMSelectInputReq);
+ dixLookupResourceByType((pointer) &pHead, eventResource, eventResourceType,
+ client, DixWriteAccess);
+ if (stuff->mask != 0) {
+ if (pHead) {
+ /* check for existing entry. */
+ for (pEvent = *pHead; pEvent; pEvent = pEvent->next) {
+ if (pEvent->client == client) {
+ pEvent->mask = stuff->mask;
+ updateEventMask(pHead);
+ return Success;
+ }
+ }
+ }
+
+ /* build the entry */
+ pNewEvent = (WMEventPtr) malloc(sizeof(WMEventRec));
+ if (!pNewEvent)
+ return BadAlloc;
+ pNewEvent->next = 0;
+ pNewEvent->client = client;
+ pNewEvent->mask = stuff->mask;
+ /*
+ * add a resource that will be deleted when
+ * the client goes away
+ */
+ clientResource = FakeClientID(client->index);
+ pNewEvent->clientResource = clientResource;
+ if (!AddResource(clientResource, ClientType, (pointer) pNewEvent))
+ return BadAlloc;
+ /*
+ * create a resource to contain a pointer to the list
+ * of clients selecting input. This must be indirect as
+ * the list may be arbitrarily rearranged which cannot be
+ * done through the resource database.
+ */
+ if (!pHead) {
+ pHead = (WMEventPtr *) malloc(sizeof(WMEventPtr));
+ if (!pHead ||
+ !AddResource(eventResource, eventResourceType, (pointer) pHead))
+ {
+ FreeResource(clientResource, RT_NONE);
+ return BadAlloc;
+ }
+ *pHead = 0;
+ }
+ pNewEvent->next = *pHead;
+ *pHead = pNewEvent;
+ updateEventMask(pHead);
}
- else if (stuff->mask == 0)
- {
- /* delete the interest */
- if (pHead)
- {
- pNewEvent = 0;
- for (pEvent = *pHead; pEvent; pEvent = pEvent->next)
- {
- if (pEvent->client == client)
- break;
- pNewEvent = pEvent;
- }
- if (pEvent)
- {
- FreeResource (pEvent->clientResource, ClientType);
- if (pNewEvent)
- pNewEvent->next = pEvent->next;
- else
- *pHead = pEvent->next;
- free(pEvent);
- updateEventMask (pHead);
- }
- }
+ else if (stuff->mask == 0) {
+ /* delete the interest */
+ if (pHead) {
+ pNewEvent = 0;
+ for (pEvent = *pHead; pEvent; pEvent = pEvent->next) {
+ if (pEvent->client == client)
+ break;
+ pNewEvent = pEvent;
+ }
+ if (pEvent) {
+ FreeResource(pEvent->clientResource, ClientType);
+ if (pNewEvent)
+ pNewEvent->next = pEvent->next;
+ else
+ *pHead = pEvent->next;
+ free(pEvent);
+ updateEventMask(pHead);
+ }
+ }
}
- else
- {
- client->errorValue = stuff->mask;
- return BadValue;
+ else {
+ client->errorValue = stuff->mask;
+ return BadValue;
}
- return Success;
+ return Success;
}
/*
@@ -255,360 +241,350 @@ ProcWindowsWMSelectInput (ClientPtr client)
*/
void
-winWindowsWMSendEvent (int type, unsigned int mask, int which, int arg,
- Window window, int x, int y, int w, int h)
+winWindowsWMSendEvent(int type, unsigned int mask, int which, int arg,
+ Window window, int x, int y, int w, int h)
{
- WMEventPtr *pHead, pEvent;
- ClientPtr client;
- xWindowsWMNotifyEvent se;
- winDebug ("winWindowsWMSendEvent %d %d %d %d, %d %d - %d %d\n",
- type, mask, which, arg, x, y, w, h);
- dixLookupResourceByType((pointer) &pHead, eventResource, eventResourceType,
- NullClient, DixUnknownAccess);
- if (!pHead)
- return;
- for (pEvent = *pHead; pEvent; pEvent = pEvent->next)
- {
- client = pEvent->client;
- winDebug ("winWindowsWMSendEvent - x%08x\n", (int) client);
- if ((pEvent->mask & mask) == 0)
- {
- continue;
- }
- winDebug ("winWindowsWMSendEvent - send\n");
-
- se.type = type + WMEventBase;
- se.kind = which;
- se.window = window;
- se.arg = arg;
- se.x = x;
- se.y = y;
- se.w = w;
- se.h = h;
- se.time = currentTime.milliseconds;
- WriteEventsToClient (client, 1, (xEvent *) &se);
+ WMEventPtr *pHead, pEvent;
+ ClientPtr client;
+ xWindowsWMNotifyEvent se;
+ winDebug ("winWindowsWMSendEvent %d %d %d %d, %d %d - %d %d\n",
+ type, mask, which, arg, x, y, w, h);
+ dixLookupResourceByType((pointer) &pHead, eventResource, eventResourceType,
+ NullClient, DixUnknownAccess);
+ if (!pHead)
+ return;
+ for (pEvent = *pHead; pEvent; pEvent = pEvent->next) {
+ client = pEvent->client;
+ winDebug ("winWindowsWMSendEvent - x%08x\n", (int) client);
+ if ((pEvent->mask & mask) == 0) {
+ continue;
+ }
+ winDebug ("winWindowsWMSendEvent - send\n");
+
+ se.type = type + WMEventBase;
+ se.kind = which;
+ se.window = window;
+ se.arg = arg;
+ se.x = x;
+ se.y = y;
+ se.w = w;
+ se.h = h;
+ se.time = currentTime.milliseconds;
+ WriteEventsToClient(client, 1, (xEvent *) &se);
}
}
/* general utility functions */
static int
-ProcWindowsWMDisableUpdate (ClientPtr client)
+ProcWindowsWMDisableUpdate(ClientPtr client)
{
- REQUEST_SIZE_MATCH(xWindowsWMDisableUpdateReq);
+ REQUEST_SIZE_MATCH(xWindowsWMDisableUpdateReq);
- //winDisableUpdate();
+ //winDisableUpdate();
- return Success;
+ return Success;
}
static int
-ProcWindowsWMReenableUpdate (ClientPtr client)
+ProcWindowsWMReenableUpdate(ClientPtr client)
{
- REQUEST_SIZE_MATCH(xWindowsWMReenableUpdateReq);
+ REQUEST_SIZE_MATCH(xWindowsWMReenableUpdateReq);
- //winEnableUpdate();
+ //winEnableUpdate();
- return Success;
+ return Success;
}
-
/* window functions */
static int
-ProcWindowsWMSetFrontProcess (ClientPtr client)
+ProcWindowsWMSetFrontProcess(ClientPtr client)
{
- REQUEST_SIZE_MATCH(xWindowsWMSetFrontProcessReq);
-
- //QuartzMessageMainThread(kWindowsSetFrontProcess, NULL, 0);
-
- return Success;
-}
+ REQUEST_SIZE_MATCH(xWindowsWMSetFrontProcessReq);
+
+ //QuartzMessageMainThread(kWindowsSetFrontProcess, NULL, 0);
+ return Success;
+}
/* frame functions */
static int
-ProcWindowsWMFrameGetRect (ClientPtr client)
+ProcWindowsWMFrameGetRect(ClientPtr client)
{
- xWindowsWMFrameGetRectReply rep;
- BoxRec ir;
- RECT rcNew;
- REQUEST(xWindowsWMFrameGetRectReq);
+ xWindowsWMFrameGetRectReply rep;
+ BoxRec ir;
+ RECT rcNew;
+
+ REQUEST(xWindowsWMFrameGetRectReq);
winDebug ("ProcWindowsWMFrameGetRect %d %d\n",
- (sizeof(xWindowsWMFrameGetRectReq) >> 2), (int) client->req_len);
-
- REQUEST_SIZE_MATCH(xWindowsWMFrameGetRectReq);
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
-
- ir = make_box (stuff->ix, stuff->iy, stuff->iw, stuff->ih);
-
- if (stuff->frame_rect != 0)
- {
- ErrorF ("ProcWindowsWMFrameGetRect - stuff->frame_rect != 0\n");
- return BadValue;
+ (sizeof(xWindowsWMFrameGetRectReq) >> 2), (int) client->req_len);
+
+ REQUEST_SIZE_MATCH(xWindowsWMFrameGetRectReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ ir = make_box(stuff->ix, stuff->iy, stuff->iw, stuff->ih);
+
+ if (stuff->frame_rect != 0) {
+ ErrorF("ProcWindowsWMFrameGetRect - stuff->frame_rect != 0\n");
+ return BadValue;
}
- /* Store the origin, height, and width in a rectangle structure */
- SetRect (&rcNew, stuff->ix, stuff->iy,
- stuff->ix + stuff->iw, stuff->iy + stuff->ih);
-
- winDebug ("ProcWindowsWMFrameGetRect - %d %d %d %d\n",
- stuff->ix, stuff->iy, stuff->ix + stuff->iw, stuff->iy + stuff->ih);
-
- /*
- * Calculate the required size of the Windows window rectangle,
- * given the size of the Windows window client area.
- */
- AdjustWindowRectEx (&rcNew, stuff->frame_style, FALSE, stuff->frame_style_ex);
- rep.x = rcNew.left;
- rep.y = rcNew.top;
- rep.w = rcNew.right - rcNew.left;
- rep.h = rcNew.bottom - rcNew.top;
- winDebug ("ProcWindowsWMFrameGetRect - %d %d %d %d\n",
- rep.x, rep.y, rep.w, rep.h);
-
- WriteToClient(client, sizeof(xWindowsWMFrameGetRectReply), (char *)&rep);
- return Success;
+ /* Store the origin, height, and width in a rectangle structure */
+ SetRect(&rcNew, stuff->ix, stuff->iy,
+ stuff->ix + stuff->iw, stuff->iy + stuff->ih);
+
+ winDebug ("ProcWindowsWMFrameGetRect - %d %d %d %d\n",
+ stuff->ix, stuff->iy, stuff->ix + stuff->iw, stuff->iy + stuff->ih);
+
+ /*
+ * Calculate the required size of the Windows window rectangle,
+ * given the size of the Windows window client area.
+ */
+ AdjustWindowRectEx(&rcNew, stuff->frame_style, FALSE,
+ stuff->frame_style_ex);
+ rep.x = rcNew.left;
+ rep.y = rcNew.top;
+ rep.w = rcNew.right - rcNew.left;
+ rep.h = rcNew.bottom - rcNew.top;
+ winDebug ("ProcWindowsWMFrameGetRect - %d %d %d %d\n",
+ rep.x, rep.y, rep.w, rep.h);
+
+ WriteToClient(client, sizeof(xWindowsWMFrameGetRectReply), (char *) &rep);
+ return Success;
}
-
static int
-ProcWindowsWMFrameDraw (ClientPtr client)
+ProcWindowsWMFrameDraw(ClientPtr client)
{
- REQUEST(xWindowsWMFrameDrawReq);
- WindowPtr pWin;
- win32RootlessWindowPtr pRLWinPriv;
- RECT rcNew;
- int nCmdShow, rc;
- RegionRec newShape;
-
- REQUEST_SIZE_MATCH (xWindowsWMFrameDrawReq);
-
- winDebug ("ProcWindowsWMFrameDraw\n");
-
- rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess);
- if (rc != Success)
- return rc;
-
- winDebug ("ProcWindowsWMFrameDraw - Window found\n");
-
- pRLWinPriv = (win32RootlessWindowPtr) RootlessFrameForWindow (pWin, TRUE);
- if (pRLWinPriv == 0) return BadWindow;
-
- winDebug ("ProcWindowsWMFrameDraw - HWND 0x%08x 0x%08x 0x%08x\n",
- (int) pRLWinPriv->hWnd, (int) stuff->frame_style,
- (int) stuff->frame_style_ex);
- winDebug ("ProcWindowsWMFrameDraw - %d %d %d %d\n",
- stuff->ix, stuff->iy, stuff->iw, stuff->ih);
-
- /* Store the origin, height, and width in a rectangle structure */
- SetRect (&rcNew, stuff->ix, stuff->iy,
- stuff->ix + stuff->iw, stuff->iy + stuff->ih);
-
- /*
- * Calculate the required size of the Windows window rectangle,
- * given the size of the Windows window client area.
- */
- AdjustWindowRectEx (&rcNew, stuff->frame_style, FALSE, stuff->frame_style_ex);
-
- /* Set the window extended style flags */
- if (!SetWindowLongPtr (pRLWinPriv->hWnd, GWL_EXSTYLE, stuff->frame_style_ex))
- {
- return BadValue;
+ REQUEST(xWindowsWMFrameDrawReq);
+ WindowPtr pWin;
+ win32RootlessWindowPtr pRLWinPriv;
+ RECT rcNew;
+ int nCmdShow, rc;
+ RegionRec newShape;
+
+ REQUEST_SIZE_MATCH(xWindowsWMFrameDrawReq);
+
+ winDebug ("ProcWindowsWMFrameDraw\n");
+
+ rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess);
+ if (rc != Success)
+ return rc;
+
+ winDebug ("ProcWindowsWMFrameDraw - Window found\n");
+
+ pRLWinPriv = (win32RootlessWindowPtr) RootlessFrameForWindow(pWin, TRUE);
+ if (pRLWinPriv == 0)
+ return BadWindow;
+
+ winDebug ("ProcWindowsWMFrameDraw - HWND 0x%08x 0x%08x 0x%08x\n",
+ (int) pRLWinPriv->hWnd, (int) stuff->frame_style,
+ (int) stuff->frame_style_ex);
+ winDebug ("ProcWindowsWMFrameDraw - %d %d %d %d\n",
+ stuff->ix, stuff->iy, stuff->iw, stuff->ih);
+
+ /* Store the origin, height, and width in a rectangle structure */
+ SetRect(&rcNew, stuff->ix, stuff->iy,
+ stuff->ix + stuff->iw, stuff->iy + stuff->ih);
+
+ /*
+ * Calculate the required size of the Windows window rectangle,
+ * given the size of the Windows window client area.
+ */
+ AdjustWindowRectEx(&rcNew, stuff->frame_style, FALSE,
+ stuff->frame_style_ex);
+
+ /* Set the window extended style flags */
+ if (!SetWindowLongPtr(pRLWinPriv->hWnd, GWL_EXSTYLE, stuff->frame_style_ex)) {
+ return BadValue;
}
- /* Set the window standard style flags */
- if (!SetWindowLongPtr (pRLWinPriv->hWnd, GWL_STYLE, stuff->frame_style))
- {
- return BadValue;
+ /* Set the window standard style flags */
+ if (!SetWindowLongPtr(pRLWinPriv->hWnd, GWL_STYLE, stuff->frame_style)) {
+ return BadValue;
}
- /* Flush the window style */
- if (!SetWindowPos (pRLWinPriv->hWnd, NULL,
- rcNew.left, rcNew.top,
- rcNew.right - rcNew.left, rcNew.bottom - rcNew.top,
- SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOACTIVATE))
- {
- return BadValue;
+ /* Flush the window style */
+ if (!SetWindowPos(pRLWinPriv->hWnd, NULL,
+ rcNew.left, rcNew.top,
+ rcNew.right - rcNew.left, rcNew.bottom - rcNew.top,
+ SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOACTIVATE)) {
+ return BadValue;
}
- if (!IsWindowVisible(pRLWinPriv->hWnd))
- nCmdShow = SW_HIDE;
- else
- nCmdShow = SW_SHOWNA;
-
- ShowWindow (pRLWinPriv->hWnd, nCmdShow);
-
- winMWExtWMUpdateIcon (pWin->drawable.id);
-
- if (wBoundingShape(pWin) != NULL)
- {
- /* wBoundingShape is relative to *inner* origin of window.
- Translate by borderWidth to get the outside-relative position. */
-
- RegionNull(&newShape);
- RegionCopy(&newShape, wBoundingShape(pWin));
- RegionTranslate(&newShape, pWin->borderWidth, pWin->borderWidth);
- winMWExtWMReshapeFrame (pRLWinPriv, &newShape);
- RegionUninit(&newShape);
+ if (!IsWindowVisible(pRLWinPriv->hWnd))
+ nCmdShow = SW_HIDE;
+ else
+ nCmdShow = SW_SHOWNA;
+
+ ShowWindow(pRLWinPriv->hWnd, nCmdShow);
+
+ winMWExtWMUpdateIcon(pWin->drawable.id);
+
+ if (wBoundingShape(pWin) != NULL) {
+ /* wBoundingShape is relative to *inner* origin of window.
+ Translate by borderWidth to get the outside-relative position. */
+
+ RegionNull(&newShape);
+ RegionCopy(&newShape, wBoundingShape(pWin));
+ RegionTranslate(&newShape, pWin->borderWidth, pWin->borderWidth);
+ winMWExtWMReshapeFrame(pRLWinPriv, &newShape);
+ RegionUninit(&newShape);
}
- winDebug ("ProcWindowsWMFrameDraw - done\n");
+ winDebug ("ProcWindowsWMFrameDraw - done\n");
- return Success;
+ return Success;
}
static int
ProcWindowsWMFrameSetTitle(ClientPtr client)
{
- unsigned int title_length, title_max;
- char *title_bytes;
- REQUEST(xWindowsWMFrameSetTitleReq);
- WindowPtr pWin;
- win32RootlessWindowPtr pRLWinPriv;
- int rc;
+ unsigned int title_length, title_max;
+ char *title_bytes;
+
+ REQUEST(xWindowsWMFrameSetTitleReq);
+ WindowPtr pWin;
+ win32RootlessWindowPtr pRLWinPriv;
+ int rc;
- winDebug ("ProcWindowsWMFrameSetTitle\n");
+ winDebug ("ProcWindowsWMFrameSetTitle\n");
- REQUEST_AT_LEAST_SIZE(xWindowsWMFrameSetTitleReq);
+ REQUEST_AT_LEAST_SIZE(xWindowsWMFrameSetTitleReq);
- rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess);
- if (rc != Success)
- return rc;
- winDebug ("ProcWindowsWMFrameSetTitle - Window found\n");
+ rc = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess);
+ if (rc != Success)
+ return rc;
+ winDebug ("ProcWindowsWMFrameSetTitle - Window found\n");
- title_length = stuff->title_length;
- title_max = (stuff->length << 2) - sizeof(xWindowsWMFrameSetTitleReq);
+ title_length = stuff->title_length;
+ title_max = (stuff->length << 2) - sizeof(xWindowsWMFrameSetTitleReq);
- if (title_max < title_length)
- return BadValue;
+ if (title_max < title_length)
+ return BadValue;
- winDebug ("ProcWindowsWMFrameSetTitle - length is valid\n");
+ winDebug ("ProcWindowsWMFrameSetTitle - length is valid\n");
- title_bytes = malloc (title_length+1);
- strncpy (title_bytes, (unsigned char *) &stuff[1], title_length);
- title_bytes[title_length] = '\0';
+ title_bytes = malloc(title_length + 1);
+ strncpy(title_bytes, (unsigned char *) &stuff[1], title_length);
+ title_bytes[title_length] = '\0';
- pRLWinPriv = (win32RootlessWindowPtr) RootlessFrameForWindow (pWin, FALSE);
+ pRLWinPriv = (win32RootlessWindowPtr) RootlessFrameForWindow(pWin, FALSE);
- if (pRLWinPriv == 0)
- {
- free (title_bytes);
- return BadWindow;
+ if (pRLWinPriv == 0) {
+ free(title_bytes);
+ return BadWindow;
}
-
- /* Flush the window style */
- SetWindowText (pRLWinPriv->hWnd, title_bytes);
- free (title_bytes);
+ /* Flush the window style */
+ SetWindowText(pRLWinPriv->hWnd, title_bytes);
- winDebug ("ProcWindowsWMFrameSetTitle - done\n");
+ free(title_bytes);
- return Success;
-}
+ winDebug ("ProcWindowsWMFrameSetTitle - done\n");
+ return Success;
+}
/* dispatch */
static int
-ProcWindowsWMDispatch (ClientPtr client)
+ProcWindowsWMDispatch(ClientPtr client)
{
- REQUEST(xReq);
+ REQUEST(xReq);
- switch (stuff->data)
- {
+ switch (stuff->data) {
case X_WindowsWMQueryVersion:
- return ProcWindowsWMQueryVersion(client);
+ return ProcWindowsWMQueryVersion(client);
}
- if (!LocalClient(client))
- return WMErrorBase + WindowsWMClientNotLocal;
+ if (!LocalClient(client))
+ return WMErrorBase + WindowsWMClientNotLocal;
- switch (stuff->data)
- {
+ switch (stuff->data) {
case X_WindowsWMSelectInput:
- return ProcWindowsWMSelectInput(client);
+ return ProcWindowsWMSelectInput(client);
case X_WindowsWMDisableUpdate:
- return ProcWindowsWMDisableUpdate(client);
+ return ProcWindowsWMDisableUpdate(client);
case X_WindowsWMReenableUpdate:
- return ProcWindowsWMReenableUpdate(client);
+ return ProcWindowsWMReenableUpdate(client);
case X_WindowsWMSetFrontProcess:
- return ProcWindowsWMSetFrontProcess(client);
+ return ProcWindowsWMSetFrontProcess(client);
case X_WindowsWMFrameGetRect:
- return ProcWindowsWMFrameGetRect(client);
+ return ProcWindowsWMFrameGetRect(client);
case X_WindowsWMFrameDraw:
- return ProcWindowsWMFrameDraw(client);
+ return ProcWindowsWMFrameDraw(client);
case X_WindowsWMFrameSetTitle:
- return ProcWindowsWMFrameSetTitle(client);
+ return ProcWindowsWMFrameSetTitle(client);
default:
- return BadRequest;
+ return BadRequest;
}
}
static void
-SNotifyEvent (xWindowsWMNotifyEvent *from, xWindowsWMNotifyEvent *to)
+SNotifyEvent(xWindowsWMNotifyEvent * from, xWindowsWMNotifyEvent * to)
{
- to->type = from->type;
- to->kind = from->kind;
- cpswaps (from->sequenceNumber, to->sequenceNumber);
- cpswapl (from->window, to->window);
- cpswapl (from->time, to->time);
- cpswapl (from->arg, to->arg);
+ to->type = from->type;
+ to->kind = from->kind;
+ cpswaps(from->sequenceNumber, to->sequenceNumber);
+ cpswapl(from->window, to->window);
+ cpswapl(from->time, to->time);
+ cpswapl(from->arg, to->arg);
}
static int
-SProcWindowsWMQueryVersion (ClientPtr client)
+SProcWindowsWMQueryVersion(ClientPtr client)
{
- int n;
- REQUEST(xWindowsWMQueryVersionReq);
- swaps(&stuff->length);
- return ProcWindowsWMQueryVersion(client);
+ int n;
+
+ REQUEST(xWindowsWMQueryVersionReq);
+ swaps(&stuff->length);
+ return ProcWindowsWMQueryVersion(client);
}
static int
-SProcWindowsWMDispatch (ClientPtr client)
+SProcWindowsWMDispatch(ClientPtr client)
{
- REQUEST(xReq);
+ REQUEST(xReq);
- /* It is bound to be non-local when there is byte swapping */
- if (!LocalClient(client))
- return WMErrorBase + WindowsWMClientNotLocal;
+ /* It is bound to be non-local when there is byte swapping */
+ if (!LocalClient(client))
+ return WMErrorBase + WindowsWMClientNotLocal;
- /* only local clients are allowed WM access */
- switch (stuff->data)
- {
+ /* only local clients are allowed WM access */
+ switch (stuff->data) {
case X_WindowsWMQueryVersion:
- return SProcWindowsWMQueryVersion(client);
+ return SProcWindowsWMQueryVersion(client);
default:
- return BadRequest;
+ return BadRequest;
}
}
void
-winWindowsWMExtensionInit (void)
+winWindowsWMExtensionInit(void)
{
- ExtensionEntry* extEntry;
-
- ClientType = CreateNewResourceType(WMFreeClient, "WMClient");
- eventResourceType = CreateNewResourceType(WMFreeEvents, "WMEvent");
- eventResource = FakeClientID(0);
-
- if (ClientType && eventResourceType &&
- (extEntry = AddExtension(WINDOWSWMNAME,
- WindowsWMNumberEvents,
- WindowsWMNumberErrors,
- ProcWindowsWMDispatch,
- SProcWindowsWMDispatch,
- NULL,
- StandardMinorOpcode)))
- {
- size_t i;
- WMReqCode = (unsigned char)extEntry->base;
- WMErrorBase = extEntry->errorBase;
- WMEventBase = extEntry->eventBase;
- for (i=0; i < WindowsWMNumberEvents; i++)
- EventSwapVector[WMEventBase + i] = (EventSwapPtr) SNotifyEvent;
+ ExtensionEntry *extEntry;
+
+ ClientType = CreateNewResourceType(WMFreeClient, "WMClient");
+ eventResourceType = CreateNewResourceType(WMFreeEvents, "WMEvent");
+ eventResource = FakeClientID(0);
+
+ if (ClientType && eventResourceType &&
+ (extEntry = AddExtension(WINDOWSWMNAME,
+ WindowsWMNumberEvents,
+ WindowsWMNumberErrors,
+ ProcWindowsWMDispatch,
+ SProcWindowsWMDispatch,
+ NULL, StandardMinorOpcode))) {
+ size_t i;
+
+ WMReqCode = (unsigned char) extEntry->base;
+ WMErrorBase = extEntry->errorBase;
+ WMEventBase = extEntry->eventBase;
+ for (i = 0; i < WindowsWMNumberEvents; i++)
+ EventSwapVector[WMEventBase + i] = (EventSwapPtr) SNotifyEvent;
}
}
diff --git a/xorg-server/hw/xwin/winwndproc.c b/xorg-server/hw/xwin/winwndproc.c
index 41ce51cec..77a3a76ba 100644
--- a/xorg-server/hw/xwin/winwndproc.c
+++ b/xorg-server/hw/xwin/winwndproc.c
@@ -53,9 +53,8 @@
*/
extern Bool g_fClipboardStarted;
-Bool g_fCursor = TRUE;
-Bool g_fButton[3] = { FALSE, FALSE, FALSE };
-
+Bool g_fCursor = TRUE;
+Bool g_fButton[3] = { FALSE, FALSE, FALSE };
/*
* Called by winWakeupHandler
@@ -63,1254 +62,1206 @@ Bool g_fButton[3] = { FALSE, FALSE, FALSE };
*/
LRESULT CALLBACK
-winWindowProc (HWND hwnd, UINT message,
- WPARAM wParam, LPARAM lParam)
+winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- static winPrivScreenPtr s_pScreenPriv = NULL;
- static winScreenInfo *s_pScreenInfo = NULL;
- static ScreenPtr s_pScreen = NULL;
- static HWND s_hwndLastPrivates = NULL;
- static HINSTANCE s_hInstance;
- static Bool s_fTracking = FALSE;
- static unsigned long s_ulServerGeneration = 0;
- static UINT s_uTaskbarRestart = 0;
- int iScanCode;
- int i;
-
- winDebugWin32Message("winWindowProc", hwnd, message, wParam, lParam);
-
- /* Watch for server regeneration */
- if (g_ulServerGeneration != s_ulServerGeneration)
- {
- /* Store new server generation */
- s_ulServerGeneration = g_ulServerGeneration;
+ static winPrivScreenPtr s_pScreenPriv = NULL;
+ static winScreenInfo *s_pScreenInfo = NULL;
+ static ScreenPtr s_pScreen = NULL;
+ static HWND s_hwndLastPrivates = NULL;
+ static HINSTANCE s_hInstance;
+ static Bool s_fTracking = FALSE;
+ static unsigned long s_ulServerGeneration = 0;
+ static UINT s_uTaskbarRestart = 0;
+ int iScanCode;
+ int i;
+
+ winDebugWin32Message("winWindowProc", hwnd, message, wParam, lParam);
+
+ /* Watch for server regeneration */
+ if (g_ulServerGeneration != s_ulServerGeneration) {
+ /* Store new server generation */
+ s_ulServerGeneration = g_ulServerGeneration;
}
- /* Only retrieve new privates pointers if window handle is null or changed */
- if ((s_pScreenPriv == NULL || hwnd != s_hwndLastPrivates)
- && (s_pScreenPriv = GetProp (hwnd, WIN_SCR_PROP)) != NULL)
- {
- winDebug ("winWindowProc - Setting privates handle\n");
- s_pScreenInfo = s_pScreenPriv->pScreenInfo;
- s_pScreen = s_pScreenInfo->pScreen;
- s_hwndLastPrivates = hwnd;
+ /* Only retrieve new privates pointers if window handle is null or changed */
+ if ((s_pScreenPriv == NULL || hwnd != s_hwndLastPrivates)
+ && (s_pScreenPriv = GetProp(hwnd, WIN_SCR_PROP)) != NULL) {
+ winDebug("winWindowProc - Setting privates handle\n");
+ s_pScreenInfo = s_pScreenPriv->pScreenInfo;
+ s_pScreen = s_pScreenInfo->pScreen;
+ s_hwndLastPrivates = hwnd;
}
- else if (s_pScreenPriv == NULL)
- {
- /* For safety, handle case that should never happen */
- s_pScreenInfo = NULL;
- s_pScreen = NULL;
- s_hwndLastPrivates = NULL;
+ else if (s_pScreenPriv == NULL) {
+ /* For safety, handle case that should never happen */
+ s_pScreenInfo = NULL;
+ s_pScreen = NULL;
+ s_hwndLastPrivates = NULL;
}
- /* Branch on message type */
- switch (message)
- {
+ /* Branch on message type */
+ switch (message) {
case WM_TRAYICON:
- return winHandleIconMessage (hwnd, message, wParam, lParam,
- s_pScreenPriv);
+ return winHandleIconMessage(hwnd, message, wParam, lParam,
+ s_pScreenPriv);
case WM_CREATE:
- winDebug ("winWindowProc - WM_CREATE\n");
-
- /*
- * Add a property to our display window that references
- * this screens' privates.
- *
- * This allows the window procedure to refer to the
- * appropriate window DC and shadow DC for the window that
- * it is processing. We use this to repaint exposed
- * areas of our display window.
- */
- s_pScreenPriv = ((LPCREATESTRUCT) lParam)->lpCreateParams;
- s_hInstance = ((LPCREATESTRUCT) lParam)->hInstance;
- s_pScreenInfo = s_pScreenPriv->pScreenInfo;
- s_pScreen = s_pScreenInfo->pScreen;
- s_hwndLastPrivates = hwnd;
- s_uTaskbarRestart = RegisterWindowMessage(TEXT("TaskbarCreated"));
- SetProp (hwnd, WIN_SCR_PROP, s_pScreenPriv);
-
- /* Setup tray icon */
- if (!s_pScreenInfo->fNoTrayIcon)
- {
- /*
- * NOTE: The WM_CREATE message is processed before CreateWindowEx
- * returns, so s_pScreenPriv->hwndScreen is invalid at this point.
- * We go ahead and copy our hwnd parameter over top of the screen
- * privates hwndScreen so that we have a valid value for
- * that member. Otherwise, the tray icon will disappear
- * the first time you move the mouse over top of it.
- */
-
- s_pScreenPriv->hwndScreen = hwnd;
-
- winInitNotifyIcon (s_pScreenPriv,FALSE);
- }
- return 0;
+ winDebug("winWindowProc - WM_CREATE\n");
+
+ /*
+ * Add a property to our display window that references
+ * this screens' privates.
+ *
+ * This allows the window procedure to refer to the
+ * appropriate window DC and shadow DC for the window that
+ * it is processing. We use this to repaint exposed
+ * areas of our display window.
+ */
+ s_pScreenPriv = ((LPCREATESTRUCT) lParam)->lpCreateParams;
+ s_hInstance = ((LPCREATESTRUCT) lParam)->hInstance;
+ s_pScreenInfo = s_pScreenPriv->pScreenInfo;
+ s_pScreen = s_pScreenInfo->pScreen;
+ s_hwndLastPrivates = hwnd;
+ s_uTaskbarRestart = RegisterWindowMessage(TEXT("TaskbarCreated"));
+ SetProp(hwnd, WIN_SCR_PROP, s_pScreenPriv);
+
+ /* Setup tray icon */
+ if (!s_pScreenInfo->fNoTrayIcon) {
+ /*
+ * NOTE: The WM_CREATE message is processed before CreateWindowEx
+ * returns, so s_pScreenPriv->hwndScreen is invalid at this point.
+ * We go ahead and copy our hwnd parameter over top of the screen
+ * privates hwndScreen so that we have a valid value for
+ * that member. Otherwise, the tray icon will disappear
+ * the first time you move the mouse over top of it.
+ */
+
+ s_pScreenPriv->hwndScreen = hwnd;
+
+ winInitNotifyIcon (s_pScreenPriv,FALSE);
+ }
+ return 0;
case WM_DISPLAYCHANGE:
- /*
- WM_DISPLAYCHANGE seems to be sent when the monitor layout or
- any monitor's resolution or depth changes, but it's lParam and
- wParam always indicate the resolution and bpp for the primary
- monitor (so ignore that as we could be on any monitor...)
- */
-
- /* We cannot handle a display mode change during initialization */
- if (s_pScreenInfo == NULL)
- FatalError ("winWindowProc - WM_DISPLAYCHANGE - The display "
- "mode changed while we were intializing. This is "
- "very bad and unexpected. Exiting.\n");
-
- /*
- * We do not care about display changes with
- * fullscreen DirectDraw engines, because those engines set
- * their own mode when they become active.
- */
- if (s_pScreenInfo->fFullScreen
- && (s_pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DD
- || s_pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL
+ /*
+ WM_DISPLAYCHANGE seems to be sent when the monitor layout or
+ any monitor's resolution or depth changes, but it's lParam and
+ wParam always indicate the resolution and bpp for the primary
+ monitor (so ignore that as we could be on any monitor...)
+ */
+
+ /* We cannot handle a display mode change during initialization */
+ if (s_pScreenInfo == NULL)
+ FatalError("winWindowProc - WM_DISPLAYCHANGE - The display "
+ "mode changed while we were intializing. This is "
+ "very bad and unexpected. Exiting.\n");
+
+ /*
+ * We do not care about display changes with
+ * fullscreen DirectDraw engines, because those engines set
+ * their own mode when they become active.
+ */
+ if (s_pScreenInfo->fFullScreen
+ && (s_pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DD
+ || s_pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL
#ifdef XWIN_PRIMARYFB
- || s_pScreenInfo->dwEngine == WIN_SERVER_PRIMARY_DD
+ || s_pScreenInfo->dwEngine == WIN_SERVER_PRIMARY_DD
#endif
- ))
- {
- break;
- }
+ )) {
+ break;
+ }
- winDebug ("winWindowProc - WM_DISPLAYCHANGE - new width: %d "
- "new height: %d new bpp: %d\n",
- LOWORD (lParam), HIWORD (lParam), wParam);
+ winDebug ("winWindowProc - WM_DISPLAYCHANGE - new width: %d "
+ "new height: %d new bpp: %d\n",
+ LOWORD(lParam), HIWORD(lParam), wParam);
- /* 0 bpp has no defined meaning, ignore this message */
- if (wParam == 0)
- break;
+ /* 0 bpp has no defined meaning, ignore this message */
+ if (wParam == 0)
+ break;
- /*
- * Check for a disruptive change in depth.
- * We can only display a message for a disruptive depth change,
- * we cannot do anything to correct the situation.
- */
- /*
- XXX: maybe we need to check if GetSystemMetrics(SM_SAMEDISPLAYFORMAT)
- has changed as well...
- */
- if (s_pScreenInfo->dwBPP != GetDeviceCaps (s_pScreenPriv->hdcScreen, BITSPIXEL))
- {
- if ((s_pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DD
- || s_pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL
+ /*
+ * Check for a disruptive change in depth.
+ * We can only display a message for a disruptive depth change,
+ * we cannot do anything to correct the situation.
+ */
+ /*
+ XXX: maybe we need to check if GetSystemMetrics(SM_SAMEDISPLAYFORMAT)
+ has changed as well...
+ */
+ if (s_pScreenInfo->dwBPP !=
+ GetDeviceCaps(s_pScreenPriv->hdcScreen, BITSPIXEL)) {
+ if ((s_pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DD ||
+ s_pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL
#ifdef XWIN_PRIMARYFB
- || s_pScreenInfo->dwEngine == WIN_SERVER_PRIMARY_DD
+ || s_pScreenInfo->dwEngine == WIN_SERVER_PRIMARY_DD
#endif
- ))
- {
- /* Cannot display the visual until the depth is restored */
- winDebug ("winWindowProc - Disruptive change in depth\n");
+ )) {
+ /* Cannot display the visual until the depth is restored */
+ winDebug ("winWindowProc - Disruptive change in depth\n");
- /* Display depth change dialog */
- winDisplayDepthChangeDialog (s_pScreenPriv);
+ /* Display depth change dialog */
+ winDisplayDepthChangeDialog(s_pScreenPriv);
- /* Flag that we have an invalid screen depth */
- s_pScreenPriv->fBadDepth = TRUE;
+ /* Flag that we have an invalid screen depth */
+ s_pScreenPriv->fBadDepth = TRUE;
- /* Minimize the display window */
- ShowWindow (hwnd, SW_MINIMIZE);
+ /* Minimize the display window */
+ ShowWindow(hwnd, SW_MINIMIZE);
}
- else
- {
- /* For GDI, performance may suffer until original depth is restored */
- ErrorF ("winWindowProc - Performance may be non-optimal after change in depth\n");
+ else {
+ /* For GDI, performance may suffer until original depth is restored */
+ ErrorF
+ ("winWindowProc - Performance may be non-optimal after change in depth\n");
}
}
- else
- {
- /* Flag that we have a valid screen depth */
- s_pScreenPriv->fBadDepth = FALSE;
+ else {
+ /* Flag that we have a valid screen depth */
+ s_pScreenPriv->fBadDepth = FALSE;
}
- /*
- If we could cheaply check if this WM_DISPLAYCHANGE change
- affects the monitor(s) which this X screen is displayed on
- then we should do so here. For the moment, assume it does.
- (this is probably usually the case so that might be an
- overoptimization)
- */
- {
- /*
- In rootless modes which are monitor or virtual desktop size
- use RandR to resize the X screen
- */
- if ((!s_pScreenInfo->fUserGaveHeightAndWidth) &&
- (s_pScreenInfo->iResizeMode == resizeWithRandr) &&
- (FALSE
+ /*
+ If we could cheaply check if this WM_DISPLAYCHANGE change
+ affects the monitor(s) which this X screen is displayed on
+ then we should do so here. For the moment, assume it does.
+ (this is probably usually the case so that might be an
+ overoptimization)
+ */
+ {
+ /*
+ In rootless modes which are monitor or virtual desktop size
+ use RandR to resize the X screen
+ */
+ if ((!s_pScreenInfo->fUserGaveHeightAndWidth) &&
+ (s_pScreenInfo->iResizeMode == resizeWithRandr) && (FALSE
#ifdef XWIN_MULTIWINDOWEXTWM
- || s_pScreenInfo->fMWExtWM
+ ||
+ s_pScreenInfo->
+ fMWExtWM
#endif
- || s_pScreenInfo->fRootless
+ ||
+ s_pScreenInfo->
+ fRootless
#ifdef XWIN_MULTIWINDOW
- || s_pScreenInfo->fMultiWindow
+ ||
+ s_pScreenInfo->
+ fMultiWindow
#endif
- ))
- {
- DWORD dwWidth = 0, dwHeight = 0;
+ )) {
+ DWORD dwWidth = 0, dwHeight = 0;
- if (s_pScreenInfo->fMultipleMonitors)
- {
- /* resize to new virtual desktop size */
- dwWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN);
- dwHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN);
+ if (s_pScreenInfo->fMultipleMonitors) {
+ /* resize to new virtual desktop size */
+ dwWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN);
+ dwHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN);
}
- else
- {
- /* resize to new size of specified monitor */
- struct GetMonitorInfoData data;
- if (QueryMonitor(s_pScreenInfo->iMonitor, &data))
- {
- if (data.bMonitorSpecifiedExists == TRUE)
- {
- dwWidth = data.monitorWidth;
- dwHeight = data.monitorHeight;
- /*
- XXX: monitor may have changed position,
- so we might need to update xinerama data
- */
+ else {
+ /* resize to new size of specified monitor */
+ struct GetMonitorInfoData data;
+
+ if (QueryMonitor(s_pScreenInfo->iMonitor, &data)) {
+ if (data.bMonitorSpecifiedExists == TRUE) {
+ dwWidth = data.monitorWidth;
+ dwHeight = data.monitorHeight;
+ /*
+ XXX: monitor may have changed position,
+ so we might need to update xinerama data
+ */
}
- else
- {
- ErrorF ("Monitor number %d no longer exists!\n", s_pScreenInfo->iMonitor);
+ else {
+ ErrorF("Monitor number %d no longer exists!\n",
+ s_pScreenInfo->iMonitor);
}
}
}
- /*
- XXX: probably a small bug here: we don't compute the work area
- and allow for task bar
-
- XXX: generally, we don't allow for the task bar being moved after
- the server is started
- */
-
- /* Set screen size to match new size, if it is different to current */
- if ((s_pScreenInfo->dwWidth != dwWidth) ||
- (s_pScreenInfo->dwHeight != dwHeight))
+ /*
+ XXX: probably a small bug here: we don't compute the work area
+ and allow for task bar
+
+ XXX: generally, we don't allow for the task bar being moved after
+ the server is started
+ */
+
+ /* Set screen size to match new size, if it is different to current */
+ if ((s_pScreenInfo->dwWidth != dwWidth) ||
+ (s_pScreenInfo->dwHeight != dwHeight)) {
+ winDoRandRScreenSetSize(s_pScreen,
+ dwWidth,
+ dwHeight,
+ (dwWidth * 25.4) /
+ monitorResolution,
+ (dwHeight * 25.4) /
+ monitorResolution);
+ }
+ }
+ else {
+ /*
+ * We can simply recreate the same-sized primary surface when
+ * the display dimensions change.
+ */
+
+ /*
+ * NOTE: The non-DirectDraw engines set the ReleasePrimarySurface
+ * and CreatePrimarySurface function pointers to point
+ * to the no operation function, NoopDDA. This allows us
+ * to blindly call these functions, even if they are not
+ * relevant to the current engine (e.g., Shadow GDI).
+ */
+
+ winDebug
+ ("winWindowProc - WM_DISPLAYCHANGE - Releasing and recreating primary surface\n");
+
+ /* Reallocate the framebuffer used by the drawing engine */
+ (*s_pScreenPriv->pwinFreeFB)(s_pScreen);
+ if (!(*s_pScreenPriv->pwinAllocateFB)(s_pScreen))
{
- winDoRandRScreenSetSize(s_pScreen,
- dwWidth,
- dwHeight,
- (dwWidth * 25.4) / monitorResolution,
- (dwHeight * 25.4) / monitorResolution);
+ ErrorF ("winWindowProc - WM_DISPLAYCHANGE - Could not reallocate framebuffer\n");
}
- }
- else
- {
- /*
- * We can simply recreate the same-sized primary surface when
- * the display dimensions change.
- */
-
- /*
- * NOTE: The non-DirectDraw engines set the ReleasePrimarySurface
- * and CreatePrimarySurface function pointers to point
- * to the no operation function, NoopDDA. This allows us
- * to blindly call these functions, even if they are not
- * relevant to the current engine (e.g., Shadow GDI).
- */
-
- winDebug ("winWindowProc - WM_DISPLAYCHANGE - Releasing and recreating primary surface\n");
-
- /* Reallocate the framebuffer used by the drawing engine */
- (*s_pScreenPriv->pwinFreeFB)(s_pScreen);
- if (!(*s_pScreenPriv->pwinAllocateFB)(s_pScreen))
- {
- ErrorF ("winWindowProc - WM_DISPLAYCHANGE - Could not reallocate framebuffer\n");
- }
- /* Update the screen pixmap to point to the new framebuffer */
- winUpdateFBPointer(s_pScreen, s_pScreenPriv->pScreenInfo->pfb);
- // Restore the ability to update screen, now with new dimensions
- SetRootClip(s_pScreen, TRUE);
-
- // and arrange for it to be repainted
- miPaintWindow(s_pScreen->root, &s_pScreen->root->borderClip, PW_BACKGROUND);
+ /* Update the screen pixmap to point to the new framebuffer */
+ winUpdateFBPointer(s_pScreen, s_pScreenPriv->pScreenInfo->pfb);
+ // Restore the ability to update screen, now with new dimensions
+ SetRootClip(s_pScreen, TRUE);
+
+ // and arrange for it to be repainted
+ miPaintWindow(s_pScreen->root, &s_pScreen->root->borderClip, PW_BACKGROUND);
}
- }
+ }
- break;
+ break;
- case WM_SYSCOMMAND:
- if (wParam == SC_MAXIMIZE||wParam == SC_RESTORE)
- {
- winDebug("Posting WM_EXITSIZEMOVE message since windows does not send it when the maximised/restored button is clicked.\n");
- PostMessage(hwnd, WM_EXITSIZEMOVE, 0, 0);
- }
- break;
+ case WM_SYSCOMMAND:
+ if (wParam == SC_MAXIMIZE||wParam == SC_RESTORE)
+ {
+ winDebug("Posting WM_EXITSIZEMOVE message since windows does not send it when the maximised/restored button is clicked.\n");
+ PostMessage(hwnd, WM_EXITSIZEMOVE, 0, 0);
+ }
+ break;
case WM_SIZE:
- {
- SCROLLINFO si;
- RECT rcWindow;
- int iWidth, iHeight;
+ {
+ SCROLLINFO si;
+ RECT rcWindow;
+ int iWidth, iHeight;
- winDebug ("winWindowProc - WM_SIZE\n");
+ winDebug("winWindowProc - WM_SIZE\n");
- /* Break if we do not allow resizing */
- if ((s_pScreenInfo->iResizeMode == notAllowed)
- || !s_pScreenInfo->fDecoration
+ /* Break if we do not allow resizing */
+ if ((s_pScreenInfo->iResizeMode == notAllowed)
+ || !s_pScreenInfo->fDecoration
#ifdef XWIN_MULTIWINDOWEXTWM
- || s_pScreenInfo->fMWExtWM
+ || s_pScreenInfo->fMWExtWM
#endif
- || s_pScreenInfo->fRootless
+ || s_pScreenInfo->fRootless
#ifdef XWIN_MULTIWINDOW
- || s_pScreenInfo->fMultiWindow
+ || s_pScreenInfo->fMultiWindow
#endif
- || s_pScreenInfo->fFullScreen)
- break;
+ || s_pScreenInfo->fFullScreen)
+ break;
- /* No need to resize if we get minimized */
- if (wParam == SIZE_MINIMIZED)
- return 0;
+ /* No need to resize if we get minimized */
+ if (wParam == SIZE_MINIMIZED)
+ return 0;
winDebug ("winWindowProc - WM_SIZE - new client area w: %d h: %d\n",
- LOWORD (lParam), HIWORD (lParam));
+ LOWORD(lParam), HIWORD(lParam));
- if (s_pScreenInfo->iResizeMode == resizeWithRandr)
- {
+ if (s_pScreenInfo->iResizeMode == resizeWithRandr) {
/* Actual resizing is done on WM_EXITSIZEMOVE */
return 0;
- }
+ }
/* Otherwise iResizeMode == resizeWithScrollbars */
- /*
- * Get the size of the whole window, including client area,
- * scrollbars, and non-client area decorations (caption, borders).
- * We do this because we need to check if the client area
- * without scrollbars is large enough to display the whole visual.
- * The new client area size passed by lParam already subtracts
- * the size of the scrollbars if they are currently displayed.
- * So checking is LOWORD(lParam) == visual_width and
- * HIWORD(lParam) == visual_height will never tell us to hide
- * the scrollbars because the client area would always be too small.
- * GetClientRect returns the same sizes given by lParam, so we
- * cannot use GetClientRect either.
- */
- GetWindowRect (hwnd, &rcWindow);
- iWidth = rcWindow.right - rcWindow.left;
- iHeight = rcWindow.bottom - rcWindow.top;
-
- /* Subtract the frame size from the window size. */
- iWidth -= 2 * GetSystemMetrics (SM_CXSIZEFRAME);
- iHeight -= (2 * GetSystemMetrics (SM_CYSIZEFRAME)
- + GetSystemMetrics (SM_CYCAPTION));
-
- /*
- * Update scrollbar page sizes.
- * NOTE: If page size == range, then the scrollbar is
- * automatically hidden.
- */
-
- /* Is the naked client area large enough to show the whole visual? */
- if (iWidth < s_pScreenInfo->dwWidth
- || iHeight < s_pScreenInfo->dwHeight)
- {
- /* Client area too small to display visual, use scrollbars */
- iWidth -= GetSystemMetrics (SM_CXVSCROLL);
- iHeight -= GetSystemMetrics (SM_CYHSCROLL);
- }
-
- /* Set the horizontal scrollbar page size */
- si.cbSize = sizeof (si);
- si.fMask = SIF_PAGE | SIF_RANGE;
- si.nMin = 0;
- si.nMax = s_pScreenInfo->dwWidth - 1;
- si.nPage = iWidth;
- SetScrollInfo (hwnd, SB_HORZ, &si, TRUE);
-
- /* Set the vertical scrollbar page size */
- si.cbSize = sizeof (si);
- si.fMask = SIF_PAGE | SIF_RANGE;
- si.nMin = 0;
- si.nMax = s_pScreenInfo->dwHeight - 1;
- si.nPage = iHeight;
- SetScrollInfo (hwnd, SB_VERT, &si, TRUE);
-
- /*
- * NOTE: Scrollbars may have moved if they were at the
- * far right/bottom, so we query their current position.
- */
-
- /* Get the horizontal scrollbar position and set the offset */
- si.cbSize = sizeof (si);
- si.fMask = SIF_POS;
- GetScrollInfo (hwnd, SB_HORZ, &si);
- s_pScreenInfo->dwXOffset = -si.nPos;
-
- /* Get the vertical scrollbar position and set the offset */
- si.cbSize = sizeof (si);
- si.fMask = SIF_POS;
- GetScrollInfo (hwnd, SB_VERT, &si);
- s_pScreenInfo->dwYOffset = -si.nPos;
- }
- return 0;
+ /*
+ * Get the size of the whole window, including client area,
+ * scrollbars, and non-client area decorations (caption, borders).
+ * We do this because we need to check if the client area
+ * without scrollbars is large enough to display the whole visual.
+ * The new client area size passed by lParam already subtracts
+ * the size of the scrollbars if they are currently displayed.
+ * So checking is LOWORD(lParam) == visual_width and
+ * HIWORD(lParam) == visual_height will never tell us to hide
+ * the scrollbars because the client area would always be too small.
+ * GetClientRect returns the same sizes given by lParam, so we
+ * cannot use GetClientRect either.
+ */
+ GetWindowRect(hwnd, &rcWindow);
+ iWidth = rcWindow.right - rcWindow.left;
+ iHeight = rcWindow.bottom - rcWindow.top;
+
+ /* Subtract the frame size from the window size. */
+ iWidth -= 2 * GetSystemMetrics(SM_CXSIZEFRAME);
+ iHeight -= (2 * GetSystemMetrics(SM_CYSIZEFRAME)
+ + GetSystemMetrics(SM_CYCAPTION));
+
+ /*
+ * Update scrollbar page sizes.
+ * NOTE: If page size == range, then the scrollbar is
+ * automatically hidden.
+ */
+
+ /* Is the naked client area large enough to show the whole visual? */
+ if (iWidth < s_pScreenInfo->dwWidth
+ || iHeight < s_pScreenInfo->dwHeight) {
+ /* Client area too small to display visual, use scrollbars */
+ iWidth -= GetSystemMetrics(SM_CXVSCROLL);
+ iHeight -= GetSystemMetrics(SM_CYHSCROLL);
+ }
+
+ /* Set the horizontal scrollbar page size */
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_PAGE | SIF_RANGE;
+ si.nMin = 0;
+ si.nMax = s_pScreenInfo->dwWidth - 1;
+ si.nPage = iWidth;
+ SetScrollInfo(hwnd, SB_HORZ, &si, TRUE);
+
+ /* Set the vertical scrollbar page size */
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_PAGE | SIF_RANGE;
+ si.nMin = 0;
+ si.nMax = s_pScreenInfo->dwHeight - 1;
+ si.nPage = iHeight;
+ SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
+
+ /*
+ * NOTE: Scrollbars may have moved if they were at the
+ * far right/bottom, so we query their current position.
+ */
+
+ /* Get the horizontal scrollbar position and set the offset */
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_POS;
+ GetScrollInfo(hwnd, SB_HORZ, &si);
+ s_pScreenInfo->dwXOffset = -si.nPos;
+
+ /* Get the vertical scrollbar position and set the offset */
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_POS;
+ GetScrollInfo(hwnd, SB_VERT, &si);
+ s_pScreenInfo->dwYOffset = -si.nPos;
+ }
+ return 0;
case WM_ENTERSIZEMOVE:
- winDebug("winWindowProc - WM_ENTERSIZEMOVE\n");
- break;
+ winDebug("winWindowProc - WM_ENTERSIZEMOVE\n");
+ break;
case WM_EXITSIZEMOVE:
- winDebug("winWindowProc - WM_EXITSIZEMOVE\n");
-
- if (s_pScreenInfo->iResizeMode == resizeWithRandr)
- {
- /* Set screen size to match new client area, if it is different to current */
- RECT rcClient;
- DWORD dwWidth, dwHeight;
-
- GetClientRect (hwnd, &rcClient);
- dwWidth = rcClient.right - rcClient.left;
- dwHeight = rcClient.bottom - rcClient.top;
-
- if ((s_pScreenInfo->dwWidth != dwWidth) ||
- (s_pScreenInfo->dwHeight != dwHeight))
- {
- /* mm = dots * (25.4 mm / inch) / (dots / inch) */
- winDoRandRScreenSetSize(s_pScreen,
- dwWidth,
- dwHeight,
- (dwWidth * 25.4) / monitorResolution,
- (dwHeight * 25.4) / monitorResolution);
+ winDebug("winWindowProc - WM_EXITSIZEMOVE\n");
+
+ if (s_pScreenInfo->iResizeMode == resizeWithRandr) {
+ /* Set screen size to match new client area, if it is different to current */
+ RECT rcClient;
+ DWORD dwWidth, dwHeight;
+
+ GetClientRect(hwnd, &rcClient);
+ dwWidth = rcClient.right - rcClient.left;
+ dwHeight = rcClient.bottom - rcClient.top;
+
+ if ((s_pScreenInfo->dwWidth != dwWidth) ||
+ (s_pScreenInfo->dwHeight != dwHeight)) {
+ /* mm = dots * (25.4 mm / inch) / (dots / inch) */
+ winDoRandRScreenSetSize(s_pScreen,
+ dwWidth,
+ dwHeight,
+ (dwWidth * 25.4) / monitorResolution,
+ (dwHeight * 25.4) / monitorResolution);
}
}
- break;
+ break;
case WM_VSCROLL:
- {
- SCROLLINFO si;
- int iVertPos;
+ {
+ SCROLLINFO si;
+ int iVertPos;
+
+ winDebug("winWindowProc - WM_VSCROLL\n");
+
+ /* Get vertical scroll bar info */
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_ALL;
+ GetScrollInfo(hwnd, SB_VERT, &si);
+
+ /* Save the vertical position for comparison later */
+ iVertPos = si.nPos;
+
+ /*
+ * Don't forget:
+ * moving the scrollbar to the DOWN, scroll the content UP
+ */
+ switch (LOWORD(wParam)) {
+ case SB_TOP:
+ si.nPos = si.nMin;
+ break;
- winDebug ("winWindowProc - WM_VSCROLL\n");
-
- /* Get vertical scroll bar info */
- si.cbSize = sizeof (si);
- si.fMask = SIF_ALL;
- GetScrollInfo (hwnd, SB_VERT, &si);
-
- /* Save the vertical position for comparison later */
- iVertPos = si.nPos;
-
- /*
- * Don't forget:
- * moving the scrollbar to the DOWN, scroll the content UP
- */
- switch (LOWORD(wParam))
- {
- case SB_TOP:
- si.nPos = si.nMin;
- break;
-
- case SB_BOTTOM:
- si.nPos = si.nMax - si.nPage + 1;
- break;
-
- case SB_LINEUP:
- si.nPos -= 1;
- break;
-
- case SB_LINEDOWN:
- si.nPos += 1;
- break;
-
- case SB_PAGEUP:
- si.nPos -= si.nPage;
- break;
-
- case SB_PAGEDOWN:
- si.nPos += si.nPage;
- break;
-
- case SB_THUMBTRACK:
- si.nPos = si.nTrackPos;
- break;
-
- default:
- break;
- }
-
- /*
- * We retrieve the position after setting it,
- * because Windows may adjust it.
- */
- si.fMask = SIF_POS;
- SetScrollInfo (hwnd, SB_VERT, &si, TRUE);
- GetScrollInfo (hwnd, SB_VERT, &si);
-
- /* Scroll the window if the position has changed */
- if (si.nPos != iVertPos)
- {
- /* Save the new offset for bit block transfers, etc. */
- s_pScreenInfo->dwYOffset = -si.nPos;
-
- /* Change displayed region in the window */
- ScrollWindowEx (hwnd,
- 0,
- iVertPos - si.nPos,
- NULL,
- NULL,
- NULL,
- NULL,
- SW_INVALIDATE);
-
- /* Redraw the window contents */
- UpdateWindow (hwnd);
- }
- }
- return 0;
+ case SB_BOTTOM:
+ si.nPos = si.nMax - si.nPage + 1;
+ break;
+
+ case SB_LINEUP:
+ si.nPos -= 1;
+ break;
+
+ case SB_LINEDOWN:
+ si.nPos += 1;
+ break;
+
+ case SB_PAGEUP:
+ si.nPos -= si.nPage;
+ break;
+
+ case SB_PAGEDOWN:
+ si.nPos += si.nPage;
+ break;
+
+ case SB_THUMBTRACK:
+ si.nPos = si.nTrackPos;
+ break;
+
+ default:
+ break;
+ }
+
+ /*
+ * We retrieve the position after setting it,
+ * because Windows may adjust it.
+ */
+ si.fMask = SIF_POS;
+ SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
+ GetScrollInfo(hwnd, SB_VERT, &si);
+
+ /* Scroll the window if the position has changed */
+ if (si.nPos != iVertPos) {
+ /* Save the new offset for bit block transfers, etc. */
+ s_pScreenInfo->dwYOffset = -si.nPos;
+
+ /* Change displayed region in the window */
+ ScrollWindowEx(hwnd,
+ 0,
+ iVertPos - si.nPos,
+ NULL, NULL, NULL, NULL, SW_INVALIDATE);
+
+ /* Redraw the window contents */
+ UpdateWindow(hwnd);
+ }
+ }
+ return 0;
case WM_HSCROLL:
- {
- SCROLLINFO si;
- int iHorzPos;
+ {
+ SCROLLINFO si;
+ int iHorzPos;
+
+ winDebug("winWindowProc - WM_HSCROLL\n");
+
+ /* Get horizontal scroll bar info */
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_ALL;
+ GetScrollInfo(hwnd, SB_HORZ, &si);
+
+ /* Save the horizontal position for comparison later */
+ iHorzPos = si.nPos;
+
+ /*
+ * Don't forget:
+ * moving the scrollbar to the RIGHT, scroll the content LEFT
+ */
+ switch (LOWORD(wParam)) {
+ case SB_LEFT:
+ si.nPos = si.nMin;
+ break;
- winDebug ("winWindowProc - WM_HSCROLL\n");
-
- /* Get horizontal scroll bar info */
- si.cbSize = sizeof (si);
- si.fMask = SIF_ALL;
- GetScrollInfo (hwnd, SB_HORZ, &si);
-
- /* Save the horizontal position for comparison later */
- iHorzPos = si.nPos;
-
- /*
- * Don't forget:
- * moving the scrollbar to the RIGHT, scroll the content LEFT
- */
- switch (LOWORD(wParam))
- {
- case SB_LEFT:
- si.nPos = si.nMin;
- break;
-
- case SB_RIGHT:
- si.nPos = si.nMax - si.nPage + 1;
- break;
-
- case SB_LINELEFT:
- si.nPos -= 1;
- break;
-
- case SB_LINERIGHT:
- si.nPos += 1;
- break;
-
- case SB_PAGELEFT:
- si.nPos -= si.nPage;
- break;
-
- case SB_PAGERIGHT:
- si.nPos += si.nPage;
- break;
-
- case SB_THUMBTRACK:
- si.nPos = si.nTrackPos;
- break;
-
- default:
- break;
- }
-
- /*
- * We retrieve the position after setting it,
- * because Windows may adjust it.
- */
- si.fMask = SIF_POS;
- SetScrollInfo (hwnd, SB_HORZ, &si, TRUE);
- GetScrollInfo (hwnd, SB_HORZ, &si);
-
- /* Scroll the window if the position has changed */
- if (si.nPos != iHorzPos)
- {
- /* Save the new offset for bit block transfers, etc. */
- s_pScreenInfo->dwXOffset = -si.nPos;
-
- /* Change displayed region in the window */
- ScrollWindowEx (hwnd,
- iHorzPos - si.nPos,
- 0,
- NULL,
- NULL,
- NULL,
- NULL,
- SW_INVALIDATE);
-
- /* Redraw the window contents */
- UpdateWindow (hwnd);
- }
- }
- return 0;
+ case SB_RIGHT:
+ si.nPos = si.nMax - si.nPage + 1;
+ break;
+
+ case SB_LINELEFT:
+ si.nPos -= 1;
+ break;
+
+ case SB_LINERIGHT:
+ si.nPos += 1;
+ break;
+
+ case SB_PAGELEFT:
+ si.nPos -= si.nPage;
+ break;
+
+ case SB_PAGERIGHT:
+ si.nPos += si.nPage;
+ break;
+
+ case SB_THUMBTRACK:
+ si.nPos = si.nTrackPos;
+ break;
+
+ default:
+ break;
+ }
+
+ /*
+ * We retrieve the position after setting it,
+ * because Windows may adjust it.
+ */
+ si.fMask = SIF_POS;
+ SetScrollInfo(hwnd, SB_HORZ, &si, TRUE);
+ GetScrollInfo(hwnd, SB_HORZ, &si);
+
+ /* Scroll the window if the position has changed */
+ if (si.nPos != iHorzPos) {
+ /* Save the new offset for bit block transfers, etc. */
+ s_pScreenInfo->dwXOffset = -si.nPos;
+
+ /* Change displayed region in the window */
+ ScrollWindowEx(hwnd,
+ iHorzPos - si.nPos,
+ 0, NULL, NULL, NULL, NULL, SW_INVALIDATE);
+
+ /* Redraw the window contents */
+ UpdateWindow(hwnd);
+ }
+ }
+ return 0;
case WM_GETMINMAXINFO:
- {
- MINMAXINFO *pMinMaxInfo = (MINMAXINFO *) lParam;
- int iCaptionHeight;
- int iBorderHeight, iBorderWidth;
-
- winDebug ("winWindowProc - WM_GETMINMAXINFO - pScreenInfo: %08x\n",
- s_pScreenInfo);
-
- /* Can't do anything without screen info */
- if (s_pScreenInfo == NULL
- || (s_pScreenInfo->iResizeMode != resizeWithScrollbars)
- || s_pScreenInfo->fFullScreen
- || !s_pScreenInfo->fDecoration
+ {
+ MINMAXINFO *pMinMaxInfo = (MINMAXINFO *) lParam;
+ int iCaptionHeight;
+ int iBorderHeight, iBorderWidth;
+
+ winDebug("winWindowProc - WM_GETMINMAXINFO - pScreenInfo: %08x\n",
+ s_pScreenInfo);
+
+ /* Can't do anything without screen info */
+ if (s_pScreenInfo == NULL
+ || (s_pScreenInfo->iResizeMode != resizeWithScrollbars)
+ || s_pScreenInfo->fFullScreen || !s_pScreenInfo->fDecoration
#ifdef XWIN_MULTIWINDOWEXTWM
- || s_pScreenInfo->fMWExtWM
+ || s_pScreenInfo->fMWExtWM
#endif
- || s_pScreenInfo->fRootless
+ || s_pScreenInfo->fRootless
#ifdef XWIN_MULTIWINDOW
- || s_pScreenInfo->fMultiWindow
+ || s_pScreenInfo->fMultiWindow
#endif
- )
- break;
-
- /*
- * Here we can override the maximum tracking size, which
- * is the largest size that can be assigned to our window
- * via the sizing border.
- */
-
- /*
- * FIXME: Do we only need to do this once, since our visual size
- * does not change? Does Windows store this value statically
- * once we have set it once?
- */
-
- /* Get the border and caption sizes */
- iCaptionHeight = GetSystemMetrics (SM_CYCAPTION);
- iBorderWidth = 2 * GetSystemMetrics (SM_CXSIZEFRAME);
- iBorderHeight = 2 * GetSystemMetrics (SM_CYSIZEFRAME);
-
- /* Allow the full visual to be displayed */
- pMinMaxInfo->ptMaxTrackSize.x
- = s_pScreenInfo->dwWidth + iBorderWidth;
- pMinMaxInfo->ptMaxTrackSize.y
- = s_pScreenInfo->dwHeight + iBorderHeight + iCaptionHeight;
- }
- return 0;
+ )
+ break;
+
+ /*
+ * Here we can override the maximum tracking size, which
+ * is the largest size that can be assigned to our window
+ * via the sizing border.
+ */
+
+ /*
+ * FIXME: Do we only need to do this once, since our visual size
+ * does not change? Does Windows store this value statically
+ * once we have set it once?
+ */
+
+ /* Get the border and caption sizes */
+ iCaptionHeight = GetSystemMetrics(SM_CYCAPTION);
+ iBorderWidth = 2 * GetSystemMetrics(SM_CXSIZEFRAME);
+ iBorderHeight = 2 * GetSystemMetrics(SM_CYSIZEFRAME);
+
+ /* Allow the full visual to be displayed */
+ pMinMaxInfo->ptMaxTrackSize.x = s_pScreenInfo->dwWidth + iBorderWidth;
+ pMinMaxInfo->ptMaxTrackSize.y
+ = s_pScreenInfo->dwHeight + iBorderHeight + iCaptionHeight;
+ }
+ return 0;
case WM_ERASEBKGND:
- winDebug ("winWindowProc - WM_ERASEBKGND\n");
- /*
- * Pretend that we did erase the background but we don't care,
- * the application uses the full window estate. This avoids some
- * flickering when resizing.
- */
- return TRUE;
+ winDebug("winWindowProc - WM_ERASEBKGND\n");
+ /*
+ * Pretend that we did erase the background but we don't care,
+ * the application uses the full window estate. This avoids some
+ * flickering when resizing.
+ */
+ return TRUE;
case WM_PAINT:
- /* Only paint if we have privates and the server is enabled */
- if (s_pScreenPriv == NULL
- || !s_pScreenPriv->fEnabled
- || (s_pScreenInfo->fFullScreen && !s_pScreenPriv->fActive)
- || s_pScreenPriv->fBadDepth)
- {
- /* We don't want to paint */
- break;
- }
-
- /* Break out here if we don't have a valid paint routine */
- if (s_pScreenPriv->pwinBltExposedRegions == NULL)
- break;
-
- /* Call the engine dependent repainter */
- (*s_pScreenPriv->pwinBltExposedRegions) (s_pScreen);
- return 0;
+ /* Only paint if we have privates and the server is enabled */
+ if (s_pScreenPriv == NULL
+ || !s_pScreenPriv->fEnabled
+ || (s_pScreenInfo->fFullScreen && !s_pScreenPriv->fActive)
+ || s_pScreenPriv->fBadDepth) {
+ /* We don't want to paint */
+ break;
+ }
+
+ /* Break out here if we don't have a valid paint routine */
+ if (s_pScreenPriv->pwinBltExposedRegions == NULL)
+ break;
+
+ /* Call the engine dependent repainter */
+ (*s_pScreenPriv->pwinBltExposedRegions) (s_pScreen);
+ return 0;
case WM_PALETTECHANGED:
- {
- winDebug ("winWindowProc - WM_PALETTECHANGED\n");
- /*
- * Don't process if we don't have privates or a colormap,
- * or if we have an invalid depth.
- */
- if (s_pScreenPriv == NULL
- || s_pScreenPriv->pcmapInstalled == NULL
- || s_pScreenPriv->fBadDepth)
- break;
-
- /* Return if we caused the palette to change */
- if ((HWND) wParam == hwnd)
- {
- /* Redraw the screen */
- (*s_pScreenPriv->pwinRedrawScreen) (s_pScreen);
- return 0;
- }
-
- /* Reinstall the windows palette */
- (*s_pScreenPriv->pwinRealizeInstalledPalette) (s_pScreen);
-
- /* Redraw the screen */
- (*s_pScreenPriv->pwinRedrawScreen) (s_pScreen);
- return 0;
- }
+ {
+ winDebug("winWindowProc - WM_PALETTECHANGED\n");
+ /*
+ * Don't process if we don't have privates or a colormap,
+ * or if we have an invalid depth.
+ */
+ if (s_pScreenPriv == NULL
+ || s_pScreenPriv->pcmapInstalled == NULL
+ || s_pScreenPriv->fBadDepth)
+ break;
+
+ /* Return if we caused the palette to change */
+ if ((HWND) wParam == hwnd) {
+ /* Redraw the screen */
+ (*s_pScreenPriv->pwinRedrawScreen) (s_pScreen);
+ return 0;
+ }
+
+ /* Reinstall the windows palette */
+ (*s_pScreenPriv->pwinRealizeInstalledPalette) (s_pScreen);
+
+ /* Redraw the screen */
+ (*s_pScreenPriv->pwinRedrawScreen) (s_pScreen);
+ return 0;
+ }
case WM_MOUSEMOVE:
- /* We can't do anything without privates */
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
+ /* We can't do anything without privates */
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
- /* We can't do anything without g_pwinPointer */
- if (g_pwinPointer == NULL)
- break;
+ /* We can't do anything without g_pwinPointer */
+ if (g_pwinPointer == NULL)
+ break;
- /* Has the mouse pointer crossed screens? */
- if (s_pScreen != miPointerGetScreen(g_pwinPointer))
- miPointerSetScreen (g_pwinPointer, s_pScreenInfo->dwScreen,
- GET_X_LPARAM(lParam)-s_pScreenInfo->dwXOffset,
- GET_Y_LPARAM(lParam)-s_pScreenInfo->dwYOffset);
-
- /* Are we tracking yet? */
- if (!s_fTracking)
- {
- TRACKMOUSEEVENT tme;
-
- /* Setup data structure */
- ZeroMemory (&tme, sizeof (tme));
- tme.cbSize = sizeof (tme);
- tme.dwFlags = TME_LEAVE;
- tme.hwndTrack = hwnd;
-
- /* Call the tracking function */
- if (!TrackMouseEvent(&tme))
- ErrorF ("winWindowProc - TrackMouseEvent failed\n");
-
- /* Flag that we are tracking now */
- s_fTracking = TRUE;
- }
-
- /* Hide or show the Windows mouse cursor */
- if (g_fSoftwareCursor && g_fCursor && (s_pScreenPriv->fActive || s_pScreenInfo->fLessPointer))
- {
- /* Hide Windows cursor */
- g_fCursor = FALSE;
- ShowCursor (FALSE);
- }
- else if (g_fSoftwareCursor && !g_fCursor && !s_pScreenPriv->fActive
- && !s_pScreenInfo->fLessPointer)
- {
- /* Show Windows cursor */
- g_fCursor = TRUE;
- ShowCursor (TRUE);
- }
-
- /* Deliver absolute cursor position to X Server */
- winEnqueueMotion(GET_X_LPARAM(lParam)-s_pScreenInfo->dwXOffset,
- GET_Y_LPARAM(lParam)-s_pScreenInfo->dwYOffset);
- return 0;
+ /* Has the mouse pointer crossed screens? */
+ if (s_pScreen != miPointerGetScreen(g_pwinPointer))
+ miPointerSetScreen(g_pwinPointer, s_pScreenInfo->dwScreen,
+ GET_X_LPARAM(lParam) - s_pScreenInfo->dwXOffset,
+ GET_Y_LPARAM(lParam) - s_pScreenInfo->dwYOffset);
+
+ /* Are we tracking yet? */
+ if (!s_fTracking) {
+ TRACKMOUSEEVENT tme;
+
+ /* Setup data structure */
+ ZeroMemory(&tme, sizeof(tme));
+ tme.cbSize = sizeof(tme);
+ tme.dwFlags = TME_LEAVE;
+ tme.hwndTrack = hwnd;
+
+ /* Call the tracking function */
+ if (!TrackMouseEvent(&tme))
+ ErrorF("winWindowProc - TrackMouseEvent failed\n");
+
+ /* Flag that we are tracking now */
+ s_fTracking = TRUE;
+ }
+
+ /* Hide or show the Windows mouse cursor */
+ if (g_fSoftwareCursor && g_fCursor &&
+ (s_pScreenPriv->fActive || s_pScreenInfo->fLessPointer)) {
+ /* Hide Windows cursor */
+ g_fCursor = FALSE;
+ ShowCursor(FALSE);
+ }
+ else if (g_fSoftwareCursor && !g_fCursor && !s_pScreenPriv->fActive
+ && !s_pScreenInfo->fLessPointer) {
+ /* Show Windows cursor */
+ g_fCursor = TRUE;
+ ShowCursor(TRUE);
+ }
+
+ /* Deliver absolute cursor position to X Server */
+ winEnqueueMotion(GET_X_LPARAM(lParam) - s_pScreenInfo->dwXOffset,
+ GET_Y_LPARAM(lParam) - s_pScreenInfo->dwYOffset);
+ return 0;
case WM_NCMOUSEMOVE:
- /*
- * We break instead of returning 0 since we need to call
- * DefWindowProc to get the mouse cursor changes
- * and min/max/close button highlighting in Windows XP.
- * The Platform SDK says that you should return 0 if you
- * process this message, but it fails to mention that you
- * will give up any default functionality if you do return 0.
- */
-
- /* We can't do anything without privates */
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
-
- /* Non-client mouse movement, show Windows cursor */
- if (g_fSoftwareCursor && !g_fCursor)
- {
- g_fCursor = TRUE;
- ShowCursor (TRUE);
- }
- break;
+ /*
+ * We break instead of returning 0 since we need to call
+ * DefWindowProc to get the mouse cursor changes
+ * and min/max/close button highlighting in Windows XP.
+ * The Platform SDK says that you should return 0 if you
+ * process this message, but it fails to mention that you
+ * will give up any default functionality if you do return 0.
+ */
+
+ /* We can't do anything without privates */
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+
+ /* Non-client mouse movement, show Windows cursor */
+ if (g_fSoftwareCursor && !g_fCursor) {
+ g_fCursor = TRUE;
+ ShowCursor(TRUE);
+ }
+ break;
case WM_MOUSELEAVE:
- /* Mouse has left our client area */
+ /* Mouse has left our client area */
- /* Flag that we are no longer tracking */
- s_fTracking = FALSE;
+ /* Flag that we are no longer tracking */
+ s_fTracking = FALSE;
- /* Show the mouse cursor, if necessary */
- if (g_fSoftwareCursor && !g_fCursor)
- {
- g_fCursor = TRUE;
- ShowCursor (TRUE);
- }
- return 0;
+ /* Show the mouse cursor, if necessary */
+ if (g_fSoftwareCursor && !g_fCursor) {
+ g_fCursor = TRUE;
+ ShowCursor(TRUE);
+ }
+ return 0;
case WM_LBUTTONDBLCLK:
case WM_LBUTTONDOWN:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
- if (s_pScreenInfo->fRootless
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ if (s_pScreenInfo->fRootless
#ifdef XWIN_MULTIWINDOWEXTWM
- || s_pScreenInfo->fMWExtWM
+ || s_pScreenInfo->fMWExtWM
#endif
- )
- SetCapture (hwnd);
- return winMouseButtonsHandle (s_pScreen, ButtonPress, Button1, wParam);
-
+ )
+ SetCapture(hwnd);
+ return winMouseButtonsHandle(s_pScreen, ButtonPress, Button1, wParam);
+
case WM_LBUTTONUP:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
- if (s_pScreenInfo->fRootless
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ if (s_pScreenInfo->fRootless
#ifdef XWIN_MULTIWINDOWEXTWM
- || s_pScreenInfo->fMWExtWM
+ || s_pScreenInfo->fMWExtWM
#endif
- )
- ReleaseCapture ();
- return winMouseButtonsHandle (s_pScreen, ButtonRelease, Button1, wParam);
+ )
+ ReleaseCapture();
+ return winMouseButtonsHandle(s_pScreen, ButtonRelease, Button1, wParam);
case WM_MBUTTONDBLCLK:
case WM_MBUTTONDOWN:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
- if (s_pScreenInfo->fRootless
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ if (s_pScreenInfo->fRootless
#ifdef XWIN_MULTIWINDOWEXTWM
- || s_pScreenInfo->fMWExtWM
+ || s_pScreenInfo->fMWExtWM
#endif
- )
- SetCapture (hwnd);
- return winMouseButtonsHandle (s_pScreen, ButtonPress, Button2, wParam);
-
+ )
+ SetCapture(hwnd);
+ return winMouseButtonsHandle(s_pScreen, ButtonPress, Button2, wParam);
+
case WM_MBUTTONUP:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
- if (s_pScreenInfo->fRootless
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ if (s_pScreenInfo->fRootless
#ifdef XWIN_MULTIWINDOWEXTWM
- || s_pScreenInfo->fMWExtWM
+ || s_pScreenInfo->fMWExtWM
#endif
- )
- ReleaseCapture ();
- return winMouseButtonsHandle (s_pScreen, ButtonRelease, Button2, wParam);
-
+ )
+ ReleaseCapture();
+ return winMouseButtonsHandle(s_pScreen, ButtonRelease, Button2, wParam);
+
case WM_RBUTTONDBLCLK:
case WM_RBUTTONDOWN:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
- if (s_pScreenInfo->fRootless
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ if (s_pScreenInfo->fRootless
#ifdef XWIN_MULTIWINDOWEXTWM
- || s_pScreenInfo->fMWExtWM
+ || s_pScreenInfo->fMWExtWM
#endif
- )
- SetCapture (hwnd);
- return winMouseButtonsHandle (s_pScreen, ButtonPress, Button3, wParam);
-
+ )
+ SetCapture(hwnd);
+ return winMouseButtonsHandle(s_pScreen, ButtonPress, Button3, wParam);
+
case WM_RBUTTONUP:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
- if (s_pScreenInfo->fRootless
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ if (s_pScreenInfo->fRootless
#ifdef XWIN_MULTIWINDOWEXTWM
- || s_pScreenInfo->fMWExtWM
+ || s_pScreenInfo->fMWExtWM
#endif
- )
- ReleaseCapture ();
- return winMouseButtonsHandle (s_pScreen, ButtonRelease, Button3, wParam);
+ )
+ ReleaseCapture();
+ return winMouseButtonsHandle(s_pScreen, ButtonRelease, Button3, wParam);
case WM_XBUTTONDBLCLK:
case WM_XBUTTONDOWN:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
- if (s_pScreenInfo->fRootless
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ if (s_pScreenInfo->fRootless
#ifdef XWIN_MULTIWINDOWEXTWM
- || s_pScreenInfo->fMWExtWM
+ || s_pScreenInfo->fMWExtWM
#endif
- )
- SetCapture (hwnd);
- return winMouseButtonsHandle (s_pScreen, ButtonPress, HIWORD(wParam) + 5, wParam);
+ )
+ SetCapture(hwnd);
+ return winMouseButtonsHandle(s_pScreen, ButtonPress, HIWORD(wParam) + 5,
+ wParam);
case WM_XBUTTONUP:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
- if (s_pScreenInfo->fRootless
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ if (s_pScreenInfo->fRootless
#ifdef XWIN_MULTIWINDOWEXTWM
- || s_pScreenInfo->fMWExtWM
+ || s_pScreenInfo->fMWExtWM
#endif
- )
- ReleaseCapture ();
- return winMouseButtonsHandle (s_pScreen, ButtonRelease, HIWORD(wParam) + 5, wParam);
+ )
+ ReleaseCapture();
+ return winMouseButtonsHandle(s_pScreen, ButtonRelease,
+ HIWORD(wParam) + 5, wParam);
case WM_TIMER:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
-
- /* Branch on the timer id */
- switch (wParam)
- {
- case WIN_E3B_TIMER_ID:
- /* Send delayed button press */
- winMouseButtonsSendEvent (ButtonPress,
- s_pScreenPriv->iE3BCachedPress);
-
- /* Kill this timer */
- KillTimer (s_pScreenPriv->hwndScreen, WIN_E3B_TIMER_ID);
-
- /* Clear screen privates flags */
- s_pScreenPriv->iE3BCachedPress = 0;
- break;
-
- case WIN_POLLING_MOUSE_TIMER_ID:
- {
- POINT point;
- WPARAM wL, wM, wR, wShift, wCtrl;
- LPARAM lPos;
-
- /* Get the current position of the mouse cursor */
- GetCursorPos (&point);
-
- /* Map from screen (-X, -Y) to root (0, 0) */
- point.x -= GetSystemMetrics (SM_XVIRTUALSCREEN);
- point.y -= GetSystemMetrics (SM_YVIRTUALSCREEN);
-
- /* Deliver absolute cursor position to X Server */
- winEnqueueMotion(point.x , point.y);
-
- /* Check if a button was released but we didn't see it */
- GetCursorPos (&point);
- wL = (GetKeyState (VK_LBUTTON) & 0x8000)?MK_LBUTTON:0;
- wM = (GetKeyState (VK_MBUTTON) & 0x8000)?MK_MBUTTON:0;
- wR = (GetKeyState (VK_RBUTTON) & 0x8000)?MK_RBUTTON:0;
- wShift = (GetKeyState (VK_SHIFT) & 0x8000)?MK_SHIFT:0;
- wCtrl = (GetKeyState (VK_CONTROL) & 0x8000)?MK_CONTROL:0;
- lPos = MAKELPARAM(point.x, point.y);
- if (g_fButton[0] && !wL)
- PostMessage (hwnd, WM_LBUTTONUP, wCtrl|wM|wR|wShift, lPos);
- if (g_fButton[1] && !wM)
- PostMessage (hwnd, WM_MBUTTONUP, wCtrl|wL|wR|wShift, lPos);
- if (g_fButton[2] && !wR)
- PostMessage (hwnd, WM_RBUTTONUP, wCtrl|wL|wM|wShift, lPos);
- }
- }
- return 0;
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+
+ /* Branch on the timer id */
+ switch (wParam) {
+ case WIN_E3B_TIMER_ID:
+ /* Send delayed button press */
+ winMouseButtonsSendEvent(ButtonPress,
+ s_pScreenPriv->iE3BCachedPress);
+
+ /* Kill this timer */
+ KillTimer(s_pScreenPriv->hwndScreen, WIN_E3B_TIMER_ID);
+
+ /* Clear screen privates flags */
+ s_pScreenPriv->iE3BCachedPress = 0;
+ break;
+
+ case WIN_POLLING_MOUSE_TIMER_ID:
+ {
+ POINT point;
+ WPARAM wL, wM, wR, wShift, wCtrl;
+ LPARAM lPos;
+
+ /* Get the current position of the mouse cursor */
+ GetCursorPos(&point);
+
+ /* Map from screen (-X, -Y) to root (0, 0) */
+ point.x -= GetSystemMetrics(SM_XVIRTUALSCREEN);
+ point.y -= GetSystemMetrics(SM_YVIRTUALSCREEN);
+
+ /* Deliver absolute cursor position to X Server */
+ winEnqueueMotion(point.x, point.y);
+
+ /* Check if a button was released but we didn't see it */
+ GetCursorPos(&point);
+ wL = (GetKeyState(VK_LBUTTON) & 0x8000) ? MK_LBUTTON : 0;
+ wM = (GetKeyState(VK_MBUTTON) & 0x8000) ? MK_MBUTTON : 0;
+ wR = (GetKeyState(VK_RBUTTON) & 0x8000) ? MK_RBUTTON : 0;
+ wShift = (GetKeyState(VK_SHIFT) & 0x8000) ? MK_SHIFT : 0;
+ wCtrl = (GetKeyState(VK_CONTROL) & 0x8000) ? MK_CONTROL : 0;
+ lPos = MAKELPARAM(point.x, point.y);
+ if (g_fButton[0] && !wL)
+ PostMessage(hwnd, WM_LBUTTONUP, wCtrl | wM | wR | wShift, lPos);
+ if (g_fButton[1] && !wM)
+ PostMessage(hwnd, WM_MBUTTONUP, wCtrl | wL | wR | wShift, lPos);
+ if (g_fButton[2] && !wR)
+ PostMessage(hwnd, WM_RBUTTONUP, wCtrl | wL | wM | wShift, lPos);
+ }
+ }
+ return 0;
case WM_CTLCOLORSCROLLBAR:
- FatalError ("winWindowProc - WM_CTLCOLORSCROLLBAR - We are not "
- "supposed to get this message. Exiting.\n");
- return 0;
+ FatalError("winWindowProc - WM_CTLCOLORSCROLLBAR - We are not "
+ "supposed to get this message. Exiting.\n");
+ return 0;
case WM_MOUSEWHEEL:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
- winDebug ("winWindowProc - WM_MOUSEWHEEL\n");
- winMouseWheel (s_pScreen, GET_WHEEL_DELTA_WPARAM(wParam));
- break;
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+ winDebug("winWindowProc - WM_MOUSEWHEEL\n");
+ winMouseWheel(s_pScreen, GET_WHEEL_DELTA_WPARAM(wParam));
+ break;
case WM_SETFOCUS:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
- /* Restore the state of all mode keys */
- winRestoreModeKeyStates ();
+ /* Restore the state of all mode keys */
+ winRestoreModeKeyStates();
- /* Add the keyboard hook if possible */
- if (g_fKeyboardHookLL)
- g_fKeyboardHookLL = winInstallKeyboardHookLL ();
- return 0;
+ /* Add the keyboard hook if possible */
+ if (g_fKeyboardHookLL)
+ g_fKeyboardHookLL = winInstallKeyboardHookLL();
+ return 0;
case WM_KILLFOCUS:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
- /* Release any pressed keys */
- winKeybdReleaseKeys ();
+ /* Release any pressed keys */
+ winKeybdReleaseKeys();
- /* Remove our keyboard hook if it is installed */
- winRemoveKeyboardHookLL ();
- return 0;
+ /* Remove our keyboard hook if it is installed */
+ winRemoveKeyboardHookLL();
+ return 0;
case WM_SYSKEYDOWN:
case WM_KEYDOWN:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
-
- /*
- * FIXME: Catching Alt-F4 like this is really terrible. This should
- * be generalized to handle other Windows keyboard signals. Actually,
- * the list keys to catch and the actions to perform when caught should
- * be configurable; that way user's can customize the keys that they
- * need to have passed through to their window manager or apps, or they
- * can remap certain actions to new key codes that do not conflict
- * with the X apps that they are using. Yeah, that'll take awhile.
- */
- if ((s_pScreenInfo->fUseWinKillKey && wParam == VK_F4
- && (GetKeyState (VK_MENU) & 0x8000))
- || (s_pScreenInfo->fUseUnixKillKey && wParam == VK_BACK
- && (GetKeyState (VK_MENU) & 0x8000)
- && (GetKeyState (VK_CONTROL) & 0x8000)))
- {
- /*
- * Better leave this message here, just in case some unsuspecting
- * user enters Alt + F4 and is surprised when the application
- * quits.
- */
- winDebug ("winWindowProc - WM_*KEYDOWN - Closekey hit, quitting\n");
-
- /* Display Exit dialog */
- winDisplayExitDialog (s_pScreenPriv);
- return 0;
- }
-
- /*
- * Don't do anything for the Windows keys, as focus will soon
- * be returned to Windows. We may be able to trap the Windows keys,
- * but we should determine if that is desirable before doing so.
- */
- if ((wParam == VK_LWIN || wParam == VK_RWIN) && !g_fKeyboardHookLL)
- break;
-
- /* Discard fake Ctrl_L events that precede AltGR on non-US keyboards */
- if (winIsFakeCtrl_L (message, wParam, lParam))
- return 0;
-
- /*
- * Discard presses generated from Windows auto-repeat
- */
- if (lParam & (1<<30))
- {
- switch (wParam)
- {
- /* ago: Pressing LControl while RControl is pressed is
- * Indicated as repeat. Fix this!
- */
- case VK_CONTROL:
- case VK_SHIFT:
- if (winCheckKeyPressed(wParam, lParam))
- return 0;
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
break;
- default:
+
+ /*
+ * FIXME: Catching Alt-F4 like this is really terrible. This should
+ * be generalized to handle other Windows keyboard signals. Actually,
+ * the list keys to catch and the actions to perform when caught should
+ * be configurable; that way user's can customize the keys that they
+ * need to have passed through to their window manager or apps, or they
+ * can remap certain actions to new key codes that do not conflict
+ * with the X apps that they are using. Yeah, that'll take awhile.
+ */
+ if ((s_pScreenInfo->fUseWinKillKey && wParam == VK_F4
+ && (GetKeyState(VK_MENU) & 0x8000))
+ || (s_pScreenInfo->fUseUnixKillKey && wParam == VK_BACK
+ && (GetKeyState(VK_MENU) & 0x8000)
+ && (GetKeyState(VK_CONTROL) & 0x8000))) {
+ /*
+ * Better leave this message here, just in case some unsuspecting
+ * user enters Alt + F4 and is surprised when the application
+ * quits.
+ */
+ winDebug ("winWindowProc - WM_*KEYDOWN - Closekey hit, quitting\n");
+
+ /* Display Exit dialog */
+ winDisplayExitDialog(s_pScreenPriv);
return 0;
}
- }
-
- /* Translate Windows key code to X scan code */
- winTranslateKey (wParam, lParam, &iScanCode);
- /* Ignore repeats for CapsLock */
- if (wParam == VK_CAPITAL)
- lParam = 1;
+ /*
+ * Don't do anything for the Windows keys, as focus will soon
+ * be returned to Windows. We may be able to trap the Windows keys,
+ * but we should determine if that is desirable before doing so.
+ */
+ if ((wParam == VK_LWIN || wParam == VK_RWIN) && !g_fKeyboardHookLL)
+ break;
- /* Send the key event(s) */
- for (i = 0; i < LOWORD(lParam); ++i)
- winSendKeyEvent (iScanCode, TRUE);
- return 0;
+ /* Discard fake Ctrl_L events that precede AltGR on non-US keyboards */
+ if (winIsFakeCtrl_L(message, wParam, lParam))
+ return 0;
+
+ /*
+ * Discard presses generated from Windows auto-repeat
+ */
+ if (lParam & (1 << 30)) {
+ switch (wParam) {
+ /* ago: Pressing LControl while RControl is pressed is
+ * Indicated as repeat. Fix this!
+ */
+ case VK_CONTROL:
+ case VK_SHIFT:
+ if (winCheckKeyPressed(wParam, lParam))
+ return 0;
+ break;
+ default:
+ return 0;
+ }
+ }
+
+ /* Translate Windows key code to X scan code */
+ winTranslateKey(wParam, lParam, &iScanCode);
+
+ /* Ignore repeats for CapsLock */
+ if (wParam == VK_CAPITAL)
+ lParam = 1;
+
+ /* Send the key event(s) */
+ for (i = 0; i < LOWORD(lParam); ++i)
+ winSendKeyEvent(iScanCode, TRUE);
+ return 0;
case WM_SYSKEYUP:
case WM_KEYUP:
- if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
- break;
-
- /*
- * Don't do anything for the Windows keys, as focus will soon
- * be returned to Windows. We may be able to trap the Windows keys,
- * but we should determine if that is desirable before doing so.
- */
- if ((wParam == VK_LWIN || wParam == VK_RWIN) && !g_fKeyboardHookLL)
- break;
-
- /* Ignore the fake Ctrl_L that follows an AltGr release */
- if (winIsFakeCtrl_L (message, wParam, lParam))
- return 0;
-
- /* Enqueue a keyup event */
- winTranslateKey (wParam, lParam, &iScanCode);
- winSendKeyEvent (iScanCode, FALSE);
-
- /* Release all pressed shift keys */
- if (wParam == VK_SHIFT)
- winFixShiftKeys (iScanCode);
- return 0;
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+
+ /*
+ * Don't do anything for the Windows keys, as focus will soon
+ * be returned to Windows. We may be able to trap the Windows keys,
+ * but we should determine if that is desirable before doing so.
+ */
+ if ((wParam == VK_LWIN || wParam == VK_RWIN) && !g_fKeyboardHookLL)
+ break;
+
+ /* Ignore the fake Ctrl_L that follows an AltGr release */
+ if (winIsFakeCtrl_L(message, wParam, lParam))
+ return 0;
+
+ /* Enqueue a keyup event */
+ winTranslateKey(wParam, lParam, &iScanCode);
+ winSendKeyEvent(iScanCode, FALSE);
+
+ /* Release all pressed shift keys */
+ if (wParam == VK_SHIFT)
+ winFixShiftKeys(iScanCode);
+ return 0;
case WM_HOTKEY:
- if (s_pScreenPriv == NULL)
- break;
+ if (s_pScreenPriv == NULL)
+ break;
- /* Call the engine-specific hot key handler */
- (*s_pScreenPriv->pwinHotKeyAltTab) (s_pScreen);
- return 0;
+ /* Call the engine-specific hot key handler */
+ (*s_pScreenPriv->pwinHotKeyAltTab) (s_pScreen);
+ return 0;
case WM_ACTIVATE:
- if (s_pScreenPriv == NULL
- || s_pScreenInfo->fIgnoreInput)
- break;
-
- /* TODO: Override display of window when we have a bad depth */
- if (LOWORD(wParam) != WA_INACTIVE && s_pScreenPriv->fBadDepth)
- {
- winDebug ("winWindowProc - WM_ACTIVATE - Bad depth, trying "
- "to override window activation\n");
-
- /* Minimize the window */
- ShowWindow (hwnd, SW_MINIMIZE);
-
- /* Display dialog box */
- if (g_hDlgDepthChange != NULL)
- {
- /* Make the existing dialog box active */
- SetActiveWindow (g_hDlgDepthChange);
- }
- else
- {
- /* TODO: Recreate the dialog box and bring to the top */
- ShowWindow (g_hDlgDepthChange, SW_SHOWDEFAULT);
- }
-
- /* Don't do any other processing of this message */
- return 0;
- }
-
- winDebug ("winWindowProc - WM_ACTIVATE\n");
-
- /*
- * Focus is being changed to another window.
- * The other window may or may not belong to
- * our process.
- */
-
- /* Clear any lingering wheel delta */
- s_pScreenPriv->iDeltaZ = 0;
-
- /* Reshow the Windows mouse cursor if we are being deactivated */
- if (g_fSoftwareCursor && LOWORD(wParam) == WA_INACTIVE
- && !g_fCursor)
- {
- /* Show Windows cursor */
- g_fCursor = TRUE;
- ShowCursor (TRUE);
- }
- return 0;
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
+
+ /* TODO: Override display of window when we have a bad depth */
+ if (LOWORD(wParam) != WA_INACTIVE && s_pScreenPriv->fBadDepth) {
+ winDebug ("winWindowProc - WM_ACTIVATE - Bad depth, trying "
+ "to override window activation\n");
+
+ /* Minimize the window */
+ ShowWindow(hwnd, SW_MINIMIZE);
+
+ /* Display dialog box */
+ if (g_hDlgDepthChange != NULL) {
+ /* Make the existing dialog box active */
+ SetActiveWindow(g_hDlgDepthChange);
+ }
+ else {
+ /* TODO: Recreate the dialog box and bring to the top */
+ ShowWindow(g_hDlgDepthChange, SW_SHOWDEFAULT);
+ }
+
+ /* Don't do any other processing of this message */
+ return 0;
+ }
+
+ winDebug("winWindowProc - WM_ACTIVATE\n");
+
+ /*
+ * Focus is being changed to another window.
+ * The other window may or may not belong to
+ * our process.
+ */
+
+ /* Clear any lingering wheel delta */
+ s_pScreenPriv->iDeltaZ = 0;
+
+ /* Reshow the Windows mouse cursor if we are being deactivated */
+ if (g_fSoftwareCursor && LOWORD(wParam) == WA_INACTIVE && !g_fCursor) {
+ /* Show Windows cursor */
+ g_fCursor = TRUE;
+ ShowCursor(TRUE);
+ }
+ return 0;
case WM_ACTIVATEAPP:
- if (s_pScreenPriv == NULL
- || s_pScreenInfo->fIgnoreInput)
- break;
+ if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput)
+ break;
- winDebug ("winWindowProc - WM_ACTIVATEAPP\n");
+ winDebug("winWindowProc - WM_ACTIVATEAPP\n");
- /* Activate or deactivate */
- s_pScreenPriv->fActive = wParam;
+ /* Activate or deactivate */
+ s_pScreenPriv->fActive = wParam;
- /* Reshow the Windows mouse cursor if we are being deactivated */
- if (g_fSoftwareCursor && !s_pScreenPriv->fActive
- && !g_fCursor)
- {
- /* Show Windows cursor */
- g_fCursor = TRUE;
- ShowCursor (TRUE);
- }
+ /* Reshow the Windows mouse cursor if we are being deactivated */
+ if (g_fSoftwareCursor && !s_pScreenPriv->fActive && !g_fCursor) {
+ /* Show Windows cursor */
+ g_fCursor = TRUE;
+ ShowCursor(TRUE);
+ }
#ifdef XWIN_CLIPBOARD
- /* Make sure the clipboard chain is ok. */
- winFixClipboardChain (0);
+ /* Make sure the clipboard chain is ok. */
+ winFixClipboardChain (0);
#endif
- /* Call engine specific screen activation/deactivation function */
- (*s_pScreenPriv->pwinActivateApp) (s_pScreen);
+ /* Call engine specific screen activation/deactivation function */
+ (*s_pScreenPriv->pwinActivateApp) (s_pScreen);
#ifdef XWIN_MULTIWINDOWINTWM
- if (s_pScreenPriv->fActive)
- {
- /* Restack all window unless using built-in wm. */
- if (s_pScreenInfo->fInternalWM && s_pScreenInfo->fAnotherWMRunning)
- winMWExtWMRestackWindows (s_pScreen);
- }
+ if (s_pScreenPriv->fActive) {
+ /* Restack all window unless using built-in wm. */
+ if (s_pScreenInfo->fInternalWM && s_pScreenInfo->fAnotherWMRunning)
+ winMWExtWMRestackWindows(s_pScreen);
+ }
#endif
- return 0;
+ return 0;
case WM_COMMAND:
- switch (LOWORD (wParam))
- {
- case ID_APP_EXIT:
- /* Display Exit dialog */
- winDisplayExitDialog (s_pScreenPriv);
- return 0;
+ switch (LOWORD(wParam)) {
+ case ID_APP_EXIT:
+ /* Display Exit dialog */
+ winDisplayExitDialog(s_pScreenPriv);
+ return 0;
#ifdef XWIN_MULTIWINDOW
- case ID_APP_HIDE_ROOT:
- if (s_pScreenPriv->fRootWindowShown)
- ShowWindow (s_pScreenPriv->hwndScreen, SW_HIDE);
- else
- ShowWindow (s_pScreenPriv->hwndScreen, SW_SHOW);
- s_pScreenPriv->fRootWindowShown = !s_pScreenPriv->fRootWindowShown;
- return 0;
+ case ID_APP_HIDE_ROOT:
+ if (s_pScreenPriv->fRootWindowShown)
+ ShowWindow(s_pScreenPriv->hwndScreen, SW_HIDE);
+ else
+ ShowWindow(s_pScreenPriv->hwndScreen, SW_SHOW);
+ s_pScreenPriv->fRootWindowShown = !s_pScreenPriv->fRootWindowShown;
+ return 0;
#endif
- case ID_APP_ABOUT:
- /* Display the About box */
- winDisplayAboutDialog (s_pScreenPriv);
- return 0;
+ case ID_APP_ABOUT:
+ /* Display the About box */
+ winDisplayAboutDialog(s_pScreenPriv);
+ return 0;
- default:
- /* It's probably one of the custom menus... */
- if (HandleCustomWM_COMMAND (0, LOWORD (wParam)))
- return 0;
- }
- break;
+ default:
+ /* It's probably one of the custom menus... */
+ if (HandleCustomWM_COMMAND(0, LOWORD(wParam)))
+ return 0;
+ }
+ break;
case WM_ENDSESSION:
case WM_GIVEUP:
- /* Tell X that we are giving up */
+ /* Tell X that we are giving up */
#ifdef XWIN_MULTIWINDOW
- if (s_pScreenInfo->fMultiWindow)
- winDeinitMultiWindowWM ();
+ if (s_pScreenInfo->fMultiWindow)
+ winDeinitMultiWindowWM();
#endif
g_fClipboardStarted=FALSE; /* This is to avoid dead-locls caused by the clipboard thread still doing some stuff */
- GiveUp (0);
- return 0;
+ GiveUp(0);
+ return 0;
case WM_CLOSE:
- /* Display Exit dialog */
- winDisplayExitDialog (s_pScreenPriv);
- return 0;
+ /* Display Exit dialog */
+ winDisplayExitDialog(s_pScreenPriv);
+ return 0;
case WM_SETCURSOR:
- if (LOWORD(lParam) == HTCLIENT)
- {
- if (!g_fSoftwareCursor) SetCursor (s_pScreenPriv->cursor.handle);
- return TRUE;
- }
- break;
+ if (LOWORD(lParam) == HTCLIENT) {
+ if (!g_fSoftwareCursor)
+ SetCursor(s_pScreenPriv->cursor.handle);
+ return TRUE;
+ }
+ break;
#ifdef XWIN_MULTIWINDOWEXTWM
case WM_MANAGE:
- winDebug ("winWindowProc - WM_MANAGE\n");
- s_pScreenInfo->fAnotherWMRunning = FALSE;
+ winDebug ("winWindowProc - WM_MANAGE\n");
+ s_pScreenInfo->fAnotherWMRunning = FALSE;
#ifdef XWIN_MULTIWINDOWINTWM
- if (s_pScreenInfo->fInternalWM)
- {
- EnumThreadWindows (g_dwCurrentThreadID, winMWExtWMDecorateWindow, 0);
- //RootlessRepositionWindows (s_pScreen);
- }
+ if (s_pScreenInfo->fInternalWM) {
+ EnumThreadWindows(g_dwCurrentThreadID, winMWExtWMDecorateWindow, 0);
+ //RootlessRepositionWindows (s_pScreen);
+ }
#endif
- break;
+ break;
case WM_UNMANAGE:
- winDebug ("winWindowProc - WM_UNMANAGE\n");
- s_pScreenInfo->fAnotherWMRunning = TRUE;
+ winDebug ("winWindowProc - WM_UNMANAGE\n");
+ s_pScreenInfo->fAnotherWMRunning = TRUE;
#ifdef XWIN_MULTIWINDOWINTWM
- if (s_pScreenInfo->fInternalWM)
- {
- EnumThreadWindows (g_dwCurrentThreadID, winMWExtWMDecorateWindow, 0);
- winMWExtWMRestackWindows (s_pScreen);
- }
+ if (s_pScreenInfo->fInternalWM) {
+ EnumThreadWindows(g_dwCurrentThreadID, winMWExtWMDecorateWindow, 0);
+ winMWExtWMRestackWindows(s_pScreen);
+ }
#endif
- break;
+ break;
#endif
default:
- if(message == s_uTaskbarRestart)
- {
- winInitNotifyIcon (s_pScreenPriv,FALSE);
- }
- break;
+ if (message == s_uTaskbarRestart) {
+ winInitNotifyIcon (s_pScreenPriv,FALSE);
+ }
+ break;
}
- return DefWindowProc (hwnd, message, wParam, lParam);
+ return DefWindowProc(hwnd, message, wParam, lParam);
}