diff options
author | marha <marha@users.sourceforge.net> | 2012-01-11 08:18:52 +0100 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2012-01-11 08:18:52 +0100 |
commit | 38e661c7d82fa0b34fbe9b3f3261295787bb6427 (patch) | |
tree | ef71c86cfe741318555e06dec3e9e2817d731e7a /xorg-server/hw/xwin | |
parent | a1e97828c89278770cb249039ec92d959440c640 (diff) | |
download | vcxsrv-38e661c7d82fa0b34fbe9b3f3261295787bb6427.tar.gz vcxsrv-38e661c7d82fa0b34fbe9b3f3261295787bb6427.tar.bz2 vcxsrv-38e661c7d82fa0b34fbe9b3f3261295787bb6427.zip |
mesa pixman xserver git update 11 jan 2012
Diffstat (limited to 'xorg-server/hw/xwin')
-rw-r--r-- | xorg-server/hw/xwin/Makefile.am | 3 | ||||
-rw-r--r-- | xorg-server/hw/xwin/winclipboard.h | 1 | ||||
-rw-r--r-- | xorg-server/hw/xwin/winclipboardthread.c | 926 | ||||
-rw-r--r-- | xorg-server/hw/xwin/winengine.c | 701 | ||||
-rw-r--r-- | xorg-server/hw/xwin/winmultiwindowwm.c | 12 | ||||
-rw-r--r-- | xorg-server/hw/xwin/winnativegdi.c | 7 | ||||
-rw-r--r-- | xorg-server/hw/xwin/winpfbdd.c | 6 | ||||
-rw-r--r-- | xorg-server/hw/xwin/winrandr.c | 2 | ||||
-rw-r--r-- | xorg-server/hw/xwin/winshadgdi.c | 1 | ||||
-rw-r--r-- | xorg-server/hw/xwin/winwin32rootless.c | 4 | ||||
-rw-r--r-- | xorg-server/hw/xwin/winwin32rootlesswindow.c | 953 | ||||
-rw-r--r-- | xorg-server/hw/xwin/winwindowswm.c | 4 |
12 files changed, 1309 insertions, 1311 deletions
diff --git a/xorg-server/hw/xwin/Makefile.am b/xorg-server/hw/xwin/Makefile.am index 256af0bb1..c49016398 100644 --- a/xorg-server/hw/xwin/Makefile.am +++ b/xorg-server/hw/xwin/Makefile.am @@ -175,7 +175,8 @@ install-exec-hook: EXTRA_DIST = \ $(xwinconfig_DATA) \ X.ico \ - XWin.rc + XWin.rc \ + XWin.exe.manifest relink: $(AM_V_at)rm -f XWin$(EXEEXT) && $(MAKE) XWin$(EXEEXT) diff --git a/xorg-server/hw/xwin/winclipboard.h b/xorg-server/hw/xwin/winclipboard.h index 089c2913b..6b5249fd1 100644 --- a/xorg-server/hw/xwin/winclipboard.h +++ b/xorg-server/hw/xwin/winclipboard.h @@ -39,7 +39,6 @@ #include <sys/select.h> #else #include <X11/Xwinsock.h> -#define HAS_WINSOCK #endif #include <fcntl.h> #include <setjmp.h> diff --git a/xorg-server/hw/xwin/winclipboardthread.c b/xorg-server/hw/xwin/winclipboardthread.c index 34a963ce8..908dfcea2 100644 --- a/xorg-server/hw/xwin/winclipboardthread.c +++ b/xorg-server/hw/xwin/winclipboardthread.c @@ -1,462 +1,464 @@ -/*
- *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
- *Copyright (C) Colin Harrison 2005-2008
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, sublicense, and/or sell copies of the Software, and to
- *permit persons to whom the Software is furnished to do so, subject to
- *the following conditions:
- *
- *The above copyright notice and this permission notice shall be
- *included in all copies or substantial portions of the Software.
- *
- *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
- *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *Except as contained in this notice, the name of the copyright holder(s)
- *and author(s) shall not be used in advertising or otherwise to promote
- *the sale, use or other dealings in this Software without prior written
- *authorization from the copyright holder(s) and author(s).
- *
- * Authors: Harold L Hunt II
- * Colin Harrison
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include <sys/types.h>
-#include "winclipboard.h"
-#ifdef __CYGWIN__
-#include <errno.h>
-#endif
-#include "misc.h"
-
-
-/*
- * References to external symbols
- */
-
-extern Bool g_fUnicodeClipboard;
-extern unsigned long serverGeneration;
-extern Bool g_fClipboardStarted;
-extern HWND g_hwndClipboard;
-extern void *g_pClipboardDisplay;
-extern Window g_iClipboardWindow;
-
-
-/*
- * Global variables
- */
-
-static jmp_buf g_jmpEntry;
-Bool g_fUnicodeSupport = FALSE;
-Bool g_fUseUnicode = FALSE;
-
-
-/*
- * Local function prototypes
- */
-
-static int
-winClipboardErrorHandler (Display *pDisplay, XErrorEvent *pErr);
-
-static int
-winClipboardIOErrorHandler (Display *pDisplay);
-
-
-/*
- * Main thread function
- */
-
-void *
-winClipboardProc (void *pvNotUsed)
-{
- Atom atomClipboard, atomClipboardManager;
- int iReturn;
- HWND hwnd = NULL;
- int iConnectionNumber = 0;
-#ifdef HAS_DEVWINDOWS
- int fdMessageQueue = 0;
-#else
- struct timeval tvTimeout;
-#endif
- fd_set fdsRead;
- int iMaxDescriptor;
- Display *pDisplay = NULL;
- Window iWindow = None;
- int iRetries;
- Bool fUseUnicode;
- char szDisplay[512];
- int iSelectError;
-
- ErrorF ("winClipboardProc - Hello\n");
-
- /* Do we have Unicode support? */
- g_fUnicodeSupport = winClipboardDetectUnicodeSupport ();
-
- /* Do we use Unicode clipboard? */
- fUseUnicode = g_fUnicodeClipboard && g_fUnicodeSupport;
-
- /* Save the Unicode support flag in a global */
- g_fUseUnicode = fUseUnicode;
-
- /* Allow multiple threads to access Xlib */
- if (XInitThreads () == 0)
- {
- ErrorF ("winClipboardProc - XInitThreads failed.\n");
- pthread_exit (NULL);
- }
-
- /* See if X supports the current locale */
- if (XSupportsLocale () == False)
- {
- ErrorF ("winClipboardProc - Warning: Locale not supported by X.\n");
- }
-
- /* Set jump point for Error exits */
- iReturn = setjmp (g_jmpEntry);
-
- /* Check if we should continue operations */
- if (iReturn != WIN_JMP_ERROR_IO
- && iReturn != WIN_JMP_OKAY)
- {
- /* setjmp returned an unknown value, exit */
- ErrorF ("winClipboardProc - setjmp returned: %d exiting\n",
- iReturn);
- pthread_exit (NULL);
- }
- else if (iReturn == WIN_JMP_ERROR_IO)
- {
- /* TODO: Cleanup the Win32 window and free any allocated memory */
- ErrorF ("winClipboardProc - setjmp returned for IO Error Handler.\n");
- pthread_exit (NULL);
- }
-
- /* Use our generated cookie for authentication */
- winSetAuthorization();
-
- /* Set error handler */
- XSetErrorHandler (winClipboardErrorHandler);
- XSetIOErrorHandler (winClipboardIOErrorHandler);
-
- /* Initialize retry count */
- iRetries = 0;
-
- /* Setup the display connection string x */
- /*
- * NOTE: Always connect to screen 0 since we require that screen
- * numbers start at 0 and increase without gaps. We only need
- * to connect to one screen on the display to get events
- * for all screens on the display. That is why there is only
- * one clipboard client thread.
- */
- snprintf (szDisplay,
- 512,
- "127.0.0.1:%s.0",
- display);
-
- /* Print the display connection string */
- ErrorF ("winClipboardProc - DISPLAY=%s\n", szDisplay);
-
- /* Open the X display */
- do
- {
- pDisplay = XOpenDisplay (szDisplay);
- if (pDisplay == NULL)
- {
- ErrorF ("winClipboardProc - Could not open display, "
- "try: %d, sleeping: %d\n",
- iRetries + 1, WIN_CONNECT_DELAY);
- ++iRetries;
- sleep (WIN_CONNECT_DELAY);
- continue;
- }
- else
- break;
- }
- while (pDisplay == NULL && iRetries < WIN_CONNECT_RETRIES);
-
- /* Make sure that the display opened */
- if (pDisplay == NULL)
- {
- ErrorF ("winClipboardProc - Failed opening the display, giving up\n");
- pthread_exit (NULL);
- }
-
- /* Save the display in the screen privates */
- g_pClipboardDisplay = pDisplay;
-
- ErrorF ("winClipboardProc - XOpenDisplay () returned and "
- "successfully opened the display.\n");
-
- /* Get our connection number */
- iConnectionNumber = ConnectionNumber (pDisplay);
-
-#ifdef HAS_DEVWINDOWS
- /* Open a file descriptor for the windows message queue */
- fdMessageQueue = open (WIN_MSG_QUEUE_FNAME, O_RDONLY);
- if (fdMessageQueue == -1)
- {
- ErrorF ("winClipboardProc - Failed opening %s\n", WIN_MSG_QUEUE_FNAME);
- pthread_exit (NULL);
- }
-
- /* Find max of our file descriptors */
- iMaxDescriptor = max (fdMessageQueue, iConnectionNumber) + 1;
-#else
- iMaxDescriptor = iConnectionNumber + 1;
-#endif
-
- /* Create atoms */
- atomClipboard = XInternAtom (pDisplay, "CLIPBOARD", False);
- atomClipboardManager = XInternAtom (pDisplay, "CLIPBOARD_MANAGER", False);
-
- /* Create a messaging window */
- iWindow = XCreateSimpleWindow (pDisplay,
- DefaultRootWindow (pDisplay),
- 1, 1,
- 500, 500,
- 0,
- BlackPixel (pDisplay, 0),
- BlackPixel (pDisplay, 0));
- if (iWindow == 0)
- {
- ErrorF ("winClipboardProc - Could not create an X window.\n");
- pthread_exit (NULL);
- }
-
- /* Select event types to watch */
- if (XSelectInput (pDisplay,
- iWindow,
- PropertyChangeMask) == BadWindow)
- ErrorF ("winClipboardProc - XSelectInput generated BadWindow "
- "on messaging window\n");
-
- /* Save the window in the screen privates */
- g_iClipboardWindow = iWindow;
-
- /* Create Windows messaging window */
- hwnd = winClipboardCreateMessagingWindow ();
-
- /* Save copy of HWND in screen privates */
- g_hwndClipboard = hwnd;
-
- /* Assert ownership of selections if Win32 clipboard is owned */
- if (NULL != GetClipboardOwner ())
- {
- /* PRIMARY */
- iReturn = XSetSelectionOwner (pDisplay, XA_PRIMARY,
- iWindow, CurrentTime);
- if (iReturn == BadAtom || iReturn == BadWindow ||
- XGetSelectionOwner (pDisplay, XA_PRIMARY) != iWindow)
- {
- ErrorF ("winClipboardProc - Could not set PRIMARY owner\n");
- pthread_exit (NULL);
- }
-
- /* CLIPBOARD */
- iReturn = XSetSelectionOwner (pDisplay, atomClipboard,
- iWindow, CurrentTime);
- if (iReturn == BadAtom || iReturn == BadWindow ||
- XGetSelectionOwner (pDisplay, atomClipboard) != iWindow)
- {
- ErrorF ("winClipboardProc - Could not set CLIPBOARD owner\n");
- pthread_exit (NULL);
- }
- }
-
- /* Pre-flush X events */
- /*
- * NOTE: Apparently you'll freeze if you don't do this,
- * because there may be events in local data structures
- * already.
- */
- winClipboardFlushXEvents (hwnd,
- iWindow,
- pDisplay,
- fUseUnicode);
-
- /* Pre-flush Windows messages */
- if (!winClipboardFlushWindowsMessageQueue (hwnd))
- return 0;
-
- /* Signal that the clipboard client has started */
- g_fClipboardStarted = TRUE;
-
- /* Loop for X events */
- while (1)
- {
- /* Setup the file descriptor set */
- /*
- * NOTE: You have to do this before every call to select
- * because select modifies the mask to indicate
- * which descriptors are ready.
- */
- FD_ZERO (&fdsRead);
- FD_SET (iConnectionNumber, &fdsRead);
-#ifdef HAS_DEVWINDOWS
- FD_SET (fdMessageQueue, &fdsRead);
-#else
- tvTimeout.tv_sec = 0;
- tvTimeout.tv_usec = 100;
-#endif
-
- /* Wait for a Windows event or an X event */
- iReturn = select (iMaxDescriptor, /* Highest fds number */
- &fdsRead, /* Read mask */
- NULL, /* No write mask */
- NULL, /* No exception mask */
-#ifdef HAS_DEVWINDOWS
- NULL /* No timeout */
-#else
- &tvTimeout /* Set timeout */
-#endif
- );
-
-#ifndef HAS_WINSOCK
- iSelectError = errno;
-#else
- iSelectError = WSAGetLastError();
-#endif
-
- if (iReturn < 0)
- {
-#ifndef HAS_WINSOCK
- if (iSelectError == EINTR)
-#else
- if (iSelectError == WSAEINTR)
-#endif
- continue;
-
- ErrorF ("winClipboardProc - Call to select () failed: %d. "
- "Bailing.\n", iReturn);
- break;
- }
-
- /* Branch on which descriptor became active */
- if (FD_ISSET (iConnectionNumber, &fdsRead))
- {
- /* Process X events */
- /* Exit when we see that server is shutting down */
- iReturn = winClipboardFlushXEvents (hwnd,
- iWindow,
- pDisplay,
- fUseUnicode);
- if (WIN_XEVENTS_SHUTDOWN == iReturn)
- {
- ErrorF ("winClipboardProc - winClipboardFlushXEvents "
- "trapped shutdown event, exiting main loop.\n");
- break;
- }
- }
-
-#ifdef HAS_DEVWINDOWS
- /* Check for Windows event ready */
- if (FD_ISSET (fdMessageQueue, &fdsRead))
-#else
- if (1)
-#endif
- {
- /* Process Windows messages */
- if (!winClipboardFlushWindowsMessageQueue (hwnd))
- {
- ErrorF ("winClipboardProc - "
- "winClipboardFlushWindowsMessageQueue trapped "
- "WM_QUIT message, exiting main loop.\n");
- break;
- }
- }
- }
-
- /* Close our X window */
- if (pDisplay && iWindow)
- {
- iReturn = XDestroyWindow (pDisplay, iWindow);
- if (iReturn == BadWindow)
- ErrorF ("winClipboardProc - XDestroyWindow returned BadWindow.\n");
- else
- ErrorF ("winClipboardProc - XDestroyWindow succeeded.\n");
- }
-
-
-#ifdef HAS_DEVWINDOWS
- /* Close our Win32 message handle */
- if (fdMessageQueue)
- close (fdMessageQueue);
-#endif
-
-#if 0
- /*
- * FIXME: XCloseDisplay hangs if we call it, as of 2004/03/26. The
- * XSync and XSelectInput calls did not help.
- */
-
- /* Discard any remaining events */
- XSync (pDisplay, TRUE);
-
- /* Select event types to watch */
- XSelectInput (pDisplay,
- DefaultRootWindow (pDisplay),
- None);
-
- /* Close our X display */
- if (pDisplay)
- {
- XCloseDisplay (pDisplay);
- }
-#endif
-
- g_iClipboardWindow = None;
- g_pClipboardDisplay = NULL;
- g_hwndClipboard = NULL;
-
- return NULL;
-}
-
-
-/*
- * winClipboardErrorHandler - Our application specific error handler
- */
-
-static int
-winClipboardErrorHandler (Display *pDisplay, XErrorEvent *pErr)
-{
- char pszErrorMsg[100];
-
- XGetErrorText (pDisplay,
- pErr->error_code,
- pszErrorMsg,
- sizeof (pszErrorMsg));
- ErrorF ("winClipboardErrorHandler - ERROR: \n\t%s\n"
- "\tSerial: %lu, Request Code: %d, Minor Code: %d\n",
- pszErrorMsg,
- pErr->serial,
- pErr->request_code,
- pErr->minor_code);
- return 0;
-}
-
-
-/*
- * winClipboardIOErrorHandler - Our application specific IO error handler
- */
-
-static int
-winClipboardIOErrorHandler (Display *pDisplay)
-{
- ErrorF ("winClipboardIOErrorHandler!\n\n");
-
- /* Restart at the main entry point */
- longjmp (g_jmpEntry, WIN_JMP_ERROR_IO);
-
- return 0;
-}
+/* + *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved. + *Copyright (C) Colin Harrison 2005-2008 + * + *Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + *"Software"), to deal in the Software without restriction, including + *without limitation the rights to use, copy, modify, merge, publish, + *distribute, sublicense, and/or sell copies of the Software, and to + *permit persons to whom the Software is furnished to do so, subject to + *the following conditions: + * + *The above copyright notice and this permission notice shall be + *included in all copies or substantial portions of the Software. + * + *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR + *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + *Except as contained in this notice, the name of the copyright holder(s) + *and author(s) shall not be used in advertising or otherwise to promote + *the sale, use or other dealings in this Software without prior written + *authorization from the copyright holder(s) and author(s). + * + * Authors: Harold L Hunt II + * Colin Harrison + */ + +#ifdef HAVE_XWIN_CONFIG_H +#include <xwin-config.h> +#else +#define HAS_WINSOCK 1 +#endif +#include <sys/types.h> +#include "winclipboard.h" +#ifdef __CYGWIN__ +#include <errno.h> +#endif +#include "misc.h" + + +/* + * References to external symbols + */ + +extern Bool g_fUnicodeClipboard; +extern unsigned long serverGeneration; +extern Bool g_fClipboardStarted; +extern HWND g_hwndClipboard; +extern void *g_pClipboardDisplay; +extern Window g_iClipboardWindow; + + +/* + * Global variables + */ + +static jmp_buf g_jmpEntry; +Bool g_fUnicodeSupport = FALSE; +Bool g_fUseUnicode = FALSE; + + +/* + * Local function prototypes + */ + +static int +winClipboardErrorHandler (Display *pDisplay, XErrorEvent *pErr); + +static int +winClipboardIOErrorHandler (Display *pDisplay); + + +/* + * Main thread function + */ + +void * +winClipboardProc (void *pvNotUsed) +{ + Atom atomClipboard, atomClipboardManager; + int iReturn; + HWND hwnd = NULL; + int iConnectionNumber = 0; +#ifdef HAS_DEVWINDOWS + int fdMessageQueue = 0; +#else + struct timeval tvTimeout; +#endif + fd_set fdsRead; + int iMaxDescriptor; + Display *pDisplay = NULL; + Window iWindow = None; + int iRetries; + Bool fUseUnicode; + char szDisplay[512]; + int iSelectError; + + ErrorF ("winClipboardProc - Hello\n"); + + /* Do we have Unicode support? */ + g_fUnicodeSupport = winClipboardDetectUnicodeSupport (); + + /* Do we use Unicode clipboard? */ + fUseUnicode = g_fUnicodeClipboard && g_fUnicodeSupport; + + /* Save the Unicode support flag in a global */ + g_fUseUnicode = fUseUnicode; + + /* Allow multiple threads to access Xlib */ + if (XInitThreads () == 0) + { + ErrorF ("winClipboardProc - XInitThreads failed.\n"); + pthread_exit (NULL); + } + + /* See if X supports the current locale */ + if (XSupportsLocale () == False) + { + ErrorF ("winClipboardProc - Warning: Locale not supported by X.\n"); + } + + /* Set jump point for Error exits */ + iReturn = setjmp (g_jmpEntry); + + /* Check if we should continue operations */ + if (iReturn != WIN_JMP_ERROR_IO + && iReturn != WIN_JMP_OKAY) + { + /* setjmp returned an unknown value, exit */ + ErrorF ("winClipboardProc - setjmp returned: %d exiting\n", + iReturn); + pthread_exit (NULL); + } + else if (iReturn == WIN_JMP_ERROR_IO) + { + /* TODO: Cleanup the Win32 window and free any allocated memory */ + ErrorF ("winClipboardProc - setjmp returned for IO Error Handler.\n"); + pthread_exit (NULL); + } + + /* Use our generated cookie for authentication */ + winSetAuthorization(); + + /* Set error handler */ + XSetErrorHandler (winClipboardErrorHandler); + XSetIOErrorHandler (winClipboardIOErrorHandler); + + /* Initialize retry count */ + iRetries = 0; + + /* Setup the display connection string x */ + /* + * NOTE: Always connect to screen 0 since we require that screen + * numbers start at 0 and increase without gaps. We only need + * to connect to one screen on the display to get events + * for all screens on the display. That is why there is only + * one clipboard client thread. + */ + snprintf (szDisplay, + 512, + "127.0.0.1:%s.0", + display); + + /* Print the display connection string */ + ErrorF ("winClipboardProc - DISPLAY=%s\n", szDisplay); + + /* Open the X display */ + do + { + pDisplay = XOpenDisplay (szDisplay); + if (pDisplay == NULL) + { + ErrorF ("winClipboardProc - Could not open display, " + "try: %d, sleeping: %d\n", + iRetries + 1, WIN_CONNECT_DELAY); + ++iRetries; + sleep (WIN_CONNECT_DELAY); + continue; + } + else + break; + } + while (pDisplay == NULL && iRetries < WIN_CONNECT_RETRIES); + + /* Make sure that the display opened */ + if (pDisplay == NULL) + { + ErrorF ("winClipboardProc - Failed opening the display, giving up\n"); + pthread_exit (NULL); + } + + /* Save the display in the screen privates */ + g_pClipboardDisplay = pDisplay; + + ErrorF ("winClipboardProc - XOpenDisplay () returned and " + "successfully opened the display.\n"); + + /* Get our connection number */ + iConnectionNumber = ConnectionNumber (pDisplay); + +#ifdef HAS_DEVWINDOWS + /* Open a file descriptor for the windows message queue */ + fdMessageQueue = open (WIN_MSG_QUEUE_FNAME, O_RDONLY); + if (fdMessageQueue == -1) + { + ErrorF ("winClipboardProc - Failed opening %s\n", WIN_MSG_QUEUE_FNAME); + pthread_exit (NULL); + } + + /* Find max of our file descriptors */ + iMaxDescriptor = max (fdMessageQueue, iConnectionNumber) + 1; +#else + iMaxDescriptor = iConnectionNumber + 1; +#endif + + /* Create atoms */ + atomClipboard = XInternAtom (pDisplay, "CLIPBOARD", False); + atomClipboardManager = XInternAtom (pDisplay, "CLIPBOARD_MANAGER", False); + + /* Create a messaging window */ + iWindow = XCreateSimpleWindow (pDisplay, + DefaultRootWindow (pDisplay), + 1, 1, + 500, 500, + 0, + BlackPixel (pDisplay, 0), + BlackPixel (pDisplay, 0)); + if (iWindow == 0) + { + ErrorF ("winClipboardProc - Could not create an X window.\n"); + pthread_exit (NULL); + } + + /* Select event types to watch */ + if (XSelectInput (pDisplay, + iWindow, + PropertyChangeMask) == BadWindow) + ErrorF ("winClipboardProc - XSelectInput generated BadWindow " + "on messaging window\n"); + + /* Save the window in the screen privates */ + g_iClipboardWindow = iWindow; + + /* Create Windows messaging window */ + hwnd = winClipboardCreateMessagingWindow (); + + /* Save copy of HWND in screen privates */ + g_hwndClipboard = hwnd; + + /* Assert ownership of selections if Win32 clipboard is owned */ + if (NULL != GetClipboardOwner ()) + { + /* PRIMARY */ + iReturn = XSetSelectionOwner (pDisplay, XA_PRIMARY, + iWindow, CurrentTime); + if (iReturn == BadAtom || iReturn == BadWindow || + XGetSelectionOwner (pDisplay, XA_PRIMARY) != iWindow) + { + ErrorF ("winClipboardProc - Could not set PRIMARY owner\n"); + pthread_exit (NULL); + } + + /* CLIPBOARD */ + iReturn = XSetSelectionOwner (pDisplay, atomClipboard, + iWindow, CurrentTime); + if (iReturn == BadAtom || iReturn == BadWindow || + XGetSelectionOwner (pDisplay, atomClipboard) != iWindow) + { + ErrorF ("winClipboardProc - Could not set CLIPBOARD owner\n"); + pthread_exit (NULL); + } + } + + /* Pre-flush X events */ + /* + * NOTE: Apparently you'll freeze if you don't do this, + * because there may be events in local data structures + * already. + */ + winClipboardFlushXEvents (hwnd, + iWindow, + pDisplay, + fUseUnicode); + + /* Pre-flush Windows messages */ + if (!winClipboardFlushWindowsMessageQueue (hwnd)) + return 0; + + /* Signal that the clipboard client has started */ + g_fClipboardStarted = TRUE; + + /* Loop for X events */ + while (1) + { + /* Setup the file descriptor set */ + /* + * NOTE: You have to do this before every call to select + * because select modifies the mask to indicate + * which descriptors are ready. + */ + FD_ZERO (&fdsRead); + FD_SET (iConnectionNumber, &fdsRead); +#ifdef HAS_DEVWINDOWS + FD_SET (fdMessageQueue, &fdsRead); +#else + tvTimeout.tv_sec = 0; + tvTimeout.tv_usec = 100; +#endif + + /* Wait for a Windows event or an X event */ + iReturn = select (iMaxDescriptor, /* Highest fds number */ + &fdsRead, /* Read mask */ + NULL, /* No write mask */ + NULL, /* No exception mask */ +#ifdef HAS_DEVWINDOWS + NULL /* No timeout */ +#else + &tvTimeout /* Set timeout */ +#endif + ); + +#ifndef HAS_WINSOCK + iSelectError = errno; +#else + iSelectError = WSAGetLastError(); +#endif + + if (iReturn < 0) + { +#ifndef HAS_WINSOCK + if (iSelectError == EINTR) +#else + if (iSelectError == WSAEINTR) +#endif + continue; + + ErrorF ("winClipboardProc - Call to select () failed: %d. " + "Bailing.\n", iReturn); + break; + } + + /* Branch on which descriptor became active */ + if (FD_ISSET (iConnectionNumber, &fdsRead)) + { + /* Process X events */ + /* Exit when we see that server is shutting down */ + iReturn = winClipboardFlushXEvents (hwnd, + iWindow, + pDisplay, + fUseUnicode); + if (WIN_XEVENTS_SHUTDOWN == iReturn) + { + ErrorF ("winClipboardProc - winClipboardFlushXEvents " + "trapped shutdown event, exiting main loop.\n"); + break; + } + } + +#ifdef HAS_DEVWINDOWS + /* Check for Windows event ready */ + if (FD_ISSET (fdMessageQueue, &fdsRead)) +#else + if (1) +#endif + { + /* Process Windows messages */ + if (!winClipboardFlushWindowsMessageQueue (hwnd)) + { + ErrorF ("winClipboardProc - " + "winClipboardFlushWindowsMessageQueue trapped " + "WM_QUIT message, exiting main loop.\n"); + break; + } + } + } + + /* Close our X window */ + if (pDisplay && iWindow) + { + iReturn = XDestroyWindow (pDisplay, iWindow); + if (iReturn == BadWindow) + ErrorF ("winClipboardProc - XDestroyWindow returned BadWindow.\n"); + else + ErrorF ("winClipboardProc - XDestroyWindow succeeded.\n"); + } + + +#ifdef HAS_DEVWINDOWS + /* Close our Win32 message handle */ + if (fdMessageQueue) + close (fdMessageQueue); +#endif + +#if 0 + /* + * FIXME: XCloseDisplay hangs if we call it, as of 2004/03/26. The + * XSync and XSelectInput calls did not help. + */ + + /* Discard any remaining events */ + XSync (pDisplay, TRUE); + + /* Select event types to watch */ + XSelectInput (pDisplay, + DefaultRootWindow (pDisplay), + None); + + /* Close our X display */ + if (pDisplay) + { + XCloseDisplay (pDisplay); + } +#endif + + g_iClipboardWindow = None; + g_pClipboardDisplay = NULL; + g_hwndClipboard = NULL; + + return NULL; +} + + +/* + * winClipboardErrorHandler - Our application specific error handler + */ + +static int +winClipboardErrorHandler (Display *pDisplay, XErrorEvent *pErr) +{ + char pszErrorMsg[100]; + + XGetErrorText (pDisplay, + pErr->error_code, + pszErrorMsg, + sizeof (pszErrorMsg)); + ErrorF ("winClipboardErrorHandler - ERROR: \n\t%s\n" + "\tSerial: %lu, Request Code: %d, Minor Code: %d\n", + pszErrorMsg, + pErr->serial, + pErr->request_code, + pErr->minor_code); + return 0; +} + + +/* + * winClipboardIOErrorHandler - Our application specific IO error handler + */ + +static int +winClipboardIOErrorHandler (Display *pDisplay) +{ + ErrorF ("winClipboardIOErrorHandler!\n\n"); + + /* Restart at the main entry point */ + longjmp (g_jmpEntry, WIN_JMP_ERROR_IO); + + return 0; +} diff --git a/xorg-server/hw/xwin/winengine.c b/xorg-server/hw/xwin/winengine.c index 1e3ee2bef..752c4fe68 100644 --- a/xorg-server/hw/xwin/winengine.c +++ b/xorg-server/hw/xwin/winengine.c @@ -1,352 +1,349 @@ -/*
- *Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved.
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, sublicense, and/or sell copies of the Software, and to
- *permit persons to whom the Software is furnished to do so, subject to
- *the following conditions:
- *
- *The above copyright notice and this permission notice shall be
- *included in all copies or substantial portions of the Software.
- *
- *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
- *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *Except as contained in this notice, the name of Harold L Hunt II
- *shall not be used in advertising or otherwise to promote the sale, use
- *or other dealings in this Software without prior written authorization
- *from Harold L Hunt II.
- *
- * Authors: Harold L Hunt II
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-#include "winmsg.h"
-
-/*
- * Global variables for function pointers into
- * dynamically loaded libraries
- */
-FARPROC g_fpDirectDrawCreate = NULL;
-FARPROC g_fpDirectDrawCreateClipper = NULL;
-
-/*
- module handle for dynamically loaded directdraw library
-*/
-static HMODULE g_hmodDirectDraw = NULL;
-
-/*
- * Detect engines supported by current Windows version
- * DirectDraw version and hardware
- */
-
-void
-winDetectSupportedEngines (void)
-{
- OSVERSIONINFO osvi;
-
- /* Initialize the engine support flags */
- g_dwEnginesSupported = WIN_SERVER_SHADOW_GDI;
-
-#ifdef XWIN_NATIVEGDI
- g_dwEnginesSupported |= WIN_SERVER_NATIVE_GDI;
-#endif
-
- /* Get operating system version information */
- ZeroMemory (&osvi, sizeof (osvi));
- osvi.dwOSVersionInfoSize = sizeof (osvi);
- GetVersionEx (&osvi);
-
- /* Branch on platform ID */
- switch (osvi.dwPlatformId)
- {
- case VER_PLATFORM_WIN32_NT:
- /* Engine 4 is supported on NT only */
- winErrorFVerb (2, "winDetectSupportedEngines - Windows NT/2000/XP\n");
- break;
-
- case VER_PLATFORM_WIN32_WINDOWS:
- /* Engine 4 is supported on NT only */
- winErrorFVerb (2, "winDetectSupportedEngines - Windows 95/98/Me\n");
- break;
- }
-
- /* Do we have DirectDraw? */
- if (g_hmodDirectDraw != NULL)
- {
- LPDIRECTDRAW lpdd = NULL;
- LPDIRECTDRAW4 lpdd4 = NULL;
- HRESULT ddrval;
-
- /* Was the DirectDrawCreate function found? */
- if (g_fpDirectDrawCreate == NULL)
- {
- /* No DirectDraw support */
- return;
- }
-
- /* DirectDrawCreate exists, try to call it */
- /* Create a DirectDraw object, store the address at lpdd */
- ddrval = (*g_fpDirectDrawCreate) (NULL,
- (void**) &lpdd,
- NULL);
- if (FAILED (ddrval))
- {
- /* No DirectDraw support */
- winErrorFVerb (2, "winDetectSupportedEngines - DirectDraw not installed\n");
- return;
- }
- else
- {
- /* We have DirectDraw */
- winErrorFVerb (2, "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;
- winErrorFVerb (2, "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 */
- winErrorFVerb (2, "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);
- }
-
- winErrorFVerb (2, "winDetectSupportedEngines - Returning, supported engines %08x\n",
- (unsigned int) g_dwEnginesSupported);
-}
-
-
-/*
- * Set the engine type, depending on the engines
- * supported for this screen, and whether the user
- * suggested an engine type
- */
-
-Bool
-winSetEngine (ScreenPtr pScreen)
-{
- winScreenPriv(pScreen);
- winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
- HDC hdc;
- DWORD dwBPP;
-
- /* Get a DC */
- hdc = GetDC (NULL);
- if (hdc == NULL)
- {
- ErrorF ("winSetEngine - Couldn't get an HDC\n");
- return FALSE;
- }
-
- /*
- * pScreenInfo->dwBPP may be 0 to indicate that the current screen
- * depth is to be used. Thus, we must query for the current display
- * depth here.
- */
- dwBPP = GetDeviceCaps (hdc, BITSPIXEL);
-
- /* Release the DC */
- ReleaseDC (NULL, hdc);
- hdc = NULL;
-
- /* ShadowGDI is the only engine that supports windowed PseudoColor */
- if (dwBPP == 8 && !pScreenInfo->fFullScreen)
- {
- winErrorFVerb (2, "winSetEngine - Windowed && PseudoColor => ShadowGDI\n");
- pScreenInfo->dwEngine = WIN_SERVER_SHADOW_GDI;
-
- /* Set engine function pointers */
- winSetEngineFunctionsShadowGDI (pScreen);
- return TRUE;
- }
-
- /* ShadowGDI is the only engine that supports Multi Window Mode */
- if (
-#ifdef XWIN_MULTIWINDOWEXTWM
- pScreenInfo->fMWExtWM
-#else
- FALSE
-#endif
-#ifdef XWIN_MULTIWINDOW
- || pScreenInfo->fMultiWindow
-#else
- || FALSE
-#endif
- )
- {
- winErrorFVerb (2, "winSetEngine - Multi Window or Rootless => ShadowGDI\n");
- pScreenInfo->dwEngine = WIN_SERVER_SHADOW_GDI;
-
- /* Set engine function pointers */
- winSetEngineFunctionsShadowGDI (pScreen);
- return TRUE;
- }
-
- /* If the user's choice is supported, we'll use that */
- if (g_dwEnginesSupported & pScreenInfo->dwEnginePreferred)
- {
- winErrorFVerb (2, "winSetEngine - Using user's preference: %d\n",
- (int) pScreenInfo->dwEnginePreferred);
- pScreenInfo->dwEngine = pScreenInfo->dwEnginePreferred;
-
- /* Setup engine function pointers */
- switch (pScreenInfo->dwEngine)
- {
- case WIN_SERVER_SHADOW_GDI:
- winSetEngineFunctionsShadowGDI (pScreen);
- break;
- case WIN_SERVER_SHADOW_DD:
- winSetEngineFunctionsShadowDD (pScreen);
- break;
- case WIN_SERVER_SHADOW_DDNL:
- winSetEngineFunctionsShadowDDNL (pScreen);
- break;
-#ifdef XWIN_PRIMARYFB
- case WIN_SERVER_PRIMARY_DD:
- winSetEngineFunctionsPrimaryDD (pScreen);
- break;
-#endif
-#ifdef XWIN_NATIVEGDI
- case WIN_SERVER_NATIVE_GDI:
- winSetEngineFunctionsNativeGDI (pScreen);
- break;
-#endif
- default:
- FatalError ("winSetEngine - Invalid engine type\n");
- }
- return TRUE;
- }
-
- /* ShadowDDNL has good performance, so why not */
- if (g_dwEnginesSupported & WIN_SERVER_SHADOW_DDNL)
- {
- winErrorFVerb (2, "winSetEngine - Using Shadow DirectDraw NonLocking\n");
- pScreenInfo->dwEngine = WIN_SERVER_SHADOW_DDNL;
-
- /* Set engine function pointers */
- winSetEngineFunctionsShadowDDNL (pScreen);
- return TRUE;
- }
-
- /* ShadowDD is next in line */
- if (g_dwEnginesSupported & WIN_SERVER_SHADOW_DD)
- {
- winErrorFVerb (2, "winSetEngine - Using Shadow DirectDraw\n");
- pScreenInfo->dwEngine = WIN_SERVER_SHADOW_DD;
-
- /* Set engine function pointers */
- winSetEngineFunctionsShadowDD (pScreen);
- return TRUE;
- }
-
- /* ShadowGDI is next in line */
- if (g_dwEnginesSupported & WIN_SERVER_SHADOW_GDI)
- {
- winErrorFVerb (2, "winSetEngine - Using Shadow GDI DIB\n");
- pScreenInfo->dwEngine = WIN_SERVER_SHADOW_GDI;
-
- /* Set engine function pointers */
- winSetEngineFunctionsShadowGDI (pScreen);
- return TRUE;
- }
-
- return TRUE;
-}
-
-
-/*
- * Get procedure addresses for DirectDrawCreate and DirectDrawCreateClipper
- */
-
-Bool
-winGetDDProcAddresses (void)
-{
- Bool fReturn = TRUE;
-
- /* Load the DirectDraw library */
- g_hmodDirectDraw = LoadLibraryEx ("ddraw.dll", NULL, 0);
- if (g_hmodDirectDraw == NULL)
- {
- ErrorF ("winGetDDProcAddresses - Could not load ddraw.dll\n");
- fReturn = TRUE;
- goto winGetDDProcAddresses_Exit;
- }
-
- /* Try to get the DirectDrawCreate address */
- g_fpDirectDrawCreate = GetProcAddress (g_hmodDirectDraw,
- "DirectDrawCreate");
- if (g_fpDirectDrawCreate == NULL)
- {
- ErrorF ("winGetDDProcAddresses - Could not get DirectDrawCreate "
- "address\n");
- fReturn = TRUE;
- goto winGetDDProcAddresses_Exit;
- }
-
- /* Try to get the DirectDrawCreateClipper address */
- g_fpDirectDrawCreateClipper = GetProcAddress (g_hmodDirectDraw,
- "DirectDrawCreateClipper");
- if (g_fpDirectDrawCreateClipper == NULL)
- {
- ErrorF ("winGetDDProcAddresses - Could not get "
- "DirectDrawCreateClipper address\n");
- fReturn = FALSE;
- goto winGetDDProcAddresses_Exit;
- }
-
- /*
- * Note: Do not unload ddraw.dll here. Do it in GiveUp
- */
-
- winGetDDProcAddresses_Exit:
- /* Unload the DirectDraw library if we failed to initialize */
- if (!fReturn && g_hmodDirectDraw != NULL)
- {
- FreeLibrary (g_hmodDirectDraw);
- g_hmodDirectDraw = NULL;
- }
-
- return fReturn;
-}
-
-void
-winReleaseDDProcAddresses(void)
-{
- if (g_hmodDirectDraw != NULL)
- {
- FreeLibrary (g_hmodDirectDraw);
- g_hmodDirectDraw = NULL;
- g_fpDirectDrawCreate = NULL;
- g_fpDirectDrawCreateClipper = NULL;
- }
-}
+/* + *Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved. + * + *Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + *"Software"), to deal in the Software without restriction, including + *without limitation the rights to use, copy, modify, merge, publish, + *distribute, sublicense, and/or sell copies of the Software, and to + *permit persons to whom the Software is furnished to do so, subject to + *the following conditions: + * + *The above copyright notice and this permission notice shall be + *included in all copies or substantial portions of the Software. + * + *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR + *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + *Except as contained in this notice, the name of Harold L Hunt II + *shall not be used in advertising or otherwise to promote the sale, use + *or other dealings in this Software without prior written authorization + *from Harold L Hunt II. + * + * Authors: Harold L Hunt II + */ + +#ifdef HAVE_XWIN_CONFIG_H +#include <xwin-config.h> +#endif +#include "win.h" +#include "winmsg.h" + +/* + * Global variables for function pointers into + * dynamically loaded libraries + */ +FARPROC g_fpDirectDrawCreate = NULL; +FARPROC g_fpDirectDrawCreateClipper = NULL; + +/* + module handle for dynamically loaded directdraw library +*/ +static HMODULE g_hmodDirectDraw = NULL; + +/* + * Detect engines supported by current Windows version + * DirectDraw version and hardware + */ + +void +winDetectSupportedEngines (void) +{ + OSVERSIONINFO osvi; + + /* Initialize the engine support flags */ + g_dwEnginesSupported = WIN_SERVER_SHADOW_GDI; + +#ifdef XWIN_NATIVEGDI + g_dwEnginesSupported |= WIN_SERVER_NATIVE_GDI; +#endif + + /* Get operating system version information */ + ZeroMemory (&osvi, sizeof (osvi)); + osvi.dwOSVersionInfoSize = sizeof (osvi); + GetVersionEx (&osvi); + + /* Branch on platform ID */ + switch (osvi.dwPlatformId) + { + case VER_PLATFORM_WIN32_NT: + /* Engine 4 is supported on NT only */ + winErrorFVerb (2, "winDetectSupportedEngines - Windows NT/2000/XP\n"); + break; + + case VER_PLATFORM_WIN32_WINDOWS: + /* Engine 4 is supported on NT only */ + winErrorFVerb (2, "winDetectSupportedEngines - Windows 95/98/Me\n"); + break; + } + + /* Do we have DirectDraw? */ + if (g_hmodDirectDraw != NULL) + { + LPDIRECTDRAW lpdd = NULL; + LPDIRECTDRAW4 lpdd4 = NULL; + HRESULT ddrval; + + /* Was the DirectDrawCreate function found? */ + if (g_fpDirectDrawCreate == NULL) + { + /* No DirectDraw support */ + return; + } + + /* DirectDrawCreate exists, try to call it */ + /* Create a DirectDraw object, store the address at lpdd */ + ddrval = (*g_fpDirectDrawCreate) (NULL, + (void**) &lpdd, + NULL); + if (FAILED (ddrval)) + { + /* No DirectDraw support */ + winErrorFVerb (2, "winDetectSupportedEngines - DirectDraw not installed\n"); + return; + } + else + { + /* We have DirectDraw */ + winErrorFVerb (2, "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; + winErrorFVerb (2, "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 */ + winErrorFVerb (2, "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); + } + + winErrorFVerb (2, "winDetectSupportedEngines - Returning, supported engines %08x\n", + (unsigned int) g_dwEnginesSupported); +} + + +/* + * Set the engine type, depending on the engines + * supported for this screen, and whether the user + * suggested an engine type + */ + +Bool +winSetEngine (ScreenPtr pScreen) +{ + winScreenPriv(pScreen); + winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; + HDC hdc; + DWORD dwBPP; + + /* Get a DC */ + hdc = GetDC (NULL); + if (hdc == NULL) + { + ErrorF ("winSetEngine - Couldn't get an HDC\n"); + return FALSE; + } + + /* + * pScreenInfo->dwBPP may be 0 to indicate that the current screen + * depth is to be used. Thus, we must query for the current display + * depth here. + */ + dwBPP = GetDeviceCaps (hdc, BITSPIXEL); + + /* Release the DC */ + ReleaseDC (NULL, hdc); + hdc = NULL; + + /* ShadowGDI is the only engine that supports windowed PseudoColor */ + if (dwBPP == 8 && !pScreenInfo->fFullScreen) + { + winErrorFVerb (2, "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 +#ifdef XWIN_MULTIWINDOWEXTWM + || pScreenInfo->fMWExtWM +#endif +#ifdef XWIN_MULTIWINDOW + || pScreenInfo->fMultiWindow +#endif + ) + { + winErrorFVerb (2, "winSetEngine - Multi Window or Rootless => ShadowGDI\n"); + pScreenInfo->dwEngine = WIN_SERVER_SHADOW_GDI; + + /* Set engine function pointers */ + winSetEngineFunctionsShadowGDI (pScreen); + return TRUE; + } + + /* If the user's choice is supported, we'll use that */ + if (g_dwEnginesSupported & pScreenInfo->dwEnginePreferred) + { + winErrorFVerb (2, "winSetEngine - Using user's preference: %d\n", + (int) pScreenInfo->dwEnginePreferred); + pScreenInfo->dwEngine = pScreenInfo->dwEnginePreferred; + + /* Setup engine function pointers */ + switch (pScreenInfo->dwEngine) + { + case WIN_SERVER_SHADOW_GDI: + winSetEngineFunctionsShadowGDI (pScreen); + break; + case WIN_SERVER_SHADOW_DD: + winSetEngineFunctionsShadowDD (pScreen); + break; + case WIN_SERVER_SHADOW_DDNL: + winSetEngineFunctionsShadowDDNL (pScreen); + break; +#ifdef XWIN_PRIMARYFB + case WIN_SERVER_PRIMARY_DD: + winSetEngineFunctionsPrimaryDD (pScreen); + break; +#endif +#ifdef XWIN_NATIVEGDI + case WIN_SERVER_NATIVE_GDI: + winSetEngineFunctionsNativeGDI (pScreen); + break; +#endif + default: + FatalError ("winSetEngine - Invalid engine type\n"); + } + return TRUE; + } + + /* ShadowDDNL has good performance, so why not */ + if (g_dwEnginesSupported & WIN_SERVER_SHADOW_DDNL) + { + winErrorFVerb (2, "winSetEngine - Using Shadow DirectDraw NonLocking\n"); + pScreenInfo->dwEngine = WIN_SERVER_SHADOW_DDNL; + + /* Set engine function pointers */ + winSetEngineFunctionsShadowDDNL (pScreen); + return TRUE; + } + + /* ShadowDD is next in line */ + if (g_dwEnginesSupported & WIN_SERVER_SHADOW_DD) + { + winErrorFVerb (2, "winSetEngine - Using Shadow DirectDraw\n"); + pScreenInfo->dwEngine = WIN_SERVER_SHADOW_DD; + + /* Set engine function pointers */ + winSetEngineFunctionsShadowDD (pScreen); + return TRUE; + } + + /* ShadowGDI is next in line */ + if (g_dwEnginesSupported & WIN_SERVER_SHADOW_GDI) + { + winErrorFVerb (2, "winSetEngine - Using Shadow GDI DIB\n"); + pScreenInfo->dwEngine = WIN_SERVER_SHADOW_GDI; + + /* Set engine function pointers */ + winSetEngineFunctionsShadowGDI (pScreen); + return TRUE; + } + + return TRUE; +} + + +/* + * Get procedure addresses for DirectDrawCreate and DirectDrawCreateClipper + */ + +Bool +winGetDDProcAddresses (void) +{ + Bool fReturn = TRUE; + + /* Load the DirectDraw library */ + g_hmodDirectDraw = LoadLibraryEx ("ddraw.dll", NULL, 0); + if (g_hmodDirectDraw == NULL) + { + ErrorF ("winGetDDProcAddresses - Could not load ddraw.dll\n"); + fReturn = TRUE; + goto winGetDDProcAddresses_Exit; + } + + /* Try to get the DirectDrawCreate address */ + g_fpDirectDrawCreate = GetProcAddress (g_hmodDirectDraw, + "DirectDrawCreate"); + if (g_fpDirectDrawCreate == NULL) + { + ErrorF ("winGetDDProcAddresses - Could not get DirectDrawCreate " + "address\n"); + fReturn = TRUE; + goto winGetDDProcAddresses_Exit; + } + + /* Try to get the DirectDrawCreateClipper address */ + g_fpDirectDrawCreateClipper = GetProcAddress (g_hmodDirectDraw, + "DirectDrawCreateClipper"); + if (g_fpDirectDrawCreateClipper == NULL) + { + ErrorF ("winGetDDProcAddresses - Could not get " + "DirectDrawCreateClipper address\n"); + fReturn = FALSE; + goto winGetDDProcAddresses_Exit; + } + + /* + * Note: Do not unload ddraw.dll here. Do it in GiveUp + */ + + winGetDDProcAddresses_Exit: + /* Unload the DirectDraw library if we failed to initialize */ + if (!fReturn && g_hmodDirectDraw != NULL) + { + FreeLibrary (g_hmodDirectDraw); + g_hmodDirectDraw = NULL; + } + + return fReturn; +} + +void +winReleaseDDProcAddresses(void) +{ + if (g_hmodDirectDraw != NULL) + { + FreeLibrary (g_hmodDirectDraw); + g_hmodDirectDraw = NULL; + g_fpDirectDrawCreate = NULL; + g_fpDirectDrawCreateClipper = NULL; + } +} diff --git a/xorg-server/hw/xwin/winmultiwindowwm.c b/xorg-server/hw/xwin/winmultiwindowwm.c index 67a58a076..7c4056388 100644 --- a/xorg-server/hw/xwin/winmultiwindowwm.c +++ b/xorg-server/hw/xwin/winmultiwindowwm.c @@ -1201,11 +1201,13 @@ winInitWM (void **ppWMInfo, XMsgProcArgPtr pXMsgArg = (XMsgProcArgPtr) malloc (sizeof(XMsgProcArgRec)); /* Bail if the input parameters are bad */ - if (pArg == NULL || pWMInfo == NULL) - { - ErrorF ("winInitWM - malloc failed.\n"); - return FALSE; - } + 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)); diff --git a/xorg-server/hw/xwin/winnativegdi.c b/xorg-server/hw/xwin/winnativegdi.c index 4d7afe898..68f802005 100644 --- a/xorg-server/hw/xwin/winnativegdi.c +++ b/xorg-server/hw/xwin/winnativegdi.c @@ -315,7 +315,6 @@ static Bool winActivateAppNativeGDI (ScreenPtr pScreen) { winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; /* * Are we active? @@ -323,7 +322,8 @@ winActivateAppNativeGDI (ScreenPtr pScreen) */ if (pScreenPriv != NULL && pScreenPriv->fActive - && pScreenInfo->fFullScreen) + && pScreenPriv->pScreenInfo + && pScreenPriv->pScreenInfo->fFullScreen) { /* * Activating, attempt to bring our window @@ -338,7 +338,8 @@ winActivateAppNativeGDI (ScreenPtr pScreen) */ if (pScreenPriv != NULL && !pScreenPriv->fActive - && pScreenInfo->fFullScreen) + && pScreenPriv->pScreenInfo + && pScreenPriv->pScreenInfo->fFullScreen) { /* * Deactivating, stuff our window onto the diff --git a/xorg-server/hw/xwin/winpfbdd.c b/xorg-server/hw/xwin/winpfbdd.c index a3990208d..1a5a0e7aa 100644 --- a/xorg-server/hw/xwin/winpfbdd.c +++ b/xorg-server/hw/xwin/winpfbdd.c @@ -461,12 +461,12 @@ static Bool winActivateAppPrimaryDD (ScreenPtr pScreen) { winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; RECT rcSrc, rcClient; HRESULT ddrval = DD_OK; /* Check for errors */ if (pScreenPriv == NULL + || pScreenPriv->pScreenInfo == NULL || pScreenPriv->pddsPrimary == NULL || pScreenPriv->pddsOffscreen == NULL) return FALSE; @@ -500,8 +500,8 @@ winActivateAppPrimaryDD (ScreenPtr pScreen) /* Setup a source rectangle */ rcSrc.left = 0; rcSrc.top = 0; - rcSrc.right = pScreenInfo->dwWidth; - rcSrc.bottom = pScreenInfo->dwHeight; + rcSrc.right = pScreenPriv->pScreenInfo->dwWidth; + rcSrc.bottom = pScreenPriv->pScreenInfo->dwHeight; ddrval = IDirectDrawSurface2_Blt (pScreenPriv->pddsPrimary, &rcClient, diff --git a/xorg-server/hw/xwin/winrandr.c b/xorg-server/hw/xwin/winrandr.c index c58119360..596c1ab9d 100644 --- a/xorg-server/hw/xwin/winrandr.c +++ b/xorg-server/hw/xwin/winrandr.c @@ -122,8 +122,6 @@ Bool winRandRScreenSetSize (ScreenPtr pScreen, CARD16 width, CARD16 height, - CARD16 pixWidth, - CARD16 pixHeight, CARD32 mmWidth, CARD32 mmHeight) { diff --git a/xorg-server/hw/xwin/winshadgdi.c b/xorg-server/hw/xwin/winshadgdi.c index 1e7cb006c..6339010b6 100644 --- a/xorg-server/hw/xwin/winshadgdi.c +++ b/xorg-server/hw/xwin/winshadgdi.c @@ -270,7 +270,6 @@ winQueryRGBBitsAndMasks (ScreenPtr pScreen) else { ErrorF ("winQueryRGBBitsAndMasks - winQueryScreenDIBFormat failed\n"); - free (pbmih); fReturn = FALSE; } diff --git a/xorg-server/hw/xwin/winwin32rootless.c b/xorg-server/hw/xwin/winwin32rootless.c index 8f9917a7b..91399c248 100644 --- a/xorg-server/hw/xwin/winwin32rootless.c +++ b/xorg-server/hw/xwin/winwin32rootless.c @@ -551,7 +551,7 @@ winMWExtWMRestackFrame (RootlessFrameID wid, RootlessFrameID nextWid) winDebug ("winMWExtWMRestackFrame (%08x)\n", (int) pRLWinPriv); #endif - if (pScreenPriv->fRestacking) return; + if (pScreenPriv && pScreenPriv->fRestacking) return; if (pScreenPriv) pScreenInfo = pScreenPriv->pScreenInfo; @@ -640,8 +640,6 @@ winMWExtWMRestackFrame (RootlessFrameID wid, RootlessFrameID nextWid) SetWindowPos (pRLWinPriv->hWnd, pRLNextWinPriv->hWnd, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE); -#if 0 -#endif } #if CYGMULTIWINDOW_DEBUG winDebug ("winMWExtWMRestackFrame - done (%08x)\n", (int) pRLWinPriv); diff --git a/xorg-server/hw/xwin/winwin32rootlesswindow.c b/xorg-server/hw/xwin/winwin32rootlesswindow.c index 60e1f8bea..fbff83888 100644 --- a/xorg-server/hw/xwin/winwin32rootlesswindow.c +++ b/xorg-server/hw/xwin/winwin32rootlesswindow.c @@ -1,476 +1,477 @@ -/*
- *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, sublicense, and/or sell copies of the Software, and to
- *permit persons to whom the Software is furnished to do so, subject to
- *the following conditions:
- *
- *The above copyright notice and this permission notice shall be
- *included in all copies or substantial portions of the Software.
- *
- *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
- *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *Except as contained in this notice, the name of the XFree86 Project
- *shall not be used in advertising or otherwise to promote the sale, use
- *or other dealings in this Software without prior written authorization
- *from the XFree86 Project.
- *
- * Authors: Kensuke Matsuzaki
- * Earle F. Philhower, III
- * Harold L Hunt II
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-#include "winprefs.h"
-
-#if 0
-/*
- * winMWExtWMReorderWindows
- */
-
-void
-winMWExtWMReorderWindows (ScreenPtr pScreen)
-{
- 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");
-#endif
-
- pScreenPriv->fRestacking = TRUE;
-
- if (pScreenPriv->fWindowOrderChanged)
- {
-#if CYGMULTIWINDOW_DEBUG
- 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);
- }
- }
-
- pScreenPriv->fRestacking = FALSE;
- pScreenPriv->fWindowOrderChanged = FALSE;
-}
-#endif
-
-
-/*
- * winMWExtWMMoveXWindow
- */
-
-void
-winMWExtWMMoveXWindow (WindowPtr pWin, int x, int y)
-{
- CARD32 *vlist = malloc(sizeof(CARD32)*2);
-
- vlist[0] = x;
- vlist[1] = y;
- ConfigureWindow (pWin, CWX | CWY, vlist, wClient(pWin));
- free(vlist);
-}
-
-
-/*
- * winMWExtWMResizeXWindow
- */
-
-void
-winMWExtWMResizeXWindow (WindowPtr pWin, int w, int h)
-{
- CARD32 *vlist = malloc(sizeof(CARD32)*2);
-
- 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)
-{
- CARD32 *vlist = malloc(sizeof(long)*4);
-
- vlist[0] = x;
- vlist[1] = y;
- vlist[2] = w;
- vlist[3] = h;
-
- ConfigureWindow (pWin, CWX | CWY | CWWidth | CWHeight, vlist, wClient(pWin));
- free(vlist);
-}
-
-
-/*
- * winMWExtWMUpdateIcon
- * Change the Windows window icon
- */
-
-void
-winMWExtWMUpdateIcon (Window id)
-{
- WindowPtr pWin;
- HICON hIcon, hiconOld;
-
- dixLookupResourceByType((pointer) &pWin, id, RT_WINDOW, NullClient, DixUnknownAccess);
- hIcon = winOverrideIcon ((unsigned long)pWin);
-
- if (!hIcon)
- hIcon = winXIconToHICON (pWin, GetSystemMetrics(SM_CXICON));
-
- if (hIcon)
- {
- win32RootlessWindowPtr pRLWinPriv
- = (win32RootlessWindowPtr) RootlessFrameForWindow (pWin, FALSE);
-
- if (pRLWinPriv->hWnd)
- {
-
- 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)
-{
- 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)
- {
- pScreen = pRLWinPriv->pFrame->win->drawable.pScreen;
- if (pScreen) pScreenPriv = winGetScreenPriv(pScreen);
- if (pScreenPriv) pScreenInfo = pScreenPriv->pScreenInfo;
- if (pRLWinPriv && pScreenInfo) winMWExtWMUpdateWindowDecoration (pRLWinPriv, pScreenInfo);
- }
- return TRUE;
-}
-
-
-/*
- * winMWExtWMUpdateWindowDecoration - Update window style.
- */
-
-void
-winMWExtWMUpdateWindowDecoration (win32RootlessWindowPtr pRLWinPriv,
- winScreenInfoPtr pScreenInfo)
-{
- Bool fDecorate = FALSE;
- DWORD dwExStyle = 0;
- DWORD dwStyle = 0;
- WINDOWPLACEMENT wndPlace;
- UINT showCmd = 0;
-
- wndPlace.length = sizeof (WINDOWPLACEMENT);
-
- /* Get current window placement */
- GetWindowPlacement (pRLWinPriv->hWnd, &wndPlace);
-
- if (winIsInternalWMRunning(pScreenInfo))
- {
- if (!pRLWinPriv->pFrame->win->overrideRedirect)
- fDecorate = TRUE;
- }
-#if 0
- if (wndPlace.showCmd == SW_HIDE)
- return;//showCmd = SWP_HIDEWINDOW;
- else
- showCmd = SWP_SHOWWINDOW;
-#else
- if (wndPlace.showCmd == SW_HIDE)
- return;
-
- if (IsWindowVisible (pRLWinPriv->hWnd))
- showCmd = SWP_SHOWWINDOW;
-#endif
-
- 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);
-#endif
- /* */
- 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);
-#endif
- /* 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;
-
- /* 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);
-
-#ifdef CYGMULTIWINDOW_DEBUG
- winDebug("\tWindowStyle: %08x %08x\n",
- WS_POPUP | WS_SIZEBOX | WS_OVERLAPPEDWINDOW,
- WS_EX_APPWINDOW);
-#endif
- /* 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);
-#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));
- }
- }
- 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;
-#endif
-
- /* 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 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);
-
- winMWExtWMReshapeFrame ((RootlessFrameID)pRLWinPriv ,
- wBoundingShape(pRLWinPriv->pFrame->win));
- }
- }
-}
-
-
-/*
- * winIsInternalWMRunning (winScreenInfoPtr pScreenInfo)
- */
-Bool
-winIsInternalWMRunning (winScreenInfoPtr pScreenInfo)
-{
- return pScreenInfo->fInternalWM && !pScreenInfo->fAnotherWMRunning;
-}
-
-
-/*
- * winMWExtWMRestackWindows
- */
-
-void
-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;
-
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMRestackWindows\n");
-#endif
-
- pScreenPriv->fRestacking = TRUE;
-
- if (pRoot != NULL)
- {
- for (pWin = pRoot->firstChild; pWin; pWin = pWin->nextSib)
- nWindow ++;
-
- hWinPosInfo = BeginDeferWindowPos(nWindow);
-
- for (pWin = pRoot->firstChild; pWin; pWin = pWin->nextSib)
- {
- if (pWin->realized)
- {
- UINT uFlags;
-
- pRLWin = (win32RootlessWindowPtr) RootlessFrameForWindow (pWin, FALSE);
- if (pRLWin == NULL) continue;
-
- if (pWinPrev)
- pRLWinPrev = (win32RootlessWindowPtr) RootlessFrameForWindow (pWinPrev, FALSE);
-
- 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);
-#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;
- }
- }
-
-#if CYGMULTIWINDOW_DEBUG
- winDebug ("winMWExtWMRestackWindows - done\n");
-#endif
- pScreenPriv->fRestacking = FALSE;
-}
+/* + *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved. + * + *Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + *"Software"), to deal in the Software without restriction, including + *without limitation the rights to use, copy, modify, merge, publish, + *distribute, sublicense, and/or sell copies of the Software, and to + *permit persons to whom the Software is furnished to do so, subject to + *the following conditions: + * + *The above copyright notice and this permission notice shall be + *included in all copies or substantial portions of the Software. + * + *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR + *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + *Except as contained in this notice, the name of the XFree86 Project + *shall not be used in advertising or otherwise to promote the sale, use + *or other dealings in this Software without prior written authorization + *from the XFree86 Project. + * + * Authors: Kensuke Matsuzaki + * Earle F. Philhower, III + * Harold L Hunt II + */ + +#ifdef HAVE_XWIN_CONFIG_H +#include <xwin-config.h> +#endif +#include "win.h" +#include "winprefs.h" + +#if 0 +/* + * winMWExtWMReorderWindows + */ + +void +winMWExtWMReorderWindows (ScreenPtr pScreen) +{ + 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"); +#endif + + pScreenPriv->fRestacking = TRUE; + + if (pScreenPriv->fWindowOrderChanged) + { +#if CYGMULTIWINDOW_DEBUG + 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); + } + } + + pScreenPriv->fRestacking = FALSE; + pScreenPriv->fWindowOrderChanged = FALSE; +} +#endif + + +/* + * winMWExtWMMoveXWindow + */ + +void +winMWExtWMMoveXWindow (WindowPtr pWin, int x, int y) +{ + CARD32 *vlist = malloc(sizeof(CARD32)*2); + + vlist[0] = x; + vlist[1] = y; + ConfigureWindow (pWin, CWX | CWY, vlist, wClient(pWin)); + free(vlist); +} + + +/* + * winMWExtWMResizeXWindow + */ + +void +winMWExtWMResizeXWindow (WindowPtr pWin, int w, int h) +{ + CARD32 *vlist = malloc(sizeof(CARD32)*2); + + 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) +{ + CARD32 *vlist = malloc(sizeof(long)*4); + + vlist[0] = x; + vlist[1] = y; + vlist[2] = w; + vlist[3] = h; + + ConfigureWindow (pWin, CWX | CWY | CWWidth | CWHeight, vlist, wClient(pWin)); + free(vlist); +} + + +/* + * winMWExtWMUpdateIcon + * Change the Windows window icon + */ + +void +winMWExtWMUpdateIcon (Window id) +{ + WindowPtr pWin; + HICON hIcon, hiconOld; + + dixLookupResourceByType((pointer) &pWin, id, RT_WINDOW, NullClient, DixUnknownAccess); + hIcon = winOverrideIcon ((unsigned long)pWin); + + if (!hIcon) + hIcon = winXIconToHICON (pWin, GetSystemMetrics(SM_CXICON)); + + if (hIcon) + { + win32RootlessWindowPtr pRLWinPriv + = (win32RootlessWindowPtr) RootlessFrameForWindow (pWin, FALSE); + + if (pRLWinPriv->hWnd) + { + + 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) +{ + 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; +} + + +/* + * winMWExtWMUpdateWindowDecoration - Update window style. + */ + +void +winMWExtWMUpdateWindowDecoration (win32RootlessWindowPtr pRLWinPriv, + winScreenInfoPtr pScreenInfo) +{ + Bool fDecorate = FALSE; + DWORD dwExStyle = 0; + DWORD dwStyle = 0; + WINDOWPLACEMENT wndPlace; + UINT showCmd = 0; + + wndPlace.length = sizeof (WINDOWPLACEMENT); + + /* Get current window placement */ + GetWindowPlacement (pRLWinPriv->hWnd, &wndPlace); + + if (winIsInternalWMRunning(pScreenInfo)) + { + if (!pRLWinPriv->pFrame->win->overrideRedirect) + fDecorate = TRUE; + } +#if 0 + if (wndPlace.showCmd == SW_HIDE) + return;//showCmd = SWP_HIDEWINDOW; + else + showCmd = SWP_SHOWWINDOW; +#else + if (wndPlace.showCmd == SW_HIDE) + return; + + if (IsWindowVisible (pRLWinPriv->hWnd)) + showCmd = SWP_SHOWWINDOW; +#endif + + 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); +#endif + /* */ + 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); +#endif + /* 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; + + /* 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); + +#ifdef CYGMULTIWINDOW_DEBUG + winDebug("\tWindowStyle: %08x %08x\n", + WS_POPUP | WS_SIZEBOX | WS_OVERLAPPEDWINDOW, + WS_EX_APPWINDOW); +#endif + /* 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); +#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)); + } + } + 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; +#endif + + /* 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 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); + + winMWExtWMReshapeFrame ((RootlessFrameID)pRLWinPriv , + wBoundingShape(pRLWinPriv->pFrame->win)); + } + } +} + + +/* + * winIsInternalWMRunning (winScreenInfoPtr pScreenInfo) + */ +Bool +winIsInternalWMRunning (winScreenInfoPtr pScreenInfo) +{ + return pScreenInfo->fInternalWM && !pScreenInfo->fAnotherWMRunning; +} + + +/* + * winMWExtWMRestackWindows + */ + +void +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; + +#if CYGMULTIWINDOW_DEBUG + winDebug ("winMWExtWMRestackWindows\n"); +#endif + + pScreenPriv->fRestacking = TRUE; + + if (pRoot != NULL) + { + for (pWin = pRoot->firstChild; pWin; pWin = pWin->nextSib) + nWindow ++; + + hWinPosInfo = BeginDeferWindowPos(nWindow); + + for (pWin = pRoot->firstChild; pWin; pWin = pWin->nextSib) + { + if (pWin->realized) + { + UINT uFlags; + + pRLWin = (win32RootlessWindowPtr) RootlessFrameForWindow (pWin, FALSE); + if (pRLWin == NULL) continue; + + if (pWinPrev) + pRLWinPrev = (win32RootlessWindowPtr) RootlessFrameForWindow (pWinPrev, FALSE); + + 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); +#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; + } + } + +#if CYGMULTIWINDOW_DEBUG + winDebug ("winMWExtWMRestackWindows - done\n"); +#endif + pScreenPriv->fRestacking = FALSE; +} diff --git a/xorg-server/hw/xwin/winwindowswm.c b/xorg-server/hw/xwin/winwindowswm.c index 577614db6..f43834d5e 100644 --- a/xorg-server/hw/xwin/winwindowswm.c +++ b/xorg-server/hw/xwin/winwindowswm.c @@ -548,7 +548,7 @@ ProcWindowsWMDispatch (ClientPtr client) return ProcWindowsWMQueryVersion(client); } - if (!LocalClient(client)) + if (!client->local) return WMErrorBase + WindowsWMClientNotLocal; switch (stuff->data) @@ -598,7 +598,7 @@ SProcWindowsWMDispatch (ClientPtr client) REQUEST(xReq); /* It is bound to be non-local when there is byte swapping */ - if (!LocalClient(client)) + if (!client->local) return WMErrorBase + WindowsWMClientNotLocal; /* only local clients are allowed WM access */ |